@echovisionlab/geul-common 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { z } from "zod";
1
+ import * as z from "zod/mini";
2
2
  import { memberIdSchema } from "./member-id.ts";
3
3
 
4
4
  export const releaseTypeSchema = z.enum([
@@ -9,21 +9,21 @@ export const releaseTypeSchema = z.enum([
9
9
  ]);
10
10
  export const creditTargetTypeSchema = z.enum(["artist", "member", "text"]);
11
11
 
12
- const creditItemSchema = z.object({
13
- id: z.string().uuid(),
12
+ const creditItemShape = {
13
+ id: z.uuid(),
14
14
  credit_type: creditTargetTypeSchema,
15
- artist_id: z.string().uuid().nullable(),
16
- artist_name: z.string().nullable(),
17
- artist_slug: z.string().nullable(),
18
- member_id: memberIdSchema.nullable(),
19
- member_name: z.string().nullable(),
20
- credited_name: z.string().nullable(),
21
- credit_role: z.string().nullable(),
15
+ artist_id: z.nullable(z.uuid()),
16
+ artist_name: z.nullable(z.string()),
17
+ artist_slug: z.nullable(z.string()),
18
+ member_id: z.nullable(memberIdSchema),
19
+ member_name: z.nullable(z.string()),
20
+ credited_name: z.nullable(z.string()),
21
+ credit_role: z.nullable(z.string()),
22
22
  sort_order: z.number(),
23
- });
23
+ };
24
24
 
25
25
  function requireMemberCreditId(
26
- credit: z.infer<typeof creditItemSchema>,
26
+ credit: z.infer<z.ZodMiniObject<typeof creditItemShape>>,
27
27
  ): boolean {
28
28
  return credit.credit_type !== "member" || credit.member_id !== null;
29
29
  }
@@ -33,95 +33,79 @@ const memberCreditRefinement = {
33
33
  path: ["member_id"] as PropertyKey[],
34
34
  };
35
35
 
36
- export const releaseCreditItemSchema = creditItemSchema
37
- .strict()
38
- .refine(requireMemberCreditId, memberCreditRefinement);
39
-
40
- export const releaseArtistItemSchema = z
41
- .object({
42
- artist_id: z.string().uuid(),
43
- artist_name: z.string(),
44
- artist_slug: z.string().nullable(),
45
- sort_order: z.number(),
46
- })
47
- .strict();
48
-
49
- export const releaseLabelItemSchema = z
50
- .object({
51
- label_id: z.string().uuid(),
52
- label_name: z.string(),
53
- label_slug: z.string().nullable(),
54
- catalog_number: z.string().nullable(),
55
- sort_order: z.number(),
56
- })
57
- .strict();
58
-
59
- export const releaseGenreItemSchema = z
60
- .object({
61
- id: z.string().uuid(),
62
- name: z.string(),
63
- slug: z.string(),
64
- })
65
- .strict();
66
-
67
- export const releaseCategoryItemSchema = z
68
- .object({
69
- id: z.string().uuid(),
70
- name: z.string(),
71
- slug: z.string(),
72
- })
73
- .strict();
74
-
75
- export const releaseStyleItemSchema = z
76
- .object({
77
- id: z.string().uuid(),
78
- name: z.string(),
79
- slug: z.string(),
80
- })
81
- .strict();
82
-
83
- export const releaseFormatItemSchema = z
84
- .object({
85
- id: z.string().uuid(),
86
- name: z.string(),
87
- slug: z.string(),
88
- format_description: z.string().nullable(),
89
- })
90
- .strict();
91
-
92
- export const trackCreditItemSchema = creditItemSchema
93
- .strict()
94
- .refine(requireMemberCreditId, memberCreditRefinement);
95
-
96
- export const releaseTrackItemSchema = z
97
- .object({
98
- id: z.string().uuid(),
99
- track_number: z.number(),
100
- title: z.string(),
101
- audio_original_file_id: z.string().uuid().nullable().optional(),
102
- credits: z.array(trackCreditItemSchema),
103
- })
104
- .strict();
105
-
106
- export const releaseCollabFieldsSchema = z
107
- .object({
108
- title: z.string().optional(),
109
- type: releaseTypeSchema.optional(),
110
- releaseDate: z.string().nullable().optional(),
111
- spotifyUrl: z.string().optional(),
112
- appleMusicUrl: z.string().optional(),
113
- bandcampUrl: z.string().optional(),
114
- youtubeMusicUrl: z.string().optional(),
115
- artists: z.array(releaseArtistItemSchema).optional(),
116
- credits: z.array(releaseCreditItemSchema).optional(),
117
- labels: z.array(releaseLabelItemSchema).optional(),
118
- categories: z.array(releaseCategoryItemSchema).optional(),
119
- genres: z.array(releaseGenreItemSchema).optional(),
120
- styles: z.array(releaseStyleItemSchema).optional(),
121
- formats: z.array(releaseFormatItemSchema).optional(),
122
- tracks: z.array(releaseTrackItemSchema).optional(),
123
- })
124
- .strict();
36
+ export const releaseCreditItemSchema = z
37
+ .strictObject(creditItemShape)
38
+ .check(z.refine(requireMemberCreditId, memberCreditRefinement));
39
+
40
+ export const releaseArtistItemSchema = z.strictObject({
41
+ artist_id: z.uuid(),
42
+ artist_name: z.string(),
43
+ artist_slug: z.nullable(z.string()),
44
+ sort_order: z.number(),
45
+ });
46
+
47
+ export const releaseLabelItemSchema = z.strictObject({
48
+ label_id: z.uuid(),
49
+ label_name: z.string(),
50
+ label_slug: z.nullable(z.string()),
51
+ catalog_number: z.nullable(z.string()),
52
+ sort_order: z.number(),
53
+ });
54
+
55
+ export const releaseGenreItemSchema = z.strictObject({
56
+ id: z.uuid(),
57
+ name: z.string(),
58
+ slug: z.string(),
59
+ });
60
+
61
+ export const releaseCategoryItemSchema = z.strictObject({
62
+ id: z.uuid(),
63
+ name: z.string(),
64
+ slug: z.string(),
65
+ });
66
+
67
+ export const releaseStyleItemSchema = z.strictObject({
68
+ id: z.uuid(),
69
+ name: z.string(),
70
+ slug: z.string(),
71
+ });
72
+
73
+ export const releaseFormatItemSchema = z.strictObject({
74
+ id: z.uuid(),
75
+ name: z.string(),
76
+ slug: z.string(),
77
+ format_description: z.nullable(z.string()),
78
+ });
79
+
80
+ export const trackCreditItemSchema = z
81
+ .strictObject(creditItemShape)
82
+ .check(z.refine(requireMemberCreditId, memberCreditRefinement));
83
+
84
+ export const releaseTrackItemSchema = z.strictObject({
85
+ id: z.uuid(),
86
+ track_number: z.number(),
87
+ title: z.string(),
88
+ audio_original_file_id: z.optional(z.nullable(z.uuid())),
89
+ credits: z.array(trackCreditItemSchema),
90
+ });
91
+
92
+ export const releaseCollabFieldsSchema = z.strictObject({
93
+ title: z.optional(z.string()),
94
+ type: z.optional(releaseTypeSchema),
95
+ releaseDate: z.optional(z.nullable(z.string())),
96
+ spotifyUrl: z.optional(z.string()),
97
+ appleMusicUrl: z.optional(z.string()),
98
+ bandcampUrl: z.optional(z.string()),
99
+ youtubeMusicUrl: z.optional(z.string()),
100
+ artists: z.optional(z.array(releaseArtistItemSchema)),
101
+ credits: z.optional(z.array(releaseCreditItemSchema)),
102
+ labels: z.optional(z.array(releaseLabelItemSchema)),
103
+ categories: z.optional(z.array(releaseCategoryItemSchema)),
104
+ genres: z.optional(z.array(releaseGenreItemSchema)),
105
+ styles: z.optional(z.array(releaseStyleItemSchema)),
106
+ formats: z.optional(z.array(releaseFormatItemSchema)),
107
+ tracks: z.optional(z.array(releaseTrackItemSchema)),
108
+ });
125
109
 
126
110
  export const RELEASE_JSON_KEYS: ReadonlySet<
127
111
  keyof z.infer<typeof releaseCollabFieldsSchema>