@rocksky/sdk 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -69,8 +69,13 @@ full canonical metadata (album, artwork, duration, MBID, ISRC, links).
69
69
  `Authorization: Bearer <token>`.
70
70
 
71
71
  **Writes — `Agent`**: two scrobble paths. `scrobble(rec)` writes full metadata
72
- you already have; `scrobbleMatch(title, artist, album?, mbId?, isrc?)` resolves
73
- full metadata via `matchSong` first, then writes. Plus
72
+ you already have; `scrobbleMatch(input, appview?)` takes a `ScrobbleMatchInput`
73
+ object (`{ title, artist, album?, mbId?, isrc?, timestamp? }` — title/artist
74
+ required; `album` overrides the resolved album, `mbId`/`isrc` are match anchors,
75
+ `timestamp` is a scrobbled-at Unix-seconds time; the optional `appview` overrides
76
+ the AppView used for matching) and resolves full metadata via `matchSong` first,
77
+ then writes — e.g. `agent.scrobbleMatch({ title: "Chaser", artist: "Calibro 35" })`.
78
+ Plus
74
79
  `createSong`/`createAlbum`/`createArtist`, `like`, `follow`,
75
80
  `shout`/`replyShout`, `setNowPlaying`/`clearNowPlaying`, `delete`. Records are the
76
81
  generated types from `./generated/types`.
package/dist/agent.d.ts CHANGED
@@ -6,6 +6,19 @@ import { type JetstreamOptions } from "./jetstream.js";
6
6
  export type ScrobbleInput = Omit<ScrobbleRecord, "createdAt"> & {
7
7
  createdAt?: string;
8
8
  };
9
+ /** Input for {@link Agent.scrobbleMatch} — `title`/`artist` required, rest optional. */
10
+ export interface ScrobbleMatchInput {
11
+ title: string;
12
+ artist: string;
13
+ /** Overrides the matched album. */
14
+ album?: string;
15
+ /** MusicBrainz recording id — anchors the match. */
16
+ mbId?: string;
17
+ /** ISRC — anchors the match. */
18
+ isrc?: string;
19
+ /** Scrobbled-at Unix seconds; omitted = now. */
20
+ timestamp?: number;
21
+ }
9
22
  /** Input for {@link Agent.createSong}. */
10
23
  export type SongInput = Omit<SongRecord, "createdAt"> & {
11
24
  createdAt?: string;
@@ -59,7 +72,7 @@ export declare class Agent {
59
72
  * `mbId`/`isrc` anchors): resolve full metadata via `matchSong`, then write.
60
73
  * Matching uses the public AppView unless `appview` is given; an empty match
61
74
  * falls back to a minimal record. */
62
- scrobbleMatch(title: string, artist: string, album?: string, mbId?: string, isrc?: string, appview?: string): Promise<string>;
75
+ scrobbleMatch(input: ScrobbleMatchInput, appview?: string): Promise<string>;
63
76
  /** Create a canonical track record (app.rocksky.song). */
64
77
  createSong(rec: SongInput): Promise<string>;
65
78
  /** Create an album record (app.rocksky.album). `artist` is the album artist. */
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAG3D,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,cAAc,EACd,cAAc,EACd,UAAU,EACX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAgB,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AA+BrE,oEAAoE;AACpE,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,EAAE,WAAW,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACvF,0CAA0C;AAC1C,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/E,0EAA0E;AAC1E,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AACjF,4CAA4C;AAC5C,MAAM,MAAM,WAAW,GAAG,IAAI,CAAC,YAAY,EAAE,WAAW,CAAC,GAAG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  export type { DateInterval } from "./client.js";
13
- export { Agent, type ScrobbleInput, type SongInput, type AlbumInput, type ArtistInput } from "./agent.js";
13
+ export { Agent, type ScrobbleInput, type ScrobbleMatchInput, type SongInput, type AlbumInput, type ArtistInput, } from "./agent.js";
14
14
  export { RockskyIndex, totalIndexed, type IndexStats } from "./dedup.js";
15
15
  export { runJetstream, DEFAULT_JETSTREAM_SERVERS, type JetstreamOptions } from "./jetstream.js";
16
16
  export { songHash, albumHash, artistHash } from "./hash.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,KAAK,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAC1G,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,mBAAmB,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EACL,KAAK,EACL,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,WAAW,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,yBAAyB,EAAE,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,mBAAmB,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -6007,7 +6007,8 @@ class Agent {
6007
6007
  }
6008
6008
  return uri2;
6009
6009
  }
6010
- async scrobbleMatch(title, artist, album, mbId, isrc, appview) {
6010
+ async scrobbleMatch(input, appview) {
6011
+ const { title, artist, album, mbId, isrc, timestamp } = input;
6011
6012
  const { RockskyClient: RockskyClient2 } = await Promise.resolve().then(() => (init_client2(), exports_client));
6012
6013
  const m = await new RockskyClient2(appview).matchSong(title, artist, mbId, isrc);
6013
6014
  const s = (k) => m && typeof m[k] === "string" ? m[k] : undefined;
@@ -6033,6 +6034,8 @@ class Agent {
6033
6034
  tidalLink: s("tidalLink"),
6034
6035
  appleMusicLink: s("appleMusicLink")
6035
6036
  } : { title, artist, album: album ?? "", albumArtist: artist, duration: 0 };
6037
+ if (timestamp !== undefined)
6038
+ rec.createdAt = new Date(timestamp * 1000).toISOString();
6036
6039
  return this.scrobble(rec);
6037
6040
  }
6038
6041
  async createSong(rec) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocksky/sdk",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "TypeScript SDK for Rocksky — built on atcute: AppView reads, AT Protocol PDS writes (scrobble, like, follow, shout), a local dedup index, and Jetstream real-time sync.",
5
5
  "license": "MIT",
6
6
  "repository": {
package/src/agent.ts CHANGED
@@ -52,6 +52,19 @@ function nowISO(): string {
52
52
  // Write inputs: `createdAt` is optional (the SDK defaults it to now).
53
53
  /** Input for {@link Agent.scrobble} (createdAt defaults to now). */
54
54
  export type ScrobbleInput = Omit<ScrobbleRecord, "createdAt"> & { createdAt?: string };
55
+ /** Input for {@link Agent.scrobbleMatch} — `title`/`artist` required, rest optional. */
56
+ export interface ScrobbleMatchInput {
57
+ title: string;
58
+ artist: string;
59
+ /** Overrides the matched album. */
60
+ album?: string;
61
+ /** MusicBrainz recording id — anchors the match. */
62
+ mbId?: string;
63
+ /** ISRC — anchors the match. */
64
+ isrc?: string;
65
+ /** Scrobbled-at Unix seconds; omitted = now. */
66
+ timestamp?: number;
67
+ }
55
68
  /** Input for {@link Agent.createSong}. */
56
69
  export type SongInput = Omit<SongRecord, "createdAt"> & { createdAt?: string };
57
70
  /** Input for {@link Agent.createAlbum} (`artist` is the album artist). */
@@ -157,14 +170,8 @@ export class Agent {
157
170
  * `mbId`/`isrc` anchors): resolve full metadata via `matchSong`, then write.
158
171
  * Matching uses the public AppView unless `appview` is given; an empty match
159
172
  * falls back to a minimal record. */
160
- async scrobbleMatch(
161
- title: string,
162
- artist: string,
163
- album?: string,
164
- mbId?: string,
165
- isrc?: string,
166
- appview?: string,
167
- ): Promise<string> {
173
+ async scrobbleMatch(input: ScrobbleMatchInput, appview?: string): Promise<string> {
174
+ const { title, artist, album, mbId, isrc, timestamp } = input;
168
175
  const { RockskyClient } = await import("./client.js");
169
176
  const m = (await new RockskyClient(appview).matchSong(title, artist, mbId, isrc)) as Record<
170
177
  string,
@@ -196,6 +203,8 @@ export class Agent {
196
203
  appleMusicLink: s("appleMusicLink"),
197
204
  }
198
205
  : { title, artist, album: album ?? "", albumArtist: artist, duration: 0 };
206
+ // "Scrobbled at" — Unix seconds; omitted -> scrobble() defaults to now.
207
+ if (timestamp !== undefined) rec.createdAt = new Date(timestamp * 1000).toISOString();
199
208
  return this.scrobble(rec);
200
209
  }
201
210
 
package/src/index.ts CHANGED
@@ -10,7 +10,14 @@
10
10
  */
11
11
  export { RockskyClient, DEFAULT_APPVIEW, Interval } from "./client.js";
12
12
  export type { DateInterval } from "./client.js";
13
- export { Agent, type ScrobbleInput, type SongInput, type AlbumInput, type ArtistInput } from "./agent.js";
13
+ export {
14
+ Agent,
15
+ type ScrobbleInput,
16
+ type ScrobbleMatchInput,
17
+ type SongInput,
18
+ type AlbumInput,
19
+ type ArtistInput,
20
+ } from "./agent.js";
14
21
  export { RockskyIndex, totalIndexed, type IndexStats } from "./dedup.js";
15
22
  export { runJetstream, DEFAULT_JETSTREAM_SERVERS, type JetstreamOptions } from "./jetstream.js";
16
23
  export { songHash, albumHash, artistHash } from "./hash.js";