sonovault 1.1.0 → 1.2.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
@@ -17,6 +17,8 @@ npm install sonovault
17
17
 
18
18
  Node 18+ (uses the built-in `fetch`). ESM and CommonJS both supported.
19
19
 
20
+ Use this library server-side. Shipping your API key in browser code exposes it to anyone who opens devtools. If a key leaks, rotate it in your [dashboard](https://sonovault.now/dashboard/keys).
21
+
20
22
  ## Quickstart
21
23
 
22
24
  ```ts
@@ -61,6 +63,16 @@ for (const row of batch.results) {
61
63
 
62
64
  List endpoints return `{ results, next_cursor }`. Pass the cursor back to get the next page. `next_cursor` is `null` on the last page.
63
65
 
66
+ ```ts
67
+ import { paginate } from "sonovault";
68
+
69
+ for await (const release of paginate((cursor) => sv.artists.releases(42, { cursor }))) {
70
+ console.log(release.title);
71
+ }
72
+ ```
73
+
74
+ Or walk the cursor yourself:
75
+
64
76
  ```ts
65
77
  let cursor: string | undefined;
66
78
  do {
@@ -88,6 +100,11 @@ try {
88
100
 
89
101
  Rate-limited responses that carry a `Retry-After` header are retried automatically. The default is 2 retries, configurable with `maxRetries`.
90
102
 
103
+
104
+ ## Examples
105
+
106
+ Runnable scripts live in [`examples/`](examples/): find an ISRC, resolve cross-platform links, enrich a play log, follow live stream events over SSE, and verify webhook deliveries.
107
+
91
108
  ## API coverage
92
109
 
93
110
  | Namespace | Methods |
package/dist/index.cjs CHANGED
@@ -22,6 +22,7 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  SonoVault: () => SonoVault,
24
24
  SonoVaultError: () => SonoVaultError,
25
+ paginate: () => paginate,
25
26
  verifyWebhookSignature: () => verifyWebhookSignature
26
27
  });
27
28
  module.exports = __toCommonJS(index_exports);
@@ -49,7 +50,7 @@ var SonoVaultError = class extends Error {
49
50
  };
50
51
 
51
52
  // src/version.ts
52
- var VERSION = "1.1.0";
53
+ var VERSION = "1.2.0";
53
54
 
54
55
  // src/client.ts
55
56
  var SonoVault = class {
@@ -276,9 +277,20 @@ function verifyWebhookSignature(options) {
276
277
  const b = Buffer.from(expected);
277
278
  return a.length === b.length && (0, import_node_crypto.timingSafeEqual)(a, b);
278
279
  }
280
+
281
+ // src/pagination.ts
282
+ async function* paginate(fetchPage) {
283
+ let cursor;
284
+ do {
285
+ const page = await fetchPage(cursor);
286
+ for (const item of page.results) yield item;
287
+ cursor = page.next_cursor ?? void 0;
288
+ } while (cursor);
289
+ }
279
290
  // Annotate the CommonJS export names for ESM import in node:
280
291
  0 && (module.exports = {
281
292
  SonoVault,
282
293
  SonoVaultError,
294
+ paginate,
283
295
  verifyWebhookSignature
284
296
  });
package/dist/index.d.cts CHANGED
@@ -410,4 +410,17 @@ declare function verifyWebhookSignature(options: {
410
410
  toleranceSeconds?: number;
411
411
  }): boolean;
412
412
 
413
- export { type Artist, type Genre, type IdentifyRequest, type IdentifyResponse, type IdentifyResult, type IswcLookupResponse, type Label, type Page, type PlatformLink, type PlatformLinksResponse, type Release, type ResolveInputType, type ResolveRequest, type ResolveResponse, type ResolveResult, SonoVault, SonoVaultError, type SonoVaultOptions, type Stream, type StreamEvent, type Track, type TrackArtist, type TrackRelease, type Webhook, verifyWebhookSignature };
413
+ /**
414
+ * Iterate every item across all pages of a cursor-paginated endpoint.
415
+ *
416
+ * ```ts
417
+ * import { paginate } from "sonovault";
418
+ *
419
+ * for await (const release of paginate((cursor) => sv.artists.releases(42, { cursor }))) {
420
+ * console.log(release.title);
421
+ * }
422
+ * ```
423
+ */
424
+ declare function paginate<T>(fetchPage: (cursor: string | undefined) => Promise<Page<T>>): AsyncGenerator<T>;
425
+
426
+ export { type Artist, type Genre, type IdentifyRequest, type IdentifyResponse, type IdentifyResult, type IswcLookupResponse, type Label, type Page, type PlatformLink, type PlatformLinksResponse, type Release, type ResolveInputType, type ResolveRequest, type ResolveResponse, type ResolveResult, SonoVault, SonoVaultError, type SonoVaultOptions, type Stream, type StreamEvent, type Track, type TrackArtist, type TrackRelease, type Webhook, paginate, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -410,4 +410,17 @@ declare function verifyWebhookSignature(options: {
410
410
  toleranceSeconds?: number;
411
411
  }): boolean;
412
412
 
413
- export { type Artist, type Genre, type IdentifyRequest, type IdentifyResponse, type IdentifyResult, type IswcLookupResponse, type Label, type Page, type PlatformLink, type PlatformLinksResponse, type Release, type ResolveInputType, type ResolveRequest, type ResolveResponse, type ResolveResult, SonoVault, SonoVaultError, type SonoVaultOptions, type Stream, type StreamEvent, type Track, type TrackArtist, type TrackRelease, type Webhook, verifyWebhookSignature };
413
+ /**
414
+ * Iterate every item across all pages of a cursor-paginated endpoint.
415
+ *
416
+ * ```ts
417
+ * import { paginate } from "sonovault";
418
+ *
419
+ * for await (const release of paginate((cursor) => sv.artists.releases(42, { cursor }))) {
420
+ * console.log(release.title);
421
+ * }
422
+ * ```
423
+ */
424
+ declare function paginate<T>(fetchPage: (cursor: string | undefined) => Promise<Page<T>>): AsyncGenerator<T>;
425
+
426
+ export { type Artist, type Genre, type IdentifyRequest, type IdentifyResponse, type IdentifyResult, type IswcLookupResponse, type Label, type Page, type PlatformLink, type PlatformLinksResponse, type Release, type ResolveInputType, type ResolveRequest, type ResolveResponse, type ResolveResult, SonoVault, SonoVaultError, type SonoVaultOptions, type Stream, type StreamEvent, type Track, type TrackArtist, type TrackRelease, type Webhook, paginate, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var SonoVaultError = class extends Error {
21
21
  };
22
22
 
23
23
  // src/version.ts
24
- var VERSION = "1.1.0";
24
+ var VERSION = "1.2.0";
25
25
 
26
26
  // src/client.ts
27
27
  var SonoVault = class {
@@ -248,8 +248,19 @@ function verifyWebhookSignature(options) {
248
248
  const b = Buffer.from(expected);
249
249
  return a.length === b.length && timingSafeEqual(a, b);
250
250
  }
251
+
252
+ // src/pagination.ts
253
+ async function* paginate(fetchPage) {
254
+ let cursor;
255
+ do {
256
+ const page = await fetchPage(cursor);
257
+ for (const item of page.results) yield item;
258
+ cursor = page.next_cursor ?? void 0;
259
+ } while (cursor);
260
+ }
251
261
  export {
252
262
  SonoVault,
253
263
  SonoVaultError,
264
+ paginate,
254
265
  verifyWebhookSignature
255
266
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonovault",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "TypeScript/Node client for the SonoVault music metadata API — ISRC, ISWC, genre, labels, release dates, and cross-platform IDs for 90M+ tracks.",
5
5
  "keywords": [
6
6
  "music",