-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcollections.ts
More file actions
112 lines (95 loc) · 3.67 KB
/
Copy pathcollections.ts
File metadata and controls
112 lines (95 loc) · 3.67 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import { z } from 'zod';
import { ApiError, ApiSuccess } from './api';
/* Structs */
export const CollectionUserProjection = z.object({
isFavorited: z.boolean(),
});
export type CollectionUserProjection = z.infer<typeof CollectionUserProjection>;
export const CollectionMap = z.object({
mapId: z.string(),
position: z.number(),
});
export type CollectionMap = z.infer<typeof CollectionMap>;
export const Collection = z.object({
id: z.string(),
creatorId: z.string(),
creationDate: z.iso.datetime({ local: true }),
name: z.string(),
description: z.string().nullish(),
albumArt: z.string().nullish(),
maps: z.array(CollectionMap),
favorites: z.number(),
userProjection: CollectionUserProjection.optional(),
});
export type Collection = z.infer<typeof Collection>;
/* GET getCollection */
export const GetCollectionSuccess = ApiSuccess.extend({
collection: Collection,
});
export type GetCollectionSuccess = z.infer<typeof GetCollectionSuccess>;
export const GetCollectionResponse = z.discriminatedUnion('success', [
GetCollectionSuccess,
ApiError,
]);
export type GetCollectionResponse = z.infer<typeof GetCollectionResponse>;
/* GET findCollections */
export const FindCollectionsSuccess = ApiSuccess.extend({
collections: z.array(Collection),
});
export type FindCollectionsSuccess = z.infer<typeof FindCollectionsSuccess>;
export const FindCollectionsResponse = z.discriminatedUnion('success', [
FindCollectionsSuccess,
ApiError,
]);
export type FindCollectionsResponse = z.infer<typeof FindCollectionsResponse>;
/* POST createCollection */
export const CreateCollectionRequest = z.object({
name: z.string(),
description: z.string().optional(),
albumArt: z.string().optional(),
mapIds: z.array(z.string()).optional(),
});
export type CreateCollectionRequest = z.infer<typeof CreateCollectionRequest>;
export const CreateCollectionSuccess = ApiSuccess.extend({
id: z.string(),
});
export type CreateCollectionSuccess = z.infer<typeof CreateCollectionSuccess>;
export const CreateCollectionResponse = z.discriminatedUnion('success', [
CreateCollectionSuccess,
ApiError,
]);
export type CreateCollectionResponse = z.infer<typeof CreateCollectionResponse>;
/* PUT updateCollection */
export const UpdateCollectionRequest = z.object({
id: z.string(),
name: z.string().optional(),
description: z.string().optional(),
albumArt: z.string().optional(),
mapIds: z.array(z.string()).optional(),
});
export type UpdateCollectionRequest = z.infer<typeof UpdateCollectionRequest>;
export const UpdateCollectionResponse = z.discriminatedUnion('success', [ApiSuccess, ApiError]);
export type UpdateCollectionResponse = z.infer<typeof UpdateCollectionResponse>;
/* DELETE deleteCollection */
export const DeleteCollectionSuccess = ApiSuccess.extend({});
export type DeleteCollectionSuccess = z.infer<typeof DeleteCollectionSuccess>;
export const DeleteCollectionResponse = z.discriminatedUnion('success', [
DeleteCollectionSuccess,
ApiError,
]);
export type DeleteCollectionResponse = z.infer<typeof DeleteCollectionResponse>;
/* Collection Favorites */
export const SetCollectionFavoritesRequest = z.object({
collectionIds: z.array(z.string()),
isFavorite: z.boolean(),
});
export type SetCollectionFavoritesRequest = z.infer<typeof SetCollectionFavoritesRequest>;
export const GetFavoriteCollectionsSuccess = ApiSuccess.extend({
collections: z.array(Collection),
});
export type GetFavoriteCollectionsSuccess = z.infer<typeof GetFavoriteCollectionsSuccess>;
export const GetFavoriteCollectionsResponse = z.discriminatedUnion('success', [
GetFavoriteCollectionsSuccess,
ApiError,
]);
export type GetFavoriteCollectionsResponse = z.infer<typeof GetFavoriteCollectionsResponse>;