chore(ui): upgrade zod

This commit is contained in:
psychedelicious
2025-07-17 21:42:18 +10:00
parent 49691aa07e
commit e58ee4c492
35 changed files with 46 additions and 37 deletions

View File

@@ -103,7 +103,7 @@
"use-debounce": "^10.0.5",
"use-device-pixel-ratio": "^1.1.2",
"uuid": "^11.1.0",
"zod": "^3.25.67",
"zod": "^4.0.5",
"zod-validation-error": "^3.5.2"
},
"peerDependencies": {

View File

@@ -201,11 +201,11 @@ importers:
specifier: ^11.1.0
version: 11.1.0
zod:
specifier: ^3.25.67
version: 3.25.76
specifier: ^4.0.5
version: 4.0.5
zod-validation-error:
specifier: ^3.5.2
version: 3.5.3(zod@3.25.76)
version: 3.5.3(zod@4.0.5)
devDependencies:
'@eslint/compat':
specifier: ^1.3.1
@@ -4543,6 +4543,9 @@ packages:
zod@3.25.76:
resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==}
zod@4.0.5:
resolution: {integrity: sha512-/5UuuRPStvHXu7RS+gmvRf4NXrNxpSllGwDnCBcJZtQsKrviYXm54yDGV2KYNLT5kq0lHGcl7lqWJLgSaG+tgA==}
zustand@4.5.7:
resolution: {integrity: sha512-CHOUy7mu3lbD6o6LJLfllpjkzhHXSBlX8B9+qPddUsIfeF5S/UZ5q0kmCsnRqT1UHFQZchNFDDzMbQsuesHWlw==}
engines: {node: '>=12.7.0'}
@@ -9103,8 +9106,14 @@ snapshots:
dependencies:
zod: 3.25.76
zod-validation-error@3.5.3(zod@4.0.5):
dependencies:
zod: 4.0.5
zod@3.25.76: {}
zod@4.0.5: {}
zustand@4.5.7(@types/react@18.3.23)(immer@10.1.1)(react@18.3.1):
dependencies:
use-sync-external-store: 1.5.0(react@18.3.1)

View File

@@ -2,7 +2,7 @@ import { createLogWriter } from '@roarr/browser-log-writer';
import { atom } from 'nanostores';
import type { Logger, MessageSerializer } from 'roarr';
import { ROARR, Roarr } from 'roarr';
import { z } from 'zod/v4';
import { z } from 'zod';
const serializeMessage: MessageSerializer = (message) => {
return JSON.stringify(message);

View File

@@ -1,4 +1,4 @@
import type { z } from 'zod/v4';
import type { z } from 'zod';
/**
* Helper to create a type guard from a zod schema. The type guard will infer the schema's TS type.

View File

@@ -6,7 +6,7 @@ import { memo, useCallback, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import type { Equals } from 'tsafe';
import { assert } from 'tsafe';
import { z } from 'zod/v4';
import { z } from 'zod';
const zMode = z.enum(['fill', 'contain', 'cover']);
type Mode = z.infer<typeof zMode>;

View File

@@ -2,7 +2,7 @@ import type { PayloadAction, Selector } from '@reduxjs/toolkit';
import { createSelector, createSlice } from '@reduxjs/toolkit';
import type { PersistConfig, RootState } from 'app/store/store';
import { zRgbaColor } from 'features/controlLayers/store/types';
import { z } from 'zod/v4';
import { z } from 'zod';
const zAutoSwitchMode = z.enum(['off', 'switch_on_start', 'switch_on_finish']);

View File

@@ -4,7 +4,7 @@ import { zModelIdentifierField } from 'features/nodes/types/common';
import { Graph } from 'features/nodes/util/graph/generation/Graph';
import type { ControlLoRAModelConfig, ControlNetModelConfig, T2IAdapterModelConfig } from 'services/api/types';
import { assert } from 'tsafe';
import { z } from 'zod/v4';
import { z } from 'zod';
const zAjustImageChannels = z.enum([
'Red (RGBA)',

View File

@@ -21,7 +21,7 @@ import type { Invocation } from 'services/api/types';
import type { Equals } from 'tsafe';
import { assert } from 'tsafe';
import { describe, test } from 'vitest';
import type { z } from 'zod/v4';
import type { z } from 'zod';
import type {
CanvasEntityIdentifier,

View File

@@ -31,7 +31,7 @@ import {
} from 'features/parameters/types/parameterSchemas';
import { getImageDTOSafe } from 'services/api/endpoints/images';
import type { JsonObject } from 'type-fest';
import { z } from 'zod/v4';
import { z } from 'zod';
const zId = z.string().min(1);
const zName = z.string().min(1).nullable();

View File

@@ -20,7 +20,7 @@ import { useTranslation } from 'react-i18next';
import { uploadImages } from 'services/api/endpoints/images';
import { useBoardName } from 'services/api/hooks/useBoardName';
import type { UploadImageArg } from 'services/api/types';
import { z } from 'zod/v4';
import { z } from 'zod';
const ACCEPTED_IMAGE_TYPES = ['image/png', 'image/jpg', 'image/jpeg', 'image/webp'];
const ACCEPTED_FILE_EXTENSIONS = ['.png', '.jpg', '.jpeg', '.webp'];

View File

@@ -2,7 +2,7 @@ import type { PayloadAction, Selector } from '@reduxjs/toolkit';
import { createSelector, createSlice } from '@reduxjs/toolkit';
import type { PersistConfig, RootState } from 'app/store/store';
import { buildZodTypeGuard } from 'common/util/zodUtils';
import { z } from 'zod/v4';
import { z } from 'zod';
const zSeedBehaviour = z.enum(['PER_ITERATION', 'PER_PROMPT']);
export const isSeedBehaviour = buildZodTypeGuard(zSeedBehaviour);

View File

@@ -5,7 +5,7 @@ import { selectBoardsListOrderBy, selectBoardsListOrderDir } from 'features/gall
import { boardsListOrderByChanged, boardsListOrderDirChanged } from 'features/gallery/store/gallerySlice';
import { memo, useCallback, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { z } from 'zod/v4';
import { z } from 'zod';
const zOrderBy = z.enum(['created_at', 'board_name']);
type OrderBy = z.infer<typeof zOrderBy>;

View File

@@ -92,7 +92,7 @@ import { useTranslation } from 'react-i18next';
import { modelsApi } from 'services/api/endpoints/models';
import type { AnyModelConfig, ModelType } from 'services/api/types';
import { assert } from 'tsafe';
import z from 'zod/v4';
import z from 'zod';
const MetadataLabel = ({ i18nKey }: { i18nKey: string }) => {
const { t } = useTranslation();

View File

@@ -11,7 +11,7 @@ import {
import type { ChangeEvent } from 'react';
import { useCallback, useEffect, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { z } from 'zod/v4';
import { z } from 'zod';
const zOrderBy = z.enum(['opened_at', 'created_at', 'updated_at', 'name']);
type OrderBy = z.infer<typeof zOrderBy>;

View File

@@ -127,7 +127,7 @@ import {
import { atom, computed } from 'nanostores';
import type { MouseEvent } from 'react';
import type { UndoableOptions } from 'redux-undo';
import type { z } from 'zod/v4';
import type { z } from 'zod';
import type { PendingConnection, Templates } from './types';

View File

@@ -1,4 +1,4 @@
import { z } from 'zod/v4';
import { z } from 'zod';
// #region Field data schemas
export const zImageField = z.object({

View File

@@ -6,7 +6,7 @@ import MersenneTwister from 'mtwist';
import { boardsApi } from 'services/api/endpoints/boards';
import { utilitiesApi } from 'services/api/endpoints/utilities';
import { assert } from 'tsafe';
import { z } from 'zod/v4';
import { z } from 'zod';
import type { ImageField } from './common';
import { zBoardField, zColorField, zImageField, zModelIdentifierField, zSchedulerField } from './common';

View File

@@ -1,5 +1,5 @@
import type { Edge, Node } from '@xyflow/react';
import { z } from 'zod/v4';
import { z } from 'zod';
import { zClassification, zProgressImage } from './common';
import { zFieldInputInstance, zFieldInputTemplate, zFieldOutputTemplate } from './field';

View File

@@ -1,4 +1,4 @@
import { z } from 'zod/v4';
import { z } from 'zod';
// Schemas and types for working with semver

View File

@@ -1,4 +1,4 @@
import { z } from 'zod/v4';
import { z } from 'zod';
// WorkflowV1 Schema

View File

@@ -1,4 +1,4 @@
import { z } from 'zod/v4';
import { z } from 'zod';
// #region Field data schemas
export const zImageField = z.object({

View File

@@ -1,4 +1,4 @@
import { z } from 'zod/v4';
import { z } from 'zod';
import {
zBoardField,

View File

@@ -1,4 +1,4 @@
import { z } from 'zod/v4';
import { z } from 'zod';
import { zFieldInputInstance, zFieldOutputInstance } from './field';
import { zSemVer } from './semver';

View File

@@ -1,4 +1,4 @@
import { z } from 'zod/v4';
import { z } from 'zod';
// Schemas and types for working with semver

View File

@@ -1,4 +1,4 @@
import { z } from 'zod/v4';
import { z } from 'zod';
import { zFieldIdentifier } from './field';
import { zInvocationNodeData, zNotesNodeData } from './invocation';

View File

@@ -1,5 +1,5 @@
import { getPrefixedId } from 'features/controlLayers/konva/util';
import { z } from 'zod/v4';
import { z } from 'zod';
import type { FieldType } from './field';
import { zFieldIdentifier } from './field';

View File

@@ -3,7 +3,7 @@ import { Graph } from 'features/nodes/util/graph/generation/Graph';
import type { AnyInvocation, Invocation } from 'services/api/types';
import { assert, AssertionError, is } from 'tsafe';
import { describe, expect, it } from 'vitest';
import { z } from 'zod/v4';
import { z } from 'zod';
describe('Graph', () => {
describe('constructor', () => {

View File

@@ -13,7 +13,7 @@ import { zWorkflowV2 } from 'features/nodes/types/v2/workflow';
import type { WorkflowV3 } from 'features/nodes/types/workflow';
import { zWorkflowV3 } from 'features/nodes/types/workflow';
import { t } from 'i18next';
import { z } from 'zod/v4';
import { z } from 'zod';
/**
* Helper schema to extract the version from a workflow.

View File

@@ -2,7 +2,7 @@ import { NUMPY_RAND_MAX } from 'app/constants';
import { roundToMultiple } from 'common/util/roundDownToMultiple';
import { buildZodTypeGuard } from 'common/util/zodUtils';
import { zModelIdentifierField, zSchedulerField } from 'features/nodes/types/common';
import { z } from 'zod/v4';
import { z } from 'zod';
/**
* Schemas, types and type guards for parameters.

View File

@@ -1,5 +1,5 @@
import type { LogLevel, LogNamespace } from 'app/logging/logger';
import { z } from 'zod/v4';
import { z } from 'zod';
const zLanguage = z.enum([
'ar',

View File

@@ -1,4 +1,4 @@
import { z } from 'zod/v4';
import { z } from 'zod';
export const zPydanticValidationError = z.object({
status: z.literal(422),

View File

@@ -1,6 +1,6 @@
import { deepClone } from 'common/util/deepClone';
import { isPlainObject } from 'es-toolkit';
import { z } from 'zod/v4';
import { z } from 'zod';
const zTabName = z.enum(['generate', 'canvas', 'upscaling', 'workflows', 'models', 'queue']);
export type TabName = z.infer<typeof zTabName>;

View File

@@ -15,7 +15,7 @@ import { t } from 'i18next';
import { useCallback } from 'react';
import { serializeError } from 'serialize-error';
import { checkBoardAccess, checkImageAccess, checkModelAccess } from 'services/api/hooks/accessChecks';
import { z } from 'zod/v4';
import { z } from 'zod';
import { fromZodError } from 'zod-validation-error/v4';
const log = logger('workflows');

View File

@@ -3,7 +3,7 @@ import { isRejectedWithValue } from '@reduxjs/toolkit';
import { $toastMap } from 'app/store/nanostores/toastMap';
import { toast } from 'features/toast/toast';
import { t } from 'i18next';
import { z } from 'zod/v4';
import { z } from 'zod';
const trialUsageErrorSubstring = 'usage allotment for the free trial';
const trialUsageErrorCode = 'USAGE_LIMIT_TRIAL';