@behindthemusictree/app-kit 43.1.5 → 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/{chunk-FOSFVEVR.js → chunk-S7GWIIHJ.js} +331 -342
- package/dist/chunk-S7GWIIHJ.js.map +1 -0
- package/dist/genre-tree/index.cjs +334 -359
- package/dist/genre-tree/index.cjs.map +1 -1
- package/dist/genre-tree/index.d.ts +922 -456
- package/dist/genre-tree/index.js +1 -23
- package/dist/index.cjs +317 -342
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -23
- package/package.json +3 -1
- package/dist/chunk-FOSFVEVR.js.map +0 -1
|
@@ -28,8 +28,6 @@ __export(genre_tree_exports, {
|
|
|
28
28
|
ArtistMinimumSchema: () => ArtistMinimumSchema,
|
|
29
29
|
ArtistNames: () => ArtistNames,
|
|
30
30
|
ArtistOriginSchema: () => ArtistOriginSchema,
|
|
31
|
-
ArtistSearchResultSchema: () => ArtistSearchResultSchema,
|
|
32
|
-
ArtistSearchResultsSchema: () => ArtistSearchResultsSchema,
|
|
33
31
|
ArtistUuidSchema: () => ArtistUuidSchema,
|
|
34
32
|
CommonsImageSchema: () => CommonsImageSchema,
|
|
35
33
|
CriteriaCreationSchema: () => CriteriaCreationSchema,
|
|
@@ -50,24 +48,15 @@ __export(genre_tree_exports, {
|
|
|
50
48
|
GenreCoverageSchema: () => GenreCoverageSchema,
|
|
51
49
|
GenrePlaylistSummarySchema: () => GenrePlaylistSummarySchema,
|
|
52
50
|
GenrePlaylistUuidSchema: () => GenrePlaylistUuidSchema,
|
|
53
|
-
GenreSearchResultSchema: () => GenreSearchResultSchema,
|
|
54
|
-
GenreSearchResultsSchema: () => GenreSearchResultsSchema,
|
|
55
|
-
GenreSearchTreeNameSchema: () => GenreSearchTreeNameSchema,
|
|
56
51
|
GenreUuidSchema: () => GenreUuidSchema,
|
|
57
52
|
MbArtistDetailedSchema: () => MbArtistDetailedSchema,
|
|
58
53
|
MbRecordingDetailedSchema: () => MbRecordingDetailedSchema,
|
|
59
54
|
NO_VIDEO_LABEL: () => NO_VIDEO_LABEL,
|
|
60
55
|
ReferenceGenreDetailedSchema: () => ReferenceGenreDetailedSchema,
|
|
61
56
|
ReferenceGenrePlaylistSchema: () => ReferenceGenrePlaylistSchema,
|
|
62
|
-
RegionGenreLexiconEntrySchema: () => RegionGenreLexiconEntrySchema,
|
|
63
|
-
RegionGenreLexiconSchema: () => RegionGenreLexiconSchema,
|
|
64
57
|
SEARCH_DEBOUNCE_MS: () => SEARCH_DEBOUNCE_MS,
|
|
65
58
|
SEARCH_QUERY_MIN_LENGTH: () => SEARCH_QUERY_MIN_LENGTH,
|
|
66
59
|
SongDetailedSchema: () => SongDetailedSchema,
|
|
67
|
-
SongHistoryEntrySchema: () => SongHistoryEntrySchema,
|
|
68
|
-
SongHistorySchema: () => SongHistorySchema,
|
|
69
|
-
SongSearchResultSchema: () => SongSearchResultSchema,
|
|
70
|
-
SongSearchResultsSchema: () => SongSearchResultsSchema,
|
|
71
60
|
SongUuidSchema: () => SongUuidSchema,
|
|
72
61
|
SubgenreCountsSchema: () => SubgenreCountsSchema,
|
|
73
62
|
SubgenreScopeSchema: () => SubgenreScopeSchema,
|
|
@@ -159,10 +148,18 @@ __export(genre_tree_exports, {
|
|
|
159
148
|
module.exports = __toCommonJS(genre_tree_exports);
|
|
160
149
|
|
|
161
150
|
// src/genre-tree/useGenre.ts
|
|
162
|
-
var
|
|
151
|
+
var import_zod25 = require("zod");
|
|
152
|
+
var import_grow_api2 = require("@behindthemusictree/grow-api");
|
|
163
153
|
|
|
164
|
-
// src/genre-tree/schemas/
|
|
165
|
-
var
|
|
154
|
+
// src/genre-tree/schemas/reference-genre.ts
|
|
155
|
+
var import_zod7 = require("zod");
|
|
156
|
+
var import_grow_api = require("@behindthemusictree/grow-api");
|
|
157
|
+
|
|
158
|
+
// src/genre-tree/schemas/criteria-playlist/simple.ts
|
|
159
|
+
var import_zod6 = require("zod");
|
|
160
|
+
|
|
161
|
+
// src/genre-tree/schemas/criteria-playlist/detailed.ts
|
|
162
|
+
var import_zod5 = require("zod");
|
|
166
163
|
|
|
167
164
|
// src/genre-tree/schemas/genre-music.ts
|
|
168
165
|
var import_zod3 = require("zod");
|
|
@@ -195,10 +192,10 @@ var CriteriaPlaylistMinimumSchema = import_zod2.z.object({
|
|
|
195
192
|
// src/genre-tree/schemas/genre-music.ts
|
|
196
193
|
var CountSchema = import_zod3.z.number().int().nonnegative();
|
|
197
194
|
var SubgenreCountsSchema = import_zod3.z.union([
|
|
198
|
-
import_zod3.z.object({
|
|
195
|
+
import_zod3.z.object({ global: CountSchema, regional: CountSchema, all: CountSchema }).strict(),
|
|
199
196
|
import_zod3.z.object({ all: CountSchema }).strict()
|
|
200
197
|
]).refine(
|
|
201
|
-
(counts) => !("
|
|
198
|
+
(counts) => !("global" in counts) || counts.all >= counts.global && counts.all >= counts.regional,
|
|
202
199
|
"The combined count must include both scoped selections"
|
|
203
200
|
);
|
|
204
201
|
var GenreCountsSchema = import_zod3.z.object({
|
|
@@ -209,7 +206,7 @@ var includesDirectSongs = (counts) => Object.values(counts.genreAndSubgenresTrac
|
|
|
209
206
|
var GenreCatalogueCountsSchema = GenreCountsSchema.refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
|
|
210
207
|
var GenrePlaylistSummarySchema = CriteriaPlaylistMinimumSchema.extend(GenreCountsSchema.shape).refine(includesDirectSongs, "Every inclusive count must include the genre itself").brand();
|
|
211
208
|
var GenreCoverageSchema = import_zod3.z.enum(["genreOnly", "genreAndSubgenres"]);
|
|
212
|
-
var SubgenreScopeSchema = import_zod3.z.enum(["
|
|
209
|
+
var SubgenreScopeSchema = import_zod3.z.enum(["global", "regional", "all"]);
|
|
213
210
|
|
|
214
211
|
// src/genre-tree/schemas/criteria/minimum.ts
|
|
215
212
|
var import_zod4 = require("zod");
|
|
@@ -220,109 +217,24 @@ var CriteriaMinimumSchema = import_zod4.z.object({
|
|
|
220
217
|
wikidataId: import_zod4.z.string().nullable().optional()
|
|
221
218
|
});
|
|
222
219
|
|
|
223
|
-
// src/genre-tree/schemas/track/base.ts
|
|
224
|
-
var import_zod8 = require("zod");
|
|
225
|
-
|
|
226
|
-
// src/genre-tree/schemas/artist-minimum.ts
|
|
227
|
-
var import_zod5 = require("zod");
|
|
228
|
-
var ArtistMinimumSchema = import_zod5.z.object({
|
|
229
|
-
uuid: import_zod5.z.string().uuid(),
|
|
230
|
-
name: import_zod5.z.string(),
|
|
231
|
-
isSpecialPurpose: import_zod5.z.boolean().optional()
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
// src/genre-tree/schemas/album-minimum.ts
|
|
235
|
-
var import_zod6 = require("zod");
|
|
236
|
-
var AlbumMinimumSchema = import_zod6.z.object({
|
|
237
|
-
uuid: import_zod6.z.string().uuid(),
|
|
238
|
-
name: import_zod6.z.string(),
|
|
239
|
-
albumArtists: import_zod6.z.array(ArtistMinimumSchema).nullable().optional()
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
// src/genre-tree/schemas/uuid-resource.ts
|
|
243
|
-
var import_zod7 = require("zod");
|
|
244
|
-
var UuidResourceSchema = import_zod7.z.object({
|
|
245
|
-
uuid: import_zod7.z.string().uuid()
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
// src/genre-tree/schemas/track/base.ts
|
|
249
|
-
var TrackBaseSchema = UuidResourceSchema.extend({
|
|
250
|
-
title: import_zod8.z.string(),
|
|
251
|
-
artists: import_zod8.z.array(ArtistMinimumSchema).nullable().optional(),
|
|
252
|
-
album: AlbumMinimumSchema.nullable().optional(),
|
|
253
|
-
trackNumber: import_zod8.z.number().nullable().optional(),
|
|
254
|
-
// null for a song not yet linked to a genre.
|
|
255
|
-
genre: CriteriaMinimumSchema.nullable(),
|
|
256
|
-
rating: import_zod8.z.number().min(0).max(10).nullable().optional(),
|
|
257
|
-
language: import_zod8.z.string().nullable().optional(),
|
|
258
|
-
playCount: import_zod8.z.number().min(0),
|
|
259
|
-
createdOn: import_zod8.z.string().datetime(),
|
|
260
|
-
updatedOn: import_zod8.z.string().datetime().nullable().optional()
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
// src/genre-tree/schemas/track/minimum.ts
|
|
264
|
-
var TrackMinimumSchema = TrackBaseSchema.pick({
|
|
265
|
-
uuid: true,
|
|
266
|
-
title: true,
|
|
267
|
-
artists: true
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
// src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
|
|
271
|
-
var import_zod9 = require("zod");
|
|
272
|
-
var CriteriaLineageRelWithoutAscendantSchema = import_zod9.z.object({
|
|
273
|
-
descendant: CriteriaMinimumSchema,
|
|
274
|
-
degree: import_zod9.z.number()
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
// src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
|
|
278
|
-
var import_zod10 = require("zod");
|
|
279
|
-
var CriteriaLineageRelWithoutDescendantSchema = import_zod10.z.object({
|
|
280
|
-
ascendant: CriteriaMinimumSchema,
|
|
281
|
-
degree: import_zod10.z.number()
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
// src/genre-tree/schemas/criteria/detailed.ts
|
|
285
|
-
var CriteriaDetailedSchema = import_zod11.z.object({
|
|
286
|
-
uuid: GenreUuidSchema,
|
|
287
|
-
name: import_zod11.z.string(),
|
|
288
|
-
summary: import_zod11.z.string().nullable(),
|
|
289
|
-
// Optional until every deployed API serves it.
|
|
290
|
-
wikidataId: import_zod11.z.string().nullable().optional(),
|
|
291
|
-
parent: CriteriaMinimumSchema.nullable(),
|
|
292
|
-
ascendants: import_zod11.z.array(CriteriaLineageRelWithoutDescendantSchema),
|
|
293
|
-
descendants: import_zod11.z.array(CriteriaLineageRelWithoutAscendantSchema).optional(),
|
|
294
|
-
root: CriteriaMinimumSchema,
|
|
295
|
-
children: import_zod11.z.array(CriteriaMinimumSchema),
|
|
296
|
-
catalogue: GenreCatalogueCountsSchema.optional(),
|
|
297
|
-
criteriaPlaylist: import_zod11.z.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]).nullable(),
|
|
298
|
-
tracks: import_zod11.z.array(TrackMinimumSchema).optional(),
|
|
299
|
-
essentialSongs: import_zod11.z.array(TrackMinimumSchema),
|
|
300
|
-
tracksCount: import_zod11.z.number(),
|
|
301
|
-
updatedOn: import_zod11.z.string().datetime().nullable()
|
|
302
|
-
});
|
|
303
|
-
|
|
304
|
-
// src/genre-tree/schemas/criteria-playlist/simple.ts
|
|
305
|
-
var import_zod13 = require("zod");
|
|
306
|
-
|
|
307
220
|
// src/genre-tree/schemas/criteria-playlist/detailed.ts
|
|
308
|
-
var
|
|
309
|
-
var CriteriaPlaylistDetailedSchema = import_zod12.z.object({
|
|
221
|
+
var CriteriaPlaylistDetailedSchema = import_zod5.z.object({
|
|
310
222
|
uuid: GenrePlaylistUuidSchema,
|
|
311
|
-
name:
|
|
312
|
-
tracksCount:
|
|
223
|
+
name: import_zod5.z.string(),
|
|
224
|
+
tracksCount: import_zod5.z.number(),
|
|
313
225
|
genreOnlyTracksCount: GenreCountsSchema.shape.genreOnlyTracksCount.optional(),
|
|
314
226
|
genreAndSubgenresTracksCount: GenreCountsSchema.shape.genreAndSubgenresTracksCount.optional(),
|
|
315
227
|
catalogue: GenreCatalogueCountsSchema.optional(),
|
|
316
228
|
// Summed YouTube views of the same songs as `tracksCount`. Optional: hear-api has no view counts.
|
|
317
|
-
viewsCount:
|
|
318
|
-
durationInSec:
|
|
319
|
-
durationStrInHourMinSec:
|
|
229
|
+
viewsCount: import_zod5.z.number().optional(),
|
|
230
|
+
durationInSec: import_zod5.z.number().min(0).nullable().optional(),
|
|
231
|
+
durationStrInHourMinSec: import_zod5.z.string().nullable().optional(),
|
|
320
232
|
// Nullable: the "Genreless" root playlist has no criteria attached and is never updated.
|
|
321
233
|
criteria: CriteriaMinimumSchema.nullable(),
|
|
322
234
|
parent: CriteriaPlaylistMinimumSchema.nullable(),
|
|
323
235
|
root: CriteriaPlaylistMinimumSchema,
|
|
324
|
-
createdOn:
|
|
325
|
-
updatedOn:
|
|
236
|
+
createdOn: import_zod5.z.string(),
|
|
237
|
+
updatedOn: import_zod5.z.string().nullable()
|
|
326
238
|
});
|
|
327
239
|
|
|
328
240
|
// src/genre-tree/schemas/criteria-playlist/simple.ts
|
|
@@ -341,24 +253,44 @@ var CriteriaPlaylistSimpleSchema = CriteriaPlaylistDetailedSchema.pick({
|
|
|
341
253
|
updatedOn: true
|
|
342
254
|
}).extend({
|
|
343
255
|
// Only on the tree/list payloads, not the detail endpoint — hence not on the detailed schema.
|
|
344
|
-
isUnacceptedRoot:
|
|
256
|
+
isUnacceptedRoot: import_zod6.z.boolean(),
|
|
345
257
|
// Optional: a backend that does not curate umbrella genres omits it.
|
|
346
|
-
isUmbrella:
|
|
258
|
+
isUmbrella: import_zod6.z.boolean().optional(),
|
|
347
259
|
// Optional: only the grow tree payload carries it; null when the genre has no scene.
|
|
348
|
-
scene:
|
|
260
|
+
scene: import_zod6.z.enum(["commercial", "underground"]).nullable().optional()
|
|
349
261
|
});
|
|
350
262
|
|
|
351
263
|
// src/genre-tree/schemas/reference-genre.ts
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
264
|
+
function checkGenreCounts(counts, path, ctx) {
|
|
265
|
+
const inclusive = counts.genreAndSubgenresTracksCount;
|
|
266
|
+
const issue = (message) => ctx.addIssue({ code: "custom", path: [...path, "genreAndSubgenresTracksCount"], message });
|
|
267
|
+
if (!Object.values(inclusive).every((count) => count >= counts.genreOnlyTracksCount)) {
|
|
268
|
+
issue("Every inclusive count must include the genre itself");
|
|
269
|
+
}
|
|
270
|
+
if ("global" in inclusive && !(inclusive.all >= inclusive.global && inclusive.all >= (inclusive.regional ?? 0))) {
|
|
271
|
+
issue("The combined count must include both scoped selections");
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
var ReferenceGenreDetailedSchema = import_grow_api.zV1GenresRetrieveResponse.extend({ criteriaPlaylist: import_grow_api.zV1GenresRetrieveResponse.shape.criteriaPlaylist.nullable() }).superRefine((genre, ctx) => {
|
|
275
|
+
checkGenreCounts(genre.catalogue, ["catalogue"], ctx);
|
|
276
|
+
if (genre.criteriaPlaylist) checkGenreCounts(genre.criteriaPlaylist, ["criteriaPlaylist"], ctx);
|
|
355
277
|
});
|
|
356
|
-
var
|
|
278
|
+
var generatedTreeRow = import_grow_api.zV1GenrePlaylistsTreeListResponse.element;
|
|
279
|
+
var ReferenceGenrePlaylistRowSchema = generatedTreeRow.extend({
|
|
357
280
|
...GenreCountsSchema.shape,
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
281
|
+
criteria: generatedTreeRow.shape.criteria.extend({ parent: generatedTreeRow.shape.criteria.shape.parent.nullable() }).nullable(),
|
|
282
|
+
parent: generatedTreeRow.shape.parent.nullable()
|
|
283
|
+
});
|
|
284
|
+
var ReferenceGenrePlaylistSchema = import_zod7.z.array(ReferenceGenrePlaylistRowSchema).superRefine((playlists, ctx) => {
|
|
285
|
+
playlists.forEach((playlist, index) => {
|
|
286
|
+
checkGenreCounts(playlist, [index], ctx);
|
|
287
|
+
checkGenreCounts(playlist.catalogue, [index, "catalogue"], ctx);
|
|
288
|
+
});
|
|
289
|
+
}).transform((playlists, ctx) => {
|
|
290
|
+
const branded = import_zod7.z.array(CriteriaPlaylistSimpleSchema).safeParse(playlists);
|
|
291
|
+
if (branded.success) return branded.data;
|
|
292
|
+
for (const issue of branded.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
293
|
+
return import_zod7.z.NEVER;
|
|
362
294
|
});
|
|
363
295
|
|
|
364
296
|
// src/genre-tree/useGenre.ts
|
|
@@ -878,14 +810,14 @@ var useFetchWrapper = (getBackendBaseUrl) => {
|
|
|
878
810
|
};
|
|
879
811
|
|
|
880
812
|
// src/genre-tree/useGenrePlaylist.ts
|
|
881
|
-
var
|
|
813
|
+
var import_zod10 = require("zod");
|
|
882
814
|
var import_react_query3 = require("@tanstack/react-query");
|
|
883
815
|
|
|
884
816
|
// src/transport/lib/use-query-with-parse.ts
|
|
885
817
|
var import_react_query2 = require("@tanstack/react-query");
|
|
886
818
|
|
|
887
819
|
// src/transport/lib/parse-with-log.ts
|
|
888
|
-
var
|
|
820
|
+
var import_zod8 = require("zod");
|
|
889
821
|
function parseWithLog(schema, data, context) {
|
|
890
822
|
const result = schema.safeParse(data);
|
|
891
823
|
if (!result.success) {
|
|
@@ -893,7 +825,7 @@ function parseWithLog(schema, data, context) {
|
|
|
893
825
|
if (data == null) {
|
|
894
826
|
throw new Error(`${prefix} received null response before schema validation`);
|
|
895
827
|
}
|
|
896
|
-
console.error(`${prefix} schema validation failed`,
|
|
828
|
+
console.error(`${prefix} schema validation failed`, import_zod8.z.flattenError(result.error));
|
|
897
829
|
throw result.error;
|
|
898
830
|
}
|
|
899
831
|
return result.data;
|
|
@@ -916,15 +848,15 @@ function useQueryWithParse({
|
|
|
916
848
|
}
|
|
917
849
|
|
|
918
850
|
// src/transport/lib/paginated-response.ts
|
|
919
|
-
var
|
|
920
|
-
var PaginatedResponseSchema = (itemSchema) =>
|
|
921
|
-
overallTotal:
|
|
922
|
-
next:
|
|
923
|
-
previous:
|
|
924
|
-
results:
|
|
925
|
-
page:
|
|
926
|
-
pageSize:
|
|
927
|
-
totalPages:
|
|
851
|
+
var import_zod9 = require("zod");
|
|
852
|
+
var PaginatedResponseSchema = (itemSchema) => import_zod9.z.object({
|
|
853
|
+
overallTotal: import_zod9.z.number(),
|
|
854
|
+
next: import_zod9.z.string().url().nullable(),
|
|
855
|
+
previous: import_zod9.z.string().url().nullable(),
|
|
856
|
+
results: import_zod9.z.array(itemSchema),
|
|
857
|
+
page: import_zod9.z.number(),
|
|
858
|
+
pageSize: import_zod9.z.number(),
|
|
859
|
+
totalPages: import_zod9.z.number()
|
|
928
860
|
});
|
|
929
861
|
|
|
930
862
|
// src/genre-tree/api/genre-playlists/queryKeys.ts
|
|
@@ -964,13 +896,13 @@ var genrePlaylistEndpoints = {
|
|
|
964
896
|
|
|
965
897
|
// src/genre-tree/lib/genre-music-selection.ts
|
|
966
898
|
function defaultGenreMusicSelection(counts) {
|
|
967
|
-
return { coverage: "genreAndSubgenres", subgenres: "
|
|
899
|
+
return { coverage: "genreAndSubgenres", subgenres: "global" in counts.genreAndSubgenresTracksCount ? "global" : "all" };
|
|
968
900
|
}
|
|
969
901
|
function genreMusicCount(counts, selection = defaultGenreMusicSelection(counts)) {
|
|
970
902
|
if (selection.coverage === "genreOnly") return counts.genreOnlyTracksCount;
|
|
971
903
|
const scopes = counts.genreAndSubgenresTracksCount;
|
|
972
904
|
if (selection.subgenres === "all") return scopes.all;
|
|
973
|
-
if (!("
|
|
905
|
+
if (!("global" in scopes)) throw new Error("Regional genres only support all subgenres");
|
|
974
906
|
return scopes[selection.subgenres];
|
|
975
907
|
}
|
|
976
908
|
function genreMusicQueryParams(selection) {
|
|
@@ -1067,16 +999,16 @@ var useListFullGenrePlaylists = (scope, getBackendBaseUrl) => {
|
|
|
1067
999
|
const queryKey = scope === "reference" ? [...genrePlaylistQueryKeys.reference.full(getBackendBaseUrl()), "genreMusicV1"] : genrePlaylistQueryKeys.me.full;
|
|
1068
1000
|
const query = useQueryWithParse({
|
|
1069
1001
|
queryKey,
|
|
1070
|
-
queryFn: () => scope === "reference" ? fetch2(genrePlaylistEndpoints.reference.tree(), true, false, {}, { treeName: "
|
|
1002
|
+
queryFn: () => scope === "reference" ? fetch2(genrePlaylistEndpoints.reference.tree(), true, false, {}, { treeName: "global" }) : fetchAllPages(
|
|
1071
1003
|
(page) => fetch2(
|
|
1072
1004
|
genrePlaylistEndpoints.me.list(),
|
|
1073
1005
|
true,
|
|
1074
1006
|
true,
|
|
1075
1007
|
{},
|
|
1076
|
-
{ page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "
|
|
1008
|
+
{ page, pageSize: FULL_LIST_PAGE_SIZE, treeName: "global" }
|
|
1077
1009
|
)
|
|
1078
1010
|
),
|
|
1079
|
-
schema: scope === "reference" ?
|
|
1011
|
+
schema: scope === "reference" ? ReferenceGenrePlaylistSchema : import_zod10.z.array(CriteriaPlaylistSimpleSchema),
|
|
1080
1012
|
context: "useListFullGenrePlaylists",
|
|
1081
1013
|
enabled: scope === "reference" || sessionRestored && !!session?.accessToken
|
|
1082
1014
|
});
|
|
@@ -1112,7 +1044,7 @@ var useInvalidateAllGenrePlaylistQueries = () => {
|
|
|
1112
1044
|
// src/transport/lib/use-validated-mutation.ts
|
|
1113
1045
|
var import_react_query4 = require("@tanstack/react-query");
|
|
1114
1046
|
var import_react5 = require("react");
|
|
1115
|
-
var
|
|
1047
|
+
var import_zod11 = require("zod");
|
|
1116
1048
|
function useValidatedMutation({
|
|
1117
1049
|
inputSchema,
|
|
1118
1050
|
outputSchema,
|
|
@@ -1145,9 +1077,9 @@ function useValidatedMutation({
|
|
|
1145
1077
|
} catch (error) {
|
|
1146
1078
|
if (error instanceof Error && "json" in error) {
|
|
1147
1079
|
try {
|
|
1148
|
-
const errorResponse =
|
|
1149
|
-
details:
|
|
1150
|
-
fieldErrors:
|
|
1080
|
+
const errorResponse = import_zod11.z.object({
|
|
1081
|
+
details: import_zod11.z.object({
|
|
1082
|
+
fieldErrors: import_zod11.z.record(import_zod11.z.string(), import_zod11.z.array(import_zod11.z.object({ message: import_zod11.z.string() })))
|
|
1151
1083
|
})
|
|
1152
1084
|
}).parse(error.json);
|
|
1153
1085
|
setFormErrors(
|
|
@@ -1181,62 +1113,146 @@ function toResourceResult({ id, isValidId, data, error, isPending }) {
|
|
|
1181
1113
|
return { status: "success", data };
|
|
1182
1114
|
}
|
|
1183
1115
|
|
|
1116
|
+
// src/genre-tree/schemas/criteria/detailed.ts
|
|
1117
|
+
var import_zod18 = require("zod");
|
|
1118
|
+
|
|
1119
|
+
// src/genre-tree/schemas/track/base.ts
|
|
1120
|
+
var import_zod15 = require("zod");
|
|
1121
|
+
|
|
1122
|
+
// src/genre-tree/schemas/artist-minimum.ts
|
|
1123
|
+
var import_zod12 = require("zod");
|
|
1124
|
+
var ArtistMinimumSchema = import_zod12.z.object({
|
|
1125
|
+
uuid: import_zod12.z.string().uuid(),
|
|
1126
|
+
name: import_zod12.z.string(),
|
|
1127
|
+
isSpecialPurpose: import_zod12.z.boolean().optional()
|
|
1128
|
+
});
|
|
1129
|
+
|
|
1130
|
+
// src/genre-tree/schemas/album-minimum.ts
|
|
1131
|
+
var import_zod13 = require("zod");
|
|
1132
|
+
var AlbumMinimumSchema = import_zod13.z.object({
|
|
1133
|
+
uuid: import_zod13.z.string().uuid(),
|
|
1134
|
+
name: import_zod13.z.string(),
|
|
1135
|
+
albumArtists: import_zod13.z.array(ArtistMinimumSchema).nullable().optional()
|
|
1136
|
+
});
|
|
1137
|
+
|
|
1138
|
+
// src/genre-tree/schemas/uuid-resource.ts
|
|
1139
|
+
var import_zod14 = require("zod");
|
|
1140
|
+
var UuidResourceSchema = import_zod14.z.object({
|
|
1141
|
+
uuid: import_zod14.z.string().uuid()
|
|
1142
|
+
});
|
|
1143
|
+
|
|
1144
|
+
// src/genre-tree/schemas/track/base.ts
|
|
1145
|
+
var TrackBaseSchema = UuidResourceSchema.extend({
|
|
1146
|
+
title: import_zod15.z.string(),
|
|
1147
|
+
artists: import_zod15.z.array(ArtistMinimumSchema).nullable().optional(),
|
|
1148
|
+
album: AlbumMinimumSchema.nullable().optional(),
|
|
1149
|
+
trackNumber: import_zod15.z.number().nullable().optional(),
|
|
1150
|
+
// null for a song not yet linked to a genre.
|
|
1151
|
+
genre: CriteriaMinimumSchema.nullable(),
|
|
1152
|
+
rating: import_zod15.z.number().min(0).max(10).nullable().optional(),
|
|
1153
|
+
language: import_zod15.z.string().nullable().optional(),
|
|
1154
|
+
playCount: import_zod15.z.number().min(0),
|
|
1155
|
+
createdOn: import_zod15.z.string().datetime(),
|
|
1156
|
+
updatedOn: import_zod15.z.string().datetime().nullable().optional()
|
|
1157
|
+
});
|
|
1158
|
+
|
|
1159
|
+
// src/genre-tree/schemas/track/minimum.ts
|
|
1160
|
+
var TrackMinimumSchema = TrackBaseSchema.pick({
|
|
1161
|
+
uuid: true,
|
|
1162
|
+
title: true,
|
|
1163
|
+
artists: true
|
|
1164
|
+
});
|
|
1165
|
+
|
|
1166
|
+
// src/genre-tree/schemas/criteria/lineage-rel/without-ascendant.ts
|
|
1167
|
+
var import_zod16 = require("zod");
|
|
1168
|
+
var CriteriaLineageRelWithoutAscendantSchema = import_zod16.z.object({
|
|
1169
|
+
descendant: CriteriaMinimumSchema,
|
|
1170
|
+
degree: import_zod16.z.number()
|
|
1171
|
+
});
|
|
1172
|
+
|
|
1173
|
+
// src/genre-tree/schemas/criteria/lineage-rel/without-descendant.ts
|
|
1174
|
+
var import_zod17 = require("zod");
|
|
1175
|
+
var CriteriaLineageRelWithoutDescendantSchema = import_zod17.z.object({
|
|
1176
|
+
ascendant: CriteriaMinimumSchema,
|
|
1177
|
+
degree: import_zod17.z.number()
|
|
1178
|
+
});
|
|
1179
|
+
|
|
1180
|
+
// src/genre-tree/schemas/criteria/detailed.ts
|
|
1181
|
+
var CriteriaDetailedSchema = import_zod18.z.object({
|
|
1182
|
+
uuid: GenreUuidSchema,
|
|
1183
|
+
name: import_zod18.z.string(),
|
|
1184
|
+
summary: import_zod18.z.string().nullable(),
|
|
1185
|
+
// Optional until every deployed API serves it.
|
|
1186
|
+
wikidataId: import_zod18.z.string().nullable().optional(),
|
|
1187
|
+
parent: CriteriaMinimumSchema.nullable(),
|
|
1188
|
+
ascendants: import_zod18.z.array(CriteriaLineageRelWithoutDescendantSchema),
|
|
1189
|
+
descendants: import_zod18.z.array(CriteriaLineageRelWithoutAscendantSchema).optional(),
|
|
1190
|
+
root: CriteriaMinimumSchema,
|
|
1191
|
+
children: import_zod18.z.array(CriteriaMinimumSchema),
|
|
1192
|
+
catalogue: GenreCatalogueCountsSchema.optional(),
|
|
1193
|
+
criteriaPlaylist: import_zod18.z.union([GenrePlaylistSummarySchema, CriteriaPlaylistMinimumSchema]).nullable(),
|
|
1194
|
+
tracks: import_zod18.z.array(TrackMinimumSchema).optional(),
|
|
1195
|
+
essentialSongs: import_zod18.z.array(TrackMinimumSchema),
|
|
1196
|
+
tracksCount: import_zod18.z.number(),
|
|
1197
|
+
updatedOn: import_zod18.z.string().datetime().nullable()
|
|
1198
|
+
});
|
|
1199
|
+
|
|
1184
1200
|
// src/genre-tree/schemas/criteria/overview.ts
|
|
1185
|
-
var
|
|
1201
|
+
var import_zod21 = require("zod");
|
|
1186
1202
|
|
|
1187
1203
|
// src/genre-tree/schemas/commons-image.ts
|
|
1188
|
-
var
|
|
1204
|
+
var import_zod20 = require("zod");
|
|
1189
1205
|
|
|
1190
1206
|
// src/genre-tree/schemas/http-url.ts
|
|
1191
|
-
var
|
|
1192
|
-
var HttpUrlSchema =
|
|
1207
|
+
var import_zod19 = require("zod");
|
|
1208
|
+
var HttpUrlSchema = import_zod19.z.url({ protocol: /^https?$/ });
|
|
1193
1209
|
|
|
1194
1210
|
// src/genre-tree/schemas/commons-image.ts
|
|
1195
|
-
var CommonsImageSchema =
|
|
1211
|
+
var CommonsImageSchema = import_zod20.z.object({
|
|
1196
1212
|
url: HttpUrlSchema,
|
|
1197
1213
|
pageUrl: HttpUrlSchema,
|
|
1198
|
-
author:
|
|
1199
|
-
license:
|
|
1214
|
+
author: import_zod20.z.string().nullable(),
|
|
1215
|
+
license: import_zod20.z.string(),
|
|
1200
1216
|
licenseUrl: HttpUrlSchema.nullable()
|
|
1201
1217
|
});
|
|
1202
1218
|
|
|
1203
1219
|
// src/genre-tree/schemas/criteria/overview.ts
|
|
1204
|
-
var CriteriaOverviewSchema =
|
|
1220
|
+
var CriteriaOverviewSchema = import_zod21.z.object({
|
|
1205
1221
|
uuid: GenreUuidSchema,
|
|
1206
|
-
name:
|
|
1207
|
-
summary:
|
|
1208
|
-
description:
|
|
1222
|
+
name: import_zod21.z.string(),
|
|
1223
|
+
summary: import_zod21.z.string().nullable(),
|
|
1224
|
+
description: import_zod21.z.string().nullable(),
|
|
1209
1225
|
summarySourceUrl: HttpUrlSchema.nullable(),
|
|
1210
1226
|
// Optional: hosts whose API does not send it (e.g. hear) stay valid.
|
|
1211
1227
|
image: CommonsImageSchema.nullable().optional(),
|
|
1212
|
-
essentialSongs:
|
|
1228
|
+
essentialSongs: import_zod21.z.array(TrackMinimumSchema).optional()
|
|
1213
1229
|
});
|
|
1214
1230
|
|
|
1215
1231
|
// src/genre-tree/schemas/criteria/simple.ts
|
|
1216
|
-
var
|
|
1217
|
-
var CriteriaSimpleSchema =
|
|
1232
|
+
var import_zod22 = require("zod");
|
|
1233
|
+
var CriteriaSimpleSchema = import_zod22.z.object({
|
|
1218
1234
|
uuid: GenreUuidSchema,
|
|
1219
|
-
name:
|
|
1235
|
+
name: import_zod22.z.string(),
|
|
1220
1236
|
parent: CriteriaMinimumSchema.nullable(),
|
|
1221
|
-
createdOn:
|
|
1222
|
-
summary:
|
|
1237
|
+
createdOn: import_zod22.z.string().datetime(),
|
|
1238
|
+
summary: import_zod22.z.string().nullable()
|
|
1223
1239
|
});
|
|
1224
1240
|
|
|
1225
1241
|
// src/genre-tree/schemas/criteria/creation.ts
|
|
1226
|
-
var
|
|
1227
|
-
var CriteriaCreationSchema =
|
|
1228
|
-
name:
|
|
1242
|
+
var import_zod23 = require("zod");
|
|
1243
|
+
var CriteriaCreationSchema = import_zod23.z.object({
|
|
1244
|
+
name: import_zod23.z.string().min(1, "Name is required"),
|
|
1229
1245
|
parent: GenreUuidSchema.optional(),
|
|
1230
|
-
essentialSongs:
|
|
1246
|
+
essentialSongs: import_zod23.z.array(import_zod23.z.string().uuid()).optional()
|
|
1231
1247
|
});
|
|
1232
1248
|
|
|
1233
1249
|
// src/genre-tree/schemas/criteria/update.ts
|
|
1234
|
-
var
|
|
1235
|
-
var CriteriaUpdateSchema =
|
|
1236
|
-
name:
|
|
1250
|
+
var import_zod24 = require("zod");
|
|
1251
|
+
var CriteriaUpdateSchema = import_zod24.z.object({
|
|
1252
|
+
name: import_zod24.z.string().optional(),
|
|
1237
1253
|
parent: GenreUuidSchema.nullable().optional(),
|
|
1238
|
-
essentialSongs:
|
|
1239
|
-
side:
|
|
1254
|
+
essentialSongs: import_zod24.z.array(import_zod24.z.string().uuid()).optional(),
|
|
1255
|
+
side: import_zod24.z.enum(["core", "pop"]).optional()
|
|
1240
1256
|
});
|
|
1241
1257
|
|
|
1242
1258
|
// src/genre-tree/api/genres/queryKeys.ts
|
|
@@ -1279,6 +1295,9 @@ var genreEndpoints = {
|
|
|
1279
1295
|
};
|
|
1280
1296
|
|
|
1281
1297
|
// src/genre-tree/useGenre.ts
|
|
1298
|
+
function schemaForScope(scope, reference, me) {
|
|
1299
|
+
return scope === "reference" ? reference : me;
|
|
1300
|
+
}
|
|
1282
1301
|
function useListGenres(page = 1, pageSize = 50, scope, getBackendBaseUrl) {
|
|
1283
1302
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
1284
1303
|
const { session, sessionRestored } = useSession();
|
|
@@ -1286,7 +1305,7 @@ function useListGenres(page = 1, pageSize = 50, scope, getBackendBaseUrl) {
|
|
|
1286
1305
|
return useQueryWithParse({
|
|
1287
1306
|
queryKey: scope === "reference" ? genreQueryKeys.reference.list(page) : genreQueryKeys.me.list(page),
|
|
1288
1307
|
queryFn: () => fetch2(endpoint, true, scope === "me", {}, { page, pageSize }),
|
|
1289
|
-
schema: PaginatedResponseSchema(CriteriaSimpleSchema),
|
|
1308
|
+
schema: schemaForScope(scope, import_grow_api2.zV1GenresListResponse, PaginatedResponseSchema(CriteriaSimpleSchema)),
|
|
1290
1309
|
context: "useListGenres",
|
|
1291
1310
|
enabled: scope === "reference" || sessionRestored && !!session?.accessToken
|
|
1292
1311
|
});
|
|
@@ -1297,12 +1316,12 @@ function useFetchGenre(scope, getBackendBaseUrl) {
|
|
|
1297
1316
|
async (id) => {
|
|
1298
1317
|
const endpoint = scope === "reference" ? genreEndpoints.reference.detail(id) : genreEndpoints.me.detail(id);
|
|
1299
1318
|
const response = await fetch2(endpoint, true, scope === "me");
|
|
1300
|
-
return parseWithLog(scope
|
|
1319
|
+
return parseWithLog(schemaForScope(scope, ReferenceGenreDetailedSchema, CriteriaDetailedSchema), response, "useFetchGenre");
|
|
1301
1320
|
},
|
|
1302
1321
|
[fetch2, scope]
|
|
1303
1322
|
);
|
|
1304
1323
|
}
|
|
1305
|
-
function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = scope
|
|
1324
|
+
function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = schemaForScope(scope, ReferenceGenreDetailedSchema, CriteriaDetailedSchema)) {
|
|
1306
1325
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
1307
1326
|
const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
|
|
1308
1327
|
const endpoints = scope === "reference" ? genreEndpoints.reference : genreEndpoints.me;
|
|
@@ -1319,7 +1338,6 @@ function useFetchGenreDetail(id, scope, getBackendBaseUrl, schema = scope === "r
|
|
|
1319
1338
|
const result = toResourceResult({ id, isValidId: validUuid !== null, data, error, isPending });
|
|
1320
1339
|
return result.status === "success" ? { status: "success", genre: result.data } : result;
|
|
1321
1340
|
}
|
|
1322
|
-
var GenreByWikidataIdSchema = PaginatedResponseSchema(CriteriaMinimumSchema);
|
|
1323
1341
|
function useGenreByWikidataId(qid, scope, getBackendBaseUrl) {
|
|
1324
1342
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
1325
1343
|
const queryKeys = scope === "reference" ? genreQueryKeys.reference : genreQueryKeys.me;
|
|
@@ -1327,12 +1345,13 @@ function useGenreByWikidataId(qid, scope, getBackendBaseUrl) {
|
|
|
1327
1345
|
const { data, ...rest } = useQueryWithParse({
|
|
1328
1346
|
queryKey: queryKeys.byWikidataId(qid ?? ""),
|
|
1329
1347
|
queryFn: () => fetch2(endpoints.list(), true, scope === "me", {}, { wikidataId: qid ?? "", pageSize: 1 }),
|
|
1330
|
-
schema:
|
|
1348
|
+
schema: schemaForScope(scope, import_grow_api2.zV1GenresListResponse, PaginatedResponseSchema(CriteriaMinimumSchema)),
|
|
1331
1349
|
context: "useGenreByWikidataId",
|
|
1332
1350
|
enabled: qid !== null
|
|
1333
1351
|
});
|
|
1334
1352
|
return { ...rest, data: data === void 0 ? void 0 : data.results[0] ?? null };
|
|
1335
1353
|
}
|
|
1354
|
+
var defaultOverviewSchema = (scope) => schemaForScope(scope, import_grow_api2.zV1GenresOverviewRetrieveResponse, CriteriaOverviewSchema);
|
|
1336
1355
|
var GENRE_OVERVIEW_STALE_TIME_MS = 6e4;
|
|
1337
1356
|
function useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema) {
|
|
1338
1357
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
@@ -1350,11 +1369,11 @@ function useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema) {
|
|
|
1350
1369
|
[fetch2, scope, schema]
|
|
1351
1370
|
);
|
|
1352
1371
|
}
|
|
1353
|
-
function useFetchGenreOverview(id, scope, getBackendBaseUrl, schema =
|
|
1372
|
+
function useFetchGenreOverview(id, scope, getBackendBaseUrl, schema = defaultOverviewSchema(scope)) {
|
|
1354
1373
|
const queryOptions = useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema);
|
|
1355
1374
|
return (0, import_react_query5.useQuery)({ ...queryOptions(id ?? ""), enabled: id !== null });
|
|
1356
1375
|
}
|
|
1357
|
-
function usePrefetchGenreOverview(scope, getBackendBaseUrl, schema =
|
|
1376
|
+
function usePrefetchGenreOverview(scope, getBackendBaseUrl, schema = defaultOverviewSchema(scope)) {
|
|
1358
1377
|
const queryClient2 = (0, import_react_query5.useQueryClient)();
|
|
1359
1378
|
const queryOptions = useGenreOverviewQueryOptions(scope, getBackendBaseUrl, schema);
|
|
1360
1379
|
return (0, import_react6.useCallback)((id) => queryClient2.prefetchQuery(queryOptions(id)), [queryClient2, queryOptions]);
|
|
@@ -1396,7 +1415,7 @@ function useUpdateGenre(scope, getBackendBaseUrl) {
|
|
|
1396
1415
|
const refreshGenreTree = useRefreshGenreTree(scope);
|
|
1397
1416
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
1398
1417
|
const { mutate, mutateAsync, isPending, formErrors } = useValidatedMutation({
|
|
1399
|
-
inputSchema:
|
|
1418
|
+
inputSchema: import_zod25.z.object({
|
|
1400
1419
|
uuid: GenreUuidSchema,
|
|
1401
1420
|
data: CriteriaUpdateSchema
|
|
1402
1421
|
}),
|
|
@@ -1426,8 +1445,8 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
|
|
|
1426
1445
|
const refreshGenreTree = useRefreshGenreTree(scope);
|
|
1427
1446
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
1428
1447
|
return useValidatedMutation({
|
|
1429
|
-
inputSchema:
|
|
1430
|
-
outputSchema:
|
|
1448
|
+
inputSchema: import_zod25.z.object({ uuid: GenreUuidSchema }),
|
|
1449
|
+
outputSchema: import_zod25.z.null(),
|
|
1431
1450
|
mutationFn: async ({ uuid }) => {
|
|
1432
1451
|
const endpoint = scope === "reference" ? genreEndpoints.reference.delete(uuid) : genreEndpoints.me.delete(uuid);
|
|
1433
1452
|
return fetch2(endpoint, true, scope === "me", { method: "DELETE" }, void 0, false, true);
|
|
@@ -1436,14 +1455,18 @@ function useDeleteGenre(scope, getBackendBaseUrl) {
|
|
|
1436
1455
|
});
|
|
1437
1456
|
}
|
|
1438
1457
|
|
|
1458
|
+
// src/genre-tree/schemas/reference-artist.ts
|
|
1459
|
+
var import_zod28 = require("zod");
|
|
1460
|
+
var import_grow_api3 = require("@behindthemusictree/grow-api");
|
|
1461
|
+
|
|
1439
1462
|
// src/genre-tree/schemas/artist-detailed.ts
|
|
1440
|
-
var
|
|
1441
|
-
var ArtistMembershipSchema =
|
|
1463
|
+
var import_zod26 = require("zod");
|
|
1464
|
+
var ArtistMembershipSchema = import_zod26.z.object({
|
|
1442
1465
|
artist: ArtistMinimumSchema,
|
|
1443
|
-
beginYear:
|
|
1444
|
-
endYear:
|
|
1445
|
-
ended:
|
|
1446
|
-
roles:
|
|
1466
|
+
beginYear: import_zod26.z.number().int().nullable(),
|
|
1467
|
+
endYear: import_zod26.z.number().int().nullable(),
|
|
1468
|
+
ended: import_zod26.z.boolean(),
|
|
1469
|
+
roles: import_zod26.z.array(import_zod26.z.string())
|
|
1447
1470
|
});
|
|
1448
1471
|
var ARTIST_LINK_KINDS = [
|
|
1449
1472
|
"official",
|
|
@@ -1457,42 +1480,75 @@ var ARTIST_LINK_KINDS = [
|
|
|
1457
1480
|
"social"
|
|
1458
1481
|
];
|
|
1459
1482
|
var ArtistImageSchema = CommonsImageSchema;
|
|
1460
|
-
var ArtistOriginSchema =
|
|
1461
|
-
name:
|
|
1462
|
-
kind:
|
|
1463
|
-
source:
|
|
1464
|
-
wikidataId:
|
|
1465
|
-
longitude:
|
|
1466
|
-
latitude:
|
|
1467
|
-
regionId:
|
|
1483
|
+
var ArtistOriginSchema = import_zod26.z.object({
|
|
1484
|
+
name: import_zod26.z.string(),
|
|
1485
|
+
kind: import_zod26.z.string().nullable(),
|
|
1486
|
+
source: import_zod26.z.enum(["begin_area", "area"]),
|
|
1487
|
+
wikidataId: import_zod26.z.string().nullable(),
|
|
1488
|
+
longitude: import_zod26.z.number().nullable(),
|
|
1489
|
+
latitude: import_zod26.z.number().nullable(),
|
|
1490
|
+
regionId: import_zod26.z.string().nullable()
|
|
1468
1491
|
});
|
|
1469
|
-
var ArtistDetailedSchema =
|
|
1470
|
-
uuid:
|
|
1471
|
-
name:
|
|
1472
|
-
musicbrainzArtistId:
|
|
1473
|
-
type:
|
|
1474
|
-
country:
|
|
1475
|
-
beginYear:
|
|
1476
|
-
endYear:
|
|
1477
|
-
ended:
|
|
1478
|
-
links:
|
|
1479
|
-
members:
|
|
1480
|
-
memberOf:
|
|
1481
|
-
albums:
|
|
1482
|
-
|
|
1483
|
-
uuid:
|
|
1484
|
-
name:
|
|
1485
|
-
year:
|
|
1486
|
-
primaryType:
|
|
1487
|
-
secondaryTypes:
|
|
1492
|
+
var ArtistDetailedSchema = import_zod26.z.object({
|
|
1493
|
+
uuid: import_zod26.z.string().uuid(),
|
|
1494
|
+
name: import_zod26.z.string(),
|
|
1495
|
+
musicbrainzArtistId: import_zod26.z.string().uuid().nullable(),
|
|
1496
|
+
type: import_zod26.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
|
|
1497
|
+
country: import_zod26.z.string().nullable(),
|
|
1498
|
+
beginYear: import_zod26.z.number().int().nullable(),
|
|
1499
|
+
endYear: import_zod26.z.number().int().nullable(),
|
|
1500
|
+
ended: import_zod26.z.boolean(),
|
|
1501
|
+
links: import_zod26.z.array(import_zod26.z.object({ kind: import_zod26.z.enum(ARTIST_LINK_KINDS), url: HttpUrlSchema })),
|
|
1502
|
+
members: import_zod26.z.array(ArtistMembershipSchema),
|
|
1503
|
+
memberOf: import_zod26.z.array(ArtistMembershipSchema),
|
|
1504
|
+
albums: import_zod26.z.array(
|
|
1505
|
+
import_zod26.z.object({
|
|
1506
|
+
uuid: import_zod26.z.string().uuid(),
|
|
1507
|
+
name: import_zod26.z.string(),
|
|
1508
|
+
year: import_zod26.z.string().nullable(),
|
|
1509
|
+
primaryType: import_zod26.z.string().nullable(),
|
|
1510
|
+
secondaryTypes: import_zod26.z.array(import_zod26.z.string())
|
|
1488
1511
|
})
|
|
1489
1512
|
),
|
|
1490
|
-
tracksCount:
|
|
1491
|
-
playableTracksCount:
|
|
1513
|
+
tracksCount: import_zod26.z.number().int(),
|
|
1514
|
+
playableTracksCount: import_zod26.z.number().int(),
|
|
1492
1515
|
image: ArtistImageSchema.nullable(),
|
|
1493
1516
|
origin: ArtistOriginSchema.nullable()
|
|
1494
1517
|
});
|
|
1495
1518
|
|
|
1519
|
+
// src/genre-tree/schemas/artist-genre-count.ts
|
|
1520
|
+
var import_zod27 = require("zod");
|
|
1521
|
+
var ArtistGenreCountSchema = import_zod27.z.object({
|
|
1522
|
+
...GenreCountsSchema.shape,
|
|
1523
|
+
catalogue: GenreCatalogueCountsSchema,
|
|
1524
|
+
genrePlaylist: GenrePlaylistUuidSchema,
|
|
1525
|
+
/** Legacy catalogue count for the default selection. */
|
|
1526
|
+
songsCount: import_zod27.z.number().int().nonnegative(),
|
|
1527
|
+
/** Legacy playlist count for the default selection. */
|
|
1528
|
+
tracksCount: import_zod27.z.number().int().nonnegative()
|
|
1529
|
+
}).superRefine((row, ctx) => {
|
|
1530
|
+
const counts = GenreCatalogueCountsSchema.safeParse(row);
|
|
1531
|
+
if (!counts.success) {
|
|
1532
|
+
for (const issue of counts.error.issues) {
|
|
1533
|
+
ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
});
|
|
1537
|
+
|
|
1538
|
+
// src/genre-tree/schemas/reference-artist.ts
|
|
1539
|
+
function intoUiShape(target) {
|
|
1540
|
+
return (value, ctx) => {
|
|
1541
|
+
const parsed = target.safeParse(value);
|
|
1542
|
+
if (parsed.success) return parsed.data;
|
|
1543
|
+
for (const issue of parsed.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
1544
|
+
return import_zod28.z.NEVER;
|
|
1545
|
+
};
|
|
1546
|
+
}
|
|
1547
|
+
var ReferenceArtistSchema = import_grow_api3.zV1ArtistsRetrieveResponse.transform(intoUiShape(ArtistDetailedSchema));
|
|
1548
|
+
var ReferenceArtistGenreCountsSchema = import_grow_api3.zV1ArtistsGenreCountsListResponse.transform(
|
|
1549
|
+
intoUiShape(import_zod28.z.array(ArtistGenreCountSchema))
|
|
1550
|
+
);
|
|
1551
|
+
|
|
1496
1552
|
// src/genre-tree/api/artists/queryKeys.ts
|
|
1497
1553
|
var artistQueryKeys = {
|
|
1498
1554
|
search: (query) => ["artistSearch", query],
|
|
@@ -1516,7 +1572,7 @@ function useArtist(uuid, getBackendBaseUrl) {
|
|
|
1516
1572
|
const { data, isPending, error } = useQueryWithParse({
|
|
1517
1573
|
queryKey: artistQueryKeys.detail(id),
|
|
1518
1574
|
queryFn: () => fetch2(artistEndpoints.detail(id), true, false),
|
|
1519
|
-
schema:
|
|
1575
|
+
schema: ReferenceArtistSchema,
|
|
1520
1576
|
enabled: isUuid,
|
|
1521
1577
|
retry: resourceRetry,
|
|
1522
1578
|
context: "useArtist"
|
|
@@ -1525,20 +1581,8 @@ function useArtist(uuid, getBackendBaseUrl) {
|
|
|
1525
1581
|
return result.status === "success" ? { status: "success", artist: result.data } : result;
|
|
1526
1582
|
}
|
|
1527
1583
|
|
|
1528
|
-
// src/genre-tree/
|
|
1529
|
-
var
|
|
1530
|
-
var ArtistSearchResultSchema = import_zod26.z.object({
|
|
1531
|
-
uuid: import_zod26.z.string().uuid(),
|
|
1532
|
-
name: import_zod26.z.string(),
|
|
1533
|
-
disambiguation: import_zod26.z.string().nullable(),
|
|
1534
|
-
type: import_zod26.z.enum(["person", "group", "orchestra", "choir", "character", "other"]).nullable(),
|
|
1535
|
-
country: import_zod26.z.string().nullable(),
|
|
1536
|
-
beginYear: import_zod26.z.number().int().nullable(),
|
|
1537
|
-
endYear: import_zod26.z.number().int().nullable(),
|
|
1538
|
-
matchedAlias: import_zod26.z.string().nullable(),
|
|
1539
|
-
recordingCount: import_zod26.z.number().int()
|
|
1540
|
-
});
|
|
1541
|
-
var ArtistSearchResultsSchema = import_zod26.z.array(ArtistSearchResultSchema);
|
|
1584
|
+
// src/genre-tree/useArtistSearch.ts
|
|
1585
|
+
var import_grow_api4 = require("@behindthemusictree/grow-api");
|
|
1542
1586
|
|
|
1543
1587
|
// src/genre-tree/useRemoteSearch.ts
|
|
1544
1588
|
var import_react_query6 = require("@tanstack/react-query");
|
|
@@ -1585,7 +1629,7 @@ function useArtistSearch(getBackendBaseUrl, text) {
|
|
|
1585
1629
|
queryKey: artistQueryKeys.search,
|
|
1586
1630
|
endpoint: artistEndpoints.search(),
|
|
1587
1631
|
params: (q) => ({ q, limit: RESULT_LIMIT }),
|
|
1588
|
-
schema:
|
|
1632
|
+
schema: import_grow_api4.zV1ArtistsSearchListResponse,
|
|
1589
1633
|
context: "useArtistSearch",
|
|
1590
1634
|
text
|
|
1591
1635
|
});
|
|
@@ -1597,9 +1641,9 @@ var import_react10 = require("react");
|
|
|
1597
1641
|
|
|
1598
1642
|
// src/transport/PlaybackContext.tsx
|
|
1599
1643
|
var import_react8 = require("react");
|
|
1600
|
-
var
|
|
1644
|
+
var import_zod29 = require("zod");
|
|
1601
1645
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
1602
|
-
var PlaybackContextSchema =
|
|
1646
|
+
var PlaybackContextSchema = import_zod29.z.object({ country: import_zod29.z.string().regex(/^[A-Z]{2}$/).nullable() });
|
|
1603
1647
|
var unmanaged = {
|
|
1604
1648
|
country: null,
|
|
1605
1649
|
key: null,
|
|
@@ -1680,8 +1724,12 @@ function usePlaybackQuery({
|
|
|
1680
1724
|
});
|
|
1681
1725
|
}
|
|
1682
1726
|
|
|
1727
|
+
// src/genre-tree/schemas/reference-song.ts
|
|
1728
|
+
var import_zod31 = require("zod");
|
|
1729
|
+
var import_grow_api5 = require("@behindthemusictree/grow-api");
|
|
1730
|
+
|
|
1683
1731
|
// src/genre-tree/schemas/song/detailed.ts
|
|
1684
|
-
var
|
|
1732
|
+
var import_zod30 = require("zod");
|
|
1685
1733
|
var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
|
|
1686
1734
|
not_found: "Video unavailable",
|
|
1687
1735
|
not_embeddable: "Embedding disabled",
|
|
@@ -1690,23 +1738,23 @@ var YOUTUBE_UNPLAYABLE_REASON_LABELS = {
|
|
|
1690
1738
|
region_whitelisted: "Region restricted"
|
|
1691
1739
|
};
|
|
1692
1740
|
var YOUTUBE_UNPLAYABLE_REASONS = Object.keys(YOUTUBE_UNPLAYABLE_REASON_LABELS);
|
|
1693
|
-
var YoutubeAvailabilitySchema =
|
|
1694
|
-
status:
|
|
1695
|
-
reason:
|
|
1696
|
-
country:
|
|
1741
|
+
var YoutubeAvailabilitySchema = import_zod30.z.object({
|
|
1742
|
+
status: import_zod30.z.enum(["eligible", "blocked", "unknown"]),
|
|
1743
|
+
reason: import_zod30.z.string().nullable(),
|
|
1744
|
+
country: import_zod30.z.string().nullable()
|
|
1697
1745
|
});
|
|
1698
1746
|
var SongDetailedSchema = TrackBaseSchema.extend({
|
|
1699
|
-
youtubeVideo:
|
|
1700
|
-
id:
|
|
1747
|
+
youtubeVideo: import_zod30.z.object({
|
|
1748
|
+
id: import_zod30.z.string(),
|
|
1701
1749
|
availability: YoutubeAvailabilitySchema.optional(),
|
|
1702
1750
|
// null = playable
|
|
1703
|
-
unplayableReason:
|
|
1704
|
-
viewCount:
|
|
1751
|
+
unplayableReason: import_zod30.z.enum(YOUTUBE_UNPLAYABLE_REASONS).nullable(),
|
|
1752
|
+
viewCount: import_zod30.z.number().int().nullable().optional()
|
|
1705
1753
|
}).nullable(),
|
|
1706
1754
|
// null for hand-made/admin songs
|
|
1707
|
-
musicbrainzRecordingId:
|
|
1708
|
-
firstReleaseYear:
|
|
1709
|
-
essentialGenres:
|
|
1755
|
+
musicbrainzRecordingId: import_zod30.z.string().uuid().nullable(),
|
|
1756
|
+
firstReleaseYear: import_zod30.z.number().int().nullable().optional(),
|
|
1757
|
+
essentialGenres: import_zod30.z.array(CriteriaMinimumSchema).optional()
|
|
1710
1758
|
});
|
|
1711
1759
|
var NO_VIDEO_LABEL = "No video available";
|
|
1712
1760
|
function isSong(track) {
|
|
@@ -1722,6 +1770,16 @@ function musicBrainzRecordingUrl(song) {
|
|
|
1722
1770
|
return song.musicbrainzRecordingId ? `https://musicbrainz.org/recording/${song.musicbrainzRecordingId}` : null;
|
|
1723
1771
|
}
|
|
1724
1772
|
|
|
1773
|
+
// src/genre-tree/schemas/reference-song.ts
|
|
1774
|
+
var ReferenceSongSchema = import_grow_api5.zV1LibrarySongsRetrieveResponse.extend({
|
|
1775
|
+
album: import_grow_api5.zV1LibrarySongsRetrieveResponse.shape.album.nullable()
|
|
1776
|
+
}).transform((song, ctx) => {
|
|
1777
|
+
const branded = SongDetailedSchema.safeParse(song);
|
|
1778
|
+
if (branded.success) return branded.data;
|
|
1779
|
+
for (const issue of branded.error.issues) ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
1780
|
+
return import_zod31.z.NEVER;
|
|
1781
|
+
});
|
|
1782
|
+
|
|
1725
1783
|
// src/genre-tree/useSong.ts
|
|
1726
1784
|
function useSong(uuid, getBackendBaseUrl) {
|
|
1727
1785
|
const id = toSongUuid(uuid);
|
|
@@ -1730,7 +1788,7 @@ function useSong(uuid, getBackendBaseUrl) {
|
|
|
1730
1788
|
getBackendBaseUrl,
|
|
1731
1789
|
queryKey: libraryQueryKeys.reference.songs.detail(id),
|
|
1732
1790
|
queryFn: (fetchBound, { signal }) => fetchBound(libraryEndpoints.reference.songs.detail(id), true, false, { signal }),
|
|
1733
|
-
schema:
|
|
1791
|
+
schema: ReferenceSongSchema,
|
|
1734
1792
|
enabled: isUuid,
|
|
1735
1793
|
retry: resourceRetry,
|
|
1736
1794
|
context: "useSong"
|
|
@@ -1739,19 +1797,8 @@ function useSong(uuid, getBackendBaseUrl) {
|
|
|
1739
1797
|
return result.status === "success" ? { status: "success", song: result.data } : result;
|
|
1740
1798
|
}
|
|
1741
1799
|
|
|
1742
|
-
// src/genre-tree/schemas/song-history.ts
|
|
1743
|
-
var import_zod29 = require("zod");
|
|
1744
|
-
var SongHistoryEntrySchema = import_zod29.z.object({
|
|
1745
|
-
uuid: import_zod29.z.string().uuid(),
|
|
1746
|
-
action: import_zod29.z.string(),
|
|
1747
|
-
actorPseudo: import_zod29.z.string().nullable(),
|
|
1748
|
-
oldValue: import_zod29.z.string().nullable(),
|
|
1749
|
-
newValue: import_zod29.z.string().nullable(),
|
|
1750
|
-
createdOn: import_zod29.z.string()
|
|
1751
|
-
});
|
|
1752
|
-
var SongHistorySchema = import_zod29.z.array(SongHistoryEntrySchema);
|
|
1753
|
-
|
|
1754
1800
|
// src/genre-tree/useSongHistory.ts
|
|
1801
|
+
var import_grow_api6 = require("@behindthemusictree/grow-api");
|
|
1755
1802
|
function useSongHistory(uuid, getBackendBaseUrl, enabled) {
|
|
1756
1803
|
const id = toSongUuid(uuid);
|
|
1757
1804
|
const active = enabled && id !== null;
|
|
@@ -1759,7 +1806,7 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
|
|
|
1759
1806
|
getBackendBaseUrl,
|
|
1760
1807
|
queryKey: libraryQueryKeys.reference.songs.history(id),
|
|
1761
1808
|
queryFn: (fetchBound, { signal }) => fetchBound(libraryEndpoints.reference.songs.history(id), true, false, { signal }),
|
|
1762
|
-
schema:
|
|
1809
|
+
schema: import_grow_api6.zV1LibrarySongsHistoryListResponse,
|
|
1763
1810
|
enabled: active,
|
|
1764
1811
|
context: "useSongHistory"
|
|
1765
1812
|
});
|
|
@@ -1769,26 +1816,8 @@ function useSongHistory(uuid, getBackendBaseUrl, enabled) {
|
|
|
1769
1816
|
return { status: "success", entries: data };
|
|
1770
1817
|
}
|
|
1771
1818
|
|
|
1772
|
-
// src/genre-tree/schemas/song-search.ts
|
|
1773
|
-
var import_zod30 = require("zod");
|
|
1774
|
-
var SongSearchResultSchema = import_zod30.z.object({
|
|
1775
|
-
uuid: import_zod30.z.string().uuid(),
|
|
1776
|
-
title: import_zod30.z.string(),
|
|
1777
|
-
artists: import_zod30.z.array(ArtistMinimumSchema),
|
|
1778
|
-
// null for songs not yet linked to a genre.
|
|
1779
|
-
genre: CriteriaMinimumSchema.nullable(),
|
|
1780
|
-
youtubeVideo: import_zod30.z.object({
|
|
1781
|
-
id: import_zod30.z.string(),
|
|
1782
|
-
unplayableReason: import_zod30.z.string().nullable()
|
|
1783
|
-
}).nullable(),
|
|
1784
|
-
firstReleaseYear: import_zod30.z.number().int().nullable()
|
|
1785
|
-
});
|
|
1786
|
-
var SongSearchResultsSchema = import_zod30.z.array(SongSearchResultSchema);
|
|
1787
|
-
function isSongSearchResultPlayable(result) {
|
|
1788
|
-
return result.youtubeVideo !== null && result.youtubeVideo.unplayableReason === null;
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
1819
|
// src/genre-tree/useSongSearch.ts
|
|
1820
|
+
var import_grow_api7 = require("@behindthemusictree/grow-api");
|
|
1792
1821
|
var DEFAULT_RESULT_LIMIT = 8;
|
|
1793
1822
|
function useSongSearch(getBackendBaseUrl, text, options = {}) {
|
|
1794
1823
|
const playback = usePlaybackContext();
|
|
@@ -1800,7 +1829,7 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
|
|
|
1800
1829
|
fetch: fetchBound,
|
|
1801
1830
|
endpoint: libraryEndpoints.reference.songs.search(),
|
|
1802
1831
|
params,
|
|
1803
|
-
schema:
|
|
1832
|
+
schema: import_grow_api7.zV1LibrarySongsSearchListResponse,
|
|
1804
1833
|
context: "useSongSearch",
|
|
1805
1834
|
text,
|
|
1806
1835
|
enabled: playback.ready,
|
|
@@ -1811,35 +1840,13 @@ function useSongSearch(getBackendBaseUrl, text, options = {}) {
|
|
|
1811
1840
|
|
|
1812
1841
|
// src/genre-tree/useArtistGenreCounts.ts
|
|
1813
1842
|
var import_react_query7 = require("@tanstack/react-query");
|
|
1814
|
-
var import_zod32 = require("zod");
|
|
1815
|
-
|
|
1816
|
-
// src/genre-tree/schemas/artist-genre-count.ts
|
|
1817
|
-
var import_zod31 = require("zod");
|
|
1818
|
-
var ArtistGenreCountSchema = import_zod31.z.object({
|
|
1819
|
-
...GenreCountsSchema.shape,
|
|
1820
|
-
catalogue: GenreCatalogueCountsSchema,
|
|
1821
|
-
genrePlaylist: GenrePlaylistUuidSchema,
|
|
1822
|
-
/** Legacy catalogue count for the default selection. */
|
|
1823
|
-
songsCount: import_zod31.z.number().int().nonnegative(),
|
|
1824
|
-
/** Legacy playlist count for the default selection. */
|
|
1825
|
-
tracksCount: import_zod31.z.number().int().nonnegative()
|
|
1826
|
-
}).superRefine((row, ctx) => {
|
|
1827
|
-
const counts = GenreCatalogueCountsSchema.safeParse(row);
|
|
1828
|
-
if (!counts.success) {
|
|
1829
|
-
for (const issue of counts.error.issues) {
|
|
1830
|
-
ctx.addIssue({ code: "custom", path: issue.path, message: issue.message });
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
});
|
|
1834
|
-
|
|
1835
|
-
// src/genre-tree/useArtistGenreCounts.ts
|
|
1836
1843
|
function useArtistGenreCounts(artistUuid, getBackendBaseUrl) {
|
|
1837
1844
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
1838
1845
|
const id = toArtistUuid(artistUuid);
|
|
1839
1846
|
return useQueryWithParse({
|
|
1840
1847
|
queryKey: [...artistQueryKeys.genreCounts(getBackendBaseUrl(), id), "genreMusicV1"],
|
|
1841
1848
|
queryFn: () => fetch2(artistEndpoints.genreCounts(id), true, false),
|
|
1842
|
-
schema:
|
|
1849
|
+
schema: ReferenceArtistGenreCountsSchema,
|
|
1843
1850
|
enabled: id !== null,
|
|
1844
1851
|
placeholderData: import_react_query7.keepPreviousData,
|
|
1845
1852
|
retry: resourceRetry,
|
|
@@ -1998,35 +2005,8 @@ function useGenreSearch({
|
|
|
1998
2005
|
};
|
|
1999
2006
|
}
|
|
2000
2007
|
|
|
2001
|
-
// src/genre-tree/schemas/genre-search.ts
|
|
2002
|
-
var import_zod33 = require("zod");
|
|
2003
|
-
var GenreSearchTreeNameSchema = import_zod33.z.enum(["canonical", "regional"]);
|
|
2004
|
-
var GenreSearchResultSchema = import_zod33.z.object({
|
|
2005
|
-
/** Criteria (genre) uuid. */
|
|
2006
|
-
uuid: GenreUuidSchema,
|
|
2007
|
-
name: import_zod33.z.string(),
|
|
2008
|
-
/** Null for app-created genres, which the Wikidata-keyed region index does not reference. */
|
|
2009
|
-
wikidataId: import_zod33.z.string().nullable(),
|
|
2010
|
-
treeName: import_zod33.z.string(),
|
|
2011
|
-
/** Null when the genre has no playlist in the tree, so it cannot be opened there. */
|
|
2012
|
-
genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
|
|
2013
|
-
root: import_zod33.z.object({ uuid: GenreUuidSchema, name: import_zod33.z.string() }),
|
|
2014
|
-
isUmbrella: import_zod33.z.boolean(),
|
|
2015
|
-
viewsCount: import_zod33.z.number().int()
|
|
2016
|
-
});
|
|
2017
|
-
var GenreSearchResultsSchema = import_zod33.z.array(GenreSearchResultSchema);
|
|
2018
|
-
var RegionGenreLexiconEntrySchema = import_zod33.z.object({
|
|
2019
|
-
wikidataId: import_zod33.z.string(),
|
|
2020
|
-
uuid: GenreUuidSchema,
|
|
2021
|
-
name: import_zod33.z.string(),
|
|
2022
|
-
treeName: import_zod33.z.string(),
|
|
2023
|
-
genrePlaylistUuid: GenrePlaylistUuidSchema.nullable(),
|
|
2024
|
-
isUmbrella: import_zod33.z.boolean(),
|
|
2025
|
-
viewsCount: import_zod33.z.number().int()
|
|
2026
|
-
});
|
|
2027
|
-
var RegionGenreLexiconSchema = import_zod33.z.array(RegionGenreLexiconEntrySchema);
|
|
2028
|
-
|
|
2029
2008
|
// src/genre-tree/useGenreRemoteSearch.ts
|
|
2009
|
+
var import_grow_api8 = require("@behindthemusictree/grow-api");
|
|
2030
2010
|
var DEFAULT_RESULT_LIMIT2 = 8;
|
|
2031
2011
|
function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAULT_RESULT_LIMIT2, enabled } = {}) {
|
|
2032
2012
|
const params = (q) => ({ q, limit, ...treeName && { treeName } });
|
|
@@ -2034,7 +2014,7 @@ function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAU
|
|
|
2034
2014
|
queryKey: (q) => genreSearchQueryKeys.search(params(q)),
|
|
2035
2015
|
endpoint: genreEndpoints.search(),
|
|
2036
2016
|
params,
|
|
2037
|
-
schema:
|
|
2017
|
+
schema: import_grow_api8.zV1GenresSearchListResponse,
|
|
2038
2018
|
context: "useGenreRemoteSearch",
|
|
2039
2019
|
text,
|
|
2040
2020
|
enabled
|
|
@@ -2043,13 +2023,14 @@ function useGenreRemoteSearch(getBackendBaseUrl, text, { treeName, limit = DEFAU
|
|
|
2043
2023
|
}
|
|
2044
2024
|
|
|
2045
2025
|
// src/genre-tree/useRegionGenreLexicon.ts
|
|
2026
|
+
var import_grow_api9 = require("@behindthemusictree/grow-api");
|
|
2046
2027
|
var EMPTY_ENTRIES = [];
|
|
2047
2028
|
function useRegionGenreLexicon(getBackendBaseUrl, enabled) {
|
|
2048
2029
|
const { fetch: fetch2 } = useFetchWrapper(getBackendBaseUrl);
|
|
2049
2030
|
const { data, isError, isPending } = useQueryWithParse({
|
|
2050
2031
|
queryKey: genreSearchQueryKeys.regionLexicon(),
|
|
2051
2032
|
queryFn: ({ signal }) => fetch2(genreEndpoints.regionLexicon(), true, false, { signal }),
|
|
2052
|
-
schema:
|
|
2033
|
+
schema: import_grow_api9.zRegionMapGenresResponse,
|
|
2053
2034
|
context: "useRegionGenreLexicon",
|
|
2054
2035
|
enabled,
|
|
2055
2036
|
staleTime: Infinity
|
|
@@ -2065,7 +2046,7 @@ var import_react14 = require("react");
|
|
|
2065
2046
|
var import_react13 = require("react");
|
|
2066
2047
|
|
|
2067
2048
|
// src/genre-tree/lib/project-genre-playlists-for-artist.ts
|
|
2068
|
-
var ZERO_SCOPED = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: {
|
|
2049
|
+
var ZERO_SCOPED = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { global: 0, regional: 0, all: 0 } };
|
|
2069
2050
|
var ZERO_ALL = { genreOnlyTracksCount: 0, genreAndSubgenresTracksCount: { all: 0 } };
|
|
2070
2051
|
var ZERO_SCOPED_CATALOGUE = GenreCatalogueCountsSchema.parse(ZERO_SCOPED);
|
|
2071
2052
|
var ZERO_ALL_CATALOGUE = GenreCatalogueCountsSchema.parse(ZERO_ALL);
|
|
@@ -2089,7 +2070,7 @@ var projectGenrePlaylistsForArtist = (playlists, counts) => {
|
|
|
2089
2070
|
}
|
|
2090
2071
|
const scopes = playlist.genreAndSubgenresTracksCount;
|
|
2091
2072
|
if (!scopes) throw new Error(`Artist projections require a reference genre summary (genre playlist ${playlist.uuid})`);
|
|
2092
|
-
const isScoped = "
|
|
2073
|
+
const isScoped = "global" in scopes;
|
|
2093
2074
|
return {
|
|
2094
2075
|
...playlist,
|
|
2095
2076
|
...isScoped ? ZERO_SCOPED : ZERO_ALL,
|
|
@@ -2247,10 +2228,10 @@ function useGenreTreeViewState({
|
|
|
2247
2228
|
var import_react17 = require("react");
|
|
2248
2229
|
|
|
2249
2230
|
// src/genre-tree/schemas/track-playlist-rel/without-playlist.ts
|
|
2250
|
-
var
|
|
2251
|
-
var makeTrackPlaylistRelSchema = (trackSchema) =>
|
|
2231
|
+
var import_zod32 = require("zod");
|
|
2232
|
+
var makeTrackPlaylistRelSchema = (trackSchema) => import_zod32.z.object({
|
|
2252
2233
|
track: trackSchema,
|
|
2253
|
-
position:
|
|
2234
|
+
position: import_zod32.z.number().min(0)
|
|
2254
2235
|
});
|
|
2255
2236
|
var makeTrackPlaylistRelPageSchema = (trackSchema) => PaginatedResponseSchema(makeTrackPlaylistRelSchema(trackSchema));
|
|
2256
2237
|
|
|
@@ -2911,25 +2892,30 @@ function ArtistNames({
|
|
|
2911
2892
|
] }, artist.uuid)) });
|
|
2912
2893
|
}
|
|
2913
2894
|
|
|
2895
|
+
// src/genre-tree/schemas/reference.ts
|
|
2896
|
+
function isSongSearchResultPlayable(result) {
|
|
2897
|
+
return result.youtubeVideo.unplayableReason === null;
|
|
2898
|
+
}
|
|
2899
|
+
|
|
2914
2900
|
// src/genre-tree/schemas/mb-artist.ts
|
|
2915
|
-
var
|
|
2916
|
-
var MbArtistDetailedSchema =
|
|
2917
|
-
musicbrainzId:
|
|
2918
|
-
name:
|
|
2901
|
+
var import_zod33 = require("zod");
|
|
2902
|
+
var MbArtistDetailedSchema = import_zod33.z.object({
|
|
2903
|
+
musicbrainzId: import_zod33.z.string().uuid(),
|
|
2904
|
+
name: import_zod33.z.string(),
|
|
2919
2905
|
musicbrainzLink: HttpUrlSchema
|
|
2920
2906
|
});
|
|
2921
2907
|
|
|
2922
2908
|
// src/genre-tree/schemas/mb-recording.ts
|
|
2923
|
-
var
|
|
2924
|
-
var MbRecordingDetailedSchema =
|
|
2925
|
-
musicbrainzId:
|
|
2926
|
-
title:
|
|
2927
|
-
score:
|
|
2928
|
-
musicbrainzArtists:
|
|
2909
|
+
var import_zod34 = require("zod");
|
|
2910
|
+
var MbRecordingDetailedSchema = import_zod34.z.object({
|
|
2911
|
+
musicbrainzId: import_zod34.z.string().uuid(),
|
|
2912
|
+
title: import_zod34.z.string(),
|
|
2913
|
+
score: import_zod34.z.number(),
|
|
2914
|
+
musicbrainzArtists: import_zod34.z.array(MbArtistDetailedSchema),
|
|
2929
2915
|
musicbrainzLink: HttpUrlSchema,
|
|
2930
|
-
durationInSec:
|
|
2931
|
-
durationStrInHourMinSec:
|
|
2932
|
-
releaseDate:
|
|
2916
|
+
durationInSec: import_zod34.z.number().min(0).nullable().optional(),
|
|
2917
|
+
durationStrInHourMinSec: import_zod34.z.string().nullable().optional(),
|
|
2918
|
+
releaseDate: import_zod34.z.union([import_zod34.z.string().datetime(), import_zod34.z.string()]).transform((val) => {
|
|
2933
2919
|
try {
|
|
2934
2920
|
const date = new Date(val);
|
|
2935
2921
|
if (isNaN(date.getTime())) {
|
|
@@ -3006,8 +2992,6 @@ function editGenreSongPages(data, edit) {
|
|
|
3006
2992
|
ArtistMinimumSchema,
|
|
3007
2993
|
ArtistNames,
|
|
3008
2994
|
ArtistOriginSchema,
|
|
3009
|
-
ArtistSearchResultSchema,
|
|
3010
|
-
ArtistSearchResultsSchema,
|
|
3011
2995
|
ArtistUuidSchema,
|
|
3012
2996
|
CommonsImageSchema,
|
|
3013
2997
|
CriteriaCreationSchema,
|
|
@@ -3028,24 +3012,15 @@ function editGenreSongPages(data, edit) {
|
|
|
3028
3012
|
GenreCoverageSchema,
|
|
3029
3013
|
GenrePlaylistSummarySchema,
|
|
3030
3014
|
GenrePlaylistUuidSchema,
|
|
3031
|
-
GenreSearchResultSchema,
|
|
3032
|
-
GenreSearchResultsSchema,
|
|
3033
|
-
GenreSearchTreeNameSchema,
|
|
3034
3015
|
GenreUuidSchema,
|
|
3035
3016
|
MbArtistDetailedSchema,
|
|
3036
3017
|
MbRecordingDetailedSchema,
|
|
3037
3018
|
NO_VIDEO_LABEL,
|
|
3038
3019
|
ReferenceGenreDetailedSchema,
|
|
3039
3020
|
ReferenceGenrePlaylistSchema,
|
|
3040
|
-
RegionGenreLexiconEntrySchema,
|
|
3041
|
-
RegionGenreLexiconSchema,
|
|
3042
3021
|
SEARCH_DEBOUNCE_MS,
|
|
3043
3022
|
SEARCH_QUERY_MIN_LENGTH,
|
|
3044
3023
|
SongDetailedSchema,
|
|
3045
|
-
SongHistoryEntrySchema,
|
|
3046
|
-
SongHistorySchema,
|
|
3047
|
-
SongSearchResultSchema,
|
|
3048
|
-
SongSearchResultsSchema,
|
|
3049
3024
|
SongUuidSchema,
|
|
3050
3025
|
SubgenreCountsSchema,
|
|
3051
3026
|
SubgenreScopeSchema,
|