installing zod + adding zod schemas
This commit is contained in:
parent
874dd5e4c7
commit
5180ecc864
4 changed files with 81 additions and 1 deletions
|
|
@ -8,5 +8,8 @@
|
|||
},
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"zod": "^4.3.6"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
export * from "./constants.js";
|
||||
export * from "./schema.js";
|
||||
|
|
|
|||
72
packages/shared/src/schema.ts
Normal file
72
packages/shared/src/schema.ts
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
import * as z from "zod";
|
||||
|
||||
export const Term = z.object({
|
||||
id: z.uuid(),
|
||||
synset_id: z.string(),
|
||||
pos: z.string(),
|
||||
created_at: z.iso.datetime(),
|
||||
});
|
||||
|
||||
export type Term = z.infer<typeof Term>;
|
||||
|
||||
export const Translation = z.object({
|
||||
id: z.uuid(),
|
||||
term_id: z.string(),
|
||||
language_code: z.string(),
|
||||
text: z.string(),
|
||||
created_at: z.iso.datetime(),
|
||||
});
|
||||
|
||||
export type Translation = z.infer<typeof Translation>;
|
||||
|
||||
export const TermGloss = z.object({
|
||||
id: z.uuid(),
|
||||
term_id: z.uuid(),
|
||||
language_code: z.string(),
|
||||
text: z.string(),
|
||||
created_at: z.iso.datetime(),
|
||||
});
|
||||
|
||||
export type TermGloss = z.infer<typeof TermGloss>;
|
||||
|
||||
export const LanguagePair = z.object({
|
||||
id: z.uuid(),
|
||||
source_language: z.string(),
|
||||
target_language: z.string(),
|
||||
label: z.string(),
|
||||
active: z.boolean(),
|
||||
created_at: z.iso.datetime(),
|
||||
});
|
||||
|
||||
export type LanguagePair = z.infer<typeof LanguagePair>;
|
||||
|
||||
export const User = z.object({
|
||||
id: z.uuid(),
|
||||
openauth_sub: z.string(),
|
||||
email: z.email(),
|
||||
display_name: z.string(),
|
||||
created_at: z.iso.datetime(),
|
||||
last_login_at: z.iso.datetime(),
|
||||
});
|
||||
|
||||
export type User = z.infer<typeof User>;
|
||||
|
||||
export const Deck = z.object({
|
||||
id: z.uuid(),
|
||||
name: z.string(),
|
||||
desciption: z.string(),
|
||||
source_language: z.string(),
|
||||
validated_languages: z.array(z.string()),
|
||||
is_public: z.boolean(),
|
||||
created_at: z.iso.datetime(),
|
||||
});
|
||||
|
||||
export type Deck = z.infer<typeof Deck>;
|
||||
|
||||
export const DeckTerm = z.object({
|
||||
deck_id: z.uuid(),
|
||||
term_id: z.uuid(),
|
||||
added: z.iso.datetime(),
|
||||
});
|
||||
|
||||
export type DeckTerm = z.infer<typeof DeckTerm>;
|
||||
6
pnpm-lock.yaml
generated
6
pnpm-lock.yaml
generated
|
|
@ -132,7 +132,11 @@ importers:
|
|||
specifier: ^0.31.10
|
||||
version: 0.31.10
|
||||
|
||||
packages/shared: {}
|
||||
packages/shared:
|
||||
dependencies:
|
||||
zod:
|
||||
specifier: ^4.3.6
|
||||
version: 4.3.6
|
||||
|
||||
packages:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue