BrianLov commited on
Commit
84cd834
·
verified ·
1 Parent(s): 71acd36

Upload folder using huggingface_hub (part 10)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. VAE/Harvest_VAE.py +88 -0
  2. VAE/Train_VAE.py +151 -0
  3. gui/frontend/README.md +16 -0
  4. gui/frontend/node_modules/zod-validation-error/LICENSE +9 -0
  5. gui/frontend/node_modules/zod-validation-error/README.md +504 -0
  6. gui/frontend/node_modules/zod-validation-error/README.v3.md +558 -0
  7. gui/frontend/node_modules/zod-validation-error/package.json +108 -0
  8. gui/frontend/node_modules/zod-validation-error/v3/index.d.mts +50 -0
  9. gui/frontend/node_modules/zod-validation-error/v3/index.d.ts +50 -0
  10. gui/frontend/node_modules/zod-validation-error/v3/index.js +309 -0
  11. gui/frontend/node_modules/zod-validation-error/v3/index.js.map +1 -0
  12. gui/frontend/node_modules/zod-validation-error/v3/index.mjs +263 -0
  13. gui/frontend/node_modules/zod-validation-error/v3/index.mjs.map +1 -0
  14. gui/frontend/node_modules/zod-validation-error/v4/index.d.mts +66 -0
  15. gui/frontend/node_modules/zod-validation-error/v4/index.d.ts +66 -0
  16. gui/frontend/node_modules/zod-validation-error/v4/index.js +725 -0
  17. gui/frontend/node_modules/zod-validation-error/v4/index.js.map +1 -0
  18. gui/frontend/node_modules/zod-validation-error/v4/index.mjs +679 -0
  19. gui/frontend/node_modules/zod-validation-error/v4/index.mjs.map +1 -0
  20. gui/frontend/node_modules/zod/src/v4-mini/index.ts +3 -0
  21. gui/frontend/node_modules/zod/src/v4/core/tests/index.test.ts +46 -0
  22. gui/frontend/node_modules/zod/src/v4/core/tests/locales/be.test.ts +124 -0
  23. gui/frontend/node_modules/zod/src/v4/core/tests/locales/el.test.ts +215 -0
  24. gui/frontend/node_modules/zod/src/v4/core/tests/locales/en.test.ts +22 -0
  25. gui/frontend/node_modules/zod/src/v4/core/tests/locales/es.test.ts +181 -0
  26. gui/frontend/node_modules/zod/src/v4/core/tests/locales/fr.test.ts +72 -0
  27. gui/frontend/node_modules/zod/src/v4/core/tests/locales/he.test.ts +379 -0
  28. gui/frontend/node_modules/zod/src/v4/core/tests/locales/hr.test.ts +163 -0
  29. gui/frontend/node_modules/zod/src/v4/core/tests/locales/nl.test.ts +46 -0
  30. gui/frontend/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +128 -0
  31. gui/frontend/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +69 -0
  32. gui/frontend/node_modules/zod/src/v4/core/tests/locales/uz.test.ts +105 -0
  33. gui/frontend/node_modules/zod/src/v4/core/tests/record-constructor.test.ts +125 -0
  34. gui/frontend/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts +45 -0
  35. gui/frontend/node_modules/zod/src/v4/core/to-json-schema.ts +622 -0
  36. gui/frontend/node_modules/zod/src/v4/core/util.ts +983 -0
  37. gui/frontend/node_modules/zod/src/v4/core/versions.ts +5 -0
  38. gui/frontend/node_modules/zod/src/v4/core/zsf.ts +323 -0
  39. gui/frontend/node_modules/zod/src/v4/index.ts +4 -0
  40. gui/frontend/node_modules/zod/src/v4/locales/ar.ts +115 -0
  41. gui/frontend/node_modules/zod/src/v4/locales/az.ts +111 -0
  42. gui/frontend/node_modules/zod/src/v4/locales/be.ts +176 -0
  43. gui/frontend/node_modules/zod/src/v4/locales/bg.ts +128 -0
  44. gui/frontend/node_modules/zod/src/v4/locales/ca.ts +116 -0
  45. gui/frontend/node_modules/zod/src/v4/locales/cs.ts +118 -0
  46. gui/frontend/node_modules/zod/src/v4/locales/da.ts +123 -0
  47. gui/frontend/node_modules/zod/src/v4/locales/de.ts +116 -0
  48. gui/frontend/node_modules/zod/src/v4/locales/el.ts +121 -0
  49. gui/frontend/node_modules/zod/src/v4/locales/en.ts +123 -0
  50. gui/frontend/node_modules/zod/src/v4/locales/eo.ts +118 -0
VAE/Harvest_VAE.py ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import torch
3
+ import torch.nn as nn
4
+ import torch.nn.functional as F
5
+ from torchvision.utils import save_image
6
+ from tqdm import tqdm
7
+
8
+ # 1. Rebuild the exact VAE Architecture to load the weights
9
+ class VAE(nn.Module):
10
+ def __init__(self, latent_dim=128):
11
+ super(VAE, self).__init__()
12
+ self.enc1 = nn.Conv2d(1, 32, 4, 2, 1)
13
+ self.enc2 = nn.Conv2d(32, 64, 4, 2, 1)
14
+ self.enc3 = nn.Conv2d(64, 128, 4, 2, 1)
15
+ self.enc4 = nn.Conv2d(128, 256, 4, 2, 1)
16
+ self.enc5 = nn.Conv2d(256, 512, 4, 2, 1)
17
+ self.fc_mu = nn.Linear(512 * 7 * 7, latent_dim)
18
+ self.fc_logvar = nn.Linear(512 * 7 * 7, latent_dim)
19
+
20
+ self.dec_fc = nn.Linear(latent_dim, 512 * 7 * 7)
21
+ self.dec1 = nn.ConvTranspose2d(512, 256, 4, 2, 1)
22
+ self.dec2 = nn.ConvTranspose2d(256, 128, 4, 2, 1)
23
+ self.dec3 = nn.ConvTranspose2d(128, 64, 4, 2, 1)
24
+ self.dec4 = nn.ConvTranspose2d(64, 32, 4, 2, 1)
25
+ self.dec5 = nn.ConvTranspose2d(32, 1, 4, 2, 1)
26
+
27
+ def decode(self, z):
28
+ x = F.relu(self.dec_fc(z))
29
+ x = x.view(x.size(0), 512, 7, 7)
30
+ x = F.relu(self.dec1(x))
31
+ x = F.relu(self.dec2(x))
32
+ x = F.relu(self.dec3(x))
33
+ x = F.relu(self.dec4(x))
34
+ x = torch.sigmoid(self.dec5(x))
35
+ return x
36
+
37
+ def main():
38
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
39
+ print(f"Targeting device for VAE harvesting: {device}")
40
+
41
+ # Set up NVMe paths
42
+ dataset_root = r"C:\Users\USER\Downloads\MedMNIST_Data"
43
+ output_dir = os.path.join(dataset_root, "VAE_Synthetic", "Normal_0")
44
+ os.makedirs(output_dir, exist_ok=True)
45
+
46
+ # 2. Load the trained brain
47
+ print("Loading VAE weights...")
48
+ model = VAE(latent_dim=128).to(device)
49
+ weight_path = os.path.join(dataset_root, "vae_baseline.pth")
50
+
51
+ if not os.path.exists(weight_path):
52
+ print(f"Error: Weights not found at {weight_path}")
53
+ return
54
+
55
+ model.load_state_dict(torch.load(weight_path, map_location=device, weights_only=True))
56
+ model.eval()
57
+
58
+ # 3. Harvest Parameters
59
+ total_images_needed = 2600
60
+ batch_size = 64
61
+ latent_dim = 128
62
+ generated_count = 0
63
+
64
+ print(f"Sampling {total_images_needed} images from the VAE latent space...")
65
+
66
+ with torch.no_grad():
67
+ with tqdm(total=total_images_needed, desc="Decoding Images") as pbar:
68
+ while generated_count < total_images_needed:
69
+ current_batch_size = min(batch_size, total_images_needed - generated_count)
70
+
71
+ # Sample random coordinates from the standard normal distribution
72
+ z = torch.randn(current_batch_size, latent_dim).to(device)
73
+
74
+ # Push through the Decoder (no need to un-normalize, Sigmoid handled it)
75
+ fake_images = model.decode(z)
76
+
77
+ # Save out
78
+ for i in range(current_batch_size):
79
+ img_path = os.path.join(output_dir, f"vae_normal_{generated_count}.png")
80
+ save_image(fake_images[i], img_path)
81
+ generated_count += 1
82
+
83
+ pbar.update(current_batch_size)
84
+
85
+ print(f"\nVAE Harvest complete. Images stored in: {output_dir}")
86
+
87
+ if __name__ == "__main__":
88
+ main()
VAE/Train_VAE.py ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import torch
3
+ import torch.nn as nn
4
+ import torch.nn.functional as F
5
+ import torch.optim as optim
6
+ from torchvision import transforms
7
+ from torchvision.utils import save_image
8
+ from torch.utils.data import DataLoader, Subset
9
+ import medmnist
10
+ from medmnist import INFO
11
+ from tqdm import tqdm
12
+
13
+ # ==========================================
14
+ # 1. The VAE Architecture
15
+ # ==========================================
16
+ class VAE(nn.Module):
17
+ def __init__(self, latent_dim=128):
18
+ super(VAE, self).__init__()
19
+
20
+ # ENCODER: Compress 224x224 down to 7x7
21
+ self.enc1 = nn.Conv2d(1, 32, 4, 2, 1) # Output: 112x112
22
+ self.enc2 = nn.Conv2d(32, 64, 4, 2, 1) # Output: 56x56
23
+ self.enc3 = nn.Conv2d(64, 128, 4, 2, 1) # Output: 28x28
24
+ self.enc4 = nn.Conv2d(128, 256, 4, 2, 1) # Output: 14x14
25
+ self.enc5 = nn.Conv2d(256, 512, 4, 2, 1) # Output: 7x7
26
+
27
+ # The Probabilistic Split (Mean and Log-Variance)
28
+ self.fc_mu = nn.Linear(512 * 7 * 7, latent_dim)
29
+ self.fc_logvar = nn.Linear(512 * 7 * 7, latent_dim)
30
+
31
+ # DECODER: Expand from latent_dim back to 224x224
32
+ self.dec_fc = nn.Linear(latent_dim, 512 * 7 * 7)
33
+ self.dec1 = nn.ConvTranspose2d(512, 256, 4, 2, 1)
34
+ self.dec2 = nn.ConvTranspose2d(256, 128, 4, 2, 1)
35
+ self.dec3 = nn.ConvTranspose2d(128, 64, 4, 2, 1)
36
+ self.dec4 = nn.ConvTranspose2d(64, 32, 4, 2, 1)
37
+ self.dec5 = nn.ConvTranspose2d(32, 1, 4, 2, 1)
38
+
39
+ def encode(self, x):
40
+ x = F.relu(self.enc1(x))
41
+ x = F.relu(self.enc2(x))
42
+ x = F.relu(self.enc3(x))
43
+ x = F.relu(self.enc4(x))
44
+ x = F.relu(self.enc5(x))
45
+ x = x.view(x.size(0), -1) # Flatten
46
+ return self.fc_mu(x), self.fc_logvar(x)
47
+
48
+ def reparameterize(self, mu, logvar):
49
+ # The Reparameterization Trick: z = mu + std * epsilon
50
+ std = torch.exp(0.5 * logvar)
51
+ eps = torch.randn_like(std)
52
+ return mu + eps * std
53
+
54
+ def decode(self, z):
55
+ x = F.relu(self.dec_fc(z))
56
+ x = x.view(x.size(0), 512, 7, 7) # Unflatten
57
+ x = F.relu(self.dec1(x))
58
+ x = F.relu(self.dec2(x))
59
+ x = F.relu(self.dec3(x))
60
+ x = F.relu(self.dec4(x))
61
+ # Sigmoid pushes pixels to exact [0, 1] range
62
+ x = torch.sigmoid(self.dec5(x))
63
+ return x
64
+
65
+ def forward(self, x):
66
+ mu, logvar = self.encode(x)
67
+ z = self.reparameterize(mu, logvar)
68
+ recon_x = self.decode(z)
69
+ return recon_x, mu, logvar
70
+
71
+ # ==========================================
72
+ # 2. The Custom VAE Loss Function
73
+ # ==========================================
74
+ def vae_loss_function(recon_x, x, mu, logvar):
75
+ # Loss 1: Reconstruction Loss (How well did it recreate the image?)
76
+ BCE = F.binary_cross_entropy(recon_x, x, reduction='sum')
77
+
78
+ # Loss 2: KL Divergence (Forces latent space to be a standard normal distribution)
79
+ KLD = -0.5 * torch.sum(1 + logvar - mu.pow(2) - logvar.exp())
80
+
81
+ return BCE + KLD
82
+
83
+ # ==========================================
84
+ # 3. The Training Engine
85
+ # ==========================================
86
+ def main():
87
+ device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
88
+ print(f"Igniting VAE Engine on: {device}")
89
+
90
+ dataset_root = r"C:\Users\USER\Downloads\MedMNIST_Data"
91
+ out_dir = os.path.join(dataset_root, "VAE_Outputs")
92
+ os.makedirs(out_dir, exist_ok=True)
93
+
94
+ # Hyperparameters
95
+ num_epochs = 100
96
+ batch_size = 64
97
+ learning_rate = 1e-4
98
+
99
+ # Strict Normalization to [0, 1] for BCE Loss
100
+ transform = transforms.Compose([
101
+ transforms.ToTensor(),
102
+ ])
103
+
104
+ print("Isolating pure 'Normal (0)' lungs...")
105
+ info = INFO['pneumoniamnist']
106
+ DataClass = getattr(medmnist, info['python_class'])
107
+ full_dataset = DataClass(split='train', transform=transform, download=False, size=224, root=dataset_root)
108
+
109
+ normal_indices = [i for i in range(len(full_dataset)) if full_dataset[i][1][0] == 0]
110
+ normal_dataset = Subset(full_dataset, normal_indices)
111
+ dataloader = DataLoader(normal_dataset, batch_size=batch_size, shuffle=True, num_workers=0)
112
+
113
+ model = VAE(latent_dim=128).to(device)
114
+ optimizer = optim.Adam(model.parameters(), lr=learning_rate)
115
+
116
+ print(f"Commencing VAE Training over {num_epochs} Epochs...")
117
+ for epoch in range(num_epochs):
118
+ model.train()
119
+ train_loss = 0
120
+ loop = tqdm(dataloader, leave=True)
121
+
122
+ for batch_idx, (data, _) in enumerate(loop):
123
+ data = data.to(device)
124
+ optimizer.zero_grad()
125
+
126
+ recon_batch, mu, logvar = model(data)
127
+ loss = vae_loss_function(recon_batch, data, mu, logvar)
128
+
129
+ loss.backward()
130
+ train_loss += loss.item()
131
+ optimizer.step()
132
+
133
+ loop.set_description(f"Epoch [{epoch+1}/{num_epochs}]")
134
+ loop.set_postfix(Loss=loss.item() / len(data))
135
+
136
+ # Generate a test image every 10 epochs
137
+ if (epoch + 1) % 10 == 0:
138
+ model.eval()
139
+ with torch.no_grad():
140
+ # Sample pure random noise from the normal distribution
141
+ sample = torch.randn(16, 128).to(device)
142
+ sample = model.decode(sample).cpu()
143
+ save_image(sample.view(16, 1, 224, 224), os.path.join(out_dir, f'sample_epoch_{epoch+1}.png'), nrow=4)
144
+
145
+ # Save the final brain
146
+ save_path = os.path.join(dataset_root, 'vae_baseline.pth')
147
+ torch.save(model.state_dict(), save_path)
148
+ print(f"\nVAE Training Complete! Weights saved to: {save_path}")
149
+
150
+ if __name__ == "__main__":
151
+ main()
gui/frontend/README.md ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # React + Vite
2
+
3
+ This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
4
+
5
+ Currently, two official plugins are available:
6
+
7
+ - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs)
8
+ - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/)
9
+
10
+ ## React Compiler
11
+
12
+ The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13
+
14
+ ## Expanding the ESLint configuration
15
+
16
+ If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project.
gui/frontend/node_modules/zod-validation-error/LICENSE ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ (The MIT License)
2
+
3
+ Copyright 2022 Causaly, Inc <front-end@causaly.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
gui/frontend/node_modules/zod-validation-error/README.md ADDED
@@ -0,0 +1,504 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # zod-validation-error
2
+
3
+ Wrap zod validation errors in user-friendly readable messages.
4
+
5
+ [![Build Status](https://github.com/causaly/zod-validation-error/actions/workflows/ci.yml/badge.svg)](https://github.com/causaly/zod-validation-error/actions/workflows/ci.yml) [![npm version](https://img.shields.io/npm/v/zod-validation-error.svg?color=0c0)](https://www.npmjs.com/package/zod-validation-error)
6
+
7
+ #### Features
8
+
9
+ - User-friendly readable error messages with extensive configuration options;
10
+ - Preserves original error details accessible via `error.details`;
11
+ - Provides a custom error map for better user-friendly messages;
12
+ - Supports both Zod v3 and v4.
13
+
14
+ **_Note:_** This version of `zod-validation-error` works with zod v4. If you are looking for zod v3 support, please refer to the [v3 documentation](./README.v3.md)
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install zod-validation-error
20
+ ```
21
+
22
+ #### Requirements
23
+
24
+ - Node.js v.18+
25
+ - TypeScript v.4.5+
26
+
27
+ ## Quick start
28
+
29
+ ```typescript
30
+ import { z as zod } from 'zod';
31
+ import { fromError, createErrorMap } from 'zod-validation-error';
32
+
33
+ // configure zod to use zod-validation-error's error map
34
+ // this is optional, you may also use your own custom error map or zod's native error map
35
+ // we recommend using zod-validation-error's error map for better user-friendly messages
36
+ // see https://zod.dev/error-customization for further details
37
+ zod.config({
38
+ customError: createErrorMap(),
39
+ });
40
+
41
+ // create zod schema
42
+ const zodSchema = zod.object({
43
+ id: zod.int().positive(),
44
+ email: zod.email(),
45
+ });
46
+
47
+ // parse some invalid value
48
+ try {
49
+ zodSchema.parse({
50
+ id: 1,
51
+ email: 'coyote@acme', // note: invalid email
52
+ });
53
+ } catch (err) {
54
+ const validationError = fromError(err);
55
+ // the error is now readable by the user
56
+ // you may print it to console
57
+ console.log(validationError.toString());
58
+ // or return it as an actual error
59
+ return validationError;
60
+ }
61
+ ```
62
+
63
+ ## Motivation
64
+
65
+ Zod errors are difficult to consume for the end-user. This library wraps Zod validation errors in user-friendly readable messages that can be exposed to the outer world, while maintaining the original errors in an array for _dev_ use.
66
+
67
+ ### Example
68
+
69
+ #### Input (from Zod)
70
+
71
+ ```json
72
+ [
73
+ {
74
+ "origin": "number",
75
+ "code": "too_small",
76
+ "minimum": 0,
77
+ "inclusive": false,
78
+ "path": ["id"],
79
+ "message": "Number must be greater than 0 at \"id\""
80
+ },
81
+ {
82
+ "origin": "string",
83
+ "code": "invalid_format",
84
+ "format": "email",
85
+ "pattern": "/^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/",
86
+ "path": ["email"],
87
+ "message": "Invalid email at \"email\""
88
+ }
89
+ ]
90
+ ```
91
+
92
+ #### Output
93
+
94
+ ```
95
+ Validation error: Number must be greater than 0 at "id"; Invalid email at "email"
96
+ ```
97
+
98
+ ## API
99
+
100
+ - [ValidationError(message[, options])](#validationerror)
101
+ - [createErrorMap(options)](#createErrorMap)
102
+ - [createMessageBuilder(options)](#createMessageBuilder)
103
+ - [isValidationError(error)](#isvalidationerror)
104
+ - [isValidationErrorLike(error)](#isvalidationerrorlike)
105
+ - [isZodErrorLike(error)](#iszoderrorlike)
106
+ - [fromError(error[, options])](#fromerror)
107
+ - [fromZodIssue(zodIssue[, options])](#fromzodissue)
108
+ - [fromZodError(zodError[, options])](#fromzoderror)
109
+ - [toValidationError([options]) => (error) => ValidationError](#tovalidationerror)
110
+
111
+ ### ValidationError
112
+
113
+ Main `ValidationError` class, extending JavaScript's native `Error`.
114
+
115
+ #### Arguments
116
+
117
+ - `message` - _string_; error message (required)
118
+ - `options` - _ErrorOptions_; error options as per [JavaScript definition](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error#options) (optional)
119
+ - `options.cause` - _any_; can be used to hold the original zod error (optional)
120
+
121
+ #### Example 1: construct new ValidationError with `message`
122
+
123
+ ```typescript
124
+ import { ValidationError } from 'zod-validation-error';
125
+
126
+ const error = new ValidationError('foobar');
127
+ console.log(error instanceof Error); // prints true
128
+ ```
129
+
130
+ #### Example 2: construct new ValidationError with `message` and `options.cause`
131
+
132
+ ```typescript
133
+ import { z as zod } from 'zod';
134
+ import { ValidationError } from 'zod-validation-error';
135
+
136
+ const error = new ValidationError('foobar', {
137
+ cause: new zod.ZodError([
138
+ {
139
+ origin: 'number',
140
+ code: 'too_small',
141
+ minimum: 0,
142
+ inclusive: false,
143
+ path: ['id'],
144
+ message: 'Number must be greater than 0 at "id"',
145
+ input: -1,
146
+ },
147
+ ]),
148
+ });
149
+
150
+ console.log(error.details); // prints issues from zod error
151
+ ```
152
+
153
+ ### createErrorMap
154
+
155
+ Creates zod-validation-error's `errorMap`, which is used to format issues into user-friendly error messages.
156
+
157
+ We think that zod's native error map is not user-friendly enough, so we provide our own implementation that formats issues into human-readable messages.
158
+
159
+ Note: zod-validation-error's `errorMap` is an errorMap like all others and thus can also be used directly with `zod` (see https://zod.dev/error-customization for further details), e.g.
160
+
161
+ #### Arguments
162
+
163
+ - `options` - _Object_; formatting options (optional)
164
+
165
+ ##### createErrorMap Options
166
+
167
+ | Name | Type | Description |
168
+ | ------------------------------- | :-------------------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
169
+ | `displayInvalidFormatDetails` | `boolean` | Indicates whether to display invalid format details (e.g. regexp pattern) in the error message (optional, defaults to `false`) |
170
+ | `maxAllowedValuesToDisplay` | `number` | Max number of allowed values to display (optional, defaults to `10`). Allowed values beyond this limit will be hidden. |
171
+ | `allowedValuesSeparator` | `string` | Used to concatenate allowed values in the message (optional, defaults to `", "`) |
172
+ | `allowedValuesLastSeparator` | `string \| undefined` | Used to concatenate last allowed value in the message (optional, defaults to `" or "`). Set to `undefined` to disable. |
173
+ | `wrapAllowedValuesInQuote` | `boolean` | Indicates whether to wrap allowed values in quotes (optional, defaults to `true`). Note that this only applies to string values. |
174
+ | `maxUnrecognizedKeysToDisplay` | `number` | Max number of unrecognized keys to display in the error message (optional, defaults to `5`) |
175
+ | `unrecognizedKeysSeparator` | `string` | Used to concatenate unrecognized keys in the message (optional, defaults to `", "`) |
176
+ | `unrecognizedKeysLastSeparator` | `string \| undefined` | Used to concatenate the last unrecognized key in message (optional, defaults to `" and "`). Set to `undefined` to disable. |
177
+ | `wrapUnrecognizedKeysInQuote` | `boolean` | Indicates whether to wrap unrecognized keys in quotes (optional, defaults to `true`). Note that this only applies to string keys. |
178
+ | `dateLocalization` | `boolean \| Intl.LocalesArgument` | Indicates whether to localize date values (optional, defaults to `true`). If set to `true`, it will use the default locale of the environment. You can also pass `Intl.LocalesArgument` to specify a custom locale. |
179
+ | `numberLocalization` | `boolean \| Intl.LocalesArgument` | Indicates whether to localize numeric values (optional, defaults to `true`). If set to `true`, it will use the default locale of the environment. You can also pass `Intl.LocalesArgument` to specify a custom locale. |
180
+
181
+ #### Example
182
+
183
+ ```typescript
184
+ import { z as zod } from 'zod';
185
+ import { createErrorMap } from 'zod-validation-error';
186
+
187
+ zod.config({
188
+ customError: createErrorMap({
189
+ // default values are used when not specified
190
+ displayInvalidFormatDetails: true,
191
+ }),
192
+ });
193
+ ```
194
+
195
+ ### createMessageBuilder
196
+
197
+ Creates zod-validation-error's default `MessageBuilder`, which is used to produce user-friendly error messages.
198
+
199
+ Meant to be passed as an option to [fromError](#fromerror), [fromZodIssue](#fromzodissue), [fromZodError](#fromzoderror) or [toValidationError](#tovalidationerror).
200
+
201
+ #### Arguments
202
+
203
+ - `options` - _Object_; formatting options (optional)
204
+
205
+ ##### createMessageBuilder Options
206
+
207
+ | Name | Type | Description |
208
+ | -------------------- | :-------------------: | ---------------------------------------------------------------------------------------------------------------------------------------- |
209
+ | `maxIssuesInMessage` | `number` | Max issues to include in user-friendly message (optional, defaults to `99`) |
210
+ | `issueSeparator` | `string` | Used to concatenate issues in user-friendly message (optional, defaults to `";"`) |
211
+ | `unionSeparator` | `string` | Used to concatenate union-issues in user-friendly message (optional, defaults to `" or "`) |
212
+ | `prefix` | `string \| undefined` | Prefix to use in user-friendly message (optional, defaults to `"Validation error"`). Pass `undefined` to disable prefix completely. |
213
+ | `prefixSeparator` | `string` | Used to concatenate prefix with rest of the user-friendly message (optional, defaults to `": "`). Not used when `prefix` is `undefined`. |
214
+ | `includePath` | `boolean` | Indicates whether to include the erroneous property key in the error message (optional, defaults to `true`) |
215
+ | `forceTitleCase` | `boolean` | Indicates whether to convert individual issue messages to title case (optional, defaults to `true`). |
216
+
217
+ #### Example
218
+
219
+ ```typescript
220
+ import { createMessageBuilder } from 'zod-validation-error';
221
+
222
+ const messageBuilder = createMessageBuilder({
223
+ maxIssuesInMessage: 3,
224
+ includePath: false,
225
+ });
226
+ ```
227
+
228
+ ### isValidationError
229
+
230
+ A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on `instanceof` comparison.
231
+
232
+ #### Arguments
233
+
234
+ - `error` - error instance (required)
235
+
236
+ #### Example
237
+
238
+ ```typescript
239
+ import { z as zod } from 'zod';
240
+ import { ValidationError, isValidationError } from 'zod-validation-error';
241
+
242
+ const err = new ValidationError('foobar');
243
+ isValidationError(err); // returns true
244
+
245
+ const invalidErr = new Error('foobar');
246
+ isValidationError(err); // returns false
247
+ ```
248
+
249
+ ### isValidationErrorLike
250
+
251
+ A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on _heuristics_ comparison.
252
+
253
+ _Why do we need heuristics since we can use a simple `instanceof` comparison?_ Because of multi-version inconsistencies. For instance, it's possible that a dependency is using an older `zod-validation-error` version internally. In such case, the `instanceof` comparison will yield invalid results because module deduplication does not apply at npm/yarn level and the prototype is different.
254
+
255
+ tl;dr if you are uncertain then it is preferable to use `isValidationErrorLike` instead of `isValidationError`.
256
+
257
+ #### Arguments
258
+
259
+ - `error` - error instance (required)
260
+
261
+ #### Example
262
+
263
+ ```typescript
264
+ import { ValidationError, isValidationErrorLike } from 'zod-validation-error';
265
+
266
+ const err = new ValidationError('foobar');
267
+ isValidationErrorLike(err); // returns true
268
+
269
+ const invalidErr = new Error('foobar');
270
+ isValidationErrorLike(err); // returns false
271
+ ```
272
+
273
+ ### isZodErrorLike
274
+
275
+ A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on _heuristics_ comparison.
276
+
277
+ _Why do we need heuristics since we can use a simple `instanceof` comparison?_ Because of multi-version inconsistencies. For instance, it's possible that a dependency is using an older `zod` version internally. In such case, the `instanceof` comparison will yield invalid results because module deduplication does not apply at npm/yarn level and the prototype is different.
278
+
279
+ #### Arguments
280
+
281
+ - `error` - error instance (required)
282
+
283
+ #### Example
284
+
285
+ ```typescript
286
+ import { z as zod } from 'zod';
287
+ import { ValidationError, isZodErrorLike } from 'zod-validation-error';
288
+
289
+ const zodValidationErr = new ValidationError('foobar');
290
+ isZodErrorLike(zodValidationErr); // returns false
291
+
292
+ const genericErr = new Error('foobar');
293
+ isZodErrorLike(genericErr); // returns false
294
+
295
+ const zodErr = new zod.ZodError([
296
+ {
297
+ origin: 'number',
298
+ code: 'too_small',
299
+ minimum: 0,
300
+ inclusive: false,
301
+ path: ['id'],
302
+ message: 'Number must be greater than 0 at "id"',
303
+ input: -1,
304
+ },
305
+ ]);
306
+ isZodErrorLike(zodErr); // returns true
307
+ ```
308
+
309
+ ### fromError
310
+
311
+ Converts an error to `ValidationError`.
312
+
313
+ _What is the difference between `fromError` and `fromZodError`?_ The `fromError` function is a less strict version of `fromZodError`. It can accept an unknown error and attempt to convert it to a `ValidationError`.
314
+
315
+ #### Arguments
316
+
317
+ - `error` - _unknown_; an error (required)
318
+ - `options` - _Object_; formatting options (optional)
319
+ - `messageBuilder` - _MessageBuilder_; a function that accepts an array of `zod.ZodIssue` objects and returns a user-friendly error message in the form of a `string` (optional).
320
+
321
+ #### Notes
322
+
323
+ Alternatively, you may pass [createMessageBuilder options](#createmessagebuilder-options) directly as `options`. These will be used as arguments to create the `MessageBuilder` instance internally.
324
+
325
+ ### fromZodIssue
326
+
327
+ Converts a single zod issue to `ValidationError`.
328
+
329
+ #### Arguments
330
+
331
+ - `zodIssue` - _zod.ZodIssue_; a ZodIssue instance (required)
332
+ - `options` - _Object_; formatting options (optional)
333
+ - `messageBuilder` - _MessageBuilder_; a function that accepts an array of `zod.ZodIssue` objects and returns a user-friendly error message in the form of a `string` (optional).
334
+
335
+ #### Notes
336
+
337
+ Alternatively, you may pass [createMessageBuilder options](#createmessagebuilder-options) directly as `options`. These will be used as arguments to create the `MessageBuilder` instance internally.
338
+
339
+ ### fromZodError
340
+
341
+ Converts zod error to `ValidationError`.
342
+
343
+ _Why is the difference between `ZodError` and `ZodIssue`?_ A `ZodError` is a collection of 1 or more `ZodIssue` instances. It's what you get when you call `zodSchema.parse()`.
344
+
345
+ #### Arguments
346
+
347
+ - `zodError` - _zod.ZodError_; a ZodError instance (required)
348
+ - `options` - _Object_; formatting options (optional)
349
+ - `messageBuilder` - _MessageBuilder_; a function that accepts an array of `zod.ZodIssue` objects and returns a user-friendly error message in the form of a `string` (optional).
350
+
351
+ #### Notes
352
+
353
+ Alternatively, you may pass [createMessageBuilder options](#createmessagebuilder-optionscreateMessageBuilder) directly as `options`. These will be used as arguments to create the `MessageBuilder` instance internally.
354
+
355
+ ### toValidationError
356
+
357
+ A curried version of `fromZodError` meant to be used for FP (Functional Programming). Note it first takes the options object if needed and returns a function that converts the `zodError` to a `ValidationError` object
358
+
359
+ ```js
360
+ toValidationError(options) => (zodError) => ValidationError
361
+ ```
362
+
363
+ #### Example using fp-ts
364
+
365
+ ```typescript
366
+ import * as Either from 'fp-ts/Either';
367
+ import { z as zod } from 'zod';
368
+ import { toValidationError, ValidationError } from 'zod-validation-error';
369
+
370
+ // create zod schema
371
+ const zodSchema = zod
372
+ .object({
373
+ id: zod.int().positive(),
374
+ email: zod.email(),
375
+ })
376
+ .brand<'User'>();
377
+
378
+ export type User = zod.infer<typeof zodSchema>;
379
+
380
+ export function parse(
381
+ value: zod.input<typeof zodSchema>
382
+ ): Either.Either<ValidationError, User> {
383
+ return Either.tryCatch(() => schema.parse(value), toValidationError());
384
+ }
385
+ ```
386
+
387
+ ## FAQ
388
+
389
+ ### What is the difference between zod-validation-error and zod's own [prettifyError](https://zod.dev/error-formatting#zprettifyerror)?
390
+
391
+ While both libraries aim to provide a human-readable string representation of a zod error, they differ in several ways...
392
+
393
+ 1. **End-user focus**: zod-validation-error provides opinionated, user-friendly error messages designed to be displayed directly to end-users in forms or API responses.
394
+ 1. **Customization options**: zod-validation-error offers extensive configuration for message formatting, such as controlling path inclusion, allowed values display, localization, and more.
395
+ 1. **Error handling**: zod-validation-error maintains the original error details while providing a clean, consistent interface through the ValidationError class.
396
+ 1. **Integration flexibility**: Beyond just formatting, zod-validation-error provides utility functions for error detection and conversion that work well in various architectural patterns, e.g. functional programming.
397
+
398
+ Disclaimer: as per this [comment](https://github.com/causaly/zod-validation-error/issues/455#issuecomment-2811895152), we have no intention to antagonize zod. In fact, we are happy to decommission this module assuming it's in the best interest of the community. As of now, it seems that there's room for both `zod-validation-error` and `prettifyError`, also based on Colin McDonnell's [response](https://github.com/causaly/zod-validation-error/issues/455#issuecomment-2814466019).
399
+
400
+ ### Do I need to use `zod-validation-error`'s error map?
401
+
402
+ No, you can use zod's native error map if you prefer. However, we recommend using `zod-validation-error`'s error map for better user-friendly messages.
403
+
404
+ You may also use your own custom error map if you have specific requirements, e.g. internationalization.
405
+
406
+ ### Where can I see how `zod-validation-error`'s error map formatting works?
407
+
408
+ The easiest way to understand how `zod-validation-error`'s error map works is to look at the [tests](./lib/v4/errorMap/errorMap.test.ts). They cover various scenarios and demonstrate how the error map formats issues into user-friendly messages.
409
+
410
+ ### How to distinguish between errors
411
+
412
+ Use the `isValidationErrorLike` type guard.
413
+
414
+ #### Example
415
+
416
+ Scenario: Distinguish between `ValidationError` VS generic `Error` in order to respond with 400 VS 500 HTTP status code respectively.
417
+
418
+ ```typescript
419
+ import { isValidationErrorLike } from 'zod-validation-error';
420
+
421
+ try {
422
+ func(); // throws Error - or - ValidationError
423
+ } catch (err) {
424
+ if (isValidationErrorLike(err)) {
425
+ return 400; // Bad Data (this is a client error)
426
+ }
427
+
428
+ return 500; // Server Error
429
+ }
430
+ ```
431
+
432
+ ### How to use `ValidationError` outside `zod`
433
+
434
+ It's possible to implement custom validation logic outside `zod` and throw a `ValidationError`.
435
+
436
+ #### Example 1: passing custom message
437
+
438
+ ```typescript
439
+ import { ValidationError } from 'zod-validation-error';
440
+ import { Buffer } from 'node:buffer';
441
+
442
+ function parseBuffer(buf: unknown): Buffer {
443
+ if (!Buffer.isBuffer(buf)) {
444
+ throw new ValidationError('Invalid argument; expected buffer');
445
+ }
446
+
447
+ return buf;
448
+ }
449
+ ```
450
+
451
+ #### Example 2: passing custom message and original error as cause
452
+
453
+ ```typescript
454
+ import { ValidationError } from 'zod-validation-error';
455
+
456
+ try {
457
+ // do something that throws an error
458
+ } catch (err) {
459
+ throw new ValidationError('Something went deeply wrong', { cause: err });
460
+ }
461
+ ```
462
+
463
+ ### How to use `ValidationError` with custom "error map"
464
+
465
+ Zod supports customizing error messages by providing a custom "error map". You may combine this with `zod-validation-error` to produce user-friendly messages.
466
+
467
+ #### Example: produce user-friendly error messages using the `customError` property
468
+
469
+ If all you need is to produce user-friendly error messages you may use the `customError` property.
470
+
471
+ ```typescript
472
+ import { z as zod } from 'zod';
473
+ import { createErrorMap } from 'zod-validation-error';
474
+
475
+ zod.config({
476
+ customError: createErrorMap({
477
+ includePath: true,
478
+ }),
479
+ });
480
+ ```
481
+
482
+ `zod-validation-error` will respect the `customError` property when it is set, no further configuration is needed.
483
+
484
+ ### Does `zod-validation-error` support CommonJS
485
+
486
+ Yes, `zod-validation-error` supports CommonJS out-of-the-box. All you need to do is import it using `require`.
487
+
488
+ #### Example
489
+
490
+ ```typescript
491
+ const { ValidationError } = require('zod-validation-error');
492
+ ```
493
+
494
+ ## Contribute
495
+
496
+ Source code contributions are most welcome. Please open a PR, ensure the linter is satisfied and all tests pass.
497
+
498
+ #### We are hiring
499
+
500
+ Causaly is building the world's largest biomedical knowledge platform, using technologies such as TypeScript, React and Node.js. Find out more about our openings at https://jobs.ashbyhq.com/causaly.
501
+
502
+ ## License
503
+
504
+ MIT
gui/frontend/node_modules/zod-validation-error/README.v3.md ADDED
@@ -0,0 +1,558 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # zod-validation-error
2
+
3
+ Wrap zod validation errors in user-friendly readable messages.
4
+
5
+ [![Build Status](https://github.com/causaly/zod-validation-error/actions/workflows/ci.yml/badge.svg)](https://github.com/causaly/zod-validation-error/actions/workflows/ci.yml) [![npm version](https://img.shields.io/npm/v/zod-validation-error.svg?color=0c0)](https://www.npmjs.com/package/zod-validation-error)
6
+
7
+ #### Features
8
+
9
+ - User-friendly readable messages, configurable via options;
10
+ - Maintain original issues under `error.details`;
11
+ - Supports both `zod` v3 and v4.
12
+
13
+ **_Note:_** This is the v3 version of `zod-validation-error`. If you are looking for zod v4 support, please click [here](/README.md).
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install zod-validation-error
19
+ ```
20
+
21
+ #### Requirements
22
+
23
+ - Node.js v.18+
24
+ - TypeScript v.4.5+
25
+
26
+ ## Quick start
27
+
28
+ ```typescript
29
+ import { z as zod } from 'zod/v3';
30
+ import { fromError } from 'zod-validation-error/v3';
31
+
32
+ // create zod schema
33
+ const zodSchema = zod.object({
34
+ id: zod.number().int().positive(),
35
+ email: zod.string().email(),
36
+ });
37
+
38
+ // parse some invalid value
39
+ try {
40
+ zodSchema.parse({
41
+ id: 1,
42
+ email: 'foobar', // note: invalid email
43
+ });
44
+ } catch (err) {
45
+ const validationError = fromError(err);
46
+ // the error is now readable by the user
47
+ // you may print it to console
48
+ console.log(validationError.toString());
49
+ // or return it as an actual error
50
+ return validationError;
51
+ }
52
+ ```
53
+
54
+ ## Motivation
55
+
56
+ Zod errors are difficult to consume for the end-user. This library wraps Zod validation errors in user-friendly readable messages that can be exposed to the outer world, while maintaining the original errors in an array for _dev_ use.
57
+
58
+ ### Example
59
+
60
+ #### Input (from Zod)
61
+
62
+ ```json
63
+ [
64
+ {
65
+ "code": "too_small",
66
+ "inclusive": false,
67
+ "message": "Number must be greater than 0",
68
+ "minimum": 0,
69
+ "path": ["id"],
70
+ "type": "number"
71
+ },
72
+ {
73
+ "code": "invalid_string",
74
+ "message": "Invalid email",
75
+ "path": ["email"],
76
+ "validation": "email"
77
+ }
78
+ ]
79
+ ```
80
+
81
+ #### Output
82
+
83
+ ```
84
+ Validation error: Number must be greater than 0 at "id"; Invalid email at "email"
85
+ ```
86
+
87
+ ## API
88
+
89
+ - [ValidationError(message[, options])](#validationerror)
90
+ - [createMessageBuilder(props)](#createMessageBuilder)
91
+ - [errorMap](#errormap)
92
+ - [isValidationError(error)](#isvalidationerror)
93
+ - [isValidationErrorLike(error)](#isvalidationerrorlike)
94
+ - [isZodErrorLike(error)](#iszoderrorlike)
95
+ - [fromError(error[, options])](#fromerror)
96
+ - [fromZodIssue(zodIssue[, options])](#fromzodissue)
97
+ - [fromZodError(zodError[, options])](#fromzoderror)
98
+ - [toValidationError([options]) => (error) => ValidationError](#tovalidationerror)
99
+
100
+ ### ValidationError
101
+
102
+ Main `ValidationError` class, extending native JavaScript `Error`.
103
+
104
+ #### Arguments
105
+
106
+ - `message` - _string_; error message (required)
107
+ - `options` - _ErrorOptions_; error options as per [JavaScript definition](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error#options) (optional)
108
+ - `options.cause` - _any_; can be used to hold the original zod error (optional)
109
+
110
+ #### Example 1: construct new ValidationError with `message`
111
+
112
+ ```typescript
113
+ const { ValidationError } = require('zod-validation-error');
114
+
115
+ const error = new ValidationError('foobar');
116
+ console.log(error instanceof Error); // prints true
117
+ ```
118
+
119
+ #### Example 2: construct new ValidationError with `message` and `options.cause`
120
+
121
+ ```typescript
122
+ import { z as zod } from 'zod/v3';
123
+ const { ValidationError } = require('zod-validation-error');
124
+
125
+ const error = new ValidationError('foobar', {
126
+ cause: new zod.ZodError([
127
+ {
128
+ code: 'invalid_string',
129
+ message: 'Invalid email',
130
+ path: ['email'],
131
+ validation: 'email',
132
+ },
133
+ ]),
134
+ });
135
+
136
+ console.log(error.details); // prints issues from zod error
137
+ ```
138
+
139
+ ### createMessageBuilder
140
+
141
+ Creates zod-validation-error's default `MessageBuilder`, which is used to produce user-friendly error messages.
142
+
143
+ Meant to be passed as an option to [fromError](#fromerror), [fromZodIssue](#fromzodissue), [fromZodError](#fromzoderror) or [toValidationError](#tovalidationerror).
144
+
145
+ You may read more on the concept of the `MessageBuilder` further [below](#MessageBuilder).
146
+
147
+ #### Arguments
148
+
149
+ - `props` - _Object_; formatting options (optional)
150
+ - `maxIssuesInMessage` - _number_; max issues to include in user-friendly message (optional, defaults to 99)
151
+ - `issueSeparator` - _string_; used to concatenate issues in user-friendly message (optional, defaults to ";")
152
+ - `unionSeparator` - _string_; used to concatenate union-issues in user-friendly message (optional, defaults to ", or")
153
+ - `prefix` - _string_ or _null_; prefix to use in user-friendly message (optional, defaults to "Validation error"). Pass `null` to disable prefix completely.
154
+ - `prefixSeparator` - _string_; used to concatenate prefix with rest of the user-friendly message (optional, defaults to ": "). Not used when `prefix` is `null`.
155
+ - `includePath` - _boolean_; used to provide control on whether to include the erroneous property name suffix or not (optional, defaults to `true`).
156
+
157
+ #### Example
158
+
159
+ ```typescript
160
+ import { createMessageBuilder } from 'zod-validation-error/v3';
161
+
162
+ const messageBuilder = createMessageBuilder({
163
+ includePath: false,
164
+ maxIssuesInMessage: 3,
165
+ });
166
+ ```
167
+
168
+ ### errorMap
169
+
170
+ A custom error map to use with zod's `setErrorMap` method and get user-friendly messages automatically.
171
+
172
+ #### Example
173
+
174
+ ```typescript
175
+ import { z as zod } from 'zod/v3';
176
+ import { errorMap } from 'zod-validation-error/v3';
177
+
178
+ zod.setErrorMap(errorMap);
179
+ ```
180
+
181
+ ### isValidationError
182
+
183
+ A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on `instanceof` comparison.
184
+
185
+ #### Arguments
186
+
187
+ - `error` - error instance (required)
188
+
189
+ #### Example
190
+
191
+ ```typescript
192
+ import { z as zod } from 'zod/v3';
193
+ import { ValidationError, isValidationError } from 'zod-validation-error/v3';
194
+
195
+ const err = new ValidationError('foobar');
196
+ isValidationError(err); // returns true
197
+
198
+ const invalidErr = new Error('foobar');
199
+ isValidationError(err); // returns false
200
+ ```
201
+
202
+ ### isValidationErrorLike
203
+
204
+ A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on _heuristics_ comparison.
205
+
206
+ _Why do we need heuristics since we can use a simple `instanceof` comparison?_ Because of multi-version inconsistencies. For instance, it's possible that a dependency is using an older `zod-validation-error` version internally. In such case, the `instanceof` comparison will yield invalid results because module deduplication does not apply at npm/yarn level and the prototype is different.
207
+
208
+ tl;dr if you are uncertain then it is preferable to use `isValidationErrorLike` instead of `isValidationError`.
209
+
210
+ #### Arguments
211
+
212
+ - `error` - error instance (required)
213
+
214
+ #### Example
215
+
216
+ ```typescript
217
+ import {
218
+ ValidationError,
219
+ isValidationErrorLike,
220
+ } from 'zod-validation-error/v3';
221
+
222
+ const err = new ValidationError('foobar');
223
+ isValidationErrorLike(err); // returns true
224
+
225
+ const invalidErr = new Error('foobar');
226
+ isValidationErrorLike(err); // returns false
227
+ ```
228
+
229
+ ### isZodErrorLike
230
+
231
+ A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on _heuristics_ comparison.
232
+
233
+ _Why do we need heuristics since we can use a simple `instanceof` comparison?_ Because of multi-version inconsistencies. For instance, it's possible that a dependency is using an older `zod` version internally. In such case, the `instanceof` comparison will yield invalid results because module deduplication does not apply at npm/yarn level and the prototype is different.
234
+
235
+ #### Arguments
236
+
237
+ - `error` - error instance (required)
238
+
239
+ #### Example
240
+
241
+ ```typescript
242
+ import { z as zod } from 'zod/v3';
243
+ import { ValidationError, isZodErrorLike } from 'zod-validation-error/v3';
244
+
245
+ const zodValidationErr = new ValidationError('foobar');
246
+ isZodErrorLike(zodValidationErr); // returns false
247
+
248
+ const genericErr = new Error('foobar');
249
+ isZodErrorLike(genericErr); // returns false
250
+
251
+ const zodErr = new zod.ZodError([
252
+ {
253
+ code: zod.ZodIssueCode.custom,
254
+ path: [],
255
+ message: 'foobar',
256
+ fatal: true,
257
+ },
258
+ ]);
259
+ isZodErrorLike(zodErr); // returns true
260
+ ```
261
+
262
+ ### fromError
263
+
264
+ Converts an error to `ValidationError`.
265
+
266
+ _What is the difference between `fromError` and `fromZodError`?_ The `fromError` function is a less strict version of `fromZodError`. It can accept an unknown error and attempt to convert it to a `ValidationError`.
267
+
268
+ #### Arguments
269
+
270
+ - `error` - _unknown_; an error (required)
271
+ - `options` - _Object_; formatting options (optional)
272
+ - `messageBuilder` - _MessageBuilder_; a function that accepts an array of `zod.ZodIssue` objects and returns a user-friendly error message in the form of a `string` (optional).
273
+
274
+ #### Notes
275
+
276
+ Alternatively, you may pass the following `options` instead of a `messageBuilder`.
277
+
278
+ - `options` - _Object_; formatting options (optional)
279
+ - `maxIssuesInMessage` - _number_; max issues to include in user-friendly message (optional, defaults to 99)
280
+ - `issueSeparator` - _string_; used to concatenate issues in user-friendly message (optional, defaults to ";")
281
+ - `unionSeparator` - _string_; used to concatenate union-issues in user-friendly message (optional, defaults to ", or")
282
+ - `prefix` - _string_ or _null_; prefix to use in user-friendly message (optional, defaults to "Validation error"). Pass `null` to disable prefix completely.
283
+ - `prefixSeparator` - _string_; used to concatenate prefix with rest of the user-friendly message (optional, defaults to ": "). Not used when `prefix` is `null`.
284
+ - `includePath` - _boolean_; used to provide control on whether to include the erroneous property name suffix or not (optional, defaults to `true`).
285
+
286
+ They will be passed as arguments to the [createMessageBuilder](#createMessageBuilder) function. The only reason they exist is to provide backwards-compatibility with older versions of `zod-validation-error`. They should however be considered deprecated and may be removed in the future.
287
+
288
+ ### fromZodIssue
289
+
290
+ Converts a single zod issue to `ValidationError`.
291
+
292
+ #### Arguments
293
+
294
+ - `zodIssue` - _zod.ZodIssue_; a ZodIssue instance (required)
295
+ - `options` - _Object_; formatting options (optional)
296
+ - `messageBuilder` - _MessageBuilder_; a function that accepts an array of `zod.ZodIssue` objects and returns a user-friendly error message in the form of a `string` (optional).
297
+
298
+ #### Notes
299
+
300
+ Alternatively, you may pass the following `options` instead of a `messageBuilder`.
301
+
302
+ - `options` - _Object_; formatting options (optional)
303
+ - `issueSeparator` - _string_; used to concatenate issues in user-friendly message (optional, defaults to ";")
304
+ - `unionSeparator` - _string_; used to concatenate union-issues in user-friendly message (optional, defaults to ", or")
305
+ - `prefix` - _string_ or _null_; prefix to use in user-friendly message (optional, defaults to "Validation error"). Pass `null` to disable prefix completely.
306
+ - `prefixSeparator` - _string_; used to concatenate prefix with rest of the user-friendly message (optional, defaults to ": "). Not used when `prefix` is `null`.
307
+ - `includePath` - _boolean_; used to provide control on whether to include the erroneous property name suffix or not (optional, defaults to `true`).
308
+
309
+ They will be passed as arguments to the [createMessageBuilder](#createMessageBuilder) function. The only reason they exist is to provide backwards-compatibility with older versions of `zod-validation-error`. They should however be considered deprecated and may be removed in the future.
310
+
311
+ ### fromZodError
312
+
313
+ Converts zod error to `ValidationError`.
314
+
315
+ _Why is the difference between `ZodError` and `ZodIssue`?_ A `ZodError` is a collection of 1 or more `ZodIssue` instances. It's what you get when you call `zodSchema.parse()`.
316
+
317
+ #### Arguments
318
+
319
+ - `zodError` - _zod.ZodError_; a ZodError instance (required)
320
+ - `options` - _Object_; formatting options (optional)
321
+ - `messageBuilder` - _MessageBuilder_; a function that accepts an array of `zod.ZodIssue` objects and returns a user-friendly error message in the form of a `string` (optional).
322
+
323
+ #### Notes
324
+
325
+ Alternatively, you may pass the following `options` instead of a `messageBuilder`.
326
+
327
+ - `options` - _Object_; formatting options (optional)
328
+ - `maxIssuesInMessage` - _number_; max issues to include in user-friendly message (optional, defaults to 99)
329
+ - `issueSeparator` - _string_; used to concatenate issues in user-friendly message (optional, defaults to ";")
330
+ - `unionSeparator` - _string_; used to concatenate union-issues in user-friendly message (optional, defaults to ", or")
331
+ - `prefix` - _string_ or _null_; prefix to use in user-friendly message (optional, defaults to "Validation error"). Pass `null` to disable prefix completely.
332
+ - `prefixSeparator` - _string_; used to concatenate prefix with rest of the user-friendly message (optional, defaults to ": "). Not used when `prefix` is `null`.
333
+ - `includePath` - _boolean_; used to provide control on whether to include the erroneous property name suffix or not (optional, defaults to `true`).
334
+
335
+ They will be passed as arguments to the [createMessageBuilder](#createMessageBuilder) function. The only reason they exist is to provide backwards-compatibility with older versions of `zod-validation-error`. They should however be considered deprecated and may be removed in the future.
336
+
337
+ ### toValidationError
338
+
339
+ A curried version of `fromZodError` meant to be used for FP (Functional Programming). Note it first takes the options object if needed and returns a function that converts the `zodError` to a `ValidationError` object
340
+
341
+ ```js
342
+ toValidationError(options) => (zodError) => ValidationError
343
+ ```
344
+
345
+ #### Example using fp-ts
346
+
347
+ ```typescript
348
+ import * as Either from 'fp-ts/Either';
349
+ import { z as zod } from 'zod/v3';
350
+ import { toValidationError, ValidationError } from 'zod-validation-error/v3';
351
+
352
+ // create zod schema
353
+ const zodSchema = zod
354
+ .object({
355
+ id: zod.number().int().positive(),
356
+ email: zod.string().email(),
357
+ })
358
+ .brand<'User'>();
359
+
360
+ export type User = zod.infer<typeof zodSchema>;
361
+
362
+ export function parse(
363
+ value: zod.input<typeof zodSchema>
364
+ ): Either.Either<ValidationError, User> {
365
+ return Either.tryCatch(() => schema.parse(value), toValidationError());
366
+ }
367
+ ```
368
+
369
+ ## MessageBuilder
370
+
371
+ `zod-validation-error` can be configured with a custom `MessageBuilder` function in order to produce case-specific error messages.
372
+
373
+ #### Example
374
+
375
+ For instance, one may want to print `invalid_string` errors to the console in red color.
376
+
377
+ ```typescript
378
+ import { z as zod } from 'zod/v3';
379
+ import { type MessageBuilder, fromError } from 'zod-validation-error/v3';
380
+ import chalk from 'chalk';
381
+
382
+ // create custom MessageBuilder
383
+ const myMessageBuilder: MessageBuilder = (issues) => {
384
+ return (
385
+ issues
386
+ // format error message
387
+ .map((issue) => {
388
+ if (issue.code === zod.ZodIssueCode.invalid_string) {
389
+ return chalk.red(issue.message);
390
+ }
391
+
392
+ return issue.message;
393
+ })
394
+ // join as string with new-line character
395
+ .join('\n')
396
+ );
397
+ };
398
+
399
+ // create zod schema
400
+ const zodSchema = zod.object({
401
+ id: zod.number().int().positive(),
402
+ email: zod.string().email(),
403
+ });
404
+
405
+ // parse some invalid value
406
+ try {
407
+ zodSchema.parse({
408
+ id: 1,
409
+ email: 'foobar', // note: invalid email value
410
+ });
411
+ } catch (err) {
412
+ const validationError = fromError(err, {
413
+ messageBuilder: myMessageBuilder,
414
+ });
415
+ // the error is now displayed with red letters
416
+ console.log(validationError.toString());
417
+ }
418
+ ```
419
+
420
+ ## FAQ
421
+
422
+ ### How to distinguish between errors
423
+
424
+ Use the `isValidationErrorLike` type guard.
425
+
426
+ #### Example
427
+
428
+ Scenario: Distinguish between `ValidationError` VS generic `Error` in order to respond with 400 VS 500 HTTP status code respectively.
429
+
430
+ ```typescript
431
+ import * as Either from 'fp-ts/Either';
432
+ import { z as zod } from 'zod/v3';
433
+ import { isValidationErrorLike } from 'zod-validation-error/v3';
434
+
435
+ try {
436
+ func(); // throws Error - or - ValidationError
437
+ } catch (err) {
438
+ if (isValidationErrorLike(err)) {
439
+ return 400; // Bad Data (this is a client error)
440
+ }
441
+
442
+ return 500; // Server Error
443
+ }
444
+ ```
445
+
446
+ ### How to use `ValidationError` outside `zod`
447
+
448
+ It's possible to implement custom validation logic outside `zod` and throw a `ValidationError`.
449
+
450
+ #### Example 1: passing custom message
451
+
452
+ ```typescript
453
+ import { ValidationError } from 'zod-validation-error/v3';
454
+ import { Buffer } from 'node:buffer';
455
+
456
+ function parseBuffer(buf: unknown): Buffer {
457
+ if (!Buffer.isBuffer(buf)) {
458
+ throw new ValidationError('Invalid argument; expected buffer');
459
+ }
460
+
461
+ return buf;
462
+ }
463
+ ```
464
+
465
+ #### Example 2: passing custom message and original error as cause
466
+
467
+ ```typescript
468
+ import { ValidationError } from 'zod-validation-error/v3';
469
+
470
+ try {
471
+ // do something that throws an error
472
+ } catch (err) {
473
+ throw new ValidationError('Something went deeply wrong', { cause: err });
474
+ }
475
+ ```
476
+
477
+ ### How to use `ValidationError` with custom "error map"
478
+
479
+ Zod supports customizing error messages by providing a custom "error map". You may combine this with `zod-validation-error` to produce user-friendly messages.
480
+
481
+ #### Example 1: produce user-friendly error messages using the `errorMap` property
482
+
483
+ If all you need is to produce user-friendly error messages you may use the `errorMap` property.
484
+
485
+ ```typescript
486
+ import { z as zod } from 'zod/v3';
487
+ import { errorMap } from 'zod-validation-error/v3';
488
+
489
+ zod.setErrorMap(errorMap);
490
+ ```
491
+
492
+ #### Example 2: extra customization using `fromZodIssue`
493
+
494
+ If you need to customize some error code, you may use the `fromZodIssue` function.
495
+
496
+ ```typescript
497
+ import { z as zod } from 'zod/v3';
498
+ import { fromZodIssue } from 'zod-validation-error/v3';
499
+
500
+ const customErrorMap: zod.ZodErrorMap = (issue, ctx) => {
501
+ switch (issue.code) {
502
+ case ZodIssueCode.invalid_type: {
503
+ return {
504
+ message:
505
+ 'Custom error message of your preference for invalid_type errors',
506
+ };
507
+ }
508
+ default: {
509
+ const validationError = fromZodIssue({
510
+ ...issue,
511
+ // fallback to the default error message
512
+ // when issue does not have a message
513
+ message: issue.message ?? ctx.defaultError,
514
+ });
515
+
516
+ return {
517
+ message: validationError.message,
518
+ };
519
+ }
520
+ }
521
+ };
522
+
523
+ zod.setErrorMap(customErrorMap);
524
+ ```
525
+
526
+ ### How to use `zod-validation-error` with `react-hook-form`?
527
+
528
+ ```typescript
529
+ import { useForm } from 'react-hook-form';
530
+ import { zodResolver } from '@hookform/resolvers/zod';
531
+ import { errorMap } from 'zod-validation-error/v3';
532
+
533
+ useForm({
534
+ resolver: zodResolver(schema, { errorMap }),
535
+ });
536
+ ```
537
+
538
+ ### Does `zod-validation-error` support CommonJS
539
+
540
+ Yes, `zod-validation-error` supports CommonJS out-of-the-box. All you need to do is import it using `require`.
541
+
542
+ #### Example
543
+
544
+ ```typescript
545
+ const { ValidationError } = require('zod-validation-error');
546
+ ```
547
+
548
+ ## Contribute
549
+
550
+ Source code contributions are most welcome. Please open a PR, ensure the linter is satisfied and all tests pass.
551
+
552
+ #### We are hiring
553
+
554
+ Causaly is building the world's largest biomedical knowledge platform, using technologies such as TypeScript, React and Node.js. Find out more about our openings at https://jobs.ashbyhq.com/causaly.
555
+
556
+ ## License
557
+
558
+ MIT
gui/frontend/node_modules/zod-validation-error/package.json ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "zod-validation-error",
3
+ "version": "4.0.2",
4
+ "description": "Wrap zod validation errors in user-friendly readable messages",
5
+ "keywords": [
6
+ "zod",
7
+ "error",
8
+ "validation"
9
+ ],
10
+ "license": "MIT",
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git://github.com/causaly/zod-validation-error.git"
14
+ },
15
+ "author": {
16
+ "name": "Dimitrios C. Michalakos",
17
+ "email": "dimitris@jmike.gr",
18
+ "url": "https://github.com/jmike"
19
+ },
20
+ "contributors": [
21
+ {
22
+ "name": "Thanos Karagiannis",
23
+ "email": "hey@maestros.io",
24
+ "url": "https://github.com/thanoskrg"
25
+ },
26
+ {
27
+ "name": "Nikos Tsompanides",
28
+ "email": "nikostsompanides@gmail.com",
29
+ "url": "https://github.com/NikosTsompanides"
30
+ },
31
+ {
32
+ "name": "Nikos Kalogridis",
33
+ "url": "https://github.com/nikoskalogridis"
34
+ }
35
+ ],
36
+ "main": "./v4/index.js",
37
+ "module": "./v4/index.mjs",
38
+ "types": "./v4/index.d.ts",
39
+ "exports": {
40
+ ".": {
41
+ "types": "./v4/index.d.ts",
42
+ "require": "./v4/index.js",
43
+ "import": "./v4/index.mjs"
44
+ },
45
+ "./v3": {
46
+ "types": "./v3/index.d.ts",
47
+ "require": "./v3/index.js",
48
+ "import": "./v3/index.mjs"
49
+ },
50
+ "./v4": {
51
+ "types": "./v4/index.d.ts",
52
+ "require": "./v4/index.js",
53
+ "import": "./v4/index.mjs"
54
+ }
55
+ },
56
+ "files": [
57
+ "v3",
58
+ "v4"
59
+ ],
60
+ "publishConfig": {
61
+ "access": "public"
62
+ },
63
+ "sideEffects": false,
64
+ "engines": {
65
+ "node": ">=18.0.0"
66
+ },
67
+ "scripts": {
68
+ "typecheck": "tsc --noEmit",
69
+ "build": "tsup --config ./tsup.config.ts",
70
+ "lint": "eslint lib --ext .ts",
71
+ "format": "prettier --config ./.prettierrc --ignore-path .gitignore -w .",
72
+ "test": "vitest run",
73
+ "changeset": "changeset",
74
+ "prerelease": "npm run build && npm run test",
75
+ "release": "changeset publish",
76
+ "prepare": "husky"
77
+ },
78
+ "lint-staged": {
79
+ "*.{js,jsx,ts,tsx}": [
80
+ "eslint --fix",
81
+ "prettier --config ./.prettierrc.json --write"
82
+ ]
83
+ },
84
+ "devDependencies": {
85
+ "@changesets/changelog-github": "^0.5.0",
86
+ "@changesets/cli": "^2.27.7",
87
+ "@commitlint/cli": "^18.0.0",
88
+ "@commitlint/config-conventional": "^18.0.0",
89
+ "@types/node": "^20.5.0",
90
+ "@typescript-eslint/eslint-plugin": "^6.4.1",
91
+ "@typescript-eslint/parser": "^6.4.1",
92
+ "concurrently": "^8.2.0",
93
+ "eslint": "^8.4.1",
94
+ "eslint-config-prettier": "^9.0.0",
95
+ "eslint-plugin-import": "^2.29.1",
96
+ "eslint-plugin-prettier": "^4.2.1",
97
+ "husky": "^9.1.7",
98
+ "lint-staged": "^15.0.1",
99
+ "prettier": "^2.8.8",
100
+ "tsup": "^8.0.2",
101
+ "typescript": "^5.1.6",
102
+ "vitest": "^3.1.2",
103
+ "zod": "^4.0.2"
104
+ },
105
+ "peerDependencies": {
106
+ "zod": "^3.25.0 || ^4.0.0"
107
+ }
108
+ }
gui/frontend/node_modules/zod-validation-error/v3/index.d.mts ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as zod from 'zod/v3';
2
+
3
+ interface ErrorOptions {
4
+ cause?: unknown;
5
+ }
6
+ declare class ValidationError extends Error {
7
+ name: 'ZodValidationError';
8
+ details: Array<zod.ZodIssue>;
9
+ constructor(message?: string, options?: ErrorOptions);
10
+ toString(): string;
11
+ }
12
+
13
+ declare function isValidationError(err: unknown): err is ValidationError;
14
+
15
+ declare function isValidationErrorLike(err: unknown): err is ValidationError;
16
+
17
+ declare function isZodErrorLike(err: unknown): err is zod.ZodError;
18
+
19
+ declare const errorMap: zod.ZodErrorMap;
20
+
21
+ type NonEmptyArray<T> = [T, ...T[]];
22
+
23
+ type ZodIssue = zod.ZodIssue;
24
+ type MessageBuilder = (issues: NonEmptyArray<ZodIssue>) => string;
25
+ type CreateMessageBuilderProps = {
26
+ issueSeparator?: string;
27
+ unionSeparator?: string;
28
+ prefix?: string | null;
29
+ prefixSeparator?: string;
30
+ includePath?: boolean;
31
+ maxIssuesInMessage?: number;
32
+ };
33
+ declare function createMessageBuilder(props?: CreateMessageBuilderProps): MessageBuilder;
34
+
35
+ type ZodError = zod.ZodError;
36
+ type FromZodErrorOptions = {
37
+ messageBuilder: MessageBuilder;
38
+ } | CreateMessageBuilderProps;
39
+ declare function fromZodError(zodError: ZodError, options?: FromZodErrorOptions): ValidationError;
40
+
41
+ declare function fromError(err: unknown, options?: FromZodErrorOptions): ValidationError;
42
+
43
+ type FromZodIssueOptions = {
44
+ messageBuilder: MessageBuilder;
45
+ } | Omit<CreateMessageBuilderProps, 'maxIssuesInMessage'>;
46
+ declare function fromZodIssue(issue: ZodIssue, options?: FromZodIssueOptions): ValidationError;
47
+
48
+ declare const toValidationError: (options?: FromZodErrorOptions) => (err: unknown) => ValidationError;
49
+
50
+ export { type ErrorOptions, type FromZodErrorOptions, type FromZodIssueOptions, type MessageBuilder, type NonEmptyArray, ValidationError, type ZodError, type ZodIssue, createMessageBuilder, errorMap, fromError, fromZodError, fromZodIssue, isValidationError, isValidationErrorLike, isZodErrorLike, toValidationError };
gui/frontend/node_modules/zod-validation-error/v3/index.d.ts ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as zod from 'zod/v3';
2
+
3
+ interface ErrorOptions {
4
+ cause?: unknown;
5
+ }
6
+ declare class ValidationError extends Error {
7
+ name: 'ZodValidationError';
8
+ details: Array<zod.ZodIssue>;
9
+ constructor(message?: string, options?: ErrorOptions);
10
+ toString(): string;
11
+ }
12
+
13
+ declare function isValidationError(err: unknown): err is ValidationError;
14
+
15
+ declare function isValidationErrorLike(err: unknown): err is ValidationError;
16
+
17
+ declare function isZodErrorLike(err: unknown): err is zod.ZodError;
18
+
19
+ declare const errorMap: zod.ZodErrorMap;
20
+
21
+ type NonEmptyArray<T> = [T, ...T[]];
22
+
23
+ type ZodIssue = zod.ZodIssue;
24
+ type MessageBuilder = (issues: NonEmptyArray<ZodIssue>) => string;
25
+ type CreateMessageBuilderProps = {
26
+ issueSeparator?: string;
27
+ unionSeparator?: string;
28
+ prefix?: string | null;
29
+ prefixSeparator?: string;
30
+ includePath?: boolean;
31
+ maxIssuesInMessage?: number;
32
+ };
33
+ declare function createMessageBuilder(props?: CreateMessageBuilderProps): MessageBuilder;
34
+
35
+ type ZodError = zod.ZodError;
36
+ type FromZodErrorOptions = {
37
+ messageBuilder: MessageBuilder;
38
+ } | CreateMessageBuilderProps;
39
+ declare function fromZodError(zodError: ZodError, options?: FromZodErrorOptions): ValidationError;
40
+
41
+ declare function fromError(err: unknown, options?: FromZodErrorOptions): ValidationError;
42
+
43
+ type FromZodIssueOptions = {
44
+ messageBuilder: MessageBuilder;
45
+ } | Omit<CreateMessageBuilderProps, 'maxIssuesInMessage'>;
46
+ declare function fromZodIssue(issue: ZodIssue, options?: FromZodIssueOptions): ValidationError;
47
+
48
+ declare const toValidationError: (options?: FromZodErrorOptions) => (err: unknown) => ValidationError;
49
+
50
+ export { type ErrorOptions, type FromZodErrorOptions, type FromZodIssueOptions, type MessageBuilder, type NonEmptyArray, ValidationError, type ZodError, type ZodIssue, createMessageBuilder, errorMap, fromError, fromZodError, fromZodIssue, isValidationError, isValidationErrorLike, isZodErrorLike, toValidationError };
gui/frontend/node_modules/zod-validation-error/v3/index.js ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // lib/v3/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ ValidationError: () => ValidationError,
34
+ createMessageBuilder: () => createMessageBuilder,
35
+ errorMap: () => errorMap,
36
+ fromError: () => fromError,
37
+ fromZodError: () => fromZodError,
38
+ fromZodIssue: () => fromZodIssue,
39
+ isValidationError: () => isValidationError,
40
+ isValidationErrorLike: () => isValidationErrorLike,
41
+ isZodErrorLike: () => isZodErrorLike,
42
+ toValidationError: () => toValidationError
43
+ });
44
+ module.exports = __toCommonJS(index_exports);
45
+
46
+ // lib/v3/isZodErrorLike.ts
47
+ function isZodErrorLike(err) {
48
+ return err instanceof Error && err.name === "ZodError" && "issues" in err && Array.isArray(err.issues);
49
+ }
50
+
51
+ // lib/v3/ValidationError.ts
52
+ var ValidationError = class extends Error {
53
+ name;
54
+ details;
55
+ constructor(message, options) {
56
+ super(message, options);
57
+ this.name = "ZodValidationError";
58
+ this.details = getIssuesFromErrorOptions(options);
59
+ }
60
+ toString() {
61
+ return this.message;
62
+ }
63
+ };
64
+ function getIssuesFromErrorOptions(options) {
65
+ if (options) {
66
+ const cause = options.cause;
67
+ if (isZodErrorLike(cause)) {
68
+ return cause.issues;
69
+ }
70
+ }
71
+ return [];
72
+ }
73
+
74
+ // lib/v3/isValidationError.ts
75
+ function isValidationError(err) {
76
+ return err instanceof ValidationError;
77
+ }
78
+
79
+ // lib/v3/isValidationErrorLike.ts
80
+ function isValidationErrorLike(err) {
81
+ return err instanceof Error && err.name === "ZodValidationError";
82
+ }
83
+
84
+ // lib/v3/fromZodIssue.ts
85
+ var zod2 = __toESM(require("zod/v3"));
86
+
87
+ // lib/v3/MessageBuilder.ts
88
+ var zod = __toESM(require("zod/v3"));
89
+
90
+ // lib/utils/NonEmptyArray.ts
91
+ function isNonEmptyArray(value) {
92
+ return value.length !== 0;
93
+ }
94
+
95
+ // lib/utils/stringify.ts
96
+ function stringifySymbol(symbol) {
97
+ return symbol.description ?? "";
98
+ }
99
+
100
+ // lib/utils/joinPath.ts
101
+ var identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u;
102
+ function joinPath(path) {
103
+ if (path.length === 1) {
104
+ let propertyKey = path[0];
105
+ if (typeof propertyKey === "symbol") {
106
+ propertyKey = stringifySymbol(propertyKey);
107
+ }
108
+ return propertyKey.toString() || '""';
109
+ }
110
+ return path.reduce((acc, propertyKey) => {
111
+ if (typeof propertyKey === "number") {
112
+ return acc + "[" + propertyKey.toString() + "]";
113
+ }
114
+ if (typeof propertyKey === "symbol") {
115
+ propertyKey = stringifySymbol(propertyKey);
116
+ }
117
+ if (propertyKey.includes('"')) {
118
+ return acc + '["' + escapeQuotes(propertyKey) + '"]';
119
+ }
120
+ if (!identifierRegex.test(propertyKey)) {
121
+ return acc + '["' + propertyKey + '"]';
122
+ }
123
+ const separator = acc.length === 0 ? "" : ".";
124
+ return acc + separator + propertyKey;
125
+ }, "");
126
+ }
127
+ function escapeQuotes(str) {
128
+ return str.replace(/"/g, '\\"');
129
+ }
130
+
131
+ // lib/v3/config.ts
132
+ var ISSUE_SEPARATOR = "; ";
133
+ var MAX_ISSUES_IN_MESSAGE = 99;
134
+ var PREFIX = "Validation error";
135
+ var PREFIX_SEPARATOR = ": ";
136
+ var UNION_SEPARATOR = ", or ";
137
+
138
+ // lib/v3/MessageBuilder.ts
139
+ function createMessageBuilder(props = {}) {
140
+ const {
141
+ issueSeparator = ISSUE_SEPARATOR,
142
+ unionSeparator = UNION_SEPARATOR,
143
+ prefixSeparator = PREFIX_SEPARATOR,
144
+ prefix = PREFIX,
145
+ includePath = true,
146
+ maxIssuesInMessage = MAX_ISSUES_IN_MESSAGE
147
+ } = props;
148
+ return (issues) => {
149
+ const message = issues.slice(0, maxIssuesInMessage).map(
150
+ (issue) => getMessageFromZodIssue({
151
+ issue,
152
+ issueSeparator,
153
+ unionSeparator,
154
+ includePath
155
+ })
156
+ ).join(issueSeparator);
157
+ return prefixMessage(message, prefix, prefixSeparator);
158
+ };
159
+ }
160
+ function getMessageFromZodIssue(props) {
161
+ const { issue, issueSeparator, unionSeparator, includePath } = props;
162
+ if (issue.code === zod.ZodIssueCode.invalid_union) {
163
+ return issue.unionErrors.reduce((acc, zodError) => {
164
+ const newIssues = zodError.issues.map(
165
+ (issue2) => getMessageFromZodIssue({
166
+ issue: issue2,
167
+ issueSeparator,
168
+ unionSeparator,
169
+ includePath
170
+ })
171
+ ).join(issueSeparator);
172
+ if (!acc.includes(newIssues)) {
173
+ acc.push(newIssues);
174
+ }
175
+ return acc;
176
+ }, []).join(unionSeparator);
177
+ }
178
+ if (issue.code === zod.ZodIssueCode.invalid_arguments) {
179
+ return [
180
+ issue.message,
181
+ ...issue.argumentsError.issues.map(
182
+ (issue2) => getMessageFromZodIssue({
183
+ issue: issue2,
184
+ issueSeparator,
185
+ unionSeparator,
186
+ includePath
187
+ })
188
+ )
189
+ ].join(issueSeparator);
190
+ }
191
+ if (issue.code === zod.ZodIssueCode.invalid_return_type) {
192
+ return [
193
+ issue.message,
194
+ ...issue.returnTypeError.issues.map(
195
+ (issue2) => getMessageFromZodIssue({
196
+ issue: issue2,
197
+ issueSeparator,
198
+ unionSeparator,
199
+ includePath
200
+ })
201
+ )
202
+ ].join(issueSeparator);
203
+ }
204
+ if (includePath && isNonEmptyArray(issue.path)) {
205
+ if (issue.path.length === 1) {
206
+ const identifier = issue.path[0];
207
+ if (typeof identifier === "number") {
208
+ return `${issue.message} at index ${identifier}`;
209
+ }
210
+ }
211
+ return `${issue.message} at "${joinPath(issue.path)}"`;
212
+ }
213
+ return issue.message;
214
+ }
215
+ function prefixMessage(message, prefix, prefixSeparator) {
216
+ if (prefix !== null) {
217
+ if (message.length > 0) {
218
+ return [prefix, message].join(prefixSeparator);
219
+ }
220
+ return prefix;
221
+ }
222
+ if (message.length > 0) {
223
+ return message;
224
+ }
225
+ return PREFIX;
226
+ }
227
+
228
+ // lib/v3/fromZodIssue.ts
229
+ function fromZodIssue(issue, options = {}) {
230
+ const messageBuilder = createMessageBuilderFromOptions(options);
231
+ const message = messageBuilder([issue]);
232
+ return new ValidationError(message, { cause: new zod2.ZodError([issue]) });
233
+ }
234
+ function createMessageBuilderFromOptions(options) {
235
+ if ("messageBuilder" in options) {
236
+ return options.messageBuilder;
237
+ }
238
+ return createMessageBuilder(options);
239
+ }
240
+
241
+ // lib/v3/errorMap.ts
242
+ var errorMap = (issue, ctx) => {
243
+ const error = fromZodIssue({
244
+ ...issue,
245
+ // fallback to the default error message
246
+ // when issue does not have a message
247
+ message: issue.message ?? ctx.defaultError
248
+ });
249
+ return {
250
+ message: error.message
251
+ };
252
+ };
253
+
254
+ // lib/v3/fromZodError.ts
255
+ function fromZodError(zodError, options = {}) {
256
+ if (!isZodErrorLike(zodError)) {
257
+ throw new TypeError(
258
+ `Invalid zodError param; expected instance of ZodError. Did you mean to use the "${fromError.name}" method instead?`
259
+ );
260
+ }
261
+ return fromZodErrorWithoutRuntimeCheck(zodError, options);
262
+ }
263
+ function fromZodErrorWithoutRuntimeCheck(zodError, options = {}) {
264
+ const zodIssues = zodError.errors;
265
+ let message;
266
+ if (isNonEmptyArray(zodIssues)) {
267
+ const messageBuilder = createMessageBuilderFromOptions2(options);
268
+ message = messageBuilder(zodIssues);
269
+ } else {
270
+ message = zodError.message;
271
+ }
272
+ return new ValidationError(message, { cause: zodError });
273
+ }
274
+ function createMessageBuilderFromOptions2(options) {
275
+ if ("messageBuilder" in options) {
276
+ return options.messageBuilder;
277
+ }
278
+ return createMessageBuilder(options);
279
+ }
280
+
281
+ // lib/v3/toValidationError.ts
282
+ var toValidationError = (options = {}) => (err) => {
283
+ if (isZodErrorLike(err)) {
284
+ return fromZodErrorWithoutRuntimeCheck(err, options);
285
+ }
286
+ if (err instanceof Error) {
287
+ return new ValidationError(err.message, { cause: err });
288
+ }
289
+ return new ValidationError("Unknown error");
290
+ };
291
+
292
+ // lib/v3/fromError.ts
293
+ function fromError(err, options = {}) {
294
+ return toValidationError(options)(err);
295
+ }
296
+ // Annotate the CommonJS export names for ESM import in node:
297
+ 0 && (module.exports = {
298
+ ValidationError,
299
+ createMessageBuilder,
300
+ errorMap,
301
+ fromError,
302
+ fromZodError,
303
+ fromZodIssue,
304
+ isValidationError,
305
+ isValidationErrorLike,
306
+ isZodErrorLike,
307
+ toValidationError
308
+ });
309
+ //# sourceMappingURL=index.js.map
gui/frontend/node_modules/zod-validation-error/v3/index.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["../lib/v3/index.ts","../lib/v3/isZodErrorLike.ts","../lib/v3/ValidationError.ts","../lib/v3/isValidationError.ts","../lib/v3/isValidationErrorLike.ts","../lib/v3/fromZodIssue.ts","../lib/v3/MessageBuilder.ts","../lib/utils/NonEmptyArray.ts","../lib/utils/stringify.ts","../lib/utils/joinPath.ts","../lib/v3/config.ts","../lib/v3/errorMap.ts","../lib/v3/fromZodError.ts","../lib/v3/toValidationError.ts","../lib/v3/fromError.ts"],"sourcesContent":["export { ValidationError, type ErrorOptions } from './ValidationError.ts';\nexport { isValidationError } from './isValidationError.ts';\nexport { isValidationErrorLike } from './isValidationErrorLike.ts';\nexport { isZodErrorLike } from './isZodErrorLike.ts';\nexport { errorMap } from './errorMap.ts';\nexport { fromError } from './fromError.ts';\nexport { fromZodIssue, type FromZodIssueOptions } from './fromZodIssue.ts';\nexport {\n fromZodError,\n type FromZodErrorOptions,\n type ZodError,\n} from './fromZodError.ts';\nexport { toValidationError } from './toValidationError.ts';\nexport {\n type MessageBuilder,\n type ZodIssue,\n createMessageBuilder,\n} from './MessageBuilder.ts';\nexport { type NonEmptyArray } from '../utils/NonEmptyArray.ts';\n","import type * as zod from 'zod/v3';\n\nexport function isZodErrorLike(err: unknown): err is zod.ZodError {\n return (\n err instanceof Error &&\n err.name === 'ZodError' &&\n 'issues' in err &&\n Array.isArray(err.issues)\n );\n}\n","import { isZodErrorLike } from './isZodErrorLike.ts';\nimport type * as zod from 'zod/v3';\n\n// make zod-validation-error compatible with\n// earlier to es2022 typescript configurations\n// @see https://github.com/causaly/zod-validation-error/issues/226\nexport interface ErrorOptions {\n cause?: unknown;\n}\n\nexport class ValidationError extends Error {\n name: 'ZodValidationError';\n details: Array<zod.ZodIssue>;\n\n constructor(message?: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'ZodValidationError';\n this.details = getIssuesFromErrorOptions(options);\n }\n\n toString(): string {\n return this.message;\n }\n}\n\nfunction getIssuesFromErrorOptions(\n options?: ErrorOptions\n): Array<zod.ZodIssue> {\n if (options) {\n const cause = options.cause;\n\n if (isZodErrorLike(cause)) {\n return cause.issues;\n }\n }\n\n return [];\n}\n","import { ValidationError } from './ValidationError.ts';\n\nexport function isValidationError(err: unknown): err is ValidationError {\n return err instanceof ValidationError;\n}\n","import type { ValidationError } from './ValidationError.ts';\n\nexport function isValidationErrorLike(err: unknown): err is ValidationError {\n return err instanceof Error && err.name === 'ZodValidationError';\n}\n","import * as zod from 'zod/v3';\n\nimport {\n type MessageBuilder,\n type CreateMessageBuilderProps,\n type ZodIssue,\n createMessageBuilder,\n} from './MessageBuilder.ts';\nimport { ValidationError } from './ValidationError.ts';\n\nexport type FromZodIssueOptions =\n | {\n messageBuilder: MessageBuilder;\n }\n // maintain backwards compatibility\n | Omit<CreateMessageBuilderProps, 'maxIssuesInMessage'>;\n\nexport function fromZodIssue(\n issue: ZodIssue,\n options: FromZodIssueOptions = {}\n): ValidationError {\n const messageBuilder = createMessageBuilderFromOptions(options);\n const message = messageBuilder([issue]);\n\n return new ValidationError(message, { cause: new zod.ZodError([issue]) });\n}\n\nfunction createMessageBuilderFromOptions(\n options: FromZodIssueOptions\n): MessageBuilder {\n if ('messageBuilder' in options) {\n return options.messageBuilder;\n }\n\n return createMessageBuilder(options);\n}\n","import * as zod from 'zod/v3';\nimport { type NonEmptyArray, isNonEmptyArray } from '../utils/NonEmptyArray.ts';\nimport { joinPath } from '../utils/joinPath.ts';\nimport {\n ISSUE_SEPARATOR,\n MAX_ISSUES_IN_MESSAGE,\n PREFIX,\n PREFIX_SEPARATOR,\n UNION_SEPARATOR,\n} from './config.ts';\n\nexport type ZodIssue = zod.ZodIssue;\n\nexport type MessageBuilder = (issues: NonEmptyArray<ZodIssue>) => string;\n\nexport type CreateMessageBuilderProps = {\n issueSeparator?: string;\n unionSeparator?: string;\n prefix?: string | null;\n prefixSeparator?: string;\n includePath?: boolean;\n maxIssuesInMessage?: number;\n};\n\nexport function createMessageBuilder(\n props: CreateMessageBuilderProps = {}\n): MessageBuilder {\n const {\n issueSeparator = ISSUE_SEPARATOR,\n unionSeparator = UNION_SEPARATOR,\n prefixSeparator = PREFIX_SEPARATOR,\n prefix = PREFIX,\n includePath = true,\n maxIssuesInMessage = MAX_ISSUES_IN_MESSAGE,\n } = props;\n return (issues) => {\n const message = issues\n // limit max number of issues printed in the reason section\n .slice(0, maxIssuesInMessage)\n // format error message\n .map((issue) =>\n getMessageFromZodIssue({\n issue,\n issueSeparator,\n unionSeparator,\n includePath,\n })\n )\n // concat as string\n .join(issueSeparator);\n\n return prefixMessage(message, prefix, prefixSeparator);\n };\n}\n\nfunction getMessageFromZodIssue(props: {\n issue: ZodIssue;\n issueSeparator: string;\n unionSeparator: string;\n includePath: boolean;\n}): string {\n const { issue, issueSeparator, unionSeparator, includePath } = props;\n\n if (issue.code === zod.ZodIssueCode.invalid_union) {\n return issue.unionErrors\n .reduce<string[]>((acc, zodError) => {\n const newIssues = zodError.issues\n .map((issue) =>\n getMessageFromZodIssue({\n issue,\n issueSeparator,\n unionSeparator,\n includePath,\n })\n )\n .join(issueSeparator);\n\n if (!acc.includes(newIssues)) {\n acc.push(newIssues);\n }\n\n return acc;\n }, [])\n .join(unionSeparator);\n }\n\n if (issue.code === zod.ZodIssueCode.invalid_arguments) {\n return [\n issue.message,\n ...issue.argumentsError.issues.map((issue) =>\n getMessageFromZodIssue({\n issue,\n issueSeparator,\n unionSeparator,\n includePath,\n })\n ),\n ].join(issueSeparator);\n }\n\n if (issue.code === zod.ZodIssueCode.invalid_return_type) {\n return [\n issue.message,\n ...issue.returnTypeError.issues.map((issue) =>\n getMessageFromZodIssue({\n issue,\n issueSeparator,\n unionSeparator,\n includePath,\n })\n ),\n ].join(issueSeparator);\n }\n\n if (includePath && isNonEmptyArray(issue.path)) {\n // handle array indices\n if (issue.path.length === 1) {\n const identifier = issue.path[0];\n\n if (typeof identifier === 'number') {\n return `${issue.message} at index ${identifier}`;\n }\n }\n\n return `${issue.message} at \"${joinPath(issue.path)}\"`;\n }\n\n return issue.message;\n}\n\nfunction prefixMessage(\n message: string,\n prefix: string | null,\n prefixSeparator: string\n): string {\n if (prefix !== null) {\n if (message.length > 0) {\n return [prefix, message].join(prefixSeparator);\n }\n\n return prefix;\n }\n\n if (message.length > 0) {\n return message;\n }\n\n // if both reason and prefix are empty, return default prefix\n // to avoid having an empty error message\n return PREFIX;\n}\n","export type NonEmptyArray<T> = [T, ...T[]];\n\nexport function isNonEmptyArray<T>(value: T[]): value is NonEmptyArray<T> {\n return value.length !== 0;\n}\n","import type { util } from 'zod/v4/core';\n\nexport function stringifySymbol(symbol: symbol): string {\n return symbol.description ?? '';\n}\n\nexport type StringifyValueOptions = {\n wrapStringValueInQuote?: boolean;\n localization?: boolean | Intl.LocalesArgument;\n};\n\nexport function stringify(\n value: util.Primitive | Date,\n options: StringifyValueOptions = {}\n): string {\n switch (typeof value) {\n case 'symbol':\n return stringifySymbol(value);\n case 'bigint':\n case 'number': {\n switch (options.localization) {\n case true:\n return value.toLocaleString();\n case false:\n return value.toString();\n default:\n return value.toLocaleString(options.localization);\n }\n }\n case 'string': {\n if (options.wrapStringValueInQuote) {\n return `\"${value}\"`;\n }\n return value;\n }\n default: {\n if (value instanceof Date) {\n switch (options.localization) {\n case true:\n return value.toLocaleString();\n case false:\n return value.toISOString();\n default:\n return value.toLocaleString(options.localization);\n }\n }\n return String(value);\n }\n }\n}\n","import { stringifySymbol } from './stringify.ts';\nimport type { NonEmptyArray } from './NonEmptyArray.ts';\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers\n */\nconst identifierRegex = /[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*/u;\n\nexport function joinPath(path: NonEmptyArray<PropertyKey>): string {\n if (path.length === 1) {\n let propertyKey = path[0];\n\n if (typeof propertyKey === 'symbol') {\n propertyKey = stringifySymbol(propertyKey);\n }\n\n return propertyKey.toString() || '\"\"';\n }\n\n return path.reduce<string>((acc, propertyKey) => {\n // handle numeric indices\n if (typeof propertyKey === 'number') {\n return acc + '[' + propertyKey.toString() + ']';\n }\n\n // handle symbols\n if (typeof propertyKey === 'symbol') {\n propertyKey = stringifySymbol(propertyKey);\n }\n\n // handle quoted values\n if (propertyKey.includes('\"')) {\n return acc + '[\"' + escapeQuotes(propertyKey) + '\"]';\n }\n\n // handle special characters\n if (!identifierRegex.test(propertyKey)) {\n return acc + '[\"' + propertyKey + '\"]';\n }\n\n // handle normal values\n const separator = acc.length === 0 ? '' : '.';\n return acc + separator + propertyKey;\n }, '');\n}\n\nfunction escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"');\n}\n","export const ISSUE_SEPARATOR = '; ';\nexport const MAX_ISSUES_IN_MESSAGE = 99; // I've got 99 problems but the b$tch ain't one\nexport const PREFIX = 'Validation error';\nexport const PREFIX_SEPARATOR = ': ';\nexport const UNION_SEPARATOR = ', or ';\n","import { fromZodIssue } from './fromZodIssue.ts';\nimport type * as zod from 'zod/v3';\n\nexport const errorMap: zod.ZodErrorMap = (issue, ctx) => {\n const error = fromZodIssue({\n ...issue,\n // fallback to the default error message\n // when issue does not have a message\n message: issue.message ?? ctx.defaultError,\n });\n\n return {\n message: error.message,\n };\n};\n","import { isNonEmptyArray } from '../utils/NonEmptyArray.ts';\nimport { fromError } from './fromError.ts';\nimport { isZodErrorLike } from './isZodErrorLike.ts';\nimport {\n createMessageBuilder,\n type CreateMessageBuilderProps,\n type MessageBuilder,\n} from './MessageBuilder.ts';\nimport { ValidationError } from './ValidationError.ts';\nimport type * as zod from 'zod/v3';\n\nexport type ZodError = zod.ZodError;\n\nexport type FromZodErrorOptions =\n | {\n messageBuilder: MessageBuilder;\n }\n // maintain backwards compatibility\n | CreateMessageBuilderProps;\n\nexport function fromZodError(\n zodError: ZodError,\n options: FromZodErrorOptions = {}\n): ValidationError {\n // perform runtime check to ensure the input is a ZodError\n // why? because people have been historically using this function incorrectly\n if (!isZodErrorLike(zodError)) {\n throw new TypeError(\n `Invalid zodError param; expected instance of ZodError. Did you mean to use the \"${fromError.name}\" method instead?`\n );\n }\n\n return fromZodErrorWithoutRuntimeCheck(zodError, options);\n}\n\nexport function fromZodErrorWithoutRuntimeCheck(\n zodError: ZodError,\n options: FromZodErrorOptions = {}\n): ValidationError {\n const zodIssues = zodError.errors;\n\n let message: string;\n if (isNonEmptyArray(zodIssues)) {\n const messageBuilder = createMessageBuilderFromOptions(options);\n message = messageBuilder(zodIssues);\n } else {\n message = zodError.message;\n }\n\n return new ValidationError(message, { cause: zodError });\n}\n\nfunction createMessageBuilderFromOptions(\n options: FromZodErrorOptions\n): MessageBuilder {\n if ('messageBuilder' in options) {\n return options.messageBuilder;\n }\n\n return createMessageBuilder(options);\n}\n","import { ValidationError } from './ValidationError.ts';\nimport { isZodErrorLike } from './isZodErrorLike.ts';\nimport {\n fromZodErrorWithoutRuntimeCheck,\n type FromZodErrorOptions,\n} from './fromZodError.ts';\n\nexport const toValidationError =\n (options: FromZodErrorOptions = {}) =>\n (err: unknown): ValidationError => {\n if (isZodErrorLike(err)) {\n return fromZodErrorWithoutRuntimeCheck(err, options);\n }\n\n if (err instanceof Error) {\n return new ValidationError(err.message, { cause: err });\n }\n\n return new ValidationError('Unknown error');\n };\n","import { toValidationError } from './toValidationError.ts';\nimport type { FromZodErrorOptions } from './fromZodError.ts';\nimport type { ValidationError } from './ValidationError.ts';\n\n/**\n * This function is a non-curried version of `toValidationError`\n */\nexport function fromError(\n err: unknown,\n options: FromZodErrorOptions = {}\n): ValidationError {\n return toValidationError(options)(err);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,SAAS,eAAe,KAAmC;AAChE,SACE,eAAe,SACf,IAAI,SAAS,cACb,YAAY,OACZ,MAAM,QAAQ,IAAI,MAAM;AAE5B;;;ACCO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EAEA,YAAY,SAAkB,SAAwB;AACpD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,UAAU,0BAA0B,OAAO;AAAA,EAClD;AAAA,EAEA,WAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AACF;AAEA,SAAS,0BACP,SACqB;AACrB,MAAI,SAAS;AACX,UAAM,QAAQ,QAAQ;AAEtB,QAAI,eAAe,KAAK,GAAG;AACzB,aAAO,MAAM;AAAA,IACf;AAAA,EACF;AAEA,SAAO,CAAC;AACV;;;ACnCO,SAAS,kBAAkB,KAAsC;AACtE,SAAO,eAAe;AACxB;;;ACFO,SAAS,sBAAsB,KAAsC;AAC1E,SAAO,eAAe,SAAS,IAAI,SAAS;AAC9C;;;ACJA,IAAAA,OAAqB;;;ACArB,UAAqB;;;ACEd,SAAS,gBAAmB,OAAuC;AACxE,SAAO,MAAM,WAAW;AAC1B;;;ACFO,SAAS,gBAAgB,QAAwB;AACtD,SAAO,OAAO,eAAe;AAC/B;;;ACEA,IAAM,kBAAkB;AAEjB,SAAS,SAAS,MAA0C;AACjE,MAAI,KAAK,WAAW,GAAG;AACrB,QAAI,cAAc,KAAK,CAAC;AAExB,QAAI,OAAO,gBAAgB,UAAU;AACnC,oBAAc,gBAAgB,WAAW;AAAA,IAC3C;AAEA,WAAO,YAAY,SAAS,KAAK;AAAA,EACnC;AAEA,SAAO,KAAK,OA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,QAAQ;AAAA,EACjB;AAEA,SAAO,qBAAqB,OAAO;AACrC;;;ACrDO,IAAM,oBACX,CAAC,UAA+B,CAAC,MACjC,CAAC,QAAkC;AACjC,MAAI,eAAe,GAAG,GAAG;AACvB,WAAO,gCAAgC,KAAK,OAAO;AAAA,EACrD;AAEA,MAAI,eAAe,OAAO;AACxB,WAAO,IAAI,gBAAgB,IAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,EACxD;AAEA,SAAO,IAAI,gBAAgB,eAAe;AAC5C;;;ACZK,SAAS,UACd,KACA,UAA+B,CAAC,GACf;AACjB,SAAO,kBAAkB,OAAO,EAAE,GAAG;AACvC;","names":["zod","issue","createMessageBuilderFromOptions"]}
gui/frontend/node_modules/zod-validation-error/v3/index.mjs ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // lib/v3/isZodErrorLike.ts
2
+ function isZodErrorLike(err) {
3
+ return err instanceof Error && err.name === "ZodError" && "issues" in err && Array.isArray(err.issues);
4
+ }
5
+
6
+ // lib/v3/ValidationError.ts
7
+ var ValidationError = class extends Error {
8
+ name;
9
+ details;
10
+ constructor(message, options) {
11
+ super(message, options);
12
+ this.name = "ZodValidationError";
13
+ this.details = getIssuesFromErrorOptions(options);
14
+ }
15
+ toString() {
16
+ return this.message;
17
+ }
18
+ };
19
+ function getIssuesFromErrorOptions(options) {
20
+ if (options) {
21
+ const cause = options.cause;
22
+ if (isZodErrorLike(cause)) {
23
+ return cause.issues;
24
+ }
25
+ }
26
+ return [];
27
+ }
28
+
29
+ // lib/v3/isValidationError.ts
30
+ function isValidationError(err) {
31
+ return err instanceof ValidationError;
32
+ }
33
+
34
+ // lib/v3/isValidationErrorLike.ts
35
+ function isValidationErrorLike(err) {
36
+ return err instanceof Error && err.name === "ZodValidationError";
37
+ }
38
+
39
+ // lib/v3/fromZodIssue.ts
40
+ import * as zod2 from "zod/v3";
41
+
42
+ // lib/v3/MessageBuilder.ts
43
+ import * as zod from "zod/v3";
44
+
45
+ // lib/utils/NonEmptyArray.ts
46
+ function isNonEmptyArray(value) {
47
+ return value.length !== 0;
48
+ }
49
+
50
+ // lib/utils/stringify.ts
51
+ function stringifySymbol(symbol) {
52
+ return symbol.description ?? "";
53
+ }
54
+
55
+ // lib/utils/joinPath.ts
56
+ var identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u;
57
+ function joinPath(path) {
58
+ if (path.length === 1) {
59
+ let propertyKey = path[0];
60
+ if (typeof propertyKey === "symbol") {
61
+ propertyKey = stringifySymbol(propertyKey);
62
+ }
63
+ return propertyKey.toString() || '""';
64
+ }
65
+ return path.reduce((acc, propertyKey) => {
66
+ if (typeof propertyKey === "number") {
67
+ return acc + "[" + propertyKey.toString() + "]";
68
+ }
69
+ if (typeof propertyKey === "symbol") {
70
+ propertyKey = stringifySymbol(propertyKey);
71
+ }
72
+ if (propertyKey.includes('"')) {
73
+ return acc + '["' + escapeQuotes(propertyKey) + '"]';
74
+ }
75
+ if (!identifierRegex.test(propertyKey)) {
76
+ return acc + '["' + propertyKey + '"]';
77
+ }
78
+ const separator = acc.length === 0 ? "" : ".";
79
+ return acc + separator + propertyKey;
80
+ }, "");
81
+ }
82
+ function escapeQuotes(str) {
83
+ return str.replace(/"/g, '\\"');
84
+ }
85
+
86
+ // lib/v3/config.ts
87
+ var ISSUE_SEPARATOR = "; ";
88
+ var MAX_ISSUES_IN_MESSAGE = 99;
89
+ var PREFIX = "Validation error";
90
+ var PREFIX_SEPARATOR = ": ";
91
+ var UNION_SEPARATOR = ", or ";
92
+
93
+ // lib/v3/MessageBuilder.ts
94
+ function createMessageBuilder(props = {}) {
95
+ const {
96
+ issueSeparator = ISSUE_SEPARATOR,
97
+ unionSeparator = UNION_SEPARATOR,
98
+ prefixSeparator = PREFIX_SEPARATOR,
99
+ prefix = PREFIX,
100
+ includePath = true,
101
+ maxIssuesInMessage = MAX_ISSUES_IN_MESSAGE
102
+ } = props;
103
+ return (issues) => {
104
+ const message = issues.slice(0, maxIssuesInMessage).map(
105
+ (issue) => getMessageFromZodIssue({
106
+ issue,
107
+ issueSeparator,
108
+ unionSeparator,
109
+ includePath
110
+ })
111
+ ).join(issueSeparator);
112
+ return prefixMessage(message, prefix, prefixSeparator);
113
+ };
114
+ }
115
+ function getMessageFromZodIssue(props) {
116
+ const { issue, issueSeparator, unionSeparator, includePath } = props;
117
+ if (issue.code === zod.ZodIssueCode.invalid_union) {
118
+ return issue.unionErrors.reduce((acc, zodError) => {
119
+ const newIssues = zodError.issues.map(
120
+ (issue2) => getMessageFromZodIssue({
121
+ issue: issue2,
122
+ issueSeparator,
123
+ unionSeparator,
124
+ includePath
125
+ })
126
+ ).join(issueSeparator);
127
+ if (!acc.includes(newIssues)) {
128
+ acc.push(newIssues);
129
+ }
130
+ return acc;
131
+ }, []).join(unionSeparator);
132
+ }
133
+ if (issue.code === zod.ZodIssueCode.invalid_arguments) {
134
+ return [
135
+ issue.message,
136
+ ...issue.argumentsError.issues.map(
137
+ (issue2) => getMessageFromZodIssue({
138
+ issue: issue2,
139
+ issueSeparator,
140
+ unionSeparator,
141
+ includePath
142
+ })
143
+ )
144
+ ].join(issueSeparator);
145
+ }
146
+ if (issue.code === zod.ZodIssueCode.invalid_return_type) {
147
+ return [
148
+ issue.message,
149
+ ...issue.returnTypeError.issues.map(
150
+ (issue2) => getMessageFromZodIssue({
151
+ issue: issue2,
152
+ issueSeparator,
153
+ unionSeparator,
154
+ includePath
155
+ })
156
+ )
157
+ ].join(issueSeparator);
158
+ }
159
+ if (includePath && isNonEmptyArray(issue.path)) {
160
+ if (issue.path.length === 1) {
161
+ const identifier = issue.path[0];
162
+ if (typeof identifier === "number") {
163
+ return `${issue.message} at index ${identifier}`;
164
+ }
165
+ }
166
+ return `${issue.message} at "${joinPath(issue.path)}"`;
167
+ }
168
+ return issue.message;
169
+ }
170
+ function prefixMessage(message, prefix, prefixSeparator) {
171
+ if (prefix !== null) {
172
+ if (message.length > 0) {
173
+ return [prefix, message].join(prefixSeparator);
174
+ }
175
+ return prefix;
176
+ }
177
+ if (message.length > 0) {
178
+ return message;
179
+ }
180
+ return PREFIX;
181
+ }
182
+
183
+ // lib/v3/fromZodIssue.ts
184
+ function fromZodIssue(issue, options = {}) {
185
+ const messageBuilder = createMessageBuilderFromOptions(options);
186
+ const message = messageBuilder([issue]);
187
+ return new ValidationError(message, { cause: new zod2.ZodError([issue]) });
188
+ }
189
+ function createMessageBuilderFromOptions(options) {
190
+ if ("messageBuilder" in options) {
191
+ return options.messageBuilder;
192
+ }
193
+ return createMessageBuilder(options);
194
+ }
195
+
196
+ // lib/v3/errorMap.ts
197
+ var errorMap = (issue, ctx) => {
198
+ const error = fromZodIssue({
199
+ ...issue,
200
+ // fallback to the default error message
201
+ // when issue does not have a message
202
+ message: issue.message ?? ctx.defaultError
203
+ });
204
+ return {
205
+ message: error.message
206
+ };
207
+ };
208
+
209
+ // lib/v3/fromZodError.ts
210
+ function fromZodError(zodError, options = {}) {
211
+ if (!isZodErrorLike(zodError)) {
212
+ throw new TypeError(
213
+ `Invalid zodError param; expected instance of ZodError. Did you mean to use the "${fromError.name}" method instead?`
214
+ );
215
+ }
216
+ return fromZodErrorWithoutRuntimeCheck(zodError, options);
217
+ }
218
+ function fromZodErrorWithoutRuntimeCheck(zodError, options = {}) {
219
+ const zodIssues = zodError.errors;
220
+ let message;
221
+ if (isNonEmptyArray(zodIssues)) {
222
+ const messageBuilder = createMessageBuilderFromOptions2(options);
223
+ message = messageBuilder(zodIssues);
224
+ } else {
225
+ message = zodError.message;
226
+ }
227
+ return new ValidationError(message, { cause: zodError });
228
+ }
229
+ function createMessageBuilderFromOptions2(options) {
230
+ if ("messageBuilder" in options) {
231
+ return options.messageBuilder;
232
+ }
233
+ return createMessageBuilder(options);
234
+ }
235
+
236
+ // lib/v3/toValidationError.ts
237
+ var toValidationError = (options = {}) => (err) => {
238
+ if (isZodErrorLike(err)) {
239
+ return fromZodErrorWithoutRuntimeCheck(err, options);
240
+ }
241
+ if (err instanceof Error) {
242
+ return new ValidationError(err.message, { cause: err });
243
+ }
244
+ return new ValidationError("Unknown error");
245
+ };
246
+
247
+ // lib/v3/fromError.ts
248
+ function fromError(err, options = {}) {
249
+ return toValidationError(options)(err);
250
+ }
251
+ export {
252
+ ValidationError,
253
+ createMessageBuilder,
254
+ errorMap,
255
+ fromError,
256
+ fromZodError,
257
+ fromZodIssue,
258
+ isValidationError,
259
+ isValidationErrorLike,
260
+ isZodErrorLike,
261
+ toValidationError
262
+ };
263
+ //# sourceMappingURL=index.mjs.map
gui/frontend/node_modules/zod-validation-error/v3/index.mjs.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["../lib/v3/isZodErrorLike.ts","../lib/v3/ValidationError.ts","../lib/v3/isValidationError.ts","../lib/v3/isValidationErrorLike.ts","../lib/v3/fromZodIssue.ts","../lib/v3/MessageBuilder.ts","../lib/utils/NonEmptyArray.ts","../lib/utils/stringify.ts","../lib/utils/joinPath.ts","../lib/v3/config.ts","../lib/v3/errorMap.ts","../lib/v3/fromZodError.ts","../lib/v3/toValidationError.ts","../lib/v3/fromError.ts"],"sourcesContent":["import type * as zod from 'zod/v3';\n\nexport function isZodErrorLike(err: unknown): err is zod.ZodError {\n return (\n err instanceof Error &&\n err.name === 'ZodError' &&\n 'issues' in err &&\n Array.isArray(err.issues)\n );\n}\n","import { isZodErrorLike } from './isZodErrorLike.ts';\nimport type * as zod from 'zod/v3';\n\n// make zod-validation-error compatible with\n// earlier to es2022 typescript configurations\n// @see https://github.com/causaly/zod-validation-error/issues/226\nexport interface ErrorOptions {\n cause?: unknown;\n}\n\nexport class ValidationError extends Error {\n name: 'ZodValidationError';\n details: Array<zod.ZodIssue>;\n\n constructor(message?: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'ZodValidationError';\n this.details = getIssuesFromErrorOptions(options);\n }\n\n toString(): string {\n return this.message;\n }\n}\n\nfunction getIssuesFromErrorOptions(\n options?: ErrorOptions\n): Array<zod.ZodIssue> {\n if (options) {\n const cause = options.cause;\n\n if (isZodErrorLike(cause)) {\n return cause.issues;\n }\n }\n\n return [];\n}\n","import { ValidationError } from './ValidationError.ts';\n\nexport function isValidationError(err: unknown): err is ValidationError {\n return err instanceof ValidationError;\n}\n","import type { ValidationError } from './ValidationError.ts';\n\nexport function isValidationErrorLike(err: unknown): err is ValidationError {\n return err instanceof Error && err.name === 'ZodValidationError';\n}\n","import * as zod from 'zod/v3';\n\nimport {\n type MessageBuilder,\n type CreateMessageBuilderProps,\n type ZodIssue,\n createMessageBuilder,\n} from './MessageBuilder.ts';\nimport { ValidationError } from './ValidationError.ts';\n\nexport type FromZodIssueOptions =\n | {\n messageBuilder: MessageBuilder;\n }\n // maintain backwards compatibility\n | Omit<CreateMessageBuilderProps, 'maxIssuesInMessage'>;\n\nexport function fromZodIssue(\n issue: ZodIssue,\n options: FromZodIssueOptions = {}\n): ValidationError {\n const messageBuilder = createMessageBuilderFromOptions(options);\n const message = messageBuilder([issue]);\n\n return new ValidationError(message, { cause: new zod.ZodError([issue]) });\n}\n\nfunction createMessageBuilderFromOptions(\n options: FromZodIssueOptions\n): MessageBuilder {\n if ('messageBuilder' in options) {\n return options.messageBuilder;\n }\n\n return createMessageBuilder(options);\n}\n","import * as zod from 'zod/v3';\nimport { type NonEmptyArray, isNonEmptyArray } from '../utils/NonEmptyArray.ts';\nimport { joinPath } from '../utils/joinPath.ts';\nimport {\n ISSUE_SEPARATOR,\n MAX_ISSUES_IN_MESSAGE,\n PREFIX,\n PREFIX_SEPARATOR,\n UNION_SEPARATOR,\n} from './config.ts';\n\nexport type ZodIssue = zod.ZodIssue;\n\nexport type MessageBuilder = (issues: NonEmptyArray<ZodIssue>) => string;\n\nexport type CreateMessageBuilderProps = {\n issueSeparator?: string;\n unionSeparator?: string;\n prefix?: string | null;\n prefixSeparator?: string;\n includePath?: boolean;\n maxIssuesInMessage?: number;\n};\n\nexport function createMessageBuilder(\n props: CreateMessageBuilderProps = {}\n): MessageBuilder {\n const {\n issueSeparator = ISSUE_SEPARATOR,\n unionSeparator = UNION_SEPARATOR,\n prefixSeparator = PREFIX_SEPARATOR,\n prefix = PREFIX,\n includePath = true,\n maxIssuesInMessage = MAX_ISSUES_IN_MESSAGE,\n } = props;\n return (issues) => {\n const message = issues\n // limit max number of issues printed in the reason section\n .slice(0, maxIssuesInMessage)\n // format error message\n .map((issue) =>\n getMessageFromZodIssue({\n issue,\n issueSeparator,\n unionSeparator,\n includePath,\n })\n )\n // concat as string\n .join(issueSeparator);\n\n return prefixMessage(message, prefix, prefixSeparator);\n };\n}\n\nfunction getMessageFromZodIssue(props: {\n issue: ZodIssue;\n issueSeparator: string;\n unionSeparator: string;\n includePath: boolean;\n}): string {\n const { issue, issueSeparator, unionSeparator, includePath } = props;\n\n if (issue.code === zod.ZodIssueCode.invalid_union) {\n return issue.unionErrors\n .reduce<string[]>((acc, zodError) => {\n const newIssues = zodError.issues\n .map((issue) =>\n getMessageFromZodIssue({\n issue,\n issueSeparator,\n unionSeparator,\n includePath,\n })\n )\n .join(issueSeparator);\n\n if (!acc.includes(newIssues)) {\n acc.push(newIssues);\n }\n\n return acc;\n }, [])\n .join(unionSeparator);\n }\n\n if (issue.code === zod.ZodIssueCode.invalid_arguments) {\n return [\n issue.message,\n ...issue.argumentsError.issues.map((issue) =>\n getMessageFromZodIssue({\n issue,\n issueSeparator,\n unionSeparator,\n includePath,\n })\n ),\n ].join(issueSeparator);\n }\n\n if (issue.code === zod.ZodIssueCode.invalid_return_type) {\n return [\n issue.message,\n ...issue.returnTypeError.issues.map((issue) =>\n getMessageFromZodIssue({\n issue,\n issueSeparator,\n unionSeparator,\n includePath,\n })\n ),\n ].join(issueSeparator);\n }\n\n if (includePath && isNonEmptyArray(issue.path)) {\n // handle array indices\n if (issue.path.length === 1) {\n const identifier = issue.path[0];\n\n if (typeof identifier === 'number') {\n return `${issue.message} at index ${identifier}`;\n }\n }\n\n return `${issue.message} at \"${joinPath(issue.path)}\"`;\n }\n\n return issue.message;\n}\n\nfunction prefixMessage(\n message: string,\n prefix: string | null,\n prefixSeparator: string\n): string {\n if (prefix !== null) {\n if (message.length > 0) {\n return [prefix, message].join(prefixSeparator);\n }\n\n return prefix;\n }\n\n if (message.length > 0) {\n return message;\n }\n\n // if both reason and prefix are empty, return default prefix\n // to avoid having an empty error message\n return PREFIX;\n}\n","export type NonEmptyArray<T> = [T, ...T[]];\n\nexport function isNonEmptyArray<T>(value: T[]): value is NonEmptyArray<T> {\n return value.length !== 0;\n}\n","import type { util } from 'zod/v4/core';\n\nexport function stringifySymbol(symbol: symbol): string {\n return symbol.description ?? '';\n}\n\nexport type StringifyValueOptions = {\n wrapStringValueInQuote?: boolean;\n localization?: boolean | Intl.LocalesArgument;\n};\n\nexport function stringify(\n value: util.Primitive | Date,\n options: StringifyValueOptions = {}\n): string {\n switch (typeof value) {\n case 'symbol':\n return stringifySymbol(value);\n case 'bigint':\n case 'number': {\n switch (options.localization) {\n case true:\n return value.toLocaleString();\n case false:\n return value.toString();\n default:\n return value.toLocaleString(options.localization);\n }\n }\n case 'string': {\n if (options.wrapStringValueInQuote) {\n return `\"${value}\"`;\n }\n return value;\n }\n default: {\n if (value instanceof Date) {\n switch (options.localization) {\n case true:\n return value.toLocaleString();\n case false:\n return value.toISOString();\n default:\n return value.toLocaleString(options.localization);\n }\n }\n return String(value);\n }\n }\n}\n","import { stringifySymbol } from './stringify.ts';\nimport type { NonEmptyArray } from './NonEmptyArray.ts';\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers\n */\nconst identifierRegex = /[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*/u;\n\nexport function joinPath(path: NonEmptyArray<PropertyKey>): string {\n if (path.length === 1) {\n let propertyKey = path[0];\n\n if (typeof propertyKey === 'symbol') {\n propertyKey = stringifySymbol(propertyKey);\n }\n\n return propertyKey.toString() || '\"\"';\n }\n\n return path.reduce<string>((acc, propertyKey) => {\n // handle numeric indices\n if (typeof propertyKey === 'number') {\n return acc + '[' + propertyKey.toString() + ']';\n }\n\n // handle symbols\n if (typeof propertyKey === 'symbol') {\n propertyKey = stringifySymbol(propertyKey);\n }\n\n // handle quoted values\n if (propertyKey.includes('\"')) {\n return acc + '[\"' + escapeQuotes(propertyKey) + '\"]';\n }\n\n // handle special characters\n if (!identifierRegex.test(propertyKey)) {\n return acc + '[\"' + propertyKey + '\"]';\n }\n\n // handle normal values\n const separator = acc.length === 0 ? '' : '.';\n return acc + separator + propertyKey;\n }, '');\n}\n\nfunction escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"');\n}\n","export const ISSUE_SEPARATOR = '; ';\nexport const MAX_ISSUES_IN_MESSAGE = 99; // I've got 99 problems but the b$tch ain't one\nexport const PREFIX = 'Validation error';\nexport const PREFIX_SEPARATOR = ': ';\nexport const UNION_SEPARATOR = ', or ';\n","import { fromZodIssue } from './fromZodIssue.ts';\nimport type * as zod from 'zod/v3';\n\nexport const errorMap: zod.ZodErrorMap = (issue, ctx) => {\n const error = fromZodIssue({\n ...issue,\n // fallback to the default error message\n // when issue does not have a message\n message: issue.message ?? ctx.defaultError,\n });\n\n return {\n message: error.message,\n };\n};\n","import { isNonEmptyArray } from '../utils/NonEmptyArray.ts';\nimport { fromError } from './fromError.ts';\nimport { isZodErrorLike } from './isZodErrorLike.ts';\nimport {\n createMessageBuilder,\n type CreateMessageBuilderProps,\n type MessageBuilder,\n} from './MessageBuilder.ts';\nimport { ValidationError } from './ValidationError.ts';\nimport type * as zod from 'zod/v3';\n\nexport type ZodError = zod.ZodError;\n\nexport type FromZodErrorOptions =\n | {\n messageBuilder: MessageBuilder;\n }\n // maintain backwards compatibility\n | CreateMessageBuilderProps;\n\nexport function fromZodError(\n zodError: ZodError,\n options: FromZodErrorOptions = {}\n): ValidationError {\n // perform runtime check to ensure the input is a ZodError\n // why? because people have been historically using this function incorrectly\n if (!isZodErrorLike(zodError)) {\n throw new TypeError(\n `Invalid zodError param; expected instance of ZodError. Did you mean to use the \"${fromError.name}\" method instead?`\n );\n }\n\n return fromZodErrorWithoutRuntimeCheck(zodError, options);\n}\n\nexport function fromZodErrorWithoutRuntimeCheck(\n zodError: ZodError,\n options: FromZodErrorOptions = {}\n): ValidationError {\n const zodIssues = zodError.errors;\n\n let message: string;\n if (isNonEmptyArray(zodIssues)) {\n const messageBuilder = createMessageBuilderFromOptions(options);\n message = messageBuilder(zodIssues);\n } else {\n message = zodError.message;\n }\n\n return new ValidationError(message, { cause: zodError });\n}\n\nfunction createMessageBuilderFromOptions(\n options: FromZodErrorOptions\n): MessageBuilder {\n if ('messageBuilder' in options) {\n return options.messageBuilder;\n }\n\n return createMessageBuilder(options);\n}\n","import { ValidationError } from './ValidationError.ts';\nimport { isZodErrorLike } from './isZodErrorLike.ts';\nimport {\n fromZodErrorWithoutRuntimeCheck,\n type FromZodErrorOptions,\n} from './fromZodError.ts';\n\nexport const toValidationError =\n (options: FromZodErrorOptions = {}) =>\n (err: unknown): ValidationError => {\n if (isZodErrorLike(err)) {\n return fromZodErrorWithoutRuntimeCheck(err, options);\n }\n\n if (err instanceof Error) {\n return new ValidationError(err.message, { cause: err });\n }\n\n return new ValidationError('Unknown error');\n };\n","import { toValidationError } from './toValidationError.ts';\nimport type { FromZodErrorOptions } from './fromZodError.ts';\nimport type { ValidationError } from './ValidationError.ts';\n\n/**\n * This function is a non-curried version of `toValidationError`\n */\nexport function fromError(\n err: unknown,\n options: FromZodErrorOptions = {}\n): ValidationError {\n return toValidationError(options)(err);\n}\n"],"mappings":";AAEO,SAAS,eAAe,KAAmC;AAChE,SACE,eAAe,SACf,IAAI,SAAS,cACb,YAAY,OACZ,MAAM,QAAQ,IAAI,MAAM;AAE5B;;;ACCO,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EAEA,YAAY,SAAkB,SAAwB;AACpD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,UAAU,0BAA0B,OAAO;AAAA,EAClD;AAAA,EAEA,WAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AACF;AAEA,SAAS,0BACP,SACqB;AACrB,MAAI,SAAS;AACX,UAAM,QAAQ,QAAQ;AAEtB,QAAI,eAAe,KAAK,GAAG;AACzB,aAAO,MAAM;AAAA,IACf;AAAA,EACF;AAEA,SAAO,CAAC;AACV;;;ACnCO,SAAS,kBAAkB,KAAsC;AACtE,SAAO,eAAe;AACxB;;;ACFO,SAAS,sBAAsB,KAAsC;AAC1E,SAAO,eAAe,SAAS,IAAI,SAAS;AAC9C;;;ACJA,YAAYA,UAAS;;;ACArB,YAAY,SAAS;;;ACEd,SAAS,gBAAmB,OAAuC;AACxE,SAAO,MAAM,WAAW;AAC1B;;;ACFO,SAAS,gBAAgB,QAAwB;AACtD,SAAO,OAAO,eAAe;AAC/B;;;ACEA,IAAM,kBAAkB;AAEjB,SAAS,SAAS,MAA0C;AACjE,MAAI,KAAK,WAAW,GAAG;AACrB,Q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AAO;AACL,cAAU,SAAS;AAAA,EACrB;AAEA,SAAO,IAAI,gBAAgB,SAAS,EAAE,OAAO,SAAS,CAAC;AACzD;AAEA,SAASA,iCACP,SACgB;AAChB,MAAI,oBAAoB,SAAS;AAC/B,WAAO,QAAQ;AAAA,EACjB;AAEA,SAAO,qBAAqB,OAAO;AACrC;;;ACrDO,IAAM,oBACX,CAAC,UAA+B,CAAC,MACjC,CAAC,QAAkC;AACjC,MAAI,eAAe,GAAG,GAAG;AACvB,WAAO,gCAAgC,KAAK,OAAO;AAAA,EACrD;AAEA,MAAI,eAAe,OAAO;AACxB,WAAO,IAAI,gBAAgB,IAAI,SAAS,EAAE,OAAO,IAAI,CAAC;AAAA,EACxD;AAEA,SAAO,IAAI,gBAAgB,eAAe;AAC5C;;;ACZK,SAAS,UACd,KACA,UAA+B,CAAC,GACf;AACjB,SAAO,kBAAkB,OAAO,EAAE,GAAG;AACvC;","names":["zod","issue","createMessageBuilderFromOptions"]}
gui/frontend/node_modules/zod-validation-error/v4/index.d.mts ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as zod from 'zod/v4/core';
2
+
3
+ declare const ZOD_VALIDATION_ERROR_NAME = "ZodValidationError";
4
+ interface ErrorOptions {
5
+ cause?: unknown;
6
+ }
7
+ declare class ValidationError extends Error {
8
+ name: typeof ZOD_VALIDATION_ERROR_NAME;
9
+ details: Array<zod.$ZodIssue>;
10
+ constructor(message?: string, options?: ErrorOptions);
11
+ toString(): string;
12
+ }
13
+
14
+ declare function isValidationError(err: unknown): err is ValidationError;
15
+
16
+ declare function isValidationErrorLike(err: unknown): err is ValidationError;
17
+
18
+ declare function isZodErrorLike(err: unknown): err is zod.$ZodError;
19
+
20
+ type ErrorMapOptions = {
21
+ dateLocalization: boolean | Intl.LocalesArgument;
22
+ numberLocalization: boolean | Intl.LocalesArgument;
23
+ displayInvalidFormatDetails: boolean;
24
+ allowedValuesSeparator: string;
25
+ allowedValuesLastSeparator: string | undefined;
26
+ wrapAllowedValuesInQuote: boolean;
27
+ maxAllowedValuesToDisplay: number;
28
+ unrecognizedKeysSeparator: string;
29
+ unrecognizedKeysLastSeparator: string | undefined;
30
+ wrapUnrecognizedKeysInQuote: boolean;
31
+ maxUnrecognizedKeysToDisplay: number;
32
+ };
33
+
34
+ declare function createErrorMap(partialOptions?: Partial<ErrorMapOptions>): zod.$ZodErrorMap<zod.$ZodIssue>;
35
+
36
+ type NonEmptyArray<T> = [T, ...T[]];
37
+
38
+ type ZodIssue = zod.$ZodIssue;
39
+ type MessageBuilder = (issues: NonEmptyArray<ZodIssue>) => string;
40
+ type MessageBuilderOptions = {
41
+ prefix: string | null | undefined;
42
+ prefixSeparator: string;
43
+ maxIssuesInMessage: number;
44
+ issueSeparator: string;
45
+ unionSeparator: string;
46
+ includePath: boolean;
47
+ forceTitleCase: boolean;
48
+ };
49
+ declare function createMessageBuilder(partialOptions?: Partial<MessageBuilderOptions>): MessageBuilder;
50
+
51
+ type ZodError = zod.$ZodError;
52
+ type FromZodErrorOptions = {
53
+ messageBuilder: MessageBuilder;
54
+ } | Partial<MessageBuilderOptions>;
55
+ declare function fromZodError(zodError: ZodError, options?: FromZodErrorOptions): ValidationError;
56
+
57
+ declare function fromError(err: unknown, options?: FromZodErrorOptions): ValidationError;
58
+
59
+ type FromZodIssueOptions = {
60
+ messageBuilder: MessageBuilder;
61
+ } | Partial<Omit<MessageBuilderOptions, 'maxIssuesInMessage'>>;
62
+ declare function fromZodIssue(issue: ZodIssue, options?: FromZodIssueOptions): ValidationError;
63
+
64
+ declare const toValidationError: (options?: FromZodErrorOptions) => (err: unknown) => ValidationError;
65
+
66
+ export { type ErrorMapOptions, type ErrorOptions, type FromZodErrorOptions, type FromZodIssueOptions, type MessageBuilder, type MessageBuilderOptions, type NonEmptyArray, ValidationError, type ZodError, type ZodIssue, createErrorMap, createMessageBuilder, fromError, fromZodError, fromZodIssue, isValidationError, isValidationErrorLike, isZodErrorLike, toValidationError };
gui/frontend/node_modules/zod-validation-error/v4/index.d.ts ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import * as zod from 'zod/v4/core';
2
+
3
+ declare const ZOD_VALIDATION_ERROR_NAME = "ZodValidationError";
4
+ interface ErrorOptions {
5
+ cause?: unknown;
6
+ }
7
+ declare class ValidationError extends Error {
8
+ name: typeof ZOD_VALIDATION_ERROR_NAME;
9
+ details: Array<zod.$ZodIssue>;
10
+ constructor(message?: string, options?: ErrorOptions);
11
+ toString(): string;
12
+ }
13
+
14
+ declare function isValidationError(err: unknown): err is ValidationError;
15
+
16
+ declare function isValidationErrorLike(err: unknown): err is ValidationError;
17
+
18
+ declare function isZodErrorLike(err: unknown): err is zod.$ZodError;
19
+
20
+ type ErrorMapOptions = {
21
+ dateLocalization: boolean | Intl.LocalesArgument;
22
+ numberLocalization: boolean | Intl.LocalesArgument;
23
+ displayInvalidFormatDetails: boolean;
24
+ allowedValuesSeparator: string;
25
+ allowedValuesLastSeparator: string | undefined;
26
+ wrapAllowedValuesInQuote: boolean;
27
+ maxAllowedValuesToDisplay: number;
28
+ unrecognizedKeysSeparator: string;
29
+ unrecognizedKeysLastSeparator: string | undefined;
30
+ wrapUnrecognizedKeysInQuote: boolean;
31
+ maxUnrecognizedKeysToDisplay: number;
32
+ };
33
+
34
+ declare function createErrorMap(partialOptions?: Partial<ErrorMapOptions>): zod.$ZodErrorMap<zod.$ZodIssue>;
35
+
36
+ type NonEmptyArray<T> = [T, ...T[]];
37
+
38
+ type ZodIssue = zod.$ZodIssue;
39
+ type MessageBuilder = (issues: NonEmptyArray<ZodIssue>) => string;
40
+ type MessageBuilderOptions = {
41
+ prefix: string | null | undefined;
42
+ prefixSeparator: string;
43
+ maxIssuesInMessage: number;
44
+ issueSeparator: string;
45
+ unionSeparator: string;
46
+ includePath: boolean;
47
+ forceTitleCase: boolean;
48
+ };
49
+ declare function createMessageBuilder(partialOptions?: Partial<MessageBuilderOptions>): MessageBuilder;
50
+
51
+ type ZodError = zod.$ZodError;
52
+ type FromZodErrorOptions = {
53
+ messageBuilder: MessageBuilder;
54
+ } | Partial<MessageBuilderOptions>;
55
+ declare function fromZodError(zodError: ZodError, options?: FromZodErrorOptions): ValidationError;
56
+
57
+ declare function fromError(err: unknown, options?: FromZodErrorOptions): ValidationError;
58
+
59
+ type FromZodIssueOptions = {
60
+ messageBuilder: MessageBuilder;
61
+ } | Partial<Omit<MessageBuilderOptions, 'maxIssuesInMessage'>>;
62
+ declare function fromZodIssue(issue: ZodIssue, options?: FromZodIssueOptions): ValidationError;
63
+
64
+ declare const toValidationError: (options?: FromZodErrorOptions) => (err: unknown) => ValidationError;
65
+
66
+ export { type ErrorMapOptions, type ErrorOptions, type FromZodErrorOptions, type FromZodIssueOptions, type MessageBuilder, type MessageBuilderOptions, type NonEmptyArray, ValidationError, type ZodError, type ZodIssue, createErrorMap, createMessageBuilder, fromError, fromZodError, fromZodIssue, isValidationError, isValidationErrorLike, isZodErrorLike, toValidationError };
gui/frontend/node_modules/zod-validation-error/v4/index.js ADDED
@@ -0,0 +1,725 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // lib/v4/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ ValidationError: () => ValidationError,
34
+ createErrorMap: () => createErrorMap,
35
+ createMessageBuilder: () => createMessageBuilder,
36
+ fromError: () => fromError,
37
+ fromZodError: () => fromZodError,
38
+ fromZodIssue: () => fromZodIssue,
39
+ isValidationError: () => isValidationError,
40
+ isValidationErrorLike: () => isValidationErrorLike,
41
+ isZodErrorLike: () => isZodErrorLike,
42
+ toValidationError: () => toValidationError
43
+ });
44
+ module.exports = __toCommonJS(index_exports);
45
+
46
+ // lib/v4/isZodErrorLike.ts
47
+ function isZodErrorLike(err) {
48
+ return err instanceof Object && "name" in err && (err.name === "ZodError" || err.name === "$ZodError") && "issues" in err && Array.isArray(err.issues);
49
+ }
50
+
51
+ // lib/v4/ValidationError.ts
52
+ var ZOD_VALIDATION_ERROR_NAME = "ZodValidationError";
53
+ var ValidationError = class extends Error {
54
+ name;
55
+ details;
56
+ constructor(message, options) {
57
+ super(message, options);
58
+ this.name = ZOD_VALIDATION_ERROR_NAME;
59
+ this.details = getIssuesFromErrorOptions(options);
60
+ }
61
+ toString() {
62
+ return this.message;
63
+ }
64
+ };
65
+ function getIssuesFromErrorOptions(options) {
66
+ if (options) {
67
+ const cause = options.cause;
68
+ if (isZodErrorLike(cause)) {
69
+ return cause.issues;
70
+ }
71
+ }
72
+ return [];
73
+ }
74
+
75
+ // lib/v4/isValidationError.ts
76
+ function isValidationError(err) {
77
+ return err instanceof ValidationError;
78
+ }
79
+
80
+ // lib/v4/isValidationErrorLike.ts
81
+ function isValidationErrorLike(err) {
82
+ return err instanceof Error && err.name === ZOD_VALIDATION_ERROR_NAME;
83
+ }
84
+
85
+ // lib/v4/errorMap/custom.ts
86
+ function parseCustomIssue(issue) {
87
+ return {
88
+ type: issue.code,
89
+ path: issue.path,
90
+ message: issue.message ?? "Invalid input"
91
+ };
92
+ }
93
+
94
+ // lib/v4/errorMap/invalidElement.ts
95
+ function parseInvalidElementIssue(issue) {
96
+ return {
97
+ type: issue.code,
98
+ path: issue.path,
99
+ message: `unexpected element in ${issue.origin}`
100
+ };
101
+ }
102
+
103
+ // lib/v4/errorMap/invalidKey.ts
104
+ function parseInvalidKeyIssue(issue) {
105
+ return {
106
+ type: issue.code,
107
+ path: issue.path,
108
+ message: `unexpected key in ${issue.origin}`
109
+ };
110
+ }
111
+
112
+ // lib/v4/errorMap/invalidStringFormat.ts
113
+ function parseInvalidStringFormatIssue(issue, options = {
114
+ displayInvalidFormatDetails: false
115
+ }) {
116
+ switch (issue.format) {
117
+ case "lowercase":
118
+ case "uppercase":
119
+ return {
120
+ type: issue.code,
121
+ path: issue.path,
122
+ message: `value must be in ${issue.format} format`
123
+ };
124
+ default: {
125
+ if (isZodIssueStringStartsWith(issue)) {
126
+ return parseStringStartsWith(issue);
127
+ }
128
+ if (isZodIssueStringEndsWith(issue)) {
129
+ return parseStringEndsWith(issue);
130
+ }
131
+ if (isZodIssueStringIncludes(issue)) {
132
+ return parseStringIncludes(issue);
133
+ }
134
+ if (isZodIssueStringInvalidRegex(issue)) {
135
+ return parseStringInvalidRegex(issue, options);
136
+ }
137
+ if (isZodIssueStringInvalidJWT(issue)) {
138
+ return parseStringInvalidJWT(issue, options);
139
+ }
140
+ return {
141
+ type: issue.code,
142
+ path: issue.path,
143
+ message: `invalid ${issue.format}`
144
+ };
145
+ }
146
+ }
147
+ }
148
+ function isZodIssueStringStartsWith(issue) {
149
+ return issue.format === "starts_with";
150
+ }
151
+ function parseStringStartsWith(issue) {
152
+ return {
153
+ type: issue.code,
154
+ path: issue.path,
155
+ message: `value must start with "${issue.prefix}"`
156
+ };
157
+ }
158
+ function isZodIssueStringEndsWith(issue) {
159
+ return issue.format === "ends_with";
160
+ }
161
+ function parseStringEndsWith(issue) {
162
+ return {
163
+ type: issue.code,
164
+ path: issue.path,
165
+ message: `value must end with "${issue.suffix}"`
166
+ };
167
+ }
168
+ function isZodIssueStringIncludes(issue) {
169
+ return issue.format === "includes";
170
+ }
171
+ function parseStringIncludes(issue) {
172
+ return {
173
+ type: issue.code,
174
+ path: issue.path,
175
+ message: `value must include "${issue.includes}"`
176
+ };
177
+ }
178
+ function isZodIssueStringInvalidRegex(issue) {
179
+ return issue.format === "regex";
180
+ }
181
+ function parseStringInvalidRegex(issue, options = {
182
+ displayInvalidFormatDetails: false
183
+ }) {
184
+ let message = "value must match pattern";
185
+ if (options.displayInvalidFormatDetails) {
186
+ message += ` "${issue.pattern}"`;
187
+ }
188
+ return {
189
+ type: issue.code,
190
+ path: issue.path,
191
+ message
192
+ };
193
+ }
194
+ function isZodIssueStringInvalidJWT(issue) {
195
+ return issue.format === "jwt";
196
+ }
197
+ function parseStringInvalidJWT(issue, options = {
198
+ displayInvalidFormatDetails: false
199
+ }) {
200
+ return {
201
+ type: issue.code,
202
+ path: issue.path,
203
+ message: options.displayInvalidFormatDetails && issue.algorithm ? `invalid jwt/${issue.algorithm}` : `invalid jwt`
204
+ };
205
+ }
206
+
207
+ // lib/v4/errorMap/invalidType.ts
208
+ function parseInvalidTypeIssue(issue) {
209
+ let message = `expected ${issue.expected}`;
210
+ if ("input" in issue) {
211
+ message += `, received ${getTypeName(issue.input)}`;
212
+ }
213
+ return {
214
+ type: issue.code,
215
+ path: issue.path,
216
+ message
217
+ };
218
+ }
219
+ function getTypeName(value) {
220
+ if (typeof value === "object") {
221
+ if (value === null) {
222
+ return "null";
223
+ }
224
+ if (value === void 0) {
225
+ return "undefined";
226
+ }
227
+ if (Array.isArray(value)) {
228
+ return "array";
229
+ }
230
+ if (value instanceof Date) {
231
+ return "date";
232
+ }
233
+ if (value instanceof RegExp) {
234
+ return "regexp";
235
+ }
236
+ if (value instanceof Map) {
237
+ return "map";
238
+ }
239
+ if (value instanceof Set) {
240
+ return "set";
241
+ }
242
+ if (value instanceof Error) {
243
+ return "error";
244
+ }
245
+ if (value instanceof Function) {
246
+ return "function";
247
+ }
248
+ return "object";
249
+ }
250
+ return typeof value;
251
+ }
252
+
253
+ // lib/v4/errorMap/invalidUnion.ts
254
+ function parseInvalidUnionIssue(issue) {
255
+ return {
256
+ type: issue.code,
257
+ path: issue.path,
258
+ message: issue.message ?? "Invalid input"
259
+ };
260
+ }
261
+
262
+ // lib/utils/stringify.ts
263
+ function stringifySymbol(symbol) {
264
+ return symbol.description ?? "";
265
+ }
266
+ function stringify(value, options = {}) {
267
+ switch (typeof value) {
268
+ case "symbol":
269
+ return stringifySymbol(value);
270
+ case "bigint":
271
+ case "number": {
272
+ switch (options.localization) {
273
+ case true:
274
+ return value.toLocaleString();
275
+ case false:
276
+ return value.toString();
277
+ default:
278
+ return value.toLocaleString(options.localization);
279
+ }
280
+ }
281
+ case "string": {
282
+ if (options.wrapStringValueInQuote) {
283
+ return `"${value}"`;
284
+ }
285
+ return value;
286
+ }
287
+ default: {
288
+ if (value instanceof Date) {
289
+ switch (options.localization) {
290
+ case true:
291
+ return value.toLocaleString();
292
+ case false:
293
+ return value.toISOString();
294
+ default:
295
+ return value.toLocaleString(options.localization);
296
+ }
297
+ }
298
+ return String(value);
299
+ }
300
+ }
301
+ }
302
+
303
+ // lib/utils/joinValues.ts
304
+ function joinValues(values, options) {
305
+ const valuesToDisplay = (options.maxValuesToDisplay ? values.slice(0, options.maxValuesToDisplay) : values).map((value) => {
306
+ return stringify(value, {
307
+ wrapStringValueInQuote: options.wrapStringValuesInQuote
308
+ });
309
+ });
310
+ if (valuesToDisplay.length < values.length) {
311
+ valuesToDisplay.push(
312
+ `${values.length - valuesToDisplay.length} more value(s)`
313
+ );
314
+ }
315
+ return valuesToDisplay.reduce((acc, value, index) => {
316
+ if (index > 0) {
317
+ if (index === valuesToDisplay.length - 1 && options.lastSeparator) {
318
+ acc += options.lastSeparator;
319
+ } else {
320
+ acc += options.separator;
321
+ }
322
+ }
323
+ acc += value;
324
+ return acc;
325
+ }, "");
326
+ }
327
+
328
+ // lib/v4/errorMap/invalidValue.ts
329
+ function parseInvalidValueIssue(issue, options) {
330
+ let message;
331
+ if (issue.values.length === 0) {
332
+ message = "invalid value";
333
+ } else if (issue.values.length === 1) {
334
+ const valueStr = stringify(issue.values[0], {
335
+ wrapStringValueInQuote: true
336
+ });
337
+ message = `expected value to be ${valueStr}`;
338
+ } else {
339
+ const valuesStr = joinValues(issue.values, {
340
+ separator: options.allowedValuesSeparator,
341
+ lastSeparator: options.allowedValuesLastSeparator,
342
+ wrapStringValuesInQuote: options.wrapAllowedValuesInQuote,
343
+ maxValuesToDisplay: options.maxAllowedValuesToDisplay
344
+ });
345
+ message = `expected value to be one of ${valuesStr}`;
346
+ }
347
+ return {
348
+ type: issue.code,
349
+ path: issue.path,
350
+ message
351
+ };
352
+ }
353
+
354
+ // lib/v4/errorMap/notMultipleOf.ts
355
+ function parseNotMultipleOfIssue(issue) {
356
+ return {
357
+ type: issue.code,
358
+ path: issue.path,
359
+ message: `expected multiple of ${issue.divisor}`
360
+ };
361
+ }
362
+
363
+ // lib/v4/errorMap/tooBig.ts
364
+ function parseTooBigIssue(issue, options) {
365
+ const maxValueStr = issue.origin === "date" ? stringify(new Date(issue.maximum), {
366
+ localization: options.dateLocalization
367
+ }) : stringify(issue.maximum, {
368
+ localization: options.numberLocalization
369
+ });
370
+ switch (issue.origin) {
371
+ case "number":
372
+ case "int":
373
+ case "bigint": {
374
+ return {
375
+ type: issue.code,
376
+ path: issue.path,
377
+ message: `number must be less than${issue.inclusive ? " or equal to" : ""} ${maxValueStr}`
378
+ };
379
+ }
380
+ case "string": {
381
+ return {
382
+ type: issue.code,
383
+ path: issue.path,
384
+ message: `string must contain at most ${maxValueStr} character(s)`
385
+ };
386
+ }
387
+ case "date": {
388
+ return {
389
+ type: issue.code,
390
+ path: issue.path,
391
+ message: `date must be ${issue.inclusive ? "prior or equal to" : "prior to"} "${maxValueStr}"`
392
+ };
393
+ }
394
+ case "array": {
395
+ return {
396
+ type: issue.code,
397
+ path: issue.path,
398
+ message: `array must contain at most ${maxValueStr} item(s)`
399
+ };
400
+ }
401
+ case "set": {
402
+ return {
403
+ type: issue.code,
404
+ path: issue.path,
405
+ message: `set must contain at most ${maxValueStr} item(s)`
406
+ };
407
+ }
408
+ case "file": {
409
+ return {
410
+ type: issue.code,
411
+ path: issue.path,
412
+ message: `file must not exceed ${maxValueStr} byte(s) in size`
413
+ };
414
+ }
415
+ default:
416
+ return {
417
+ type: issue.code,
418
+ path: issue.path,
419
+ message: `value must be less than${issue.inclusive ? " or equal to" : ""} ${maxValueStr}`
420
+ };
421
+ }
422
+ }
423
+
424
+ // lib/v4/errorMap/tooSmall.ts
425
+ function parseTooSmallIssue(issue, options) {
426
+ const minValueStr = issue.origin === "date" ? stringify(new Date(issue.minimum), {
427
+ localization: options.dateLocalization
428
+ }) : stringify(issue.minimum, {
429
+ localization: options.numberLocalization
430
+ });
431
+ switch (issue.origin) {
432
+ case "number":
433
+ case "int":
434
+ case "bigint": {
435
+ return {
436
+ type: issue.code,
437
+ path: issue.path,
438
+ message: `number must be greater than${issue.inclusive ? " or equal to" : ""} ${minValueStr}`
439
+ };
440
+ }
441
+ case "date": {
442
+ return {
443
+ type: issue.code,
444
+ path: issue.path,
445
+ message: `date must be ${issue.inclusive ? "later or equal to" : "later to"} "${minValueStr}"`
446
+ };
447
+ }
448
+ case "string": {
449
+ return {
450
+ type: issue.code,
451
+ path: issue.path,
452
+ message: `string must contain at least ${minValueStr} character(s)`
453
+ };
454
+ }
455
+ case "array": {
456
+ return {
457
+ type: issue.code,
458
+ path: issue.path,
459
+ message: `array must contain at least ${minValueStr} item(s)`
460
+ };
461
+ }
462
+ case "set": {
463
+ return {
464
+ type: issue.code,
465
+ path: issue.path,
466
+ message: `set must contain at least ${minValueStr} item(s)`
467
+ };
468
+ }
469
+ case "file": {
470
+ return {
471
+ type: issue.code,
472
+ path: issue.path,
473
+ message: `file must be at least ${minValueStr} byte(s) in size`
474
+ };
475
+ }
476
+ default:
477
+ return {
478
+ type: issue.code,
479
+ path: issue.path,
480
+ message: `value must be greater than${issue.inclusive ? " or equal to" : ""} ${minValueStr}`
481
+ };
482
+ }
483
+ }
484
+
485
+ // lib/v4/errorMap/unrecognizedKeys.ts
486
+ function parseUnrecognizedKeysIssue(issue, options) {
487
+ const keysStr = joinValues(issue.keys, {
488
+ separator: options.unrecognizedKeysSeparator,
489
+ lastSeparator: options.unrecognizedKeysLastSeparator,
490
+ wrapStringValuesInQuote: options.wrapUnrecognizedKeysInQuote,
491
+ maxValuesToDisplay: options.maxUnrecognizedKeysToDisplay
492
+ });
493
+ return {
494
+ type: issue.code,
495
+ path: issue.path,
496
+ message: `unrecognized key(s) ${keysStr} in object`
497
+ };
498
+ }
499
+
500
+ // lib/v4/errorMap/errorMap.ts
501
+ var issueParsers = {
502
+ invalid_type: parseInvalidTypeIssue,
503
+ too_big: parseTooBigIssue,
504
+ too_small: parseTooSmallIssue,
505
+ invalid_format: parseInvalidStringFormatIssue,
506
+ invalid_value: parseInvalidValueIssue,
507
+ invalid_element: parseInvalidElementIssue,
508
+ not_multiple_of: parseNotMultipleOfIssue,
509
+ unrecognized_keys: parseUnrecognizedKeysIssue,
510
+ invalid_key: parseInvalidKeyIssue,
511
+ custom: parseCustomIssue,
512
+ invalid_union: parseInvalidUnionIssue
513
+ };
514
+ var defaultErrorMapOptions = {
515
+ displayInvalidFormatDetails: false,
516
+ allowedValuesSeparator: ", ",
517
+ allowedValuesLastSeparator: " or ",
518
+ wrapAllowedValuesInQuote: true,
519
+ maxAllowedValuesToDisplay: 10,
520
+ unrecognizedKeysSeparator: ", ",
521
+ unrecognizedKeysLastSeparator: " and ",
522
+ wrapUnrecognizedKeysInQuote: true,
523
+ maxUnrecognizedKeysToDisplay: 5,
524
+ dateLocalization: true,
525
+ numberLocalization: true
526
+ };
527
+ function createErrorMap(partialOptions = {}) {
528
+ const options = {
529
+ ...defaultErrorMapOptions,
530
+ ...partialOptions
531
+ };
532
+ const errorMap = (issue) => {
533
+ if (issue.code === void 0) {
534
+ return "Not supported issue type";
535
+ }
536
+ const parseFunc = issueParsers[issue.code];
537
+ const ast = parseFunc(issue, options);
538
+ return ast.message;
539
+ };
540
+ return errorMap;
541
+ }
542
+
543
+ // lib/utils/NonEmptyArray.ts
544
+ function isNonEmptyArray(value) {
545
+ return value.length !== 0;
546
+ }
547
+
548
+ // lib/utils/joinPath.ts
549
+ var identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u;
550
+ function joinPath(path) {
551
+ if (path.length === 1) {
552
+ let propertyKey = path[0];
553
+ if (typeof propertyKey === "symbol") {
554
+ propertyKey = stringifySymbol(propertyKey);
555
+ }
556
+ return propertyKey.toString() || '""';
557
+ }
558
+ return path.reduce((acc, propertyKey) => {
559
+ if (typeof propertyKey === "number") {
560
+ return acc + "[" + propertyKey.toString() + "]";
561
+ }
562
+ if (typeof propertyKey === "symbol") {
563
+ propertyKey = stringifySymbol(propertyKey);
564
+ }
565
+ if (propertyKey.includes('"')) {
566
+ return acc + '["' + escapeQuotes(propertyKey) + '"]';
567
+ }
568
+ if (!identifierRegex.test(propertyKey)) {
569
+ return acc + '["' + propertyKey + '"]';
570
+ }
571
+ const separator = acc.length === 0 ? "" : ".";
572
+ return acc + separator + propertyKey;
573
+ }, "");
574
+ }
575
+ function escapeQuotes(str) {
576
+ return str.replace(/"/g, '\\"');
577
+ }
578
+
579
+ // lib/utils/titleCase.ts
580
+ function titleCase(value) {
581
+ if (value.length === 0) {
582
+ return value;
583
+ }
584
+ return value.charAt(0).toUpperCase() + value.slice(1);
585
+ }
586
+
587
+ // lib/v4/MessageBuilder.ts
588
+ var defaultMessageBuilderOptions = {
589
+ prefix: "Validation error",
590
+ prefixSeparator: ": ",
591
+ maxIssuesInMessage: 99,
592
+ // I've got 99 problems but the b$tch ain't one
593
+ unionSeparator: " or ",
594
+ issueSeparator: "; ",
595
+ includePath: true,
596
+ forceTitleCase: true
597
+ };
598
+ function createMessageBuilder(partialOptions = {}) {
599
+ const options = {
600
+ ...defaultMessageBuilderOptions,
601
+ ...partialOptions
602
+ };
603
+ return function messageBuilder(issues) {
604
+ const message = issues.slice(0, options.maxIssuesInMessage).map((issue) => mapIssue(issue, options)).join(options.issueSeparator);
605
+ return conditionallyPrefixMessage(message, options);
606
+ };
607
+ }
608
+ function mapIssue(issue, options) {
609
+ if (issue.code === "invalid_union" && isNonEmptyArray(issue.errors)) {
610
+ const individualMessages = issue.errors.map(
611
+ (issues) => issues.map(
612
+ (subIssue) => mapIssue(
613
+ {
614
+ ...subIssue,
615
+ path: issue.path.concat(subIssue.path)
616
+ },
617
+ options
618
+ )
619
+ ).join(options.issueSeparator)
620
+ );
621
+ return Array.from(new Set(individualMessages)).join(options.unionSeparator);
622
+ }
623
+ const buf = [];
624
+ if (options.forceTitleCase) {
625
+ buf.push(titleCase(issue.message));
626
+ } else {
627
+ buf.push(issue.message);
628
+ }
629
+ pathCondition: if (options.includePath && issue.path !== void 0 && isNonEmptyArray(issue.path)) {
630
+ if (issue.path.length === 1) {
631
+ const identifier = issue.path[0];
632
+ if (typeof identifier === "number") {
633
+ buf.push(` at index ${identifier}`);
634
+ break pathCondition;
635
+ }
636
+ }
637
+ buf.push(` at "${joinPath(issue.path)}"`);
638
+ }
639
+ return buf.join("");
640
+ }
641
+ function conditionallyPrefixMessage(message, options) {
642
+ if (options.prefix != null) {
643
+ if (message.length > 0) {
644
+ return [options.prefix, message].join(options.prefixSeparator);
645
+ }
646
+ return options.prefix;
647
+ }
648
+ if (message.length > 0) {
649
+ return message;
650
+ }
651
+ return defaultMessageBuilderOptions.prefix;
652
+ }
653
+
654
+ // lib/v4/fromZodError.ts
655
+ function fromZodError(zodError, options = {}) {
656
+ if (!isZodErrorLike(zodError)) {
657
+ throw new TypeError(
658
+ `Invalid zodError param; expected instance of ZodError. Did you mean to use the "${fromError.name}" method instead?`
659
+ );
660
+ }
661
+ return fromZodErrorWithoutRuntimeCheck(zodError, options);
662
+ }
663
+ function fromZodErrorWithoutRuntimeCheck(zodError, options = {}) {
664
+ const zodIssues = zodError.issues;
665
+ let message;
666
+ if (isNonEmptyArray(zodIssues)) {
667
+ const messageBuilder = createMessageBuilderFromOptions(options);
668
+ message = messageBuilder(zodIssues);
669
+ } else {
670
+ message = zodError.message;
671
+ }
672
+ return new ValidationError(message, { cause: zodError });
673
+ }
674
+ function createMessageBuilderFromOptions(options) {
675
+ if ("messageBuilder" in options) {
676
+ return options.messageBuilder;
677
+ }
678
+ return createMessageBuilder(options);
679
+ }
680
+
681
+ // lib/v4/toValidationError.ts
682
+ var toValidationError = (options = {}) => (err) => {
683
+ if (isZodErrorLike(err)) {
684
+ return fromZodErrorWithoutRuntimeCheck(err, options);
685
+ }
686
+ if (err instanceof Error) {
687
+ return new ValidationError(err.message, { cause: err });
688
+ }
689
+ return new ValidationError("Unknown error");
690
+ };
691
+
692
+ // lib/v4/fromError.ts
693
+ function fromError(err, options = {}) {
694
+ return toValidationError(options)(err);
695
+ }
696
+
697
+ // lib/v4/fromZodIssue.ts
698
+ var zod = __toESM(require("zod/v4/core"));
699
+ function fromZodIssue(issue, options = {}) {
700
+ const messageBuilder = createMessageBuilderFromOptions2(options);
701
+ const message = messageBuilder([issue]);
702
+ return new ValidationError(message, {
703
+ cause: new zod.$ZodRealError([issue])
704
+ });
705
+ }
706
+ function createMessageBuilderFromOptions2(options) {
707
+ if ("messageBuilder" in options) {
708
+ return options.messageBuilder;
709
+ }
710
+ return createMessageBuilder(options);
711
+ }
712
+ // Annotate the CommonJS export names for ESM import in node:
713
+ 0 && (module.exports = {
714
+ ValidationError,
715
+ createErrorMap,
716
+ createMessageBuilder,
717
+ fromError,
718
+ fromZodError,
719
+ fromZodIssue,
720
+ isValidationError,
721
+ isValidationErrorLike,
722
+ isZodErrorLike,
723
+ toValidationError
724
+ });
725
+ //# sourceMappingURL=index.js.map
gui/frontend/node_modules/zod-validation-error/v4/index.js.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["../lib/v4/index.ts","../lib/v4/isZodErrorLike.ts","../lib/v4/ValidationError.ts","../lib/v4/isValidationError.ts","../lib/v4/isValidationErrorLike.ts","../lib/v4/errorMap/custom.ts","../lib/v4/errorMap/invalidElement.ts","../lib/v4/errorMap/invalidKey.ts","../lib/v4/errorMap/invalidStringFormat.ts","../lib/v4/errorMap/invalidType.ts","../lib/v4/errorMap/invalidUnion.ts","../lib/utils/stringify.ts","../lib/utils/joinValues.ts","../lib/v4/errorMap/invalidValue.ts","../lib/v4/errorMap/notMultipleOf.ts","../lib/v4/errorMap/tooBig.ts","../lib/v4/errorMap/tooSmall.ts","../lib/v4/errorMap/unrecognizedKeys.ts","../lib/v4/errorMap/errorMap.ts","../lib/utils/NonEmptyArray.ts","../lib/utils/joinPath.ts","../lib/utils/titleCase.ts","../lib/v4/MessageBuilder.ts","../lib/v4/fromZodError.ts","../lib/v4/toValidationError.ts","../lib/v4/fromError.ts","../lib/v4/fromZodIssue.ts"],"sourcesContent":["export { ValidationError, type ErrorOptions } from './ValidationError.ts';\nexport { isValidationError } from './isValidationError.ts';\nexport { isValidationErrorLike } from './isValidationErrorLike.ts';\nexport { isZodErrorLike } from './isZodErrorLike.ts';\nexport { createErrorMap, type ErrorMapOptions } from './errorMap/index.ts';\nexport { fromError } from './fromError.ts';\nexport { fromZodIssue, type FromZodIssueOptions } from './fromZodIssue.ts';\nexport {\n fromZodError,\n type FromZodErrorOptions,\n type ZodError,\n} from './fromZodError.ts';\nexport { toValidationError } from './toValidationError.ts';\nexport {\n type MessageBuilder,\n type ZodIssue,\n createMessageBuilder,\n type MessageBuilderOptions,\n} from './MessageBuilder.ts';\nexport { type NonEmptyArray } from '../utils/NonEmptyArray.ts';\n","import type * as zod from 'zod/v4/core';\n\nexport function isZodErrorLike(err: unknown): err is zod.$ZodError {\n return (\n err instanceof Object &&\n 'name' in err &&\n (err.name === 'ZodError' || err.name === '$ZodError') &&\n 'issues' in err &&\n Array.isArray(err.issues)\n );\n}\n","import { isZodErrorLike } from './isZodErrorLike.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport const ZOD_VALIDATION_ERROR_NAME = 'ZodValidationError';\n\n// make zod-validation-error compatible with\n// earlier to es2022 typescript configurations\n// @see https://github.com/causaly/zod-validation-error/issues/226\nexport interface ErrorOptions {\n cause?: unknown;\n}\n\nexport class ValidationError extends Error {\n name: typeof ZOD_VALIDATION_ERROR_NAME;\n details: Array<zod.$ZodIssue>;\n\n constructor(message?: string, options?: ErrorOptions) {\n super(message, options);\n this.name = ZOD_VALIDATION_ERROR_NAME;\n this.details = getIssuesFromErrorOptions(options);\n }\n\n toString(): string {\n return this.message;\n }\n}\n\nfunction getIssuesFromErrorOptions(\n options?: ErrorOptions\n): Array<zod.$ZodIssue> {\n if (options) {\n const cause = options.cause;\n if (isZodErrorLike(cause)) {\n return cause.issues;\n }\n }\n\n return [];\n}\n","import { ValidationError } from './ValidationError.ts';\n\nexport function isValidationError(err: unknown): err is ValidationError {\n return err instanceof ValidationError;\n}\n","import {\n ZOD_VALIDATION_ERROR_NAME,\n type ValidationError,\n} from './ValidationError.ts';\n\nexport function isValidationErrorLike(err: unknown): err is ValidationError {\n return err instanceof Error && err.name === ZOD_VALIDATION_ERROR_NAME;\n}\n","import type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree } from './types.ts';\n\nexport function parseCustomIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueCustom>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: issue.message ?? 'Invalid input',\n };\n}\n","import type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree } from './types.ts';\n\nexport function parseInvalidElementIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidElement>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `unexpected element in ${issue.origin}`,\n };\n}\n","import type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree } from './types.ts';\n\nexport function parseInvalidKeyIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidKey>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `unexpected key in ${issue.origin}`,\n };\n}\n","import type { AbstractSyntaxTree, ErrorMapOptions } from './types.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport function parseInvalidStringFormatIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>,\n options: Pick<ErrorMapOptions, 'displayInvalidFormatDetails'> = {\n displayInvalidFormatDetails: false,\n }\n): AbstractSyntaxTree {\n switch (issue.format) {\n case 'lowercase':\n case 'uppercase':\n return {\n type: issue.code,\n path: issue.path,\n message: `value must be in ${issue.format} format`,\n };\n default: {\n if (isZodIssueStringStartsWith(issue)) {\n return parseStringStartsWith(issue);\n }\n if (isZodIssueStringEndsWith(issue)) {\n return parseStringEndsWith(issue);\n }\n if (isZodIssueStringIncludes(issue)) {\n return parseStringIncludes(issue);\n }\n if (isZodIssueStringInvalidRegex(issue)) {\n return parseStringInvalidRegex(issue, options);\n }\n if (isZodIssueStringInvalidJWT(issue)) {\n return parseStringInvalidJWT(issue, options);\n }\n\n return {\n type: issue.code,\n path: issue.path,\n message: `invalid ${issue.format}`,\n };\n }\n }\n}\nfunction isZodIssueStringStartsWith(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>\n): issue is zod.$ZodRawIssue<zod.$ZodIssueStringStartsWith> {\n return issue.format === 'starts_with';\n}\n\nfunction parseStringStartsWith(\n issue: zod.$ZodRawIssue<zod.$ZodIssueStringStartsWith>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `value must start with \"${issue.prefix}\"`,\n };\n}\n\nfunction isZodIssueStringEndsWith(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>\n): issue is zod.$ZodRawIssue<zod.$ZodIssueStringEndsWith> {\n return issue.format === 'ends_with';\n}\nfunction parseStringEndsWith(\n issue: zod.$ZodRawIssue<zod.$ZodIssueStringEndsWith>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `value must end with \"${issue.suffix}\"`,\n };\n}\n\nfunction isZodIssueStringIncludes(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>\n): issue is zod.$ZodRawIssue<zod.$ZodIssueStringIncludes> {\n return issue.format === 'includes';\n}\nfunction parseStringIncludes(\n issue: zod.$ZodRawIssue<zod.$ZodIssueStringIncludes>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `value must include \"${issue.includes}\"`,\n };\n}\n\nfunction isZodIssueStringInvalidRegex(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>\n): issue is zod.$ZodRawIssue<zod.$ZodIssueStringInvalidRegex> {\n return issue.format === 'regex';\n}\nfunction parseStringInvalidRegex(\n issue: zod.$ZodRawIssue<zod.$ZodIssueStringInvalidRegex>,\n options: Pick<ErrorMapOptions, 'displayInvalidFormatDetails'> = {\n displayInvalidFormatDetails: false,\n }\n): AbstractSyntaxTree {\n let message = 'value must match pattern';\n if (options.displayInvalidFormatDetails) {\n message += ` \"${issue.pattern}\"`;\n }\n\n return {\n type: issue.code,\n path: issue.path,\n message,\n };\n}\n\nfunction isZodIssueStringInvalidJWT(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>\n): issue is zod.$ZodRawIssue<zod.$ZodIssueStringInvalidJWT> {\n return issue.format === 'jwt';\n}\nfunction parseStringInvalidJWT(\n issue: zod.$ZodRawIssue<zod.$ZodIssueStringInvalidJWT>,\n options: Pick<ErrorMapOptions, 'displayInvalidFormatDetails'> = {\n displayInvalidFormatDetails: false,\n }\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message:\n options.displayInvalidFormatDetails && issue.algorithm\n ? `invalid jwt/${issue.algorithm}`\n : `invalid jwt`,\n };\n}\n","import type { AbstractSyntaxTree } from './types.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport function parseInvalidTypeIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidType>\n): AbstractSyntaxTree {\n let message = `expected ${issue.expected}`;\n\n // note: it's possible that issue.input is not defined\n if ('input' in issue) {\n message += `, received ${getTypeName(issue.input)}`;\n }\n\n return {\n type: issue.code,\n path: issue.path,\n message,\n };\n}\n\nexport function getTypeName(value: unknown): string {\n if (typeof value === 'object') {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return 'undefined';\n }\n if (Array.isArray(value)) {\n return 'array';\n }\n if (value instanceof Date) {\n return 'date';\n }\n if (value instanceof RegExp) {\n return 'regexp';\n }\n if (value instanceof Map) {\n return 'map';\n }\n if (value instanceof Set) {\n return 'set';\n }\n if (value instanceof Error) {\n return 'error';\n }\n if (value instanceof Function) {\n return 'function';\n }\n return 'object';\n }\n\n return typeof value;\n}\n","import type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree } from './types.ts';\n\nexport function parseInvalidUnionIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidUnion>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: issue.message ?? 'Invalid input',\n };\n}\n","import type { util } from 'zod/v4/core';\n\nexport function stringifySymbol(symbol: symbol): string {\n return symbol.description ?? '';\n}\n\nexport type StringifyValueOptions = {\n wrapStringValueInQuote?: boolean;\n localization?: boolean | Intl.LocalesArgument;\n};\n\nexport function stringify(\n value: util.Primitive | Date,\n options: StringifyValueOptions = {}\n): string {\n switch (typeof value) {\n case 'symbol':\n return stringifySymbol(value);\n case 'bigint':\n case 'number': {\n switch (options.localization) {\n case true:\n return value.toLocaleString();\n case false:\n return value.toString();\n default:\n return value.toLocaleString(options.localization);\n }\n }\n case 'string': {\n if (options.wrapStringValueInQuote) {\n return `\"${value}\"`;\n }\n return value;\n }\n default: {\n if (value instanceof Date) {\n switch (options.localization) {\n case true:\n return value.toLocaleString();\n case false:\n return value.toISOString();\n default:\n return value.toLocaleString(options.localization);\n }\n }\n return String(value);\n }\n }\n}\n","import { stringify } from './stringify.ts';\nimport type { util } from 'zod/v4/core';\n\nexport type JoinValuesOptions = {\n separator: string;\n lastSeparator?: string;\n wrapStringValuesInQuote?: boolean;\n maxValuesToDisplay?: number;\n};\n\nexport function joinValues(\n values: Array<util.Primitive>,\n options: JoinValuesOptions\n): string {\n const valuesToDisplay = (\n options.maxValuesToDisplay\n ? values.slice(0, options.maxValuesToDisplay)\n : values\n ).map((value) => {\n return stringify(value, {\n wrapStringValueInQuote: options.wrapStringValuesInQuote,\n });\n });\n\n // add remaining values count (if any)\n // this is to avoid displaying too many values in the error message\n // and to keep the message concise\n // e.g. `\"foo\", \"bar\", \"baz\" or 3 more value(s)`\n if (valuesToDisplay.length < values.length) {\n valuesToDisplay.push(\n `${values.length - valuesToDisplay.length} more value(s)`\n );\n }\n\n return valuesToDisplay.reduce<string>((acc, value, index) => {\n if (index > 0) {\n if (index === valuesToDisplay.length - 1 && options.lastSeparator) {\n acc += options.lastSeparator;\n } else {\n acc += options.separator;\n }\n }\n\n acc += value;\n\n return acc;\n }, '');\n}\n","import { joinValues } from '../../utils/joinValues.ts';\nimport { stringify } from '../../utils/stringify.ts';\nimport type { AbstractSyntaxTree, ErrorMapOptions } from './types.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport function parseInvalidValueIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidValue>,\n options: Pick<\n ErrorMapOptions,\n | 'allowedValuesSeparator'\n | 'maxAllowedValuesToDisplay'\n | 'wrapAllowedValuesInQuote'\n | 'allowedValuesLastSeparator'\n >\n): AbstractSyntaxTree {\n let message: string;\n\n if (issue.values.length === 0) {\n message = 'invalid value';\n } else if (issue.values.length === 1) {\n const valueStr = stringify(issue.values[0], {\n wrapStringValueInQuote: true,\n });\n message = `expected value to be ${valueStr}`;\n } else {\n const valuesStr = joinValues(issue.values, {\n separator: options.allowedValuesSeparator,\n lastSeparator: options.allowedValuesLastSeparator,\n wrapStringValuesInQuote: options.wrapAllowedValuesInQuote,\n maxValuesToDisplay: options.maxAllowedValuesToDisplay,\n });\n message = `expected value to be one of ${valuesStr}`;\n }\n\n return {\n type: issue.code,\n path: issue.path,\n message,\n };\n}\n","import type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree } from './types.ts';\n\nexport function parseNotMultipleOfIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueNotMultipleOf>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `expected multiple of ${issue.divisor}`,\n };\n}\n","import { stringify } from '../../utils/stringify.ts';\nimport type { AbstractSyntaxTree, ErrorMapOptions } from './types.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport function parseTooBigIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueTooBig>,\n options: Pick<ErrorMapOptions, 'dateLocalization' | 'numberLocalization'>\n): AbstractSyntaxTree {\n const maxValueStr =\n issue.origin === 'date'\n ? stringify(new Date(issue.maximum as number), {\n localization: options.dateLocalization,\n })\n : stringify(issue.maximum, {\n localization: options.numberLocalization,\n });\n\n switch (issue.origin) {\n case 'number':\n case 'int':\n case 'bigint': {\n return {\n type: issue.code,\n path: issue.path,\n message: `number must be less than${\n issue.inclusive ? ' or equal to' : ''\n } ${maxValueStr}`,\n };\n }\n case 'string': {\n return {\n type: issue.code,\n path: issue.path,\n message: `string must contain at most ${maxValueStr} character(s)`,\n };\n }\n case 'date': {\n return {\n type: issue.code,\n path: issue.path,\n message: `date must be ${\n issue.inclusive ? 'prior or equal to' : 'prior to'\n } \"${maxValueStr}\"`,\n };\n }\n case 'array': {\n return {\n type: issue.code,\n path: issue.path,\n message: `array must contain at most ${maxValueStr} item(s)`,\n };\n }\n case 'set': {\n return {\n type: issue.code,\n path: issue.path,\n message: `set must contain at most ${maxValueStr} item(s)`,\n };\n }\n case 'file': {\n return {\n type: issue.code,\n path: issue.path,\n message: `file must not exceed ${maxValueStr} byte(s) in size`,\n };\n }\n default:\n return {\n type: issue.code,\n path: issue.path,\n message: `value must be less than${\n issue.inclusive ? ' or equal to' : ''\n } ${maxValueStr}`,\n };\n }\n}\n","import { stringify } from '../../utils/stringify.ts';\nimport type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree, ErrorMapOptions } from './types.ts';\n\nexport function parseTooSmallIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueTooSmall>,\n options: Pick<ErrorMapOptions, 'dateLocalization' | 'numberLocalization'>\n): AbstractSyntaxTree {\n const minValueStr =\n issue.origin === 'date'\n ? stringify(new Date(issue.minimum as number), {\n localization: options.dateLocalization,\n })\n : stringify(issue.minimum, {\n localization: options.numberLocalization,\n });\n\n switch (issue.origin) {\n case 'number':\n case 'int':\n case 'bigint': {\n return {\n type: issue.code,\n path: issue.path,\n message: `number must be greater than${\n issue.inclusive ? ' or equal to' : ''\n } ${minValueStr}`,\n };\n }\n case 'date': {\n return {\n type: issue.code,\n path: issue.path,\n message: `date must be ${\n issue.inclusive ? 'later or equal to' : 'later to'\n } \"${minValueStr}\"`,\n };\n }\n case 'string': {\n return {\n type: issue.code,\n path: issue.path,\n message: `string must contain at least ${minValueStr} character(s)`,\n };\n }\n case 'array': {\n return {\n type: issue.code,\n path: issue.path,\n message: `array must contain at least ${minValueStr} item(s)`,\n };\n }\n case 'set': {\n return {\n type: issue.code,\n path: issue.path,\n message: `set must contain at least ${minValueStr} item(s)`,\n };\n }\n case 'file': {\n return {\n type: issue.code,\n path: issue.path,\n message: `file must be at least ${minValueStr} byte(s) in size`,\n };\n }\n default:\n return {\n type: issue.code,\n path: issue.path,\n message: `value must be greater than${\n issue.inclusive ? ' or equal to' : ''\n } ${minValueStr}`,\n };\n }\n}\n","import { joinValues } from '../../utils/joinValues.ts';\nimport type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree, ErrorMapOptions } from './types.ts';\n\nexport function parseUnrecognizedKeysIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueUnrecognizedKeys>,\n options: Pick<\n ErrorMapOptions,\n | 'unrecognizedKeysSeparator'\n | 'unrecognizedKeysLastSeparator'\n | 'wrapUnrecognizedKeysInQuote'\n | 'maxUnrecognizedKeysToDisplay'\n >\n): AbstractSyntaxTree {\n const keysStr = joinValues(issue.keys, {\n separator: options.unrecognizedKeysSeparator,\n lastSeparator: options.unrecognizedKeysLastSeparator,\n wrapStringValuesInQuote: options.wrapUnrecognizedKeysInQuote,\n maxValuesToDisplay: options.maxUnrecognizedKeysToDisplay,\n });\n\n return {\n type: issue.code,\n path: issue.path,\n message: `unrecognized key(s) ${keysStr} in object`,\n };\n}\n","import { parseCustomIssue } from './custom.ts';\nimport { parseInvalidElementIssue } from './invalidElement.ts';\nimport { parseInvalidKeyIssue } from './invalidKey.ts';\nimport { parseInvalidStringFormatIssue } from './invalidStringFormat.ts';\nimport { parseInvalidTypeIssue } from './invalidType.ts';\nimport { parseInvalidUnionIssue } from './invalidUnion.ts';\nimport { parseInvalidValueIssue } from './invalidValue.ts';\nimport { parseNotMultipleOfIssue } from './notMultipleOf.ts';\nimport { parseTooBigIssue } from './tooBig.ts';\nimport { parseTooSmallIssue } from './tooSmall.ts';\nimport { parseUnrecognizedKeysIssue } from './unrecognizedKeys.ts';\nimport type {\n AbstractSyntaxTree,\n ErrorMapOptions,\n IssueType,\n} from './types.ts';\nimport type * as zod from 'zod/v4/core';\n\ntype IssueParsers = {\n [IssueCode in IssueType]: (\n issue: zod.$ZodRawIssue<Extract<zod.$ZodIssue, { code: IssueCode }>>,\n options: ErrorMapOptions\n ) => AbstractSyntaxTree;\n};\n\nconst issueParsers: IssueParsers = {\n invalid_type: parseInvalidTypeIssue,\n too_big: parseTooBigIssue,\n too_small: parseTooSmallIssue,\n invalid_format: parseInvalidStringFormatIssue,\n invalid_value: parseInvalidValueIssue,\n invalid_element: parseInvalidElementIssue,\n not_multiple_of: parseNotMultipleOfIssue,\n unrecognized_keys: parseUnrecognizedKeysIssue,\n invalid_key: parseInvalidKeyIssue,\n custom: parseCustomIssue,\n invalid_union: parseInvalidUnionIssue,\n};\n\nexport const defaultErrorMapOptions = {\n displayInvalidFormatDetails: false,\n allowedValuesSeparator: ', ',\n allowedValuesLastSeparator: ' or ',\n wrapAllowedValuesInQuote: true,\n maxAllowedValuesToDisplay: 10,\n unrecognizedKeysSeparator: ', ',\n unrecognizedKeysLastSeparator: ' and ',\n wrapUnrecognizedKeysInQuote: true,\n maxUnrecognizedKeysToDisplay: 5,\n dateLocalization: true,\n numberLocalization: true,\n} as const satisfies ErrorMapOptions;\n\nexport function createErrorMap(\n partialOptions: Partial<ErrorMapOptions> = {}\n): zod.$ZodErrorMap<zod.$ZodIssue> {\n // fill-in default options\n const options = {\n ...defaultErrorMapOptions,\n ...partialOptions,\n };\n\n const errorMap: zod.$ZodErrorMap<zod.$ZodIssue> = (issue) => {\n if (issue.code === undefined) {\n // TODO: handle this case\n return 'Not supported issue type';\n }\n\n const parseFunc = issueParsers[issue.code] as (\n iss: typeof issue,\n opts: ErrorMapOptions\n ) => AbstractSyntaxTree;\n const ast = parseFunc(issue, options);\n return ast.message;\n };\n\n return errorMap;\n}\n","export type NonEmptyArray<T> = [T, ...T[]];\n\nexport function isNonEmptyArray<T>(value: T[]): value is NonEmptyArray<T> {\n return value.length !== 0;\n}\n","import { stringifySymbol } from './stringify.ts';\nimport type { NonEmptyArray } from './NonEmptyArray.ts';\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers\n */\nconst identifierRegex = /[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*/u;\n\nexport function joinPath(path: NonEmptyArray<PropertyKey>): string {\n if (path.length === 1) {\n let propertyKey = path[0];\n\n if (typeof propertyKey === 'symbol') {\n propertyKey = stringifySymbol(propertyKey);\n }\n\n return propertyKey.toString() || '\"\"';\n }\n\n return path.reduce<string>((acc, propertyKey) => {\n // handle numeric indices\n if (typeof propertyKey === 'number') {\n return acc + '[' + propertyKey.toString() + ']';\n }\n\n // handle symbols\n if (typeof propertyKey === 'symbol') {\n propertyKey = stringifySymbol(propertyKey);\n }\n\n // handle quoted values\n if (propertyKey.includes('\"')) {\n return acc + '[\"' + escapeQuotes(propertyKey) + '\"]';\n }\n\n // handle special characters\n if (!identifierRegex.test(propertyKey)) {\n return acc + '[\"' + propertyKey + '\"]';\n }\n\n // handle normal values\n const separator = acc.length === 0 ? '' : '.';\n return acc + separator + propertyKey;\n }, '');\n}\n\nfunction escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"');\n}\n","export function titleCase(value: string): string {\n if (value.length === 0) {\n return value;\n }\n return value.charAt(0).toUpperCase() + value.slice(1);\n}\n","import { joinPath } from '../utils/joinPath.ts';\nimport { isNonEmptyArray, type NonEmptyArray } from '../utils/NonEmptyArray.ts';\nimport { titleCase } from '../utils/titleCase.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport type ZodIssue = zod.$ZodIssue;\n\nexport type MessageBuilder = (issues: NonEmptyArray<ZodIssue>) => string;\n\nexport type MessageBuilderOptions = {\n prefix: string | null | undefined;\n prefixSeparator: string;\n maxIssuesInMessage: number;\n issueSeparator: string;\n unionSeparator: string;\n includePath: boolean;\n forceTitleCase: boolean;\n};\n\nexport const defaultMessageBuilderOptions: MessageBuilderOptions & {\n prefix: string;\n} = {\n prefix: 'Validation error',\n prefixSeparator: ': ',\n maxIssuesInMessage: 99, // I've got 99 problems but the b$tch ain't one\n unionSeparator: ' or ',\n issueSeparator: '; ',\n includePath: true,\n forceTitleCase: true,\n};\n\nexport function createMessageBuilder(\n partialOptions: Partial<MessageBuilderOptions> = {}\n): MessageBuilder {\n const options = {\n ...defaultMessageBuilderOptions,\n ...partialOptions,\n };\n\n return function messageBuilder(issues) {\n const message = issues\n // limit max number of issues printed in the reason section\n .slice(0, options.maxIssuesInMessage)\n // format error message\n .map((issue) => mapIssue(issue, options))\n // concat as string\n .join(options.issueSeparator);\n\n return conditionallyPrefixMessage(message, options);\n };\n}\n\nfunction mapIssue(\n issue: zod.$ZodIssue,\n options: MessageBuilderOptions\n): string {\n if (issue.code === 'invalid_union' && isNonEmptyArray(issue.errors)) {\n const individualMessages = issue.errors.map((issues) =>\n issues\n .map((subIssue) =>\n mapIssue(\n {\n ...subIssue,\n path: issue.path.concat(subIssue.path),\n },\n options\n )\n )\n .join(options.issueSeparator)\n );\n\n // deduplicate messages\n // and join them with the union separator\n // to create a single message for the invalid union issue\n return Array.from(new Set(individualMessages)).join(options.unionSeparator);\n }\n\n const buf = [];\n\n if (options.forceTitleCase) {\n buf.push(titleCase(issue.message));\n } else {\n buf.push(issue.message);\n }\n\n pathCondition: if (\n options.includePath &&\n issue.path !== undefined &&\n isNonEmptyArray(issue.path)\n ) {\n // handle array indices\n if (issue.path.length === 1) {\n const identifier = issue.path[0];\n\n if (typeof identifier === 'number') {\n buf.push(` at index ${identifier}`);\n break pathCondition;\n }\n }\n\n buf.push(` at \"${joinPath(issue.path)}\"`);\n }\n\n return buf.join('');\n}\n\nfunction conditionallyPrefixMessage(\n message: string,\n options: Pick<MessageBuilderOptions, 'prefix' | 'prefixSeparator'>\n): string {\n if (options.prefix != null) {\n if (message.length > 0) {\n return [options.prefix, message].join(options.prefixSeparator);\n }\n\n return options.prefix;\n }\n\n if (message.length > 0) {\n return message;\n }\n\n // if both reason and prefix are empty, return default prefix\n // to avoid having an empty error message\n return defaultMessageBuilderOptions.prefix;\n}\n","import { isNonEmptyArray } from '../utils/NonEmptyArray.ts';\nimport { fromError } from './fromError.ts';\nimport { isZodErrorLike } from './isZodErrorLike.ts';\nimport {\n createMessageBuilder,\n type MessageBuilderOptions,\n type MessageBuilder,\n} from './MessageBuilder.ts';\nimport { ValidationError } from './ValidationError.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport type ZodError = zod.$ZodError;\n\nexport type FromZodErrorOptions =\n | {\n messageBuilder: MessageBuilder;\n }\n // maintain backwards compatibility\n | Partial<MessageBuilderOptions>;\n\nexport function fromZodError(\n zodError: ZodError,\n options: FromZodErrorOptions = {}\n): ValidationError {\n // perform runtime check to ensure the input is a ZodError\n // why? because people have been historically using this function incorrectly\n if (!isZodErrorLike(zodError)) {\n throw new TypeError(\n `Invalid zodError param; expected instance of ZodError. Did you mean to use the \"${fromError.name}\" method instead?`\n );\n }\n\n return fromZodErrorWithoutRuntimeCheck(zodError, options);\n}\n\nexport function fromZodErrorWithoutRuntimeCheck(\n zodError: ZodError,\n options: FromZodErrorOptions = {}\n): ValidationError {\n const zodIssues = zodError.issues;\n\n let message: string;\n if (isNonEmptyArray(zodIssues)) {\n const messageBuilder = createMessageBuilderFromOptions(options);\n message = messageBuilder(zodIssues);\n } else {\n message = zodError.message;\n }\n\n return new ValidationError(message, { cause: zodError });\n}\n\nfunction createMessageBuilderFromOptions(\n options: FromZodErrorOptions\n): MessageBuilder {\n if ('messageBuilder' in options) {\n return options.messageBuilder;\n }\n\n return createMessageBuilder(options);\n}\n","import { ValidationError } from './ValidationError.ts';\nimport { isZodErrorLike } from './isZodErrorLike.ts';\nimport {\n fromZodErrorWithoutRuntimeCheck,\n type FromZodErrorOptions,\n} from './fromZodError.ts';\n\nexport const toValidationError =\n (options: FromZodErrorOptions = {}) =>\n (err: unknown): ValidationError => {\n if (isZodErrorLike(err)) {\n return fromZodErrorWithoutRuntimeCheck(err, options);\n }\n\n if (err instanceof Error) {\n return new ValidationError(err.message, { cause: err });\n }\n\n return new ValidationError('Unknown error');\n };\n","import { toValidationError } from './toValidationError.ts';\nimport type { FromZodErrorOptions } from './fromZodError.ts';\nimport type { ValidationError } from './ValidationError.ts';\n\n/**\n * This function is a non-curried version of `toValidationError`\n */\nexport function fromError(\n err: unknown,\n options: FromZodErrorOptions = {}\n): ValidationError {\n return toValidationError(options)(err);\n}\n","import * as zod from 'zod/v4/core';\n\nimport {\n type MessageBuilder,\n type MessageBuilderOptions,\n type ZodIssue,\n createMessageBuilder,\n} from './MessageBuilder.ts';\nimport { ValidationError } from './ValidationError.ts';\n\nexport type FromZodIssueOptions =\n | {\n messageBuilder: MessageBuilder;\n }\n // maintain backwards compatibility\n | Partial<Omit<MessageBuilderOptions, 'maxIssuesInMessage'>>;\n\nexport function fromZodIssue(\n issue: ZodIssue,\n options: FromZodIssueOptions = {}\n): ValidationError {\n const messageBuilder = createMessageBuilderFromOptions(options);\n const message = messageBuilder([issue]);\n\n return new ValidationError(message, {\n cause: new zod.$ZodRealError([issue]),\n });\n}\n\nfunction createMessageBuilderFromOptions(\n options: FromZodIssueOptions\n): MessageBuilder {\n if ('messageBuilder' in options) {\n return options.messageBuilder;\n }\n\n return createMessageBuilder(options);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,SAAS,eAAe,KAAoC;AACjE,SACE,eAAe,UACf,UAAU,QACT,IAAI,SAAS,cAAc,IAAI,SAAS,gBACzC,YAAY,OACZ,MAAM,QAAQ,IAAI,MAAM;AAE5B;;;ACPO,IAAM,4BAA4B;AASlC,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EAEA,YAAY,SAAkB,SAAwB;AACpD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,UAAU,0BAA0B,OAAO;AAAA,EAClD;AAAA,EAEA,WAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AACF;AAEA,SAAS,0BACP,SACsB;AACtB,MAAI,SAAS;AACX,UAAM,QAAQ,QAAQ;AACtB,QAAI,eAAe,KAAK,GAAG;AACzB,aAAO,MAAM;AAAA,IACf;AAAA,EACF;AAEA,SAAO,CAAC;AACV;;;ACpCO,SAAS,kBAAkB,KAAsC;AACtE,SAAO,eAAe;AACxB;;;ACCO,SAAS,sBAAsB,KAAsC;AAC1E,SAAO,eAAe,SAAS,IAAI,SAAS;AAC9C;;;ACJO,SAAS,iBACd,OACoB;AACpB,SAAO;AAAA,IACL,MAAM,MAAM;AAAA,IACZ,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM,WAAW;AAAA,EAC5B;AACF;;;ACRO,SAAS,yBACd,OACoB;AACpB,SAAO;AAAA,IACL,MAAM,MAAM;AAAA,IACZ,MAAM,MAAM;AAAA,IACZ,SAAS,yBAAyB,MAAM,MAAM;AAAA,EAChD;AACF;;;ACRO,SAAS,qBACd,OACoB;AACpB,SAAO;AAAA,IACL,MA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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // lib/v4/isZodErrorLike.ts
2
+ function isZodErrorLike(err) {
3
+ return err instanceof Object && "name" in err && (err.name === "ZodError" || err.name === "$ZodError") && "issues" in err && Array.isArray(err.issues);
4
+ }
5
+
6
+ // lib/v4/ValidationError.ts
7
+ var ZOD_VALIDATION_ERROR_NAME = "ZodValidationError";
8
+ var ValidationError = class extends Error {
9
+ name;
10
+ details;
11
+ constructor(message, options) {
12
+ super(message, options);
13
+ this.name = ZOD_VALIDATION_ERROR_NAME;
14
+ this.details = getIssuesFromErrorOptions(options);
15
+ }
16
+ toString() {
17
+ return this.message;
18
+ }
19
+ };
20
+ function getIssuesFromErrorOptions(options) {
21
+ if (options) {
22
+ const cause = options.cause;
23
+ if (isZodErrorLike(cause)) {
24
+ return cause.issues;
25
+ }
26
+ }
27
+ return [];
28
+ }
29
+
30
+ // lib/v4/isValidationError.ts
31
+ function isValidationError(err) {
32
+ return err instanceof ValidationError;
33
+ }
34
+
35
+ // lib/v4/isValidationErrorLike.ts
36
+ function isValidationErrorLike(err) {
37
+ return err instanceof Error && err.name === ZOD_VALIDATION_ERROR_NAME;
38
+ }
39
+
40
+ // lib/v4/errorMap/custom.ts
41
+ function parseCustomIssue(issue) {
42
+ return {
43
+ type: issue.code,
44
+ path: issue.path,
45
+ message: issue.message ?? "Invalid input"
46
+ };
47
+ }
48
+
49
+ // lib/v4/errorMap/invalidElement.ts
50
+ function parseInvalidElementIssue(issue) {
51
+ return {
52
+ type: issue.code,
53
+ path: issue.path,
54
+ message: `unexpected element in ${issue.origin}`
55
+ };
56
+ }
57
+
58
+ // lib/v4/errorMap/invalidKey.ts
59
+ function parseInvalidKeyIssue(issue) {
60
+ return {
61
+ type: issue.code,
62
+ path: issue.path,
63
+ message: `unexpected key in ${issue.origin}`
64
+ };
65
+ }
66
+
67
+ // lib/v4/errorMap/invalidStringFormat.ts
68
+ function parseInvalidStringFormatIssue(issue, options = {
69
+ displayInvalidFormatDetails: false
70
+ }) {
71
+ switch (issue.format) {
72
+ case "lowercase":
73
+ case "uppercase":
74
+ return {
75
+ type: issue.code,
76
+ path: issue.path,
77
+ message: `value must be in ${issue.format} format`
78
+ };
79
+ default: {
80
+ if (isZodIssueStringStartsWith(issue)) {
81
+ return parseStringStartsWith(issue);
82
+ }
83
+ if (isZodIssueStringEndsWith(issue)) {
84
+ return parseStringEndsWith(issue);
85
+ }
86
+ if (isZodIssueStringIncludes(issue)) {
87
+ return parseStringIncludes(issue);
88
+ }
89
+ if (isZodIssueStringInvalidRegex(issue)) {
90
+ return parseStringInvalidRegex(issue, options);
91
+ }
92
+ if (isZodIssueStringInvalidJWT(issue)) {
93
+ return parseStringInvalidJWT(issue, options);
94
+ }
95
+ return {
96
+ type: issue.code,
97
+ path: issue.path,
98
+ message: `invalid ${issue.format}`
99
+ };
100
+ }
101
+ }
102
+ }
103
+ function isZodIssueStringStartsWith(issue) {
104
+ return issue.format === "starts_with";
105
+ }
106
+ function parseStringStartsWith(issue) {
107
+ return {
108
+ type: issue.code,
109
+ path: issue.path,
110
+ message: `value must start with "${issue.prefix}"`
111
+ };
112
+ }
113
+ function isZodIssueStringEndsWith(issue) {
114
+ return issue.format === "ends_with";
115
+ }
116
+ function parseStringEndsWith(issue) {
117
+ return {
118
+ type: issue.code,
119
+ path: issue.path,
120
+ message: `value must end with "${issue.suffix}"`
121
+ };
122
+ }
123
+ function isZodIssueStringIncludes(issue) {
124
+ return issue.format === "includes";
125
+ }
126
+ function parseStringIncludes(issue) {
127
+ return {
128
+ type: issue.code,
129
+ path: issue.path,
130
+ message: `value must include "${issue.includes}"`
131
+ };
132
+ }
133
+ function isZodIssueStringInvalidRegex(issue) {
134
+ return issue.format === "regex";
135
+ }
136
+ function parseStringInvalidRegex(issue, options = {
137
+ displayInvalidFormatDetails: false
138
+ }) {
139
+ let message = "value must match pattern";
140
+ if (options.displayInvalidFormatDetails) {
141
+ message += ` "${issue.pattern}"`;
142
+ }
143
+ return {
144
+ type: issue.code,
145
+ path: issue.path,
146
+ message
147
+ };
148
+ }
149
+ function isZodIssueStringInvalidJWT(issue) {
150
+ return issue.format === "jwt";
151
+ }
152
+ function parseStringInvalidJWT(issue, options = {
153
+ displayInvalidFormatDetails: false
154
+ }) {
155
+ return {
156
+ type: issue.code,
157
+ path: issue.path,
158
+ message: options.displayInvalidFormatDetails && issue.algorithm ? `invalid jwt/${issue.algorithm}` : `invalid jwt`
159
+ };
160
+ }
161
+
162
+ // lib/v4/errorMap/invalidType.ts
163
+ function parseInvalidTypeIssue(issue) {
164
+ let message = `expected ${issue.expected}`;
165
+ if ("input" in issue) {
166
+ message += `, received ${getTypeName(issue.input)}`;
167
+ }
168
+ return {
169
+ type: issue.code,
170
+ path: issue.path,
171
+ message
172
+ };
173
+ }
174
+ function getTypeName(value) {
175
+ if (typeof value === "object") {
176
+ if (value === null) {
177
+ return "null";
178
+ }
179
+ if (value === void 0) {
180
+ return "undefined";
181
+ }
182
+ if (Array.isArray(value)) {
183
+ return "array";
184
+ }
185
+ if (value instanceof Date) {
186
+ return "date";
187
+ }
188
+ if (value instanceof RegExp) {
189
+ return "regexp";
190
+ }
191
+ if (value instanceof Map) {
192
+ return "map";
193
+ }
194
+ if (value instanceof Set) {
195
+ return "set";
196
+ }
197
+ if (value instanceof Error) {
198
+ return "error";
199
+ }
200
+ if (value instanceof Function) {
201
+ return "function";
202
+ }
203
+ return "object";
204
+ }
205
+ return typeof value;
206
+ }
207
+
208
+ // lib/v4/errorMap/invalidUnion.ts
209
+ function parseInvalidUnionIssue(issue) {
210
+ return {
211
+ type: issue.code,
212
+ path: issue.path,
213
+ message: issue.message ?? "Invalid input"
214
+ };
215
+ }
216
+
217
+ // lib/utils/stringify.ts
218
+ function stringifySymbol(symbol) {
219
+ return symbol.description ?? "";
220
+ }
221
+ function stringify(value, options = {}) {
222
+ switch (typeof value) {
223
+ case "symbol":
224
+ return stringifySymbol(value);
225
+ case "bigint":
226
+ case "number": {
227
+ switch (options.localization) {
228
+ case true:
229
+ return value.toLocaleString();
230
+ case false:
231
+ return value.toString();
232
+ default:
233
+ return value.toLocaleString(options.localization);
234
+ }
235
+ }
236
+ case "string": {
237
+ if (options.wrapStringValueInQuote) {
238
+ return `"${value}"`;
239
+ }
240
+ return value;
241
+ }
242
+ default: {
243
+ if (value instanceof Date) {
244
+ switch (options.localization) {
245
+ case true:
246
+ return value.toLocaleString();
247
+ case false:
248
+ return value.toISOString();
249
+ default:
250
+ return value.toLocaleString(options.localization);
251
+ }
252
+ }
253
+ return String(value);
254
+ }
255
+ }
256
+ }
257
+
258
+ // lib/utils/joinValues.ts
259
+ function joinValues(values, options) {
260
+ const valuesToDisplay = (options.maxValuesToDisplay ? values.slice(0, options.maxValuesToDisplay) : values).map((value) => {
261
+ return stringify(value, {
262
+ wrapStringValueInQuote: options.wrapStringValuesInQuote
263
+ });
264
+ });
265
+ if (valuesToDisplay.length < values.length) {
266
+ valuesToDisplay.push(
267
+ `${values.length - valuesToDisplay.length} more value(s)`
268
+ );
269
+ }
270
+ return valuesToDisplay.reduce((acc, value, index) => {
271
+ if (index > 0) {
272
+ if (index === valuesToDisplay.length - 1 && options.lastSeparator) {
273
+ acc += options.lastSeparator;
274
+ } else {
275
+ acc += options.separator;
276
+ }
277
+ }
278
+ acc += value;
279
+ return acc;
280
+ }, "");
281
+ }
282
+
283
+ // lib/v4/errorMap/invalidValue.ts
284
+ function parseInvalidValueIssue(issue, options) {
285
+ let message;
286
+ if (issue.values.length === 0) {
287
+ message = "invalid value";
288
+ } else if (issue.values.length === 1) {
289
+ const valueStr = stringify(issue.values[0], {
290
+ wrapStringValueInQuote: true
291
+ });
292
+ message = `expected value to be ${valueStr}`;
293
+ } else {
294
+ const valuesStr = joinValues(issue.values, {
295
+ separator: options.allowedValuesSeparator,
296
+ lastSeparator: options.allowedValuesLastSeparator,
297
+ wrapStringValuesInQuote: options.wrapAllowedValuesInQuote,
298
+ maxValuesToDisplay: options.maxAllowedValuesToDisplay
299
+ });
300
+ message = `expected value to be one of ${valuesStr}`;
301
+ }
302
+ return {
303
+ type: issue.code,
304
+ path: issue.path,
305
+ message
306
+ };
307
+ }
308
+
309
+ // lib/v4/errorMap/notMultipleOf.ts
310
+ function parseNotMultipleOfIssue(issue) {
311
+ return {
312
+ type: issue.code,
313
+ path: issue.path,
314
+ message: `expected multiple of ${issue.divisor}`
315
+ };
316
+ }
317
+
318
+ // lib/v4/errorMap/tooBig.ts
319
+ function parseTooBigIssue(issue, options) {
320
+ const maxValueStr = issue.origin === "date" ? stringify(new Date(issue.maximum), {
321
+ localization: options.dateLocalization
322
+ }) : stringify(issue.maximum, {
323
+ localization: options.numberLocalization
324
+ });
325
+ switch (issue.origin) {
326
+ case "number":
327
+ case "int":
328
+ case "bigint": {
329
+ return {
330
+ type: issue.code,
331
+ path: issue.path,
332
+ message: `number must be less than${issue.inclusive ? " or equal to" : ""} ${maxValueStr}`
333
+ };
334
+ }
335
+ case "string": {
336
+ return {
337
+ type: issue.code,
338
+ path: issue.path,
339
+ message: `string must contain at most ${maxValueStr} character(s)`
340
+ };
341
+ }
342
+ case "date": {
343
+ return {
344
+ type: issue.code,
345
+ path: issue.path,
346
+ message: `date must be ${issue.inclusive ? "prior or equal to" : "prior to"} "${maxValueStr}"`
347
+ };
348
+ }
349
+ case "array": {
350
+ return {
351
+ type: issue.code,
352
+ path: issue.path,
353
+ message: `array must contain at most ${maxValueStr} item(s)`
354
+ };
355
+ }
356
+ case "set": {
357
+ return {
358
+ type: issue.code,
359
+ path: issue.path,
360
+ message: `set must contain at most ${maxValueStr} item(s)`
361
+ };
362
+ }
363
+ case "file": {
364
+ return {
365
+ type: issue.code,
366
+ path: issue.path,
367
+ message: `file must not exceed ${maxValueStr} byte(s) in size`
368
+ };
369
+ }
370
+ default:
371
+ return {
372
+ type: issue.code,
373
+ path: issue.path,
374
+ message: `value must be less than${issue.inclusive ? " or equal to" : ""} ${maxValueStr}`
375
+ };
376
+ }
377
+ }
378
+
379
+ // lib/v4/errorMap/tooSmall.ts
380
+ function parseTooSmallIssue(issue, options) {
381
+ const minValueStr = issue.origin === "date" ? stringify(new Date(issue.minimum), {
382
+ localization: options.dateLocalization
383
+ }) : stringify(issue.minimum, {
384
+ localization: options.numberLocalization
385
+ });
386
+ switch (issue.origin) {
387
+ case "number":
388
+ case "int":
389
+ case "bigint": {
390
+ return {
391
+ type: issue.code,
392
+ path: issue.path,
393
+ message: `number must be greater than${issue.inclusive ? " or equal to" : ""} ${minValueStr}`
394
+ };
395
+ }
396
+ case "date": {
397
+ return {
398
+ type: issue.code,
399
+ path: issue.path,
400
+ message: `date must be ${issue.inclusive ? "later or equal to" : "later to"} "${minValueStr}"`
401
+ };
402
+ }
403
+ case "string": {
404
+ return {
405
+ type: issue.code,
406
+ path: issue.path,
407
+ message: `string must contain at least ${minValueStr} character(s)`
408
+ };
409
+ }
410
+ case "array": {
411
+ return {
412
+ type: issue.code,
413
+ path: issue.path,
414
+ message: `array must contain at least ${minValueStr} item(s)`
415
+ };
416
+ }
417
+ case "set": {
418
+ return {
419
+ type: issue.code,
420
+ path: issue.path,
421
+ message: `set must contain at least ${minValueStr} item(s)`
422
+ };
423
+ }
424
+ case "file": {
425
+ return {
426
+ type: issue.code,
427
+ path: issue.path,
428
+ message: `file must be at least ${minValueStr} byte(s) in size`
429
+ };
430
+ }
431
+ default:
432
+ return {
433
+ type: issue.code,
434
+ path: issue.path,
435
+ message: `value must be greater than${issue.inclusive ? " or equal to" : ""} ${minValueStr}`
436
+ };
437
+ }
438
+ }
439
+
440
+ // lib/v4/errorMap/unrecognizedKeys.ts
441
+ function parseUnrecognizedKeysIssue(issue, options) {
442
+ const keysStr = joinValues(issue.keys, {
443
+ separator: options.unrecognizedKeysSeparator,
444
+ lastSeparator: options.unrecognizedKeysLastSeparator,
445
+ wrapStringValuesInQuote: options.wrapUnrecognizedKeysInQuote,
446
+ maxValuesToDisplay: options.maxUnrecognizedKeysToDisplay
447
+ });
448
+ return {
449
+ type: issue.code,
450
+ path: issue.path,
451
+ message: `unrecognized key(s) ${keysStr} in object`
452
+ };
453
+ }
454
+
455
+ // lib/v4/errorMap/errorMap.ts
456
+ var issueParsers = {
457
+ invalid_type: parseInvalidTypeIssue,
458
+ too_big: parseTooBigIssue,
459
+ too_small: parseTooSmallIssue,
460
+ invalid_format: parseInvalidStringFormatIssue,
461
+ invalid_value: parseInvalidValueIssue,
462
+ invalid_element: parseInvalidElementIssue,
463
+ not_multiple_of: parseNotMultipleOfIssue,
464
+ unrecognized_keys: parseUnrecognizedKeysIssue,
465
+ invalid_key: parseInvalidKeyIssue,
466
+ custom: parseCustomIssue,
467
+ invalid_union: parseInvalidUnionIssue
468
+ };
469
+ var defaultErrorMapOptions = {
470
+ displayInvalidFormatDetails: false,
471
+ allowedValuesSeparator: ", ",
472
+ allowedValuesLastSeparator: " or ",
473
+ wrapAllowedValuesInQuote: true,
474
+ maxAllowedValuesToDisplay: 10,
475
+ unrecognizedKeysSeparator: ", ",
476
+ unrecognizedKeysLastSeparator: " and ",
477
+ wrapUnrecognizedKeysInQuote: true,
478
+ maxUnrecognizedKeysToDisplay: 5,
479
+ dateLocalization: true,
480
+ numberLocalization: true
481
+ };
482
+ function createErrorMap(partialOptions = {}) {
483
+ const options = {
484
+ ...defaultErrorMapOptions,
485
+ ...partialOptions
486
+ };
487
+ const errorMap = (issue) => {
488
+ if (issue.code === void 0) {
489
+ return "Not supported issue type";
490
+ }
491
+ const parseFunc = issueParsers[issue.code];
492
+ const ast = parseFunc(issue, options);
493
+ return ast.message;
494
+ };
495
+ return errorMap;
496
+ }
497
+
498
+ // lib/utils/NonEmptyArray.ts
499
+ function isNonEmptyArray(value) {
500
+ return value.length !== 0;
501
+ }
502
+
503
+ // lib/utils/joinPath.ts
504
+ var identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u;
505
+ function joinPath(path) {
506
+ if (path.length === 1) {
507
+ let propertyKey = path[0];
508
+ if (typeof propertyKey === "symbol") {
509
+ propertyKey = stringifySymbol(propertyKey);
510
+ }
511
+ return propertyKey.toString() || '""';
512
+ }
513
+ return path.reduce((acc, propertyKey) => {
514
+ if (typeof propertyKey === "number") {
515
+ return acc + "[" + propertyKey.toString() + "]";
516
+ }
517
+ if (typeof propertyKey === "symbol") {
518
+ propertyKey = stringifySymbol(propertyKey);
519
+ }
520
+ if (propertyKey.includes('"')) {
521
+ return acc + '["' + escapeQuotes(propertyKey) + '"]';
522
+ }
523
+ if (!identifierRegex.test(propertyKey)) {
524
+ return acc + '["' + propertyKey + '"]';
525
+ }
526
+ const separator = acc.length === 0 ? "" : ".";
527
+ return acc + separator + propertyKey;
528
+ }, "");
529
+ }
530
+ function escapeQuotes(str) {
531
+ return str.replace(/"/g, '\\"');
532
+ }
533
+
534
+ // lib/utils/titleCase.ts
535
+ function titleCase(value) {
536
+ if (value.length === 0) {
537
+ return value;
538
+ }
539
+ return value.charAt(0).toUpperCase() + value.slice(1);
540
+ }
541
+
542
+ // lib/v4/MessageBuilder.ts
543
+ var defaultMessageBuilderOptions = {
544
+ prefix: "Validation error",
545
+ prefixSeparator: ": ",
546
+ maxIssuesInMessage: 99,
547
+ // I've got 99 problems but the b$tch ain't one
548
+ unionSeparator: " or ",
549
+ issueSeparator: "; ",
550
+ includePath: true,
551
+ forceTitleCase: true
552
+ };
553
+ function createMessageBuilder(partialOptions = {}) {
554
+ const options = {
555
+ ...defaultMessageBuilderOptions,
556
+ ...partialOptions
557
+ };
558
+ return function messageBuilder(issues) {
559
+ const message = issues.slice(0, options.maxIssuesInMessage).map((issue) => mapIssue(issue, options)).join(options.issueSeparator);
560
+ return conditionallyPrefixMessage(message, options);
561
+ };
562
+ }
563
+ function mapIssue(issue, options) {
564
+ if (issue.code === "invalid_union" && isNonEmptyArray(issue.errors)) {
565
+ const individualMessages = issue.errors.map(
566
+ (issues) => issues.map(
567
+ (subIssue) => mapIssue(
568
+ {
569
+ ...subIssue,
570
+ path: issue.path.concat(subIssue.path)
571
+ },
572
+ options
573
+ )
574
+ ).join(options.issueSeparator)
575
+ );
576
+ return Array.from(new Set(individualMessages)).join(options.unionSeparator);
577
+ }
578
+ const buf = [];
579
+ if (options.forceTitleCase) {
580
+ buf.push(titleCase(issue.message));
581
+ } else {
582
+ buf.push(issue.message);
583
+ }
584
+ pathCondition: if (options.includePath && issue.path !== void 0 && isNonEmptyArray(issue.path)) {
585
+ if (issue.path.length === 1) {
586
+ const identifier = issue.path[0];
587
+ if (typeof identifier === "number") {
588
+ buf.push(` at index ${identifier}`);
589
+ break pathCondition;
590
+ }
591
+ }
592
+ buf.push(` at "${joinPath(issue.path)}"`);
593
+ }
594
+ return buf.join("");
595
+ }
596
+ function conditionallyPrefixMessage(message, options) {
597
+ if (options.prefix != null) {
598
+ if (message.length > 0) {
599
+ return [options.prefix, message].join(options.prefixSeparator);
600
+ }
601
+ return options.prefix;
602
+ }
603
+ if (message.length > 0) {
604
+ return message;
605
+ }
606
+ return defaultMessageBuilderOptions.prefix;
607
+ }
608
+
609
+ // lib/v4/fromZodError.ts
610
+ function fromZodError(zodError, options = {}) {
611
+ if (!isZodErrorLike(zodError)) {
612
+ throw new TypeError(
613
+ `Invalid zodError param; expected instance of ZodError. Did you mean to use the "${fromError.name}" method instead?`
614
+ );
615
+ }
616
+ return fromZodErrorWithoutRuntimeCheck(zodError, options);
617
+ }
618
+ function fromZodErrorWithoutRuntimeCheck(zodError, options = {}) {
619
+ const zodIssues = zodError.issues;
620
+ let message;
621
+ if (isNonEmptyArray(zodIssues)) {
622
+ const messageBuilder = createMessageBuilderFromOptions(options);
623
+ message = messageBuilder(zodIssues);
624
+ } else {
625
+ message = zodError.message;
626
+ }
627
+ return new ValidationError(message, { cause: zodError });
628
+ }
629
+ function createMessageBuilderFromOptions(options) {
630
+ if ("messageBuilder" in options) {
631
+ return options.messageBuilder;
632
+ }
633
+ return createMessageBuilder(options);
634
+ }
635
+
636
+ // lib/v4/toValidationError.ts
637
+ var toValidationError = (options = {}) => (err) => {
638
+ if (isZodErrorLike(err)) {
639
+ return fromZodErrorWithoutRuntimeCheck(err, options);
640
+ }
641
+ if (err instanceof Error) {
642
+ return new ValidationError(err.message, { cause: err });
643
+ }
644
+ return new ValidationError("Unknown error");
645
+ };
646
+
647
+ // lib/v4/fromError.ts
648
+ function fromError(err, options = {}) {
649
+ return toValidationError(options)(err);
650
+ }
651
+
652
+ // lib/v4/fromZodIssue.ts
653
+ import * as zod from "zod/v4/core";
654
+ function fromZodIssue(issue, options = {}) {
655
+ const messageBuilder = createMessageBuilderFromOptions2(options);
656
+ const message = messageBuilder([issue]);
657
+ return new ValidationError(message, {
658
+ cause: new zod.$ZodRealError([issue])
659
+ });
660
+ }
661
+ function createMessageBuilderFromOptions2(options) {
662
+ if ("messageBuilder" in options) {
663
+ return options.messageBuilder;
664
+ }
665
+ return createMessageBuilder(options);
666
+ }
667
+ export {
668
+ ValidationError,
669
+ createErrorMap,
670
+ createMessageBuilder,
671
+ fromError,
672
+ fromZodError,
673
+ fromZodIssue,
674
+ isValidationError,
675
+ isValidationErrorLike,
676
+ isZodErrorLike,
677
+ toValidationError
678
+ };
679
+ //# sourceMappingURL=index.mjs.map
gui/frontend/node_modules/zod-validation-error/v4/index.mjs.map ADDED
@@ -0,0 +1 @@
 
 
1
+ {"version":3,"sources":["../lib/v4/isZodErrorLike.ts","../lib/v4/ValidationError.ts","../lib/v4/isValidationError.ts","../lib/v4/isValidationErrorLike.ts","../lib/v4/errorMap/custom.ts","../lib/v4/errorMap/invalidElement.ts","../lib/v4/errorMap/invalidKey.ts","../lib/v4/errorMap/invalidStringFormat.ts","../lib/v4/errorMap/invalidType.ts","../lib/v4/errorMap/invalidUnion.ts","../lib/utils/stringify.ts","../lib/utils/joinValues.ts","../lib/v4/errorMap/invalidValue.ts","../lib/v4/errorMap/notMultipleOf.ts","../lib/v4/errorMap/tooBig.ts","../lib/v4/errorMap/tooSmall.ts","../lib/v4/errorMap/unrecognizedKeys.ts","../lib/v4/errorMap/errorMap.ts","../lib/utils/NonEmptyArray.ts","../lib/utils/joinPath.ts","../lib/utils/titleCase.ts","../lib/v4/MessageBuilder.ts","../lib/v4/fromZodError.ts","../lib/v4/toValidationError.ts","../lib/v4/fromError.ts","../lib/v4/fromZodIssue.ts"],"sourcesContent":["import type * as zod from 'zod/v4/core';\n\nexport function isZodErrorLike(err: unknown): err is zod.$ZodError {\n return (\n err instanceof Object &&\n 'name' in err &&\n (err.name === 'ZodError' || err.name === '$ZodError') &&\n 'issues' in err &&\n Array.isArray(err.issues)\n );\n}\n","import { isZodErrorLike } from './isZodErrorLike.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport const ZOD_VALIDATION_ERROR_NAME = 'ZodValidationError';\n\n// make zod-validation-error compatible with\n// earlier to es2022 typescript configurations\n// @see https://github.com/causaly/zod-validation-error/issues/226\nexport interface ErrorOptions {\n cause?: unknown;\n}\n\nexport class ValidationError extends Error {\n name: typeof ZOD_VALIDATION_ERROR_NAME;\n details: Array<zod.$ZodIssue>;\n\n constructor(message?: string, options?: ErrorOptions) {\n super(message, options);\n this.name = ZOD_VALIDATION_ERROR_NAME;\n this.details = getIssuesFromErrorOptions(options);\n }\n\n toString(): string {\n return this.message;\n }\n}\n\nfunction getIssuesFromErrorOptions(\n options?: ErrorOptions\n): Array<zod.$ZodIssue> {\n if (options) {\n const cause = options.cause;\n if (isZodErrorLike(cause)) {\n return cause.issues;\n }\n }\n\n return [];\n}\n","import { ValidationError } from './ValidationError.ts';\n\nexport function isValidationError(err: unknown): err is ValidationError {\n return err instanceof ValidationError;\n}\n","import {\n ZOD_VALIDATION_ERROR_NAME,\n type ValidationError,\n} from './ValidationError.ts';\n\nexport function isValidationErrorLike(err: unknown): err is ValidationError {\n return err instanceof Error && err.name === ZOD_VALIDATION_ERROR_NAME;\n}\n","import type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree } from './types.ts';\n\nexport function parseCustomIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueCustom>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: issue.message ?? 'Invalid input',\n };\n}\n","import type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree } from './types.ts';\n\nexport function parseInvalidElementIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidElement>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `unexpected element in ${issue.origin}`,\n };\n}\n","import type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree } from './types.ts';\n\nexport function parseInvalidKeyIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidKey>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `unexpected key in ${issue.origin}`,\n };\n}\n","import type { AbstractSyntaxTree, ErrorMapOptions } from './types.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport function parseInvalidStringFormatIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>,\n options: Pick<ErrorMapOptions, 'displayInvalidFormatDetails'> = {\n displayInvalidFormatDetails: false,\n }\n): AbstractSyntaxTree {\n switch (issue.format) {\n case 'lowercase':\n case 'uppercase':\n return {\n type: issue.code,\n path: issue.path,\n message: `value must be in ${issue.format} format`,\n };\n default: {\n if (isZodIssueStringStartsWith(issue)) {\n return parseStringStartsWith(issue);\n }\n if (isZodIssueStringEndsWith(issue)) {\n return parseStringEndsWith(issue);\n }\n if (isZodIssueStringIncludes(issue)) {\n return parseStringIncludes(issue);\n }\n if (isZodIssueStringInvalidRegex(issue)) {\n return parseStringInvalidRegex(issue, options);\n }\n if (isZodIssueStringInvalidJWT(issue)) {\n return parseStringInvalidJWT(issue, options);\n }\n\n return {\n type: issue.code,\n path: issue.path,\n message: `invalid ${issue.format}`,\n };\n }\n }\n}\nfunction isZodIssueStringStartsWith(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>\n): issue is zod.$ZodRawIssue<zod.$ZodIssueStringStartsWith> {\n return issue.format === 'starts_with';\n}\n\nfunction parseStringStartsWith(\n issue: zod.$ZodRawIssue<zod.$ZodIssueStringStartsWith>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `value must start with \"${issue.prefix}\"`,\n };\n}\n\nfunction isZodIssueStringEndsWith(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>\n): issue is zod.$ZodRawIssue<zod.$ZodIssueStringEndsWith> {\n return issue.format === 'ends_with';\n}\nfunction parseStringEndsWith(\n issue: zod.$ZodRawIssue<zod.$ZodIssueStringEndsWith>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `value must end with \"${issue.suffix}\"`,\n };\n}\n\nfunction isZodIssueStringIncludes(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>\n): issue is zod.$ZodRawIssue<zod.$ZodIssueStringIncludes> {\n return issue.format === 'includes';\n}\nfunction parseStringIncludes(\n issue: zod.$ZodRawIssue<zod.$ZodIssueStringIncludes>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `value must include \"${issue.includes}\"`,\n };\n}\n\nfunction isZodIssueStringInvalidRegex(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>\n): issue is zod.$ZodRawIssue<zod.$ZodIssueStringInvalidRegex> {\n return issue.format === 'regex';\n}\nfunction parseStringInvalidRegex(\n issue: zod.$ZodRawIssue<zod.$ZodIssueStringInvalidRegex>,\n options: Pick<ErrorMapOptions, 'displayInvalidFormatDetails'> = {\n displayInvalidFormatDetails: false,\n }\n): AbstractSyntaxTree {\n let message = 'value must match pattern';\n if (options.displayInvalidFormatDetails) {\n message += ` \"${issue.pattern}\"`;\n }\n\n return {\n type: issue.code,\n path: issue.path,\n message,\n };\n}\n\nfunction isZodIssueStringInvalidJWT(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidStringFormat>\n): issue is zod.$ZodRawIssue<zod.$ZodIssueStringInvalidJWT> {\n return issue.format === 'jwt';\n}\nfunction parseStringInvalidJWT(\n issue: zod.$ZodRawIssue<zod.$ZodIssueStringInvalidJWT>,\n options: Pick<ErrorMapOptions, 'displayInvalidFormatDetails'> = {\n displayInvalidFormatDetails: false,\n }\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message:\n options.displayInvalidFormatDetails && issue.algorithm\n ? `invalid jwt/${issue.algorithm}`\n : `invalid jwt`,\n };\n}\n","import type { AbstractSyntaxTree } from './types.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport function parseInvalidTypeIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidType>\n): AbstractSyntaxTree {\n let message = `expected ${issue.expected}`;\n\n // note: it's possible that issue.input is not defined\n if ('input' in issue) {\n message += `, received ${getTypeName(issue.input)}`;\n }\n\n return {\n type: issue.code,\n path: issue.path,\n message,\n };\n}\n\nexport function getTypeName(value: unknown): string {\n if (typeof value === 'object') {\n if (value === null) {\n return 'null';\n }\n if (value === undefined) {\n return 'undefined';\n }\n if (Array.isArray(value)) {\n return 'array';\n }\n if (value instanceof Date) {\n return 'date';\n }\n if (value instanceof RegExp) {\n return 'regexp';\n }\n if (value instanceof Map) {\n return 'map';\n }\n if (value instanceof Set) {\n return 'set';\n }\n if (value instanceof Error) {\n return 'error';\n }\n if (value instanceof Function) {\n return 'function';\n }\n return 'object';\n }\n\n return typeof value;\n}\n","import type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree } from './types.ts';\n\nexport function parseInvalidUnionIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidUnion>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: issue.message ?? 'Invalid input',\n };\n}\n","import type { util } from 'zod/v4/core';\n\nexport function stringifySymbol(symbol: symbol): string {\n return symbol.description ?? '';\n}\n\nexport type StringifyValueOptions = {\n wrapStringValueInQuote?: boolean;\n localization?: boolean | Intl.LocalesArgument;\n};\n\nexport function stringify(\n value: util.Primitive | Date,\n options: StringifyValueOptions = {}\n): string {\n switch (typeof value) {\n case 'symbol':\n return stringifySymbol(value);\n case 'bigint':\n case 'number': {\n switch (options.localization) {\n case true:\n return value.toLocaleString();\n case false:\n return value.toString();\n default:\n return value.toLocaleString(options.localization);\n }\n }\n case 'string': {\n if (options.wrapStringValueInQuote) {\n return `\"${value}\"`;\n }\n return value;\n }\n default: {\n if (value instanceof Date) {\n switch (options.localization) {\n case true:\n return value.toLocaleString();\n case false:\n return value.toISOString();\n default:\n return value.toLocaleString(options.localization);\n }\n }\n return String(value);\n }\n }\n}\n","import { stringify } from './stringify.ts';\nimport type { util } from 'zod/v4/core';\n\nexport type JoinValuesOptions = {\n separator: string;\n lastSeparator?: string;\n wrapStringValuesInQuote?: boolean;\n maxValuesToDisplay?: number;\n};\n\nexport function joinValues(\n values: Array<util.Primitive>,\n options: JoinValuesOptions\n): string {\n const valuesToDisplay = (\n options.maxValuesToDisplay\n ? values.slice(0, options.maxValuesToDisplay)\n : values\n ).map((value) => {\n return stringify(value, {\n wrapStringValueInQuote: options.wrapStringValuesInQuote,\n });\n });\n\n // add remaining values count (if any)\n // this is to avoid displaying too many values in the error message\n // and to keep the message concise\n // e.g. `\"foo\", \"bar\", \"baz\" or 3 more value(s)`\n if (valuesToDisplay.length < values.length) {\n valuesToDisplay.push(\n `${values.length - valuesToDisplay.length} more value(s)`\n );\n }\n\n return valuesToDisplay.reduce<string>((acc, value, index) => {\n if (index > 0) {\n if (index === valuesToDisplay.length - 1 && options.lastSeparator) {\n acc += options.lastSeparator;\n } else {\n acc += options.separator;\n }\n }\n\n acc += value;\n\n return acc;\n }, '');\n}\n","import { joinValues } from '../../utils/joinValues.ts';\nimport { stringify } from '../../utils/stringify.ts';\nimport type { AbstractSyntaxTree, ErrorMapOptions } from './types.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport function parseInvalidValueIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueInvalidValue>,\n options: Pick<\n ErrorMapOptions,\n | 'allowedValuesSeparator'\n | 'maxAllowedValuesToDisplay'\n | 'wrapAllowedValuesInQuote'\n | 'allowedValuesLastSeparator'\n >\n): AbstractSyntaxTree {\n let message: string;\n\n if (issue.values.length === 0) {\n message = 'invalid value';\n } else if (issue.values.length === 1) {\n const valueStr = stringify(issue.values[0], {\n wrapStringValueInQuote: true,\n });\n message = `expected value to be ${valueStr}`;\n } else {\n const valuesStr = joinValues(issue.values, {\n separator: options.allowedValuesSeparator,\n lastSeparator: options.allowedValuesLastSeparator,\n wrapStringValuesInQuote: options.wrapAllowedValuesInQuote,\n maxValuesToDisplay: options.maxAllowedValuesToDisplay,\n });\n message = `expected value to be one of ${valuesStr}`;\n }\n\n return {\n type: issue.code,\n path: issue.path,\n message,\n };\n}\n","import type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree } from './types.ts';\n\nexport function parseNotMultipleOfIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueNotMultipleOf>\n): AbstractSyntaxTree {\n return {\n type: issue.code,\n path: issue.path,\n message: `expected multiple of ${issue.divisor}`,\n };\n}\n","import { stringify } from '../../utils/stringify.ts';\nimport type { AbstractSyntaxTree, ErrorMapOptions } from './types.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport function parseTooBigIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueTooBig>,\n options: Pick<ErrorMapOptions, 'dateLocalization' | 'numberLocalization'>\n): AbstractSyntaxTree {\n const maxValueStr =\n issue.origin === 'date'\n ? stringify(new Date(issue.maximum as number), {\n localization: options.dateLocalization,\n })\n : stringify(issue.maximum, {\n localization: options.numberLocalization,\n });\n\n switch (issue.origin) {\n case 'number':\n case 'int':\n case 'bigint': {\n return {\n type: issue.code,\n path: issue.path,\n message: `number must be less than${\n issue.inclusive ? ' or equal to' : ''\n } ${maxValueStr}`,\n };\n }\n case 'string': {\n return {\n type: issue.code,\n path: issue.path,\n message: `string must contain at most ${maxValueStr} character(s)`,\n };\n }\n case 'date': {\n return {\n type: issue.code,\n path: issue.path,\n message: `date must be ${\n issue.inclusive ? 'prior or equal to' : 'prior to'\n } \"${maxValueStr}\"`,\n };\n }\n case 'array': {\n return {\n type: issue.code,\n path: issue.path,\n message: `array must contain at most ${maxValueStr} item(s)`,\n };\n }\n case 'set': {\n return {\n type: issue.code,\n path: issue.path,\n message: `set must contain at most ${maxValueStr} item(s)`,\n };\n }\n case 'file': {\n return {\n type: issue.code,\n path: issue.path,\n message: `file must not exceed ${maxValueStr} byte(s) in size`,\n };\n }\n default:\n return {\n type: issue.code,\n path: issue.path,\n message: `value must be less than${\n issue.inclusive ? ' or equal to' : ''\n } ${maxValueStr}`,\n };\n }\n}\n","import { stringify } from '../../utils/stringify.ts';\nimport type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree, ErrorMapOptions } from './types.ts';\n\nexport function parseTooSmallIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueTooSmall>,\n options: Pick<ErrorMapOptions, 'dateLocalization' | 'numberLocalization'>\n): AbstractSyntaxTree {\n const minValueStr =\n issue.origin === 'date'\n ? stringify(new Date(issue.minimum as number), {\n localization: options.dateLocalization,\n })\n : stringify(issue.minimum, {\n localization: options.numberLocalization,\n });\n\n switch (issue.origin) {\n case 'number':\n case 'int':\n case 'bigint': {\n return {\n type: issue.code,\n path: issue.path,\n message: `number must be greater than${\n issue.inclusive ? ' or equal to' : ''\n } ${minValueStr}`,\n };\n }\n case 'date': {\n return {\n type: issue.code,\n path: issue.path,\n message: `date must be ${\n issue.inclusive ? 'later or equal to' : 'later to'\n } \"${minValueStr}\"`,\n };\n }\n case 'string': {\n return {\n type: issue.code,\n path: issue.path,\n message: `string must contain at least ${minValueStr} character(s)`,\n };\n }\n case 'array': {\n return {\n type: issue.code,\n path: issue.path,\n message: `array must contain at least ${minValueStr} item(s)`,\n };\n }\n case 'set': {\n return {\n type: issue.code,\n path: issue.path,\n message: `set must contain at least ${minValueStr} item(s)`,\n };\n }\n case 'file': {\n return {\n type: issue.code,\n path: issue.path,\n message: `file must be at least ${minValueStr} byte(s) in size`,\n };\n }\n default:\n return {\n type: issue.code,\n path: issue.path,\n message: `value must be greater than${\n issue.inclusive ? ' or equal to' : ''\n } ${minValueStr}`,\n };\n }\n}\n","import { joinValues } from '../../utils/joinValues.ts';\nimport type * as zod from 'zod/v4/core';\nimport type { AbstractSyntaxTree, ErrorMapOptions } from './types.ts';\n\nexport function parseUnrecognizedKeysIssue(\n issue: zod.$ZodRawIssue<zod.$ZodIssueUnrecognizedKeys>,\n options: Pick<\n ErrorMapOptions,\n | 'unrecognizedKeysSeparator'\n | 'unrecognizedKeysLastSeparator'\n | 'wrapUnrecognizedKeysInQuote'\n | 'maxUnrecognizedKeysToDisplay'\n >\n): AbstractSyntaxTree {\n const keysStr = joinValues(issue.keys, {\n separator: options.unrecognizedKeysSeparator,\n lastSeparator: options.unrecognizedKeysLastSeparator,\n wrapStringValuesInQuote: options.wrapUnrecognizedKeysInQuote,\n maxValuesToDisplay: options.maxUnrecognizedKeysToDisplay,\n });\n\n return {\n type: issue.code,\n path: issue.path,\n message: `unrecognized key(s) ${keysStr} in object`,\n };\n}\n","import { parseCustomIssue } from './custom.ts';\nimport { parseInvalidElementIssue } from './invalidElement.ts';\nimport { parseInvalidKeyIssue } from './invalidKey.ts';\nimport { parseInvalidStringFormatIssue } from './invalidStringFormat.ts';\nimport { parseInvalidTypeIssue } from './invalidType.ts';\nimport { parseInvalidUnionIssue } from './invalidUnion.ts';\nimport { parseInvalidValueIssue } from './invalidValue.ts';\nimport { parseNotMultipleOfIssue } from './notMultipleOf.ts';\nimport { parseTooBigIssue } from './tooBig.ts';\nimport { parseTooSmallIssue } from './tooSmall.ts';\nimport { parseUnrecognizedKeysIssue } from './unrecognizedKeys.ts';\nimport type {\n AbstractSyntaxTree,\n ErrorMapOptions,\n IssueType,\n} from './types.ts';\nimport type * as zod from 'zod/v4/core';\n\ntype IssueParsers = {\n [IssueCode in IssueType]: (\n issue: zod.$ZodRawIssue<Extract<zod.$ZodIssue, { code: IssueCode }>>,\n options: ErrorMapOptions\n ) => AbstractSyntaxTree;\n};\n\nconst issueParsers: IssueParsers = {\n invalid_type: parseInvalidTypeIssue,\n too_big: parseTooBigIssue,\n too_small: parseTooSmallIssue,\n invalid_format: parseInvalidStringFormatIssue,\n invalid_value: parseInvalidValueIssue,\n invalid_element: parseInvalidElementIssue,\n not_multiple_of: parseNotMultipleOfIssue,\n unrecognized_keys: parseUnrecognizedKeysIssue,\n invalid_key: parseInvalidKeyIssue,\n custom: parseCustomIssue,\n invalid_union: parseInvalidUnionIssue,\n};\n\nexport const defaultErrorMapOptions = {\n displayInvalidFormatDetails: false,\n allowedValuesSeparator: ', ',\n allowedValuesLastSeparator: ' or ',\n wrapAllowedValuesInQuote: true,\n maxAllowedValuesToDisplay: 10,\n unrecognizedKeysSeparator: ', ',\n unrecognizedKeysLastSeparator: ' and ',\n wrapUnrecognizedKeysInQuote: true,\n maxUnrecognizedKeysToDisplay: 5,\n dateLocalization: true,\n numberLocalization: true,\n} as const satisfies ErrorMapOptions;\n\nexport function createErrorMap(\n partialOptions: Partial<ErrorMapOptions> = {}\n): zod.$ZodErrorMap<zod.$ZodIssue> {\n // fill-in default options\n const options = {\n ...defaultErrorMapOptions,\n ...partialOptions,\n };\n\n const errorMap: zod.$ZodErrorMap<zod.$ZodIssue> = (issue) => {\n if (issue.code === undefined) {\n // TODO: handle this case\n return 'Not supported issue type';\n }\n\n const parseFunc = issueParsers[issue.code] as (\n iss: typeof issue,\n opts: ErrorMapOptions\n ) => AbstractSyntaxTree;\n const ast = parseFunc(issue, options);\n return ast.message;\n };\n\n return errorMap;\n}\n","export type NonEmptyArray<T> = [T, ...T[]];\n\nexport function isNonEmptyArray<T>(value: T[]): value is NonEmptyArray<T> {\n return value.length !== 0;\n}\n","import { stringifySymbol } from './stringify.ts';\nimport type { NonEmptyArray } from './NonEmptyArray.ts';\n\n/**\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#identifiers\n */\nconst identifierRegex = /[$_\\p{ID_Start}][$\\u200c\\u200d\\p{ID_Continue}]*/u;\n\nexport function joinPath(path: NonEmptyArray<PropertyKey>): string {\n if (path.length === 1) {\n let propertyKey = path[0];\n\n if (typeof propertyKey === 'symbol') {\n propertyKey = stringifySymbol(propertyKey);\n }\n\n return propertyKey.toString() || '\"\"';\n }\n\n return path.reduce<string>((acc, propertyKey) => {\n // handle numeric indices\n if (typeof propertyKey === 'number') {\n return acc + '[' + propertyKey.toString() + ']';\n }\n\n // handle symbols\n if (typeof propertyKey === 'symbol') {\n propertyKey = stringifySymbol(propertyKey);\n }\n\n // handle quoted values\n if (propertyKey.includes('\"')) {\n return acc + '[\"' + escapeQuotes(propertyKey) + '\"]';\n }\n\n // handle special characters\n if (!identifierRegex.test(propertyKey)) {\n return acc + '[\"' + propertyKey + '\"]';\n }\n\n // handle normal values\n const separator = acc.length === 0 ? '' : '.';\n return acc + separator + propertyKey;\n }, '');\n}\n\nfunction escapeQuotes(str: string): string {\n return str.replace(/\"/g, '\\\\\"');\n}\n","export function titleCase(value: string): string {\n if (value.length === 0) {\n return value;\n }\n return value.charAt(0).toUpperCase() + value.slice(1);\n}\n","import { joinPath } from '../utils/joinPath.ts';\nimport { isNonEmptyArray, type NonEmptyArray } from '../utils/NonEmptyArray.ts';\nimport { titleCase } from '../utils/titleCase.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport type ZodIssue = zod.$ZodIssue;\n\nexport type MessageBuilder = (issues: NonEmptyArray<ZodIssue>) => string;\n\nexport type MessageBuilderOptions = {\n prefix: string | null | undefined;\n prefixSeparator: string;\n maxIssuesInMessage: number;\n issueSeparator: string;\n unionSeparator: string;\n includePath: boolean;\n forceTitleCase: boolean;\n};\n\nexport const defaultMessageBuilderOptions: MessageBuilderOptions & {\n prefix: string;\n} = {\n prefix: 'Validation error',\n prefixSeparator: ': ',\n maxIssuesInMessage: 99, // I've got 99 problems but the b$tch ain't one\n unionSeparator: ' or ',\n issueSeparator: '; ',\n includePath: true,\n forceTitleCase: true,\n};\n\nexport function createMessageBuilder(\n partialOptions: Partial<MessageBuilderOptions> = {}\n): MessageBuilder {\n const options = {\n ...defaultMessageBuilderOptions,\n ...partialOptions,\n };\n\n return function messageBuilder(issues) {\n const message = issues\n // limit max number of issues printed in the reason section\n .slice(0, options.maxIssuesInMessage)\n // format error message\n .map((issue) => mapIssue(issue, options))\n // concat as string\n .join(options.issueSeparator);\n\n return conditionallyPrefixMessage(message, options);\n };\n}\n\nfunction mapIssue(\n issue: zod.$ZodIssue,\n options: MessageBuilderOptions\n): string {\n if (issue.code === 'invalid_union' && isNonEmptyArray(issue.errors)) {\n const individualMessages = issue.errors.map((issues) =>\n issues\n .map((subIssue) =>\n mapIssue(\n {\n ...subIssue,\n path: issue.path.concat(subIssue.path),\n },\n options\n )\n )\n .join(options.issueSeparator)\n );\n\n // deduplicate messages\n // and join them with the union separator\n // to create a single message for the invalid union issue\n return Array.from(new Set(individualMessages)).join(options.unionSeparator);\n }\n\n const buf = [];\n\n if (options.forceTitleCase) {\n buf.push(titleCase(issue.message));\n } else {\n buf.push(issue.message);\n }\n\n pathCondition: if (\n options.includePath &&\n issue.path !== undefined &&\n isNonEmptyArray(issue.path)\n ) {\n // handle array indices\n if (issue.path.length === 1) {\n const identifier = issue.path[0];\n\n if (typeof identifier === 'number') {\n buf.push(` at index ${identifier}`);\n break pathCondition;\n }\n }\n\n buf.push(` at \"${joinPath(issue.path)}\"`);\n }\n\n return buf.join('');\n}\n\nfunction conditionallyPrefixMessage(\n message: string,\n options: Pick<MessageBuilderOptions, 'prefix' | 'prefixSeparator'>\n): string {\n if (options.prefix != null) {\n if (message.length > 0) {\n return [options.prefix, message].join(options.prefixSeparator);\n }\n\n return options.prefix;\n }\n\n if (message.length > 0) {\n return message;\n }\n\n // if both reason and prefix are empty, return default prefix\n // to avoid having an empty error message\n return defaultMessageBuilderOptions.prefix;\n}\n","import { isNonEmptyArray } from '../utils/NonEmptyArray.ts';\nimport { fromError } from './fromError.ts';\nimport { isZodErrorLike } from './isZodErrorLike.ts';\nimport {\n createMessageBuilder,\n type MessageBuilderOptions,\n type MessageBuilder,\n} from './MessageBuilder.ts';\nimport { ValidationError } from './ValidationError.ts';\nimport type * as zod from 'zod/v4/core';\n\nexport type ZodError = zod.$ZodError;\n\nexport type FromZodErrorOptions =\n | {\n messageBuilder: MessageBuilder;\n }\n // maintain backwards compatibility\n | Partial<MessageBuilderOptions>;\n\nexport function fromZodError(\n zodError: ZodError,\n options: FromZodErrorOptions = {}\n): ValidationError {\n // perform runtime check to ensure the input is a ZodError\n // why? because people have been historically using this function incorrectly\n if (!isZodErrorLike(zodError)) {\n throw new TypeError(\n `Invalid zodError param; expected instance of ZodError. Did you mean to use the \"${fromError.name}\" method instead?`\n );\n }\n\n return fromZodErrorWithoutRuntimeCheck(zodError, options);\n}\n\nexport function fromZodErrorWithoutRuntimeCheck(\n zodError: ZodError,\n options: FromZodErrorOptions = {}\n): ValidationError {\n const zodIssues = zodError.issues;\n\n let message: string;\n if (isNonEmptyArray(zodIssues)) {\n const messageBuilder = createMessageBuilderFromOptions(options);\n message = messageBuilder(zodIssues);\n } else {\n message = zodError.message;\n }\n\n return new ValidationError(message, { cause: zodError });\n}\n\nfunction createMessageBuilderFromOptions(\n options: FromZodErrorOptions\n): MessageBuilder {\n if ('messageBuilder' in options) {\n return options.messageBuilder;\n }\n\n return createMessageBuilder(options);\n}\n","import { ValidationError } from './ValidationError.ts';\nimport { isZodErrorLike } from './isZodErrorLike.ts';\nimport {\n fromZodErrorWithoutRuntimeCheck,\n type FromZodErrorOptions,\n} from './fromZodError.ts';\n\nexport const toValidationError =\n (options: FromZodErrorOptions = {}) =>\n (err: unknown): ValidationError => {\n if (isZodErrorLike(err)) {\n return fromZodErrorWithoutRuntimeCheck(err, options);\n }\n\n if (err instanceof Error) {\n return new ValidationError(err.message, { cause: err });\n }\n\n return new ValidationError('Unknown error');\n };\n","import { toValidationError } from './toValidationError.ts';\nimport type { FromZodErrorOptions } from './fromZodError.ts';\nimport type { ValidationError } from './ValidationError.ts';\n\n/**\n * This function is a non-curried version of `toValidationError`\n */\nexport function fromError(\n err: unknown,\n options: FromZodErrorOptions = {}\n): ValidationError {\n return toValidationError(options)(err);\n}\n","import * as zod from 'zod/v4/core';\n\nimport {\n type MessageBuilder,\n type MessageBuilderOptions,\n type ZodIssue,\n createMessageBuilder,\n} from './MessageBuilder.ts';\nimport { ValidationError } from './ValidationError.ts';\n\nexport type FromZodIssueOptions =\n | {\n messageBuilder: MessageBuilder;\n }\n // maintain backwards compatibility\n | Partial<Omit<MessageBuilderOptions, 'maxIssuesInMessage'>>;\n\nexport function fromZodIssue(\n issue: ZodIssue,\n options: FromZodIssueOptions = {}\n): ValidationError {\n const messageBuilder = createMessageBuilderFromOptions(options);\n const message = messageBuilder([issue]);\n\n return new ValidationError(message, {\n cause: new zod.$ZodRealError([issue]),\n });\n}\n\nfunction createMessageBuilderFromOptions(\n options: FromZodIssueOptions\n): MessageBuilder {\n if ('messageBuilder' in options) {\n return options.messageBuilder;\n }\n\n return createMessageBuilder(options);\n}\n"],"mappings":";AAEO,SAAS,eAAe,KAAoC;AACjE,SACE,eAAe,UACf,UAAU,QACT,IAAI,SAAS,cAAc,IAAI,SAAS,gBACzC,YAAY,OACZ,MAAM,QAAQ,IAAI,MAAM;AAE5B;;;ACPO,IAAM,4BAA4B;AASlC,IAAM,kBAAN,cAA8B,MAAM;AAAA,EACzC;AAAA,EACA;AAAA,EAEA,YAAY,SAAkB,SAAwB;AACpD,UAAM,SAAS,OAAO;AACtB,SAAK,OAAO;AACZ,SAAK,UAAU,0BAA0B,OAAO;AAAA,EAClD;AAAA,EAEA,WAAmB;AACjB,WAAO,KAAK;AAAA,EACd;AACF;AAEA,SAAS,0BACP,SACsB;AACtB,MAAI,SAAS;AACX,UAAM,QAAQ,QAAQ;AACtB,QAAI,eAAe,KAAK,GAAG;AACzB,aAAO,MAAM;AAAA,IACf;AAAA,EACF;AAEA,SAAO,CAAC;AACV;;;ACpCO,SAAS,kBAAkB,KAAsC;AACtE,SAAO,eAAe;AACxB;;;ACCO,SAAS,sBAAsB,KAAsC;AAC1E,SAAO,eAAe,SAAS,IAAI,SAAS;AAC9C;;;ACJO,SAAS,iBACd,OACoB;AACpB,SAAO;AAAA,IACL,MAAM,MAAM;AAAA,IACZ,MAAM,MAAM;AAAA,IACZ,SAAS,MAAM,WAAW;AAAA,EAC5B;AACF;;;ACRO,SAAS,yBACd,OACoB;AACpB,SAAO;AAAA,IACL,MAAM,MAAM;AAAA,IACZ,MAAM,MAAM;AAAA,IACZ,SAAS,yBAAyB,MAAM,MAAM;AAAA,EAChD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AS,UACd,KACA,UAA+B,CAAC,GACf;AACjB,SAAO,kBAAkB,OAAO,EAAE,GAAG;AACvC;;;ACZA,YAAY,SAAS;AAiBd,SAAS,aACd,OACA,UAA+B,CAAC,GACf;AACjB,QAAM,iBAAiBA,iCAAgC,OAAO;AAC9D,QAAM,UAAU,eAAe,CAAC,KAAK,CAAC;AAEtC,SAAO,IAAI,gBAAgB,SAAS;AAAA,IAClC,OAAO,IAAQ,kBAAc,CAAC,KAAK,CAAC;AAAA,EACtC,CAAC;AACH;AAEA,SAASA,iCACP,SACgB;AAChB,MAAI,oBAAoB,SAAS;AAC/B,WAAO,QAAQ;AAAA,EACjB;AAEA,SAAO,qBAAqB,OAAO;AACrC;","names":["createMessageBuilderFromOptions"]}
gui/frontend/node_modules/zod/src/v4-mini/index.ts ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ import * as z from "../v4/mini/external.js";
2
+ export * from "../v4/mini/external.js";
3
+ export { z };
gui/frontend/node_modules/zod/src/v4/core/tests/index.test.ts ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, expectTypeOf, test } from "vitest";
2
+ import * as z from "zod/v3";
3
+
4
+ test("test", () => {
5
+ expect(true).toBe(true);
6
+ });
7
+
8
+ test("test2", () => {
9
+ expect(() => z.string().parse(234)).toThrowErrorMatchingInlineSnapshot(`
10
+ [ZodError: [
11
+ {
12
+ "code": "invalid_type",
13
+ "expected": "string",
14
+ "received": "number",
15
+ "path": [],
16
+ "message": "Expected string, received number"
17
+ }
18
+ ]]
19
+ `);
20
+ });
21
+
22
+ test("async validation", async () => {
23
+ const testTuple = z
24
+ .tuple([z.string().refine(async () => true), z.number().refine(async () => true)])
25
+ .refine(async () => true);
26
+ expectTypeOf<typeof testTuple._output>().toEqualTypeOf<[string, number]>();
27
+
28
+ const val = await testTuple.parseAsync(["asdf", 1234]);
29
+ expect(val).toEqual(val);
30
+
31
+ const r1 = await testTuple.safeParseAsync(["asdf", "asdf"]);
32
+ expect(r1.success).toEqual(false);
33
+ expect(r1.error!).toMatchInlineSnapshot(`
34
+ [ZodError: [
35
+ {
36
+ "code": "invalid_type",
37
+ "expected": "number",
38
+ "received": "string",
39
+ "path": [
40
+ 1
41
+ ],
42
+ "message": "Expected number, received string"
43
+ }
44
+ ]]
45
+ `);
46
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/locales/be.test.ts ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, it } from "vitest";
2
+ import be from "../../../locales/be.js";
3
+
4
+ describe("Belarusian localization", () => {
5
+ const localeError = be().localeError;
6
+
7
+ describe("pluralization rules", () => {
8
+ for (const { type, cases } of TEST_CASES) {
9
+ describe(`${type} pluralization`, () => {
10
+ for (const { count, expected } of cases) {
11
+ it(`correctly pluralizes ${count} ${type}`, () => {
12
+ const error = localeError({
13
+ code: "too_small",
14
+ minimum: count,
15
+ type: "number",
16
+ inclusive: true,
17
+ path: [],
18
+ origin: type,
19
+ input: count - 1,
20
+ });
21
+ expect(error).toContain(expected);
22
+ });
23
+ }
24
+ });
25
+ }
26
+
27
+ it("handles negative numbers correctly", () => {
28
+ const error = localeError({
29
+ code: "too_small",
30
+ minimum: -2,
31
+ type: "number",
32
+ inclusive: true,
33
+ path: [],
34
+ origin: "array",
35
+ input: -3,
36
+ });
37
+ expect(error).toContain("-2 элементы");
38
+ });
39
+
40
+ it("handles zero correctly", () => {
41
+ const error = localeError({
42
+ code: "too_small",
43
+ minimum: 0,
44
+ type: "number",
45
+ inclusive: true,
46
+ path: [],
47
+ origin: "array",
48
+ input: -1,
49
+ });
50
+ expect(error).toContain("0 элементаў");
51
+ });
52
+
53
+ it("handles bigint values correctly", () => {
54
+ const error = localeError({
55
+ code: "too_small",
56
+ minimum: BigInt(21),
57
+ type: "number",
58
+ inclusive: true,
59
+ path: [],
60
+ origin: "array",
61
+ input: BigInt(20),
62
+ });
63
+ expect(error).toContain("21 элемент");
64
+ });
65
+ });
66
+ });
67
+
68
+ const TEST_CASES = [
69
+ {
70
+ type: "array",
71
+ cases: [
72
+ { count: 1, expected: "1 элемент" },
73
+ { count: 2, expected: "2 элементы" },
74
+ { count: 5, expected: "5 элементаў" },
75
+ { count: 11, expected: "11 элементаў" },
76
+ { count: 21, expected: "21 элемент" },
77
+ { count: 22, expected: "22 элементы" },
78
+ { count: 25, expected: "25 элементаў" },
79
+ { count: 101, expected: "101 элемент" },
80
+ { count: 111, expected: "111 элементаў" },
81
+ ],
82
+ },
83
+ {
84
+ type: "set",
85
+ cases: [
86
+ { count: 1, expected: "1 элемент" },
87
+ { count: 2, expected: "2 элементы" },
88
+ { count: 5, expected: "5 элементаў" },
89
+ { count: 11, expected: "11 элементаў" },
90
+ { count: 21, expected: "21 элемент" },
91
+ { count: 22, expected: "22 элементы" },
92
+ { count: 25, expected: "25 элементаў" },
93
+ { count: 101, expected: "101 элемент" },
94
+ { count: 111, expected: "111 элементаў" },
95
+ ],
96
+ },
97
+ {
98
+ type: "string",
99
+ cases: [
100
+ { count: 1, expected: "1 сімвал" },
101
+ { count: 2, expected: "2 сімвалы" },
102
+ { count: 5, expected: "5 сімвалаў" },
103
+ { count: 11, expected: "11 сімвалаў" },
104
+ { count: 21, expected: "21 сімвал" },
105
+ { count: 22, expected: "22 сімвалы" },
106
+ { count: 25, expected: "25 сімвалаў" },
107
+ ],
108
+ },
109
+ {
110
+ type: "file",
111
+ cases: [
112
+ { count: 0, expected: "0 байтаў" },
113
+ { count: 1, expected: "1 байт" },
114
+ { count: 2, expected: "2 байты" },
115
+ { count: 5, expected: "5 байтаў" },
116
+ { count: 11, expected: "11 байтаў" },
117
+ { count: 21, expected: "21 байт" },
118
+ { count: 22, expected: "22 байты" },
119
+ { count: 25, expected: "25 байтаў" },
120
+ { count: 101, expected: "101 байт" },
121
+ { count: 110, expected: "110 байтаў" },
122
+ ],
123
+ },
124
+ ] as const;
gui/frontend/node_modules/zod/src/v4/core/tests/locales/el.test.ts ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import { z } from "../../../../index.js";
3
+ import el from "../../../locales/el.js";
4
+
5
+ test("Greek locale - too_small errors", () => {
6
+ z.config(el());
7
+
8
+ // Test string type translation
9
+ const stringSchema = z.string().min(5);
10
+ const stringResult = stringSchema.safeParse("abc");
11
+ expect(stringResult.success).toBe(false);
12
+ if (!stringResult.success) {
13
+ expect(stringResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν string να έχει >=5 χαρακτήρες");
14
+ }
15
+
16
+ // Test number type translation
17
+ const numberSchema = z.number().min(10);
18
+ const numberResult = numberSchema.safeParse(5);
19
+ expect(numberResult.success).toBe(false);
20
+ if (!numberResult.success) {
21
+ expect(numberResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν number να είναι >=10");
22
+ }
23
+
24
+ // Test array type translation
25
+ const arraySchema = z.array(z.string()).min(3);
26
+ const arrayResult = arraySchema.safeParse(["a", "b"]);
27
+ expect(arrayResult.success).toBe(false);
28
+ if (!arrayResult.success) {
29
+ expect(arrayResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν array να έχει >=3 στοιχεία");
30
+ }
31
+
32
+ // Test set type translation
33
+ const setSchema = z.set(z.string()).min(2);
34
+ const setResult = setSchema.safeParse(new Set(["a"]));
35
+ expect(setResult.success).toBe(false);
36
+ if (!setResult.success) {
37
+ expect(setResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν set να έχει >=2 στοιχεία");
38
+ }
39
+ });
40
+
41
+ test("Greek locale - too_big errors", () => {
42
+ z.config(el());
43
+
44
+ // Test string type translation
45
+ const stringSchema = z.string().max(3);
46
+ const stringResult = stringSchema.safeParse("abcde");
47
+ expect(stringResult.success).toBe(false);
48
+ if (!stringResult.success) {
49
+ expect(stringResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν string να έχει <=3 χαρακτήρες");
50
+ }
51
+
52
+ // Test number type translation
53
+ const numberSchema = z.number().max(10);
54
+ const numberResult = numberSchema.safeParse(15);
55
+ expect(numberResult.success).toBe(false);
56
+ if (!numberResult.success) {
57
+ expect(numberResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν number να είναι <=10");
58
+ }
59
+
60
+ // Test array type translation
61
+ const arraySchema = z.array(z.string()).max(2);
62
+ const arrayResult = arraySchema.safeParse(["a", "b", "c"]);
63
+ expect(arrayResult.success).toBe(false);
64
+ if (!arrayResult.success) {
65
+ expect(arrayResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν array να έχει <=2 στοιχεία");
66
+ }
67
+ });
68
+
69
+ test("Greek locale - invalid_type errors", () => {
70
+ z.config(el());
71
+
72
+ // Test string expected, number received
73
+ const stringSchema = z.string();
74
+ const stringResult = stringSchema.safeParse(123);
75
+ expect(stringResult.success).toBe(false);
76
+ if (!stringResult.success) {
77
+ expect(stringResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν string, λήφθηκε number");
78
+ }
79
+
80
+ // Test number expected, string received
81
+ const numberSchema = z.number();
82
+ const numberResult = numberSchema.safeParse("abc");
83
+ expect(numberResult.success).toBe(false);
84
+ if (!numberResult.success) {
85
+ expect(numberResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν number, λήφθηκε string");
86
+ }
87
+
88
+ // Test boolean expected, null received
89
+ const booleanSchema = z.boolean();
90
+ const booleanResult = booleanSchema.safeParse(null);
91
+ expect(booleanResult.success).toBe(false);
92
+ if (!booleanResult.success) {
93
+ expect(booleanResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν boolean, λήφθηκε null");
94
+ }
95
+
96
+ // Test array expected, object received
97
+ const arraySchema = z.array(z.string());
98
+ const arrayResult = arraySchema.safeParse({});
99
+ expect(arrayResult.success).toBe(false);
100
+ if (!arrayResult.success) {
101
+ expect(arrayResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν array, λήφθηκε object");
102
+ }
103
+ });
104
+
105
+ test("Greek locale - other error cases", () => {
106
+ z.config(el());
107
+
108
+ // Test invalid_element with map (only "map" | "set" produce invalid_element)
109
+ const mapSchema = z.map(z.bigint(), z.number());
110
+ const mapResult = mapSchema.safeParse(new Map([[BigInt(123), BigInt(123)]]));
111
+ expect(mapResult.success).toBe(false);
112
+ if (!mapResult.success) {
113
+ expect(mapResult.error.issues[0].code).toBe("invalid_element");
114
+ expect(mapResult.error.issues[0].message).toBe("Μη έγκυρη τιμή στο map");
115
+ }
116
+
117
+ // Test invalid_key with record (only "map" | "record" produce invalid_key)
118
+ const recordSchema = z.record(z.number(), z.string());
119
+ const recordResult = recordSchema.safeParse({ notANumber: "value" });
120
+ expect(recordResult.success).toBe(false);
121
+ if (!recordResult.success) {
122
+ expect(recordResult.error.issues[0].code).toBe("invalid_key");
123
+ expect(recordResult.error.issues[0].message).toBe("Μη έγκυρο κλειδί στο record");
124
+ }
125
+
126
+ // Test invalid_value with enum
127
+ const enumSchema = z.enum(["a", "b"]);
128
+ const enumResult = enumSchema.safeParse("c");
129
+ expect(enumResult.success).toBe(false);
130
+ if (!enumResult.success) {
131
+ expect(enumResult.error.issues[0].message).toBe('Μη έγκυρη επιλογή: αναμενόταν ένα από "a"|"b"');
132
+ }
133
+
134
+ // Test not_multiple_of
135
+ const multipleSchema = z.number().multipleOf(3);
136
+ const multipleResult = multipleSchema.safeParse(10);
137
+ expect(multipleResult.success).toBe(false);
138
+ if (!multipleResult.success) {
139
+ expect(multipleResult.error.issues[0].message).toBe("Μη έγκυρος αριθμός: πρέπει να είναι πολλαπλάσιο του 3");
140
+ }
141
+
142
+ // Test unrecognized_keys (single key)
143
+ const strictSchema = z.object({ a: z.string() }).strict();
144
+ const strictResult = strictSchema.safeParse({ a: "test", b: "extra" });
145
+ expect(strictResult.success).toBe(false);
146
+ if (!strictResult.success) {
147
+ expect(strictResult.error.issues[0].message).toBe('Άγνωστο κλειδί: "b"');
148
+ }
149
+
150
+ // Test unrecognized_keys (multiple keys)
151
+ const strictMultipleResult = strictSchema.safeParse({
152
+ a: "test",
153
+ b: "extra",
154
+ c: "another",
155
+ });
156
+ expect(strictMultipleResult.success).toBe(false);
157
+ if (!strictMultipleResult.success) {
158
+ expect(strictMultipleResult.error.issues[0].message).toBe('Άγνωστα κλειδιά: "b", "c"');
159
+ }
160
+
161
+ // Test invalid_union
162
+ const unionSchema = z.union([z.string(), z.number()]);
163
+ const unionResult = unionSchema.safeParse(true);
164
+ expect(unionResult.success).toBe(false);
165
+ if (!unionResult.success) {
166
+ expect(unionResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος");
167
+ }
168
+
169
+ // Test invalid_format with regex
170
+ const regexSchema = z.string().regex(/^[a-z]+$/);
171
+ const regexResult = regexSchema.safeParse("ABC123");
172
+ expect(regexResult.success).toBe(false);
173
+ if (!regexResult.success) {
174
+ expect(regexResult.error.issues[0].message).toBe(
175
+ "Μη έγκυρη συμβολοσειρά: πρέπει να ταιριάζει με το μοτίβο /^[a-z]+$/"
176
+ );
177
+ }
178
+
179
+ // Test invalid_format with startsWith
180
+ const startsWithSchema = z.string().startsWith("hello");
181
+ const startsWithResult = startsWithSchema.safeParse("world");
182
+ expect(startsWithResult.success).toBe(false);
183
+ if (!startsWithResult.success) {
184
+ expect(startsWithResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να ξεκινά με "hello"');
185
+ }
186
+
187
+ // Test invalid_format with endsWith
188
+ const endsWithSchema = z.string().endsWith("world");
189
+ const endsWithResult = endsWithSchema.safeParse("hello");
190
+ expect(endsWithResult.success).toBe(false);
191
+ if (!endsWithResult.success) {
192
+ expect(endsWithResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να τελειώνει με "world"');
193
+ }
194
+
195
+ // Test invalid_format with includes
196
+ const includesSchema = z.string().includes("test");
197
+ const includesResult = includesSchema.safeParse("hello");
198
+ expect(includesResult.success).toBe(false);
199
+ if (!includesResult.success) {
200
+ expect(includesResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να περιέχει "test"');
201
+ }
202
+ });
203
+
204
+ test("Greek locale - invalid_type with instanceof (class-name expected)", () => {
205
+ z.config(el());
206
+
207
+ // When `expected` starts with a capital letter, render an `instanceof` message,
208
+ // matching the convention used by most other locales (de, es, fr, it, etc.).
209
+ const dateSchema = z.instanceof(Date);
210
+ const dateResult = dateSchema.safeParse("not a date");
211
+ expect(dateResult.success).toBe(false);
212
+ if (!dateResult.success) {
213
+ expect(dateResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν instanceof Date, λήφθηκε string");
214
+ }
215
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/locales/en.test.ts ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import { parsedType } from "../../util.js";
3
+
4
+ test("parsedType", () => {
5
+ expect(parsedType("string")).toBe("string");
6
+ expect(parsedType(1)).toBe("number");
7
+ expect(parsedType(true)).toBe("boolean");
8
+ expect(parsedType(null)).toBe("null");
9
+ expect(parsedType(undefined)).toBe("undefined");
10
+ expect(parsedType([])).toBe("array");
11
+ expect(parsedType({})).toBe("object");
12
+ expect(parsedType(new Date())).toBe("Date");
13
+ expect(parsedType(new Map())).toBe("Map");
14
+ expect(parsedType(new Set())).toBe("Set");
15
+ expect(parsedType(new Error())).toBe("Error");
16
+
17
+ const nullPrototype = Object.create(null);
18
+ expect(parsedType(nullPrototype)).toBe("object");
19
+
20
+ const doubleNullPrototype = Object.create(Object.create(null));
21
+ expect(parsedType(doubleNullPrototype)).toBe("object");
22
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/locales/es.test.ts ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import { z } from "../../../../index.js";
3
+ import es from "../../../locales/es.js";
4
+
5
+ test("Spanish locale - type name translations in too_small errors", () => {
6
+ z.config(es());
7
+
8
+ // Test string type translation
9
+ const stringSchema = z.string().min(5);
10
+ const stringResult = stringSchema.safeParse("abc");
11
+ expect(stringResult.success).toBe(false);
12
+ if (!stringResult.success) {
13
+ expect(stringResult.error.issues[0].message).toBe(
14
+ "Demasiado pequeño: se esperaba que texto tuviera >=5 caracteres"
15
+ );
16
+ }
17
+
18
+ // Test number type translation
19
+ const numberSchema = z.number().min(10);
20
+ const numberResult = numberSchema.safeParse(5);
21
+ expect(numberResult.success).toBe(false);
22
+ if (!numberResult.success) {
23
+ expect(numberResult.error.issues[0].message).toBe("Demasiado pequeño: se esperaba que número fuera >=10");
24
+ }
25
+
26
+ // Test array type translation
27
+ const arraySchema = z.array(z.string()).min(3);
28
+ const arrayResult = arraySchema.safeParse(["a", "b"]);
29
+ expect(arrayResult.success).toBe(false);
30
+ if (!arrayResult.success) {
31
+ expect(arrayResult.error.issues[0].message).toBe(
32
+ "Demasiado pequeño: se esperaba que arreglo tuviera >=3 elementos"
33
+ );
34
+ }
35
+
36
+ // Test set type translation
37
+ const setSchema = z.set(z.string()).min(2);
38
+ const setResult = setSchema.safeParse(new Set(["a"]));
39
+ expect(setResult.success).toBe(false);
40
+ if (!setResult.success) {
41
+ expect(setResult.error.issues[0].message).toBe("Demasiado pequeño: se esperaba que conjunto tuviera >=2 elementos");
42
+ }
43
+ });
44
+
45
+ test("Spanish locale - type name translations in too_big errors", () => {
46
+ z.config(es());
47
+
48
+ // Test string type translation
49
+ const stringSchema = z.string().max(3);
50
+ const stringResult = stringSchema.safeParse("abcde");
51
+ expect(stringResult.success).toBe(false);
52
+ if (!stringResult.success) {
53
+ expect(stringResult.error.issues[0].message).toBe("Demasiado grande: se esperaba que texto tuviera <=3 caracteres");
54
+ }
55
+
56
+ // Test number type translation
57
+ const numberSchema = z.number().max(10);
58
+ const numberResult = numberSchema.safeParse(15);
59
+ expect(numberResult.success).toBe(false);
60
+ if (!numberResult.success) {
61
+ expect(numberResult.error.issues[0].message).toBe("Demasiado grande: se esperaba que número fuera <=10");
62
+ }
63
+
64
+ // Test array type translation
65
+ const arraySchema = z.array(z.string()).max(2);
66
+ const arrayResult = arraySchema.safeParse(["a", "b", "c"]);
67
+ expect(arrayResult.success).toBe(false);
68
+ if (!arrayResult.success) {
69
+ expect(arrayResult.error.issues[0].message).toBe("Demasiado grande: se esperaba que arreglo tuviera <=2 elementos");
70
+ }
71
+ });
72
+
73
+ test("Spanish locale - type name translations in invalid_type errors", () => {
74
+ z.config(es());
75
+
76
+ // Test string expected, number received
77
+ const stringSchema = z.string();
78
+ const stringResult = stringSchema.safeParse(123);
79
+ expect(stringResult.success).toBe(false);
80
+ if (!stringResult.success) {
81
+ expect(stringResult.error.issues[0].message).toBe("Entrada inválida: se esperaba texto, recibido número");
82
+ }
83
+
84
+ // Test number expected, string received
85
+ const numberSchema = z.number();
86
+ const numberResult = numberSchema.safeParse("abc");
87
+ expect(numberResult.success).toBe(false);
88
+ if (!numberResult.success) {
89
+ expect(numberResult.error.issues[0].message).toBe("Entrada inválida: se esperaba número, recibido texto");
90
+ }
91
+
92
+ // Test boolean expected, null received
93
+ const booleanSchema = z.boolean();
94
+ const booleanResult = booleanSchema.safeParse(null);
95
+ expect(booleanResult.success).toBe(false);
96
+ if (!booleanResult.success) {
97
+ expect(booleanResult.error.issues[0].message).toBe("Entrada inválida: se esperaba booleano, recibido nulo");
98
+ }
99
+
100
+ // Test array expected, object received
101
+ const arraySchema = z.array(z.string());
102
+ const arrayResult = arraySchema.safeParse({});
103
+ expect(arrayResult.success).toBe(false);
104
+ if (!arrayResult.success) {
105
+ expect(arrayResult.error.issues[0].message).toBe("Entrada inválida: se esperaba arreglo, recibido objeto");
106
+ }
107
+ });
108
+
109
+ test("Spanish locale - fallback for unknown type names", () => {
110
+ z.config(es());
111
+
112
+ // Test with a type that's not in the TypeNames dictionary
113
+ // This will test the fallback behavior
114
+ const dateSchema = z.date().min(new Date("2025-01-01"));
115
+ const dateResult = dateSchema.safeParse(new Date("2024-01-01"));
116
+ expect(dateResult.success).toBe(false);
117
+ if (!dateResult.success) {
118
+ // Should use "fecha" since we included it in TypeNames
119
+ expect(dateResult.error.issues[0].message).toContain("fecha");
120
+ }
121
+ });
122
+
123
+ test("Spanish locale - other error cases", () => {
124
+ z.config(es());
125
+
126
+ // Test invalid_element with tuple
127
+ const tupleSchema = z.tuple([z.string(), z.number()]);
128
+ const tupleResult = tupleSchema.safeParse(["abc", "not a number"]);
129
+ expect(tupleResult.success).toBe(false);
130
+ if (!tupleResult.success) {
131
+ expect(tupleResult.error.issues[0].message).toContain("Entrada inválida");
132
+ }
133
+
134
+ // Test invalid_value with enum
135
+ const enumSchema = z.enum(["a", "b"]);
136
+ const enumResult = enumSchema.safeParse("c");
137
+ expect(enumResult.success).toBe(false);
138
+ if (!enumResult.success) {
139
+ expect(enumResult.error.issues[0].message).toBe('Opción inválida: se esperaba una de "a"|"b"');
140
+ }
141
+
142
+ // Test not_multiple_of
143
+ const multipleSchema = z.number().multipleOf(3);
144
+ const multipleResult = multipleSchema.safeParse(10);
145
+ expect(multipleResult.success).toBe(false);
146
+ if (!multipleResult.success) {
147
+ expect(multipleResult.error.issues[0].message).toBe("Número inválido: debe ser múltiplo de 3");
148
+ }
149
+
150
+ // Test unrecognized_keys
151
+ const strictSchema = z.object({ a: z.string() }).strict();
152
+ const strictResult = strictSchema.safeParse({ a: "test", b: "extra" });
153
+ expect(strictResult.success).toBe(false);
154
+ if (!strictResult.success) {
155
+ expect(strictResult.error.issues[0].message).toBe('Llave desconocida: "b"');
156
+ }
157
+
158
+ // Test invalid_union
159
+ const unionSchema = z.union([z.string(), z.number()]);
160
+ const unionResult = unionSchema.safeParse(true);
161
+ expect(unionResult.success).toBe(false);
162
+ if (!unionResult.success) {
163
+ expect(unionResult.error.issues[0].message).toBe("Entrada inválida");
164
+ }
165
+
166
+ // Test invalid_format with regex
167
+ const regexSchema = z.string().regex(/^[a-z]+$/);
168
+ const regexResult = regexSchema.safeParse("ABC123");
169
+ expect(regexResult.success).toBe(false);
170
+ if (!regexResult.success) {
171
+ expect(regexResult.error.issues[0].message).toBe("Cadena inválida: debe coincidir con el patrón /^[a-z]+$/");
172
+ }
173
+
174
+ // Test invalid_format with startsWith
175
+ const startsWithSchema = z.string().startsWith("hello");
176
+ const startsWithResult = startsWithSchema.safeParse("world");
177
+ expect(startsWithResult.success).toBe(false);
178
+ if (!startsWithResult.success) {
179
+ expect(startsWithResult.error.issues[0].message).toBe('Cadena inválida: debe comenzar con "hello"');
180
+ }
181
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/locales/fr.test.ts ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import { z } from "../../../../index.js";
3
+ import fr from "../../../locales/fr.js";
4
+
5
+ test("French locale - type name translations in too_small errors", () => {
6
+ z.config(fr());
7
+
8
+ const stringResult = z.string().min(5).safeParse("abc");
9
+ expect(stringResult.success).toBe(false);
10
+ if (!stringResult.success) {
11
+ expect(stringResult.error.issues[0].message).toBe("Trop petit : chaîne doit avoir >=5 caractères");
12
+ }
13
+
14
+ const numberResult = z.number().min(10).safeParse(5);
15
+ expect(numberResult.success).toBe(false);
16
+ if (!numberResult.success) {
17
+ expect(numberResult.error.issues[0].message).toBe("Trop petit : nombre doit être >=10");
18
+ }
19
+
20
+ const arrayResult = z.array(z.string()).min(3).safeParse(["a", "b"]);
21
+ expect(arrayResult.success).toBe(false);
22
+ if (!arrayResult.success) {
23
+ expect(arrayResult.error.issues[0].message).toBe("Trop petit : tableau doit avoir >=3 éléments");
24
+ }
25
+
26
+ const setResult = z
27
+ .set(z.string())
28
+ .min(2)
29
+ .safeParse(new Set(["a"]));
30
+ expect(setResult.success).toBe(false);
31
+ if (!setResult.success) {
32
+ expect(setResult.error.issues[0].message).toBe("Trop petit : ensemble doit avoir >=2 éléments");
33
+ }
34
+ });
35
+
36
+ test("French locale - type name translations in too_big errors", () => {
37
+ z.config(fr());
38
+
39
+ const stringResult = z.string().max(3).safeParse("abcde");
40
+ expect(stringResult.success).toBe(false);
41
+ if (!stringResult.success) {
42
+ expect(stringResult.error.issues[0].message).toBe("Trop grand : chaîne doit avoir <=3 caractères");
43
+ }
44
+
45
+ const numberResult = z.number().max(10).safeParse(15);
46
+ expect(numberResult.success).toBe(false);
47
+ if (!numberResult.success) {
48
+ expect(numberResult.error.issues[0].message).toBe("Trop grand : nombre doit être <=10");
49
+ }
50
+
51
+ const arrayResult = z.array(z.string()).max(2).safeParse(["a", "b", "c"]);
52
+ expect(arrayResult.success).toBe(false);
53
+ if (!arrayResult.success) {
54
+ expect(arrayResult.error.issues[0].message).toBe("Trop grand : tableau doit avoir <=2 éléments");
55
+ }
56
+ });
57
+
58
+ test("French locale - type name translations in invalid_type errors", () => {
59
+ z.config(fr());
60
+
61
+ const stringResult = z.string().safeParse(123);
62
+ expect(stringResult.success).toBe(false);
63
+ if (!stringResult.success) {
64
+ expect(stringResult.error.issues[0].message).toBe("Entrée invalide : chaîne attendu, nombre reçu");
65
+ }
66
+
67
+ const arrayResult = z.array(z.string()).safeParse({});
68
+ expect(arrayResult.success).toBe(false);
69
+ if (!arrayResult.success) {
70
+ expect(arrayResult.error.issues[0].message).toBe("Entrée invalide : tableau attendu, objet reçu");
71
+ }
72
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/locales/he.test.ts ADDED
@@ -0,0 +1,379 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { beforeEach, describe, expect, test } from "vitest";
2
+ import { z } from "../../../../index.js";
3
+ import he from "../../../locales/he.js";
4
+
5
+ describe("Hebrew localization", () => {
6
+ beforeEach(() => {
7
+ z.config(he());
8
+ });
9
+
10
+ describe("too_small errors with definite article and gendered verbs", () => {
11
+ test("string type (feminine - צריכה)", () => {
12
+ const schema = z.string().min(3);
13
+ const result = schema.safeParse("ab");
14
+ expect(result.success).toBe(false);
15
+ if (!result.success) {
16
+ expect(result.error.issues[0].message).toBe("קצר מדי: המחרוזת צריכה להכיל 3 תווים או יותר");
17
+ }
18
+ });
19
+
20
+ test("number type (masculine - צריך)", () => {
21
+ const schema = z.number().min(10);
22
+ const result = schema.safeParse(5);
23
+ expect(result.success).toBe(false);
24
+ if (!result.success) {
25
+ expect(result.error.issues[0].message).toBe("קטן מדי: המספר צריך להיות גדול או שווה ל-10");
26
+ }
27
+ });
28
+
29
+ test("array type (masculine - צריך)", () => {
30
+ const schema = z.array(z.string()).min(1);
31
+ const result = schema.safeParse([]);
32
+ expect(result.success).toBe(false);
33
+ if (!result.success) {
34
+ expect(result.error.issues[0].message).toBe("קטן מדי: המערך צריך להכיל לפחות פריט אחד");
35
+ }
36
+ });
37
+
38
+ test("set type (feminine - צריכה)", () => {
39
+ const schema = z.set(z.string()).min(2);
40
+ const result = schema.safeParse(new Set(["a"]));
41
+ expect(result.success).toBe(false);
42
+ if (!result.success) {
43
+ expect(result.error.issues[0].message).toBe("קטן מדי: הקבוצה (Set) צריכה להכיל 2 פריטים או יותר");
44
+ }
45
+ });
46
+ });
47
+
48
+ describe("too_big errors with definite article and gendered verbs", () => {
49
+ test("string type (feminine - צריכה)", () => {
50
+ const schema = z.string().max(3);
51
+ const result = schema.safeParse("abcde");
52
+ expect(result.success).toBe(false);
53
+ if (!result.success) {
54
+ expect(result.error.issues[0].message).toBe("ארוך מדי: המחרוזת צריכה להכיל 3 תווים או פחות");
55
+ }
56
+ });
57
+
58
+ test("number type (masculine - צריך)", () => {
59
+ const schema = z.number().max(365);
60
+ const result = schema.safeParse(400);
61
+ expect(result.success).toBe(false);
62
+ if (!result.success) {
63
+ expect(result.error.issues[0].message).toBe("גדול מדי: המספר צריך להיות קטן או שווה ל-365");
64
+ }
65
+ });
66
+
67
+ test("array max", () => {
68
+ const schema = z.array(z.string()).max(2);
69
+ const result = schema.safeParse(["a", "b", "c"]);
70
+ expect(result.success).toBe(false);
71
+ if (!result.success) {
72
+ expect(result.error.issues[0].message).toBe("גדול מדי: המערך צריך להכיל 2 פריטים או פחות");
73
+ }
74
+ });
75
+ });
76
+
77
+ describe("invalid_type errors with definite article and gendered verbs", () => {
78
+ test("string expected (feminine), number received", () => {
79
+ const schema = z.string();
80
+ const result = schema.safeParse(123);
81
+ expect(result.success).toBe(false);
82
+ if (!result.success) {
83
+ expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות מחרוזת, התקבל מספר");
84
+ }
85
+ });
86
+
87
+ test("number expected (masculine), string received", () => {
88
+ const schema = z.number();
89
+ const result = schema.safeParse("abc");
90
+ expect(result.success).toBe(false);
91
+ if (!result.success) {
92
+ expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות מספר, התקבל מחרוזת");
93
+ }
94
+ });
95
+
96
+ test("boolean expected (masculine), null received", () => {
97
+ const schema = z.boolean();
98
+ const result = schema.safeParse(null);
99
+ expect(result.success).toBe(false);
100
+ if (!result.success) {
101
+ expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות ערך בוליאני, התקבל ערך ריק (null)");
102
+ }
103
+ });
104
+
105
+ test("array expected (masculine), object received", () => {
106
+ const schema = z.array(z.string());
107
+ const result = schema.safeParse({});
108
+ expect(result.success).toBe(false);
109
+ if (!result.success) {
110
+ expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות מערך, התקבל אובייקט");
111
+ }
112
+ });
113
+
114
+ test("object expected (masculine), array received", () => {
115
+ const schema = z.object({ a: z.string() });
116
+ const result = schema.safeParse([]);
117
+ expect(result.success).toBe(false);
118
+ if (!result.success) {
119
+ expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות אובייקט, התקבל מערך");
120
+ }
121
+ });
122
+
123
+ test("function expected (feminine), string received", () => {
124
+ const schema = z.function();
125
+ const result = schema.safeParse("not a function");
126
+ expect(result.success).toBe(false);
127
+ if (!result.success) {
128
+ expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות פונקציה, התקבל מחרוזת");
129
+ }
130
+ });
131
+ });
132
+
133
+ describe("gendered verbs consistency", () => {
134
+ test("feminine types use צריכה", () => {
135
+ const feminineTypes = [
136
+ { schema: z.string().min(5), input: "abc" },
137
+ { schema: z.set(z.string()).min(2), input: new Set(["a"]) },
138
+ ];
139
+
140
+ for (const { schema, input } of feminineTypes) {
141
+ const result = schema.safeParse(input);
142
+ expect(result.success).toBe(false);
143
+ if (!result.success) {
144
+ expect(result.error.issues[0].message).toContain("צריכה");
145
+ }
146
+ }
147
+ });
148
+
149
+ test("masculine types use צריך", () => {
150
+ const masculineTypes = [
151
+ { schema: z.number().min(10), input: 5 },
152
+ { schema: z.array(z.string()).min(2), input: ["a"] },
153
+ ];
154
+
155
+ for (const { schema, input } of masculineTypes) {
156
+ const result = schema.safeParse(input);
157
+ expect(result.success).toBe(false);
158
+ if (!result.success) {
159
+ expect(result.error.issues[0].message).toContain("צריך");
160
+ }
161
+ }
162
+ });
163
+ });
164
+
165
+ describe("invalid_value with enum", () => {
166
+ test("single value", () => {
167
+ const schema = z.enum(["a"]);
168
+ const result = schema.safeParse("b");
169
+ expect(result.success).toBe(false);
170
+ if (!result.success) {
171
+ expect(result.error.issues[0].message).toBe('ערך לא תקין: הערך חייב להיות "a"');
172
+ }
173
+ });
174
+
175
+ test("two values", () => {
176
+ const schema = z.enum(["a", "b"]);
177
+ const result = schema.safeParse("c");
178
+ expect(result.success).toBe(false);
179
+ if (!result.success) {
180
+ expect(result.error.issues[0].message).toBe('ערך לא תקין: האפשרויות המתאימות הן "a" או "b"');
181
+ }
182
+ });
183
+
184
+ test("multiple values", () => {
185
+ const schema = z.enum(["a", "b", "c"]);
186
+ const result = schema.safeParse("d");
187
+ expect(result.success).toBe(false);
188
+ if (!result.success) {
189
+ expect(result.error.issues[0].message).toBe('ערך לא תקין: האפשרויות המתאימות הן "a", "b" או "c"');
190
+ }
191
+ });
192
+ });
193
+
194
+ describe("other error types", () => {
195
+ test("not_multiple_of", () => {
196
+ const schema = z.number().multipleOf(3);
197
+ const result = schema.safeParse(10);
198
+ expect(result.success).toBe(false);
199
+ if (!result.success) {
200
+ expect(result.error.issues[0].message).toBe("מספר לא תקין: חייב להיות מכפלה של 3");
201
+ }
202
+ });
203
+
204
+ test("unrecognized_keys - single key", () => {
205
+ const schema = z.object({ a: z.string() }).strict();
206
+ const result = schema.safeParse({ a: "test", b: "extra" });
207
+ expect(result.success).toBe(false);
208
+ if (!result.success) {
209
+ expect(result.error.issues[0].message).toBe('מפתח לא מזוהה: "b"');
210
+ }
211
+ });
212
+
213
+ test("unrecognized_keys - multiple keys", () => {
214
+ const schema = z.object({ a: z.string() }).strict();
215
+ const result = schema.safeParse({ a: "test", b: "extra", c: "more" });
216
+ expect(result.success).toBe(false);
217
+ if (!result.success) {
218
+ expect(result.error.issues[0].message).toBe('מפתחות לא מזוהים: "b", "c"');
219
+ }
220
+ });
221
+
222
+ test("invalid_union", () => {
223
+ const schema = z.union([z.string(), z.number()]);
224
+ const result = schema.safeParse(true);
225
+ expect(result.success).toBe(false);
226
+ if (!result.success) {
227
+ expect(result.error.issues[0].message).toBe("קלט לא תקין");
228
+ }
229
+ });
230
+
231
+ test("invalid_key in object", () => {
232
+ const schema = z.record(z.number(), z.string());
233
+ const result = schema.safeParse({ notANumber: "value" });
234
+ expect(result.success).toBe(false);
235
+ if (!result.success) {
236
+ expect(result.error.issues[0].message).toBe("שדה לא תקין באובייקט");
237
+ }
238
+ });
239
+ });
240
+
241
+ describe("invalid_format with string checks", () => {
242
+ test("startsWith", () => {
243
+ const schema = z.string().startsWith("hello");
244
+ const result = schema.safeParse("world");
245
+ expect(result.success).toBe(false);
246
+ if (!result.success) {
247
+ expect(result.error.issues[0].message).toBe('המחרוזת חייבת להתחיל ב "hello"');
248
+ }
249
+ });
250
+
251
+ test("endsWith", () => {
252
+ const schema = z.string().endsWith("world");
253
+ const result = schema.safeParse("hello");
254
+ expect(result.success).toBe(false);
255
+ if (!result.success) {
256
+ expect(result.error.issues[0].message).toBe('המחרוזת חייבת להסתיים ב "world"');
257
+ }
258
+ });
259
+
260
+ test("includes", () => {
261
+ const schema = z.string().includes("test");
262
+ const result = schema.safeParse("hello world");
263
+ expect(result.success).toBe(false);
264
+ if (!result.success) {
265
+ expect(result.error.issues[0].message).toBe('המחרוזת חייבת לכלול "test"');
266
+ }
267
+ });
268
+
269
+ test("regex", () => {
270
+ const schema = z.string().regex(/^[a-z]+$/);
271
+ const result = schema.safeParse("ABC123");
272
+ expect(result.success).toBe(false);
273
+ if (!result.success) {
274
+ expect(result.error.issues[0].message).toBe("המחרוזת חייבת להתאים לתבנית /^[a-z]+$/");
275
+ }
276
+ });
277
+ });
278
+
279
+ describe("invalid_format with common formats", () => {
280
+ test("email", () => {
281
+ const schema = z.string().email();
282
+ const result = schema.safeParse("not-an-email");
283
+ expect(result.success).toBe(false);
284
+ if (!result.success) {
285
+ expect(result.error.issues[0].message).toBe("כתובת אימייל לא תקינה");
286
+ }
287
+ });
288
+
289
+ test("url", () => {
290
+ const schema = z.string().url();
291
+ const result = schema.safeParse("not-a-url");
292
+ expect(result.success).toBe(false);
293
+ if (!result.success) {
294
+ expect(result.error.issues[0].message).toBe("כתובת רשת לא תקינה");
295
+ }
296
+ });
297
+
298
+ test("uuid", () => {
299
+ const schema = z.string().uuid();
300
+ const result = schema.safeParse("not-a-uuid");
301
+ expect(result.success).toBe(false);
302
+ if (!result.success) {
303
+ expect(result.error.issues[0].message).toBe("UUID לא תקין");
304
+ }
305
+ });
306
+ });
307
+
308
+ describe("tuple validation", () => {
309
+ test("invalid element type in tuple shows full error message", () => {
310
+ const schema = z.tuple([z.string(), z.number()]);
311
+ const result = schema.safeParse(["abc", "not a number"]);
312
+ expect(result.success).toBe(false);
313
+ if (!result.success) {
314
+ expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות מספר, התקבל מחרוזת");
315
+ }
316
+ });
317
+ });
318
+
319
+ describe("inclusive vs exclusive bounds", () => {
320
+ test("inclusive minimum (>=)", () => {
321
+ const schema = z.number().min(10);
322
+ const result = schema.safeParse(5);
323
+ expect(result.success).toBe(false);
324
+ if (!result.success) {
325
+ expect(result.error.issues[0].message).toBe("קטן מדי: המספר צריך להיות גדול או שווה ל-10");
326
+ }
327
+ });
328
+
329
+ test("exclusive minimum (>)", () => {
330
+ const schema = z.number().gt(10);
331
+ const result = schema.safeParse(10);
332
+ expect(result.success).toBe(false);
333
+ if (!result.success) {
334
+ expect(result.error.issues[0].message).toBe("קטן מדי: המספר צריך להיות גדול מ-10");
335
+ }
336
+ });
337
+
338
+ test("inclusive maximum (<=)", () => {
339
+ const schema = z.number().max(10);
340
+ const result = schema.safeParse(15);
341
+ expect(result.success).toBe(false);
342
+ if (!result.success) {
343
+ expect(result.error.issues[0].message).toBe("גדול מדי: המספר צריך להיות קטן או שווה ל-10");
344
+ }
345
+ });
346
+
347
+ test("exclusive maximum (<)", () => {
348
+ const schema = z.number().lt(10);
349
+ const result = schema.safeParse(10);
350
+ expect(result.success).toBe(false);
351
+ if (!result.success) {
352
+ expect(result.error.issues[0].message).toBe("גדול מדי: המספר צריך להיות קטן מ-10");
353
+ }
354
+ });
355
+ });
356
+
357
+ describe("all type names with definite article", () => {
358
+ test("verifies all type translations are correct", () => {
359
+ const types = [
360
+ { schema: z.string(), expected: "מחרוזת", input: 123 },
361
+ { schema: z.number(), expected: "מספר", input: "abc" },
362
+ { schema: z.boolean(), expected: "ערך בוליאני", input: "abc" },
363
+ { schema: z.bigint(), expected: "BigInt", input: "abc" },
364
+ { schema: z.date(), expected: "תאריך", input: "abc" },
365
+ { schema: z.array(z.any()), expected: "מערך", input: "abc" },
366
+ { schema: z.object({}), expected: "אובייקט", input: "abc" },
367
+ { schema: z.function(), expected: "פונקציה", input: "abc" },
368
+ ];
369
+
370
+ for (const { schema, expected, input } of types) {
371
+ const result = schema.safeParse(input);
372
+ expect(result.success).toBe(false);
373
+ if (!result.success) {
374
+ expect(result.error.issues[0].message).toContain(expected);
375
+ }
376
+ }
377
+ });
378
+ });
379
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/locales/hr.test.ts ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import { z } from "../../../../index.js";
3
+ import hr from "../../../locales/hr.js";
4
+
5
+ test("Croatian locale - type name translations in too_small errors", () => {
6
+ z.config(hr());
7
+
8
+ // Test string type translation
9
+ const stringSchema = z.string().min(5);
10
+ const stringResult = stringSchema.safeParse("abc");
11
+ expect(stringResult.success).toBe(false);
12
+ if (!stringResult.success) {
13
+ expect(stringResult.error.issues[0].message).toBe("Premalo: očekivano da tekst ima >=5 znakova");
14
+ }
15
+
16
+ // Test number type translation
17
+ const numberSchema = z.number().min(10);
18
+ const numberResult = numberSchema.safeParse(5);
19
+ expect(numberResult.success).toBe(false);
20
+ if (!numberResult.success) {
21
+ expect(numberResult.error.issues[0].message).toBe("Premalo: očekivano da broj bude >=10");
22
+ }
23
+
24
+ // Test array type translation
25
+ const arraySchema = z.array(z.string()).min(3);
26
+ const arrayResult = arraySchema.safeParse(["a", "b"]);
27
+ expect(arrayResult.success).toBe(false);
28
+ if (!arrayResult.success) {
29
+ expect(arrayResult.error.issues[0].message).toBe("Premalo: očekivano da niz ima >=3 stavki");
30
+ }
31
+
32
+ // Test set type translation
33
+ const setSchema = z.set(z.string()).min(2);
34
+ const setResult = setSchema.safeParse(new Set(["a"]));
35
+ expect(setResult.success).toBe(false);
36
+ if (!setResult.success) {
37
+ expect(setResult.error.issues[0].message).toBe("Premalo: očekivano da skup ima >=2 stavki");
38
+ }
39
+ });
40
+
41
+ test("Croatian locale - type name translations in too_big errors", () => {
42
+ z.config(hr());
43
+
44
+ // Test string type translation
45
+ const stringSchema = z.string().max(3);
46
+ const stringResult = stringSchema.safeParse("abcde");
47
+ expect(stringResult.success).toBe(false);
48
+ if (!stringResult.success) {
49
+ expect(stringResult.error.issues[0].message).toBe("Preveliko: očekivano da tekst ima <=3 znakova");
50
+ }
51
+
52
+ // Test number type translation
53
+ const numberSchema = z.number().max(10);
54
+ const numberResult = numberSchema.safeParse(15);
55
+ expect(numberResult.success).toBe(false);
56
+ if (!numberResult.success) {
57
+ expect(numberResult.error.issues[0].message).toBe("Preveliko: očekivano da broj bude <=10");
58
+ }
59
+
60
+ // Test array type translation
61
+ const arraySchema = z.array(z.string()).max(2);
62
+ const arrayResult = arraySchema.safeParse(["a", "b", "c"]);
63
+ expect(arrayResult.success).toBe(false);
64
+ if (!arrayResult.success) {
65
+ expect(arrayResult.error.issues[0].message).toBe("Preveliko: očekivano da niz ima <=2 stavki");
66
+ }
67
+ });
68
+
69
+ test("Croatian locale - type name translations in invalid_type errors", () => {
70
+ z.config(hr());
71
+
72
+ // Test string expected, number received
73
+ const stringSchema = z.string();
74
+ const stringResult = stringSchema.safeParse(123);
75
+ expect(stringResult.success).toBe(false);
76
+ if (!stringResult.success) {
77
+ expect(stringResult.error.issues[0].message).toBe("Neispravan unos: očekuje se tekst, a primljeno je broj");
78
+ }
79
+
80
+ // Test number expected, string received
81
+ const numberSchema = z.number();
82
+ const numberResult = numberSchema.safeParse("abc");
83
+ expect(numberResult.success).toBe(false);
84
+ if (!numberResult.success) {
85
+ expect(numberResult.error.issues[0].message).toBe("Neispravan unos: očekuje se broj, a primljeno je tekst");
86
+ }
87
+
88
+ // Test boolean expected, null received
89
+ const booleanSchema = z.boolean();
90
+ const booleanResult = booleanSchema.safeParse(null);
91
+ expect(booleanResult.success).toBe(false);
92
+ if (!booleanResult.success) {
93
+ expect(booleanResult.error.issues[0].message).toBe("Neispravan unos: očekuje se boolean, a primljeno je null");
94
+ }
95
+
96
+ // Test array expected, object received
97
+ const arraySchema = z.array(z.string());
98
+ const arrayResult = arraySchema.safeParse({});
99
+ expect(arrayResult.success).toBe(false);
100
+ if (!arrayResult.success) {
101
+ expect(arrayResult.error.issues[0].message).toBe("Neispravan unos: očekuje se niz, a primljeno je objekt");
102
+ }
103
+ });
104
+
105
+ test("Croatian locale - other error cases", () => {
106
+ z.config(hr());
107
+
108
+ // Test invalid_element with tuple
109
+ const tupleSchema = z.tuple([z.string(), z.number()]);
110
+ const tupleResult = tupleSchema.safeParse(["abc", "not a number"]);
111
+ expect(tupleResult.success).toBe(false);
112
+ if (!tupleResult.success) {
113
+ expect(tupleResult.error.issues[0].message).toContain("Neispravan unos");
114
+ }
115
+
116
+ // Test invalid_value with enum
117
+ const enumSchema = z.enum(["a", "b"]);
118
+ const enumResult = enumSchema.safeParse("c");
119
+ expect(enumResult.success).toBe(false);
120
+ if (!enumResult.success) {
121
+ expect(enumResult.error.issues[0].message).toBe('Neispravna opcija: očekivano jedno od "a"|"b"');
122
+ }
123
+
124
+ // Test not_multiple_of
125
+ const multipleSchema = z.number().multipleOf(3);
126
+ const multipleResult = multipleSchema.safeParse(10);
127
+ expect(multipleResult.success).toBe(false);
128
+ if (!multipleResult.success) {
129
+ expect(multipleResult.error.issues[0].message).toBe("Neispravan broj: mora biti višekratnik od 3");
130
+ }
131
+
132
+ // Test unrecognized_keys
133
+ const strictSchema = z.object({ a: z.string() }).strict();
134
+ const strictResult = strictSchema.safeParse({ a: "test", b: "extra" });
135
+ expect(strictResult.success).toBe(false);
136
+ if (!strictResult.success) {
137
+ expect(strictResult.error.issues[0].message).toBe('Neprepoznat ključ: "b"');
138
+ }
139
+
140
+ // Test invalid_union
141
+ const unionSchema = z.union([z.string(), z.number()]);
142
+ const unionResult = unionSchema.safeParse(true);
143
+ expect(unionResult.success).toBe(false);
144
+ if (!unionResult.success) {
145
+ expect(unionResult.error.issues[0].message).toBe("Neispravan unos");
146
+ }
147
+
148
+ // Test invalid_format with regex
149
+ const regexSchema = z.string().regex(/^[a-z]+$/);
150
+ const regexResult = regexSchema.safeParse("ABC123");
151
+ expect(regexResult.success).toBe(false);
152
+ if (!regexResult.success) {
153
+ expect(regexResult.error.issues[0].message).toBe("Neispravan tekst: mora odgovarati uzorku /^[a-z]+$/");
154
+ }
155
+
156
+ // Test invalid_format with startsWith
157
+ const startsWithSchema = z.string().startsWith("hello");
158
+ const startsWithResult = startsWithSchema.safeParse("world");
159
+ expect(startsWithResult.success).toBe(false);
160
+ if (!startsWithResult.success) {
161
+ expect(startsWithResult.error.issues[0].message).toBe('Neispravan tekst: mora započinjati s "hello"');
162
+ }
163
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/locales/nl.test.ts ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import nl from "../../../locales/nl.js";
3
+
4
+ test("Dutch locale error messages", () => {
5
+ const { localeError } = nl();
6
+
7
+ // Test invalid_type
8
+ expect(
9
+ localeError({
10
+ code: "invalid_type",
11
+ expected: "string",
12
+ input: 123,
13
+ })
14
+ ).toBe("Ongeldige invoer: verwacht string, ontving getal");
15
+
16
+ // Test too_big with sizing
17
+ expect(
18
+ localeError({
19
+ code: "too_big",
20
+ origin: "string",
21
+ maximum: 10,
22
+ inclusive: true,
23
+ input: "test string that is too long",
24
+ })
25
+ ).toBe("Te lang: verwacht dat string <=10 tekens heeft");
26
+
27
+ // Test too_small with sizing
28
+ expect(
29
+ localeError({
30
+ code: "too_small",
31
+ origin: "array",
32
+ minimum: 5,
33
+ inclusive: false,
34
+ input: [1, 2],
35
+ })
36
+ ).toBe("Te klein: verwacht dat array >5 elementen heeft");
37
+
38
+ // Test invalid_format
39
+ expect(
40
+ localeError({
41
+ code: "invalid_format",
42
+ format: "email",
43
+ input: "invalid-email",
44
+ })
45
+ ).toBe("Ongeldig: emailadres");
46
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/locales/ru.test.ts ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, it } from "vitest";
2
+ import ru from "../../../locales/ru.js";
3
+
4
+ describe("Russian localization", () => {
5
+ const localeError = ru().localeError;
6
+
7
+ describe("pluralization rules", () => {
8
+ for (const { type, cases } of TEST_CASES) {
9
+ describe(`${type} pluralization`, () => {
10
+ for (const { count, expected } of cases) {
11
+ it(`correctly pluralizes ${count} ${type}`, () => {
12
+ const error = localeError({
13
+ code: "too_small",
14
+ minimum: count,
15
+ type: "number",
16
+ inclusive: true,
17
+ path: [],
18
+ origin: type,
19
+ input: count - 1,
20
+ });
21
+
22
+ expect(error).toContain(expected);
23
+ });
24
+ }
25
+ });
26
+ }
27
+
28
+ it("handles negative numbers correctly", () => {
29
+ const error = localeError({
30
+ code: "too_small",
31
+ minimum: -2,
32
+ type: "number",
33
+ inclusive: true,
34
+ path: [],
35
+ origin: "array",
36
+ input: -3,
37
+ });
38
+
39
+ expect(error).toContain("-2 элемента");
40
+ });
41
+
42
+ it("handles zero correctly", () => {
43
+ const error = localeError({
44
+ code: "too_small",
45
+ minimum: 0,
46
+ type: "number",
47
+ inclusive: true,
48
+ path: [],
49
+ origin: "array",
50
+ input: -1,
51
+ });
52
+
53
+ expect(error).toContain("0 элементов");
54
+ });
55
+
56
+ it("handles bigint values correctly", () => {
57
+ const error = localeError({
58
+ code: "too_small",
59
+ minimum: BigInt(21),
60
+ type: "number",
61
+ inclusive: true,
62
+ path: [],
63
+ origin: "array",
64
+ input: BigInt(20),
65
+ });
66
+
67
+ expect(error).toContain("21 элемент");
68
+ });
69
+ });
70
+ });
71
+
72
+ const TEST_CASES = [
73
+ {
74
+ type: "array",
75
+ cases: [
76
+ { count: 1, expected: "1 элемент" },
77
+ { count: 2, expected: "2 элемента" },
78
+ { count: 5, expected: "5 элементов" },
79
+ { count: 11, expected: "11 элементов" },
80
+ { count: 21, expected: "21 элемент" },
81
+ { count: 22, expected: "22 элемента" },
82
+ { count: 25, expected: "25 элементов" },
83
+ { count: 101, expected: "101 элемент" },
84
+ { count: 111, expected: "111 элементов" },
85
+ ],
86
+ },
87
+ {
88
+ type: "set",
89
+ cases: [
90
+ { count: 1, expected: "1 элемент" },
91
+ { count: 2, expected: "2 элемента" },
92
+ { count: 5, expected: "5 элементов" },
93
+ { count: 11, expected: "11 элементов" },
94
+ { count: 21, expected: "21 элемент" },
95
+ { count: 22, expected: "22 элемента" },
96
+ { count: 25, expected: "25 элементов" },
97
+ { count: 101, expected: "101 элемент" },
98
+ { count: 111, expected: "111 элементов" },
99
+ ],
100
+ },
101
+ {
102
+ type: "string",
103
+ cases: [
104
+ { count: 1, expected: "1 символ" },
105
+ { count: 2, expected: "2 символа" },
106
+ { count: 5, expected: "5 символов" },
107
+ { count: 11, expected: "11 символов" },
108
+ { count: 21, expected: "21 символ" },
109
+ { count: 22, expected: "22 символа" },
110
+ { count: 25, expected: "25 символов" },
111
+ ],
112
+ },
113
+ {
114
+ type: "file",
115
+ cases: [
116
+ { count: 0, expected: "0 байт" },
117
+ { count: 1, expected: "1 байт" },
118
+ { count: 2, expected: "2 байта" },
119
+ { count: 5, expected: "5 байт" },
120
+ { count: 11, expected: "11 байт" },
121
+ { count: 21, expected: "21 байт" },
122
+ { count: 22, expected: "22 байта" },
123
+ { count: 25, expected: "25 байт" },
124
+ { count: 101, expected: "101 байт" },
125
+ { count: 110, expected: "110 байт" },
126
+ ],
127
+ },
128
+ ] as const;
gui/frontend/node_modules/zod/src/v4/core/tests/locales/tr.test.ts ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+ import { parsedType } from "../../util.js";
4
+
5
+ test("parsedType", () => {
6
+ expect(parsedType("string")).toBe("string");
7
+ expect(parsedType(1)).toBe("number");
8
+ expect(parsedType(true)).toBe("boolean");
9
+ expect(parsedType(null)).toBe("null");
10
+ expect(parsedType(undefined)).toBe("undefined");
11
+ expect(parsedType([])).toBe("array");
12
+ expect(parsedType({})).toBe("object");
13
+ expect(parsedType(new Date())).toBe("Date");
14
+ expect(parsedType(new Map())).toBe("Map");
15
+ expect(parsedType(new Set())).toBe("Set");
16
+ expect(parsedType(new Error())).toBe("Error");
17
+
18
+ const nullPrototype = Object.create(null);
19
+ expect(parsedType(nullPrototype)).toBe("object");
20
+
21
+ const doubleNullPrototype = Object.create(Object.create(null));
22
+ expect(parsedType(doubleNullPrototype)).toBe("object");
23
+
24
+ expect(parsedType(Number.NaN)).toBe("nan");
25
+ });
26
+
27
+ test("locales - tr", () => {
28
+ z.config(z.locales.tr());
29
+
30
+ const invalidType = z.number().safeParse("a");
31
+ expect(invalidType.error!.issues[0].code).toBe("invalid_type");
32
+ expect(invalidType.error!.issues[0].message).toBe("Geçersiz değer: beklenen number, alınan string");
33
+
34
+ const invalidType2 = z.string().safeParse(1);
35
+ expect(invalidType2.error!.issues[0].code).toBe("invalid_type");
36
+ expect(invalidType2.error!.issues[0].message).toBe("Geçersiz değer: beklenen string, alınan number");
37
+
38
+ const invalidValue = z.enum(["a", "b"]).safeParse(1);
39
+ expect(invalidValue.error!.issues[0].code).toBe("invalid_value");
40
+ expect(invalidValue.error!.issues[0].message).toBe('Geçersiz seçenek: aşağıdakilerden biri olmalı: "a"|"b"');
41
+
42
+ const tooBig = z.number().max(10).safeParse(15);
43
+ expect(tooBig.error!.issues[0].code).toBe("too_big");
44
+ expect(tooBig.error!.issues[0].message).toBe("Çok büyük: beklenen number <=10");
45
+
46
+ const tooSmall = z.number().min(10).safeParse(5);
47
+ expect(tooSmall.error!.issues[0].code).toBe("too_small");
48
+ expect(tooSmall.error!.issues[0].message).toBe("Çok küçük: beklenen number >=10");
49
+
50
+ const invalidFormatRegex = z.string().regex(/abcd/).safeParse("invalid-string");
51
+ expect(invalidFormatRegex.error!.issues[0].code).toBe("invalid_format");
52
+ expect(invalidFormatRegex.error!.issues[0].message).toBe("Geçersiz metin: /abcd/ desenine uymalı");
53
+
54
+ const invalidFormatStartsWith = z.string().startsWith("abcd").safeParse("invalid-string");
55
+ expect(invalidFormatStartsWith.error!.issues[0].code).toBe("invalid_format");
56
+ expect(invalidFormatStartsWith.error!.issues[0].message).toBe('Geçersiz metin: "abcd" ile başlamalı');
57
+
58
+ const notMultipleOf = z.number().multipleOf(3).safeParse(10);
59
+ expect(notMultipleOf.error!.issues[0].code).toBe("not_multiple_of");
60
+ expect(notMultipleOf.error!.issues[0].message).toBe("Geçersiz sayı: 3 ile tam bölünebilmeli");
61
+
62
+ const unrecognizedKeys = z.object({ a: z.string(), b: z.number() }).strict().safeParse({ a: "a", b: 1, c: 2 });
63
+ expect(unrecognizedKeys.error!.issues[0].code).toBe("unrecognized_keys");
64
+ expect(unrecognizedKeys.error!.issues[0].message).toBe('Tanınmayan anahtar: "c"');
65
+
66
+ const invalidUnion = z.union([z.string(), z.number()]).safeParse(true);
67
+ expect(invalidUnion.error!.issues[0].code).toBe("invalid_union");
68
+ expect(invalidUnion.error!.issues[0].message).toBe("Geçersiz değer");
69
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/locales/uz.test.ts ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("locales - uz", () => {
5
+ z.config(z.locales.uz());
6
+
7
+ const invalidType = z.number().safeParse("a");
8
+ expect(invalidType.error!.issues[0].code).toBe("invalid_type");
9
+ expect(invalidType.error!.issues[0].message).toBe("Noto‘g‘ri kirish: kutilgan raqam, qabul qilingan string");
10
+
11
+ const invalidType2 = z.string().safeParse(1);
12
+ expect(invalidType2.error!.issues[0].code).toBe("invalid_type");
13
+ expect(invalidType2.error!.issues[0].message).toBe("Noto‘g‘ri kirish: kutilgan string, qabul qilingan raqam");
14
+
15
+ const invalidValue = z.enum(["a", "b"]).safeParse(1);
16
+ expect(invalidValue.error!.issues[0].code).toBe("invalid_value");
17
+ expect(invalidValue.error!.issues[0].message).toBe('Noto‘g‘ri variant: quyidagilardan biri kutilgan "a"|"b"');
18
+
19
+ const tooBig = z.number().max(10).safeParse(15);
20
+ expect(tooBig.error!.issues[0].code).toBe("too_big");
21
+ expect(tooBig.error!.issues[0].message).toBe("Juda katta: kutilgan number <=10");
22
+
23
+ const tooSmall = z.number().min(10).safeParse(5);
24
+ expect(tooSmall.error!.issues[0].code).toBe("too_small");
25
+ expect(tooSmall.error!.issues[0].message).toBe("Juda kichik: kutilgan number >=10");
26
+
27
+ const invalidFormatRegex = z.string().regex(/abcd/).safeParse("invalid-string");
28
+ expect(invalidFormatRegex.error!.issues[0].code).toBe("invalid_format");
29
+ expect(invalidFormatRegex.error!.issues[0].message).toContain("shabloniga mos kelishi kerak");
30
+
31
+ const invalidFormatStartsWith = z.string().startsWith("abcd").safeParse("invalid-string");
32
+ expect(invalidFormatStartsWith.error!.issues[0].code).toBe("invalid_format");
33
+ expect(invalidFormatStartsWith.error!.issues[0].message).toContain('"abcd" bilan boshlanishi kerak');
34
+
35
+ const notMultipleOf = z.number().multipleOf(3).safeParse(10);
36
+ expect(notMultipleOf.error!.issues[0].code).toBe("not_multiple_of");
37
+ expect(notMultipleOf.error!.issues[0].message).toContain("3 ning karralisi bo‘lishi kerak");
38
+
39
+ const unrecognizedKeys = z.object({ a: z.string(), b: z.number() }).strict().safeParse({ a: "a", b: 1, c: 2 });
40
+ expect(unrecognizedKeys.error!.issues[0].code).toBe("unrecognized_keys");
41
+ expect(unrecognizedKeys.error!.issues[0].message).toContain('Noma’lum kalit: "c"');
42
+
43
+ const invalidUnion = z.union([z.string(), z.number()]).safeParse(true);
44
+ expect(invalidUnion.error!.issues[0].code).toBe("invalid_union");
45
+ expect(invalidUnion.error!.issues[0].message).toBe("Noto‘g‘ri kirish");
46
+
47
+ const tooBigString = z.string().max(5).safeParse("too long string");
48
+ expect(tooBigString.error!.issues[0].code).toBe("too_big");
49
+ expect(tooBigString.error!.issues[0].message).toContain("belgi");
50
+ expect(tooBigString.error!.issues[0].message).toContain("bo‘lishi kerak");
51
+
52
+ const tooSmallArray = z.array(z.string()).min(3).safeParse(["a", "b"]);
53
+ expect(tooSmallArray.error!.issues[0].code).toBe("too_small");
54
+ expect(tooSmallArray.error!.issues[0].message).toContain("element");
55
+ expect(tooSmallArray.error!.issues[0].message).toContain("bo‘lishi kerak");
56
+
57
+ const invalidFormatEndsWith = z.string().endsWith("xyz").safeParse("invalid-string");
58
+ expect(invalidFormatEndsWith.error!.issues[0].code).toBe("invalid_format");
59
+ expect(invalidFormatEndsWith.error!.issues[0].message).toContain('"xyz" bilan tugashi kerak');
60
+
61
+ const invalidFormatIncludes = z.string().includes("test").safeParse("invalid-string");
62
+ expect(invalidFormatIncludes.error!.issues[0].code).toBe("invalid_format");
63
+ expect(invalidFormatIncludes.error!.issues[0].message).toContain('"test" ni o‘z ichiga olishi kerak');
64
+
65
+ const invalidFormatEmail = z.string().email().safeParse("invalid-email");
66
+ expect(invalidFormatEmail.error!.issues[0].code).toBe("invalid_format");
67
+ expect(invalidFormatEmail.error!.issues[0].message).toContain("elektron pochta manzili");
68
+
69
+ const invalidFormatUrl = z.string().url().safeParse("invalid-url");
70
+ expect(invalidFormatUrl.error!.issues[0].code).toBe("invalid_format");
71
+ expect(invalidFormatUrl.error!.issues[0].message).toContain("URL");
72
+
73
+ const unrecognizedKeysMultiple = z
74
+ .object({ a: z.string(), b: z.number() })
75
+ .strict()
76
+ .safeParse({ a: "a", b: 1, c: 2, d: 3 });
77
+ expect(unrecognizedKeysMultiple.error!.issues[0].code).toBe("unrecognized_keys");
78
+ expect(unrecognizedKeysMultiple.error!.issues[0].message).toContain("Noma’lum kalitlar");
79
+
80
+ const invalidElement = z.array(z.string()).safeParse([1, 2, 3]);
81
+ expect(invalidElement.error!.issues[0].code).toBe("invalid_type");
82
+ expect(invalidElement.error!.issues[0].message).toContain("raqam");
83
+
84
+ const tooSmallMap = z
85
+ .map(z.string(), z.string())
86
+ .min(3)
87
+ .safeParse(new Map([["a", "b"]]));
88
+ expect(tooSmallMap.error!.issues[0].code).toBe("too_small");
89
+ expect(tooSmallMap.error!.issues[0].message).toContain("yozuv");
90
+ expect(tooSmallMap.error!.issues[0].message).toContain("bo‘lishi kerak");
91
+
92
+ const tooBigMap = z
93
+ .map(z.string(), z.string())
94
+ .max(2)
95
+ .safeParse(
96
+ new Map([
97
+ ["a", "b"],
98
+ ["c", "d"],
99
+ ["e", "f"],
100
+ ])
101
+ );
102
+ expect(tooBigMap.error!.issues[0].code).toBe("too_big");
103
+ expect(tooBigMap.error!.issues[0].message).toContain("yozuv");
104
+ expect(tooBigMap.error!.issues[0].message).toContain("bo‘lishi kerak");
105
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/record-constructor.test.ts ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { expect, test } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ test("record should parse objects with non-function constructor field", () => {
5
+ const schema = z.record(z.string(), z.any());
6
+
7
+ expect(() => schema.parse({ constructor: "string", key: "value" })).not.toThrow();
8
+
9
+ const result1 = schema.parse({ constructor: "string", key: "value" });
10
+ expect(result1).toEqual({ constructor: "string", key: "value" });
11
+
12
+ expect(() => schema.parse({ constructor: 123, key: "value" })).not.toThrow();
13
+
14
+ const result2 = schema.parse({ constructor: 123, key: "value" });
15
+ expect(result2).toEqual({ constructor: 123, key: "value" });
16
+
17
+ expect(() => schema.parse({ constructor: null, key: "value" })).not.toThrow();
18
+
19
+ const result3 = schema.parse({ constructor: null, key: "value" });
20
+ expect(result3).toEqual({ constructor: null, key: "value" });
21
+
22
+ expect(() => schema.parse({ constructor: {}, key: "value" })).not.toThrow();
23
+
24
+ const result4 = schema.parse({ constructor: {}, key: "value" });
25
+ expect(result4).toEqual({ constructor: {}, key: "value" });
26
+
27
+ expect(() => schema.parse({ constructor: [], key: "value" })).not.toThrow();
28
+
29
+ const result5 = schema.parse({ constructor: [], key: "value" });
30
+ expect(result5).toEqual({ constructor: [], key: "value" });
31
+
32
+ expect(() => schema.parse({ constructor: true, key: "value" })).not.toThrow();
33
+
34
+ const result6 = schema.parse({ constructor: true, key: "value" });
35
+ expect(result6).toEqual({ constructor: true, key: "value" });
36
+ });
37
+
38
+ test("record should still work with normal objects", () => {
39
+ const schema = z.record(z.string(), z.string());
40
+
41
+ expect(() => schema.parse({ normalKey: "value" })).not.toThrow();
42
+
43
+ const result1 = schema.parse({ normalKey: "value" });
44
+ expect(result1).toEqual({ normalKey: "value" });
45
+
46
+ expect(() => schema.parse({ key1: "value1", key2: "value2" })).not.toThrow();
47
+
48
+ const result2 = schema.parse({ key1: "value1", key2: "value2" });
49
+ expect(result2).toEqual({ key1: "value1", key2: "value2" });
50
+ });
51
+
52
+ test("record should validate values according to schema even with constructor field", () => {
53
+ const stringSchema = z.record(z.string(), z.string());
54
+
55
+ expect(() => stringSchema.parse({ constructor: "string", key: "value" })).not.toThrow();
56
+
57
+ expect(() => stringSchema.parse({ constructor: 123, key: "value" })).toThrow();
58
+ });
59
+
60
+ test("record should work with different key types and constructor field", () => {
61
+ const enumSchema = z.record(z.enum(["constructor", "key"]), z.string());
62
+
63
+ expect(() => enumSchema.parse({ constructor: "value1", key: "value2" })).not.toThrow();
64
+
65
+ const result = enumSchema.parse({ constructor: "value1", key: "value2" });
66
+ expect(result).toEqual({ constructor: "value1", key: "value2" });
67
+ });
68
+
69
+ test("record should skip non-enumerable own properties", () => {
70
+ const schema = z.record(z.string(), z.string());
71
+
72
+ const input = { key: "value" };
73
+ Object.defineProperty(input, "~standard", {
74
+ value: { validate: () => {}, vendor: "zod", version: 1 },
75
+ enumerable: false,
76
+ writable: false,
77
+ configurable: false,
78
+ });
79
+
80
+ const result = schema.safeParse(input);
81
+ expect(result.success).toBe(true);
82
+ if (result.success) {
83
+ expect(result.data).toEqual({ key: "value" });
84
+ expect("~standard" in result.data).toBe(false);
85
+ }
86
+ });
87
+
88
+ test("record fails on enumerable invalid values even when non-enumerable properties are present", () => {
89
+ const schema = z.record(z.string(), z.string());
90
+
91
+ const input = { key: "value", bad: 123 };
92
+ Object.defineProperty(input, "hidden", {
93
+ value: "should be ignored",
94
+ enumerable: false,
95
+ });
96
+
97
+ const result = schema.safeParse(input);
98
+ expect(result.success).toBe(false);
99
+ });
100
+
101
+ test("record validates enumerable Symbol keys and skips non-enumerable Symbol keys", () => {
102
+ const enumerableSym = Symbol.for("included");
103
+ const nonEnumerableSym = Symbol.for("hidden");
104
+ const schema = z.record(z.symbol(), z.string());
105
+
106
+ const input: Record<symbol, unknown> = { [enumerableSym]: "value" };
107
+ Object.defineProperty(input, nonEnumerableSym, {
108
+ value: 123,
109
+ enumerable: false,
110
+ });
111
+
112
+ const result = schema.safeParse(input);
113
+ expect(result.success).toBe(true);
114
+ if (result.success) {
115
+ expect(result.data[enumerableSym]).toBe("value");
116
+ expect(Object.prototype.hasOwnProperty.call(result.data, nonEnumerableSym)).toBe(false);
117
+ }
118
+ });
119
+
120
+ test("z.json() accepts z.toJSONSchema() output (issue #5714)", () => {
121
+ const schema = z.object({ name: z.string() });
122
+ const jsonSchema = z.toJSONSchema(schema);
123
+
124
+ expect(z.json().safeParse(jsonSchema).success).toBe(true);
125
+ });
gui/frontend/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { describe, expect, it } from "vitest";
2
+ import * as z from "zod/v4";
3
+
4
+ describe("Recursive Tuples Regression #5089", () => {
5
+ it("creates recursive tuple without crash", () => {
6
+ expect(() => {
7
+ const y = z.lazy((): any => z.tuple([y, y]).or(z.string()));
8
+ }).not.toThrow();
9
+ });
10
+
11
+ it("parses recursive tuple data correctly", () => {
12
+ const y = z.lazy((): any => z.tuple([y, y]).or(z.string()));
13
+
14
+ // Base case
15
+ expect(y.parse("hello")).toBe("hello");
16
+
17
+ // Recursive cases
18
+ expect(() => y.parse(["a", "b"])).not.toThrow();
19
+ expect(() => y.parse(["a", ["b", "c"]])).not.toThrow();
20
+ });
21
+
22
+ it("matches #5089 expected behavior", () => {
23
+ // Exact code from the issue
24
+ expect(() => {
25
+ const y = z.lazy((): any => z.tuple([y, y]).or(z.string()));
26
+ y.parse(["a", ["b", "c"]]);
27
+ }).not.toThrow();
28
+ });
29
+
30
+ it("handles workaround pattern", () => {
31
+ // Alternative pattern from issue discussion
32
+ expect(() => {
33
+ const y = z.lazy((): any => z.string().or(z.lazy(() => z.tuple([y, y]))));
34
+ y.parse(["a", ["b", "c"]]);
35
+ }).not.toThrow();
36
+ });
37
+
38
+ it("recursive arrays still work (comparison)", () => {
39
+ const y = z.lazy((): any => z.array(y).or(z.string()));
40
+
41
+ expect(y.parse("hello")).toBe("hello");
42
+ expect(y.parse(["hello", "world"])).toEqual(["hello", "world"]);
43
+ expect(y.parse(["a", ["b", "c"]])).toEqual(["a", ["b", "c"]]);
44
+ });
45
+ });
gui/frontend/node_modules/zod/src/v4/core/to-json-schema.ts ADDED
@@ -0,0 +1,622 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type * as core from "../core/index.js";
2
+ import type * as JSONSchema from "./json-schema.js";
3
+ import { type $ZodRegistry, globalRegistry } from "./registries.js";
4
+ import type * as schemas from "./schemas.js";
5
+ import type { StandardJSONSchemaV1, StandardSchemaWithJSONProps } from "./standard-schema.js";
6
+
7
+ export type Processor<T extends schemas.$ZodType = schemas.$ZodType> = (
8
+ schema: T,
9
+ ctx: ToJSONSchemaContext,
10
+ json: JSONSchema.BaseSchema,
11
+ params: ProcessParams
12
+ ) => void;
13
+
14
+ export interface JSONSchemaGeneratorParams {
15
+ processors: Record<string, Processor>;
16
+ /** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def.
17
+ * @default globalRegistry */
18
+ metadata?: $ZodRegistry<Record<string, any>>;
19
+ /** The JSON Schema version to target.
20
+ * - `"draft-2020-12"` — Default. JSON Schema Draft 2020-12
21
+ * - `"draft-07"` — JSON Schema Draft 7
22
+ * - `"draft-04"` — JSON Schema Draft 4
23
+ * - `"openapi-3.0"` — OpenAPI 3.0 Schema Object */
24
+ target?: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string) | undefined;
25
+ /** How to handle unrepresentable types.
26
+ * - `"throw"` — Default. Unrepresentable types throw an error
27
+ * - `"any"` — Unrepresentable types become `{}` */
28
+ unrepresentable?: "throw" | "any";
29
+ /** Arbitrary custom logic that can be used to modify the generated JSON Schema. */
30
+ override?: (ctx: {
31
+ zodSchema: schemas.$ZodTypes;
32
+ jsonSchema: JSONSchema.BaseSchema;
33
+ path: (string | number)[];
34
+ }) => void;
35
+ /** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, defaults, coerced primitives, etc.
36
+ * - `"output"` — Default. Convert the output schema.
37
+ * - `"input"` — Convert the input schema. */
38
+ io?: "input" | "output";
39
+ cycles?: "ref" | "throw";
40
+ reused?: "ref" | "inline";
41
+ external?:
42
+ | {
43
+ registry: $ZodRegistry<{ id?: string | undefined }>;
44
+ uri?: ((id: string) => string) | undefined;
45
+ defs: Record<string, JSONSchema.BaseSchema>;
46
+ }
47
+ | undefined;
48
+ }
49
+
50
+ /**
51
+ * Parameters for the toJSONSchema function.
52
+ */
53
+ export type ToJSONSchemaParams = Omit<JSONSchemaGeneratorParams, "processors" | "external">;
54
+
55
+ /**
56
+ * Parameters for the toJSONSchema function when passing a registry.
57
+ */
58
+ export interface RegistryToJSONSchemaParams extends ToJSONSchemaParams {
59
+ uri?: (id: string) => string;
60
+ }
61
+
62
+ export interface ProcessParams {
63
+ schemaPath: schemas.$ZodType[];
64
+ path: (string | number)[];
65
+ }
66
+
67
+ export interface Seen {
68
+ /** JSON Schema result for this Zod schema */
69
+ schema: JSONSchema.BaseSchema;
70
+ /** A cached version of the schema that doesn't get overwritten during ref resolution */
71
+ def?: JSONSchema.BaseSchema;
72
+ defId?: string | undefined;
73
+ /** Number of times this schema was encountered during traversal */
74
+ count: number;
75
+ /** Cycle path */
76
+ cycle?: (string | number)[] | undefined;
77
+ isParent?: boolean | undefined;
78
+ /** Schema to inherit JSON Schema properties from (set by processor for wrappers) */
79
+ ref?: schemas.$ZodType | null;
80
+ /** JSON Schema property path for this schema */
81
+ path?: (string | number)[] | undefined;
82
+ }
83
+
84
+ export interface ToJSONSchemaContext {
85
+ processors: Record<string, Processor>;
86
+ metadataRegistry: $ZodRegistry<Record<string, any>>;
87
+ target: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string);
88
+ unrepresentable: "throw" | "any";
89
+ override: (ctx: {
90
+ // must be schemas.$ZodType to prevent recursive type resolution error
91
+ zodSchema: schemas.$ZodType;
92
+ jsonSchema: JSONSchema.BaseSchema;
93
+ path: (string | number)[];
94
+ }) => void;
95
+ io: "input" | "output";
96
+ counter: number;
97
+ seen: Map<schemas.$ZodType, Seen>;
98
+ cycles: "ref" | "throw";
99
+ reused: "ref" | "inline";
100
+ external?:
101
+ | {
102
+ registry: $ZodRegistry<{ id?: string | undefined }>;
103
+ uri?: ((id: string) => string) | undefined;
104
+ defs: Record<string, JSONSchema.BaseSchema>;
105
+ }
106
+ | undefined;
107
+ }
108
+
109
+ // function initializeContext<T extends schemas.$ZodType>(inputs: JSONSchemaGeneratorParams<T>): ToJSONSchemaContext<T> {
110
+ // return {
111
+ // processor: inputs.processor,
112
+ // metadataRegistry: inputs.metadata ?? globalRegistry,
113
+ // target: inputs.target ?? "draft-2020-12",
114
+ // unrepresentable: inputs.unrepresentable ?? "throw",
115
+ // };
116
+ // }
117
+
118
+ export function initializeContext(params: JSONSchemaGeneratorParams): ToJSONSchemaContext {
119
+ // Normalize target: convert old non-hyphenated versions to hyphenated versions
120
+ let target: ToJSONSchemaContext["target"] = params?.target ?? "draft-2020-12";
121
+ if (target === "draft-4") target = "draft-04";
122
+ if (target === "draft-7") target = "draft-07";
123
+
124
+ return {
125
+ processors: params.processors ?? {},
126
+ metadataRegistry: params?.metadata ?? globalRegistry,
127
+ target,
128
+ unrepresentable: params?.unrepresentable ?? "throw",
129
+ override: (params?.override as any) ?? (() => {}),
130
+ io: params?.io ?? "output",
131
+ counter: 0,
132
+ seen: new Map(),
133
+ cycles: params?.cycles ?? "ref",
134
+ reused: params?.reused ?? "inline",
135
+ external: params?.external ?? undefined,
136
+ };
137
+ }
138
+
139
+ export function process<T extends schemas.$ZodType>(
140
+ schema: T,
141
+ ctx: ToJSONSchemaContext,
142
+ _params: ProcessParams = { path: [], schemaPath: [] }
143
+ ): JSONSchema.BaseSchema {
144
+ const def = schema._zod.def as schemas.$ZodTypes["_zod"]["def"];
145
+
146
+ // check for schema in seens
147
+ const seen = ctx.seen.get(schema);
148
+
149
+ if (seen) {
150
+ seen.count++;
151
+
152
+ // check if cycle
153
+ const isCycle = _params.schemaPath.includes(schema);
154
+ if (isCycle) {
155
+ seen.cycle = _params.path;
156
+ }
157
+
158
+ return seen.schema;
159
+ }
160
+
161
+ // initialize
162
+ const result: Seen = { schema: {}, count: 1, cycle: undefined, path: _params.path };
163
+ ctx.seen.set(schema, result);
164
+
165
+ // custom method overrides default behavior
166
+ const overrideSchema = schema._zod.toJSONSchema?.();
167
+ if (overrideSchema) {
168
+ result.schema = overrideSchema as any;
169
+ } else {
170
+ const params = {
171
+ ..._params,
172
+ schemaPath: [..._params.schemaPath, schema],
173
+ path: _params.path,
174
+ };
175
+
176
+ if (schema._zod.processJSONSchema) {
177
+ schema._zod.processJSONSchema(ctx, result.schema, params);
178
+ } else {
179
+ const _json = result.schema;
180
+ const processor = ctx.processors[def.type];
181
+ if (!processor) {
182
+ throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
183
+ }
184
+ processor(schema, ctx, _json, params);
185
+ }
186
+
187
+ const parent = schema._zod.parent as T;
188
+
189
+ if (parent) {
190
+ // Also set ref if processor didn't (for inheritance)
191
+ if (!result.ref) result.ref = parent;
192
+ process(parent, ctx, params);
193
+ ctx.seen.get(parent)!.isParent = true;
194
+ }
195
+ }
196
+
197
+ // metadata
198
+ const meta = ctx.metadataRegistry.get(schema);
199
+ if (meta) Object.assign(result.schema, meta);
200
+
201
+ if (ctx.io === "input" && isTransforming(schema)) {
202
+ // examples/defaults only apply to output type of pipe
203
+ delete result.schema.examples;
204
+ delete result.schema.default;
205
+ }
206
+
207
+ // set prefault as default
208
+ if (ctx.io === "input" && "_prefault" in result.schema) result.schema.default ??= result.schema._prefault;
209
+ delete result.schema._prefault;
210
+
211
+ // pulling fresh from ctx.seen in case it was overwritten
212
+ const _result = ctx.seen.get(schema)!;
213
+
214
+ return _result.schema;
215
+ }
216
+
217
+ export function extractDefs<T extends schemas.$ZodType>(
218
+ ctx: ToJSONSchemaContext,
219
+ schema: T
220
+ // params: EmitParams
221
+ ): void {
222
+ // iterate over seen map;
223
+ const root = ctx.seen.get(schema);
224
+
225
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
226
+
227
+ // Track ids to detect duplicates across different schemas
228
+ const idToSchema = new Map<string, schemas.$ZodType>();
229
+ for (const entry of ctx.seen.entries()) {
230
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
231
+ if (id) {
232
+ const existing = idToSchema.get(id);
233
+ if (existing && existing !== entry[0]) {
234
+ throw new Error(
235
+ `Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`
236
+ );
237
+ }
238
+ idToSchema.set(id, entry[0]);
239
+ }
240
+ }
241
+
242
+ // returns a ref to the schema
243
+ // defId will be empty if the ref points to an external schema (or #)
244
+ const makeURI = (entry: [schemas.$ZodType<unknown, unknown>, Seen]): { ref: string; defId?: string } => {
245
+ // comparing the seen objects because sometimes
246
+ // multiple schemas map to the same seen object.
247
+ // e.g. lazy
248
+
249
+ // external is configured
250
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
251
+ if (ctx.external) {
252
+ const externalId = ctx.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${ctx.counter++}`;
253
+
254
+ // check if schema is in the external registry
255
+ const uriGenerator = ctx.external.uri ?? ((id: string) => id);
256
+ if (externalId) {
257
+ return { ref: uriGenerator(externalId) };
258
+ }
259
+
260
+ // otherwise, add to __shared
261
+ const id: string = entry[1].defId ?? (entry[1].schema.id as string) ?? `schema${ctx.counter++}`;
262
+ entry[1].defId = id; // set defId so it will be reused if needed
263
+ return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
264
+ }
265
+
266
+ if (entry[1] === root) {
267
+ return { ref: "#" };
268
+ }
269
+
270
+ // self-contained schema
271
+ const uriPrefix = `#`;
272
+ const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
273
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
274
+ return { defId, ref: defUriPrefix + defId };
275
+ };
276
+
277
+ // stored cached version in `def` property
278
+ // remove all properties, set $ref
279
+ const extractToDef = (entry: [schemas.$ZodType<unknown, unknown>, Seen]): void => {
280
+ // if the schema is already a reference, do not extract it
281
+ if (entry[1].schema.$ref) {
282
+ return;
283
+ }
284
+ const seen = entry[1];
285
+ const { ref, defId } = makeURI(entry);
286
+
287
+ seen.def = { ...seen.schema };
288
+ // defId won't be set if the schema is a reference to an external schema
289
+ // or if the schema is the root schema
290
+ if (defId) seen.defId = defId;
291
+ // wipe away all properties except $ref
292
+ const schema = seen.schema;
293
+ for (const key in schema) {
294
+ delete schema[key];
295
+ }
296
+ schema.$ref = ref;
297
+ };
298
+
299
+ // throw on cycles
300
+
301
+ // break cycles
302
+ if (ctx.cycles === "throw") {
303
+ for (const entry of ctx.seen.entries()) {
304
+ const seen = entry[1];
305
+ if (seen.cycle) {
306
+ throw new Error(
307
+ "Cycle detected: " +
308
+ `#/${seen.cycle?.join("/")}/<root>` +
309
+ '\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.'
310
+ );
311
+ }
312
+ }
313
+ }
314
+
315
+ // extract schemas into $defs
316
+ for (const entry of ctx.seen.entries()) {
317
+ const seen = entry[1];
318
+
319
+ // convert root schema to # $ref
320
+ if (schema === entry[0]) {
321
+ extractToDef(entry); // this has special handling for the root schema
322
+ continue;
323
+ }
324
+
325
+ // extract schemas that are in the external registry
326
+ if (ctx.external) {
327
+ const ext = ctx.external.registry.get(entry[0])?.id;
328
+ if (schema !== entry[0] && ext) {
329
+ extractToDef(entry);
330
+ continue;
331
+ }
332
+ }
333
+
334
+ // extract schemas with `id` meta
335
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
336
+ if (id) {
337
+ extractToDef(entry);
338
+ continue;
339
+ }
340
+
341
+ // break cycles
342
+ if (seen.cycle) {
343
+ // any
344
+ extractToDef(entry);
345
+ continue;
346
+ }
347
+
348
+ // extract reused schemas
349
+ if (seen.count > 1) {
350
+ if (ctx.reused === "ref") {
351
+ extractToDef(entry);
352
+ // biome-ignore lint:
353
+ continue;
354
+ }
355
+ }
356
+ }
357
+ }
358
+
359
+ export function finalize<T extends schemas.$ZodType>(
360
+ ctx: ToJSONSchemaContext,
361
+ schema: T
362
+ ): ZodStandardJSONSchemaPayload<T> {
363
+ const root = ctx.seen.get(schema);
364
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
365
+
366
+ // flatten refs - inherit properties from parent schemas
367
+ const flattenRef = (zodSchema: schemas.$ZodType) => {
368
+ const seen = ctx.seen.get(zodSchema)!;
369
+
370
+ // already processed
371
+ if (seen.ref === null) return;
372
+
373
+ const schema = seen.def ?? seen.schema;
374
+ const _cached = { ...schema };
375
+
376
+ const ref = seen.ref;
377
+ seen.ref = null; // prevent infinite recursion
378
+
379
+ if (ref) {
380
+ flattenRef(ref);
381
+
382
+ const refSeen = ctx.seen.get(ref)!;
383
+ const refSchema = refSeen.schema;
384
+
385
+ // merge referenced schema into current
386
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
387
+ // older drafts can't combine $ref with other properties
388
+ schema.allOf = schema.allOf ?? [];
389
+ schema.allOf.push(refSchema);
390
+ } else {
391
+ Object.assign(schema, refSchema);
392
+ }
393
+ // restore child's own properties (child wins)
394
+ Object.assign(schema, _cached);
395
+
396
+ const isParentRef = zodSchema._zod.parent === ref;
397
+
398
+ // For parent chain, child is a refinement - remove parent-only properties
399
+ if (isParentRef) {
400
+ for (const key in schema) {
401
+ if (key === "$ref" || key === "allOf") continue;
402
+ if (!(key in _cached)) {
403
+ delete schema[key];
404
+ }
405
+ }
406
+ }
407
+
408
+ // When ref was extracted to $defs, remove properties that match the definition
409
+ if (refSchema.$ref && refSeen.def) {
410
+ for (const key in schema) {
411
+ if (key === "$ref" || key === "allOf") continue;
412
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) {
413
+ delete schema[key];
414
+ }
415
+ }
416
+ }
417
+ }
418
+
419
+ // If parent was extracted (has $ref), propagate $ref to this schema
420
+ // This handles cases like: readonly().meta({id}).describe()
421
+ // where processor sets ref to innerType but parent should be referenced
422
+ const parent = zodSchema._zod.parent;
423
+ if (parent && parent !== ref) {
424
+ // Ensure parent is processed first so its def has inherited properties
425
+ flattenRef(parent);
426
+ const parentSeen = ctx.seen.get(parent);
427
+ if (parentSeen?.schema.$ref) {
428
+ schema.$ref = parentSeen.schema.$ref;
429
+ // De-duplicate with parent's definition
430
+ if (parentSeen.def) {
431
+ for (const key in schema) {
432
+ if (key === "$ref" || key === "allOf") continue;
433
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) {
434
+ delete schema[key];
435
+ }
436
+ }
437
+ }
438
+ }
439
+ }
440
+
441
+ // execute overrides
442
+ ctx.override({
443
+ zodSchema: zodSchema as schemas.$ZodTypes,
444
+ jsonSchema: schema,
445
+ path: seen.path ?? [],
446
+ });
447
+ };
448
+
449
+ for (const entry of [...ctx.seen.entries()].reverse()) {
450
+ flattenRef(entry[0]);
451
+ }
452
+
453
+ const result: JSONSchema.BaseSchema = {};
454
+ if (ctx.target === "draft-2020-12") {
455
+ result.$schema = "https://json-schema.org/draft/2020-12/schema";
456
+ } else if (ctx.target === "draft-07") {
457
+ result.$schema = "http://json-schema.org/draft-07/schema#";
458
+ } else if (ctx.target === "draft-04") {
459
+ result.$schema = "http://json-schema.org/draft-04/schema#";
460
+ } else if (ctx.target === "openapi-3.0") {
461
+ // OpenAPI 3.0 schema objects should not include a $schema property
462
+ } else {
463
+ // Arbitrary string values are allowed but won't have a $schema property set
464
+ }
465
+
466
+ if (ctx.external?.uri) {
467
+ const id = ctx.external.registry.get(schema)?.id;
468
+ if (!id) throw new Error("Schema is missing an `id` property");
469
+ result.$id = ctx.external.uri(id);
470
+ }
471
+
472
+ Object.assign(result, root.def ?? root.schema);
473
+
474
+ // The `id` in `.meta()` is a Zod-specific registration tag used to extract
475
+ // schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
476
+ // from the output body where it would otherwise leak. The id is preserved
477
+ // implicitly via the $defs key (and via $ref paths).
478
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
479
+ if (rootMetaId !== undefined && result.id === rootMetaId) delete result.id;
480
+
481
+ // build defs object
482
+ const defs: JSONSchema.BaseSchema["$defs"] = ctx.external?.defs ?? {};
483
+ for (const entry of ctx.seen.entries()) {
484
+ const seen = entry[1];
485
+ if (seen.def && seen.defId) {
486
+ if (seen.def.id === seen.defId) delete seen.def.id;
487
+ defs[seen.defId] = seen.def;
488
+ }
489
+ }
490
+
491
+ // set definitions in result
492
+ if (ctx.external) {
493
+ } else {
494
+ if (Object.keys(defs).length > 0) {
495
+ if (ctx.target === "draft-2020-12") {
496
+ result.$defs = defs;
497
+ } else {
498
+ result.definitions = defs;
499
+ }
500
+ }
501
+ }
502
+
503
+ try {
504
+ // this "finalizes" this schema and ensures all cycles are removed
505
+ // each call to finalize() is functionally independent
506
+ // though the seen map is shared
507
+ const finalized = JSON.parse(JSON.stringify(result));
508
+ Object.defineProperty(finalized, "~standard", {
509
+ value: {
510
+ ...schema["~standard"],
511
+ jsonSchema: {
512
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
513
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors),
514
+ },
515
+ },
516
+ enumerable: false,
517
+ writable: false,
518
+ });
519
+
520
+ return finalized;
521
+ } catch (_err) {
522
+ throw new Error("Error converting schema to JSON.");
523
+ }
524
+ }
525
+
526
+ function isTransforming(
527
+ _schema: schemas.$ZodType,
528
+ _ctx?: {
529
+ seen: Set<schemas.$ZodType>;
530
+ }
531
+ ): boolean {
532
+ const ctx = _ctx ?? { seen: new Set() };
533
+
534
+ if (ctx.seen.has(_schema)) return false;
535
+ ctx.seen.add(_schema);
536
+
537
+ const def = (_schema as schemas.$ZodTypes)._zod.def;
538
+
539
+ if (def.type === "transform") return true;
540
+
541
+ if (def.type === "array") return isTransforming(def.element, ctx);
542
+ if (def.type === "set") return isTransforming(def.valueType, ctx);
543
+ if (def.type === "lazy") return isTransforming(def.getter(), ctx);
544
+
545
+ if (
546
+ def.type === "promise" ||
547
+ def.type === "optional" ||
548
+ def.type === "nonoptional" ||
549
+ def.type === "nullable" ||
550
+ def.type === "readonly" ||
551
+ def.type === "default" ||
552
+ def.type === "prefault"
553
+ ) {
554
+ return isTransforming(def.innerType, ctx);
555
+ }
556
+
557
+ if (def.type === "intersection") {
558
+ return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
559
+ }
560
+ if (def.type === "record" || def.type === "map") {
561
+ return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
562
+ }
563
+ if (def.type === "pipe") {
564
+ if (_schema._zod.traits.has("$ZodCodec")) return true;
565
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
566
+ }
567
+
568
+ if (def.type === "object") {
569
+ for (const key in def.shape) {
570
+ if (isTransforming(def.shape[key]!, ctx)) return true;
571
+ }
572
+ return false;
573
+ }
574
+ if (def.type === "union") {
575
+ for (const option of def.options) {
576
+ if (isTransforming(option, ctx)) return true;
577
+ }
578
+ return false;
579
+ }
580
+ if (def.type === "tuple") {
581
+ for (const item of def.items) {
582
+ if (isTransforming(item, ctx)) return true;
583
+ }
584
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
585
+ return false;
586
+ }
587
+
588
+ return false;
589
+ }
590
+
591
+ export type ZodStandardSchemaWithJSON<T> = StandardSchemaWithJSONProps<core.input<T>, core.output<T>>;
592
+ export interface ZodStandardJSONSchemaPayload<T> extends JSONSchema.BaseSchema {
593
+ "~standard": ZodStandardSchemaWithJSON<T>;
594
+ }
595
+
596
+ /**
597
+ * Creates a toJSONSchema method for a schema instance.
598
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
599
+ */
600
+ export const createToJSONSchemaMethod =
601
+ <T extends schemas.$ZodType>(schema: T, processors: Record<string, Processor> = {}) =>
602
+ (params?: ToJSONSchemaParams): ZodStandardJSONSchemaPayload<T> => {
603
+ const ctx = initializeContext({ ...params, processors });
604
+ process(schema, ctx);
605
+ extractDefs(ctx, schema);
606
+ return finalize(ctx, schema);
607
+ };
608
+
609
+ /**
610
+ * Creates a toJSONSchema method for a schema instance.
611
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
612
+ */
613
+ type StandardJSONSchemaMethodParams = Parameters<StandardJSONSchemaV1["~standard"]["jsonSchema"]["input"]>[0];
614
+ export const createStandardJSONSchemaMethod =
615
+ <T extends schemas.$ZodType>(schema: T, io: "input" | "output", processors: Record<string, Processor> = {}) =>
616
+ (params?: StandardJSONSchemaMethodParams): JSONSchema.BaseSchema => {
617
+ const { libraryOptions, target } = params ?? {};
618
+ const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors });
619
+ process(schema, ctx);
620
+ extractDefs(ctx, schema);
621
+ return finalize(ctx, schema);
622
+ };
gui/frontend/node_modules/zod/src/v4/core/util.ts ADDED
@@ -0,0 +1,983 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type * as checks from "./checks.js";
2
+ import { globalConfig } from "./core.js";
3
+ import type { $ZodConfig } from "./core.js";
4
+ import type * as errors from "./errors.js";
5
+ import type * as schemas from "./schemas.js";
6
+
7
+ // json
8
+ export type JSONType = string | number | boolean | null | JSONType[] | { [key: string]: JSONType };
9
+ export type JWTAlgorithm =
10
+ | "HS256"
11
+ | "HS384"
12
+ | "HS512"
13
+ | "RS256"
14
+ | "RS384"
15
+ | "RS512"
16
+ | "ES256"
17
+ | "ES384"
18
+ | "ES512"
19
+ | "PS256"
20
+ | "PS384"
21
+ | "PS512"
22
+ | "EdDSA"
23
+ | (string & {});
24
+
25
+ export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha384" | "sha512";
26
+ export type HashEncoding = "hex" | "base64" | "base64url";
27
+ export type HashFormat = `${HashAlgorithm}_${HashEncoding}`;
28
+ export type IPVersion = "v4" | "v6";
29
+ export type MimeTypes =
30
+ | "application/json"
31
+ | "application/xml"
32
+ | "application/x-www-form-urlencoded"
33
+ | "application/javascript"
34
+ | "application/pdf"
35
+ | "application/zip"
36
+ | "application/vnd.ms-excel"
37
+ | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
38
+ | "application/msword"
39
+ | "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
40
+ | "application/vnd.ms-powerpoint"
41
+ | "application/vnd.openxmlformats-officedocument.presentationml.presentation"
42
+ | "application/octet-stream"
43
+ | "application/graphql"
44
+ | "text/html"
45
+ | "text/plain"
46
+ | "text/css"
47
+ | "text/javascript"
48
+ | "text/csv"
49
+ | "image/png"
50
+ | "image/jpeg"
51
+ | "image/gif"
52
+ | "image/svg+xml"
53
+ | "image/webp"
54
+ | "audio/mpeg"
55
+ | "audio/ogg"
56
+ | "audio/wav"
57
+ | "audio/webm"
58
+ | "video/mp4"
59
+ | "video/webm"
60
+ | "video/ogg"
61
+ | "font/woff"
62
+ | "font/woff2"
63
+ | "font/ttf"
64
+ | "font/otf"
65
+ | "multipart/form-data"
66
+ | (string & {});
67
+ export type ParsedTypes =
68
+ | "string"
69
+ | "number"
70
+ | "bigint"
71
+ | "boolean"
72
+ | "symbol"
73
+ | "undefined"
74
+ | "object"
75
+ | "function"
76
+ | "file"
77
+ | "date"
78
+ | "array"
79
+ | "map"
80
+ | "set"
81
+ | "nan"
82
+ | "null"
83
+ | "promise";
84
+
85
+ // utils
86
+ export type AssertEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? true : false;
87
+ export type AssertNotEqual<T, U> = (<V>() => V extends T ? 1 : 2) extends <V>() => V extends U ? 1 : 2 ? false : true;
88
+ export type AssertExtends<T, U> = T extends U ? T : never;
89
+ export type IsAny<T> = 0 extends 1 & T ? true : false;
90
+ export type Omit<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
91
+ export type OmitKeys<T, K extends string> = Pick<T, Exclude<keyof T, K>>;
92
+ export type MakePartial<T, K extends keyof T> = Omit<T, K> & InexactPartial<Pick<T, K>>;
93
+ export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
94
+
95
+ export type Exactly<T, X> = T & Record<Exclude<keyof X, keyof T>, never>;
96
+ export type NoUndefined<T> = T extends undefined ? never : T;
97
+ export type Whatever = {} | undefined | null;
98
+ export type LoosePartial<T extends object> = InexactPartial<T> & {
99
+ [k: string]: unknown;
100
+ };
101
+ export type Mask<Keys extends PropertyKey> = { [K in Keys]?: true };
102
+ export type Writeable<T> = { -readonly [P in keyof T]: T[P] } & {};
103
+ export type InexactPartial<T> = {
104
+ [P in keyof T]?: T[P] | undefined;
105
+ };
106
+ export type EmptyObject = Record<string, never>;
107
+ export type BuiltIn =
108
+ | (((...args: any[]) => any) | (new (...args: any[]) => any))
109
+ | { readonly [Symbol.toStringTag]: string }
110
+ | Date
111
+ | Error
112
+ | Generator
113
+ | Promise<unknown>
114
+ | RegExp;
115
+ export type MakeReadonly<T> = T extends Map<infer K, infer V>
116
+ ? ReadonlyMap<K, V>
117
+ : T extends Set<infer V>
118
+ ? ReadonlySet<V>
119
+ : T extends [infer Head, ...infer Tail]
120
+ ? readonly [Head, ...Tail]
121
+ : T extends Array<infer V>
122
+ ? ReadonlyArray<V>
123
+ : T extends BuiltIn
124
+ ? T
125
+ : Readonly<T>;
126
+ export type SomeObject = Record<PropertyKey, any>;
127
+ export type Identity<T> = T;
128
+ export type Flatten<T> = Identity<{ [k in keyof T]: T[k] }>;
129
+ export type Mapped<T> = { [k in keyof T]: T[k] };
130
+ export type Prettify<T> = {
131
+ // @ts-ignore
132
+ [K in keyof T]: T[K];
133
+ } & {};
134
+
135
+ export type NoNeverKeys<T> = {
136
+ [k in keyof T]: [T[k]] extends [never] ? never : k;
137
+ }[keyof T];
138
+ export type NoNever<T> = Identity<{
139
+ [k in NoNeverKeys<T>]: k extends keyof T ? T[k] : never;
140
+ }>;
141
+ export type Extend<A extends SomeObject, B extends SomeObject> = Flatten<
142
+ // fast path when there is no keys overlap
143
+ keyof A & keyof B extends never
144
+ ? A & B
145
+ : {
146
+ [K in keyof A as K extends keyof B ? never : K]: A[K];
147
+ } & {
148
+ [K in keyof B]: B[K];
149
+ }
150
+ >;
151
+
152
+ export type TupleItems = ReadonlyArray<schemas.SomeType>;
153
+ export type AnyFunc = (...args: any[]) => any;
154
+ export type IsProp<T, K extends keyof T> = T[K] extends AnyFunc ? never : K;
155
+ export type MaybeAsync<T> = T | Promise<T>;
156
+ export type KeyOf<T> = keyof OmitIndexSignature<T>;
157
+ export type OmitIndexSignature<T> = {
158
+ [K in keyof T as string extends K ? never : K extends string ? K : never]: T[K];
159
+ };
160
+ export type ExtractIndexSignature<T> = {
161
+ [K in keyof T as string extends K ? K : K extends string ? never : K]: T[K];
162
+ };
163
+ export type Keys<T extends object> = keyof OmitIndexSignature<T>;
164
+
165
+ export type SchemaClass<T extends schemas.SomeType> = {
166
+ new (def: T["_zod"]["def"]): T;
167
+ };
168
+ export type EnumValue = string | number; // | bigint | boolean | symbol;
169
+ export type EnumLike = Readonly<Record<string, EnumValue>>;
170
+ export type ToEnum<T extends EnumValue> = Flatten<{ [k in T]: k }>;
171
+ export type KeysEnum<T extends object> = ToEnum<Exclude<keyof T, symbol>>;
172
+ export type KeysArray<T extends object> = Flatten<(keyof T & string)[]>;
173
+ export type Literal = string | number | bigint | boolean | null | undefined;
174
+ export type LiteralArray = Array<Literal>;
175
+ export type Primitive = string | number | symbol | bigint | boolean | null | undefined;
176
+ export type PrimitiveArray = Array<Primitive>;
177
+ export type HasSize = { size: number };
178
+ export type HasLength = { length: number }; // string | Array<unknown> | Set<unknown> | File;
179
+ export type Numeric = number | bigint | Date;
180
+ export type SafeParseResult<T> = SafeParseSuccess<T> | SafeParseError<T>;
181
+ export type SafeParseSuccess<T> = { success: true; data: T; error?: never };
182
+ export type SafeParseError<T> = {
183
+ success: false;
184
+ data?: never;
185
+ error: errors.$ZodError<T>;
186
+ };
187
+
188
+ export type PropValues = Record<string, Set<Primitive>>;
189
+ export type PrimitiveSet = Set<Primitive>;
190
+
191
+ // functions
192
+ export function assertEqual<A, B>(val: AssertEqual<A, B>): AssertEqual<A, B> {
193
+ return val;
194
+ }
195
+
196
+ export function assertNotEqual<A, B>(val: AssertNotEqual<A, B>): AssertNotEqual<A, B> {
197
+ return val;
198
+ }
199
+
200
+ export function assertIs<T>(_arg: T): void {}
201
+
202
+ export function assertNever(_x: never): never {
203
+ throw new Error("Unexpected value in exhaustive check");
204
+ }
205
+ export function assert<T>(_: any): asserts _ is T {}
206
+
207
+ export function getEnumValues(entries: EnumLike): EnumValue[] {
208
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
209
+ const values = Object.entries(entries)
210
+ .filter(([k, _]) => numericValues.indexOf(+k) === -1)
211
+ .map(([_, v]) => v);
212
+ return values;
213
+ }
214
+
215
+ export function joinValues<T extends Primitive[]>(array: T, separator = "|"): string {
216
+ return array.map((val) => stringifyPrimitive(val)).join(separator);
217
+ }
218
+
219
+ export function jsonStringifyReplacer(_: string, value: any): any {
220
+ if (typeof value === "bigint") return value.toString();
221
+ return value;
222
+ }
223
+
224
+ export function cached<T>(getter: () => T): { value: T } {
225
+ const set = false;
226
+ return {
227
+ get value() {
228
+ if (!set) {
229
+ const value = getter();
230
+ Object.defineProperty(this, "value", { value });
231
+ return value;
232
+ }
233
+ throw new Error("cached value already set");
234
+ },
235
+ };
236
+ }
237
+
238
+ export function nullish(input: any): boolean {
239
+ return input === null || input === undefined;
240
+ }
241
+
242
+ export function cleanRegex(source: string): string {
243
+ const start = source.startsWith("^") ? 1 : 0;
244
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
245
+ return source.slice(start, end);
246
+ }
247
+
248
+ export function floatSafeRemainder(val: number, step: number): number {
249
+ const ratio = val / step;
250
+ const roundedRatio = Math.round(ratio);
251
+ // Use a relative epsilon scaled to the magnitude of the result
252
+ const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
253
+ if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
254
+ return ratio - roundedRatio;
255
+ }
256
+
257
+ const EVALUATING = /* @__PURE__*/ Symbol("evaluating");
258
+
259
+ export function defineLazy<T, K extends keyof T>(object: T, key: K, getter: () => T[K]): void {
260
+ let value: T[K] | typeof EVALUATING | undefined = undefined;
261
+ Object.defineProperty(object, key, {
262
+ get() {
263
+ if (value === EVALUATING) {
264
+ // Circular reference detected, return undefined to break the cycle
265
+ return undefined as T[K];
266
+ }
267
+ if (value === undefined) {
268
+ value = EVALUATING;
269
+ value = getter();
270
+ }
271
+ return value;
272
+ },
273
+ set(v) {
274
+ Object.defineProperty(object, key, {
275
+ value: v,
276
+ // configurable: true,
277
+ });
278
+ // object[key] = v;
279
+ },
280
+ configurable: true,
281
+ });
282
+ }
283
+
284
+ export function objectClone(obj: object) {
285
+ return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj));
286
+ }
287
+
288
+ export function assignProp<T extends object, K extends PropertyKey>(
289
+ target: T,
290
+ prop: K,
291
+ value: K extends keyof T ? T[K] : any
292
+ ): void {
293
+ Object.defineProperty(target, prop, {
294
+ value,
295
+ writable: true,
296
+ enumerable: true,
297
+ configurable: true,
298
+ });
299
+ }
300
+
301
+ export function mergeDefs(...defs: Record<string, any>[]): any {
302
+ const mergedDescriptors: Record<string, PropertyDescriptor> = {};
303
+
304
+ for (const def of defs) {
305
+ const descriptors = Object.getOwnPropertyDescriptors(def);
306
+ Object.assign(mergedDescriptors, descriptors);
307
+ }
308
+
309
+ return Object.defineProperties({}, mergedDescriptors);
310
+ }
311
+
312
+ export function cloneDef(schema: schemas.$ZodType): any {
313
+ return mergeDefs(schema._zod.def);
314
+ }
315
+
316
+ export function getElementAtPath(obj: any, path: (string | number)[] | null | undefined): any {
317
+ if (!path) return obj;
318
+ return path.reduce((acc, key) => acc?.[key], obj);
319
+ }
320
+
321
+ export function promiseAllObject<T extends object>(promisesObj: T): Promise<{ [k in keyof T]: Awaited<T[k]> }> {
322
+ const keys = Object.keys(promisesObj);
323
+ const promises = keys.map((key) => (promisesObj as any)[key]);
324
+
325
+ return Promise.all(promises).then((results) => {
326
+ const resolvedObj: any = {};
327
+ for (let i = 0; i < keys.length; i++) {
328
+ resolvedObj[keys[i]!] = results[i];
329
+ }
330
+ return resolvedObj;
331
+ });
332
+ }
333
+
334
+ export function randomString(length = 10): string {
335
+ const chars = "abcdefghijklmnopqrstuvwxyz";
336
+ let str = "";
337
+ for (let i = 0; i < length; i++) {
338
+ str += chars[Math.floor(Math.random() * chars.length)];
339
+ }
340
+ return str;
341
+ }
342
+
343
+ export function esc(str: string): string {
344
+ return JSON.stringify(str);
345
+ }
346
+
347
+ export function slugify(input: string): string {
348
+ return input
349
+ .toLowerCase()
350
+ .trim()
351
+ .replace(/[^\w\s-]/g, "")
352
+ .replace(/[\s_-]+/g, "-")
353
+ .replace(/^-+|-+$/g, "");
354
+ }
355
+
356
+ export const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void = (
357
+ "captureStackTrace" in Error ? Error.captureStackTrace : (..._args: any[]) => {}
358
+ ) as any;
359
+
360
+ export function isObject(data: any): data is Record<PropertyKey, unknown> {
361
+ return typeof data === "object" && data !== null && !Array.isArray(data);
362
+ }
363
+
364
+ export const allowsEval: { value: boolean } = /* @__PURE__*/ cached(() => {
365
+ // Skip the probe under `jitless`: strict CSPs report the caught `new Function`
366
+ // as a `securitypolicyviolation` even though the throw is swallowed.
367
+ if (globalConfig.jitless) {
368
+ return false;
369
+ }
370
+
371
+ // @ts-ignore
372
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
373
+ return false;
374
+ }
375
+
376
+ try {
377
+ const F = Function;
378
+ new F("");
379
+ return true;
380
+ } catch (_) {
381
+ return false;
382
+ }
383
+ });
384
+
385
+ export function isPlainObject(o: any): o is Record<PropertyKey, unknown> {
386
+ if (isObject(o) === false) return false;
387
+
388
+ // modified constructor
389
+ const ctor = o.constructor;
390
+ if (ctor === undefined) return true;
391
+
392
+ if (typeof ctor !== "function") return true;
393
+
394
+ // modified prototype
395
+ const prot = ctor.prototype;
396
+ if (isObject(prot) === false) return false;
397
+
398
+ // ctor doesn't have static `isPrototypeOf`
399
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
400
+ return false;
401
+ }
402
+
403
+ return true;
404
+ }
405
+
406
+ export function shallowClone(o: any): any {
407
+ if (isPlainObject(o)) return { ...o };
408
+ if (Array.isArray(o)) return [...o];
409
+ if (o instanceof Map) return new Map(o);
410
+ if (o instanceof Set) return new Set(o);
411
+ return o;
412
+ }
413
+
414
+ export function numKeys(data: any): number {
415
+ let keyCount = 0;
416
+ for (const key in data) {
417
+ if (Object.prototype.hasOwnProperty.call(data, key)) {
418
+ keyCount++;
419
+ }
420
+ }
421
+ return keyCount;
422
+ }
423
+
424
+ export const getParsedType = (data: any): ParsedTypes => {
425
+ const t = typeof data;
426
+
427
+ switch (t) {
428
+ case "undefined":
429
+ return "undefined";
430
+
431
+ case "string":
432
+ return "string";
433
+
434
+ case "number":
435
+ return Number.isNaN(data) ? "nan" : "number";
436
+
437
+ case "boolean":
438
+ return "boolean";
439
+
440
+ case "function":
441
+ return "function";
442
+
443
+ case "bigint":
444
+ return "bigint";
445
+
446
+ case "symbol":
447
+ return "symbol";
448
+
449
+ case "object":
450
+ if (Array.isArray(data)) {
451
+ return "array";
452
+ }
453
+ if (data === null) {
454
+ return "null";
455
+ }
456
+ if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
457
+ return "promise";
458
+ }
459
+ if (typeof Map !== "undefined" && data instanceof Map) {
460
+ return "map";
461
+ }
462
+ if (typeof Set !== "undefined" && data instanceof Set) {
463
+ return "set";
464
+ }
465
+ if (typeof Date !== "undefined" && data instanceof Date) {
466
+ return "date";
467
+ }
468
+ // @ts-ignore
469
+ if (typeof File !== "undefined" && data instanceof File) {
470
+ return "file";
471
+ }
472
+ return "object";
473
+
474
+ default:
475
+ throw new Error(`Unknown data type: ${t}`);
476
+ }
477
+ };
478
+
479
+ export const propertyKeyTypes: Set<string> = /* @__PURE__*/ new Set(["string", "number", "symbol"]);
480
+ export const primitiveTypes: Set<string> = /* @__PURE__*/ new Set([
481
+ "string",
482
+ "number",
483
+ "bigint",
484
+ "boolean",
485
+ "symbol",
486
+ "undefined",
487
+ ]);
488
+ export function escapeRegex(str: string): string {
489
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
490
+ }
491
+
492
+ // zod-specific utils
493
+ export function clone<T extends schemas.$ZodType>(inst: T, def?: T["_zod"]["def"], params?: { parent: boolean }): T {
494
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
495
+ if (!def || params?.parent) cl._zod.parent = inst;
496
+ return cl as any;
497
+ }
498
+
499
+ export type EmptyToNever<T> = keyof T extends never ? never : T;
500
+
501
+ export type Normalize<T> = T extends undefined
502
+ ? never
503
+ : T extends Record<any, any>
504
+ ? Flatten<
505
+ {
506
+ [k in keyof Omit<T, "error" | "message">]: T[k];
507
+ } & ("error" extends keyof T
508
+ ? {
509
+ error?: Exclude<T["error"], string>;
510
+ // path?: PropertyKey[] | undefined;
511
+ // message?: string | undefined;
512
+ }
513
+ : unknown)
514
+ >
515
+ : never;
516
+
517
+ export function normalizeParams<T>(_params: T): Normalize<T> {
518
+ const params: any = _params;
519
+
520
+ if (!params) return {} as any;
521
+ if (typeof params === "string") return { error: () => params } as any;
522
+ if (params?.message !== undefined) {
523
+ if (params?.error !== undefined) throw new Error("Cannot specify both `message` and `error` params");
524
+ params.error = params.message;
525
+ }
526
+ delete params.message;
527
+ if (typeof params.error === "string") return { ...params, error: () => params.error } as any;
528
+ return params;
529
+ }
530
+
531
+ export function createTransparentProxy<T extends object>(getter: () => T): T {
532
+ let target: T;
533
+ return new Proxy(
534
+ {},
535
+ {
536
+ get(_, prop, receiver) {
537
+ target ??= getter();
538
+ return Reflect.get(target, prop, receiver);
539
+ },
540
+ set(_, prop, value, receiver) {
541
+ target ??= getter();
542
+ return Reflect.set(target, prop, value, receiver);
543
+ },
544
+ has(_, prop) {
545
+ target ??= getter();
546
+ return Reflect.has(target, prop);
547
+ },
548
+ deleteProperty(_, prop) {
549
+ target ??= getter();
550
+ return Reflect.deleteProperty(target, prop);
551
+ },
552
+ ownKeys(_) {
553
+ target ??= getter();
554
+ return Reflect.ownKeys(target);
555
+ },
556
+ getOwnPropertyDescriptor(_, prop) {
557
+ target ??= getter();
558
+ return Reflect.getOwnPropertyDescriptor(target, prop);
559
+ },
560
+ defineProperty(_, prop, descriptor) {
561
+ target ??= getter();
562
+ return Reflect.defineProperty(target, prop, descriptor);
563
+ },
564
+ }
565
+ ) as T;
566
+ }
567
+
568
+ export function stringifyPrimitive(value: any): string {
569
+ if (typeof value === "bigint") return value.toString() + "n";
570
+ if (typeof value === "string") return `"${value}"`;
571
+ return `${value}`;
572
+ }
573
+
574
+ export function optionalKeys(shape: schemas.$ZodShape): string[] {
575
+ return Object.keys(shape).filter((k) => {
576
+ return shape[k]!._zod.optin === "optional" && shape[k]!._zod.optout === "optional";
577
+ });
578
+ }
579
+
580
+ export type CleanKey<T extends PropertyKey> = T extends `?${infer K}` ? K : T extends `${infer K}?` ? K : T;
581
+ export type ToCleanMap<T extends schemas.$ZodLooseShape> = {
582
+ [k in keyof T]: k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k;
583
+ };
584
+ export type FromCleanMap<T extends schemas.$ZodLooseShape> = {
585
+ [k in keyof T as k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k]: k;
586
+ };
587
+
588
+ export const NUMBER_FORMAT_RANGES: Record<checks.$ZodNumberFormats, [number, number]> = {
589
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
590
+ int32: [-2147483648, 2147483647],
591
+ uint32: [0, 4294967295],
592
+ float32: [-3.4028234663852886e38, 3.4028234663852886e38],
593
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE],
594
+ };
595
+
596
+ export const BIGINT_FORMAT_RANGES: Record<checks.$ZodBigIntFormats, [bigint, bigint]> = {
597
+ int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")],
598
+ uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")],
599
+ };
600
+
601
+ export function pick(schema: schemas.$ZodObject, mask: Record<string, unknown>): any {
602
+ const currDef = schema._zod.def;
603
+
604
+ const checks = currDef.checks;
605
+ const hasChecks = checks && checks.length > 0;
606
+ if (hasChecks) {
607
+ throw new Error(".pick() cannot be used on object schemas containing refinements");
608
+ }
609
+
610
+ const def = mergeDefs(schema._zod.def, {
611
+ get shape() {
612
+ const newShape: Writeable<schemas.$ZodShape> = {};
613
+ for (const key in mask) {
614
+ if (!(key in currDef.shape)) {
615
+ throw new Error(`Unrecognized key: "${key}"`);
616
+ }
617
+ if (!mask[key]) continue;
618
+ newShape[key] = currDef.shape[key]!;
619
+ }
620
+
621
+ assignProp(this, "shape", newShape); // self-caching
622
+ return newShape;
623
+ },
624
+ checks: [],
625
+ });
626
+
627
+ return clone(schema, def) as any;
628
+ }
629
+
630
+ export function omit(schema: schemas.$ZodObject, mask: object): any {
631
+ const currDef = schema._zod.def;
632
+
633
+ const checks = currDef.checks;
634
+ const hasChecks = checks && checks.length > 0;
635
+ if (hasChecks) {
636
+ throw new Error(".omit() cannot be used on object schemas containing refinements");
637
+ }
638
+
639
+ const def = mergeDefs(schema._zod.def, {
640
+ get shape() {
641
+ const newShape: Writeable<schemas.$ZodShape> = { ...schema._zod.def.shape };
642
+ for (const key in mask) {
643
+ if (!(key in currDef.shape)) {
644
+ throw new Error(`Unrecognized key: "${key}"`);
645
+ }
646
+ if (!(mask as any)[key]) continue;
647
+
648
+ delete newShape[key];
649
+ }
650
+ assignProp(this, "shape", newShape); // self-caching
651
+ return newShape;
652
+ },
653
+ checks: [],
654
+ });
655
+
656
+ return clone(schema, def);
657
+ }
658
+
659
+ export function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any {
660
+ if (!isPlainObject(shape)) {
661
+ throw new Error("Invalid input to extend: expected a plain object");
662
+ }
663
+
664
+ const checks = schema._zod.def.checks;
665
+ const hasChecks = checks && checks.length > 0;
666
+ if (hasChecks) {
667
+ // Only throw if new shape overlaps with existing shape
668
+ // Use getOwnPropertyDescriptor to check key existence without accessing values
669
+ const existingShape = schema._zod.def.shape;
670
+ for (const key in shape) {
671
+ if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) {
672
+ throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
673
+ }
674
+ }
675
+ }
676
+
677
+ const def = mergeDefs(schema._zod.def, {
678
+ get shape() {
679
+ const _shape = { ...schema._zod.def.shape, ...shape };
680
+ assignProp(this, "shape", _shape); // self-caching
681
+ return _shape;
682
+ },
683
+ });
684
+ return clone(schema, def) as any;
685
+ }
686
+
687
+ export function safeExtend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any {
688
+ if (!isPlainObject(shape)) {
689
+ throw new Error("Invalid input to safeExtend: expected a plain object");
690
+ }
691
+ const def = mergeDefs(schema._zod.def, {
692
+ get shape() {
693
+ const _shape = { ...schema._zod.def.shape, ...shape };
694
+ assignProp(this, "shape", _shape); // self-caching
695
+ return _shape;
696
+ },
697
+ });
698
+ return clone(schema, def) as any;
699
+ }
700
+
701
+ export function merge(a: schemas.$ZodObject, b: schemas.$ZodObject): any {
702
+ if (a._zod.def.checks?.length) {
703
+ throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
704
+ }
705
+ const def = mergeDefs(a._zod.def, {
706
+ get shape() {
707
+ const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
708
+ assignProp(this, "shape", _shape); // self-caching
709
+ return _shape;
710
+ },
711
+ get catchall() {
712
+ return b._zod.def.catchall;
713
+ },
714
+ checks: b._zod.def.checks ?? [],
715
+ });
716
+
717
+ return clone(a, def) as any;
718
+ }
719
+
720
+ export function partial(
721
+ Class: SchemaClass<schemas.$ZodOptional> | null,
722
+ schema: schemas.$ZodObject,
723
+ mask: object | undefined
724
+ ): any {
725
+ const currDef = schema._zod.def;
726
+ const checks = currDef.checks;
727
+ const hasChecks = checks && checks.length > 0;
728
+ if (hasChecks) {
729
+ throw new Error(".partial() cannot be used on object schemas containing refinements");
730
+ }
731
+
732
+ const def = mergeDefs(schema._zod.def, {
733
+ get shape() {
734
+ const oldShape = schema._zod.def.shape;
735
+ const shape: Writeable<schemas.$ZodShape> = { ...oldShape };
736
+
737
+ if (mask) {
738
+ for (const key in mask) {
739
+ if (!(key in oldShape)) {
740
+ throw new Error(`Unrecognized key: "${key}"`);
741
+ }
742
+ if (!(mask as any)[key]) continue;
743
+ // if (oldShape[key]!._zod.optin === "optional") continue;
744
+ shape[key] = Class
745
+ ? new Class({
746
+ type: "optional",
747
+ innerType: oldShape[key]!,
748
+ })
749
+ : oldShape[key]!;
750
+ }
751
+ } else {
752
+ for (const key in oldShape) {
753
+ // if (oldShape[key]!._zod.optin === "optional") continue;
754
+ shape[key] = Class
755
+ ? new Class({
756
+ type: "optional",
757
+ innerType: oldShape[key]!,
758
+ })
759
+ : oldShape[key]!;
760
+ }
761
+ }
762
+
763
+ assignProp(this, "shape", shape); // self-caching
764
+ return shape;
765
+ },
766
+ checks: [],
767
+ });
768
+
769
+ return clone(schema, def) as any;
770
+ }
771
+
772
+ export function required(
773
+ Class: SchemaClass<schemas.$ZodNonOptional>,
774
+ schema: schemas.$ZodObject,
775
+ mask: object | undefined
776
+ ): any {
777
+ const def = mergeDefs(schema._zod.def, {
778
+ get shape() {
779
+ const oldShape = schema._zod.def.shape;
780
+ const shape: Writeable<schemas.$ZodShape> = { ...oldShape };
781
+
782
+ if (mask) {
783
+ for (const key in mask) {
784
+ if (!(key in shape)) {
785
+ throw new Error(`Unrecognized key: "${key}"`);
786
+ }
787
+ if (!(mask as any)[key]) continue;
788
+ // overwrite with non-optional
789
+ shape[key] = new Class({
790
+ type: "nonoptional",
791
+ innerType: oldShape[key]!,
792
+ });
793
+ }
794
+ } else {
795
+ for (const key in oldShape) {
796
+ // overwrite with non-optional
797
+ shape[key] = new Class({
798
+ type: "nonoptional",
799
+ innerType: oldShape[key]!,
800
+ });
801
+ }
802
+ }
803
+
804
+ assignProp(this, "shape", shape); // self-caching
805
+ return shape;
806
+ },
807
+ });
808
+
809
+ return clone(schema, def) as any;
810
+ }
811
+
812
+ export type Constructor<T, Def extends any[] = any[]> = new (...args: Def) => T;
813
+
814
+ // invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom
815
+ export function aborted(x: schemas.ParsePayload, startIndex = 0): boolean {
816
+ if (x.aborted === true) return true;
817
+ for (let i = startIndex; i < x.issues.length; i++) {
818
+ if (x.issues[i]?.continue !== true) {
819
+ return true;
820
+ }
821
+ }
822
+ return false;
823
+ }
824
+
825
+ // Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined).
826
+ // Used to respect `abort: true` in .refine() even for checks that have a `when` function.
827
+ export function explicitlyAborted(x: schemas.ParsePayload, startIndex = 0): boolean {
828
+ if (x.aborted === true) return true;
829
+ for (let i = startIndex; i < x.issues.length; i++) {
830
+ if (x.issues[i]?.continue === false) {
831
+ return true;
832
+ }
833
+ }
834
+ return false;
835
+ }
836
+
837
+ export function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[] {
838
+ return issues.map((iss) => {
839
+ (iss as any).path ??= [];
840
+ (iss as any).path.unshift(path);
841
+ return iss;
842
+ });
843
+ }
844
+
845
+ export function unwrapMessage(message: string | { message: string } | undefined | null): string | undefined {
846
+ return typeof message === "string" ? message : message?.message;
847
+ }
848
+
849
+ export function finalizeIssue(
850
+ iss: errors.$ZodRawIssue,
851
+ ctx: schemas.ParseContextInternal | undefined,
852
+ config: $ZodConfig
853
+ ): errors.$ZodIssue {
854
+ const message = iss.message
855
+ ? iss.message
856
+ : (unwrapMessage(iss.inst?._zod.def?.error?.(iss as never)) ??
857
+ unwrapMessage(ctx?.error?.(iss as never)) ??
858
+ unwrapMessage(config.customError?.(iss)) ??
859
+ unwrapMessage(config.localeError?.(iss)) ??
860
+ "Invalid input");
861
+
862
+ const { inst: _inst, continue: _continue, input: _input, ...rest } = iss as any;
863
+ rest.path ??= [];
864
+ rest.message = message;
865
+ if (ctx?.reportInput) {
866
+ rest.input = _input;
867
+ }
868
+ return rest;
869
+ }
870
+
871
+ export function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown" {
872
+ if (input instanceof Set) return "set";
873
+ if (input instanceof Map) return "map";
874
+ // @ts-ignore
875
+ if (input instanceof File) return "file";
876
+ return "unknown";
877
+ }
878
+
879
+ export function getLengthableOrigin(input: any): "array" | "string" | "unknown" {
880
+ if (Array.isArray(input)) return "array";
881
+ if (typeof input === "string") return "string";
882
+ return "unknown";
883
+ }
884
+
885
+ export function parsedType(data: unknown): errors.$ZodInvalidTypeExpected {
886
+ const t = typeof data;
887
+ switch (t) {
888
+ case "number": {
889
+ return Number.isNaN(data) ? "nan" : "number";
890
+ }
891
+ case "object": {
892
+ if (data === null) {
893
+ return "null";
894
+ }
895
+ if (Array.isArray(data)) {
896
+ return "array";
897
+ }
898
+
899
+ const obj = data as object;
900
+ if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) {
901
+ return (obj.constructor as { name: string }).name;
902
+ }
903
+ }
904
+ }
905
+ return t;
906
+ }
907
+
908
+ ////////// REFINES //////////
909
+ export function issue(_iss: string, input: any, inst: any): errors.$ZodRawIssue;
910
+ export function issue(_iss: errors.$ZodRawIssue): errors.$ZodRawIssue;
911
+ export function issue(...args: [string | errors.$ZodRawIssue, any?, any?]): errors.$ZodRawIssue {
912
+ const [iss, input, inst] = args;
913
+ if (typeof iss === "string") {
914
+ return {
915
+ message: iss,
916
+ code: "custom",
917
+ input,
918
+ inst,
919
+ };
920
+ }
921
+
922
+ return { ...iss };
923
+ }
924
+
925
+ export function cleanEnum(obj: Record<string, EnumValue>): EnumValue[] {
926
+ return Object.entries(obj)
927
+ .filter(([k, _]) => {
928
+ // return true if NaN, meaning it's not a number, thus a string key
929
+ return Number.isNaN(Number.parseInt(k, 10));
930
+ })
931
+ .map((el) => el[1]);
932
+ }
933
+
934
+ // Codec utility functions
935
+ export function base64ToUint8Array(base64: string): InstanceType<typeof Uint8Array> {
936
+ const binaryString = atob(base64);
937
+ const bytes = new Uint8Array(binaryString.length);
938
+ for (let i = 0; i < binaryString.length; i++) {
939
+ bytes[i] = binaryString.charCodeAt(i);
940
+ }
941
+ return bytes;
942
+ }
943
+
944
+ export function uint8ArrayToBase64(bytes: Uint8Array): string {
945
+ let binaryString = "";
946
+ for (let i = 0; i < bytes.length; i++) {
947
+ binaryString += String.fromCharCode(bytes[i]);
948
+ }
949
+ return btoa(binaryString);
950
+ }
951
+
952
+ export function base64urlToUint8Array(base64url: string): InstanceType<typeof Uint8Array> {
953
+ const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/");
954
+ const padding = "=".repeat((4 - (base64.length % 4)) % 4);
955
+ return base64ToUint8Array(base64 + padding);
956
+ }
957
+
958
+ export function uint8ArrayToBase64url(bytes: Uint8Array): string {
959
+ return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
960
+ }
961
+
962
+ export function hexToUint8Array(hex: string): InstanceType<typeof Uint8Array> {
963
+ const cleanHex = hex.replace(/^0x/, "");
964
+ if (cleanHex.length % 2 !== 0) {
965
+ throw new Error("Invalid hex string length");
966
+ }
967
+ const bytes = new Uint8Array(cleanHex.length / 2);
968
+ for (let i = 0; i < cleanHex.length; i += 2) {
969
+ bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16);
970
+ }
971
+ return bytes;
972
+ }
973
+
974
+ export function uint8ArrayToHex(bytes: Uint8Array): string {
975
+ return Array.from(bytes)
976
+ .map((b) => b.toString(16).padStart(2, "0"))
977
+ .join("");
978
+ }
979
+
980
+ // instanceof
981
+ export abstract class Class {
982
+ constructor(..._args: any[]) {}
983
+ }
gui/frontend/node_modules/zod/src/v4/core/versions.ts ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ export const version = {
2
+ major: 4,
3
+ minor: 4,
4
+ patch: 3 as number,
5
+ } as const;
gui/frontend/node_modules/zod/src/v4/core/zsf.ts ADDED
@@ -0,0 +1,323 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ///////////////////////////////////////////////////
2
+ //////////////// TYPES ///////////////////
3
+ ///////////////////////////////////////////////////
4
+
5
+ export interface $ZSF {
6
+ $zsf: { version: number };
7
+ type: string;
8
+ // default value if not defined
9
+ default: unknown;
10
+ // fallback value if validation fails
11
+ fallback: unknown;
12
+ }
13
+
14
+ export interface $ZSFString extends $ZSF {
15
+ type: "string";
16
+ min_length?: number;
17
+ max_length?: number;
18
+ pattern?: string;
19
+ }
20
+
21
+ export type NumberTypes = "float32" | "int32" | "uint32" | "float64" | "int64" | "uint64" | "bigint" | "bigdecimal";
22
+
23
+ export interface $ZSFNumber extends $ZSF {
24
+ type: "number";
25
+ format?: NumberTypes;
26
+ minimum?: number;
27
+ maximum?: number;
28
+ multiple_of?: number;
29
+ }
30
+
31
+ export interface $ZSFBoolean extends $ZSF {
32
+ type: "boolean";
33
+ }
34
+
35
+ export interface $ZSFNull extends $ZSF {
36
+ type: "null";
37
+ }
38
+
39
+ export interface $ZSFUndefined extends $ZSF {
40
+ type: "undefined";
41
+ }
42
+
43
+ export interface $ZSFOptional<T extends $ZSF = $ZSF> extends $ZSF {
44
+ type: "optional";
45
+ inner: T;
46
+ }
47
+
48
+ export interface $ZSFNever extends $ZSF {
49
+ type: "never";
50
+ }
51
+
52
+ export interface $ZSFAny extends $ZSF {
53
+ type: "any";
54
+ }
55
+
56
+ /** Supports */
57
+ export interface $ZSFEnum<Elements extends { [k: string]: $ZSFLiteral } = { [k: string]: $ZSFLiteral }> extends $ZSF {
58
+ type: "enum";
59
+ elements: Elements;
60
+ }
61
+
62
+ export interface $ZSFArray<PrefixItems extends $ZSF[] = $ZSF[], Items extends $ZSF = $ZSF> extends $ZSF {
63
+ type: "array";
64
+ prefixItems: PrefixItems;
65
+ items: Items;
66
+ }
67
+
68
+ // type $ZSFObjectProperties = { [k: string]: $ZSF };
69
+ type $ZSFObjectProperties = Array<{
70
+ key: string;
71
+ value: $ZSF;
72
+ format?: "literal" | "pattern";
73
+ ordering?: number;
74
+ }>;
75
+ export interface $ZSFObject<Properties extends $ZSFObjectProperties = $ZSFObjectProperties> extends $ZSF {
76
+ type: "object";
77
+ properties: Properties;
78
+ }
79
+
80
+ // export interface $ZSFTuple<
81
+ // Items extends $ZSF[] = $ZSF[],
82
+ // Rest extends $ZSF = $ZSF,
83
+ // > extends $ZSF {
84
+ // type: "array";
85
+ // items: Items;
86
+ // rest: Rest;
87
+ // }
88
+
89
+ /** Supports arbitrary literal values */
90
+ export interface $ZSFLiteral<T extends $ZSF = $ZSF> extends $ZSF {
91
+ type: "literal";
92
+ schema: T;
93
+ value: unknown;
94
+ }
95
+
96
+ export interface $ZSFUnion<Elements extends $ZSF[] = $ZSF[]> extends $ZSF {
97
+ type: "union";
98
+ elements: Elements;
99
+ }
100
+
101
+ export interface $ZSFIntersection extends $ZSF {
102
+ type: "intersection";
103
+ elements: $ZSF[];
104
+ }
105
+
106
+ export interface $ZSFMap<K extends $ZSF = $ZSF, V extends $ZSF = $ZSF> extends $ZSF {
107
+ type: "map";
108
+ keys: K;
109
+ values: V;
110
+ }
111
+
112
+ export interface $ZSFConditional<If extends $ZSF, Then extends $ZSF, Else extends $ZSF> extends $ZSF {
113
+ type: "conditional";
114
+ if: If;
115
+ then: Then;
116
+ else: Else;
117
+ }
118
+
119
+ /////////////////////////////////////////////////
120
+ //////////////// CHECKS ////////////////
121
+ /////////////////////////////////////////////////
122
+
123
+ // export interface $ZSFCheckRegex {
124
+ // check: "regex";
125
+ // pattern: string;
126
+ // }
127
+
128
+ // export interface $ZSFCheckEmail {
129
+ // check: "email";
130
+ // }
131
+
132
+ // export interface $ZSFCheckURL {
133
+ // check: "url";
134
+ // }
135
+
136
+ // export interface $ZSFCheckEmoji {
137
+ // check: "emoji";
138
+ // }
139
+
140
+ // export interface $ZSFCheckUUID {
141
+ // check: "uuid";
142
+ // }
143
+
144
+ // export interface $ZSFCheckUUIDv4 {
145
+ // check: "uuidv4";
146
+ // }
147
+
148
+ // export interface $ZSFCheckUUIDv6 {
149
+ // check: "uuidv6";
150
+ // }
151
+
152
+ // export interface $ZSFCheckNanoid {
153
+ // check: "nanoid";
154
+ // }
155
+
156
+ // export interface $ZSFCheckGUID {
157
+ // check: "guid";
158
+ // }
159
+
160
+ // export interface $ZSFCheckCUID {
161
+ // check: "cuid";
162
+ // }
163
+
164
+ // export interface $ZSFCheckCUID2 {
165
+ // check: "cuid2";
166
+ // }
167
+
168
+ // export interface $ZSFCheckULID {
169
+ // check: "ulid";
170
+ // }
171
+
172
+ // export interface $ZSFCheckXID {
173
+ // check: "xid";
174
+ // }
175
+
176
+ // export interface $ZSFCheckKSUID {
177
+ // check: "ksuid";
178
+ // }
179
+
180
+ // export interface $ZSFCheckISODateTime {
181
+ // check: "datetime";
182
+ // precision?: number;
183
+ // local?: boolean;
184
+ // }
185
+
186
+ // export interface $ZSFCheckISODate {
187
+ // check: "date";
188
+ // }
189
+
190
+ // export interface $ZSFCheckISOTime {
191
+ // check: "time";
192
+ // precision?: number;
193
+ // local?: boolean;
194
+ // }
195
+
196
+ // export interface $ZSFCheckDuration {
197
+ // check: "duration";
198
+ // }
199
+
200
+ // export interface $ZSFCheckIP {
201
+ // check: "ip";
202
+ // }
203
+
204
+ // export interface $ZSFCheckIPv4 {
205
+ // check: "ipv4";
206
+ // }
207
+
208
+ // export interface $ZSFCheckIPv6 {
209
+ // check: "ipv6";
210
+ // }
211
+
212
+ // export interface $ZSFCheckBase64 {
213
+ // check: "base64";
214
+ // }
215
+
216
+ // export interface $ZSFCheckJWT {
217
+ // check: "jwt";
218
+ // }
219
+
220
+ // export interface $ZSFCheckJSONString {
221
+ // check: "json_string";
222
+ // }
223
+
224
+ // export interface $ZSFCheckPrefix {
225
+ // check: "prefix";
226
+ // prefix: string;
227
+ // }
228
+
229
+ // export interface $ZSFCheckSuffix {
230
+ // check: "suffix";
231
+ // suffix: string;
232
+ // }
233
+
234
+ // export interface $ZSFCheckIncludes {
235
+ // check: "includes";
236
+ // includes: string;
237
+ // }
238
+
239
+ // export interface $ZSFCheckMinSize {
240
+ // check: "min_size";
241
+ // minimum: number;
242
+ // }
243
+
244
+ // export interface $ZSFCheckMaxSize {
245
+ // check: "max_size";
246
+ // maximum: number;
247
+ // }
248
+
249
+ // export interface $ZSFCheckSizeEquals {
250
+ // check: "size_equals";
251
+ // size: number;
252
+ // }
253
+
254
+ // export interface $ZSFCheckLessThan {
255
+ // check: "less_than";
256
+ // maximum: number | bigint | Date;
257
+ // }
258
+
259
+ // export interface $ZSFCheckLessThanOrEqual {
260
+ // check: "less_than_or_equal";
261
+ // maximum: number | bigint | Date;
262
+ // }
263
+
264
+ // export interface $ZSFCheckGreaterThan {
265
+ // check: "greater_than";
266
+ // minimum: number | bigint | Date;
267
+ // }
268
+
269
+ // export interface $ZSFCheckGreaterThanOrEqual {
270
+ // check: "greater_than_or_equal";
271
+ // minimum: number | bigint | Date;
272
+ // }
273
+
274
+ // export interface $ZSFCheckEquals {
275
+ // check: "equals";
276
+ // value: number | bigint | Date;
277
+ // }
278
+
279
+ // export interface $ZSFCheckMultipleOf {
280
+ // check: "multiple_of";
281
+ // multipleOf: number;
282
+ // }
283
+
284
+ // export type $ZSFStringFormatChecks =
285
+ // | $ZSFCheckRegex
286
+ // | $ZSFCheckEmail
287
+ // | $ZSFCheckURL
288
+ // | $ZSFCheckEmoji
289
+ // | $ZSFCheckUUID
290
+ // | $ZSFCheckUUIDv4
291
+ // | $ZSFCheckUUIDv6
292
+ // | $ZSFCheckNanoid
293
+ // | $ZSFCheckGUID
294
+ // | $ZSFCheckCUID
295
+ // | $ZSFCheckCUID2
296
+ // | $ZSFCheckULID
297
+ // | $ZSFCheckXID
298
+ // | $ZSFCheckKSUID
299
+ // | $ZSFCheckISODateTime
300
+ // | $ZSFCheckISODate
301
+ // | $ZSFCheckISOTime
302
+ // | $ZSFCheckDuration
303
+ // | $ZSFCheckIP
304
+ // | $ZSFCheckIPv4
305
+ // | $ZSFCheckIPv6
306
+ // | $ZSFCheckBase64
307
+ // | $ZSFCheckJWT
308
+ // | $ZSFCheckJSONString
309
+ // | $ZSFCheckPrefix
310
+ // | $ZSFCheckSuffix
311
+ // | $ZSFCheckIncludes;
312
+
313
+ // export type $ZSFCheck =
314
+ // | $ZSFStringFormatChecks
315
+ // | $ZSFCheckMinSize
316
+ // | $ZSFCheckMaxSize
317
+ // | $ZSFCheckSizeEquals
318
+ // | $ZSFCheckLessThan
319
+ // | $ZSFCheckLessThanOrEqual
320
+ // | $ZSFCheckGreaterThan
321
+ // | $ZSFCheckGreaterThanOrEqual
322
+ // | $ZSFCheckEquals
323
+ // | $ZSFCheckMultipleOf;
gui/frontend/node_modules/zod/src/v4/index.ts ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import z4 from "./classic/index.js";
2
+ export * from "./classic/index.js";
3
+
4
+ export default z4;
gui/frontend/node_modules/zod/src/v4/locales/ar.ts ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "حرف", verb: "أن يحوي" },
8
+ file: { unit: "بايت", verb: "أن يحوي" },
9
+ array: { unit: "عنصر", verb: "أن يحوي" },
10
+ set: { unit: "عنصر", verb: "أن يحوي" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const FormatDictionary: {
18
+ [k in $ZodStringFormats | (string & {})]?: string;
19
+ } = {
20
+ regex: "مدخل",
21
+ email: "بريد إلكتروني",
22
+ url: "رابط",
23
+ emoji: "إيموجي",
24
+ uuid: "UUID",
25
+ uuidv4: "UUIDv4",
26
+ uuidv6: "UUIDv6",
27
+ nanoid: "nanoid",
28
+ guid: "GUID",
29
+ cuid: "cuid",
30
+ cuid2: "cuid2",
31
+ ulid: "ULID",
32
+ xid: "XID",
33
+ ksuid: "KSUID",
34
+ datetime: "تاريخ ووقت بمعيار ISO",
35
+ date: "تاريخ بمعيار ISO",
36
+ time: "وقت بمعيار ISO",
37
+ duration: "مدة بمعيار ISO",
38
+ ipv4: "عنوان IPv4",
39
+ ipv6: "عنوان IPv6",
40
+ cidrv4: "مدى عناوين بصيغة IPv4",
41
+ cidrv6: "مدى عناوين بصيغة IPv6",
42
+ base64: "نَص بترميز base64-encoded",
43
+ base64url: "نَص بترميز base64url-encoded",
44
+ json_string: "نَص على هيئة JSON",
45
+ e164: "رقم هاتف بمعيار E.164",
46
+ jwt: "JWT",
47
+ template_literal: "مدخل",
48
+ };
49
+
50
+ const TypeDictionary: {
51
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
52
+ } = {
53
+ nan: "NaN",
54
+ };
55
+
56
+ return (issue) => {
57
+ switch (issue.code) {
58
+ case "invalid_type": {
59
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
60
+ const receivedType = util.parsedType(issue.input);
61
+ const received = TypeDictionary[receivedType] ?? receivedType;
62
+ if (/^[A-Z]/.test(issue.expected)) {
63
+ return `مدخلات غير مقبولة: يفترض إدخال instanceof ${issue.expected}، ولكن تم إدخال ${received}`;
64
+ }
65
+ return `مدخلات غير مقبولة: يفترض إدخال ${expected}، ولكن تم إدخال ${received}`;
66
+ }
67
+ case "invalid_value":
68
+ if (issue.values.length === 1)
69
+ return `مدخلات غير مقبولة: يفترض إدخال ${util.stringifyPrimitive(issue.values[0])}`;
70
+ return `اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${util.joinValues(issue.values, "|")}`;
71
+ case "too_big": {
72
+ const adj = issue.inclusive ? "<=" : "<";
73
+ const sizing = getSizing(issue.origin);
74
+ if (sizing)
75
+ return ` أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "عنصر"}`;
76
+ return `أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()}`;
77
+ }
78
+ case "too_small": {
79
+ const adj = issue.inclusive ? ">=" : ">";
80
+ const sizing = getSizing(issue.origin);
81
+ if (sizing) {
82
+ return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
83
+ }
84
+
85
+ return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()}`;
86
+ }
87
+ case "invalid_format": {
88
+ const _issue = issue as errors.$ZodStringFormatIssues;
89
+ if (_issue.format === "starts_with") return `نَص غير مقبول: يجب أن يبدأ بـ "${issue.prefix}"`;
90
+ if (_issue.format === "ends_with") return `نَص غير مقبول: يجب أن ينتهي بـ "${_issue.suffix}"`;
91
+ if (_issue.format === "includes") return `نَص غير مقبول: يجب أن يتضمَّن "${_issue.includes}"`;
92
+ if (_issue.format === "regex") return `نَص غير مقبول: يجب أن يطابق النمط ${_issue.pattern}`;
93
+ return `${FormatDictionary[_issue.format] ?? issue.format} غير مقبول`;
94
+ }
95
+ case "not_multiple_of":
96
+ return `رقم غير مقبول: يجب أن يكون من مضاعفات ${issue.divisor}`;
97
+ case "unrecognized_keys":
98
+ return `معرف${issue.keys.length > 1 ? "ات" : ""} غريب${issue.keys.length > 1 ? "ة" : ""}: ${util.joinValues(issue.keys, "، ")}`;
99
+ case "invalid_key":
100
+ return `معرف غير مقبول في ${issue.origin}`;
101
+ case "invalid_union":
102
+ return "مدخل غير مقبول";
103
+ case "invalid_element":
104
+ return `مدخل غير مقبول في ${issue.origin}`;
105
+ default:
106
+ return "مدخل غير مقبول";
107
+ }
108
+ };
109
+ };
110
+
111
+ export default function (): { localeError: errors.$ZodErrorMap } {
112
+ return {
113
+ localeError: error(),
114
+ };
115
+ }
gui/frontend/node_modules/zod/src/v4/locales/az.ts ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "simvol", verb: "olmalıdır" },
8
+ file: { unit: "bayt", verb: "olmalıdır" },
9
+ array: { unit: "element", verb: "olmalıdır" },
10
+ set: { unit: "element", verb: "olmalıdır" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const FormatDictionary: {
18
+ [k in $ZodStringFormats | (string & {})]?: string;
19
+ } = {
20
+ regex: "input",
21
+ email: "email address",
22
+ url: "URL",
23
+ emoji: "emoji",
24
+ uuid: "UUID",
25
+ uuidv4: "UUIDv4",
26
+ uuidv6: "UUIDv6",
27
+ nanoid: "nanoid",
28
+ guid: "GUID",
29
+ cuid: "cuid",
30
+ cuid2: "cuid2",
31
+ ulid: "ULID",
32
+ xid: "XID",
33
+ ksuid: "KSUID",
34
+ datetime: "ISO datetime",
35
+ date: "ISO date",
36
+ time: "ISO time",
37
+ duration: "ISO duration",
38
+ ipv4: "IPv4 address",
39
+ ipv6: "IPv6 address",
40
+ cidrv4: "IPv4 range",
41
+ cidrv6: "IPv6 range",
42
+ base64: "base64-encoded string",
43
+ base64url: "base64url-encoded string",
44
+ json_string: "JSON string",
45
+ e164: "E.164 number",
46
+ jwt: "JWT",
47
+ template_literal: "input",
48
+ };
49
+
50
+ const TypeDictionary: {
51
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
52
+ } = {
53
+ nan: "NaN",
54
+ };
55
+
56
+ return (issue) => {
57
+ switch (issue.code) {
58
+ case "invalid_type": {
59
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
60
+ const receivedType = util.parsedType(issue.input);
61
+ const received = TypeDictionary[receivedType] ?? receivedType;
62
+ if (/^[A-Z]/.test(issue.expected)) {
63
+ return `Yanlış dəyər: gözlənilən instanceof ${issue.expected}, daxil olan ${received}`;
64
+ }
65
+ return `Yanlış dəyər: gözlənilən ${expected}, daxil olan ${received}`;
66
+ }
67
+ case "invalid_value":
68
+ if (issue.values.length === 1) return `Yanlış dəyər: gözlənilən ${util.stringifyPrimitive(issue.values[0])}`;
69
+ return `Yanlış seçim: aşağıdakılardan biri olmalıdır: ${util.joinValues(issue.values, "|")}`;
70
+ case "too_big": {
71
+ const adj = issue.inclusive ? "<=" : "<";
72
+ const sizing = getSizing(issue.origin);
73
+ if (sizing)
74
+ return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "element"}`;
75
+ return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()}`;
76
+ }
77
+ case "too_small": {
78
+ const adj = issue.inclusive ? ">=" : ">";
79
+ const sizing = getSizing(issue.origin);
80
+ if (sizing) return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`;
81
+ return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()}`;
82
+ }
83
+ case "invalid_format": {
84
+ const _issue = issue as errors.$ZodStringFormatIssues;
85
+ if (_issue.format === "starts_with") return `Yanlış mətn: "${_issue.prefix}" ilə başlamalıdır`;
86
+ if (_issue.format === "ends_with") return `Yanlış mətn: "${_issue.suffix}" ilə bitməlidir`;
87
+ if (_issue.format === "includes") return `Yanlış mətn: "${_issue.includes}" daxil olmalıdır`;
88
+ if (_issue.format === "regex") return `Yanlış mətn: ${_issue.pattern} şablonuna uyğun olmalıdır`;
89
+ return `Yanlış ${FormatDictionary[_issue.format] ?? issue.format}`;
90
+ }
91
+ case "not_multiple_of":
92
+ return `Yanlış ədəd: ${issue.divisor} ilə bölünə bilən olmalıdır`;
93
+ case "unrecognized_keys":
94
+ return `Tanınmayan açar${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`;
95
+ case "invalid_key":
96
+ return `${issue.origin} daxilində yanlış açar`;
97
+ case "invalid_union":
98
+ return "Yanlış dəyər";
99
+ case "invalid_element":
100
+ return `${issue.origin} daxilində yanlış dəyər`;
101
+ default:
102
+ return `Yanlış dəyər`;
103
+ }
104
+ };
105
+ };
106
+
107
+ export default function (): { localeError: errors.$ZodErrorMap } {
108
+ return {
109
+ localeError: error(),
110
+ };
111
+ }
gui/frontend/node_modules/zod/src/v4/locales/be.ts ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ function getBelarusianPlural(count: number, one: string, few: string, many: string): string {
6
+ const absCount = Math.abs(count);
7
+ const lastDigit = absCount % 10;
8
+ const lastTwoDigits = absCount % 100;
9
+
10
+ if (lastTwoDigits >= 11 && lastTwoDigits <= 19) {
11
+ return many;
12
+ }
13
+
14
+ if (lastDigit === 1) {
15
+ return one;
16
+ }
17
+
18
+ if (lastDigit >= 2 && lastDigit <= 4) {
19
+ return few;
20
+ }
21
+
22
+ return many;
23
+ }
24
+
25
+ interface BelarusianSizable {
26
+ unit: {
27
+ one: string;
28
+ few: string;
29
+ many: string;
30
+ };
31
+ verb: string;
32
+ }
33
+ const error: () => errors.$ZodErrorMap = () => {
34
+ const Sizable: Record<string, BelarusianSizable> = {
35
+ string: {
36
+ unit: {
37
+ one: "сімвал",
38
+ few: "сімвалы",
39
+ many: "сімвалаў",
40
+ },
41
+ verb: "мець",
42
+ },
43
+ array: {
44
+ unit: {
45
+ one: "элемент",
46
+ few: "элементы",
47
+ many: "элементаў",
48
+ },
49
+ verb: "мець",
50
+ },
51
+ set: {
52
+ unit: {
53
+ one: "элемент",
54
+ few: "элементы",
55
+ many: "элементаў",
56
+ },
57
+ verb: "мець",
58
+ },
59
+ file: {
60
+ unit: {
61
+ one: "байт",
62
+ few: "байты",
63
+ many: "байтаў",
64
+ },
65
+ verb: "мець",
66
+ },
67
+ };
68
+
69
+ function getSizing(origin: string): BelarusianSizable | null {
70
+ return Sizable[origin] ?? null;
71
+ }
72
+
73
+ const FormatDictionary: {
74
+ [k in $ZodStringFormats | (string & {})]?: string;
75
+ } = {
76
+ regex: "увод",
77
+ email: "email адрас",
78
+ url: "URL",
79
+ emoji: "эмодзі",
80
+ uuid: "UUID",
81
+ uuidv4: "UUIDv4",
82
+ uuidv6: "UUIDv6",
83
+ nanoid: "nanoid",
84
+ guid: "GUID",
85
+ cuid: "cuid",
86
+ cuid2: "cuid2",
87
+ ulid: "ULID",
88
+ xid: "XID",
89
+ ksuid: "KSUID",
90
+ datetime: "ISO дата і час",
91
+ date: "ISO дата",
92
+ time: "ISO час",
93
+ duration: "ISO працягласць",
94
+ ipv4: "IPv4 адрас",
95
+ ipv6: "IPv6 адрас",
96
+ cidrv4: "IPv4 дыяпазон",
97
+ cidrv6: "IPv6 дыяпазон",
98
+ base64: "радок у фармаце base64",
99
+ base64url: "радок у фармаце base64url",
100
+ json_string: "JSON радок",
101
+ e164: "нумар E.164",
102
+ jwt: "JWT",
103
+ template_literal: "увод",
104
+ };
105
+
106
+ const TypeDictionary: {
107
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
108
+ } = {
109
+ nan: "NaN",
110
+ number: "лік",
111
+ array: "масіў",
112
+ };
113
+
114
+ return (issue) => {
115
+ switch (issue.code) {
116
+ case "invalid_type": {
117
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
118
+ const receivedType = util.parsedType(issue.input);
119
+ const received = TypeDictionary[receivedType] ?? receivedType;
120
+ if (/^[A-Z]/.test(issue.expected)) {
121
+ return `Няправільны ўвод: чакаўся instanceof ${issue.expected}, атрымана ${received}`;
122
+ }
123
+ return `Няправільны ўвод: чакаўся ${expected}, атрымана ${received}`;
124
+ }
125
+ case "invalid_value":
126
+ if (issue.values.length === 1) return `Няправільны ўвод: чакалася ${util.stringifyPrimitive(issue.values[0])}`;
127
+ return `Няправільны варыянт: чакаўся адзін з ${util.joinValues(issue.values, "|")}`;
128
+ case "too_big": {
129
+ const adj = issue.inclusive ? "<=" : "<";
130
+ const sizing = getSizing(issue.origin);
131
+ if (sizing) {
132
+ const maxValue = Number(issue.maximum);
133
+ const unit = getBelarusianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
134
+ return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна ${sizing.verb} ${adj}${issue.maximum.toString()} ${unit}`;
135
+ }
136
+ return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна быць ${adj}${issue.maximum.toString()}`;
137
+ }
138
+ case "too_small": {
139
+ const adj = issue.inclusive ? ">=" : ">";
140
+ const sizing = getSizing(issue.origin);
141
+ if (sizing) {
142
+ const minValue = Number(issue.minimum);
143
+ const unit = getBelarusianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many);
144
+ return `Занадта малы: чакалася, што ${issue.origin} павінна ${sizing.verb} ${adj}${issue.minimum.toString()} ${unit}`;
145
+ }
146
+ return `Занадта малы: чакалася, што ${issue.origin} павінна быць ${adj}${issue.minimum.toString()}`;
147
+ }
148
+ case "invalid_format": {
149
+ const _issue = issue as errors.$ZodStringFormatIssues;
150
+ if (_issue.format === "starts_with") return `Няправільны радок: павінен пачы��ацца з "${_issue.prefix}"`;
151
+ if (_issue.format === "ends_with") return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`;
152
+ if (_issue.format === "includes") return `Няправільны радок: павінен змяшчаць "${_issue.includes}"`;
153
+ if (_issue.format === "regex") return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`;
154
+ return `Няправільны ${FormatDictionary[_issue.format] ?? issue.format}`;
155
+ }
156
+ case "not_multiple_of":
157
+ return `Няправільны лік: павінен быць кратным ${issue.divisor}`;
158
+ case "unrecognized_keys":
159
+ return `Нераспазнаны ${issue.keys.length > 1 ? "ключы" : "ключ"}: ${util.joinValues(issue.keys, ", ")}`;
160
+ case "invalid_key":
161
+ return `Няправільны ключ у ${issue.origin}`;
162
+ case "invalid_union":
163
+ return "Няправільны ўвод";
164
+ case "invalid_element":
165
+ return `Няправільнае значэнне ў ${issue.origin}`;
166
+ default:
167
+ return `Няправільны ўвод`;
168
+ }
169
+ };
170
+ };
171
+
172
+ export default function (): { localeError: errors.$ZodErrorMap } {
173
+ return {
174
+ localeError: error(),
175
+ };
176
+ }
gui/frontend/node_modules/zod/src/v4/locales/bg.ts ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "символа", verb: "да съдържа" },
8
+ file: { unit: "байта", verb: "да съдържа" },
9
+ array: { unit: "елемента", verb: "да съдържа" },
10
+ set: { unit: "елемента", verb: "да съдържа" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const FormatDictionary: {
18
+ [k in $ZodStringFormats | (string & {})]?: string;
19
+ } = {
20
+ regex: "вход",
21
+ email: "имейл адрес",
22
+ url: "URL",
23
+ emoji: "емоджи",
24
+ uuid: "UUID",
25
+ uuidv4: "UUIDv4",
26
+ uuidv6: "UUIDv6",
27
+ nanoid: "nanoid",
28
+ guid: "GUID",
29
+ cuid: "cuid",
30
+ cuid2: "cuid2",
31
+ ulid: "ULID",
32
+ xid: "XID",
33
+ ksuid: "KSUID",
34
+ datetime: "ISO време",
35
+ date: "ISO дата",
36
+ time: "ISO време",
37
+ duration: "ISO продължителност",
38
+ ipv4: "IPv4 адрес",
39
+ ipv6: "IPv6 адрес",
40
+ cidrv4: "IPv4 диапазон",
41
+ cidrv6: "IPv6 диапазон",
42
+ base64: "base64-кодиран низ",
43
+ base64url: "base64url-кодиран низ",
44
+ json_string: "JSON низ",
45
+ e164: "E.164 номер",
46
+ jwt: "JWT",
47
+ template_literal: "вход",
48
+ };
49
+
50
+ const TypeDictionary: {
51
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
52
+ } = {
53
+ nan: "NaN",
54
+ number: "число",
55
+ array: "масив",
56
+ };
57
+
58
+ return (issue) => {
59
+ switch (issue.code) {
60
+ case "invalid_type": {
61
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
62
+ const receivedType = util.parsedType(issue.input);
63
+ const received = TypeDictionary[receivedType] ?? receivedType;
64
+ if (/^[A-Z]/.test(issue.expected)) {
65
+ return `Невалиден вход: очакван instanceof ${issue.expected}, получен ${received}`;
66
+ }
67
+ return `Невалиден вход: очакван ${expected}, получен ${received}`;
68
+ }
69
+
70
+ case "invalid_value":
71
+ if (issue.values.length === 1) return `Невалиден вход: очакван ${util.stringifyPrimitive(issue.values[0])}`;
72
+ return `Невалидна опция: очаквано едно от ${util.joinValues(issue.values, "|")}`;
73
+ case "too_big": {
74
+ const adj = issue.inclusive ? "<=" : "<";
75
+ const sizing = getSizing(issue.origin);
76
+ if (sizing)
77
+ return `Твърде голямо: очаква се ${issue.origin ?? "стойност"} да съдържа ${adj}${issue.maximum.toString()} ${sizing.unit ?? "елемента"}`;
78
+ return `Твърде голямо: очаква се ${issue.origin ?? "стойност"} да бъде ${adj}${issue.maximum.toString()}`;
79
+ }
80
+ case "too_small": {
81
+ const adj = issue.inclusive ? ">=" : ">";
82
+ const sizing = getSizing(issue.origin);
83
+ if (sizing) {
84
+ return `Твърде малко: очаква се ${issue.origin} да съдържа ${adj}${issue.minimum.toString()} ${sizing.unit}`;
85
+ }
86
+
87
+ return `Твърде малко: очаква се ${issue.origin} да бъде ${adj}${issue.minimum.toString()}`;
88
+ }
89
+ case "invalid_format": {
90
+ const _issue = issue as errors.$ZodStringFormatIssues;
91
+ if (_issue.format === "starts_with") {
92
+ return `Невалиден низ: трябва да започва с "${_issue.prefix}"`;
93
+ }
94
+ if (_issue.format === "ends_with") return `Невалиден низ: трябва да завършва с "${_issue.suffix}"`;
95
+ if (_issue.format === "includes") return `Невалиден низ: трябва да включва "${_issue.includes}"`;
96
+ if (_issue.format === "regex") return `Невалиден низ: трябва да съвпада с ${_issue.pattern}`;
97
+
98
+ let invalid_adj = "Невалиден";
99
+
100
+ if (_issue.format === "emoji") invalid_adj = "Невалидно";
101
+ if (_issue.format === "datetime") invalid_adj = "Невалидно";
102
+ if (_issue.format === "date") invalid_adj = "Невалидна";
103
+ if (_issue.format === "time") invalid_adj = "Невалидно";
104
+ if (_issue.format === "duration") invalid_adj = "Невалидна";
105
+
106
+ return `${invalid_adj} ${FormatDictionary[_issue.format] ?? issue.format}`;
107
+ }
108
+ case "not_multiple_of":
109
+ return `Невалидно число: трябва да бъде кратно на ${issue.divisor}`;
110
+ case "unrecognized_keys":
111
+ return `Неразпознат${issue.keys.length > 1 ? "и" : ""} ключ${issue.keys.length > 1 ? "ове" : ""}: ${util.joinValues(issue.keys, ", ")}`;
112
+ case "invalid_key":
113
+ return `Невалиден ключ в ${issue.origin}`;
114
+ case "invalid_union":
115
+ return "Невалиден вход";
116
+ case "invalid_element":
117
+ return `Невалидна стойност в ${issue.origin}`;
118
+ default:
119
+ return `Невалиден вход`;
120
+ }
121
+ };
122
+ };
123
+
124
+ export default function (): { localeError: errors.$ZodErrorMap } {
125
+ return {
126
+ localeError: error(),
127
+ };
128
+ }
gui/frontend/node_modules/zod/src/v4/locales/ca.ts ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "caràcters", verb: "contenir" },
8
+ file: { unit: "bytes", verb: "contenir" },
9
+ array: { unit: "elements", verb: "contenir" },
10
+ set: { unit: "elements", verb: "contenir" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const FormatDictionary: {
18
+ [k in $ZodStringFormats | (string & {})]?: string;
19
+ } = {
20
+ regex: "entrada",
21
+ email: "adreça electrònica",
22
+ url: "URL",
23
+ emoji: "emoji",
24
+ uuid: "UUID",
25
+ uuidv4: "UUIDv4",
26
+ uuidv6: "UUIDv6",
27
+ nanoid: "nanoid",
28
+ guid: "GUID",
29
+ cuid: "cuid",
30
+ cuid2: "cuid2",
31
+ ulid: "ULID",
32
+ xid: "XID",
33
+ ksuid: "KSUID",
34
+ datetime: "data i hora ISO",
35
+ date: "data ISO",
36
+ time: "hora ISO",
37
+ duration: "durada ISO",
38
+ ipv4: "adreça IPv4",
39
+ ipv6: "adreça IPv6",
40
+ cidrv4: "rang IPv4",
41
+ cidrv6: "rang IPv6",
42
+ base64: "cadena codificada en base64",
43
+ base64url: "cadena codificada en base64url",
44
+ json_string: "cadena JSON",
45
+ e164: "número E.164",
46
+ jwt: "JWT",
47
+ template_literal: "entrada",
48
+ };
49
+
50
+ const TypeDictionary: {
51
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
52
+ } = {
53
+ nan: "NaN",
54
+ };
55
+
56
+ return (issue) => {
57
+ switch (issue.code) {
58
+ case "invalid_type": {
59
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
60
+ const receivedType = util.parsedType(issue.input);
61
+ const received = TypeDictionary[receivedType] ?? receivedType;
62
+ if (/^[A-Z]/.test(issue.expected)) {
63
+ return `Tipus invàlid: s'esperava instanceof ${issue.expected}, s'ha rebut ${received}`;
64
+ }
65
+ return `Tipus invàlid: s'esperava ${expected}, s'ha rebut ${received}`;
66
+ }
67
+ case "invalid_value":
68
+ if (issue.values.length === 1) return `Valor invàlid: s'esperava ${util.stringifyPrimitive(issue.values[0])}`;
69
+ return `Opció invàlida: s'esperava una de ${util.joinValues(issue.values, " o ")}`;
70
+ case "too_big": {
71
+ const adj = issue.inclusive ? "com a màxim" : "menys de";
72
+ const sizing = getSizing(issue.origin);
73
+ if (sizing)
74
+ return `Massa gran: s'esperava que ${issue.origin ?? "el valor"} contingués ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
75
+ return `Massa gran: s'esperava que ${issue.origin ?? "el valor"} fos ${adj} ${issue.maximum.toString()}`;
76
+ }
77
+ case "too_small": {
78
+ const adj = issue.inclusive ? "com a mínim" : "més de";
79
+ const sizing = getSizing(issue.origin);
80
+ if (sizing) {
81
+ return `Massa petit: s'esperava que ${issue.origin} contingués ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
82
+ }
83
+
84
+ return `Massa petit: s'esperava que ${issue.origin} fos ${adj} ${issue.minimum.toString()}`;
85
+ }
86
+ case "invalid_format": {
87
+ const _issue = issue as errors.$ZodStringFormatIssues;
88
+ if (_issue.format === "starts_with") {
89
+ return `Format invàlid: ha de començar amb "${_issue.prefix}"`;
90
+ }
91
+ if (_issue.format === "ends_with") return `Format invàlid: ha d'acabar amb "${_issue.suffix}"`;
92
+ if (_issue.format === "includes") return `Format invàlid: ha d'incloure "${_issue.includes}"`;
93
+ if (_issue.format === "regex") return `Format invàlid: ha de coincidir amb el patró ${_issue.pattern}`;
94
+ return `Format invàlid per a ${FormatDictionary[_issue.format] ?? issue.format}`;
95
+ }
96
+ case "not_multiple_of":
97
+ return `Número invàlid: ha de ser múltiple de ${issue.divisor}`;
98
+ case "unrecognized_keys":
99
+ return `Clau${issue.keys.length > 1 ? "s" : ""} no reconeguda${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
100
+ case "invalid_key":
101
+ return `Clau invàlida a ${issue.origin}`;
102
+ case "invalid_union":
103
+ return "Entrada invàlida"; // Could also be "Tipus d'unió invàlid" but "Entrada invàlida" is more general
104
+ case "invalid_element":
105
+ return `Element invàlid a ${issue.origin}`;
106
+ default:
107
+ return `Entrada invàlida`;
108
+ }
109
+ };
110
+ };
111
+
112
+ export default function (): { localeError: errors.$ZodErrorMap } {
113
+ return {
114
+ localeError: error(),
115
+ };
116
+ }
gui/frontend/node_modules/zod/src/v4/locales/cs.ts ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "znaků", verb: "mít" },
8
+ file: { unit: "bajtů", verb: "mít" },
9
+ array: { unit: "prvků", verb: "mít" },
10
+ set: { unit: "prvků", verb: "mít" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const FormatDictionary: {
18
+ [k in $ZodStringFormats | (string & {})]?: string;
19
+ } = {
20
+ regex: "regulární výraz",
21
+ email: "e-mailová adresa",
22
+ url: "URL",
23
+ emoji: "emoji",
24
+ uuid: "UUID",
25
+ uuidv4: "UUIDv4",
26
+ uuidv6: "UUIDv6",
27
+ nanoid: "nanoid",
28
+ guid: "GUID",
29
+ cuid: "cuid",
30
+ cuid2: "cuid2",
31
+ ulid: "ULID",
32
+ xid: "XID",
33
+ ksuid: "KSUID",
34
+ datetime: "datum a čas ve formátu ISO",
35
+ date: "datum ve formátu ISO",
36
+ time: "čas ve formátu ISO",
37
+ duration: "doba trvání ISO",
38
+ ipv4: "IPv4 adresa",
39
+ ipv6: "IPv6 adresa",
40
+ cidrv4: "rozsah IPv4",
41
+ cidrv6: "rozsah IPv6",
42
+ base64: "řetězec zakódovaný ve formátu base64",
43
+ base64url: "řetězec zakódovaný ve formátu base64url",
44
+ json_string: "řetězec ve formátu JSON",
45
+ e164: "číslo E.164",
46
+ jwt: "JWT",
47
+ template_literal: "vstup",
48
+ };
49
+
50
+ const TypeDictionary: {
51
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
52
+ } = {
53
+ nan: "NaN",
54
+ number: "číslo",
55
+ string: "řetězec",
56
+ function: "funkce",
57
+ array: "pole",
58
+ };
59
+
60
+ return (issue) => {
61
+ switch (issue.code) {
62
+ case "invalid_type": {
63
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
64
+ const receivedType = util.parsedType(issue.input);
65
+ const received = TypeDictionary[receivedType] ?? receivedType;
66
+ if (/^[A-Z]/.test(issue.expected)) {
67
+ return `Neplatný vstup: očekáváno instanceof ${issue.expected}, obdrženo ${received}`;
68
+ }
69
+ return `Neplatný vstup: očekáváno ${expected}, obdrženo ${received}`;
70
+ }
71
+ case "invalid_value":
72
+ if (issue.values.length === 1) return `Neplatný vstup: očekáváno ${util.stringifyPrimitive(issue.values[0])}`;
73
+ return `Neplatná možnost: očekávána jedna z hodnot ${util.joinValues(issue.values, "|")}`;
74
+ case "too_big": {
75
+ const adj = issue.inclusive ? "<=" : "<";
76
+ const sizing = getSizing(issue.origin);
77
+ if (sizing) {
78
+ return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.maximum.toString()} ${sizing.unit ?? "prvků"}`;
79
+ }
80
+ return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.maximum.toString()}`;
81
+ }
82
+ case "too_small": {
83
+ const adj = issue.inclusive ? ">=" : ">";
84
+ const sizing = getSizing(issue.origin);
85
+ if (sizing) {
86
+ return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.minimum.toString()} ${sizing.unit ?? "prvků"}`;
87
+ }
88
+ return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.minimum.toString()}`;
89
+ }
90
+ case "invalid_format": {
91
+ const _issue = issue as errors.$ZodStringFormatIssues;
92
+ if (_issue.format === "starts_with") return `Neplatný řetězec: musí začínat na "${_issue.prefix}"`;
93
+ if (_issue.format === "ends_with") return `Neplatný řetězec: musí končit na "${_issue.suffix}"`;
94
+ if (_issue.format === "includes") return `Neplatný řetězec: musí obsahovat "${_issue.includes}"`;
95
+ if (_issue.format === "regex") return `Neplatný řetězec: musí odpovídat vzoru ${_issue.pattern}`;
96
+ return `Neplatný formát ${FormatDictionary[_issue.format] ?? issue.format}`;
97
+ }
98
+ case "not_multiple_of":
99
+ return `Neplatné číslo: musí být násobkem ${issue.divisor}`;
100
+ case "unrecognized_keys":
101
+ return `Neznámé klíče: ${util.joinValues(issue.keys, ", ")}`;
102
+ case "invalid_key":
103
+ return `Neplatný klíč v ${issue.origin}`;
104
+ case "invalid_union":
105
+ return "Neplatný vstup";
106
+ case "invalid_element":
107
+ return `Neplatná hodnota v ${issue.origin}`;
108
+ default:
109
+ return `Neplatný vstup`;
110
+ }
111
+ };
112
+ };
113
+
114
+ export default function (): { localeError: errors.$ZodErrorMap } {
115
+ return {
116
+ localeError: error(),
117
+ };
118
+ }
gui/frontend/node_modules/zod/src/v4/locales/da.ts ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "tegn", verb: "havde" },
8
+ file: { unit: "bytes", verb: "havde" },
9
+ array: { unit: "elementer", verb: "indeholdt" },
10
+ set: { unit: "elementer", verb: "indeholdt" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const FormatDictionary: {
18
+ [k in $ZodStringFormats | (string & {})]?: string;
19
+ } = {
20
+ regex: "input",
21
+ email: "e-mailadresse",
22
+ url: "URL",
23
+ emoji: "emoji",
24
+ uuid: "UUID",
25
+ uuidv4: "UUIDv4",
26
+ uuidv6: "UUIDv6",
27
+ nanoid: "nanoid",
28
+ guid: "GUID",
29
+ cuid: "cuid",
30
+ cuid2: "cuid2",
31
+ ulid: "ULID",
32
+ xid: "XID",
33
+ ksuid: "KSUID",
34
+ datetime: "ISO dato- og klokkeslæt",
35
+ date: "ISO-dato",
36
+ time: "ISO-klokkeslæt",
37
+ duration: "ISO-varighed",
38
+ ipv4: "IPv4-område",
39
+ ipv6: "IPv6-område",
40
+ cidrv4: "IPv4-spektrum",
41
+ cidrv6: "IPv6-spektrum",
42
+ base64: "base64-kodet streng",
43
+ base64url: "base64url-kodet streng",
44
+ json_string: "JSON-streng",
45
+ e164: "E.164-nummer",
46
+ jwt: "JWT",
47
+ template_literal: "input",
48
+ };
49
+
50
+ const TypeDictionary: {
51
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
52
+ } = {
53
+ nan: "NaN",
54
+ string: "streng",
55
+ number: "tal",
56
+ boolean: "boolean",
57
+ array: "liste",
58
+ object: "objekt",
59
+ set: "sæt",
60
+ file: "fil",
61
+ };
62
+
63
+ return (issue) => {
64
+ switch (issue.code) {
65
+ case "invalid_type": {
66
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
67
+ const receivedType = util.parsedType(issue.input);
68
+ const received = TypeDictionary[receivedType] ?? receivedType;
69
+ if (/^[A-Z]/.test(issue.expected)) {
70
+ return `Ugyldigt input: forventede instanceof ${issue.expected}, fik ${received}`;
71
+ }
72
+ return `Ugyldigt input: forventede ${expected}, fik ${received}`;
73
+ }
74
+ case "invalid_value":
75
+ if (issue.values.length === 1) return `Ugyldig værdi: forventede ${util.stringifyPrimitive(issue.values[0])}`;
76
+ return `Ugyldigt valg: forventede en af følgende ${util.joinValues(issue.values, "|")}`;
77
+ case "too_big": {
78
+ const adj = issue.inclusive ? "<=" : "<";
79
+ const sizing = getSizing(issue.origin);
80
+ const origin = TypeDictionary[issue.origin] ?? issue.origin;
81
+ if (sizing)
82
+ return `For stor: forventede ${origin ?? "value"} ${sizing.verb} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elementer"}`;
83
+ return `For stor: forventede ${origin ?? "value"} havde ${adj} ${issue.maximum.toString()}`;
84
+ }
85
+ case "too_small": {
86
+ const adj = issue.inclusive ? ">=" : ">";
87
+ const sizing = getSizing(issue.origin);
88
+ const origin = TypeDictionary[issue.origin] ?? issue.origin;
89
+ if (sizing) {
90
+ return `For lille: forventede ${origin} ${sizing.verb} ${adj} ${issue.minimum.toString()} ${sizing.unit}`;
91
+ }
92
+
93
+ return `For lille: forventede ${origin} havde ${adj} ${issue.minimum.toString()}`;
94
+ }
95
+ case "invalid_format": {
96
+ const _issue = issue as errors.$ZodStringFormatIssues;
97
+ if (_issue.format === "starts_with") return `Ugyldig streng: skal starte med "${_issue.prefix}"`;
98
+ if (_issue.format === "ends_with") return `Ugyldig streng: skal ende med "${_issue.suffix}"`;
99
+ if (_issue.format === "includes") return `Ugyldig streng: skal indeholde "${_issue.includes}"`;
100
+ if (_issue.format === "regex") return `Ugyldig streng: skal matche mønsteret ${_issue.pattern}`;
101
+ return `Ugyldig ${FormatDictionary[_issue.format] ?? issue.format}`;
102
+ }
103
+ case "not_multiple_of":
104
+ return `Ugyldigt tal: skal være deleligt med ${issue.divisor}`;
105
+ case "unrecognized_keys":
106
+ return `${issue.keys.length > 1 ? "Ukendte nøgler" : "Ukendt nøgle"}: ${util.joinValues(issue.keys, ", ")}`;
107
+ case "invalid_key":
108
+ return `Ugyldig nøgle i ${issue.origin}`;
109
+ case "invalid_union":
110
+ return "Ugyldigt input: matcher ingen af de tilladte typer";
111
+ case "invalid_element":
112
+ return `Ugyldig værdi i ${issue.origin}`;
113
+ default:
114
+ return `Ugyldigt input`;
115
+ }
116
+ };
117
+ };
118
+
119
+ export default function (): { localeError: errors.$ZodErrorMap } {
120
+ return {
121
+ localeError: error(),
122
+ };
123
+ }
gui/frontend/node_modules/zod/src/v4/locales/de.ts ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "Zeichen", verb: "zu haben" },
8
+ file: { unit: "Bytes", verb: "zu haben" },
9
+ array: { unit: "Elemente", verb: "zu haben" },
10
+ set: { unit: "Elemente", verb: "zu haben" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const FormatDictionary: {
18
+ [k in $ZodStringFormats | (string & {})]?: string;
19
+ } = {
20
+ regex: "Eingabe",
21
+ email: "E-Mail-Adresse",
22
+ url: "URL",
23
+ emoji: "Emoji",
24
+ uuid: "UUID",
25
+ uuidv4: "UUIDv4",
26
+ uuidv6: "UUIDv6",
27
+ nanoid: "nanoid",
28
+ guid: "GUID",
29
+ cuid: "cuid",
30
+ cuid2: "cuid2",
31
+ ulid: "ULID",
32
+ xid: "XID",
33
+ ksuid: "KSUID",
34
+ datetime: "ISO-Datum und -Uhrzeit",
35
+ date: "ISO-Datum",
36
+ time: "ISO-Uhrzeit",
37
+ duration: "ISO-Dauer",
38
+ ipv4: "IPv4-Adresse",
39
+ ipv6: "IPv6-Adresse",
40
+ cidrv4: "IPv4-Bereich",
41
+ cidrv6: "IPv6-Bereich",
42
+ base64: "Base64-codierter String",
43
+ base64url: "Base64-URL-codierter String",
44
+ json_string: "JSON-String",
45
+ e164: "E.164-Nummer",
46
+ jwt: "JWT",
47
+ template_literal: "Eingabe",
48
+ };
49
+
50
+ const TypeDictionary: {
51
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
52
+ } = {
53
+ nan: "NaN",
54
+ number: "Zahl",
55
+ array: "Array",
56
+ };
57
+
58
+ return (issue) => {
59
+ switch (issue.code) {
60
+ case "invalid_type": {
61
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
62
+ const receivedType = util.parsedType(issue.input);
63
+ const received = TypeDictionary[receivedType] ?? receivedType;
64
+ if (/^[A-Z]/.test(issue.expected)) {
65
+ return `Ungültige Eingabe: erwartet instanceof ${issue.expected}, erhalten ${received}`;
66
+ }
67
+ return `Ungültige Eingabe: erwartet ${expected}, erhalten ${received}`;
68
+ }
69
+ case "invalid_value":
70
+ if (issue.values.length === 1) return `Ungültige Eingabe: erwartet ${util.stringifyPrimitive(issue.values[0])}`;
71
+ return `Ungültige Option: erwartet eine von ${util.joinValues(issue.values, "|")}`;
72
+ case "too_big": {
73
+ const adj = issue.inclusive ? "<=" : "<";
74
+ const sizing = getSizing(issue.origin);
75
+ if (sizing)
76
+ return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "Elemente"} hat`;
77
+ return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ist`;
78
+ }
79
+ case "too_small": {
80
+ const adj = issue.inclusive ? ">=" : ">";
81
+ const sizing = getSizing(issue.origin);
82
+ if (sizing) {
83
+ return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} hat`;
84
+ }
85
+
86
+ return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ist`;
87
+ }
88
+ case "invalid_format": {
89
+ const _issue = issue as errors.$ZodStringFormatIssues;
90
+ if (_issue.format === "starts_with") return `Ungültiger String: muss mit "${_issue.prefix}" beginnen`;
91
+ if (_issue.format === "ends_with") return `Ungültiger String: muss mit "${_issue.suffix}" enden`;
92
+ if (_issue.format === "includes") return `Ungültiger String: muss "${_issue.includes}" enthalten`;
93
+ if (_issue.format === "regex") return `Ungültiger String: muss dem Muster ${_issue.pattern} entsprechen`;
94
+ return `Ungültig: ${FormatDictionary[_issue.format] ?? issue.format}`;
95
+ }
96
+ case "not_multiple_of":
97
+ return `Ungültige Zahl: muss ein Vielfaches von ${issue.divisor} sein`;
98
+ case "unrecognized_keys":
99
+ return `${issue.keys.length > 1 ? "Unbekannte Schlüssel" : "Unbekannter Schlüssel"}: ${util.joinValues(issue.keys, ", ")}`;
100
+ case "invalid_key":
101
+ return `Ungültiger Schlüssel in ${issue.origin}`;
102
+ case "invalid_union":
103
+ return "Ungültige Eingabe";
104
+ case "invalid_element":
105
+ return `Ungültiger Wert in ${issue.origin}`;
106
+ default:
107
+ return `Ungültige Eingabe`;
108
+ }
109
+ };
110
+ };
111
+
112
+ export default function (): { localeError: errors.$ZodErrorMap } {
113
+ return {
114
+ localeError: error(),
115
+ };
116
+ }
gui/frontend/node_modules/zod/src/v4/locales/el.ts ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "χαρακτήρες", verb: "να έχει" },
8
+ file: { unit: "bytes", verb: "να έχει" },
9
+ array: { unit: "στοιχεία", verb: "να έχει" },
10
+ set: { unit: "στοιχεία", verb: "να έχει" },
11
+ map: { unit: "καταχωρήσεις", verb: "να έχει" },
12
+ };
13
+
14
+ function getSizing(origin: string): { unit: string; verb: string } | null {
15
+ return Sizable[origin] ?? null;
16
+ }
17
+
18
+ const FormatDictionary: {
19
+ [k in $ZodStringFormats | (string & {})]?: string;
20
+ } = {
21
+ regex: "είσοδος",
22
+ email: "διεύθυνση email",
23
+ url: "URL",
24
+ emoji: "emoji",
25
+ uuid: "UUID",
26
+ uuidv4: "UUIDv4",
27
+ uuidv6: "UUIDv6",
28
+ nanoid: "nanoid",
29
+ guid: "GUID",
30
+ cuid: "cuid",
31
+ cuid2: "cuid2",
32
+ ulid: "ULID",
33
+ xid: "XID",
34
+ ksuid: "KSUID",
35
+ datetime: "ISO ημερομηνία και ώρα",
36
+ date: "ISO ημερομηνία",
37
+ time: "ISO ώρα",
38
+ duration: "ISO διάρκεια",
39
+ ipv4: "διεύθυνση IPv4",
40
+ ipv6: "διεύθυνση IPv6",
41
+ mac: "διεύθυνση MAC",
42
+ cidrv4: "εύρος IPv4",
43
+ cidrv6: "εύρος IPv6",
44
+ base64: "συμβολοσειρά κωδικοποιημένη σε base64",
45
+ base64url: "συμβολοσειρά κωδικοποιημένη σε base64url",
46
+ json_string: "συμβολοσειρά JSON",
47
+ e164: "αριθμός E.164",
48
+ jwt: "JWT",
49
+ template_literal: "είσοδος",
50
+ };
51
+
52
+ const TypeDictionary: {
53
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
54
+ } = {
55
+ nan: "NaN",
56
+ };
57
+
58
+ return (issue) => {
59
+ switch (issue.code) {
60
+ case "invalid_type": {
61
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
62
+ const receivedType = util.parsedType(issue.input);
63
+ const received = TypeDictionary[receivedType] ?? receivedType;
64
+ if (typeof issue.expected === "string" && /^[A-Z]/.test(issue.expected)) {
65
+ return `Μη έγκυρη είσοδος: αναμενόταν instanceof ${issue.expected}, λήφθηκε ${received}`;
66
+ }
67
+ return `Μη έγκυρη είσοδος: αναμενόταν ${expected}, λήφθηκε ${received}`;
68
+ }
69
+
70
+ case "invalid_value":
71
+ if (issue.values.length === 1)
72
+ return `Μη έγκυρη είσοδος: αναμενόταν ${util.stringifyPrimitive(issue.values[0])}`;
73
+ return `Μη έγκυρη επιλογή: αναμενόταν ένα από ${util.joinValues(issue.values, "|")}`;
74
+ case "too_big": {
75
+ const adj = issue.inclusive ? "<=" : "<";
76
+ const sizing = getSizing(issue.origin);
77
+ if (sizing)
78
+ return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να έχει ${adj}${issue.maximum.toString()} ${sizing.unit ?? "στοιχεία"}`;
79
+ return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να είναι ${adj}${issue.maximum.toString()}`;
80
+ }
81
+ case "too_small": {
82
+ const adj = issue.inclusive ? ">=" : ">";
83
+ const sizing = getSizing(issue.origin);
84
+ if (sizing) {
85
+ return `Πολύ μικρό: αναμενόταν ${issue.origin} να έχει ${adj}${issue.minimum.toString()} ${sizing.unit}`;
86
+ }
87
+
88
+ return `Πολύ μικρό: αναμενόταν ${issue.origin} να είναι ${adj}${issue.minimum.toString()}`;
89
+ }
90
+ case "invalid_format": {
91
+ const _issue = issue as errors.$ZodStringFormatIssues;
92
+ if (_issue.format === "starts_with") {
93
+ return `Μη έγκυρη συμβολοσειρά: πρέπει να ξεκινά με "${_issue.prefix}"`;
94
+ }
95
+ if (_issue.format === "ends_with") return `Μη έγκυρη συμβολοσειρά: πρέπει να τελειώνει με "${_issue.suffix}"`;
96
+ if (_issue.format === "includes") return `Μη έγκυρη συμβολοσειρά: πρέπει να περιέχει "${_issue.includes}"`;
97
+ if (_issue.format === "regex")
98
+ return `Μη έγκυρη συμβολοσειρά: πρέπει να ταιριάζει με το μοτίβο ${_issue.pattern}`;
99
+ return `Μη έγκυρο: ${FormatDictionary[_issue.format] ?? issue.format}`;
100
+ }
101
+ case "not_multiple_of":
102
+ return `Μη έγκυρος αριθμός: πρέπει να είναι πολλαπλάσιο του ${issue.divisor}`;
103
+ case "unrecognized_keys":
104
+ return `Άγνωστ${issue.keys.length > 1 ? "α" : "ο"} κλειδ${issue.keys.length > 1 ? "ιά" : "ί"}: ${util.joinValues(issue.keys, ", ")}`;
105
+ case "invalid_key":
106
+ return `Μη έγκυρο κλειδί στο ${issue.origin}`;
107
+ case "invalid_union":
108
+ return "Μη έγκυρη είσοδος";
109
+ case "invalid_element":
110
+ return `Μη έγκυρη τιμή στο ${issue.origin}`;
111
+ default:
112
+ return `Μη έγκυρη είσοδος`;
113
+ }
114
+ };
115
+ };
116
+
117
+ export default function (): { localeError: errors.$ZodErrorMap } {
118
+ return {
119
+ localeError: error(),
120
+ };
121
+ }
gui/frontend/node_modules/zod/src/v4/locales/en.ts ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "characters", verb: "to have" },
8
+ file: { unit: "bytes", verb: "to have" },
9
+ array: { unit: "items", verb: "to have" },
10
+ set: { unit: "items", verb: "to have" },
11
+ map: { unit: "entries", verb: "to have" },
12
+ };
13
+
14
+ function getSizing(origin: string): { unit: string; verb: string } | null {
15
+ return Sizable[origin] ?? null;
16
+ }
17
+
18
+ const FormatDictionary: {
19
+ [k in $ZodStringFormats | (string & {})]?: string;
20
+ } = {
21
+ regex: "input",
22
+ email: "email address",
23
+ url: "URL",
24
+ emoji: "emoji",
25
+ uuid: "UUID",
26
+ uuidv4: "UUIDv4",
27
+ uuidv6: "UUIDv6",
28
+ nanoid: "nanoid",
29
+ guid: "GUID",
30
+ cuid: "cuid",
31
+ cuid2: "cuid2",
32
+ ulid: "ULID",
33
+ xid: "XID",
34
+ ksuid: "KSUID",
35
+ datetime: "ISO datetime",
36
+ date: "ISO date",
37
+ time: "ISO time",
38
+ duration: "ISO duration",
39
+ ipv4: "IPv4 address",
40
+ ipv6: "IPv6 address",
41
+ mac: "MAC address",
42
+ cidrv4: "IPv4 range",
43
+ cidrv6: "IPv6 range",
44
+ base64: "base64-encoded string",
45
+ base64url: "base64url-encoded string",
46
+ json_string: "JSON string",
47
+ e164: "E.164 number",
48
+ jwt: "JWT",
49
+ template_literal: "input",
50
+ };
51
+
52
+ // type names: missing keys = do not translate (use raw value via ?? fallback)
53
+ const TypeDictionary: {
54
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
55
+ } = {
56
+ // Compatibility: "nan" -> "NaN" for display
57
+ nan: "NaN",
58
+ // All other type names omitted - they fall back to raw values via ?? operator
59
+ };
60
+
61
+ return (issue) => {
62
+ switch (issue.code) {
63
+ case "invalid_type": {
64
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
65
+ const receivedType = util.parsedType(issue.input);
66
+ const received = TypeDictionary[receivedType] ?? receivedType;
67
+ return `Invalid input: expected ${expected}, received ${received}`;
68
+ }
69
+
70
+ case "invalid_value":
71
+ if (issue.values.length === 1) return `Invalid input: expected ${util.stringifyPrimitive(issue.values[0])}`;
72
+ return `Invalid option: expected one of ${util.joinValues(issue.values, "|")}`;
73
+ case "too_big": {
74
+ const adj = issue.inclusive ? "<=" : "<";
75
+ const sizing = getSizing(issue.origin);
76
+ if (sizing)
77
+ return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`;
78
+ return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`;
79
+ }
80
+ case "too_small": {
81
+ const adj = issue.inclusive ? ">=" : ">";
82
+ const sizing = getSizing(issue.origin);
83
+ if (sizing) {
84
+ return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`;
85
+ }
86
+
87
+ return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`;
88
+ }
89
+ case "invalid_format": {
90
+ const _issue = issue as errors.$ZodStringFormatIssues;
91
+ if (_issue.format === "starts_with") {
92
+ return `Invalid string: must start with "${_issue.prefix}"`;
93
+ }
94
+ if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`;
95
+ if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`;
96
+ if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`;
97
+ return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`;
98
+ }
99
+ case "not_multiple_of":
100
+ return `Invalid number: must be a multiple of ${issue.divisor}`;
101
+ case "unrecognized_keys":
102
+ return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`;
103
+ case "invalid_key":
104
+ return `Invalid key in ${issue.origin}`;
105
+ case "invalid_union":
106
+ if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) {
107
+ const opts = issue.options.map((o) => `'${o}'`).join(" | ");
108
+ return `Invalid discriminator value. Expected ${opts}`;
109
+ }
110
+ return "Invalid input";
111
+ case "invalid_element":
112
+ return `Invalid value in ${issue.origin}`;
113
+ default:
114
+ return `Invalid input`;
115
+ }
116
+ };
117
+ };
118
+
119
+ export default function (): { localeError: errors.$ZodErrorMap } {
120
+ return {
121
+ localeError: error(),
122
+ };
123
+ }
gui/frontend/node_modules/zod/src/v4/locales/eo.ts ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import type { $ZodStringFormats } from "../core/checks.js";
2
+ import type * as errors from "../core/errors.js";
3
+ import * as util from "../core/util.js";
4
+
5
+ const error: () => errors.$ZodErrorMap = () => {
6
+ const Sizable: Record<string, { unit: string; verb: string }> = {
7
+ string: { unit: "karaktrojn", verb: "havi" },
8
+ file: { unit: "bajtojn", verb: "havi" },
9
+ array: { unit: "elementojn", verb: "havi" },
10
+ set: { unit: "elementojn", verb: "havi" },
11
+ };
12
+
13
+ function getSizing(origin: string): { unit: string; verb: string } | null {
14
+ return Sizable[origin] ?? null;
15
+ }
16
+
17
+ const FormatDictionary: {
18
+ [k in $ZodStringFormats | (string & {})]?: string;
19
+ } = {
20
+ regex: "enigo",
21
+ email: "retadreso",
22
+ url: "URL",
23
+ emoji: "emoĝio",
24
+ uuid: "UUID",
25
+ uuidv4: "UUIDv4",
26
+ uuidv6: "UUIDv6",
27
+ nanoid: "nanoid",
28
+ guid: "GUID",
29
+ cuid: "cuid",
30
+ cuid2: "cuid2",
31
+ ulid: "ULID",
32
+ xid: "XID",
33
+ ksuid: "KSUID",
34
+ datetime: "ISO-datotempo",
35
+ date: "ISO-dato",
36
+ time: "ISO-tempo",
37
+ duration: "ISO-daŭro",
38
+ ipv4: "IPv4-adreso",
39
+ ipv6: "IPv6-adreso",
40
+ cidrv4: "IPv4-rango",
41
+ cidrv6: "IPv6-rango",
42
+ base64: "64-ume kodita karaktraro",
43
+ base64url: "URL-64-ume kodita karaktraro",
44
+ json_string: "JSON-karaktraro",
45
+ e164: "E.164-nombro",
46
+ jwt: "JWT",
47
+ template_literal: "enigo",
48
+ };
49
+
50
+ const TypeDictionary: {
51
+ [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string;
52
+ } = {
53
+ nan: "NaN",
54
+ number: "nombro",
55
+ array: "tabelo",
56
+ null: "senvalora",
57
+ };
58
+
59
+ return (issue) => {
60
+ switch (issue.code) {
61
+ case "invalid_type": {
62
+ const expected = TypeDictionary[issue.expected] ?? issue.expected;
63
+ const receivedType = util.parsedType(issue.input);
64
+ const received = TypeDictionary[receivedType] ?? receivedType;
65
+ if (/^[A-Z]/.test(issue.expected)) {
66
+ return `Nevalida enigo: atendiĝis instanceof ${issue.expected}, riceviĝis ${received}`;
67
+ }
68
+ return `Nevalida enigo: atendiĝis ${expected}, riceviĝis ${received}`;
69
+ }
70
+
71
+ case "invalid_value":
72
+ if (issue.values.length === 1) return `Nevalida enigo: atendiĝis ${util.stringifyPrimitive(issue.values[0])}`;
73
+ return `Nevalida opcio: atendiĝis unu el ${util.joinValues(issue.values, "|")}`;
74
+ case "too_big": {
75
+ const adj = issue.inclusive ? "<=" : "<";
76
+ const sizing = getSizing(issue.origin);
77
+ if (sizing)
78
+ return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementojn"}`;
79
+ return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()}`;
80
+ }
81
+ case "too_small": {
82
+ const adj = issue.inclusive ? ">=" : ">";
83
+ const sizing = getSizing(issue.origin);
84
+ if (sizing) {
85
+ return `Tro malgranda: atendiĝis ke ${issue.origin} havu ${adj}${issue.minimum.toString()} ${sizing.unit}`;
86
+ }
87
+
88
+ return `Tro malgranda: atendiĝis ke ${issue.origin} estu ${adj}${issue.minimum.toString()}`;
89
+ }
90
+ case "invalid_format": {
91
+ const _issue = issue as errors.$ZodStringFormatIssues;
92
+ if (_issue.format === "starts_with") return `Nevalida karaktraro: devas komenciĝi per "${_issue.prefix}"`;
93
+ if (_issue.format === "ends_with") return `Nevalida karaktraro: devas finiĝi per "${_issue.suffix}"`;
94
+ if (_issue.format === "includes") return `Nevalida karaktraro: devas inkluzivi "${_issue.includes}"`;
95
+ if (_issue.format === "regex") return `Nevalida karaktraro: devas kongrui kun la modelo ${_issue.pattern}`;
96
+ return `Nevalida ${FormatDictionary[_issue.format] ?? issue.format}`;
97
+ }
98
+ case "not_multiple_of":
99
+ return `Nevalida nombro: devas esti oblo de ${issue.divisor}`;
100
+ case "unrecognized_keys":
101
+ return `Nekonata${issue.keys.length > 1 ? "j" : ""} ŝlosilo${issue.keys.length > 1 ? "j" : ""}: ${util.joinValues(issue.keys, ", ")}`;
102
+ case "invalid_key":
103
+ return `Nevalida ŝlosilo en ${issue.origin}`;
104
+ case "invalid_union":
105
+ return "Nevalida enigo";
106
+ case "invalid_element":
107
+ return `Nevalida valoro en ${issue.origin}`;
108
+ default:
109
+ return `Nevalida enigo`;
110
+ }
111
+ };
112
+ };
113
+
114
+ export default function (): { localeError: errors.$ZodErrorMap } {
115
+ return {
116
+ localeError: error(),
117
+ };
118
+ }