@audd/sdk 1.5.6 → 1.5.7

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/dist/index.d.cts CHANGED
@@ -38,11 +38,15 @@ type Source = string | URL | Blob | Uint8Array;
38
38
  * - RECOGNITION — `recognize`, `recognizeEnterprise`, `advanced.findLyrics`:
39
39
  * retry on pre-upload connection failures + 5xx.
40
40
  * DO NOT retry on read-timeout-after-upload (cost protection).
41
- * - MUTATING — `streams.add`, `streams.delete`, etc., `customCatalog.add`:
41
+ * - MUTATING — `streams.add`, `streams.delete`, etc.:
42
42
  * retry only on pre-upload connection failures. DO NOT retry
43
43
  * 5xx (the side effect may have happened).
44
+ * - NONE — `customCatalog.add`: never retry. Custom-catalog upload is
45
+ * metered; auto-retry on transport failure could double-charge
46
+ * for the same audio fingerprinting. Surface a clean error and
47
+ * let the caller decide.
44
48
  */
45
- type RetryClass = "read" | "recognition" | "mutating";
49
+ type RetryClass = "read" | "recognition" | "mutating" | "none";
46
50
  interface RetryPolicy {
47
51
  retryClass: RetryClass;
48
52
  maxAttempts: number;
@@ -318,8 +322,8 @@ interface CustomCatalogAddOptions {
318
322
  }
319
323
  declare class CustomCatalog {
320
324
  private readonly http;
321
- private readonly mutatingPolicy;
322
- constructor(http: HttpClient, mutatingPolicy: RetryPolicy);
325
+ private readonly noRetryPolicy;
326
+ constructor(http: HttpClient, noRetryPolicy: RetryPolicy);
323
327
  /**
324
328
  * **This is NOT how you submit audio for music recognition.** For
325
329
  * recognition, use `audd.recognize()` (or `audd.recognizeEnterprise()` for
@@ -331,6 +335,11 @@ declare class CustomCatalog {
331
335
  * Calling this again with the same `audioId` re-fingerprints that slot.
332
336
  * There is no public list/delete endpoint; track `audioId` ↔ song
333
337
  * mappings on your side.
338
+ *
339
+ * **No automatic retry.** Custom-catalog upload is metered, and a transport
340
+ * failure could otherwise cause a silent re-upload that double-charges. Any
341
+ * 5xx or pre-upload connection error surfaces as a clean exception — the
342
+ * caller decides whether to retry.
334
343
  */
335
344
  add(opts: CustomCatalogAddOptions): Promise<void>;
336
345
  }
package/dist/index.d.ts CHANGED
@@ -38,11 +38,15 @@ type Source = string | URL | Blob | Uint8Array;
38
38
  * - RECOGNITION — `recognize`, `recognizeEnterprise`, `advanced.findLyrics`:
39
39
  * retry on pre-upload connection failures + 5xx.
40
40
  * DO NOT retry on read-timeout-after-upload (cost protection).
41
- * - MUTATING — `streams.add`, `streams.delete`, etc., `customCatalog.add`:
41
+ * - MUTATING — `streams.add`, `streams.delete`, etc.:
42
42
  * retry only on pre-upload connection failures. DO NOT retry
43
43
  * 5xx (the side effect may have happened).
44
+ * - NONE — `customCatalog.add`: never retry. Custom-catalog upload is
45
+ * metered; auto-retry on transport failure could double-charge
46
+ * for the same audio fingerprinting. Surface a clean error and
47
+ * let the caller decide.
44
48
  */
45
- type RetryClass = "read" | "recognition" | "mutating";
49
+ type RetryClass = "read" | "recognition" | "mutating" | "none";
46
50
  interface RetryPolicy {
47
51
  retryClass: RetryClass;
48
52
  maxAttempts: number;
@@ -318,8 +322,8 @@ interface CustomCatalogAddOptions {
318
322
  }
319
323
  declare class CustomCatalog {
320
324
  private readonly http;
321
- private readonly mutatingPolicy;
322
- constructor(http: HttpClient, mutatingPolicy: RetryPolicy);
325
+ private readonly noRetryPolicy;
326
+ constructor(http: HttpClient, noRetryPolicy: RetryPolicy);
323
327
  /**
324
328
  * **This is NOT how you submit audio for music recognition.** For
325
329
  * recognition, use `audd.recognize()` (or `audd.recognizeEnterprise()` for
@@ -331,6 +335,11 @@ declare class CustomCatalog {
331
335
  * Calling this again with the same `audioId` re-fingerprints that slot.
332
336
  * There is no public list/delete endpoint; track `audioId` ↔ song
333
337
  * mappings on your side.
338
+ *
339
+ * **No automatic retry.** Custom-catalog upload is metered, and a transport
340
+ * failure could otherwise cause a silent re-upload that double-charges. Any
341
+ * 5xx or pre-upload connection error surfaces as a clean exception — the
342
+ * caller decides whether to retry.
334
343
  */
335
344
  add(opts: CustomCatalogAddOptions): Promise<void>;
336
345
  }
package/dist/index.js CHANGED
@@ -662,6 +662,8 @@ function shouldRetryResponse(resp, retryClass) {
662
662
  return s >= HTTP_SERVER_ERROR_FLOOR;
663
663
  case "mutating":
664
664
  return false;
665
+ case "none":
666
+ return false;
665
667
  }
666
668
  }
667
669
  function shouldRetryError(err, retryClass) {
@@ -672,6 +674,8 @@ function shouldRetryError(err, retryClass) {
672
674
  return isPreUploadConnectionError(err);
673
675
  case "mutating":
674
676
  return isPreUploadConnectionError(err);
677
+ case "none":
678
+ return false;
675
679
  }
676
680
  }
677
681
  function sleep(ms) {
@@ -1244,12 +1248,12 @@ async function runRetried2(fn, policy) {
1244
1248
  }
1245
1249
  }
1246
1250
  var CustomCatalog = class {
1247
- constructor(http, mutatingPolicy) {
1251
+ constructor(http, noRetryPolicy) {
1248
1252
  this.http = http;
1249
- this.mutatingPolicy = mutatingPolicy;
1253
+ this.noRetryPolicy = noRetryPolicy;
1250
1254
  }
1251
1255
  http;
1252
- mutatingPolicy;
1256
+ noRetryPolicy;
1253
1257
  /**
1254
1258
  * **This is NOT how you submit audio for music recognition.** For
1255
1259
  * recognition, use `audd.recognize()` (or `audd.recognizeEnterprise()` for
@@ -1261,6 +1265,11 @@ var CustomCatalog = class {
1261
1265
  * Calling this again with the same `audioId` re-fingerprints that slot.
1262
1266
  * There is no public list/delete endpoint; track `audioId` ↔ song
1263
1267
  * mappings on your side.
1268
+ *
1269
+ * **No automatic retry.** Custom-catalog upload is metered, and a transport
1270
+ * failure could otherwise cause a silent re-upload that double-charges. Any
1271
+ * 5xx or pre-upload connection error surfaces as a clean exception — the
1272
+ * caller decides whether to retry.
1264
1273
  */
1265
1274
  async add(opts) {
1266
1275
  const reopen = prepareSource(opts.source);
@@ -1269,7 +1278,7 @@ var CustomCatalog = class {
1269
1278
  const prepared = await reopen();
1270
1279
  const fields = { ...prepared.fields, audio_id: audioId };
1271
1280
  return this.http.postForm(UPLOAD_URL, fields);
1272
- }, this.mutatingPolicy);
1281
+ }, this.noRetryPolicy);
1273
1282
  decodeSuccess2(resp.jsonBody, resp.httpStatus, resp.requestId);
1274
1283
  }
1275
1284
  };
@@ -1513,7 +1522,7 @@ var AudD = class {
1513
1522
  /** Sub-namespace for the private fingerprint catalog. NOT for recognition. */
1514
1523
  get customCatalog() {
1515
1524
  if (this._customCatalog === void 0) {
1516
- this._customCatalog = new CustomCatalog(this._http, this.policyFor("mutating"));
1525
+ this._customCatalog = new CustomCatalog(this._http, this.policyFor("none"));
1517
1526
  }
1518
1527
  return this._customCatalog;
1519
1528
  }