@audd/sdk 1.5.5 → 1.5.6

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.cjs CHANGED
@@ -1169,30 +1169,42 @@ var Streams = class {
1169
1169
  parseCallback(body) {
1170
1170
  return parseCallback(body);
1171
1171
  }
1172
- /**
1173
- * Long-poll the AudD subscription endpoint.
1174
- *
1175
- * Returns a {@link LongpollPoll} handle with three async-iterables —
1176
- * `matches`, `notifications`, `errors` — that are filled by a background
1177
- * loop. Iterate them independently or in parallel via `Promise.all([...])`.
1178
- *
1179
- * Before the first request the SDK runs a one-time `getCallbackUrl`
1180
- * preflight: AudD silently discards events for accounts that haven't set a
1181
- * callback URL, and the preflight surfaces that misconfiguration as an
1182
- * actionable {@link AudDInvalidRequestError}. Pass `skipCallbackCheck: true`
1183
- * to bypass.
1184
- */
1185
- async longpoll(category, opts = {}) {
1186
- if (opts.skipCallbackCheck !== true) {
1172
+ async longpoll(arg1, opts = {}) {
1173
+ let category;
1174
+ let effectiveOpts;
1175
+ if (typeof arg1 === "string") {
1176
+ category = arg1;
1177
+ effectiveOpts = opts;
1178
+ } else {
1179
+ effectiveOpts = arg1;
1180
+ const hasRadioId = arg1.radioId !== void 0;
1181
+ const hasCategory = arg1.category !== void 0;
1182
+ if (hasRadioId && hasCategory) {
1183
+ throw new AudDInvalidRequestError({
1184
+ errorCode: 0,
1185
+ message: "longpoll(): pass exactly one of `radioId` or `category` \u2014 got both.",
1186
+ httpStatus: 0
1187
+ });
1188
+ }
1189
+ if (!hasRadioId && !hasCategory) {
1190
+ throw new AudDInvalidRequestError({
1191
+ errorCode: 0,
1192
+ message: "longpoll(): pass exactly one of `radioId` or `category` \u2014 got neither.",
1193
+ httpStatus: 0
1194
+ });
1195
+ }
1196
+ category = hasRadioId ? this.deriveLongpollCategory(arg1.radioId) : arg1.category;
1197
+ }
1198
+ if (effectiveOpts.skipCallbackCheck !== true) {
1187
1199
  await this.preflightCallbackUrl();
1188
1200
  }
1189
- const timeoutSec = opts.timeout ?? 50;
1201
+ const timeoutSec = effectiveOpts.timeout ?? 50;
1190
1202
  const httpClient = this.http;
1191
1203
  const readPolicy = this.readPolicy;
1192
1204
  return startLongpoll({
1193
1205
  category,
1194
1206
  timeout: timeoutSec,
1195
- sinceTime: opts.sinceTime,
1207
+ sinceTime: effectiveOpts.sinceTime,
1196
1208
  fetchOnce: (params, signal) => runRetried(
1197
1209
  () => httpClient.get(`${API_BASE}/longpoll/`, params, { signal }),
1198
1210
  readPolicy