@vllnt/convex-music 0.1.0-canary.09eea4e
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/LICENSE +21 -0
- package/README.md +169 -0
- package/dist/client/index.d.ts +284 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +166 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +100 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +2 -0
- package/dist/client/types.js.map +1 -0
- package/dist/component/_generated/api.d.ts +125 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +1143 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +133 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +80 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/actions.d.ts +144 -0
- package/dist/component/actions.d.ts.map +1 -0
- package/dist/component/actions.js +125 -0
- package/dist/component/actions.js.map +1 -0
- package/dist/component/catalog/browse_order.d.ts +22 -0
- package/dist/component/catalog/browse_order.d.ts.map +1 -0
- package/dist/component/catalog/browse_order.js +37 -0
- package/dist/component/catalog/browse_order.js.map +1 -0
- package/dist/component/catalog/field_source_policy.d.ts +30 -0
- package/dist/component/catalog/field_source_policy.d.ts.map +1 -0
- package/dist/component/catalog/field_source_policy.js +36 -0
- package/dist/component/catalog/field_source_policy.js.map +1 -0
- package/dist/component/catalog/merge.d.ts +58 -0
- package/dist/component/catalog/merge.d.ts.map +1 -0
- package/dist/component/catalog/merge.js +74 -0
- package/dist/component/catalog/merge.js.map +1 -0
- package/dist/component/catalog/mutations.d.ts +78 -0
- package/dist/component/catalog/mutations.d.ts.map +1 -0
- package/dist/component/catalog/mutations.js +259 -0
- package/dist/component/catalog/mutations.js.map +1 -0
- package/dist/component/catalog/promote.d.ts +21 -0
- package/dist/component/catalog/promote.d.ts.map +1 -0
- package/dist/component/catalog/promote.js +25 -0
- package/dist/component/catalog/promote.js.map +1 -0
- package/dist/component/catalog/queries.d.ts +421 -0
- package/dist/component/catalog/queries.d.ts.map +1 -0
- package/dist/component/catalog/queries.js +168 -0
- package/dist/component/catalog/queries.js.map +1 -0
- package/dist/component/config/mutations.d.ts +11 -0
- package/dist/component/config/mutations.d.ts.map +1 -0
- package/dist/component/config/mutations.js +30 -0
- package/dist/component/config/mutations.js.map +1 -0
- package/dist/component/config/queries.d.ts +9 -0
- package/dist/component/config/queries.d.ts.map +1 -0
- package/dist/component/config/queries.js +20 -0
- package/dist/component/config/queries.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +30 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/crons.d.ts +11 -0
- package/dist/component/crons.d.ts.map +1 -0
- package/dist/component/crons.js +41 -0
- package/dist/component/crons.js.map +1 -0
- package/dist/component/imports/actions.d.ts +119 -0
- package/dist/component/imports/actions.d.ts.map +1 -0
- package/dist/component/imports/actions.js +442 -0
- package/dist/component/imports/actions.js.map +1 -0
- package/dist/component/imports/dedupe.d.ts +29 -0
- package/dist/component/imports/dedupe.d.ts.map +1 -0
- package/dist/component/imports/dedupe.js +33 -0
- package/dist/component/imports/dedupe.js.map +1 -0
- package/dist/component/imports/mutations.d.ts +59 -0
- package/dist/component/imports/mutations.d.ts.map +1 -0
- package/dist/component/imports/mutations.js +151 -0
- package/dist/component/imports/mutations.js.map +1 -0
- package/dist/component/imports/queries.d.ts +68 -0
- package/dist/component/imports/queries.d.ts.map +1 -0
- package/dist/component/imports/queries.js +22 -0
- package/dist/component/imports/queries.js.map +1 -0
- package/dist/component/imports/state.d.ts +36 -0
- package/dist/component/imports/state.d.ts.map +1 -0
- package/dist/component/imports/state.js +62 -0
- package/dist/component/imports/state.js.map +1 -0
- package/dist/component/mutations.d.ts +55 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +74 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/providers/actions.d.ts +26 -0
- package/dist/component/providers/actions.d.ts.map +1 -0
- package/dist/component/providers/actions.js +92 -0
- package/dist/component/providers/actions.js.map +1 -0
- package/dist/component/providers/apple/impl.d.ts +52 -0
- package/dist/component/providers/apple/impl.d.ts.map +1 -0
- package/dist/component/providers/apple/impl.js +127 -0
- package/dist/component/providers/apple/impl.js.map +1 -0
- package/dist/component/providers/apple/jwt.d.ts +32 -0
- package/dist/component/providers/apple/jwt.d.ts.map +1 -0
- package/dist/component/providers/apple/jwt.js +68 -0
- package/dist/component/providers/apple/jwt.js.map +1 -0
- package/dist/component/providers/apple/mappers.d.ts +20 -0
- package/dist/component/providers/apple/mappers.d.ts.map +1 -0
- package/dist/component/providers/apple/mappers.js +68 -0
- package/dist/component/providers/apple/mappers.js.map +1 -0
- package/dist/component/providers/apple/types.d.ts +80 -0
- package/dist/component/providers/apple/types.d.ts.map +1 -0
- package/dist/component/providers/apple/types.js +7 -0
- package/dist/component/providers/apple/types.js.map +1 -0
- package/dist/component/providers/deezer/impl.d.ts +37 -0
- package/dist/component/providers/deezer/impl.d.ts.map +1 -0
- package/dist/component/providers/deezer/impl.js +99 -0
- package/dist/component/providers/deezer/impl.js.map +1 -0
- package/dist/component/providers/deezer/mappers.d.ts +18 -0
- package/dist/component/providers/deezer/mappers.d.ts.map +1 -0
- package/dist/component/providers/deezer/mappers.js +53 -0
- package/dist/component/providers/deezer/mappers.js.map +1 -0
- package/dist/component/providers/deezer/types.d.ts +59 -0
- package/dist/component/providers/deezer/types.d.ts.map +1 -0
- package/dist/component/providers/deezer/types.js +7 -0
- package/dist/component/providers/deezer/types.js.map +1 -0
- package/dist/component/providers/fetch.d.ts +69 -0
- package/dist/component/providers/fetch.d.ts.map +1 -0
- package/dist/component/providers/fetch.js +145 -0
- package/dist/component/providers/fetch.js.map +1 -0
- package/dist/component/providers/musicbrainz/impl.d.ts +36 -0
- package/dist/component/providers/musicbrainz/impl.d.ts.map +1 -0
- package/dist/component/providers/musicbrainz/impl.js +74 -0
- package/dist/component/providers/musicbrainz/impl.js.map +1 -0
- package/dist/component/providers/musicbrainz/mappers.d.ts +10 -0
- package/dist/component/providers/musicbrainz/mappers.d.ts.map +1 -0
- package/dist/component/providers/musicbrainz/mappers.js +32 -0
- package/dist/component/providers/musicbrainz/mappers.js.map +1 -0
- package/dist/component/providers/musicbrainz/types.d.ts +24 -0
- package/dist/component/providers/musicbrainz/types.d.ts.map +1 -0
- package/dist/component/providers/musicbrainz/types.js +7 -0
- package/dist/component/providers/musicbrainz/types.js.map +1 -0
- package/dist/component/providers/registry.d.ts +22 -0
- package/dist/component/providers/registry.d.ts.map +1 -0
- package/dist/component/providers/registry.js +33 -0
- package/dist/component/providers/registry.js.map +1 -0
- package/dist/component/providers/spotify/client.d.ts +25 -0
- package/dist/component/providers/spotify/client.d.ts.map +1 -0
- package/dist/component/providers/spotify/client.js +30 -0
- package/dist/component/providers/spotify/client.js.map +1 -0
- package/dist/component/providers/spotify/impl.d.ts +51 -0
- package/dist/component/providers/spotify/impl.d.ts.map +1 -0
- package/dist/component/providers/spotify/impl.js +131 -0
- package/dist/component/providers/spotify/impl.js.map +1 -0
- package/dist/component/providers/spotify/mappers.d.ts +18 -0
- package/dist/component/providers/spotify/mappers.d.ts.map +1 -0
- package/dist/component/providers/spotify/mappers.js +60 -0
- package/dist/component/providers/spotify/mappers.js.map +1 -0
- package/dist/component/providers/spotify/types.d.ts +97 -0
- package/dist/component/providers/spotify/types.d.ts.map +1 -0
- package/dist/component/providers/spotify/types.js +7 -0
- package/dist/component/providers/spotify/types.js.map +1 -0
- package/dist/component/providers/types.d.ts +84 -0
- package/dist/component/providers/types.d.ts.map +1 -0
- package/dist/component/providers/types.js +10 -0
- package/dist/component/providers/types.js.map +1 -0
- package/dist/component/providers/wikidata/impl.d.ts +34 -0
- package/dist/component/providers/wikidata/impl.d.ts.map +1 -0
- package/dist/component/providers/wikidata/impl.js +88 -0
- package/dist/component/providers/wikidata/impl.js.map +1 -0
- package/dist/component/providers/wikidata/mappers.d.ts +11 -0
- package/dist/component/providers/wikidata/mappers.d.ts.map +1 -0
- package/dist/component/providers/wikidata/mappers.js +53 -0
- package/dist/component/providers/wikidata/mappers.js.map +1 -0
- package/dist/component/providers/wikidata/types.d.ts +35 -0
- package/dist/component/providers/wikidata/types.d.ts.map +1 -0
- package/dist/component/providers/wikidata/types.js +8 -0
- package/dist/component/providers/wikidata/types.js.map +1 -0
- package/dist/component/queries.d.ts +103 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +45 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +566 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +59 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/sources/actions.d.ts +51 -0
- package/dist/component/sources/actions.d.ts.map +1 -0
- package/dist/component/sources/actions.js +164 -0
- package/dist/component/sources/actions.js.map +1 -0
- package/dist/component/sources/mutations.d.ts +25 -0
- package/dist/component/sources/mutations.d.ts.map +1 -0
- package/dist/component/sources/mutations.js +64 -0
- package/dist/component/sources/mutations.js.map +1 -0
- package/dist/component/sources/queries.d.ts +19 -0
- package/dist/component/sources/queries.d.ts.map +1 -0
- package/dist/component/sources/queries.js +20 -0
- package/dist/component/sources/queries.js.map +1 -0
- package/dist/component/sync/lifecycle.d.ts +46 -0
- package/dist/component/sync/lifecycle.d.ts.map +1 -0
- package/dist/component/sync/lifecycle.js +87 -0
- package/dist/component/sync/lifecycle.js.map +1 -0
- package/dist/component/sync/mutations.d.ts +101 -0
- package/dist/component/sync/mutations.d.ts.map +1 -0
- package/dist/component/sync/mutations.js +132 -0
- package/dist/component/sync/mutations.js.map +1 -0
- package/dist/component/sync/queries.d.ts +69 -0
- package/dist/component/sync/queries.d.ts.map +1 -0
- package/dist/component/sync/queries.js +32 -0
- package/dist/component/sync/queries.js.map +1 -0
- package/dist/component/validators.d.ts +1112 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +317 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/react/index.d.ts +42 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +43 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared.d.ts +28 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +24 -0
- package/dist/shared.js.map +1 -0
- package/package.json +126 -0
- package/src/client/index.ts +558 -0
- package/src/client/types.ts +117 -0
- package/src/component/_generated/api.ts +141 -0
- package/src/component/_generated/component.ts +1814 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +169 -0
- package/src/component/actions.ts +156 -0
- package/src/component/catalog/browse_order.test.ts +55 -0
- package/src/component/catalog/browse_order.ts +43 -0
- package/src/component/catalog/field_source_policy.test.ts +47 -0
- package/src/component/catalog/field_source_policy.ts +44 -0
- package/src/component/catalog/merge.test.ts +187 -0
- package/src/component/catalog/merge.ts +134 -0
- package/src/component/catalog/mutations.ts +328 -0
- package/src/component/catalog/promote.ts +40 -0
- package/src/component/catalog/queries.ts +220 -0
- package/src/component/config/mutations.ts +29 -0
- package/src/component/config/queries.ts +20 -0
- package/src/component/convex.config.ts +32 -0
- package/src/component/crons.test.ts +8 -0
- package/src/component/crons.ts +52 -0
- package/src/component/imports/actions.ts +553 -0
- package/src/component/imports/dedupe.test.ts +66 -0
- package/src/component/imports/dedupe.ts +54 -0
- package/src/component/imports/mutations.ts +203 -0
- package/src/component/imports/queries.ts +25 -0
- package/src/component/imports/state.test.ts +60 -0
- package/src/component/imports/state.ts +74 -0
- package/src/component/mutations.ts +96 -0
- package/src/component/providers/actions.ts +127 -0
- package/src/component/providers/apple/impl.test.ts +267 -0
- package/src/component/providers/apple/impl.ts +224 -0
- package/src/component/providers/apple/jwt.test.ts +153 -0
- package/src/component/providers/apple/jwt.ts +99 -0
- package/src/component/providers/apple/mappers.test.ts +190 -0
- package/src/component/providers/apple/mappers.ts +100 -0
- package/src/component/providers/apple/types.ts +77 -0
- package/src/component/providers/deezer/impl.test.ts +109 -0
- package/src/component/providers/deezer/impl.ts +179 -0
- package/src/component/providers/deezer/mappers.test.ts +78 -0
- package/src/component/providers/deezer/mappers.ts +72 -0
- package/src/component/providers/deezer/types.ts +59 -0
- package/src/component/providers/fetch.test.ts +282 -0
- package/src/component/providers/fetch.ts +190 -0
- package/src/component/providers/musicbrainz/impl.test.ts +79 -0
- package/src/component/providers/musicbrainz/impl.ts +132 -0
- package/src/component/providers/musicbrainz/mappers.test.ts +75 -0
- package/src/component/providers/musicbrainz/mappers.ts +34 -0
- package/src/component/providers/musicbrainz/types.ts +20 -0
- package/src/component/providers/registry.test.ts +14 -0
- package/src/component/providers/registry.ts +48 -0
- package/src/component/providers/spotify/client.test.ts +80 -0
- package/src/component/providers/spotify/client.ts +57 -0
- package/src/component/providers/spotify/impl.test.ts +311 -0
- package/src/component/providers/spotify/impl.ts +230 -0
- package/src/component/providers/spotify/mappers.test.ts +182 -0
- package/src/component/providers/spotify/mappers.ts +81 -0
- package/src/component/providers/spotify/types.ts +101 -0
- package/src/component/providers/types.ts +95 -0
- package/src/component/providers/wikidata/impl.test.ts +81 -0
- package/src/component/providers/wikidata/impl.ts +139 -0
- package/src/component/providers/wikidata/mappers.test.ts +62 -0
- package/src/component/providers/wikidata/mappers.ts +66 -0
- package/src/component/providers/wikidata/types.ts +28 -0
- package/src/component/queries.ts +51 -0
- package/src/component/schema.ts +81 -0
- package/src/component/sources/actions.ts +177 -0
- package/src/component/sources/mutations.ts +67 -0
- package/src/component/sources/queries.ts +21 -0
- package/src/component/sync/lifecycle.test.ts +72 -0
- package/src/component/sync/lifecycle.ts +121 -0
- package/src/component/sync/mutations.ts +154 -0
- package/src/component/sync/queries.ts +33 -0
- package/src/component/validators.ts +411 -0
- package/src/react/index.test.ts +78 -0
- package/src/react/index.ts +112 -0
- package/src/shared.ts +32 -0
- package/src/test.ts +22 -0
|
@@ -0,0 +1,558 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FunctionArgs,
|
|
3
|
+
FunctionReference,
|
|
4
|
+
FunctionReturnType,
|
|
5
|
+
} from "convex/server";
|
|
6
|
+
import type { Provider } from "../shared.js";
|
|
7
|
+
import type {
|
|
8
|
+
CacheEntry,
|
|
9
|
+
CatalogAlbum,
|
|
10
|
+
CatalogArtist,
|
|
11
|
+
CatalogPlaylist,
|
|
12
|
+
CatalogTrack,
|
|
13
|
+
EntryKey,
|
|
14
|
+
NormalizedArtist,
|
|
15
|
+
NormalizedTrack,
|
|
16
|
+
PutInput,
|
|
17
|
+
SearchHit,
|
|
18
|
+
} from "./types.js";
|
|
19
|
+
|
|
20
|
+
/** Arguments to fetch a provider entity into the catalog (read-through). */
|
|
21
|
+
export type FetchInput = {
|
|
22
|
+
provider: Provider;
|
|
23
|
+
externalId: string;
|
|
24
|
+
force?: boolean;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** Arguments to search a provider for artists or tracks. */
|
|
28
|
+
export type SearchInput = {
|
|
29
|
+
provider: Provider;
|
|
30
|
+
query: string;
|
|
31
|
+
type: "artist" | "track";
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** Arguments to import an artist into the catalog. */
|
|
35
|
+
export type ImportArtistInput = {
|
|
36
|
+
provider: Provider;
|
|
37
|
+
targetMode: "name" | "providerId";
|
|
38
|
+
name?: string;
|
|
39
|
+
providerId?: string;
|
|
40
|
+
/** Back-compat alias for `tracks: "top"`. */
|
|
41
|
+
withTracks?: boolean;
|
|
42
|
+
/** Track traversal depth: artist only / top tracks / every album track. */
|
|
43
|
+
tracks?: "none" | "top" | "all";
|
|
44
|
+
mode?: "import" | "refresh" | "reimport" | "repair";
|
|
45
|
+
priority?: "high" | "normal" | "low";
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Arguments to import a track into the catalog. */
|
|
49
|
+
export type ImportTrackInput = {
|
|
50
|
+
provider: Provider;
|
|
51
|
+
providerId: string;
|
|
52
|
+
/** Also import the track's album (when the provider exposes an album id). */
|
|
53
|
+
withAlbum?: boolean;
|
|
54
|
+
mode?: "import" | "refresh" | "reimport" | "repair";
|
|
55
|
+
priority?: "high" | "normal" | "low";
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/** Arguments to import a playlist (+ its tracks) into the catalog. */
|
|
59
|
+
export type ImportPlaylistInput = ImportTrackInput & {
|
|
60
|
+
/** Cap how many of the playlist's tracks to import. */
|
|
61
|
+
limit?: number;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/** Arguments to import an album by provider id (+ its tracks + artists). */
|
|
65
|
+
export type ImportAlbumInput = ImportTrackInput & {
|
|
66
|
+
/** Cap how many of the album's tracks to import. */
|
|
67
|
+
limit?: number;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/** The outcome of an import: the request id + its terminal status. */
|
|
71
|
+
export type ImportResult = { requestId: string; status: string };
|
|
72
|
+
|
|
73
|
+
/** Arguments to upsert a provider's artist into the catalog. */
|
|
74
|
+
export type UpsertArtistInput = {
|
|
75
|
+
provider: Provider;
|
|
76
|
+
externalId: string;
|
|
77
|
+
value: NormalizedArtist;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** Arguments to upsert a provider's track (ISRC required) into the catalog. */
|
|
81
|
+
export type UpsertTrackInput = {
|
|
82
|
+
provider: Provider;
|
|
83
|
+
externalId: string;
|
|
84
|
+
value: NormalizedTrack;
|
|
85
|
+
artistIds?: string[];
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/** Arguments to upsert a playlist by source-provider identity. */
|
|
89
|
+
export type UpsertPlaylistInput = {
|
|
90
|
+
provider: Provider;
|
|
91
|
+
providerId: string;
|
|
92
|
+
title: string;
|
|
93
|
+
description?: string;
|
|
94
|
+
coverUrl?: string;
|
|
95
|
+
url?: string;
|
|
96
|
+
owner?: string;
|
|
97
|
+
trackIds: string[];
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** Arguments to upsert an album by source-provider identity. */
|
|
101
|
+
export type UpsertAlbumInput = {
|
|
102
|
+
provider: Provider;
|
|
103
|
+
providerId: string;
|
|
104
|
+
title: string;
|
|
105
|
+
artistIds: string[];
|
|
106
|
+
releaseDate?: string;
|
|
107
|
+
coverUrl?: string;
|
|
108
|
+
url?: string;
|
|
109
|
+
trackCount?: number;
|
|
110
|
+
trackIds: string[];
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/** Arguments to select eligible catalog rows for a daily picker. */
|
|
114
|
+
export type SelectEligibleInput = {
|
|
115
|
+
kind: "artist" | "track";
|
|
116
|
+
limit: number;
|
|
117
|
+
excludeIds?: string[];
|
|
118
|
+
salt?: string;
|
|
119
|
+
scanLimit?: number;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* The component's function references, as exposed on the host via
|
|
124
|
+
* `components.music`.
|
|
125
|
+
*/
|
|
126
|
+
export interface MusicComponent {
|
|
127
|
+
mutations: {
|
|
128
|
+
put: FunctionReference<"mutation", "internal", PutInput, string>;
|
|
129
|
+
invalidate: FunctionReference<"mutation", "internal", EntryKey, boolean>;
|
|
130
|
+
pruneExpired: FunctionReference<
|
|
131
|
+
"mutation",
|
|
132
|
+
"internal",
|
|
133
|
+
Record<string, never>,
|
|
134
|
+
number
|
|
135
|
+
>;
|
|
136
|
+
};
|
|
137
|
+
queries: {
|
|
138
|
+
get: FunctionReference<"query", "internal", EntryKey, CacheEntry | null>;
|
|
139
|
+
getByIsrc: FunctionReference<
|
|
140
|
+
"query",
|
|
141
|
+
"internal",
|
|
142
|
+
{ isrc: string },
|
|
143
|
+
CacheEntry[]
|
|
144
|
+
>;
|
|
145
|
+
stats: FunctionReference<
|
|
146
|
+
"query",
|
|
147
|
+
"internal",
|
|
148
|
+
Record<string, never>,
|
|
149
|
+
{ total: number }
|
|
150
|
+
>;
|
|
151
|
+
};
|
|
152
|
+
catalog: {
|
|
153
|
+
mutations: {
|
|
154
|
+
upsertArtist: FunctionReference<
|
|
155
|
+
"mutation",
|
|
156
|
+
"internal",
|
|
157
|
+
UpsertArtistInput,
|
|
158
|
+
string
|
|
159
|
+
>;
|
|
160
|
+
upsertTrack: FunctionReference<
|
|
161
|
+
"mutation",
|
|
162
|
+
"internal",
|
|
163
|
+
UpsertTrackInput,
|
|
164
|
+
string
|
|
165
|
+
>;
|
|
166
|
+
upsertPlaylist: FunctionReference<
|
|
167
|
+
"mutation",
|
|
168
|
+
"internal",
|
|
169
|
+
UpsertPlaylistInput,
|
|
170
|
+
string
|
|
171
|
+
>;
|
|
172
|
+
upsertAlbum: FunctionReference<
|
|
173
|
+
"mutation",
|
|
174
|
+
"internal",
|
|
175
|
+
UpsertAlbumInput,
|
|
176
|
+
string
|
|
177
|
+
>;
|
|
178
|
+
};
|
|
179
|
+
queries: {
|
|
180
|
+
getArtist: FunctionReference<
|
|
181
|
+
"query",
|
|
182
|
+
"internal",
|
|
183
|
+
{ id: string },
|
|
184
|
+
CatalogArtist | null
|
|
185
|
+
>;
|
|
186
|
+
getTrack: FunctionReference<
|
|
187
|
+
"query",
|
|
188
|
+
"internal",
|
|
189
|
+
{ id: string },
|
|
190
|
+
CatalogTrack | null
|
|
191
|
+
>;
|
|
192
|
+
getPlaylist: FunctionReference<
|
|
193
|
+
"query",
|
|
194
|
+
"internal",
|
|
195
|
+
{ id: string },
|
|
196
|
+
CatalogPlaylist | null
|
|
197
|
+
>;
|
|
198
|
+
getAlbum: FunctionReference<
|
|
199
|
+
"query",
|
|
200
|
+
"internal",
|
|
201
|
+
{ id: string },
|
|
202
|
+
CatalogAlbum | null
|
|
203
|
+
>;
|
|
204
|
+
getAlbumByProvider: FunctionReference<
|
|
205
|
+
"query",
|
|
206
|
+
"internal",
|
|
207
|
+
{ provider: Provider; providerId: string },
|
|
208
|
+
CatalogAlbum | null
|
|
209
|
+
>;
|
|
210
|
+
getTrackByIsrc: FunctionReference<
|
|
211
|
+
"query",
|
|
212
|
+
"internal",
|
|
213
|
+
{ isrc: string },
|
|
214
|
+
CatalogTrack | null
|
|
215
|
+
>;
|
|
216
|
+
searchArtists: FunctionReference<
|
|
217
|
+
"query",
|
|
218
|
+
"internal",
|
|
219
|
+
{ query: string; limit?: number },
|
|
220
|
+
CatalogArtist[]
|
|
221
|
+
>;
|
|
222
|
+
searchTracks: FunctionReference<
|
|
223
|
+
"query",
|
|
224
|
+
"internal",
|
|
225
|
+
{ query: string; limit?: number },
|
|
226
|
+
CatalogTrack[]
|
|
227
|
+
>;
|
|
228
|
+
selectEligible: FunctionReference<
|
|
229
|
+
"query",
|
|
230
|
+
"internal",
|
|
231
|
+
SelectEligibleInput,
|
|
232
|
+
Array<CatalogArtist | CatalogTrack>
|
|
233
|
+
>;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
236
|
+
actions: {
|
|
237
|
+
fetchArtist: FunctionReference<
|
|
238
|
+
"action",
|
|
239
|
+
"internal",
|
|
240
|
+
FetchInput,
|
|
241
|
+
CatalogArtist | null
|
|
242
|
+
>;
|
|
243
|
+
fetchTrack: FunctionReference<
|
|
244
|
+
"action",
|
|
245
|
+
"internal",
|
|
246
|
+
FetchInput,
|
|
247
|
+
CatalogTrack | null
|
|
248
|
+
>;
|
|
249
|
+
search: FunctionReference<"action", "internal", SearchInput, SearchHit[]>;
|
|
250
|
+
resolveByIsrc: FunctionReference<
|
|
251
|
+
"action",
|
|
252
|
+
"internal",
|
|
253
|
+
{ isrc: string; provider: Provider },
|
|
254
|
+
CatalogTrack | null
|
|
255
|
+
>;
|
|
256
|
+
};
|
|
257
|
+
config: {
|
|
258
|
+
mutations: {
|
|
259
|
+
configure: FunctionReference<
|
|
260
|
+
"mutation",
|
|
261
|
+
"internal",
|
|
262
|
+
{ provider: Provider; secrets: Record<string, string> },
|
|
263
|
+
null
|
|
264
|
+
>;
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
imports: {
|
|
268
|
+
actions: {
|
|
269
|
+
importArtist: FunctionReference<
|
|
270
|
+
"action",
|
|
271
|
+
"internal",
|
|
272
|
+
ImportArtistInput,
|
|
273
|
+
ImportResult
|
|
274
|
+
>;
|
|
275
|
+
importTrack: FunctionReference<
|
|
276
|
+
"action",
|
|
277
|
+
"internal",
|
|
278
|
+
ImportTrackInput,
|
|
279
|
+
ImportResult
|
|
280
|
+
>;
|
|
281
|
+
importPlaylist: FunctionReference<
|
|
282
|
+
"action",
|
|
283
|
+
"internal",
|
|
284
|
+
ImportPlaylistInput,
|
|
285
|
+
ImportResult
|
|
286
|
+
>;
|
|
287
|
+
importAlbum: FunctionReference<
|
|
288
|
+
"action",
|
|
289
|
+
"internal",
|
|
290
|
+
ImportAlbumInput,
|
|
291
|
+
ImportResult
|
|
292
|
+
>;
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
interface RunQueryCtx {
|
|
298
|
+
runQuery<Q extends FunctionReference<"query", "internal">>(
|
|
299
|
+
reference: Q,
|
|
300
|
+
args: FunctionArgs<Q>,
|
|
301
|
+
): Promise<FunctionReturnType<Q>>;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
interface RunMutationCtx {
|
|
305
|
+
runMutation<M extends FunctionReference<"mutation", "internal">>(
|
|
306
|
+
reference: M,
|
|
307
|
+
args: FunctionArgs<M>,
|
|
308
|
+
): Promise<FunctionReturnType<M>>;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
interface RunActionCtx {
|
|
312
|
+
runAction<A extends FunctionReference<"action", "internal">>(
|
|
313
|
+
reference: A,
|
|
314
|
+
args: FunctionArgs<A>,
|
|
315
|
+
): Promise<FunctionReturnType<A>>;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Consumer-facing client for `@vllnt/convex-music`. Construct with the mounted
|
|
320
|
+
* component ref, then call from host queries/mutations/actions.
|
|
321
|
+
*
|
|
322
|
+
* `0.1.0` is the raw provider-fetch cache; the durable music catalog
|
|
323
|
+
* (artists/tracks/playlists) the component will own is planned (see ROADMAP).
|
|
324
|
+
* The host owns auth and gates write methods behind its own mutations, and keeps
|
|
325
|
+
* gameplay + editorial, referencing catalog rows by id / ISRC.
|
|
326
|
+
*
|
|
327
|
+
* @example
|
|
328
|
+
* ```ts
|
|
329
|
+
* const music = new Music(components.music);
|
|
330
|
+
* const hit = await music.get(ctx, { kind: "track", provider: "spotify", externalId: id });
|
|
331
|
+
* ```
|
|
332
|
+
*/
|
|
333
|
+
export class Music {
|
|
334
|
+
constructor(private readonly component: MusicComponent) {}
|
|
335
|
+
|
|
336
|
+
/** Cache (insert or refresh) a provider's normalized facts for an entity. */
|
|
337
|
+
put(ctx: RunMutationCtx, input: PutInput): Promise<string> {
|
|
338
|
+
return ctx.runMutation(this.component.mutations.put, input);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** Fetch one cached entry, or `null` if missing or expired. */
|
|
342
|
+
get(ctx: RunQueryCtx, key: EntryKey): Promise<CacheEntry | null> {
|
|
343
|
+
return ctx.runQuery(this.component.queries.get, key);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/** Every fresh cached track for an ISRC, across providers. */
|
|
347
|
+
getByIsrc(ctx: RunQueryCtx, isrc: string): Promise<CacheEntry[]> {
|
|
348
|
+
return ctx.runQuery(this.component.queries.getByIsrc, { isrc });
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/** Drop one cached entry. Returns whether a row was deleted. */
|
|
352
|
+
invalidate(ctx: RunMutationCtx, key: EntryKey): Promise<boolean> {
|
|
353
|
+
return ctx.runMutation(this.component.mutations.invalidate, key);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** Delete every expired entry. Idempotent; safe to run on a schedule. */
|
|
357
|
+
pruneExpired(ctx: RunMutationCtx): Promise<number> {
|
|
358
|
+
return ctx.runMutation(this.component.mutations.pruneExpired, {});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** Count of cached entries (fresh + expired). */
|
|
362
|
+
stats(ctx: RunQueryCtx): Promise<{ total: number }> {
|
|
363
|
+
return ctx.runQuery(this.component.queries.stats, {});
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** Upsert a provider's artist into the catalog; returns the unified artist id. */
|
|
367
|
+
upsertArtist(ctx: RunMutationCtx, input: UpsertArtistInput): Promise<string> {
|
|
368
|
+
return ctx.runMutation(this.component.catalog.mutations.upsertArtist, input);
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** Upsert a provider's track (ISRC required); returns the unified track id. */
|
|
372
|
+
upsertTrack(ctx: RunMutationCtx, input: UpsertTrackInput): Promise<string> {
|
|
373
|
+
return ctx.runMutation(this.component.catalog.mutations.upsertTrack, input);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** Upsert a playlist by source-provider identity; returns the playlist id. */
|
|
377
|
+
upsertPlaylist(
|
|
378
|
+
ctx: RunMutationCtx,
|
|
379
|
+
input: UpsertPlaylistInput,
|
|
380
|
+
): Promise<string> {
|
|
381
|
+
return ctx.runMutation(
|
|
382
|
+
this.component.catalog.mutations.upsertPlaylist,
|
|
383
|
+
input,
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/** Upsert an album by source-provider identity; returns the album id. */
|
|
388
|
+
upsertAlbum(ctx: RunMutationCtx, input: UpsertAlbumInput): Promise<string> {
|
|
389
|
+
return ctx.runMutation(this.component.catalog.mutations.upsertAlbum, input);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
/** Fetch one album by id. */
|
|
393
|
+
getAlbum(ctx: RunQueryCtx, id: string): Promise<CatalogAlbum | null> {
|
|
394
|
+
return ctx.runQuery(this.component.catalog.queries.getAlbum, { id });
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/** Resolve an album by its source-provider identity. */
|
|
398
|
+
getAlbumByProvider(
|
|
399
|
+
ctx: RunQueryCtx,
|
|
400
|
+
provider: Provider,
|
|
401
|
+
providerId: string,
|
|
402
|
+
): Promise<CatalogAlbum | null> {
|
|
403
|
+
return ctx.runQuery(this.component.catalog.queries.getAlbumByProvider, {
|
|
404
|
+
provider,
|
|
405
|
+
providerId,
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** Fetch one unified artist by id. */
|
|
410
|
+
getArtist(ctx: RunQueryCtx, id: string): Promise<CatalogArtist | null> {
|
|
411
|
+
return ctx.runQuery(this.component.catalog.queries.getArtist, { id });
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** Fetch one unified track by id. */
|
|
415
|
+
getTrack(ctx: RunQueryCtx, id: string): Promise<CatalogTrack | null> {
|
|
416
|
+
return ctx.runQuery(this.component.catalog.queries.getTrack, { id });
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/** Fetch one playlist by id. */
|
|
420
|
+
getPlaylist(ctx: RunQueryCtx, id: string): Promise<CatalogPlaylist | null> {
|
|
421
|
+
return ctx.runQuery(this.component.catalog.queries.getPlaylist, { id });
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/** Resolve a unified track by ISRC. */
|
|
425
|
+
getTrackByIsrc(ctx: RunQueryCtx, isrc: string): Promise<CatalogTrack | null> {
|
|
426
|
+
return ctx.runQuery(this.component.catalog.queries.getTrackByIsrc, { isrc });
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/** Full-text search artists by name. */
|
|
430
|
+
searchArtists(
|
|
431
|
+
ctx: RunQueryCtx,
|
|
432
|
+
query: string,
|
|
433
|
+
limit?: number,
|
|
434
|
+
): Promise<CatalogArtist[]> {
|
|
435
|
+
return ctx.runQuery(this.component.catalog.queries.searchArtists, {
|
|
436
|
+
query,
|
|
437
|
+
limit,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/** Full-text search tracks by title. */
|
|
442
|
+
searchTracks(
|
|
443
|
+
ctx: RunQueryCtx,
|
|
444
|
+
query: string,
|
|
445
|
+
limit?: number,
|
|
446
|
+
): Promise<CatalogTrack[]> {
|
|
447
|
+
return ctx.runQuery(this.component.catalog.queries.searchTracks, {
|
|
448
|
+
query,
|
|
449
|
+
limit,
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/** Select eligible catalog rows for a daily picker (stable rotation). */
|
|
454
|
+
selectEligible(
|
|
455
|
+
ctx: RunQueryCtx,
|
|
456
|
+
input: SelectEligibleInput,
|
|
457
|
+
): Promise<Array<CatalogArtist | CatalogTrack>> {
|
|
458
|
+
return ctx.runQuery(this.component.catalog.queries.selectEligible, input);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* Read-through fetch an artist by provider id, promoting it into the catalog.
|
|
463
|
+
* Cache-through unless `force`. Returns the unified artist row.
|
|
464
|
+
*/
|
|
465
|
+
fetchArtist(ctx: RunActionCtx, input: FetchInput): Promise<CatalogArtist | null> {
|
|
466
|
+
return ctx.runAction(this.component.actions.fetchArtist, input);
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* Read-through fetch a track by provider id, promoting it + its artists.
|
|
471
|
+
* Cache-through unless `force`. Returns the unified track row.
|
|
472
|
+
*/
|
|
473
|
+
fetchTrack(ctx: RunActionCtx, input: FetchInput): Promise<CatalogTrack | null> {
|
|
474
|
+
return ctx.runAction(this.component.actions.fetchTrack, input);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/** Search a provider for artists or tracks (discovery; no promotion). */
|
|
478
|
+
search(ctx: RunActionCtx, input: SearchInput): Promise<SearchHit[]> {
|
|
479
|
+
return ctx.runAction(this.component.actions.search, input);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Resolve a track by ISRC cross-provider (catalog hit, else search the provider
|
|
484
|
+
* by ISRC and promote). `null` if no provider has it.
|
|
485
|
+
*/
|
|
486
|
+
resolveByIsrc(
|
|
487
|
+
ctx: RunActionCtx,
|
|
488
|
+
isrc: string,
|
|
489
|
+
provider: Provider,
|
|
490
|
+
): Promise<CatalogTrack | null> {
|
|
491
|
+
return ctx.runAction(this.component.actions.resolveByIsrc, {
|
|
492
|
+
isrc,
|
|
493
|
+
provider,
|
|
494
|
+
});
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* Store a provider's credentials (the host reads its own deployment env vars
|
|
499
|
+
* and passes them in — a component is sandboxed from the deployment's env).
|
|
500
|
+
* Spotify: `{ clientId, clientSecret }`; Apple: `{ issuer, keyId, privateKeyPem }`.
|
|
501
|
+
*/
|
|
502
|
+
configure(
|
|
503
|
+
ctx: RunMutationCtx,
|
|
504
|
+
provider: Provider,
|
|
505
|
+
secrets: Record<string, string>,
|
|
506
|
+
): Promise<null> {
|
|
507
|
+
return ctx.runMutation(this.component.config.mutations.configure, {
|
|
508
|
+
provider,
|
|
509
|
+
secrets,
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* Import an artist into the catalog (by name or provider id). Creates a
|
|
515
|
+
* dedup-aware control-plane request, runs the traversal, and returns the
|
|
516
|
+
* request id + terminal status.
|
|
517
|
+
*/
|
|
518
|
+
importArtist(
|
|
519
|
+
ctx: RunActionCtx,
|
|
520
|
+
input: ImportArtistInput,
|
|
521
|
+
): Promise<ImportResult> {
|
|
522
|
+
return ctx.runAction(this.component.imports.actions.importArtist, input);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/** Import a track by provider id into the catalog (+ its credited artists). */
|
|
526
|
+
importTrack(ctx: RunActionCtx, input: ImportTrackInput): Promise<ImportResult> {
|
|
527
|
+
return ctx.runAction(this.component.imports.actions.importTrack, input);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
/** Import a playlist by provider id (+ its tracks) into the catalog. */
|
|
531
|
+
importPlaylist(
|
|
532
|
+
ctx: RunActionCtx,
|
|
533
|
+
input: ImportPlaylistInput,
|
|
534
|
+
): Promise<ImportResult> {
|
|
535
|
+
return ctx.runAction(this.component.imports.actions.importPlaylist, input);
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/** Import an album by provider id (+ its tracks + artists) into the catalog. */
|
|
539
|
+
importAlbum(ctx: RunActionCtx, input: ImportAlbumInput): Promise<ImportResult> {
|
|
540
|
+
return ctx.runAction(this.component.imports.actions.importAlbum, input);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export type {
|
|
545
|
+
ArtistRef,
|
|
546
|
+
CacheEntry,
|
|
547
|
+
CacheValue,
|
|
548
|
+
CatalogAlbum,
|
|
549
|
+
CatalogArtist,
|
|
550
|
+
CatalogPlaylist,
|
|
551
|
+
CatalogTrack,
|
|
552
|
+
EntryKey,
|
|
553
|
+
NormalizedAlbum,
|
|
554
|
+
NormalizedArtist,
|
|
555
|
+
NormalizedTrack,
|
|
556
|
+
PutInput,
|
|
557
|
+
SearchHit,
|
|
558
|
+
} from "./types.js";
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { GenericId, Infer } from "convex/values";
|
|
2
|
+
import type {
|
|
3
|
+
albumDoc,
|
|
4
|
+
artistDoc,
|
|
5
|
+
playlistDoc,
|
|
6
|
+
trackDoc,
|
|
7
|
+
} from "../component/validators.js";
|
|
8
|
+
import type { EntityKind, Provider } from "../shared.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Replace every branded component `Id<T>` with a plain `string`. Host-side, the
|
|
12
|
+
* component's row ids are opaque strings (the host doesn't own those tables), so
|
|
13
|
+
* the public catalog types carry `string` ids — matching how `components.music`
|
|
14
|
+
* exposes them.
|
|
15
|
+
*/
|
|
16
|
+
type StringifyIds<T> = T extends GenericId<string>
|
|
17
|
+
? string
|
|
18
|
+
: T extends Array<infer U>
|
|
19
|
+
? Array<StringifyIds<U>>
|
|
20
|
+
: T extends object
|
|
21
|
+
? { [K in keyof T]: StringifyIds<T[K]> }
|
|
22
|
+
: T;
|
|
23
|
+
|
|
24
|
+
/** A unified catalog artist (every provider's facts merged), as returned. */
|
|
25
|
+
export type CatalogArtist = StringifyIds<Infer<typeof artistDoc>>;
|
|
26
|
+
|
|
27
|
+
/** A unified catalog track (keyed by ISRC), as returned. */
|
|
28
|
+
export type CatalogTrack = StringifyIds<Infer<typeof trackDoc>>;
|
|
29
|
+
|
|
30
|
+
/** A playlist (source-provider identity + ordered membership), as returned. */
|
|
31
|
+
export type CatalogPlaylist = StringifyIds<Infer<typeof playlistDoc>>;
|
|
32
|
+
|
|
33
|
+
/** An album (source-provider identity + track membership), as returned. */
|
|
34
|
+
export type CatalogAlbum = StringifyIds<Infer<typeof albumDoc>>;
|
|
35
|
+
|
|
36
|
+
/** A normalized search hit (provider id + value), discriminated by kind. */
|
|
37
|
+
export type SearchHit =
|
|
38
|
+
| { type: "artist"; externalId: string; value: NormalizedArtist }
|
|
39
|
+
| { type: "track"; externalId: string; value: NormalizedTrack };
|
|
40
|
+
|
|
41
|
+
/** A credited artist reference inside a track/album value. */
|
|
42
|
+
export interface ArtistRef {
|
|
43
|
+
name: string;
|
|
44
|
+
externalId?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Normalized, provider-sourced track facts (fields vary by provider). */
|
|
48
|
+
export interface NormalizedTrack {
|
|
49
|
+
title: string;
|
|
50
|
+
artists: ArtistRef[];
|
|
51
|
+
isrc?: string;
|
|
52
|
+
/** Track genres where the provider supplies them (Apple); `[]` otherwise. */
|
|
53
|
+
genres: string[];
|
|
54
|
+
/** 0–100 where the provider supplies it (Spotify); scales staleness. */
|
|
55
|
+
popularity?: number;
|
|
56
|
+
durationMs?: number;
|
|
57
|
+
previewUrl?: string;
|
|
58
|
+
coverUrl?: string;
|
|
59
|
+
url?: string;
|
|
60
|
+
/** The track's album provider id, for `importTrack({ withAlbum })`. */
|
|
61
|
+
albumId?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Normalized, provider-sourced artist facts (fields vary by provider). */
|
|
65
|
+
export interface NormalizedArtist {
|
|
66
|
+
name: string;
|
|
67
|
+
genres: string[];
|
|
68
|
+
popularity?: number;
|
|
69
|
+
imageUrl?: string;
|
|
70
|
+
url?: string;
|
|
71
|
+
country?: string;
|
|
72
|
+
gender?: string;
|
|
73
|
+
debutYear?: number;
|
|
74
|
+
members?: "solo" | "group";
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Normalized, provider-sourced album facts. */
|
|
78
|
+
export interface NormalizedAlbum {
|
|
79
|
+
title: string;
|
|
80
|
+
artists: ArtistRef[];
|
|
81
|
+
releaseDate?: string;
|
|
82
|
+
coverUrl?: string;
|
|
83
|
+
url?: string;
|
|
84
|
+
trackCount?: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** The normalized payload for any cached entity. */
|
|
88
|
+
export type CacheValue = NormalizedTrack | NormalizedArtist | NormalizedAlbum;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The opaque key that addresses one cached entry. A `type` (not an `interface`)
|
|
92
|
+
* so it satisfies Convex's `DefaultFunctionArgs` index-signature constraint.
|
|
93
|
+
*/
|
|
94
|
+
export type EntryKey = {
|
|
95
|
+
kind: EntityKind;
|
|
96
|
+
provider: Provider;
|
|
97
|
+
externalId: string;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** Arguments to cache one entity. `ttlMs` omitted means never expires. */
|
|
101
|
+
export type PutInput = EntryKey & {
|
|
102
|
+
isrc?: string;
|
|
103
|
+
value: CacheValue;
|
|
104
|
+
ttlMs?: number;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** A cache entry as returned by the component queries. */
|
|
108
|
+
export interface CacheEntry extends EntryKey {
|
|
109
|
+
_id: string;
|
|
110
|
+
_creationTime: number;
|
|
111
|
+
isrc?: string;
|
|
112
|
+
value: CacheValue;
|
|
113
|
+
fetchedAt: number;
|
|
114
|
+
expiresAt: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export type { EntityKind, Provider };
|