@audd/sdk 1.5.4 → 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/README.md +2 -2
- package/dist/index.cjs +29 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +29 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -228,6 +228,19 @@ interface LongpollOptions {
|
|
|
228
228
|
timeout?: number;
|
|
229
229
|
/** Bypass the default-on `getCallbackUrl` preflight. */
|
|
230
230
|
skipCallbackCheck?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Radio id to subscribe to — the SDK derives the 9-char category locally
|
|
233
|
+
* from `(api_token, radio_id)`. Mutually exclusive with `category`. Only
|
|
234
|
+
* meaningful on the object-form call site (`longpoll({ radioId: 42 })`).
|
|
235
|
+
*/
|
|
236
|
+
radioId?: number;
|
|
237
|
+
/**
|
|
238
|
+
* Pre-derived 9-char longpoll category. Mutually exclusive with `radioId`.
|
|
239
|
+
* Only meaningful on the object-form call site
|
|
240
|
+
* (`longpoll({ category: "abc123def" })`); the positional string form
|
|
241
|
+
* `longpoll("abc123def")` is the more common way to pass a category.
|
|
242
|
+
*/
|
|
243
|
+
category?: string;
|
|
231
244
|
}
|
|
232
245
|
declare class Streams {
|
|
233
246
|
private readonly http;
|
|
@@ -266,6 +279,17 @@ declare class Streams {
|
|
|
266
279
|
/**
|
|
267
280
|
* Long-poll the AudD subscription endpoint.
|
|
268
281
|
*
|
|
282
|
+
* Two call shapes:
|
|
283
|
+
*
|
|
284
|
+
* - **Common case** — pass an options object with `radioId`; the SDK
|
|
285
|
+
* derives the 9-char category locally from `(api_token, radio_id)`:
|
|
286
|
+
* `longpoll({ radioId: 42 })`.
|
|
287
|
+
* - **Tokenless / pre-derived category** — pass the category as a positional
|
|
288
|
+
* string (`longpoll("abc123def")`) or via the object form
|
|
289
|
+
* (`longpoll({ category: "abc123def" })`). Useful when the category was
|
|
290
|
+
* shared with you (e.g. a browser/mobile client running without the
|
|
291
|
+
* api_token).
|
|
292
|
+
*
|
|
269
293
|
* Returns a {@link LongpollPoll} handle with three async-iterables —
|
|
270
294
|
* `matches`, `notifications`, `errors` — that are filled by a background
|
|
271
295
|
* loop. Iterate them independently or in parallel via `Promise.all([...])`.
|
|
@@ -275,8 +299,16 @@ declare class Streams {
|
|
|
275
299
|
* callback URL, and the preflight surfaces that misconfiguration as an
|
|
276
300
|
* actionable {@link AudDInvalidRequestError}. Pass `skipCallbackCheck: true`
|
|
277
301
|
* to bypass.
|
|
302
|
+
*
|
|
303
|
+
* Throws {@link AudDInvalidRequestError} if the object form supplies both
|
|
304
|
+
* `radioId` and `category`, or neither.
|
|
278
305
|
*/
|
|
279
306
|
longpoll(category: string, opts?: LongpollOptions): Promise<LongpollPoll>;
|
|
307
|
+
longpoll(opts: LongpollOptions & ({
|
|
308
|
+
radioId: number;
|
|
309
|
+
} | {
|
|
310
|
+
category: string;
|
|
311
|
+
})): Promise<LongpollPoll>;
|
|
280
312
|
private preflightCallbackUrl;
|
|
281
313
|
}
|
|
282
314
|
|
package/dist/index.d.ts
CHANGED
|
@@ -228,6 +228,19 @@ interface LongpollOptions {
|
|
|
228
228
|
timeout?: number;
|
|
229
229
|
/** Bypass the default-on `getCallbackUrl` preflight. */
|
|
230
230
|
skipCallbackCheck?: boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Radio id to subscribe to — the SDK derives the 9-char category locally
|
|
233
|
+
* from `(api_token, radio_id)`. Mutually exclusive with `category`. Only
|
|
234
|
+
* meaningful on the object-form call site (`longpoll({ radioId: 42 })`).
|
|
235
|
+
*/
|
|
236
|
+
radioId?: number;
|
|
237
|
+
/**
|
|
238
|
+
* Pre-derived 9-char longpoll category. Mutually exclusive with `radioId`.
|
|
239
|
+
* Only meaningful on the object-form call site
|
|
240
|
+
* (`longpoll({ category: "abc123def" })`); the positional string form
|
|
241
|
+
* `longpoll("abc123def")` is the more common way to pass a category.
|
|
242
|
+
*/
|
|
243
|
+
category?: string;
|
|
231
244
|
}
|
|
232
245
|
declare class Streams {
|
|
233
246
|
private readonly http;
|
|
@@ -266,6 +279,17 @@ declare class Streams {
|
|
|
266
279
|
/**
|
|
267
280
|
* Long-poll the AudD subscription endpoint.
|
|
268
281
|
*
|
|
282
|
+
* Two call shapes:
|
|
283
|
+
*
|
|
284
|
+
* - **Common case** — pass an options object with `radioId`; the SDK
|
|
285
|
+
* derives the 9-char category locally from `(api_token, radio_id)`:
|
|
286
|
+
* `longpoll({ radioId: 42 })`.
|
|
287
|
+
* - **Tokenless / pre-derived category** — pass the category as a positional
|
|
288
|
+
* string (`longpoll("abc123def")`) or via the object form
|
|
289
|
+
* (`longpoll({ category: "abc123def" })`). Useful when the category was
|
|
290
|
+
* shared with you (e.g. a browser/mobile client running without the
|
|
291
|
+
* api_token).
|
|
292
|
+
*
|
|
269
293
|
* Returns a {@link LongpollPoll} handle with three async-iterables —
|
|
270
294
|
* `matches`, `notifications`, `errors` — that are filled by a background
|
|
271
295
|
* loop. Iterate them independently or in parallel via `Promise.all([...])`.
|
|
@@ -275,8 +299,16 @@ declare class Streams {
|
|
|
275
299
|
* callback URL, and the preflight surfaces that misconfiguration as an
|
|
276
300
|
* actionable {@link AudDInvalidRequestError}. Pass `skipCallbackCheck: true`
|
|
277
301
|
* to bypass.
|
|
302
|
+
*
|
|
303
|
+
* Throws {@link AudDInvalidRequestError} if the object form supplies both
|
|
304
|
+
* `radioId` and `category`, or neither.
|
|
278
305
|
*/
|
|
279
306
|
longpoll(category: string, opts?: LongpollOptions): Promise<LongpollPoll>;
|
|
307
|
+
longpoll(opts: LongpollOptions & ({
|
|
308
|
+
radioId: number;
|
|
309
|
+
} | {
|
|
310
|
+
category: string;
|
|
311
|
+
})): Promise<LongpollPoll>;
|
|
280
312
|
private preflightCallbackUrl;
|
|
281
313
|
}
|
|
282
314
|
|
package/dist/index.js
CHANGED
|
@@ -1147,30 +1147,42 @@ var Streams = class {
|
|
|
1147
1147
|
parseCallback(body) {
|
|
1148
1148
|
return parseCallback(body);
|
|
1149
1149
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1150
|
+
async longpoll(arg1, opts = {}) {
|
|
1151
|
+
let category;
|
|
1152
|
+
let effectiveOpts;
|
|
1153
|
+
if (typeof arg1 === "string") {
|
|
1154
|
+
category = arg1;
|
|
1155
|
+
effectiveOpts = opts;
|
|
1156
|
+
} else {
|
|
1157
|
+
effectiveOpts = arg1;
|
|
1158
|
+
const hasRadioId = arg1.radioId !== void 0;
|
|
1159
|
+
const hasCategory = arg1.category !== void 0;
|
|
1160
|
+
if (hasRadioId && hasCategory) {
|
|
1161
|
+
throw new AudDInvalidRequestError({
|
|
1162
|
+
errorCode: 0,
|
|
1163
|
+
message: "longpoll(): pass exactly one of `radioId` or `category` \u2014 got both.",
|
|
1164
|
+
httpStatus: 0
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
if (!hasRadioId && !hasCategory) {
|
|
1168
|
+
throw new AudDInvalidRequestError({
|
|
1169
|
+
errorCode: 0,
|
|
1170
|
+
message: "longpoll(): pass exactly one of `radioId` or `category` \u2014 got neither.",
|
|
1171
|
+
httpStatus: 0
|
|
1172
|
+
});
|
|
1173
|
+
}
|
|
1174
|
+
category = hasRadioId ? this.deriveLongpollCategory(arg1.radioId) : arg1.category;
|
|
1175
|
+
}
|
|
1176
|
+
if (effectiveOpts.skipCallbackCheck !== true) {
|
|
1165
1177
|
await this.preflightCallbackUrl();
|
|
1166
1178
|
}
|
|
1167
|
-
const timeoutSec =
|
|
1179
|
+
const timeoutSec = effectiveOpts.timeout ?? 50;
|
|
1168
1180
|
const httpClient = this.http;
|
|
1169
1181
|
const readPolicy = this.readPolicy;
|
|
1170
1182
|
return startLongpoll({
|
|
1171
1183
|
category,
|
|
1172
1184
|
timeout: timeoutSec,
|
|
1173
|
-
sinceTime:
|
|
1185
|
+
sinceTime: effectiveOpts.sinceTime,
|
|
1174
1186
|
fetchOnce: (params, signal) => runRetried(
|
|
1175
1187
|
() => httpClient.get(`${API_BASE}/longpoll/`, params, { signal }),
|
|
1176
1188
|
readPolicy
|