Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@
"strip-ansi": "7.1.2",
"tslib": "2.8.1",
"vitest": "4.1.3",
"zod": "3.25.76"
"zod": "4.4.3"
}
}
2 changes: 1 addition & 1 deletion packages/internal/postgres/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"slonik": "48.13.2",
"slonik-interceptor-query-logging": "48.13.2",
"slonik-sql-tag-raw": "48.13.2",
"zod": "3.25.76"
"zod": "4.4.3"
},
"devDependencies": {
"@hive/service-common": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"graphql": "^16.8.1",
"graphql-tag": "2.12.6",
"tslib": "2.8.1",
"zod": "3.25.76"
"zod": "4.4.3"
},
"devDependencies": {
"@types/env-ci": "3.1.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/libraries/cli/src/commands/app/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ export default class AppCreate extends Command<typeof AppCreate> {
}
}

const ManifestModel = z.record(z.string());
const ManifestModel = z.record(z.string(), z.string());

const CreateAppDeploymentMutation = graphql(/* GraphQL */ `
mutation CreateAppDeployment($input: CreateAppDeploymentInput!) {
Expand Down
4 changes: 2 additions & 2 deletions packages/libraries/laboratory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"react-dom": "^18.0.0 || ^19.0.0",
"subscriptions-transport-ws": "^0.11.0",
"tslib": "^2.8.1",
"zod": "^4.1.12"
"zod": "^4.4.3"
},
"dependencies": {
"@base-ui/react": "^1.1.0",
Expand Down Expand Up @@ -135,7 +135,7 @@
"vite-plugin-commonjs": "^0.10.4",
"vite-plugin-dts": "^4.5.4",
"vite-plugin-monaco-editor": "^1.1.0",
"zod": "^4.3.6"
"zod": "4.4.3"
},
"publishConfig": {
"access": "public"
Expand Down
2 changes: 1 addition & 1 deletion packages/migrations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"tslib": "2.8.1",
"tsx": "4.19.2",
"typescript": "5.7.3",
"zod": "3.25.76"
"zod": "4.4.3"
},
"buildOptions": {
"external": [
Expand Down
2 changes: 1 addition & 1 deletion packages/migrations/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if (environmentErrors.length) {
process.exit(1);
}

function extractConfig<Input, Output>(config: zod.SafeParseReturnType<Input, Output>): Output {
function extractConfig<Output>(config: zod.ZodSafeParseResult<Output>): Output {
if (!config.success) {
throw new Error('Something went wrong.');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/migrations/src/scripts/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if (environmentErrors.length) {
process.exit(1);
}

function extractConfig<Input, Output>(config: zod.SafeParseReturnType<Input, Output>): Output {
function extractConfig<Output>(config: zod.ZodSafeParseResult<Output>): Output {
if (!config.success) {
throw new Error('Something went wrong.');
}
Expand Down
4 changes: 2 additions & 2 deletions packages/services/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"redlock": "5.0.0-beta.2",
"stripe": "17.5.0",
"vitest": "4.1.3",
"zod": "3.25.76",
"zod-validation-error": "3.4.0"
"zod": "4.4.3",
"zod-validation-error": "5.0.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ export const addAlertChannel: NonNullable<MutationResolvers['addAlertChannel']>
const result = AddAlertChannelModel.safeParse(input);

if (!result.success) {
const errors = z.treeifyError(result.error);
return {
error: {
message: 'Please check your input.',
inputErrors: {
slackChannel: result.error.formErrors.fieldErrors.slack?.[0],
webhookEndpoint: result.error.formErrors.fieldErrors.webhook?.[0],
name: result.error.formErrors.fieldErrors.name?.[0],
slackChannel: errors.properties?.slack?.errors.at(0),
webhookEndpoint: errors.properties?.webhook?.errors.at(0),
name: errors.properties?.name?.errors.at(0),
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,14 @@ export class AuthManager {
const result = InputModel.safeParse(input);

if (!result.success) {
const errors = z.treeifyError(result.error);
return {
type: 'error' as const,
error: {
message: 'Please check your input.',
inputErrors: {
displayName: result.error.formErrors.fieldErrors.displayName?.[0],
fullName: result.error.formErrors.fieldErrors.fullName?.[0],
displayName: errors.properties?.displayName?.errors?.at(0),
fullName: errors.properties?.fullName?.errors?.at(0),
},
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { WEB_APP_URL } from '../../shared/providers/tokens';
const EmailVerificationModelBase = zod.object({
id: zod.string().uuid(),
userIdentityId: zod.string(),
email: zod.string().email(),
email: zod.email(),
createdAt: zod.number().transform(v => new Date(v)),
});

Expand Down Expand Up @@ -132,7 +132,7 @@ export class EmailVerification {
WHERE "saaru"."user_id" = ${input.userIdentityId}
`,
)
.then(v => zod.object({ email: zod.string().email() }).nullable().parse(v));
.then(v => zod.object({ email: zod.email() }).nullable().parse(v));

if (!superTokensUser) {
throw new HiveError('User identity not found.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,10 @@ export class CollectionProvider {
});

if (validationResult.error) {
const errors = zod.treeifyError(validationResult.error);
return {
type: 'error' as const,
message: validationResult.error.errors[0].message,
message: errors.errors[0],
};
}

Expand Down Expand Up @@ -467,9 +468,10 @@ export class CollectionProvider {
});

if (validationResult.error) {
const errors = zod.treeifyError(validationResult.error);
return {
type: 'error' as const,
message: validationResult.error.errors[0].message,
message: errors.errors[0],
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ export const addSlackIntegration: NonNullable<MutationResolvers['addSlackIntegra
const result = AddSlackTokenIntegrationModel.safeParse(input);

if (!result.success) {
throw new HiveError(
result.error.formErrors.fieldErrors.token?.[0] ?? 'Please check your input.',
);
const errors = z.treeifyError(result.error);
throw new HiveError(errors.errors.at(0) ?? 'Please check your input.');
}

const organization = await injector.get(IdTranslator).translateOrganizationId(input);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ export class PreflightScriptProvider {
const validationResult = UpdatePreflightScriptModel.safeParse({ sourceCode: args.sourceCode });

if (validationResult.error) {
const errors = z.treeifyError(validationResult.error);
return {
error: {
message: validationResult.error.errors[0].message,
message: errors.errors[0],
},
};
}
Expand Down Expand Up @@ -147,9 +148,10 @@ export class PreflightScriptProvider {
const { data: preflightScript, error } = PreflightScriptModel.safeParse(result);

if (error) {
const errors = z.treeifyError(error);
return {
error: {
message: error.errors[0].message,
message: errors.errors[0],
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -580,16 +580,17 @@ export class OrganizationManager {
});

const InputModel = z.object({
email: z.string().email().max(128, 'Email must be at most 128 characters long'),
email: z.email().max(128, 'Email must be at most 128 characters long'),
});
const result = InputModel.safeParse(input);

if (!result.success) {
const errors = z.treeifyError(result.error);
return {
error: {
message: 'Please check your input.',
inputErrors: {
email: result.error.formErrors.fieldErrors.email?.[0],
email: errors.properties?.email?.errors?.at(0),
},
},
};
Expand Down Expand Up @@ -973,12 +974,13 @@ export class OrganizationManager {
});

if (!inputValidation.success) {
const errors = z.treeifyError(inputValidation.error);
return {
error: {
message: 'Please check your input.',
inputErrors: {
name: inputValidation.error.formErrors.fieldErrors.name?.[0],
description: inputValidation.error.formErrors.fieldErrors.description?.[0],
name: errors?.properties?.name?.errors.at(0),
description: errors?.properties?.description?.errors.at(0),
},
},
};
Expand Down Expand Up @@ -1173,7 +1175,7 @@ export class OrganizationManager {
});

if (!updatedMembership) {
throw new Error('Somethign went wrong.');
throw new Error('Something went wrong.');
}

const result = {
Expand Down Expand Up @@ -1225,12 +1227,13 @@ export class OrganizationManager {
});

if (!inputValidation.success) {
const errors = z.treeifyError(inputValidation.error);
return {
error: {
message: 'Please check your input.',
inputErrors: {
name: inputValidation.error.formErrors.fieldErrors.name?.[0],
description: inputValidation.error.formErrors.fieldErrors.description?.[0],
name: errors?.properties?.name?.errors.at(0),
description: errors?.properties?.description?.errors.at(0),
},
},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import z from 'zod';
import { IdTranslator } from '../../../shared/providers/id-translator';
import { OrganizationManager } from '../../providers/organization-manager';
import { OrganizationSlugModel } from '../../validation';
Expand All @@ -9,11 +10,10 @@ export const updateOrganizationSlug: NonNullable<
const parsedInput = OrganizationSlugModel.safeParse(input.slug);

if (!parsedInput.success) {
const errors = z.treeifyError(parsedInput.error);
return {
error: {
message:
parsedInput.error.formErrors.fieldErrors?.[0]?.[0] ??
'Changing the organization slug failed.',
message: errors.errors.at(0) ?? 'Changing the organization slug failed.',
},
};
}
Expand Down
6 changes: 3 additions & 3 deletions packages/services/api/src/modules/organization/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { reservedOrganizationSlugs } from './providers/organization-config';
export const OrganizationNameModel = NameModel.min(2).max(50);
export const OrganizationSlugModel = z
.string({
required_error: 'Organization slug is required',
error: issue => (issue.input === undefined ? 'Organization slug is required' : issue.message),
})
.min(1, 'Organization slug is required')
.max(50, 'Slug must be less than 50 characters')
Expand All @@ -16,7 +16,7 @@ export const OrganizationSlugModel = z
export const CreateOrUpdateMemberRoleModel = z.object({
name: z
.string({
required_error: 'Please enter role name',
error: issue => (issue.input === undefined ? 'Please enter role name' : issue.message),
})
.trim()
.min(2, 'Role name must be at least 2 characters long')
Expand All @@ -28,7 +28,7 @@ export const CreateOrUpdateMemberRoleModel = z.object({
.refine(val => val !== 'Viewer' && val !== 'Admin', 'Viewer and Admin are reserved'),
description: z
.string({
required_error: 'Please enter role description',
error: issue => (issue.input === undefined ? 'Please enter role description' : issue.message),
})
.trim()
.min(2, 'Role description must be at least 2 characters long')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ export class ProjectManager {
const inputParseResult = CreateProjectModel.safeParse(input);

if (!inputParseResult.success) {
const errors = z.treeifyError(inputParseResult.error);
return {
ok: false as const,
message: 'Please check your input.',
inputErrors: {
slug: inputParseResult.error.formErrors.fieldErrors.slug?.[0],
slug: errors?.properties?.slug?.errors?.at(0),
},
};
}
Expand Down Expand Up @@ -307,10 +308,10 @@ export class ProjectManager {
const inputParseResult = UpdateProjectSlugModel.safeParse(input);

if (!inputParseResult.success) {
const errors = z.treeifyError(inputParseResult.error);
return {
ok: false,
message:
inputParseResult.error.formErrors.fieldErrors.slug?.[0] ?? 'Please check your input.',
message: errors?.errors.at(0) ?? 'Please check your input.',
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/services/api/src/modules/project/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { NameModel } from '../../shared/entities';
export const ProjectNameModel = NameModel.min(2).max(40);
export const ProjectSlugModel = z
.string({
required_error: 'Project slug is required',
error: issue => (issue.input === undefined ? 'Project slug is required' : issue.message),
})
.min(1, 'Project slug is required')
.max(50, 'Slug must be less than 50 characters')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ export class SavedFiltersProvider {

const validationResult = CreateSavedFilterInputModel.safeParse(input);
if (!validationResult.success) {
const errors = zod.treeifyError(validationResult.error);
return {
type: 'error',
message: validationResult.error.errors[0].message,
message: errors.errors?.at(0) ?? 'Something went wrong.',
};
}

Expand Down Expand Up @@ -306,9 +307,10 @@ export class SavedFiltersProvider {

const validationResult = UpdateSavedFilterInputModel.safeParse(input);
if (!validationResult.success) {
const errors = zod.treeifyError(validationResult.error);
return {
type: 'error',
message: validationResult.error.errors[0].message,
message: errors.errors?.at(0) ?? 'Something went wrong.',
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,13 +737,14 @@ export class SchemaManager {
});

if (!parseResult.success) {
const errors = z.treeifyError(parseResult.error);
return {
error: {
__typename: 'UpdateSchemaCompositionExternalError' as const,
message: parseResult.error.message,
inputErrors: {
endpoint: parseResult.error.formErrors.fieldErrors.endpoint?.[0],
secret: parseResult.error.formErrors.fieldErrors.secret?.[0],
endpoint: errors?.properties?.endpoint?.errors.at(0),
secret: errors?.properties?.secret?.errors.at(0),
},
},
};
Expand Down
Loading
Loading