@omelhorsite/sdk 0.4.0 → 0.4.1

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.
Files changed (35) hide show
  1. package/README.md +4 -4
  2. package/dist/index.js +4 -4
  3. package/dist/types/auth/device.d.ts +1 -1
  4. package/dist/types/auth/index.d.ts +2 -2
  5. package/dist/types/auth/tokens.d.ts +15 -15
  6. package/dist/types/client.d.ts +10 -10
  7. package/dist/types/errors.d.ts +12 -15
  8. package/dist/types/http.d.ts +74 -118
  9. package/dist/types/index.d.ts +1 -2
  10. package/dist/types/local/qr.d.ts +1 -1
  11. package/dist/types/local/wordlist.d.ts +2 -3
  12. package/dist/types/resources/account.d.ts +14 -17
  13. package/dist/types/resources/auth/index.d.ts +1 -1
  14. package/dist/types/resources/auth/passkeys.d.ts +127 -163
  15. package/dist/types/resources/auth/sessions.d.ts +110 -152
  16. package/dist/types/resources/chests.d.ts +27 -31
  17. package/dist/types/resources/dynamicQrs.d.ts +29 -45
  18. package/dist/types/resources/forms.d.ts +37 -58
  19. package/dist/types/resources/jobs.d.ts +28 -40
  20. package/dist/types/resources/media.d.ts +48 -61
  21. package/dist/types/resources/music/artists.d.ts +179 -245
  22. package/dist/types/resources/music/imports.d.ts +181 -210
  23. package/dist/types/resources/music/index.d.ts +8 -7
  24. package/dist/types/resources/music/playlists.d.ts +77 -110
  25. package/dist/types/resources/music/social.d.ts +153 -228
  26. package/dist/types/resources/music/songs.d.ts +160 -206
  27. package/dist/types/resources/realtime.d.ts +75 -88
  28. package/dist/types/resources/shortLinks.d.ts +33 -45
  29. package/dist/types/resources/storage/upload.d.ts +42 -56
  30. package/dist/types/resources/storage.d.ts +71 -104
  31. package/dist/types/resources/tools/backgroundRemoval.d.ts +11 -13
  32. package/dist/types/resources/tools/captions.d.ts +107 -135
  33. package/dist/types/resources/tools/upscale.d.ts +12 -16
  34. package/dist/types/types.d.ts +29 -38
  35. package/package.json +1 -1
@@ -9,43 +9,37 @@
9
9
  * ## Two routes, and which one is the real one
10
10
  *
11
11
  * - `GET /media/:id/data` and `GET /media/:id/data_url` are the CANONICAL
12
- * routes. `MediaController` serves them, and every new client should use
13
- * them.
12
+ * routes. Every new client should use them.
14
13
  * - `GET /fs_nodes/:id/data` and `GET /fs_nodes/:id/data_url` are a TEMPORARY
15
- * ALIAS, in the backend's own words: "the old `/fs_nodes/:id/data{,_url}`
16
- * routes keep a temporary numeric-id alias for the web frontend".
17
- * `FsNodesController` branches on `params[:id] =~ /\A\d+\z/` and hands a
18
- * numeric id to the same `MusicMediaServing` concern; a storage UUID keeps
19
- * the old filesystem behaviour. The alias exists because the web frontend
20
- * still builds those URLs, and it is scheduled to go together with the
21
- * `*_fs_node_id` blueprint twins.
14
+ * ALIAS. An all-digit id there is served as media; a storage UUID keeps the
15
+ * filesystem behaviour. The alias is scheduled to go, together with the
16
+ * `*_fs_node_id` twins on the music records.
22
17
  *
23
18
  * {@link MediaNamespace.aliasUrl} and {@link MediaNamespace.aliasDataUrl} are
24
- * here so a port of the old web code type-checks, and for the one case where
19
+ * here for code that still spells the old routes, and for the one case where
25
20
  * the alias is genuinely more capable (see the OAuth note below). Reach for
26
21
  * {@link MediaNamespace.url} and {@link MediaNamespace.dataUrl} in new code.
27
22
  *
28
23
  * ## A media id is not a storage node id
29
24
  *
30
- * It is an `active_storage_attachments` primary key, which
31
- * `ApplicationBlueprint.media_id_fields` serialises with `.to_s` - so it is a
32
- * STRING whose characters happen to all be digits (`"48211"`). Storage node
33
- * ids are uuids. The two id spaces are not interchangeable, and the only
34
- * reason a media id works on the `fs_nodes` path at all is the numeric branch
35
- * described above. {@link isMediaId} exists to keep that straight.
25
+ * It is a STRING whose characters happen to all be digits (`"48211"`).
26
+ * Storage node ids are uuids. The two id spaces are not interchangeable, and
27
+ * the only reason a media id works on the `fs_nodes` path at all is the
28
+ * numeric branch described above. {@link isMediaId} exists to keep that
29
+ * straight.
36
30
  *
37
31
  * ## 404 NEVER 401, and why that will empty somebody's library
38
32
  *
39
- * `resolve_music_attachment` returns `nil` - and the controller answers `404
40
- * "Not found"` - for every one of these, deliberately indistinguishable:
33
+ * The server answers `404 "Not found"` for every one of these, deliberately
34
+ * indistinguishable:
41
35
  *
42
36
  * - the id does not exist;
43
37
  * - it exists but belongs to a book, a tool output, another user;
44
38
  * - the caller sent no credential at all;
45
39
  * - the caller sent a credential that no longer resolves to a live session.
46
40
  *
47
- * The routes are declared `allow_unauthenticated_access`, so authentication
48
- * never gets a chance to answer `401`. That is correct for the server:
41
+ * The routes accept anonymous callers, so authentication never gets a chance
42
+ * to answer `401`. That is correct for the server:
49
43
  * existence must not leak. It is a TRAP for the client.
50
44
  *
51
45
  * A client that reads `404` as "this file is gone" will, the moment a session
@@ -59,8 +53,8 @@
59
53
  *
60
54
  * ## The rate ceilings are not the same on the two routes, and that is the point
61
55
  *
62
- * `rack-attack`'s `GENERAL_EXEMPT_PATHS` matches `/media/:id/data` and
63
- * `/fs_nodes/:id/(data|zip)`, and matches NEITHER `data_url`:
56
+ * The general rate-limit exemption covers `/media/:id/data` and
57
+ * `/fs_nodes/:id/(data|zip)`, and NEITHER `data_url`:
64
58
  *
65
59
  * - **`data` is EXEMPT** from the 600/min authenticated and 120/min anonymous
66
60
  * ceilings, on both the canonical route and the alias. An artwork grid, a
@@ -79,12 +73,12 @@
79
73
  *
80
74
  * ## An OAuth access token cannot reach `/media/*` at all
81
75
  *
82
- * `MediaController` declares no `oauth_scope`, and `enforce_oauth_scope!`
83
- * denies by omission: an OAuth token gets `403 {"error":"insufficient_scope"}`
84
- * before the action runs. `FsNodesController` DOES declare `storage:read` on
85
- * `data`/`data_url`, so - until `MediaController` grows a scope - a token
86
- * holding `storage:read` can reach music bytes through the temporary alias and
87
- * not through the canonical route. That inversion is a server-side gap rather
76
+ * The canonical routes accept no OAuth scope at all: an OAuth token gets
77
+ * `403 {"error":"insufficient_scope"}` whatever it carries. The `/fs_nodes`
78
+ * alias DOES accept `storage:read` on `data`/`data_url`, so - until the
79
+ * canonical routes gain a scope - a token holding `storage:read` can reach
80
+ * music bytes through the temporary alias and not through the canonical
81
+ * route. That inversion is a server-side gap rather
88
82
  * than a design decision; it is the single reason to prefer the alias, and it
89
83
  * is expected to close. A session token or the browser cookie reaches both.
90
84
  *
@@ -102,8 +96,7 @@
102
96
  import { Resource } from "../http";
103
97
  import type { FileOutput, RequestOptions } from "../types";
104
98
  /**
105
- * An `active_storage_attachments` id, as the blueprints serialise it: a string
106
- * of digits.
99
+ * A media id: a string of digits.
107
100
  *
108
101
  * Typed as a plain `string` rather than a branded type because that is what
109
102
  * every `*_media_id` field on a song, an artist and a playlist already is, and
@@ -112,7 +105,7 @@ import type { FileOutput, RequestOptions } from "../types";
112
105
  export type MediaId = string;
113
106
  /**
114
107
  * How long a presigned URL from {@link MediaNamespace.dataUrl} stays valid:
115
- * six hours (`MediaUrls::EXPIRY`).
108
+ * six hours.
116
109
  *
117
110
  * The window is long because it has to be, not out of generosity. A media
118
111
  * element re-requests the object on every seek and whenever it resumes a
@@ -123,8 +116,7 @@ export type MediaId = string;
123
116
  export declare const MEDIA_URL_TTL_MS: number;
124
117
  /**
125
118
  * How long a browser may reuse the `302` from `GET /media/:id/data`:
126
- * five minutes (`MusicMediaServing::REDIRECT_CACHE_TTL`), `Cache-Control:
127
- * private`.
119
+ * five minutes, `Cache-Control: private`.
128
120
  *
129
121
  * It exists because a redirect with no `Cache-Control` is never cached, so
130
122
  * every `<img>` re-followed the hop on every mount and artwork visibly
@@ -149,7 +141,7 @@ export declare class MediaNamespace extends Resource {
149
141
  * {@link MEDIA_REDIRECT_CACHE_TTL_MS}. Do NOT put `crossorigin` on the
150
142
  * element: it turns a no-cors load into a CORS one and re-creates exactly
151
143
  * the failure the split between `data` and `data_url` exists to avoid.
152
- * - **token mode (the native app, the CLI)**: this URL alone is a `404`,
144
+ * - **token mode**: this URL alone is a `404`,
153
145
  * because no credential reaches the server. Use
154
146
  * {@link authenticatedUrl} instead.
155
147
  *
@@ -166,11 +158,9 @@ export declare class MediaNamespace extends Resource {
166
158
  * be a getter. In cookie mode there is no token and it returns the bare URL,
167
159
  * which is the correct answer there.
168
160
  *
169
- * `Session.candidate_tokens` reads the `Authorization` header, then
170
- * `params[:token]`, then the cookie, so a query token is a first-class
171
- * credential on this route - and, unlike on the HTML pages served by this
172
- * host, it is not a redirect-injection risk here because there is no page to
173
- * render as somebody else.
161
+ * The server reads the `Authorization` header, then the `token` query
162
+ * parameter, then the cookie, so a query token is a first-class credential
163
+ * on this route.
174
164
  *
175
165
  * **THE RESULT IS A LIVE CREDENTIAL.** It goes into the DOM, into the server
176
166
  * access log, into `Referer` and into anything that records URLs; anyone
@@ -220,8 +210,8 @@ export declare class MediaNamespace extends Resource {
220
210
  * @throws {OmsApiError} 404 `"Not found"` - which does NOT mean the media is
221
211
  * gone. See {@link isMediaMissing} and the namespace notes.
222
212
  * @throws {OmsAuthError} 403 `insufficient_scope` when the client
223
- * authenticated with an OAuth access token; `MediaController` declares no
224
- * scope, so no token reaches it.
213
+ * authenticated with an OAuth access token; the route accepts no scope, so
214
+ * no OAuth token reaches it.
225
215
  */
226
216
  dataUrl(id: MediaId, options?: RequestOptions): Promise<string>;
227
217
  /**
@@ -240,9 +230,8 @@ export declare class MediaNamespace extends Resource {
240
230
  * to a native downloader instead, both of which stream to disk. This method
241
231
  * is for artwork and for the odd file a host really does need in memory.
242
232
  *
243
- * The server falls back to sending the bytes inline (with a
244
- * `Content-Disposition` filename) when the storage service has no URL host,
245
- * which is what dev and test look like; both shapes arrive here identically.
233
+ * The server may also send the bytes inline (with a `Content-Disposition`
234
+ * filename) instead of redirecting; both shapes arrive here identically.
246
235
  *
247
236
  * The runtime follows the redirect, and every conformant one drops the
248
237
  * `Authorization` header on the cross-origin hop. That is not a limitation to
@@ -260,18 +249,17 @@ export declare class MediaNamespace extends Resource {
260
249
  * `GET /fs_nodes/:id/data` - the TEMPORARY numeric-id alias for {@link url}.
261
250
  *
262
251
  * Identical bytes, identical owner-or-404 rule, identical rate-limit
263
- * exemption, resolved by the same `MusicMediaServing` concern. It is here for
264
- * two reasons and no others: code ported from the old web frontend still
265
- * spells it this way, and it is currently the only media route an OAuth token
266
- * carrying `storage:read` can reach (see the namespace notes).
252
+ * exemption. It is here for two reasons and no others: code that still
253
+ * spells the old route, and it is currently the only media route an OAuth
254
+ * token carrying `storage:read` can reach (see the namespace notes).
267
255
  *
268
- * The id must be all digits. `FsNodesController#data` only takes the media
269
- * branch for `/\A\d+\z/`; anything else is looked up as a storage node,
270
- * which for a media id means a 404 with a completely different cause.
271
- * {@link isMediaId} checks that before you spend a request finding out.
256
+ * The id must be all digits. The alias only serves media for an all-digit
257
+ * id; anything else is looked up as a storage node, which for a media id
258
+ * means a 404 with a completely different cause. {@link isMediaId} checks
259
+ * that before you spend a request finding out.
272
260
  *
273
- * @deprecated Prefer {@link url}. The backend calls this alias temporary and
274
- * it will be removed together with the `*_fs_node_id` blueprint twins.
261
+ * @deprecated Prefer {@link url}. The alias is temporary and will be removed
262
+ * together with the `*_fs_node_id` twins.
275
263
  */
276
264
  aliasUrl(id: MediaId): string;
277
265
  /**
@@ -305,9 +293,9 @@ export declare function isMediaId(value: unknown): value is MediaId;
305
293
  * Whether an error is a media `404`.
306
294
  *
307
295
  * **Read the name as "the server would not serve this", never as "this does
308
- * not exist".** The media routes are `allow_unauthenticated_access` and
309
- * `resolve_music_attachment` collapses five different situations into the same
310
- * `404`, on purpose, so that the existence of a file never leaks: unknown id,
296
+ * not exist".** The media routes accept anonymous callers and collapse five
297
+ * different situations into the same `404`, on purpose, so that the existence
298
+ * of a file never leaks: unknown id,
311
299
  * wrong owner, non-music attachment, no credential, and a credential that has
312
300
  * expired.
313
301
  *
@@ -335,16 +323,15 @@ export declare function isMediaMissing(error: unknown): boolean;
335
323
  *
336
324
  * Every music record offers the same choice twice over: a compressed twin and
337
325
  * an original, either of which may be `null`. The compressed one is what a
338
- * client should reach for - the originals are lossless files on a Raspberry Pi
339
- * and an album grid that asks for them takes seconds per tile - and the
340
- * fallback chain is written out by hand in every client today.
326
+ * client should reach for - the originals are lossless files and an album
327
+ * grid that asks for them takes seconds per tile.
341
328
  *
342
329
  * ```ts
343
330
  * const artwork = firstMediaId(song.compressed_artwork_media_id, song.artwork_media_id);
344
331
  * const audio = firstMediaId(song.compressed_audio_media_id, song.audio_media_id);
345
332
  * ```
346
333
  *
347
- * Empty strings are treated as absent: a blueprint field is `null` when there
334
+ * Empty strings are treated as absent: the field is `null` when there
348
335
  * is no attachment, but a form round-trip through a URL or a database can turn
349
336
  * that into `""`, and an empty id would build a request for `/media//data`.
350
337
  */