UNPKG

@linode/validation

Version:

Yup validation schemas for use with the Linode APIv4

1,073 lines (1,062 loc) 124 kB
"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); // src/index.ts var index_exports = {}; __export(index_exports, { AttachVolumeSchema: () => AttachVolumeSchema, CHECK_ATTEMPTS: () => CHECK_ATTEMPTS, CHECK_INTERVAL: () => CHECK_INTERVAL, CHECK_TIMEOUT: () => CHECK_TIMEOUT, CUSTOM_PORTS_ERROR_MESSAGE: () => CUSTOM_PORTS_ERROR_MESSAGE, CloneVolumeSchema: () => CloneVolumeSchema, ConfigProfileInterfaceSchema: () => ConfigProfileInterfaceSchema, ConfigProfileInterfacesSchema: () => ConfigProfileInterfacesSchema, CreateBucketSchema: () => CreateBucketSchema, CreateFirewallDeviceSchema: () => CreateFirewallDeviceSchema, CreateFirewallSchema: () => CreateFirewallSchema, CreateLinodeConfigSchema: () => CreateLinodeConfigSchema, CreateLinodeDiskFromImageSchema: () => CreateLinodeDiskFromImageSchema, CreateLinodeDiskSchema: () => CreateLinodeDiskSchema, CreateLinodeInterfaceSchema: () => CreateLinodeInterfaceSchema, CreateLinodeSchema: () => CreateLinodeSchema, CreateNodePoolSchema: () => CreateNodePoolSchema, CreateSnapshotSchema: () => CreateSnapshotSchema, CreateTransferSchema: () => CreateTransferSchema, CreateUserSchema: () => CreateUserSchema, CreateVPCInterfaceSchema: () => CreateVPCInterfaceSchema, CreateVolumeSchema: () => CreateVolumeSchema, CreditCardSchema: () => CreditCardSchema, EditNodePoolSchema: () => EditNodePoolSchema, FirewallDeviceSchema: () => FirewallDeviceSchema, FirewallRuleSchema: () => FirewallRuleSchema, FirewallRuleTypeSchema: () => FirewallRuleTypeSchema, IPAllocationSchema: () => IPAllocationSchema, IP_EITHER_BOTH_NOT_NEITHER: () => IP_EITHER_BOTH_NOT_NEITHER, IP_ERROR_MESSAGE: () => IP_ERROR_MESSAGE, ModifyLinodeInterfaceSchema: () => ModifyLinodeInterfaceSchema, NodeBalancerSchema: () => NodeBalancerSchema, PRIVATE_IPV4_REGEX: () => PRIVATE_IPV4_REGEX, PRIVATE_IPV6_REGEX: () => PRIVATE_IPV6_REGEX, PaymentMethodSchema: () => PaymentMethodSchema, PaymentSchema: () => PaymentSchema, PromoCodeSchema: () => PromoCodeSchema, RebuildLinodeFromStackScriptSchema: () => RebuildLinodeFromStackScriptSchema, RebuildLinodeSchema: () => RebuildLinodeSchema, ResizeLinodeDiskSchema: () => ResizeLinodeDiskSchema, ResizeVolumeSchema: () => ResizeVolumeSchema, SecurityQuestionsSchema: () => SecurityQuestionsSchema, SendCodeToPhoneNumberSchema: () => SendCodeToPhoneNumberSchema, UpdateAccountSettingsSchema: () => UpdateAccountSettingsSchema, UpdateBucketAccessSchema: () => UpdateBucketAccessSchema, UpdateConfigInterfaceOrderSchema: () => UpdateConfigInterfaceOrderSchema, UpdateConfigInterfaceSchema: () => UpdateConfigInterfaceSchema, UpdateFirewallSchema: () => UpdateFirewallSchema, UpdateFirewallSettingsSchema: () => UpdateFirewallSettingsSchema, UpdateGrantSchema: () => UpdateGrantSchema, UpdateLinodeAlertsSchema: () => UpdateLinodeAlertsSchema, UpdateLinodeConfigSchema: () => UpdateLinodeConfigSchema, UpdateLinodeDiskSchema: () => UpdateLinodeDiskSchema, UpdateLinodeInterfaceSettingsSchema: () => UpdateLinodeInterfaceSettingsSchema, UpdateLinodePasswordSchema: () => UpdateLinodePasswordSchema, UpdateLinodeSchema: () => UpdateLinodeSchema, UpdateNodeBalancerConfigSchema: () => UpdateNodeBalancerConfigSchema, UpdateNodeBalancerSchema: () => UpdateNodeBalancerSchema, UpdateUserEmailSchema: () => UpdateUserEmailSchema, UpdateUserNameSchema: () => UpdateUserNameSchema, UpdateUserSchema: () => UpdateUserSchema, UpdateVolumeSchema: () => UpdateVolumeSchema, UpgradeToLinodeInterfaceSchema: () => UpgradeToLinodeInterfaceSchema, UploadCertificateSchema: () => UploadCertificateSchema, VerifyPhoneNumberCodeSchema: () => VerifyPhoneNumberCodeSchema, addSharegroupImagesSchema: () => addSharegroupImagesSchema, addSharegroupMemberSchema: () => addSharegroupMemberSchema, allocateIPSchema: () => allocateIPSchema, assignAddressesSchema: () => assignAddressesSchema, baseImageSchema: () => baseImageSchema, clusterLabelSchema: () => clusterLabelSchema, createAccountLimitSupportTicketSchema: () => createAccountLimitSupportTicketSchema, createAlertDefinitionSchema: () => createAlertDefinitionSchema, createCloudNATSchema: () => createCloudNATSchema, createContactSchema: () => createContactSchema, createCredentialSchema: () => createCredentialSchema, createDatabaseConnectionPoolSchema: () => createDatabaseConnectionPoolSchema, createDatabaseSchema: () => createDatabaseSchema, createDestinationSchema: () => createDestinationSchema, createDomainSchema: () => createDomainSchema, createDynamicAdvancedConfigSchema: () => createDynamicAdvancedConfigSchema, createImageSchema: () => createImageSchema, createKubeClusterSchema: () => createKubeClusterSchema, createKubeClusterWithRequiredACLSchema: () => createKubeClusterWithRequiredACLSchema, createNodeBalancerConfigSchema: () => createNodeBalancerConfigSchema, createOAuthClientSchema: () => createOAuthClientSchema, createObjectStorageKeysSchema: () => createObjectStorageKeysSchema, createPersonalAccessTokenSchema: () => createPersonalAccessTokenSchema, createPlacementGroupSchema: () => createPlacementGroupSchema, createRecordSchema: () => createRecordSchema, createReplySchema: () => createReplySchema, createSMTPSupportTicketSchema: () => createSMTPSupportTicketSchema, createSSHKeySchema: () => createSSHKeySchema, createServiceMonitorSchema: () => createServiceMonitorSchema, createSharegroupSchema: () => createSharegroupSchema, createStreamSchema: () => createStreamSchema, createSubnetSchemaIPv4: () => createSubnetSchemaIPv4, createSubnetSchemaWithIPv6: () => createSubnetSchemaWithIPv6, createSupportTicketSchema: () => createSupportTicketSchema, createVPCSchema: () => createVPCSchema, credentialLabel: () => credentialLabel, credentialPassword: () => credentialPassword, credentialUsername: () => credentialUsername, destinationFormSchema: () => destinationFormSchema, determineIPType: () => determineIPType, dimensionFilters: () => dimensionFilters, editAlertDefinitionSchema: () => editAlertDefinitionSchema, emailSchema: () => emailSchema, enableTwoFactorSchema: () => enableTwoFactorSchema, generateSharegroupTokenSchema: () => generateSharegroupTokenSchema, getDynamicDatabaseSchema: () => getDynamicDatabaseSchema, importZoneSchema: () => importZoneSchema, ipAddress: () => ipAddress, ipv4Address: () => ipv4Address, ipv6Address: () => ipv6Address, isCustomPortsValid: () => isCustomPortsValid, kubernetesControlPlaneACLPayloadSchema: () => kubernetesControlPlaneACLPayloadSchema, kubernetesEnterpriseControlPlaneACLPayloadSchema: () => kubernetesEnterpriseControlPlaneACLPayloadSchema, kubernetesLabelSchema: () => kubernetesLabelSchema, kubernetesTaintSchema: () => kubernetesTaintSchema, longviewClientCreate: () => longviewClientCreate, metricCriteria: () => metricCriteria, modifySubnetSchema: () => modifySubnetSchema, nodeBalancerConfigNodeSchema: () => nodeBalancerConfigNodeSchema, shareAddressesSchema: () => shareAddressesSchema, sharegroupImageSchema: () => sharegroupImageSchema, sshSettingSchema: () => sshSettingSchema, stackScriptSchema: () => stackScriptSchema, streamAndDestinationFormSchema: () => streamAndDestinationFormSchema, triggerConditionValidation: () => triggerConditionValidation, updateAccountSchema: () => updateAccountSchema, updateCloudNATSchema: () => updateCloudNATSchema, updateCredentialSchema: () => updateCredentialSchema, updateDatabaseConnectionPoolSchema: () => updateDatabaseConnectionPoolSchema, updateDatabaseSchema: () => updateDatabaseSchema, updateDestinationSchema: () => updateDestinationSchema, updateDomainSchema: () => updateDomainSchema, updateIPSchema: () => updateIPSchema, updateImageRegionsSchema: () => updateImageRegionsSchema, updateImageSchema: () => updateImageSchema, updateMaintenanceSchema: () => updateMaintenanceSchema, updateManagedLinodeSchema: () => updateManagedLinodeSchema, updateOAuthClientSchema: () => updateOAuthClientSchema, updateObjectStorageKeysSchema: () => updateObjectStorageKeysSchema, updatePasswordSchema: () => updatePasswordSchema, updatePlacementGroupSchema: () => updatePlacementGroupSchema, updatePrivateNetworkSchema: () => updatePrivateNetworkSchema, updateProfileSchema: () => updateProfileSchema, updateRecordSchema: () => updateRecordSchema, updateSSHKeySchema: () => updateSSHKeySchema, updateSharegroupImageSchema: () => updateSharegroupImageSchema, updateSharegroupMemberSchema: () => updateSharegroupMemberSchema, updateSharegroupSchema: () => updateSharegroupSchema, updateSharegroupTokenSchema: () => updateSharegroupTokenSchema, updateStackScriptSchema: () => updateStackScriptSchema, updateStreamSchema: () => updateStreamSchema, updateVPCSchema: () => updateVPCSchema, uploadImageSchema: () => uploadImageSchema, userNameErrors: () => userNameErrors, validateIP: () => validateIP, vpcsValidateIP: () => vpcsValidateIP }); module.exports = __toCommonJS(index_exports); // src/account.schema.ts var import_yup2 = require("yup"); // src/profile.schema.ts var import_libphonenumber_js = require("libphonenumber-js"); var import_yup = require("yup"); var EMAIL_VALIDATION_REGEX = new RegExp( // eslint-disable-next-line sonarjs/regex-complexity /^(?!-.*|.*(\.{2}|@-))[a-zA-Z0-9_.+"-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]*[a-zA-Z0-9]$/ ); var createPersonalAccessTokenSchema = (0, import_yup.object)({ scopes: (0, import_yup.string)(), expiry: (0, import_yup.string)(), label: (0, import_yup.string)().min(1, "Label must be between 1 and 100 characters.").max(100, "Label must be between 1 and 100 characters.") }); var createSSHKeySchema = (0, import_yup.object)({ label: (0, import_yup.string)().required("Label is required.").min(1, "Label must be between 1 and 64 characters.").max(64, "Label must be between 1 and 64 characters.").trim(), ssh_key: (0, import_yup.string)() }); var updateSSHKeySchema = (0, import_yup.object)({ label: (0, import_yup.string)().required("Label is required.").min(1, "Label must be between 1 and 64 characters.").max(64, "Label must be between 1 and 64 characters.").trim() }); var emailSchema = (0, import_yup.string)().required("Email address is required.").max(128, "Email address must be 128 characters or less.").email("Must be a valid email address.").matches(EMAIL_VALIDATION_REGEX, `Invalid email address.`); var updateProfileSchema = (0, import_yup.object)({ email: (0, import_yup.string)().email().matches(EMAIL_VALIDATION_REGEX, `Invalid email address. `), timezone: (0, import_yup.string)(), email_notifications: (0, import_yup.boolean)(), authorized_keys: (0, import_yup.array)().of((0, import_yup.string)()), restricted: (0, import_yup.boolean)(), two_factor_auth: (0, import_yup.boolean)(), lish_auth_method: (0, import_yup.string)().oneOf(["password_keys", "keys_only", "disabled"]), authentication_type: (0, import_yup.string)().oneOf(["password", "github"]) }); var SendCodeToPhoneNumberSchema = (0, import_yup.object)({ iso_code: (0, import_yup.string)().required(), phone_number: (0, import_yup.string)().test( "is-phone-number", "Not a valid phone number", (phone_number, context) => { const { iso_code } = context.parent; if (!phone_number) { return false; } return (0, import_libphonenumber_js.isPossiblePhoneNumber)(phone_number, iso_code); } ) }); var VerifyPhoneNumberCodeSchema = (0, import_yup.object)({ otp_code: (0, import_yup.string)().required("Verification Code is required.").test( "digits only", "The verification code must only contain digits.", (value) => { if (!value) { return true; } return /^\d+$/.test(value); } ) }); var SecurityQuestionsSchema = (0, import_yup.object)({ security_questions: (0, import_yup.array)().of( (0, import_yup.object)({ question_id: (0, import_yup.number)().required("You must pick a question."), response: (0, import_yup.string)().min(3, "Answers must be at least 3 characters.").max(17, "Answers must be at most 17 characters.").required("You must provide an answer to each security question.") }).required() ).length(3, "You must answer all 3 security questions.").required() }); // src/account.schema.ts var updateAccountSchema = (0, import_yup2.object)({ email: (0, import_yup2.string)().max(128, "Email must be 128 characters or less."), address_1: (0, import_yup2.string)().max(64, "Address must be 64 characters or less."), city: (0, import_yup2.string)().max(24, "City must be 24 characters or less."), company: (0, import_yup2.string)().max(128, "Company must be 128 characters or less."), country: (0, import_yup2.string)().min(2, "Country code must be two letters.").max(2, "Country code must be two letters."), first_name: (0, import_yup2.string)().max(50, "First name must be 50 characters or less."), last_name: (0, import_yup2.string)().max(50, "Last name must be 50 characters or less."), address_2: (0, import_yup2.string)().max(64, "Address must be 64 characters or less."), phone: (0, import_yup2.string)().max(32, "Phone number must be 32 characters or less."), state: (0, import_yup2.string)().max(24, "State must be 24 characters or less."), tax_id: (0, import_yup2.string)().max(100, "Tax ID must be 100 characters or less."), zip: (0, import_yup2.string)().max(16, "Zip code must be 16 characters or less.") }); var createOAuthClientSchema = (0, import_yup2.object)({ label: (0, import_yup2.string)().required("Label is required.").min(1, "Label must be between 1 and 512 characters.").max(512, "Label must be between 1 and 512 characters."), redirect_uri: (0, import_yup2.string)().required("Redirect URI is required.") }); var updateOAuthClientSchema = (0, import_yup2.object)({ label: (0, import_yup2.string)().min(1, "Label must be between 1 and 512 characters.").max(512, "Label must be between 1 and 512 characters."), redirect_uri: (0, import_yup2.string)() }); var PaymentSchema = (0, import_yup2.object)({ usd: (0, import_yup2.string)().required("USD payment amount is required.") }); var CreditCardSchema = (0, import_yup2.object)({ card_number: (0, import_yup2.string)().required("Credit card number is required.").min(13, "Credit card number must be between 13 and 23 characters.").max(23, "Credit card number must be between 13 and 23 characters."), expiry_year: (0, import_yup2.number)().test( "length", "Expiration year must be 2 or 4 digits.", (value) => [2, 4].includes(String(value).length) ).required("Expiration year is required.").typeError("Expiration year must be a number.").min((/* @__PURE__ */ new Date()).getFullYear(), "Expiration year must not be in the past.").max((/* @__PURE__ */ new Date()).getFullYear() + 20, "Expiry too far in the future."), expiry_month: (0, import_yup2.number)().required("Expiration month is required.").typeError("Expiration month must be a number.").min(1, "Expiration month must be a number from 1 to 12.").max(12, "Expiration month must be a number from 1 to 12."), cvv: (0, import_yup2.string)().required("Security code is required.").min(3, "Security code must be between 3 and 4 characters.").max(4, "Security code must be between 3 and 4 characters.") }); var PaymentMethodSchema = (0, import_yup2.object)({ type: (0, import_yup2.mixed)().oneOf( ["credit_card", "payment_method_nonce"], "Type must be credit_card or payment_method_nonce." ), data: (0, import_yup2.object)().when("type", { is: "credit_card", then: () => CreditCardSchema, otherwise: () => (0, import_yup2.object)({ nonce: (0, import_yup2.string)().required("Payment nonce is required.") }) }), is_default: (0, import_yup2.boolean)().required( "You must indicate if this should be your default method of payment." ) }); var userNameErrors = { lengthError: "Username must be between 3 and 32 characters.", consecutiveError: "Username must not include two dashes or underscores in a row.", charsError: "Username may only contain letters, numbers, dashes, and underscores and must begin and end with letters or numbers.", spacesError: "Username may not contain spaces or tabs.", nonAsciiError: "Username must only use ASCII characters." }; var usernameSchema = (0, import_yup2.string)().required("Username is required.").min(3, userNameErrors.lengthError).max(32, userNameErrors.lengthError).test("ascii-only", userNameErrors.nonAsciiError, (value) => { if (!value) return false; return [...value].every((char) => char.charCodeAt(0) <= 127); }).test("no-whitespace", userNameErrors.spacesError, (value) => { if (!value) return true; return !/[ \t]/.test(value); }).test( "no-consecutive-separators", userNameErrors.consecutiveError, (value) => { if (!value) return true; return !value.includes("__") && !value.includes("--"); } ).test("valid-characters", userNameErrors.charsError, (value) => { if (!value) return false; const firstChar = value[0]; const lastChar = value[value.length - 1]; const isAlphaNum = /[a-zA-Z0-9]/; if (!isAlphaNum.test(firstChar) || !isAlphaNum.test(lastChar)) { return false; } return /^[a-zA-Z0-9_-]+$/.test(value); }); var CreateUserSchema = (0, import_yup2.object)({ username: usernameSchema, email: emailSchema, restricted: (0, import_yup2.boolean)().required( "You must indicate if this user should have restricted access." ) }); var UpdateUserNameSchema = (0, import_yup2.object)({ username: usernameSchema }); var UpdateUserEmailSchema = (0, import_yup2.object)({ email: emailSchema }); var UpdateUserSchema = (0, import_yup2.object)({ username: (0, import_yup2.string)().min(3, userNameErrors.lengthError).max(32, userNameErrors.lengthError), email: (0, import_yup2.string)().email("Must be a valid email address."), restricted: (0, import_yup2.boolean)() }); var GrantSchema = (0, import_yup2.object)({ id: (0, import_yup2.number)().required("ID is required."), permissions: (0, import_yup2.string)().oneOf( ["read_only", "read_write"], "Permissions must be null, read_only, or read_write." ).nullable("Permissions must be null, read_only, or read_write.") }); var UpdateGrantSchema = (0, import_yup2.object)({ global: (0, import_yup2.object)(), linode: (0, import_yup2.array)().of(GrantSchema), domain: (0, import_yup2.array)().of(GrantSchema), nodebalancer: (0, import_yup2.array)().of(GrantSchema), image: (0, import_yup2.array)().of(GrantSchema), longview: (0, import_yup2.array)().of(GrantSchema), stackscript: (0, import_yup2.array)().of(GrantSchema), volume: (0, import_yup2.array)().of(GrantSchema) }); var UpdateAccountSettingsSchema = (0, import_yup2.object)({ network_helper: (0, import_yup2.boolean)(), backups_enabled: (0, import_yup2.boolean)(), managed: (0, import_yup2.boolean)(), longview_subscription: (0, import_yup2.string)().nullable(), object_storage: (0, import_yup2.string)(), interfaces_for_new_linodes: (0, import_yup2.string)() }); var PromoCodeSchema = (0, import_yup2.object)({ promo_code: (0, import_yup2.string)().required("Promo code is required.").min(1, "Promo code must be between 1 and 32 characters.").max(32, "Promo code must be between 1 and 32 characters.") }); // src/buckets.schema.ts var import_yup3 = require("yup"); var ENDPOINT_TYPES = ["E0", "E1", "E2", "E3"]; var CreateBucketSchema = (0, import_yup3.object)().shape( { label: (0, import_yup3.string)().required("Bucket name is required.").min(3, "Bucket name must be between 3 and 63 characters.").matches(/^\S*$/, "Bucket name must not contain spaces.").matches( /^[a-z0-9].*[a-z0-9]$/, "Bucket name must start and end with a lowercase letter or number." ).matches( /^(?!.*[.-]{2})[a-z0-9.-]+$/, "Bucket name must contain only lowercase letters, numbers, periods (.), and hyphens (-). Adjacent periods and hyphens are not allowed." ).max(63, "Bucket name must be between 3 and 63 characters.").test( "unique-label", "A bucket with this name already exists in your selected region", (value, context) => { var _a; const { cluster, region } = context.parent; const buckets = (_a = context.options.context) == null ? void 0 : _a.buckets; if (!Array.isArray(buckets)) { return true; } return !buckets.some( (bucket) => bucket.label === value && (bucket.cluster === cluster || bucket.region === region) ); } ), cluster: (0, import_yup3.string)().when("region", { is: (region) => !region || region.length === 0, then: (schema) => schema.required("Cluster is required.") }), region: (0, import_yup3.string)().when("cluster", { is: (cluster) => !cluster || cluster.length === 0, then: (schema) => schema.required("Region is required.") }), endpoint_type: (0, import_yup3.string)().oneOf([...ENDPOINT_TYPES]).optional(), cors_enabled: (0, import_yup3.boolean)().optional(), acl: (0, import_yup3.string)().oneOf([ "private", "public-read", "authenticated-read", "public-read-write" ]).optional(), s3_endpoint: (0, import_yup3.string)().optional() }, [["cluster", "region"]] ).test("cors-enabled-check", "Invalid CORS configuration.", function(value) { const { endpoint_type, cors_enabled } = value; if ((endpoint_type === "E0" || endpoint_type === "E1") && !cors_enabled) { return this.createError({ path: "cors_enabled", message: "CORS must be enabled for endpoint type E0 or E1." }); } if ((endpoint_type === "E2" || endpoint_type === "E3") && cors_enabled) { return this.createError({ path: "cors_enabled", message: "CORS must be disabled for endpoint type E2 or E3." }); } return true; }); var UploadCertificateSchema = (0, import_yup3.object)({ certificate: (0, import_yup3.string)().required("Certificate is required."), private_key: (0, import_yup3.string)().required("Private key is required.") }); var UpdateBucketAccessSchema = (0, import_yup3.object)({ acl: (0, import_yup3.string)().oneOf([ "private", "public-read", "authenticated-read", "public-read-write" ]).notRequired(), cors_enabled: (0, import_yup3.boolean)().notRequired() }); // src/cloudnats.schema.ts var import_yup4 = require("yup"); var VALID_PORT_SIZES = [ 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384 ]; var createCloudNATSchema = (0, import_yup4.object)({ addresses: (0, import_yup4.array)().of( (0, import_yup4.object)({ address: (0, import_yup4.string)().required("Address must be a string.") }) ).notRequired(), label: (0, import_yup4.string)().required("Label is required.").max(150, "Label must be 150 characters or fewer."), port_prefix_default_len: (0, import_yup4.number)().oneOf(VALID_PORT_SIZES, "Invalid port size.").notRequired(), region: (0, import_yup4.string)().required("Region is required.") }); var updateCloudNATSchema = (0, import_yup4.object)({ label: (0, import_yup4.string)().max(150, "Label must be 150 characters or fewer.") }); // src/cloudpulse.schema.ts var import_yup5 = require("yup"); var fieldErrorMessage = "This field is required."; var dimensionFilters = (0, import_yup5.object)({ dimension_label: (0, import_yup5.string)().required(fieldErrorMessage), operator: (0, import_yup5.string)().oneOf(["eq", "neq", "startswith", "endswith", "in"]).required(fieldErrorMessage), value: (0, import_yup5.string)().required(fieldErrorMessage) }); var metricCriteria = (0, import_yup5.object)({ metric: (0, import_yup5.string)().required(fieldErrorMessage), aggregate_function: (0, import_yup5.string)().oneOf(["avg", "count", "max", "min", "sum"]).required(fieldErrorMessage), operator: (0, import_yup5.string)().oneOf(["eq", "gt", "lt", "gte", "lte"]).required(fieldErrorMessage), threshold: (0, import_yup5.number)().required(fieldErrorMessage).min(0, "Enter a positive value.").typeError("The value should be a number."), dimension_filters: (0, import_yup5.array)().of(dimensionFilters.defined()).optional() }); var triggerConditionValidation = (0, import_yup5.object)({ criteria_condition: (0, import_yup5.string)().oneOf(["ALL"]).required("Criteria condition is required"), polling_interval_seconds: (0, import_yup5.number)().required(fieldErrorMessage), evaluation_period_seconds: (0, import_yup5.number)().required(fieldErrorMessage), trigger_occurrences: (0, import_yup5.number)().required(fieldErrorMessage).positive("Enter a positive value.").typeError("The value should be a number.") }); var specialStartEndRegex = /^[^a-zA-Z0-9]/; var createAlertDefinitionSchema = (0, import_yup5.object)({ label: (0, import_yup5.string)().required(fieldErrorMessage).matches( /^[^*#&+:<>"?@%{}\\\/]+$/, "Name cannot contain special characters: * # & + : < > ? @ % { } \\ /." ).max(100, "Name must be 100 characters or less.").test( "no-special-start-end", "Name cannot start or end with a special character.", (value) => { return !specialStartEndRegex.test(value != null ? value : ""); } ), description: (0, import_yup5.string)().max(100, "Description must be 100 characters or less.").test( "no-special-start-end", "Description cannot start or end with a special character.", (value) => { return !specialStartEndRegex.test(value != null ? value : ""); } ).optional(), severity: (0, import_yup5.number)().oneOf([0, 1, 2, 3]).required(fieldErrorMessage), rule_criteria: (0, import_yup5.object)({ rules: (0, import_yup5.array)().of(metricCriteria).min(1, "At least one metric criteria is required.").required() }).required(), trigger_conditions: triggerConditionValidation, channel_ids: (0, import_yup5.array)().of((0, import_yup5.number)().required()).required().min(1, "At least one notification channel is required."), tags: (0, import_yup5.array)().of((0, import_yup5.string)().defined()).optional(), entity_ids: (0, import_yup5.array)().of((0, import_yup5.string)().defined()).optional(), regions: (0, import_yup5.array)().of((0, import_yup5.string)().defined()).optional(), scope: (0, import_yup5.string)().oneOf(["entity", "region", "account"]).nullable().optional() }); var editAlertDefinitionSchema = (0, import_yup5.object)({ channel_ids: (0, import_yup5.array)().of((0, import_yup5.number)().required()).optional(), label: (0, import_yup5.string)().matches( /^[^*#&+:<>"?@%{}\\/]+$/, "Name cannot contain special characters: * # & + : < > ? @ % { } \\ /." ).max(100, "Name must be 100 characters or less.").test( "no-special-start-end", "Name cannot start or end with a special character.", (value) => { return !specialStartEndRegex.test(value != null ? value : ""); } ).optional(), description: (0, import_yup5.string)().max(100, "Description must be 100 characters or less.").test( "no-special-start-end", "Description cannot start or end with a special character.", (value) => { return !specialStartEndRegex.test(value != null ? value : ""); } ).optional(), entity_ids: (0, import_yup5.array)().of((0, import_yup5.string)().defined()).optional(), rule_criteria: (0, import_yup5.object)({ rules: (0, import_yup5.array)().of(metricCriteria).min(1, "At least one metric criteria is required.").required() }).optional().default(void 0), tags: (0, import_yup5.array)().of((0, import_yup5.string)().defined()).optional(), trigger_conditions: triggerConditionValidation.optional().default(void 0), severity: (0, import_yup5.number)().oneOf([0, 1, 2, 3]).optional(), status: (0, import_yup5.string)().oneOf([ "enabled", "disabled", "in progress", "failed", "provisioning", "disabling", "enabling" ]).optional(), scope: (0, import_yup5.string)().oneOf(["entity", "region", "account"]).nullable().optional(), regions: (0, import_yup5.array)().of((0, import_yup5.string)().defined()).optional() }); // src/databases.schema.ts var import_yup6 = require("yup"); var import_yup7 = require("yup"); var LABEL_MESSAGE = "Label must be between 3 and 32 characters"; var createDatabaseSchema = (0, import_yup7.object)({ label: (0, import_yup7.string)().required("Label is required").min(3, LABEL_MESSAGE).max(32, LABEL_MESSAGE), engine: (0, import_yup7.string)().required("Database Engine is required"), region: (0, import_yup7.string)().required("Region is required"), type: (0, import_yup7.string)().required("Type is required"), cluster_size: (0, import_yup6.number)().oneOf([1, 2, 3], "Nodes are required").required("Nodes are required") }); var getDynamicDatabaseSchema = (isVPCSelected) => { if (!isVPCSelected) { return createDatabaseSchema; } return createDatabaseSchema.shape({ private_network: (0, import_yup7.object)().shape({ subnet_id: (0, import_yup6.number)().nullable().required("Subnet is required.") }) }); }; var updateMaintenanceSchema = (0, import_yup7.object)({ frequency: (0, import_yup7.string)().oneOf(["weekly", "monthly"]).optional(), hour_of_day: (0, import_yup6.number)(), day_of_week: (0, import_yup6.number)(), week_of_month: (0, import_yup6.number)().nullable() }); var updateDatabaseSchema = (0, import_yup7.object)({ label: (0, import_yup7.string)().notRequired().min(3, LABEL_MESSAGE).max(32, LABEL_MESSAGE), allow_list: (0, import_yup7.array)().of((0, import_yup7.string)()).notRequired(), updates: (0, import_yup7.object)().notRequired().shape({ frequency: (0, import_yup7.string)().oneOf(["weekly", "monthly"]), duration: (0, import_yup6.number)(), hour_of_day: (0, import_yup6.number)(), day_of_week: (0, import_yup6.number)(), week_of_month: (0, import_yup6.number)().nullable() }).nullable(), type: (0, import_yup7.string)().notRequired() }); var updatePrivateNetworkSchema = (0, import_yup7.object)({ private_network: (0, import_yup7.object)().shape({ vpc_id: (0, import_yup6.number)().required("VPC is required."), subnet_id: (0, import_yup6.number)().required("Subnet is required."), public_access: (0, import_yup6.boolean)().default(false) }) }); var createValidator = (key, field) => { const fieldTypes = Array.isArray(field.type) ? field.type : [field.type]; switch (true) { case fieldTypes.includes("integer"): return (0, import_yup6.number)().transform((val, originalVal) => originalVal === "" ? void 0 : val).integer(`${key} must be a whole number`).required(`${key} is required`); case fieldTypes.includes("number"): return (0, import_yup6.number)().transform((val, originalVal) => originalVal === "" ? void 0 : val).required(`${key} is required`); case fieldTypes.includes("string"): return (0, import_yup7.string)(); case fieldTypes.includes("boolean"): return (0, import_yup6.boolean)(); default: return null; } }; var applyConstraints = (validator, key, field) => { if (!validator) return null; if (field.minimum !== void 0) { validator = validator.min( field.minimum, `${key} must be at least ${field.minimum}` ); } if (field.maximum !== void 0) { if (field.maximum > Number.MAX_SAFE_INTEGER) { validator = validator.max( Number.MAX_SAFE_INTEGER, `${key} must be at most ${Number.MAX_SAFE_INTEGER}` ); } else { validator = validator.max( field.maximum, `${key} must be at most ${field.maximum}` ); } } if (field.minLength !== void 0) { validator = validator.min( field.minLength, `${key} must be at least ${field.minLength} characters` ); } if (field.maxLength !== void 0) { validator = validator.max( field.maxLength, `${key} must be at most ${field.maxLength} characters` ); } if (field.pattern) { const pattern = field.pattern; if (key === "default_time_zone") { validator = validator.matches( new RegExp(pattern), `${key} must be an IANA timezone, 'SYSTEM', or a valid UTC offset (e.g., '+03:00')` ); } else { validator = validator.matches( new RegExp(pattern), `Please ensure that ${key} follows the format ${field.example}` ); } } if (key === "wal_sender_timeout") { validator = validator.test( "is-zero-or-in-range", `${key} must be 0 or between 5000 and 10800000`, (value) => { if (typeof value !== "number") return false; return value === 0 || value >= 5e3 && value <= 108e5; } ); } if (key === "timezone") { if (!field.value) { validator = validator.required("timezone cannot be empty"); } } if (key === "net_buffer_length") { validator = validator.test( "is-multiple-of-1024", `${key} must be a multiple of 1024`, (value) => { if (typeof value !== "number") return false; return value % 1024 === 0; } ); } return validator; }; var processField = (schemaShape, field) => { if (!field.label || !field.type) { return; } const key = field.label; let validator = createValidator(key, field); validator = applyConstraints(validator, key, field); if (validator) { schemaShape[key] = (0, import_yup7.object)().shape({ value: validator }); } }; var createDynamicAdvancedConfigSchema = (allConfigurations) => { if (!Array.isArray(allConfigurations) || allConfigurations.length === 0) { return (0, import_yup7.object)().shape({}); } const schemaShape = {}; allConfigurations.forEach((field) => processField(schemaShape, field)); return (0, import_yup7.object)().shape({ configs: (0, import_yup7.array)().of( (0, import_yup7.object)({ label: (0, import_yup7.string)().required(), value: (0, import_yup6.mixed)().when("label", (label, schema) => { var _a, _b; if (Array.isArray(label)) { label = label[0]; } if (typeof label !== "string" || !schemaShape[label]) { return schema; } const valueSchema = (_b = (_a = schemaShape[label]) == null ? void 0 : _a.fields) == null ? void 0 : _b.value; return valueSchema ? valueSchema : schema; }) }) ) }); }; var createDatabaseConnectionPoolSchema = (0, import_yup7.object)({ database: (0, import_yup7.string)().required("Database is required"), mode: (0, import_yup7.string)().oneOf(["transaction", "session", "statement"], "Pool mode is required").required("Pool mode is required"), label: (0, import_yup7.string)().required("Name is required").max(63, "Name must not exceed 63 characters"), size: (0, import_yup6.number)().required("Size is required"), username: (0, import_yup7.string)().nullable().required("Username is required") }); var updateDatabaseConnectionPoolSchema = (0, import_yup7.object)({ database: (0, import_yup7.string)().optional(), mode: (0, import_yup7.string)().oneOf(["transaction", "session", "statement"]).optional(), size: (0, import_yup6.number)().optional(), username: (0, import_yup7.string)().nullable().optional() }); // src/delivery.schema.ts var import_yup8 = require("yup"); var maxLength = 255; var maxLengthMessage = "Length must be 255 characters or less."; var authenticationDetailsSchema = (0, import_yup8.object)({ basic_authentication_user: (0, import_yup8.string)().max(maxLength, maxLengthMessage).required(), basic_authentication_password: (0, import_yup8.string)().max(maxLength, maxLengthMessage).required() }); var authenticationSchema = (0, import_yup8.object)({ type: (0, import_yup8.string)().oneOf(["basic", "none"]).required(), details: (0, import_yup8.mixed)().defined().when("type", { is: "basic", then: () => authenticationDetailsSchema.required(), otherwise: () => (0, import_yup8.mixed)().nullable().test( "null-or-undefined", "For type `none` details should be `null` or `undefined`.", (value) => !value ) }) }); var clientCertificateDetailsSchema = (0, import_yup8.object)({ tls_hostname: (0, import_yup8.string)().max(maxLength, maxLengthMessage).required(), client_ca_certificate: (0, import_yup8.string)().required(), client_certificate: (0, import_yup8.string)().required(), client_private_key: (0, import_yup8.string)().required() }); var customHeaderSchema = (0, import_yup8.object)({ name: (0, import_yup8.string)().max(maxLength, maxLengthMessage).required(), value: (0, import_yup8.string)().max(maxLength, maxLengthMessage).required() }); var customHTTPsDetailsSchema = (0, import_yup8.object)({ authentication: authenticationSchema.required(), client_certificate_details: clientCertificateDetailsSchema.optional(), content_type: (0, import_yup8.string)().oneOf(["application/json", "application/json; charset=utf-8"]).required(), custom_headers: (0, import_yup8.array)().of(customHeaderSchema).min(1).optional(), data_compression: (0, import_yup8.string)().oneOf(["gzip", "None"]).required(), endpoint_url: (0, import_yup8.string)().max(maxLength, maxLengthMessage).required() }); var akamaiObjectStorageDetailsBaseSchema = (0, import_yup8.object)({ host: (0, import_yup8.string)().max(maxLength, maxLengthMessage).required("Host is required."), bucket_name: (0, import_yup8.string)().required("Bucket name is required.").min(3, "Bucket name must be between 3 and 63 characters.").matches(/^\S*$/, "Bucket name must not contain spaces.").matches( /^[a-z0-9].*[a-z0-9]$/, "Bucket name must start and end with a lowercase letter or number." ).matches( /^(?!.*[.-]{2})[a-z0-9.-]+$/, "Bucket name must contain only lowercase letters, numbers, periods (.), and hyphens (-). Adjacent periods and hyphens are not allowed." ).max(63, "Bucket name must be between 3 and 63 characters."), path: (0, import_yup8.string)().max(maxLength, maxLengthMessage).defined(), access_key_id: (0, import_yup8.string)().max(maxLength, maxLengthMessage).required("Access Key ID is required."), access_key_secret: (0, import_yup8.string)().max(maxLength, maxLengthMessage).required("Secret Access Key is required.") }); var akamaiObjectStorageDetailsPayloadSchema = akamaiObjectStorageDetailsBaseSchema.shape({ path: (0, import_yup8.string)().max(maxLength, maxLengthMessage).optional() }); var destinationSchemaBase = (0, import_yup8.object)().shape({ label: (0, import_yup8.string)().max(maxLength, maxLengthMessage).required("Destination name is required."), type: (0, import_yup8.string)().oneOf(["akamai_object_storage", "custom_https"]).required(), details: (0, import_yup8.mixed)().defined().required().when("type", { is: "akamai_object_storage", then: () => akamaiObjectStorageDetailsBaseSchema, otherwise: () => customHTTPsDetailsSchema }) }); var destinationFormSchema = destinationSchemaBase; var createDestinationSchema = destinationSchemaBase.shape({ details: (0, import_yup8.mixed)().defined().required().when("type", { is: "akamai_object_storage", then: () => akamaiObjectStorageDetailsPayloadSchema, otherwise: () => customHTTPsDetailsSchema }) }); var updateDestinationSchema = createDestinationSchema.omit(["type"]).shape({ details: (0, import_yup8.lazy)((value) => { if ("bucket_name" in value) { return akamaiObjectStorageDetailsPayloadSchema.noUnknown( "Object contains unknown fields for Akamai Object Storage Details." ); } if ("client_certificate_details" in value) { return customHTTPsDetailsSchema.noUnknown( "Object contains unknown fields for Custom HTTPS Details." ); } return (0, import_yup8.mixed)().test({ name: "details-schema", message: "Details object does not match any known schema.", test: () => false }); }) }); var clusterRequiredMessage = "At least one cluster must be selected."; var streamDetailsBase = (0, import_yup8.object)({ cluster_ids: (0, import_yup8.array)().of((0, import_yup8.number)().defined(clusterRequiredMessage)).when("is_auto_add_all_clusters_enabled", { is: false, then: (schema) => schema.min(1, clusterRequiredMessage).required(clusterRequiredMessage) }), is_auto_add_all_clusters_enabled: (0, import_yup8.boolean)() }); var streamDetailsSchema = streamDetailsBase.test( "cluster_ids-or-all_clusters_enabled", "Either cluster_ids or is_auto_add_all_clusters_enabled should be set.", (value) => { const HasClusterIds = "cluster_ids" in value; const HasAllClustersEnabled = "is_auto_add_all_clusters_enabled" in value; return HasClusterIds !== HasAllClustersEnabled; } ); var detailsShouldNotExistOrBeNull = (schema) => schema.nullable().test( "details-should-not-exist", "Details should be null or no details passed for type `audit_logs`", (value, ctx) => !("details" in ctx) || value === null ); var streamSchemaBase = (0, import_yup8.object)({ label: (0, import_yup8.string)().min(3, "Stream name must have at least 3 characters").max(maxLength, maxLengthMessage).required("Stream name is required."), status: (0, import_yup8.mixed)().oneOf(["active", "inactive"]), type: (0, import_yup8.string)().oneOf(["audit_logs", "lke_audit_logs"]).required("Stream type is required."), destinations: (0, import_yup8.array)().of((0, import_yup8.number)().defined()).ensure().min(1).required(), details: (0, import_yup8.mixed)().when("type", { is: "lke_audit_logs", then: () => streamDetailsSchema.required(), otherwise: detailsShouldNotExistOrBeNull }) }); var createStreamSchema = streamSchemaBase; var updateStreamSchema = streamSchemaBase.omit(["type"]).shape({ status: (0, import_yup8.mixed)().oneOf(["active", "inactive"]).required(), details: (0, import_yup8.lazy)((value) => { if (value && typeof value === "object" && ("cluster_ids" in value || "is_auto_add_all_clusters_enabled" in value)) { return streamDetailsSchema.required(); } return detailsShouldNotExistOrBeNull((0, import_yup8.mixed)()); }) }).noUnknown("Object contains unknown fields"); var streamAndDestinationFormSchema = (0, import_yup8.object)({ stream: streamSchemaBase.shape({ destinations: (0, import_yup8.array)().of((0, import_yup8.number)().required()).required(), details: (0, import_yup8.mixed)().when("type", { is: "lke_audit_logs", then: () => streamDetailsBase.required(), otherwise: (schema) => schema.nullable().equals([null], "Details must be null for audit_logs type") }) }), destination: destinationFormSchema.defined().when("stream.destinations", { is: (value) => !(value == null ? void 0 : value.length), then: (schema) => schema, otherwise: (schema) => schema.shape({ details: (0, import_yup8.mixed)().strip() }) }) }); // src/domains.schema.ts var import_yup9 = require("yup"); var importZoneSchema = (0, import_yup9.object)({ domain: (0, import_yup9.string)().required("Domain is required."), remote_nameserver: (0, import_yup9.string)().required("Remote nameserver is required.") }); var domainSchemaBase = (0, import_yup9.object)().shape({ domain: (0, import_yup9.string)().matches( // eslint-disable-next-line sonarjs/slow-regex /([a-zA-Z0-9-_]+\.)+([a-zA-Z]{2,3}\.)?([a-zA-Z]{2,16}|XN--[a-zA-Z0-9]+)/, "Domain is not valid." ), status: (0, import_yup9.mixed)().oneOf(["disabled", "active", "edit_mode", "has_errors"]), tags: (0, import_yup9.array)(), description: (0, import_yup9.string)().min(1, "Description must be between 1 and 253 characters.").max(253, "Description must be between 1 and 253 characters."), retry_sec: (0, import_yup9.number)(), master_ips: (0, import_yup9.array)().of((0, import_yup9.string)()), axfr_ips: (0, import_yup9.array)().of((0, import_yup9.string)()).typeError("Must be a comma-separated list of IP addresses."), expire_sec: (0, import_yup9.number)(), refresh_sec: (0, import_yup9.number)(), ttl_sec: (0, import_yup9.number)() }); var createDomainSchema = domainSchemaBase.shape({ domain: (0, import_yup9.string)().required("Domain is required.").matches( // eslint-disable-next-line sonarjs/slow-regex /([a-zA-Z0-9-_]+\.)+([a-zA-Z]{2,3}\.)?([a-zA-Z]{2,16}|XN--[a-zA-Z0-9]+)/, "Domain is not valid." ), tags: (0, import_yup9.array)().of((0, import_yup9.string)()), type: (0, import_yup9.mixed)().required().oneOf(["master", "slave"]), soa_email: (0, import_yup9.string)().when("type", { is: "master", then: (schema) => schema.required("SOA Email is required.") }).email("SOA Email is not valid.").trim(), master_ips: (0, import_yup9.array)().of((0, import_yup9.string)()).when("type", { is: "slave", then: (schema) => schema.compact().ensure().required("At least one primary IP address is required.").min(1, "At least one primary IP address is required.") }) }); var updateDomainSchema = domainSchemaBase.shape({ domainId: (0, import_yup9.number)(), soa_email: (0, import_yup9.string)().email("SOA Email is not valid."), axfr_ips: (0, import_yup9.array)().of((0, import_yup9.string)()), tags: (0, import_yup9.array)().of((0, import_yup9.string)()) }); // src/firewalls.schema.ts var import_ipaddr = __toESM(require("ipaddr.js"), 1); var import_yup10 = require("yup"); var IP_ERROR_MESSAGE = "Must be a valid IPv4 or IPv6 address or range."; var validateIP = (ipAddress2) => { if (ipAddress2 !== "" && !ipAddress2) { return false; } const [, mask] = ipAddress2.split("/"); try { if (mask) { import_ipaddr.default.parseCIDR(ipAddress2); } else { import_ipaddr.default.parse(ipAddress2); } } catch (err) { if (ipAddress2 !== "") { return false; } } return true; }; var CreateFirewallDeviceSchema = (0, import_yup10.object)({ linodes: (0, import_yup10.array)().of((0, import_yup10.number)()), nodebalancers: (0, import_yup10.array)().of((0, import_yup10.number)()) }); var ipAddress = (0, import_yup10.string)().defined().test({ name: "validateIP", message: IP_ERROR_MESSAGE, test: validateIP }); var CUSTOM_PORTS_ERROR_MESSAGE = ""; var validatePort = (port) => { CUSTOM_PORTS_ERROR_MESSAGE = "Ports must be an integer, range of integers, or a comma-separated list of integers."; if (!port) { CUSTOM_PORTS_ERROR_MESSAGE = "Must be 1-65535"; return false; } const convertedPort = parseInt(port, 10); if (!(1 <= convertedPort && convertedPort <= 65535)) { CUSTOM_PORTS_ERROR_MESSAGE = "Must be 1-65535"; return false; } if (port.startsWith("0")) { CUSTOM_PORTS_ERROR_MESSAGE = "Port must not have leading zeroes"; return false; } if (String(convertedPort) !== port) { return false; } return true; }; var isCustomPortsValid = (ports) => { const portList = (ports == null ? void 0 : ports.split(",")) || []; let portLimitCount = 0; for (const port of portList) { const cleanedPort = port.trim(); if (cleanedPort.includes("-")) { const portRange = cleanedPort.split("-"); if (!validatePort(portRange[0]) || !validatePort(portRange[1])) { return false; } if (portRange.length !== 2) { CUSTOM_PORTS_ERROR_MESSAGE = "Ranges must have 2 values"; return false; } if (parseInt(portRange[0], 10) >= parseInt(portRange[1], 10)) { CUSTOM_PORTS_ERROR_MESSAGE = "Range must start with a smaller number and end with a larger number"; return false; } portLimitCount += 2; } else { if (!validatePort(cleanedPort)) { return false; } portLimitCount++; } } if (portLimitCount > 15) { CUSTOM_PORTS_ERROR_MESSAGE = "Number of ports or port range endpoints exceeded. Max allowed is 15"; return false; } return true; }; var validateFirewallPorts = (0, import_yup10.string)().test({ name: "firewall-ports", message: CUSTOM_PORTS_ERROR_MESSAGE, test: (value) => { if (!value) { return false; } try { isCustomPortsValid(value); } catch (err) { return false; } return true; } }); var FirewallRuleTypeSchema = (0, import_yup10.object)().shape({ action: (0, import_yup10.string)().oneOf(["ACCEPT", "DROP"]).nullable(), description: (0, import_yup10.string)().nullable(), label: (0, import_yup10.string)().nullable(), protocol: (0, import_yup10.string)().oneOf(["ALL", "TCP", "UDP", "ICMP", "IPENCAP"]).nullable(), ports: (0, import_yup10.string)().when("protocol", { is: (val) => val !== "ICMP"