@behindthemusictree/app-kit 43.1.4 → 44.0.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.
@@ -31,10 +31,21 @@ import {
31
31
  } from "./chunk-RGHDVBEY.js";
32
32
 
33
33
  // src/genre-tree/useGenre.ts
34
- import { z as z20 } from "zod";
34
+ import { z as z21 } from "zod";
35
+ import {
36
+ zV1GenresListResponse,
37
+ zV1GenresOverviewRetrieveResponse
38
+ } from "@behindthemusictree/grow-api";
35
39
 
36
- // src/genre-tree/schemas/criteria/detailed.ts
37
- import { z as z10 } from "zod";
40
+ // src/genre-tree/schemas/reference-genre.ts
41
+ import { z as z6 } from "zod";
42
+ import { zV1GenresRetrieveResponse, zV1GenrePlaylistsTreeListResponse } from "@behindthemusictree/grow-api";
43
+
44
+ // src/genre-tree/schemas/criteria-playlist/simple.ts
45
+ import { z as z5 } from "zod";
46
+
47
+ // src/genre-tree/schemas/criteria-playlist/detailed.ts
48
+ import { z as z4 } from "zod";
38
49
 
39
50
  // src/genre-tree/schemas/genre-music.ts
40
51
  import { z as z2 } from "zod";
@@ -49,10 +60,10 @@ var CriteriaPlaylistMinimumSchema = z.object({
49
60
  // src/genre-tree/schemas/genre-music.ts
50
61
  var CountSchema = z2.number().int().nonnegative();
51
62
  var SubgenreCountsSchema = z2.union([
52
- z2.object({ canonical: CountSchema, regional: CountSchema, all: CountSchema }).strict(),
63
+ z2.object({ global: CountSchema, regional: CountSchema, all: CountSchema }).strict(),
53
64
  z2.object({ all: CountSchema }).strict()
54
65
  ]).refine(
55
- (counts) => !("canonical" in counts) || counts.all >= counts.canonical && counts.all >= counts.regional,
66
+ (counts) => !("global" in counts) || counts.all >= counts.global && counts.all >= counts.regional,
56
67
  "The combined count must include both scoped selections"
57
68
  );
58
69
  var GenreCountsSchema = z2.object({
@@ -63,7 +74,7 @@ var includesDirectSongs = (counts) => Object.values(counts.genreAndSubgenresTrac
63
74
  var GenreCatalogueCountsSchema = GenreCountsSchema.refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
64
75
  var GenrePlaylistSummarySchema = CriteriaPlaylistMinimumSchema.extend(GenreCountsSchema.shape).refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
65
76
  var GenreCoverageSchema = z2.enum(["genreOnly", "genreAndSubgenres"]);
66
- var SubgenreScopeSchema = z2.enum(["canonical", "regional", "all"]);
77
+ var SubgenreScopeSchema = z2.enum(["global", "regional", "all"]);
67
78
 
68
79
  // src/genre-tree/schemas/criteria/minimum.ts
69
80
  import { z as z3 } from "zod";
@@ -74,109 +85,24 @@ var CriteriaMinimumSchema = z3.object({
74
85
  wikidataId: z3.string().nullable().optional()
75
86
  });
76
87
 
77
- // src/genre-tree/schemas/track/base.ts
78
- import { z as z7 } from "zod";
79
-
80
- // src/genre-tree/schemas/artist-minimum.ts
81
- import { z as z4 } from "zod";
82
- var ArtistMinimumSchema = z4.object({
83
- uuid: z4.string().uuid(),
84
- name: z4.string(),
85
- isSpecialPurpose: z4.boolean().optional()
86
- });
87
-
88
- // src/genre-tree/schemas/album-minimum.ts
89
- import { z as z5 } from "zod";
90
- var AlbumMinimumSchema = z5.object({
91
- uuid: z5.string().uuid(),
92
- name: z5.string(),
93
- albumArtists: z5.array(ArtistMinimumSchema).nullable().optional()
94
- });
95
-
96
- // src/genre-tree/schemas/uuid-resource.ts
97
- import { z as z6 } from "zod";
98
- var UuidResourceSchema = z6.object({
99
- uuid: z6.string().uuid()
100
- });
101
-
102
- // src/genre-tree/schemas/track/base.ts
103
- var TrackBaseSchema = UuidResourceSchema.extend({
104
- title: z7.string(),
105
- artists: z7.array(ArtistMinimumSchema).nullable().optional(),
106
- album: AlbumMinimumSchema.nullable().optional(),
107
- trackNumber: z7.number().nullable().optional(),
108
- // null for a song not yet linked to a genre.
109
- genre: CriteriaMinimumSchema.nullable(),
110
- rating: z7.number().min(0).max(10).nullable().optional(),
111
- language: z7.string().nullable().optional(),
112
- playCount: z7.number().min(0),
113
- createdOn: z7.string().datetime(),
114
- updatedOn: z7.string().datetime().nullable().optional()
115
- });
116
-
117
- // src/genre-tree/schemas/track/minimum.ts
118
- var TrackMinimumSchema = TrackBaseSchema.pick({
119
- uuid: true,
120
- title: true,
121
- artists: true
122
- });
123
-
124
- // src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
125
- import { z as z8 } from "zod";
126
- var CriteriaLineageRelWithoutAscendantSchema = z8.object({
127
- descendant: CriteriaMinimumSchema,
128
- degree: z8.number()
129
- });
130
-
131
- // src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
132
- import { z as z9 } from "zod";
133
- var CriteriaLineageRelWithoutDescendantSchema = z9.object({
134
- ascendant: CriteriaMinimumSchema,
135
- degree: z9.number()
136
- });
137
-
138
- // src/genre-tree/schemas/criteria/detailed.ts
139
- var CriteriaDetailedSchema = z10.object({
140
- uuid: GenreUuidSchema,
141
- name: z10.string(),
142
- summary: z10.string().nullable(),
143
- // Optional until every deployed API serves it.
144
- wikidataId: z10.string().nullable().optional(),
145
- parent: CriteriaMinimumSchema.nullable(),
146
- ascendants: z10.array(CriteriaLineageRelWithoutDescendantSchema),
147
- descendants: z10.array(CriteriaLineageRelWithoutAscendantSchema).optional(),
148
- root: CriteriaMinimumSchema,
149
- children: z10.array(CriteriaMinimumSchema),
150
- catalogue: GenreCatalogueCountsSchema.optional(),
151
- criteriaPlaylist: z10.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]).nullable(),
152
- tracks: z10.array(TrackMinimumSchema).optional(),
153
- essentialSongs: z10.array(TrackMinimumSchema),
154
- tracksCount: z10.number(),
155
- updatedOn: z10.string().datetime().nullable()
156
- });
157
-
158
- // src/genre-tree/schemas/criteria-playlist/simple.ts
159
- import { z as z12 } from "zod";
160
-
161
88
  // src/genre-tree/schemas/criteria-playlist/detailed.ts
162
- import { z as z11 } from "zod";
163
- var CriteriaPlaylistDetailedSchema = z11.object({
89
+ var CriteriaPlaylistDetailedSchema = z4.object({
164
90
  uuid: GenrePlaylistUuidSchema,
165
- name: z11.string(),
166
- tracksCount: z11.number(),
91
+ name: z4.string(),
92
+ tracksCount: z4.number(),
167
93
  genreOnlyTracksCount: GenreCountsSchema.shape.genreOnlyTracksCount.optional(),
168
94
  genreAndSubgenresTracksCount: GenreCountsSchema.shape.genreAndSubgenresTracksCount.optional(),
169
95
  catalogue: GenreCatalogueCountsSchema.optional(),
170
96
  // Summed YouTube views of the same songs as `tracksCount`. Optional: hear-api has no view counts.
171
- viewsCount: z11.number().optional(),
172
- durationInSec: z11.number().min(0).nullable().optional(),
173
- durationStrInHourMinSec: z11.string().nullable().optional(),
97
+ viewsCount: z4.number().optional(),
98
+ durationInSec: z4.number().min(0).nullable().optional(),
99
+ durationStrInHourMinSec: z4.string().nullable().optional(),
174
100
  // Nullable: the "Genreless" root playlist has no criteria attached and is never updated.
175
101
  criteria: CriteriaMinimumSchema.nullable(),
176
102
  parent: CriteriaPlaylistMinimumSchema.nullable(),
177
103
  root: CriteriaPlaylistMinimumSchema,
178
- createdOn: z11.string(),
179
- updatedOn: z11.string().nullable()
104
+ createdOn: z4.string(),
105
+ updatedOn: z4.string().nullable()
180
106
  });
181
107
 
182
108
  // src/genre-tree/schemas/criteria-playlist/simple.ts
@@ -195,24 +121,44 @@ var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
195
121
  updatedOn: true
196
122
  }).extend({
197
123
  // Only on the tree/list payloads, not the detail endpoint — hence not on the detailed schema.
198
- isUnacceptedRoot: z12.boolean(),
124
+ isUnacceptedRoot: z5.boolean(),
199
125
  // Optional: a backend that does not curate umbrella genres omits it.
200
- isUmbrella: z12.boolean().optional(),
126
+ isUmbrella: z5.boolean().optional(),
201
127
  // Optional: only the grow tree payload carries it; null when the genre has no scene.
202
- scene: z12.enum(["commercial", "underground"]).nullable().optional()
128
+ scene: z5.enum(["commercial", "underground"]).nullable().optional()
203
129
  });
204
130
 
205
131
  // src/genre-tree/schemas/reference-genre.ts
206
- var ReferenceGenreDetailedSchema = CriteriaDetailedSchema.extend({
207
- catalogue: GenreCatalogueCountsSchema,
208
- criteriaPlaylist: GenrePlaylistSummarySchema.nullable()
132
+ function checkGenreCounts(counts, path, ctx) {
133
+ const inclusive = counts.genreAndSubgenresTracksCount;
134
+ const issue = (message) => ctx.addIssue({ code: "custom", path: [...path, "genreAndSubgenresTracksCount"], message });
135
+ if (!Object.values(inclusive).every((count) => count >= counts.genreOnlyTracksCount)) {
136
+ issue("Every inclusive count must include the genre itself");
137
+ }
138
+ if ("global" in inclusive && !(inclusive.all >= inclusive.global && inclusive.all >= (inclusive.regional ?? 0))) {
139
+ issue("The combined count must include both scoped selections");
140
+ }
141
+ }
142
+ var ReferenceGenreDetailedSchema = zV1GenresRetrieveResponse.extend({ criteriaPlaylist: zV1GenresRetrieveResponse.shape.criteriaPlaylist.nullable() }).superRefine((genre, ctx) => {
143
+ checkGenreCounts(genre.catalogue, ["catalogue"], ctx);
144
+ if (genre.criteriaPlaylist) checkGenreCounts(genre.criteriaPlaylist, ["criteriaPlaylist"], ctx);
209
145
  });
210
- var ReferenceGenrePlaylistSchema = CriteriaPlaylistSimpleSchema.extend({
146
+ var generatedTreeRow = zV1GenrePlaylistsTreeListResponse.element;
147
+ var ReferenceGenrePlaylistRowSchema = generatedTreeRow.extend({
211
148
  ...GenreCountsSchema.shape,
212
- catalogue: GenreCatalogueCountsSchema
213
- }).superRefine((playlist, ctx) => {
214
- const counts = GenreCatalogueCountsSchema.safeParse(playlist);
215
- if (!counts.success) for (const issue of counts.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
149
+ criteria: generatedTreeRow.shape.criteria.extend({ parent: generatedTreeRow.shape.criteria.shape.parent.nullable() }).nullable(),
150
+ parent: generatedTreeRow.shape.parent.nullable()
151
+ });
152
+ var ReferenceGenrePlaylistSchema = z6.array(ReferenceGenrePlaylistRowSchema).superRefine((playlists, ctx) => {
153
+ playlists.forEach((playlist, index) => {
154
+ checkGenreCounts(playlist, [index], ctx);
155
+ checkGenreCounts(playlist.catalogue, [index, "catalogue"], ctx);
156
+ });
157
+ }).transform((playlists, ctx) => {
158
+ const branded = z6.array(CriteriaPlaylistSimpleSchema).safeParse(playlists);
159
+ if (branded.success) return branded.data;
160
+ for (const issue of branded.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
161
+ return z6.NEVER;
216
162
  });
217
163
 
218
164
  // src/genre-tree/useGenre.ts
@@ -220,7 +166,7 @@ import { useQuery, useQueryClient as useQueryClient2 } from "@tanstack/react-que
220
166
  import { useCallback } from "react";
221
167
 
222
168
  // src/genre-tree/useGenrePlaylist.ts
223
- import { z as z13 } from "zod";
169
+ import { z as z7 } from "zod";
224
170
  import { useQueryClient } from "@tanstack/react-query";
225
171
 
226
172
  // src/genre-tree/api/genre-playlists/queryKeys.ts
@@ -260,13 +206,13 @@ var genrePlaylistEndpoints = {
260
206
 
261
207
  // src/genre-tree/lib/genre-music-selection.ts
262
208
  function defaultGenreMusicSelection(counts) {
263
- return { coverage: "genreAndSubgenres", subgenres: "canonical" in counts.genreAndSubgenresTracksCount ? "canonical" : "all" };
209
+ return { coverage: "genreAndSubgenres", subgenres: "global" in counts.genreAndSubgenresTracksCount ? "global" : "all" };
264
210
  }
265
211
  function genreMusicCount(counts, selection = defaultGenreMusicSelection(counts)) {
266
212
  if (selection.coverage === "genreOnly") return counts.genreOnlyTracksCount;
267
213
  const scopes = counts.genreAndSubgenresTracksCount;
268
214
  if (selection.subgenres === "all") return scopes.all;
269
- if (!("canonical" in scopes)) throw new Error("Regional genres only support all subgenres");
215
+ if (!("global" in scopes)) throw new Error("Regional genres only support all subgenres");
270
216
  return scopes[selection.subgenres];
271
217
  }
272
218
  function genreMusicQueryParams(selection) {
@@ -363,16 +309,16 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
363
309
  const queryKey = scope === "reference" ? [...genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()), "genreMusicV1"] : genrePlaylistQueryKeys.me.full;
364
310
  const query = useQueryWithParse({
365
311
  queryKey,
366
- queryFn: () => scope === "reference" ? fetch(genrePlaylistEndpoints.reference.tree(), true, false, {}, { treeName: "canonical" }) : fetchAllPages(
312
+ queryFn: () => scope === "reference" ? fetch(genrePlaylistEndpoints.reference.tree(), true, false, {}, { treeName: "global" }) : fetchAllPages(
367
313
  (page) => fetch(
368
314
  genrePlaylistEndpoints.me.list(),
369
315
  true,
370
316
  true,
371
317
  {},
372
- { page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "canonical" }
318
+ { page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "global" }
373
319
  )
374
320
  ),
375
- schema: scope === "reference" ? z13.array(ReferenceGenrePlaylistSchema) : z13.array(CriteriaPlaylistSimpleSchema),
321
+ schema: scope === "reference" ? ReferenceGenrePlaylistSchema : z7.array(CriteriaPlaylistSimpleSchema),
376
322
  context: "useListFullGenrePlaylists",
377
323
  enabled: scope === "reference" || sessionRestored && !!session?.accessToken
378
324
  });
@@ -405,62 +351,146 @@ var useInvalidateAllGenrePlaylistQueries = () => {
405
351
  ]);
406
352
  };
407
353
 
354
+ // src/genre-tree/schemas/criteria/detailed.ts
355
+ import { z as z14 } from "zod";
356
+
357
+ // src/genre-tree/schemas/track/base.ts
358
+ import { z as z11 } from "zod";
359
+
360
+ // src/genre-tree/schemas/artist-minimum.ts
361
+ import { z as z8 } from "zod";
362
+ var ArtistMinimumSchema = z8.object({
363
+ uuid: z8.string().uuid(),
364
+ name: z8.string(),
365
+ isSpecialPurpose: z8.boolean().optional()
366
+ });
367
+
368
+ // src/genre-tree/schemas/album-minimum.ts
369
+ import { z as z9 } from "zod";
370
+ var AlbumMinimumSchema = z9.object({
371
+ uuid: z9.string().uuid(),
372
+ name: z9.string(),
373
+ albumArtists: z9.array(ArtistMinimumSchema).nullable().optional()
374
+ });
375
+
376
+ // src/genre-tree/schemas/uuid-resource.ts
377
+ import { z as z10 } from "zod";
378
+ var UuidResourceSchema = z10.object({
379
+ uuid: z10.string().uuid()
380
+ });
381
+
382
+ // src/genre-tree/schemas/track/base.ts
383
+ var TrackBaseSchema = UuidResourceSchema.extend({
384
+ title: z11.string(),
385
+ artists: z11.array(ArtistMinimumSchema).nullable().optional(),
386
+ album: AlbumMinimumSchema.nullable().optional(),
387
+ trackNumber: z11.number().nullable().optional(),
388
+ // null for a song not yet linked to a genre.
389
+ genre: CriteriaMinimumSchema.nullable(),
390
+ rating: z11.number().min(0).max(10).nullable().optional(),
391
+ language: z11.string().nullable().optional(),
392
+ playCount: z11.number().min(0),
393
+ createdOn: z11.string().datetime(),
394
+ updatedOn: z11.string().datetime().nullable().optional()
395
+ });
396
+
397
+ // src/genre-tree/schemas/track/minimum.ts
398
+ var TrackMinimumSchema = TrackBaseSchema.pick({
399
+ uuid: true,
400
+ title: true,
401
+ artists: true
402
+ });
403
+
404
+ // src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
405
+ import { z as z12 } from "zod";
406
+ var CriteriaLineageRelWithoutAscendantSchema = z12.object({
407
+ descendant: CriteriaMinimumSchema,
408
+ degree: z12.number()
409
+ });
410
+
411
+ // src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
412
+ import { z as z13 } from "zod";
413
+ var CriteriaLineageRelWithoutDescendantSchema = z13.object({
414
+ ascendant: CriteriaMinimumSchema,
415
+ degree: z13.number()
416
+ });
417
+
418
+ // src/genre-tree/schemas/criteria/detailed.ts
419
+ var CriteriaDetailedSchema = z14.object({
420
+ uuid: GenreUuidSchema,
421
+ name: z14.string(),
422
+ summary: z14.string().nullable(),
423
+ // Optional until every deployed API serves it.
424
+ wikidataId: z14.string().nullable().optional(),
425
+ parent: CriteriaMinimumSchema.nullable(),
426
+ ascendants: z14.array(CriteriaLineageRelWithoutDescendantSchema),
427
+ descendants: z14.array(CriteriaLineageRelWithoutAscendantSchema).optional(),
428
+ root: CriteriaMinimumSchema,
429
+ children: z14.array(CriteriaMinimumSchema),
430
+ catalogue: GenreCatalogueCountsSchema.optional(),
431
+ criteriaPlaylist: z14.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]).nullable(),
432
+ tracks: z14.array(TrackMinimumSchema).optional(),
433
+ essentialSongs: z14.array(TrackMinimumSchema),
434
+ tracksCount: z14.number(),
435
+ updatedOn: z14.string().datetime().nullable()
436
+ });
437
+
408
438
  // src/genre-tree/schemas/criteria/overview.ts
409
- import { z as z16 } from "zod";
439
+ import { z as z17 } from "zod";
410
440
 
411
441
  // src/genre-tree/schemas/commons-image.ts
412
- import { z as z15 } from "zod";
442
+ import { z as z16 } from "zod";
413
443
 
414
444
  // src/genre-tree/schemas/http-url.ts
415
- import { z as z14 } from "zod";
416
- var HttpUrlSchema = z14.url({ protocol: /^https?$/ });
445
+ import { z as z15 } from "zod";
446
+ var HttpUrlSchema = z15.url({ protocol: /^https?$/ });
417
447
 
418
448
  // src/genre-tree/schemas/commons-image.ts
419
- var CommonsImageSchema = z15.object({
449
+ var CommonsImageSchema = z16.object({
420
450
  url: HttpUrlSchema,
421
451
  pageUrl: HttpUrlSchema,
422
- author: z15.string().nullable(),
423
- license: z15.string(),
452
+ author: z16.string().nullable(),
453
+ license: z16.string(),
424
454
  licenseUrl: HttpUrlSchema.nullable()
425
455
  });
426
456
 
427
457
  // src/genre-tree/schemas/criteria/overview.ts
428
- var CriteriaOverviewSchema = z16.object({
458
+ var CriteriaOverviewSchema = z17.object({
429
459
  uuid: GenreUuidSchema,
430
- name: z16.string(),
431
- summary: z16.string().nullable(),
432
- description: z16.string().nullable(),
460
+ name: z17.string(),
461
+ summary: z17.string().nullable(),
462
+ description: z17.string().nullable(),
433
463
  summarySourceUrl: HttpUrlSchema.nullable(),
434
464
  // Optional: hosts whose API does not send it (e.g. hear) stay valid.
435
465
  image: CommonsImageSchema.nullable().optional(),
436
- essentialSongs: z16.array(TrackMinimumSchema).optional()
466
+ essentialSongs: z17.array(TrackMinimumSchema).optional()
437
467
  });
438
468
 
439
469
  // src/genre-tree/schemas/criteria/simple.ts
440
- import { z as z17 } from "zod";
441
- var CriteriaSimpleSchema = z17.object({
470
+ import { z as z18 } from "zod";
471
+ var CriteriaSimpleSchema = z18.object({
442
472
  uuid: GenreUuidSchema,
443
- name: z17.string(),
473
+ name: z18.string(),
444
474
  parent: CriteriaMinimumSchema.nullable(),
445
- createdOn: z17.string().datetime(),
446
- summary: z17.string().nullable()
475
+ createdOn: z18.string().datetime(),
476
+ summary: z18.string().nullable()
447
477
  });
448
478
 
449
479
  // src/genre-tree/schemas/criteria/creation.ts
450
- import { z as z18 } from "zod";
451
- var CriteriaCreationSchema = z18.object({
452
- name: z18.string().min(1, "Name is required"),
480
+ import { z as z19 } from "zod";
481
+ var CriteriaCreationSchema = z19.object({
482
+ name: z19.string().min(1, "Name is required"),
453
483
  parent: GenreUuidSchema.optional(),
454
- essentialSongs: z18.array(z18.string().uuid()).optional()
484
+ essentialSongs: z19.array(z19.string().uuid()).optional()
455
485
  });
456
486
 
457
487
  // src/genre-tree/schemas/criteria/update.ts
458
- import { z as z19 } from "zod";
459
- var CriteriaUpdateSchema = z19.object({
460
- name: z19.string().optional(),
488
+ import { z as z20 } from "zod";
489
+ var CriteriaUpdateSchema = z20.object({
490
+ name: z20.string().optional(),
461
491
  parent: GenreUuidSchema.nullable().optional(),
462
- essentialSongs: z19.array(z19.string().uuid()).optional(),
463
- side: z19.enum(["core", "pop"]).optional()
492
+ essentialSongs: z20.array(z20.string().uuid()).optional(),
493
+ side: z20.enum(["core", "pop"]).optional()
464
494
  });
465
495
 
466
496
  // src/genre-tree/api/genres/queryKeys.ts
@@ -503,6 +533,9 @@ var genreEndpoints = {
503
533
  };
504
534
 
505
535
  // src/genre-tree/useGenre.ts
536
+ function schemaForScope(scope, reference, me) {
537
+ return scope === "reference" ? reference : me;
538
+ }
506
539
  function useListGenres(page = 1, pageSize = 50, scope, getBackendBaseUrl) {
507
540
  const { fetch } = useFetchWrapper(getBackendBaseUrl);
508
541
  const { session, sessionRestored } = useSession();
@@ -510,7 +543,7 @@ function useListGenres(page = 1, pageSize = 50, scope, getBackendBaseUrl) {
510
543
  return useQueryWithParse({
511
544
  queryKey: scope === "reference" ? genreQueryKeys.reference.list(page) : genreQueryKeys.me.list(page),
512
545
  queryFn: () => fetch(endpoint, true, scope === "me", {}, { page, pageSize }),
513
- schema: PaginatedResponseSchema(CriteriaSimpleSchema),
546
+ schema: schemaForScope(scope, zV1GenresListResponse, PaginatedResponseSchema(CriteriaSimpleSchema)),
514
547
  context: "useListGenres",
515
548
  enabled: scope === "reference" || sessionRestored && !!session?.accessToken
516
549
  });
@@ -521,12 +554,12 @@ function useFetchGenre(scope, getBackendBaseUrl) {
521
554
  async (id) => {
522
555
  const endpoint = scope === "reference" ? genreEndpoints.reference.detail(id) : genreEndpoints.me.detail(id);
523
556
  const response = await fetch(endpoint, true, scope === "me");
524
- return parseWithLog(scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema, response, "useFetchGenre");
557
+ return parseWithLog(schemaForScope(scope, ReferenceGenreDetailedSchema, CriteriaDetailedSchema), response, "useFetchGenre");
525
558
  },
526
559
  [fetch, scope]
527
560
  );
528
561
  }
529
- function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema) {
562
+ function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = schemaForScope(scope, ReferenceGenreDetailedSchema, CriteriaDetailedSchema)) {
530
563
  const { fetch } = useFetchWrapper(getBackendBaseUrl);
531
564
  const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
532
565
  const endpoints = scope === "reference" ? genreEndpoints.reference : genreEndpoints.me;
@@ -543,7 +576,6 @@ function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = scope === "r
543
576
  const result = toResourceResult({ id, isValidId: validUuid !== null, data, error, isPending });
544
577
  return result.status === "success" ? { status: "success", genre: result.data } : result;
545
578
  }
546
- var GenreByWikidataIdSchema = PaginatedResponseSchema(CriteriaMinimumSchema);
547
579
  function useGenreByWikidataId(qid, scope, getBackendBaseUrl) {
548
580
  const { fetch } = useFetchWrapper(getBackendBaseUrl);
549
581
  const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
@@ -551,12 +583,13 @@ function useGenreByWikidataId(qid, scope, getBackendBaseUrl) {
551
583
  const { data, ...rest } = useQueryWithParse({
552
584
  queryKey: queryKeys.byWikidataId(qid ?? ""),
553
585
  queryFn: () => fetch(endpoints.list(), true, scope === "me", {}, { wikidataId: qid ?? "", pageSize: 1 }),
554
- schema: GenreByWikidataIdSchema,
586
+ schema: schemaForScope(scope, zV1GenresListResponse, PaginatedResponseSchema(CriteriaMinimumSchema)),
555
587
  context: "useGenreByWikidataId",
556
588
  enabled: qid !== null
557
589
  });
558
590
  return { ...rest, data: data === void 0 ? void 0 : data.results[0] ?? null };
559
591
  }
592
+ var defaultOverviewSchema = (scope) => schemaForScope(scope, zV1GenresOverviewRetrieveResponse, CriteriaOverviewSchema);
560
593
  var GENRE_OVERVIEW_STALE_TIME_MS = 6e4;
561
594
  function useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema) {
562
595
  const { fetch } = useFetchWrapper(getBackendBaseUrl);
@@ -574,11 +607,11 @@ function useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema) {
574
607
  [fetch, scope, schema]
575
608
  );
576
609
  }
577
- function useFetchGenreOverview(id, scope, getBackendBaseUrl, schema = CriteriaOverviewSchema) {
610
+ function useFetchGenreOverview(id, scope, getBackendBaseUrl, schema = defaultOverviewSchema(scope)) {
578
611
  const queryOptions = useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema);
579
612
  return useQuery({ ...queryOptions(id ?? ""), enabled: id !== null });
580
613
  }
581
- function usePrefetchGenreOverview(scope, getBackendBaseUrl, schema = CriteriaOverviewSchema) {
614
+ function usePrefetchGenreOverview(scope, getBackendBaseUrl, schema = defaultOverviewSchema(scope)) {
582
615
  const queryClient = useQueryClient2();
583
616
  const queryOptions = useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema);
584
617
  return useCallback((id) => queryClient.prefetchQuery(queryOptions(id)), [queryClient, queryOptions]);
@@ -620,7 +653,7 @@ function useUpdateGenre(scope, getBackendBaseUrl) {
620
653
  const refreshGenreTree = useRefreshGenreTree(scope);
621
654
  const { fetch } = useFetchWrapper(getBackendBaseUrl);
622
655
  const { mutate, mutateAsync, isPending, formErrors } = useValidatedMutation({
623
- inputSchema: z20.object({
656
+ inputSchema: z21.object({
624
657
  uuid: GenreUuidSchema,
625
658
  data: CriteriaUpdateSchema
626
659
  }),
@@ -650,8 +683,8 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
650
683
  const refreshGenreTree = useRefreshGenreTree(scope);
651
684
  const { fetch } = useFetchWrapper(getBackendBaseUrl);
652
685
  return useValidatedMutation({
653
- inputSchema: z20.object({ uuid: GenreUuidSchema }),
654
- outputSchema: z20.null(),
686
+ inputSchema: z21.object({ uuid: GenreUuidSchema }),
687
+ outputSchema: z21.null(),
655
688
  mutationFn: async ({ uuid }) => {
656
689
  const endpoint = scope === "reference" ? genreEndpoints.reference.delete(uuid) : genreEndpoints.me.delete(uuid);
657
690
  return fetch(endpoint, true, scope === "me", { method: "DELETE" }, void 0, false, true);
@@ -660,14 +693,18 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
660
693
  });
661
694
  }
662
695
 
696
+ // src/genre-tree/schemas/reference-artist.ts
697
+ import { z as z24 } from "zod";
698
+ import { zV1ArtistsRetrieveResponse, zV1ArtistsGenreCountsListResponse } from "@behindthemusictree/grow-api";
699
+
663
700
  // src/genre-tree/schemas/artist-detailed.ts
664
- import { z as z21 } from "zod";
665
- var ArtistMembershipSchema = z21.object({
701
+ import { z as z22 } from "zod";
702
+ var ArtistMembershipSchema = z22.object({
666
703
  artist: ArtistMinimumSchema,
667
- beginYear: z21.number().int().nullable(),
668
- endYear: z21.number().int().nullable(),
669
- ended: z21.boolean(),
670
- roles: z21.array(z21.string())
704
+ beginYear: z22.number().int().nullable(),
705
+ endYear: z22.number().int().nullable(),
706
+ ended: z22.boolean(),
707
+ roles: z22.array(z22.string())
671
708
  });
672
709
  var ARTIST_LINK_KINDS = [
673
710
  "official",
@@ -681,42 +718,75 @@ var ARTIST_LINK_KINDS = [
681
718
  "social"
682
719
  ];
683
720
  var ArtistImageSchema = CommonsImageSchema;
684
- var ArtistOriginSchema = z21.object({
685
- name: z21.string(),
686
- kind: z21.string().nullable(),
687
- source: z21.enum(["begin_area", "area"]),
688
- wikidataId: z21.string().nullable(),
689
- longitude: z21.number().nullable(),
690
- latitude: z21.number().nullable(),
691
- regionId: z21.string().nullable()
721
+ var ArtistOriginSchema = z22.object({
722
+ name: z22.string(),
723
+ kind: z22.string().nullable(),
724
+ source: z22.enum(["begin_area", "area"]),
725
+ wikidataId: z22.string().nullable(),
726
+ longitude: z22.number().nullable(),
727
+ latitude: z22.number().nullable(),
728
+ regionId: z22.string().nullable()
692
729
  });
693
- var ArtistDetailedSchema = z21.object({
694
- uuid: z21.string().uuid(),
695
- name: z21.string(),
696
- musicbrainzArtistId: z21.string().uuid().nullable(),
697
- type: z21.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
698
- country: z21.string().nullable(),
699
- beginYear: z21.number().int().nullable(),
700
- endYear: z21.number().int().nullable(),
701
- ended: z21.boolean(),
702
- links: z21.array(z21.object({ kind: z21.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
703
- members: z21.array(ArtistMembershipSchema),
704
- memberOf: z21.array(ArtistMembershipSchema),
705
- albums: z21.array(
706
- z21.object({
707
- uuid: z21.string().uuid(),
708
- name: z21.string(),
709
- year: z21.string().nullable(),
710
- primaryType: z21.string().nullable(),
711
- secondaryTypes: z21.array(z21.string())
730
+ var ArtistDetailedSchema = z22.object({
731
+ uuid: z22.string().uuid(),
732
+ name: z22.string(),
733
+ musicbrainzArtistId: z22.string().uuid().nullable(),
734
+ type: z22.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
735
+ country: z22.string().nullable(),
736
+ beginYear: z22.number().int().nullable(),
737
+ endYear: z22.number().int().nullable(),
738
+ ended: z22.boolean(),
739
+ links: z22.array(z22.object({ kind: z22.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
740
+ members: z22.array(ArtistMembershipSchema),
741
+ memberOf: z22.array(ArtistMembershipSchema),
742
+ albums: z22.array(
743
+ z22.object({
744
+ uuid: z22.string().uuid(),
745
+ name: z22.string(),
746
+ year: z22.string().nullable(),
747
+ primaryType: z22.string().nullable(),
748
+ secondaryTypes: z22.array(z22.string())
712
749
  })
713
750
  ),
714
- tracksCount: z21.number().int(),
715
- playableTracksCount: z21.number().int(),
751
+ tracksCount: z22.number().int(),
752
+ playableTracksCount: z22.number().int(),
716
753
  image: ArtistImageSchema.nullable(),
717
754
  origin: ArtistOriginSchema.nullable()
718
755
  });
719
756
 
757
+ // src/genre-tree/schemas/artist-genre-count.ts
758
+ import { z as z23 } from "zod";
759
+ var ArtistGenreCountSchema = z23.object({
760
+ ...GenreCountsSchema.shape,
761
+ catalogue: GenreCatalogueCountsSchema,
762
+ genrePlaylist: GenrePlaylistUuidSchema,
763
+ /** Legacy catalogue count for the default selection. */
764
+ songsCount: z23.number().int().nonnegative(),
765
+ /** Legacy playlist count for the default selection. */
766
+ tracksCount: z23.number().int().nonnegative()
767
+ }).superRefine((row, ctx) => {
768
+ const counts = GenreCatalogueCountsSchema.safeParse(row);
769
+ if (!counts.success) {
770
+ for (const issue of counts.error.issues) {
771
+ ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
772
+ }
773
+ }
774
+ });
775
+
776
+ // src/genre-tree/schemas/reference-artist.ts
777
+ function intoUiShape(target) {
778
+ return (value, ctx) => {
779
+ const parsed = target.safeParse(value);
780
+ if (parsed.success) return parsed.data;
781
+ for (const issue of parsed.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
782
+ return z24.NEVER;
783
+ };
784
+ }
785
+ var ReferenceArtistSchema = zV1ArtistsRetrieveResponse.transform(intoUiShape(ArtistDetailedSchema));
786
+ var ReferenceArtistGenreCountsSchema = zV1ArtistsGenreCountsListResponse.transform(
787
+ intoUiShape(z24.array(ArtistGenreCountSchema))
788
+ );
789
+
720
790
  // src/genre-tree/api/artists/queryKeys.ts
721
791
  var artistQueryKeys = {
722
792
  search: (query) => ["artistSearch", query],
@@ -740,7 +810,7 @@ function useArtist(uuid, getBackendBaseUrl) {
740
810
  const { data, isPending, error } = useQueryWithParse({
741
811
  queryKey: artistQueryKeys.detail(id),
742
812
  queryFn: () => fetch(artistEndpoints.detail(id), true, false),
743
- schema: ArtistDetailedSchema,
813
+ schema: ReferenceArtistSchema,
744
814
  enabled: isUuid,
745
815
  retry: resourceRetry,
746
816
  context: "useArtist"
@@ -749,20 +819,8 @@ function useArtist(uuid, getBackendBaseUrl) {
749
819
  return result.status === "success" ? { status: "success", artist: result.data } : result;
750
820
  }
751
821
 
752
- // src/genre-tree/schemas/artist-search.ts
753
- import { z as z22 } from "zod";
754
- var ArtistSearchResultSchema = z22.object({
755
- uuid: z22.string().uuid(),
756
- name: z22.string(),
757
- disambiguation: z22.string().nullable(),
758
- type: z22.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
759
- country: z22.string().nullable(),
760
- beginYear: z22.number().int().nullable(),
761
- endYear: z22.number().int().nullable(),
762
- matchedAlias: z22.string().nullable(),
763
- recordingCount: z22.number().int()
764
- });
765
- var ArtistSearchResultsSchema = z22.array(ArtistSearchResultSchema);
822
+ // src/genre-tree/useArtistSearch.ts
823
+ import { zV1ArtistsSearchListResponse } from "@behindthemusictree/grow-api";
766
824
 
767
825
  // src/genre-tree/useRemoteSearch.ts
768
826
  import { keepPreviousData } from "@tanstack/react-query";
@@ -809,15 +867,19 @@ function useArtistSearch(getBackendBaseUrl, text) {
809
867
  queryKey: artistQueryKeys.search,
810
868
  endpoint: artistEndpoints.search(),
811
869
  params: (q) => ({ q, limit: RESULT_LIMIT }),
812
- schema: ArtistSearchResultsSchema,
870
+ schema: zV1ArtistsSearchListResponse,
813
871
  context: "useArtistSearch",
814
872
  text
815
873
  });
816
874
  return { artists: results, isError, settled, pending };
817
875
  }
818
876
 
877
+ // src/genre-tree/schemas/reference-song.ts
878
+ import { z as z26 } from "zod";
879
+ import { zV1LibrarySongsRetrieveResponse } from "@behindthemusictree/grow-api";
880
+
819
881
  // src/genre-tree/schemas/song/detailed.ts
820
- import { z as z23 } from "zod";
882
+ import { z as z25 } from "zod";
821
883
  var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
822
884
  not_found: "Video unavailable",
823
885
  not_embeddable: "Embedding disabled",
@@ -826,23 +888,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
826
888
  region_whitelisted: "Region restricted"
827
889
  };
828
890
  var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
829
- var YoutubeAvailabilitySchema = z23.object({
830
- status: z23.enum(["eligible", "blocked", "unknown"]),
831
- reason: z23.string().nullable(),
832
- country: z23.string().nullable()
891
+ var YoutubeAvailabilitySchema = z25.object({
892
+ status: z25.enum(["eligible", "blocked", "unknown"]),
893
+ reason: z25.string().nullable(),
894
+ country: z25.string().nullable()
833
895
  });
834
896
  var SongDetailedSchema = TrackBaseSchema.extend({
835
- youtubeVideo: z23.object({
836
- id: z23.string(),
897
+ youtubeVideo: z25.object({
898
+ id: z25.string(),
837
899
  availability: YoutubeAvailabilitySchema.optional(),
838
900
  // null = playable
839
- unplayableReason: z23.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
840
- viewCount: z23.number().int().nullable().optional()
901
+ unplayableReason: z25.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
902
+ viewCount: z25.number().int().nullable().optional()
841
903
  }).nullable(),
842
904
  // null for hand-made/admin songs
843
- musicbrainzRecordingId: z23.string().uuid().nullable(),
844
- firstReleaseYear: z23.number().int().nullable().optional(),
845
- essentialGenres: z23.array(CriteriaMinimumSchema).optional()
905
+ musicbrainzRecordingId: z25.string().uuid().nullable(),
906
+ firstReleaseYear: z25.number().int().nullable().optional(),
907
+ essentialGenres: z25.array(CriteriaMinimumSchema).optional()
846
908
  });
847
909
  var NO_VIDEO_LABEL = "No video available";
848
910
  function isSong(track) {
@@ -858,6 +920,16 @@ function musicBrainzRecordingUrl(song) {
858
920
  return song.musicbrainzRecordingId ? `https://musicbrainz.org/recording/${song.musicbrainzRecordingId}` : null;
859
921
  }
860
922
 
923
+ // src/genre-tree/schemas/reference-song.ts
924
+ var ReferenceSongSchema = zV1LibrarySongsRetrieveResponse.extend({
925
+ album: zV1LibrarySongsRetrieveResponse.shape.album.nullable()
926
+ }).transform((song, ctx) => {
927
+ const branded = SongDetailedSchema.safeParse(song);
928
+ if (branded.success) return branded.data;
929
+ for (const issue of branded.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
930
+ return z26.NEVER;
931
+ });
932
+
861
933
  // src/genre-tree/useSong.ts
862
934
  function useSong(uuid, getBackendBaseUrl) {
863
935
  const id = toSongUuid(uuid);
@@ -866,7 +938,7 @@ function useSong(uuid, getBackendBaseUrl) {
866
938
  getBackendBaseUrl,
867
939
  queryKey: libraryQueryKeys.reference.songs.detail(id),
868
940
  queryFn: (fetchBound, { signal }) => fetchBound(libraryEndpoints.reference.songs.detail(id), true, false, { signal }),
869
- schema: SongDetailedSchema,
941
+ schema: ReferenceSongSchema,
870
942
  enabled: isUuid,
871
943
  retry: resourceRetry,
872
944
  context: "useSong"
@@ -875,19 +947,8 @@ function useSong(uuid, getBackendBaseUrl) {
875
947
  return result.status === "success" ? { status: "success", song: result.data } : result;
876
948
  }
877
949
 
878
- // src/genre-tree/schemas/song-history.ts
879
- import { z as z24 } from "zod";
880
- var SongHistoryEntrySchema = z24.object({
881
- uuid: z24.string().uuid(),
882
- action: z24.string(),
883
- actorPseudo: z24.string().nullable(),
884
- oldValue: z24.string().nullable(),
885
- newValue: z24.string().nullable(),
886
- createdOn: z24.string()
887
- });
888
- var SongHistorySchema = z24.array(SongHistoryEntrySchema);
889
-
890
950
  // src/genre-tree/useSongHistory.ts
951
+ import { zV1LibrarySongsHistoryListResponse } from "@behindthemusictree/grow-api";
891
952
  function useSongHistory(uuid, getBackendBaseUrl, enabled) {
892
953
  const id = toSongUuid(uuid);
893
954
  const active = enabled && id !== null;
@@ -895,7 +956,7 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
895
956
  getBackendBaseUrl,
896
957
  queryKey: libraryQueryKeys.reference.songs.history(id),
897
958
  queryFn: (fetchBound, { signal }) => fetchBound(libraryEndpoints.reference.songs.history(id), true, false, { signal }),
898
- schema: SongHistorySchema,
959
+ schema: zV1LibrarySongsHistoryListResponse,
899
960
  enabled: active,
900
961
  context: "useSongHistory"
901
962
  });
@@ -905,26 +966,8 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
905
966
  return { status: "success", entries: data };
906
967
  }
907
968
 
908
- // src/genre-tree/schemas/song-search.ts
909
- import { z as z25 } from "zod";
910
- var SongSearchResultSchema = z25.object({
911
- uuid: z25.string().uuid(),
912
- title: z25.string(),
913
- artists: z25.array(ArtistMinimumSchema),
914
- // null for songs not yet linked to a genre.
915
- genre: CriteriaMinimumSchema.nullable(),
916
- youtubeVideo: z25.object({
917
- id: z25.string(),
918
- unplayableReason: z25.string().nullable()
919
- }).nullable(),
920
- firstReleaseYear: z25.number().int().nullable()
921
- });
922
- var SongSearchResultsSchema = z25.array(SongSearchResultSchema);
923
- function isSongSearchResultPlayable(result) {
924
- return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
925
- }
926
-
927
969
  // src/genre-tree/useSongSearch.ts
970
+ import { zV1LibrarySongsSearchListResponse } from "@behindthemusictree/grow-api";
928
971
  var DEFAULT_RESULT_LIMIT = 8;
929
972
  function useSongSearch(getBackendBaseUrl, text, options = {}) {
930
973
  const playback = usePlaybackContext();
@@ -936,7 +979,7 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
936
979
  fetch: fetchBound,
937
980
  endpoint: libraryEndpoints.reference.songs.search(),
938
981
  params,
939
- schema: SongSearchResultsSchema,
982
+ schema: zV1LibrarySongsSearchListResponse,
940
983
  context: "useSongSearch",
941
984
  text,
942
985
  enabled: playback.ready,
@@ -947,35 +990,13 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
947
990
 
948
991
  // src/genre-tree/useArtistGenreCounts.ts
949
992
  import { keepPreviousData as keepPreviousData2 } from "@tanstack/react-query";
950
- import { z as z27 } from "zod";
951
-
952
- // src/genre-tree/schemas/artist-genre-count.ts
953
- import { z as z26 } from "zod";
954
- var ArtistGenreCountSchema = z26.object({
955
- ...GenreCountsSchema.shape,
956
- catalogue: GenreCatalogueCountsSchema,
957
- genrePlaylist: GenrePlaylistUuidSchema,
958
- /** Legacy catalogue count for the default selection. */
959
- songsCount: z26.number().int().nonnegative(),
960
- /** Legacy playlist count for the default selection. */
961
- tracksCount: z26.number().int().nonnegative()
962
- }).superRefine((row, ctx) => {
963
- const counts = GenreCatalogueCountsSchema.safeParse(row);
964
- if (!counts.success) {
965
- for (const issue of counts.error.issues) {
966
- ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
967
- }
968
- }
969
- });
970
-
971
- // src/genre-tree/useArtistGenreCounts.ts
972
993
  function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
973
994
  const { fetch } = useFetchWrapper(getBackendBaseUrl);
974
995
  const id = toArtistUuid(artistUuid);
975
996
  return useQueryWithParse({
976
997
  queryKey: [...artistQueryKeys.genreCounts(getBackendBaseUrl(), id), "genreMusicV1"],
977
998
  queryFn: () => fetch(artistEndpoints.genreCounts(id), true, false),
978
- schema: z27.array(ArtistGenreCountSchema),
999
+ schema: ReferenceArtistGenreCountsSchema,
979
1000
  enabled: id !== null,
980
1001
  placeholderData: keepPreviousData2,
981
1002
  retry: resourceRetry,
@@ -1134,35 +1155,8 @@ function useGenreSearch({
1134
1155
  };
1135
1156
  }
1136
1157
 
1137
- // src/genre-tree/schemas/genre-search.ts
1138
- import { z as z28 } from "zod";
1139
- var GenreSearchTreeNameSchema = z28.enum(["canonical", "regional"]);
1140
- var GenreSearchResultSchema = z28.object({
1141
- /** Criteria (genre) uuid. */
1142
- uuid: GenreUuidSchema,
1143
- name: z28.string(),
1144
- /** Null for app-created genres, which the Wikidata-keyed region index does not reference. */
1145
- wikidataId: z28.string().nullable(),
1146
- treeName: z28.string(),
1147
- /** Null when the genre has no playlist in the tree, so it cannot be opened there. */
1148
- genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
1149
- root: z28.object({ uuid: GenreUuidSchema, name: z28.string() }),
1150
- isUmbrella: z28.boolean(),
1151
- viewsCount: z28.number().int()
1152
- });
1153
- var GenreSearchResultsSchema = z28.array(GenreSearchResultSchema);
1154
- var RegionGenreLexiconEntrySchema = z28.object({
1155
- wikidataId: z28.string(),
1156
- uuid: GenreUuidSchema,
1157
- name: z28.string(),
1158
- treeName: z28.string(),
1159
- genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
1160
- isUmbrella: z28.boolean(),
1161
- viewsCount: z28.number().int()
1162
- });
1163
- var RegionGenreLexiconSchema = z28.array(RegionGenreLexiconEntrySchema);
1164
-
1165
1158
  // src/genre-tree/useGenreRemoteSearch.ts
1159
+ import { zV1GenresSearchListResponse } from "@behindthemusictree/grow-api";
1166
1160
  var DEFAULT_RESULT_LIMIT2 = 8;
1167
1161
  function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAULT_RESULT_LIMIT2, enabled } = {}) {
1168
1162
  const params = (q) => ({ q, limit, ...treeName && { treeName } });
@@ -1170,7 +1164,7 @@ function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAU
1170
1164
  queryKey: (q) => genreSearchQueryKeys.search(params(q)),
1171
1165
  endpoint: genreEndpoints.search(),
1172
1166
  params,
1173
- schema: GenreSearchResultsSchema,
1167
+ schema: zV1GenresSearchListResponse,
1174
1168
  context: "useGenreRemoteSearch",
1175
1169
  text,
1176
1170
  enabled
@@ -1179,13 +1173,14 @@ function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAU
1179
1173
  }
1180
1174
 
1181
1175
  // src/genre-tree/useRegionGenreLexicon.ts
1176
+ import { zRegionMapGenresResponse } from "@behindthemusictree/grow-api";
1182
1177
  var EMPTY_ENTRIES = [];
1183
1178
  function useRegionGenreLexicon(getBackendBaseUrl, enabled) {
1184
1179
  const { fetch } = useFetchWrapper(getBackendBaseUrl);
1185
1180
  const { data, isError, isPending } = useQueryWithParse({
1186
1181
  queryKey: genreSearchQueryKeys.regionLexicon(),
1187
1182
  queryFn: ({ signal }) => fetch(genreEndpoints.regionLexicon(), true, false, { signal }),
1188
- schema: RegionGenreLexiconSchema,
1183
+ schema: zRegionMapGenresResponse,
1189
1184
  context: "useRegionGenreLexicon",
1190
1185
  enabled,
1191
1186
  staleTime: Infinity
@@ -1201,7 +1196,7 @@ import { useCallback as useCallback2, useEffect as useEffect2, useMemo as useMem
1201
1196
  import { useMemo as useMemo2 } from "react";
1202
1197
 
1203
1198
  // src/genre-tree/lib/project-genre-playlists-for-artist.ts
1204
- var ZERO_SCOPED = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { canonical: 0, regional: 0, all: 0 } };
1199
+ var ZERO_SCOPED = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { global: 0, regional: 0, all: 0 } };
1205
1200
  var ZERO_ALL = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { all: 0 } };
1206
1201
  var ZERO_SCOPED_CATALOGUE = GenreCatalogueCountsSchema.parse(ZERO_SCOPED);
1207
1202
  var ZERO_ALL_CATALOGUE = GenreCatalogueCountsSchema.parse(ZERO_ALL);
@@ -1225,7 +1220,7 @@ var projectGenrePlaylistsForArtist = (playlists, counts) => {
1225
1220
  }
1226
1221
  const scopes = playlist.genreAndSubgenresTracksCount;
1227
1222
  if (!scopes) throw new Error(`Artist projections require a reference genre summary (genre playlist ${playlist.uuid})`);
1228
- const isScoped = "canonical" in scopes;
1223
+ const isScoped = "global" in scopes;
1229
1224
  return {
1230
1225
  ...playlist,
1231
1226
  ...isScoped ? ZERO_SCOPED : ZERO_ALL,
@@ -1383,10 +1378,10 @@ function useGenreTreeViewState({
1383
1378
  import { createContext as createContext2, useState as useState5, useContext as useContext2, useCallback as useCallback4, useEffect as useEffect3, useMemo as useMemo5, useRef as useRef3 } from "react";
1384
1379
 
1385
1380
  // src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
1386
- import { z as z29 } from "zod";
1387
- var makeTrackPlaylistRelSchema = (trackSchema) => z29.object({
1381
+ import { z as z27 } from "zod";
1382
+ var makeTrackPlaylistRelSchema = (trackSchema) => z27.object({
1388
1383
  track: trackSchema,
1389
- position: z29.number().min(0)
1384
+ position: z27.number().min(0)
1390
1385
  });
1391
1386
  var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
1392
1387
 
@@ -2030,25 +2025,30 @@ function ArtistNames({
2030
2025
  ] }, artist.uuid)) });
2031
2026
  }
2032
2027
 
2028
+ // src/genre-tree/schemas/reference.ts
2029
+ function isSongSearchResultPlayable(result) {
2030
+ return result.youtubeVideo.unplayableReason === null;
2031
+ }
2032
+
2033
2033
  // src/genre-tree/schemas/mb-artist.ts
2034
- import { z as z30 } from "zod";
2035
- var MbArtistDetailedSchema = z30.object({
2036
- musicbrainzId: z30.string().uuid(),
2037
- name: z30.string(),
2034
+ import { z as z28 } from "zod";
2035
+ var MbArtistDetailedSchema = z28.object({
2036
+ musicbrainzId: z28.string().uuid(),
2037
+ name: z28.string(),
2038
2038
  musicbrainzLink: HttpUrlSchema
2039
2039
  });
2040
2040
 
2041
2041
  // src/genre-tree/schemas/mb-recording.ts
2042
- import { z as z31 } from "zod";
2043
- var MbRecordingDetailedSchema = z31.object({
2044
- musicbrainzId: z31.string().uuid(),
2045
- title: z31.string(),
2046
- score: z31.number(),
2047
- musicbrainzArtists: z31.array(MbArtistDetailedSchema),
2042
+ import { z as z29 } from "zod";
2043
+ var MbRecordingDetailedSchema = z29.object({
2044
+ musicbrainzId: z29.string().uuid(),
2045
+ title: z29.string(),
2046
+ score: z29.number(),
2047
+ musicbrainzArtists: z29.array(MbArtistDetailedSchema),
2048
2048
  musicbrainzLink: HttpUrlSchema,
2049
- durationInSec: z31.number().min(0).nullable().optional(),
2050
- durationStrInHourMinSec: z31.string().nullable().optional(),
2051
- releaseDate: z31.union([z31.string().datetime(), z31.string()]).transform((val) => {
2049
+ durationInSec: z29.number().min(0).nullable().optional(),
2050
+ durationStrInHourMinSec: z29.string().nullable().optional(),
2051
+ releaseDate: z29.union([z29.string().datetime(), z29.string()]).transform((val) => {
2052
2052
  try {
2053
2053
  const date = new Date(val);
2054
2054
  if (isNaN(date.getTime())) {
@@ -2125,14 +2125,6 @@ export {
2125
2125
  GenreCoverageSchema,
2126
2126
  SubgenreScopeSchema,
2127
2127
  CriteriaMinimumSchema,
2128
- ArtistMinimumSchema,
2129
- AlbumMinimumSchema,
2130
- UuidResourceSchema,
2131
- TrackBaseSchema,
2132
- TrackMinimumSchema,
2133
- CriteriaLineageRelWithoutAscendantSchema,
2134
- CriteriaLineageRelWithoutDescendantSchema,
2135
- CriteriaDetailedSchema,
2136
2128
  CriteriaPlaylistDetailedSchema,
2137
2129
  CriteriaPlaylistSimpleSchema,
2138
2130
  ReferenceGenreDetailedSchema,
@@ -2150,6 +2142,14 @@ export {
2150
2142
  useListFullGenrePlaylists,
2151
2143
  useFetchGenrePlaylist,
2152
2144
  useInvalidateAllGenrePlaylistQueries,
2145
+ ArtistMinimumSchema,
2146
+ AlbumMinimumSchema,
2147
+ UuidResourceSchema,
2148
+ TrackBaseSchema,
2149
+ TrackMinimumSchema,
2150
+ CriteriaLineageRelWithoutAscendantSchema,
2151
+ CriteriaLineageRelWithoutDescendantSchema,
2152
+ CriteriaDetailedSchema,
2153
2153
  CommonsImageSchema,
2154
2154
  CriteriaOverviewSchema,
2155
2155
  CriteriaSimpleSchema,
@@ -2172,11 +2172,10 @@ export {
2172
2172
  ArtistImageSchema,
2173
2173
  ArtistOriginSchema,
2174
2174
  ArtistDetailedSchema,
2175
+ ArtistGenreCountSchema,
2175
2176
  artistQueryKeys,
2176
2177
  artistEndpoints,
2177
2178
  useArtist,
2178
- ArtistSearchResultSchema,
2179
- ArtistSearchResultsSchema,
2180
2179
  SEARCH_DEBOUNCE_MS,
2181
2180
  SEARCH_QUERY_MIN_LENGTH,
2182
2181
  useRemoteSearch,
@@ -2189,14 +2188,8 @@ export {
2189
2188
  songUnplayableReason,
2190
2189
  musicBrainzRecordingUrl,
2191
2190
  useSong,
2192
- SongHistoryEntrySchema,
2193
- SongHistorySchema,
2194
2191
  useSongHistory,
2195
- SongSearchResultSchema,
2196
- SongSearchResultsSchema,
2197
- isSongSearchResultPlayable,
2198
2192
  useSongSearch,
2199
- ArtistGenreCountSchema,
2200
2193
  useArtistGenreCounts,
2201
2194
  foldSearchText,
2202
2195
  trigramSimilarity,
@@ -2206,11 +2199,6 @@ export {
2206
2199
  rankNameIndex,
2207
2200
  useSearchQueryState,
2208
2201
  useGenreSearch,
2209
- GenreSearchTreeNameSchema,
2210
- GenreSearchResultSchema,
2211
- GenreSearchResultsSchema,
2212
- RegionGenreLexiconEntrySchema,
2213
- RegionGenreLexiconSchema,
2214
2202
  useGenreRemoteSearch,
2215
2203
  useRegionGenreLexicon,
2216
2204
  projectGenrePlaylistsForArtist,
@@ -2237,6 +2225,7 @@ export {
2237
2225
  TrackListProvider,
2238
2226
  useTrackList,
2239
2227
  ArtistNames,
2228
+ isSongSearchResultPlayable,
2240
2229
  MbArtistDetailedSchema,
2241
2230
  MbRecordingDetailedSchema,
2242
2231
  FORM_RATING_NULL_VALUE,
@@ -2246,4 +2235,4 @@ export {
2246
2235
  getReparentCandidates,
2247
2236
  editGenreSongPages
2248
2237
  };
2249
- //# sourceMappingURL=chunk-FOSFVEVR.js.map
2238
+ //# sourceMappingURL=chunk-S7GWIIHJ.js.map