@omelhorsite/sdk 0.2.0 → 0.4.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.
Files changed (96) hide show
  1. package/README.md +112 -130
  2. package/dist/index.js +4800 -610
  3. package/dist/types/client.d.ts +60 -3
  4. package/dist/types/http.d.ts +444 -19
  5. package/dist/types/index.d.ts +5 -1
  6. package/dist/types/internal/attachments.d.ts +17 -0
  7. package/dist/types/internal/helpers.d.ts +9 -0
  8. package/dist/types/listing.d.ts +90 -0
  9. package/dist/types/resources/account.d.ts +71 -5
  10. package/dist/types/resources/admin/authorizedApplications.d.ts +133 -0
  11. package/dist/types/resources/admin/chests.d.ts +51 -0
  12. package/dist/types/resources/admin/eventAlerts.d.ts +60 -0
  13. package/dist/types/resources/admin/identities.d.ts +99 -0
  14. package/dist/types/resources/admin/index.d.ts +77 -0
  15. package/dist/types/resources/admin/jobs.d.ts +97 -0
  16. package/dist/types/resources/admin/myOauthApplications.d.ts +282 -0
  17. package/dist/types/resources/admin/notepads.d.ts +49 -0
  18. package/dist/types/resources/admin/oauthApplications.d.ts +309 -0
  19. package/dist/types/resources/admin/quotas.d.ts +114 -0
  20. package/dist/types/resources/admin/shortLinks.d.ts +201 -0
  21. package/dist/types/resources/admin/types.d.ts +222 -0
  22. package/dist/types/resources/admin/vocalSeparations.d.ts +98 -0
  23. package/dist/types/resources/admin.d.ts +1841 -0
  24. package/dist/types/resources/auth/index.d.ts +39 -0
  25. package/dist/types/resources/auth/passkeys.d.ts +652 -0
  26. package/dist/types/resources/auth/sessions.d.ts +844 -0
  27. package/dist/types/resources/chests.d.ts +54 -3
  28. package/dist/types/resources/content/analysis.d.ts +62 -0
  29. package/dist/types/resources/content/blogs.d.ts +471 -0
  30. package/dist/types/resources/content/feedbacks.d.ts +263 -0
  31. package/dist/types/resources/content/index.d.ts +52 -0
  32. package/dist/types/resources/content/intel/articles.d.ts +230 -0
  33. package/dist/types/resources/content/intel/config.d.ts +135 -0
  34. package/dist/types/resources/content/intel/index.d.ts +53 -0
  35. package/dist/types/resources/content/intel/items.d.ts +91 -0
  36. package/dist/types/resources/content/intel/reports.d.ts +108 -0
  37. package/dist/types/resources/content/intel/scripts.d.ts +152 -0
  38. package/dist/types/resources/content/intel/sources.d.ts +236 -0
  39. package/dist/types/resources/content/intel/stats.d.ts +105 -0
  40. package/dist/types/resources/content/intel/types.d.ts +86 -0
  41. package/dist/types/resources/content/jokes.d.ts +93 -0
  42. package/dist/types/resources/content/notifications.d.ts +147 -0
  43. package/dist/types/resources/content/serviceUsages.d.ts +73 -0
  44. package/dist/types/resources/content/servicesStatus.d.ts +194 -0
  45. package/dist/types/resources/content/siteConfig.d.ts +43 -0
  46. package/dist/types/resources/content/spaceInvaders.d.ts +154 -0
  47. package/dist/types/resources/content.d.ts +2775 -0
  48. package/dist/types/resources/dynamicQrs.d.ts +39 -3
  49. package/dist/types/resources/forms.d.ts +176 -35
  50. package/dist/types/resources/index.d.ts +19 -8
  51. package/dist/types/resources/ipLookup.d.ts +20 -4
  52. package/dist/types/resources/jobs.d.ts +69 -25
  53. package/dist/types/resources/library/annotations.d.ts +162 -0
  54. package/dist/types/resources/library/books.d.ts +534 -0
  55. package/dist/types/resources/library/chat.d.ts +259 -0
  56. package/dist/types/resources/library/index.d.ts +39 -0
  57. package/dist/types/resources/library/shelves.d.ts +237 -0
  58. package/dist/types/resources/library/types.d.ts +120 -0
  59. package/dist/types/resources/library.d.ts +1433 -0
  60. package/dist/types/resources/linkTrees.d.ts +142 -30
  61. package/dist/types/resources/media.d.ts +351 -0
  62. package/dist/types/resources/movies/addons.d.ts +388 -0
  63. package/dist/types/resources/movies/collections.d.ts +352 -0
  64. package/dist/types/resources/movies/index.d.ts +29 -0
  65. package/dist/types/resources/movies/types.d.ts +50 -0
  66. package/dist/types/resources/movies/watchProgress.d.ts +277 -0
  67. package/dist/types/resources/movies.d.ts +1160 -0
  68. package/dist/types/resources/music/artists.d.ts +1068 -0
  69. package/dist/types/resources/music/imports.d.ts +941 -0
  70. package/dist/types/resources/music/index.d.ts +61 -0
  71. package/dist/types/resources/music/playlists.d.ts +1027 -0
  72. package/dist/types/resources/music/social.d.ts +1132 -0
  73. package/dist/types/resources/music/songs.d.ts +1167 -0
  74. package/dist/types/resources/notepads.d.ts +4 -1
  75. package/dist/types/resources/quotas.d.ts +7 -1
  76. package/dist/types/resources/realtime.d.ts +855 -0
  77. package/dist/types/resources/shortLinks.d.ts +49 -5
  78. package/dist/types/resources/social/groupChats.d.ts +458 -0
  79. package/dist/types/resources/social/index.d.ts +19 -0
  80. package/dist/types/resources/social/messages.d.ts +424 -0
  81. package/dist/types/resources/social/relationships.d.ts +322 -0
  82. package/dist/types/resources/social/types.d.ts +37 -0
  83. package/dist/types/resources/social.d.ts +1348 -0
  84. package/dist/types/resources/storage/upload.d.ts +158 -11
  85. package/dist/types/resources/storage.d.ts +111 -27
  86. package/dist/types/resources/tickets.d.ts +101 -13
  87. package/dist/types/resources/tools/backgroundRemoval.d.ts +18 -3
  88. package/dist/types/resources/tools/captions.d.ts +448 -21
  89. package/dist/types/resources/tools/downloader.d.ts +21 -0
  90. package/dist/types/resources/tools/index.d.ts +57 -15
  91. package/dist/types/resources/tools/jumpstyle.d.ts +50 -17
  92. package/dist/types/resources/tools/transcription.d.ts +35 -13
  93. package/dist/types/resources/tools/upscale.d.ts +23 -3
  94. package/dist/types/resources/tools/vocalSeparation.d.ts +30 -13
  95. package/dist/types/types.d.ts +249 -17
  96. package/package.json +2 -1
@@ -0,0 +1,309 @@
1
+ /** `oms.admin.oauthApplications` - the review queue and the registry of every OAuth client. Administrators only. */
2
+ import type { OmsScope } from "../../auth/tokens";
3
+ import { Resource } from "../../http";
4
+ import type { RequestOptions, Timestamp } from "../../types";
5
+ import type { OauthApplicationSummary } from "./types";
6
+ /**
7
+ * A registered client as an ADMINISTRATOR sees it: same eleven keys as
8
+ * {@link OwnedOauthApplication}, but `approved_by` is real and the row can
9
+ * belong to anybody on the server.
10
+ */
11
+ export interface AdminOauthApplication extends OauthApplicationSummary {
12
+ }
13
+ /**
14
+ * {@link AdminOauthApplication} plus the counters that answer "is this client
15
+ * live right now".
16
+ *
17
+ * Returned by every administrator action EXCEPT `index` and `pending`, which
18
+ * send the summary: the counters cost five aggregate queries per row and a
19
+ * listing does not pay for them.
20
+ */
21
+ export interface AdminOauthApplicationDetail extends AdminOauthApplication {
22
+ /**
23
+ * Unrevoked AND unexpired access tokens. Note the difference from
24
+ * {@link AuthorizedApplication.token_count}, which counts unrevoked only: an
25
+ * expired-but-refreshable token counts there and not here, so this number can
26
+ * read `0` for a client that will be talking to the server again in a second.
27
+ */
28
+ readonly live_token_count: number;
29
+ /** Distinct people behind those live tokens. The blast radius of a revocation. */
30
+ readonly live_token_users: number;
31
+ /** Every token ever minted for this client, revoked and expired included. */
32
+ readonly total_token_count: number;
33
+ /** When the most recent token was minted, `null` if never. */
34
+ readonly last_token_at: Timestamp | null;
35
+ /**
36
+ * Device grants nobody has approved yet (`resource_owner_id IS NULL`), i.e.
37
+ * device flows in progress. Approved-but-uncollected grants are NOT counted
38
+ * here, though a revocation kills those too.
39
+ */
40
+ readonly pending_device_grants: number;
41
+ }
42
+ /** What {@link AdminOauthApplicationsNamespace.pending} answers with. */
43
+ export interface AdminOauthPendingQueue {
44
+ /** Oldest first: it is a queue, not a feed. A newest-first queue starves its own bottom. */
45
+ readonly applications: AdminOauthApplication[];
46
+ /** `applications.length`. Sent so a badge does not have to load the array. */
47
+ readonly count: number;
48
+ }
49
+ /** Arguments for {@link AdminOauthApplicationsNamespace.register}. */
50
+ export interface RegisterOauthApplicationInput {
51
+ /** Normalised then required. See {@link OAUTH_APP_NAME_MAX_LENGTH}. */
52
+ readonly name: string;
53
+ /** Unknown scopes are dropped; an empty result after filtering is a `400`. */
54
+ readonly scopes: readonly (OmsScope | string)[] | string;
55
+ /** Defaults to `false`. Every client this project ships is public. */
56
+ readonly confidential?: boolean;
57
+ /** Blank registers {@link NATIVE_LOOPBACK_REDIRECT_VALUE}. */
58
+ readonly redirect_uri?: string;
59
+ }
60
+ /** What {@link AdminOauthApplicationsNamespace.register} answers with. */
61
+ export interface AdminOauthApplicationWithSecret {
62
+ readonly application: AdminOauthApplicationDetail;
63
+ /** Once, and `null` for a public client. See {@link OwnedOauthApplicationWithSecret}. */
64
+ readonly client_secret: string | null;
65
+ }
66
+ /** Arguments for {@link AdminOauthApplicationsNamespace.reject}. */
67
+ export interface RejectOauthApplicationInput {
68
+ /**
69
+ * Required, non-blank, at most 500 characters. **The owner is shown this
70
+ * text**, so write it for them.
71
+ */
72
+ readonly reason: string;
73
+ /**
74
+ * Kill the client's live tokens as well.
75
+ *
76
+ * Opt-in, and it only decides anything for a client that was NOT approved -
77
+ * rejecting an APPROVED client always revokes, whatever this says, because an
78
+ * administrator withdrawing trust has decided the client should stop acting,
79
+ * not that it should stop acting eventually.
80
+ */
81
+ readonly revoke_tokens?: boolean;
82
+ }
83
+ /** What {@link AdminOauthApplicationsNamespace.approve} and `.reject()` answer with. */
84
+ export interface OauthApplicationReview {
85
+ readonly application: AdminOauthApplicationDetail;
86
+ /** Present on `reject`. Absent on `approve`, which never revokes anything. */
87
+ readonly revoked_tokens?: number;
88
+ }
89
+ /** What {@link AdminOauthApplicationsNamespace.revokeTokens} answers with. */
90
+ export interface OauthTokenRevocation {
91
+ readonly application: AdminOauthApplicationDetail;
92
+ readonly revoked_tokens: number;
93
+ }
94
+ /**
95
+ * What {@link AdminOauthApplicationsNamespace.destroy} answers with.
96
+ *
97
+ * The `client_id` is spelled **`uid`** here and `client_id` on the owner route
98
+ * ({@link OwnedOauthApplicationDeletion}). One value, two routes, two names,
99
+ * and nothing reconciles them.
100
+ */
101
+ export interface AdminOauthApplicationDeletion {
102
+ readonly id: number;
103
+ /** The `client_id`. Named after the column, not after the protocol. */
104
+ readonly uid: string;
105
+ readonly revoked_tokens: number;
106
+ }
107
+ /**
108
+ * `oms.admin.oauthApplications` - **administrators only**. The review queue and
109
+ * the registry of every OAuth client on the server.
110
+ *
111
+ * Every method here answers `403 "Admin access required"` to a non-admin. See
112
+ * the namespace documentation for the exact error shape and why
113
+ * re-authenticating will not help.
114
+ *
115
+ * This is the other end of {@link MyOauthApplicationsNamespace}: the same
116
+ * table, without the ownership filter. `destroy` here deletes anybody's client
117
+ * and cuts off everyone using it.
118
+ *
119
+ * Together with the self-service surface, this is the ONLY way a client gets
120
+ * registered: dynamic client registration is off, and there is no client
121
+ * management under `/oauth/*`.
122
+ *
123
+ * ## Review receipts, and why a read here is not a pure read
124
+ *
125
+ * {@link list}, {@link pending} and {@link get} each record, in a server-side
126
+ * cache and keyed to the calling administrator, a digest of what they were just
127
+ * shown. {@link approve} then refuses with `409 review_stale` if the row no
128
+ * longer matches.
129
+ *
130
+ * That exists because approving by id approves whatever the row holds when the
131
+ * request lands, not what the queue rendered - and the window between a
132
+ * reviewer's eyes and their click belongs to the applicant, who may edit a
133
+ * pending client freely (they have to be able to: that is how a refused
134
+ * registration gets fixed). Register something innocent, wait to be read,
135
+ * rename it to "omelhorsite Oficial" with a redirect URI you control, and the
136
+ * approval lands on a client nobody reviewed.
137
+ *
138
+ * Two consequences for a client of this SDK:
139
+ *
140
+ * - **calling `approve` without having read the client first is allowed** and
141
+ * behaves exactly as it would with no receipt. No receipt means no
142
+ * contradiction. This layer tightens the reviewed path; the authorisation
143
+ * check is the `403` above, not this;
144
+ * - the digest covers name, scopes, redirect URIs, `confidential` and owner. It
145
+ * deliberately excludes `approval_status`, so approving twice stays
146
+ * idempotent, and the receipt lasts 7 days.
147
+ *
148
+ * {@link reject} and {@link revokeTokens} are NOT gated this way on purpose:
149
+ * refusing or shutting down a client that changed under you is the safe
150
+ * direction, and a shut-down button that can refuse is how a client stays live.
151
+ */
152
+ export declare class AdminOauthApplicationsNamespace extends Resource {
153
+ /**
154
+ * `GET /admin/oauth_applications` - every client on the server, newest first.
155
+ *
156
+ * No pagination and no filter. Records a review receipt for every row
157
+ * returned; see the class documentation.
158
+ *
159
+ * Summaries, not details: no token counters. Use {@link get} for those.
160
+ *
161
+ * @throws {OmsAuthError} 403 for a non-admin.
162
+ */
163
+ list(options?: RequestOptions): Promise<AdminOauthApplication[]>;
164
+ /**
165
+ * `GET /admin/oauth_applications/pending` - the review queue, oldest first.
166
+ *
167
+ * A separate collection route and NOT a filter on {@link list}, so an admin
168
+ * panel can poll one cheap indexed query without carrying the other
169
+ * listing's joins. Ordered by `created_at` then `id`, which makes the order
170
+ * total: two rows can share a timestamp, and an unstable order makes a
171
+ * polling panel jitter.
172
+ *
173
+ * Records a review receipt for every row returned.
174
+ *
175
+ * @throws {OmsAuthError} 403 for a non-admin.
176
+ */
177
+ pending(options?: RequestOptions): Promise<AdminOauthPendingQueue>;
178
+ /**
179
+ * `GET /admin/oauth_applications/:id` - one client, with its token counters.
180
+ *
181
+ * **`id` may be either the numeric primary key or the `client_id`.** The
182
+ * lookup tries the id first and falls back to the `uid`, which is what makes
183
+ * `oms.admin.oauthApplications.get("oms-cli")` work. The owner route has no
184
+ * such fallback.
185
+ *
186
+ * Records a review receipt.
187
+ *
188
+ * @throws {OmsApiError} 404 `{ "error": "not_found" }`.
189
+ * @throws {OmsAuthError} 403 for a non-admin.
190
+ */
191
+ get(id: number | string, options?: RequestOptions): Promise<AdminOauthApplicationDetail>;
192
+ /**
193
+ * `POST /admin/oauth_applications` - registers a client by hand, already
194
+ * approved.
195
+ *
196
+ * Named `register` and not `create` because it is not the counterpart of
197
+ * {@link MyOauthApplicationsNamespace.create}: what lands here is **born
198
+ * `approved`**, with `owner_id` NULL and `approved_by` set to the calling
199
+ * administrator. An admin registering a client IS the approval; routing them
200
+ * through their own queue would be theatre. It never appears in
201
+ * {@link pending}.
202
+ *
203
+ * **Answers `200`, not `201`**, unlike the self-service registration. Do not
204
+ * branch on the status.
205
+ *
206
+ * The response is the ONLY place `client_secret` ever exists. See
207
+ * {@link OwnedOauthApplicationWithSecret} for why there is nothing to read
208
+ * back later.
209
+ *
210
+ * `confidential` defaults to `false`, which is right for the clients this
211
+ * surface exists to register: anything that ships to end users cannot keep a
212
+ * secret.
213
+ *
214
+ * Retries are disabled: a replay after a lost response mints a second client
215
+ * with a second `client_id` and a second secret you never saw.
216
+ *
217
+ * @throws {OmsApiError} 400 (bare string) for a blank name, no known scope,
218
+ * or too many redirect URIs; 422 `validation_failed` with an `errors` array
219
+ * for a redirect URI this server will not register.
220
+ * @throws {OmsAuthError} 403 for a non-admin.
221
+ */
222
+ register(input: RegisterOauthApplicationInput, options?: RequestOptions): Promise<AdminOauthApplicationWithSecret>;
223
+ /**
224
+ * `POST /admin/oauth_applications/:id/approve` - lets the client start
225
+ * minting tokens.
226
+ *
227
+ * Idempotent, and it works from `rejected` as well as from `pending`: there
228
+ * is no separate rehabilitation action. Approving an already-approved client
229
+ * answers `200` and deliberately does NOT notify the owner a second time - a
230
+ * double click is not two decisions.
231
+ *
232
+ * **Read the class documentation on review receipts before wiring a retry
233
+ * around this.** If this administrator rendered the client and it changed
234
+ * afterwards, the answer is `409 review_stale`, and the body carries the
235
+ * CURRENT row under `application` so the screen can show what it turned into
236
+ * rather than sending someone to go and find out. Retrying that verbatim just
237
+ * gets the same `409`; the fix is to re-read and review again.
238
+ *
239
+ * @throws {OmsApiError} 409 `review_stale`; 404 `not_found`; 422
240
+ * `validation_failed`.
241
+ * @throws {OmsAuthError} 403 for a non-admin.
242
+ */
243
+ approve(id: number | string, options?: RequestOptions): Promise<OauthApplicationReview>;
244
+ /**
245
+ * `POST /admin/oauth_applications/:id/reject` - refuses a registration, or
246
+ * pulls an approved client off the air.
247
+ *
248
+ * One action, two buttons. `pending -> rejected` is a refusal at review;
249
+ * `approved -> rejected` is a suspension, and there is no fourth state to put
250
+ * a client in.
251
+ *
252
+ * **Rejecting shuts the gate but does not by itself kill issued tokens.** A
253
+ * rejected client can no longer mint, refresh or exchange anything, yet
254
+ * access tokens already in the wild keep working until they expire - a blast
255
+ * radius of the two-hour token lifetime. Which is why:
256
+ *
257
+ * - `revoke_tokens: true` kills them in the same breath. Opt-in, so refusing
258
+ * a never-approved registration stays the cheap, quiet operation it should
259
+ * be;
260
+ * - a client that WAS approved has its tokens revoked regardless of the flag.
261
+ *
262
+ * `reason` is required and the OWNER sees it. Re-rejecting with the same
263
+ * reason is a no-op notification-wise; changing the wording notifies again.
264
+ *
265
+ * Not gated by a review receipt: shutting a client down is always the safe
266
+ * direction.
267
+ *
268
+ * @throws {OmsApiError} 400 `reason_required` for a blank reason; 422
269
+ * `validation_failed` past 500 characters; 404 `not_found`.
270
+ * @throws {OmsAuthError} 403 for a non-admin.
271
+ */
272
+ reject(id: number | string, input: RejectOauthApplicationInput, options?: RequestOptions): Promise<OauthApplicationReview>;
273
+ /**
274
+ * `POST /admin/oauth_applications/:id/revoke_tokens` - kills everything the
275
+ * client holds, and leaves the client standing.
276
+ *
277
+ * The 3am action: the `client_id` is fine, what it is doing is not. Every
278
+ * live access token dies, every access grant dies, every device grant is
279
+ * deleted, and the client can be used for a fresh login the second
280
+ * afterwards. Approval is untouched.
281
+ *
282
+ * This is the whole-server version of
283
+ * {@link AuthorizedApplicationsNamespace.revoke}, which only ever touches the
284
+ * caller's own tokens. Read `live_token_users` on the detail first to know
285
+ * how many people you are about to sign out.
286
+ *
287
+ * @throws {OmsApiError} 404 `not_found`.
288
+ * @throws {OmsAuthError} 403 for a non-admin.
289
+ */
290
+ revokeTokens(id: number | string, options?: RequestOptions): Promise<OauthTokenRevocation>;
291
+ /**
292
+ * `DELETE /admin/oauth_applications/:id` - deletes anybody's client.
293
+ *
294
+ * Revokes first, then destroys, so the revocation stamps exist for the moment
295
+ * in between and the device grants (which hold a restricting foreign key) are
296
+ * cleared by hand rather than by a cascade.
297
+ *
298
+ * This is not the tidy-up that {@link MyOauthApplicationsNamespace.destroy}
299
+ * is. Deleting a client somebody else registered signs out everyone using it
300
+ * and there is no undo: the `client_id` is gone and a new registration gets a
301
+ * new one. {@link revokeTokens} is the reversible version.
302
+ *
303
+ * Answers `200` with a body; note the key is `uid`, not `client_id`.
304
+ *
305
+ * @throws {OmsApiError} 404 `not_found`.
306
+ * @throws {OmsAuthError} 403 for a non-admin.
307
+ */
308
+ destroy(id: number | string, options?: RequestOptions): Promise<AdminOauthApplicationDeletion>;
309
+ }
@@ -0,0 +1,114 @@
1
+ /** `oms.admin.quotas` - another person's quota ceilings. Administrators only. */
2
+ import type { QuotaPeriod, QuotaResource, QuotaUnit } from "../quotas";
3
+ import { Resource } from "../../http";
4
+ import type { Id, RequestOptions } from "../../types";
5
+ /**
6
+ * How an override behaves.
7
+ *
8
+ * - `"default"` DELETES the override row, so the person falls back to the
9
+ * catalogue default. It does not write a number equal to the default, which
10
+ * matters the day a default changes;
11
+ * - `"unlimited"` writes an override with a NULL value, which the server reads
12
+ * as no ceiling at all;
13
+ * - `"limit"` writes the number in `value`.
14
+ */
15
+ export type AdminQuotaOverrideMode = "default" | "unlimited" | "limit";
16
+ /** One change to apply. See {@link AdminQuotasNamespace.update}. */
17
+ export interface AdminQuotaOverride {
18
+ readonly resource: QuotaResource | string;
19
+ readonly mode: AdminQuotaOverrideMode;
20
+ /** Required for `"limit"`, ignored otherwise. Must be `>= 0` and fit in a signed 64-bit integer. */
21
+ readonly value?: number;
22
+ }
23
+ /** The stored override behind a {@link AdminUserQuotaEntry}, if there is one. */
24
+ export interface AdminQuotaOverrideState {
25
+ /** The number, or `null` when the override means unlimited. */
26
+ readonly value: number | null;
27
+ /** `true` exactly when `value` is `null`. */
28
+ readonly unlimited: boolean;
29
+ }
30
+ /**
31
+ * One resource, for one person, as an administrator sees it.
32
+ *
33
+ * This is the ordinary quota entry that `oms.quotas.list()` returns, plus the
34
+ * two keys that only make sense while editing: what the default WOULD be, and
35
+ * what is currently overriding it.
36
+ */
37
+ export interface AdminUserQuotaEntry {
38
+ readonly resource: QuotaResource | string;
39
+ readonly unit: QuotaUnit | string;
40
+ readonly period: QuotaPeriod | string;
41
+ /** Consumption right now, in `unit`. */
42
+ readonly used: number;
43
+ /** The effective ceiling, or `null` when unlimited. */
44
+ readonly limit: number | null;
45
+ /** `limit - used`, floored at zero. `null` when unlimited. */
46
+ readonly remaining: number | null;
47
+ readonly unlimited: boolean;
48
+ /** The catalogue default for a signed-in user. What `"default"` mode restores. */
49
+ readonly user_default: number;
50
+ /** The stored override, or `null` when there is none and the default applies. */
51
+ readonly override: AdminQuotaOverrideState | null;
52
+ }
53
+ /** What {@link AdminQuotasNamespace} returns. */
54
+ export interface AdminUserQuotas {
55
+ readonly user_id: Id;
56
+ readonly handle: string;
57
+ /**
58
+ * **Every** resource in the catalogue, including the storage and music
59
+ * ceilings. Unlike the anonymous answer from `oms.quotas.list()`, nothing is
60
+ * left out here. Look entries up by `resource`, never by position.
61
+ */
62
+ readonly quotas: AdminUserQuotaEntry[];
63
+ /**
64
+ * Legacy twin of the `music_storage_bytes` entry's `limit`, `null` when
65
+ * unlimited. Kept for older clients that read it. Prefer the catalogue
66
+ * entry; this key is on its way out.
67
+ */
68
+ readonly music_storage_limit_bytes: number | null;
69
+ }
70
+ /**
71
+ * `oms.admin.quotas` - **administrators only**. Another person's ceilings.
72
+ *
73
+ * The person's own view of the same numbers is `oms.quotas.list()`, which needs
74
+ * no privilege and cannot change anything.
75
+ */
76
+ export declare class AdminQuotasNamespace extends Resource {
77
+ /**
78
+ * `GET /admin/users/:user/quotas` - the full catalogue for one person.
79
+ *
80
+ * **`user` may be a user id OR a handle.** The lookup tries the id first and
81
+ * then the handle, downcased, which is why an admin tool can take whatever
82
+ * was typed into a search box.
83
+ *
84
+ * @throws {OmsApiError} 404 `"User not found"` (a bare JSON string).
85
+ * @throws {OmsAuthError} 403 for a non-admin.
86
+ */
87
+ get(user: Id | string, options?: RequestOptions): Promise<AdminUserQuotas>;
88
+ /**
89
+ * `PUT /admin/users/:user/quotas` - applies a batch of overrides.
90
+ *
91
+ * **`PUT`, not `PATCH`.** The server accepts either verb for this update;
92
+ * this SDK sends `PUT`.
93
+ *
94
+ * **The batch is NOT atomic, and this is the thing to design around.** The
95
+ * server loops over `overrides` and writes each one as it goes, with no
96
+ * transaction around the loop: a bad entry in the middle answers `400` with
97
+ * everything BEFORE it already written and everything after it untouched. So
98
+ * a failed call leaves a partial state, and the only reliable way to know
99
+ * what landed is the answer to a fresh {@link get}. Validate the batch
100
+ * yourself before sending it, or send one override per call.
101
+ *
102
+ * Passing an empty `overrides` array is a legal no-op and a cheap way to read
103
+ * the quotas back, though {@link get} is the honest way to do that.
104
+ *
105
+ * The response is the full, reloaded catalogue, so there is no need to follow
106
+ * this with a read on the success path.
107
+ *
108
+ * @throws {OmsApiError} 400 `"Unknown resource: x"`, `"Invalid mode: x"`, or
109
+ * `"Invalid value for x"` for a negative number or one past the signed
110
+ * 64-bit ceiling. All three are bare JSON strings. 404 `"User not found"`.
111
+ * @throws {OmsAuthError} 403 for a non-admin.
112
+ */
113
+ update(user: Id | string, overrides: readonly AdminQuotaOverride[], options?: RequestOptions): Promise<AdminUserQuotas>;
114
+ }
@@ -0,0 +1,201 @@
1
+ /** `oms.admin.shortLinks` - every public short link and its traffic. Administrators only. */
2
+ import { Resource } from "../../http";
3
+ import type { Id, RequestOptions, Timestamp } from "../../types";
4
+ import type { AdminDailyCount } from "./types";
5
+ /** Compact owner object on an admin short link row. `null` for an anonymous link. */
6
+ export interface AdminShortLinkOwner {
7
+ readonly id: Id;
8
+ readonly name: string;
9
+ readonly handle: string;
10
+ }
11
+ /**
12
+ * A short link as the admin tool sees it.
13
+ *
14
+ * This is NOT the shape the ordinary `shortLinks` namespace returns. The
15
+ * differences are load-bearing:
16
+ *
17
+ * - there is **no `updated_at`**, uniquely on this surface;
18
+ * - there is **no `short_link_clicks` array**. The ordinary shape inlines EVERY
19
+ * click ever recorded, which is a payload hazard on a busy link; here it is
20
+ * replaced by the two aggregates below;
21
+ * - the full user record is replaced by the compact {@link AdminShortLinkOwner}.
22
+ */
23
+ export interface AdminShortLink {
24
+ /**
25
+ * Primary key, and an **integer**: `short_links` kept a bigint primary key
26
+ * while the `user_id` next to it is a string.
27
+ */
28
+ readonly id: number;
29
+ readonly url: string;
30
+ readonly endpoint: string;
31
+ /**
32
+ * Always `null` or `""` on this surface: the listing, the drilldown and the
33
+ * delete are all scoped to non-namespaced links so that private chest,
34
+ * notepad and storage-share URLs never surface here.
35
+ * {@link AdminShortLinksNamespace.namespaces} is the one exception and it
36
+ * only returns counts.
37
+ */
38
+ readonly namespace: string | null;
39
+ /** Owner id, or `null` for a link created anonymously. */
40
+ readonly user_id: Id | null;
41
+ readonly owner: AdminShortLinkOwner | null;
42
+ readonly created_at: Timestamp;
43
+ /** Total clicks. Computed per page in one grouped query, not per row. */
44
+ readonly click_count: number;
45
+ readonly last_click_at: Timestamp | null;
46
+ }
47
+ /** Filters for {@link AdminShortLinksNamespace.list}. */
48
+ export interface ListAdminShortLinksParams {
49
+ /**
50
+ * `"auth"` for links with an owner, `"anon"` for links without one. Any other
51
+ * value, including omitting it, means both.
52
+ */
53
+ readonly owner?: "auth" | "anon" | "all";
54
+ /**
55
+ * Case-insensitive substring matched against the endpoint OR the destination
56
+ * URL.
57
+ *
58
+ * **A plain top-level string, not the `search[column]` bucket the rest of
59
+ * this API uses.** The server reads `search` as a plain string here, so
60
+ * sending a bucket would be read as a hash and match nothing.
61
+ */
62
+ readonly search?: string;
63
+ }
64
+ /**
65
+ * A page of {@link AdminShortLinksNamespace.list}.
66
+ *
67
+ * Not a {@link Paginated}, because there is nothing to page through: see
68
+ * {@link AdminShortLinkPage.limit}.
69
+ */
70
+ export interface AdminShortLinkPage {
71
+ /** At most {@link AdminShortLinkPage.limit} rows, newest first. */
72
+ readonly items: AdminShortLink[];
73
+ /** How many links match the filter in total. Frequently larger than `items.length`. */
74
+ readonly total: number;
75
+ /**
76
+ * The hard server-side cap, currently 100.
77
+ *
78
+ * **There is no pagination on this endpoint and no way to reach row 101.**
79
+ * When `total > limit` the rest is simply unreachable through this route; the
80
+ * only way to find a specific link beyond the cap is to narrow
81
+ * {@link ListAdminShortLinksParams.search} until it fits.
82
+ */
83
+ readonly limit: number;
84
+ }
85
+ /** What {@link AdminShortLinksNamespace.stats} answers with. */
86
+ export interface AdminShortLinkStats {
87
+ /** Non-namespaced links only, like everything else on this surface. */
88
+ readonly total_links: number;
89
+ readonly total_clicks: number;
90
+ readonly clicks_last_24h: number;
91
+ readonly clicks_last_7d: number;
92
+ readonly zero_click_count: number;
93
+ /** Already a percentage, `0` to `100`, one decimal. Not a fraction. */
94
+ readonly zero_click_percent: number;
95
+ /** Rounded to two decimals. `0` when there are no links. */
96
+ readonly avg_clicks_per_link: number;
97
+ readonly creations_daily: AdminDailyCount[];
98
+ readonly clicks_daily: AdminDailyCount[];
99
+ }
100
+ /** One row of {@link AdminShortLinksNamespace.namespaces}. */
101
+ export interface AdminShortLinkNamespaceCount {
102
+ /**
103
+ * `null` for user links, or one of the reserved tool namespaces: `"n"`
104
+ * notepads, `"c"` chests, `"ss"` storage shares, `"qr"` dynamic QR, `"f"`
105
+ * forms, `"t"` link trees.
106
+ */
107
+ readonly namespace: string | null;
108
+ readonly count: number;
109
+ }
110
+ /** Clicks grouped by country, on the admin drilldown. */
111
+ export interface AdminShortLinkCountryCount {
112
+ /** ISO 3166-1 alpha-2 as stored at click time. */
113
+ readonly country: string;
114
+ readonly count: number;
115
+ }
116
+ /** Clicks grouped by browser or app, on the admin drilldown. */
117
+ export interface AdminShortLinkDeviceCount {
118
+ readonly device_name: string;
119
+ readonly count: number;
120
+ }
121
+ /**
122
+ * What {@link AdminShortLinksNamespace.get} answers with.
123
+ *
124
+ * Note what is NOT here: no `total_clicks` and no `last_click_at` at the top
125
+ * level. The drilldown leaves the totals out because the same two numbers are
126
+ * already on `link`. Read them from there.
127
+ */
128
+ export interface AdminShortLinkDetail {
129
+ readonly link: AdminShortLink;
130
+ readonly clicks_daily: AdminDailyCount[];
131
+ /** Top 10 countries by clicks, descending. Rows with no country are excluded. */
132
+ readonly top_countries: AdminShortLinkCountryCount[];
133
+ /** Top 5 devices by clicks, descending. Rows with no device are excluded. */
134
+ readonly top_devices: AdminShortLinkDeviceCount[];
135
+ }
136
+ /**
137
+ * `oms.admin.shortLinks` - **administrators only**. Every public short link and
138
+ * its traffic.
139
+ *
140
+ * The unprivileged half is `oms.shortLinks`, which only ever shows the caller's
141
+ * own links. This one shows everybody's, anonymous ones included, which is the
142
+ * point: an anonymous short link has no owner to report it.
143
+ *
144
+ * **Scoped to non-namespaced links throughout.** Links minted by the internal
145
+ * tools (notepads, chests, storage shares, dynamic QR, forms, link trees) carry
146
+ * a namespace and are excluded from {@link list}, {@link get}, {@link stats}
147
+ * and {@link destroy}, so an admin panel cannot accidentally surface a private
148
+ * chest URL. {@link namespaces} is the deliberate exception and returns nothing
149
+ * but counts.
150
+ */
151
+ export declare class AdminShortLinksNamespace extends Resource {
152
+ /**
153
+ * `GET /admin/short_links` - the newest 100 matching links.
154
+ *
155
+ * Read {@link AdminShortLinkPage.limit} before building a table on this: the
156
+ * cap is hard and there is no page parameter.
157
+ *
158
+ * @throws {OmsAuthError} 403 for a non-admin.
159
+ */
160
+ list(params?: ListAdminShortLinksParams, options?: RequestOptions): Promise<AdminShortLinkPage>;
161
+ /**
162
+ * `GET /admin/short_links/stats` - server-wide totals and two 30 day series.
163
+ *
164
+ * @throws {OmsAuthError} 403 for a non-admin.
165
+ */
166
+ stats(options?: RequestOptions): Promise<AdminShortLinkStats>;
167
+ /**
168
+ * `GET /admin/short_links/namespaces` - how many links each namespace holds.
169
+ *
170
+ * The ONE call on this surface that looks past the non-namespaced scope, and
171
+ * even so it only ever returns counts, never a row. User links come first
172
+ * (`namespace: null`), then the reserved namespaces alphabetically.
173
+ *
174
+ * @throws {OmsAuthError} 403 for a non-admin.
175
+ */
176
+ namespaces(options?: RequestOptions): Promise<AdminShortLinkNamespaceCount[]>;
177
+ /**
178
+ * `GET /admin/short_links/:id` - one link with its traffic breakdown.
179
+ *
180
+ * @throws {OmsApiError} 404 `{ "error": "not_found" }` - which is also the
181
+ * answer for a link that exists but carries a namespace, since those are
182
+ * out of scope here.
183
+ * @throws {OmsAuthError} 403 for a non-admin.
184
+ */
185
+ get(id: number | string, options?: RequestOptions): Promise<AdminShortLinkDetail>;
186
+ /**
187
+ * `DELETE /admin/short_links/:id` - deletes anybody's short link.
188
+ *
189
+ * Answers `200` with `{ id }`, not `204`. The clicks go with it.
190
+ *
191
+ * The link stops resolving immediately and there is no undo: the endpoint
192
+ * becomes free again and somebody else can claim it, which is worth
193
+ * remembering before deleting something that was printed or posted.
194
+ *
195
+ * @throws {OmsApiError} 404 `not_found`, namespaced links included.
196
+ * @throws {OmsAuthError} 403 for a non-admin.
197
+ */
198
+ destroy(id: number | string, options?: RequestOptions): Promise<{
199
+ readonly id: number;
200
+ }>;
201
+ }