B2B-88: add starter kit structure and elements

This commit is contained in:
devmc-ee
2025-06-08 16:18:30 +03:00
parent 657a36a298
commit e7b25600cb
1280 changed files with 77893 additions and 5688 deletions

View File

@@ -0,0 +1,6 @@
import { z } from 'zod';
export const AcceptInvitationSchema = z.object({
inviteToken: z.string().uuid(),
nextPath: z.string().min(1),
});

View File

@@ -0,0 +1,50 @@
import { z } from 'zod';
/**
* @name RESERVED_NAMES_ARRAY
* @description Array of reserved names for team accounts
* This is a list of names that cannot be used for team accounts as they are reserved for other purposes.
* Please include any new reserved names here.
*/
const RESERVED_NAMES_ARRAY = [
'settings',
'billing',
// please add more reserved names here
];
const SPECIAL_CHARACTERS_REGEX = /[!@#$%^&*()+=[\]{};':"\\|,.<>/?]/;
/**
* @name TeamNameSchema
*/
export const TeamNameSchema = z
.string({
description: 'The name of the team account',
})
.min(2)
.max(50)
.refine(
(name) => {
console.log(name);
return !SPECIAL_CHARACTERS_REGEX.test(name);
},
{
message: 'teams:specialCharactersError',
},
)
.refine(
(name) => {
return !RESERVED_NAMES_ARRAY.includes(name.toLowerCase());
},
{
message: 'teams:reservedNameError',
},
);
/**
* @name CreateTeamSchema
* @description Schema for creating a team account
*/
export const CreateTeamSchema = z.object({
name: TeamNameSchema,
});

View File

@@ -0,0 +1,5 @@
import { z } from 'zod';
export const DeleteInvitationSchema = z.object({
invitationId: z.number().int(),
});

View File

@@ -0,0 +1,6 @@
import { z } from 'zod';
export const DeleteTeamAccountSchema = z.object({
accountId: z.string().uuid(),
otp: z.string().min(1),
});

View File

@@ -0,0 +1,26 @@
import { z } from 'zod';
const InviteSchema = z.object({
email: z.string().email(),
role: z.string().min(1).max(100),
});
export const InviteMembersSchema = z
.object({
invitations: InviteSchema.array().min(1).max(5),
})
.refine(
(data) => {
const emails = data.invitations.map((member) =>
member.email.toLowerCase(),
);
const uniqueEmails = new Set(emails);
return emails.length === uniqueEmails.size;
},
{
message: 'Duplicate emails are not allowed',
path: ['invitations'],
},
);

View File

@@ -0,0 +1,6 @@
import { z } from 'zod';
export const LeaveTeamAccountSchema = z.object({
accountId: z.string().uuid(),
confirmation: z.custom((value) => value === 'LEAVE'),
});

View File

@@ -0,0 +1,6 @@
import { z } from 'zod';
export const RemoveMemberSchema = z.object({
accountId: z.string().uuid(),
userId: z.string().uuid(),
});

View File

@@ -0,0 +1,5 @@
import { z } from 'zod';
export const RenewInvitationSchema = z.object({
invitationId: z.number().positive(),
});

View File

@@ -0,0 +1,11 @@
import { z } from 'zod';
export const TransferOwnershipConfirmationSchema = z.object({
accountId: z.string().uuid(),
userId: z.string().uuid(),
otp: z.string().min(6),
});
export type TransferOwnershipConfirmationData = z.infer<
typeof TransferOwnershipConfirmationSchema
>;

View File

@@ -0,0 +1,6 @@
import { z } from 'zod';
export const UpdateInvitationSchema = z.object({
invitationId: z.number(),
role: z.string().min(1),
});

View File

@@ -0,0 +1,10 @@
import { z } from 'zod';
export const RoleSchema = z.object({
role: z.string().min(1),
});
export const UpdateMemberRoleSchema = RoleSchema.extend({
accountId: z.string().uuid(),
userId: z.string().uuid(),
});

View File

@@ -0,0 +1,14 @@
import { z } from 'zod';
import { TeamNameSchema } from './create-team.schema';
export const TeamNameFormSchema = z.object({
name: TeamNameSchema,
});
export const UpdateTeamNameSchema = TeamNameFormSchema.merge(
z.object({
slug: z.string().min(1).max(255),
path: z.string().min(1).max(255),
}),
);