@scrobblr/types 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +49 -0
  2. package/dist/generated/ActivityDay.d.ts +4 -0
  3. package/dist/generated/ActivityDay.js +2 -0
  4. package/dist/generated/Album.d.ts +14 -0
  5. package/dist/generated/Album.js +2 -0
  6. package/dist/generated/ApiToken.d.ts +10 -0
  7. package/dist/generated/ApiToken.js +2 -0
  8. package/dist/generated/Artist.d.ts +14 -0
  9. package/dist/generated/Artist.js +2 -0
  10. package/dist/generated/Comment.d.ts +12 -0
  11. package/dist/generated/Comment.js +2 -0
  12. package/dist/generated/ImageCandidate.d.ts +21 -0
  13. package/dist/generated/ImageCandidate.js +2 -0
  14. package/dist/generated/NowPlaying.d.ts +12 -0
  15. package/dist/generated/NowPlaying.js +2 -0
  16. package/dist/generated/NowPlayingRich.d.ts +14 -0
  17. package/dist/generated/NowPlayingRich.js +2 -0
  18. package/dist/generated/Scrobble.d.ts +13 -0
  19. package/dist/generated/Scrobble.js +2 -0
  20. package/dist/generated/ScrobbleRich.d.ts +16 -0
  21. package/dist/generated/ScrobbleRich.js +2 -0
  22. package/dist/generated/TopArtist.d.ts +6 -0
  23. package/dist/generated/TopArtist.js +2 -0
  24. package/dist/generated/TopListener.d.ts +11 -0
  25. package/dist/generated/TopListener.js +2 -0
  26. package/dist/generated/TopTrack.d.ts +8 -0
  27. package/dist/generated/TopTrack.js +2 -0
  28. package/dist/generated/Track.d.ts +14 -0
  29. package/dist/generated/Track.js +2 -0
  30. package/dist/generated/User.d.ts +20 -0
  31. package/dist/generated/User.js +2 -0
  32. package/dist/generated/UserProfile.d.ts +17 -0
  33. package/dist/generated/UserProfile.js +2 -0
  34. package/dist/generated/UserSession.d.ts +9 -0
  35. package/dist/generated/UserSession.js +2 -0
  36. package/dist/generated/index.d.ts +17 -0
  37. package/dist/generated/index.js +19 -0
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.js +4 -0
  40. package/package.json +45 -0
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # @scrobblr/types
2
+
3
+ Shared TypeScript types for Scrobblr, generated from the Rust API models
4
+ (`crates/shared`) via [ts-rs]. This package is the **contract** between the
5
+ backend and every TypeScript client (the browser extension in this repo, and
6
+ the separate web app).
7
+
8
+ ## How it stays in sync
9
+
10
+ The `.ts` files under `src/generated/` are produced by ts-rs: running
11
+ `cargo test -p shared` at the repo root regenerates them (the export dir is set
12
+ by `TS_RS_EXPORT_DIR` in `.cargo/config.toml`). **Never edit them by hand.**
13
+
14
+ `src/generated/index.ts` is an auto-generated barrel — `bun run gen-index`
15
+ (part of `bun run build`) rebuilds it from whatever files exist, so a new model
16
+ can't be forgotten.
17
+
18
+ ## Consuming it
19
+
20
+ Inside this monorepo it's a workspace dependency (`"@scrobblr/types": "workspace:*"`).
21
+
22
+ Elsewhere (the web repo, contributors):
23
+
24
+ ```sh
25
+ bun add @scrobblr/types
26
+ ```
27
+
28
+ ```ts
29
+ import type { ScrobbleRich, UserProfile } from "@scrobblr/types";
30
+ ```
31
+
32
+ ## Publishing
33
+
34
+ Published to the public npm registry by
35
+ [`.github/workflows/types-release.yml`](../../.github/workflows/types-release.yml).
36
+
37
+ 1. Change a model in `crates/shared`, run `cargo test -p shared`, commit the
38
+ regenerated `src/generated/` files.
39
+ 2. Tag a release: `git tag types-v0.2.0 && git push origin types-v0.2.0`
40
+ (or run the workflow manually with a version).
41
+
42
+ The workflow regenerates the bindings and **fails if the committed types are
43
+ stale**, then builds and publishes. Bump the version following semver —
44
+ removing or renaming a field is a breaking change for consumers.
45
+
46
+ Requires an `NPM_TOKEN` repo secret (an npm automation/granular token with
47
+ publish rights to the `@scrobblr` scope).
48
+
49
+ [ts-rs]: https://github.com/Aleph-Alpha/ts-rs
@@ -0,0 +1,4 @@
1
+ export type ActivityDay = {
2
+ day: string;
3
+ scrobble_count: number;
4
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Album
3
+ */
4
+ export type Album = {
5
+ id: number;
6
+ artist_id: number;
7
+ title: string;
8
+ title_normalized: string;
9
+ mbid: string | null;
10
+ image_url: string | null;
11
+ release_date: string | null;
12
+ scrobble_count: number;
13
+ created_at: string;
14
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,10 @@
1
+ export type ApiToken = {
2
+ id: string;
3
+ user_id: number;
4
+ name: string;
5
+ token_hash: string;
6
+ scopes: Array<string>;
7
+ last_used_at: string | null;
8
+ created_at: string;
9
+ expires_at: string | null;
10
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Artist
3
+ */
4
+ export type Artist = {
5
+ id: number;
6
+ name: string;
7
+ name_normalized: string;
8
+ mbid: string | null;
9
+ image_url: string | null;
10
+ bio: string | null;
11
+ scrobble_count: number;
12
+ listener_count: number;
13
+ created_at: string;
14
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A user comment on a catalog entity, joined with the commenter's identity.
3
+ */
4
+ export type Comment = {
5
+ id: number;
6
+ user_id: number;
7
+ username: string;
8
+ display_name: string | null;
9
+ image_url: string | null;
10
+ body: string;
11
+ created_at: string;
12
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * A community-uploaded image candidate for an artist or album. Uploads add
3
+ * candidates rather than replacing the image; the most-liked candidate
4
+ * (once it clears the vote threshold) becomes the entity's displayed image.
5
+ */
6
+ export type ImageCandidate = {
7
+ id: number;
8
+ url: string;
9
+ uploaded_by: string;
10
+ vote_count: number;
11
+ /**
12
+ * Whether the requesting user has liked this candidate (false when
13
+ * unauthenticated).
14
+ */
15
+ has_voted: boolean;
16
+ /**
17
+ * Whether this candidate is the entity's current displayed image.
18
+ */
19
+ is_default: boolean;
20
+ created_at: string;
21
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,12 @@
1
+ /**
2
+ * NowPlaying
3
+ */
4
+ export type NowPlaying = {
5
+ user_id: number;
6
+ track_id: number;
7
+ artist_id: number;
8
+ album_id: number | null;
9
+ started_at: string;
10
+ expires_at: string;
11
+ source: string;
12
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,14 @@
1
+ export type NowPlayingRich = {
2
+ track_title: string;
3
+ artist_name: string;
4
+ album_title: string | null;
5
+ album_image: string | null;
6
+ /**
7
+ * Fallback artwork for clients when the album has no cover (tracks have
8
+ * no artwork of their own — the album cover is the track's image).
9
+ */
10
+ artist_image: string | null;
11
+ started_at: string;
12
+ expires_at: string;
13
+ source: string;
14
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Scrobble
3
+ */
4
+ export type Scrobble = {
5
+ id: number;
6
+ user_id: number;
7
+ track_id: number;
8
+ artist_id: number;
9
+ album_id: number | null;
10
+ played_at: string;
11
+ source: string;
12
+ duration_ms: number | null;
13
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Rich scrobble for API responses (joined data)
3
+ */
4
+ export type ScrobbleRich = {
5
+ id: number;
6
+ played_at: string;
7
+ source: string;
8
+ track_id: number;
9
+ track_title: string;
10
+ artist_id: number;
11
+ artist_name: string;
12
+ album_id: number | null;
13
+ album_title: string | null;
14
+ album_image: string | null;
15
+ duration_ms: number | null;
16
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,6 @@
1
+ export type TopArtist = {
2
+ artist_id: number;
3
+ artist_name: string;
4
+ image_url: string | null;
5
+ play_count: number;
6
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,11 @@
1
+ /**
2
+ * A user who listens to a given artist or track, with their play count.
3
+ * Only public profiles are ever returned.
4
+ */
5
+ export type TopListener = {
6
+ user_id: number;
7
+ username: string;
8
+ display_name: string | null;
9
+ image_url: string | null;
10
+ play_count: number;
11
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,8 @@
1
+ export type TopTrack = {
2
+ track_id: number;
3
+ track_title: string;
4
+ artist_id: number;
5
+ artist_name: string;
6
+ album_image: string | null;
7
+ play_count: number;
8
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Track
3
+ */
4
+ export type Track = {
5
+ id: number;
6
+ artist_id: number;
7
+ album_id: number | null;
8
+ title: string;
9
+ title_normalized: string;
10
+ mbid: string | null;
11
+ duration_ms: number | null;
12
+ scrobble_count: number;
13
+ created_at: string;
14
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * User
3
+ */
4
+ export type User = {
5
+ id: number;
6
+ username: string;
7
+ email: string;
8
+ password_hash: string;
9
+ display_name: string | null;
10
+ bio: string | null;
11
+ image_url: string | null;
12
+ website_url: string | null;
13
+ country: string | null;
14
+ scrobble_count: number;
15
+ is_private: boolean;
16
+ is_verified: boolean;
17
+ last_seen_at: string | null;
18
+ created_at: string;
19
+ updated_at: string;
20
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Public-facing profile (no sensitive fields)
3
+ */
4
+ export type UserProfile = {
5
+ id: number;
6
+ username: string;
7
+ display_name: string | null;
8
+ bio: string | null;
9
+ image_url: string | null;
10
+ website_url: string | null;
11
+ country: string | null;
12
+ scrobble_count: number;
13
+ is_private: boolean;
14
+ is_verified: boolean;
15
+ last_seen_at: string | null;
16
+ created_at: string;
17
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,9 @@
1
+ export type UserSession = {
2
+ id: string;
3
+ user_id: number;
4
+ ip_address: string | null;
5
+ user_agent: string | null;
6
+ created_at: string;
7
+ expires_at: string;
8
+ last_used_at: string;
9
+ };
@@ -0,0 +1,2 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ export {};
@@ -0,0 +1,17 @@
1
+ export * from "./ActivityDay.js";
2
+ export * from "./Album.js";
3
+ export * from "./ApiToken.js";
4
+ export * from "./Artist.js";
5
+ export * from "./Comment.js";
6
+ export * from "./ImageCandidate.js";
7
+ export * from "./NowPlaying.js";
8
+ export * from "./NowPlayingRich.js";
9
+ export * from "./Scrobble.js";
10
+ export * from "./ScrobbleRich.js";
11
+ export * from "./TopArtist.js";
12
+ export * from "./TopListener.js";
13
+ export * from "./TopTrack.js";
14
+ export * from "./Track.js";
15
+ export * from "./User.js";
16
+ export * from "./UserProfile.js";
17
+ export * from "./UserSession.js";
@@ -0,0 +1,19 @@
1
+ // AUTO-GENERATED by scripts/gen-index.ts — do not edit.
2
+ // Re-run with `bun run gen-index` (part of `bun run build`).
3
+ export * from "./ActivityDay.js";
4
+ export * from "./Album.js";
5
+ export * from "./ApiToken.js";
6
+ export * from "./Artist.js";
7
+ export * from "./Comment.js";
8
+ export * from "./ImageCandidate.js";
9
+ export * from "./NowPlaying.js";
10
+ export * from "./NowPlayingRich.js";
11
+ export * from "./Scrobble.js";
12
+ export * from "./ScrobbleRich.js";
13
+ export * from "./TopArtist.js";
14
+ export * from "./TopListener.js";
15
+ export * from "./TopTrack.js";
16
+ export * from "./Track.js";
17
+ export * from "./User.js";
18
+ export * from "./UserProfile.js";
19
+ export * from "./UserSession.js";
@@ -0,0 +1 @@
1
+ export * from "./generated/index.js";
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ // Public entrypoint for @scrobblr/types.
2
+ // The barrel below is auto-generated from the ts-rs output; see
3
+ // scripts/gen-index.ts. Add hand-written exports here, not in generated/.
4
+ export * from "./generated/index.js";
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@scrobblr/types",
3
+ "version": "0.1.0",
4
+ "description": "Shared TypeScript types for Scrobblr, generated from the Rust API models via ts-rs.",
5
+ "license": "AGPL-3.0-only",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/scrobblrhq/scrobblr.git",
9
+ "directory": "packages/types"
10
+ },
11
+ "homepage": "https://github.com/scrobblrhq/scrobblr/tree/main/packages/types#readme",
12
+ "bugs": "https://github.com/scrobblrhq/scrobblr/issues",
13
+ "type": "module",
14
+ "sideEffects": false,
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "import": "./dist/index.js",
21
+ "default": "./dist/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public",
29
+ "registry": "https://registry.npmjs.org"
30
+ },
31
+ "scripts": {
32
+ "gen-index": "bun run scripts/gen-index.ts",
33
+ "build": "bun run gen-index && tsc -p tsconfig.build.json",
34
+ "clean": "rm -rf dist",
35
+ "check": "tsc --noEmit",
36
+ "prepublishOnly": "bun run build"
37
+ },
38
+ "peerDependencies": {
39
+ "typescript": "^5"
40
+ },
41
+ "devDependencies": {
42
+ "@types/bun": "latest",
43
+ "typescript": "^5"
44
+ }
45
+ }