-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfirestore-types.ts
More file actions
74 lines (67 loc) · 2.18 KB
/
firestore-types.ts
File metadata and controls
74 lines (67 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import z from "zod";
import { zInstrument, zPart } from "./types.js";
// Firestore Timestamps (serverTimestamp() on write, Timestamp on read)
const zTimestamp = z.any();
export const zUserData = z.object({
displayName: z.string(),
email: z.string().email(),
});
export const zUserDoc = zUserData.extend({ createdAt: zTimestamp });
export type UserData = z.infer<typeof zUserData>;
export type UserDoc = z.infer<typeof zUserDoc>;
export const zProjectData = z.object({
title: z.string(),
ownerId: z.string(),
collaboratorIds: z.array(z.string()),
});
export const zProjectDoc = zProjectData.extend({ createdAt: zTimestamp });
export type ProjectData = z.infer<typeof zProjectData>;
export type ProjectDoc = z.infer<typeof zProjectDoc>;
export const zSongData = z.object({
title: z.string(),
composer: z.string(),
sub: z.string(),
tags: z.array(z.string()),
projectId: z.string(),
uploadedBy: z.string(),
latestRevisionId: z.string(),
});
export const zSongDoc = zSongData.extend({
createdAt: zTimestamp,
deletedAt: zTimestamp.nullable().optional(),
});
export type SongData = z.infer<typeof zSongData>;
export type SongDoc = z.infer<typeof zSongDoc>;
export const zRevisionData = z.object({
revisionNumber: z.number().int().positive(),
uploadedBy: z.string(),
mscz: z.string(),
metajson: z.string(),
midi: z.string(),
parts: z.array(zPart),
notes: z.string(),
isLatest: z.boolean(),
});
export const zRevisionDoc = zRevisionData.extend({ uploadedAt: zTimestamp });
export type RevisionData = z.infer<typeof zRevisionData>;
export type RevisionDoc = z.infer<typeof zRevisionDoc>;
export const zSongbookEntry = z.object({
songId: z.string(),
revisionId: z.string(),
order: z.number().int(),
instruments: z.array(zInstrument),
});
export type SongbookEntry = z.infer<typeof zSongbookEntry>;
export const zSongbookData = z.object({
title: z.string(),
ownerId: z.string(),
slug: z.string(),
isPublished: z.boolean(),
entries: z.array(zSongbookEntry),
});
export const zSongbookDoc = zSongbookData.extend({
createdAt: zTimestamp,
updatedAt: zTimestamp,
});
export type SongbookData = z.infer<typeof zSongbookData>;
export type SongbookDoc = z.infer<typeof zSongbookDoc>;