@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.
package/dist/index.cjs CHANGED
@@ -31,8 +31,6 @@ __export(src_exports, {
31
31
  ArtistMinimumSchema: () => ArtistMinimumSchema,
32
32
  ArtistNames: () => ArtistNames,
33
33
  ArtistOriginSchema: () => ArtistOriginSchema,
34
- ArtistSearchResultSchema: () => ArtistSearchResultSchema,
35
- ArtistSearchResultsSchema: () => ArtistSearchResultsSchema,
36
34
  ArtistUuidSchema: () => ArtistUuidSchema,
37
35
  AudioMediaController: () => AudioMediaController,
38
36
  AuthRequired: () => AuthRequired,
@@ -65,9 +63,6 @@ __export(src_exports, {
65
63
  GenreCoverageSchema: () => GenreCoverageSchema,
66
64
  GenrePlaylistSummarySchema: () => GenrePlaylistSummarySchema,
67
65
  GenrePlaylistUuidSchema: () => GenrePlaylistUuidSchema,
68
- GenreSearchResultSchema: () => GenreSearchResultSchema,
69
- GenreSearchResultsSchema: () => GenreSearchResultsSchema,
70
- GenreSearchTreeNameSchema: () => GenreSearchTreeNameSchema,
71
66
  GenreUuidSchema: () => GenreUuidSchema,
72
67
  InvalidInputError: () => InvalidInputError,
73
68
  MbArtistDetailedSchema: () => MbArtistDetailedSchema,
@@ -83,18 +78,12 @@ __export(src_exports, {
83
78
  PopupProvider: () => PopupProvider,
84
79
  ReferenceGenreDetailedSchema: () => ReferenceGenreDetailedSchema,
85
80
  ReferenceGenrePlaylistSchema: () => ReferenceGenrePlaylistSchema,
86
- RegionGenreLexiconEntrySchema: () => RegionGenreLexiconEntrySchema,
87
- RegionGenreLexiconSchema: () => RegionGenreLexiconSchema,
88
81
  SEARCH_DEBOUNCE_MS: () => SEARCH_DEBOUNCE_MS,
89
82
  SEARCH_QUERY_MIN_LENGTH: () => SEARCH_QUERY_MIN_LENGTH,
90
83
  SPOTIFY_EXCHANGE_CONFIG: () => SPOTIFY_EXCHANGE_CONFIG,
91
84
  ServiceError: () => ServiceError,
92
85
  SessionProvider: () => SessionProvider,
93
86
  SongDetailedSchema: () => SongDetailedSchema,
94
- SongHistoryEntrySchema: () => SongHistoryEntrySchema,
95
- SongHistorySchema: () => SongHistorySchema,
96
- SongSearchResultSchema: () => SongSearchResultSchema,
97
- SongSearchResultsSchema: () => SongSearchResultsSchema,
98
87
  SongUuidSchema: () => SongUuidSchema,
99
88
  SubgenreCountsSchema: () => SubgenreCountsSchema,
100
89
  SubgenreScopeSchema: () => SubgenreScopeSchema,
@@ -2136,10 +2125,18 @@ function useCurrentTime() {
2136
2125
  }
2137
2126
 
2138
2127
  // src/genre-tree/useGenre.ts
2139
- var import_zod25 = require("zod");
2128
+ var import_zod26 = require("zod");
2129
+ var import_grow_api2 = require("@behindthemusictree/grow-api");
2140
2130
 
2141
- // src/genre-tree/schemas/criteria/detailed.ts
2142
- var import_zod15 = require("zod");
2131
+ // src/genre-tree/schemas/reference-genre.ts
2132
+ var import_zod11 = require("zod");
2133
+ var import_grow_api = require("@behindthemusictree/grow-api");
2134
+
2135
+ // src/genre-tree/schemas/criteria-playlist/simple.ts
2136
+ var import_zod10 = require("zod");
2137
+
2138
+ // src/genre-tree/schemas/criteria-playlist/detailed.ts
2139
+ var import_zod9 = require("zod");
2143
2140
 
2144
2141
  // src/genre-tree/schemas/genre-music.ts
2145
2142
  var import_zod7 = require("zod");
@@ -2172,10 +2169,10 @@ var CriteriaPlaylistMinimumSchema = import_zod6.z.object({
2172
2169
  // src/genre-tree/schemas/genre-music.ts
2173
2170
  var CountSchema = import_zod7.z.number().int().nonnegative();
2174
2171
  var SubgenreCountsSchema = import_zod7.z.union([
2175
- import_zod7.z.object({ canonical: CountSchema, regional: CountSchema, all: CountSchema }).strict(),
2172
+ import_zod7.z.object({ global: CountSchema, regional: CountSchema, all: CountSchema }).strict(),
2176
2173
  import_zod7.z.object({ all: CountSchema }).strict()
2177
2174
  ]).refine(
2178
- (counts) => !("canonical" in counts) || counts.all >= counts.canonical && counts.all >= counts.regional,
2175
+ (counts) => !("global" in counts) || counts.all >= counts.global && counts.all >= counts.regional,
2179
2176
  "The combined count must include both scoped selections"
2180
2177
  );
2181
2178
  var GenreCountsSchema = import_zod7.z.object({
@@ -2186,7 +2183,7 @@ var includesDirectSongs = (counts) => Object.values(counts.genreAndSubgenresTrac
2186
2183
  var GenreCatalogueCountsSchema = GenreCountsSchema.refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
2187
2184
  var GenrePlaylistSummarySchema = CriteriaPlaylistMinimumSchema.extend(GenreCountsSchema.shape).refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
2188
2185
  var GenreCoverageSchema = import_zod7.z.enum(["genreOnly", "genreAndSubgenres"]);
2189
- var SubgenreScopeSchema = import_zod7.z.enum(["canonical", "regional", "all"]);
2186
+ var SubgenreScopeSchema = import_zod7.z.enum(["global", "regional", "all"]);
2190
2187
 
2191
2188
  // src/genre-tree/schemas/criteria/minimum.ts
2192
2189
  var import_zod8 = require("zod");
@@ -2197,109 +2194,24 @@ var CriteriaMinimumSchema = import_zod8.z.object({
2197
2194
  wikidataId: import_zod8.z.string().nullable().optional()
2198
2195
  });
2199
2196
 
2200
- // src/genre-tree/schemas/track/base.ts
2201
- var import_zod12 = require("zod");
2202
-
2203
- // src/genre-tree/schemas/artist-minimum.ts
2204
- var import_zod9 = require("zod");
2205
- var ArtistMinimumSchema = import_zod9.z.object({
2206
- uuid: import_zod9.z.string().uuid(),
2207
- name: import_zod9.z.string(),
2208
- isSpecialPurpose: import_zod9.z.boolean().optional()
2209
- });
2210
-
2211
- // src/genre-tree/schemas/album-minimum.ts
2212
- var import_zod10 = require("zod");
2213
- var AlbumMinimumSchema = import_zod10.z.object({
2214
- uuid: import_zod10.z.string().uuid(),
2215
- name: import_zod10.z.string(),
2216
- albumArtists: import_zod10.z.array(ArtistMinimumSchema).nullable().optional()
2217
- });
2218
-
2219
- // src/genre-tree/schemas/uuid-resource.ts
2220
- var import_zod11 = require("zod");
2221
- var UuidResourceSchema = import_zod11.z.object({
2222
- uuid: import_zod11.z.string().uuid()
2223
- });
2224
-
2225
- // src/genre-tree/schemas/track/base.ts
2226
- var TrackBaseSchema = UuidResourceSchema.extend({
2227
- title: import_zod12.z.string(),
2228
- artists: import_zod12.z.array(ArtistMinimumSchema).nullable().optional(),
2229
- album: AlbumMinimumSchema.nullable().optional(),
2230
- trackNumber: import_zod12.z.number().nullable().optional(),
2231
- // null for a song not yet linked to a genre.
2232
- genre: CriteriaMinimumSchema.nullable(),
2233
- rating: import_zod12.z.number().min(0).max(10).nullable().optional(),
2234
- language: import_zod12.z.string().nullable().optional(),
2235
- playCount: import_zod12.z.number().min(0),
2236
- createdOn: import_zod12.z.string().datetime(),
2237
- updatedOn: import_zod12.z.string().datetime().nullable().optional()
2238
- });
2239
-
2240
- // src/genre-tree/schemas/track/minimum.ts
2241
- var TrackMinimumSchema = TrackBaseSchema.pick({
2242
- uuid: true,
2243
- title: true,
2244
- artists: true
2245
- });
2246
-
2247
- // src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
2248
- var import_zod13 = require("zod");
2249
- var CriteriaLineageRelWithoutAscendantSchema = import_zod13.z.object({
2250
- descendant: CriteriaMinimumSchema,
2251
- degree: import_zod13.z.number()
2252
- });
2253
-
2254
- // src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
2255
- var import_zod14 = require("zod");
2256
- var CriteriaLineageRelWithoutDescendantSchema = import_zod14.z.object({
2257
- ascendant: CriteriaMinimumSchema,
2258
- degree: import_zod14.z.number()
2259
- });
2260
-
2261
- // src/genre-tree/schemas/criteria/detailed.ts
2262
- var CriteriaDetailedSchema = import_zod15.z.object({
2263
- uuid: GenreUuidSchema,
2264
- name: import_zod15.z.string(),
2265
- summary: import_zod15.z.string().nullable(),
2266
- // Optional until every deployed API serves it.
2267
- wikidataId: import_zod15.z.string().nullable().optional(),
2268
- parent: CriteriaMinimumSchema.nullable(),
2269
- ascendants: import_zod15.z.array(CriteriaLineageRelWithoutDescendantSchema),
2270
- descendants: import_zod15.z.array(CriteriaLineageRelWithoutAscendantSchema).optional(),
2271
- root: CriteriaMinimumSchema,
2272
- children: import_zod15.z.array(CriteriaMinimumSchema),
2273
- catalogue: GenreCatalogueCountsSchema.optional(),
2274
- criteriaPlaylist: import_zod15.z.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]).nullable(),
2275
- tracks: import_zod15.z.array(TrackMinimumSchema).optional(),
2276
- essentialSongs: import_zod15.z.array(TrackMinimumSchema),
2277
- tracksCount: import_zod15.z.number(),
2278
- updatedOn: import_zod15.z.string().datetime().nullable()
2279
- });
2280
-
2281
- // src/genre-tree/schemas/criteria-playlist/simple.ts
2282
- var import_zod17 = require("zod");
2283
-
2284
2197
  // src/genre-tree/schemas/criteria-playlist/detailed.ts
2285
- var import_zod16 = require("zod");
2286
- var CriteriaPlaylistDetailedSchema = import_zod16.z.object({
2198
+ var CriteriaPlaylistDetailedSchema = import_zod9.z.object({
2287
2199
  uuid: GenrePlaylistUuidSchema,
2288
- name: import_zod16.z.string(),
2289
- tracksCount: import_zod16.z.number(),
2200
+ name: import_zod9.z.string(),
2201
+ tracksCount: import_zod9.z.number(),
2290
2202
  genreOnlyTracksCount: GenreCountsSchema.shape.genreOnlyTracksCount.optional(),
2291
2203
  genreAndSubgenresTracksCount: GenreCountsSchema.shape.genreAndSubgenresTracksCount.optional(),
2292
2204
  catalogue: GenreCatalogueCountsSchema.optional(),
2293
2205
  // Summed YouTube views of the same songs as `tracksCount`. Optional: hear-api has no view counts.
2294
- viewsCount: import_zod16.z.number().optional(),
2295
- durationInSec: import_zod16.z.number().min(0).nullable().optional(),
2296
- durationStrInHourMinSec: import_zod16.z.string().nullable().optional(),
2206
+ viewsCount: import_zod9.z.number().optional(),
2207
+ durationInSec: import_zod9.z.number().min(0).nullable().optional(),
2208
+ durationStrInHourMinSec: import_zod9.z.string().nullable().optional(),
2297
2209
  // Nullable: the "Genreless" root playlist has no criteria attached and is never updated.
2298
2210
  criteria: CriteriaMinimumSchema.nullable(),
2299
2211
  parent: CriteriaPlaylistMinimumSchema.nullable(),
2300
2212
  root: CriteriaPlaylistMinimumSchema,
2301
- createdOn: import_zod16.z.string(),
2302
- updatedOn: import_zod16.z.string().nullable()
2213
+ createdOn: import_zod9.z.string(),
2214
+ updatedOn: import_zod9.z.string().nullable()
2303
2215
  });
2304
2216
 
2305
2217
  // src/genre-tree/schemas/criteria-playlist/simple.ts
@@ -2318,24 +2230,44 @@ var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
2318
2230
  updatedOn: true
2319
2231
  }).extend({
2320
2232
  // Only on the tree/list payloads, not the detail endpoint — hence not on the detailed schema.
2321
- isUnacceptedRoot: import_zod17.z.boolean(),
2233
+ isUnacceptedRoot: import_zod10.z.boolean(),
2322
2234
  // Optional: a backend that does not curate umbrella genres omits it.
2323
- isUmbrella: import_zod17.z.boolean().optional(),
2235
+ isUmbrella: import_zod10.z.boolean().optional(),
2324
2236
  // Optional: only the grow tree payload carries it; null when the genre has no scene.
2325
- scene: import_zod17.z.enum(["commercial", "underground"]).nullable().optional()
2237
+ scene: import_zod10.z.enum(["commercial", "underground"]).nullable().optional()
2326
2238
  });
2327
2239
 
2328
2240
  // src/genre-tree/schemas/reference-genre.ts
2329
- var ReferenceGenreDetailedSchema = CriteriaDetailedSchema.extend({
2330
- catalogue: GenreCatalogueCountsSchema,
2331
- criteriaPlaylist: GenrePlaylistSummarySchema.nullable()
2241
+ function checkGenreCounts(counts, path, ctx) {
2242
+ const inclusive = counts.genreAndSubgenresTracksCount;
2243
+ const issue = (message) => ctx.addIssue({ code: "custom", path: [...path, "genreAndSubgenresTracksCount"], message });
2244
+ if (!Object.values(inclusive).every((count) => count >= counts.genreOnlyTracksCount)) {
2245
+ issue("Every inclusive count must include the genre itself");
2246
+ }
2247
+ if ("global" in inclusive && !(inclusive.all >= inclusive.global && inclusive.all >= (inclusive.regional ?? 0))) {
2248
+ issue("The combined count must include both scoped selections");
2249
+ }
2250
+ }
2251
+ var ReferenceGenreDetailedSchema = import_grow_api.zV1GenresRetrieveResponse.extend({ criteriaPlaylist: import_grow_api.zV1GenresRetrieveResponse.shape.criteriaPlaylist.nullable() }).superRefine((genre, ctx) => {
2252
+ checkGenreCounts(genre.catalogue, ["catalogue"], ctx);
2253
+ if (genre.criteriaPlaylist) checkGenreCounts(genre.criteriaPlaylist, ["criteriaPlaylist"], ctx);
2332
2254
  });
2333
- var ReferenceGenrePlaylistSchema = CriteriaPlaylistSimpleSchema.extend({
2255
+ var generatedTreeRow = import_grow_api.zV1GenrePlaylistsTreeListResponse.element;
2256
+ var ReferenceGenrePlaylistRowSchema = generatedTreeRow.extend({
2334
2257
  ...GenreCountsSchema.shape,
2335
- catalogue: GenreCatalogueCountsSchema
2336
- }).superRefine((playlist, ctx) => {
2337
- const counts = GenreCatalogueCountsSchema.safeParse(playlist);
2338
- if (!counts.success) for (const issue of counts.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
2258
+ criteria: generatedTreeRow.shape.criteria.extend({ parent: generatedTreeRow.shape.criteria.shape.parent.nullable() }).nullable(),
2259
+ parent: generatedTreeRow.shape.parent.nullable()
2260
+ });
2261
+ var ReferenceGenrePlaylistSchema = import_zod11.z.array(ReferenceGenrePlaylistRowSchema).superRefine((playlists, ctx) => {
2262
+ playlists.forEach((playlist, index) => {
2263
+ checkGenreCounts(playlist, [index], ctx);
2264
+ checkGenreCounts(playlist.catalogue, [index, "catalogue"], ctx);
2265
+ });
2266
+ }).transform((playlists, ctx) => {
2267
+ const branded = import_zod11.z.array(CriteriaPlaylistSimpleSchema).safeParse(playlists);
2268
+ if (branded.success) return branded.data;
2269
+ for (const issue of branded.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
2270
+ return import_zod11.z.NEVER;
2339
2271
  });
2340
2272
 
2341
2273
  // src/genre-tree/useGenre.ts
@@ -2343,7 +2275,7 @@ var import_react_query5 = require("@tanstack/react-query");
2343
2275
  var import_react16 = require("react");
2344
2276
 
2345
2277
  // src/genre-tree/useGenrePlaylist.ts
2346
- var import_zod18 = require("zod");
2278
+ var import_zod12 = require("zod");
2347
2279
  var import_react_query4 = require("@tanstack/react-query");
2348
2280
 
2349
2281
  // src/genre-tree/api/genre-playlists/queryKeys.ts
@@ -2383,13 +2315,13 @@ var genrePlaylistEndpoints = {
2383
2315
 
2384
2316
  // src/genre-tree/lib/genre-music-selection.ts
2385
2317
  function defaultGenreMusicSelection(counts) {
2386
- return { coverage: "genreAndSubgenres", subgenres: "canonical" in counts.genreAndSubgenresTracksCount ? "canonical" : "all" };
2318
+ return { coverage: "genreAndSubgenres", subgenres: "global" in counts.genreAndSubgenresTracksCount ? "global" : "all" };
2387
2319
  }
2388
2320
  function genreMusicCount(counts, selection = defaultGenreMusicSelection(counts)) {
2389
2321
  if (selection.coverage === "genreOnly") return counts.genreOnlyTracksCount;
2390
2322
  const scopes = counts.genreAndSubgenresTracksCount;
2391
2323
  if (selection.subgenres === "all") return scopes.all;
2392
- if (!("canonical" in scopes)) throw new Error("Regional genres only support all subgenres");
2324
+ if (!("global" in scopes)) throw new Error("Regional genres only support all subgenres");
2393
2325
  return scopes[selection.subgenres];
2394
2326
  }
2395
2327
  function genreMusicQueryParams(selection) {
@@ -2486,16 +2418,16 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
2486
2418
  const queryKey = scope === "reference" ? [...genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()), "genreMusicV1"] : genrePlaylistQueryKeys.me.full;
2487
2419
  const query = useQueryWithParse({
2488
2420
  queryKey,
2489
- queryFn: () => scope === "reference" ? fetch2(genrePlaylistEndpoints.reference.tree(), true, false, {}, { treeName: "canonical" }) : fetchAllPages(
2421
+ queryFn: () => scope === "reference" ? fetch2(genrePlaylistEndpoints.reference.tree(), true, false, {}, { treeName: "global" }) : fetchAllPages(
2490
2422
  (page) => fetch2(
2491
2423
  genrePlaylistEndpoints.me.list(),
2492
2424
  true,
2493
2425
  true,
2494
2426
  {},
2495
- { page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "canonical" }
2427
+ { page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "global" }
2496
2428
  )
2497
2429
  ),
2498
- schema: scope === "reference" ? import_zod18.z.array(ReferenceGenrePlaylistSchema) : import_zod18.z.array(CriteriaPlaylistSimpleSchema),
2430
+ schema: scope === "reference" ? ReferenceGenrePlaylistSchema : import_zod12.z.array(CriteriaPlaylistSimpleSchema),
2499
2431
  context: "useListFullGenrePlaylists",
2500
2432
  enabled: scope === "reference" || sessionRestored && !!session?.accessToken
2501
2433
  });
@@ -2528,62 +2460,146 @@ var useInvalidateAllGenrePlaylistQueries = () => {
2528
2460
  ]);
2529
2461
  };
2530
2462
 
2463
+ // src/genre-tree/schemas/criteria/detailed.ts
2464
+ var import_zod19 = require("zod");
2465
+
2466
+ // src/genre-tree/schemas/track/base.ts
2467
+ var import_zod16 = require("zod");
2468
+
2469
+ // src/genre-tree/schemas/artist-minimum.ts
2470
+ var import_zod13 = require("zod");
2471
+ var ArtistMinimumSchema = import_zod13.z.object({
2472
+ uuid: import_zod13.z.string().uuid(),
2473
+ name: import_zod13.z.string(),
2474
+ isSpecialPurpose: import_zod13.z.boolean().optional()
2475
+ });
2476
+
2477
+ // src/genre-tree/schemas/album-minimum.ts
2478
+ var import_zod14 = require("zod");
2479
+ var AlbumMinimumSchema = import_zod14.z.object({
2480
+ uuid: import_zod14.z.string().uuid(),
2481
+ name: import_zod14.z.string(),
2482
+ albumArtists: import_zod14.z.array(ArtistMinimumSchema).nullable().optional()
2483
+ });
2484
+
2485
+ // src/genre-tree/schemas/uuid-resource.ts
2486
+ var import_zod15 = require("zod");
2487
+ var UuidResourceSchema = import_zod15.z.object({
2488
+ uuid: import_zod15.z.string().uuid()
2489
+ });
2490
+
2491
+ // src/genre-tree/schemas/track/base.ts
2492
+ var TrackBaseSchema = UuidResourceSchema.extend({
2493
+ title: import_zod16.z.string(),
2494
+ artists: import_zod16.z.array(ArtistMinimumSchema).nullable().optional(),
2495
+ album: AlbumMinimumSchema.nullable().optional(),
2496
+ trackNumber: import_zod16.z.number().nullable().optional(),
2497
+ // null for a song not yet linked to a genre.
2498
+ genre: CriteriaMinimumSchema.nullable(),
2499
+ rating: import_zod16.z.number().min(0).max(10).nullable().optional(),
2500
+ language: import_zod16.z.string().nullable().optional(),
2501
+ playCount: import_zod16.z.number().min(0),
2502
+ createdOn: import_zod16.z.string().datetime(),
2503
+ updatedOn: import_zod16.z.string().datetime().nullable().optional()
2504
+ });
2505
+
2506
+ // src/genre-tree/schemas/track/minimum.ts
2507
+ var TrackMinimumSchema = TrackBaseSchema.pick({
2508
+ uuid: true,
2509
+ title: true,
2510
+ artists: true
2511
+ });
2512
+
2513
+ // src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
2514
+ var import_zod17 = require("zod");
2515
+ var CriteriaLineageRelWithoutAscendantSchema = import_zod17.z.object({
2516
+ descendant: CriteriaMinimumSchema,
2517
+ degree: import_zod17.z.number()
2518
+ });
2519
+
2520
+ // src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
2521
+ var import_zod18 = require("zod");
2522
+ var CriteriaLineageRelWithoutDescendantSchema = import_zod18.z.object({
2523
+ ascendant: CriteriaMinimumSchema,
2524
+ degree: import_zod18.z.number()
2525
+ });
2526
+
2527
+ // src/genre-tree/schemas/criteria/detailed.ts
2528
+ var CriteriaDetailedSchema = import_zod19.z.object({
2529
+ uuid: GenreUuidSchema,
2530
+ name: import_zod19.z.string(),
2531
+ summary: import_zod19.z.string().nullable(),
2532
+ // Optional until every deployed API serves it.
2533
+ wikidataId: import_zod19.z.string().nullable().optional(),
2534
+ parent: CriteriaMinimumSchema.nullable(),
2535
+ ascendants: import_zod19.z.array(CriteriaLineageRelWithoutDescendantSchema),
2536
+ descendants: import_zod19.z.array(CriteriaLineageRelWithoutAscendantSchema).optional(),
2537
+ root: CriteriaMinimumSchema,
2538
+ children: import_zod19.z.array(CriteriaMinimumSchema),
2539
+ catalogue: GenreCatalogueCountsSchema.optional(),
2540
+ criteriaPlaylist: import_zod19.z.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]).nullable(),
2541
+ tracks: import_zod19.z.array(TrackMinimumSchema).optional(),
2542
+ essentialSongs: import_zod19.z.array(TrackMinimumSchema),
2543
+ tracksCount: import_zod19.z.number(),
2544
+ updatedOn: import_zod19.z.string().datetime().nullable()
2545
+ });
2546
+
2531
2547
  // src/genre-tree/schemas/criteria/overview.ts
2532
- var import_zod21 = require("zod");
2548
+ var import_zod22 = require("zod");
2533
2549
 
2534
2550
  // src/genre-tree/schemas/commons-image.ts
2535
- var import_zod20 = require("zod");
2551
+ var import_zod21 = require("zod");
2536
2552
 
2537
2553
  // src/genre-tree/schemas/http-url.ts
2538
- var import_zod19 = require("zod");
2539
- var HttpUrlSchema = import_zod19.z.url({ protocol: /^https?$/ });
2554
+ var import_zod20 = require("zod");
2555
+ var HttpUrlSchema = import_zod20.z.url({ protocol: /^https?$/ });
2540
2556
 
2541
2557
  // src/genre-tree/schemas/commons-image.ts
2542
- var CommonsImageSchema = import_zod20.z.object({
2558
+ var CommonsImageSchema = import_zod21.z.object({
2543
2559
  url: HttpUrlSchema,
2544
2560
  pageUrl: HttpUrlSchema,
2545
- author: import_zod20.z.string().nullable(),
2546
- license: import_zod20.z.string(),
2561
+ author: import_zod21.z.string().nullable(),
2562
+ license: import_zod21.z.string(),
2547
2563
  licenseUrl: HttpUrlSchema.nullable()
2548
2564
  });
2549
2565
 
2550
2566
  // src/genre-tree/schemas/criteria/overview.ts
2551
- var CriteriaOverviewSchema = import_zod21.z.object({
2567
+ var CriteriaOverviewSchema = import_zod22.z.object({
2552
2568
  uuid: GenreUuidSchema,
2553
- name: import_zod21.z.string(),
2554
- summary: import_zod21.z.string().nullable(),
2555
- description: import_zod21.z.string().nullable(),
2569
+ name: import_zod22.z.string(),
2570
+ summary: import_zod22.z.string().nullable(),
2571
+ description: import_zod22.z.string().nullable(),
2556
2572
  summarySourceUrl: HttpUrlSchema.nullable(),
2557
2573
  // Optional: hosts whose API does not send it (e.g. hear) stay valid.
2558
2574
  image: CommonsImageSchema.nullable().optional(),
2559
- essentialSongs: import_zod21.z.array(TrackMinimumSchema).optional()
2575
+ essentialSongs: import_zod22.z.array(TrackMinimumSchema).optional()
2560
2576
  });
2561
2577
 
2562
2578
  // src/genre-tree/schemas/criteria/simple.ts
2563
- var import_zod22 = require("zod");
2564
- var CriteriaSimpleSchema = import_zod22.z.object({
2579
+ var import_zod23 = require("zod");
2580
+ var CriteriaSimpleSchema = import_zod23.z.object({
2565
2581
  uuid: GenreUuidSchema,
2566
- name: import_zod22.z.string(),
2582
+ name: import_zod23.z.string(),
2567
2583
  parent: CriteriaMinimumSchema.nullable(),
2568
- createdOn: import_zod22.z.string().datetime(),
2569
- summary: import_zod22.z.string().nullable()
2584
+ createdOn: import_zod23.z.string().datetime(),
2585
+ summary: import_zod23.z.string().nullable()
2570
2586
  });
2571
2587
 
2572
2588
  // src/genre-tree/schemas/criteria/creation.ts
2573
- var import_zod23 = require("zod");
2574
- var CriteriaCreationSchema = import_zod23.z.object({
2575
- name: import_zod23.z.string().min(1, "Name is required"),
2589
+ var import_zod24 = require("zod");
2590
+ var CriteriaCreationSchema = import_zod24.z.object({
2591
+ name: import_zod24.z.string().min(1, "Name is required"),
2576
2592
  parent: GenreUuidSchema.optional(),
2577
- essentialSongs: import_zod23.z.array(import_zod23.z.string().uuid()).optional()
2593
+ essentialSongs: import_zod24.z.array(import_zod24.z.string().uuid()).optional()
2578
2594
  });
2579
2595
 
2580
2596
  // src/genre-tree/schemas/criteria/update.ts
2581
- var import_zod24 = require("zod");
2582
- var CriteriaUpdateSchema = import_zod24.z.object({
2583
- name: import_zod24.z.string().optional(),
2597
+ var import_zod25 = require("zod");
2598
+ var CriteriaUpdateSchema = import_zod25.z.object({
2599
+ name: import_zod25.z.string().optional(),
2584
2600
  parent: GenreUuidSchema.nullable().optional(),
2585
- essentialSongs: import_zod24.z.array(import_zod24.z.string().uuid()).optional(),
2586
- side: import_zod24.z.enum(["core", "pop"]).optional()
2601
+ essentialSongs: import_zod25.z.array(import_zod25.z.string().uuid()).optional(),
2602
+ side: import_zod25.z.enum(["core", "pop"]).optional()
2587
2603
  });
2588
2604
 
2589
2605
  // src/genre-tree/api/genres/queryKeys.ts
@@ -2626,6 +2642,9 @@ var genreEndpoints = {
2626
2642
  };
2627
2643
 
2628
2644
  // src/genre-tree/useGenre.ts
2645
+ function schemaForScope(scope, reference, me) {
2646
+ return scope === "reference" ? reference : me;
2647
+ }
2629
2648
  function useListGenres(page = 1, pageSize = 50, scope, getBackendBaseUrl) {
2630
2649
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2631
2650
  const { session, sessionRestored } = useSession();
@@ -2633,7 +2652,7 @@ function useListGenres(page = 1, pageSize = 50, scope, getBackendBaseUrl) {
2633
2652
  return useQueryWithParse({
2634
2653
  queryKey: scope === "reference" ? genreQueryKeys.reference.list(page) : genreQueryKeys.me.list(page),
2635
2654
  queryFn: () => fetch2(endpoint, true, scope === "me", {}, { page, pageSize }),
2636
- schema: PaginatedResponseSchema(CriteriaSimpleSchema),
2655
+ schema: schemaForScope(scope, import_grow_api2.zV1GenresListResponse, PaginatedResponseSchema(CriteriaSimpleSchema)),
2637
2656
  context: "useListGenres",
2638
2657
  enabled: scope === "reference" || sessionRestored && !!session?.accessToken
2639
2658
  });
@@ -2644,12 +2663,12 @@ function useFetchGenre(scope, getBackendBaseUrl) {
2644
2663
  async (id) => {
2645
2664
  const endpoint = scope === "reference" ? genreEndpoints.reference.detail(id) : genreEndpoints.me.detail(id);
2646
2665
  const response = await fetch2(endpoint, true, scope === "me");
2647
- return parseWithLog(scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema, response, "useFetchGenre");
2666
+ return parseWithLog(schemaForScope(scope, ReferenceGenreDetailedSchema, CriteriaDetailedSchema), response, "useFetchGenre");
2648
2667
  },
2649
2668
  [fetch2, scope]
2650
2669
  );
2651
2670
  }
2652
- function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = scope === "reference" ? ReferenceGenreDetailedSchema : CriteriaDetailedSchema) {
2671
+ function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = schemaForScope(scope, ReferenceGenreDetailedSchema, CriteriaDetailedSchema)) {
2653
2672
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2654
2673
  const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
2655
2674
  const endpoints = scope === "reference" ? genreEndpoints.reference : genreEndpoints.me;
@@ -2666,7 +2685,6 @@ function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = scope === "r
2666
2685
  const result = toResourceResult({ id, isValidId: validUuid !== null, data, error, isPending });
2667
2686
  return result.status === "success" ? { status: "success", genre: result.data } : result;
2668
2687
  }
2669
- var GenreByWikidataIdSchema = PaginatedResponseSchema(CriteriaMinimumSchema);
2670
2688
  function useGenreByWikidataId(qid, scope, getBackendBaseUrl) {
2671
2689
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2672
2690
  const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
@@ -2674,12 +2692,13 @@ function useGenreByWikidataId(qid, scope, getBackendBaseUrl) {
2674
2692
  const { data, ...rest } = useQueryWithParse({
2675
2693
  queryKey: queryKeys.byWikidataId(qid ?? ""),
2676
2694
  queryFn: () => fetch2(endpoints.list(), true, scope === "me", {}, { wikidataId: qid ?? "", pageSize: 1 }),
2677
- schema: GenreByWikidataIdSchema,
2695
+ schema: schemaForScope(scope, import_grow_api2.zV1GenresListResponse, PaginatedResponseSchema(CriteriaMinimumSchema)),
2678
2696
  context: "useGenreByWikidataId",
2679
2697
  enabled: qid !== null
2680
2698
  });
2681
2699
  return { ...rest, data: data === void 0 ? void 0 : data.results[0] ?? null };
2682
2700
  }
2701
+ var defaultOverviewSchema = (scope) => schemaForScope(scope, import_grow_api2.zV1GenresOverviewRetrieveResponse, CriteriaOverviewSchema);
2683
2702
  var GENRE_OVERVIEW_STALE_TIME_MS = 6e4;
2684
2703
  function useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema) {
2685
2704
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
@@ -2697,11 +2716,11 @@ function useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema) {
2697
2716
  [fetch2, scope, schema]
2698
2717
  );
2699
2718
  }
2700
- function useFetchGenreOverview(id, scope, getBackendBaseUrl, schema = CriteriaOverviewSchema) {
2719
+ function useFetchGenreOverview(id, scope, getBackendBaseUrl, schema = defaultOverviewSchema(scope)) {
2701
2720
  const queryOptions = useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema);
2702
2721
  return (0, import_react_query5.useQuery)({ ...queryOptions(id ?? ""), enabled: id !== null });
2703
2722
  }
2704
- function usePrefetchGenreOverview(scope, getBackendBaseUrl, schema = CriteriaOverviewSchema) {
2723
+ function usePrefetchGenreOverview(scope, getBackendBaseUrl, schema = defaultOverviewSchema(scope)) {
2705
2724
  const queryClient2 = (0, import_react_query5.useQueryClient)();
2706
2725
  const queryOptions = useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema);
2707
2726
  return (0, import_react16.useCallback)((id) => queryClient2.prefetchQuery(queryOptions(id)), [queryClient2, queryOptions]);
@@ -2743,7 +2762,7 @@ function useUpdateGenre(scope, getBackendBaseUrl) {
2743
2762
  const refreshGenreTree = useRefreshGenreTree(scope);
2744
2763
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2745
2764
  const { mutate, mutateAsync, isPending, formErrors } = useValidatedMutation({
2746
- inputSchema: import_zod25.z.object({
2765
+ inputSchema: import_zod26.z.object({
2747
2766
  uuid: GenreUuidSchema,
2748
2767
  data: CriteriaUpdateSchema
2749
2768
  }),
@@ -2773,8 +2792,8 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
2773
2792
  const refreshGenreTree = useRefreshGenreTree(scope);
2774
2793
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
2775
2794
  return useValidatedMutation({
2776
- inputSchema: import_zod25.z.object({ uuid: GenreUuidSchema }),
2777
- outputSchema: import_zod25.z.null(),
2795
+ inputSchema: import_zod26.z.object({ uuid: GenreUuidSchema }),
2796
+ outputSchema: import_zod26.z.null(),
2778
2797
  mutationFn: async ({ uuid }) => {
2779
2798
  const endpoint = scope === "reference" ? genreEndpoints.reference.delete(uuid) : genreEndpoints.me.delete(uuid);
2780
2799
  return fetch2(endpoint, true, scope === "me", { method: "DELETE" }, void 0, false, true);
@@ -2783,14 +2802,18 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
2783
2802
  });
2784
2803
  }
2785
2804
 
2805
+ // src/genre-tree/schemas/reference-artist.ts
2806
+ var import_zod29 = require("zod");
2807
+ var import_grow_api3 = require("@behindthemusictree/grow-api");
2808
+
2786
2809
  // src/genre-tree/schemas/artist-detailed.ts
2787
- var import_zod26 = require("zod");
2788
- var ArtistMembershipSchema = import_zod26.z.object({
2810
+ var import_zod27 = require("zod");
2811
+ var ArtistMembershipSchema = import_zod27.z.object({
2789
2812
  artist: ArtistMinimumSchema,
2790
- beginYear: import_zod26.z.number().int().nullable(),
2791
- endYear: import_zod26.z.number().int().nullable(),
2792
- ended: import_zod26.z.boolean(),
2793
- roles: import_zod26.z.array(import_zod26.z.string())
2813
+ beginYear: import_zod27.z.number().int().nullable(),
2814
+ endYear: import_zod27.z.number().int().nullable(),
2815
+ ended: import_zod27.z.boolean(),
2816
+ roles: import_zod27.z.array(import_zod27.z.string())
2794
2817
  });
2795
2818
  var ARTIST_LINK_KINDS = [
2796
2819
  "official",
@@ -2804,42 +2827,75 @@ var ARTIST_LINK_KINDS = [
2804
2827
  "social"
2805
2828
  ];
2806
2829
  var ArtistImageSchema = CommonsImageSchema;
2807
- var ArtistOriginSchema = import_zod26.z.object({
2808
- name: import_zod26.z.string(),
2809
- kind: import_zod26.z.string().nullable(),
2810
- source: import_zod26.z.enum(["begin_area", "area"]),
2811
- wikidataId: import_zod26.z.string().nullable(),
2812
- longitude: import_zod26.z.number().nullable(),
2813
- latitude: import_zod26.z.number().nullable(),
2814
- regionId: import_zod26.z.string().nullable()
2830
+ var ArtistOriginSchema = import_zod27.z.object({
2831
+ name: import_zod27.z.string(),
2832
+ kind: import_zod27.z.string().nullable(),
2833
+ source: import_zod27.z.enum(["begin_area", "area"]),
2834
+ wikidataId: import_zod27.z.string().nullable(),
2835
+ longitude: import_zod27.z.number().nullable(),
2836
+ latitude: import_zod27.z.number().nullable(),
2837
+ regionId: import_zod27.z.string().nullable()
2815
2838
  });
2816
- var ArtistDetailedSchema = import_zod26.z.object({
2817
- uuid: import_zod26.z.string().uuid(),
2818
- name: import_zod26.z.string(),
2819
- musicbrainzArtistId: import_zod26.z.string().uuid().nullable(),
2820
- type: import_zod26.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
2821
- country: import_zod26.z.string().nullable(),
2822
- beginYear: import_zod26.z.number().int().nullable(),
2823
- endYear: import_zod26.z.number().int().nullable(),
2824
- ended: import_zod26.z.boolean(),
2825
- links: import_zod26.z.array(import_zod26.z.object({ kind: import_zod26.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
2826
- members: import_zod26.z.array(ArtistMembershipSchema),
2827
- memberOf: import_zod26.z.array(ArtistMembershipSchema),
2828
- albums: import_zod26.z.array(
2829
- import_zod26.z.object({
2830
- uuid: import_zod26.z.string().uuid(),
2831
- name: import_zod26.z.string(),
2832
- year: import_zod26.z.string().nullable(),
2833
- primaryType: import_zod26.z.string().nullable(),
2834
- secondaryTypes: import_zod26.z.array(import_zod26.z.string())
2839
+ var ArtistDetailedSchema = import_zod27.z.object({
2840
+ uuid: import_zod27.z.string().uuid(),
2841
+ name: import_zod27.z.string(),
2842
+ musicbrainzArtistId: import_zod27.z.string().uuid().nullable(),
2843
+ type: import_zod27.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
2844
+ country: import_zod27.z.string().nullable(),
2845
+ beginYear: import_zod27.z.number().int().nullable(),
2846
+ endYear: import_zod27.z.number().int().nullable(),
2847
+ ended: import_zod27.z.boolean(),
2848
+ links: import_zod27.z.array(import_zod27.z.object({ kind: import_zod27.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
2849
+ members: import_zod27.z.array(ArtistMembershipSchema),
2850
+ memberOf: import_zod27.z.array(ArtistMembershipSchema),
2851
+ albums: import_zod27.z.array(
2852
+ import_zod27.z.object({
2853
+ uuid: import_zod27.z.string().uuid(),
2854
+ name: import_zod27.z.string(),
2855
+ year: import_zod27.z.string().nullable(),
2856
+ primaryType: import_zod27.z.string().nullable(),
2857
+ secondaryTypes: import_zod27.z.array(import_zod27.z.string())
2835
2858
  })
2836
2859
  ),
2837
- tracksCount: import_zod26.z.number().int(),
2838
- playableTracksCount: import_zod26.z.number().int(),
2860
+ tracksCount: import_zod27.z.number().int(),
2861
+ playableTracksCount: import_zod27.z.number().int(),
2839
2862
  image: ArtistImageSchema.nullable(),
2840
2863
  origin: ArtistOriginSchema.nullable()
2841
2864
  });
2842
2865
 
2866
+ // src/genre-tree/schemas/artist-genre-count.ts
2867
+ var import_zod28 = require("zod");
2868
+ var ArtistGenreCountSchema = import_zod28.z.object({
2869
+ ...GenreCountsSchema.shape,
2870
+ catalogue: GenreCatalogueCountsSchema,
2871
+ genrePlaylist: GenrePlaylistUuidSchema,
2872
+ /** Legacy catalogue count for the default selection. */
2873
+ songsCount: import_zod28.z.number().int().nonnegative(),
2874
+ /** Legacy playlist count for the default selection. */
2875
+ tracksCount: import_zod28.z.number().int().nonnegative()
2876
+ }).superRefine((row, ctx) => {
2877
+ const counts = GenreCatalogueCountsSchema.safeParse(row);
2878
+ if (!counts.success) {
2879
+ for (const issue of counts.error.issues) {
2880
+ ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
2881
+ }
2882
+ }
2883
+ });
2884
+
2885
+ // src/genre-tree/schemas/reference-artist.ts
2886
+ function intoUiShape(target) {
2887
+ return (value, ctx) => {
2888
+ const parsed = target.safeParse(value);
2889
+ if (parsed.success) return parsed.data;
2890
+ for (const issue of parsed.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
2891
+ return import_zod29.z.NEVER;
2892
+ };
2893
+ }
2894
+ var ReferenceArtistSchema = import_grow_api3.zV1ArtistsRetrieveResponse.transform(intoUiShape(ArtistDetailedSchema));
2895
+ var ReferenceArtistGenreCountsSchema = import_grow_api3.zV1ArtistsGenreCountsListResponse.transform(
2896
+ intoUiShape(import_zod29.z.array(ArtistGenreCountSchema))
2897
+ );
2898
+
2843
2899
  // src/genre-tree/api/artists/queryKeys.ts
2844
2900
  var artistQueryKeys = {
2845
2901
  search: (query) => ["artistSearch", query],
@@ -2863,7 +2919,7 @@ function useArtist(uuid, getBackendBaseUrl) {
2863
2919
  const { data, isPending, error } = useQueryWithParse({
2864
2920
  queryKey: artistQueryKeys.detail(id),
2865
2921
  queryFn: () => fetch2(artistEndpoints.detail(id), true, false),
2866
- schema: ArtistDetailedSchema,
2922
+ schema: ReferenceArtistSchema,
2867
2923
  enabled: isUuid,
2868
2924
  retry: resourceRetry,
2869
2925
  context: "useArtist"
@@ -2872,20 +2928,8 @@ function useArtist(uuid, getBackendBaseUrl) {
2872
2928
  return result.status === "success" ? { status: "success", artist: result.data } : result;
2873
2929
  }
2874
2930
 
2875
- // src/genre-tree/schemas/artist-search.ts
2876
- var import_zod27 = require("zod");
2877
- var ArtistSearchResultSchema = import_zod27.z.object({
2878
- uuid: import_zod27.z.string().uuid(),
2879
- name: import_zod27.z.string(),
2880
- disambiguation: import_zod27.z.string().nullable(),
2881
- type: import_zod27.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
2882
- country: import_zod27.z.string().nullable(),
2883
- beginYear: import_zod27.z.number().int().nullable(),
2884
- endYear: import_zod27.z.number().int().nullable(),
2885
- matchedAlias: import_zod27.z.string().nullable(),
2886
- recordingCount: import_zod27.z.number().int()
2887
- });
2888
- var ArtistSearchResultsSchema = import_zod27.z.array(ArtistSearchResultSchema);
2931
+ // src/genre-tree/useArtistSearch.ts
2932
+ var import_grow_api4 = require("@behindthemusictree/grow-api");
2889
2933
 
2890
2934
  // src/genre-tree/useRemoteSearch.ts
2891
2935
  var import_react_query6 = require("@tanstack/react-query");
@@ -2932,15 +2976,19 @@ function useArtistSearch(getBackendBaseUrl, text) {
2932
2976
  queryKey: artistQueryKeys.search,
2933
2977
  endpoint: artistEndpoints.search(),
2934
2978
  params: (q) => ({ q, limit: RESULT_LIMIT }),
2935
- schema: ArtistSearchResultsSchema,
2979
+ schema: import_grow_api4.zV1ArtistsSearchListResponse,
2936
2980
  context: "useArtistSearch",
2937
2981
  text
2938
2982
  });
2939
2983
  return { artists: results, isError, settled, pending };
2940
2984
  }
2941
2985
 
2986
+ // src/genre-tree/schemas/reference-song.ts
2987
+ var import_zod31 = require("zod");
2988
+ var import_grow_api5 = require("@behindthemusictree/grow-api");
2989
+
2942
2990
  // src/genre-tree/schemas/song/detailed.ts
2943
- var import_zod28 = require("zod");
2991
+ var import_zod30 = require("zod");
2944
2992
  var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
2945
2993
  not_found: "Video unavailable",
2946
2994
  not_embeddable: "Embedding disabled",
@@ -2949,23 +2997,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
2949
2997
  region_whitelisted: "Region restricted"
2950
2998
  };
2951
2999
  var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
2952
- var YoutubeAvailabilitySchema = import_zod28.z.object({
2953
- status: import_zod28.z.enum(["eligible", "blocked", "unknown"]),
2954
- reason: import_zod28.z.string().nullable(),
2955
- country: import_zod28.z.string().nullable()
3000
+ var YoutubeAvailabilitySchema = import_zod30.z.object({
3001
+ status: import_zod30.z.enum(["eligible", "blocked", "unknown"]),
3002
+ reason: import_zod30.z.string().nullable(),
3003
+ country: import_zod30.z.string().nullable()
2956
3004
  });
2957
3005
  var SongDetailedSchema = TrackBaseSchema.extend({
2958
- youtubeVideo: import_zod28.z.object({
2959
- id: import_zod28.z.string(),
3006
+ youtubeVideo: import_zod30.z.object({
3007
+ id: import_zod30.z.string(),
2960
3008
  availability: YoutubeAvailabilitySchema.optional(),
2961
3009
  // null = playable
2962
- unplayableReason: import_zod28.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
2963
- viewCount: import_zod28.z.number().int().nullable().optional()
3010
+ unplayableReason: import_zod30.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
3011
+ viewCount: import_zod30.z.number().int().nullable().optional()
2964
3012
  }).nullable(),
2965
3013
  // null for hand-made/admin songs
2966
- musicbrainzRecordingId: import_zod28.z.string().uuid().nullable(),
2967
- firstReleaseYear: import_zod28.z.number().int().nullable().optional(),
2968
- essentialGenres: import_zod28.z.array(CriteriaMinimumSchema).optional()
3014
+ musicbrainzRecordingId: import_zod30.z.string().uuid().nullable(),
3015
+ firstReleaseYear: import_zod30.z.number().int().nullable().optional(),
3016
+ essentialGenres: import_zod30.z.array(CriteriaMinimumSchema).optional()
2969
3017
  });
2970
3018
  var NO_VIDEO_LABEL = "No video available";
2971
3019
  function isSong(track) {
@@ -2981,6 +3029,16 @@ function musicBrainzRecordingUrl(song) {
2981
3029
  return song.musicbrainzRecordingId ? `https://musicbrainz.org/recording/${song.musicbrainzRecordingId}` : null;
2982
3030
  }
2983
3031
 
3032
+ // src/genre-tree/schemas/reference-song.ts
3033
+ var ReferenceSongSchema = import_grow_api5.zV1LibrarySongsRetrieveResponse.extend({
3034
+ album: import_grow_api5.zV1LibrarySongsRetrieveResponse.shape.album.nullable()
3035
+ }).transform((song, ctx) => {
3036
+ const branded = SongDetailedSchema.safeParse(song);
3037
+ if (branded.success) return branded.data;
3038
+ for (const issue of branded.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
3039
+ return import_zod31.z.NEVER;
3040
+ });
3041
+
2984
3042
  // src/genre-tree/useSong.ts
2985
3043
  function useSong(uuid, getBackendBaseUrl) {
2986
3044
  const id = toSongUuid(uuid);
@@ -2989,7 +3047,7 @@ function useSong(uuid, getBackendBaseUrl) {
2989
3047
  getBackendBaseUrl,
2990
3048
  queryKey: libraryQueryKeys.reference.songs.detail(id),
2991
3049
  queryFn: (fetchBound, { signal }) => fetchBound(libraryEndpoints.reference.songs.detail(id), true, false, { signal }),
2992
- schema: SongDetailedSchema,
3050
+ schema: ReferenceSongSchema,
2993
3051
  enabled: isUuid,
2994
3052
  retry: resourceRetry,
2995
3053
  context: "useSong"
@@ -2998,19 +3056,8 @@ function useSong(uuid, getBackendBaseUrl) {
2998
3056
  return result.status === "success" ? { status: "success", song: result.data } : result;
2999
3057
  }
3000
3058
 
3001
- // src/genre-tree/schemas/song-history.ts
3002
- var import_zod29 = require("zod");
3003
- var SongHistoryEntrySchema = import_zod29.z.object({
3004
- uuid: import_zod29.z.string().uuid(),
3005
- action: import_zod29.z.string(),
3006
- actorPseudo: import_zod29.z.string().nullable(),
3007
- oldValue: import_zod29.z.string().nullable(),
3008
- newValue: import_zod29.z.string().nullable(),
3009
- createdOn: import_zod29.z.string()
3010
- });
3011
- var SongHistorySchema = import_zod29.z.array(SongHistoryEntrySchema);
3012
-
3013
3059
  // src/genre-tree/useSongHistory.ts
3060
+ var import_grow_api6 = require("@behindthemusictree/grow-api");
3014
3061
  function useSongHistory(uuid, getBackendBaseUrl, enabled) {
3015
3062
  const id = toSongUuid(uuid);
3016
3063
  const active = enabled && id !== null;
@@ -3018,7 +3065,7 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
3018
3065
  getBackendBaseUrl,
3019
3066
  queryKey: libraryQueryKeys.reference.songs.history(id),
3020
3067
  queryFn: (fetchBound, { signal }) => fetchBound(libraryEndpoints.reference.songs.history(id), true, false, { signal }),
3021
- schema: SongHistorySchema,
3068
+ schema: import_grow_api6.zV1LibrarySongsHistoryListResponse,
3022
3069
  enabled: active,
3023
3070
  context: "useSongHistory"
3024
3071
  });
@@ -3028,26 +3075,8 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
3028
3075
  return { status: "success", entries: data };
3029
3076
  }
3030
3077
 
3031
- // src/genre-tree/schemas/song-search.ts
3032
- var import_zod30 = require("zod");
3033
- var SongSearchResultSchema = import_zod30.z.object({
3034
- uuid: import_zod30.z.string().uuid(),
3035
- title: import_zod30.z.string(),
3036
- artists: import_zod30.z.array(ArtistMinimumSchema),
3037
- // null for songs not yet linked to a genre.
3038
- genre: CriteriaMinimumSchema.nullable(),
3039
- youtubeVideo: import_zod30.z.object({
3040
- id: import_zod30.z.string(),
3041
- unplayableReason: import_zod30.z.string().nullable()
3042
- }).nullable(),
3043
- firstReleaseYear: import_zod30.z.number().int().nullable()
3044
- });
3045
- var SongSearchResultsSchema = import_zod30.z.array(SongSearchResultSchema);
3046
- function isSongSearchResultPlayable(result) {
3047
- return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
3048
- }
3049
-
3050
3078
  // src/genre-tree/useSongSearch.ts
3079
+ var import_grow_api7 = require("@behindthemusictree/grow-api");
3051
3080
  var DEFAULT_RESULT_LIMIT = 8;
3052
3081
  function useSongSearch(getBackendBaseUrl, text, options = {}) {
3053
3082
  const playback = usePlaybackContext();
@@ -3059,7 +3088,7 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
3059
3088
  fetch: fetchBound,
3060
3089
  endpoint: libraryEndpoints.reference.songs.search(),
3061
3090
  params,
3062
- schema: SongSearchResultsSchema,
3091
+ schema: import_grow_api7.zV1LibrarySongsSearchListResponse,
3063
3092
  context: "useSongSearch",
3064
3093
  text,
3065
3094
  enabled: playback.ready,
@@ -3070,35 +3099,13 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
3070
3099
 
3071
3100
  // src/genre-tree/useArtistGenreCounts.ts
3072
3101
  var import_react_query7 = require("@tanstack/react-query");
3073
- var import_zod32 = require("zod");
3074
-
3075
- // src/genre-tree/schemas/artist-genre-count.ts
3076
- var import_zod31 = require("zod");
3077
- var ArtistGenreCountSchema = import_zod31.z.object({
3078
- ...GenreCountsSchema.shape,
3079
- catalogue: GenreCatalogueCountsSchema,
3080
- genrePlaylist: GenrePlaylistUuidSchema,
3081
- /** Legacy catalogue count for the default selection. */
3082
- songsCount: import_zod31.z.number().int().nonnegative(),
3083
- /** Legacy playlist count for the default selection. */
3084
- tracksCount: import_zod31.z.number().int().nonnegative()
3085
- }).superRefine((row, ctx) => {
3086
- const counts = GenreCatalogueCountsSchema.safeParse(row);
3087
- if (!counts.success) {
3088
- for (const issue of counts.error.issues) {
3089
- ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
3090
- }
3091
- }
3092
- });
3093
-
3094
- // src/genre-tree/useArtistGenreCounts.ts
3095
3102
  function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
3096
3103
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
3097
3104
  const id = toArtistUuid(artistUuid);
3098
3105
  return useQueryWithParse({
3099
3106
  queryKey: [...artistQueryKeys.genreCounts(getBackendBaseUrl(), id), "genreMusicV1"],
3100
3107
  queryFn: () => fetch2(artistEndpoints.genreCounts(id), true, false),
3101
- schema: import_zod32.z.array(ArtistGenreCountSchema),
3108
+ schema: ReferenceArtistGenreCountsSchema,
3102
3109
  enabled: id !== null,
3103
3110
  placeholderData: import_react_query7.keepPreviousData,
3104
3111
  retry: resourceRetry,
@@ -3257,35 +3264,8 @@ function useGenreSearch({
3257
3264
  };
3258
3265
  }
3259
3266
 
3260
- // src/genre-tree/schemas/genre-search.ts
3261
- var import_zod33 = require("zod");
3262
- var GenreSearchTreeNameSchema = import_zod33.z.enum(["canonical", "regional"]);
3263
- var GenreSearchResultSchema = import_zod33.z.object({
3264
- /** Criteria (genre) uuid. */
3265
- uuid: GenreUuidSchema,
3266
- name: import_zod33.z.string(),
3267
- /** Null for app-created genres, which the Wikidata-keyed region index does not reference. */
3268
- wikidataId: import_zod33.z.string().nullable(),
3269
- treeName: import_zod33.z.string(),
3270
- /** Null when the genre has no playlist in the tree, so it cannot be opened there. */
3271
- genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
3272
- root: import_zod33.z.object({ uuid: GenreUuidSchema, name: import_zod33.z.string() }),
3273
- isUmbrella: import_zod33.z.boolean(),
3274
- viewsCount: import_zod33.z.number().int()
3275
- });
3276
- var GenreSearchResultsSchema = import_zod33.z.array(GenreSearchResultSchema);
3277
- var RegionGenreLexiconEntrySchema = import_zod33.z.object({
3278
- wikidataId: import_zod33.z.string(),
3279
- uuid: GenreUuidSchema,
3280
- name: import_zod33.z.string(),
3281
- treeName: import_zod33.z.string(),
3282
- genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
3283
- isUmbrella: import_zod33.z.boolean(),
3284
- viewsCount: import_zod33.z.number().int()
3285
- });
3286
- var RegionGenreLexiconSchema = import_zod33.z.array(RegionGenreLexiconEntrySchema);
3287
-
3288
3267
  // src/genre-tree/useGenreRemoteSearch.ts
3268
+ var import_grow_api8 = require("@behindthemusictree/grow-api");
3289
3269
  var DEFAULT_RESULT_LIMIT2 = 8;
3290
3270
  function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAULT_RESULT_LIMIT2, enabled } = {}) {
3291
3271
  const params = (q) => ({ q, limit, ...treeName && { treeName } });
@@ -3293,7 +3273,7 @@ function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAU
3293
3273
  queryKey: (q) => genreSearchQueryKeys.search(params(q)),
3294
3274
  endpoint: genreEndpoints.search(),
3295
3275
  params,
3296
- schema: GenreSearchResultsSchema,
3276
+ schema: import_grow_api8.zV1GenresSearchListResponse,
3297
3277
  context: "useGenreRemoteSearch",
3298
3278
  text,
3299
3279
  enabled
@@ -3302,13 +3282,14 @@ function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAU
3302
3282
  }
3303
3283
 
3304
3284
  // src/genre-tree/useRegionGenreLexicon.ts
3285
+ var import_grow_api9 = require("@behindthemusictree/grow-api");
3305
3286
  var EMPTY_ENTRIES = [];
3306
3287
  function useRegionGenreLexicon(getBackendBaseUrl, enabled) {
3307
3288
  const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
3308
3289
  const { data, isError, isPending } = useQueryWithParse({
3309
3290
  queryKey: genreSearchQueryKeys.regionLexicon(),
3310
3291
  queryFn: ({ signal }) => fetch2(genreEndpoints.regionLexicon(), true, false, { signal }),
3311
- schema: RegionGenreLexiconSchema,
3292
+ schema: import_grow_api9.zRegionMapGenresResponse,
3312
3293
  context: "useRegionGenreLexicon",
3313
3294
  enabled,
3314
3295
  staleTime: Infinity
@@ -3324,7 +3305,7 @@ var import_react21 = require("react");
3324
3305
  var import_react20 = require("react");
3325
3306
 
3326
3307
  // src/genre-tree/lib/project-genre-playlists-for-artist.ts
3327
- var ZERO_SCOPED = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { canonical: 0, regional: 0, all: 0 } };
3308
+ var ZERO_SCOPED = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { global: 0, regional: 0, all: 0 } };
3328
3309
  var ZERO_ALL = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { all: 0 } };
3329
3310
  var ZERO_SCOPED_CATALOGUE = GenreCatalogueCountsSchema.parse(ZERO_SCOPED);
3330
3311
  var ZERO_ALL_CATALOGUE = GenreCatalogueCountsSchema.parse(ZERO_ALL);
@@ -3348,7 +3329,7 @@ var projectGenrePlaylistsForArtist = (playlists, counts) => {
3348
3329
  }
3349
3330
  const scopes = playlist.genreAndSubgenresTracksCount;
3350
3331
  if (!scopes) throw new Error(`Artist projections require a reference genre summary (genre playlist ${playlist.uuid})`);
3351
- const isScoped = "canonical" in scopes;
3332
+ const isScoped = "global" in scopes;
3352
3333
  return {
3353
3334
  ...playlist,
3354
3335
  ...isScoped ? ZERO_SCOPED : ZERO_ALL,
@@ -3506,10 +3487,10 @@ function useGenreTreeViewState({
3506
3487
  var import_react23 = require("react");
3507
3488
 
3508
3489
  // src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
3509
- var import_zod34 = require("zod");
3510
- var makeTrackPlaylistRelSchema = (trackSchema) => import_zod34.z.object({
3490
+ var import_zod32 = require("zod");
3491
+ var makeTrackPlaylistRelSchema = (trackSchema) => import_zod32.z.object({
3511
3492
  track: trackSchema,
3512
- position: import_zod34.z.number().min(0)
3493
+ position: import_zod32.z.number().min(0)
3513
3494
  });
3514
3495
  var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
3515
3496
 
@@ -4153,25 +4134,30 @@ function ArtistNames({
4153
4134
  ] }, artist.uuid)) });
4154
4135
  }
4155
4136
 
4137
+ // src/genre-tree/schemas/reference.ts
4138
+ function isSongSearchResultPlayable(result) {
4139
+ return result.youtubeVideo.unplayableReason === null;
4140
+ }
4141
+
4156
4142
  // src/genre-tree/schemas/mb-artist.ts
4157
- var import_zod35 = require("zod");
4158
- var MbArtistDetailedSchema = import_zod35.z.object({
4159
- musicbrainzId: import_zod35.z.string().uuid(),
4160
- name: import_zod35.z.string(),
4143
+ var import_zod33 = require("zod");
4144
+ var MbArtistDetailedSchema = import_zod33.z.object({
4145
+ musicbrainzId: import_zod33.z.string().uuid(),
4146
+ name: import_zod33.z.string(),
4161
4147
  musicbrainzLink: HttpUrlSchema
4162
4148
  });
4163
4149
 
4164
4150
  // src/genre-tree/schemas/mb-recording.ts
4165
- var import_zod36 = require("zod");
4166
- var MbRecordingDetailedSchema = import_zod36.z.object({
4167
- musicbrainzId: import_zod36.z.string().uuid(),
4168
- title: import_zod36.z.string(),
4169
- score: import_zod36.z.number(),
4170
- musicbrainzArtists: import_zod36.z.array(MbArtistDetailedSchema),
4151
+ var import_zod34 = require("zod");
4152
+ var MbRecordingDetailedSchema = import_zod34.z.object({
4153
+ musicbrainzId: import_zod34.z.string().uuid(),
4154
+ title: import_zod34.z.string(),
4155
+ score: import_zod34.z.number(),
4156
+ musicbrainzArtists: import_zod34.z.array(MbArtistDetailedSchema),
4171
4157
  musicbrainzLink: HttpUrlSchema,
4172
- durationInSec: import_zod36.z.number().min(0).nullable().optional(),
4173
- durationStrInHourMinSec: import_zod36.z.string().nullable().optional(),
4174
- releaseDate: import_zod36.z.union([import_zod36.z.string().datetime(), import_zod36.z.string()]).transform((val) => {
4158
+ durationInSec: import_zod34.z.number().min(0).nullable().optional(),
4159
+ durationStrInHourMinSec: import_zod34.z.string().nullable().optional(),
4160
+ releaseDate: import_zod34.z.union([import_zod34.z.string().datetime(), import_zod34.z.string()]).transform((val) => {
4175
4161
  try {
4176
4162
  const date = new Date(val);
4177
4163
  if (isNaN(date.getTime())) {
@@ -4251,8 +4237,6 @@ function editGenreSongPages(data, edit) {
4251
4237
  ArtistMinimumSchema,
4252
4238
  ArtistNames,
4253
4239
  ArtistOriginSchema,
4254
- ArtistSearchResultSchema,
4255
- ArtistSearchResultsSchema,
4256
4240
  ArtistUuidSchema,
4257
4241
  AudioMediaController,
4258
4242
  AuthRequired,
@@ -4285,9 +4269,6 @@ function editGenreSongPages(data, edit) {
4285
4269
  GenreCoverageSchema,
4286
4270
  GenrePlaylistSummarySchema,
4287
4271
  GenrePlaylistUuidSchema,
4288
- GenreSearchResultSchema,
4289
- GenreSearchResultsSchema,
4290
- GenreSearchTreeNameSchema,
4291
4272
  GenreUuidSchema,
4292
4273
  InvalidInputError,
4293
4274
  MbArtistDetailedSchema,
@@ -4303,18 +4284,12 @@ function editGenreSongPages(data, edit) {
4303
4284
  PopupProvider,
4304
4285
  ReferenceGenreDetailedSchema,
4305
4286
  ReferenceGenrePlaylistSchema,
4306
- RegionGenreLexiconEntrySchema,
4307
- RegionGenreLexiconSchema,
4308
4287
  SEARCH_DEBOUNCE_MS,
4309
4288
  SEARCH_QUERY_MIN_LENGTH,
4310
4289
  SPOTIFY_EXCHANGE_CONFIG,
4311
4290
  ServiceError,
4312
4291
  SessionProvider,
4313
4292
  SongDetailedSchema,
4314
- SongHistoryEntrySchema,
4315
- SongHistorySchema,
4316
- SongSearchResultSchema,
4317
- SongSearchResultsSchema,
4318
4293
  SongUuidSchema,
4319
4294
  SubgenreCountsSchema,
4320
4295
  SubgenreScopeSchema,