@vllnt/convex-music 0.1.0-canary.a823b81
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 +121 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +78 -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 +118 -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 +125 -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 +156 -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 +140 -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
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 bntvllnt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
<!-- Badges -->
|
|
2
|
+
|
|
3
|
+
[](https://convex.dev/components)
|
|
4
|
+
[](https://www.npmjs.com/package/@vllnt/convex-music)
|
|
5
|
+
[](https://github.com/vllnt/convex-music/actions/workflows/ci.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
8
|
+
# @vllnt/convex-music
|
|
9
|
+
|
|
10
|
+
A provider-neutral, cached music catalog for Convex apps — look up tracks, artists, and albums
|
|
11
|
+
from Spotify, Apple Music, and more through one typed API, with results cached in the component's
|
|
12
|
+
own sandboxed tables.
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
const music = new Music(components.music);
|
|
16
|
+
|
|
17
|
+
// Cache a provider's normalized facts for an entity (TTL-bounded)…
|
|
18
|
+
await music.put(ctx, { kind: "track", provider: "spotify", externalId: id, isrc, value });
|
|
19
|
+
// …then read it back fast on the next request.
|
|
20
|
+
const hit = await music.get(ctx, { kind: "track", provider: "spotify", externalId: id });
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- One typed API across providers — Spotify and Apple Music today; Deezer, MusicBrainz, and
|
|
26
|
+
Wikidata as drop-in adapters.
|
|
27
|
+
- Sandboxed cache tables with a per-entry TTL — dedupe provider calls and ease rate limits.
|
|
28
|
+
- Tracks, artists, and albums, cached by opaque provider id and cross-referenced by ISRC.
|
|
29
|
+
- `getByIsrc` resolves the same recording across every provider you've cached.
|
|
30
|
+
- `pruneExpired` is an idempotent sweep, safe to run on a schedule.
|
|
31
|
+
- Stores only public catalog facts — no secrets or credentials.
|
|
32
|
+
- `[planned]` Owns a durable music catalog (artists / tracks / playlists) populated from providers
|
|
33
|
+
and read via API; your app keeps gameplay + editorial, referencing catalog rows by id / ISRC.
|
|
34
|
+
- `[planned]` In-component import / sync / repair engine, driven by mount policy.
|
|
35
|
+
- `[planned]` Provider fetch/search adapters (`search`, `getTrack` / `getArtist` / `getAlbum`).
|
|
36
|
+
- `[planned]` Field-source policy — configure what comes back from search + catalog reads: which
|
|
37
|
+
entity kinds, which fields, and — for **every field independently** — which provider(s) supply it:
|
|
38
|
+
one, an ordered pick, an explicit subset (e.g. 3 of 4 preview URLs), or all. Multi-select returns a
|
|
39
|
+
provider-keyed map, so adding providers never changes a field's type. Default at mount, override per call.
|
|
40
|
+
- `[planned]` Multiple catalogs per mount — one `app.use` holds many catalogs (e.g. artists, tracks),
|
|
41
|
+
each with its own providers + field-source policy; a default catalog keeps single use zero-config.
|
|
42
|
+
Named mounts remain available for hard isolation.
|
|
43
|
+
- `[planned]` Pluggable providers — add a provider as one adapter (its raw schema + a mapper to the
|
|
44
|
+
internal normalized schema) registered in the registry; no core changes.
|
|
45
|
+
- `[planned]` Artist-image auto-sync with a configurable provider-selection policy.
|
|
46
|
+
|
|
47
|
+
## Installation
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npm install @vllnt/convex-music
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Requires `convex@^1.41.0` as a peer dependency.
|
|
54
|
+
|
|
55
|
+
### Environment variables `[planned]`
|
|
56
|
+
|
|
57
|
+
Provider credentials are supplied as [Convex environment variables](https://docs.convex.dev/production/environment-variables) on your deployment (used once the provider adapters ship):
|
|
58
|
+
|
|
59
|
+
| Provider | Variables |
|
|
60
|
+
| --- | --- |
|
|
61
|
+
| Spotify | `SPOTIFY_CLIENT_ID`, `SPOTIFY_CLIENT_SECRET` |
|
|
62
|
+
| Apple Music | `APPLE_MUSIC_ISSUER`, `APPLE_MUSIC_KID`, `APPLE_MUSIC_PRIVATE_KEY` |
|
|
63
|
+
|
|
64
|
+
Which providers are enabled (and their preference order) is set in the mount policy, not via env flags.
|
|
65
|
+
|
|
66
|
+
## Usage
|
|
67
|
+
|
|
68
|
+
Mount the component in your app's `convex.config.ts`:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { defineApp } from "convex/server";
|
|
72
|
+
import music from "@vllnt/convex-music/convex.config";
|
|
73
|
+
|
|
74
|
+
const app = defineApp();
|
|
75
|
+
app.use(music);
|
|
76
|
+
export default app;
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Then use the client from your own queries and mutations. The host owns auth — gate the write
|
|
80
|
+
methods behind your own authorized functions, and persist results into your own domain tables:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import { Music } from "@vllnt/convex-music";
|
|
84
|
+
import { components } from "./_generated/api";
|
|
85
|
+
|
|
86
|
+
const music = new Music(components.music);
|
|
87
|
+
|
|
88
|
+
export const cacheTrack = internalMutation({
|
|
89
|
+
args: { externalId: v.string(), isrc: v.string(), value: trackValue },
|
|
90
|
+
handler: (ctx, args) =>
|
|
91
|
+
music.put(ctx, {
|
|
92
|
+
kind: "track",
|
|
93
|
+
provider: "spotify",
|
|
94
|
+
externalId: args.externalId,
|
|
95
|
+
isrc: args.isrc,
|
|
96
|
+
value: args.value,
|
|
97
|
+
ttlMs: 1000 * 60 * 60 * 24, // refresh daily
|
|
98
|
+
}),
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## API Reference
|
|
103
|
+
|
|
104
|
+
| Method | Kind | Description |
|
|
105
|
+
| --- | --- | --- |
|
|
106
|
+
| `put(ctx, input)` | mutation | Cache (insert or refresh) one provider's facts; returns the entry id. |
|
|
107
|
+
| `get(ctx, key)` | query | Fetch one cached entry, or `null` if missing or expired. |
|
|
108
|
+
| `getByIsrc(ctx, isrc)` | query | Every fresh cached track for an ISRC, across providers. |
|
|
109
|
+
| `invalidate(ctx, key)` | mutation | Drop one cached entry; returns whether a row was deleted. |
|
|
110
|
+
| `pruneExpired(ctx)` | mutation | Delete every expired entry; returns the count removed. |
|
|
111
|
+
| `stats(ctx)` | query | Count of cached entries. |
|
|
112
|
+
|
|
113
|
+
Full reference — signatures, value shapes, and error codes: [`docs/API.md`](docs/API.md).
|
|
114
|
+
|
|
115
|
+
## React [planned]
|
|
116
|
+
|
|
117
|
+
> Shipped in the `./react` entry; wraps the **planned** catalog query surface (not in 0.1.0).
|
|
118
|
+
|
|
119
|
+
Optional, tree-shakeable hooks over `convex/react`. The host re-exports its own catalog query
|
|
120
|
+
refs and passes them in — the component never owns the host's `api`. `react` + `convex/react`
|
|
121
|
+
are optional peer deps, so a backend-only consumer pulls in zero React.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { useArtist, useSearchTracks } from "@vllnt/convex-music/react";
|
|
125
|
+
import { api } from "../convex/_generated/api"; // your wrappers re-exporting the component queries
|
|
126
|
+
|
|
127
|
+
const artist = useArtist(api.music.getArtist, artistId);
|
|
128
|
+
const tracks = useSearchTracks(api.music.searchTracks, query, 20);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
| Hook | Returns | Description |
|
|
132
|
+
| --- | --- | --- |
|
|
133
|
+
| `useArtist(ref, id)` | `CatalogArtist \| null` | Reactively read one unified artist by id. |
|
|
134
|
+
| `useTrack(ref, id)` | `CatalogTrack \| null` | Reactively read one unified track by id. |
|
|
135
|
+
| `useArtistImage(ref, provider, id, policy?)` | `string \| null` | Project an artist image per a field-source policy. |
|
|
136
|
+
| `useTrackPreview(ref, provider, id, policy?)` | `string \| null` | Project a track preview URL per a field-source policy. |
|
|
137
|
+
| `useSearchArtists(ref, query, limit?)` | `CatalogArtist[]` | Reactively search artists by name. |
|
|
138
|
+
| `useSearchTracks(ref, query, limit?)` | `CatalogTrack[]` | Reactively search tracks by title. |
|
|
139
|
+
|
|
140
|
+
## Security
|
|
141
|
+
|
|
142
|
+
- The component caches only public catalog facts — no secrets or credentials are stored.
|
|
143
|
+
- Provider credentials live in the host's environment; they never reach the client.
|
|
144
|
+
- The host gates every write method behind its own authorized functions.
|
|
145
|
+
|
|
146
|
+
See [`SECURITY.md`](SECURITY.md) for vulnerability reporting.
|
|
147
|
+
|
|
148
|
+
## Testing
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
pnpm test # vitest + convex-test + @edge-runtime/vm
|
|
152
|
+
pnpm test:coverage # 100% coverage gate
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Contributing
|
|
156
|
+
|
|
157
|
+
See [`CONTRIBUTING.md`](CONTRIBUTING.md). Issues and pull requests welcome.
|
|
158
|
+
|
|
159
|
+
## Author
|
|
160
|
+
|
|
161
|
+
Built by [bntvllnt](https://github.com/bntvllnt) · [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
|
|
162
|
+
|
|
163
|
+
Part of the [@vllnt](https://github.com/vllnt) Convex component fleet — [vllnt.com](https://vllnt.com)
|
|
164
|
+
|
|
165
|
+
If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
|
|
166
|
+
|
|
167
|
+
## License
|
|
168
|
+
|
|
169
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import type { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
|
|
2
|
+
import type { Provider } from "../shared.js";
|
|
3
|
+
import type { CacheEntry, CatalogAlbum, CatalogArtist, CatalogPlaylist, CatalogTrack, EntryKey, NormalizedArtist, NormalizedTrack, PutInput, SearchHit } from "./types.js";
|
|
4
|
+
/** Arguments to fetch a provider entity into the catalog (read-through). */
|
|
5
|
+
export type FetchInput = {
|
|
6
|
+
provider: Provider;
|
|
7
|
+
externalId: string;
|
|
8
|
+
force?: boolean;
|
|
9
|
+
};
|
|
10
|
+
/** Arguments to search a provider for artists or tracks. */
|
|
11
|
+
export type SearchInput = {
|
|
12
|
+
provider: Provider;
|
|
13
|
+
query: string;
|
|
14
|
+
type: "artist" | "track";
|
|
15
|
+
};
|
|
16
|
+
/** Arguments to import an artist into the catalog. */
|
|
17
|
+
export type ImportArtistInput = {
|
|
18
|
+
provider: Provider;
|
|
19
|
+
targetMode: "name" | "providerId";
|
|
20
|
+
name?: string;
|
|
21
|
+
providerId?: string;
|
|
22
|
+
/** Back-compat alias for `tracks: "top"`. */
|
|
23
|
+
withTracks?: boolean;
|
|
24
|
+
/** Track traversal depth: artist only / top tracks / every album track. */
|
|
25
|
+
tracks?: "none" | "top" | "all";
|
|
26
|
+
mode?: "import" | "refresh" | "reimport" | "repair";
|
|
27
|
+
priority?: "high" | "normal" | "low";
|
|
28
|
+
};
|
|
29
|
+
/** Arguments to import a track into the catalog. */
|
|
30
|
+
export type ImportTrackInput = {
|
|
31
|
+
provider: Provider;
|
|
32
|
+
providerId: string;
|
|
33
|
+
/** Also import the track's album (when the provider exposes an album id). */
|
|
34
|
+
withAlbum?: boolean;
|
|
35
|
+
mode?: "import" | "refresh" | "reimport" | "repair";
|
|
36
|
+
priority?: "high" | "normal" | "low";
|
|
37
|
+
};
|
|
38
|
+
/** Arguments to import a playlist (+ its tracks) into the catalog. */
|
|
39
|
+
export type ImportPlaylistInput = ImportTrackInput & {
|
|
40
|
+
/** Cap how many of the playlist's tracks to import. */
|
|
41
|
+
limit?: number;
|
|
42
|
+
};
|
|
43
|
+
/** Arguments to import an album by provider id (+ its tracks + artists). */
|
|
44
|
+
export type ImportAlbumInput = ImportTrackInput & {
|
|
45
|
+
/** Cap how many of the album's tracks to import. */
|
|
46
|
+
limit?: number;
|
|
47
|
+
};
|
|
48
|
+
/** The outcome of an import: the request id + its terminal status. */
|
|
49
|
+
export type ImportResult = {
|
|
50
|
+
requestId: string;
|
|
51
|
+
status: string;
|
|
52
|
+
};
|
|
53
|
+
/** Arguments to upsert a provider's artist into the catalog. */
|
|
54
|
+
export type UpsertArtistInput = {
|
|
55
|
+
provider: Provider;
|
|
56
|
+
externalId: string;
|
|
57
|
+
value: NormalizedArtist;
|
|
58
|
+
};
|
|
59
|
+
/** Arguments to upsert a provider's track (ISRC required) into the catalog. */
|
|
60
|
+
export type UpsertTrackInput = {
|
|
61
|
+
provider: Provider;
|
|
62
|
+
externalId: string;
|
|
63
|
+
value: NormalizedTrack;
|
|
64
|
+
artistIds?: string[];
|
|
65
|
+
};
|
|
66
|
+
/** Arguments to upsert a playlist by source-provider identity. */
|
|
67
|
+
export type UpsertPlaylistInput = {
|
|
68
|
+
provider: Provider;
|
|
69
|
+
providerId: string;
|
|
70
|
+
title: string;
|
|
71
|
+
description?: string;
|
|
72
|
+
coverUrl?: string;
|
|
73
|
+
url?: string;
|
|
74
|
+
owner?: string;
|
|
75
|
+
trackIds: string[];
|
|
76
|
+
};
|
|
77
|
+
/** Arguments to upsert an album by source-provider identity. */
|
|
78
|
+
export type UpsertAlbumInput = {
|
|
79
|
+
provider: Provider;
|
|
80
|
+
providerId: string;
|
|
81
|
+
title: string;
|
|
82
|
+
artistIds: string[];
|
|
83
|
+
releaseDate?: string;
|
|
84
|
+
coverUrl?: string;
|
|
85
|
+
url?: string;
|
|
86
|
+
trackCount?: number;
|
|
87
|
+
trackIds: string[];
|
|
88
|
+
};
|
|
89
|
+
/** Arguments to select eligible catalog rows for a daily picker. */
|
|
90
|
+
export type SelectEligibleInput = {
|
|
91
|
+
kind: "artist" | "track";
|
|
92
|
+
limit: number;
|
|
93
|
+
excludeIds?: string[];
|
|
94
|
+
salt?: string;
|
|
95
|
+
scanLimit?: number;
|
|
96
|
+
};
|
|
97
|
+
/**
|
|
98
|
+
* The component's function references, as exposed on the host via
|
|
99
|
+
* `components.music`.
|
|
100
|
+
*/
|
|
101
|
+
export interface MusicComponent {
|
|
102
|
+
mutations: {
|
|
103
|
+
put: FunctionReference<"mutation", "internal", PutInput, string>;
|
|
104
|
+
invalidate: FunctionReference<"mutation", "internal", EntryKey, boolean>;
|
|
105
|
+
pruneExpired: FunctionReference<"mutation", "internal", Record<string, never>, number>;
|
|
106
|
+
};
|
|
107
|
+
queries: {
|
|
108
|
+
get: FunctionReference<"query", "internal", EntryKey, CacheEntry | null>;
|
|
109
|
+
getByIsrc: FunctionReference<"query", "internal", {
|
|
110
|
+
isrc: string;
|
|
111
|
+
}, CacheEntry[]>;
|
|
112
|
+
stats: FunctionReference<"query", "internal", Record<string, never>, {
|
|
113
|
+
total: number;
|
|
114
|
+
}>;
|
|
115
|
+
};
|
|
116
|
+
catalog: {
|
|
117
|
+
mutations: {
|
|
118
|
+
upsertArtist: FunctionReference<"mutation", "internal", UpsertArtistInput, string>;
|
|
119
|
+
upsertTrack: FunctionReference<"mutation", "internal", UpsertTrackInput, string>;
|
|
120
|
+
upsertPlaylist: FunctionReference<"mutation", "internal", UpsertPlaylistInput, string>;
|
|
121
|
+
upsertAlbum: FunctionReference<"mutation", "internal", UpsertAlbumInput, string>;
|
|
122
|
+
};
|
|
123
|
+
queries: {
|
|
124
|
+
getArtist: FunctionReference<"query", "internal", {
|
|
125
|
+
id: string;
|
|
126
|
+
}, CatalogArtist | null>;
|
|
127
|
+
getTrack: FunctionReference<"query", "internal", {
|
|
128
|
+
id: string;
|
|
129
|
+
}, CatalogTrack | null>;
|
|
130
|
+
getPlaylist: FunctionReference<"query", "internal", {
|
|
131
|
+
id: string;
|
|
132
|
+
}, CatalogPlaylist | null>;
|
|
133
|
+
getAlbum: FunctionReference<"query", "internal", {
|
|
134
|
+
id: string;
|
|
135
|
+
}, CatalogAlbum | null>;
|
|
136
|
+
getAlbumByProvider: FunctionReference<"query", "internal", {
|
|
137
|
+
provider: Provider;
|
|
138
|
+
providerId: string;
|
|
139
|
+
}, CatalogAlbum | null>;
|
|
140
|
+
getTrackByIsrc: FunctionReference<"query", "internal", {
|
|
141
|
+
isrc: string;
|
|
142
|
+
}, CatalogTrack | null>;
|
|
143
|
+
searchArtists: FunctionReference<"query", "internal", {
|
|
144
|
+
query: string;
|
|
145
|
+
limit?: number;
|
|
146
|
+
}, CatalogArtist[]>;
|
|
147
|
+
searchTracks: FunctionReference<"query", "internal", {
|
|
148
|
+
query: string;
|
|
149
|
+
limit?: number;
|
|
150
|
+
}, CatalogTrack[]>;
|
|
151
|
+
selectEligible: FunctionReference<"query", "internal", SelectEligibleInput, Array<CatalogArtist | CatalogTrack>>;
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
actions: {
|
|
155
|
+
fetchArtist: FunctionReference<"action", "internal", FetchInput, CatalogArtist | null>;
|
|
156
|
+
fetchTrack: FunctionReference<"action", "internal", FetchInput, CatalogTrack | null>;
|
|
157
|
+
search: FunctionReference<"action", "internal", SearchInput, SearchHit[]>;
|
|
158
|
+
resolveByIsrc: FunctionReference<"action", "internal", {
|
|
159
|
+
isrc: string;
|
|
160
|
+
provider: Provider;
|
|
161
|
+
}, CatalogTrack | null>;
|
|
162
|
+
};
|
|
163
|
+
config: {
|
|
164
|
+
mutations: {
|
|
165
|
+
configure: FunctionReference<"mutation", "internal", {
|
|
166
|
+
provider: Provider;
|
|
167
|
+
secrets: Record<string, string>;
|
|
168
|
+
}, null>;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
imports: {
|
|
172
|
+
actions: {
|
|
173
|
+
importArtist: FunctionReference<"action", "internal", ImportArtistInput, ImportResult>;
|
|
174
|
+
importTrack: FunctionReference<"action", "internal", ImportTrackInput, ImportResult>;
|
|
175
|
+
importPlaylist: FunctionReference<"action", "internal", ImportPlaylistInput, ImportResult>;
|
|
176
|
+
importAlbum: FunctionReference<"action", "internal", ImportAlbumInput, ImportResult>;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
interface RunQueryCtx {
|
|
181
|
+
runQuery<Q extends FunctionReference<"query", "internal">>(reference: Q, args: FunctionArgs<Q>): Promise<FunctionReturnType<Q>>;
|
|
182
|
+
}
|
|
183
|
+
interface RunMutationCtx {
|
|
184
|
+
runMutation<M extends FunctionReference<"mutation", "internal">>(reference: M, args: FunctionArgs<M>): Promise<FunctionReturnType<M>>;
|
|
185
|
+
}
|
|
186
|
+
interface RunActionCtx {
|
|
187
|
+
runAction<A extends FunctionReference<"action", "internal">>(reference: A, args: FunctionArgs<A>): Promise<FunctionReturnType<A>>;
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Consumer-facing client for `@vllnt/convex-music`. Construct with the mounted
|
|
191
|
+
* component ref, then call from host queries/mutations/actions.
|
|
192
|
+
*
|
|
193
|
+
* `0.1.0` is the raw provider-fetch cache; the durable music catalog
|
|
194
|
+
* (artists/tracks/playlists) the component will own is planned (see ROADMAP).
|
|
195
|
+
* The host owns auth and gates write methods behind its own mutations, and keeps
|
|
196
|
+
* gameplay + editorial, referencing catalog rows by id / ISRC.
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```ts
|
|
200
|
+
* const music = new Music(components.music);
|
|
201
|
+
* const hit = await music.get(ctx, { kind: "track", provider: "spotify", externalId: id });
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
export declare class Music {
|
|
205
|
+
private readonly component;
|
|
206
|
+
constructor(component: MusicComponent);
|
|
207
|
+
/** Cache (insert or refresh) a provider's normalized facts for an entity. */
|
|
208
|
+
put(ctx: RunMutationCtx, input: PutInput): Promise<string>;
|
|
209
|
+
/** Fetch one cached entry, or `null` if missing or expired. */
|
|
210
|
+
get(ctx: RunQueryCtx, key: EntryKey): Promise<CacheEntry | null>;
|
|
211
|
+
/** Every fresh cached track for an ISRC, across providers. */
|
|
212
|
+
getByIsrc(ctx: RunQueryCtx, isrc: string): Promise<CacheEntry[]>;
|
|
213
|
+
/** Drop one cached entry. Returns whether a row was deleted. */
|
|
214
|
+
invalidate(ctx: RunMutationCtx, key: EntryKey): Promise<boolean>;
|
|
215
|
+
/** Delete every expired entry. Idempotent; safe to run on a schedule. */
|
|
216
|
+
pruneExpired(ctx: RunMutationCtx): Promise<number>;
|
|
217
|
+
/** Count of cached entries (fresh + expired). */
|
|
218
|
+
stats(ctx: RunQueryCtx): Promise<{
|
|
219
|
+
total: number;
|
|
220
|
+
}>;
|
|
221
|
+
/** Upsert a provider's artist into the catalog; returns the unified artist id. */
|
|
222
|
+
upsertArtist(ctx: RunMutationCtx, input: UpsertArtistInput): Promise<string>;
|
|
223
|
+
/** Upsert a provider's track (ISRC required); returns the unified track id. */
|
|
224
|
+
upsertTrack(ctx: RunMutationCtx, input: UpsertTrackInput): Promise<string>;
|
|
225
|
+
/** Upsert a playlist by source-provider identity; returns the playlist id. */
|
|
226
|
+
upsertPlaylist(ctx: RunMutationCtx, input: UpsertPlaylistInput): Promise<string>;
|
|
227
|
+
/** Upsert an album by source-provider identity; returns the album id. */
|
|
228
|
+
upsertAlbum(ctx: RunMutationCtx, input: UpsertAlbumInput): Promise<string>;
|
|
229
|
+
/** Fetch one album by id. */
|
|
230
|
+
getAlbum(ctx: RunQueryCtx, id: string): Promise<CatalogAlbum | null>;
|
|
231
|
+
/** Resolve an album by its source-provider identity. */
|
|
232
|
+
getAlbumByProvider(ctx: RunQueryCtx, provider: Provider, providerId: string): Promise<CatalogAlbum | null>;
|
|
233
|
+
/** Fetch one unified artist by id. */
|
|
234
|
+
getArtist(ctx: RunQueryCtx, id: string): Promise<CatalogArtist | null>;
|
|
235
|
+
/** Fetch one unified track by id. */
|
|
236
|
+
getTrack(ctx: RunQueryCtx, id: string): Promise<CatalogTrack | null>;
|
|
237
|
+
/** Fetch one playlist by id. */
|
|
238
|
+
getPlaylist(ctx: RunQueryCtx, id: string): Promise<CatalogPlaylist | null>;
|
|
239
|
+
/** Resolve a unified track by ISRC. */
|
|
240
|
+
getTrackByIsrc(ctx: RunQueryCtx, isrc: string): Promise<CatalogTrack | null>;
|
|
241
|
+
/** Full-text search artists by name. */
|
|
242
|
+
searchArtists(ctx: RunQueryCtx, query: string, limit?: number): Promise<CatalogArtist[]>;
|
|
243
|
+
/** Full-text search tracks by title. */
|
|
244
|
+
searchTracks(ctx: RunQueryCtx, query: string, limit?: number): Promise<CatalogTrack[]>;
|
|
245
|
+
/** Select eligible catalog rows for a daily picker (stable rotation). */
|
|
246
|
+
selectEligible(ctx: RunQueryCtx, input: SelectEligibleInput): Promise<Array<CatalogArtist | CatalogTrack>>;
|
|
247
|
+
/**
|
|
248
|
+
* Read-through fetch an artist by provider id, promoting it into the catalog.
|
|
249
|
+
* Cache-through unless `force`. Returns the unified artist row.
|
|
250
|
+
*/
|
|
251
|
+
fetchArtist(ctx: RunActionCtx, input: FetchInput): Promise<CatalogArtist | null>;
|
|
252
|
+
/**
|
|
253
|
+
* Read-through fetch a track by provider id, promoting it + its artists.
|
|
254
|
+
* Cache-through unless `force`. Returns the unified track row.
|
|
255
|
+
*/
|
|
256
|
+
fetchTrack(ctx: RunActionCtx, input: FetchInput): Promise<CatalogTrack | null>;
|
|
257
|
+
/** Search a provider for artists or tracks (discovery; no promotion). */
|
|
258
|
+
search(ctx: RunActionCtx, input: SearchInput): Promise<SearchHit[]>;
|
|
259
|
+
/**
|
|
260
|
+
* Resolve a track by ISRC cross-provider (catalog hit, else search the provider
|
|
261
|
+
* by ISRC and promote). `null` if no provider has it.
|
|
262
|
+
*/
|
|
263
|
+
resolveByIsrc(ctx: RunActionCtx, isrc: string, provider: Provider): Promise<CatalogTrack | null>;
|
|
264
|
+
/**
|
|
265
|
+
* Store a provider's credentials (the host reads its own deployment env vars
|
|
266
|
+
* and passes them in — a component is sandboxed from the deployment's env).
|
|
267
|
+
* Spotify: `{ clientId, clientSecret }`; Apple: `{ issuer, keyId, privateKeyPem }`.
|
|
268
|
+
*/
|
|
269
|
+
configure(ctx: RunMutationCtx, provider: Provider, secrets: Record<string, string>): Promise<null>;
|
|
270
|
+
/**
|
|
271
|
+
* Import an artist into the catalog (by name or provider id). Creates a
|
|
272
|
+
* dedup-aware control-plane request, runs the traversal, and returns the
|
|
273
|
+
* request id + terminal status.
|
|
274
|
+
*/
|
|
275
|
+
importArtist(ctx: RunActionCtx, input: ImportArtistInput): Promise<ImportResult>;
|
|
276
|
+
/** Import a track by provider id into the catalog (+ its credited artists). */
|
|
277
|
+
importTrack(ctx: RunActionCtx, input: ImportTrackInput): Promise<ImportResult>;
|
|
278
|
+
/** Import a playlist by provider id (+ its tracks) into the catalog. */
|
|
279
|
+
importPlaylist(ctx: RunActionCtx, input: ImportPlaylistInput): Promise<ImportResult>;
|
|
280
|
+
/** Import an album by provider id (+ its tracks + artists) into the catalog. */
|
|
281
|
+
importAlbum(ctx: RunActionCtx, input: ImportAlbumInput): Promise<ImportResult>;
|
|
282
|
+
}
|
|
283
|
+
export type { ArtistRef, CacheEntry, CacheValue, CatalogAlbum, CatalogArtist, CatalogPlaylist, CatalogTrack, EntryKey, NormalizedAlbum, NormalizedArtist, NormalizedTrack, PutInput, SearchHit, } from "./types.js";
|
|
284
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EACV,UAAU,EACV,YAAY,EACZ,aAAa,EACb,eAAe,EACf,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,QAAQ,EACR,SAAS,EACV,MAAM,YAAY,CAAC;AAEpB,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAAG;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC1B,CAAC;AAEF,sDAAsD;AACtD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,QAAQ,CAAC;IACnB,UAAU,EAAE,MAAM,GAAG,YAAY,CAAC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,6CAA6C;IAC7C,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2EAA2E;IAC3E,MAAM,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,CAAC;IAChC,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ACR,SAAS,GACV,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Consumer-facing client for `@vllnt/convex-music`. Construct with the mounted
|
|
3
|
+
* component ref, then call from host queries/mutations/actions.
|
|
4
|
+
*
|
|
5
|
+
* `0.1.0` is the raw provider-fetch cache; the durable music catalog
|
|
6
|
+
* (artists/tracks/playlists) the component will own is planned (see ROADMAP).
|
|
7
|
+
* The host owns auth and gates write methods behind its own mutations, and keeps
|
|
8
|
+
* gameplay + editorial, referencing catalog rows by id / ISRC.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const music = new Music(components.music);
|
|
13
|
+
* const hit = await music.get(ctx, { kind: "track", provider: "spotify", externalId: id });
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export class Music {
|
|
17
|
+
component;
|
|
18
|
+
constructor(component) {
|
|
19
|
+
this.component = component;
|
|
20
|
+
}
|
|
21
|
+
/** Cache (insert or refresh) a provider's normalized facts for an entity. */
|
|
22
|
+
put(ctx, input) {
|
|
23
|
+
return ctx.runMutation(this.component.mutations.put, input);
|
|
24
|
+
}
|
|
25
|
+
/** Fetch one cached entry, or `null` if missing or expired. */
|
|
26
|
+
get(ctx, key) {
|
|
27
|
+
return ctx.runQuery(this.component.queries.get, key);
|
|
28
|
+
}
|
|
29
|
+
/** Every fresh cached track for an ISRC, across providers. */
|
|
30
|
+
getByIsrc(ctx, isrc) {
|
|
31
|
+
return ctx.runQuery(this.component.queries.getByIsrc, { isrc });
|
|
32
|
+
}
|
|
33
|
+
/** Drop one cached entry. Returns whether a row was deleted. */
|
|
34
|
+
invalidate(ctx, key) {
|
|
35
|
+
return ctx.runMutation(this.component.mutations.invalidate, key);
|
|
36
|
+
}
|
|
37
|
+
/** Delete every expired entry. Idempotent; safe to run on a schedule. */
|
|
38
|
+
pruneExpired(ctx) {
|
|
39
|
+
return ctx.runMutation(this.component.mutations.pruneExpired, {});
|
|
40
|
+
}
|
|
41
|
+
/** Count of cached entries (fresh + expired). */
|
|
42
|
+
stats(ctx) {
|
|
43
|
+
return ctx.runQuery(this.component.queries.stats, {});
|
|
44
|
+
}
|
|
45
|
+
/** Upsert a provider's artist into the catalog; returns the unified artist id. */
|
|
46
|
+
upsertArtist(ctx, input) {
|
|
47
|
+
return ctx.runMutation(this.component.catalog.mutations.upsertArtist, input);
|
|
48
|
+
}
|
|
49
|
+
/** Upsert a provider's track (ISRC required); returns the unified track id. */
|
|
50
|
+
upsertTrack(ctx, input) {
|
|
51
|
+
return ctx.runMutation(this.component.catalog.mutations.upsertTrack, input);
|
|
52
|
+
}
|
|
53
|
+
/** Upsert a playlist by source-provider identity; returns the playlist id. */
|
|
54
|
+
upsertPlaylist(ctx, input) {
|
|
55
|
+
return ctx.runMutation(this.component.catalog.mutations.upsertPlaylist, input);
|
|
56
|
+
}
|
|
57
|
+
/** Upsert an album by source-provider identity; returns the album id. */
|
|
58
|
+
upsertAlbum(ctx, input) {
|
|
59
|
+
return ctx.runMutation(this.component.catalog.mutations.upsertAlbum, input);
|
|
60
|
+
}
|
|
61
|
+
/** Fetch one album by id. */
|
|
62
|
+
getAlbum(ctx, id) {
|
|
63
|
+
return ctx.runQuery(this.component.catalog.queries.getAlbum, { id });
|
|
64
|
+
}
|
|
65
|
+
/** Resolve an album by its source-provider identity. */
|
|
66
|
+
getAlbumByProvider(ctx, provider, providerId) {
|
|
67
|
+
return ctx.runQuery(this.component.catalog.queries.getAlbumByProvider, {
|
|
68
|
+
provider,
|
|
69
|
+
providerId,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/** Fetch one unified artist by id. */
|
|
73
|
+
getArtist(ctx, id) {
|
|
74
|
+
return ctx.runQuery(this.component.catalog.queries.getArtist, { id });
|
|
75
|
+
}
|
|
76
|
+
/** Fetch one unified track by id. */
|
|
77
|
+
getTrack(ctx, id) {
|
|
78
|
+
return ctx.runQuery(this.component.catalog.queries.getTrack, { id });
|
|
79
|
+
}
|
|
80
|
+
/** Fetch one playlist by id. */
|
|
81
|
+
getPlaylist(ctx, id) {
|
|
82
|
+
return ctx.runQuery(this.component.catalog.queries.getPlaylist, { id });
|
|
83
|
+
}
|
|
84
|
+
/** Resolve a unified track by ISRC. */
|
|
85
|
+
getTrackByIsrc(ctx, isrc) {
|
|
86
|
+
return ctx.runQuery(this.component.catalog.queries.getTrackByIsrc, { isrc });
|
|
87
|
+
}
|
|
88
|
+
/** Full-text search artists by name. */
|
|
89
|
+
searchArtists(ctx, query, limit) {
|
|
90
|
+
return ctx.runQuery(this.component.catalog.queries.searchArtists, {
|
|
91
|
+
query,
|
|
92
|
+
limit,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/** Full-text search tracks by title. */
|
|
96
|
+
searchTracks(ctx, query, limit) {
|
|
97
|
+
return ctx.runQuery(this.component.catalog.queries.searchTracks, {
|
|
98
|
+
query,
|
|
99
|
+
limit,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/** Select eligible catalog rows for a daily picker (stable rotation). */
|
|
103
|
+
selectEligible(ctx, input) {
|
|
104
|
+
return ctx.runQuery(this.component.catalog.queries.selectEligible, input);
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Read-through fetch an artist by provider id, promoting it into the catalog.
|
|
108
|
+
* Cache-through unless `force`. Returns the unified artist row.
|
|
109
|
+
*/
|
|
110
|
+
fetchArtist(ctx, input) {
|
|
111
|
+
return ctx.runAction(this.component.actions.fetchArtist, input);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Read-through fetch a track by provider id, promoting it + its artists.
|
|
115
|
+
* Cache-through unless `force`. Returns the unified track row.
|
|
116
|
+
*/
|
|
117
|
+
fetchTrack(ctx, input) {
|
|
118
|
+
return ctx.runAction(this.component.actions.fetchTrack, input);
|
|
119
|
+
}
|
|
120
|
+
/** Search a provider for artists or tracks (discovery; no promotion). */
|
|
121
|
+
search(ctx, input) {
|
|
122
|
+
return ctx.runAction(this.component.actions.search, input);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Resolve a track by ISRC cross-provider (catalog hit, else search the provider
|
|
126
|
+
* by ISRC and promote). `null` if no provider has it.
|
|
127
|
+
*/
|
|
128
|
+
resolveByIsrc(ctx, isrc, provider) {
|
|
129
|
+
return ctx.runAction(this.component.actions.resolveByIsrc, {
|
|
130
|
+
isrc,
|
|
131
|
+
provider,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Store a provider's credentials (the host reads its own deployment env vars
|
|
136
|
+
* and passes them in — a component is sandboxed from the deployment's env).
|
|
137
|
+
* Spotify: `{ clientId, clientSecret }`; Apple: `{ issuer, keyId, privateKeyPem }`.
|
|
138
|
+
*/
|
|
139
|
+
configure(ctx, provider, secrets) {
|
|
140
|
+
return ctx.runMutation(this.component.config.mutations.configure, {
|
|
141
|
+
provider,
|
|
142
|
+
secrets,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Import an artist into the catalog (by name or provider id). Creates a
|
|
147
|
+
* dedup-aware control-plane request, runs the traversal, and returns the
|
|
148
|
+
* request id + terminal status.
|
|
149
|
+
*/
|
|
150
|
+
importArtist(ctx, input) {
|
|
151
|
+
return ctx.runAction(this.component.imports.actions.importArtist, input);
|
|
152
|
+
}
|
|
153
|
+
/** Import a track by provider id into the catalog (+ its credited artists). */
|
|
154
|
+
importTrack(ctx, input) {
|
|
155
|
+
return ctx.runAction(this.component.imports.actions.importTrack, input);
|
|
156
|
+
}
|
|
157
|
+
/** Import a playlist by provider id (+ its tracks) into the catalog. */
|
|
158
|
+
importPlaylist(ctx, input) {
|
|
159
|
+
return ctx.runAction(this.component.imports.actions.importPlaylist, input);
|
|
160
|
+
}
|
|
161
|
+
/** Import an album by provider id (+ its tracks + artists) into the catalog. */
|
|
162
|
+
importAlbum(ctx, input) {
|
|
163
|
+
return ctx.runAction(this.component.imports.actions.importAlbum, input);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=index.js.map
|