add userprefrerencedb

This commit is contained in:
rubikscraft
2022-04-13 16:33:07 +02:00
parent 9469090614
commit 2bbe798097
9 changed files with 262 additions and 219 deletions

View File

@@ -10,15 +10,21 @@ export const PrefValueTypes = tuple('string', 'number', 'boolean');
// Decoded Representations
export const DecodedSysPrefSchema = z.object({
export const DecodedPrefSchema = z.object({
key: z.string(),
value: IsPrefValue(),
type: z.enum(PrefValueTypes),
})
});
export type DecodedPref = z.infer<typeof DecodedSysPrefSchema>;
// Usr and Sys
export const DecodedSysPrefSchema = DecodedPrefSchema;
export type DecodedSysPref = z.infer<typeof DecodedSysPrefSchema>;
export const DecodedUsrPrefSchema = DecodedSysPrefSchema.merge(z.object({
user: IsEntityID(),
}))
export const DecodedUsrPrefSchema = DecodedSysPrefSchema.merge(
z.object({
user: IsEntityID(),
}),
);
export type DecodedUsrPref = z.infer<typeof DecodedUsrPrefSchema>;

View File

@@ -1,9 +0,0 @@
import { z } from 'zod';
import { IsEntityID } from '../validators/entity-id.validator';
export const ESysPreferenceSchema = z.object({
id: IsEntityID().optional(),
key: z.string(),
value: z.string(),
});
export type ESysPreference = z.infer<typeof ESysPreferenceSchema>;

View File

@@ -1,11 +0,0 @@
import { z } from 'zod';
import { IsEntityID } from '../validators/entity-id.validator';
import { IsPosInt } from '../validators/positive-int.validator';
export const EUsrPreferenceSchema = z.object({
id: IsEntityID().optional(),
key: z.string(),
value: z.string(),
userId: IsPosInt(),
})
export type EUsrPreference = z.infer<typeof EUsrPreferenceSchema>;