nah gonna redo it again

This commit is contained in:
bootunloader
2026-01-03 09:55:02 +02:00
parent b36492dc52
commit c7ff53e8ac
4 changed files with 442 additions and 1484 deletions

View File

@@ -1,248 +1,248 @@
import { z } from "zod";
export type Session = {
sId: string;
ip: string;
userAgent: string;
username: string;
userType: string;
sId: string;
ip: string;
userAgent: string;
username: string;
userType: string;
};
export type APISession = {
ip: string;
sessionToken: string;
userId: string;
ip: string;
sessionToken: string;
userId: string;
};
export const zAuthPayload = z.object({
username: z.string().min(4).max(64),
password: z.string().min(8).max(64),
username: z.string().min(4).max(64),
password: z.string().min(8).max(64),
});
export const zUser = z.object({
id: z.string().length(16),
createdAt: z.string(),
updatedAt: z.string(),
username: z.string().min(4).max(64),
password: z.string().min(8).max(64),
userType: z.string().min(4).max(5),
association: z.string(),
id: z.string().length(16),
createdAt: z.string(),
updatedAt: z.string(),
username: z.string().min(4).max(64),
password: z.string().min(8).max(64),
userType: z.string().min(4).max(5),
association: z.string(),
});
export type User = z.infer<typeof zUser>;
export const zLooseUser = z.object({
id: z.string().length(16).optional(),
createdAt: z.string().optional(),
updatedAt: z.string().optional(),
username: z.string().min(4).max(64),
password: z.string().min(8).max(64),
userType: z.string().min(4).max(5),
association: z.string(),
id: z.string().length(16).optional(),
createdAt: z.string().optional(),
updatedAt: z.string().optional(),
username: z.string().min(4).max(64),
password: z.string().min(8).max(64),
userType: z.string().min(4).max(5),
association: z.string(),
});
export type LooseUser = z.infer<typeof zLooseUser>;
export const zApiUser = z.object({
id: z.string().length(16),
userType: z.number(),
disableBooking: z.string().nullable().optional(),
sendVoucher: z.string().nullable().optional(),
voucherGenerated: z.string().nullable().optional(),
parentAdmin: z.number(),
parentDistributor: z.number(),
userName: z.string(),
userCity: z.string().nullable().optional(),
userId: z.string(),
password: z.string(),
accessDenied: z.number(),
phoneNumber: z.string(),
emailAddress: z.string(),
disable: z.number(),
commission: z.number(),
commissionPangora: z.number(),
allowTitles: z.string(),
specialDealer: z.number(),
allowBalance: z.number(),
balance: z.number(),
profitlossShare: z.number(),
shareProfitonly: z.number(),
allowRemoveold: z.number(),
removeDays: z.number().nullable().optional(),
language: z.number(),
postData: z.boolean().nullable().optional(),
createdAt: z.string().nullable(),
updatedAt: z.string().nullable(),
id: z.string().length(16),
userType: z.number(),
disableBooking: z.string().nullable().optional(),
sendVoucher: z.string().nullable().optional(),
voucherGenerated: z.string().nullable().optional(),
parentAdmin: z.number(),
parentDistributor: z.number(),
userName: z.string(),
userCity: z.string().nullable().optional(),
userId: z.string(),
password: z.string(),
accessDenied: z.number(),
phoneNumber: z.string(),
emailAddress: z.string(),
disable: z.number(),
commission: z.number(),
commissionPangora: z.number(),
allowTitles: z.string(),
specialDealer: z.number(),
allowBalance: z.number(),
balance: z.number(),
profitlossShare: z.number(),
shareProfitonly: z.number(),
allowRemoveold: z.number(),
removeDays: z.number().nullable().optional(),
language: z.number(),
postData: z.boolean().nullable().optional(),
createdAt: z.string().nullable(),
updatedAt: z.string().nullable(),
});
export type ApiUser = z.infer<typeof zApiUser>;
export const zApiPostUser = z.object({
id: z.string(),
userName: z.string(),
userId: z.string(),
postData: z.boolean(),
balance: z.number().optional(),
id: z.string(),
userName: z.string(),
userId: z.string(),
postData: z.boolean(),
balance: z.number().optional(),
});
export type ApiPostUser = z.infer<typeof zApiPostUser>;
export const zLooseApiUser = z.object({
id: z.string().length(16).optional(),
userType: z.number().optional(),
disableBooking: z.string().nullable().optional(),
sendVoucher: z.string().nullable().optional(),
voucherGenerated: z.string().nullable().optional(),
parentAdmin: z.number(),
parentDistributor: z.number(),
userName: z.string(),
userCity: z.string().nullable().optional(),
userId: z.string().optional(),
password: z.string(),
accessDenied: z.number(),
phoneNumber: z.string(),
emailAddress: z.string(),
disable: z.number(),
commission: z.number(),
commissionPangora: z.number(),
allowTitles: z.string(),
specialDealer: z.number(),
allowBalance: z.number(),
balance: z.number(),
profitlossShare: z.number(),
shareProfitonly: z.number(),
allowRemoveold: z.number(),
removeDays: z.number().nullable().optional(),
language: z.number().optional(),
postData: z.boolean().nullable().optional(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
id: z.string().length(16).optional(),
userType: z.number().optional(),
disableBooking: z.string().nullable().optional(),
sendVoucher: z.string().nullable().optional(),
voucherGenerated: z.string().nullable().optional(),
parentAdmin: z.number(),
parentDistributor: z.number(),
userName: z.string(),
userCity: z.string().nullable().optional(),
userId: z.string().optional(),
password: z.string(),
accessDenied: z.number(),
phoneNumber: z.string(),
emailAddress: z.string(),
disable: z.number(),
commission: z.number(),
commissionPangora: z.number(),
allowTitles: z.string(),
specialDealer: z.number(),
allowBalance: z.number(),
balance: z.number(),
profitlossShare: z.number(),
shareProfitonly: z.number(),
allowRemoveold: z.number(),
removeDays: z.number().nullable().optional(),
language: z.number().optional(),
postData: z.boolean().nullable().optional(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
});
export type LooseApiUser = z.infer<typeof zLooseApiUser>;
export const zDraw = z.object({
id: z.string(),
title: z.string(),
closeTime: z.string(),
filterDuplicatesWhilePosting: z.boolean(),
drawType: z.number(),
adminId: z.number(),
abRateF: z.coerce.number(),
abRateS: z.coerce.number(),
abcRateF: z.coerce.number(),
abcRateS: z.coerce.number(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
id: z.string(),
title: z.string(),
closeTime: z.string(),
filterDuplicatesWhilePosting: z.boolean(),
drawType: z.number(),
adminId: z.number(),
abRateF: z.coerce.number(),
abRateS: z.coerce.number(),
abcRateF: z.coerce.number(),
abcRateS: z.coerce.number(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
});
export type Draw = z.infer<typeof zDraw>;
export const zBookingEntry = z.object({
id: z.string(),
distributorId: z.number(),
dealerId: z.number(),
drawId: z.number(),
bookDate: z.string(),
number: z.string(),
first: z.number(),
second: z.number(),
changedBalance: z.number(),
sheetName: z.string().nullable().optional(),
sheetId: z.string().nullable().optional(),
requestId: z.string(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
id: z.string(),
distributorId: z.number(),
dealerId: z.number(),
drawId: z.number(),
bookDate: z.string(),
number: z.string(),
first: z.number(),
second: z.number(),
changedBalance: z.number(),
sheetName: z.string().nullable().optional(),
sheetId: z.string().nullable().optional(),
requestId: z.string(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
});
export type BookingEntry = z.infer<typeof zBookingEntry>;
export const zPostDataEntry = z.object({
id: z.string(),
requestId: z.string().nullable().optional(),
number: z.string(),
first: z.number(),
second: z.number(),
userId: z.string().nullable().optional(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
id: z.string(),
requestId: z.string().nullable().optional(),
number: z.string(),
first: z.number(),
second: z.number(),
userId: z.string().nullable().optional(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
});
export type PostDataEntry = z.infer<typeof zPostDataEntry>;
const zPostDataHistory = z.object({
id: z.string(),
data: z.array(zPostDataEntry),
drawId: z.number(),
bookDate: z.string(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
id: z.string(),
data: z.array(zPostDataEntry),
drawId: z.number(),
bookDate: z.string(),
createdAt: z.string().nullable().optional(),
updatedAt: z.string().nullable().optional(),
});
export type PostDataHistory = z.infer<typeof zPostDataHistory>;
export const zPresetDataEntry = z.object({
id: z.string(),
drawId: z.number(),
bookDate: z.string(),
number: z.string(),
first: z.number(),
second: z.number(),
createdAt: z.string().nullable().optional(),
dealerId: z.number().optional().nullable(),
id: z.string(),
drawId: z.number(),
bookDate: z.string(),
number: z.string(),
first: z.number(),
second: z.number(),
createdAt: z.string().nullable().optional(),
dealerId: z.number().optional().nullable(),
});
export type PresetDataEntry = z.infer<typeof zPresetDataEntry>;
export const fsPair = z.object({
first: z.number(),
second: z.number(),
first: z.number(),
second: z.number(),
});
export const zLexiCodeCacheObject = z.object({
number: z.string(),
rate: fsPair,
prize: fsPair,
frequency: fsPair,
number: z.string(),
rate: fsPair,
prize: fsPair,
frequency: fsPair,
});
export const reducedFinalSheetRow = z.object({
id: z.string(),
number: z.string(),
frequency: fsPair,
frequencies: z.object({
// a: fsPair,
// ab: fsPair,
// abc: fsPair,
// "+abc": fsPair,
// "a+bc": fsPair,
// "ab+c": fsPair,
abcd: fsPair,
}),
rate: fsPair,
prize: fsPair,
profit: fsPair,
id: z.string(),
number: z.string(),
frequency: fsPair,
frequencies: z.object({
// a: fsPair,
// ab: fsPair,
// abc: fsPair,
// "+abc": fsPair,
// "a+bc": fsPair,
// "ab+c": fsPair,
abcd: fsPair,
}),
rate: fsPair,
prize: fsPair,
profit: fsPair,
});
export const zfinalSheetRow = z.object({
id: z.string(),
number: z.string(),
frequency: fsPair,
rate: fsPair,
prize: fsPair,
profit: fsPair,
id: z.string(),
number: z.string(),
frequency: fsPair,
rate: fsPair,
prize: fsPair,
profit: fsPair,
a: zLexiCodeCacheObject,
xa: zLexiCodeCacheObject,
xxa: zLexiCodeCacheObject,
xxxa: zLexiCodeCacheObject,
ab: zLexiCodeCacheObject,
xab: zLexiCodeCacheObject,
axb: zLexiCodeCacheObject,
xaxb: zLexiCodeCacheObject,
xxab: zLexiCodeCacheObject,
axxb: zLexiCodeCacheObject,
abc: zLexiCodeCacheObject,
xabc: zLexiCodeCacheObject,
axbc: zLexiCodeCacheObject,
abxc: zLexiCodeCacheObject,
abcd: zLexiCodeCacheObject,
a: zLexiCodeCacheObject,
xa: zLexiCodeCacheObject,
xxa: zLexiCodeCacheObject,
xxxa: zLexiCodeCacheObject,
ab: zLexiCodeCacheObject,
xab: zLexiCodeCacheObject,
axb: zLexiCodeCacheObject,
xaxb: zLexiCodeCacheObject,
xxab: zLexiCodeCacheObject,
axxb: zLexiCodeCacheObject,
abc: zLexiCodeCacheObject,
xabc: zLexiCodeCacheObject,
axbc: zLexiCodeCacheObject,
abxc: zLexiCodeCacheObject,
abcd: zLexiCodeCacheObject,
});
export type ServerError = Array<{
message: string;
value?: string;
meta?: any;
message: string;
value?: string;
meta?: any;
}>;
export const UserTypes = { ADMIN: "ADMIN", USER: "USER" };
@@ -250,8 +250,8 @@ export const UserTypes = { ADMIN: "ADMIN", USER: "USER" };
export const ApiUserTypes = { ADMIN: 1, DISTRIBUTOR: 2, DEALER: 3 };
export type ApiPostUserWithParent = ApiPostUser & {
parentAdmin: number;
parentDistributor: number;
parentAdmin: number;
parentDistributor: number;
};
export type LexiCodeCacheObject = z.infer<typeof zLexiCodeCacheObject>;
@@ -265,108 +265,109 @@ export type ReducedFinalSheetRow = z.infer<typeof reducedFinalSheetRow>;
export type FSPair = z.infer<typeof fsPair>;
export type FSTotals = {
rate: FSPair;
prize: FSPair;
commission: FSPair;
netRate: FSPair;
frequency: FSPair;
rate: FSPair;
prize: FSPair;
commission: FSPair;
netRate: FSPair;
frequency: FSPair;
};
export type ReducedFinalSheetData = {
id: string;
date: string;
drawId: string;
data: Array<ReducedFinalSheetRow>;
totals: FSTotals;
createdAt?: string;
updatedAt?: string;
id: string;
date: string;
drawId: string;
data: Array<ReducedFinalSheetRow>;
totals: FSTotals;
createdAt?: string;
updatedAt?: string;
};
export type FinalSheetData = {
id: string;
date: string;
drawId: string;
data: Array<FinalSheetRow>;
totals: FSTotals;
createdAt?: string;
updatedAt?: string;
id: string;
date: string;
drawId: string;
data: Array<FinalSheetRow>;
totals: FSTotals;
createdAt?: string;
updatedAt?: string;
};
export type AuthPayload = z.infer<typeof zAuthPayload>;
export type SessionData = {
username: string;
userType: string;
username: string;
userType: string;
};
export type BookingInputValues = {
number: string;
default: { first: string; second: string };
first: Record<string, string>;
second: Record<string, string>;
number: string;
default: { first: string; second: string };
first: Record<string, string>;
second: Record<string, string>;
};
export const zPostDataHistoryFilters = z.object({
date: z.string(),
draw: zDraw,
date: z.string(),
draw: zDraw,
});
export type PostDataHistoryFilters = z.infer<typeof zPostDataHistoryFilters>;
export const zDDFilters = z.object({
date: z.string(),
draw: zDraw.optional(),
date: z.string(),
draw: zDraw.optional(),
});
export type DDFilters = z.infer<typeof zDDFilters>;
export const zDDUserFilters = z.object({
date: z.string(),
draw: zDraw.optional(),
user: zApiUser.optional(),
date: z.string(),
draw: zDraw.optional(),
user: zApiUser.optional(),
});
export type DDUserFilters = z.infer<typeof zDDUserFilters>;
export const zPostDataFilters = z.object({
date: z.string(),
draw: zDraw.optional().nullable(),
minPrize: z.coerce.number(),
maxPrize: z.coerce.number(),
twoDigitRates: fsPair,
threeDigitRates: fsPair,
customData: z.string(),
date: z.string(),
draw: zDraw.optional().nullable(),
minPrize: z.coerce.number(),
maxPrize: z.coerce.number(),
twoDigitRates: fsPair,
threeDigitRates: fsPair,
customData: z.string(),
});
export type PostDataFilters = z.infer<typeof zPostDataFilters>;
// TODO: THIS IS OUTDATED, HAVE TO UPDATE THIS TO A NEW DISTRIBUTOR
export const DEFAULT_RANDOM_DISTRIBUTOR = {
id: "apiuser:6339",
userType: 2,
disableBooking: null,
sendVoucher: null,
voucherGenerated: null,
parentAdmin: 15,
parentDistributor: 0,
userName: "Baba Sagar",
userCity: "Shikar pur",
userId: "317XY3",
password: "405613",
accessDenied: 0,
phoneNumber: "",
emailAddress: "",
disable: 0,
commission: 20.0,
commissionPangora: 20.0,
allowTitles: ",7,8,9,10,11,12,13,14,15,16,30,31,32,",
specialDealer: 0,
allowBalance: 1,
balance: 30094.905,
profitlossShare: 50.0,
shareProfitonly: 0,
allowRemoveold: 0,
removeDays: 30,
language: 0,
createdAt: new Date().toString(),
updatedAt: new Date().toString(),
id: "apiuser:6339",
userType: 2,
disableBooking: null,
sendVoucher: null,
voucherGenerated: null,
parentAdmin: 15,
parentDistributor: 0,
userName: "Baba Sagar",
userCity: "Shikar pur",
userId: "298HAM",
password: "HA16Z7",
accessDenied: 0,
phoneNumber: "",
emailAddress: "",
disable: 0,
commission: 20.0,
commissionPangora: 20.0,
allowTitles: ",7,8,9,10,11,12,13,14,15,16,30,31,32,",
specialDealer: 0,
allowBalance: 1,
balance: 30094.905,
profitlossShare: 50.0,
shareProfitonly: 0,
allowRemoveold: 0,
removeDays: 30,
language: 0,
createdAt: new Date().toString(),
updatedAt: new Date().toString(),
} as unknown as ApiUser;