diff --git a/VAE/Harvest_VAE.py b/VAE/Harvest_VAE.py new file mode 100644 index 0000000000000000000000000000000000000000..dce7ad8137cee91f6d6adb60653de27fb3ea9f6f --- /dev/null +++ b/VAE/Harvest_VAE.py @@ -0,0 +1,88 @@ +import os +import torch +import torch.nn as nn +import torch.nn.functional as F +from torchvision.utils import save_image +from tqdm import tqdm + +# 1. Rebuild the exact VAE Architecture to load the weights +class VAE(nn.Module): + def __init__(self, latent_dim=128): + super(VAE, self).__init__() + self.enc1 = nn.Conv2d(1, 32, 4, 2, 1) + self.enc2 = nn.Conv2d(32, 64, 4, 2, 1) + self.enc3 = nn.Conv2d(64, 128, 4, 2, 1) + self.enc4 = nn.Conv2d(128, 256, 4, 2, 1) + self.enc5 = nn.Conv2d(256, 512, 4, 2, 1) + self.fc_mu = nn.Linear(512 * 7 * 7, latent_dim) + self.fc_logvar = nn.Linear(512 * 7 * 7, latent_dim) + + self.dec_fc = nn.Linear(latent_dim, 512 * 7 * 7) + self.dec1 = nn.ConvTranspose2d(512, 256, 4, 2, 1) + self.dec2 = nn.ConvTranspose2d(256, 128, 4, 2, 1) + self.dec3 = nn.ConvTranspose2d(128, 64, 4, 2, 1) + self.dec4 = nn.ConvTranspose2d(64, 32, 4, 2, 1) + self.dec5 = nn.ConvTranspose2d(32, 1, 4, 2, 1) + + def decode(self, z): + x = F.relu(self.dec_fc(z)) + x = x.view(x.size(0), 512, 7, 7) + x = F.relu(self.dec1(x)) + x = F.relu(self.dec2(x)) + x = F.relu(self.dec3(x)) + x = F.relu(self.dec4(x)) + x = torch.sigmoid(self.dec5(x)) + return x + +def main(): + device = torch.device("cuda" if torch.cuda.is_available() else "cpu") + print(f"Targeting device for VAE harvesting: {device}") + + # Set up NVMe paths + dataset_root = r"C:\Users\USER\Downloads\MedMNIST_Data" + output_dir = os.path.join(dataset_root, "VAE_Synthetic", "Normal_0") + os.makedirs(output_dir, exist_ok=True) + + # 2. Load the trained brain + print("Loading VAE weights...") + model = VAE(latent_dim=128).to(device) + weight_path = os.path.join(dataset_root, "vae_baseline.pth") + + if not os.path.exists(weight_path): + print(f"Error: Weights not found at {weight_path}") + return + + model.load_state_dict(torch.load(weight_path, map_location=device, weights_only=True)) + model.eval() + + # 3. Harvest Parameters + total_images_needed = 2600 + batch_size = 64 + latent_dim = 128 + generated_count = 0 + + print(f"Sampling {total_images_needed} images from the VAE latent space...") + + with torch.no_grad(): + with tqdm(total=total_images_needed, desc="Decoding Images") as pbar: + while generated_count < total_images_needed: + current_batch_size = min(batch_size, total_images_needed - generated_count) + + # Sample random coordinates from the standard normal distribution + z = torch.randn(current_batch_size, latent_dim).to(device) + + # Push through the Decoder (no need to un-normalize, Sigmoid handled it) + fake_images = model.decode(z) + + # Save out + for i in range(current_batch_size): + img_path = os.path.join(output_dir, f"vae_normal_{generated_count}.png") + save_image(fake_images[i], img_path) + generated_count += 1 + + pbar.update(current_batch_size) + + print(f"\nVAE Harvest complete. Images stored in: {output_dir}") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/VAE/Train_VAE.py b/VAE/Train_VAE.py new file mode 100644 index 0000000000000000000000000000000000000000..ae9dd5ad7db398d55159da87773117081ace481a --- /dev/null +++ b/VAE/Train_VAE.py @@ -0,0 +1,151 @@ +import os +import torch +import torch.nn as nn +import torch.nn.functional as F +import torch.optim as optim +from torchvision import transforms +from torchvision.utils import save_image +from torch.utils.data import DataLoader, Subset +import medmnist +from medmnist import INFO +from tqdm import tqdm + +# ========================================== +# 1. The VAE Architecture +# ========================================== +class VAE(nn.Module): + def __init__(self, latent_dim=128): + super(VAE, self).__init__() + + # ENCODER: Compress 224x224 down to 7x7 + self.enc1 = nn.Conv2d(1, 32, 4, 2, 1) # Output: 112x112 + self.enc2 = nn.Conv2d(32, 64, 4, 2, 1) # Output: 56x56 + self.enc3 = nn.Conv2d(64, 128, 4, 2, 1) # Output: 28x28 + self.enc4 = nn.Conv2d(128, 256, 4, 2, 1) # Output: 14x14 + self.enc5 = nn.Conv2d(256, 512, 4, 2, 1) # Output: 7x7 + + # The Probabilistic Split (Mean and Log-Variance) + self.fc_mu = nn.Linear(512 * 7 * 7, latent_dim) + self.fc_logvar = nn.Linear(512 * 7 * 7, latent_dim) + + # DECODER: Expand from latent_dim back to 224x224 + self.dec_fc = nn.Linear(latent_dim, 512 * 7 * 7) + self.dec1 = nn.ConvTranspose2d(512, 256, 4, 2, 1) + self.dec2 = nn.ConvTranspose2d(256, 128, 4, 2, 1) + self.dec3 = nn.ConvTranspose2d(128, 64, 4, 2, 1) + self.dec4 = nn.ConvTranspose2d(64, 32, 4, 2, 1) + self.dec5 = nn.ConvTranspose2d(32, 1, 4, 2, 1) + + def encode(self, x): + x = F.relu(self.enc1(x)) + x = F.relu(self.enc2(x)) + x = F.relu(self.enc3(x)) + x = F.relu(self.enc4(x)) + x = F.relu(self.enc5(x)) + x = x.view(x.size(0), -1) # Flatten + return self.fc_mu(x), self.fc_logvar(x) + + def reparameterize(self, mu, logvar): + # The Reparameterization Trick: z = mu + std * epsilon + std = torch.exp(0.5 * logvar) + eps = torch.randn_like(std) + return mu + eps * std + + def decode(self, z): + x = F.relu(self.dec_fc(z)) + x = x.view(x.size(0), 512, 7, 7) # Unflatten + x = F.relu(self.dec1(x)) + x = F.relu(self.dec2(x)) + x = F.relu(self.dec3(x)) + x = F.relu(self.dec4(x)) + # Sigmoid pushes pixels to exact [0, 1] range + x = torch.sigmoid(self.dec5(x)) + return x + + def forward(self, x): + mu, logvar = self.encode(x) + z = self.reparameterize(mu, logvar) + recon_x = self.decode(z) + return recon_x, mu, logvar + +# ========================================== +# 2. The Custom VAE Loss Function +# ========================================== +def vae_loss_function(recon_x, x, mu, logvar): + # Loss 1: Reconstruction Loss (How well did it recreate the image?) + BCE = F.binary_cross_entropy(recon_x, x, reduction='sum') + + # Loss 2: KL Divergence (Forces latent space to be a standard normal distribution) + KLD = -0.5 * torch.sum(1 + logvar - mu.pow(2) - logvar.exp()) + + return BCE + KLD + +# ========================================== +# 3. The Training Engine +# ========================================== +def main(): + device = torch.device("cuda" if torch.cuda.is_available() else "cpu") + print(f"Igniting VAE Engine on: {device}") + + dataset_root = r"C:\Users\USER\Downloads\MedMNIST_Data" + out_dir = os.path.join(dataset_root, "VAE_Outputs") + os.makedirs(out_dir, exist_ok=True) + + # Hyperparameters + num_epochs = 100 + batch_size = 64 + learning_rate = 1e-4 + + # Strict Normalization to [0, 1] for BCE Loss + transform = transforms.Compose([ + transforms.ToTensor(), + ]) + + print("Isolating pure 'Normal (0)' lungs...") + info = INFO['pneumoniamnist'] + DataClass = getattr(medmnist, info['python_class']) + full_dataset = DataClass(split='train', transform=transform, download=False, size=224, root=dataset_root) + + normal_indices = [i for i in range(len(full_dataset)) if full_dataset[i][1][0] == 0] + normal_dataset = Subset(full_dataset, normal_indices) + dataloader = DataLoader(normal_dataset, batch_size=batch_size, shuffle=True, num_workers=0) + + model = VAE(latent_dim=128).to(device) + optimizer = optim.Adam(model.parameters(), lr=learning_rate) + + print(f"Commencing VAE Training over {num_epochs} Epochs...") + for epoch in range(num_epochs): + model.train() + train_loss = 0 + loop = tqdm(dataloader, leave=True) + + for batch_idx, (data, _) in enumerate(loop): + data = data.to(device) + optimizer.zero_grad() + + recon_batch, mu, logvar = model(data) + loss = vae_loss_function(recon_batch, data, mu, logvar) + + loss.backward() + train_loss += loss.item() + optimizer.step() + + loop.set_description(f"Epoch [{epoch+1}/{num_epochs}]") + loop.set_postfix(Loss=loss.item() / len(data)) + + # Generate a test image every 10 epochs + if (epoch + 1) % 10 == 0: + model.eval() + with torch.no_grad(): + # Sample pure random noise from the normal distribution + sample = torch.randn(16, 128).to(device) + sample = model.decode(sample).cpu() + save_image(sample.view(16, 1, 224, 224), os.path.join(out_dir, f'sample_epoch_{epoch+1}.png'), nrow=4) + + # Save the final brain + save_path = os.path.join(dataset_root, 'vae_baseline.pth') + torch.save(model.state_dict(), save_path) + print(f"\nVAE Training Complete! Weights saved to: {save_path}") + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/gui/frontend/README.md b/gui/frontend/README.md new file mode 100644 index 0000000000000000000000000000000000000000..a36934d874c7fbc51aecd1c66dffc106f60693a9 --- /dev/null +++ b/gui/frontend/README.md @@ -0,0 +1,16 @@ +# React + Vite + +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. + +Currently, two official plugins are available: + +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Oxc](https://oxc.rs) +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) + +## React Compiler + +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). + +## Expanding the ESLint configuration + +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. diff --git a/gui/frontend/node_modules/zod-validation-error/LICENSE b/gui/frontend/node_modules/zod-validation-error/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..c2d088e4a5afe7ec7513012198b8dfc479ab3508 --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/LICENSE @@ -0,0 +1,9 @@ +(The MIT License) + +Copyright 2022 Causaly, Inc + +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: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +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. diff --git a/gui/frontend/node_modules/zod-validation-error/README.md b/gui/frontend/node_modules/zod-validation-error/README.md new file mode 100644 index 0000000000000000000000000000000000000000..66b579ea197e4c51974ce1e058a30b216a31848b --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/README.md @@ -0,0 +1,504 @@ +# zod-validation-error + +Wrap zod validation errors in user-friendly readable messages. + +[![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) + +#### Features + +- User-friendly readable error messages with extensive configuration options; +- Preserves original error details accessible via `error.details`; +- Provides a custom error map for better user-friendly messages; +- Supports both Zod v3 and v4. + +**_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) + +## Installation + +```bash +npm install zod-validation-error +``` + +#### Requirements + +- Node.js v.18+ +- TypeScript v.4.5+ + +## Quick start + +```typescript +import { z as zod } from 'zod'; +import { fromError, createErrorMap } from 'zod-validation-error'; + +// configure zod to use zod-validation-error's error map +// this is optional, you may also use your own custom error map or zod's native error map +// we recommend using zod-validation-error's error map for better user-friendly messages +// see https://zod.dev/error-customization for further details +zod.config({ + customError: createErrorMap(), +}); + +// create zod schema +const zodSchema = zod.object({ + id: zod.int().positive(), + email: zod.email(), +}); + +// parse some invalid value +try { + zodSchema.parse({ + id: 1, + email: 'coyote@acme', // note: invalid email + }); +} catch (err) { + const validationError = fromError(err); + // the error is now readable by the user + // you may print it to console + console.log(validationError.toString()); + // or return it as an actual error + return validationError; +} +``` + +## Motivation + +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. + +### Example + +#### Input (from Zod) + +```json +[ + { + "origin": "number", + "code": "too_small", + "minimum": 0, + "inclusive": false, + "path": ["id"], + "message": "Number must be greater than 0 at \"id\"" + }, + { + "origin": "string", + "code": "invalid_format", + "format": "email", + "pattern": "/^(?!\\.)(?!.*\\.\\.)([A-Za-z0-9_'+\\-\\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\\-]*\\.)+[A-Za-z]{2,}$/", + "path": ["email"], + "message": "Invalid email at \"email\"" + } +] +``` + +#### Output + +``` +Validation error: Number must be greater than 0 at "id"; Invalid email at "email" +``` + +## API + +- [ValidationError(message[, options])](#validationerror) +- [createErrorMap(options)](#createErrorMap) +- [createMessageBuilder(options)](#createMessageBuilder) +- [isValidationError(error)](#isvalidationerror) +- [isValidationErrorLike(error)](#isvalidationerrorlike) +- [isZodErrorLike(error)](#iszoderrorlike) +- [fromError(error[, options])](#fromerror) +- [fromZodIssue(zodIssue[, options])](#fromzodissue) +- [fromZodError(zodError[, options])](#fromzoderror) +- [toValidationError([options]) => (error) => ValidationError](#tovalidationerror) + +### ValidationError + +Main `ValidationError` class, extending JavaScript's native `Error`. + +#### Arguments + +- `message` - _string_; error message (required) +- `options` - _ErrorOptions_; error options as per [JavaScript definition](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error#options) (optional) + - `options.cause` - _any_; can be used to hold the original zod error (optional) + +#### Example 1: construct new ValidationError with `message` + +```typescript +import { ValidationError } from 'zod-validation-error'; + +const error = new ValidationError('foobar'); +console.log(error instanceof Error); // prints true +``` + +#### Example 2: construct new ValidationError with `message` and `options.cause` + +```typescript +import { z as zod } from 'zod'; +import { ValidationError } from 'zod-validation-error'; + +const error = new ValidationError('foobar', { + cause: new zod.ZodError([ + { + origin: 'number', + code: 'too_small', + minimum: 0, + inclusive: false, + path: ['id'], + message: 'Number must be greater than 0 at "id"', + input: -1, + }, + ]), +}); + +console.log(error.details); // prints issues from zod error +``` + +### createErrorMap + +Creates zod-validation-error's `errorMap`, which is used to format issues into user-friendly error messages. + +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. + +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. + +#### Arguments + +- `options` - _Object_; formatting options (optional) + +##### createErrorMap Options + +| Name | Type | Description | +| ------------------------------- | :-------------------------------: | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `displayInvalidFormatDetails` | `boolean` | Indicates whether to display invalid format details (e.g. regexp pattern) in the error message (optional, defaults to `false`) | +| `maxAllowedValuesToDisplay` | `number` | Max number of allowed values to display (optional, defaults to `10`). Allowed values beyond this limit will be hidden. | +| `allowedValuesSeparator` | `string` | Used to concatenate allowed values in the message (optional, defaults to `", "`) | +| `allowedValuesLastSeparator` | `string \| undefined` | Used to concatenate last allowed value in the message (optional, defaults to `" or "`). Set to `undefined` to disable. | +| `wrapAllowedValuesInQuote` | `boolean` | Indicates whether to wrap allowed values in quotes (optional, defaults to `true`). Note that this only applies to string values. | +| `maxUnrecognizedKeysToDisplay` | `number` | Max number of unrecognized keys to display in the error message (optional, defaults to `5`) | +| `unrecognizedKeysSeparator` | `string` | Used to concatenate unrecognized keys in the message (optional, defaults to `", "`) | +| `unrecognizedKeysLastSeparator` | `string \| undefined` | Used to concatenate the last unrecognized key in message (optional, defaults to `" and "`). Set to `undefined` to disable. | +| `wrapUnrecognizedKeysInQuote` | `boolean` | Indicates whether to wrap unrecognized keys in quotes (optional, defaults to `true`). Note that this only applies to string keys. | +| `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. | +| `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. | + +#### Example + +```typescript +import { z as zod } from 'zod'; +import { createErrorMap } from 'zod-validation-error'; + +zod.config({ + customError: createErrorMap({ + // default values are used when not specified + displayInvalidFormatDetails: true, + }), +}); +``` + +### createMessageBuilder + +Creates zod-validation-error's default `MessageBuilder`, which is used to produce user-friendly error messages. + +Meant to be passed as an option to [fromError](#fromerror), [fromZodIssue](#fromzodissue), [fromZodError](#fromzoderror) or [toValidationError](#tovalidationerror). + +#### Arguments + +- `options` - _Object_; formatting options (optional) + +##### createMessageBuilder Options + +| Name | Type | Description | +| -------------------- | :-------------------: | ---------------------------------------------------------------------------------------------------------------------------------------- | +| `maxIssuesInMessage` | `number` | Max issues to include in user-friendly message (optional, defaults to `99`) | +| `issueSeparator` | `string` | Used to concatenate issues in user-friendly message (optional, defaults to `";"`) | +| `unionSeparator` | `string` | Used to concatenate union-issues in user-friendly message (optional, defaults to `" or "`) | +| `prefix` | `string \| undefined` | Prefix to use in user-friendly message (optional, defaults to `"Validation error"`). Pass `undefined` to disable prefix completely. | +| `prefixSeparator` | `string` | Used to concatenate prefix with rest of the user-friendly message (optional, defaults to `": "`). Not used when `prefix` is `undefined`. | +| `includePath` | `boolean` | Indicates whether to include the erroneous property key in the error message (optional, defaults to `true`) | +| `forceTitleCase` | `boolean` | Indicates whether to convert individual issue messages to title case (optional, defaults to `true`). | + +#### Example + +```typescript +import { createMessageBuilder } from 'zod-validation-error'; + +const messageBuilder = createMessageBuilder({ + maxIssuesInMessage: 3, + includePath: false, +}); +``` + +### isValidationError + +A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on `instanceof` comparison. + +#### Arguments + +- `error` - error instance (required) + +#### Example + +```typescript +import { z as zod } from 'zod'; +import { ValidationError, isValidationError } from 'zod-validation-error'; + +const err = new ValidationError('foobar'); +isValidationError(err); // returns true + +const invalidErr = new Error('foobar'); +isValidationError(err); // returns false +``` + +### isValidationErrorLike + +A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on _heuristics_ comparison. + +_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. + +tl;dr if you are uncertain then it is preferable to use `isValidationErrorLike` instead of `isValidationError`. + +#### Arguments + +- `error` - error instance (required) + +#### Example + +```typescript +import { ValidationError, isValidationErrorLike } from 'zod-validation-error'; + +const err = new ValidationError('foobar'); +isValidationErrorLike(err); // returns true + +const invalidErr = new Error('foobar'); +isValidationErrorLike(err); // returns false +``` + +### isZodErrorLike + +A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on _heuristics_ comparison. + +_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. + +#### Arguments + +- `error` - error instance (required) + +#### Example + +```typescript +import { z as zod } from 'zod'; +import { ValidationError, isZodErrorLike } from 'zod-validation-error'; + +const zodValidationErr = new ValidationError('foobar'); +isZodErrorLike(zodValidationErr); // returns false + +const genericErr = new Error('foobar'); +isZodErrorLike(genericErr); // returns false + +const zodErr = new zod.ZodError([ + { + origin: 'number', + code: 'too_small', + minimum: 0, + inclusive: false, + path: ['id'], + message: 'Number must be greater than 0 at "id"', + input: -1, + }, +]); +isZodErrorLike(zodErr); // returns true +``` + +### fromError + +Converts an error to `ValidationError`. + +_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`. + +#### Arguments + +- `error` - _unknown_; an error (required) +- `options` - _Object_; formatting options (optional) + - `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). + +#### Notes + +Alternatively, you may pass [createMessageBuilder options](#createmessagebuilder-options) directly as `options`. These will be used as arguments to create the `MessageBuilder` instance internally. + +### fromZodIssue + +Converts a single zod issue to `ValidationError`. + +#### Arguments + +- `zodIssue` - _zod.ZodIssue_; a ZodIssue instance (required) +- `options` - _Object_; formatting options (optional) + - `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). + +#### Notes + +Alternatively, you may pass [createMessageBuilder options](#createmessagebuilder-options) directly as `options`. These will be used as arguments to create the `MessageBuilder` instance internally. + +### fromZodError + +Converts zod error to `ValidationError`. + +_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()`. + +#### Arguments + +- `zodError` - _zod.ZodError_; a ZodError instance (required) +- `options` - _Object_; formatting options (optional) + - `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). + +#### Notes + +Alternatively, you may pass [createMessageBuilder options](#createmessagebuilder-optionscreateMessageBuilder) directly as `options`. These will be used as arguments to create the `MessageBuilder` instance internally. + +### toValidationError + +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 + +```js +toValidationError(options) => (zodError) => ValidationError +``` + +#### Example using fp-ts + +```typescript +import * as Either from 'fp-ts/Either'; +import { z as zod } from 'zod'; +import { toValidationError, ValidationError } from 'zod-validation-error'; + +// create zod schema +const zodSchema = zod + .object({ + id: zod.int().positive(), + email: zod.email(), + }) + .brand<'User'>(); + +export type User = zod.infer; + +export function parse( + value: zod.input +): Either.Either { + return Either.tryCatch(() => schema.parse(value), toValidationError()); +} +``` + +## FAQ + +### What is the difference between zod-validation-error and zod's own [prettifyError](https://zod.dev/error-formatting#zprettifyerror)? + +While both libraries aim to provide a human-readable string representation of a zod error, they differ in several ways... + +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. +1. **Customization options**: zod-validation-error offers extensive configuration for message formatting, such as controlling path inclusion, allowed values display, localization, and more. +1. **Error handling**: zod-validation-error maintains the original error details while providing a clean, consistent interface through the ValidationError class. +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. + +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). + +### Do I need to use `zod-validation-error`'s error map? + +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. + +You may also use your own custom error map if you have specific requirements, e.g. internationalization. + +### Where can I see how `zod-validation-error`'s error map formatting works? + +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. + +### How to distinguish between errors + +Use the `isValidationErrorLike` type guard. + +#### Example + +Scenario: Distinguish between `ValidationError` VS generic `Error` in order to respond with 400 VS 500 HTTP status code respectively. + +```typescript +import { isValidationErrorLike } from 'zod-validation-error'; + +try { + func(); // throws Error - or - ValidationError +} catch (err) { + if (isValidationErrorLike(err)) { + return 400; // Bad Data (this is a client error) + } + + return 500; // Server Error +} +``` + +### How to use `ValidationError` outside `zod` + +It's possible to implement custom validation logic outside `zod` and throw a `ValidationError`. + +#### Example 1: passing custom message + +```typescript +import { ValidationError } from 'zod-validation-error'; +import { Buffer } from 'node:buffer'; + +function parseBuffer(buf: unknown): Buffer { + if (!Buffer.isBuffer(buf)) { + throw new ValidationError('Invalid argument; expected buffer'); + } + + return buf; +} +``` + +#### Example 2: passing custom message and original error as cause + +```typescript +import { ValidationError } from 'zod-validation-error'; + +try { + // do something that throws an error +} catch (err) { + throw new ValidationError('Something went deeply wrong', { cause: err }); +} +``` + +### How to use `ValidationError` with custom "error map" + +Zod supports customizing error messages by providing a custom "error map". You may combine this with `zod-validation-error` to produce user-friendly messages. + +#### Example: produce user-friendly error messages using the `customError` property + +If all you need is to produce user-friendly error messages you may use the `customError` property. + +```typescript +import { z as zod } from 'zod'; +import { createErrorMap } from 'zod-validation-error'; + +zod.config({ + customError: createErrorMap({ + includePath: true, + }), +}); +``` + +`zod-validation-error` will respect the `customError` property when it is set, no further configuration is needed. + +### Does `zod-validation-error` support CommonJS + +Yes, `zod-validation-error` supports CommonJS out-of-the-box. All you need to do is import it using `require`. + +#### Example + +```typescript +const { ValidationError } = require('zod-validation-error'); +``` + +## Contribute + +Source code contributions are most welcome. Please open a PR, ensure the linter is satisfied and all tests pass. + +#### We are hiring + +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. + +## License + +MIT diff --git a/gui/frontend/node_modules/zod-validation-error/README.v3.md b/gui/frontend/node_modules/zod-validation-error/README.v3.md new file mode 100644 index 0000000000000000000000000000000000000000..e5a2572fa45d7f75c206748295f62eb5f7d22431 --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/README.v3.md @@ -0,0 +1,558 @@ +# zod-validation-error + +Wrap zod validation errors in user-friendly readable messages. + +[![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) + +#### Features + +- User-friendly readable messages, configurable via options; +- Maintain original issues under `error.details`; +- Supports both `zod` v3 and v4. + +**_Note:_** This is the v3 version of `zod-validation-error`. If you are looking for zod v4 support, please click [here](/README.md). + +## Installation + +```bash +npm install zod-validation-error +``` + +#### Requirements + +- Node.js v.18+ +- TypeScript v.4.5+ + +## Quick start + +```typescript +import { z as zod } from 'zod/v3'; +import { fromError } from 'zod-validation-error/v3'; + +// create zod schema +const zodSchema = zod.object({ + id: zod.number().int().positive(), + email: zod.string().email(), +}); + +// parse some invalid value +try { + zodSchema.parse({ + id: 1, + email: 'foobar', // note: invalid email + }); +} catch (err) { + const validationError = fromError(err); + // the error is now readable by the user + // you may print it to console + console.log(validationError.toString()); + // or return it as an actual error + return validationError; +} +``` + +## Motivation + +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. + +### Example + +#### Input (from Zod) + +```json +[ + { + "code": "too_small", + "inclusive": false, + "message": "Number must be greater than 0", + "minimum": 0, + "path": ["id"], + "type": "number" + }, + { + "code": "invalid_string", + "message": "Invalid email", + "path": ["email"], + "validation": "email" + } +] +``` + +#### Output + +``` +Validation error: Number must be greater than 0 at "id"; Invalid email at "email" +``` + +## API + +- [ValidationError(message[, options])](#validationerror) +- [createMessageBuilder(props)](#createMessageBuilder) +- [errorMap](#errormap) +- [isValidationError(error)](#isvalidationerror) +- [isValidationErrorLike(error)](#isvalidationerrorlike) +- [isZodErrorLike(error)](#iszoderrorlike) +- [fromError(error[, options])](#fromerror) +- [fromZodIssue(zodIssue[, options])](#fromzodissue) +- [fromZodError(zodError[, options])](#fromzoderror) +- [toValidationError([options]) => (error) => ValidationError](#tovalidationerror) + +### ValidationError + +Main `ValidationError` class, extending native JavaScript `Error`. + +#### Arguments + +- `message` - _string_; error message (required) +- `options` - _ErrorOptions_; error options as per [JavaScript definition](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/Error#options) (optional) + - `options.cause` - _any_; can be used to hold the original zod error (optional) + +#### Example 1: construct new ValidationError with `message` + +```typescript +const { ValidationError } = require('zod-validation-error'); + +const error = new ValidationError('foobar'); +console.log(error instanceof Error); // prints true +``` + +#### Example 2: construct new ValidationError with `message` and `options.cause` + +```typescript +import { z as zod } from 'zod/v3'; +const { ValidationError } = require('zod-validation-error'); + +const error = new ValidationError('foobar', { + cause: new zod.ZodError([ + { + code: 'invalid_string', + message: 'Invalid email', + path: ['email'], + validation: 'email', + }, + ]), +}); + +console.log(error.details); // prints issues from zod error +``` + +### createMessageBuilder + +Creates zod-validation-error's default `MessageBuilder`, which is used to produce user-friendly error messages. + +Meant to be passed as an option to [fromError](#fromerror), [fromZodIssue](#fromzodissue), [fromZodError](#fromzoderror) or [toValidationError](#tovalidationerror). + +You may read more on the concept of the `MessageBuilder` further [below](#MessageBuilder). + +#### Arguments + +- `props` - _Object_; formatting options (optional) + - `maxIssuesInMessage` - _number_; max issues to include in user-friendly message (optional, defaults to 99) + - `issueSeparator` - _string_; used to concatenate issues in user-friendly message (optional, defaults to ";") + - `unionSeparator` - _string_; used to concatenate union-issues in user-friendly message (optional, defaults to ", or") + - `prefix` - _string_ or _null_; prefix to use in user-friendly message (optional, defaults to "Validation error"). Pass `null` to disable prefix completely. + - `prefixSeparator` - _string_; used to concatenate prefix with rest of the user-friendly message (optional, defaults to ": "). Not used when `prefix` is `null`. + - `includePath` - _boolean_; used to provide control on whether to include the erroneous property name suffix or not (optional, defaults to `true`). + +#### Example + +```typescript +import { createMessageBuilder } from 'zod-validation-error/v3'; + +const messageBuilder = createMessageBuilder({ + includePath: false, + maxIssuesInMessage: 3, +}); +``` + +### errorMap + +A custom error map to use with zod's `setErrorMap` method and get user-friendly messages automatically. + +#### Example + +```typescript +import { z as zod } from 'zod/v3'; +import { errorMap } from 'zod-validation-error/v3'; + +zod.setErrorMap(errorMap); +``` + +### isValidationError + +A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on `instanceof` comparison. + +#### Arguments + +- `error` - error instance (required) + +#### Example + +```typescript +import { z as zod } from 'zod/v3'; +import { ValidationError, isValidationError } from 'zod-validation-error/v3'; + +const err = new ValidationError('foobar'); +isValidationError(err); // returns true + +const invalidErr = new Error('foobar'); +isValidationError(err); // returns false +``` + +### isValidationErrorLike + +A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on _heuristics_ comparison. + +_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. + +tl;dr if you are uncertain then it is preferable to use `isValidationErrorLike` instead of `isValidationError`. + +#### Arguments + +- `error` - error instance (required) + +#### Example + +```typescript +import { + ValidationError, + isValidationErrorLike, +} from 'zod-validation-error/v3'; + +const err = new ValidationError('foobar'); +isValidationErrorLike(err); // returns true + +const invalidErr = new Error('foobar'); +isValidationErrorLike(err); // returns false +``` + +### isZodErrorLike + +A [type guard](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates) utility function, based on _heuristics_ comparison. + +_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. + +#### Arguments + +- `error` - error instance (required) + +#### Example + +```typescript +import { z as zod } from 'zod/v3'; +import { ValidationError, isZodErrorLike } from 'zod-validation-error/v3'; + +const zodValidationErr = new ValidationError('foobar'); +isZodErrorLike(zodValidationErr); // returns false + +const genericErr = new Error('foobar'); +isZodErrorLike(genericErr); // returns false + +const zodErr = new zod.ZodError([ + { + code: zod.ZodIssueCode.custom, + path: [], + message: 'foobar', + fatal: true, + }, +]); +isZodErrorLike(zodErr); // returns true +``` + +### fromError + +Converts an error to `ValidationError`. + +_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`. + +#### Arguments + +- `error` - _unknown_; an error (required) +- `options` - _Object_; formatting options (optional) + - `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). + +#### Notes + +Alternatively, you may pass the following `options` instead of a `messageBuilder`. + +- `options` - _Object_; formatting options (optional) + - `maxIssuesInMessage` - _number_; max issues to include in user-friendly message (optional, defaults to 99) + - `issueSeparator` - _string_; used to concatenate issues in user-friendly message (optional, defaults to ";") + - `unionSeparator` - _string_; used to concatenate union-issues in user-friendly message (optional, defaults to ", or") + - `prefix` - _string_ or _null_; prefix to use in user-friendly message (optional, defaults to "Validation error"). Pass `null` to disable prefix completely. + - `prefixSeparator` - _string_; used to concatenate prefix with rest of the user-friendly message (optional, defaults to ": "). Not used when `prefix` is `null`. + - `includePath` - _boolean_; used to provide control on whether to include the erroneous property name suffix or not (optional, defaults to `true`). + +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. + +### fromZodIssue + +Converts a single zod issue to `ValidationError`. + +#### Arguments + +- `zodIssue` - _zod.ZodIssue_; a ZodIssue instance (required) +- `options` - _Object_; formatting options (optional) + - `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). + +#### Notes + +Alternatively, you may pass the following `options` instead of a `messageBuilder`. + +- `options` - _Object_; formatting options (optional) + - `issueSeparator` - _string_; used to concatenate issues in user-friendly message (optional, defaults to ";") + - `unionSeparator` - _string_; used to concatenate union-issues in user-friendly message (optional, defaults to ", or") + - `prefix` - _string_ or _null_; prefix to use in user-friendly message (optional, defaults to "Validation error"). Pass `null` to disable prefix completely. + - `prefixSeparator` - _string_; used to concatenate prefix with rest of the user-friendly message (optional, defaults to ": "). Not used when `prefix` is `null`. + - `includePath` - _boolean_; used to provide control on whether to include the erroneous property name suffix or not (optional, defaults to `true`). + +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. + +### fromZodError + +Converts zod error to `ValidationError`. + +_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()`. + +#### Arguments + +- `zodError` - _zod.ZodError_; a ZodError instance (required) +- `options` - _Object_; formatting options (optional) + - `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). + +#### Notes + +Alternatively, you may pass the following `options` instead of a `messageBuilder`. + +- `options` - _Object_; formatting options (optional) + - `maxIssuesInMessage` - _number_; max issues to include in user-friendly message (optional, defaults to 99) + - `issueSeparator` - _string_; used to concatenate issues in user-friendly message (optional, defaults to ";") + - `unionSeparator` - _string_; used to concatenate union-issues in user-friendly message (optional, defaults to ", or") + - `prefix` - _string_ or _null_; prefix to use in user-friendly message (optional, defaults to "Validation error"). Pass `null` to disable prefix completely. + - `prefixSeparator` - _string_; used to concatenate prefix with rest of the user-friendly message (optional, defaults to ": "). Not used when `prefix` is `null`. + - `includePath` - _boolean_; used to provide control on whether to include the erroneous property name suffix or not (optional, defaults to `true`). + +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. + +### toValidationError + +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 + +```js +toValidationError(options) => (zodError) => ValidationError +``` + +#### Example using fp-ts + +```typescript +import * as Either from 'fp-ts/Either'; +import { z as zod } from 'zod/v3'; +import { toValidationError, ValidationError } from 'zod-validation-error/v3'; + +// create zod schema +const zodSchema = zod + .object({ + id: zod.number().int().positive(), + email: zod.string().email(), + }) + .brand<'User'>(); + +export type User = zod.infer; + +export function parse( + value: zod.input +): Either.Either { + return Either.tryCatch(() => schema.parse(value), toValidationError()); +} +``` + +## MessageBuilder + +`zod-validation-error` can be configured with a custom `MessageBuilder` function in order to produce case-specific error messages. + +#### Example + +For instance, one may want to print `invalid_string` errors to the console in red color. + +```typescript +import { z as zod } from 'zod/v3'; +import { type MessageBuilder, fromError } from 'zod-validation-error/v3'; +import chalk from 'chalk'; + +// create custom MessageBuilder +const myMessageBuilder: MessageBuilder = (issues) => { + return ( + issues + // format error message + .map((issue) => { + if (issue.code === zod.ZodIssueCode.invalid_string) { + return chalk.red(issue.message); + } + + return issue.message; + }) + // join as string with new-line character + .join('\n') + ); +}; + +// create zod schema +const zodSchema = zod.object({ + id: zod.number().int().positive(), + email: zod.string().email(), +}); + +// parse some invalid value +try { + zodSchema.parse({ + id: 1, + email: 'foobar', // note: invalid email value + }); +} catch (err) { + const validationError = fromError(err, { + messageBuilder: myMessageBuilder, + }); + // the error is now displayed with red letters + console.log(validationError.toString()); +} +``` + +## FAQ + +### How to distinguish between errors + +Use the `isValidationErrorLike` type guard. + +#### Example + +Scenario: Distinguish between `ValidationError` VS generic `Error` in order to respond with 400 VS 500 HTTP status code respectively. + +```typescript +import * as Either from 'fp-ts/Either'; +import { z as zod } from 'zod/v3'; +import { isValidationErrorLike } from 'zod-validation-error/v3'; + +try { + func(); // throws Error - or - ValidationError +} catch (err) { + if (isValidationErrorLike(err)) { + return 400; // Bad Data (this is a client error) + } + + return 500; // Server Error +} +``` + +### How to use `ValidationError` outside `zod` + +It's possible to implement custom validation logic outside `zod` and throw a `ValidationError`. + +#### Example 1: passing custom message + +```typescript +import { ValidationError } from 'zod-validation-error/v3'; +import { Buffer } from 'node:buffer'; + +function parseBuffer(buf: unknown): Buffer { + if (!Buffer.isBuffer(buf)) { + throw new ValidationError('Invalid argument; expected buffer'); + } + + return buf; +} +``` + +#### Example 2: passing custom message and original error as cause + +```typescript +import { ValidationError } from 'zod-validation-error/v3'; + +try { + // do something that throws an error +} catch (err) { + throw new ValidationError('Something went deeply wrong', { cause: err }); +} +``` + +### How to use `ValidationError` with custom "error map" + +Zod supports customizing error messages by providing a custom "error map". You may combine this with `zod-validation-error` to produce user-friendly messages. + +#### Example 1: produce user-friendly error messages using the `errorMap` property + +If all you need is to produce user-friendly error messages you may use the `errorMap` property. + +```typescript +import { z as zod } from 'zod/v3'; +import { errorMap } from 'zod-validation-error/v3'; + +zod.setErrorMap(errorMap); +``` + +#### Example 2: extra customization using `fromZodIssue` + +If you need to customize some error code, you may use the `fromZodIssue` function. + +```typescript +import { z as zod } from 'zod/v3'; +import { fromZodIssue } from 'zod-validation-error/v3'; + +const customErrorMap: zod.ZodErrorMap = (issue, ctx) => { + switch (issue.code) { + case ZodIssueCode.invalid_type: { + return { + message: + 'Custom error message of your preference for invalid_type errors', + }; + } + default: { + const validationError = fromZodIssue({ + ...issue, + // fallback to the default error message + // when issue does not have a message + message: issue.message ?? ctx.defaultError, + }); + + return { + message: validationError.message, + }; + } + } +}; + +zod.setErrorMap(customErrorMap); +``` + +### How to use `zod-validation-error` with `react-hook-form`? + +```typescript +import { useForm } from 'react-hook-form'; +import { zodResolver } from '@hookform/resolvers/zod'; +import { errorMap } from 'zod-validation-error/v3'; + +useForm({ + resolver: zodResolver(schema, { errorMap }), +}); +``` + +### Does `zod-validation-error` support CommonJS + +Yes, `zod-validation-error` supports CommonJS out-of-the-box. All you need to do is import it using `require`. + +#### Example + +```typescript +const { ValidationError } = require('zod-validation-error'); +``` + +## Contribute + +Source code contributions are most welcome. Please open a PR, ensure the linter is satisfied and all tests pass. + +#### We are hiring + +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. + +## License + +MIT diff --git a/gui/frontend/node_modules/zod-validation-error/package.json b/gui/frontend/node_modules/zod-validation-error/package.json new file mode 100644 index 0000000000000000000000000000000000000000..e5708a5db4ed93e461d3eeee4afcdf0b9d687a2b --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/package.json @@ -0,0 +1,108 @@ +{ + "name": "zod-validation-error", + "version": "4.0.2", + "description": "Wrap zod validation errors in user-friendly readable messages", + "keywords": [ + "zod", + "error", + "validation" + ], + "license": "MIT", + "repository": { + "type": "git", + "url": "git://github.com/causaly/zod-validation-error.git" + }, + "author": { + "name": "Dimitrios C. Michalakos", + "email": "dimitris@jmike.gr", + "url": "https://github.com/jmike" + }, + "contributors": [ + { + "name": "Thanos Karagiannis", + "email": "hey@maestros.io", + "url": "https://github.com/thanoskrg" + }, + { + "name": "Nikos Tsompanides", + "email": "nikostsompanides@gmail.com", + "url": "https://github.com/NikosTsompanides" + }, + { + "name": "Nikos Kalogridis", + "url": "https://github.com/nikoskalogridis" + } + ], + "main": "./v4/index.js", + "module": "./v4/index.mjs", + "types": "./v4/index.d.ts", + "exports": { + ".": { + "types": "./v4/index.d.ts", + "require": "./v4/index.js", + "import": "./v4/index.mjs" + }, + "./v3": { + "types": "./v3/index.d.ts", + "require": "./v3/index.js", + "import": "./v3/index.mjs" + }, + "./v4": { + "types": "./v4/index.d.ts", + "require": "./v4/index.js", + "import": "./v4/index.mjs" + } + }, + "files": [ + "v3", + "v4" + ], + "publishConfig": { + "access": "public" + }, + "sideEffects": false, + "engines": { + "node": ">=18.0.0" + }, + "scripts": { + "typecheck": "tsc --noEmit", + "build": "tsup --config ./tsup.config.ts", + "lint": "eslint lib --ext .ts", + "format": "prettier --config ./.prettierrc --ignore-path .gitignore -w .", + "test": "vitest run", + "changeset": "changeset", + "prerelease": "npm run build && npm run test", + "release": "changeset publish", + "prepare": "husky" + }, + "lint-staged": { + "*.{js,jsx,ts,tsx}": [ + "eslint --fix", + "prettier --config ./.prettierrc.json --write" + ] + }, + "devDependencies": { + "@changesets/changelog-github": "^0.5.0", + "@changesets/cli": "^2.27.7", + "@commitlint/cli": "^18.0.0", + "@commitlint/config-conventional": "^18.0.0", + "@types/node": "^20.5.0", + "@typescript-eslint/eslint-plugin": "^6.4.1", + "@typescript-eslint/parser": "^6.4.1", + "concurrently": "^8.2.0", + "eslint": "^8.4.1", + "eslint-config-prettier": "^9.0.0", + "eslint-plugin-import": "^2.29.1", + "eslint-plugin-prettier": "^4.2.1", + "husky": "^9.1.7", + "lint-staged": "^15.0.1", + "prettier": "^2.8.8", + "tsup": "^8.0.2", + "typescript": "^5.1.6", + "vitest": "^3.1.2", + "zod": "^4.0.2" + }, + "peerDependencies": { + "zod": "^3.25.0 || ^4.0.0" + } +} diff --git a/gui/frontend/node_modules/zod-validation-error/v3/index.d.mts b/gui/frontend/node_modules/zod-validation-error/v3/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..3e72ebf0e64c87c571b1c96f5a9b6b9abf35d6f7 --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v3/index.d.mts @@ -0,0 +1,50 @@ +import * as zod from 'zod/v3'; + +interface ErrorOptions { + cause?: unknown; +} +declare class ValidationError extends Error { + name: 'ZodValidationError'; + details: Array; + constructor(message?: string, options?: ErrorOptions); + toString(): string; +} + +declare function isValidationError(err: unknown): err is ValidationError; + +declare function isValidationErrorLike(err: unknown): err is ValidationError; + +declare function isZodErrorLike(err: unknown): err is zod.ZodError; + +declare const errorMap: zod.ZodErrorMap; + +type NonEmptyArray = [T, ...T[]]; + +type ZodIssue = zod.ZodIssue; +type MessageBuilder = (issues: NonEmptyArray) => string; +type CreateMessageBuilderProps = { + issueSeparator?: string; + unionSeparator?: string; + prefix?: string | null; + prefixSeparator?: string; + includePath?: boolean; + maxIssuesInMessage?: number; +}; +declare function createMessageBuilder(props?: CreateMessageBuilderProps): MessageBuilder; + +type ZodError = zod.ZodError; +type FromZodErrorOptions = { + messageBuilder: MessageBuilder; +} | CreateMessageBuilderProps; +declare function fromZodError(zodError: ZodError, options?: FromZodErrorOptions): ValidationError; + +declare function fromError(err: unknown, options?: FromZodErrorOptions): ValidationError; + +type FromZodIssueOptions = { + messageBuilder: MessageBuilder; +} | Omit; +declare function fromZodIssue(issue: ZodIssue, options?: FromZodIssueOptions): ValidationError; + +declare const toValidationError: (options?: FromZodErrorOptions) => (err: unknown) => ValidationError; + +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 }; diff --git a/gui/frontend/node_modules/zod-validation-error/v3/index.d.ts b/gui/frontend/node_modules/zod-validation-error/v3/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3e72ebf0e64c87c571b1c96f5a9b6b9abf35d6f7 --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v3/index.d.ts @@ -0,0 +1,50 @@ +import * as zod from 'zod/v3'; + +interface ErrorOptions { + cause?: unknown; +} +declare class ValidationError extends Error { + name: 'ZodValidationError'; + details: Array; + constructor(message?: string, options?: ErrorOptions); + toString(): string; +} + +declare function isValidationError(err: unknown): err is ValidationError; + +declare function isValidationErrorLike(err: unknown): err is ValidationError; + +declare function isZodErrorLike(err: unknown): err is zod.ZodError; + +declare const errorMap: zod.ZodErrorMap; + +type NonEmptyArray = [T, ...T[]]; + +type ZodIssue = zod.ZodIssue; +type MessageBuilder = (issues: NonEmptyArray) => string; +type CreateMessageBuilderProps = { + issueSeparator?: string; + unionSeparator?: string; + prefix?: string | null; + prefixSeparator?: string; + includePath?: boolean; + maxIssuesInMessage?: number; +}; +declare function createMessageBuilder(props?: CreateMessageBuilderProps): MessageBuilder; + +type ZodError = zod.ZodError; +type FromZodErrorOptions = { + messageBuilder: MessageBuilder; +} | CreateMessageBuilderProps; +declare function fromZodError(zodError: ZodError, options?: FromZodErrorOptions): ValidationError; + +declare function fromError(err: unknown, options?: FromZodErrorOptions): ValidationError; + +type FromZodIssueOptions = { + messageBuilder: MessageBuilder; +} | Omit; +declare function fromZodIssue(issue: ZodIssue, options?: FromZodIssueOptions): ValidationError; + +declare const toValidationError: (options?: FromZodErrorOptions) => (err: unknown) => ValidationError; + +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 }; diff --git a/gui/frontend/node_modules/zod-validation-error/v3/index.js b/gui/frontend/node_modules/zod-validation-error/v3/index.js new file mode 100644 index 0000000000000000000000000000000000000000..54fc1c586a5a81773f2ba914643f4eb1d9117c80 --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v3/index.js @@ -0,0 +1,309 @@ +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// lib/v3/index.ts +var index_exports = {}; +__export(index_exports, { + ValidationError: () => ValidationError, + createMessageBuilder: () => createMessageBuilder, + errorMap: () => errorMap, + fromError: () => fromError, + fromZodError: () => fromZodError, + fromZodIssue: () => fromZodIssue, + isValidationError: () => isValidationError, + isValidationErrorLike: () => isValidationErrorLike, + isZodErrorLike: () => isZodErrorLike, + toValidationError: () => toValidationError +}); +module.exports = __toCommonJS(index_exports); + +// lib/v3/isZodErrorLike.ts +function isZodErrorLike(err) { + return err instanceof Error && err.name === "ZodError" && "issues" in err && Array.isArray(err.issues); +} + +// lib/v3/ValidationError.ts +var ValidationError = class extends Error { + name; + details; + constructor(message, options) { + super(message, options); + this.name = "ZodValidationError"; + this.details = getIssuesFromErrorOptions(options); + } + toString() { + return this.message; + } +}; +function getIssuesFromErrorOptions(options) { + if (options) { + const cause = options.cause; + if (isZodErrorLike(cause)) { + return cause.issues; + } + } + return []; +} + +// lib/v3/isValidationError.ts +function isValidationError(err) { + return err instanceof ValidationError; +} + +// lib/v3/isValidationErrorLike.ts +function isValidationErrorLike(err) { + return err instanceof Error && err.name === "ZodValidationError"; +} + +// lib/v3/fromZodIssue.ts +var zod2 = __toESM(require("zod/v3")); + +// lib/v3/MessageBuilder.ts +var zod = __toESM(require("zod/v3")); + +// lib/utils/NonEmptyArray.ts +function isNonEmptyArray(value) { + return value.length !== 0; +} + +// lib/utils/stringify.ts +function stringifySymbol(symbol) { + return symbol.description ?? ""; +} + +// lib/utils/joinPath.ts +var identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u; +function joinPath(path) { + if (path.length === 1) { + let propertyKey = path[0]; + if (typeof propertyKey === "symbol") { + propertyKey = stringifySymbol(propertyKey); + } + return propertyKey.toString() || '""'; + } + return path.reduce((acc, propertyKey) => { + if (typeof propertyKey === "number") { + return acc + "[" + propertyKey.toString() + "]"; + } + if (typeof propertyKey === "symbol") { + propertyKey = stringifySymbol(propertyKey); + } + if (propertyKey.includes('"')) { + return acc + '["' + escapeQuotes(propertyKey) + '"]'; + } + if (!identifierRegex.test(propertyKey)) { + return acc + '["' + propertyKey + '"]'; + } + const separator = acc.length === 0 ? "" : "."; + return acc + separator + propertyKey; + }, ""); +} +function escapeQuotes(str) { + return str.replace(/"/g, '\\"'); +} + +// lib/v3/config.ts +var ISSUE_SEPARATOR = "; "; +var MAX_ISSUES_IN_MESSAGE = 99; +var PREFIX = "Validation error"; +var PREFIX_SEPARATOR = ": "; +var UNION_SEPARATOR = ", or "; + +// lib/v3/MessageBuilder.ts +function createMessageBuilder(props = {}) { + const { + issueSeparator = ISSUE_SEPARATOR, + unionSeparator = UNION_SEPARATOR, + prefixSeparator = PREFIX_SEPARATOR, + prefix = PREFIX, + includePath = true, + maxIssuesInMessage = MAX_ISSUES_IN_MESSAGE + } = props; + return (issues) => { + const message = issues.slice(0, maxIssuesInMessage).map( + (issue) => getMessageFromZodIssue({ + issue, + issueSeparator, + unionSeparator, + includePath + }) + ).join(issueSeparator); + return prefixMessage(message, prefix, prefixSeparator); + }; +} +function getMessageFromZodIssue(props) { + const { issue, issueSeparator, unionSeparator, includePath } = props; + if (issue.code === zod.ZodIssueCode.invalid_union) { + return issue.unionErrors.reduce((acc, zodError) => { + const newIssues = zodError.issues.map( + (issue2) => getMessageFromZodIssue({ + issue: issue2, + issueSeparator, + unionSeparator, + includePath + }) + ).join(issueSeparator); + if (!acc.includes(newIssues)) { + acc.push(newIssues); + } + return acc; + }, []).join(unionSeparator); + } + if (issue.code === zod.ZodIssueCode.invalid_arguments) { + return [ + issue.message, + ...issue.argumentsError.issues.map( + (issue2) => getMessageFromZodIssue({ + issue: issue2, + issueSeparator, + unionSeparator, + includePath + }) + ) + ].join(issueSeparator); + } + if (issue.code === zod.ZodIssueCode.invalid_return_type) { + return [ + issue.message, + ...issue.returnTypeError.issues.map( + (issue2) => getMessageFromZodIssue({ + issue: issue2, + issueSeparator, + unionSeparator, + includePath + }) + ) + ].join(issueSeparator); + } + if (includePath && isNonEmptyArray(issue.path)) { + if (issue.path.length === 1) { + const identifier = issue.path[0]; + if (typeof identifier === "number") { + return `${issue.message} at index ${identifier}`; + } + } + return `${issue.message} at "${joinPath(issue.path)}"`; + } + return issue.message; +} +function prefixMessage(message, prefix, prefixSeparator) { + if (prefix !== null) { + if (message.length > 0) { + return [prefix, message].join(prefixSeparator); + } + return prefix; + } + if (message.length > 0) { + return message; + } + return PREFIX; +} + +// lib/v3/fromZodIssue.ts +function fromZodIssue(issue, options = {}) { + const messageBuilder = createMessageBuilderFromOptions(options); + const message = messageBuilder([issue]); + return new ValidationError(message, { cause: new zod2.ZodError([issue]) }); +} +function createMessageBuilderFromOptions(options) { + if ("messageBuilder" in options) { + return options.messageBuilder; + } + return createMessageBuilder(options); +} + +// lib/v3/errorMap.ts +var errorMap = (issue, ctx) => { + const error = fromZodIssue({ + ...issue, + // fallback to the default error message + // when issue does not have a message + message: issue.message ?? ctx.defaultError + }); + return { + message: error.message + }; +}; + +// lib/v3/fromZodError.ts +function fromZodError(zodError, options = {}) { + if (!isZodErrorLike(zodError)) { + throw new TypeError( + `Invalid zodError param; expected instance of ZodError. Did you mean to use the "${fromError.name}" method instead?` + ); + } + return fromZodErrorWithoutRuntimeCheck(zodError, options); +} +function fromZodErrorWithoutRuntimeCheck(zodError, options = {}) { + const zodIssues = zodError.errors; + let message; + if (isNonEmptyArray(zodIssues)) { + const messageBuilder = createMessageBuilderFromOptions2(options); + message = messageBuilder(zodIssues); + } else { + message = zodError.message; + } + return new ValidationError(message, { cause: zodError }); +} +function createMessageBuilderFromOptions2(options) { + if ("messageBuilder" in options) { + return options.messageBuilder; + } + return createMessageBuilder(options); +} + +// lib/v3/toValidationError.ts +var toValidationError = (options = {}) => (err) => { + if (isZodErrorLike(err)) { + return fromZodErrorWithoutRuntimeCheck(err, options); + } + if (err instanceof Error) { + return new ValidationError(err.message, { cause: err }); + } + return new ValidationError("Unknown error"); +}; + +// lib/v3/fromError.ts +function fromError(err, options = {}) { + return toValidationError(options)(err); +} +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + ValidationError, + createMessageBuilder, + errorMap, + fromError, + fromZodError, + fromZodIssue, + isValidationError, + isValidationErrorLike, + isZodErrorLike, + toValidationError +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/gui/frontend/node_modules/zod-validation-error/v3/index.js.map b/gui/frontend/node_modules/zod-validation-error/v3/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..2c4de61ff52123ee56f8bda4600b5746b45d85bd --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v3/index.js.map @@ -0,0 +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;\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 {\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;\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) => 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((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[]];\n\nexport function isNonEmptyArray(value: T[]): value is NonEmptyArray {\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): 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((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":"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","names":["zod","issue","createMessageBuilderFromOptions"]} \ No newline at end of file diff --git a/gui/frontend/node_modules/zod-validation-error/v3/index.mjs b/gui/frontend/node_modules/zod-validation-error/v3/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..c6afb8ae7a31284684310b1ea74fcc912164fb5c --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v3/index.mjs @@ -0,0 +1,263 @@ +// lib/v3/isZodErrorLike.ts +function isZodErrorLike(err) { + return err instanceof Error && err.name === "ZodError" && "issues" in err && Array.isArray(err.issues); +} + +// lib/v3/ValidationError.ts +var ValidationError = class extends Error { + name; + details; + constructor(message, options) { + super(message, options); + this.name = "ZodValidationError"; + this.details = getIssuesFromErrorOptions(options); + } + toString() { + return this.message; + } +}; +function getIssuesFromErrorOptions(options) { + if (options) { + const cause = options.cause; + if (isZodErrorLike(cause)) { + return cause.issues; + } + } + return []; +} + +// lib/v3/isValidationError.ts +function isValidationError(err) { + return err instanceof ValidationError; +} + +// lib/v3/isValidationErrorLike.ts +function isValidationErrorLike(err) { + return err instanceof Error && err.name === "ZodValidationError"; +} + +// lib/v3/fromZodIssue.ts +import * as zod2 from "zod/v3"; + +// lib/v3/MessageBuilder.ts +import * as zod from "zod/v3"; + +// lib/utils/NonEmptyArray.ts +function isNonEmptyArray(value) { + return value.length !== 0; +} + +// lib/utils/stringify.ts +function stringifySymbol(symbol) { + return symbol.description ?? ""; +} + +// lib/utils/joinPath.ts +var identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u; +function joinPath(path) { + if (path.length === 1) { + let propertyKey = path[0]; + if (typeof propertyKey === "symbol") { + propertyKey = stringifySymbol(propertyKey); + } + return propertyKey.toString() || '""'; + } + return path.reduce((acc, propertyKey) => { + if (typeof propertyKey === "number") { + return acc + "[" + propertyKey.toString() + "]"; + } + if (typeof propertyKey === "symbol") { + propertyKey = stringifySymbol(propertyKey); + } + if (propertyKey.includes('"')) { + return acc + '["' + escapeQuotes(propertyKey) + '"]'; + } + if (!identifierRegex.test(propertyKey)) { + return acc + '["' + propertyKey + '"]'; + } + const separator = acc.length === 0 ? "" : "."; + return acc + separator + propertyKey; + }, ""); +} +function escapeQuotes(str) { + return str.replace(/"/g, '\\"'); +} + +// lib/v3/config.ts +var ISSUE_SEPARATOR = "; "; +var MAX_ISSUES_IN_MESSAGE = 99; +var PREFIX = "Validation error"; +var PREFIX_SEPARATOR = ": "; +var UNION_SEPARATOR = ", or "; + +// lib/v3/MessageBuilder.ts +function createMessageBuilder(props = {}) { + const { + issueSeparator = ISSUE_SEPARATOR, + unionSeparator = UNION_SEPARATOR, + prefixSeparator = PREFIX_SEPARATOR, + prefix = PREFIX, + includePath = true, + maxIssuesInMessage = MAX_ISSUES_IN_MESSAGE + } = props; + return (issues) => { + const message = issues.slice(0, maxIssuesInMessage).map( + (issue) => getMessageFromZodIssue({ + issue, + issueSeparator, + unionSeparator, + includePath + }) + ).join(issueSeparator); + return prefixMessage(message, prefix, prefixSeparator); + }; +} +function getMessageFromZodIssue(props) { + const { issue, issueSeparator, unionSeparator, includePath } = props; + if (issue.code === zod.ZodIssueCode.invalid_union) { + return issue.unionErrors.reduce((acc, zodError) => { + const newIssues = zodError.issues.map( + (issue2) => getMessageFromZodIssue({ + issue: issue2, + issueSeparator, + unionSeparator, + includePath + }) + ).join(issueSeparator); + if (!acc.includes(newIssues)) { + acc.push(newIssues); + } + return acc; + }, []).join(unionSeparator); + } + if (issue.code === zod.ZodIssueCode.invalid_arguments) { + return [ + issue.message, + ...issue.argumentsError.issues.map( + (issue2) => getMessageFromZodIssue({ + issue: issue2, + issueSeparator, + unionSeparator, + includePath + }) + ) + ].join(issueSeparator); + } + if (issue.code === zod.ZodIssueCode.invalid_return_type) { + return [ + issue.message, + ...issue.returnTypeError.issues.map( + (issue2) => getMessageFromZodIssue({ + issue: issue2, + issueSeparator, + unionSeparator, + includePath + }) + ) + ].join(issueSeparator); + } + if (includePath && isNonEmptyArray(issue.path)) { + if (issue.path.length === 1) { + const identifier = issue.path[0]; + if (typeof identifier === "number") { + return `${issue.message} at index ${identifier}`; + } + } + return `${issue.message} at "${joinPath(issue.path)}"`; + } + return issue.message; +} +function prefixMessage(message, prefix, prefixSeparator) { + if (prefix !== null) { + if (message.length > 0) { + return [prefix, message].join(prefixSeparator); + } + return prefix; + } + if (message.length > 0) { + return message; + } + return PREFIX; +} + +// lib/v3/fromZodIssue.ts +function fromZodIssue(issue, options = {}) { + const messageBuilder = createMessageBuilderFromOptions(options); + const message = messageBuilder([issue]); + return new ValidationError(message, { cause: new zod2.ZodError([issue]) }); +} +function createMessageBuilderFromOptions(options) { + if ("messageBuilder" in options) { + return options.messageBuilder; + } + return createMessageBuilder(options); +} + +// lib/v3/errorMap.ts +var errorMap = (issue, ctx) => { + const error = fromZodIssue({ + ...issue, + // fallback to the default error message + // when issue does not have a message + message: issue.message ?? ctx.defaultError + }); + return { + message: error.message + }; +}; + +// lib/v3/fromZodError.ts +function fromZodError(zodError, options = {}) { + if (!isZodErrorLike(zodError)) { + throw new TypeError( + `Invalid zodError param; expected instance of ZodError. Did you mean to use the "${fromError.name}" method instead?` + ); + } + return fromZodErrorWithoutRuntimeCheck(zodError, options); +} +function fromZodErrorWithoutRuntimeCheck(zodError, options = {}) { + const zodIssues = zodError.errors; + let message; + if (isNonEmptyArray(zodIssues)) { + const messageBuilder = createMessageBuilderFromOptions2(options); + message = messageBuilder(zodIssues); + } else { + message = zodError.message; + } + return new ValidationError(message, { cause: zodError }); +} +function createMessageBuilderFromOptions2(options) { + if ("messageBuilder" in options) { + return options.messageBuilder; + } + return createMessageBuilder(options); +} + +// lib/v3/toValidationError.ts +var toValidationError = (options = {}) => (err) => { + if (isZodErrorLike(err)) { + return fromZodErrorWithoutRuntimeCheck(err, options); + } + if (err instanceof Error) { + return new ValidationError(err.message, { cause: err }); + } + return new ValidationError("Unknown error"); +}; + +// lib/v3/fromError.ts +function fromError(err, options = {}) { + return toValidationError(options)(err); +} +export { + ValidationError, + createMessageBuilder, + errorMap, + fromError, + fromZodError, + fromZodIssue, + isValidationError, + isValidationErrorLike, + isZodErrorLike, + toValidationError +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/gui/frontend/node_modules/zod-validation-error/v3/index.mjs.map b/gui/frontend/node_modules/zod-validation-error/v3/index.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..c75174269b80da82f106143c27c28673bdcd6a39 --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v3/index.mjs.map @@ -0,0 +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;\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 {\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;\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) => 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((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[]];\n\nexport function isNonEmptyArray(value: T[]): value is NonEmptyArray {\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): 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((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":"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","names":["zod","issue","createMessageBuilderFromOptions"]} \ No newline at end of file diff --git a/gui/frontend/node_modules/zod-validation-error/v4/index.d.mts b/gui/frontend/node_modules/zod-validation-error/v4/index.d.mts new file mode 100644 index 0000000000000000000000000000000000000000..c1ec18a5377b7d90471fdcc5cb329e656dc360e2 --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v4/index.d.mts @@ -0,0 +1,66 @@ +import * as zod from 'zod/v4/core'; + +declare const ZOD_VALIDATION_ERROR_NAME = "ZodValidationError"; +interface ErrorOptions { + cause?: unknown; +} +declare class ValidationError extends Error { + name: typeof ZOD_VALIDATION_ERROR_NAME; + details: Array; + constructor(message?: string, options?: ErrorOptions); + toString(): string; +} + +declare function isValidationError(err: unknown): err is ValidationError; + +declare function isValidationErrorLike(err: unknown): err is ValidationError; + +declare function isZodErrorLike(err: unknown): err is zod.$ZodError; + +type ErrorMapOptions = { + dateLocalization: boolean | Intl.LocalesArgument; + numberLocalization: boolean | Intl.LocalesArgument; + displayInvalidFormatDetails: boolean; + allowedValuesSeparator: string; + allowedValuesLastSeparator: string | undefined; + wrapAllowedValuesInQuote: boolean; + maxAllowedValuesToDisplay: number; + unrecognizedKeysSeparator: string; + unrecognizedKeysLastSeparator: string | undefined; + wrapUnrecognizedKeysInQuote: boolean; + maxUnrecognizedKeysToDisplay: number; +}; + +declare function createErrorMap(partialOptions?: Partial): zod.$ZodErrorMap; + +type NonEmptyArray = [T, ...T[]]; + +type ZodIssue = zod.$ZodIssue; +type MessageBuilder = (issues: NonEmptyArray) => string; +type MessageBuilderOptions = { + prefix: string | null | undefined; + prefixSeparator: string; + maxIssuesInMessage: number; + issueSeparator: string; + unionSeparator: string; + includePath: boolean; + forceTitleCase: boolean; +}; +declare function createMessageBuilder(partialOptions?: Partial): MessageBuilder; + +type ZodError = zod.$ZodError; +type FromZodErrorOptions = { + messageBuilder: MessageBuilder; +} | Partial; +declare function fromZodError(zodError: ZodError, options?: FromZodErrorOptions): ValidationError; + +declare function fromError(err: unknown, options?: FromZodErrorOptions): ValidationError; + +type FromZodIssueOptions = { + messageBuilder: MessageBuilder; +} | Partial>; +declare function fromZodIssue(issue: ZodIssue, options?: FromZodIssueOptions): ValidationError; + +declare const toValidationError: (options?: FromZodErrorOptions) => (err: unknown) => ValidationError; + +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 }; diff --git a/gui/frontend/node_modules/zod-validation-error/v4/index.d.ts b/gui/frontend/node_modules/zod-validation-error/v4/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..c1ec18a5377b7d90471fdcc5cb329e656dc360e2 --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v4/index.d.ts @@ -0,0 +1,66 @@ +import * as zod from 'zod/v4/core'; + +declare const ZOD_VALIDATION_ERROR_NAME = "ZodValidationError"; +interface ErrorOptions { + cause?: unknown; +} +declare class ValidationError extends Error { + name: typeof ZOD_VALIDATION_ERROR_NAME; + details: Array; + constructor(message?: string, options?: ErrorOptions); + toString(): string; +} + +declare function isValidationError(err: unknown): err is ValidationError; + +declare function isValidationErrorLike(err: unknown): err is ValidationError; + +declare function isZodErrorLike(err: unknown): err is zod.$ZodError; + +type ErrorMapOptions = { + dateLocalization: boolean | Intl.LocalesArgument; + numberLocalization: boolean | Intl.LocalesArgument; + displayInvalidFormatDetails: boolean; + allowedValuesSeparator: string; + allowedValuesLastSeparator: string | undefined; + wrapAllowedValuesInQuote: boolean; + maxAllowedValuesToDisplay: number; + unrecognizedKeysSeparator: string; + unrecognizedKeysLastSeparator: string | undefined; + wrapUnrecognizedKeysInQuote: boolean; + maxUnrecognizedKeysToDisplay: number; +}; + +declare function createErrorMap(partialOptions?: Partial): zod.$ZodErrorMap; + +type NonEmptyArray = [T, ...T[]]; + +type ZodIssue = zod.$ZodIssue; +type MessageBuilder = (issues: NonEmptyArray) => string; +type MessageBuilderOptions = { + prefix: string | null | undefined; + prefixSeparator: string; + maxIssuesInMessage: number; + issueSeparator: string; + unionSeparator: string; + includePath: boolean; + forceTitleCase: boolean; +}; +declare function createMessageBuilder(partialOptions?: Partial): MessageBuilder; + +type ZodError = zod.$ZodError; +type FromZodErrorOptions = { + messageBuilder: MessageBuilder; +} | Partial; +declare function fromZodError(zodError: ZodError, options?: FromZodErrorOptions): ValidationError; + +declare function fromError(err: unknown, options?: FromZodErrorOptions): ValidationError; + +type FromZodIssueOptions = { + messageBuilder: MessageBuilder; +} | Partial>; +declare function fromZodIssue(issue: ZodIssue, options?: FromZodIssueOptions): ValidationError; + +declare const toValidationError: (options?: FromZodErrorOptions) => (err: unknown) => ValidationError; + +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 }; diff --git a/gui/frontend/node_modules/zod-validation-error/v4/index.js b/gui/frontend/node_modules/zod-validation-error/v4/index.js new file mode 100644 index 0000000000000000000000000000000000000000..408637d76a1822e62a712f88a71d5ba002b2d400 --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v4/index.js @@ -0,0 +1,725 @@ +"use strict"; +var __create = Object.create; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __getProtoOf = Object.getPrototypeOf; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( + // If the importer is in node compatibility mode or this is not an ESM + // file that has been converted to a CommonJS file using a Babel- + // compatible transform (i.e. "__esModule" has not been set), then set + // "default" to the CommonJS "module.exports" for node compatibility. + isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, + mod +)); +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// lib/v4/index.ts +var index_exports = {}; +__export(index_exports, { + ValidationError: () => ValidationError, + createErrorMap: () => createErrorMap, + createMessageBuilder: () => createMessageBuilder, + fromError: () => fromError, + fromZodError: () => fromZodError, + fromZodIssue: () => fromZodIssue, + isValidationError: () => isValidationError, + isValidationErrorLike: () => isValidationErrorLike, + isZodErrorLike: () => isZodErrorLike, + toValidationError: () => toValidationError +}); +module.exports = __toCommonJS(index_exports); + +// lib/v4/isZodErrorLike.ts +function isZodErrorLike(err) { + return err instanceof Object && "name" in err && (err.name === "ZodError" || err.name === "$ZodError") && "issues" in err && Array.isArray(err.issues); +} + +// lib/v4/ValidationError.ts +var ZOD_VALIDATION_ERROR_NAME = "ZodValidationError"; +var ValidationError = class extends Error { + name; + details; + constructor(message, options) { + super(message, options); + this.name = ZOD_VALIDATION_ERROR_NAME; + this.details = getIssuesFromErrorOptions(options); + } + toString() { + return this.message; + } +}; +function getIssuesFromErrorOptions(options) { + if (options) { + const cause = options.cause; + if (isZodErrorLike(cause)) { + return cause.issues; + } + } + return []; +} + +// lib/v4/isValidationError.ts +function isValidationError(err) { + return err instanceof ValidationError; +} + +// lib/v4/isValidationErrorLike.ts +function isValidationErrorLike(err) { + return err instanceof Error && err.name === ZOD_VALIDATION_ERROR_NAME; +} + +// lib/v4/errorMap/custom.ts +function parseCustomIssue(issue) { + return { + type: issue.code, + path: issue.path, + message: issue.message ?? "Invalid input" + }; +} + +// lib/v4/errorMap/invalidElement.ts +function parseInvalidElementIssue(issue) { + return { + type: issue.code, + path: issue.path, + message: `unexpected element in ${issue.origin}` + }; +} + +// lib/v4/errorMap/invalidKey.ts +function parseInvalidKeyIssue(issue) { + return { + type: issue.code, + path: issue.path, + message: `unexpected key in ${issue.origin}` + }; +} + +// lib/v4/errorMap/invalidStringFormat.ts +function parseInvalidStringFormatIssue(issue, options = { + displayInvalidFormatDetails: false +}) { + switch (issue.format) { + case "lowercase": + case "uppercase": + return { + type: issue.code, + path: issue.path, + message: `value must be in ${issue.format} format` + }; + default: { + if (isZodIssueStringStartsWith(issue)) { + return parseStringStartsWith(issue); + } + if (isZodIssueStringEndsWith(issue)) { + return parseStringEndsWith(issue); + } + if (isZodIssueStringIncludes(issue)) { + return parseStringIncludes(issue); + } + if (isZodIssueStringInvalidRegex(issue)) { + return parseStringInvalidRegex(issue, options); + } + if (isZodIssueStringInvalidJWT(issue)) { + return parseStringInvalidJWT(issue, options); + } + return { + type: issue.code, + path: issue.path, + message: `invalid ${issue.format}` + }; + } + } +} +function isZodIssueStringStartsWith(issue) { + return issue.format === "starts_with"; +} +function parseStringStartsWith(issue) { + return { + type: issue.code, + path: issue.path, + message: `value must start with "${issue.prefix}"` + }; +} +function isZodIssueStringEndsWith(issue) { + return issue.format === "ends_with"; +} +function parseStringEndsWith(issue) { + return { + type: issue.code, + path: issue.path, + message: `value must end with "${issue.suffix}"` + }; +} +function isZodIssueStringIncludes(issue) { + return issue.format === "includes"; +} +function parseStringIncludes(issue) { + return { + type: issue.code, + path: issue.path, + message: `value must include "${issue.includes}"` + }; +} +function isZodIssueStringInvalidRegex(issue) { + return issue.format === "regex"; +} +function parseStringInvalidRegex(issue, options = { + displayInvalidFormatDetails: false +}) { + let message = "value must match pattern"; + if (options.displayInvalidFormatDetails) { + message += ` "${issue.pattern}"`; + } + return { + type: issue.code, + path: issue.path, + message + }; +} +function isZodIssueStringInvalidJWT(issue) { + return issue.format === "jwt"; +} +function parseStringInvalidJWT(issue, options = { + displayInvalidFormatDetails: false +}) { + return { + type: issue.code, + path: issue.path, + message: options.displayInvalidFormatDetails && issue.algorithm ? `invalid jwt/${issue.algorithm}` : `invalid jwt` + }; +} + +// lib/v4/errorMap/invalidType.ts +function parseInvalidTypeIssue(issue) { + let message = `expected ${issue.expected}`; + if ("input" in issue) { + message += `, received ${getTypeName(issue.input)}`; + } + return { + type: issue.code, + path: issue.path, + message + }; +} +function getTypeName(value) { + if (typeof value === "object") { + if (value === null) { + return "null"; + } + if (value === void 0) { + return "undefined"; + } + if (Array.isArray(value)) { + return "array"; + } + if (value instanceof Date) { + return "date"; + } + if (value instanceof RegExp) { + return "regexp"; + } + if (value instanceof Map) { + return "map"; + } + if (value instanceof Set) { + return "set"; + } + if (value instanceof Error) { + return "error"; + } + if (value instanceof Function) { + return "function"; + } + return "object"; + } + return typeof value; +} + +// lib/v4/errorMap/invalidUnion.ts +function parseInvalidUnionIssue(issue) { + return { + type: issue.code, + path: issue.path, + message: issue.message ?? "Invalid input" + }; +} + +// lib/utils/stringify.ts +function stringifySymbol(symbol) { + return symbol.description ?? ""; +} +function stringify(value, options = {}) { + switch (typeof value) { + case "symbol": + return stringifySymbol(value); + case "bigint": + case "number": { + switch (options.localization) { + case true: + return value.toLocaleString(); + case false: + return value.toString(); + default: + return value.toLocaleString(options.localization); + } + } + case "string": { + if (options.wrapStringValueInQuote) { + return `"${value}"`; + } + return value; + } + default: { + if (value instanceof Date) { + switch (options.localization) { + case true: + return value.toLocaleString(); + case false: + return value.toISOString(); + default: + return value.toLocaleString(options.localization); + } + } + return String(value); + } + } +} + +// lib/utils/joinValues.ts +function joinValues(values, options) { + const valuesToDisplay = (options.maxValuesToDisplay ? values.slice(0, options.maxValuesToDisplay) : values).map((value) => { + return stringify(value, { + wrapStringValueInQuote: options.wrapStringValuesInQuote + }); + }); + if (valuesToDisplay.length < values.length) { + valuesToDisplay.push( + `${values.length - valuesToDisplay.length} more value(s)` + ); + } + return valuesToDisplay.reduce((acc, value, index) => { + if (index > 0) { + if (index === valuesToDisplay.length - 1 && options.lastSeparator) { + acc += options.lastSeparator; + } else { + acc += options.separator; + } + } + acc += value; + return acc; + }, ""); +} + +// lib/v4/errorMap/invalidValue.ts +function parseInvalidValueIssue(issue, options) { + let message; + if (issue.values.length === 0) { + message = "invalid value"; + } else if (issue.values.length === 1) { + const valueStr = stringify(issue.values[0], { + wrapStringValueInQuote: true + }); + message = `expected value to be ${valueStr}`; + } else { + const valuesStr = joinValues(issue.values, { + separator: options.allowedValuesSeparator, + lastSeparator: options.allowedValuesLastSeparator, + wrapStringValuesInQuote: options.wrapAllowedValuesInQuote, + maxValuesToDisplay: options.maxAllowedValuesToDisplay + }); + message = `expected value to be one of ${valuesStr}`; + } + return { + type: issue.code, + path: issue.path, + message + }; +} + +// lib/v4/errorMap/notMultipleOf.ts +function parseNotMultipleOfIssue(issue) { + return { + type: issue.code, + path: issue.path, + message: `expected multiple of ${issue.divisor}` + }; +} + +// lib/v4/errorMap/tooBig.ts +function parseTooBigIssue(issue, options) { + const maxValueStr = issue.origin === "date" ? stringify(new Date(issue.maximum), { + localization: options.dateLocalization + }) : stringify(issue.maximum, { + localization: options.numberLocalization + }); + switch (issue.origin) { + case "number": + case "int": + case "bigint": { + return { + type: issue.code, + path: issue.path, + message: `number must be less than${issue.inclusive ? " or equal to" : ""} ${maxValueStr}` + }; + } + case "string": { + return { + type: issue.code, + path: issue.path, + message: `string must contain at most ${maxValueStr} character(s)` + }; + } + case "date": { + return { + type: issue.code, + path: issue.path, + message: `date must be ${issue.inclusive ? "prior or equal to" : "prior to"} "${maxValueStr}"` + }; + } + case "array": { + return { + type: issue.code, + path: issue.path, + message: `array must contain at most ${maxValueStr} item(s)` + }; + } + case "set": { + return { + type: issue.code, + path: issue.path, + message: `set must contain at most ${maxValueStr} item(s)` + }; + } + case "file": { + return { + type: issue.code, + path: issue.path, + message: `file must not exceed ${maxValueStr} byte(s) in size` + }; + } + default: + return { + type: issue.code, + path: issue.path, + message: `value must be less than${issue.inclusive ? " or equal to" : ""} ${maxValueStr}` + }; + } +} + +// lib/v4/errorMap/tooSmall.ts +function parseTooSmallIssue(issue, options) { + const minValueStr = issue.origin === "date" ? stringify(new Date(issue.minimum), { + localization: options.dateLocalization + }) : stringify(issue.minimum, { + localization: options.numberLocalization + }); + switch (issue.origin) { + case "number": + case "int": + case "bigint": { + return { + type: issue.code, + path: issue.path, + message: `number must be greater than${issue.inclusive ? " or equal to" : ""} ${minValueStr}` + }; + } + case "date": { + return { + type: issue.code, + path: issue.path, + message: `date must be ${issue.inclusive ? "later or equal to" : "later to"} "${minValueStr}"` + }; + } + case "string": { + return { + type: issue.code, + path: issue.path, + message: `string must contain at least ${minValueStr} character(s)` + }; + } + case "array": { + return { + type: issue.code, + path: issue.path, + message: `array must contain at least ${minValueStr} item(s)` + }; + } + case "set": { + return { + type: issue.code, + path: issue.path, + message: `set must contain at least ${minValueStr} item(s)` + }; + } + case "file": { + return { + type: issue.code, + path: issue.path, + message: `file must be at least ${minValueStr} byte(s) in size` + }; + } + default: + return { + type: issue.code, + path: issue.path, + message: `value must be greater than${issue.inclusive ? " or equal to" : ""} ${minValueStr}` + }; + } +} + +// lib/v4/errorMap/unrecognizedKeys.ts +function parseUnrecognizedKeysIssue(issue, options) { + const keysStr = joinValues(issue.keys, { + separator: options.unrecognizedKeysSeparator, + lastSeparator: options.unrecognizedKeysLastSeparator, + wrapStringValuesInQuote: options.wrapUnrecognizedKeysInQuote, + maxValuesToDisplay: options.maxUnrecognizedKeysToDisplay + }); + return { + type: issue.code, + path: issue.path, + message: `unrecognized key(s) ${keysStr} in object` + }; +} + +// lib/v4/errorMap/errorMap.ts +var issueParsers = { + invalid_type: parseInvalidTypeIssue, + too_big: parseTooBigIssue, + too_small: parseTooSmallIssue, + invalid_format: parseInvalidStringFormatIssue, + invalid_value: parseInvalidValueIssue, + invalid_element: parseInvalidElementIssue, + not_multiple_of: parseNotMultipleOfIssue, + unrecognized_keys: parseUnrecognizedKeysIssue, + invalid_key: parseInvalidKeyIssue, + custom: parseCustomIssue, + invalid_union: parseInvalidUnionIssue +}; +var defaultErrorMapOptions = { + displayInvalidFormatDetails: false, + allowedValuesSeparator: ", ", + allowedValuesLastSeparator: " or ", + wrapAllowedValuesInQuote: true, + maxAllowedValuesToDisplay: 10, + unrecognizedKeysSeparator: ", ", + unrecognizedKeysLastSeparator: " and ", + wrapUnrecognizedKeysInQuote: true, + maxUnrecognizedKeysToDisplay: 5, + dateLocalization: true, + numberLocalization: true +}; +function createErrorMap(partialOptions = {}) { + const options = { + ...defaultErrorMapOptions, + ...partialOptions + }; + const errorMap = (issue) => { + if (issue.code === void 0) { + return "Not supported issue type"; + } + const parseFunc = issueParsers[issue.code]; + const ast = parseFunc(issue, options); + return ast.message; + }; + return errorMap; +} + +// lib/utils/NonEmptyArray.ts +function isNonEmptyArray(value) { + return value.length !== 0; +} + +// lib/utils/joinPath.ts +var identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u; +function joinPath(path) { + if (path.length === 1) { + let propertyKey = path[0]; + if (typeof propertyKey === "symbol") { + propertyKey = stringifySymbol(propertyKey); + } + return propertyKey.toString() || '""'; + } + return path.reduce((acc, propertyKey) => { + if (typeof propertyKey === "number") { + return acc + "[" + propertyKey.toString() + "]"; + } + if (typeof propertyKey === "symbol") { + propertyKey = stringifySymbol(propertyKey); + } + if (propertyKey.includes('"')) { + return acc + '["' + escapeQuotes(propertyKey) + '"]'; + } + if (!identifierRegex.test(propertyKey)) { + return acc + '["' + propertyKey + '"]'; + } + const separator = acc.length === 0 ? "" : "."; + return acc + separator + propertyKey; + }, ""); +} +function escapeQuotes(str) { + return str.replace(/"/g, '\\"'); +} + +// lib/utils/titleCase.ts +function titleCase(value) { + if (value.length === 0) { + return value; + } + return value.charAt(0).toUpperCase() + value.slice(1); +} + +// lib/v4/MessageBuilder.ts +var defaultMessageBuilderOptions = { + prefix: "Validation error", + prefixSeparator: ": ", + maxIssuesInMessage: 99, + // I've got 99 problems but the b$tch ain't one + unionSeparator: " or ", + issueSeparator: "; ", + includePath: true, + forceTitleCase: true +}; +function createMessageBuilder(partialOptions = {}) { + const options = { + ...defaultMessageBuilderOptions, + ...partialOptions + }; + return function messageBuilder(issues) { + const message = issues.slice(0, options.maxIssuesInMessage).map((issue) => mapIssue(issue, options)).join(options.issueSeparator); + return conditionallyPrefixMessage(message, options); + }; +} +function mapIssue(issue, options) { + if (issue.code === "invalid_union" && isNonEmptyArray(issue.errors)) { + const individualMessages = issue.errors.map( + (issues) => issues.map( + (subIssue) => mapIssue( + { + ...subIssue, + path: issue.path.concat(subIssue.path) + }, + options + ) + ).join(options.issueSeparator) + ); + return Array.from(new Set(individualMessages)).join(options.unionSeparator); + } + const buf = []; + if (options.forceTitleCase) { + buf.push(titleCase(issue.message)); + } else { + buf.push(issue.message); + } + pathCondition: if (options.includePath && issue.path !== void 0 && isNonEmptyArray(issue.path)) { + if (issue.path.length === 1) { + const identifier = issue.path[0]; + if (typeof identifier === "number") { + buf.push(` at index ${identifier}`); + break pathCondition; + } + } + buf.push(` at "${joinPath(issue.path)}"`); + } + return buf.join(""); +} +function conditionallyPrefixMessage(message, options) { + if (options.prefix != null) { + if (message.length > 0) { + return [options.prefix, message].join(options.prefixSeparator); + } + return options.prefix; + } + if (message.length > 0) { + return message; + } + return defaultMessageBuilderOptions.prefix; +} + +// lib/v4/fromZodError.ts +function fromZodError(zodError, options = {}) { + if (!isZodErrorLike(zodError)) { + throw new TypeError( + `Invalid zodError param; expected instance of ZodError. Did you mean to use the "${fromError.name}" method instead?` + ); + } + return fromZodErrorWithoutRuntimeCheck(zodError, options); +} +function fromZodErrorWithoutRuntimeCheck(zodError, options = {}) { + const zodIssues = zodError.issues; + let message; + if (isNonEmptyArray(zodIssues)) { + const messageBuilder = createMessageBuilderFromOptions(options); + message = messageBuilder(zodIssues); + } else { + message = zodError.message; + } + return new ValidationError(message, { cause: zodError }); +} +function createMessageBuilderFromOptions(options) { + if ("messageBuilder" in options) { + return options.messageBuilder; + } + return createMessageBuilder(options); +} + +// lib/v4/toValidationError.ts +var toValidationError = (options = {}) => (err) => { + if (isZodErrorLike(err)) { + return fromZodErrorWithoutRuntimeCheck(err, options); + } + if (err instanceof Error) { + return new ValidationError(err.message, { cause: err }); + } + return new ValidationError("Unknown error"); +}; + +// lib/v4/fromError.ts +function fromError(err, options = {}) { + return toValidationError(options)(err); +} + +// lib/v4/fromZodIssue.ts +var zod = __toESM(require("zod/v4/core")); +function fromZodIssue(issue, options = {}) { + const messageBuilder = createMessageBuilderFromOptions2(options); + const message = messageBuilder([issue]); + return new ValidationError(message, { + cause: new zod.$ZodRealError([issue]) + }); +} +function createMessageBuilderFromOptions2(options) { + if ("messageBuilder" in options) { + return options.messageBuilder; + } + return createMessageBuilder(options); +} +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + ValidationError, + createErrorMap, + createMessageBuilder, + fromError, + fromZodError, + fromZodIssue, + isValidationError, + isValidationErrorLike, + isZodErrorLike, + toValidationError +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/gui/frontend/node_modules/zod-validation-error/v4/index.js.map b/gui/frontend/node_modules/zod-validation-error/v4/index.js.map new file mode 100644 index 0000000000000000000000000000000000000000..dac8d4df4e005e061cb113ad63ac898eab07f45f --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v4/index.js.map @@ -0,0 +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;\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 {\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\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\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\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,\n options: Pick = {\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\n): issue is zod.$ZodRawIssue {\n return issue.format === 'starts_with';\n}\n\nfunction parseStringStartsWith(\n issue: zod.$ZodRawIssue\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\n): issue is zod.$ZodRawIssue {\n return issue.format === 'ends_with';\n}\nfunction parseStringEndsWith(\n issue: zod.$ZodRawIssue\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\n): issue is zod.$ZodRawIssue {\n return issue.format === 'includes';\n}\nfunction parseStringIncludes(\n issue: zod.$ZodRawIssue\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\n): issue is zod.$ZodRawIssue {\n return issue.format === 'regex';\n}\nfunction parseStringInvalidRegex(\n issue: zod.$ZodRawIssue,\n options: Pick = {\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\n): issue is zod.$ZodRawIssue {\n return issue.format === 'jwt';\n}\nfunction parseStringInvalidJWT(\n issue: zod.$ZodRawIssue,\n options: Pick = {\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\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\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,\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((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,\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\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,\n options: Pick\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,\n options: Pick\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,\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>,\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 = {}\n): zod.$ZodErrorMap {\n // fill-in default options\n const options = {\n ...defaultErrorMapOptions,\n ...partialOptions,\n };\n\n const errorMap: zod.$ZodErrorMap = (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[]];\n\nexport function isNonEmptyArray(value: T[]): value is NonEmptyArray {\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): 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((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) => 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 = {}\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\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;\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>;\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":"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","names":["createMessageBuilderFromOptions"]} \ No newline at end of file diff --git a/gui/frontend/node_modules/zod-validation-error/v4/index.mjs b/gui/frontend/node_modules/zod-validation-error/v4/index.mjs new file mode 100644 index 0000000000000000000000000000000000000000..6abe057b8236417b4023adfb613007355ee7a1c2 --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v4/index.mjs @@ -0,0 +1,679 @@ +// lib/v4/isZodErrorLike.ts +function isZodErrorLike(err) { + return err instanceof Object && "name" in err && (err.name === "ZodError" || err.name === "$ZodError") && "issues" in err && Array.isArray(err.issues); +} + +// lib/v4/ValidationError.ts +var ZOD_VALIDATION_ERROR_NAME = "ZodValidationError"; +var ValidationError = class extends Error { + name; + details; + constructor(message, options) { + super(message, options); + this.name = ZOD_VALIDATION_ERROR_NAME; + this.details = getIssuesFromErrorOptions(options); + } + toString() { + return this.message; + } +}; +function getIssuesFromErrorOptions(options) { + if (options) { + const cause = options.cause; + if (isZodErrorLike(cause)) { + return cause.issues; + } + } + return []; +} + +// lib/v4/isValidationError.ts +function isValidationError(err) { + return err instanceof ValidationError; +} + +// lib/v4/isValidationErrorLike.ts +function isValidationErrorLike(err) { + return err instanceof Error && err.name === ZOD_VALIDATION_ERROR_NAME; +} + +// lib/v4/errorMap/custom.ts +function parseCustomIssue(issue) { + return { + type: issue.code, + path: issue.path, + message: issue.message ?? "Invalid input" + }; +} + +// lib/v4/errorMap/invalidElement.ts +function parseInvalidElementIssue(issue) { + return { + type: issue.code, + path: issue.path, + message: `unexpected element in ${issue.origin}` + }; +} + +// lib/v4/errorMap/invalidKey.ts +function parseInvalidKeyIssue(issue) { + return { + type: issue.code, + path: issue.path, + message: `unexpected key in ${issue.origin}` + }; +} + +// lib/v4/errorMap/invalidStringFormat.ts +function parseInvalidStringFormatIssue(issue, options = { + displayInvalidFormatDetails: false +}) { + switch (issue.format) { + case "lowercase": + case "uppercase": + return { + type: issue.code, + path: issue.path, + message: `value must be in ${issue.format} format` + }; + default: { + if (isZodIssueStringStartsWith(issue)) { + return parseStringStartsWith(issue); + } + if (isZodIssueStringEndsWith(issue)) { + return parseStringEndsWith(issue); + } + if (isZodIssueStringIncludes(issue)) { + return parseStringIncludes(issue); + } + if (isZodIssueStringInvalidRegex(issue)) { + return parseStringInvalidRegex(issue, options); + } + if (isZodIssueStringInvalidJWT(issue)) { + return parseStringInvalidJWT(issue, options); + } + return { + type: issue.code, + path: issue.path, + message: `invalid ${issue.format}` + }; + } + } +} +function isZodIssueStringStartsWith(issue) { + return issue.format === "starts_with"; +} +function parseStringStartsWith(issue) { + return { + type: issue.code, + path: issue.path, + message: `value must start with "${issue.prefix}"` + }; +} +function isZodIssueStringEndsWith(issue) { + return issue.format === "ends_with"; +} +function parseStringEndsWith(issue) { + return { + type: issue.code, + path: issue.path, + message: `value must end with "${issue.suffix}"` + }; +} +function isZodIssueStringIncludes(issue) { + return issue.format === "includes"; +} +function parseStringIncludes(issue) { + return { + type: issue.code, + path: issue.path, + message: `value must include "${issue.includes}"` + }; +} +function isZodIssueStringInvalidRegex(issue) { + return issue.format === "regex"; +} +function parseStringInvalidRegex(issue, options = { + displayInvalidFormatDetails: false +}) { + let message = "value must match pattern"; + if (options.displayInvalidFormatDetails) { + message += ` "${issue.pattern}"`; + } + return { + type: issue.code, + path: issue.path, + message + }; +} +function isZodIssueStringInvalidJWT(issue) { + return issue.format === "jwt"; +} +function parseStringInvalidJWT(issue, options = { + displayInvalidFormatDetails: false +}) { + return { + type: issue.code, + path: issue.path, + message: options.displayInvalidFormatDetails && issue.algorithm ? `invalid jwt/${issue.algorithm}` : `invalid jwt` + }; +} + +// lib/v4/errorMap/invalidType.ts +function parseInvalidTypeIssue(issue) { + let message = `expected ${issue.expected}`; + if ("input" in issue) { + message += `, received ${getTypeName(issue.input)}`; + } + return { + type: issue.code, + path: issue.path, + message + }; +} +function getTypeName(value) { + if (typeof value === "object") { + if (value === null) { + return "null"; + } + if (value === void 0) { + return "undefined"; + } + if (Array.isArray(value)) { + return "array"; + } + if (value instanceof Date) { + return "date"; + } + if (value instanceof RegExp) { + return "regexp"; + } + if (value instanceof Map) { + return "map"; + } + if (value instanceof Set) { + return "set"; + } + if (value instanceof Error) { + return "error"; + } + if (value instanceof Function) { + return "function"; + } + return "object"; + } + return typeof value; +} + +// lib/v4/errorMap/invalidUnion.ts +function parseInvalidUnionIssue(issue) { + return { + type: issue.code, + path: issue.path, + message: issue.message ?? "Invalid input" + }; +} + +// lib/utils/stringify.ts +function stringifySymbol(symbol) { + return symbol.description ?? ""; +} +function stringify(value, options = {}) { + switch (typeof value) { + case "symbol": + return stringifySymbol(value); + case "bigint": + case "number": { + switch (options.localization) { + case true: + return value.toLocaleString(); + case false: + return value.toString(); + default: + return value.toLocaleString(options.localization); + } + } + case "string": { + if (options.wrapStringValueInQuote) { + return `"${value}"`; + } + return value; + } + default: { + if (value instanceof Date) { + switch (options.localization) { + case true: + return value.toLocaleString(); + case false: + return value.toISOString(); + default: + return value.toLocaleString(options.localization); + } + } + return String(value); + } + } +} + +// lib/utils/joinValues.ts +function joinValues(values, options) { + const valuesToDisplay = (options.maxValuesToDisplay ? values.slice(0, options.maxValuesToDisplay) : values).map((value) => { + return stringify(value, { + wrapStringValueInQuote: options.wrapStringValuesInQuote + }); + }); + if (valuesToDisplay.length < values.length) { + valuesToDisplay.push( + `${values.length - valuesToDisplay.length} more value(s)` + ); + } + return valuesToDisplay.reduce((acc, value, index) => { + if (index > 0) { + if (index === valuesToDisplay.length - 1 && options.lastSeparator) { + acc += options.lastSeparator; + } else { + acc += options.separator; + } + } + acc += value; + return acc; + }, ""); +} + +// lib/v4/errorMap/invalidValue.ts +function parseInvalidValueIssue(issue, options) { + let message; + if (issue.values.length === 0) { + message = "invalid value"; + } else if (issue.values.length === 1) { + const valueStr = stringify(issue.values[0], { + wrapStringValueInQuote: true + }); + message = `expected value to be ${valueStr}`; + } else { + const valuesStr = joinValues(issue.values, { + separator: options.allowedValuesSeparator, + lastSeparator: options.allowedValuesLastSeparator, + wrapStringValuesInQuote: options.wrapAllowedValuesInQuote, + maxValuesToDisplay: options.maxAllowedValuesToDisplay + }); + message = `expected value to be one of ${valuesStr}`; + } + return { + type: issue.code, + path: issue.path, + message + }; +} + +// lib/v4/errorMap/notMultipleOf.ts +function parseNotMultipleOfIssue(issue) { + return { + type: issue.code, + path: issue.path, + message: `expected multiple of ${issue.divisor}` + }; +} + +// lib/v4/errorMap/tooBig.ts +function parseTooBigIssue(issue, options) { + const maxValueStr = issue.origin === "date" ? stringify(new Date(issue.maximum), { + localization: options.dateLocalization + }) : stringify(issue.maximum, { + localization: options.numberLocalization + }); + switch (issue.origin) { + case "number": + case "int": + case "bigint": { + return { + type: issue.code, + path: issue.path, + message: `number must be less than${issue.inclusive ? " or equal to" : ""} ${maxValueStr}` + }; + } + case "string": { + return { + type: issue.code, + path: issue.path, + message: `string must contain at most ${maxValueStr} character(s)` + }; + } + case "date": { + return { + type: issue.code, + path: issue.path, + message: `date must be ${issue.inclusive ? "prior or equal to" : "prior to"} "${maxValueStr}"` + }; + } + case "array": { + return { + type: issue.code, + path: issue.path, + message: `array must contain at most ${maxValueStr} item(s)` + }; + } + case "set": { + return { + type: issue.code, + path: issue.path, + message: `set must contain at most ${maxValueStr} item(s)` + }; + } + case "file": { + return { + type: issue.code, + path: issue.path, + message: `file must not exceed ${maxValueStr} byte(s) in size` + }; + } + default: + return { + type: issue.code, + path: issue.path, + message: `value must be less than${issue.inclusive ? " or equal to" : ""} ${maxValueStr}` + }; + } +} + +// lib/v4/errorMap/tooSmall.ts +function parseTooSmallIssue(issue, options) { + const minValueStr = issue.origin === "date" ? stringify(new Date(issue.minimum), { + localization: options.dateLocalization + }) : stringify(issue.minimum, { + localization: options.numberLocalization + }); + switch (issue.origin) { + case "number": + case "int": + case "bigint": { + return { + type: issue.code, + path: issue.path, + message: `number must be greater than${issue.inclusive ? " or equal to" : ""} ${minValueStr}` + }; + } + case "date": { + return { + type: issue.code, + path: issue.path, + message: `date must be ${issue.inclusive ? "later or equal to" : "later to"} "${minValueStr}"` + }; + } + case "string": { + return { + type: issue.code, + path: issue.path, + message: `string must contain at least ${minValueStr} character(s)` + }; + } + case "array": { + return { + type: issue.code, + path: issue.path, + message: `array must contain at least ${minValueStr} item(s)` + }; + } + case "set": { + return { + type: issue.code, + path: issue.path, + message: `set must contain at least ${minValueStr} item(s)` + }; + } + case "file": { + return { + type: issue.code, + path: issue.path, + message: `file must be at least ${minValueStr} byte(s) in size` + }; + } + default: + return { + type: issue.code, + path: issue.path, + message: `value must be greater than${issue.inclusive ? " or equal to" : ""} ${minValueStr}` + }; + } +} + +// lib/v4/errorMap/unrecognizedKeys.ts +function parseUnrecognizedKeysIssue(issue, options) { + const keysStr = joinValues(issue.keys, { + separator: options.unrecognizedKeysSeparator, + lastSeparator: options.unrecognizedKeysLastSeparator, + wrapStringValuesInQuote: options.wrapUnrecognizedKeysInQuote, + maxValuesToDisplay: options.maxUnrecognizedKeysToDisplay + }); + return { + type: issue.code, + path: issue.path, + message: `unrecognized key(s) ${keysStr} in object` + }; +} + +// lib/v4/errorMap/errorMap.ts +var issueParsers = { + invalid_type: parseInvalidTypeIssue, + too_big: parseTooBigIssue, + too_small: parseTooSmallIssue, + invalid_format: parseInvalidStringFormatIssue, + invalid_value: parseInvalidValueIssue, + invalid_element: parseInvalidElementIssue, + not_multiple_of: parseNotMultipleOfIssue, + unrecognized_keys: parseUnrecognizedKeysIssue, + invalid_key: parseInvalidKeyIssue, + custom: parseCustomIssue, + invalid_union: parseInvalidUnionIssue +}; +var defaultErrorMapOptions = { + displayInvalidFormatDetails: false, + allowedValuesSeparator: ", ", + allowedValuesLastSeparator: " or ", + wrapAllowedValuesInQuote: true, + maxAllowedValuesToDisplay: 10, + unrecognizedKeysSeparator: ", ", + unrecognizedKeysLastSeparator: " and ", + wrapUnrecognizedKeysInQuote: true, + maxUnrecognizedKeysToDisplay: 5, + dateLocalization: true, + numberLocalization: true +}; +function createErrorMap(partialOptions = {}) { + const options = { + ...defaultErrorMapOptions, + ...partialOptions + }; + const errorMap = (issue) => { + if (issue.code === void 0) { + return "Not supported issue type"; + } + const parseFunc = issueParsers[issue.code]; + const ast = parseFunc(issue, options); + return ast.message; + }; + return errorMap; +} + +// lib/utils/NonEmptyArray.ts +function isNonEmptyArray(value) { + return value.length !== 0; +} + +// lib/utils/joinPath.ts +var identifierRegex = /[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*/u; +function joinPath(path) { + if (path.length === 1) { + let propertyKey = path[0]; + if (typeof propertyKey === "symbol") { + propertyKey = stringifySymbol(propertyKey); + } + return propertyKey.toString() || '""'; + } + return path.reduce((acc, propertyKey) => { + if (typeof propertyKey === "number") { + return acc + "[" + propertyKey.toString() + "]"; + } + if (typeof propertyKey === "symbol") { + propertyKey = stringifySymbol(propertyKey); + } + if (propertyKey.includes('"')) { + return acc + '["' + escapeQuotes(propertyKey) + '"]'; + } + if (!identifierRegex.test(propertyKey)) { + return acc + '["' + propertyKey + '"]'; + } + const separator = acc.length === 0 ? "" : "."; + return acc + separator + propertyKey; + }, ""); +} +function escapeQuotes(str) { + return str.replace(/"/g, '\\"'); +} + +// lib/utils/titleCase.ts +function titleCase(value) { + if (value.length === 0) { + return value; + } + return value.charAt(0).toUpperCase() + value.slice(1); +} + +// lib/v4/MessageBuilder.ts +var defaultMessageBuilderOptions = { + prefix: "Validation error", + prefixSeparator: ": ", + maxIssuesInMessage: 99, + // I've got 99 problems but the b$tch ain't one + unionSeparator: " or ", + issueSeparator: "; ", + includePath: true, + forceTitleCase: true +}; +function createMessageBuilder(partialOptions = {}) { + const options = { + ...defaultMessageBuilderOptions, + ...partialOptions + }; + return function messageBuilder(issues) { + const message = issues.slice(0, options.maxIssuesInMessage).map((issue) => mapIssue(issue, options)).join(options.issueSeparator); + return conditionallyPrefixMessage(message, options); + }; +} +function mapIssue(issue, options) { + if (issue.code === "invalid_union" && isNonEmptyArray(issue.errors)) { + const individualMessages = issue.errors.map( + (issues) => issues.map( + (subIssue) => mapIssue( + { + ...subIssue, + path: issue.path.concat(subIssue.path) + }, + options + ) + ).join(options.issueSeparator) + ); + return Array.from(new Set(individualMessages)).join(options.unionSeparator); + } + const buf = []; + if (options.forceTitleCase) { + buf.push(titleCase(issue.message)); + } else { + buf.push(issue.message); + } + pathCondition: if (options.includePath && issue.path !== void 0 && isNonEmptyArray(issue.path)) { + if (issue.path.length === 1) { + const identifier = issue.path[0]; + if (typeof identifier === "number") { + buf.push(` at index ${identifier}`); + break pathCondition; + } + } + buf.push(` at "${joinPath(issue.path)}"`); + } + return buf.join(""); +} +function conditionallyPrefixMessage(message, options) { + if (options.prefix != null) { + if (message.length > 0) { + return [options.prefix, message].join(options.prefixSeparator); + } + return options.prefix; + } + if (message.length > 0) { + return message; + } + return defaultMessageBuilderOptions.prefix; +} + +// lib/v4/fromZodError.ts +function fromZodError(zodError, options = {}) { + if (!isZodErrorLike(zodError)) { + throw new TypeError( + `Invalid zodError param; expected instance of ZodError. Did you mean to use the "${fromError.name}" method instead?` + ); + } + return fromZodErrorWithoutRuntimeCheck(zodError, options); +} +function fromZodErrorWithoutRuntimeCheck(zodError, options = {}) { + const zodIssues = zodError.issues; + let message; + if (isNonEmptyArray(zodIssues)) { + const messageBuilder = createMessageBuilderFromOptions(options); + message = messageBuilder(zodIssues); + } else { + message = zodError.message; + } + return new ValidationError(message, { cause: zodError }); +} +function createMessageBuilderFromOptions(options) { + if ("messageBuilder" in options) { + return options.messageBuilder; + } + return createMessageBuilder(options); +} + +// lib/v4/toValidationError.ts +var toValidationError = (options = {}) => (err) => { + if (isZodErrorLike(err)) { + return fromZodErrorWithoutRuntimeCheck(err, options); + } + if (err instanceof Error) { + return new ValidationError(err.message, { cause: err }); + } + return new ValidationError("Unknown error"); +}; + +// lib/v4/fromError.ts +function fromError(err, options = {}) { + return toValidationError(options)(err); +} + +// lib/v4/fromZodIssue.ts +import * as zod from "zod/v4/core"; +function fromZodIssue(issue, options = {}) { + const messageBuilder = createMessageBuilderFromOptions2(options); + const message = messageBuilder([issue]); + return new ValidationError(message, { + cause: new zod.$ZodRealError([issue]) + }); +} +function createMessageBuilderFromOptions2(options) { + if ("messageBuilder" in options) { + return options.messageBuilder; + } + return createMessageBuilder(options); +} +export { + ValidationError, + createErrorMap, + createMessageBuilder, + fromError, + fromZodError, + fromZodIssue, + isValidationError, + isValidationErrorLike, + isZodErrorLike, + toValidationError +}; +//# sourceMappingURL=index.mjs.map \ No newline at end of file diff --git a/gui/frontend/node_modules/zod-validation-error/v4/index.mjs.map b/gui/frontend/node_modules/zod-validation-error/v4/index.mjs.map new file mode 100644 index 0000000000000000000000000000000000000000..4d119c6c3a4f7c0bf727e8a9dba6ce40cc99932c --- /dev/null +++ b/gui/frontend/node_modules/zod-validation-error/v4/index.mjs.map @@ -0,0 +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;\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 {\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\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\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\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,\n options: Pick = {\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\n): issue is zod.$ZodRawIssue {\n return issue.format === 'starts_with';\n}\n\nfunction parseStringStartsWith(\n issue: zod.$ZodRawIssue\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\n): issue is zod.$ZodRawIssue {\n return issue.format === 'ends_with';\n}\nfunction parseStringEndsWith(\n issue: zod.$ZodRawIssue\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\n): issue is zod.$ZodRawIssue {\n return issue.format === 'includes';\n}\nfunction parseStringIncludes(\n issue: zod.$ZodRawIssue\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\n): issue is zod.$ZodRawIssue {\n return issue.format === 'regex';\n}\nfunction parseStringInvalidRegex(\n issue: zod.$ZodRawIssue,\n options: Pick = {\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\n): issue is zod.$ZodRawIssue {\n return issue.format === 'jwt';\n}\nfunction parseStringInvalidJWT(\n issue: zod.$ZodRawIssue,\n options: Pick = {\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\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\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,\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((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,\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\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,\n options: Pick\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,\n options: Pick\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,\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>,\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 = {}\n): zod.$ZodErrorMap {\n // fill-in default options\n const options = {\n ...defaultErrorMapOptions,\n ...partialOptions,\n };\n\n const errorMap: zod.$ZodErrorMap = (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[]];\n\nexport function isNonEmptyArray(value: T[]): value is NonEmptyArray {\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): 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((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) => 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 = {}\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\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;\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>;\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":"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","names":["createMessageBuilderFromOptions"]} \ No newline at end of file diff --git a/gui/frontend/node_modules/zod/src/v4-mini/index.ts b/gui/frontend/node_modules/zod/src/v4-mini/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..bb95da0a24829980395bc1300b1edcc8474b3dfb --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4-mini/index.ts @@ -0,0 +1,3 @@ +import * as z from "../v4/mini/external.js"; +export * from "../v4/mini/external.js"; +export { z }; diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/index.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/index.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..bc9a7bd918dca8360a24ff5b6d55e9418a961e28 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/index.test.ts @@ -0,0 +1,46 @@ +import { expect, expectTypeOf, test } from "vitest"; +import * as z from "zod/v3"; + +test("test", () => { + expect(true).toBe(true); +}); + +test("test2", () => { + expect(() => z.string().parse(234)).toThrowErrorMatchingInlineSnapshot(` + [ZodError: [ + { + "code": "invalid_type", + "expected": "string", + "received": "number", + "path": [], + "message": "Expected string, received number" + } + ]] + `); +}); + +test("async validation", async () => { + const testTuple = z + .tuple([z.string().refine(async () => true), z.number().refine(async () => true)]) + .refine(async () => true); + expectTypeOf().toEqualTypeOf<[string, number]>(); + + const val = await testTuple.parseAsync(["asdf", 1234]); + expect(val).toEqual(val); + + const r1 = await testTuple.safeParseAsync(["asdf", "asdf"]); + expect(r1.success).toEqual(false); + expect(r1.error!).toMatchInlineSnapshot(` + [ZodError: [ + { + "code": "invalid_type", + "expected": "number", + "received": "string", + "path": [ + 1 + ], + "message": "Expected number, received string" + } + ]] + `); +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/be.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/be.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..6e4fccf464af5904449c7a5238208e85dfee43ed --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/be.test.ts @@ -0,0 +1,124 @@ +import { describe, expect, it } from "vitest"; +import be from "../../../locales/be.js"; + +describe("Belarusian localization", () => { + const localeError = be().localeError; + + describe("pluralization rules", () => { + for (const { type, cases } of TEST_CASES) { + describe(`${type} pluralization`, () => { + for (const { count, expected } of cases) { + it(`correctly pluralizes ${count} ${type}`, () => { + const error = localeError({ + code: "too_small", + minimum: count, + type: "number", + inclusive: true, + path: [], + origin: type, + input: count - 1, + }); + expect(error).toContain(expected); + }); + } + }); + } + + it("handles negative numbers correctly", () => { + const error = localeError({ + code: "too_small", + minimum: -2, + type: "number", + inclusive: true, + path: [], + origin: "array", + input: -3, + }); + expect(error).toContain("-2 элементы"); + }); + + it("handles zero correctly", () => { + const error = localeError({ + code: "too_small", + minimum: 0, + type: "number", + inclusive: true, + path: [], + origin: "array", + input: -1, + }); + expect(error).toContain("0 элементаў"); + }); + + it("handles bigint values correctly", () => { + const error = localeError({ + code: "too_small", + minimum: BigInt(21), + type: "number", + inclusive: true, + path: [], + origin: "array", + input: BigInt(20), + }); + expect(error).toContain("21 элемент"); + }); + }); +}); + +const TEST_CASES = [ + { + type: "array", + cases: [ + { count: 1, expected: "1 элемент" }, + { count: 2, expected: "2 элементы" }, + { count: 5, expected: "5 элементаў" }, + { count: 11, expected: "11 элементаў" }, + { count: 21, expected: "21 элемент" }, + { count: 22, expected: "22 элементы" }, + { count: 25, expected: "25 элементаў" }, + { count: 101, expected: "101 элемент" }, + { count: 111, expected: "111 элементаў" }, + ], + }, + { + type: "set", + cases: [ + { count: 1, expected: "1 элемент" }, + { count: 2, expected: "2 элементы" }, + { count: 5, expected: "5 элементаў" }, + { count: 11, expected: "11 элементаў" }, + { count: 21, expected: "21 элемент" }, + { count: 22, expected: "22 элементы" }, + { count: 25, expected: "25 элементаў" }, + { count: 101, expected: "101 элемент" }, + { count: 111, expected: "111 элементаў" }, + ], + }, + { + type: "string", + cases: [ + { count: 1, expected: "1 сімвал" }, + { count: 2, expected: "2 сімвалы" }, + { count: 5, expected: "5 сімвалаў" }, + { count: 11, expected: "11 сімвалаў" }, + { count: 21, expected: "21 сімвал" }, + { count: 22, expected: "22 сімвалы" }, + { count: 25, expected: "25 сімвалаў" }, + ], + }, + { + type: "file", + cases: [ + { count: 0, expected: "0 байтаў" }, + { count: 1, expected: "1 байт" }, + { count: 2, expected: "2 байты" }, + { count: 5, expected: "5 байтаў" }, + { count: 11, expected: "11 байтаў" }, + { count: 21, expected: "21 байт" }, + { count: 22, expected: "22 байты" }, + { count: 25, expected: "25 байтаў" }, + { count: 101, expected: "101 байт" }, + { count: 110, expected: "110 байтаў" }, + ], + }, +] as const; diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/el.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/el.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..cd4813981aefa28ddf881f6c906fd14ef01043fe --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/el.test.ts @@ -0,0 +1,215 @@ +import { expect, test } from "vitest"; +import { z } from "../../../../index.js"; +import el from "../../../locales/el.js"; + +test("Greek locale - too_small errors", () => { + z.config(el()); + + // Test string type translation + const stringSchema = z.string().min(5); + const stringResult = stringSchema.safeParse("abc"); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν string να έχει >=5 χαρακτήρες"); + } + + // Test number type translation + const numberSchema = z.number().min(10); + const numberResult = numberSchema.safeParse(5); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν number να είναι >=10"); + } + + // Test array type translation + const arraySchema = z.array(z.string()).min(3); + const arrayResult = arraySchema.safeParse(["a", "b"]); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν array να έχει >=3 στοιχεία"); + } + + // Test set type translation + const setSchema = z.set(z.string()).min(2); + const setResult = setSchema.safeParse(new Set(["a"])); + expect(setResult.success).toBe(false); + if (!setResult.success) { + expect(setResult.error.issues[0].message).toBe("Πολύ μικρό: αναμενόταν set να έχει >=2 στοιχεία"); + } +}); + +test("Greek locale - too_big errors", () => { + z.config(el()); + + // Test string type translation + const stringSchema = z.string().max(3); + const stringResult = stringSchema.safeParse("abcde"); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν string να έχει <=3 χαρακτήρες"); + } + + // Test number type translation + const numberSchema = z.number().max(10); + const numberResult = numberSchema.safeParse(15); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν number να είναι <=10"); + } + + // Test array type translation + const arraySchema = z.array(z.string()).max(2); + const arrayResult = arraySchema.safeParse(["a", "b", "c"]); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Πολύ μεγάλο: αναμενόταν array να έχει <=2 στοιχεία"); + } +}); + +test("Greek locale - invalid_type errors", () => { + z.config(el()); + + // Test string expected, number received + const stringSchema = z.string(); + const stringResult = stringSchema.safeParse(123); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν string, λήφθηκε number"); + } + + // Test number expected, string received + const numberSchema = z.number(); + const numberResult = numberSchema.safeParse("abc"); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν number, λήφθηκε string"); + } + + // Test boolean expected, null received + const booleanSchema = z.boolean(); + const booleanResult = booleanSchema.safeParse(null); + expect(booleanResult.success).toBe(false); + if (!booleanResult.success) { + expect(booleanResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν boolean, λήφθηκε null"); + } + + // Test array expected, object received + const arraySchema = z.array(z.string()); + const arrayResult = arraySchema.safeParse({}); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν array, λήφθηκε object"); + } +}); + +test("Greek locale - other error cases", () => { + z.config(el()); + + // Test invalid_element with map (only "map" | "set" produce invalid_element) + const mapSchema = z.map(z.bigint(), z.number()); + const mapResult = mapSchema.safeParse(new Map([[BigInt(123), BigInt(123)]])); + expect(mapResult.success).toBe(false); + if (!mapResult.success) { + expect(mapResult.error.issues[0].code).toBe("invalid_element"); + expect(mapResult.error.issues[0].message).toBe("Μη έγκυρη τιμή στο map"); + } + + // Test invalid_key with record (only "map" | "record" produce invalid_key) + const recordSchema = z.record(z.number(), z.string()); + const recordResult = recordSchema.safeParse({ notANumber: "value" }); + expect(recordResult.success).toBe(false); + if (!recordResult.success) { + expect(recordResult.error.issues[0].code).toBe("invalid_key"); + expect(recordResult.error.issues[0].message).toBe("Μη έγκυρο κλειδί στο record"); + } + + // Test invalid_value with enum + const enumSchema = z.enum(["a", "b"]); + const enumResult = enumSchema.safeParse("c"); + expect(enumResult.success).toBe(false); + if (!enumResult.success) { + expect(enumResult.error.issues[0].message).toBe('Μη έγκυρη επιλογή: αναμενόταν ένα από "a"|"b"'); + } + + // Test not_multiple_of + const multipleSchema = z.number().multipleOf(3); + const multipleResult = multipleSchema.safeParse(10); + expect(multipleResult.success).toBe(false); + if (!multipleResult.success) { + expect(multipleResult.error.issues[0].message).toBe("Μη έγκυρος αριθμός: πρέπει να είναι πολλαπλάσιο του 3"); + } + + // Test unrecognized_keys (single key) + const strictSchema = z.object({ a: z.string() }).strict(); + const strictResult = strictSchema.safeParse({ a: "test", b: "extra" }); + expect(strictResult.success).toBe(false); + if (!strictResult.success) { + expect(strictResult.error.issues[0].message).toBe('Άγνωστο κλειδί: "b"'); + } + + // Test unrecognized_keys (multiple keys) + const strictMultipleResult = strictSchema.safeParse({ + a: "test", + b: "extra", + c: "another", + }); + expect(strictMultipleResult.success).toBe(false); + if (!strictMultipleResult.success) { + expect(strictMultipleResult.error.issues[0].message).toBe('Άγνωστα κλειδιά: "b", "c"'); + } + + // Test invalid_union + const unionSchema = z.union([z.string(), z.number()]); + const unionResult = unionSchema.safeParse(true); + expect(unionResult.success).toBe(false); + if (!unionResult.success) { + expect(unionResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος"); + } + + // Test invalid_format with regex + const regexSchema = z.string().regex(/^[a-z]+$/); + const regexResult = regexSchema.safeParse("ABC123"); + expect(regexResult.success).toBe(false); + if (!regexResult.success) { + expect(regexResult.error.issues[0].message).toBe( + "Μη έγκυρη συμβολοσειρά: πρέπει να ταιριάζει με το μοτίβο /^[a-z]+$/" + ); + } + + // Test invalid_format with startsWith + const startsWithSchema = z.string().startsWith("hello"); + const startsWithResult = startsWithSchema.safeParse("world"); + expect(startsWithResult.success).toBe(false); + if (!startsWithResult.success) { + expect(startsWithResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να ξεκινά με "hello"'); + } + + // Test invalid_format with endsWith + const endsWithSchema = z.string().endsWith("world"); + const endsWithResult = endsWithSchema.safeParse("hello"); + expect(endsWithResult.success).toBe(false); + if (!endsWithResult.success) { + expect(endsWithResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να τελειώνει με "world"'); + } + + // Test invalid_format with includes + const includesSchema = z.string().includes("test"); + const includesResult = includesSchema.safeParse("hello"); + expect(includesResult.success).toBe(false); + if (!includesResult.success) { + expect(includesResult.error.issues[0].message).toBe('Μη έγκυρη συμβολοσειρά: πρέπει να περιέχει "test"'); + } +}); + +test("Greek locale - invalid_type with instanceof (class-name expected)", () => { + z.config(el()); + + // When `expected` starts with a capital letter, render an `instanceof` message, + // matching the convention used by most other locales (de, es, fr, it, etc.). + const dateSchema = z.instanceof(Date); + const dateResult = dateSchema.safeParse("not a date"); + expect(dateResult.success).toBe(false); + if (!dateResult.success) { + expect(dateResult.error.issues[0].message).toBe("Μη έγκυρη είσοδος: αναμενόταν instanceof Date, λήφθηκε string"); + } +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/en.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/en.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..75fcaeaf91eb6a26d63b5e92c26ffa60d26cd40d --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/en.test.ts @@ -0,0 +1,22 @@ +import { expect, test } from "vitest"; +import { parsedType } from "../../util.js"; + +test("parsedType", () => { + expect(parsedType("string")).toBe("string"); + expect(parsedType(1)).toBe("number"); + expect(parsedType(true)).toBe("boolean"); + expect(parsedType(null)).toBe("null"); + expect(parsedType(undefined)).toBe("undefined"); + expect(parsedType([])).toBe("array"); + expect(parsedType({})).toBe("object"); + expect(parsedType(new Date())).toBe("Date"); + expect(parsedType(new Map())).toBe("Map"); + expect(parsedType(new Set())).toBe("Set"); + expect(parsedType(new Error())).toBe("Error"); + + const nullPrototype = Object.create(null); + expect(parsedType(nullPrototype)).toBe("object"); + + const doubleNullPrototype = Object.create(Object.create(null)); + expect(parsedType(doubleNullPrototype)).toBe("object"); +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/es.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/es.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..280934e11409651a5e9cf9af66bee4b834fd7171 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/es.test.ts @@ -0,0 +1,181 @@ +import { expect, test } from "vitest"; +import { z } from "../../../../index.js"; +import es from "../../../locales/es.js"; + +test("Spanish locale - type name translations in too_small errors", () => { + z.config(es()); + + // Test string type translation + const stringSchema = z.string().min(5); + const stringResult = stringSchema.safeParse("abc"); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe( + "Demasiado pequeño: se esperaba que texto tuviera >=5 caracteres" + ); + } + + // Test number type translation + const numberSchema = z.number().min(10); + const numberResult = numberSchema.safeParse(5); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Demasiado pequeño: se esperaba que número fuera >=10"); + } + + // Test array type translation + const arraySchema = z.array(z.string()).min(3); + const arrayResult = arraySchema.safeParse(["a", "b"]); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe( + "Demasiado pequeño: se esperaba que arreglo tuviera >=3 elementos" + ); + } + + // Test set type translation + const setSchema = z.set(z.string()).min(2); + const setResult = setSchema.safeParse(new Set(["a"])); + expect(setResult.success).toBe(false); + if (!setResult.success) { + expect(setResult.error.issues[0].message).toBe("Demasiado pequeño: se esperaba que conjunto tuviera >=2 elementos"); + } +}); + +test("Spanish locale - type name translations in too_big errors", () => { + z.config(es()); + + // Test string type translation + const stringSchema = z.string().max(3); + const stringResult = stringSchema.safeParse("abcde"); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Demasiado grande: se esperaba que texto tuviera <=3 caracteres"); + } + + // Test number type translation + const numberSchema = z.number().max(10); + const numberResult = numberSchema.safeParse(15); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Demasiado grande: se esperaba que número fuera <=10"); + } + + // Test array type translation + const arraySchema = z.array(z.string()).max(2); + const arrayResult = arraySchema.safeParse(["a", "b", "c"]); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Demasiado grande: se esperaba que arreglo tuviera <=2 elementos"); + } +}); + +test("Spanish locale - type name translations in invalid_type errors", () => { + z.config(es()); + + // Test string expected, number received + const stringSchema = z.string(); + const stringResult = stringSchema.safeParse(123); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Entrada inválida: se esperaba texto, recibido número"); + } + + // Test number expected, string received + const numberSchema = z.number(); + const numberResult = numberSchema.safeParse("abc"); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Entrada inválida: se esperaba número, recibido texto"); + } + + // Test boolean expected, null received + const booleanSchema = z.boolean(); + const booleanResult = booleanSchema.safeParse(null); + expect(booleanResult.success).toBe(false); + if (!booleanResult.success) { + expect(booleanResult.error.issues[0].message).toBe("Entrada inválida: se esperaba booleano, recibido nulo"); + } + + // Test array expected, object received + const arraySchema = z.array(z.string()); + const arrayResult = arraySchema.safeParse({}); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Entrada inválida: se esperaba arreglo, recibido objeto"); + } +}); + +test("Spanish locale - fallback for unknown type names", () => { + z.config(es()); + + // Test with a type that's not in the TypeNames dictionary + // This will test the fallback behavior + const dateSchema = z.date().min(new Date("2025-01-01")); + const dateResult = dateSchema.safeParse(new Date("2024-01-01")); + expect(dateResult.success).toBe(false); + if (!dateResult.success) { + // Should use "fecha" since we included it in TypeNames + expect(dateResult.error.issues[0].message).toContain("fecha"); + } +}); + +test("Spanish locale - other error cases", () => { + z.config(es()); + + // Test invalid_element with tuple + const tupleSchema = z.tuple([z.string(), z.number()]); + const tupleResult = tupleSchema.safeParse(["abc", "not a number"]); + expect(tupleResult.success).toBe(false); + if (!tupleResult.success) { + expect(tupleResult.error.issues[0].message).toContain("Entrada inválida"); + } + + // Test invalid_value with enum + const enumSchema = z.enum(["a", "b"]); + const enumResult = enumSchema.safeParse("c"); + expect(enumResult.success).toBe(false); + if (!enumResult.success) { + expect(enumResult.error.issues[0].message).toBe('Opción inválida: se esperaba una de "a"|"b"'); + } + + // Test not_multiple_of + const multipleSchema = z.number().multipleOf(3); + const multipleResult = multipleSchema.safeParse(10); + expect(multipleResult.success).toBe(false); + if (!multipleResult.success) { + expect(multipleResult.error.issues[0].message).toBe("Número inválido: debe ser múltiplo de 3"); + } + + // Test unrecognized_keys + const strictSchema = z.object({ a: z.string() }).strict(); + const strictResult = strictSchema.safeParse({ a: "test", b: "extra" }); + expect(strictResult.success).toBe(false); + if (!strictResult.success) { + expect(strictResult.error.issues[0].message).toBe('Llave desconocida: "b"'); + } + + // Test invalid_union + const unionSchema = z.union([z.string(), z.number()]); + const unionResult = unionSchema.safeParse(true); + expect(unionResult.success).toBe(false); + if (!unionResult.success) { + expect(unionResult.error.issues[0].message).toBe("Entrada inválida"); + } + + // Test invalid_format with regex + const regexSchema = z.string().regex(/^[a-z]+$/); + const regexResult = regexSchema.safeParse("ABC123"); + expect(regexResult.success).toBe(false); + if (!regexResult.success) { + expect(regexResult.error.issues[0].message).toBe("Cadena inválida: debe coincidir con el patrón /^[a-z]+$/"); + } + + // Test invalid_format with startsWith + const startsWithSchema = z.string().startsWith("hello"); + const startsWithResult = startsWithSchema.safeParse("world"); + expect(startsWithResult.success).toBe(false); + if (!startsWithResult.success) { + expect(startsWithResult.error.issues[0].message).toBe('Cadena inválida: debe comenzar con "hello"'); + } +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/fr.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/fr.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..48112b73fe9d6b3282283c435ceb3d777440a1cf --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/fr.test.ts @@ -0,0 +1,72 @@ +import { expect, test } from "vitest"; +import { z } from "../../../../index.js"; +import fr from "../../../locales/fr.js"; + +test("French locale - type name translations in too_small errors", () => { + z.config(fr()); + + const stringResult = z.string().min(5).safeParse("abc"); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Trop petit : chaîne doit avoir >=5 caractères"); + } + + const numberResult = z.number().min(10).safeParse(5); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Trop petit : nombre doit être >=10"); + } + + const arrayResult = z.array(z.string()).min(3).safeParse(["a", "b"]); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Trop petit : tableau doit avoir >=3 éléments"); + } + + const setResult = z + .set(z.string()) + .min(2) + .safeParse(new Set(["a"])); + expect(setResult.success).toBe(false); + if (!setResult.success) { + expect(setResult.error.issues[0].message).toBe("Trop petit : ensemble doit avoir >=2 éléments"); + } +}); + +test("French locale - type name translations in too_big errors", () => { + z.config(fr()); + + const stringResult = z.string().max(3).safeParse("abcde"); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Trop grand : chaîne doit avoir <=3 caractères"); + } + + const numberResult = z.number().max(10).safeParse(15); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Trop grand : nombre doit être <=10"); + } + + const arrayResult = z.array(z.string()).max(2).safeParse(["a", "b", "c"]); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Trop grand : tableau doit avoir <=2 éléments"); + } +}); + +test("French locale - type name translations in invalid_type errors", () => { + z.config(fr()); + + const stringResult = z.string().safeParse(123); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Entrée invalide : chaîne attendu, nombre reçu"); + } + + const arrayResult = z.array(z.string()).safeParse({}); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Entrée invalide : tableau attendu, objet reçu"); + } +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/he.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/he.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..50724314afc695f4ee0c74add4ccf6765c39ccfd --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/he.test.ts @@ -0,0 +1,379 @@ +import { beforeEach, describe, expect, test } from "vitest"; +import { z } from "../../../../index.js"; +import he from "../../../locales/he.js"; + +describe("Hebrew localization", () => { + beforeEach(() => { + z.config(he()); + }); + + describe("too_small errors with definite article and gendered verbs", () => { + test("string type (feminine - צריכה)", () => { + const schema = z.string().min(3); + const result = schema.safeParse("ab"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קצר מדי: המחרוזת צריכה להכיל 3 תווים או יותר"); + } + }); + + test("number type (masculine - צריך)", () => { + const schema = z.number().min(10); + const result = schema.safeParse(5); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קטן מדי: המספר צריך להיות גדול או שווה ל-10"); + } + }); + + test("array type (masculine - צריך)", () => { + const schema = z.array(z.string()).min(1); + const result = schema.safeParse([]); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קטן מדי: המערך צריך להכיל לפחות פריט אחד"); + } + }); + + test("set type (feminine - צריכה)", () => { + const schema = z.set(z.string()).min(2); + const result = schema.safeParse(new Set(["a"])); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קטן מדי: הקבוצה (Set) צריכה להכיל 2 פריטים או יותר"); + } + }); + }); + + describe("too_big errors with definite article and gendered verbs", () => { + test("string type (feminine - צריכה)", () => { + const schema = z.string().max(3); + const result = schema.safeParse("abcde"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("ארוך מדי: המחרוזת צריכה להכיל 3 תווים או פחות"); + } + }); + + test("number type (masculine - צריך)", () => { + const schema = z.number().max(365); + const result = schema.safeParse(400); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("גדול מדי: המספר צריך להיות קטן או שווה ל-365"); + } + }); + + test("array max", () => { + const schema = z.array(z.string()).max(2); + const result = schema.safeParse(["a", "b", "c"]); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("גדול מדי: המערך צריך להכיל 2 פריטים או פחות"); + } + }); + }); + + describe("invalid_type errors with definite article and gendered verbs", () => { + test("string expected (feminine), number received", () => { + const schema = z.string(); + const result = schema.safeParse(123); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות מחרוזת, התקבל מספר"); + } + }); + + test("number expected (masculine), string received", () => { + const schema = z.number(); + const result = schema.safeParse("abc"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות מספר, התקבל מחרוזת"); + } + }); + + test("boolean expected (masculine), null received", () => { + const schema = z.boolean(); + const result = schema.safeParse(null); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות ערך בוליאני, התקבל ערך ריק (null)"); + } + }); + + test("array expected (masculine), object received", () => { + const schema = z.array(z.string()); + const result = schema.safeParse({}); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות מערך, התקבל אובייקט"); + } + }); + + test("object expected (masculine), array received", () => { + const schema = z.object({ a: z.string() }); + const result = schema.safeParse([]); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות אובייקט, התקבל מערך"); + } + }); + + test("function expected (feminine), string received", () => { + const schema = z.function(); + const result = schema.safeParse("not a function"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות פונקציה, התקבל מחרוזת"); + } + }); + }); + + describe("gendered verbs consistency", () => { + test("feminine types use צריכה", () => { + const feminineTypes = [ + { schema: z.string().min(5), input: "abc" }, + { schema: z.set(z.string()).min(2), input: new Set(["a"]) }, + ]; + + for (const { schema, input } of feminineTypes) { + const result = schema.safeParse(input); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toContain("צריכה"); + } + } + }); + + test("masculine types use צריך", () => { + const masculineTypes = [ + { schema: z.number().min(10), input: 5 }, + { schema: z.array(z.string()).min(2), input: ["a"] }, + ]; + + for (const { schema, input } of masculineTypes) { + const result = schema.safeParse(input); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toContain("צריך"); + } + } + }); + }); + + describe("invalid_value with enum", () => { + test("single value", () => { + const schema = z.enum(["a"]); + const result = schema.safeParse("b"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe('ערך לא תקין: הערך חייב להיות "a"'); + } + }); + + test("two values", () => { + const schema = z.enum(["a", "b"]); + const result = schema.safeParse("c"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe('ערך לא תקין: האפשרויות המתאימות הן "a" או "b"'); + } + }); + + test("multiple values", () => { + const schema = z.enum(["a", "b", "c"]); + const result = schema.safeParse("d"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe('ערך לא תקין: האפשרויות המתאימות הן "a", "b" או "c"'); + } + }); + }); + + describe("other error types", () => { + test("not_multiple_of", () => { + const schema = z.number().multipleOf(3); + const result = schema.safeParse(10); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("מספר לא תקין: חייב להיות מכפלה של 3"); + } + }); + + test("unrecognized_keys - single key", () => { + const schema = z.object({ a: z.string() }).strict(); + const result = schema.safeParse({ a: "test", b: "extra" }); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe('מפתח לא מזוהה: "b"'); + } + }); + + test("unrecognized_keys - multiple keys", () => { + const schema = z.object({ a: z.string() }).strict(); + const result = schema.safeParse({ a: "test", b: "extra", c: "more" }); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe('מפתחות לא מזוהים: "b", "c"'); + } + }); + + test("invalid_union", () => { + const schema = z.union([z.string(), z.number()]); + const result = schema.safeParse(true); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קלט לא תקין"); + } + }); + + test("invalid_key in object", () => { + const schema = z.record(z.number(), z.string()); + const result = schema.safeParse({ notANumber: "value" }); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("שדה לא תקין באובייקט"); + } + }); + }); + + describe("invalid_format with string checks", () => { + test("startsWith", () => { + const schema = z.string().startsWith("hello"); + const result = schema.safeParse("world"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe('המחרוזת חייבת להתחיל ב "hello"'); + } + }); + + test("endsWith", () => { + const schema = z.string().endsWith("world"); + const result = schema.safeParse("hello"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe('המחרוזת חייבת להסתיים ב "world"'); + } + }); + + test("includes", () => { + const schema = z.string().includes("test"); + const result = schema.safeParse("hello world"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe('המחרוזת חייבת לכלול "test"'); + } + }); + + test("regex", () => { + const schema = z.string().regex(/^[a-z]+$/); + const result = schema.safeParse("ABC123"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("המחרוזת חייבת להתאים לתבנית /^[a-z]+$/"); + } + }); + }); + + describe("invalid_format with common formats", () => { + test("email", () => { + const schema = z.string().email(); + const result = schema.safeParse("not-an-email"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("כתובת אימייל לא תקינה"); + } + }); + + test("url", () => { + const schema = z.string().url(); + const result = schema.safeParse("not-a-url"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("כתובת רשת לא תקינה"); + } + }); + + test("uuid", () => { + const schema = z.string().uuid(); + const result = schema.safeParse("not-a-uuid"); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("UUID לא תקין"); + } + }); + }); + + describe("tuple validation", () => { + test("invalid element type in tuple shows full error message", () => { + const schema = z.tuple([z.string(), z.number()]); + const result = schema.safeParse(["abc", "not a number"]); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קלט לא תקין: צריך להיות מספר, התקבל מחרוזת"); + } + }); + }); + + describe("inclusive vs exclusive bounds", () => { + test("inclusive minimum (>=)", () => { + const schema = z.number().min(10); + const result = schema.safeParse(5); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קטן מדי: המספר צריך להיות גדול או שווה ל-10"); + } + }); + + test("exclusive minimum (>)", () => { + const schema = z.number().gt(10); + const result = schema.safeParse(10); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("קטן מדי: המספר צריך להיות גדול מ-10"); + } + }); + + test("inclusive maximum (<=)", () => { + const schema = z.number().max(10); + const result = schema.safeParse(15); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("גדול מדי: המספר צריך להיות קטן או שווה ל-10"); + } + }); + + test("exclusive maximum (<)", () => { + const schema = z.number().lt(10); + const result = schema.safeParse(10); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toBe("גדול מדי: המספר צריך להיות קטן מ-10"); + } + }); + }); + + describe("all type names with definite article", () => { + test("verifies all type translations are correct", () => { + const types = [ + { schema: z.string(), expected: "מחרוזת", input: 123 }, + { schema: z.number(), expected: "מספר", input: "abc" }, + { schema: z.boolean(), expected: "ערך בוליאני", input: "abc" }, + { schema: z.bigint(), expected: "BigInt", input: "abc" }, + { schema: z.date(), expected: "תאריך", input: "abc" }, + { schema: z.array(z.any()), expected: "מערך", input: "abc" }, + { schema: z.object({}), expected: "אובייקט", input: "abc" }, + { schema: z.function(), expected: "פונקציה", input: "abc" }, + ]; + + for (const { schema, expected, input } of types) { + const result = schema.safeParse(input); + expect(result.success).toBe(false); + if (!result.success) { + expect(result.error.issues[0].message).toContain(expected); + } + } + }); + }); +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/hr.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/hr.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..14b529424091e7785c7f5998bea9f6d734c0c081 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/hr.test.ts @@ -0,0 +1,163 @@ +import { expect, test } from "vitest"; +import { z } from "../../../../index.js"; +import hr from "../../../locales/hr.js"; + +test("Croatian locale - type name translations in too_small errors", () => { + z.config(hr()); + + // Test string type translation + const stringSchema = z.string().min(5); + const stringResult = stringSchema.safeParse("abc"); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Premalo: očekivano da tekst ima >=5 znakova"); + } + + // Test number type translation + const numberSchema = z.number().min(10); + const numberResult = numberSchema.safeParse(5); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Premalo: očekivano da broj bude >=10"); + } + + // Test array type translation + const arraySchema = z.array(z.string()).min(3); + const arrayResult = arraySchema.safeParse(["a", "b"]); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Premalo: očekivano da niz ima >=3 stavki"); + } + + // Test set type translation + const setSchema = z.set(z.string()).min(2); + const setResult = setSchema.safeParse(new Set(["a"])); + expect(setResult.success).toBe(false); + if (!setResult.success) { + expect(setResult.error.issues[0].message).toBe("Premalo: očekivano da skup ima >=2 stavki"); + } +}); + +test("Croatian locale - type name translations in too_big errors", () => { + z.config(hr()); + + // Test string type translation + const stringSchema = z.string().max(3); + const stringResult = stringSchema.safeParse("abcde"); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Preveliko: očekivano da tekst ima <=3 znakova"); + } + + // Test number type translation + const numberSchema = z.number().max(10); + const numberResult = numberSchema.safeParse(15); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Preveliko: očekivano da broj bude <=10"); + } + + // Test array type translation + const arraySchema = z.array(z.string()).max(2); + const arrayResult = arraySchema.safeParse(["a", "b", "c"]); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Preveliko: očekivano da niz ima <=2 stavki"); + } +}); + +test("Croatian locale - type name translations in invalid_type errors", () => { + z.config(hr()); + + // Test string expected, number received + const stringSchema = z.string(); + const stringResult = stringSchema.safeParse(123); + expect(stringResult.success).toBe(false); + if (!stringResult.success) { + expect(stringResult.error.issues[0].message).toBe("Neispravan unos: očekuje se tekst, a primljeno je broj"); + } + + // Test number expected, string received + const numberSchema = z.number(); + const numberResult = numberSchema.safeParse("abc"); + expect(numberResult.success).toBe(false); + if (!numberResult.success) { + expect(numberResult.error.issues[0].message).toBe("Neispravan unos: očekuje se broj, a primljeno je tekst"); + } + + // Test boolean expected, null received + const booleanSchema = z.boolean(); + const booleanResult = booleanSchema.safeParse(null); + expect(booleanResult.success).toBe(false); + if (!booleanResult.success) { + expect(booleanResult.error.issues[0].message).toBe("Neispravan unos: očekuje se boolean, a primljeno je null"); + } + + // Test array expected, object received + const arraySchema = z.array(z.string()); + const arrayResult = arraySchema.safeParse({}); + expect(arrayResult.success).toBe(false); + if (!arrayResult.success) { + expect(arrayResult.error.issues[0].message).toBe("Neispravan unos: očekuje se niz, a primljeno je objekt"); + } +}); + +test("Croatian locale - other error cases", () => { + z.config(hr()); + + // Test invalid_element with tuple + const tupleSchema = z.tuple([z.string(), z.number()]); + const tupleResult = tupleSchema.safeParse(["abc", "not a number"]); + expect(tupleResult.success).toBe(false); + if (!tupleResult.success) { + expect(tupleResult.error.issues[0].message).toContain("Neispravan unos"); + } + + // Test invalid_value with enum + const enumSchema = z.enum(["a", "b"]); + const enumResult = enumSchema.safeParse("c"); + expect(enumResult.success).toBe(false); + if (!enumResult.success) { + expect(enumResult.error.issues[0].message).toBe('Neispravna opcija: očekivano jedno od "a"|"b"'); + } + + // Test not_multiple_of + const multipleSchema = z.number().multipleOf(3); + const multipleResult = multipleSchema.safeParse(10); + expect(multipleResult.success).toBe(false); + if (!multipleResult.success) { + expect(multipleResult.error.issues[0].message).toBe("Neispravan broj: mora biti višekratnik od 3"); + } + + // Test unrecognized_keys + const strictSchema = z.object({ a: z.string() }).strict(); + const strictResult = strictSchema.safeParse({ a: "test", b: "extra" }); + expect(strictResult.success).toBe(false); + if (!strictResult.success) { + expect(strictResult.error.issues[0].message).toBe('Neprepoznat ključ: "b"'); + } + + // Test invalid_union + const unionSchema = z.union([z.string(), z.number()]); + const unionResult = unionSchema.safeParse(true); + expect(unionResult.success).toBe(false); + if (!unionResult.success) { + expect(unionResult.error.issues[0].message).toBe("Neispravan unos"); + } + + // Test invalid_format with regex + const regexSchema = z.string().regex(/^[a-z]+$/); + const regexResult = regexSchema.safeParse("ABC123"); + expect(regexResult.success).toBe(false); + if (!regexResult.success) { + expect(regexResult.error.issues[0].message).toBe("Neispravan tekst: mora odgovarati uzorku /^[a-z]+$/"); + } + + // Test invalid_format with startsWith + const startsWithSchema = z.string().startsWith("hello"); + const startsWithResult = startsWithSchema.safeParse("world"); + expect(startsWithResult.success).toBe(false); + if (!startsWithResult.success) { + expect(startsWithResult.error.issues[0].message).toBe('Neispravan tekst: mora započinjati s "hello"'); + } +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/nl.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/nl.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..02a6e05d10047ab2cb844e5e886b699c42748f1b --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/nl.test.ts @@ -0,0 +1,46 @@ +import { expect, test } from "vitest"; +import nl from "../../../locales/nl.js"; + +test("Dutch locale error messages", () => { + const { localeError } = nl(); + + // Test invalid_type + expect( + localeError({ + code: "invalid_type", + expected: "string", + input: 123, + }) + ).toBe("Ongeldige invoer: verwacht string, ontving getal"); + + // Test too_big with sizing + expect( + localeError({ + code: "too_big", + origin: "string", + maximum: 10, + inclusive: true, + input: "test string that is too long", + }) + ).toBe("Te lang: verwacht dat string <=10 tekens heeft"); + + // Test too_small with sizing + expect( + localeError({ + code: "too_small", + origin: "array", + minimum: 5, + inclusive: false, + input: [1, 2], + }) + ).toBe("Te klein: verwacht dat array >5 elementen heeft"); + + // Test invalid_format + expect( + localeError({ + code: "invalid_format", + format: "email", + input: "invalid-email", + }) + ).toBe("Ongeldig: emailadres"); +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/ru.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/ru.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..6fb7c95f40b634914483f8dde056f52f71410047 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/ru.test.ts @@ -0,0 +1,128 @@ +import { describe, expect, it } from "vitest"; +import ru from "../../../locales/ru.js"; + +describe("Russian localization", () => { + const localeError = ru().localeError; + + describe("pluralization rules", () => { + for (const { type, cases } of TEST_CASES) { + describe(`${type} pluralization`, () => { + for (const { count, expected } of cases) { + it(`correctly pluralizes ${count} ${type}`, () => { + const error = localeError({ + code: "too_small", + minimum: count, + type: "number", + inclusive: true, + path: [], + origin: type, + input: count - 1, + }); + + expect(error).toContain(expected); + }); + } + }); + } + + it("handles negative numbers correctly", () => { + const error = localeError({ + code: "too_small", + minimum: -2, + type: "number", + inclusive: true, + path: [], + origin: "array", + input: -3, + }); + + expect(error).toContain("-2 элемента"); + }); + + it("handles zero correctly", () => { + const error = localeError({ + code: "too_small", + minimum: 0, + type: "number", + inclusive: true, + path: [], + origin: "array", + input: -1, + }); + + expect(error).toContain("0 элементов"); + }); + + it("handles bigint values correctly", () => { + const error = localeError({ + code: "too_small", + minimum: BigInt(21), + type: "number", + inclusive: true, + path: [], + origin: "array", + input: BigInt(20), + }); + + expect(error).toContain("21 элемент"); + }); + }); +}); + +const TEST_CASES = [ + { + type: "array", + cases: [ + { count: 1, expected: "1 элемент" }, + { count: 2, expected: "2 элемента" }, + { count: 5, expected: "5 элементов" }, + { count: 11, expected: "11 элементов" }, + { count: 21, expected: "21 элемент" }, + { count: 22, expected: "22 элемента" }, + { count: 25, expected: "25 элементов" }, + { count: 101, expected: "101 элемент" }, + { count: 111, expected: "111 элементов" }, + ], + }, + { + type: "set", + cases: [ + { count: 1, expected: "1 элемент" }, + { count: 2, expected: "2 элемента" }, + { count: 5, expected: "5 элементов" }, + { count: 11, expected: "11 элементов" }, + { count: 21, expected: "21 элемент" }, + { count: 22, expected: "22 элемента" }, + { count: 25, expected: "25 элементов" }, + { count: 101, expected: "101 элемент" }, + { count: 111, expected: "111 элементов" }, + ], + }, + { + type: "string", + cases: [ + { count: 1, expected: "1 символ" }, + { count: 2, expected: "2 символа" }, + { count: 5, expected: "5 символов" }, + { count: 11, expected: "11 символов" }, + { count: 21, expected: "21 символ" }, + { count: 22, expected: "22 символа" }, + { count: 25, expected: "25 символов" }, + ], + }, + { + type: "file", + cases: [ + { count: 0, expected: "0 байт" }, + { count: 1, expected: "1 байт" }, + { count: 2, expected: "2 байта" }, + { count: 5, expected: "5 байт" }, + { count: 11, expected: "11 байт" }, + { count: 21, expected: "21 байт" }, + { count: 22, expected: "22 байта" }, + { count: 25, expected: "25 байт" }, + { count: 101, expected: "101 байт" }, + { count: 110, expected: "110 байт" }, + ], + }, +] as const; diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/tr.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/tr.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..bc46bf41e9f2535d94d4325d0b85a4bbfd0b6410 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/tr.test.ts @@ -0,0 +1,69 @@ +import { expect, test } from "vitest"; +import * as z from "zod/v4"; +import { parsedType } from "../../util.js"; + +test("parsedType", () => { + expect(parsedType("string")).toBe("string"); + expect(parsedType(1)).toBe("number"); + expect(parsedType(true)).toBe("boolean"); + expect(parsedType(null)).toBe("null"); + expect(parsedType(undefined)).toBe("undefined"); + expect(parsedType([])).toBe("array"); + expect(parsedType({})).toBe("object"); + expect(parsedType(new Date())).toBe("Date"); + expect(parsedType(new Map())).toBe("Map"); + expect(parsedType(new Set())).toBe("Set"); + expect(parsedType(new Error())).toBe("Error"); + + const nullPrototype = Object.create(null); + expect(parsedType(nullPrototype)).toBe("object"); + + const doubleNullPrototype = Object.create(Object.create(null)); + expect(parsedType(doubleNullPrototype)).toBe("object"); + + expect(parsedType(Number.NaN)).toBe("nan"); +}); + +test("locales - tr", () => { + z.config(z.locales.tr()); + + const invalidType = z.number().safeParse("a"); + expect(invalidType.error!.issues[0].code).toBe("invalid_type"); + expect(invalidType.error!.issues[0].message).toBe("Geçersiz değer: beklenen number, alınan string"); + + const invalidType2 = z.string().safeParse(1); + expect(invalidType2.error!.issues[0].code).toBe("invalid_type"); + expect(invalidType2.error!.issues[0].message).toBe("Geçersiz değer: beklenen string, alınan number"); + + const invalidValue = z.enum(["a", "b"]).safeParse(1); + expect(invalidValue.error!.issues[0].code).toBe("invalid_value"); + expect(invalidValue.error!.issues[0].message).toBe('Geçersiz seçenek: aşağıdakilerden biri olmalı: "a"|"b"'); + + const tooBig = z.number().max(10).safeParse(15); + expect(tooBig.error!.issues[0].code).toBe("too_big"); + expect(tooBig.error!.issues[0].message).toBe("Çok büyük: beklenen number <=10"); + + const tooSmall = z.number().min(10).safeParse(5); + expect(tooSmall.error!.issues[0].code).toBe("too_small"); + expect(tooSmall.error!.issues[0].message).toBe("Çok küçük: beklenen number >=10"); + + const invalidFormatRegex = z.string().regex(/abcd/).safeParse("invalid-string"); + expect(invalidFormatRegex.error!.issues[0].code).toBe("invalid_format"); + expect(invalidFormatRegex.error!.issues[0].message).toBe("Geçersiz metin: /abcd/ desenine uymalı"); + + const invalidFormatStartsWith = z.string().startsWith("abcd").safeParse("invalid-string"); + expect(invalidFormatStartsWith.error!.issues[0].code).toBe("invalid_format"); + expect(invalidFormatStartsWith.error!.issues[0].message).toBe('Geçersiz metin: "abcd" ile başlamalı'); + + const notMultipleOf = z.number().multipleOf(3).safeParse(10); + expect(notMultipleOf.error!.issues[0].code).toBe("not_multiple_of"); + expect(notMultipleOf.error!.issues[0].message).toBe("Geçersiz sayı: 3 ile tam bölünebilmeli"); + + const unrecognizedKeys = z.object({ a: z.string(), b: z.number() }).strict().safeParse({ a: "a", b: 1, c: 2 }); + expect(unrecognizedKeys.error!.issues[0].code).toBe("unrecognized_keys"); + expect(unrecognizedKeys.error!.issues[0].message).toBe('Tanınmayan anahtar: "c"'); + + const invalidUnion = z.union([z.string(), z.number()]).safeParse(true); + expect(invalidUnion.error!.issues[0].code).toBe("invalid_union"); + expect(invalidUnion.error!.issues[0].message).toBe("Geçersiz değer"); +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/locales/uz.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/uz.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..bcb43a2785b5aaf8c942a068b203e111a29ff49a --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/locales/uz.test.ts @@ -0,0 +1,105 @@ +import { expect, test } from "vitest"; +import * as z from "zod/v4"; + +test("locales - uz", () => { + z.config(z.locales.uz()); + + const invalidType = z.number().safeParse("a"); + expect(invalidType.error!.issues[0].code).toBe("invalid_type"); + expect(invalidType.error!.issues[0].message).toBe("Noto‘g‘ri kirish: kutilgan raqam, qabul qilingan string"); + + const invalidType2 = z.string().safeParse(1); + expect(invalidType2.error!.issues[0].code).toBe("invalid_type"); + expect(invalidType2.error!.issues[0].message).toBe("Noto‘g‘ri kirish: kutilgan string, qabul qilingan raqam"); + + const invalidValue = z.enum(["a", "b"]).safeParse(1); + expect(invalidValue.error!.issues[0].code).toBe("invalid_value"); + expect(invalidValue.error!.issues[0].message).toBe('Noto‘g‘ri variant: quyidagilardan biri kutilgan "a"|"b"'); + + const tooBig = z.number().max(10).safeParse(15); + expect(tooBig.error!.issues[0].code).toBe("too_big"); + expect(tooBig.error!.issues[0].message).toBe("Juda katta: kutilgan number <=10"); + + const tooSmall = z.number().min(10).safeParse(5); + expect(tooSmall.error!.issues[0].code).toBe("too_small"); + expect(tooSmall.error!.issues[0].message).toBe("Juda kichik: kutilgan number >=10"); + + const invalidFormatRegex = z.string().regex(/abcd/).safeParse("invalid-string"); + expect(invalidFormatRegex.error!.issues[0].code).toBe("invalid_format"); + expect(invalidFormatRegex.error!.issues[0].message).toContain("shabloniga mos kelishi kerak"); + + const invalidFormatStartsWith = z.string().startsWith("abcd").safeParse("invalid-string"); + expect(invalidFormatStartsWith.error!.issues[0].code).toBe("invalid_format"); + expect(invalidFormatStartsWith.error!.issues[0].message).toContain('"abcd" bilan boshlanishi kerak'); + + const notMultipleOf = z.number().multipleOf(3).safeParse(10); + expect(notMultipleOf.error!.issues[0].code).toBe("not_multiple_of"); + expect(notMultipleOf.error!.issues[0].message).toContain("3 ning karralisi bo‘lishi kerak"); + + const unrecognizedKeys = z.object({ a: z.string(), b: z.number() }).strict().safeParse({ a: "a", b: 1, c: 2 }); + expect(unrecognizedKeys.error!.issues[0].code).toBe("unrecognized_keys"); + expect(unrecognizedKeys.error!.issues[0].message).toContain('Noma’lum kalit: "c"'); + + const invalidUnion = z.union([z.string(), z.number()]).safeParse(true); + expect(invalidUnion.error!.issues[0].code).toBe("invalid_union"); + expect(invalidUnion.error!.issues[0].message).toBe("Noto‘g‘ri kirish"); + + const tooBigString = z.string().max(5).safeParse("too long string"); + expect(tooBigString.error!.issues[0].code).toBe("too_big"); + expect(tooBigString.error!.issues[0].message).toContain("belgi"); + expect(tooBigString.error!.issues[0].message).toContain("bo‘lishi kerak"); + + const tooSmallArray = z.array(z.string()).min(3).safeParse(["a", "b"]); + expect(tooSmallArray.error!.issues[0].code).toBe("too_small"); + expect(tooSmallArray.error!.issues[0].message).toContain("element"); + expect(tooSmallArray.error!.issues[0].message).toContain("bo‘lishi kerak"); + + const invalidFormatEndsWith = z.string().endsWith("xyz").safeParse("invalid-string"); + expect(invalidFormatEndsWith.error!.issues[0].code).toBe("invalid_format"); + expect(invalidFormatEndsWith.error!.issues[0].message).toContain('"xyz" bilan tugashi kerak'); + + const invalidFormatIncludes = z.string().includes("test").safeParse("invalid-string"); + expect(invalidFormatIncludes.error!.issues[0].code).toBe("invalid_format"); + expect(invalidFormatIncludes.error!.issues[0].message).toContain('"test" ni o‘z ichiga olishi kerak'); + + const invalidFormatEmail = z.string().email().safeParse("invalid-email"); + expect(invalidFormatEmail.error!.issues[0].code).toBe("invalid_format"); + expect(invalidFormatEmail.error!.issues[0].message).toContain("elektron pochta manzili"); + + const invalidFormatUrl = z.string().url().safeParse("invalid-url"); + expect(invalidFormatUrl.error!.issues[0].code).toBe("invalid_format"); + expect(invalidFormatUrl.error!.issues[0].message).toContain("URL"); + + const unrecognizedKeysMultiple = z + .object({ a: z.string(), b: z.number() }) + .strict() + .safeParse({ a: "a", b: 1, c: 2, d: 3 }); + expect(unrecognizedKeysMultiple.error!.issues[0].code).toBe("unrecognized_keys"); + expect(unrecognizedKeysMultiple.error!.issues[0].message).toContain("Noma’lum kalitlar"); + + const invalidElement = z.array(z.string()).safeParse([1, 2, 3]); + expect(invalidElement.error!.issues[0].code).toBe("invalid_type"); + expect(invalidElement.error!.issues[0].message).toContain("raqam"); + + const tooSmallMap = z + .map(z.string(), z.string()) + .min(3) + .safeParse(new Map([["a", "b"]])); + expect(tooSmallMap.error!.issues[0].code).toBe("too_small"); + expect(tooSmallMap.error!.issues[0].message).toContain("yozuv"); + expect(tooSmallMap.error!.issues[0].message).toContain("bo‘lishi kerak"); + + const tooBigMap = z + .map(z.string(), z.string()) + .max(2) + .safeParse( + new Map([ + ["a", "b"], + ["c", "d"], + ["e", "f"], + ]) + ); + expect(tooBigMap.error!.issues[0].code).toBe("too_big"); + expect(tooBigMap.error!.issues[0].message).toContain("yozuv"); + expect(tooBigMap.error!.issues[0].message).toContain("bo‘lishi kerak"); +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/record-constructor.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/record-constructor.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..91b5d5c0f660941e206277f47e4ec59155614adf --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/record-constructor.test.ts @@ -0,0 +1,125 @@ +import { expect, test } from "vitest"; +import * as z from "zod/v4"; + +test("record should parse objects with non-function constructor field", () => { + const schema = z.record(z.string(), z.any()); + + expect(() => schema.parse({ constructor: "string", key: "value" })).not.toThrow(); + + const result1 = schema.parse({ constructor: "string", key: "value" }); + expect(result1).toEqual({ constructor: "string", key: "value" }); + + expect(() => schema.parse({ constructor: 123, key: "value" })).not.toThrow(); + + const result2 = schema.parse({ constructor: 123, key: "value" }); + expect(result2).toEqual({ constructor: 123, key: "value" }); + + expect(() => schema.parse({ constructor: null, key: "value" })).not.toThrow(); + + const result3 = schema.parse({ constructor: null, key: "value" }); + expect(result3).toEqual({ constructor: null, key: "value" }); + + expect(() => schema.parse({ constructor: {}, key: "value" })).not.toThrow(); + + const result4 = schema.parse({ constructor: {}, key: "value" }); + expect(result4).toEqual({ constructor: {}, key: "value" }); + + expect(() => schema.parse({ constructor: [], key: "value" })).not.toThrow(); + + const result5 = schema.parse({ constructor: [], key: "value" }); + expect(result5).toEqual({ constructor: [], key: "value" }); + + expect(() => schema.parse({ constructor: true, key: "value" })).not.toThrow(); + + const result6 = schema.parse({ constructor: true, key: "value" }); + expect(result6).toEqual({ constructor: true, key: "value" }); +}); + +test("record should still work with normal objects", () => { + const schema = z.record(z.string(), z.string()); + + expect(() => schema.parse({ normalKey: "value" })).not.toThrow(); + + const result1 = schema.parse({ normalKey: "value" }); + expect(result1).toEqual({ normalKey: "value" }); + + expect(() => schema.parse({ key1: "value1", key2: "value2" })).not.toThrow(); + + const result2 = schema.parse({ key1: "value1", key2: "value2" }); + expect(result2).toEqual({ key1: "value1", key2: "value2" }); +}); + +test("record should validate values according to schema even with constructor field", () => { + const stringSchema = z.record(z.string(), z.string()); + + expect(() => stringSchema.parse({ constructor: "string", key: "value" })).not.toThrow(); + + expect(() => stringSchema.parse({ constructor: 123, key: "value" })).toThrow(); +}); + +test("record should work with different key types and constructor field", () => { + const enumSchema = z.record(z.enum(["constructor", "key"]), z.string()); + + expect(() => enumSchema.parse({ constructor: "value1", key: "value2" })).not.toThrow(); + + const result = enumSchema.parse({ constructor: "value1", key: "value2" }); + expect(result).toEqual({ constructor: "value1", key: "value2" }); +}); + +test("record should skip non-enumerable own properties", () => { + const schema = z.record(z.string(), z.string()); + + const input = { key: "value" }; + Object.defineProperty(input, "~standard", { + value: { validate: () => {}, vendor: "zod", version: 1 }, + enumerable: false, + writable: false, + configurable: false, + }); + + const result = schema.safeParse(input); + expect(result.success).toBe(true); + if (result.success) { + expect(result.data).toEqual({ key: "value" }); + expect("~standard" in result.data).toBe(false); + } +}); + +test("record fails on enumerable invalid values even when non-enumerable properties are present", () => { + const schema = z.record(z.string(), z.string()); + + const input = { key: "value", bad: 123 }; + Object.defineProperty(input, "hidden", { + value: "should be ignored", + enumerable: false, + }); + + const result = schema.safeParse(input); + expect(result.success).toBe(false); +}); + +test("record validates enumerable Symbol keys and skips non-enumerable Symbol keys", () => { + const enumerableSym = Symbol.for("included"); + const nonEnumerableSym = Symbol.for("hidden"); + const schema = z.record(z.symbol(), z.string()); + + const input: Record = { [enumerableSym]: "value" }; + Object.defineProperty(input, nonEnumerableSym, { + value: 123, + enumerable: false, + }); + + const result = schema.safeParse(input); + expect(result.success).toBe(true); + if (result.success) { + expect(result.data[enumerableSym]).toBe("value"); + expect(Object.prototype.hasOwnProperty.call(result.data, nonEnumerableSym)).toBe(false); + } +}); + +test("z.json() accepts z.toJSONSchema() output (issue #5714)", () => { + const schema = z.object({ name: z.string() }); + const jsonSchema = z.toJSONSchema(schema); + + expect(z.json().safeParse(jsonSchema).success).toBe(true); +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts b/gui/frontend/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts new file mode 100644 index 0000000000000000000000000000000000000000..c8d0e631be6b5f20b9b63b1d1fcc933bac63e8db --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/tests/recursive-tuples.test.ts @@ -0,0 +1,45 @@ +import { describe, expect, it } from "vitest"; +import * as z from "zod/v4"; + +describe("Recursive Tuples Regression #5089", () => { + it("creates recursive tuple without crash", () => { + expect(() => { + const y = z.lazy((): any => z.tuple([y, y]).or(z.string())); + }).not.toThrow(); + }); + + it("parses recursive tuple data correctly", () => { + const y = z.lazy((): any => z.tuple([y, y]).or(z.string())); + + // Base case + expect(y.parse("hello")).toBe("hello"); + + // Recursive cases + expect(() => y.parse(["a", "b"])).not.toThrow(); + expect(() => y.parse(["a", ["b", "c"]])).not.toThrow(); + }); + + it("matches #5089 expected behavior", () => { + // Exact code from the issue + expect(() => { + const y = z.lazy((): any => z.tuple([y, y]).or(z.string())); + y.parse(["a", ["b", "c"]]); + }).not.toThrow(); + }); + + it("handles workaround pattern", () => { + // Alternative pattern from issue discussion + expect(() => { + const y = z.lazy((): any => z.string().or(z.lazy(() => z.tuple([y, y])))); + y.parse(["a", ["b", "c"]]); + }).not.toThrow(); + }); + + it("recursive arrays still work (comparison)", () => { + const y = z.lazy((): any => z.array(y).or(z.string())); + + expect(y.parse("hello")).toBe("hello"); + expect(y.parse(["hello", "world"])).toEqual(["hello", "world"]); + expect(y.parse(["a", ["b", "c"]])).toEqual(["a", ["b", "c"]]); + }); +}); diff --git a/gui/frontend/node_modules/zod/src/v4/core/to-json-schema.ts b/gui/frontend/node_modules/zod/src/v4/core/to-json-schema.ts new file mode 100644 index 0000000000000000000000000000000000000000..c7c744049d425935408e995c5c23c77cac0daf9a --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/to-json-schema.ts @@ -0,0 +1,622 @@ +import type * as core from "../core/index.js"; +import type * as JSONSchema from "./json-schema.js"; +import { type $ZodRegistry, globalRegistry } from "./registries.js"; +import type * as schemas from "./schemas.js"; +import type { StandardJSONSchemaV1, StandardSchemaWithJSONProps } from "./standard-schema.js"; + +export type Processor = ( + schema: T, + ctx: ToJSONSchemaContext, + json: JSONSchema.BaseSchema, + params: ProcessParams +) => void; + +export interface JSONSchemaGeneratorParams { + processors: Record; + /** A registry used to look up metadata for each schema. Any schema with an `id` property will be extracted as a $def. + * @default globalRegistry */ + metadata?: $ZodRegistry>; + /** The JSON Schema version to target. + * - `"draft-2020-12"` — Default. JSON Schema Draft 2020-12 + * - `"draft-07"` — JSON Schema Draft 7 + * - `"draft-04"` — JSON Schema Draft 4 + * - `"openapi-3.0"` — OpenAPI 3.0 Schema Object */ + target?: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string) | undefined; + /** How to handle unrepresentable types. + * - `"throw"` — Default. Unrepresentable types throw an error + * - `"any"` — Unrepresentable types become `{}` */ + unrepresentable?: "throw" | "any"; + /** Arbitrary custom logic that can be used to modify the generated JSON Schema. */ + override?: (ctx: { + zodSchema: schemas.$ZodTypes; + jsonSchema: JSONSchema.BaseSchema; + path: (string | number)[]; + }) => void; + /** Whether to extract the `"input"` or `"output"` type. Relevant to transforms, defaults, coerced primitives, etc. + * - `"output"` — Default. Convert the output schema. + * - `"input"` — Convert the input schema. */ + io?: "input" | "output"; + cycles?: "ref" | "throw"; + reused?: "ref" | "inline"; + external?: + | { + registry: $ZodRegistry<{ id?: string | undefined }>; + uri?: ((id: string) => string) | undefined; + defs: Record; + } + | undefined; +} + +/** + * Parameters for the toJSONSchema function. + */ +export type ToJSONSchemaParams = Omit; + +/** + * Parameters for the toJSONSchema function when passing a registry. + */ +export interface RegistryToJSONSchemaParams extends ToJSONSchemaParams { + uri?: (id: string) => string; +} + +export interface ProcessParams { + schemaPath: schemas.$ZodType[]; + path: (string | number)[]; +} + +export interface Seen { + /** JSON Schema result for this Zod schema */ + schema: JSONSchema.BaseSchema; + /** A cached version of the schema that doesn't get overwritten during ref resolution */ + def?: JSONSchema.BaseSchema; + defId?: string | undefined; + /** Number of times this schema was encountered during traversal */ + count: number; + /** Cycle path */ + cycle?: (string | number)[] | undefined; + isParent?: boolean | undefined; + /** Schema to inherit JSON Schema properties from (set by processor for wrappers) */ + ref?: schemas.$ZodType | null; + /** JSON Schema property path for this schema */ + path?: (string | number)[] | undefined; +} + +export interface ToJSONSchemaContext { + processors: Record; + metadataRegistry: $ZodRegistry>; + target: "draft-04" | "draft-07" | "draft-2020-12" | "openapi-3.0" | ({} & string); + unrepresentable: "throw" | "any"; + override: (ctx: { + // must be schemas.$ZodType to prevent recursive type resolution error + zodSchema: schemas.$ZodType; + jsonSchema: JSONSchema.BaseSchema; + path: (string | number)[]; + }) => void; + io: "input" | "output"; + counter: number; + seen: Map; + cycles: "ref" | "throw"; + reused: "ref" | "inline"; + external?: + | { + registry: $ZodRegistry<{ id?: string | undefined }>; + uri?: ((id: string) => string) | undefined; + defs: Record; + } + | undefined; +} + +// function initializeContext(inputs: JSONSchemaGeneratorParams): ToJSONSchemaContext { +// return { +// processor: inputs.processor, +// metadataRegistry: inputs.metadata ?? globalRegistry, +// target: inputs.target ?? "draft-2020-12", +// unrepresentable: inputs.unrepresentable ?? "throw", +// }; +// } + +export function initializeContext(params: JSONSchemaGeneratorParams): ToJSONSchemaContext { + // Normalize target: convert old non-hyphenated versions to hyphenated versions + let target: ToJSONSchemaContext["target"] = params?.target ?? "draft-2020-12"; + if (target === "draft-4") target = "draft-04"; + if (target === "draft-7") target = "draft-07"; + + return { + processors: params.processors ?? {}, + metadataRegistry: params?.metadata ?? globalRegistry, + target, + unrepresentable: params?.unrepresentable ?? "throw", + override: (params?.override as any) ?? (() => {}), + io: params?.io ?? "output", + counter: 0, + seen: new Map(), + cycles: params?.cycles ?? "ref", + reused: params?.reused ?? "inline", + external: params?.external ?? undefined, + }; +} + +export function process( + schema: T, + ctx: ToJSONSchemaContext, + _params: ProcessParams = { path: [], schemaPath: [] } +): JSONSchema.BaseSchema { + const def = schema._zod.def as schemas.$ZodTypes["_zod"]["def"]; + + // check for schema in seens + const seen = ctx.seen.get(schema); + + if (seen) { + seen.count++; + + // check if cycle + const isCycle = _params.schemaPath.includes(schema); + if (isCycle) { + seen.cycle = _params.path; + } + + return seen.schema; + } + + // initialize + const result: Seen = { schema: {}, count: 1, cycle: undefined, path: _params.path }; + ctx.seen.set(schema, result); + + // custom method overrides default behavior + const overrideSchema = schema._zod.toJSONSchema?.(); + if (overrideSchema) { + result.schema = overrideSchema as any; + } else { + const params = { + ..._params, + schemaPath: [..._params.schemaPath, schema], + path: _params.path, + }; + + if (schema._zod.processJSONSchema) { + schema._zod.processJSONSchema(ctx, result.schema, params); + } else { + const _json = result.schema; + const processor = ctx.processors[def.type]; + if (!processor) { + throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`); + } + processor(schema, ctx, _json, params); + } + + const parent = schema._zod.parent as T; + + if (parent) { + // Also set ref if processor didn't (for inheritance) + if (!result.ref) result.ref = parent; + process(parent, ctx, params); + ctx.seen.get(parent)!.isParent = true; + } + } + + // metadata + const meta = ctx.metadataRegistry.get(schema); + if (meta) Object.assign(result.schema, meta); + + if (ctx.io === "input" && isTransforming(schema)) { + // examples/defaults only apply to output type of pipe + delete result.schema.examples; + delete result.schema.default; + } + + // set prefault as default + if (ctx.io === "input" && "_prefault" in result.schema) result.schema.default ??= result.schema._prefault; + delete result.schema._prefault; + + // pulling fresh from ctx.seen in case it was overwritten + const _result = ctx.seen.get(schema)!; + + return _result.schema; +} + +export function extractDefs( + ctx: ToJSONSchemaContext, + schema: T + // params: EmitParams +): void { + // iterate over seen map; + const root = ctx.seen.get(schema); + + if (!root) throw new Error("Unprocessed schema. This is a bug in Zod."); + + // Track ids to detect duplicates across different schemas + const idToSchema = new Map(); + for (const entry of ctx.seen.entries()) { + const id = ctx.metadataRegistry.get(entry[0])?.id; + if (id) { + const existing = idToSchema.get(id); + if (existing && existing !== entry[0]) { + throw new Error( + `Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.` + ); + } + idToSchema.set(id, entry[0]); + } + } + + // returns a ref to the schema + // defId will be empty if the ref points to an external schema (or #) + const makeURI = (entry: [schemas.$ZodType, Seen]): { ref: string; defId?: string } => { + // comparing the seen objects because sometimes + // multiple schemas map to the same seen object. + // e.g. lazy + + // external is configured + const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions"; + if (ctx.external) { + const externalId = ctx.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${ctx.counter++}`; + + // check if schema is in the external registry + const uriGenerator = ctx.external.uri ?? ((id: string) => id); + if (externalId) { + return { ref: uriGenerator(externalId) }; + } + + // otherwise, add to __shared + const id: string = entry[1].defId ?? (entry[1].schema.id as string) ?? `schema${ctx.counter++}`; + entry[1].defId = id; // set defId so it will be reused if needed + return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` }; + } + + if (entry[1] === root) { + return { ref: "#" }; + } + + // self-contained schema + const uriPrefix = `#`; + const defUriPrefix = `${uriPrefix}/${defsSegment}/`; + const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`; + return { defId, ref: defUriPrefix + defId }; + }; + + // stored cached version in `def` property + // remove all properties, set $ref + const extractToDef = (entry: [schemas.$ZodType, Seen]): void => { + // if the schema is already a reference, do not extract it + if (entry[1].schema.$ref) { + return; + } + const seen = entry[1]; + const { ref, defId } = makeURI(entry); + + seen.def = { ...seen.schema }; + // defId won't be set if the schema is a reference to an external schema + // or if the schema is the root schema + if (defId) seen.defId = defId; + // wipe away all properties except $ref + const schema = seen.schema; + for (const key in schema) { + delete schema[key]; + } + schema.$ref = ref; + }; + + // throw on cycles + + // break cycles + if (ctx.cycles === "throw") { + for (const entry of ctx.seen.entries()) { + const seen = entry[1]; + if (seen.cycle) { + throw new Error( + "Cycle detected: " + + `#/${seen.cycle?.join("/")}/` + + '\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.' + ); + } + } + } + + // extract schemas into $defs + for (const entry of ctx.seen.entries()) { + const seen = entry[1]; + + // convert root schema to # $ref + if (schema === entry[0]) { + extractToDef(entry); // this has special handling for the root schema + continue; + } + + // extract schemas that are in the external registry + if (ctx.external) { + const ext = ctx.external.registry.get(entry[0])?.id; + if (schema !== entry[0] && ext) { + extractToDef(entry); + continue; + } + } + + // extract schemas with `id` meta + const id = ctx.metadataRegistry.get(entry[0])?.id; + if (id) { + extractToDef(entry); + continue; + } + + // break cycles + if (seen.cycle) { + // any + extractToDef(entry); + continue; + } + + // extract reused schemas + if (seen.count > 1) { + if (ctx.reused === "ref") { + extractToDef(entry); + // biome-ignore lint: + continue; + } + } + } +} + +export function finalize( + ctx: ToJSONSchemaContext, + schema: T +): ZodStandardJSONSchemaPayload { + const root = ctx.seen.get(schema); + if (!root) throw new Error("Unprocessed schema. This is a bug in Zod."); + + // flatten refs - inherit properties from parent schemas + const flattenRef = (zodSchema: schemas.$ZodType) => { + const seen = ctx.seen.get(zodSchema)!; + + // already processed + if (seen.ref === null) return; + + const schema = seen.def ?? seen.schema; + const _cached = { ...schema }; + + const ref = seen.ref; + seen.ref = null; // prevent infinite recursion + + if (ref) { + flattenRef(ref); + + const refSeen = ctx.seen.get(ref)!; + const refSchema = refSeen.schema; + + // merge referenced schema into current + if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) { + // older drafts can't combine $ref with other properties + schema.allOf = schema.allOf ?? []; + schema.allOf.push(refSchema); + } else { + Object.assign(schema, refSchema); + } + // restore child's own properties (child wins) + Object.assign(schema, _cached); + + const isParentRef = zodSchema._zod.parent === ref; + + // For parent chain, child is a refinement - remove parent-only properties + if (isParentRef) { + for (const key in schema) { + if (key === "$ref" || key === "allOf") continue; + if (!(key in _cached)) { + delete schema[key]; + } + } + } + + // When ref was extracted to $defs, remove properties that match the definition + if (refSchema.$ref && refSeen.def) { + for (const key in schema) { + if (key === "$ref" || key === "allOf") continue; + if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) { + delete schema[key]; + } + } + } + } + + // If parent was extracted (has $ref), propagate $ref to this schema + // This handles cases like: readonly().meta({id}).describe() + // where processor sets ref to innerType but parent should be referenced + const parent = zodSchema._zod.parent; + if (parent && parent !== ref) { + // Ensure parent is processed first so its def has inherited properties + flattenRef(parent); + const parentSeen = ctx.seen.get(parent); + if (parentSeen?.schema.$ref) { + schema.$ref = parentSeen.schema.$ref; + // De-duplicate with parent's definition + if (parentSeen.def) { + for (const key in schema) { + if (key === "$ref" || key === "allOf") continue; + if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) { + delete schema[key]; + } + } + } + } + } + + // execute overrides + ctx.override({ + zodSchema: zodSchema as schemas.$ZodTypes, + jsonSchema: schema, + path: seen.path ?? [], + }); + }; + + for (const entry of [...ctx.seen.entries()].reverse()) { + flattenRef(entry[0]); + } + + const result: JSONSchema.BaseSchema = {}; + if (ctx.target === "draft-2020-12") { + result.$schema = "https://json-schema.org/draft/2020-12/schema"; + } else if (ctx.target === "draft-07") { + result.$schema = "http://json-schema.org/draft-07/schema#"; + } else if (ctx.target === "draft-04") { + result.$schema = "http://json-schema.org/draft-04/schema#"; + } else if (ctx.target === "openapi-3.0") { + // OpenAPI 3.0 schema objects should not include a $schema property + } else { + // Arbitrary string values are allowed but won't have a $schema property set + } + + if (ctx.external?.uri) { + const id = ctx.external.registry.get(schema)?.id; + if (!id) throw new Error("Schema is missing an `id` property"); + result.$id = ctx.external.uri(id); + } + + Object.assign(result, root.def ?? root.schema); + + // The `id` in `.meta()` is a Zod-specific registration tag used to extract + // schemas into $defs — it is not user-facing JSON Schema metadata. Strip it + // from the output body where it would otherwise leak. The id is preserved + // implicitly via the $defs key (and via $ref paths). + const rootMetaId = ctx.metadataRegistry.get(schema)?.id; + if (rootMetaId !== undefined && result.id === rootMetaId) delete result.id; + + // build defs object + const defs: JSONSchema.BaseSchema["$defs"] = ctx.external?.defs ?? {}; + for (const entry of ctx.seen.entries()) { + const seen = entry[1]; + if (seen.def && seen.defId) { + if (seen.def.id === seen.defId) delete seen.def.id; + defs[seen.defId] = seen.def; + } + } + + // set definitions in result + if (ctx.external) { + } else { + if (Object.keys(defs).length > 0) { + if (ctx.target === "draft-2020-12") { + result.$defs = defs; + } else { + result.definitions = defs; + } + } + } + + try { + // this "finalizes" this schema and ensures all cycles are removed + // each call to finalize() is functionally independent + // though the seen map is shared + const finalized = JSON.parse(JSON.stringify(result)); + Object.defineProperty(finalized, "~standard", { + value: { + ...schema["~standard"], + jsonSchema: { + input: createStandardJSONSchemaMethod(schema, "input", ctx.processors), + output: createStandardJSONSchemaMethod(schema, "output", ctx.processors), + }, + }, + enumerable: false, + writable: false, + }); + + return finalized; + } catch (_err) { + throw new Error("Error converting schema to JSON."); + } +} + +function isTransforming( + _schema: schemas.$ZodType, + _ctx?: { + seen: Set; + } +): boolean { + const ctx = _ctx ?? { seen: new Set() }; + + if (ctx.seen.has(_schema)) return false; + ctx.seen.add(_schema); + + const def = (_schema as schemas.$ZodTypes)._zod.def; + + if (def.type === "transform") return true; + + if (def.type === "array") return isTransforming(def.element, ctx); + if (def.type === "set") return isTransforming(def.valueType, ctx); + if (def.type === "lazy") return isTransforming(def.getter(), ctx); + + if ( + def.type === "promise" || + def.type === "optional" || + def.type === "nonoptional" || + def.type === "nullable" || + def.type === "readonly" || + def.type === "default" || + def.type === "prefault" + ) { + return isTransforming(def.innerType, ctx); + } + + if (def.type === "intersection") { + return isTransforming(def.left, ctx) || isTransforming(def.right, ctx); + } + if (def.type === "record" || def.type === "map") { + return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx); + } + if (def.type === "pipe") { + if (_schema._zod.traits.has("$ZodCodec")) return true; + return isTransforming(def.in, ctx) || isTransforming(def.out, ctx); + } + + if (def.type === "object") { + for (const key in def.shape) { + if (isTransforming(def.shape[key]!, ctx)) return true; + } + return false; + } + if (def.type === "union") { + for (const option of def.options) { + if (isTransforming(option, ctx)) return true; + } + return false; + } + if (def.type === "tuple") { + for (const item of def.items) { + if (isTransforming(item, ctx)) return true; + } + if (def.rest && isTransforming(def.rest, ctx)) return true; + return false; + } + + return false; +} + +export type ZodStandardSchemaWithJSON = StandardSchemaWithJSONProps, core.output>; +export interface ZodStandardJSONSchemaPayload extends JSONSchema.BaseSchema { + "~standard": ZodStandardSchemaWithJSON; +} + +/** + * Creates a toJSONSchema method for a schema instance. + * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing. + */ +export const createToJSONSchemaMethod = + (schema: T, processors: Record = {}) => + (params?: ToJSONSchemaParams): ZodStandardJSONSchemaPayload => { + const ctx = initializeContext({ ...params, processors }); + process(schema, ctx); + extractDefs(ctx, schema); + return finalize(ctx, schema); + }; + +/** + * Creates a toJSONSchema method for a schema instance. + * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing. + */ +type StandardJSONSchemaMethodParams = Parameters[0]; +export const createStandardJSONSchemaMethod = + (schema: T, io: "input" | "output", processors: Record = {}) => + (params?: StandardJSONSchemaMethodParams): JSONSchema.BaseSchema => { + const { libraryOptions, target } = params ?? {}; + const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors }); + process(schema, ctx); + extractDefs(ctx, schema); + return finalize(ctx, schema); + }; diff --git a/gui/frontend/node_modules/zod/src/v4/core/util.ts b/gui/frontend/node_modules/zod/src/v4/core/util.ts new file mode 100644 index 0000000000000000000000000000000000000000..8738df4ed090c9c700376f2f2e4e1fd92ec73560 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/util.ts @@ -0,0 +1,983 @@ +import type * as checks from "./checks.js"; +import { globalConfig } from "./core.js"; +import type { $ZodConfig } from "./core.js"; +import type * as errors from "./errors.js"; +import type * as schemas from "./schemas.js"; + +// json +export type JSONType = string | number | boolean | null | JSONType[] | { [key: string]: JSONType }; +export type JWTAlgorithm = + | "HS256" + | "HS384" + | "HS512" + | "RS256" + | "RS384" + | "RS512" + | "ES256" + | "ES384" + | "ES512" + | "PS256" + | "PS384" + | "PS512" + | "EdDSA" + | (string & {}); + +export type HashAlgorithm = "md5" | "sha1" | "sha256" | "sha384" | "sha512"; +export type HashEncoding = "hex" | "base64" | "base64url"; +export type HashFormat = `${HashAlgorithm}_${HashEncoding}`; +export type IPVersion = "v4" | "v6"; +export type MimeTypes = + | "application/json" + | "application/xml" + | "application/x-www-form-urlencoded" + | "application/javascript" + | "application/pdf" + | "application/zip" + | "application/vnd.ms-excel" + | "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" + | "application/msword" + | "application/vnd.openxmlformats-officedocument.wordprocessingml.document" + | "application/vnd.ms-powerpoint" + | "application/vnd.openxmlformats-officedocument.presentationml.presentation" + | "application/octet-stream" + | "application/graphql" + | "text/html" + | "text/plain" + | "text/css" + | "text/javascript" + | "text/csv" + | "image/png" + | "image/jpeg" + | "image/gif" + | "image/svg+xml" + | "image/webp" + | "audio/mpeg" + | "audio/ogg" + | "audio/wav" + | "audio/webm" + | "video/mp4" + | "video/webm" + | "video/ogg" + | "font/woff" + | "font/woff2" + | "font/ttf" + | "font/otf" + | "multipart/form-data" + | (string & {}); +export type ParsedTypes = + | "string" + | "number" + | "bigint" + | "boolean" + | "symbol" + | "undefined" + | "object" + | "function" + | "file" + | "date" + | "array" + | "map" + | "set" + | "nan" + | "null" + | "promise"; + +// utils +export type AssertEqual = (() => V extends T ? 1 : 2) extends () => V extends U ? 1 : 2 ? true : false; +export type AssertNotEqual = (() => V extends T ? 1 : 2) extends () => V extends U ? 1 : 2 ? false : true; +export type AssertExtends = T extends U ? T : never; +export type IsAny = 0 extends 1 & T ? true : false; +export type Omit = Pick>; +export type OmitKeys = Pick>; +export type MakePartial = Omit & InexactPartial>; +export type MakeRequired = Omit & Required>; + +export type Exactly = T & Record, never>; +export type NoUndefined = T extends undefined ? never : T; +export type Whatever = {} | undefined | null; +export type LoosePartial = InexactPartial & { + [k: string]: unknown; +}; +export type Mask = { [K in Keys]?: true }; +export type Writeable = { -readonly [P in keyof T]: T[P] } & {}; +export type InexactPartial = { + [P in keyof T]?: T[P] | undefined; +}; +export type EmptyObject = Record; +export type BuiltIn = + | (((...args: any[]) => any) | (new (...args: any[]) => any)) + | { readonly [Symbol.toStringTag]: string } + | Date + | Error + | Generator + | Promise + | RegExp; +export type MakeReadonly = T extends Map + ? ReadonlyMap + : T extends Set + ? ReadonlySet + : T extends [infer Head, ...infer Tail] + ? readonly [Head, ...Tail] + : T extends Array + ? ReadonlyArray + : T extends BuiltIn + ? T + : Readonly; +export type SomeObject = Record; +export type Identity = T; +export type Flatten = Identity<{ [k in keyof T]: T[k] }>; +export type Mapped = { [k in keyof T]: T[k] }; +export type Prettify = { + // @ts-ignore + [K in keyof T]: T[K]; +} & {}; + +export type NoNeverKeys = { + [k in keyof T]: [T[k]] extends [never] ? never : k; +}[keyof T]; +export type NoNever = Identity<{ + [k in NoNeverKeys]: k extends keyof T ? T[k] : never; +}>; +export type Extend = Flatten< + // fast path when there is no keys overlap + keyof A & keyof B extends never + ? A & B + : { + [K in keyof A as K extends keyof B ? never : K]: A[K]; + } & { + [K in keyof B]: B[K]; + } +>; + +export type TupleItems = ReadonlyArray; +export type AnyFunc = (...args: any[]) => any; +export type IsProp = T[K] extends AnyFunc ? never : K; +export type MaybeAsync = T | Promise; +export type KeyOf = keyof OmitIndexSignature; +export type OmitIndexSignature = { + [K in keyof T as string extends K ? never : K extends string ? K : never]: T[K]; +}; +export type ExtractIndexSignature = { + [K in keyof T as string extends K ? K : K extends string ? never : K]: T[K]; +}; +export type Keys = keyof OmitIndexSignature; + +export type SchemaClass = { + new (def: T["_zod"]["def"]): T; +}; +export type EnumValue = string | number; // | bigint | boolean | symbol; +export type EnumLike = Readonly>; +export type ToEnum = Flatten<{ [k in T]: k }>; +export type KeysEnum = ToEnum>; +export type KeysArray = Flatten<(keyof T & string)[]>; +export type Literal = string | number | bigint | boolean | null | undefined; +export type LiteralArray = Array; +export type Primitive = string | number | symbol | bigint | boolean | null | undefined; +export type PrimitiveArray = Array; +export type HasSize = { size: number }; +export type HasLength = { length: number }; // string | Array | Set | File; +export type Numeric = number | bigint | Date; +export type SafeParseResult = SafeParseSuccess | SafeParseError; +export type SafeParseSuccess = { success: true; data: T; error?: never }; +export type SafeParseError = { + success: false; + data?: never; + error: errors.$ZodError; +}; + +export type PropValues = Record>; +export type PrimitiveSet = Set; + +// functions +export function assertEqual(val: AssertEqual): AssertEqual { + return val; +} + +export function assertNotEqual(val: AssertNotEqual): AssertNotEqual { + return val; +} + +export function assertIs(_arg: T): void {} + +export function assertNever(_x: never): never { + throw new Error("Unexpected value in exhaustive check"); +} +export function assert(_: any): asserts _ is T {} + +export function getEnumValues(entries: EnumLike): EnumValue[] { + const numericValues = Object.values(entries).filter((v) => typeof v === "number"); + const values = Object.entries(entries) + .filter(([k, _]) => numericValues.indexOf(+k) === -1) + .map(([_, v]) => v); + return values; +} + +export function joinValues(array: T, separator = "|"): string { + return array.map((val) => stringifyPrimitive(val)).join(separator); +} + +export function jsonStringifyReplacer(_: string, value: any): any { + if (typeof value === "bigint") return value.toString(); + return value; +} + +export function cached(getter: () => T): { value: T } { + const set = false; + return { + get value() { + if (!set) { + const value = getter(); + Object.defineProperty(this, "value", { value }); + return value; + } + throw new Error("cached value already set"); + }, + }; +} + +export function nullish(input: any): boolean { + return input === null || input === undefined; +} + +export function cleanRegex(source: string): string { + const start = source.startsWith("^") ? 1 : 0; + const end = source.endsWith("$") ? source.length - 1 : source.length; + return source.slice(start, end); +} + +export function floatSafeRemainder(val: number, step: number): number { + const ratio = val / step; + const roundedRatio = Math.round(ratio); + // Use a relative epsilon scaled to the magnitude of the result + const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1); + if (Math.abs(ratio - roundedRatio) < tolerance) return 0; + return ratio - roundedRatio; +} + +const EVALUATING = /* @__PURE__*/ Symbol("evaluating"); + +export function defineLazy(object: T, key: K, getter: () => T[K]): void { + let value: T[K] | typeof EVALUATING | undefined = undefined; + Object.defineProperty(object, key, { + get() { + if (value === EVALUATING) { + // Circular reference detected, return undefined to break the cycle + return undefined as T[K]; + } + if (value === undefined) { + value = EVALUATING; + value = getter(); + } + return value; + }, + set(v) { + Object.defineProperty(object, key, { + value: v, + // configurable: true, + }); + // object[key] = v; + }, + configurable: true, + }); +} + +export function objectClone(obj: object) { + return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj)); +} + +export function assignProp( + target: T, + prop: K, + value: K extends keyof T ? T[K] : any +): void { + Object.defineProperty(target, prop, { + value, + writable: true, + enumerable: true, + configurable: true, + }); +} + +export function mergeDefs(...defs: Record[]): any { + const mergedDescriptors: Record = {}; + + for (const def of defs) { + const descriptors = Object.getOwnPropertyDescriptors(def); + Object.assign(mergedDescriptors, descriptors); + } + + return Object.defineProperties({}, mergedDescriptors); +} + +export function cloneDef(schema: schemas.$ZodType): any { + return mergeDefs(schema._zod.def); +} + +export function getElementAtPath(obj: any, path: (string | number)[] | null | undefined): any { + if (!path) return obj; + return path.reduce((acc, key) => acc?.[key], obj); +} + +export function promiseAllObject(promisesObj: T): Promise<{ [k in keyof T]: Awaited }> { + const keys = Object.keys(promisesObj); + const promises = keys.map((key) => (promisesObj as any)[key]); + + return Promise.all(promises).then((results) => { + const resolvedObj: any = {}; + for (let i = 0; i < keys.length; i++) { + resolvedObj[keys[i]!] = results[i]; + } + return resolvedObj; + }); +} + +export function randomString(length = 10): string { + const chars = "abcdefghijklmnopqrstuvwxyz"; + let str = ""; + for (let i = 0; i < length; i++) { + str += chars[Math.floor(Math.random() * chars.length)]; + } + return str; +} + +export function esc(str: string): string { + return JSON.stringify(str); +} + +export function slugify(input: string): string { + return input + .toLowerCase() + .trim() + .replace(/[^\w\s-]/g, "") + .replace(/[\s_-]+/g, "-") + .replace(/^-+|-+$/g, ""); +} + +export const captureStackTrace: (targetObject: object, constructorOpt?: Function) => void = ( + "captureStackTrace" in Error ? Error.captureStackTrace : (..._args: any[]) => {} +) as any; + +export function isObject(data: any): data is Record { + return typeof data === "object" && data !== null && !Array.isArray(data); +} + +export const allowsEval: { value: boolean } = /* @__PURE__*/ cached(() => { + // Skip the probe under `jitless`: strict CSPs report the caught `new Function` + // as a `securitypolicyviolation` even though the throw is swallowed. + if (globalConfig.jitless) { + return false; + } + + // @ts-ignore + if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) { + return false; + } + + try { + const F = Function; + new F(""); + return true; + } catch (_) { + return false; + } +}); + +export function isPlainObject(o: any): o is Record { + if (isObject(o) === false) return false; + + // modified constructor + const ctor = o.constructor; + if (ctor === undefined) return true; + + if (typeof ctor !== "function") return true; + + // modified prototype + const prot = ctor.prototype; + if (isObject(prot) === false) return false; + + // ctor doesn't have static `isPrototypeOf` + if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) { + return false; + } + + return true; +} + +export function shallowClone(o: any): any { + if (isPlainObject(o)) return { ...o }; + if (Array.isArray(o)) return [...o]; + if (o instanceof Map) return new Map(o); + if (o instanceof Set) return new Set(o); + return o; +} + +export function numKeys(data: any): number { + let keyCount = 0; + for (const key in data) { + if (Object.prototype.hasOwnProperty.call(data, key)) { + keyCount++; + } + } + return keyCount; +} + +export const getParsedType = (data: any): ParsedTypes => { + const t = typeof data; + + switch (t) { + case "undefined": + return "undefined"; + + case "string": + return "string"; + + case "number": + return Number.isNaN(data) ? "nan" : "number"; + + case "boolean": + return "boolean"; + + case "function": + return "function"; + + case "bigint": + return "bigint"; + + case "symbol": + return "symbol"; + + case "object": + if (Array.isArray(data)) { + return "array"; + } + if (data === null) { + return "null"; + } + if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { + return "promise"; + } + if (typeof Map !== "undefined" && data instanceof Map) { + return "map"; + } + if (typeof Set !== "undefined" && data instanceof Set) { + return "set"; + } + if (typeof Date !== "undefined" && data instanceof Date) { + return "date"; + } + // @ts-ignore + if (typeof File !== "undefined" && data instanceof File) { + return "file"; + } + return "object"; + + default: + throw new Error(`Unknown data type: ${t}`); + } +}; + +export const propertyKeyTypes: Set = /* @__PURE__*/ new Set(["string", "number", "symbol"]); +export const primitiveTypes: Set = /* @__PURE__*/ new Set([ + "string", + "number", + "bigint", + "boolean", + "symbol", + "undefined", +]); +export function escapeRegex(str: string): string { + return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); +} + +// zod-specific utils +export function clone(inst: T, def?: T["_zod"]["def"], params?: { parent: boolean }): T { + const cl = new inst._zod.constr(def ?? inst._zod.def); + if (!def || params?.parent) cl._zod.parent = inst; + return cl as any; +} + +export type EmptyToNever = keyof T extends never ? never : T; + +export type Normalize = T extends undefined + ? never + : T extends Record + ? Flatten< + { + [k in keyof Omit]: T[k]; + } & ("error" extends keyof T + ? { + error?: Exclude; + // path?: PropertyKey[] | undefined; + // message?: string | undefined; + } + : unknown) + > + : never; + +export function normalizeParams(_params: T): Normalize { + const params: any = _params; + + if (!params) return {} as any; + if (typeof params === "string") return { error: () => params } as any; + if (params?.message !== undefined) { + if (params?.error !== undefined) throw new Error("Cannot specify both `message` and `error` params"); + params.error = params.message; + } + delete params.message; + if (typeof params.error === "string") return { ...params, error: () => params.error } as any; + return params; +} + +export function createTransparentProxy(getter: () => T): T { + let target: T; + return new Proxy( + {}, + { + get(_, prop, receiver) { + target ??= getter(); + return Reflect.get(target, prop, receiver); + }, + set(_, prop, value, receiver) { + target ??= getter(); + return Reflect.set(target, prop, value, receiver); + }, + has(_, prop) { + target ??= getter(); + return Reflect.has(target, prop); + }, + deleteProperty(_, prop) { + target ??= getter(); + return Reflect.deleteProperty(target, prop); + }, + ownKeys(_) { + target ??= getter(); + return Reflect.ownKeys(target); + }, + getOwnPropertyDescriptor(_, prop) { + target ??= getter(); + return Reflect.getOwnPropertyDescriptor(target, prop); + }, + defineProperty(_, prop, descriptor) { + target ??= getter(); + return Reflect.defineProperty(target, prop, descriptor); + }, + } + ) as T; +} + +export function stringifyPrimitive(value: any): string { + if (typeof value === "bigint") return value.toString() + "n"; + if (typeof value === "string") return `"${value}"`; + return `${value}`; +} + +export function optionalKeys(shape: schemas.$ZodShape): string[] { + return Object.keys(shape).filter((k) => { + return shape[k]!._zod.optin === "optional" && shape[k]!._zod.optout === "optional"; + }); +} + +export type CleanKey = T extends `?${infer K}` ? K : T extends `${infer K}?` ? K : T; +export type ToCleanMap = { + [k in keyof T]: k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k; +}; +export type FromCleanMap = { + [k in keyof T as k extends `?${infer K}` ? K : k extends `${infer K}?` ? K : k]: k; +}; + +export const NUMBER_FORMAT_RANGES: Record = { + safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER], + int32: [-2147483648, 2147483647], + uint32: [0, 4294967295], + float32: [-3.4028234663852886e38, 3.4028234663852886e38], + float64: [-Number.MAX_VALUE, Number.MAX_VALUE], +}; + +export const BIGINT_FORMAT_RANGES: Record = { + int64: [/* @__PURE__*/ BigInt("-9223372036854775808"), /* @__PURE__*/ BigInt("9223372036854775807")], + uint64: [/* @__PURE__*/ BigInt(0), /* @__PURE__*/ BigInt("18446744073709551615")], +}; + +export function pick(schema: schemas.$ZodObject, mask: Record): any { + const currDef = schema._zod.def; + + const checks = currDef.checks; + const hasChecks = checks && checks.length > 0; + if (hasChecks) { + throw new Error(".pick() cannot be used on object schemas containing refinements"); + } + + const def = mergeDefs(schema._zod.def, { + get shape() { + const newShape: Writeable = {}; + for (const key in mask) { + if (!(key in currDef.shape)) { + throw new Error(`Unrecognized key: "${key}"`); + } + if (!mask[key]) continue; + newShape[key] = currDef.shape[key]!; + } + + assignProp(this, "shape", newShape); // self-caching + return newShape; + }, + checks: [], + }); + + return clone(schema, def) as any; +} + +export function omit(schema: schemas.$ZodObject, mask: object): any { + const currDef = schema._zod.def; + + const checks = currDef.checks; + const hasChecks = checks && checks.length > 0; + if (hasChecks) { + throw new Error(".omit() cannot be used on object schemas containing refinements"); + } + + const def = mergeDefs(schema._zod.def, { + get shape() { + const newShape: Writeable = { ...schema._zod.def.shape }; + for (const key in mask) { + if (!(key in currDef.shape)) { + throw new Error(`Unrecognized key: "${key}"`); + } + if (!(mask as any)[key]) continue; + + delete newShape[key]; + } + assignProp(this, "shape", newShape); // self-caching + return newShape; + }, + checks: [], + }); + + return clone(schema, def); +} + +export function extend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any { + if (!isPlainObject(shape)) { + throw new Error("Invalid input to extend: expected a plain object"); + } + + const checks = schema._zod.def.checks; + const hasChecks = checks && checks.length > 0; + if (hasChecks) { + // Only throw if new shape overlaps with existing shape + // Use getOwnPropertyDescriptor to check key existence without accessing values + const existingShape = schema._zod.def.shape; + for (const key in shape) { + if (Object.getOwnPropertyDescriptor(existingShape, key) !== undefined) { + throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead."); + } + } + } + + const def = mergeDefs(schema._zod.def, { + get shape() { + const _shape = { ...schema._zod.def.shape, ...shape }; + assignProp(this, "shape", _shape); // self-caching + return _shape; + }, + }); + return clone(schema, def) as any; +} + +export function safeExtend(schema: schemas.$ZodObject, shape: schemas.$ZodShape): any { + if (!isPlainObject(shape)) { + throw new Error("Invalid input to safeExtend: expected a plain object"); + } + const def = mergeDefs(schema._zod.def, { + get shape() { + const _shape = { ...schema._zod.def.shape, ...shape }; + assignProp(this, "shape", _shape); // self-caching + return _shape; + }, + }); + return clone(schema, def) as any; +} + +export function merge(a: schemas.$ZodObject, b: schemas.$ZodObject): any { + if (a._zod.def.checks?.length) { + throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead."); + } + const def = mergeDefs(a._zod.def, { + get shape() { + const _shape = { ...a._zod.def.shape, ...b._zod.def.shape }; + assignProp(this, "shape", _shape); // self-caching + return _shape; + }, + get catchall() { + return b._zod.def.catchall; + }, + checks: b._zod.def.checks ?? [], + }); + + return clone(a, def) as any; +} + +export function partial( + Class: SchemaClass | null, + schema: schemas.$ZodObject, + mask: object | undefined +): any { + const currDef = schema._zod.def; + const checks = currDef.checks; + const hasChecks = checks && checks.length > 0; + if (hasChecks) { + throw new Error(".partial() cannot be used on object schemas containing refinements"); + } + + const def = mergeDefs(schema._zod.def, { + get shape() { + const oldShape = schema._zod.def.shape; + const shape: Writeable = { ...oldShape }; + + if (mask) { + for (const key in mask) { + if (!(key in oldShape)) { + throw new Error(`Unrecognized key: "${key}"`); + } + if (!(mask as any)[key]) continue; + // if (oldShape[key]!._zod.optin === "optional") continue; + shape[key] = Class + ? new Class({ + type: "optional", + innerType: oldShape[key]!, + }) + : oldShape[key]!; + } + } else { + for (const key in oldShape) { + // if (oldShape[key]!._zod.optin === "optional") continue; + shape[key] = Class + ? new Class({ + type: "optional", + innerType: oldShape[key]!, + }) + : oldShape[key]!; + } + } + + assignProp(this, "shape", shape); // self-caching + return shape; + }, + checks: [], + }); + + return clone(schema, def) as any; +} + +export function required( + Class: SchemaClass, + schema: schemas.$ZodObject, + mask: object | undefined +): any { + const def = mergeDefs(schema._zod.def, { + get shape() { + const oldShape = schema._zod.def.shape; + const shape: Writeable = { ...oldShape }; + + if (mask) { + for (const key in mask) { + if (!(key in shape)) { + throw new Error(`Unrecognized key: "${key}"`); + } + if (!(mask as any)[key]) continue; + // overwrite with non-optional + shape[key] = new Class({ + type: "nonoptional", + innerType: oldShape[key]!, + }); + } + } else { + for (const key in oldShape) { + // overwrite with non-optional + shape[key] = new Class({ + type: "nonoptional", + innerType: oldShape[key]!, + }); + } + } + + assignProp(this, "shape", shape); // self-caching + return shape; + }, + }); + + return clone(schema, def) as any; +} + +export type Constructor = new (...args: Def) => T; + +// invalid_type | too_big | too_small | invalid_format | not_multiple_of | unrecognized_keys | invalid_union | invalid_key | invalid_element | invalid_value | custom +export function aborted(x: schemas.ParsePayload, startIndex = 0): boolean { + if (x.aborted === true) return true; + for (let i = startIndex; i < x.issues.length; i++) { + if (x.issues[i]?.continue !== true) { + return true; + } + } + return false; +} + +// Checks for explicit abort (continue === false), as opposed to implicit abort (continue === undefined). +// Used to respect `abort: true` in .refine() even for checks that have a `when` function. +export function explicitlyAborted(x: schemas.ParsePayload, startIndex = 0): boolean { + if (x.aborted === true) return true; + for (let i = startIndex; i < x.issues.length; i++) { + if (x.issues[i]?.continue === false) { + return true; + } + } + return false; +} + +export function prefixIssues(path: PropertyKey, issues: errors.$ZodRawIssue[]): errors.$ZodRawIssue[] { + return issues.map((iss) => { + (iss as any).path ??= []; + (iss as any).path.unshift(path); + return iss; + }); +} + +export function unwrapMessage(message: string | { message: string } | undefined | null): string | undefined { + return typeof message === "string" ? message : message?.message; +} + +export function finalizeIssue( + iss: errors.$ZodRawIssue, + ctx: schemas.ParseContextInternal | undefined, + config: $ZodConfig +): errors.$ZodIssue { + const message = iss.message + ? iss.message + : (unwrapMessage(iss.inst?._zod.def?.error?.(iss as never)) ?? + unwrapMessage(ctx?.error?.(iss as never)) ?? + unwrapMessage(config.customError?.(iss)) ?? + unwrapMessage(config.localeError?.(iss)) ?? + "Invalid input"); + + const { inst: _inst, continue: _continue, input: _input, ...rest } = iss as any; + rest.path ??= []; + rest.message = message; + if (ctx?.reportInput) { + rest.input = _input; + } + return rest; +} + +export function getSizableOrigin(input: any): "set" | "map" | "file" | "unknown" { + if (input instanceof Set) return "set"; + if (input instanceof Map) return "map"; + // @ts-ignore + if (input instanceof File) return "file"; + return "unknown"; +} + +export function getLengthableOrigin(input: any): "array" | "string" | "unknown" { + if (Array.isArray(input)) return "array"; + if (typeof input === "string") return "string"; + return "unknown"; +} + +export function parsedType(data: unknown): errors.$ZodInvalidTypeExpected { + const t = typeof data; + switch (t) { + case "number": { + return Number.isNaN(data) ? "nan" : "number"; + } + case "object": { + if (data === null) { + return "null"; + } + if (Array.isArray(data)) { + return "array"; + } + + const obj = data as object; + if (obj && Object.getPrototypeOf(obj) !== Object.prototype && "constructor" in obj && obj.constructor) { + return (obj.constructor as { name: string }).name; + } + } + } + return t; +} + +////////// REFINES ////////// +export function issue(_iss: string, input: any, inst: any): errors.$ZodRawIssue; +export function issue(_iss: errors.$ZodRawIssue): errors.$ZodRawIssue; +export function issue(...args: [string | errors.$ZodRawIssue, any?, any?]): errors.$ZodRawIssue { + const [iss, input, inst] = args; + if (typeof iss === "string") { + return { + message: iss, + code: "custom", + input, + inst, + }; + } + + return { ...iss }; +} + +export function cleanEnum(obj: Record): EnumValue[] { + return Object.entries(obj) + .filter(([k, _]) => { + // return true if NaN, meaning it's not a number, thus a string key + return Number.isNaN(Number.parseInt(k, 10)); + }) + .map((el) => el[1]); +} + +// Codec utility functions +export function base64ToUint8Array(base64: string): InstanceType { + const binaryString = atob(base64); + const bytes = new Uint8Array(binaryString.length); + for (let i = 0; i < binaryString.length; i++) { + bytes[i] = binaryString.charCodeAt(i); + } + return bytes; +} + +export function uint8ArrayToBase64(bytes: Uint8Array): string { + let binaryString = ""; + for (let i = 0; i < bytes.length; i++) { + binaryString += String.fromCharCode(bytes[i]); + } + return btoa(binaryString); +} + +export function base64urlToUint8Array(base64url: string): InstanceType { + const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/"); + const padding = "=".repeat((4 - (base64.length % 4)) % 4); + return base64ToUint8Array(base64 + padding); +} + +export function uint8ArrayToBase64url(bytes: Uint8Array): string { + return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""); +} + +export function hexToUint8Array(hex: string): InstanceType { + const cleanHex = hex.replace(/^0x/, ""); + if (cleanHex.length % 2 !== 0) { + throw new Error("Invalid hex string length"); + } + const bytes = new Uint8Array(cleanHex.length / 2); + for (let i = 0; i < cleanHex.length; i += 2) { + bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16); + } + return bytes; +} + +export function uint8ArrayToHex(bytes: Uint8Array): string { + return Array.from(bytes) + .map((b) => b.toString(16).padStart(2, "0")) + .join(""); +} + +// instanceof +export abstract class Class { + constructor(..._args: any[]) {} +} diff --git a/gui/frontend/node_modules/zod/src/v4/core/versions.ts b/gui/frontend/node_modules/zod/src/v4/core/versions.ts new file mode 100644 index 0000000000000000000000000000000000000000..49bb43ffd07fd6ef8227e37354f120d163fd5c93 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/versions.ts @@ -0,0 +1,5 @@ +export const version = { + major: 4, + minor: 4, + patch: 3 as number, +} as const; diff --git a/gui/frontend/node_modules/zod/src/v4/core/zsf.ts b/gui/frontend/node_modules/zod/src/v4/core/zsf.ts new file mode 100644 index 0000000000000000000000000000000000000000..8966cf646b2c7bc3960d9047d1b07d00e91eff41 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/core/zsf.ts @@ -0,0 +1,323 @@ +/////////////////////////////////////////////////// +//////////////// TYPES /////////////////// +/////////////////////////////////////////////////// + +export interface $ZSF { + $zsf: { version: number }; + type: string; + // default value if not defined + default: unknown; + // fallback value if validation fails + fallback: unknown; +} + +export interface $ZSFString extends $ZSF { + type: "string"; + min_length?: number; + max_length?: number; + pattern?: string; +} + +export type NumberTypes = "float32" | "int32" | "uint32" | "float64" | "int64" | "uint64" | "bigint" | "bigdecimal"; + +export interface $ZSFNumber extends $ZSF { + type: "number"; + format?: NumberTypes; + minimum?: number; + maximum?: number; + multiple_of?: number; +} + +export interface $ZSFBoolean extends $ZSF { + type: "boolean"; +} + +export interface $ZSFNull extends $ZSF { + type: "null"; +} + +export interface $ZSFUndefined extends $ZSF { + type: "undefined"; +} + +export interface $ZSFOptional extends $ZSF { + type: "optional"; + inner: T; +} + +export interface $ZSFNever extends $ZSF { + type: "never"; +} + +export interface $ZSFAny extends $ZSF { + type: "any"; +} + +/** Supports */ +export interface $ZSFEnum extends $ZSF { + type: "enum"; + elements: Elements; +} + +export interface $ZSFArray extends $ZSF { + type: "array"; + prefixItems: PrefixItems; + items: Items; +} + +// type $ZSFObjectProperties = { [k: string]: $ZSF }; +type $ZSFObjectProperties = Array<{ + key: string; + value: $ZSF; + format?: "literal" | "pattern"; + ordering?: number; +}>; +export interface $ZSFObject extends $ZSF { + type: "object"; + properties: Properties; +} + +// export interface $ZSFTuple< +// Items extends $ZSF[] = $ZSF[], +// Rest extends $ZSF = $ZSF, +// > extends $ZSF { +// type: "array"; +// items: Items; +// rest: Rest; +// } + +/** Supports arbitrary literal values */ +export interface $ZSFLiteral extends $ZSF { + type: "literal"; + schema: T; + value: unknown; +} + +export interface $ZSFUnion extends $ZSF { + type: "union"; + elements: Elements; +} + +export interface $ZSFIntersection extends $ZSF { + type: "intersection"; + elements: $ZSF[]; +} + +export interface $ZSFMap extends $ZSF { + type: "map"; + keys: K; + values: V; +} + +export interface $ZSFConditional extends $ZSF { + type: "conditional"; + if: If; + then: Then; + else: Else; +} + +///////////////////////////////////////////////// +//////////////// CHECKS //////////////// +///////////////////////////////////////////////// + +// export interface $ZSFCheckRegex { +// check: "regex"; +// pattern: string; +// } + +// export interface $ZSFCheckEmail { +// check: "email"; +// } + +// export interface $ZSFCheckURL { +// check: "url"; +// } + +// export interface $ZSFCheckEmoji { +// check: "emoji"; +// } + +// export interface $ZSFCheckUUID { +// check: "uuid"; +// } + +// export interface $ZSFCheckUUIDv4 { +// check: "uuidv4"; +// } + +// export interface $ZSFCheckUUIDv6 { +// check: "uuidv6"; +// } + +// export interface $ZSFCheckNanoid { +// check: "nanoid"; +// } + +// export interface $ZSFCheckGUID { +// check: "guid"; +// } + +// export interface $ZSFCheckCUID { +// check: "cuid"; +// } + +// export interface $ZSFCheckCUID2 { +// check: "cuid2"; +// } + +// export interface $ZSFCheckULID { +// check: "ulid"; +// } + +// export interface $ZSFCheckXID { +// check: "xid"; +// } + +// export interface $ZSFCheckKSUID { +// check: "ksuid"; +// } + +// export interface $ZSFCheckISODateTime { +// check: "datetime"; +// precision?: number; +// local?: boolean; +// } + +// export interface $ZSFCheckISODate { +// check: "date"; +// } + +// export interface $ZSFCheckISOTime { +// check: "time"; +// precision?: number; +// local?: boolean; +// } + +// export interface $ZSFCheckDuration { +// check: "duration"; +// } + +// export interface $ZSFCheckIP { +// check: "ip"; +// } + +// export interface $ZSFCheckIPv4 { +// check: "ipv4"; +// } + +// export interface $ZSFCheckIPv6 { +// check: "ipv6"; +// } + +// export interface $ZSFCheckBase64 { +// check: "base64"; +// } + +// export interface $ZSFCheckJWT { +// check: "jwt"; +// } + +// export interface $ZSFCheckJSONString { +// check: "json_string"; +// } + +// export interface $ZSFCheckPrefix { +// check: "prefix"; +// prefix: string; +// } + +// export interface $ZSFCheckSuffix { +// check: "suffix"; +// suffix: string; +// } + +// export interface $ZSFCheckIncludes { +// check: "includes"; +// includes: string; +// } + +// export interface $ZSFCheckMinSize { +// check: "min_size"; +// minimum: number; +// } + +// export interface $ZSFCheckMaxSize { +// check: "max_size"; +// maximum: number; +// } + +// export interface $ZSFCheckSizeEquals { +// check: "size_equals"; +// size: number; +// } + +// export interface $ZSFCheckLessThan { +// check: "less_than"; +// maximum: number | bigint | Date; +// } + +// export interface $ZSFCheckLessThanOrEqual { +// check: "less_than_or_equal"; +// maximum: number | bigint | Date; +// } + +// export interface $ZSFCheckGreaterThan { +// check: "greater_than"; +// minimum: number | bigint | Date; +// } + +// export interface $ZSFCheckGreaterThanOrEqual { +// check: "greater_than_or_equal"; +// minimum: number | bigint | Date; +// } + +// export interface $ZSFCheckEquals { +// check: "equals"; +// value: number | bigint | Date; +// } + +// export interface $ZSFCheckMultipleOf { +// check: "multiple_of"; +// multipleOf: number; +// } + +// export type $ZSFStringFormatChecks = +// | $ZSFCheckRegex +// | $ZSFCheckEmail +// | $ZSFCheckURL +// | $ZSFCheckEmoji +// | $ZSFCheckUUID +// | $ZSFCheckUUIDv4 +// | $ZSFCheckUUIDv6 +// | $ZSFCheckNanoid +// | $ZSFCheckGUID +// | $ZSFCheckCUID +// | $ZSFCheckCUID2 +// | $ZSFCheckULID +// | $ZSFCheckXID +// | $ZSFCheckKSUID +// | $ZSFCheckISODateTime +// | $ZSFCheckISODate +// | $ZSFCheckISOTime +// | $ZSFCheckDuration +// | $ZSFCheckIP +// | $ZSFCheckIPv4 +// | $ZSFCheckIPv6 +// | $ZSFCheckBase64 +// | $ZSFCheckJWT +// | $ZSFCheckJSONString +// | $ZSFCheckPrefix +// | $ZSFCheckSuffix +// | $ZSFCheckIncludes; + +// export type $ZSFCheck = +// | $ZSFStringFormatChecks +// | $ZSFCheckMinSize +// | $ZSFCheckMaxSize +// | $ZSFCheckSizeEquals +// | $ZSFCheckLessThan +// | $ZSFCheckLessThanOrEqual +// | $ZSFCheckGreaterThan +// | $ZSFCheckGreaterThanOrEqual +// | $ZSFCheckEquals +// | $ZSFCheckMultipleOf; diff --git a/gui/frontend/node_modules/zod/src/v4/index.ts b/gui/frontend/node_modules/zod/src/v4/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..31110e977d5b83532c6eb34ded964c364e452cf4 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/index.ts @@ -0,0 +1,4 @@ +import z4 from "./classic/index.js"; +export * from "./classic/index.js"; + +export default z4; diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ar.ts b/gui/frontend/node_modules/zod/src/v4/locales/ar.ts new file mode 100644 index 0000000000000000000000000000000000000000..f28bde9907870075cdcdcfe0d0056d00a4361708 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ar.ts @@ -0,0 +1,115 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "حرف", verb: "أن يحوي" }, + file: { unit: "بايت", verb: "أن يحوي" }, + array: { unit: "عنصر", verb: "أن يحوي" }, + set: { unit: "عنصر", verb: "أن يحوي" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "مدخل", + email: "بريد إلكتروني", + url: "رابط", + emoji: "إيموجي", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "تاريخ ووقت بمعيار ISO", + date: "تاريخ بمعيار ISO", + time: "وقت بمعيار ISO", + duration: "مدة بمعيار ISO", + ipv4: "عنوان IPv4", + ipv6: "عنوان IPv6", + cidrv4: "مدى عناوين بصيغة IPv4", + cidrv6: "مدى عناوين بصيغة IPv6", + base64: "نَص بترميز base64-encoded", + base64url: "نَص بترميز base64url-encoded", + json_string: "نَص على هيئة JSON", + e164: "رقم هاتف بمعيار E.164", + jwt: "JWT", + template_literal: "مدخل", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `مدخلات غير مقبولة: يفترض إدخال instanceof ${issue.expected}، ولكن تم إدخال ${received}`; + } + return `مدخلات غير مقبولة: يفترض إدخال ${expected}، ولكن تم إدخال ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `مدخلات غير مقبولة: يفترض إدخال ${util.stringifyPrimitive(issue.values[0])}`; + return `اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return ` أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "عنصر"}`; + return `أكبر من اللازم: يفترض أن تكون ${issue.origin ?? "القيمة"} ${adj} ${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()} ${sizing.unit}`; + } + + return `أصغر من اللازم: يفترض لـ ${issue.origin} أن يكون ${adj} ${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `نَص غير مقبول: يجب أن يبدأ بـ "${issue.prefix}"`; + if (_issue.format === "ends_with") return `نَص غير مقبول: يجب أن ينتهي بـ "${_issue.suffix}"`; + if (_issue.format === "includes") return `نَص غير مقبول: يجب أن يتضمَّن "${_issue.includes}"`; + if (_issue.format === "regex") return `نَص غير مقبول: يجب أن يطابق النمط ${_issue.pattern}`; + return `${FormatDictionary[_issue.format] ?? issue.format} غير مقبول`; + } + case "not_multiple_of": + return `رقم غير مقبول: يجب أن يكون من مضاعفات ${issue.divisor}`; + case "unrecognized_keys": + return `معرف${issue.keys.length > 1 ? "ات" : ""} غريب${issue.keys.length > 1 ? "ة" : ""}: ${util.joinValues(issue.keys, "، ")}`; + case "invalid_key": + return `معرف غير مقبول في ${issue.origin}`; + case "invalid_union": + return "مدخل غير مقبول"; + case "invalid_element": + return `مدخل غير مقبول في ${issue.origin}`; + default: + return "مدخل غير مقبول"; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/az.ts b/gui/frontend/node_modules/zod/src/v4/locales/az.ts new file mode 100644 index 0000000000000000000000000000000000000000..d6ae91fb1a2ab45b900a3a15b605cf892b7125e2 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/az.ts @@ -0,0 +1,111 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "simvol", verb: "olmalıdır" }, + file: { unit: "bayt", verb: "olmalıdır" }, + array: { unit: "element", verb: "olmalıdır" }, + set: { unit: "element", verb: "olmalıdır" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "input", + email: "email address", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO datetime", + date: "ISO date", + time: "ISO time", + duration: "ISO duration", + ipv4: "IPv4 address", + ipv6: "IPv6 address", + cidrv4: "IPv4 range", + cidrv6: "IPv6 range", + base64: "base64-encoded string", + base64url: "base64url-encoded string", + json_string: "JSON string", + e164: "E.164 number", + jwt: "JWT", + template_literal: "input", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Yanlış dəyər: gözlənilən instanceof ${issue.expected}, daxil olan ${received}`; + } + return `Yanlış dəyər: gözlənilən ${expected}, daxil olan ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Yanlış dəyər: gözlənilən ${util.stringifyPrimitive(issue.values[0])}`; + return `Yanlış seçim: aşağıdakılardan biri olmalıdır: ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "element"}`; + return `Çox böyük: gözlənilən ${issue.origin ?? "dəyər"} ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`; + return `Çox kiçik: gözlənilən ${issue.origin} ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Yanlış mətn: "${_issue.prefix}" ilə başlamalıdır`; + if (_issue.format === "ends_with") return `Yanlış mətn: "${_issue.suffix}" ilə bitməlidir`; + if (_issue.format === "includes") return `Yanlış mətn: "${_issue.includes}" daxil olmalıdır`; + if (_issue.format === "regex") return `Yanlış mətn: ${_issue.pattern} şablonuna uyğun olmalıdır`; + return `Yanlış ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Yanlış ədəd: ${issue.divisor} ilə bölünə bilən olmalıdır`; + case "unrecognized_keys": + return `Tanınmayan açar${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `${issue.origin} daxilində yanlış açar`; + case "invalid_union": + return "Yanlış dəyər"; + case "invalid_element": + return `${issue.origin} daxilində yanlış dəyər`; + default: + return `Yanlış dəyər`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/be.ts b/gui/frontend/node_modules/zod/src/v4/locales/be.ts new file mode 100644 index 0000000000000000000000000000000000000000..e8a7bad9cb09f79760f00fa6b4a99579a74d2326 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/be.ts @@ -0,0 +1,176 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +function getBelarusianPlural(count: number, one: string, few: string, many: string): string { + const absCount = Math.abs(count); + const lastDigit = absCount % 10; + const lastTwoDigits = absCount % 100; + + if (lastTwoDigits >= 11 && lastTwoDigits <= 19) { + return many; + } + + if (lastDigit === 1) { + return one; + } + + if (lastDigit >= 2 && lastDigit <= 4) { + return few; + } + + return many; +} + +interface BelarusianSizable { + unit: { + one: string; + few: string; + many: string; + }; + verb: string; +} +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { + unit: { + one: "сімвал", + few: "сімвалы", + many: "сімвалаў", + }, + verb: "мець", + }, + array: { + unit: { + one: "элемент", + few: "элементы", + many: "элементаў", + }, + verb: "мець", + }, + set: { + unit: { + one: "элемент", + few: "элементы", + many: "элементаў", + }, + verb: "мець", + }, + file: { + unit: { + one: "байт", + few: "байты", + many: "байтаў", + }, + verb: "мець", + }, + }; + + function getSizing(origin: string): BelarusianSizable | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "увод", + email: "email адрас", + url: "URL", + emoji: "эмодзі", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO дата і час", + date: "ISO дата", + time: "ISO час", + duration: "ISO працягласць", + ipv4: "IPv4 адрас", + ipv6: "IPv6 адрас", + cidrv4: "IPv4 дыяпазон", + cidrv6: "IPv6 дыяпазон", + base64: "радок у фармаце base64", + base64url: "радок у фармаце base64url", + json_string: "JSON радок", + e164: "нумар E.164", + jwt: "JWT", + template_literal: "увод", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "лік", + array: "масіў", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Няправільны ўвод: чакаўся instanceof ${issue.expected}, атрымана ${received}`; + } + return `Няправільны ўвод: чакаўся ${expected}, атрымана ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Няправільны ўвод: чакалася ${util.stringifyPrimitive(issue.values[0])}`; + return `Няправільны варыянт: чакаўся адзін з ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) { + const maxValue = Number(issue.maximum); + const unit = getBelarusianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many); + return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна ${sizing.verb} ${adj}${issue.maximum.toString()} ${unit}`; + } + return `Занадта вялікі: чакалася, што ${issue.origin ?? "значэнне"} павінна быць ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + const minValue = Number(issue.minimum); + const unit = getBelarusianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many); + return `Занадта малы: чакалася, што ${issue.origin} павінна ${sizing.verb} ${adj}${issue.minimum.toString()} ${unit}`; + } + return `Занадта малы: чакалася, што ${issue.origin} павінна быць ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Няправільны радок: павінен пачынацца з "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Няправільны радок: павінен заканчвацца на "${_issue.suffix}"`; + if (_issue.format === "includes") return `Няправільны радок: павінен змяшчаць "${_issue.includes}"`; + if (_issue.format === "regex") return `Няправільны радок: павінен адпавядаць шаблону ${_issue.pattern}`; + return `Няправільны ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Няправільны лік: павінен быць кратным ${issue.divisor}`; + case "unrecognized_keys": + return `Нераспазнаны ${issue.keys.length > 1 ? "ключы" : "ключ"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Няправільны ключ у ${issue.origin}`; + case "invalid_union": + return "Няправільны ўвод"; + case "invalid_element": + return `Няправільнае значэнне ў ${issue.origin}`; + default: + return `Няправільны ўвод`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/bg.ts b/gui/frontend/node_modules/zod/src/v4/locales/bg.ts new file mode 100644 index 0000000000000000000000000000000000000000..f103d48fa8c0c75da09a9fbb3f84d07843842a41 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/bg.ts @@ -0,0 +1,128 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "символа", verb: "да съдържа" }, + file: { unit: "байта", verb: "да съдържа" }, + array: { unit: "елемента", verb: "да съдържа" }, + set: { unit: "елемента", verb: "да съдържа" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "вход", + email: "имейл адрес", + url: "URL", + emoji: "емоджи", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO време", + date: "ISO дата", + time: "ISO време", + duration: "ISO продължителност", + ipv4: "IPv4 адрес", + ipv6: "IPv6 адрес", + cidrv4: "IPv4 диапазон", + cidrv6: "IPv6 диапазон", + base64: "base64-кодиран низ", + base64url: "base64url-кодиран низ", + json_string: "JSON низ", + e164: "E.164 номер", + jwt: "JWT", + template_literal: "вход", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "число", + array: "масив", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Невалиден вход: очакван instanceof ${issue.expected}, получен ${received}`; + } + return `Невалиден вход: очакван ${expected}, получен ${received}`; + } + + case "invalid_value": + if (issue.values.length === 1) return `Невалиден вход: очакван ${util.stringifyPrimitive(issue.values[0])}`; + return `Невалидна опция: очаквано едно от ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Твърде голямо: очаква се ${issue.origin ?? "стойност"} да съдържа ${adj}${issue.maximum.toString()} ${sizing.unit ?? "елемента"}`; + return `Твърде голямо: очаква се ${issue.origin ?? "стойност"} да бъде ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Твърде малко: очаква се ${issue.origin} да съдържа ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Твърде малко: очаква се ${issue.origin} да бъде ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Невалиден низ: трябва да започва с "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Невалиден низ: трябва да завършва с "${_issue.suffix}"`; + if (_issue.format === "includes") return `Невалиден низ: трябва да включва "${_issue.includes}"`; + if (_issue.format === "regex") return `Невалиден низ: трябва да съвпада с ${_issue.pattern}`; + + let invalid_adj = "Невалиден"; + + if (_issue.format === "emoji") invalid_adj = "Невалидно"; + if (_issue.format === "datetime") invalid_adj = "Невалидно"; + if (_issue.format === "date") invalid_adj = "Невалидна"; + if (_issue.format === "time") invalid_adj = "Невалидно"; + if (_issue.format === "duration") invalid_adj = "Невалидна"; + + return `${invalid_adj} ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Невалидно число: трябва да бъде кратно на ${issue.divisor}`; + case "unrecognized_keys": + return `Неразпознат${issue.keys.length > 1 ? "и" : ""} ключ${issue.keys.length > 1 ? "ове" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Невалиден ключ в ${issue.origin}`; + case "invalid_union": + return "Невалиден вход"; + case "invalid_element": + return `Невалидна стойност в ${issue.origin}`; + default: + return `Невалиден вход`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ca.ts b/gui/frontend/node_modules/zod/src/v4/locales/ca.ts new file mode 100644 index 0000000000000000000000000000000000000000..13d38b653157af1fae1db2917a901b937cf2b1e3 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ca.ts @@ -0,0 +1,116 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "caràcters", verb: "contenir" }, + file: { unit: "bytes", verb: "contenir" }, + array: { unit: "elements", verb: "contenir" }, + set: { unit: "elements", verb: "contenir" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "entrada", + email: "adreça electrònica", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "data i hora ISO", + date: "data ISO", + time: "hora ISO", + duration: "durada ISO", + ipv4: "adreça IPv4", + ipv6: "adreça IPv6", + cidrv4: "rang IPv4", + cidrv6: "rang IPv6", + base64: "cadena codificada en base64", + base64url: "cadena codificada en base64url", + json_string: "cadena JSON", + e164: "número E.164", + jwt: "JWT", + template_literal: "entrada", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Tipus invàlid: s'esperava instanceof ${issue.expected}, s'ha rebut ${received}`; + } + return `Tipus invàlid: s'esperava ${expected}, s'ha rebut ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Valor invàlid: s'esperava ${util.stringifyPrimitive(issue.values[0])}`; + return `Opció invàlida: s'esperava una de ${util.joinValues(issue.values, " o ")}`; + case "too_big": { + const adj = issue.inclusive ? "com a màxim" : "menys de"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Massa gran: s'esperava que ${issue.origin ?? "el valor"} contingués ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elements"}`; + return `Massa gran: s'esperava que ${issue.origin ?? "el valor"} fos ${adj} ${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? "com a mínim" : "més de"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Massa petit: s'esperava que ${issue.origin} contingués ${adj} ${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Massa petit: s'esperava que ${issue.origin} fos ${adj} ${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Format invàlid: ha de començar amb "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Format invàlid: ha d'acabar amb "${_issue.suffix}"`; + if (_issue.format === "includes") return `Format invàlid: ha d'incloure "${_issue.includes}"`; + if (_issue.format === "regex") return `Format invàlid: ha de coincidir amb el patró ${_issue.pattern}`; + return `Format invàlid per a ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Número invàlid: ha de ser múltiple de ${issue.divisor}`; + case "unrecognized_keys": + return `Clau${issue.keys.length > 1 ? "s" : ""} no reconeguda${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Clau invàlida a ${issue.origin}`; + case "invalid_union": + return "Entrada invàlida"; // Could also be "Tipus d'unió invàlid" but "Entrada invàlida" is more general + case "invalid_element": + return `Element invàlid a ${issue.origin}`; + default: + return `Entrada invàlida`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/cs.ts b/gui/frontend/node_modules/zod/src/v4/locales/cs.ts new file mode 100644 index 0000000000000000000000000000000000000000..75d59714140d79bafe10165fe508a1b7db6c11f0 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/cs.ts @@ -0,0 +1,118 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "znaků", verb: "mít" }, + file: { unit: "bajtů", verb: "mít" }, + array: { unit: "prvků", verb: "mít" }, + set: { unit: "prvků", verb: "mít" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "regulární výraz", + email: "e-mailová adresa", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "datum a čas ve formátu ISO", + date: "datum ve formátu ISO", + time: "čas ve formátu ISO", + duration: "doba trvání ISO", + ipv4: "IPv4 adresa", + ipv6: "IPv6 adresa", + cidrv4: "rozsah IPv4", + cidrv6: "rozsah IPv6", + base64: "řetězec zakódovaný ve formátu base64", + base64url: "řetězec zakódovaný ve formátu base64url", + json_string: "řetězec ve formátu JSON", + e164: "číslo E.164", + jwt: "JWT", + template_literal: "vstup", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "číslo", + string: "řetězec", + function: "funkce", + array: "pole", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Neplatný vstup: očekáváno instanceof ${issue.expected}, obdrženo ${received}`; + } + return `Neplatný vstup: očekáváno ${expected}, obdrženo ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Neplatný vstup: očekáváno ${util.stringifyPrimitive(issue.values[0])}`; + return `Neplatná možnost: očekávána jedna z hodnot ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.maximum.toString()} ${sizing.unit ?? "prvků"}`; + } + return `Hodnota je příliš velká: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí mít ${adj}${issue.minimum.toString()} ${sizing.unit ?? "prvků"}`; + } + return `Hodnota je příliš malá: ${issue.origin ?? "hodnota"} musí být ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Neplatný řetězec: musí začínat na "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Neplatný řetězec: musí končit na "${_issue.suffix}"`; + if (_issue.format === "includes") return `Neplatný řetězec: musí obsahovat "${_issue.includes}"`; + if (_issue.format === "regex") return `Neplatný řetězec: musí odpovídat vzoru ${_issue.pattern}`; + return `Neplatný formát ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Neplatné číslo: musí být násobkem ${issue.divisor}`; + case "unrecognized_keys": + return `Neznámé klíče: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Neplatný klíč v ${issue.origin}`; + case "invalid_union": + return "Neplatný vstup"; + case "invalid_element": + return `Neplatná hodnota v ${issue.origin}`; + default: + return `Neplatný vstup`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/da.ts b/gui/frontend/node_modules/zod/src/v4/locales/da.ts new file mode 100644 index 0000000000000000000000000000000000000000..e28062a43d1c8b9a0a4b1f7918f3b2050e38d30f --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/da.ts @@ -0,0 +1,123 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "tegn", verb: "havde" }, + file: { unit: "bytes", verb: "havde" }, + array: { unit: "elementer", verb: "indeholdt" }, + set: { unit: "elementer", verb: "indeholdt" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "input", + email: "e-mailadresse", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO dato- og klokkeslæt", + date: "ISO-dato", + time: "ISO-klokkeslæt", + duration: "ISO-varighed", + ipv4: "IPv4-område", + ipv6: "IPv6-område", + cidrv4: "IPv4-spektrum", + cidrv6: "IPv6-spektrum", + base64: "base64-kodet streng", + base64url: "base64url-kodet streng", + json_string: "JSON-streng", + e164: "E.164-nummer", + jwt: "JWT", + template_literal: "input", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + string: "streng", + number: "tal", + boolean: "boolean", + array: "liste", + object: "objekt", + set: "sæt", + file: "fil", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Ugyldigt input: forventede instanceof ${issue.expected}, fik ${received}`; + } + return `Ugyldigt input: forventede ${expected}, fik ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Ugyldig værdi: forventede ${util.stringifyPrimitive(issue.values[0])}`; + return `Ugyldigt valg: forventede en af følgende ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + const origin = TypeDictionary[issue.origin] ?? issue.origin; + if (sizing) + return `For stor: forventede ${origin ?? "value"} ${sizing.verb} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "elementer"}`; + return `For stor: forventede ${origin ?? "value"} havde ${adj} ${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + const origin = TypeDictionary[issue.origin] ?? issue.origin; + if (sizing) { + return `For lille: forventede ${origin} ${sizing.verb} ${adj} ${issue.minimum.toString()} ${sizing.unit}`; + } + + return `For lille: forventede ${origin} havde ${adj} ${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Ugyldig streng: skal starte med "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Ugyldig streng: skal ende med "${_issue.suffix}"`; + if (_issue.format === "includes") return `Ugyldig streng: skal indeholde "${_issue.includes}"`; + if (_issue.format === "regex") return `Ugyldig streng: skal matche mønsteret ${_issue.pattern}`; + return `Ugyldig ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Ugyldigt tal: skal være deleligt med ${issue.divisor}`; + case "unrecognized_keys": + return `${issue.keys.length > 1 ? "Ukendte nøgler" : "Ukendt nøgle"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Ugyldig nøgle i ${issue.origin}`; + case "invalid_union": + return "Ugyldigt input: matcher ingen af de tilladte typer"; + case "invalid_element": + return `Ugyldig værdi i ${issue.origin}`; + default: + return `Ugyldigt input`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/de.ts b/gui/frontend/node_modules/zod/src/v4/locales/de.ts new file mode 100644 index 0000000000000000000000000000000000000000..dbcae388a3f703e678444da657f8830873dd9a60 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/de.ts @@ -0,0 +1,116 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "Zeichen", verb: "zu haben" }, + file: { unit: "Bytes", verb: "zu haben" }, + array: { unit: "Elemente", verb: "zu haben" }, + set: { unit: "Elemente", verb: "zu haben" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "Eingabe", + email: "E-Mail-Adresse", + url: "URL", + emoji: "Emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO-Datum und -Uhrzeit", + date: "ISO-Datum", + time: "ISO-Uhrzeit", + duration: "ISO-Dauer", + ipv4: "IPv4-Adresse", + ipv6: "IPv6-Adresse", + cidrv4: "IPv4-Bereich", + cidrv6: "IPv6-Bereich", + base64: "Base64-codierter String", + base64url: "Base64-URL-codierter String", + json_string: "JSON-String", + e164: "E.164-Nummer", + jwt: "JWT", + template_literal: "Eingabe", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "Zahl", + array: "Array", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Ungültige Eingabe: erwartet instanceof ${issue.expected}, erhalten ${received}`; + } + return `Ungültige Eingabe: erwartet ${expected}, erhalten ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Ungültige Eingabe: erwartet ${util.stringifyPrimitive(issue.values[0])}`; + return `Ungültige Option: erwartet eine von ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "Elemente"} hat`; + return `Zu groß: erwartet, dass ${issue.origin ?? "Wert"} ${adj}${issue.maximum.toString()} ist`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} hat`; + } + + return `Zu klein: erwartet, dass ${issue.origin} ${adj}${issue.minimum.toString()} ist`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Ungültiger String: muss mit "${_issue.prefix}" beginnen`; + if (_issue.format === "ends_with") return `Ungültiger String: muss mit "${_issue.suffix}" enden`; + if (_issue.format === "includes") return `Ungültiger String: muss "${_issue.includes}" enthalten`; + if (_issue.format === "regex") return `Ungültiger String: muss dem Muster ${_issue.pattern} entsprechen`; + return `Ungültig: ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Ungültige Zahl: muss ein Vielfaches von ${issue.divisor} sein`; + case "unrecognized_keys": + return `${issue.keys.length > 1 ? "Unbekannte Schlüssel" : "Unbekannter Schlüssel"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Ungültiger Schlüssel in ${issue.origin}`; + case "invalid_union": + return "Ungültige Eingabe"; + case "invalid_element": + return `Ungültiger Wert in ${issue.origin}`; + default: + return `Ungültige Eingabe`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/el.ts b/gui/frontend/node_modules/zod/src/v4/locales/el.ts new file mode 100644 index 0000000000000000000000000000000000000000..d2a394d08fba666447fbcccbc408d4288c55d9eb --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/el.ts @@ -0,0 +1,121 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "χαρακτήρες", verb: "να έχει" }, + file: { unit: "bytes", verb: "να έχει" }, + array: { unit: "στοιχεία", verb: "να έχει" }, + set: { unit: "στοιχεία", verb: "να έχει" }, + map: { unit: "καταχωρήσεις", verb: "να έχει" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "είσοδος", + email: "διεύθυνση email", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO ημερομηνία και ώρα", + date: "ISO ημερομηνία", + time: "ISO ώρα", + duration: "ISO διάρκεια", + ipv4: "διεύθυνση IPv4", + ipv6: "διεύθυνση IPv6", + mac: "διεύθυνση MAC", + cidrv4: "εύρος IPv4", + cidrv6: "εύρος IPv6", + base64: "συμβολοσειρά κωδικοποιημένη σε base64", + base64url: "συμβολοσειρά κωδικοποιημένη σε base64url", + json_string: "συμβολοσειρά JSON", + e164: "αριθμός E.164", + jwt: "JWT", + template_literal: "είσοδος", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (typeof issue.expected === "string" && /^[A-Z]/.test(issue.expected)) { + return `Μη έγκυρη είσοδος: αναμενόταν instanceof ${issue.expected}, λήφθηκε ${received}`; + } + return `Μη έγκυρη είσοδος: αναμενόταν ${expected}, λήφθηκε ${received}`; + } + + case "invalid_value": + if (issue.values.length === 1) + return `Μη έγκυρη είσοδος: αναμενόταν ${util.stringifyPrimitive(issue.values[0])}`; + return `Μη έγκυρη επιλογή: αναμενόταν ένα από ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να έχει ${adj}${issue.maximum.toString()} ${sizing.unit ?? "στοιχεία"}`; + return `Πολύ μεγάλο: αναμενόταν ${issue.origin ?? "τιμή"} να είναι ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Πολύ μικρό: αναμενόταν ${issue.origin} να έχει ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Πολύ μικρό: αναμενόταν ${issue.origin} να είναι ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Μη έγκυρη συμβολοσειρά: πρέπει να ξεκινά με "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Μη έγκυρη συμβολοσειρά: πρέπει να τελειώνει με "${_issue.suffix}"`; + if (_issue.format === "includes") return `Μη έγκυρη συμβολοσειρά: πρέπει να περιέχει "${_issue.includes}"`; + if (_issue.format === "regex") + return `Μη έγκυρη συμβολοσειρά: πρέπει να ταιριάζει με το μοτίβο ${_issue.pattern}`; + return `Μη έγκυρο: ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Μη έγκυρος αριθμός: πρέπει να είναι πολλαπλάσιο του ${issue.divisor}`; + case "unrecognized_keys": + return `Άγνωστ${issue.keys.length > 1 ? "α" : "ο"} κλειδ${issue.keys.length > 1 ? "ιά" : "ί"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Μη έγκυρο κλειδί στο ${issue.origin}`; + case "invalid_union": + return "Μη έγκυρη είσοδος"; + case "invalid_element": + return `Μη έγκυρη τιμή στο ${issue.origin}`; + default: + return `Μη έγκυρη είσοδος`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/en.ts b/gui/frontend/node_modules/zod/src/v4/locales/en.ts new file mode 100644 index 0000000000000000000000000000000000000000..08bf45fc5dd8f1cbf07464c800b03cc3e1acc6b1 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/en.ts @@ -0,0 +1,123 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "characters", verb: "to have" }, + file: { unit: "bytes", verb: "to have" }, + array: { unit: "items", verb: "to have" }, + set: { unit: "items", verb: "to have" }, + map: { unit: "entries", verb: "to have" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "input", + email: "email address", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO datetime", + date: "ISO date", + time: "ISO time", + duration: "ISO duration", + ipv4: "IPv4 address", + ipv6: "IPv6 address", + mac: "MAC address", + cidrv4: "IPv4 range", + cidrv6: "IPv6 range", + base64: "base64-encoded string", + base64url: "base64url-encoded string", + json_string: "JSON string", + e164: "E.164 number", + jwt: "JWT", + template_literal: "input", + }; + + // type names: missing keys = do not translate (use raw value via ?? fallback) + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + // Compatibility: "nan" -> "NaN" for display + nan: "NaN", + // All other type names omitted - they fall back to raw values via ?? operator + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + return `Invalid input: expected ${expected}, received ${received}`; + } + + case "invalid_value": + if (issue.values.length === 1) return `Invalid input: expected ${util.stringifyPrimitive(issue.values[0])}`; + return `Invalid option: expected one of ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Too big: expected ${issue.origin ?? "value"} to have ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"}`; + return `Too big: expected ${issue.origin ?? "value"} to be ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Too small: expected ${issue.origin} to have ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Too small: expected ${issue.origin} to be ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Invalid string: must start with "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Invalid string: must end with "${_issue.suffix}"`; + if (_issue.format === "includes") return `Invalid string: must include "${_issue.includes}"`; + if (_issue.format === "regex") return `Invalid string: must match pattern ${_issue.pattern}`; + return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Invalid number: must be a multiple of ${issue.divisor}`; + case "unrecognized_keys": + return `Unrecognized key${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Invalid key in ${issue.origin}`; + case "invalid_union": + if (issue.options && Array.isArray(issue.options) && issue.options.length > 0) { + const opts = issue.options.map((o) => `'${o}'`).join(" | "); + return `Invalid discriminator value. Expected ${opts}`; + } + return "Invalid input"; + case "invalid_element": + return `Invalid value in ${issue.origin}`; + default: + return `Invalid input`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/eo.ts b/gui/frontend/node_modules/zod/src/v4/locales/eo.ts new file mode 100644 index 0000000000000000000000000000000000000000..f848cc65a09a9e6a101a8b19e8dfc5f8ae330367 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/eo.ts @@ -0,0 +1,118 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "karaktrojn", verb: "havi" }, + file: { unit: "bajtojn", verb: "havi" }, + array: { unit: "elementojn", verb: "havi" }, + set: { unit: "elementojn", verb: "havi" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "enigo", + email: "retadreso", + url: "URL", + emoji: "emoĝio", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO-datotempo", + date: "ISO-dato", + time: "ISO-tempo", + duration: "ISO-daŭro", + ipv4: "IPv4-adreso", + ipv6: "IPv6-adreso", + cidrv4: "IPv4-rango", + cidrv6: "IPv6-rango", + base64: "64-ume kodita karaktraro", + base64url: "URL-64-ume kodita karaktraro", + json_string: "JSON-karaktraro", + e164: "E.164-nombro", + jwt: "JWT", + template_literal: "enigo", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "nombro", + array: "tabelo", + null: "senvalora", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Nevalida enigo: atendiĝis instanceof ${issue.expected}, riceviĝis ${received}`; + } + return `Nevalida enigo: atendiĝis ${expected}, riceviĝis ${received}`; + } + + case "invalid_value": + if (issue.values.length === 1) return `Nevalida enigo: atendiĝis ${util.stringifyPrimitive(issue.values[0])}`; + return `Nevalida opcio: atendiĝis unu el ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementojn"}`; + return `Tro granda: atendiĝis ke ${issue.origin ?? "valoro"} havu ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Tro malgranda: atendiĝis ke ${issue.origin} havu ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Tro malgranda: atendiĝis ke ${issue.origin} estu ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Nevalida karaktraro: devas komenciĝi per "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Nevalida karaktraro: devas finiĝi per "${_issue.suffix}"`; + if (_issue.format === "includes") return `Nevalida karaktraro: devas inkluzivi "${_issue.includes}"`; + if (_issue.format === "regex") return `Nevalida karaktraro: devas kongrui kun la modelo ${_issue.pattern}`; + return `Nevalida ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Nevalida nombro: devas esti oblo de ${issue.divisor}`; + case "unrecognized_keys": + return `Nekonata${issue.keys.length > 1 ? "j" : ""} ŝlosilo${issue.keys.length > 1 ? "j" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Nevalida ŝlosilo en ${issue.origin}`; + case "invalid_union": + return "Nevalida enigo"; + case "invalid_element": + return `Nevalida valoro en ${issue.origin}`; + default: + return `Nevalida enigo`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/es.ts b/gui/frontend/node_modules/zod/src/v4/locales/es.ts new file mode 100644 index 0000000000000000000000000000000000000000..7b890a6952973f0617338b4c9d8e5a917655a6ed --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/es.ts @@ -0,0 +1,141 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "caracteres", verb: "tener" }, + file: { unit: "bytes", verb: "tener" }, + array: { unit: "elementos", verb: "tener" }, + set: { unit: "elementos", verb: "tener" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "entrada", + email: "dirección de correo electrónico", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "fecha y hora ISO", + date: "fecha ISO", + time: "hora ISO", + duration: "duración ISO", + ipv4: "dirección IPv4", + ipv6: "dirección IPv6", + cidrv4: "rango IPv4", + cidrv6: "rango IPv6", + base64: "cadena codificada en base64", + base64url: "URL codificada en base64", + json_string: "cadena JSON", + e164: "número E.164", + jwt: "JWT", + template_literal: "entrada", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + string: "texto", + number: "número", + boolean: "booleano", + array: "arreglo", + object: "objeto", + set: "conjunto", + file: "archivo", + date: "fecha", + bigint: "número grande", + symbol: "símbolo", + undefined: "indefinido", + null: "nulo", + function: "función", + map: "mapa", + record: "registro", + tuple: "tupla", + enum: "enumeración", + union: "unión", + literal: "literal", + promise: "promesa", + void: "vacío", + never: "nunca", + unknown: "desconocido", + any: "cualquiera", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Entrada inválida: se esperaba instanceof ${issue.expected}, recibido ${received}`; + } + return `Entrada inválida: se esperaba ${expected}, recibido ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Entrada inválida: se esperaba ${util.stringifyPrimitive(issue.values[0])}`; + return `Opción inválida: se esperaba una de ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + const origin = TypeDictionary[issue.origin] ?? issue.origin; + if (sizing) + return `Demasiado grande: se esperaba que ${origin ?? "valor"} tuviera ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementos"}`; + return `Demasiado grande: se esperaba que ${origin ?? "valor"} fuera ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + const origin = TypeDictionary[issue.origin] ?? issue.origin; + if (sizing) { + return `Demasiado pequeño: se esperaba que ${origin} tuviera ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Demasiado pequeño: se esperaba que ${origin} fuera ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Cadena inválida: debe comenzar con "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Cadena inválida: debe terminar en "${_issue.suffix}"`; + if (_issue.format === "includes") return `Cadena inválida: debe incluir "${_issue.includes}"`; + if (_issue.format === "regex") return `Cadena inválida: debe coincidir con el patrón ${_issue.pattern}`; + return `Inválido ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Número inválido: debe ser múltiplo de ${issue.divisor}`; + case "unrecognized_keys": + return `Llave${issue.keys.length > 1 ? "s" : ""} desconocida${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Llave inválida en ${TypeDictionary[issue.origin] ?? issue.origin}`; + case "invalid_union": + return "Entrada inválida"; + case "invalid_element": + return `Valor inválido en ${TypeDictionary[issue.origin] ?? issue.origin}`; + default: + return `Entrada inválida`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/fa.ts b/gui/frontend/node_modules/zod/src/v4/locales/fa.ts new file mode 100644 index 0000000000000000000000000000000000000000..524894a4e0467f95b370aba86bfbd229c262b133 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/fa.ts @@ -0,0 +1,126 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "کاراکتر", verb: "داشته باشد" }, + file: { unit: "بایت", verb: "داشته باشد" }, + array: { unit: "آیتم", verb: "داشته باشد" }, + set: { unit: "آیتم", verb: "داشته باشد" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "ورودی", + email: "آدرس ایمیل", + url: "URL", + emoji: "ایموجی", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "تاریخ و زمان ایزو", + date: "تاریخ ایزو", + time: "زمان ایزو", + duration: "مدت زمان ایزو", + ipv4: "IPv4 آدرس", + ipv6: "IPv6 آدرس", + cidrv4: "IPv4 دامنه", + cidrv6: "IPv6 دامنه", + base64: "base64-encoded رشته", + base64url: "base64url-encoded رشته", + json_string: "JSON رشته", + e164: "E.164 عدد", + jwt: "JWT", + template_literal: "ورودی", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "عدد", + array: "آرایه", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `ورودی نامعتبر: می‌بایست instanceof ${issue.expected} می‌بود، ${received} دریافت شد`; + } + return `ورودی نامعتبر: می‌بایست ${expected} می‌بود، ${received} دریافت شد`; + } + case "invalid_value": + if (issue.values.length === 1) { + return `ورودی نامعتبر: می‌بایست ${util.stringifyPrimitive(issue.values[0])} می‌بود`; + } + return `گزینه نامعتبر: می‌بایست یکی از ${util.joinValues(issue.values, "|")} می‌بود`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `خیلی بزرگ: ${issue.origin ?? "مقدار"} باید ${adj}${issue.maximum.toString()} ${sizing.unit ?? "عنصر"} باشد`; + } + return `خیلی بزرگ: ${issue.origin ?? "مقدار"} باید ${adj}${issue.maximum.toString()} باشد`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `خیلی کوچک: ${issue.origin} باید ${adj}${issue.minimum.toString()} ${sizing.unit} باشد`; + } + return `خیلی کوچک: ${issue.origin} باید ${adj}${issue.minimum.toString()} باشد`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `رشته نامعتبر: باید با "${_issue.prefix}" شروع شود`; + } + if (_issue.format === "ends_with") { + return `رشته نامعتبر: باید با "${_issue.suffix}" تمام شود`; + } + if (_issue.format === "includes") { + return `رشته نامعتبر: باید شامل "${_issue.includes}" باشد`; + } + if (_issue.format === "regex") { + return `رشته نامعتبر: باید با الگوی ${_issue.pattern} مطابقت داشته باشد`; + } + return `${FormatDictionary[_issue.format] ?? issue.format} نامعتبر`; + } + case "not_multiple_of": + return `عدد نامعتبر: باید مضرب ${issue.divisor} باشد`; + case "unrecognized_keys": + return `کلید${issue.keys.length > 1 ? "های" : ""} ناشناس: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `کلید ناشناس در ${issue.origin}`; + case "invalid_union": + return `ورودی نامعتبر`; + case "invalid_element": + return `مقدار نامعتبر در ${issue.origin}`; + default: + return `ورودی نامعتبر`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/fi.ts b/gui/frontend/node_modules/zod/src/v4/locales/fi.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6e8a982b78f0b692488da1850cada6d3b1a75b1 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/fi.ts @@ -0,0 +1,121 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "merkkiä", subject: "merkkijonon" }, + file: { unit: "tavua", subject: "tiedoston" }, + array: { unit: "alkiota", subject: "listan" }, + set: { unit: "alkiota", subject: "joukon" }, + number: { unit: "", subject: "luvun" }, + bigint: { unit: "", subject: "suuren kokonaisluvun" }, + int: { unit: "", subject: "kokonaisluvun" }, + date: { unit: "", subject: "päivämäärän" }, + }; + + function getSizing(origin: string): { unit: string; subject: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "säännöllinen lauseke", + email: "sähköpostiosoite", + url: "URL-osoite", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO-aikaleima", + date: "ISO-päivämäärä", + time: "ISO-aika", + duration: "ISO-kesto", + ipv4: "IPv4-osoite", + ipv6: "IPv6-osoite", + cidrv4: "IPv4-alue", + cidrv6: "IPv6-alue", + base64: "base64-koodattu merkkijono", + base64url: "base64url-koodattu merkkijono", + json_string: "JSON-merkkijono", + e164: "E.164-luku", + jwt: "JWT", + template_literal: "templaattimerkkijono", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Virheellinen tyyppi: odotettiin instanceof ${issue.expected}, oli ${received}`; + } + return `Virheellinen tyyppi: odotettiin ${expected}, oli ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Virheellinen syöte: täytyy olla ${util.stringifyPrimitive(issue.values[0])}`; + return `Virheellinen valinta: täytyy olla yksi seuraavista: ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Liian suuri: ${sizing.subject} täytyy olla ${adj}${issue.maximum.toString()} ${sizing.unit}`.trim(); + } + return `Liian suuri: arvon täytyy olla ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Liian pieni: ${sizing.subject} täytyy olla ${adj}${issue.minimum.toString()} ${sizing.unit}`.trim(); + } + return `Liian pieni: arvon täytyy olla ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Virheellinen syöte: täytyy alkaa "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Virheellinen syöte: täytyy loppua "${_issue.suffix}"`; + if (_issue.format === "includes") return `Virheellinen syöte: täytyy sisältää "${_issue.includes}"`; + if (_issue.format === "regex") { + return `Virheellinen syöte: täytyy vastata säännöllistä lauseketta ${_issue.pattern}`; + } + return `Virheellinen ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Virheellinen luku: täytyy olla luvun ${issue.divisor} monikerta`; + case "unrecognized_keys": + return `${issue.keys.length > 1 ? "Tuntemattomat avaimet" : "Tuntematon avain"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return "Virheellinen avain tietueessa"; + case "invalid_union": + return "Virheellinen unioni"; + case "invalid_element": + return "Virheellinen arvo joukossa"; + default: + return `Virheellinen syöte`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/fr-CA.ts b/gui/frontend/node_modules/zod/src/v4/locales/fr-CA.ts new file mode 100644 index 0000000000000000000000000000000000000000..91406077e964533e757c6734e7b7524be3721f8c --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/fr-CA.ts @@ -0,0 +1,116 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "caractères", verb: "avoir" }, + file: { unit: "octets", verb: "avoir" }, + array: { unit: "éléments", verb: "avoir" }, + set: { unit: "éléments", verb: "avoir" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "entrée", + email: "adresse courriel", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "date-heure ISO", + date: "date ISO", + time: "heure ISO", + duration: "durée ISO", + ipv4: "adresse IPv4", + ipv6: "adresse IPv6", + cidrv4: "plage IPv4", + cidrv6: "plage IPv6", + base64: "chaîne encodée en base64", + base64url: "chaîne encodée en base64url", + json_string: "chaîne JSON", + e164: "numéro E.164", + jwt: "JWT", + template_literal: "entrée", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Entrée invalide : attendu instanceof ${issue.expected}, reçu ${received}`; + } + return `Entrée invalide : attendu ${expected}, reçu ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Entrée invalide : attendu ${util.stringifyPrimitive(issue.values[0])}`; + return `Option invalide : attendu l'une des valeurs suivantes ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "≤" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Trop grand : attendu que ${issue.origin ?? "la valeur"} ait ${adj}${issue.maximum.toString()} ${sizing.unit}`; + return `Trop grand : attendu que ${issue.origin ?? "la valeur"} soit ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? "≥" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Trop petit : attendu que ${issue.origin} ait ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Trop petit : attendu que ${issue.origin} soit ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Chaîne invalide : doit commencer par "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Chaîne invalide : doit se terminer par "${_issue.suffix}"`; + if (_issue.format === "includes") return `Chaîne invalide : doit inclure "${_issue.includes}"`; + if (_issue.format === "regex") return `Chaîne invalide : doit correspondre au motif ${_issue.pattern}`; + return `${FormatDictionary[_issue.format] ?? issue.format} invalide`; + } + case "not_multiple_of": + return `Nombre invalide : doit être un multiple de ${issue.divisor}`; + case "unrecognized_keys": + return `Clé${issue.keys.length > 1 ? "s" : ""} non reconnue${issue.keys.length > 1 ? "s" : ""} : ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Clé invalide dans ${issue.origin}`; + case "invalid_union": + return "Entrée invalide"; + case "invalid_element": + return `Valeur invalide dans ${issue.origin}`; + default: + return `Entrée invalide`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/fr.ts b/gui/frontend/node_modules/zod/src/v4/locales/fr.ts new file mode 100644 index 0000000000000000000000000000000000000000..8578fc4eb5b02e9cd6e9e9d6baad35d6ebe190b5 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/fr.ts @@ -0,0 +1,132 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "caractères", verb: "avoir" }, + file: { unit: "octets", verb: "avoir" }, + array: { unit: "éléments", verb: "avoir" }, + set: { unit: "éléments", verb: "avoir" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "entrée", + email: "adresse e-mail", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "date et heure ISO", + date: "date ISO", + time: "heure ISO", + duration: "durée ISO", + ipv4: "adresse IPv4", + ipv6: "adresse IPv6", + cidrv4: "plage IPv4", + cidrv6: "plage IPv6", + base64: "chaîne encodée en base64", + base64url: "chaîne encodée en base64url", + json_string: "chaîne JSON", + e164: "numéro E.164", + jwt: "JWT", + template_literal: "entrée", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + string: "chaîne", + number: "nombre", + int: "entier", + boolean: "booléen", + bigint: "grand entier", + symbol: "symbole", + undefined: "indéfini", + null: "null", + never: "jamais", + void: "vide", + date: "date", + array: "tableau", + object: "objet", + tuple: "tuple", + record: "enregistrement", + map: "carte", + set: "ensemble", + file: "fichier", + nonoptional: "non-optionnel", + nan: "NaN", + function: "fonction", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Entrée invalide : instanceof ${issue.expected} attendu, ${received} reçu`; + } + return `Entrée invalide : ${expected} attendu, ${received} reçu`; + } + case "invalid_value": + if (issue.values.length === 1) return `Entrée invalide : ${util.stringifyPrimitive(issue.values[0])} attendu`; + return `Option invalide : une valeur parmi ${util.joinValues(issue.values, "|")} attendue`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Trop grand : ${TypeDictionary[issue.origin] ?? "valeur"} doit ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "élément(s)"}`; + return `Trop grand : ${TypeDictionary[issue.origin] ?? "valeur"} doit être ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Trop petit : ${TypeDictionary[issue.origin] ?? "valeur"} doit ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`; + return `Trop petit : ${TypeDictionary[issue.origin] ?? "valeur"} doit être ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Chaîne invalide : doit commencer par "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Chaîne invalide : doit se terminer par "${_issue.suffix}"`; + if (_issue.format === "includes") return `Chaîne invalide : doit inclure "${_issue.includes}"`; + if (_issue.format === "regex") return `Chaîne invalide : doit correspondre au modèle ${_issue.pattern}`; + return `${FormatDictionary[_issue.format] ?? issue.format} invalide`; + } + case "not_multiple_of": + return `Nombre invalide : doit être un multiple de ${issue.divisor}`; + case "unrecognized_keys": + return `Clé${issue.keys.length > 1 ? "s" : ""} non reconnue${issue.keys.length > 1 ? "s" : ""} : ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Clé invalide dans ${issue.origin}`; + case "invalid_union": + return "Entrée invalide"; + case "invalid_element": + return `Valeur invalide dans ${issue.origin}`; + default: + return `Entrée invalide`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/he.ts b/gui/frontend/node_modules/zod/src/v4/locales/he.ts new file mode 100644 index 0000000000000000000000000000000000000000..fd85db333c41991390bb91be6439b43587ab20af --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/he.ts @@ -0,0 +1,246 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + // Hebrew labels + grammatical gender + const TypeNames: Record = { + string: { label: "מחרוזת", gender: "f" }, + number: { label: "מספר", gender: "m" }, + boolean: { label: "ערך בוליאני", gender: "m" }, + bigint: { label: "BigInt", gender: "m" }, + date: { label: "תאריך", gender: "m" }, + array: { label: "מערך", gender: "m" }, + object: { label: "אובייקט", gender: "m" }, + null: { label: "ערך ריק (null)", gender: "m" }, + undefined: { label: "ערך לא מוגדר (undefined)", gender: "m" }, + symbol: { label: "סימבול (Symbol)", gender: "m" }, + function: { label: "פונקציה", gender: "f" }, + map: { label: "מפה (Map)", gender: "f" }, + set: { label: "קבוצה (Set)", gender: "f" }, + file: { label: "קובץ", gender: "m" }, + promise: { label: "Promise", gender: "m" }, + NaN: { label: "NaN", gender: "m" }, + unknown: { label: "ערך לא ידוע", gender: "m" }, + value: { label: "ערך", gender: "m" }, + }; + + // Sizing units for size-related messages + localized origin labels + const Sizable: Record = { + string: { unit: "תווים", shortLabel: "קצר", longLabel: "ארוך" }, + file: { unit: "בייטים", shortLabel: "קטן", longLabel: "גדול" }, + array: { unit: "פריטים", shortLabel: "קטן", longLabel: "גדול" }, + set: { unit: "פריטים", shortLabel: "קטן", longLabel: "גדול" }, + number: { unit: "", shortLabel: "קטן", longLabel: "גדול" }, // no unit + }; + + // Helpers — labels, articles, and verbs + const typeEntry = (t?: string | null) => (t ? TypeNames[t] : undefined); + + const typeLabel = (t?: string | null): string => { + const e = typeEntry(t); + if (e) return e.label; + // fallback: show raw string if unknown + return t ?? TypeNames.unknown.label; + }; + + const withDefinite = (t?: string | null): string => `ה${typeLabel(t)}`; + + const verbFor = (t?: string | null): string => { + const e = typeEntry(t); + const gender = e?.gender ?? "m"; + return gender === "f" ? "צריכה להיות" : "צריך להיות"; + }; + + const getSizing = (origin?: string | null) => { + if (!origin) return null; + return Sizable[origin] ?? null; + }; + + const FormatDictionary: { + [k in $ZodStringFormats]: { label: string; gender: "m" | "f" }; + } = { + regex: { label: "קלט", gender: "m" }, + email: { label: "כתובת אימייל", gender: "f" }, + url: { label: "כתובת רשת", gender: "f" }, + emoji: { label: "אימוג'י", gender: "m" }, + uuid: { label: "UUID", gender: "m" }, + nanoid: { label: "nanoid", gender: "m" }, + guid: { label: "GUID", gender: "m" }, + cuid: { label: "cuid", gender: "m" }, + cuid2: { label: "cuid2", gender: "m" }, + ulid: { label: "ULID", gender: "m" }, + xid: { label: "XID", gender: "m" }, + ksuid: { label: "KSUID", gender: "m" }, + datetime: { label: "תאריך וזמן ISO", gender: "m" }, + date: { label: "תאריך ISO", gender: "m" }, + time: { label: "זמן ISO", gender: "m" }, + duration: { label: "משך זמן ISO", gender: "m" }, + ipv4: { label: "כתובת IPv4", gender: "f" }, + ipv6: { label: "כתובת IPv6", gender: "f" }, + cidrv4: { label: "טווח IPv4", gender: "m" }, + cidrv6: { label: "טווח IPv6", gender: "m" }, + base64: { label: "מחרוזת בבסיס 64", gender: "f" }, + base64url: { label: "מחרוזת בבסיס 64 לכתובות רשת", gender: "f" }, + json_string: { label: "מחרוזת JSON", gender: "f" }, + e164: { label: "מספר E.164", gender: "m" }, + jwt: { label: "JWT", gender: "m" }, + ends_with: { label: "קלט", gender: "m" }, + includes: { label: "קלט", gender: "m" }, + lowercase: { label: "קלט", gender: "m" }, + starts_with: { label: "קלט", gender: "m" }, + uppercase: { label: "קלט", gender: "m" }, + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + // Expected type: show without definite article for clearer Hebrew + const expectedKey = issue.expected as string | undefined; + const expected = TypeDictionary[expectedKey ?? ""] ?? typeLabel(expectedKey); + // Received: show localized label if known, otherwise constructor/raw + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? TypeNames[receivedType]?.label ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `קלט לא תקין: צריך להיות instanceof ${issue.expected}, התקבל ${received}`; + } + return `קלט לא תקין: צריך להיות ${expected}, התקבל ${received}`; + } + + case "invalid_value": { + if (issue.values.length === 1) { + return `ערך לא תקין: הערך חייב להיות ${util.stringifyPrimitive(issue.values[0])}`; + } + // Join values with proper Hebrew formatting + const stringified = issue.values.map((v) => util.stringifyPrimitive(v)); + if (issue.values.length === 2) { + return `ערך לא תקין: האפשרויות המתאימות הן ${stringified[0]} או ${stringified[1]}`; + } + // For 3+ values: "a", "b" או "c" + const lastValue = stringified[stringified.length - 1]; + const restValues = stringified.slice(0, -1).join(", "); + return `ערך לא תקין: האפשרויות המתאימות הן ${restValues} או ${lastValue}`; + } + + case "too_big": { + const sizing = getSizing(issue.origin); + const subject = withDefinite(issue.origin ?? "value"); + + if (issue.origin === "string") { + // Special handling for strings - more natural Hebrew + return `${sizing?.longLabel ?? "ארוך"} מדי: ${subject} צריכה להכיל ${issue.maximum.toString()} ${sizing?.unit ?? ""} ${issue.inclusive ? "או פחות" : "לכל היותר"}`.trim(); + } + + if (issue.origin === "number") { + // Natural Hebrew for numbers + const comparison = issue.inclusive ? `קטן או שווה ל-${issue.maximum}` : `קטן מ-${issue.maximum}`; + return `גדול מדי: ${subject} צריך להיות ${comparison}`; + } + + if (issue.origin === "array" || issue.origin === "set") { + // Natural Hebrew for arrays and sets + const verb = issue.origin === "set" ? "צריכה" : "צריך"; + const comparison = issue.inclusive + ? `${issue.maximum} ${sizing?.unit ?? ""} או פחות` + : `פחות מ-${issue.maximum} ${sizing?.unit ?? ""}`; + return `גדול מדי: ${subject} ${verb} להכיל ${comparison}`.trim(); + } + + const adj = issue.inclusive ? "<=" : "<"; + const be = verbFor(issue.origin ?? "value"); + if (sizing?.unit) { + return `${sizing.longLabel} מדי: ${subject} ${be} ${adj}${issue.maximum.toString()} ${sizing.unit}`; + } + return `${sizing?.longLabel ?? "גדול"} מדי: ${subject} ${be} ${adj}${issue.maximum.toString()}`; + } + + case "too_small": { + const sizing = getSizing(issue.origin); + const subject = withDefinite(issue.origin ?? "value"); + + if (issue.origin === "string") { + // Special handling for strings - more natural Hebrew + return `${sizing?.shortLabel ?? "קצר"} מדי: ${subject} צריכה להכיל ${issue.minimum.toString()} ${sizing?.unit ?? ""} ${issue.inclusive ? "או יותר" : "לפחות"}`.trim(); + } + + if (issue.origin === "number") { + // Natural Hebrew for numbers + const comparison = issue.inclusive ? `גדול או שווה ל-${issue.minimum}` : `גדול מ-${issue.minimum}`; + return `קטן מדי: ${subject} צריך להיות ${comparison}`; + } + + if (issue.origin === "array" || issue.origin === "set") { + // Natural Hebrew for arrays and sets + const verb = issue.origin === "set" ? "צריכה" : "צריך"; + + // Special case for singular (minimum === 1) + if (issue.minimum === 1 && issue.inclusive) { + const singularPhrase = issue.origin === "set" ? "לפחות פריט אחד" : "לפחות פריט אחד"; + return `קטן מדי: ${subject} ${verb} להכיל ${singularPhrase}`; + } + + const comparison = issue.inclusive + ? `${issue.minimum} ${sizing?.unit ?? ""} או יותר` + : `יותר מ-${issue.minimum} ${sizing?.unit ?? ""}`; + return `קטן מדי: ${subject} ${verb} להכיל ${comparison}`.trim(); + } + + const adj = issue.inclusive ? ">=" : ">"; + const be = verbFor(issue.origin ?? "value"); + if (sizing?.unit) { + return `${sizing.shortLabel} מדי: ${subject} ${be} ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + return `${sizing?.shortLabel ?? "קטן"} מדי: ${subject} ${be} ${adj}${issue.minimum.toString()}`; + } + + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + // These apply to strings — use feminine grammar + ה׳ הידיעה + if (_issue.format === "starts_with") return `המחרוזת חייבת להתחיל ב "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `המחרוזת חייבת להסתיים ב "${_issue.suffix}"`; + if (_issue.format === "includes") return `המחרוזת חייבת לכלול "${_issue.includes}"`; + if (_issue.format === "regex") return `המחרוזת חייבת להתאים לתבנית ${_issue.pattern}`; + + // Handle gender agreement for formats + const nounEntry = FormatDictionary[_issue.format]; + const noun = nounEntry?.label ?? _issue.format; + const gender = nounEntry?.gender ?? "m"; + const adjective = gender === "f" ? "תקינה" : "תקין"; + return `${noun} לא ${adjective}`; + } + + case "not_multiple_of": + return `מספר לא תקין: חייב להיות מכפלה של ${issue.divisor}`; + + case "unrecognized_keys": + return `מפתח${issue.keys.length > 1 ? "ות" : ""} לא מזוה${issue.keys.length > 1 ? "ים" : "ה"}: ${util.joinValues(issue.keys, ", ")}`; + + case "invalid_key": { + return `שדה לא תקין באובייקט`; + } + + case "invalid_union": + return "קלט לא תקין"; + + case "invalid_element": { + const place = withDefinite(issue.origin ?? "array"); + return `ערך לא תקין ב${place}`; + } + + default: + return `קלט לא תקין`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/hr.ts b/gui/frontend/node_modules/zod/src/v4/locales/hr.ts new file mode 100644 index 0000000000000000000000000000000000000000..124c5a27994a538ce33b44f29a424098b20306d8 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/hr.ts @@ -0,0 +1,131 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "znakova", verb: "imati" }, + file: { unit: "bajtova", verb: "imati" }, + array: { unit: "stavki", verb: "imati" }, + set: { unit: "stavki", verb: "imati" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "unos", + email: "email adresa", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO datum i vrijeme", + date: "ISO datum", + time: "ISO vrijeme", + duration: "ISO trajanje", + ipv4: "IPv4 adresa", + ipv6: "IPv6 adresa", + cidrv4: "IPv4 raspon", + cidrv6: "IPv6 raspon", + base64: "base64 kodirani tekst", + base64url: "base64url kodirani tekst", + json_string: "JSON tekst", + e164: "E.164 broj", + jwt: "JWT", + template_literal: "unos", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + string: "tekst", + number: "broj", + boolean: "boolean", + array: "niz", + object: "objekt", + set: "skup", + file: "datoteka", + date: "datum", + bigint: "bigint", + symbol: "simbol", + undefined: "undefined", + null: "null", + function: "funkcija", + map: "mapa", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Neispravan unos: očekuje se instanceof ${issue.expected}, a primljeno je ${received}`; + } + return `Neispravan unos: očekuje se ${expected}, a primljeno je ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Neispravna vrijednost: očekivano ${util.stringifyPrimitive(issue.values[0])}`; + return `Neispravna opcija: očekivano jedno od ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + const origin = TypeDictionary[issue.origin] ?? issue.origin; + if (sizing) + return `Preveliko: očekivano da ${origin ?? "vrijednost"} ima ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemenata"}`; + return `Preveliko: očekivano da ${origin ?? "vrijednost"} bude ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + const origin = TypeDictionary[issue.origin] ?? issue.origin; + if (sizing) { + return `Premalo: očekivano da ${origin} ima ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Premalo: očekivano da ${origin} bude ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Neispravan tekst: mora započinjati s "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Neispravan tekst: mora završavati s "${_issue.suffix}"`; + if (_issue.format === "includes") return `Neispravan tekst: mora sadržavati "${_issue.includes}"`; + if (_issue.format === "regex") return `Neispravan tekst: mora odgovarati uzorku ${_issue.pattern}`; + return `Neispravna ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Neispravan broj: mora biti višekratnik od ${issue.divisor}`; + case "unrecognized_keys": + return `Neprepoznat${issue.keys.length > 1 ? "i ključevi" : " ključ"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Neispravan ključ u ${TypeDictionary[issue.origin] ?? issue.origin}`; + case "invalid_union": + return "Neispravan unos"; + case "invalid_element": + return `Neispravna vrijednost u ${TypeDictionary[issue.origin] ?? issue.origin}`; + default: + return `Neispravan unos`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/hu.ts b/gui/frontend/node_modules/zod/src/v4/locales/hu.ts new file mode 100644 index 0000000000000000000000000000000000000000..5ea46a9d38715b84bbf4f6d16532498fbbb5bb82 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/hu.ts @@ -0,0 +1,117 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "karakter", verb: "legyen" }, + file: { unit: "byte", verb: "legyen" }, + array: { unit: "elem", verb: "legyen" }, + set: { unit: "elem", verb: "legyen" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "bemenet", + email: "email cím", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO időbélyeg", + date: "ISO dátum", + time: "ISO idő", + duration: "ISO időintervallum", + ipv4: "IPv4 cím", + ipv6: "IPv6 cím", + cidrv4: "IPv4 tartomány", + cidrv6: "IPv6 tartomány", + base64: "base64-kódolt string", + base64url: "base64url-kódolt string", + json_string: "JSON string", + e164: "E.164 szám", + jwt: "JWT", + template_literal: "bemenet", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "szám", + array: "tömb", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Érvénytelen bemenet: a várt érték instanceof ${issue.expected}, a kapott érték ${received}`; + } + return `Érvénytelen bemenet: a várt érték ${expected}, a kapott érték ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Érvénytelen bemenet: a várt érték ${util.stringifyPrimitive(issue.values[0])}`; + return `Érvénytelen opció: valamelyik érték várt ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Túl nagy: ${issue.origin ?? "érték"} mérete túl nagy ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elem"}`; + return `Túl nagy: a bemeneti érték ${issue.origin ?? "érték"} túl nagy: ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Túl kicsi: a bemeneti érték ${issue.origin} mérete túl kicsi ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Túl kicsi: a bemeneti érték ${issue.origin} túl kicsi ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Érvénytelen string: "${_issue.prefix}" értékkel kell kezdődnie`; + if (_issue.format === "ends_with") return `Érvénytelen string: "${_issue.suffix}" értékkel kell végződnie`; + if (_issue.format === "includes") return `Érvénytelen string: "${_issue.includes}" értéket kell tartalmaznia`; + if (_issue.format === "regex") return `Érvénytelen string: ${_issue.pattern} mintának kell megfelelnie`; + return `Érvénytelen ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Érvénytelen szám: ${issue.divisor} többszörösének kell lennie`; + case "unrecognized_keys": + return `Ismeretlen kulcs${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Érvénytelen kulcs ${issue.origin}`; + case "invalid_union": + return "Érvénytelen bemenet"; + case "invalid_element": + return `Érvénytelen érték: ${issue.origin}`; + default: + return `Érvénytelen bemenet`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/hy.ts b/gui/frontend/node_modules/zod/src/v4/locales/hy.ts new file mode 100644 index 0000000000000000000000000000000000000000..8635804d6068d7f09d4ce30a50a1ea3293e5da85 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/hy.ts @@ -0,0 +1,164 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +function getArmenianPlural(count: number, one: string, many: string): string { + return Math.abs(count) === 1 ? one : many; +} + +function withDefiniteArticle(word: string | undefined): string { + if (!word) return ""; + const vowels = ["ա", "ե", "ը", "ի", "ո", "ու", "օ"]; + const lastChar = word[word.length - 1]; + return word + (vowels.includes(lastChar) ? "ն" : "ը"); +} + +interface ArmenianSizable { + unit: { + one: string; + many: string; + }; + verb: string; +} + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { + unit: { + one: "նշան", + many: "նշաններ", + }, + verb: "ունենալ", + }, + file: { + unit: { + one: "բայթ", + many: "բայթեր", + }, + verb: "ունենալ", + }, + array: { + unit: { + one: "տարր", + many: "տարրեր", + }, + verb: "ունենալ", + }, + set: { + unit: { + one: "տարր", + many: "տարրեր", + }, + verb: "ունենալ", + }, + }; + + function getSizing(origin: string): ArmenianSizable | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "մուտք", + email: "էլ. հասցե", + url: "URL", + emoji: "էմոջի", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO ամսաթիվ և ժամ", + date: "ISO ամսաթիվ", + time: "ISO ժամ", + duration: "ISO տևողություն", + ipv4: "IPv4 հասցե", + ipv6: "IPv6 հասցե", + cidrv4: "IPv4 միջակայք", + cidrv6: "IPv6 միջակայք", + base64: "base64 ձևաչափով տող", + base64url: "base64url ձևաչափով տող", + json_string: "JSON տող", + e164: "E.164 համար", + jwt: "JWT", + template_literal: "մուտք", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "թիվ", + array: "զանգված", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Սխալ մուտքագրում․ սպասվում էր instanceof ${issue.expected}, ստացվել է ${received}`; + } + return `Սխալ մուտքագրում․ սպասվում էր ${expected}, ստացվել է ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Սխալ մուտքագրում․ սպասվում էր ${util.stringifyPrimitive(issue.values[1])}`; + return `Սխալ տարբերակ․ սպասվում էր հետևյալներից մեկը՝ ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) { + const maxValue = Number(issue.maximum); + const unit = getArmenianPlural(maxValue, sizing.unit.one, sizing.unit.many); + return `Չափազանց մեծ արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin ?? "արժեք")} կունենա ${adj}${issue.maximum.toString()} ${unit}`; + } + return `Չափազանց մեծ արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin ?? "արժեք")} լինի ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + const minValue = Number(issue.minimum); + const unit = getArmenianPlural(minValue, sizing.unit.one, sizing.unit.many); + return `Չափազանց փոքր արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin)} կունենա ${adj}${issue.minimum.toString()} ${unit}`; + } + return `Չափազանց փոքր արժեք․ սպասվում է, որ ${withDefiniteArticle(issue.origin)} լինի ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Սխալ տող․ պետք է սկսվի "${_issue.prefix}"-ով`; + if (_issue.format === "ends_with") return `Սխալ տող․ պետք է ավարտվի "${_issue.suffix}"-ով`; + if (_issue.format === "includes") return `Սխալ տող․ պետք է պարունակի "${_issue.includes}"`; + if (_issue.format === "regex") return `Սխալ տող․ պետք է համապատասխանի ${_issue.pattern} ձևաչափին`; + return `Սխալ ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Սխալ թիվ․ պետք է բազմապատիկ լինի ${issue.divisor}-ի`; + case "unrecognized_keys": + return `Չճանաչված բանալի${issue.keys.length > 1 ? "ներ" : ""}. ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Սխալ բանալի ${withDefiniteArticle(issue.origin)}-ում`; + case "invalid_union": + return "Սխալ մուտքագրում"; + case "invalid_element": + return `Սխալ արժեք ${withDefiniteArticle(issue.origin)}-ում`; + default: + return `Սխալ մուտքագրում`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/id.ts b/gui/frontend/node_modules/zod/src/v4/locales/id.ts new file mode 100644 index 0000000000000000000000000000000000000000..72ca30579999d8e849b31a8289cfb937d75ae93c --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/id.ts @@ -0,0 +1,115 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "karakter", verb: "memiliki" }, + file: { unit: "byte", verb: "memiliki" }, + array: { unit: "item", verb: "memiliki" }, + set: { unit: "item", verb: "memiliki" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "input", + email: "alamat email", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "tanggal dan waktu format ISO", + date: "tanggal format ISO", + time: "jam format ISO", + duration: "durasi format ISO", + ipv4: "alamat IPv4", + ipv6: "alamat IPv6", + cidrv4: "rentang alamat IPv4", + cidrv6: "rentang alamat IPv6", + base64: "string dengan enkode base64", + base64url: "string dengan enkode base64url", + json_string: "string JSON", + e164: "angka E.164", + jwt: "JWT", + template_literal: "input", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Input tidak valid: diharapkan instanceof ${issue.expected}, diterima ${received}`; + } + return `Input tidak valid: diharapkan ${expected}, diterima ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Input tidak valid: diharapkan ${util.stringifyPrimitive(issue.values[0])}`; + return `Pilihan tidak valid: diharapkan salah satu dari ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Terlalu besar: diharapkan ${issue.origin ?? "value"} memiliki ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemen"}`; + return `Terlalu besar: diharapkan ${issue.origin ?? "value"} menjadi ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Terlalu kecil: diharapkan ${issue.origin} memiliki ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Terlalu kecil: diharapkan ${issue.origin} menjadi ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `String tidak valid: harus dimulai dengan "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `String tidak valid: harus berakhir dengan "${_issue.suffix}"`; + if (_issue.format === "includes") return `String tidak valid: harus menyertakan "${_issue.includes}"`; + if (_issue.format === "regex") return `String tidak valid: harus sesuai pola ${_issue.pattern}`; + return `${FormatDictionary[_issue.format] ?? issue.format} tidak valid`; + } + case "not_multiple_of": + return `Angka tidak valid: harus kelipatan dari ${issue.divisor}`; + case "unrecognized_keys": + return `Kunci tidak dikenali ${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Kunci tidak valid di ${issue.origin}`; + case "invalid_union": + return "Input tidak valid"; + case "invalid_element": + return `Nilai tidak valid di ${issue.origin}`; + default: + return `Input tidak valid`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/index.ts b/gui/frontend/node_modules/zod/src/v4/locales/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..2e0c03994bc12a75f58f2c15b91bf4f6e0b4ed6b --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/index.ts @@ -0,0 +1,52 @@ +export { default as ar } from "./ar.js"; +export { default as az } from "./az.js"; +export { default as be } from "./be.js"; +export { default as bg } from "./bg.js"; +export { default as ca } from "./ca.js"; +export { default as cs } from "./cs.js"; +export { default as da } from "./da.js"; +export { default as de } from "./de.js"; +export { default as el } from "./el.js"; +export { default as en } from "./en.js"; +export { default as eo } from "./eo.js"; +export { default as es } from "./es.js"; +export { default as fa } from "./fa.js"; +export { default as fi } from "./fi.js"; +export { default as fr } from "./fr.js"; +export { default as frCA } from "./fr-CA.js"; +export { default as he } from "./he.js"; +export { default as hr } from "./hr.js"; +export { default as hu } from "./hu.js"; +export { default as hy } from "./hy.js"; +export { default as id } from "./id.js"; +export { default as is } from "./is.js"; +export { default as it } from "./it.js"; +export { default as ja } from "./ja.js"; +export { default as ka } from "./ka.js"; +export { default as kh } from "./kh.js"; +export { default as km } from "./km.js"; +export { default as ko } from "./ko.js"; +export { default as lt } from "./lt.js"; +export { default as mk } from "./mk.js"; +export { default as ms } from "./ms.js"; +export { default as nl } from "./nl.js"; +export { default as no } from "./no.js"; +export { default as ota } from "./ota.js"; +export { default as ps } from "./ps.js"; +export { default as pl } from "./pl.js"; +export { default as pt } from "./pt.js"; +export { default as ro } from "./ro.js"; +export { default as ru } from "./ru.js"; +export { default as sl } from "./sl.js"; +export { default as sv } from "./sv.js"; +export { default as ta } from "./ta.js"; +export { default as th } from "./th.js"; +export { default as tr } from "./tr.js"; +export { default as ua } from "./ua.js"; +export { default as uk } from "./uk.js"; +export { default as ur } from "./ur.js"; +export { default as uz } from "./uz.js"; +export { default as vi } from "./vi.js"; +export { default as zhCN } from "./zh-CN.js"; +export { default as zhTW } from "./zh-TW.js"; +export { default as yo } from "./yo.js"; diff --git a/gui/frontend/node_modules/zod/src/v4/locales/is.ts b/gui/frontend/node_modules/zod/src/v4/locales/is.ts new file mode 100644 index 0000000000000000000000000000000000000000..7b3e9f775b0c4d17eb85f42072b8795bb33a3628 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/is.ts @@ -0,0 +1,119 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "stafi", verb: "að hafa" }, + file: { unit: "bæti", verb: "að hafa" }, + array: { unit: "hluti", verb: "að hafa" }, + set: { unit: "hluti", verb: "að hafa" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "gildi", + email: "netfang", + url: "vefslóð", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO dagsetning og tími", + date: "ISO dagsetning", + time: "ISO tími", + duration: "ISO tímalengd", + ipv4: "IPv4 address", + ipv6: "IPv6 address", + cidrv4: "IPv4 range", + cidrv6: "IPv6 range", + base64: "base64-encoded strengur", + base64url: "base64url-encoded strengur", + json_string: "JSON strengur", + e164: "E.164 tölugildi", + jwt: "JWT", + template_literal: "gildi", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "númer", + array: "fylki", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Rangt gildi: Þú slóst inn ${received} þar sem á að vera instanceof ${issue.expected}`; + } + return `Rangt gildi: Þú slóst inn ${received} þar sem á að vera ${expected}`; + } + + case "invalid_value": + if (issue.values.length === 1) return `Rangt gildi: gert ráð fyrir ${util.stringifyPrimitive(issue.values[0])}`; + return `Ógilt val: má vera eitt af eftirfarandi ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Of stórt: gert er ráð fyrir að ${issue.origin ?? "gildi"} hafi ${adj}${issue.maximum.toString()} ${sizing.unit ?? "hluti"}`; + return `Of stórt: gert er ráð fyrir að ${issue.origin ?? "gildi"} sé ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Of lítið: gert er ráð fyrir að ${issue.origin} hafi ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Of lítið: gert er ráð fyrir að ${issue.origin} sé ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Ógildur strengur: verður að byrja á "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Ógildur strengur: verður að enda á "${_issue.suffix}"`; + if (_issue.format === "includes") return `Ógildur strengur: verður að innihalda "${_issue.includes}"`; + if (_issue.format === "regex") return `Ógildur strengur: verður að fylgja mynstri ${_issue.pattern}`; + return `Rangt ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Röng tala: verður að vera margfeldi af ${issue.divisor}`; + case "unrecognized_keys": + return `Óþekkt ${issue.keys.length > 1 ? "ir lyklar" : "ur lykill"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Rangur lykill í ${issue.origin}`; + case "invalid_union": + return "Rangt gildi"; + case "invalid_element": + return `Rangt gildi í ${issue.origin}`; + default: + return `Rangt gildi`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/it.ts b/gui/frontend/node_modules/zod/src/v4/locales/it.ts new file mode 100644 index 0000000000000000000000000000000000000000..68074fac8f3be801bd52f6bfb6347cb3b8d0331c --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/it.ts @@ -0,0 +1,116 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "caratteri", verb: "avere" }, + file: { unit: "byte", verb: "avere" }, + array: { unit: "elementi", verb: "avere" }, + set: { unit: "elementi", verb: "avere" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "input", + email: "indirizzo email", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "data e ora ISO", + date: "data ISO", + time: "ora ISO", + duration: "durata ISO", + ipv4: "indirizzo IPv4", + ipv6: "indirizzo IPv6", + cidrv4: "intervallo IPv4", + cidrv6: "intervallo IPv6", + base64: "stringa codificata in base64", + base64url: "URL codificata in base64", + json_string: "stringa JSON", + e164: "numero E.164", + jwt: "JWT", + template_literal: "input", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "numero", + array: "vettore", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Input non valido: atteso instanceof ${issue.expected}, ricevuto ${received}`; + } + return `Input non valido: atteso ${expected}, ricevuto ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Input non valido: atteso ${util.stringifyPrimitive(issue.values[0])}`; + return `Opzione non valida: atteso uno tra ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Troppo grande: ${issue.origin ?? "valore"} deve avere ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementi"}`; + return `Troppo grande: ${issue.origin ?? "valore"} deve essere ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Troppo piccolo: ${issue.origin} deve avere ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Troppo piccolo: ${issue.origin} deve essere ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Stringa non valida: deve iniziare con "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Stringa non valida: deve terminare con "${_issue.suffix}"`; + if (_issue.format === "includes") return `Stringa non valida: deve includere "${_issue.includes}"`; + if (_issue.format === "regex") return `Stringa non valida: deve corrispondere al pattern ${_issue.pattern}`; + return `Input non valido: ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Numero non valido: deve essere un multiplo di ${issue.divisor}`; + case "unrecognized_keys": + return `Chiav${issue.keys.length > 1 ? "i" : "e"} non riconosciut${issue.keys.length > 1 ? "e" : "a"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Chiave non valida in ${issue.origin}`; + case "invalid_union": + return "Input non valido"; + case "invalid_element": + return `Valore non valido in ${issue.origin}`; + default: + return `Input non valido`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ja.ts b/gui/frontend/node_modules/zod/src/v4/locales/ja.ts new file mode 100644 index 0000000000000000000000000000000000000000..0cb3c5c8057e86af6740b1c0b42093ff255de58d --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ja.ts @@ -0,0 +1,114 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "文字", verb: "である" }, + file: { unit: "バイト", verb: "である" }, + array: { unit: "要素", verb: "である" }, + set: { unit: "要素", verb: "である" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "入力値", + email: "メールアドレス", + url: "URL", + emoji: "絵文字", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO日時", + date: "ISO日付", + time: "ISO時刻", + duration: "ISO期間", + ipv4: "IPv4アドレス", + ipv6: "IPv6アドレス", + cidrv4: "IPv4範囲", + cidrv6: "IPv6範囲", + base64: "base64エンコード文字列", + base64url: "base64urlエンコード文字列", + json_string: "JSON文字列", + e164: "E.164番号", + jwt: "JWT", + template_literal: "入力値", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "数値", + array: "配列", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `無効な入力: instanceof ${issue.expected}が期待されましたが、${received}が入力されました`; + } + return `無効な入力: ${expected}が期待されましたが、${received}が入力されました`; + } + case "invalid_value": + if (issue.values.length === 1) return `無効な入力: ${util.stringifyPrimitive(issue.values[0])}が期待されました`; + return `無効な選択: ${util.joinValues(issue.values, "、")}のいずれかである必要があります`; + case "too_big": { + const adj = issue.inclusive ? "以下である" : "より小さい"; + const sizing = getSizing(issue.origin); + if (sizing) + return `大きすぎる値: ${issue.origin ?? "値"}は${issue.maximum.toString()}${sizing.unit ?? "要素"}${adj}必要があります`; + return `大きすぎる値: ${issue.origin ?? "値"}は${issue.maximum.toString()}${adj}必要があります`; + } + case "too_small": { + const adj = issue.inclusive ? "以上である" : "より大きい"; + const sizing = getSizing(issue.origin); + if (sizing) + return `小さすぎる値: ${issue.origin}は${issue.minimum.toString()}${sizing.unit}${adj}必要があります`; + return `小さすぎる値: ${issue.origin}は${issue.minimum.toString()}${adj}必要があります`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `無効な文字列: "${_issue.prefix}"で始まる必要があります`; + if (_issue.format === "ends_with") return `無効な文字列: "${_issue.suffix}"で終わる必要があります`; + if (_issue.format === "includes") return `無効な文字列: "${_issue.includes}"を含む必要があります`; + if (_issue.format === "regex") return `無効な文字列: パターン${_issue.pattern}に一致する必要があります`; + return `無効な${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `無効な数値: ${issue.divisor}の倍数である必要があります`; + case "unrecognized_keys": + return `認識されていないキー${issue.keys.length > 1 ? "群" : ""}: ${util.joinValues(issue.keys, "、")}`; + case "invalid_key": + return `${issue.origin}内の無効なキー`; + case "invalid_union": + return "無効な入力"; + case "invalid_element": + return `${issue.origin}内の無効な値`; + default: + return `無効な入力`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ka.ts b/gui/frontend/node_modules/zod/src/v4/locales/ka.ts new file mode 100644 index 0000000000000000000000000000000000000000..867843fbcc8333010b3d88e9faa10622a9654a09 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ka.ts @@ -0,0 +1,123 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "სიმბოლო", verb: "უნდა შეიცავდეს" }, + file: { unit: "ბაიტი", verb: "უნდა შეიცავდეს" }, + array: { unit: "ელემენტი", verb: "უნდა შეიცავდეს" }, + set: { unit: "ელემენტი", verb: "უნდა შეიცავდეს" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "შეყვანა", + email: "ელ-ფოსტის მისამართი", + url: "URL", + emoji: "ემოჯი", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "თარიღი-დრო", + date: "თარიღი", + time: "დრო", + duration: "ხანგრძლივობა", + ipv4: "IPv4 მისამართი", + ipv6: "IPv6 მისამართი", + cidrv4: "IPv4 დიაპაზონი", + cidrv6: "IPv6 დიაპაზონი", + base64: "base64-კოდირებული ველი", + base64url: "base64url-კოდირებული ველი", + json_string: "JSON ველი", + e164: "E.164 ნომერი", + jwt: "JWT", + template_literal: "შეყვანა", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "რიცხვი", + string: "ველი", + boolean: "ბულეანი", + function: "ფუნქცია", + array: "მასივი", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `არასწორი შეყვანა: მოსალოდნელი instanceof ${issue.expected}, მიღებული ${received}`; + } + return `არასწორი შეყვანა: მოსალოდნელი ${expected}, მიღებული ${received}`; + } + + case "invalid_value": + if (issue.values.length === 1) + return `არასწორი შეყვანა: მოსალოდნელი ${util.stringifyPrimitive(issue.values[0])}`; + return `არასწორი ვარიანტი: მოსალოდნელია ერთ-ერთი ${util.joinValues(issue.values, "|")}-დან`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `ზედმეტად დიდი: მოსალოდნელი ${issue.origin ?? "მნიშვნელობა"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit}`; + return `ზედმეტად დიდი: მოსალოდნელი ${issue.origin ?? "მნიშვნელობა"} იყოს ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `ზედმეტად პატარა: მოსალოდნელი ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `ზედმეტად პატარა: მოსალოდნელი ${issue.origin} იყოს ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `არასწორი ველი: უნდა იწყებოდეს "${_issue.prefix}"-ით`; + } + if (_issue.format === "ends_with") return `არასწორი ველი: უნდა მთავრდებოდეს "${_issue.suffix}"-ით`; + if (_issue.format === "includes") return `არასწორი ველი: უნდა შეიცავდეს "${_issue.includes}"-ს`; + if (_issue.format === "regex") return `არასწორი ველი: უნდა შეესაბამებოდეს შაბლონს ${_issue.pattern}`; + return `არასწორი ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `არასწორი რიცხვი: უნდა იყოს ${issue.divisor}-ის ჯერადი`; + case "unrecognized_keys": + return `უცნობი გასაღებ${issue.keys.length > 1 ? "ები" : "ი"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `არასწორი გასაღები ${issue.origin}-ში`; + case "invalid_union": + return "არასწორი შეყვანა"; + case "invalid_element": + return `არასწორი მნიშვნელობა ${issue.origin}-ში`; + default: + return `არასწორი შეყვანა`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/kh.ts b/gui/frontend/node_modules/zod/src/v4/locales/kh.ts new file mode 100644 index 0000000000000000000000000000000000000000..84371b306d97564f3bacc90e443c0b3c46243230 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/kh.ts @@ -0,0 +1,7 @@ +import type * as errors from "../core/errors.js"; +import km from "./km.js"; + +/** @deprecated Use `km` instead. */ +export default function (): { localeError: errors.$ZodErrorMap } { + return km(); +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/km.ts b/gui/frontend/node_modules/zod/src/v4/locales/km.ts new file mode 100644 index 0000000000000000000000000000000000000000..9988eadc8f55159bcc58c61e10d1278c528dd197 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/km.ts @@ -0,0 +1,119 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "តួអក្សរ", verb: "គួរមាន" }, + file: { unit: "បៃ", verb: "គួរមាន" }, + array: { unit: "ធាតុ", verb: "គួរមាន" }, + set: { unit: "ធាតុ", verb: "គួរមាន" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "ទិន្នន័យបញ្ចូល", + email: "អាសយដ្ឋានអ៊ីមែល", + url: "URL", + emoji: "សញ្ញាអារម្មណ៍", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "កាលបរិច្ឆេទ និងម៉ោង ISO", + date: "កាលបរិច្ឆេទ ISO", + time: "ម៉ោង ISO", + duration: "រយៈពេល ISO", + ipv4: "អាសយដ្ឋាន IPv4", + ipv6: "អាសយដ្ឋាន IPv6", + cidrv4: "ដែនអាសយដ្ឋាន IPv4", + cidrv6: "ដែនអាសយដ្ឋាន IPv6", + base64: "ខ្សែអក្សរអ៊ិកូដ base64", + base64url: "ខ្សែអក្សរអ៊ិកូដ base64url", + json_string: "ខ្សែអក្សរ JSON", + e164: "លេខ E.164", + jwt: "JWT", + template_literal: "ទិន្នន័យបញ្ចូល", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "លេខ", + array: "អារេ (Array)", + null: "គ្មានតម្លៃ (null)", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ instanceof ${issue.expected} ប៉ុន្តែទទួលបាន ${received}`; + } + return `ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${expected} ប៉ុន្តែទទួលបាន ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${util.stringifyPrimitive(issue.values[0])}`; + return `ជម្រើសមិនត្រឹមត្រូវ៖ ត្រូវជាមួយក្នុងចំណោម ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `ធំពេក៖ ត្រូវការ ${issue.origin ?? "តម្លៃ"} ${adj} ${issue.maximum.toString()} ${sizing.unit ?? "ធាតុ"}`; + return `ធំពេក៖ ត្រូវការ ${issue.origin ?? "តម្លៃ"} ${adj} ${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `តូចពេក៖ ត្រូវការ ${issue.origin} ${adj} ${issue.minimum.toString()} ${sizing.unit}`; + } + + return `តូចពេក៖ ត្រូវការ ${issue.origin} ${adj} ${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវចាប់ផ្តើមដោយ "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវបញ្ចប់ដោយ "${_issue.suffix}"`; + if (_issue.format === "includes") return `ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវមាន "${_issue.includes}"`; + if (_issue.format === "regex") return `ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវតែផ្គូផ្គងនឹងទម្រង់ដែលបានកំណត់ ${_issue.pattern}`; + return `មិនត្រឹមត្រូវ៖ ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `លេខមិនត្រឹមត្រូវ៖ ត្រូវតែជាពហុគុណនៃ ${issue.divisor}`; + case "unrecognized_keys": + return `រកឃើញសោមិនស្គាល់៖ ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `សោមិនត្រឹមត្រូវនៅក្នុង ${issue.origin}`; + case "invalid_union": + return `ទិន្នន័យមិនត្រឹមត្រូវ`; + case "invalid_element": + return `ទិន្នន័យមិនត្រឹមត្រូវនៅក្នុង ${issue.origin}`; + default: + return `ទិន្នន័យមិនត្រឹមត្រូវ`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ko.ts b/gui/frontend/node_modules/zod/src/v4/locales/ko.ts new file mode 100644 index 0000000000000000000000000000000000000000..fb55b0d6d407bd03eaeb0a17888fe13106eccb6c --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ko.ts @@ -0,0 +1,121 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "문자", verb: "to have" }, + file: { unit: "바이트", verb: "to have" }, + array: { unit: "개", verb: "to have" }, + set: { unit: "개", verb: "to have" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "입력", + email: "이메일 주소", + url: "URL", + emoji: "이모지", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO 날짜시간", + date: "ISO 날짜", + time: "ISO 시간", + duration: "ISO 기간", + ipv4: "IPv4 주소", + ipv6: "IPv6 주소", + cidrv4: "IPv4 범위", + cidrv6: "IPv6 범위", + base64: "base64 인코딩 문자열", + base64url: "base64url 인코딩 문자열", + json_string: "JSON 문자열", + e164: "E.164 번호", + jwt: "JWT", + template_literal: "입력", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `잘못된 입력: 예상 타입은 instanceof ${issue.expected}, 받은 타입은 ${received}입니다`; + } + return `잘못된 입력: 예상 타입은 ${expected}, 받은 타입은 ${received}입니다`; + } + case "invalid_value": + if (issue.values.length === 1) + return `잘못된 입력: 값은 ${util.stringifyPrimitive(issue.values[0])} 이어야 합니다`; + return `잘못된 옵션: ${util.joinValues(issue.values, "또는 ")} 중 하나여야 합니다`; + case "too_big": { + const adj = issue.inclusive ? "이하" : "미만"; + const suffix = adj === "미만" ? "이어야 합니다" : "여야 합니다"; + const sizing = getSizing(issue.origin); + const unit = sizing?.unit ?? "요소"; + if (sizing) return `${issue.origin ?? "값"}이 너무 큽니다: ${issue.maximum.toString()}${unit} ${adj}${suffix}`; + + return `${issue.origin ?? "값"}이 너무 큽니다: ${issue.maximum.toString()} ${adj}${suffix}`; + } + case "too_small": { + const adj = issue.inclusive ? "이상" : "초과"; + const suffix = adj === "이상" ? "이어야 합니다" : "여야 합니다"; + const sizing = getSizing(issue.origin); + const unit = sizing?.unit ?? "요소"; + if (sizing) { + return `${issue.origin ?? "값"}이 너무 작습니다: ${issue.minimum.toString()}${unit} ${adj}${suffix}`; + } + + return `${issue.origin ?? "값"}이 너무 작습니다: ${issue.minimum.toString()} ${adj}${suffix}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `잘못된 문자열: "${_issue.prefix}"(으)로 시작해야 합니다`; + } + if (_issue.format === "ends_with") return `잘못된 문자열: "${_issue.suffix}"(으)로 끝나야 합니다`; + if (_issue.format === "includes") return `잘못된 문자열: "${_issue.includes}"을(를) 포함해야 합니다`; + if (_issue.format === "regex") return `잘못된 문자열: 정규식 ${_issue.pattern} 패턴과 일치해야 합니다`; + return `잘못된 ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `잘못된 숫자: ${issue.divisor}의 배수여야 합니다`; + case "unrecognized_keys": + return `인식할 수 없는 키: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `잘못된 키: ${issue.origin}`; + case "invalid_union": + return `잘못된 입력`; + case "invalid_element": + return `잘못된 값: ${issue.origin}`; + default: + return `잘못된 입력`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/lt.ts b/gui/frontend/node_modules/zod/src/v4/locales/lt.ts new file mode 100644 index 0000000000000000000000000000000000000000..f4d4e17713e983869a0497dc5efab0068481e9dc --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/lt.ts @@ -0,0 +1,239 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const capitalizeFirstCharacter = (text: string): string => { + return text.charAt(0).toUpperCase() + text.slice(1); +}; + +type UnitType = "one" | "few" | "many"; +type SizeableComparisonType = "smaller" | "bigger"; + +function getUnitTypeFromNumber(number: number): UnitType { + const abs = Math.abs(number); + const last = abs % 10; + const last2 = abs % 100; + + if ((last2 >= 11 && last2 <= 19) || last === 0) return "many"; + if (last === 1) return "one"; + return "few"; +} + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record< + string, + { + unit: Record; + verb: Record; + } + > = { + string: { + unit: { + one: "simbolis", + few: "simboliai", + many: "simbolių", + }, + verb: { + smaller: { + inclusive: "turi būti ne ilgesnė kaip", + notInclusive: "turi būti trumpesnė kaip", + }, + bigger: { + inclusive: "turi būti ne trumpesnė kaip", + notInclusive: "turi būti ilgesnė kaip", + }, + }, + }, + file: { + unit: { + one: "baitas", + few: "baitai", + many: "baitų", + }, + verb: { + smaller: { + inclusive: "turi būti ne didesnis kaip", + notInclusive: "turi būti mažesnis kaip", + }, + bigger: { + inclusive: "turi būti ne mažesnis kaip", + notInclusive: "turi būti didesnis kaip", + }, + }, + }, + array: { + unit: { + one: "elementą", + few: "elementus", + many: "elementų", + }, + verb: { + smaller: { + inclusive: "turi turėti ne daugiau kaip", + notInclusive: "turi turėti mažiau kaip", + }, + bigger: { + inclusive: "turi turėti ne mažiau kaip", + notInclusive: "turi turėti daugiau kaip", + }, + }, + }, + set: { + unit: { + one: "elementą", + few: "elementus", + many: "elementų", + }, + verb: { + smaller: { + inclusive: "turi turėti ne daugiau kaip", + notInclusive: "turi turėti mažiau kaip", + }, + bigger: { + inclusive: "turi turėti ne mažiau kaip", + notInclusive: "turi turėti daugiau kaip", + }, + }, + }, + }; + + function getSizing( + origin: string, + unitType: UnitType, + inclusive: boolean, + targetShouldBe: SizeableComparisonType + ): { + unit: string; + verb: string; + } | null { + const result = Sizable[origin] ?? null; + if (result === null) return result; + + return { + unit: result.unit[unitType], + verb: result.verb[targetShouldBe][inclusive ? "inclusive" : "notInclusive"], + }; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "įvestis", + email: "el. pašto adresas", + url: "URL", + emoji: "jaustukas", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO data ir laikas", + date: "ISO data", + time: "ISO laikas", + duration: "ISO trukmė", + ipv4: "IPv4 adresas", + ipv6: "IPv6 adresas", + cidrv4: "IPv4 tinklo prefiksas (CIDR)", + cidrv6: "IPv6 tinklo prefiksas (CIDR)", + base64: "base64 užkoduota eilutė", + base64url: "base64url užkoduota eilutė", + json_string: "JSON eilutė", + e164: "E.164 numeris", + jwt: "JWT", + template_literal: "įvestis", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "skaičius", + bigint: "sveikasis skaičius", + string: "eilutė", + boolean: "loginė reikšmė", + undefined: "neapibrėžta reikšmė", + function: "funkcija", + symbol: "simbolis", + array: "masyvas", + object: "objektas", + null: "nulinė reikšmė", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Gautas tipas ${received}, o tikėtasi - instanceof ${issue.expected}`; + } + return `Gautas tipas ${received}, o tikėtasi - ${expected}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Privalo būti ${util.stringifyPrimitive(issue.values[0])}`; + return `Privalo būti vienas iš ${util.joinValues(issue.values, "|")} pasirinkimų`; + case "too_big": { + const origin = TypeDictionary[issue.origin] ?? issue.origin; + const sizing = getSizing( + issue.origin, + getUnitTypeFromNumber(Number(issue.maximum)), + issue.inclusive ?? false, + "smaller" + ); + if (sizing?.verb) + return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} ${sizing.verb} ${issue.maximum.toString()} ${sizing.unit ?? "elementų"}`; + const adj = issue.inclusive ? "ne didesnis kaip" : "mažesnis kaip"; + return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi būti ${adj} ${issue.maximum.toString()} ${sizing?.unit}`; + } + case "too_small": { + const origin = TypeDictionary[issue.origin] ?? issue.origin; + const sizing = getSizing( + issue.origin, + getUnitTypeFromNumber(Number(issue.minimum)), + issue.inclusive ?? false, + "bigger" + ); + if (sizing?.verb) + return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} ${sizing.verb} ${issue.minimum.toString()} ${sizing.unit ?? "elementų"}`; + const adj = issue.inclusive ? "ne mažesnis kaip" : "didesnis kaip"; + return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi būti ${adj} ${issue.minimum.toString()} ${sizing?.unit}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Eilutė privalo prasidėti "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Eilutė privalo pasibaigti "${_issue.suffix}"`; + if (_issue.format === "includes") return `Eilutė privalo įtraukti "${_issue.includes}"`; + if (_issue.format === "regex") return `Eilutė privalo atitikti ${_issue.pattern}`; + return `Neteisingas ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Skaičius privalo būti ${issue.divisor} kartotinis.`; + case "unrecognized_keys": + return `Neatpažint${issue.keys.length > 1 ? "i" : "as"} rakt${issue.keys.length > 1 ? "ai" : "as"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return "Rastas klaidingas raktas"; + case "invalid_union": + return "Klaidinga įvestis"; + case "invalid_element": { + const origin = TypeDictionary[issue.origin] ?? issue.origin; + return `${capitalizeFirstCharacter(origin ?? issue.origin ?? "reikšmė")} turi klaidingą įvestį`; + } + default: + return "Klaidinga įvestis"; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/mk.ts b/gui/frontend/node_modules/zod/src/v4/locales/mk.ts new file mode 100644 index 0000000000000000000000000000000000000000..f320fa83aedb58c63c7f42c4bca16a433e786591 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/mk.ts @@ -0,0 +1,118 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "знаци", verb: "да имаат" }, + file: { unit: "бајти", verb: "да имаат" }, + array: { unit: "ставки", verb: "да имаат" }, + set: { unit: "ставки", verb: "да имаат" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "внес", + email: "адреса на е-пошта", + url: "URL", + emoji: "емоџи", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO датум и време", + date: "ISO датум", + time: "ISO време", + duration: "ISO времетраење", + ipv4: "IPv4 адреса", + ipv6: "IPv6 адреса", + cidrv4: "IPv4 опсег", + cidrv6: "IPv6 опсег", + base64: "base64-енкодирана низа", + base64url: "base64url-енкодирана низа", + json_string: "JSON низа", + e164: "E.164 број", + jwt: "JWT", + template_literal: "внес", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "број", + array: "низа", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Грешен внес: се очекува instanceof ${issue.expected}, примено ${received}`; + } + return `Грешен внес: се очекува ${expected}, примено ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Invalid input: expected ${util.stringifyPrimitive(issue.values[0])}`; + return `Грешана опција: се очекува една ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Премногу голем: се очекува ${issue.origin ?? "вредноста"} да има ${adj}${issue.maximum.toString()} ${sizing.unit ?? "елементи"}`; + return `Премногу голем: се очекува ${issue.origin ?? "вредноста"} да биде ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Премногу мал: се очекува ${issue.origin} да има ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Премногу мал: се очекува ${issue.origin} да биде ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Неважечка низа: мора да започнува со "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Неважечка низа: мора да завршува со "${_issue.suffix}"`; + if (_issue.format === "includes") return `Неважечка низа: мора да вклучува "${_issue.includes}"`; + if (_issue.format === "regex") return `Неважечка низа: мора да одгоара на патернот ${_issue.pattern}`; + return `Invalid ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Грешен број: мора да биде делив со ${issue.divisor}`; + case "unrecognized_keys": + return `${issue.keys.length > 1 ? "Непрепознаени клучеви" : "Непрепознаен клуч"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Грешен клуч во ${issue.origin}`; + case "invalid_union": + return "Грешен внес"; + case "invalid_element": + return `Грешна вредност во ${issue.origin}`; + default: + return `Грешен внес`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ms.ts b/gui/frontend/node_modules/zod/src/v4/locales/ms.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ead32da42980807c3bf327506a8a98fd0ab974d --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ms.ts @@ -0,0 +1,115 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "aksara", verb: "mempunyai" }, + file: { unit: "bait", verb: "mempunyai" }, + array: { unit: "elemen", verb: "mempunyai" }, + set: { unit: "elemen", verb: "mempunyai" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "input", + email: "alamat e-mel", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "tarikh masa ISO", + date: "tarikh ISO", + time: "masa ISO", + duration: "tempoh ISO", + ipv4: "alamat IPv4", + ipv6: "alamat IPv6", + cidrv4: "julat IPv4", + cidrv6: "julat IPv6", + base64: "string dikodkan base64", + base64url: "string dikodkan base64url", + json_string: "string JSON", + e164: "nombor E.164", + jwt: "JWT", + template_literal: "input", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "nombor", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Input tidak sah: dijangka instanceof ${issue.expected}, diterima ${received}`; + } + return `Input tidak sah: dijangka ${expected}, diterima ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Input tidak sah: dijangka ${util.stringifyPrimitive(issue.values[0])}`; + return `Pilihan tidak sah: dijangka salah satu daripada ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Terlalu besar: dijangka ${issue.origin ?? "nilai"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemen"}`; + return `Terlalu besar: dijangka ${issue.origin ?? "nilai"} adalah ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Terlalu kecil: dijangka ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Terlalu kecil: dijangka ${issue.origin} adalah ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `String tidak sah: mesti bermula dengan "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `String tidak sah: mesti berakhir dengan "${_issue.suffix}"`; + if (_issue.format === "includes") return `String tidak sah: mesti mengandungi "${_issue.includes}"`; + if (_issue.format === "regex") return `String tidak sah: mesti sepadan dengan corak ${_issue.pattern}`; + return `${FormatDictionary[_issue.format] ?? issue.format} tidak sah`; + } + case "not_multiple_of": + return `Nombor tidak sah: perlu gandaan ${issue.divisor}`; + case "unrecognized_keys": + return `Kunci tidak dikenali: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Kunci tidak sah dalam ${issue.origin}`; + case "invalid_union": + return "Input tidak sah"; + case "invalid_element": + return `Nilai tidak sah dalam ${issue.origin}`; + default: + return `Input tidak sah`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/nl.ts b/gui/frontend/node_modules/zod/src/v4/locales/nl.ts new file mode 100644 index 0000000000000000000000000000000000000000..3ed3099e5e9cc5ad7d1bd65bb5be98e4bff7f6d6 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/nl.ts @@ -0,0 +1,121 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "tekens", verb: "heeft" }, + file: { unit: "bytes", verb: "heeft" }, + array: { unit: "elementen", verb: "heeft" }, + set: { unit: "elementen", verb: "heeft" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "invoer", + email: "emailadres", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO datum en tijd", + date: "ISO datum", + time: "ISO tijd", + duration: "ISO duur", + ipv4: "IPv4-adres", + ipv6: "IPv6-adres", + cidrv4: "IPv4-bereik", + cidrv6: "IPv6-bereik", + base64: "base64-gecodeerde tekst", + base64url: "base64 URL-gecodeerde tekst", + json_string: "JSON string", + e164: "E.164-nummer", + jwt: "JWT", + template_literal: "invoer", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "getal", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Ongeldige invoer: verwacht instanceof ${issue.expected}, ontving ${received}`; + } + return `Ongeldige invoer: verwacht ${expected}, ontving ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Ongeldige invoer: verwacht ${util.stringifyPrimitive(issue.values[0])}`; + return `Ongeldige optie: verwacht één van ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + const longName = issue.origin === "date" ? "laat" : issue.origin === "string" ? "lang" : "groot"; + + if (sizing) + return `Te ${longName}: verwacht dat ${issue.origin ?? "waarde"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementen"} ${sizing.verb}`; + return `Te ${longName}: verwacht dat ${issue.origin ?? "waarde"} ${adj}${issue.maximum.toString()} is`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + const shortName = issue.origin === "date" ? "vroeg" : issue.origin === "string" ? "kort" : "klein"; + + if (sizing) { + return `Te ${shortName}: verwacht dat ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} ${sizing.verb}`; + } + + return `Te ${shortName}: verwacht dat ${issue.origin} ${adj}${issue.minimum.toString()} is`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Ongeldige tekst: moet met "${_issue.prefix}" beginnen`; + } + if (_issue.format === "ends_with") return `Ongeldige tekst: moet op "${_issue.suffix}" eindigen`; + if (_issue.format === "includes") return `Ongeldige tekst: moet "${_issue.includes}" bevatten`; + if (_issue.format === "regex") return `Ongeldige tekst: moet overeenkomen met patroon ${_issue.pattern}`; + return `Ongeldig: ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Ongeldig getal: moet een veelvoud van ${issue.divisor} zijn`; + case "unrecognized_keys": + return `Onbekende key${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Ongeldige key in ${issue.origin}`; + case "invalid_union": + return "Ongeldige invoer"; + case "invalid_element": + return `Ongeldige waarde in ${issue.origin}`; + default: + return `Ongeldige invoer`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/no.ts b/gui/frontend/node_modules/zod/src/v4/locales/no.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca3028eb2a8283137456f9919b4c36c3f041942b --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/no.ts @@ -0,0 +1,116 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "tegn", verb: "å ha" }, + file: { unit: "bytes", verb: "å ha" }, + array: { unit: "elementer", verb: "å inneholde" }, + set: { unit: "elementer", verb: "å inneholde" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "input", + email: "e-postadresse", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO dato- og klokkeslett", + date: "ISO-dato", + time: "ISO-klokkeslett", + duration: "ISO-varighet", + ipv4: "IPv4-område", + ipv6: "IPv6-område", + cidrv4: "IPv4-spekter", + cidrv6: "IPv6-spekter", + base64: "base64-enkodet streng", + base64url: "base64url-enkodet streng", + json_string: "JSON-streng", + e164: "E.164-nummer", + jwt: "JWT", + template_literal: "input", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "tall", + array: "liste", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Ugyldig input: forventet instanceof ${issue.expected}, fikk ${received}`; + } + return `Ugyldig input: forventet ${expected}, fikk ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Ugyldig verdi: forventet ${util.stringifyPrimitive(issue.values[0])}`; + return `Ugyldig valg: forventet en av ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `For stor(t): forventet ${issue.origin ?? "value"} til å ha ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementer"}`; + return `For stor(t): forventet ${issue.origin ?? "value"} til å ha ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `For lite(n): forventet ${issue.origin} til å ha ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `For lite(n): forventet ${issue.origin} til å ha ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Ugyldig streng: må starte med "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Ugyldig streng: må ende med "${_issue.suffix}"`; + if (_issue.format === "includes") return `Ugyldig streng: må inneholde "${_issue.includes}"`; + if (_issue.format === "regex") return `Ugyldig streng: må matche mønsteret ${_issue.pattern}`; + return `Ugyldig ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Ugyldig tall: må være et multiplum av ${issue.divisor}`; + case "unrecognized_keys": + return `${issue.keys.length > 1 ? "Ukjente nøkler" : "Ukjent nøkkel"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Ugyldig nøkkel i ${issue.origin}`; + case "invalid_union": + return "Ugyldig input"; + case "invalid_element": + return `Ugyldig verdi i ${issue.origin}`; + default: + return `Ugyldig input`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ota.ts b/gui/frontend/node_modules/zod/src/v4/locales/ota.ts new file mode 100644 index 0000000000000000000000000000000000000000..d157d864db39b9329d5c0e306326b849fd772523 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ota.ts @@ -0,0 +1,117 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "harf", verb: "olmalıdır" }, + file: { unit: "bayt", verb: "olmalıdır" }, + array: { unit: "unsur", verb: "olmalıdır" }, + set: { unit: "unsur", verb: "olmalıdır" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "giren", + email: "epostagâh", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO hengâmı", + date: "ISO tarihi", + time: "ISO zamanı", + duration: "ISO müddeti", + ipv4: "IPv4 nişânı", + ipv6: "IPv6 nişânı", + cidrv4: "IPv4 menzili", + cidrv6: "IPv6 menzili", + base64: "base64-şifreli metin", + base64url: "base64url-şifreli metin", + json_string: "JSON metin", + e164: "E.164 sayısı", + jwt: "JWT", + template_literal: "giren", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "numara", + array: "saf", + null: "gayb", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Fâsit giren: umulan instanceof ${issue.expected}, alınan ${received}`; + } + return `Fâsit giren: umulan ${expected}, alınan ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Fâsit giren: umulan ${util.stringifyPrimitive(issue.values[0])}`; + return `Fâsit tercih: mûteberler ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Fazla büyük: ${issue.origin ?? "value"}, ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elements"} sahip olmalıydı.`; + return `Fazla büyük: ${issue.origin ?? "value"}, ${adj}${issue.maximum.toString()} olmalıydı.`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Fazla küçük: ${issue.origin}, ${adj}${issue.minimum.toString()} ${sizing.unit} sahip olmalıydı.`; + } + + return `Fazla küçük: ${issue.origin}, ${adj}${issue.minimum.toString()} olmalıydı.`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Fâsit metin: "${_issue.prefix}" ile başlamalı.`; + if (_issue.format === "ends_with") return `Fâsit metin: "${_issue.suffix}" ile bitmeli.`; + if (_issue.format === "includes") return `Fâsit metin: "${_issue.includes}" ihtivâ etmeli.`; + if (_issue.format === "regex") return `Fâsit metin: ${_issue.pattern} nakşına uymalı.`; + return `Fâsit ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Fâsit sayı: ${issue.divisor} katı olmalıydı.`; + case "unrecognized_keys": + return `Tanınmayan anahtar ${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `${issue.origin} için tanınmayan anahtar var.`; + case "invalid_union": + return "Giren tanınamadı."; + case "invalid_element": + return `${issue.origin} için tanınmayan kıymet var.`; + default: + return `Kıymet tanınamadı.`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/pl.ts b/gui/frontend/node_modules/zod/src/v4/locales/pl.ts new file mode 100644 index 0000000000000000000000000000000000000000..df7a7c60ca660839db565b849b2f326c9e79b3bd --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/pl.ts @@ -0,0 +1,118 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "znaków", verb: "mieć" }, + file: { unit: "bajtów", verb: "mieć" }, + array: { unit: "elementów", verb: "mieć" }, + set: { unit: "elementów", verb: "mieć" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "wyrażenie", + email: "adres email", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "data i godzina w formacie ISO", + date: "data w formacie ISO", + time: "godzina w formacie ISO", + duration: "czas trwania ISO", + ipv4: "adres IPv4", + ipv6: "adres IPv6", + cidrv4: "zakres IPv4", + cidrv6: "zakres IPv6", + base64: "ciąg znaków zakodowany w formacie base64", + base64url: "ciąg znaków zakodowany w formacie base64url", + json_string: "ciąg znaków w formacie JSON", + e164: "liczba E.164", + jwt: "JWT", + template_literal: "wejście", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "liczba", + array: "tablica", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Nieprawidłowe dane wejściowe: oczekiwano instanceof ${issue.expected}, otrzymano ${received}`; + } + return `Nieprawidłowe dane wejściowe: oczekiwano ${expected}, otrzymano ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Nieprawidłowe dane wejściowe: oczekiwano ${util.stringifyPrimitive(issue.values[0])}`; + return `Nieprawidłowa opcja: oczekiwano jednej z wartości ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Za duża wartość: oczekiwano, że ${issue.origin ?? "wartość"} będzie mieć ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementów"}`; + } + return `Zbyt duż(y/a/e): oczekiwano, że ${issue.origin ?? "wartość"} będzie wynosić ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Za mała wartość: oczekiwano, że ${issue.origin ?? "wartość"} będzie mieć ${adj}${issue.minimum.toString()} ${sizing.unit ?? "elementów"}`; + } + return `Zbyt mał(y/a/e): oczekiwano, że ${issue.origin ?? "wartość"} będzie wynosić ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") + return `Nieprawidłowy ciąg znaków: musi zaczynać się od "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Nieprawidłowy ciąg znaków: musi kończyć się na "${_issue.suffix}"`; + if (_issue.format === "includes") return `Nieprawidłowy ciąg znaków: musi zawierać "${_issue.includes}"`; + if (_issue.format === "regex") return `Nieprawidłowy ciąg znaków: musi odpowiadać wzorcowi ${_issue.pattern}`; + return `Nieprawidłow(y/a/e) ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Nieprawidłowa liczba: musi być wielokrotnością ${issue.divisor}`; + case "unrecognized_keys": + return `Nierozpoznane klucze${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Nieprawidłowy klucz w ${issue.origin}`; + case "invalid_union": + return "Nieprawidłowe dane wejściowe"; + case "invalid_element": + return `Nieprawidłowa wartość w ${issue.origin}`; + default: + return `Nieprawidłowe dane wejściowe`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ps.ts b/gui/frontend/node_modules/zod/src/v4/locales/ps.ts new file mode 100644 index 0000000000000000000000000000000000000000..dc60fdd5038c51ee9d045c8b3b511f16556d24c3 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ps.ts @@ -0,0 +1,126 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "توکي", verb: "ولري" }, + file: { unit: "بایټس", verb: "ولري" }, + array: { unit: "توکي", verb: "ولري" }, + set: { unit: "توکي", verb: "ولري" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "ورودي", + email: "بریښنالیک", + url: "یو آر ال", + emoji: "ایموجي", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "نیټه او وخت", + date: "نېټه", + time: "وخت", + duration: "موده", + ipv4: "د IPv4 پته", + ipv6: "د IPv6 پته", + cidrv4: "د IPv4 ساحه", + cidrv6: "د IPv6 ساحه", + base64: "base64-encoded متن", + base64url: "base64url-encoded متن", + json_string: "JSON متن", + e164: "د E.164 شمېره", + jwt: "JWT", + template_literal: "ورودي", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "عدد", + array: "ارې", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `ناسم ورودي: باید instanceof ${issue.expected} وای, مګر ${received} ترلاسه شو`; + } + return `ناسم ورودي: باید ${expected} وای, مګر ${received} ترلاسه شو`; + } + case "invalid_value": + if (issue.values.length === 1) { + return `ناسم ورودي: باید ${util.stringifyPrimitive(issue.values[0])} وای`; + } + return `ناسم انتخاب: باید یو له ${util.joinValues(issue.values, "|")} څخه وای`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `ډیر لوی: ${issue.origin ?? "ارزښت"} باید ${adj}${issue.maximum.toString()} ${sizing.unit ?? "عنصرونه"} ولري`; + } + return `ډیر لوی: ${issue.origin ?? "ارزښت"} باید ${adj}${issue.maximum.toString()} وي`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `ډیر کوچنی: ${issue.origin} باید ${adj}${issue.minimum.toString()} ${sizing.unit} ولري`; + } + return `ډیر کوچنی: ${issue.origin} باید ${adj}${issue.minimum.toString()} وي`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `ناسم متن: باید د "${_issue.prefix}" سره پیل شي`; + } + if (_issue.format === "ends_with") { + return `ناسم متن: باید د "${_issue.suffix}" سره پای ته ورسيږي`; + } + if (_issue.format === "includes") { + return `ناسم متن: باید "${_issue.includes}" ولري`; + } + if (_issue.format === "regex") { + return `ناسم متن: باید د ${_issue.pattern} سره مطابقت ولري`; + } + return `${FormatDictionary[_issue.format] ?? issue.format} ناسم دی`; + } + case "not_multiple_of": + return `ناسم عدد: باید د ${issue.divisor} مضرب وي`; + case "unrecognized_keys": + return `ناسم ${issue.keys.length > 1 ? "کلیډونه" : "کلیډ"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `ناسم کلیډ په ${issue.origin} کې`; + case "invalid_union": + return `ناسمه ورودي`; + case "invalid_element": + return `ناسم عنصر په ${issue.origin} کې`; + default: + return `ناسمه ورودي`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/pt.ts b/gui/frontend/node_modules/zod/src/v4/locales/pt.ts new file mode 100644 index 0000000000000000000000000000000000000000..9ded285b58f5a09cc1a39748e91f4d7fd0a29283 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/pt.ts @@ -0,0 +1,116 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "caracteres", verb: "ter" }, + file: { unit: "bytes", verb: "ter" }, + array: { unit: "itens", verb: "ter" }, + set: { unit: "itens", verb: "ter" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "padrão", + email: "endereço de e-mail", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "data e hora ISO", + date: "data ISO", + time: "hora ISO", + duration: "duração ISO", + ipv4: "endereço IPv4", + ipv6: "endereço IPv6", + cidrv4: "faixa de IPv4", + cidrv6: "faixa de IPv6", + base64: "texto codificado em base64", + base64url: "URL codificada em base64", + json_string: "texto JSON", + e164: "número E.164", + jwt: "JWT", + template_literal: "entrada", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "número", + null: "nulo", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Tipo inválido: esperado instanceof ${issue.expected}, recebido ${received}`; + } + return `Tipo inválido: esperado ${expected}, recebido ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Entrada inválida: esperado ${util.stringifyPrimitive(issue.values[0])}`; + return `Opção inválida: esperada uma das ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Muito grande: esperado que ${issue.origin ?? "valor"} tivesse ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementos"}`; + return `Muito grande: esperado que ${issue.origin ?? "valor"} fosse ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Muito pequeno: esperado que ${issue.origin} tivesse ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Muito pequeno: esperado que ${issue.origin} fosse ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Texto inválido: deve começar com "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Texto inválido: deve terminar com "${_issue.suffix}"`; + if (_issue.format === "includes") return `Texto inválido: deve incluir "${_issue.includes}"`; + if (_issue.format === "regex") return `Texto inválido: deve corresponder ao padrão ${_issue.pattern}`; + return `${FormatDictionary[_issue.format] ?? issue.format} inválido`; + } + case "not_multiple_of": + return `Número inválido: deve ser múltiplo de ${issue.divisor}`; + case "unrecognized_keys": + return `Chave${issue.keys.length > 1 ? "s" : ""} desconhecida${issue.keys.length > 1 ? "s" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Chave inválida em ${issue.origin}`; + case "invalid_union": + return "Entrada inválida"; + case "invalid_element": + return `Valor inválido em ${issue.origin}`; + default: + return `Campo inválido`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ro.ts b/gui/frontend/node_modules/zod/src/v4/locales/ro.ts new file mode 100644 index 0000000000000000000000000000000000000000..8ac116dbd57b76fe5c44cd26fe4131943b7bc1f2 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ro.ts @@ -0,0 +1,129 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "caractere", verb: "să aibă" }, + file: { unit: "octeți", verb: "să aibă" }, + array: { unit: "elemente", verb: "să aibă" }, + set: { unit: "elemente", verb: "să aibă" }, + map: { unit: "intrări", verb: "să aibă" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "intrare", + email: "adresă de email", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "dată și oră ISO", + date: "dată ISO", + time: "oră ISO", + duration: "durată ISO", + ipv4: "adresă IPv4", + ipv6: "adresă IPv6", + mac: "adresă MAC", + cidrv4: "interval IPv4", + cidrv6: "interval IPv6", + base64: "șir codat base64", + base64url: "șir codat base64url", + json_string: "șir JSON", + e164: "număr E.164", + jwt: "JWT", + template_literal: "intrare", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + string: "șir", + number: "număr", + boolean: "boolean", + function: "funcție", + array: "matrice", + object: "obiect", + undefined: "nedefinit", + symbol: "simbol", + bigint: "număr mare", + void: "void", + never: "never", + map: "hartă", + set: "set", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + return `Intrare invalidă: așteptat ${expected}, primit ${received}`; + } + + case "invalid_value": + if (issue.values.length === 1) return `Intrare invalidă: așteptat ${util.stringifyPrimitive(issue.values[0])}`; + return `Opțiune invalidă: așteptat una dintre ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elemente"}`; + return `Prea mare: așteptat ca ${issue.origin ?? "valoarea"} să fie ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Prea mic: așteptat ca ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Prea mic: așteptat ca ${issue.origin} să fie ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Șir invalid: trebuie să înceapă cu "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Șir invalid: trebuie să se termine cu "${_issue.suffix}"`; + if (_issue.format === "includes") return `Șir invalid: trebuie să includă "${_issue.includes}"`; + if (_issue.format === "regex") return `Șir invalid: trebuie să se potrivească cu modelul ${_issue.pattern}`; + return `Format invalid: ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Număr invalid: trebuie să fie multiplu de ${issue.divisor}`; + case "unrecognized_keys": + return `Chei nerecunoscute: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Cheie invalidă în ${issue.origin}`; + case "invalid_union": + return "Intrare invalidă"; + case "invalid_element": + return `Valoare invalidă în ${issue.origin}`; + default: + return `Intrare invalidă`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ru.ts b/gui/frontend/node_modules/zod/src/v4/locales/ru.ts new file mode 100644 index 0000000000000000000000000000000000000000..cf223db405a8ca5fee6914613edc3ba6415cab9f --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ru.ts @@ -0,0 +1,176 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +function getRussianPlural(count: number, one: string, few: string, many: string): string { + const absCount = Math.abs(count); + const lastDigit = absCount % 10; + const lastTwoDigits = absCount % 100; + + if (lastTwoDigits >= 11 && lastTwoDigits <= 19) { + return many; + } + + if (lastDigit === 1) { + return one; + } + + if (lastDigit >= 2 && lastDigit <= 4) { + return few; + } + + return many; +} + +interface RussianSizable { + unit: { + one: string; + few: string; + many: string; + }; + verb: string; +} +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { + unit: { + one: "символ", + few: "символа", + many: "символов", + }, + verb: "иметь", + }, + file: { + unit: { + one: "байт", + few: "байта", + many: "байт", + }, + verb: "иметь", + }, + array: { + unit: { + one: "элемент", + few: "элемента", + many: "элементов", + }, + verb: "иметь", + }, + set: { + unit: { + one: "элемент", + few: "элемента", + many: "элементов", + }, + verb: "иметь", + }, + }; + + function getSizing(origin: string): RussianSizable | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "ввод", + email: "email адрес", + url: "URL", + emoji: "эмодзи", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO дата и время", + date: "ISO дата", + time: "ISO время", + duration: "ISO длительность", + ipv4: "IPv4 адрес", + ipv6: "IPv6 адрес", + cidrv4: "IPv4 диапазон", + cidrv6: "IPv6 диапазон", + base64: "строка в формате base64", + base64url: "строка в формате base64url", + json_string: "JSON строка", + e164: "номер E.164", + jwt: "JWT", + template_literal: "ввод", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "число", + array: "массив", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Неверный ввод: ожидалось instanceof ${issue.expected}, получено ${received}`; + } + return `Неверный ввод: ожидалось ${expected}, получено ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Неверный ввод: ожидалось ${util.stringifyPrimitive(issue.values[0])}`; + return `Неверный вариант: ожидалось одно из ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) { + const maxValue = Number(issue.maximum); + const unit = getRussianPlural(maxValue, sizing.unit.one, sizing.unit.few, sizing.unit.many); + return `Слишком большое значение: ожидалось, что ${issue.origin ?? "значение"} будет иметь ${adj}${issue.maximum.toString()} ${unit}`; + } + return `Слишком большое значение: ожидалось, что ${issue.origin ?? "значение"} будет ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + const minValue = Number(issue.minimum); + const unit = getRussianPlural(minValue, sizing.unit.one, sizing.unit.few, sizing.unit.many); + return `Слишком маленькое значение: ожидалось, что ${issue.origin} будет иметь ${adj}${issue.minimum.toString()} ${unit}`; + } + return `Слишком маленькое значение: ожидалось, что ${issue.origin} будет ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Неверная строка: должна начинаться с "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Неверная строка: должна заканчиваться на "${_issue.suffix}"`; + if (_issue.format === "includes") return `Неверная строка: должна содержать "${_issue.includes}"`; + if (_issue.format === "regex") return `Неверная строка: должна соответствовать шаблону ${_issue.pattern}`; + return `Неверный ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Неверное число: должно быть кратным ${issue.divisor}`; + case "unrecognized_keys": + return `Нераспознанн${issue.keys.length > 1 ? "ые" : "ый"} ключ${issue.keys.length > 1 ? "и" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Неверный ключ в ${issue.origin}`; + case "invalid_union": + return "Неверные входные данные"; + case "invalid_element": + return `Неверное значение в ${issue.origin}`; + default: + return `Неверные входные данные`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/sl.ts b/gui/frontend/node_modules/zod/src/v4/locales/sl.ts new file mode 100644 index 0000000000000000000000000000000000000000..1b83c44349f94b5cc16dd38eb18196133528ffee --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/sl.ts @@ -0,0 +1,118 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "znakov", verb: "imeti" }, + file: { unit: "bajtov", verb: "imeti" }, + array: { unit: "elementov", verb: "imeti" }, + set: { unit: "elementov", verb: "imeti" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "vnos", + email: "e-poštni naslov", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO datum in čas", + date: "ISO datum", + time: "ISO čas", + duration: "ISO trajanje", + ipv4: "IPv4 naslov", + ipv6: "IPv6 naslov", + cidrv4: "obseg IPv4", + cidrv6: "obseg IPv6", + base64: "base64 kodiran niz", + base64url: "base64url kodiran niz", + json_string: "JSON niz", + e164: "E.164 številka", + jwt: "JWT", + template_literal: "vnos", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "število", + array: "tabela", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Neveljaven vnos: pričakovano instanceof ${issue.expected}, prejeto ${received}`; + } + return `Neveljaven vnos: pričakovano ${expected}, prejeto ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Neveljaven vnos: pričakovano ${util.stringifyPrimitive(issue.values[0])}`; + return `Neveljavna možnost: pričakovano eno izmed ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Preveliko: pričakovano, da bo ${issue.origin ?? "vrednost"} imelo ${adj}${issue.maximum.toString()} ${sizing.unit ?? "elementov"}`; + return `Preveliko: pričakovano, da bo ${issue.origin ?? "vrednost"} ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Premajhno: pričakovano, da bo ${issue.origin} imelo ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + return `Premajhno: pričakovano, da bo ${issue.origin} ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Neveljaven niz: mora se začeti z "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Neveljaven niz: mora se končati z "${_issue.suffix}"`; + if (_issue.format === "includes") return `Neveljaven niz: mora vsebovati "${_issue.includes}"`; + if (_issue.format === "regex") return `Neveljaven niz: mora ustrezati vzorcu ${_issue.pattern}`; + return `Neveljaven ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Neveljavno število: mora biti večkratnik ${issue.divisor}`; + case "unrecognized_keys": + return `Neprepoznan${issue.keys.length > 1 ? "i ključi" : " ključ"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Neveljaven ključ v ${issue.origin}`; + case "invalid_union": + return "Neveljaven vnos"; + case "invalid_element": + return `Neveljavna vrednost v ${issue.origin}`; + default: + return "Neveljaven vnos"; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/sv.ts b/gui/frontend/node_modules/zod/src/v4/locales/sv.ts new file mode 100644 index 0000000000000000000000000000000000000000..a25aed8f23b900aac9f1fef0639bd8663b073394 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/sv.ts @@ -0,0 +1,119 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "tecken", verb: "att ha" }, + file: { unit: "bytes", verb: "att ha" }, + array: { unit: "objekt", verb: "att innehålla" }, + set: { unit: "objekt", verb: "att innehålla" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "reguljärt uttryck", + email: "e-postadress", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO-datum och tid", + date: "ISO-datum", + time: "ISO-tid", + duration: "ISO-varaktighet", + ipv4: "IPv4-intervall", + ipv6: "IPv6-intervall", + cidrv4: "IPv4-spektrum", + cidrv6: "IPv6-spektrum", + base64: "base64-kodad sträng", + base64url: "base64url-kodad sträng", + json_string: "JSON-sträng", + e164: "E.164-nummer", + jwt: "JWT", + template_literal: "mall-literal", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "antal", + array: "lista", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Ogiltig inmatning: förväntat instanceof ${issue.expected}, fick ${received}`; + } + return `Ogiltig inmatning: förväntat ${expected}, fick ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Ogiltig inmatning: förväntat ${util.stringifyPrimitive(issue.values[0])}`; + return `Ogiltigt val: förväntade en av ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `För stor(t): förväntade ${issue.origin ?? "värdet"} att ha ${adj}${issue.maximum.toString()} ${sizing.unit ?? "element"}`; + } + return `För stor(t): förväntat ${issue.origin ?? "värdet"} att ha ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `För lite(t): förväntade ${issue.origin ?? "värdet"} att ha ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + return `För lite(t): förväntade ${issue.origin ?? "värdet"} att ha ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `Ogiltig sträng: måste börja med "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `Ogiltig sträng: måste sluta med "${_issue.suffix}"`; + if (_issue.format === "includes") return `Ogiltig sträng: måste innehålla "${_issue.includes}"`; + if (_issue.format === "regex") return `Ogiltig sträng: måste matcha mönstret "${_issue.pattern}"`; + return `Ogiltig(t) ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Ogiltigt tal: måste vara en multipel av ${issue.divisor}`; + case "unrecognized_keys": + return `${issue.keys.length > 1 ? "Okända nycklar" : "Okänd nyckel"}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Ogiltig nyckel i ${issue.origin ?? "värdet"}`; + case "invalid_union": + return "Ogiltig input"; + case "invalid_element": + return `Ogiltigt värde i ${issue.origin ?? "värdet"}`; + default: + return `Ogiltig input`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ta.ts b/gui/frontend/node_modules/zod/src/v4/locales/ta.ts new file mode 100644 index 0000000000000000000000000000000000000000..ea83f8b7aa1e742c3f79eeeb7d42fc8cf1384bb3 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ta.ts @@ -0,0 +1,118 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "எழுத்துக்கள்", verb: "கொண்டிருக்க வேண்டும்" }, + file: { unit: "பைட்டுகள்", verb: "கொண்டிருக்க வேண்டும்" }, + array: { unit: "உறுப்புகள்", verb: "கொண்டிருக்க வேண்டும்" }, + set: { unit: "உறுப்புகள்", verb: "கொண்டிருக்க வேண்டும்" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "உள்ளீடு", + email: "மின்னஞ்சல் முகவரி", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO தேதி நேரம்", + date: "ISO தேதி", + time: "ISO நேரம்", + duration: "ISO கால அளவு", + ipv4: "IPv4 முகவரி", + ipv6: "IPv6 முகவரி", + cidrv4: "IPv4 வரம்பு", + cidrv6: "IPv6 வரம்பு", + base64: "base64-encoded சரம்", + base64url: "base64url-encoded சரம்", + json_string: "JSON சரம்", + e164: "E.164 எண்", + jwt: "JWT", + template_literal: "input", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "எண்", + array: "அணி", + null: "வெறுமை", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது instanceof ${issue.expected}, பெறப்பட்டது ${received}`; + } + return `தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${expected}, பெறப்பட்டது ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${util.stringifyPrimitive(issue.values[0])}`; + return `தவறான விருப்பம்: எதிர்பார்க்கப்பட்டது ${util.joinValues(issue.values, "|")} இல் ஒன்று`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `மிக பெரியது: எதிர்பார்க்கப்பட்டது ${issue.origin ?? "மதிப்பு"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "உறுப்புகள்"} ஆக இருக்க வேண்டும்`; + } + return `மிக பெரியது: எதிர்பார்க்கப்பட்டது ${issue.origin ?? "மதிப்பு"} ${adj}${issue.maximum.toString()} ஆக இருக்க வேண்டும்`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} ஆக இருக்க வேண்டும்`; // + } + + return `மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${issue.origin} ${adj}${issue.minimum.toString()} ஆக இருக்க வேண்டும்`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `தவறான சரம்: "${_issue.prefix}" இல் தொடங்க வேண்டும்`; + if (_issue.format === "ends_with") return `தவறான சரம்: "${_issue.suffix}" இல் முடிவடைய வேண்டும்`; + if (_issue.format === "includes") return `தவறான சரம்: "${_issue.includes}" ஐ உள்ளடக்க வேண்டும்`; + if (_issue.format === "regex") return `தவறான சரம்: ${_issue.pattern} முறைபாட்டுடன் பொருந்த வேண்டும்`; + return `தவறான ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `தவறான எண்: ${issue.divisor} இன் பலமாக இருக்க வேண்டும்`; + case "unrecognized_keys": + return `அடையாளம் தெரியாத விசை${issue.keys.length > 1 ? "கள்" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `${issue.origin} இல் தவறான விசை`; + case "invalid_union": + return "தவறான உள்ளீடு"; + case "invalid_element": + return `${issue.origin} இல் தவறான மதிப்பு`; + default: + return `தவறான உள்ளீடு`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/th.ts b/gui/frontend/node_modules/zod/src/v4/locales/th.ts new file mode 100644 index 0000000000000000000000000000000000000000..47f435154ba38100dab422f689b34c65a0e0b548 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/th.ts @@ -0,0 +1,119 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "ตัวอักษร", verb: "ควรมี" }, + file: { unit: "ไบต์", verb: "ควรมี" }, + array: { unit: "รายการ", verb: "ควรมี" }, + set: { unit: "รายการ", verb: "ควรมี" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "ข้อมูลที่ป้อน", + email: "ที่อยู่อีเมล", + url: "URL", + emoji: "อิโมจิ", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "วันที่เวลาแบบ ISO", + date: "วันที่แบบ ISO", + time: "เวลาแบบ ISO", + duration: "ช่วงเวลาแบบ ISO", + ipv4: "ที่อยู่ IPv4", + ipv6: "ที่อยู่ IPv6", + cidrv4: "ช่วง IP แบบ IPv4", + cidrv6: "ช่วง IP แบบ IPv6", + base64: "ข้อความแบบ Base64", + base64url: "ข้อความแบบ Base64 สำหรับ URL", + json_string: "ข้อความแบบ JSON", + e164: "เบอร์โทรศัพท์ระหว่างประเทศ (E.164)", + jwt: "โทเคน JWT", + template_literal: "ข้อมูลที่ป้อน", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "ตัวเลข", + array: "อาร์เรย์ (Array)", + null: "ไม่มีค่า (null)", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น instanceof ${issue.expected} แต่ได้รับ ${received}`; + } + return `ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น ${expected} แต่ได้รับ ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `ค่าไม่ถูกต้อง: ควรเป็น ${util.stringifyPrimitive(issue.values[0])}`; + return `ตัวเลือกไม่ถูกต้อง: ควรเป็นหนึ่งใน ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "ไม่เกิน" : "น้อยกว่า"; + const sizing = getSizing(issue.origin); + if (sizing) + return `เกินกำหนด: ${issue.origin ?? "ค่า"} ควรมี${adj} ${issue.maximum.toString()} ${sizing.unit ?? "รายการ"}`; + return `เกินกำหนด: ${issue.origin ?? "ค่า"} ควรมี${adj} ${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? "อย่างน้อย" : "มากกว่า"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `น้อยกว่ากำหนด: ${issue.origin} ควรมี${adj} ${issue.minimum.toString()} ${sizing.unit}`; + } + + return `น้อยกว่ากำหนด: ${issue.origin} ควรมี${adj} ${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `รูปแบบไม่ถูกต้อง: ข้อความต้องขึ้นต้นด้วย "${_issue.prefix}"`; + } + if (_issue.format === "ends_with") return `รูปแบบไม่ถูกต้อง: ข้อความต้องลงท้ายด้วย "${_issue.suffix}"`; + if (_issue.format === "includes") return `รูปแบบไม่ถูกต้อง: ข้อความต้องมี "${_issue.includes}" อยู่ในข้อความ`; + if (_issue.format === "regex") return `รูปแบบไม่ถูกต้อง: ต้องตรงกับรูปแบบที่กำหนด ${_issue.pattern}`; + return `รูปแบบไม่ถูกต้อง: ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `ตัวเลขไม่ถูกต้อง: ต้องเป็นจำนวนที่หารด้วย ${issue.divisor} ได้ลงตัว`; + case "unrecognized_keys": + return `พบคีย์ที่ไม่รู้จัก: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `คีย์ไม่ถูกต้องใน ${issue.origin}`; + case "invalid_union": + return "ข้อมูลไม่ถูกต้อง: ไม่ตรงกับรูปแบบยูเนียนที่กำหนดไว้"; + case "invalid_element": + return `ข้อมูลไม่ถูกต้องใน ${issue.origin}`; + default: + return `ข้อมูลไม่ถูกต้อง`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/tr.ts b/gui/frontend/node_modules/zod/src/v4/locales/tr.ts new file mode 100644 index 0000000000000000000000000000000000000000..2bc578d7b20a6c5c7ab7e34d5f591812165b1eae --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/tr.ts @@ -0,0 +1,111 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "karakter", verb: "olmalı" }, + file: { unit: "bayt", verb: "olmalı" }, + array: { unit: "öğe", verb: "olmalı" }, + set: { unit: "öğe", verb: "olmalı" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "girdi", + email: "e-posta adresi", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO tarih ve saat", + date: "ISO tarih", + time: "ISO saat", + duration: "ISO süre", + ipv4: "IPv4 adresi", + ipv6: "IPv6 adresi", + cidrv4: "IPv4 aralığı", + cidrv6: "IPv6 aralığı", + base64: "base64 ile şifrelenmiş metin", + base64url: "base64url ile şifrelenmiş metin", + json_string: "JSON dizesi", + e164: "E.164 sayısı", + jwt: "JWT", + template_literal: "Şablon dizesi", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Geçersiz değer: beklenen instanceof ${issue.expected}, alınan ${received}`; + } + return `Geçersiz değer: beklenen ${expected}, alınan ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Geçersiz değer: beklenen ${util.stringifyPrimitive(issue.values[0])}`; + return `Geçersiz seçenek: aşağıdakilerden biri olmalı: ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Çok büyük: beklenen ${issue.origin ?? "değer"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "öğe"}`; + return `Çok büyük: beklenen ${issue.origin ?? "değer"} ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) return `Çok küçük: beklenen ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`; + return `Çok küçük: beklenen ${issue.origin} ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Geçersiz metin: "${_issue.prefix}" ile başlamalı`; + if (_issue.format === "ends_with") return `Geçersiz metin: "${_issue.suffix}" ile bitmeli`; + if (_issue.format === "includes") return `Geçersiz metin: "${_issue.includes}" içermeli`; + if (_issue.format === "regex") return `Geçersiz metin: ${_issue.pattern} desenine uymalı`; + return `Geçersiz ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Geçersiz sayı: ${issue.divisor} ile tam bölünebilmeli`; + case "unrecognized_keys": + return `Tanınmayan anahtar${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `${issue.origin} içinde geçersiz anahtar`; + case "invalid_union": + return "Geçersiz değer"; + case "invalid_element": + return `${issue.origin} içinde geçersiz değer`; + default: + return `Geçersiz değer`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ua.ts b/gui/frontend/node_modules/zod/src/v4/locales/ua.ts new file mode 100644 index 0000000000000000000000000000000000000000..e43526272e9c345dc603b4e4918b85f22ef97ad6 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ua.ts @@ -0,0 +1,7 @@ +import type * as errors from "../core/errors.js"; +import uk from "./uk.js"; + +/** @deprecated Use `uk` instead. */ +export default function (): { localeError: errors.$ZodErrorMap } { + return uk(); +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/uk.ts b/gui/frontend/node_modules/zod/src/v4/locales/uk.ts new file mode 100644 index 0000000000000000000000000000000000000000..424e2f3b2fd266404b4e9b3eeccab75043e8479a --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/uk.ts @@ -0,0 +1,117 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "символів", verb: "матиме" }, + file: { unit: "байтів", verb: "матиме" }, + array: { unit: "елементів", verb: "матиме" }, + set: { unit: "елементів", verb: "матиме" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "вхідні дані", + email: "адреса електронної пошти", + url: "URL", + emoji: "емодзі", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "дата та час ISO", + date: "дата ISO", + time: "час ISO", + duration: "тривалість ISO", + ipv4: "адреса IPv4", + ipv6: "адреса IPv6", + cidrv4: "діапазон IPv4", + cidrv6: "діапазон IPv6", + base64: "рядок у кодуванні base64", + base64url: "рядок у кодуванні base64url", + json_string: "рядок JSON", + e164: "номер E.164", + jwt: "JWT", + template_literal: "вхідні дані", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "число", + array: "масив", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Неправильні вхідні дані: очікується instanceof ${issue.expected}, отримано ${received}`; + } + return `Неправильні вхідні дані: очікується ${expected}, отримано ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Неправильні вхідні дані: очікується ${util.stringifyPrimitive(issue.values[0])}`; + return `Неправильна опція: очікується одне з ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Занадто велике: очікується, що ${issue.origin ?? "значення"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "елементів"}`; + return `Занадто велике: очікується, що ${issue.origin ?? "значення"} буде ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Занадто мале: очікується, що ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Занадто мале: очікується, що ${issue.origin} буде ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Неправильний рядок: повинен починатися з "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Неправильний рядок: повинен закінчуватися на "${_issue.suffix}"`; + if (_issue.format === "includes") return `Неправильний рядок: повинен містити "${_issue.includes}"`; + if (_issue.format === "regex") return `Неправильний рядок: повинен відповідати шаблону ${_issue.pattern}`; + return `Неправильний ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Неправильне число: повинно бути кратним ${issue.divisor}`; + case "unrecognized_keys": + return `Нерозпізнаний ключ${issue.keys.length > 1 ? "і" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Неправильний ключ у ${issue.origin}`; + case "invalid_union": + return "Неправильні вхідні дані"; + case "invalid_element": + return `Неправильне значення у ${issue.origin}`; + default: + return `Неправильні вхідні дані`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/ur.ts b/gui/frontend/node_modules/zod/src/v4/locales/ur.ts new file mode 100644 index 0000000000000000000000000000000000000000..86f4cb2022d529f2122708f366ee118e97dbafee --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/ur.ts @@ -0,0 +1,119 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "حروف", verb: "ہونا" }, + file: { unit: "بائٹس", verb: "ہونا" }, + array: { unit: "آئٹمز", verb: "ہونا" }, + set: { unit: "آئٹمز", verb: "ہونا" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "ان پٹ", + email: "ای میل ایڈریس", + url: "یو آر ایل", + emoji: "ایموجی", + uuid: "یو یو آئی ڈی", + uuidv4: "یو یو آئی ڈی وی 4", + uuidv6: "یو یو آئی ڈی وی 6", + nanoid: "نینو آئی ڈی", + guid: "جی یو آئی ڈی", + cuid: "سی یو آئی ڈی", + cuid2: "سی یو آئی ڈی 2", + ulid: "یو ایل آئی ڈی", + xid: "ایکس آئی ڈی", + ksuid: "کے ایس یو آئی ڈی", + datetime: "آئی ایس او ڈیٹ ٹائم", + date: "آئی ایس او تاریخ", + time: "آئی ایس او وقت", + duration: "آئی ایس او مدت", + ipv4: "آئی پی وی 4 ایڈریس", + ipv6: "آئی پی وی 6 ایڈریس", + cidrv4: "آئی پی وی 4 رینج", + cidrv6: "آئی پی وی 6 رینج", + base64: "بیس 64 ان کوڈڈ سٹرنگ", + base64url: "بیس 64 یو آر ایل ان کوڈڈ سٹرنگ", + json_string: "جے ایس او این سٹرنگ", + e164: "ای 164 نمبر", + jwt: "جے ڈبلیو ٹی", + template_literal: "ان پٹ", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "نمبر", + array: "آرے", + null: "نل", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `غلط ان پٹ: instanceof ${issue.expected} متوقع تھا، ${received} موصول ہوا`; + } + return `غلط ان پٹ: ${expected} متوقع تھا، ${received} موصول ہوا`; + } + case "invalid_value": + if (issue.values.length === 1) return `غلط ان پٹ: ${util.stringifyPrimitive(issue.values[0])} متوقع تھا`; + return `غلط آپشن: ${util.joinValues(issue.values, "|")} میں سے ایک متوقع تھا`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `بہت بڑا: ${issue.origin ?? "ویلیو"} کے ${adj}${issue.maximum.toString()} ${sizing.unit ?? "عناصر"} ہونے متوقع تھے`; + return `بہت بڑا: ${issue.origin ?? "ویلیو"} کا ${adj}${issue.maximum.toString()} ہونا متوقع تھا`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `بہت چھوٹا: ${issue.origin} کے ${adj}${issue.minimum.toString()} ${sizing.unit} ہونے متوقع تھے`; + } + + return `بہت چھوٹا: ${issue.origin} کا ${adj}${issue.minimum.toString()} ہونا متوقع تھا`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `غلط سٹرنگ: "${_issue.prefix}" سے شروع ہونا چاہیے`; + } + if (_issue.format === "ends_with") return `غلط سٹرنگ: "${_issue.suffix}" پر ختم ہونا چاہیے`; + if (_issue.format === "includes") return `غلط سٹرنگ: "${_issue.includes}" شامل ہونا چاہیے`; + if (_issue.format === "regex") return `غلط سٹرنگ: پیٹرن ${_issue.pattern} سے میچ ہونا چاہیے`; + return `غلط ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `غلط نمبر: ${issue.divisor} کا مضاعف ہونا چاہیے`; + case "unrecognized_keys": + return `غیر تسلیم شدہ کی${issue.keys.length > 1 ? "ز" : ""}: ${util.joinValues(issue.keys, "، ")}`; + case "invalid_key": + return `${issue.origin} میں غلط کی`; + case "invalid_union": + return "غلط ان پٹ"; + case "invalid_element": + return `${issue.origin} میں غلط ویلیو`; + default: + return `غلط ان پٹ`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/uz.ts b/gui/frontend/node_modules/zod/src/v4/locales/uz.ts new file mode 100644 index 0000000000000000000000000000000000000000..08b690eb1203213212ab556eff7fb5d79e1682dc --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/uz.ts @@ -0,0 +1,117 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "belgi", verb: "bo‘lishi kerak" }, + file: { unit: "bayt", verb: "bo‘lishi kerak" }, + array: { unit: "element", verb: "bo‘lishi kerak" }, + set: { unit: "element", verb: "bo‘lishi kerak" }, + map: { unit: "yozuv", verb: "bo‘lishi kerak" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "kirish", + email: "elektron pochta manzili", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO sana va vaqti", + date: "ISO sana", + time: "ISO vaqt", + duration: "ISO davomiylik", + ipv4: "IPv4 manzil", + ipv6: "IPv6 manzil", + mac: "MAC manzil", + cidrv4: "IPv4 diapazon", + cidrv6: "IPv6 diapazon", + base64: "base64 kodlangan satr", + base64url: "base64url kodlangan satr", + json_string: "JSON satr", + e164: "E.164 raqam", + jwt: "JWT", + template_literal: "kirish", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "raqam", + array: "massiv", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Noto‘g‘ri kirish: kutilgan instanceof ${issue.expected}, qabul qilingan ${received}`; + } + return `Noto‘g‘ri kirish: kutilgan ${expected}, qabul qilingan ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `Noto‘g‘ri kirish: kutilgan ${util.stringifyPrimitive(issue.values[0])}`; + return `Noto‘g‘ri variant: quyidagilardan biri kutilgan ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Juda katta: kutilgan ${issue.origin ?? "qiymat"} ${adj}${issue.maximum.toString()} ${sizing.unit} ${sizing.verb}`; + return `Juda katta: kutilgan ${issue.origin ?? "qiymat"} ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Juda kichik: kutilgan ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit} ${sizing.verb}`; + } + return `Juda kichik: kutilgan ${issue.origin} ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Noto‘g‘ri satr: "${_issue.prefix}" bilan boshlanishi kerak`; + if (_issue.format === "ends_with") return `Noto‘g‘ri satr: "${_issue.suffix}" bilan tugashi kerak`; + if (_issue.format === "includes") return `Noto‘g‘ri satr: "${_issue.includes}" ni o‘z ichiga olishi kerak`; + if (_issue.format === "regex") return `Noto‘g‘ri satr: ${_issue.pattern} shabloniga mos kelishi kerak`; + return `Noto‘g‘ri ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `Noto‘g‘ri raqam: ${issue.divisor} ning karralisi bo‘lishi kerak`; + case "unrecognized_keys": + return `Noma’lum kalit${issue.keys.length > 1 ? "lar" : ""}: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `${issue.origin} dagi kalit noto‘g‘ri`; + case "invalid_union": + return "Noto‘g‘ri kirish"; + case "invalid_element": + return `${issue.origin} da noto‘g‘ri qiymat`; + default: + return `Noto‘g‘ri kirish`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/vi.ts b/gui/frontend/node_modules/zod/src/v4/locales/vi.ts new file mode 100644 index 0000000000000000000000000000000000000000..673594d1a83eb1a199fe5866b9a5cb6ce04126c7 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/vi.ts @@ -0,0 +1,117 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "ký tự", verb: "có" }, + file: { unit: "byte", verb: "có" }, + array: { unit: "phần tử", verb: "có" }, + set: { unit: "phần tử", verb: "có" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "đầu vào", + email: "địa chỉ email", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ngày giờ ISO", + date: "ngày ISO", + time: "giờ ISO", + duration: "khoảng thời gian ISO", + ipv4: "địa chỉ IPv4", + ipv6: "địa chỉ IPv6", + cidrv4: "dải IPv4", + cidrv6: "dải IPv6", + base64: "chuỗi mã hóa base64", + base64url: "chuỗi mã hóa base64url", + json_string: "chuỗi JSON", + e164: "số E.164", + jwt: "JWT", + template_literal: "đầu vào", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "số", + array: "mảng", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Đầu vào không hợp lệ: mong đợi instanceof ${issue.expected}, nhận được ${received}`; + } + return `Đầu vào không hợp lệ: mong đợi ${expected}, nhận được ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) + return `Đầu vào không hợp lệ: mong đợi ${util.stringifyPrimitive(issue.values[0])}`; + return `Tùy chọn không hợp lệ: mong đợi một trong các giá trị ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Quá lớn: mong đợi ${issue.origin ?? "giá trị"} ${sizing.verb} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "phần tử"}`; + return `Quá lớn: mong đợi ${issue.origin ?? "giá trị"} ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `Quá nhỏ: mong đợi ${issue.origin} ${sizing.verb} ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + + return `Quá nhỏ: mong đợi ${issue.origin} ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Chuỗi không hợp lệ: phải bắt đầu bằng "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Chuỗi không hợp lệ: phải kết thúc bằng "${_issue.suffix}"`; + if (_issue.format === "includes") return `Chuỗi không hợp lệ: phải bao gồm "${_issue.includes}"`; + if (_issue.format === "regex") return `Chuỗi không hợp lệ: phải khớp với mẫu ${_issue.pattern}`; + return `${FormatDictionary[_issue.format] ?? issue.format} không hợp lệ`; + } + case "not_multiple_of": + return `Số không hợp lệ: phải là bội số của ${issue.divisor}`; + case "unrecognized_keys": + return `Khóa không được nhận dạng: ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `Khóa không hợp lệ trong ${issue.origin}`; + case "invalid_union": + return "Đầu vào không hợp lệ"; + case "invalid_element": + return `Giá trị không hợp lệ trong ${issue.origin}`; + default: + return `Đầu vào không hợp lệ`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/yo.ts b/gui/frontend/node_modules/zod/src/v4/locales/yo.ts new file mode 100644 index 0000000000000000000000000000000000000000..c821d229c98d66e3caac1a8fb4c5611a81e94ca2 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/yo.ts @@ -0,0 +1,124 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "àmi", verb: "ní" }, + file: { unit: "bytes", verb: "ní" }, + array: { unit: "nkan", verb: "ní" }, + set: { unit: "nkan", verb: "ní" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "ẹ̀rọ ìbáwọlé", + email: "àdírẹ́sì ìmẹ́lì", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "àkókò ISO", + date: "ọjọ́ ISO", + time: "àkókò ISO", + duration: "àkókò tó pé ISO", + ipv4: "àdírẹ́sì IPv4", + ipv6: "àdírẹ́sì IPv6", + cidrv4: "àgbègbè IPv4", + cidrv6: "àgbègbè IPv6", + base64: "ọ̀rọ̀ tí a kọ́ ní base64", + base64url: "ọ̀rọ̀ base64url", + json_string: "ọ̀rọ̀ JSON", + e164: "nọ́mbà E.164", + jwt: "JWT", + template_literal: "ẹ̀rọ ìbáwọlé", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "nọ́mbà", + array: "akopọ", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `Ìbáwọlé aṣìṣe: a ní láti fi instanceof ${issue.expected}, àmọ̀ a rí ${received}`; + } + return `Ìbáwọlé aṣìṣe: a ní láti fi ${expected}, àmọ̀ a rí ${received}`; + } + + case "invalid_value": + if (issue.values.length === 1) return `Ìbáwọlé aṣìṣe: a ní láti fi ${util.stringifyPrimitive(issue.values[0])}`; + return `Àṣàyàn aṣìṣe: yan ọ̀kan lára ${util.joinValues(issue.values, "|")}`; + + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Tó pọ̀ jù: a ní láti jẹ́ pé ${issue.origin ?? "iye"} ${sizing.verb} ${adj}${issue.maximum} ${sizing.unit}`; + return `Tó pọ̀ jù: a ní láti jẹ́ ${adj}${issue.maximum}`; + } + + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) + return `Kéré ju: a ní láti jẹ́ pé ${issue.origin} ${sizing.verb} ${adj}${issue.minimum} ${sizing.unit}`; + return `Kéré ju: a ní láti jẹ́ ${adj}${issue.minimum}`; + } + + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${_issue.prefix}"`; + if (_issue.format === "ends_with") return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${_issue.suffix}"`; + if (_issue.format === "includes") return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${_issue.includes}"`; + if (_issue.format === "regex") return `Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${_issue.pattern}`; + return `Aṣìṣe: ${FormatDictionary[_issue.format] ?? issue.format}`; + } + + case "not_multiple_of": + return `Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${issue.divisor}`; + + case "unrecognized_keys": + return `Bọtìnì àìmọ̀: ${util.joinValues(issue.keys, ", ")}`; + + case "invalid_key": + return `Bọtìnì aṣìṣe nínú ${issue.origin}`; + + case "invalid_union": + return "Ìbáwọlé aṣìṣe"; + + case "invalid_element": + return `Iye aṣìṣe nínú ${issue.origin}`; + + default: + return "Ìbáwọlé aṣìṣe"; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/zh-CN.ts b/gui/frontend/node_modules/zod/src/v4/locales/zh-CN.ts new file mode 100644 index 0000000000000000000000000000000000000000..728759ad8ac06d4fef7ea3eca33fcfcfc220b303 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/zh-CN.ts @@ -0,0 +1,116 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "字符", verb: "包含" }, + file: { unit: "字节", verb: "包含" }, + array: { unit: "项", verb: "包含" }, + set: { unit: "项", verb: "包含" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "输入", + email: "电子邮件", + url: "URL", + emoji: "表情符号", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO日期时间", + date: "ISO日期", + time: "ISO时间", + duration: "ISO时长", + ipv4: "IPv4地址", + ipv6: "IPv6地址", + cidrv4: "IPv4网段", + cidrv6: "IPv6网段", + base64: "base64编码字符串", + base64url: "base64url编码字符串", + json_string: "JSON字符串", + e164: "E.164号码", + jwt: "JWT", + template_literal: "输入", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + number: "数字", + array: "数组", + null: "空值(null)", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `无效输入:期望 instanceof ${issue.expected},实际接收 ${received}`; + } + return `无效输入:期望 ${expected},实际接收 ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `无效输入:期望 ${util.stringifyPrimitive(issue.values[0])}`; + return `无效选项:期望以下之一 ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `数值过大:期望 ${issue.origin ?? "值"} ${adj}${issue.maximum.toString()} ${sizing.unit ?? "个元素"}`; + return `数值过大:期望 ${issue.origin ?? "值"} ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `数值过小:期望 ${issue.origin} ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + return `数值过小:期望 ${issue.origin} ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") return `无效字符串:必须以 "${_issue.prefix}" 开头`; + if (_issue.format === "ends_with") return `无效字符串:必须以 "${_issue.suffix}" 结尾`; + if (_issue.format === "includes") return `无效字符串:必须包含 "${_issue.includes}"`; + if (_issue.format === "regex") return `无效字符串:必须满足正则表达式 ${_issue.pattern}`; + return `无效${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `无效数字:必须是 ${issue.divisor} 的倍数`; + case "unrecognized_keys": + return `出现未知的键(key): ${util.joinValues(issue.keys, ", ")}`; + case "invalid_key": + return `${issue.origin} 中的键(key)无效`; + case "invalid_union": + return "无效输入"; + case "invalid_element": + return `${issue.origin} 中包含无效值(value)`; + default: + return `无效输入`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/locales/zh-TW.ts b/gui/frontend/node_modules/zod/src/v4/locales/zh-TW.ts new file mode 100644 index 0000000000000000000000000000000000000000..62a02defb2433aba12d420c0f0670a6e6f47e5a5 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/locales/zh-TW.ts @@ -0,0 +1,115 @@ +import type { $ZodStringFormats } from "../core/checks.js"; +import type * as errors from "../core/errors.js"; +import * as util from "../core/util.js"; + +const error: () => errors.$ZodErrorMap = () => { + const Sizable: Record = { + string: { unit: "字元", verb: "擁有" }, + file: { unit: "位元組", verb: "擁有" }, + array: { unit: "項目", verb: "擁有" }, + set: { unit: "項目", verb: "擁有" }, + }; + + function getSizing(origin: string): { unit: string; verb: string } | null { + return Sizable[origin] ?? null; + } + + const FormatDictionary: { + [k in $ZodStringFormats | (string & {})]?: string; + } = { + regex: "輸入", + email: "郵件地址", + url: "URL", + emoji: "emoji", + uuid: "UUID", + uuidv4: "UUIDv4", + uuidv6: "UUIDv6", + nanoid: "nanoid", + guid: "GUID", + cuid: "cuid", + cuid2: "cuid2", + ulid: "ULID", + xid: "XID", + ksuid: "KSUID", + datetime: "ISO 日期時間", + date: "ISO 日期", + time: "ISO 時間", + duration: "ISO 期間", + ipv4: "IPv4 位址", + ipv6: "IPv6 位址", + cidrv4: "IPv4 範圍", + cidrv6: "IPv6 範圍", + base64: "base64 編碼字串", + base64url: "base64url 編碼字串", + json_string: "JSON 字串", + e164: "E.164 數值", + jwt: "JWT", + template_literal: "輸入", + }; + + const TypeDictionary: { + [k in errors.$ZodInvalidTypeExpected | (string & {})]?: string; + } = { + nan: "NaN", + }; + + return (issue) => { + switch (issue.code) { + case "invalid_type": { + const expected = TypeDictionary[issue.expected] ?? issue.expected; + const receivedType = util.parsedType(issue.input); + const received = TypeDictionary[receivedType] ?? receivedType; + if (/^[A-Z]/.test(issue.expected)) { + return `無效的輸入值:預期為 instanceof ${issue.expected},但收到 ${received}`; + } + return `無效的輸入值:預期為 ${expected},但收到 ${received}`; + } + case "invalid_value": + if (issue.values.length === 1) return `無效的輸入值:預期為 ${util.stringifyPrimitive(issue.values[0])}`; + return `無效的選項:預期為以下其中之一 ${util.joinValues(issue.values, "|")}`; + case "too_big": { + const adj = issue.inclusive ? "<=" : "<"; + const sizing = getSizing(issue.origin); + if (sizing) + return `數值過大:預期 ${issue.origin ?? "值"} 應為 ${adj}${issue.maximum.toString()} ${sizing.unit ?? "個元素"}`; + return `數值過大:預期 ${issue.origin ?? "值"} 應為 ${adj}${issue.maximum.toString()}`; + } + case "too_small": { + const adj = issue.inclusive ? ">=" : ">"; + const sizing = getSizing(issue.origin); + if (sizing) { + return `數值過小:預期 ${issue.origin} 應為 ${adj}${issue.minimum.toString()} ${sizing.unit}`; + } + return `數值過小:預期 ${issue.origin} 應為 ${adj}${issue.minimum.toString()}`; + } + case "invalid_format": { + const _issue = issue as errors.$ZodStringFormatIssues; + if (_issue.format === "starts_with") { + return `無效的字串:必須以 "${_issue.prefix}" 開頭`; + } + if (_issue.format === "ends_with") return `無效的字串:必須以 "${_issue.suffix}" 結尾`; + if (_issue.format === "includes") return `無效的字串:必須包含 "${_issue.includes}"`; + if (_issue.format === "regex") return `無效的字串:必須符合格式 ${_issue.pattern}`; + return `無效的 ${FormatDictionary[_issue.format] ?? issue.format}`; + } + case "not_multiple_of": + return `無效的數字:必須為 ${issue.divisor} 的倍數`; + case "unrecognized_keys": + return `無法識別的鍵值${issue.keys.length > 1 ? "們" : ""}:${util.joinValues(issue.keys, "、")}`; + case "invalid_key": + return `${issue.origin} 中有無效的鍵值`; + case "invalid_union": + return "無效的輸入值"; + case "invalid_element": + return `${issue.origin} 中有無效的值`; + default: + return `無效的輸入值`; + } + }; +}; + +export default function (): { localeError: errors.$ZodErrorMap } { + return { + localeError: error(), + }; +} diff --git a/gui/frontend/node_modules/zod/src/v4/mini/checks.ts b/gui/frontend/node_modules/zod/src/v4/mini/checks.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3e47c642aa457fb318325ab2c6847dfd5cc3f06 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/mini/checks.ts @@ -0,0 +1,32 @@ +export { + _lt as lt, + _lte as lte, + _lte as maximum, + _gt as gt, + _gte as gte, + _gte as minimum, + _positive as positive, + _negative as negative, + _nonpositive as nonpositive, + _nonnegative as nonnegative, + _multipleOf as multipleOf, + _maxSize as maxSize, + _minSize as minSize, + _size as size, + _maxLength as maxLength, + _minLength as minLength, + _length as length, + _regex as regex, + _lowercase as lowercase, + _uppercase as uppercase, + _includes as includes, + _startsWith as startsWith, + _endsWith as endsWith, + _property as property, + _mime as mime, + _overwrite as overwrite, + _normalize as normalize, + _trim as trim, + _toLowerCase as toLowerCase, + _toUpperCase as toUpperCase, +} from "../core/index.js"; diff --git a/gui/frontend/node_modules/zod/src/v4/mini/coerce.ts b/gui/frontend/node_modules/zod/src/v4/mini/coerce.ts new file mode 100644 index 0000000000000000000000000000000000000000..79ff95c3a2e679a6ae35b711c666512cb177deaa --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/mini/coerce.ts @@ -0,0 +1,27 @@ +import * as core from "../core/index.js"; +import * as schemas from "./schemas.js"; + +// @__NO_SIDE_EFFECTS__ +export function string(params?: string | core.$ZodStringParams): schemas.ZodMiniString { + return core._coercedString(schemas.ZodMiniString, params) as schemas.ZodMiniString; +} + +// @__NO_SIDE_EFFECTS__ +export function number(params?: string | core.$ZodNumberParams): schemas.ZodMiniNumber { + return core._coercedNumber(schemas.ZodMiniNumber, params) as schemas.ZodMiniNumber; +} + +// @__NO_SIDE_EFFECTS__ +export function boolean(params?: string | core.$ZodBooleanParams): schemas.ZodMiniBoolean { + return core._coercedBoolean(schemas.ZodMiniBoolean, params) as schemas.ZodMiniBoolean; +} + +// @__NO_SIDE_EFFECTS__ +export function bigint(params?: string | core.$ZodBigIntParams): schemas.ZodMiniBigInt { + return core._coercedBigint(schemas.ZodMiniBigInt, params) as schemas.ZodMiniBigInt; +} + +// @__NO_SIDE_EFFECTS__ +export function date(params?: string | core.$ZodDateParams): schemas.ZodMiniDate { + return core._coercedDate(schemas.ZodMiniDate, params) as schemas.ZodMiniDate; +} diff --git a/gui/frontend/node_modules/zod/src/v4/mini/external.ts b/gui/frontend/node_modules/zod/src/v4/mini/external.ts new file mode 100644 index 0000000000000000000000000000000000000000..67661e9e81a2752cb013fcf0176f4a7f51d68a5e --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/mini/external.ts @@ -0,0 +1,41 @@ +export * as core from "../core/index.js"; +export * from "./parse.js"; +export * from "./schemas.js"; +export * from "./checks.js"; + +export type { infer, output, input } from "../core/index.js"; +export type { JSONType } from "../core/util.js"; +export { + globalRegistry, + registry, + config, + $output, + $input, + $brand, + clone, + regexes, + treeifyError, + prettifyError, + formatError, + flattenError, + TimePrecision, + util, + NEVER, +} from "../core/index.js"; +export { toJSONSchema } from "../core/json-schema-processors.js"; + +export * as locales from "../locales/index.js"; +/** A special constant with type `never` */ +// export const NEVER = {} as never; + +// iso +export * as iso from "./iso.js"; +export { + ZodMiniISODateTime, + ZodMiniISODate, + ZodMiniISOTime, + ZodMiniISODuration, +} from "./iso.js"; + +// coerce +export * as coerce from "./coerce.js"; diff --git a/gui/frontend/node_modules/zod/src/v4/mini/index.ts b/gui/frontend/node_modules/zod/src/v4/mini/index.ts new file mode 100644 index 0000000000000000000000000000000000000000..f6c2a264981d92dee01551b7236a648a958f728a --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/mini/index.ts @@ -0,0 +1,3 @@ +import * as z from "./external.js"; +export * from "./external.js"; +export { z }; diff --git a/gui/frontend/node_modules/zod/src/v4/mini/iso.ts b/gui/frontend/node_modules/zod/src/v4/mini/iso.ts new file mode 100644 index 0000000000000000000000000000000000000000..55569ee60e3edc948f845bf0168e87703fa55207 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/mini/iso.ts @@ -0,0 +1,66 @@ +import * as core from "../core/index.js"; +import * as schemas from "./schemas.js"; + +// iso time +export interface ZodMiniISODateTime extends schemas.ZodMiniStringFormat<"datetime"> { + _zod: core.$ZodISODateTimeInternals; +} +export const ZodMiniISODateTime: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniISODateTime", + (inst, def) => { + core.$ZodISODateTime.init(inst, def); + schemas.ZodMiniStringFormat.init(inst, def); + } +); +// @__NO_SIDE_EFFECTS__ +export function datetime(params?: string | core.$ZodISODateTimeParams): ZodMiniISODateTime { + return core._isoDateTime(ZodMiniISODateTime, params); +} + +// iso date +export interface ZodMiniISODate extends schemas.ZodMiniStringFormat<"date"> { + _zod: core.$ZodISODateInternals; +} +export const ZodMiniISODate: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniISODate", + (inst, def) => { + core.$ZodISODate.init(inst, def); + schemas.ZodMiniStringFormat.init(inst, def); + } +); +// @__NO_SIDE_EFFECTS__ +export function date(params?: string | core.$ZodISODateParams): ZodMiniISODate { + return core._isoDate(ZodMiniISODate, params); +} + +// iso time +export interface ZodMiniISOTime extends schemas.ZodMiniStringFormat<"time"> { + _zod: core.$ZodISOTimeInternals; +} +export const ZodMiniISOTime: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniISOTime", + (inst, def) => { + core.$ZodISOTime.init(inst, def); + schemas.ZodMiniStringFormat.init(inst, def); + } +); +// @__NO_SIDE_EFFECTS__ +export function time(params?: string | core.$ZodISOTimeParams): ZodMiniISOTime { + return core._isoTime(ZodMiniISOTime, params); +} + +// iso duration +export interface ZodMiniISODuration extends schemas.ZodMiniStringFormat<"duration"> { + _zod: core.$ZodISODurationInternals; +} +export const ZodMiniISODuration: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniISODuration", + (inst, def) => { + core.$ZodISODuration.init(inst, def); + schemas.ZodMiniStringFormat.init(inst, def); + } +); +// @__NO_SIDE_EFFECTS__ +export function duration(params?: string | core.$ZodISODurationParams): ZodMiniISODuration { + return core._isoDuration(ZodMiniISODuration, params); +} diff --git a/gui/frontend/node_modules/zod/src/v4/mini/parse.ts b/gui/frontend/node_modules/zod/src/v4/mini/parse.ts new file mode 100644 index 0000000000000000000000000000000000000000..d4d1ee2f15742251c67c3454814364c2d69e1b4b --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/mini/parse.ts @@ -0,0 +1,14 @@ +export { + parse, + safeParse, + parseAsync, + safeParseAsync, + encode, + decode, + encodeAsync, + decodeAsync, + safeEncode, + safeDecode, + safeEncodeAsync, + safeDecodeAsync, +} from "../core/index.js"; diff --git a/gui/frontend/node_modules/zod/src/v4/mini/schemas.ts b/gui/frontend/node_modules/zod/src/v4/mini/schemas.ts new file mode 100644 index 0000000000000000000000000000000000000000..38978a03d5aaa21b2dd79904c7cbe8da03874a35 --- /dev/null +++ b/gui/frontend/node_modules/zod/src/v4/mini/schemas.ts @@ -0,0 +1,1947 @@ +import * as core from "../core/index.js"; +import * as util from "../core/util.js"; +import * as parse from "./parse.js"; + +type SomeType = core.SomeType; + +export interface ZodMiniType< + out Output = unknown, + out Input = unknown, + out Internals extends core.$ZodTypeInternals = core.$ZodTypeInternals, +> extends core.$ZodType { + type: Internals["def"]["type"]; + check(...checks: (core.CheckFn> | core.$ZodCheck>)[]): this; + with(...checks: (core.CheckFn> | core.$ZodCheck>)[]): this; + clone(def?: Internals["def"], params?: { parent: boolean }): this; + register( + registry: R, + ...meta: this extends R["_schema"] + ? undefined extends R["_meta"] + ? [core.$replace?] + : [core.$replace] + : ["Incompatible schema"] + ): this; + brand( + value?: T + ): PropertyKey extends T ? this : core.$ZodBranded; + + def: Internals["def"]; + + parse(data: unknown, params?: core.ParseContext): core.output; + safeParse(data: unknown, params?: core.ParseContext): util.SafeParseResult>; + parseAsync(data: unknown, params?: core.ParseContext): Promise>; + safeParseAsync( + data: unknown, + params?: core.ParseContext + ): Promise>>; + apply(fn: (schema: this) => T): T; +} + +interface _ZodMiniType + extends ZodMiniType {} + +export const ZodMiniType: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniType", + (inst, def) => { + if (!inst._zod) throw new Error("Uninitialized schema in ZodMiniType."); + + core.$ZodType.init(inst, def); + + inst.def = def; + inst.type = def.type; + inst.parse = (data, params) => parse.parse(inst, data, params, { callee: inst.parse }); + inst.safeParse = (data, params) => parse.safeParse(inst, data, params); + inst.parseAsync = async (data, params) => parse.parseAsync(inst, data, params, { callee: inst.parseAsync }); + inst.safeParseAsync = async (data, params) => parse.safeParseAsync(inst, data, params); + inst.check = (...checks) => { + return inst.clone( + { + ...def, + checks: [ + ...(def.checks ?? []), + ...checks.map((ch) => + typeof ch === "function" + ? { + _zod: { check: ch, def: { check: "custom" }, onattach: [] }, + } + : ch + ), + ], + }, + { parent: true } + ); + }; + inst.with = inst.check; + inst.clone = (_def, params) => core.clone(inst, _def, params); + inst.brand = () => inst as any; + inst.register = ((reg: any, meta: any) => { + reg.add(inst, meta); + return inst; + }) as any; + inst.apply = (fn) => fn(inst); + } +); + +export interface _ZodMiniString = core.$ZodStringInternals> + extends _ZodMiniType, + core.$ZodString { + _zod: T; +} + +// ZodMiniString +export interface ZodMiniString + extends _ZodMiniString>, + core.$ZodString {} +export const ZodMiniString: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniString", + (inst, def) => { + core.$ZodString.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function string(params?: string | core.$ZodStringParams): ZodMiniString { + return core._string(ZodMiniString, params) as any; +} + +// ZodMiniStringFormat +export interface ZodMiniStringFormat + extends _ZodMiniString>, + core.$ZodStringFormat { + // _zod: core.$ZodStringFormatInternals; +} +export const ZodMiniStringFormat: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniStringFormat", + (inst, def) => { + core.$ZodStringFormat.init(inst, def); + ZodMiniString.init(inst, def); + } +); + +// ZodMiniEmail +export interface ZodMiniEmail extends _ZodMiniString {} +export const ZodMiniEmail: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniEmail", + (inst, def) => { + core.$ZodEmail.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function email(params?: string | core.$ZodEmailParams): ZodMiniEmail { + return core._email(ZodMiniEmail, params); +} + +// ZodMiniGUID +export interface ZodMiniGUID extends _ZodMiniString { + // _zod: core.$ZodGUIDInternals; +} +export const ZodMiniGUID: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniGUID", + (inst, def) => { + core.$ZodGUID.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function guid(params?: string | core.$ZodGUIDParams): ZodMiniGUID { + return core._guid(ZodMiniGUID, params); +} + +// ZodMiniUUID +export interface ZodMiniUUID extends _ZodMiniString { + // _zod: core.$ZodUUIDInternals; +} +export const ZodMiniUUID: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniUUID", + (inst, def) => { + core.$ZodUUID.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function uuid(params?: string | core.$ZodUUIDParams): ZodMiniUUID { + return core._uuid(ZodMiniUUID, params); +} + +// @__NO_SIDE_EFFECTS__ +export function uuidv4(params?: string | core.$ZodUUIDv4Params): ZodMiniUUID { + return core._uuidv4(ZodMiniUUID, params); +} + +// ZodMiniUUIDv6 + +// @__NO_SIDE_EFFECTS__ +export function uuidv6(params?: string | core.$ZodUUIDv6Params): ZodMiniUUID { + return core._uuidv6(ZodMiniUUID, params); +} + +// ZodMiniUUIDv7 + +// @__NO_SIDE_EFFECTS__ +export function uuidv7(params?: string | core.$ZodUUIDv7Params): ZodMiniUUID { + return core._uuidv7(ZodMiniUUID, params); +} + +// ZodMiniURL +export interface ZodMiniURL extends _ZodMiniString { + // _zod: core.$ZodURLInternals; +} +export const ZodMiniURL: core.$constructor = /*@__PURE__*/ core.$constructor("ZodMiniURL", (inst, def) => { + core.$ZodURL.init(inst, def); + ZodMiniStringFormat.init(inst, def); +}); + +// @__NO_SIDE_EFFECTS__ +export function url(params?: string | core.$ZodURLParams): ZodMiniURL { + return core._url(ZodMiniURL, params); +} + +// @__NO_SIDE_EFFECTS__ +export function httpUrl(params?: string | Omit): ZodMiniURL { + return core._url(ZodMiniURL, { + protocol: core.regexes.httpProtocol, + hostname: core.regexes.domain, + ...util.normalizeParams(params), + }); +} + +// ZodMiniEmoji +export interface ZodMiniEmoji extends _ZodMiniString { + // _zod: core.$ZodEmojiInternals; +} +export const ZodMiniEmoji: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniEmoji", + (inst, def) => { + core.$ZodEmoji.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function emoji(params?: string | core.$ZodEmojiParams): ZodMiniEmoji { + return core._emoji(ZodMiniEmoji, params); +} + +// ZodMiniNanoID +export interface ZodMiniNanoID extends _ZodMiniString { + // _zod: core.$ZodNanoIDInternals; +} +export const ZodMiniNanoID: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniNanoID", + (inst, def) => { + core.$ZodNanoID.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function nanoid(params?: string | core.$ZodNanoIDParams): ZodMiniNanoID { + return core._nanoid(ZodMiniNanoID, params); +} + +// ZodMiniCUID +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead. + * See https://github.com/paralleldrive/cuid. + */ +export interface ZodMiniCUID extends _ZodMiniString { + // _zod: core.$ZodCUIDInternals; +} +/** + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link ZodMiniCUID2} instead. + * See https://github.com/paralleldrive/cuid. + */ +export const ZodMiniCUID: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniCUID", + (inst, def) => { + core.$ZodCUID.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +/** + * Validates a CUID v1 string. + * + * @deprecated CUID v1 is deprecated by its authors due to information leakage + * (timestamps embedded in the id). Use {@link cuid2 | `z.cuid2()`} instead. + * See https://github.com/paralleldrive/cuid. + */ +// @__NO_SIDE_EFFECTS__ +export function cuid(params?: string | core.$ZodCUIDParams): ZodMiniCUID { + return core._cuid(ZodMiniCUID, params); +} + +// ZodMiniCUID2 +export interface ZodMiniCUID2 extends _ZodMiniString { + // _zod: core.$ZodCUID2Internals; +} +export const ZodMiniCUID2: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniCUID2", + (inst, def) => { + core.$ZodCUID2.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function cuid2(params?: string | core.$ZodCUID2Params): ZodMiniCUID2 { + return core._cuid2(ZodMiniCUID2, params); +} + +// ZodMiniULID +export interface ZodMiniULID extends _ZodMiniString { + // _zod: core.$ZodULIDInternals; +} +export const ZodMiniULID: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniULID", + (inst, def) => { + core.$ZodULID.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function ulid(params?: string | core.$ZodULIDParams): ZodMiniULID { + return core._ulid(ZodMiniULID, params); +} + +// ZodMiniXID +export interface ZodMiniXID extends _ZodMiniString { + // _zod: core.$ZodXIDInternals; +} +export const ZodMiniXID: core.$constructor = /*@__PURE__*/ core.$constructor("ZodMiniXID", (inst, def) => { + core.$ZodXID.init(inst, def); + ZodMiniStringFormat.init(inst, def); +}); + +// @__NO_SIDE_EFFECTS__ +export function xid(params?: string | core.$ZodXIDParams): ZodMiniXID { + return core._xid(ZodMiniXID, params); +} + +// ZodMiniKSUID +export interface ZodMiniKSUID extends _ZodMiniString { + // _zod: core.$ZodKSUIDInternals; +} +export const ZodMiniKSUID: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniKSUID", + (inst, def) => { + core.$ZodKSUID.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function ksuid(params?: string | core.$ZodKSUIDParams): ZodMiniKSUID { + return core._ksuid(ZodMiniKSUID, params); +} + +// ZodMiniIPv4 +export interface ZodMiniIPv4 extends _ZodMiniString { + // _zod: core.$ZodIPv4Internals; +} +export const ZodMiniIPv4: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniIPv4", + (inst, def) => { + core.$ZodIPv4.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function ipv4(params?: string | core.$ZodIPv4Params): ZodMiniIPv4 { + return core._ipv4(ZodMiniIPv4, params); +} + +// ZodMiniIPv6 +export interface ZodMiniIPv6 extends _ZodMiniString { + // _zod: core.$ZodIPv6Internals; +} +export const ZodMiniIPv6: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniIPv6", + (inst, def) => { + core.$ZodIPv6.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function ipv6(params?: string | core.$ZodIPv6Params): ZodMiniIPv6 { + return core._ipv6(ZodMiniIPv6, params); +} + +// ZodMiniCIDRv4 +export interface ZodMiniCIDRv4 extends _ZodMiniString { + // _zod: core.$ZodCIDRv4Internals; +} +export const ZodMiniCIDRv4: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniCIDRv4", + (inst, def) => { + core.$ZodCIDRv4.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function cidrv4(params?: string | core.$ZodCIDRv4Params): ZodMiniCIDRv4 { + return core._cidrv4(ZodMiniCIDRv4, params); +} + +// ZodMiniCIDRv6 +export interface ZodMiniCIDRv6 extends _ZodMiniString { + // _zod: core.$ZodCIDRv6Internals; +} +export const ZodMiniCIDRv6: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniCIDRv6", + (inst, def) => { + core.$ZodCIDRv6.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function cidrv6(params?: string | core.$ZodCIDRv6Params): ZodMiniCIDRv6 { + return core._cidrv6(ZodMiniCIDRv6, params); +} + +// ZodMiniMAC +export interface ZodMiniMAC extends _ZodMiniString { + // _zod: core.$ZodMACInternals; +} +export const ZodMiniMAC: core.$constructor = /*@__PURE__*/ core.$constructor("ZodMiniMAC", (inst, def) => { + core.$ZodMAC.init(inst, def); + ZodMiniStringFormat.init(inst, def); +}); + +// @__NO_SIDE_EFFECTS__ +export function mac(params?: string | core.$ZodMACParams): ZodMiniMAC { + return core._mac(ZodMiniMAC, params); +} + +// ZodMiniBase64 +export interface ZodMiniBase64 extends _ZodMiniString { + // _zod: core.$ZodBase64Internals; +} +export const ZodMiniBase64: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniBase64", + (inst, def) => { + core.$ZodBase64.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); +// @__NO_SIDE_EFFECTS__ +export function base64(params?: string | core.$ZodBase64Params): ZodMiniBase64 { + return core._base64(ZodMiniBase64, params); +} + +// ZodMiniBase64URL +export interface ZodMiniBase64URL extends _ZodMiniString { + // _zod: core.$ZodBase64URLInternals; +} +export const ZodMiniBase64URL: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniBase64URL", + (inst, def) => { + core.$ZodBase64URL.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); +// @__NO_SIDE_EFFECTS__ +export function base64url(params?: string | core.$ZodBase64URLParams): ZodMiniBase64URL { + return core._base64url(ZodMiniBase64URL, params); +} + +// ZodMiniE164 +export interface ZodMiniE164 extends _ZodMiniString { + // _zod: core.$ZodE164Internals; +} +export const ZodMiniE164: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniE164", + (inst, def) => { + core.$ZodE164.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function e164(params?: string | core.$ZodE164Params): ZodMiniE164 { + return core._e164(ZodMiniE164, params); +} + +// ZodMiniJWT +export interface ZodMiniJWT extends _ZodMiniString { + // _zod: core.$ZodJWTInternals; +} +export const ZodMiniJWT: core.$constructor = /*@__PURE__*/ core.$constructor("ZodMiniJWT", (inst, def) => { + core.$ZodJWT.init(inst, def); + ZodMiniStringFormat.init(inst, def); +}); + +// @__NO_SIDE_EFFECTS__ +export function jwt(params?: string | core.$ZodJWTParams): ZodMiniJWT { + return core._jwt(ZodMiniJWT, params); +} + +// ZodMiniCustomStringFormat +export interface ZodMiniCustomStringFormat + extends ZodMiniStringFormat, + core.$ZodCustomStringFormat { + _zod: core.$ZodCustomStringFormatInternals; +} +export const ZodMiniCustomStringFormat: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniCustomStringFormat", + (inst, def) => { + core.$ZodCustomStringFormat.init(inst, def); + ZodMiniStringFormat.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function stringFormat( + format: Format, + fnOrRegex: ((arg: string) => util.MaybeAsync) | RegExp, + _params: string | core.$ZodStringFormatParams = {} +): ZodMiniCustomStringFormat { + return core._stringFormat(ZodMiniCustomStringFormat, format, fnOrRegex, _params) as any; +} + +// @__NO_SIDE_EFFECTS__ +export function hostname(_params?: string | core.$ZodStringFormatParams): ZodMiniCustomStringFormat<"hostname"> { + return core._stringFormat(ZodMiniCustomStringFormat, "hostname", core.regexes.hostname, _params) as any; +} + +// @__NO_SIDE_EFFECTS__ +export function hex(_params?: string | core.$ZodStringFormatParams): ZodMiniCustomStringFormat<"hex"> { + return core._stringFormat(ZodMiniCustomStringFormat, "hex", core.regexes.hex, _params) as any; +} + +// @__NO_SIDE_EFFECTS__ +export function hash( + alg: Alg, + params?: { + enc?: Enc; + } & core.$ZodStringFormatParams +): ZodMiniCustomStringFormat<`${Alg}_${Enc}`> { + const enc = params?.enc ?? "hex"; + const format = `${alg}_${enc}` as const; + const regex = core.regexes[format as keyof typeof core.regexes] as RegExp; + // check for unrecognized format + if (!regex) throw new Error(`Unrecognized hash format: ${format}`); + return core._stringFormat(ZodMiniCustomStringFormat, format, regex, params) as any; +} + +// ZodMiniNumber +interface _ZodMiniNumber = core.$ZodNumberInternals> + extends _ZodMiniType, + core.$ZodNumber { + _zod: T; +} +export interface ZodMiniNumber + extends _ZodMiniNumber>, + core.$ZodNumber {} +export const ZodMiniNumber: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniNumber", + (inst, def) => { + core.$ZodNumber.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function number(params?: string | core.$ZodNumberParams): ZodMiniNumber { + return core._number(ZodMiniNumber, params) as any; +} + +// ZodMiniNumberFormat +export interface ZodMiniNumberFormat extends _ZodMiniNumber, core.$ZodNumberFormat {} +export const ZodMiniNumberFormat: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniNumberFormat", + (inst, def) => { + core.$ZodNumberFormat.init(inst, def); + ZodMiniNumber.init(inst, def); + } +); + +// int + +// @__NO_SIDE_EFFECTS__ +export function int(params?: string | core.$ZodCheckNumberFormatParams): ZodMiniNumberFormat { + return core._int(ZodMiniNumberFormat, params); +} + +// float32 + +// @__NO_SIDE_EFFECTS__ +export function float32(params?: string | core.$ZodCheckNumberFormatParams): ZodMiniNumberFormat { + return core._float32(ZodMiniNumberFormat, params); +} + +// float64 + +// @__NO_SIDE_EFFECTS__ +export function float64(params?: string | core.$ZodCheckNumberFormatParams): ZodMiniNumberFormat { + return core._float64(ZodMiniNumberFormat, params); +} + +// int32 + +// @__NO_SIDE_EFFECTS__ +export function int32(params?: string | core.$ZodCheckNumberFormatParams): ZodMiniNumberFormat { + return core._int32(ZodMiniNumberFormat, params); +} + +// uint32 + +// @__NO_SIDE_EFFECTS__ +export function uint32(params?: string | core.$ZodCheckNumberFormatParams): ZodMiniNumberFormat { + return core._uint32(ZodMiniNumberFormat, params); +} + +// ZodMiniBoolean +export interface ZodMiniBoolean extends _ZodMiniType> { + // _zod: core.$ZodBooleanInternals; +} +export const ZodMiniBoolean: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniBoolean", + (inst, def) => { + core.$ZodBoolean.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function boolean(params?: string | core.$ZodBooleanParams): ZodMiniBoolean { + return core._boolean(ZodMiniBoolean, params) as any; +} + +// ZodMiniBigInt +export interface ZodMiniBigInt extends _ZodMiniType>, core.$ZodBigInt { + // _zod: core.$ZodBigIntInternals; +} +export const ZodMiniBigInt: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniBigInt", + (inst, def) => { + core.$ZodBigInt.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function bigint(params?: string | core.$ZodBigIntParams): ZodMiniBigInt { + return core._bigint(ZodMiniBigInt, params) as any; +} + +// bigint formats + +// ZodMiniBigIntFormat +export interface ZodMiniBigIntFormat extends _ZodMiniType { + // _zod: core.$ZodBigIntFormatInternals; +} +export const ZodMiniBigIntFormat: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniBigIntFormat", + (inst, def) => { + core.$ZodBigIntFormat.init(inst, def); + ZodMiniBigInt.init(inst, def); + } +); + +// int64 + +// @__NO_SIDE_EFFECTS__ +export function int64(params?: string | core.$ZodBigIntFormatParams): ZodMiniBigIntFormat { + return core._int64(ZodMiniBigIntFormat, params); +} + +// uint64 + +// @__NO_SIDE_EFFECTS__ +export function uint64(params?: string | core.$ZodBigIntFormatParams): ZodMiniBigIntFormat { + return core._uint64(ZodMiniBigIntFormat, params); +} + +// ZodMiniSymbol +export interface ZodMiniSymbol extends _ZodMiniType { + // _zod: core.$ZodSymbolInternals; +} +export const ZodMiniSymbol: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniSymbol", + (inst, def) => { + core.$ZodSymbol.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function symbol(params?: string | core.$ZodSymbolParams): ZodMiniSymbol { + return core._symbol(ZodMiniSymbol, params) as any; +} + +// ZodMiniUndefined +export interface ZodMiniUndefined extends _ZodMiniType { + // _zod: core.$ZodUndefinedInternals; +} +export const ZodMiniUndefined: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniUndefined", + (inst, def) => { + core.$ZodUndefined.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +function _undefined(params?: string | core.$ZodUndefinedParams): ZodMiniUndefined { + return core._undefined(ZodMiniUndefined, params) as any; +} +export { _undefined as undefined }; + +// ZodMiniNull +export interface ZodMiniNull extends _ZodMiniType { + // _zod: core.$ZodNullInternals; +} +export const ZodMiniNull: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniNull", + (inst, def) => { + core.$ZodNull.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +function _null(params?: string | core.$ZodNullParams): ZodMiniNull { + return core._null(ZodMiniNull, params) as any; +} +export { _null as null }; + +// ZodMiniAny +export interface ZodMiniAny extends _ZodMiniType { + // _zod: core.$ZodAnyInternals; +} +export const ZodMiniAny: core.$constructor = /*@__PURE__*/ core.$constructor("ZodMiniAny", (inst, def) => { + core.$ZodAny.init(inst, def); + ZodMiniType.init(inst, def); +}); + +// @__NO_SIDE_EFFECTS__ +export function any(): ZodMiniAny { + return core._any(ZodMiniAny) as any; +} + +// ZodMiniUnknown +export interface ZodMiniUnknown extends _ZodMiniType { + // _zod: core.$ZodUnknownInternals; +} +export const ZodMiniUnknown: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniUnknown", + (inst, def) => { + core.$ZodUnknown.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function unknown(): ZodMiniUnknown { + return core._unknown(ZodMiniUnknown) as any; +} + +// ZodMiniNever +export interface ZodMiniNever extends _ZodMiniType { + // _zod: core.$ZodNeverInternals; +} +export const ZodMiniNever: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniNever", + (inst, def) => { + core.$ZodNever.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function never(params?: string | core.$ZodNeverParams): ZodMiniNever { + return core._never(ZodMiniNever, params) as any; +} + +// ZodMiniVoid +export interface ZodMiniVoid extends _ZodMiniType { + // _zod: core.$ZodVoidInternals; +} +export const ZodMiniVoid: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniVoid", + (inst, def) => { + core.$ZodVoid.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +function _void(params?: string | core.$ZodVoidParams): ZodMiniVoid { + return core._void(ZodMiniVoid, params) as any; +} +export { _void as void }; + +// ZodMiniDate +export interface ZodMiniDate extends _ZodMiniType> { + // _zod: core.$ZodDateInternals; +} + +export const ZodMiniDate: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniDate", + (inst, def) => { + core.$ZodDate.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function date(params?: string | core.$ZodDateParams): ZodMiniDate { + return core._date(ZodMiniDate, params) as any; +} + +// ZodMiniArray +export interface ZodMiniArray + extends _ZodMiniType>, + core.$ZodArray { + // _zod: core.$ZodArrayInternals; +} +export const ZodMiniArray: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniArray", + (inst, def) => { + core.$ZodArray.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +export function array(element: T, params?: string | core.$ZodArrayParams): ZodMiniArray; +// @__NO_SIDE_EFFECTS__ +export function array(element: SomeType, params?: any): ZodMiniArray { + return new ZodMiniArray({ + type: "array", + element: element as core.$ZodType, + ...util.normalizeParams(params), + }) as any; +} + +// .keyof +// @__NO_SIDE_EFFECTS__ +export function keyof(schema: T): ZodMiniEnum> { + const shape = schema._zod.def.shape; + return _enum(Object.keys(shape)) as any; +} + +// ZodMiniObject +export interface ZodMiniObject< + /** @ts-ignore Cast variance */ + out Shape extends core.$ZodShape = core.$ZodShape, + out Config extends core.$ZodObjectConfig = core.$strip, +> extends ZodMiniType>, + core.$ZodObject { + shape: Shape; +} +export const ZodMiniObject: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniObject", + (inst, def) => { + core.$ZodObject.init(inst, def); + ZodMiniType.init(inst, def); + util.defineLazy(inst, "shape", () => def.shape); + } +); +// @__NO_SIDE_EFFECTS__ +export function object>( + shape?: T, + params?: string | core.$ZodObjectParams +): ZodMiniObject, core.$strip> { + const def: core.$ZodObjectDef = { + type: "object", + shape: shape ?? {}, + ...util.normalizeParams(params), + }; + return new ZodMiniObject(def) as any; +} + +// strictObject +// @__NO_SIDE_EFFECTS__ +export function strictObject( + shape: T, + params?: string | core.$ZodObjectParams +): ZodMiniObject, core.$strict> { + return new ZodMiniObject({ + type: "object", + shape, + catchall: never(), + ...util.normalizeParams(params), + }) as any; +} + +// looseObject +// @__NO_SIDE_EFFECTS__ +export function looseObject( + shape: T, + params?: string | core.$ZodObjectParams +): ZodMiniObject, core.$loose> { + return new ZodMiniObject({ + type: "object", + shape, + catchall: unknown(), + ...util.normalizeParams(params), + }) as any; +} + +// object methods +// @__NO_SIDE_EFFECTS__ +export function extend( + schema: T, + shape: U +): ZodMiniObject>, T["_zod"]["config"]> { + return util.extend(schema, shape); +} + +export type SafeExtendShape = { + [K in keyof Ext]: K extends keyof Base + ? core.output extends core.output + ? core.input extends core.input + ? Ext[K] + : never + : never + : Ext[K]; +}; + +// @__NO_SIDE_EFFECTS__ +export function safeExtend( + schema: T, + shape: SafeExtendShape +): ZodMiniObject>, T["_zod"]["config"]> { + return util.safeExtend(schema, shape as any); +} + +/** @deprecated Identical to `z.extend(A, B)` */ +export function merge( + a: T, + b: U +): ZodMiniObject, T["_zod"]["config"]>; +// @__NO_SIDE_EFFECTS__ +export function merge(schema: ZodMiniObject, shape: any): ZodMiniObject { + return util.extend(schema, shape); +} + +// @__NO_SIDE_EFFECTS__ +export function pick>( + schema: T, + mask: M & Record, never> +): ZodMiniObject>, T["_zod"]["config"]> { + return util.pick(schema, mask as any); +} + +// .omit + +// @__NO_SIDE_EFFECTS__ +export function omit>( + schema: T, + mask: M & Record, never> +): ZodMiniObject>, T["_zod"]["config"]> { + return util.omit(schema, mask); +} + +// @__NO_SIDE_EFFECTS__ +export function partial( + schema: T +): ZodMiniObject< + { + -readonly [k in keyof T["shape"]]: ZodMiniOptional; + }, + T["_zod"]["config"] +>; +// @__NO_SIDE_EFFECTS__ +export function partial>( + schema: T, + mask: M & Record, never> +): ZodMiniObject< + { + -readonly [k in keyof T["shape"]]: k extends keyof M ? ZodMiniOptional : T["shape"][k]; + }, + T["_zod"]["config"] +>; +// @__NO_SIDE_EFFECTS__ +export function partial(schema: ZodMiniObject, mask?: object) { + return util.partial(ZodMiniOptional, schema, mask); +} + +export type RequiredInterfaceShape< + Shape extends core.$ZodLooseShape, + Keys extends PropertyKey = keyof Shape, +> = util.Identity< + { + [k in keyof Shape as k extends Keys ? k : never]: ZodMiniNonOptional; + } & { + [k in keyof Shape as k extends Keys ? never : k]: Shape[k]; + } +>; + +// @__NO_SIDE_EFFECTS__ +export function required( + schema: T +): ZodMiniObject< + { + -readonly [k in keyof T["shape"]]: ZodMiniNonOptional; + }, + T["_zod"]["config"] +>; +// @__NO_SIDE_EFFECTS__ +export function required>( + schema: T, + mask: M & Record, never> +): ZodMiniObject< + util.Extend< + T["shape"], + { + [k in keyof M & keyof T["shape"]]: ZodMiniNonOptional; + } + >, + T["_zod"]["config"] +>; +// @__NO_SIDE_EFFECTS__ +export function required(schema: ZodMiniObject, mask?: object) { + return util.required(ZodMiniNonOptional, schema, mask); +} + +// @__NO_SIDE_EFFECTS__ +export function catchall( + inst: T, + catchall: U +): ZodMiniObject> { + return inst.clone({ ...inst._zod.def, catchall: catchall as any }) as any; +} + +// ZodMiniUnion +export interface ZodMiniUnion + extends _ZodMiniType> { + // _zod: core.$ZodUnionInternals; +} +export const ZodMiniUnion: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniUnion", + (inst, def) => { + core.$ZodUnion.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function union( + options: T, + params?: string | core.$ZodUnionParams +): ZodMiniUnion { + return new ZodMiniUnion({ + type: "union", + options: options as any as core.$ZodType[], + ...util.normalizeParams(params), + }) as any; +} + +// ZodMiniXor +export interface ZodMiniXor + extends _ZodMiniType> { + // _zod: core.$ZodXorInternals; +} +export const ZodMiniXor: core.$constructor = /*@__PURE__*/ core.$constructor("ZodMiniXor", (inst, def) => { + ZodMiniUnion.init(inst, def); + core.$ZodXor.init(inst, def); +}); + +/** Creates an exclusive union (XOR) where exactly one option must match. + * Unlike regular unions that succeed when any option matches, xor fails if + * zero or more than one option matches the input. */ +export function xor( + options: T, + params?: string | core.$ZodXorParams +): ZodMiniXor { + return new ZodMiniXor({ + type: "union", + options: options as any as core.$ZodType[], + inclusive: false, + ...util.normalizeParams(params), + }) as any; +} + +// ZodMiniDiscriminatedUnion +export interface ZodMiniDiscriminatedUnion< + Options extends readonly SomeType[] = readonly core.$ZodType[], + Disc extends string = string, +> extends ZodMiniUnion { + _zod: core.$ZodDiscriminatedUnionInternals; +} +export const ZodMiniDiscriminatedUnion: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniDiscriminatedUnion", + (inst, def) => { + core.$ZodDiscriminatedUnion.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function discriminatedUnion< + Types extends readonly [core.$ZodTypeDiscriminable, ...core.$ZodTypeDiscriminable[]], + Disc extends string, +>( + discriminator: Disc, + options: Types, + params?: string | core.$ZodDiscriminatedUnionParams +): ZodMiniDiscriminatedUnion { + return new ZodMiniDiscriminatedUnion({ + type: "union", + options, + discriminator, + ...util.normalizeParams(params), + }) as ZodMiniDiscriminatedUnion; +} + +// ZodMiniIntersection +export interface ZodMiniIntersection + extends _ZodMiniType> { + // _zod: core.$ZodIntersectionInternals; +} +export const ZodMiniIntersection: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniIntersection", + (inst, def) => { + core.$ZodIntersection.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function intersection(left: T, right: U): ZodMiniIntersection { + return new ZodMiniIntersection({ + type: "intersection", + left: left as any as core.$ZodType, + right: right as any as core.$ZodType, + }) as any; +} + +// ZodMiniTuple +export interface ZodMiniTuple< + T extends util.TupleItems = readonly core.$ZodType[], + Rest extends SomeType | null = core.$ZodType | null, +> extends _ZodMiniType> { + // _zod: core.$ZodTupleInternals; +} +export const ZodMiniTuple: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniTuple", + (inst, def) => { + core.$ZodTuple.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +export function tuple( + items: T, + params?: string | core.$ZodTupleParams +): ZodMiniTuple; +export function tuple( + items: T, + rest: Rest, + params?: string | core.$ZodTupleParams +): ZodMiniTuple; +export function tuple(items: [], params?: string | core.$ZodTupleParams): ZodMiniTuple<[], null>; +// @__NO_SIDE_EFFECTS__ +export function tuple( + items: SomeType[], + _paramsOrRest?: string | core.$ZodTupleParams | SomeType, + _params?: string | core.$ZodTupleParams +) { + const hasRest = _paramsOrRest instanceof core.$ZodType; + const params = hasRest ? _params : _paramsOrRest; + const rest = hasRest ? _paramsOrRest : null; + return new ZodMiniTuple({ + type: "tuple", + items: items as any as core.$ZodType[], + rest, + ...util.normalizeParams(params), + }); +} + +// ZodMiniRecord +export interface ZodMiniRecord< + Key extends core.$ZodRecordKey = core.$ZodRecordKey, + Value extends SomeType = core.$ZodType, +> extends _ZodMiniType> { + // _zod: core.$ZodRecordInternals; +} +export const ZodMiniRecord: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniRecord", + (inst, def) => { + core.$ZodRecord.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function record( + keyType: Key, + valueType: Value, + params?: string | core.$ZodRecordParams +): ZodMiniRecord { + // v3-compat: z.record(valueType, params?) — defaults keyType to z.string() + if (!valueType || !(valueType as any)._zod) { + return new ZodMiniRecord({ + type: "record", + keyType: string() as any, + valueType: keyType as any as core.$ZodType, + ...util.normalizeParams(valueType as string | core.$ZodRecordParams | undefined), + }) as any; + } + return new ZodMiniRecord({ + type: "record", + keyType, + valueType: valueType as any as core.$ZodType, + ...util.normalizeParams(params), + }) as any; +} +// @__NO_SIDE_EFFECTS__ +export function partialRecord( + keyType: Key, + valueType: Value, + params?: string | core.$ZodRecordParams +): ZodMiniRecord { + const k = core.clone(keyType); + k._zod.values = undefined; + return new ZodMiniRecord({ + type: "record", + keyType: k, + valueType: valueType as any, + ...util.normalizeParams(params), + }) as any; +} + +export function looseRecord( + keyType: Key, + valueType: Value, + params?: string | core.$ZodRecordParams +): ZodMiniRecord { + return new ZodMiniRecord({ + type: "record", + keyType, + valueType: valueType as any as core.$ZodType, + mode: "loose", + ...util.normalizeParams(params), + }) as any; +} + +// ZodMiniMap +export interface ZodMiniMap + extends _ZodMiniType> { + // _zod: core.$ZodMapInternals; +} +export const ZodMiniMap: core.$constructor = /*@__PURE__*/ core.$constructor("ZodMiniMap", (inst, def) => { + core.$ZodMap.init(inst, def); + ZodMiniType.init(inst, def); +}); + +// @__NO_SIDE_EFFECTS__ +export function map( + keyType: Key, + valueType: Value, + params?: string | core.$ZodMapParams +): ZodMiniMap { + return new ZodMiniMap({ + type: "map", + keyType: keyType as any as core.$ZodType, + valueType: valueType as any as core.$ZodType, + ...util.normalizeParams(params), + }) as any; +} + +// ZodMiniSet +export interface ZodMiniSet extends _ZodMiniType> { + // _zod: core.$ZodSetInternals; +} +export const ZodMiniSet: core.$constructor = /*@__PURE__*/ core.$constructor("ZodMiniSet", (inst, def) => { + core.$ZodSet.init(inst, def); + ZodMiniType.init(inst, def); +}); + +// @__NO_SIDE_EFFECTS__ +export function set(valueType: Value, params?: string | core.$ZodSetParams): ZodMiniSet { + return new ZodMiniSet({ + type: "set", + valueType: valueType as any as core.$ZodType, + ...util.normalizeParams(params), + }) as any; +} + +// ZodMiniEnum +export interface ZodMiniEnum extends _ZodMiniType> { + // _zod: core.$ZodEnumInternals; + options: Array; +} +export const ZodMiniEnum: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniEnum", + (inst, def) => { + core.$ZodEnum.init(inst, def); + ZodMiniType.init(inst, def); + + inst.options = Object.values(def.entries); + } +); + +function _enum( + values: T, + params?: string | core.$ZodEnumParams +): ZodMiniEnum>; +function _enum(entries: T, params?: string | core.$ZodEnumParams): ZodMiniEnum; +// @__NO_SIDE_EFFECTS__ +function _enum(values: any, params?: string | core.$ZodEnumParams) { + const entries: any = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values; + + return new ZodMiniEnum({ + type: "enum", + entries, + ...util.normalizeParams(params), + }) as any; +} +export { _enum as enum }; + +// @__NO_SIDE_EFFECTS__ +/** @deprecated This API has been merged into `z.enum()`. Use `z.enum()` instead. + * + * ```ts + * enum Colors { red, green, blue } + * z.enum(Colors); + * ``` + */ +export function nativeEnum(entries: T, params?: string | core.$ZodEnumParams): ZodMiniEnum { + return new ZodMiniEnum({ + type: "enum", + entries, + ...util.normalizeParams(params), + }) as any as ZodMiniEnum; +} + +// ZodMiniLiteral +export interface ZodMiniLiteral + extends _ZodMiniType> { + // _zod: core.$ZodLiteralInternals; +} +export const ZodMiniLiteral: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniLiteral", + (inst, def) => { + core.$ZodLiteral.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +export function literal>( + value: T, + params?: string | core.$ZodLiteralParams +): ZodMiniLiteral; +export function literal( + value: T, + params?: string | core.$ZodLiteralParams +): ZodMiniLiteral; +// @__NO_SIDE_EFFECTS__ +export function literal(value: any, params: any) { + return new ZodMiniLiteral({ + type: "literal", + values: Array.isArray(value) ? value : [value], + ...util.normalizeParams(params), + }); +} + +// ZodMiniFile +export interface ZodMiniFile extends _ZodMiniType { + // _zod: core.$ZodFileInternals; +} +export const ZodMiniFile: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniFile", + (inst, def) => { + core.$ZodFile.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function file(params?: string | core.$ZodFileParams): ZodMiniFile { + return core._file(ZodMiniFile, params) as any; +} + +// ZodMiniTransform +export interface ZodMiniTransform extends _ZodMiniType> { + // _zod: core.$ZodTransformInternals; +} +export const ZodMiniTransform: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniTransform", + (inst, def) => { + core.$ZodTransform.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function transform( + fn: (input: I, ctx: core.ParsePayload) => O +): ZodMiniTransform, I> { + return new ZodMiniTransform({ + type: "transform", + transform: fn as any, + }) as any; +} + +// ZodMiniOptional +export interface ZodMiniOptional + extends _ZodMiniType>, + core.$ZodOptional { + // _zod: core.$ZodOptionalInternals; +} +export const ZodMiniOptional: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniOptional", + (inst, def) => { + core.$ZodOptional.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function optional(innerType: T): ZodMiniOptional { + return new ZodMiniOptional({ + type: "optional", + innerType: innerType as any as core.$ZodType, + }) as any; +} + +// ZodMiniExactOptional +export interface ZodMiniExactOptional + extends _ZodMiniType>, + core.$ZodExactOptional { + // _zod: core.$ZodExactOptionalInternals; +} +export const ZodMiniExactOptional: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniExactOptional", + (inst, def) => { + core.$ZodExactOptional.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function exactOptional(innerType: T): ZodMiniExactOptional { + return new ZodMiniExactOptional({ + type: "optional", + innerType: innerType as any as core.$ZodType, + }) as any; +} + +// ZodMiniNullable +export interface ZodMiniNullable + extends _ZodMiniType> { + // _zod: core.$ZodNullableInternals; +} +export const ZodMiniNullable: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniNullable", + (inst, def) => { + core.$ZodNullable.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function nullable(innerType: T): ZodMiniNullable { + return new ZodMiniNullable({ + type: "nullable", + innerType: innerType as any as core.$ZodType, + }) as any; +} + +// nullish +// @__NO_SIDE_EFFECTS__ +export function nullish(innerType: T): ZodMiniOptional> { + return optional(nullable(innerType)); +} + +// ZodMiniDefault +export interface ZodMiniDefault extends _ZodMiniType> { + // _zod: core.$ZodDefaultInternals; +} +export const ZodMiniDefault: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniDefault", + (inst, def) => { + core.$ZodDefault.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function _default( + innerType: T, + defaultValue: util.NoUndefined> | (() => util.NoUndefined>) +): ZodMiniDefault { + return new ZodMiniDefault({ + type: "default", + innerType: innerType as any as core.$ZodType, + get defaultValue() { + return typeof defaultValue === "function" ? (defaultValue as Function)() : util.shallowClone(defaultValue); + }, + }) as any; +} + +// ZodMiniPrefault +export interface ZodMiniPrefault + extends _ZodMiniType> { + // _zod: core.$ZodPrefaultInternals; +} +export const ZodMiniPrefault: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniPrefault", + (inst, def) => { + core.$ZodPrefault.init(inst, def); + ZodMiniType.init(inst, def); + } +); +// @__NO_SIDE_EFFECTS__ +export function prefault( + innerType: T, + defaultValue: util.NoUndefined> | (() => util.NoUndefined>) +): ZodMiniPrefault { + return new ZodMiniPrefault({ + type: "prefault", + innerType: innerType as any as core.$ZodType, + get defaultValue() { + return typeof defaultValue === "function" ? (defaultValue as Function)() : util.shallowClone(defaultValue); + }, + }) as any; +} + +// ZodMiniNonOptional +export interface ZodMiniNonOptional + extends _ZodMiniType> { + // _zod: core.$ZodNonOptionalInternals; +} +export const ZodMiniNonOptional: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniNonOptional", + (inst, def) => { + core.$ZodNonOptional.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function nonoptional( + innerType: T, + params?: string | core.$ZodNonOptionalParams +): ZodMiniNonOptional { + return new ZodMiniNonOptional({ + type: "nonoptional", + innerType: innerType as any as core.$ZodType, + ...util.normalizeParams(params), + }) as any; +} + +// ZodMiniSuccess +export interface ZodMiniSuccess extends _ZodMiniType> { + // _zod: core.$ZodSuccessInternals; +} +export const ZodMiniSuccess: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniSuccess", + (inst, def) => { + core.$ZodSuccess.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function success(innerType: T): ZodMiniSuccess { + return new ZodMiniSuccess({ + type: "success", + innerType: innerType as any as core.$ZodType, + }) as any; +} + +// ZodMiniCatch +export interface ZodMiniCatch extends _ZodMiniType> { + // _zod: core.$ZodCatchInternals; +} +export const ZodMiniCatch: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniCatch", + (inst, def) => { + core.$ZodCatch.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +function _catch( + innerType: T, + catchValue: core.output | ((ctx: core.$ZodCatchCtx) => core.output) +): ZodMiniCatch { + return new ZodMiniCatch({ + type: "catch", + innerType: innerType as any as core.$ZodType, + catchValue: (typeof catchValue === "function" ? catchValue : () => catchValue) as ( + ctx: core.$ZodCatchCtx + ) => core.output, + }) as any; +} +export { _catch as catch }; + +// ZodMiniNaN +export interface ZodMiniNaN extends _ZodMiniType { + // _zod: core.$ZodNaNInternals; +} +export const ZodMiniNaN: core.$constructor = /*@__PURE__*/ core.$constructor("ZodMiniNaN", (inst, def) => { + core.$ZodNaN.init(inst, def); + ZodMiniType.init(inst, def); +}); + +// @__NO_SIDE_EFFECTS__ +export function nan(params?: string | core.$ZodNaNParams): ZodMiniNaN { + return core._nan(ZodMiniNaN, params) as any; +} + +// ZodMiniPipe +export interface ZodMiniPipe + extends _ZodMiniType> { + // _zod: core.$ZodPipeInternals; +} +export const ZodMiniPipe: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniPipe", + (inst, def) => { + core.$ZodPipe.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function pipe< + const A extends SomeType, + B extends core.$ZodType> = core.$ZodType>, +>(in_: A, out: B | core.$ZodType>): ZodMiniPipe { + return new ZodMiniPipe({ + type: "pipe", + in: in_ as any as core.$ZodType, + out: out as any as core.$ZodType, + }) as any; +} + +// ZodMiniCodec +export interface ZodMiniCodec + extends ZodMiniPipe, + core.$ZodCodec { + _zod: core.$ZodCodecInternals; + def: core.$ZodCodecDef; +} +export const ZodMiniCodec: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniCodec", + (inst, def) => { + ZodMiniPipe.init(inst, def); + core.$ZodCodec.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function codec( + in_: A, + out: B, + params: { + decode: (value: core.output, payload: core.ParsePayload>) => core.util.MaybeAsync>; + encode: (value: core.input, payload: core.ParsePayload>) => core.util.MaybeAsync>; + } +): ZodMiniCodec { + return new ZodMiniCodec({ + type: "pipe", + in: in_ as any as core.$ZodType, + out: out as any as core.$ZodType, + transform: params.decode as any, + reverseTransform: params.encode as any, + }) as any; +} + +// @__NO_SIDE_EFFECTS__ +export function invertCodec(codec: ZodMiniCodec): ZodMiniCodec { + const def = codec._zod.def; + return new ZodMiniCodec({ + type: "pipe", + in: def.out as any, + out: def.in as any, + transform: def.reverseTransform as any, + reverseTransform: def.transform as any, + }) as any; +} + +// ZodMiniReadonly +export interface ZodMiniReadonly + extends _ZodMiniType> { + // _zod: core.$ZodReadonlyInternals; +} +export const ZodMiniReadonly: core.$constructor = /*@__PURE__*/ core.$constructor( + "ZodMiniReadonly", + (inst, def) => { + core.$ZodReadonly.init(inst, def); + ZodMiniType.init(inst, def); + } +); + +// @__NO_SIDE_EFFECTS__ +export function readonly(innerType: T): ZodMiniReadonly { + return new ZodMiniReadonly({ + type: "readonly", + innerType: innerType as any as core.$ZodType, + }) as any; +} + +// ZodMiniTemplateLiteral +export interface ZodMiniTemplateLiteral