@omelhorsite/sdk 0.3.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.
- package/README.md +112 -130
- package/dist/index.js +1045 -1242
- package/dist/types/index.d.ts +1 -0
- package/dist/types/internal/attachments.d.ts +17 -0
- package/dist/types/internal/helpers.d.ts +9 -0
- package/dist/types/listing.d.ts +90 -0
- package/dist/types/resources/account.d.ts +5 -2
- package/dist/types/resources/admin/authorizedApplications.d.ts +133 -0
- package/dist/types/resources/admin/chests.d.ts +51 -0
- package/dist/types/resources/admin/eventAlerts.d.ts +60 -0
- package/dist/types/resources/admin/identities.d.ts +99 -0
- package/dist/types/resources/admin/index.d.ts +77 -0
- package/dist/types/resources/admin/jobs.d.ts +97 -0
- package/dist/types/resources/admin/myOauthApplications.d.ts +282 -0
- package/dist/types/resources/admin/notepads.d.ts +49 -0
- package/dist/types/resources/admin/oauthApplications.d.ts +309 -0
- package/dist/types/resources/admin/quotas.d.ts +114 -0
- package/dist/types/resources/admin/shortLinks.d.ts +201 -0
- package/dist/types/resources/admin/types.d.ts +222 -0
- package/dist/types/resources/admin/vocalSeparations.d.ts +98 -0
- package/dist/types/resources/admin.d.ts +17 -13
- package/dist/types/resources/auth/sessions.d.ts +6 -9
- package/dist/types/resources/content/analysis.d.ts +62 -0
- package/dist/types/resources/content/blogs.d.ts +471 -0
- package/dist/types/resources/content/feedbacks.d.ts +263 -0
- package/dist/types/resources/content/index.d.ts +52 -0
- package/dist/types/resources/content/intel/articles.d.ts +230 -0
- package/dist/types/resources/content/intel/config.d.ts +135 -0
- package/dist/types/resources/content/intel/index.d.ts +53 -0
- package/dist/types/resources/content/intel/items.d.ts +91 -0
- package/dist/types/resources/content/intel/reports.d.ts +108 -0
- package/dist/types/resources/content/intel/scripts.d.ts +152 -0
- package/dist/types/resources/content/intel/sources.d.ts +236 -0
- package/dist/types/resources/content/intel/stats.d.ts +105 -0
- package/dist/types/resources/content/intel/types.d.ts +86 -0
- package/dist/types/resources/content/jokes.d.ts +93 -0
- package/dist/types/resources/content/notifications.d.ts +147 -0
- package/dist/types/resources/content/serviceUsages.d.ts +73 -0
- package/dist/types/resources/content/servicesStatus.d.ts +194 -0
- package/dist/types/resources/content/siteConfig.d.ts +43 -0
- package/dist/types/resources/content/spaceInvaders.d.ts +154 -0
- package/dist/types/resources/content.d.ts +41 -236
- package/dist/types/resources/jobs.d.ts +7 -4
- package/dist/types/resources/library/annotations.d.ts +162 -0
- package/dist/types/resources/library/books.d.ts +534 -0
- package/dist/types/resources/library/chat.d.ts +259 -0
- package/dist/types/resources/library/index.d.ts +39 -0
- package/dist/types/resources/library/shelves.d.ts +237 -0
- package/dist/types/resources/library/types.d.ts +120 -0
- package/dist/types/resources/library.d.ts +20 -22
- package/dist/types/resources/movies/addons.d.ts +388 -0
- package/dist/types/resources/movies/collections.d.ts +352 -0
- package/dist/types/resources/movies/index.d.ts +29 -0
- package/dist/types/resources/movies/types.d.ts +50 -0
- package/dist/types/resources/movies/watchProgress.d.ts +277 -0
- package/dist/types/resources/movies.d.ts +27 -53
- package/dist/types/resources/music/artists.d.ts +3 -1
- package/dist/types/resources/music/imports.d.ts +9 -8
- package/dist/types/resources/music/playlists.d.ts +8 -7
- package/dist/types/resources/music/songs.d.ts +5 -21
- package/dist/types/resources/shortLinks.d.ts +5 -2
- package/dist/types/resources/social/groupChats.d.ts +458 -0
- package/dist/types/resources/social/index.d.ts +19 -0
- package/dist/types/resources/social/messages.d.ts +424 -0
- package/dist/types/resources/social/relationships.d.ts +322 -0
- package/dist/types/resources/social/types.d.ts +37 -0
- package/dist/types/resources/social.d.ts +21 -3
- package/dist/types/resources/storage.d.ts +24 -6
- package/dist/types/resources/tickets.d.ts +19 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9450,6 +9450,48 @@ var local = Object.freeze({
|
|
|
9450
9450
|
})
|
|
9451
9451
|
});
|
|
9452
9452
|
|
|
9453
|
+
// src/listing.ts
|
|
9454
|
+
var BASE_FILTER_COLUMNS = Object.freeze(["id", "created_at", "updated_at"]);
|
|
9455
|
+
function listQuery(params, at, base = {}) {
|
|
9456
|
+
const search = bucket(base.search, params.search);
|
|
9457
|
+
const exact = bucket(base.exactSearch, params.exactSearch);
|
|
9458
|
+
const extra = bucket(base.extraOptions, params.extraOptions);
|
|
9459
|
+
const modifiers = {};
|
|
9460
|
+
if (at !== undefined)
|
|
9461
|
+
modifiers["page"] = pageModifier(at.page, at.pageSize);
|
|
9462
|
+
const order = params.order ?? base.order;
|
|
9463
|
+
if (order !== undefined)
|
|
9464
|
+
modifiers["order"] = order;
|
|
9465
|
+
if (params.random === true)
|
|
9466
|
+
modifiers["random"] = true;
|
|
9467
|
+
return {
|
|
9468
|
+
...base.top ?? {},
|
|
9469
|
+
...search === undefined ? {} : { search },
|
|
9470
|
+
...exact === undefined ? {} : { exact_search: exact },
|
|
9471
|
+
...Object.keys(modifiers).length === 0 ? {} : { modifiers },
|
|
9472
|
+
...extra === undefined ? {} : { extra_options: extra }
|
|
9473
|
+
};
|
|
9474
|
+
}
|
|
9475
|
+
async function paginate(params, defaultPageSize, load) {
|
|
9476
|
+
const pageSize = resolvePageSize(params.pageSize ?? defaultPageSize);
|
|
9477
|
+
const page = resolvePageNumber(params.page);
|
|
9478
|
+
const loader = async (at) => {
|
|
9479
|
+
const rows = await load(at);
|
|
9480
|
+
return Array.isArray(rows) ? [...rows] : [];
|
|
9481
|
+
};
|
|
9482
|
+
return createPage(await loader({ page, pageSize }), page, pageSize, loader);
|
|
9483
|
+
}
|
|
9484
|
+
function bucket(sugar, explicit) {
|
|
9485
|
+
const merged = { ...sugar ?? {}, ...explicit ?? {} };
|
|
9486
|
+
const out = {};
|
|
9487
|
+
for (const [key, value] of Object.entries(merged)) {
|
|
9488
|
+
if (value === undefined)
|
|
9489
|
+
continue;
|
|
9490
|
+
out[key] = Array.isArray(value) ? [...value] : value;
|
|
9491
|
+
}
|
|
9492
|
+
return Object.keys(out).length === 0 ? undefined : out;
|
|
9493
|
+
}
|
|
9494
|
+
|
|
9453
9495
|
// src/resources/storage/upload.ts
|
|
9454
9496
|
var MULTIPART_THRESHOLD = 32 * 1024 * 1024;
|
|
9455
9497
|
var MULTIPART_PART_SIZE = 32 * 1024 * 1024;
|
|
@@ -10047,15 +10089,12 @@ function base64(bytes) {
|
|
|
10047
10089
|
}
|
|
10048
10090
|
|
|
10049
10091
|
// src/resources/account.ts
|
|
10092
|
+
var ACCOUNT_SESSION_FILTER_COLUMNS = Object.freeze(["user_id"]);
|
|
10093
|
+
|
|
10050
10094
|
class AccountSessionsNamespace extends Resource {
|
|
10051
10095
|
async list(params = {}, options = {}) {
|
|
10052
|
-
const
|
|
10053
|
-
|
|
10054
|
-
...options,
|
|
10055
|
-
query: sessionQuery(params, page, pageSize)
|
|
10056
|
-
});
|
|
10057
|
-
const first = resolvePageNumber(params.page);
|
|
10058
|
-
return createPage(await load({ page: first, pageSize: size }), first, size, load);
|
|
10096
|
+
const base = { exactSearch: { user_id: params.userId } };
|
|
10097
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/sessions", { ...options, query: listQuery(params, at, base) }));
|
|
10059
10098
|
}
|
|
10060
10099
|
async current(options = {}) {
|
|
10061
10100
|
return this.http.get("/sessions/mine", options);
|
|
@@ -10144,56 +10183,98 @@ function updateBody(input) {
|
|
|
10144
10183
|
share_listening: input.shareListening
|
|
10145
10184
|
};
|
|
10146
10185
|
}
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10186
|
+
|
|
10187
|
+
// src/resources/admin/authorizedApplications.ts
|
|
10188
|
+
class AuthorizedApplicationsNamespace extends Resource {
|
|
10189
|
+
async list(options = {}) {
|
|
10190
|
+
const body = await this.http.get("/authorized_applications", options);
|
|
10191
|
+
return body?.applications ?? [];
|
|
10192
|
+
}
|
|
10193
|
+
async revoke(id, options = {}) {
|
|
10194
|
+
return this.http.delete(`/authorized_applications/${encodeURIComponent(String(id))}`, options);
|
|
10195
|
+
}
|
|
10152
10196
|
}
|
|
10153
10197
|
|
|
10154
|
-
// src/resources/admin.ts
|
|
10155
|
-
|
|
10156
|
-
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
]);
|
|
10160
|
-
var OAUTH_APP_NAME_MAX_LENGTH = 60;
|
|
10161
|
-
var OAUTH_APP_MAX_PENDING = 5;
|
|
10162
|
-
var OAUTH_REDIRECT_URI_MAX_COUNT = 8;
|
|
10163
|
-
var OAUTH_REDIRECT_URI_MAX_LENGTH = 1024;
|
|
10164
|
-
var NATIVE_LOOPBACK_REDIRECT_URIS = Object.freeze([
|
|
10165
|
-
"http://127.0.0.1/callback",
|
|
10166
|
-
"http://[::1]/callback"
|
|
10167
|
-
]);
|
|
10168
|
-
var NATIVE_LOOPBACK_REDIRECT_VALUE = "http://127.0.0.1/callback http://[::1]/callback";
|
|
10169
|
-
var SHIPPED_CLIENT_IDS = Object.freeze(["oms-cli", "oms-mcp"]);
|
|
10170
|
-
function isShippedClient(application) {
|
|
10171
|
-
return SHIPPED_CLIENT_IDS.includes(application.client_id);
|
|
10198
|
+
// src/resources/admin/chests.ts
|
|
10199
|
+
class AdminChestsNamespace extends Resource {
|
|
10200
|
+
async stats(options = {}) {
|
|
10201
|
+
return this.http.get("/admin/chests/stats", options);
|
|
10202
|
+
}
|
|
10172
10203
|
}
|
|
10173
|
-
|
|
10174
|
-
|
|
10204
|
+
|
|
10205
|
+
// src/resources/admin/eventAlerts.ts
|
|
10206
|
+
class AdminEventAlertsNamespace extends Resource {
|
|
10207
|
+
async list(options = {}) {
|
|
10208
|
+
const body = await this.http.get("/admin/event_alerts", options);
|
|
10209
|
+
return {
|
|
10210
|
+
delivering: body?.delivering ?? false,
|
|
10211
|
+
webhook_configured: body?.webhook_configured ?? false,
|
|
10212
|
+
events: body?.events ?? []
|
|
10213
|
+
};
|
|
10214
|
+
}
|
|
10175
10215
|
}
|
|
10176
|
-
|
|
10177
|
-
|
|
10216
|
+
|
|
10217
|
+
// src/resources/admin/identities.ts
|
|
10218
|
+
var IDENTITY_PROVIDERS = ["google_oauth2", "github", "spotify"];
|
|
10219
|
+
var LINKED_IDENTITY_FILTER_COLUMNS = Object.freeze(["user_id"]);
|
|
10220
|
+
|
|
10221
|
+
class LinkedIdentitiesNamespace extends Resource {
|
|
10222
|
+
async list(params = {}, options = {}) {
|
|
10223
|
+
const base = { order: "created_at:desc" };
|
|
10224
|
+
return paginate(params, 100, (at) => this.http.get("/identities", { ...options, query: listQuery(params, at, base) }));
|
|
10225
|
+
}
|
|
10226
|
+
async destroy(id, options = {}) {
|
|
10227
|
+
await this.http.delete(`/identities/${encodeURIComponent(id)}`, options);
|
|
10228
|
+
}
|
|
10178
10229
|
}
|
|
10179
|
-
|
|
10180
|
-
|
|
10181
|
-
|
|
10230
|
+
|
|
10231
|
+
// src/resources/admin/jobs.ts
|
|
10232
|
+
var ADMIN_JOB_FILTER_COLUMNS = Object.freeze([
|
|
10233
|
+
"id",
|
|
10234
|
+
"job_type",
|
|
10235
|
+
"status",
|
|
10236
|
+
"created_at",
|
|
10237
|
+
"updated_at",
|
|
10238
|
+
"finished_at"
|
|
10239
|
+
]);
|
|
10240
|
+
|
|
10241
|
+
class AdminJobsNamespace extends Resource {
|
|
10242
|
+
async list(params = {}, options = {}) {
|
|
10243
|
+
const base = { order: "created_at:desc", exactSearch: { status: params.status, job_type: params.jobType } };
|
|
10244
|
+
return paginate(params, 100, (at) => this.http.get("/admin/jobs", { ...options, query: listQuery(params, at, base) }));
|
|
10245
|
+
}
|
|
10246
|
+
async cancel(id, options = {}) {
|
|
10247
|
+
return this.http.post(`/admin/jobs/${encodeURIComponent(id)}/cancel`, undefined, options);
|
|
10248
|
+
}
|
|
10249
|
+
async cleanupStuck(options = {}) {
|
|
10250
|
+
return this.http.post("/admin/jobs/cleanup_stuck", undefined, { retry: false, ...options });
|
|
10251
|
+
}
|
|
10182
10252
|
}
|
|
10183
|
-
|
|
10184
|
-
|
|
10185
|
-
|
|
10186
|
-
if (
|
|
10187
|
-
|
|
10188
|
-
|
|
10189
|
-
|
|
10190
|
-
|
|
10253
|
+
|
|
10254
|
+
// src/internal/helpers.ts
|
|
10255
|
+
function assertPresent(field, value) {
|
|
10256
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
10257
|
+
throw new OmsError(`${field} is required and cannot be blank.`, "invalid_request");
|
|
10258
|
+
}
|
|
10259
|
+
}
|
|
10260
|
+
function pickOptional(source, keys) {
|
|
10261
|
+
const out = {};
|
|
10262
|
+
for (const key of keys) {
|
|
10263
|
+
const value = source[key];
|
|
10264
|
+
if (value !== undefined)
|
|
10265
|
+
out[key] = value;
|
|
10266
|
+
}
|
|
10267
|
+
return out;
|
|
10191
10268
|
}
|
|
10192
10269
|
function scopeList(scopes) {
|
|
10193
10270
|
const parts = Array.isArray(scopes) ? scopes : String(scopes).split(/[\s,]+/);
|
|
10194
10271
|
return parts.map((scope) => String(scope).trim()).filter((scope) => scope.length > 0);
|
|
10195
10272
|
}
|
|
10273
|
+
function idSegment(id) {
|
|
10274
|
+
return encodeURIComponent(String(id));
|
|
10275
|
+
}
|
|
10196
10276
|
|
|
10277
|
+
// src/resources/admin/myOauthApplications.ts
|
|
10197
10278
|
class MyOauthApplicationsNamespace extends Resource {
|
|
10198
10279
|
async list(options = {}) {
|
|
10199
10280
|
const body = await this.http.get("/oauth_applications", options);
|
|
@@ -10227,36 +10308,14 @@ class MyOauthApplicationsNamespace extends Resource {
|
|
|
10227
10308
|
}
|
|
10228
10309
|
}
|
|
10229
10310
|
|
|
10230
|
-
|
|
10231
|
-
|
|
10232
|
-
|
|
10233
|
-
return
|
|
10234
|
-
}
|
|
10235
|
-
async revoke(id, options = {}) {
|
|
10236
|
-
return this.http.delete(`/authorized_applications/${encodeURIComponent(String(id))}`, options);
|
|
10237
|
-
}
|
|
10238
|
-
}
|
|
10239
|
-
var IDENTITY_PROVIDERS = ["google_oauth2", "github", "spotify"];
|
|
10240
|
-
|
|
10241
|
-
class LinkedIdentitiesNamespace extends Resource {
|
|
10242
|
-
async list(params = {}, options = {}) {
|
|
10243
|
-
const page = params.page ?? 1;
|
|
10244
|
-
const pageSize = params.pageSize ?? 100;
|
|
10245
|
-
const order = params.order ?? "created_at:desc";
|
|
10246
|
-
const load = async (at) => {
|
|
10247
|
-
const query = {
|
|
10248
|
-
modifiers: { page: pageModifier(at.page, at.pageSize), order }
|
|
10249
|
-
};
|
|
10250
|
-
const items = await this.http.get("/identities", { ...options, query });
|
|
10251
|
-
return items ?? [];
|
|
10252
|
-
};
|
|
10253
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
10254
|
-
}
|
|
10255
|
-
async destroy(id, options = {}) {
|
|
10256
|
-
await this.http.delete(`/identities/${encodeURIComponent(id)}`, options);
|
|
10311
|
+
// src/resources/admin/notepads.ts
|
|
10312
|
+
class AdminNotepadsNamespace extends Resource {
|
|
10313
|
+
async stats(options = {}) {
|
|
10314
|
+
return this.http.get("/admin/notepads/stats", options);
|
|
10257
10315
|
}
|
|
10258
10316
|
}
|
|
10259
10317
|
|
|
10318
|
+
// src/resources/admin/oauthApplications.ts
|
|
10260
10319
|
class AdminOauthApplicationsNamespace extends Resource {
|
|
10261
10320
|
async list(options = {}) {
|
|
10262
10321
|
const body = await this.http.get("/admin/oauth_applications", options);
|
|
@@ -10295,6 +10354,7 @@ class AdminOauthApplicationsNamespace extends Resource {
|
|
|
10295
10354
|
}
|
|
10296
10355
|
}
|
|
10297
10356
|
|
|
10357
|
+
// src/resources/admin/quotas.ts
|
|
10298
10358
|
class AdminQuotasNamespace extends Resource {
|
|
10299
10359
|
async get(user, options = {}) {
|
|
10300
10360
|
return this.http.get(`/admin/users/${encodeURIComponent(user)}/quotas`, options);
|
|
@@ -10310,36 +10370,7 @@ class AdminQuotasNamespace extends Resource {
|
|
|
10310
10370
|
}
|
|
10311
10371
|
}
|
|
10312
10372
|
|
|
10313
|
-
|
|
10314
|
-
async list(params = {}, options = {}) {
|
|
10315
|
-
const page = params.page ?? 1;
|
|
10316
|
-
const pageSize = params.pageSize ?? 100;
|
|
10317
|
-
const order = params.order ?? "created_at:desc";
|
|
10318
|
-
const exact = {};
|
|
10319
|
-
if (params.status !== undefined) {
|
|
10320
|
-
exact["status"] = Array.isArray(params.status) ? [...params.status] : String(params.status);
|
|
10321
|
-
}
|
|
10322
|
-
if (params.jobType !== undefined) {
|
|
10323
|
-
exact["job_type"] = Array.isArray(params.jobType) ? [...params.jobType] : String(params.jobType);
|
|
10324
|
-
}
|
|
10325
|
-
const load = async (at) => {
|
|
10326
|
-
const query = {
|
|
10327
|
-
modifiers: { page: pageModifier(at.page, at.pageSize), order },
|
|
10328
|
-
...Object.keys(exact).length === 0 ? {} : { exact_search: exact }
|
|
10329
|
-
};
|
|
10330
|
-
const items = await this.http.get("/admin/jobs", { ...options, query });
|
|
10331
|
-
return items ?? [];
|
|
10332
|
-
};
|
|
10333
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
10334
|
-
}
|
|
10335
|
-
async cancel(id, options = {}) {
|
|
10336
|
-
return this.http.post(`/admin/jobs/${encodeURIComponent(id)}/cancel`, undefined, options);
|
|
10337
|
-
}
|
|
10338
|
-
async cleanupStuck(options = {}) {
|
|
10339
|
-
return this.http.post("/admin/jobs/cleanup_stuck", undefined, { retry: false, ...options });
|
|
10340
|
-
}
|
|
10341
|
-
}
|
|
10342
|
-
|
|
10373
|
+
// src/resources/admin/shortLinks.ts
|
|
10343
10374
|
class AdminShortLinksNamespace extends Resource {
|
|
10344
10375
|
async list(params = {}, options = {}) {
|
|
10345
10376
|
const query = {
|
|
@@ -10367,33 +10398,28 @@ class AdminShortLinksNamespace extends Resource {
|
|
|
10367
10398
|
}
|
|
10368
10399
|
}
|
|
10369
10400
|
|
|
10401
|
+
// src/resources/admin/vocalSeparations.ts
|
|
10402
|
+
var ADMIN_VOCAL_SEPARATION_FILTER_COLUMNS = Object.freeze([
|
|
10403
|
+
"id",
|
|
10404
|
+
"status",
|
|
10405
|
+
"model_id",
|
|
10406
|
+
"created_at",
|
|
10407
|
+
"finished_at",
|
|
10408
|
+
"user_id",
|
|
10409
|
+
"song_id"
|
|
10410
|
+
]);
|
|
10411
|
+
|
|
10370
10412
|
class AdminVocalSeparationsNamespace extends Resource {
|
|
10371
10413
|
async list(params = {}, options = {}) {
|
|
10372
|
-
const
|
|
10373
|
-
|
|
10374
|
-
|
|
10375
|
-
|
|
10376
|
-
if (params.status !== undefined) {
|
|
10377
|
-
exact["status"] = Array.isArray(params.status) ? [...params.status] : String(params.status);
|
|
10378
|
-
}
|
|
10379
|
-
if (params.modelId !== undefined) {
|
|
10380
|
-
exact["model_id"] = Array.isArray(params.modelId) ? [...params.modelId] : String(params.modelId);
|
|
10381
|
-
}
|
|
10382
|
-
if (params.userId !== undefined)
|
|
10383
|
-
exact["user_id"] = params.userId;
|
|
10384
|
-
const load = async (at) => {
|
|
10385
|
-
const query = {
|
|
10386
|
-
modifiers: { page: pageModifier(at.page, at.pageSize), order },
|
|
10387
|
-
...Object.keys(exact).length === 0 ? {} : { exact_search: exact },
|
|
10388
|
-
...params.source === undefined ? {} : { source: params.source }
|
|
10389
|
-
};
|
|
10390
|
-
const items = await this.http.get("/admin/vocal_separations", {
|
|
10391
|
-
...options,
|
|
10392
|
-
query
|
|
10393
|
-
});
|
|
10394
|
-
return items ?? [];
|
|
10414
|
+
const base = {
|
|
10415
|
+
order: "created_at:desc",
|
|
10416
|
+
exactSearch: { status: params.status, model_id: params.modelId, user_id: params.userId },
|
|
10417
|
+
top: params.source === undefined ? {} : { source: params.source }
|
|
10395
10418
|
};
|
|
10396
|
-
return
|
|
10419
|
+
return paginate(params, 100, (at) => this.http.get("/admin/vocal_separations", {
|
|
10420
|
+
...options,
|
|
10421
|
+
query: listQuery(params, at, base)
|
|
10422
|
+
}));
|
|
10397
10423
|
}
|
|
10398
10424
|
async get(id, options = {}) {
|
|
10399
10425
|
return this.http.get(`/admin/vocal_separations/${encodeURIComponent(id)}`, options);
|
|
@@ -10405,30 +10431,46 @@ class AdminVocalSeparationsNamespace extends Resource {
|
|
|
10405
10431
|
await this.http.delete(`/admin/vocal_separations/${encodeURIComponent(id)}`, options);
|
|
10406
10432
|
}
|
|
10407
10433
|
}
|
|
10408
|
-
|
|
10409
|
-
|
|
10410
|
-
|
|
10411
|
-
|
|
10412
|
-
|
|
10434
|
+
// src/resources/admin/types.ts
|
|
10435
|
+
var OAUTH_APPROVAL_STATUSES = Object.freeze([
|
|
10436
|
+
"pending",
|
|
10437
|
+
"approved",
|
|
10438
|
+
"rejected"
|
|
10439
|
+
]);
|
|
10440
|
+
var OAUTH_APP_NAME_MAX_LENGTH = 60;
|
|
10441
|
+
var OAUTH_APP_MAX_PENDING = 5;
|
|
10442
|
+
var OAUTH_REDIRECT_URI_MAX_COUNT = 8;
|
|
10443
|
+
var OAUTH_REDIRECT_URI_MAX_LENGTH = 1024;
|
|
10444
|
+
var NATIVE_LOOPBACK_REDIRECT_URIS = Object.freeze([
|
|
10445
|
+
"http://127.0.0.1/callback",
|
|
10446
|
+
"http://[::1]/callback"
|
|
10447
|
+
]);
|
|
10448
|
+
var NATIVE_LOOPBACK_REDIRECT_VALUE = "http://127.0.0.1/callback http://[::1]/callback";
|
|
10449
|
+
var SHIPPED_CLIENT_IDS = Object.freeze(["oms-cli", "oms-mcp"]);
|
|
10450
|
+
function isShippedClient(application) {
|
|
10451
|
+
return SHIPPED_CLIENT_IDS.includes(application.client_id);
|
|
10413
10452
|
}
|
|
10414
|
-
|
|
10415
|
-
|
|
10416
|
-
async stats(options = {}) {
|
|
10417
|
-
return this.http.get("/admin/notepads/stats", options);
|
|
10418
|
-
}
|
|
10453
|
+
function splitRedirectUris(value) {
|
|
10454
|
+
return (value ?? "").split(/\s+/).map((uri) => uri.trim()).filter((uri) => uri.length > 0);
|
|
10419
10455
|
}
|
|
10420
|
-
|
|
10421
|
-
|
|
10422
|
-
|
|
10423
|
-
|
|
10424
|
-
|
|
10425
|
-
|
|
10426
|
-
|
|
10427
|
-
|
|
10428
|
-
|
|
10429
|
-
|
|
10456
|
+
function normalizeRedirectUris(raw) {
|
|
10457
|
+
return splitRedirectUris(raw).filter((value, index, all) => all.indexOf(value) === index).join(" ");
|
|
10458
|
+
}
|
|
10459
|
+
function registeredRedirectUris(raw) {
|
|
10460
|
+
const normalized = normalizeRedirectUris(raw);
|
|
10461
|
+
return normalized.length > 0 ? normalized : NATIVE_LOOPBACK_REDIRECT_VALUE;
|
|
10462
|
+
}
|
|
10463
|
+
function editWouldRequeue(application, next) {
|
|
10464
|
+
if (application.approval_status !== "approved")
|
|
10465
|
+
return false;
|
|
10466
|
+
if (next.name.trim() !== application.name)
|
|
10467
|
+
return true;
|
|
10468
|
+
if (next.scopes.some((scope) => !application.scopes.includes(scope)))
|
|
10469
|
+
return true;
|
|
10470
|
+
return registeredRedirectUris(next.redirectUris) !== registeredRedirectUris(application.redirect_uri);
|
|
10430
10471
|
}
|
|
10431
10472
|
|
|
10473
|
+
// src/resources/admin/index.ts
|
|
10432
10474
|
class AdminNamespace extends Resource {
|
|
10433
10475
|
myApplications;
|
|
10434
10476
|
authorizedApplications;
|
|
@@ -10606,6 +10648,7 @@ var SESSION_DEVICE_TYPES = [
|
|
|
10606
10648
|
function isVerificationCode(value) {
|
|
10607
10649
|
return new RegExp(`^[0-9]{${VERIFICATION_CODE_LENGTH}}$`).test(value);
|
|
10608
10650
|
}
|
|
10651
|
+
var USER_FILTER_COLUMNS = Object.freeze(["name", "handle"]);
|
|
10609
10652
|
|
|
10610
10653
|
class AuthSessionsNamespace extends Resource {
|
|
10611
10654
|
async signIn(input, options = {}) {
|
|
@@ -10677,10 +10720,11 @@ class AuthSessionsNamespace extends Resource {
|
|
|
10677
10720
|
await this.http.post("/users/destroy_end", { code }, options);
|
|
10678
10721
|
}
|
|
10679
10722
|
async listUsers(params = {}, options = {}) {
|
|
10680
|
-
const
|
|
10681
|
-
|
|
10682
|
-
|
|
10683
|
-
|
|
10723
|
+
const base = {
|
|
10724
|
+
search: { name: params.name, handle: params.handle },
|
|
10725
|
+
exactSearch: { handle: params.exactHandle }
|
|
10726
|
+
};
|
|
10727
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/users", { ...options, query: listQuery(params, at, base) }));
|
|
10684
10728
|
}
|
|
10685
10729
|
async deactivateUser(id, options = {}) {
|
|
10686
10730
|
return this.http.post(`/users/${encodeURIComponent(id)}/deactivate`, undefined, options);
|
|
@@ -10689,13 +10733,6 @@ class AuthSessionsNamespace extends Resource {
|
|
|
10689
10733
|
return this.http.post(`/users/${encodeURIComponent(id)}/reactivate`, undefined, options);
|
|
10690
10734
|
}
|
|
10691
10735
|
}
|
|
10692
|
-
function userQuery(params, page, pageSize) {
|
|
10693
|
-
return {
|
|
10694
|
-
search: { name: params.name, handle: params.handle },
|
|
10695
|
-
exact_search: { handle: params.exactHandle },
|
|
10696
|
-
modifiers: { order: params.order, page: pageModifier(page, pageSize) }
|
|
10697
|
-
};
|
|
10698
|
-
}
|
|
10699
10736
|
|
|
10700
10737
|
// src/resources/chests.ts
|
|
10701
10738
|
class ChestEntriesNamespace extends Resource {
|
|
@@ -10805,21 +10842,20 @@ class ChestsNamespace extends Resource {
|
|
|
10805
10842
|
}
|
|
10806
10843
|
}
|
|
10807
10844
|
|
|
10808
|
-
// src/resources/content.ts
|
|
10809
|
-
|
|
10810
|
-
|
|
10811
|
-
|
|
10812
|
-
|
|
10813
|
-
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
query.exact_search = params.exactSearch;
|
|
10820
|
-
return query;
|
|
10845
|
+
// src/resources/content/analysis.ts
|
|
10846
|
+
var ANALYSIS_DAILY_WINDOW_DAYS = 30;
|
|
10847
|
+
|
|
10848
|
+
class AnalysisNamespace extends Resource {
|
|
10849
|
+
async storages(options = {}) {
|
|
10850
|
+
return this.http.get("/analysis/storages", options);
|
|
10851
|
+
}
|
|
10852
|
+
async filesDaily(options = {}) {
|
|
10853
|
+
const body = await this.http.get("/analysis/files_daily", options);
|
|
10854
|
+
return body.creations_daily;
|
|
10855
|
+
}
|
|
10821
10856
|
}
|
|
10822
10857
|
|
|
10858
|
+
// src/resources/content/blogs.ts
|
|
10823
10859
|
class BlogsNamespace extends Resource {
|
|
10824
10860
|
posts;
|
|
10825
10861
|
constructor(http) {
|
|
@@ -10875,29 +10911,8 @@ class BlogPostsNamespace extends Resource {
|
|
|
10875
10911
|
}
|
|
10876
10912
|
}
|
|
10877
10913
|
|
|
10878
|
-
|
|
10879
|
-
|
|
10880
|
-
const load = async (p) => this.http.get("/notifications", {
|
|
10881
|
-
...options,
|
|
10882
|
-
query: listQuery(params, p.page, p.pageSize)
|
|
10883
|
-
});
|
|
10884
|
-
const page = params.page ?? 1;
|
|
10885
|
-
const pageSize = params.pageSize ?? 100;
|
|
10886
|
-
const items = await load({ page, pageSize });
|
|
10887
|
-
return createPage(items, page, pageSize, load);
|
|
10888
|
-
}
|
|
10889
|
-
async unreadCount(options = {}) {
|
|
10890
|
-
const body = await this.http.get("/notifications/unread_count", options);
|
|
10891
|
-
return body.count;
|
|
10892
|
-
}
|
|
10893
|
-
async markAllRead(options = {}) {
|
|
10894
|
-
const body = await this.http.post("/notifications/read_all", undefined, options);
|
|
10895
|
-
return body.count;
|
|
10896
|
-
}
|
|
10897
|
-
async dismiss(id, options = {}) {
|
|
10898
|
-
await this.http.delete(`/notifications/${encodeURIComponent(String(id))}`, options);
|
|
10899
|
-
}
|
|
10900
|
-
}
|
|
10914
|
+
// src/resources/content/feedbacks.ts
|
|
10915
|
+
var FEEDBACK_FILTER_COLUMNS = Object.freeze(["status", "user_id"]);
|
|
10901
10916
|
var FEEDBACK_STATUSES = ["new", "read", "archived"];
|
|
10902
10917
|
var FEEDBACK_CONTENT_MAX_BYTES = 5000;
|
|
10903
10918
|
var FEEDBACK_MAX_ATTACHMENTS = 6;
|
|
@@ -10912,14 +10927,7 @@ class FeedbacksNamespace extends Resource {
|
|
|
10912
10927
|
return body.id;
|
|
10913
10928
|
}
|
|
10914
10929
|
async list(params = {}, options = {}) {
|
|
10915
|
-
|
|
10916
|
-
...options,
|
|
10917
|
-
query: listQuery(params, p.page, p.pageSize)
|
|
10918
|
-
});
|
|
10919
|
-
const page = params.page ?? 1;
|
|
10920
|
-
const pageSize = params.pageSize ?? 100;
|
|
10921
|
-
const items = await load({ page, pageSize });
|
|
10922
|
-
return createPage(items, page, pageSize, load);
|
|
10930
|
+
return paginate(params, 100, (at) => this.http.get("/feedbacks", { ...options, query: listQuery(params, at) }));
|
|
10923
10931
|
}
|
|
10924
10932
|
async get(id, options = {}) {
|
|
10925
10933
|
return this.http.get(`/feedbacks/${encodeURIComponent(id)}`, options);
|
|
@@ -10938,215 +10946,124 @@ class FeedbacksNamespace extends Resource {
|
|
|
10938
10946
|
}
|
|
10939
10947
|
}
|
|
10940
10948
|
|
|
10941
|
-
|
|
10949
|
+
// src/resources/content/intel/articles.ts
|
|
10950
|
+
var INTEL_ARTICLE_FILTER_COLUMNS = Object.freeze(["title", "summary", "category", "importance", "enriched"]);
|
|
10951
|
+
|
|
10952
|
+
class IntelArticlesNamespace extends Resource {
|
|
10942
10953
|
async list(params = {}, options = {}) {
|
|
10943
|
-
const
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
10947
|
-
|
|
10954
|
+
const top = {};
|
|
10955
|
+
if (params.q !== undefined)
|
|
10956
|
+
top["q"] = params.q;
|
|
10957
|
+
if (params.minImportance !== undefined)
|
|
10958
|
+
top["min_importance"] = params.minImportance;
|
|
10959
|
+
if (params.sort !== undefined)
|
|
10960
|
+
top["sort"] = params.sort;
|
|
10961
|
+
return paginate(params, 50, (at) => this.http.get("/intel_articles", { ...options, query: listQuery(params, at, { top }) }));
|
|
10948
10962
|
}
|
|
10949
|
-
async
|
|
10950
|
-
return this.http.
|
|
10963
|
+
async get(id, options = {}) {
|
|
10964
|
+
return this.http.get(`/intel_articles/${encodeURIComponent(id)}`, options);
|
|
10951
10965
|
}
|
|
10952
|
-
async
|
|
10953
|
-
|
|
10954
|
-
}
|
|
10955
|
-
async destroy(id, options = {}) {
|
|
10956
|
-
await this.http.delete(`/jokes/${encodeURIComponent(String(id))}`, options);
|
|
10966
|
+
async delete(id, options = {}) {
|
|
10967
|
+
await this.http.delete(`/intel_articles/${encodeURIComponent(id)}`, options);
|
|
10957
10968
|
}
|
|
10958
10969
|
}
|
|
10959
10970
|
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
return this.http.get("/config", options);
|
|
10963
|
-
}
|
|
10964
|
-
}
|
|
10965
|
-
var EXTERNAL_SERVICE_SLUGS = ["vocal_separator", "ai", "yt_dlp"];
|
|
10966
|
-
var INTERNAL_SERVICE_SLUGS = [
|
|
10967
|
-
"accounts",
|
|
10968
|
-
"notifications",
|
|
10969
|
-
"storage",
|
|
10970
|
-
"socials",
|
|
10971
|
-
"short_links",
|
|
10972
|
-
"ip_lookup",
|
|
10973
|
-
"jokes",
|
|
10974
|
-
"space_invaders"
|
|
10975
|
-
];
|
|
10976
|
-
var ALL_SERVICE_SLUGS = [...INTERNAL_SERVICE_SLUGS, ...EXTERNAL_SERVICE_SLUGS];
|
|
10977
|
-
var UPTIME_CACHE_SECONDS = 60;
|
|
10978
|
-
var UPTIME_WINDOW_DAYS = 90;
|
|
10979
|
-
|
|
10980
|
-
class ServicesStatusNamespace extends Resource {
|
|
10981
|
-
async current(options = {}) {
|
|
10982
|
-
return this.http.get("/services_status", options);
|
|
10983
|
-
}
|
|
10984
|
-
async uptime(options = {}) {
|
|
10985
|
-
return this.http.get("/services_status/uptime", options);
|
|
10986
|
-
}
|
|
10987
|
-
}
|
|
10988
|
-
var SERVICE_USAGE_IDS = [
|
|
10989
|
-
"storage",
|
|
10990
|
-
"tools",
|
|
10991
|
-
"games",
|
|
10992
|
-
"music",
|
|
10993
|
-
"movies",
|
|
10994
|
-
"ai",
|
|
10995
|
-
"account",
|
|
10996
|
-
"tickets",
|
|
10997
|
-
"messages",
|
|
10998
|
-
"blogs",
|
|
10999
|
-
"status",
|
|
11000
|
-
"administration"
|
|
11001
|
-
];
|
|
10971
|
+
// src/resources/content/intel/config.ts
|
|
10972
|
+
var INTEL_PROMPT_KEYS = ["build", "enrich_plan", "enrich_actors", "enrich_synth", "report"];
|
|
11002
10973
|
|
|
11003
|
-
class
|
|
11004
|
-
async
|
|
11005
|
-
return this.http.
|
|
10974
|
+
class IntelConfigNamespace extends Resource {
|
|
10975
|
+
async get(options = {}) {
|
|
10976
|
+
return this.http.get("/intel_config", options);
|
|
11006
10977
|
}
|
|
11007
|
-
async
|
|
11008
|
-
return this.http.
|
|
11009
|
-
...
|
|
11010
|
-
...input.
|
|
11011
|
-
|
|
10978
|
+
async update(input, options = {}) {
|
|
10979
|
+
return this.http.patch("/intel_config", {
|
|
10980
|
+
...input.rubric === undefined ? {} : { rubric: input.rubric },
|
|
10981
|
+
...input.prompts === undefined ? {} : { prompts: input.prompts },
|
|
10982
|
+
...input.buildModel === undefined ? {} : { build_model: input.buildModel },
|
|
10983
|
+
...input.reportModel === undefined ? {} : { report_model: input.reportModel },
|
|
10984
|
+
...input.reportMinImportance === undefined ? {} : { report_min_importance: input.reportMinImportance },
|
|
10985
|
+
...input.enrichMinImportance === undefined ? {} : { enrich_min_importance: input.enrichMinImportance },
|
|
10986
|
+
...input.webSearch === undefined ? {} : { web_search: input.webSearch },
|
|
10987
|
+
...input.maxSources === undefined ? {} : { max_sources: input.maxSources }
|
|
10988
|
+
}, options);
|
|
11012
10989
|
}
|
|
11013
10990
|
}
|
|
11014
|
-
var ANALYSIS_DAILY_WINDOW_DAYS = 30;
|
|
11015
10991
|
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
return this.http.get("/analysis/storages", options);
|
|
11019
|
-
}
|
|
11020
|
-
async filesDaily(options = {}) {
|
|
11021
|
-
const body = await this.http.get("/analysis/files_daily", options);
|
|
11022
|
-
return body.creations_daily;
|
|
11023
|
-
}
|
|
11024
|
-
}
|
|
11025
|
-
var SPACE_INVADERS_MAX_POINTS_PER_KILL = 10;
|
|
11026
|
-
var SPACE_INVADERS_MAX_KILLS_PER_SECOND = 1;
|
|
11027
|
-
var SPACE_INVADERS_MAX_SESSION_SECONDS = 24 * 60 * 60;
|
|
11028
|
-
var SPACE_INVADERS_LEADERBOARD_SIZE = 100;
|
|
10992
|
+
// src/resources/content/intel/items.ts
|
|
10993
|
+
var INTEL_ITEM_FILTER_COLUMNS = Object.freeze(["intel_source_id", "external_id", "title", "content", "url"]);
|
|
11029
10994
|
|
|
11030
|
-
class
|
|
11031
|
-
async leaderboard(options = {}) {
|
|
11032
|
-
return this.http.get("/space_invaders_games/leaderboard", options);
|
|
11033
|
-
}
|
|
10995
|
+
class IntelItemsNamespace extends Resource {
|
|
11034
10996
|
async list(params = {}, options = {}) {
|
|
11035
|
-
const
|
|
11036
|
-
|
|
11037
|
-
query: listQuery(params, p.page, p.pageSize)
|
|
11038
|
-
});
|
|
11039
|
-
const page = params.page ?? 1;
|
|
11040
|
-
const pageSize = params.pageSize ?? 100;
|
|
11041
|
-
const items = await load({ page, pageSize });
|
|
11042
|
-
return createPage(items, page, pageSize, load);
|
|
10997
|
+
const base = { order: "created_at:desc", exactSearch: { intel_source_id: params.sourceId } };
|
|
10998
|
+
return paginate(params, 25, (at) => this.http.get("/intel_items", { ...options, query: listQuery(params, at, base) }));
|
|
11043
10999
|
}
|
|
11044
|
-
async
|
|
11045
|
-
return this.http.
|
|
11000
|
+
async get(id, options = {}) {
|
|
11001
|
+
return this.http.get(`/intel_items/${encodeURIComponent(id)}`, options);
|
|
11046
11002
|
}
|
|
11047
|
-
async
|
|
11048
|
-
await this.http.delete(`/
|
|
11003
|
+
async delete(id, options = {}) {
|
|
11004
|
+
await this.http.delete(`/intel_items/${encodeURIComponent(id)}`, options);
|
|
11049
11005
|
}
|
|
11050
11006
|
}
|
|
11051
|
-
var INTEL_ALLOWED_PREFIXES = ["api", "img"];
|
|
11052
|
-
var INTEL_UPSTREAM_OPEN_TIMEOUT_MS = 5000;
|
|
11053
|
-
var INTEL_UPSTREAM_READ_TIMEOUT_MS = 60000;
|
|
11054
11007
|
|
|
11055
|
-
|
|
11056
|
-
|
|
11057
|
-
return this.http.get(intelPath(path), { ...options, ...query === undefined ? {} : { query } });
|
|
11058
|
-
}
|
|
11059
|
-
async fetch(path, query, options = {}) {
|
|
11060
|
-
return this.http.download(intelPath(path), { ...options, ...query === undefined ? {} : { query } });
|
|
11061
|
-
}
|
|
11062
|
-
url(path, query) {
|
|
11063
|
-
return this.http.url(intelPath(path), query);
|
|
11064
|
-
}
|
|
11065
|
-
}
|
|
11066
|
-
function intelPath(path) {
|
|
11067
|
-
const segments = path.replace(/^\/+/, "").split("/");
|
|
11068
|
-
return `/intel/${segments.map((segment) => encodeURIComponent(segment)).join("/")}`;
|
|
11069
|
-
}
|
|
11070
|
-
var INTEL_ARTICLE_CATEGORIES = [
|
|
11071
|
-
"incidente",
|
|
11072
|
-
"politica",
|
|
11073
|
-
"comunidade",
|
|
11074
|
-
"sociedade",
|
|
11075
|
-
"internacional",
|
|
11076
|
-
"economia",
|
|
11077
|
-
"outro"
|
|
11078
|
-
];
|
|
11079
|
-
var INTEL_REPORT_KINDS = ["6h", "day", "week", "month"];
|
|
11080
|
-
var INTEL_SOURCE_HEALTHS = ["unknown", "ok", "error"];
|
|
11081
|
-
var INTEL_PROMPT_KEYS = ["build", "enrich_plan", "enrich_actors", "enrich_synth", "report"];
|
|
11082
|
-
var INTEL_SOURCE_DISABLE_AFTER_FAILURES = 20;
|
|
11083
|
-
var INTEL_SCRIPT_MAX_CODE_BYTES = 64 * 1024;
|
|
11008
|
+
// src/resources/content/intel/reports.ts
|
|
11009
|
+
var INTEL_REPORT_FILTER_COLUMNS = Object.freeze(["kind"]);
|
|
11084
11010
|
|
|
11085
|
-
class
|
|
11011
|
+
class IntelReportsNamespace extends Resource {
|
|
11086
11012
|
async list(params = {}, options = {}) {
|
|
11087
|
-
const
|
|
11088
|
-
|
|
11089
|
-
const load = (at) => {
|
|
11090
|
-
const query = listQuery(params, at.page, at.pageSize);
|
|
11091
|
-
if (params.q !== undefined)
|
|
11092
|
-
query.q = params.q;
|
|
11093
|
-
if (params.minImportance !== undefined)
|
|
11094
|
-
query.min_importance = params.minImportance;
|
|
11095
|
-
if (params.sort !== undefined)
|
|
11096
|
-
query.sort = params.sort;
|
|
11097
|
-
return this.http.get("/intel_articles", { ...options, query });
|
|
11098
|
-
};
|
|
11099
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
11013
|
+
const base = { exactSearch: { kind: params.kind } };
|
|
11014
|
+
return paginate(params, 50, (at) => this.http.get("/intel_reports", { ...options, query: listQuery(params, at, base) }));
|
|
11100
11015
|
}
|
|
11101
11016
|
async get(id, options = {}) {
|
|
11102
|
-
return this.http.get(`/
|
|
11017
|
+
return this.http.get(`/intel_reports/${encodeURIComponent(id)}`, options);
|
|
11103
11018
|
}
|
|
11104
11019
|
async delete(id, options = {}) {
|
|
11105
|
-
await this.http.delete(`/
|
|
11020
|
+
await this.http.delete(`/intel_reports/${encodeURIComponent(id)}`, options);
|
|
11106
11021
|
}
|
|
11107
11022
|
}
|
|
11108
11023
|
|
|
11109
|
-
|
|
11024
|
+
// src/resources/content/intel/scripts.ts
|
|
11025
|
+
var INTEL_SCRIPT_MAX_CODE_BYTES = 64 * 1024;
|
|
11026
|
+
var INTEL_SCRIPT_FILTER_COLUMNS = Object.freeze(["name", "builtin", "slug"]);
|
|
11027
|
+
|
|
11028
|
+
class IntelScriptsNamespace extends Resource {
|
|
11110
11029
|
async list(params = {}, options = {}) {
|
|
11111
|
-
const
|
|
11112
|
-
|
|
11113
|
-
const exactSearch = {
|
|
11114
|
-
...params.exactSearch,
|
|
11115
|
-
...params.kind === undefined ? {} : { kind: params.kind }
|
|
11116
|
-
};
|
|
11117
|
-
const load = (at) => this.http.get("/intel_reports", {
|
|
11118
|
-
...options,
|
|
11119
|
-
query: listQuery({ ...params, ...Object.keys(exactSearch).length === 0 ? {} : { exactSearch } }, at.page, at.pageSize)
|
|
11120
|
-
});
|
|
11121
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
11030
|
+
const base = { order: "created_at:desc", exactSearch: { builtin: params.builtin } };
|
|
11031
|
+
return paginate(params, 100, (at) => this.http.get("/intel_scripts", { ...options, query: listQuery(params, at, base) }));
|
|
11122
11032
|
}
|
|
11123
11033
|
async get(id, options = {}) {
|
|
11124
|
-
return this.http.get(`/
|
|
11034
|
+
return this.http.get(`/intel_scripts/${encodeURIComponent(id)}`, options);
|
|
11035
|
+
}
|
|
11036
|
+
async create(input, options = {}) {
|
|
11037
|
+
return this.http.post("/intel_scripts", {
|
|
11038
|
+
name: input.name,
|
|
11039
|
+
code: input.code,
|
|
11040
|
+
...input.description === undefined ? {} : { description: input.description }
|
|
11041
|
+
}, { retry: false, ...options });
|
|
11042
|
+
}
|
|
11043
|
+
async update(id, input, options = {}) {
|
|
11044
|
+
return this.http.patch(`/intel_scripts/${encodeURIComponent(id)}`, {
|
|
11045
|
+
...input.name === undefined ? {} : { name: input.name },
|
|
11046
|
+
...input.code === undefined ? {} : { code: input.code },
|
|
11047
|
+
...input.description === undefined ? {} : { description: input.description }
|
|
11048
|
+
}, options);
|
|
11125
11049
|
}
|
|
11126
11050
|
async delete(id, options = {}) {
|
|
11127
|
-
await this.http.delete(`/
|
|
11051
|
+
await this.http.delete(`/intel_scripts/${encodeURIComponent(id)}`, options);
|
|
11128
11052
|
}
|
|
11129
11053
|
}
|
|
11130
11054
|
|
|
11055
|
+
// src/resources/content/intel/sources.ts
|
|
11056
|
+
var INTEL_SOURCE_HEALTHS = ["unknown", "ok", "error"];
|
|
11057
|
+
var INTEL_SOURCE_DISABLE_AFTER_FAILURES = 20;
|
|
11058
|
+
var INTEL_SOURCE_FILTER_COLUMNS = Object.freeze(["name", "health", "enabled", "intel_script_id"]);
|
|
11059
|
+
|
|
11131
11060
|
class IntelSourcesNamespace extends Resource {
|
|
11132
11061
|
async list(params = {}, options = {}) {
|
|
11133
|
-
const
|
|
11134
|
-
|
|
11135
|
-
|
|
11136
|
-
...params.exactSearch,
|
|
11137
|
-
...params.health === undefined ? {} : { health: params.health },
|
|
11138
|
-
...params.enabled === undefined ? {} : { enabled: params.enabled },
|
|
11139
|
-
...params.scriptId === undefined ? {} : { intel_script_id: params.scriptId }
|
|
11062
|
+
const base = {
|
|
11063
|
+
order: "created_at:desc",
|
|
11064
|
+
exactSearch: { health: params.health, enabled: params.enabled, intel_script_id: params.scriptId }
|
|
11140
11065
|
};
|
|
11141
|
-
|
|
11142
|
-
...options,
|
|
11143
|
-
query: listQuery({
|
|
11144
|
-
...params,
|
|
11145
|
-
order: params.order ?? "created_at:desc",
|
|
11146
|
-
...Object.keys(exactSearch).length === 0 ? {} : { exactSearch }
|
|
11147
|
-
}, at.page, at.pageSize)
|
|
11148
|
-
});
|
|
11149
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
11066
|
+
return paginate(params, 100, (at) => this.http.get("/intel_sources", { ...options, query: listQuery(params, at, base) }));
|
|
11150
11067
|
}
|
|
11151
11068
|
async get(id, options = {}) {
|
|
11152
11069
|
return this.http.get(`/intel_sources/${encodeURIComponent(id)}`, options);
|
|
@@ -11178,95 +11095,23 @@ class IntelSourcesNamespace extends Resource {
|
|
|
11178
11095
|
}
|
|
11179
11096
|
}
|
|
11180
11097
|
|
|
11181
|
-
|
|
11182
|
-
async list(params = {}, options = {}) {
|
|
11183
|
-
const page = params.page ?? 1;
|
|
11184
|
-
const pageSize = params.pageSize ?? 100;
|
|
11185
|
-
const exactSearch = {
|
|
11186
|
-
...params.exactSearch,
|
|
11187
|
-
...params.builtin === undefined ? {} : { builtin: params.builtin }
|
|
11188
|
-
};
|
|
11189
|
-
const load = (at) => this.http.get("/intel_scripts", {
|
|
11190
|
-
...options,
|
|
11191
|
-
query: listQuery({
|
|
11192
|
-
...params,
|
|
11193
|
-
order: params.order ?? "created_at:desc",
|
|
11194
|
-
...Object.keys(exactSearch).length === 0 ? {} : { exactSearch }
|
|
11195
|
-
}, at.page, at.pageSize)
|
|
11196
|
-
});
|
|
11197
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
11198
|
-
}
|
|
11199
|
-
async get(id, options = {}) {
|
|
11200
|
-
return this.http.get(`/intel_scripts/${encodeURIComponent(id)}`, options);
|
|
11201
|
-
}
|
|
11202
|
-
async create(input, options = {}) {
|
|
11203
|
-
return this.http.post("/intel_scripts", {
|
|
11204
|
-
name: input.name,
|
|
11205
|
-
code: input.code,
|
|
11206
|
-
...input.description === undefined ? {} : { description: input.description }
|
|
11207
|
-
}, { retry: false, ...options });
|
|
11208
|
-
}
|
|
11209
|
-
async update(id, input, options = {}) {
|
|
11210
|
-
return this.http.patch(`/intel_scripts/${encodeURIComponent(id)}`, {
|
|
11211
|
-
...input.name === undefined ? {} : { name: input.name },
|
|
11212
|
-
...input.code === undefined ? {} : { code: input.code },
|
|
11213
|
-
...input.description === undefined ? {} : { description: input.description }
|
|
11214
|
-
}, options);
|
|
11215
|
-
}
|
|
11216
|
-
async delete(id, options = {}) {
|
|
11217
|
-
await this.http.delete(`/intel_scripts/${encodeURIComponent(id)}`, options);
|
|
11218
|
-
}
|
|
11219
|
-
}
|
|
11220
|
-
|
|
11221
|
-
class IntelItemsNamespace extends Resource {
|
|
11222
|
-
async list(params = {}, options = {}) {
|
|
11223
|
-
const page = params.page ?? 1;
|
|
11224
|
-
const pageSize = params.pageSize ?? 25;
|
|
11225
|
-
const exactSearch = {
|
|
11226
|
-
...params.exactSearch,
|
|
11227
|
-
...params.sourceId === undefined ? {} : { intel_source_id: params.sourceId }
|
|
11228
|
-
};
|
|
11229
|
-
const load = (at) => this.http.get("/intel_items", {
|
|
11230
|
-
...options,
|
|
11231
|
-
query: listQuery({
|
|
11232
|
-
...params,
|
|
11233
|
-
order: params.order ?? "created_at:desc",
|
|
11234
|
-
...Object.keys(exactSearch).length === 0 ? {} : { exactSearch }
|
|
11235
|
-
}, at.page, at.pageSize)
|
|
11236
|
-
});
|
|
11237
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
11238
|
-
}
|
|
11239
|
-
async get(id, options = {}) {
|
|
11240
|
-
return this.http.get(`/intel_items/${encodeURIComponent(id)}`, options);
|
|
11241
|
-
}
|
|
11242
|
-
async delete(id, options = {}) {
|
|
11243
|
-
await this.http.delete(`/intel_items/${encodeURIComponent(id)}`, options);
|
|
11244
|
-
}
|
|
11245
|
-
}
|
|
11246
|
-
|
|
11247
|
-
class IntelConfigNamespace extends Resource {
|
|
11248
|
-
async get(options = {}) {
|
|
11249
|
-
return this.http.get("/intel_config", options);
|
|
11250
|
-
}
|
|
11251
|
-
async update(input, options = {}) {
|
|
11252
|
-
return this.http.patch("/intel_config", {
|
|
11253
|
-
...input.rubric === undefined ? {} : { rubric: input.rubric },
|
|
11254
|
-
...input.prompts === undefined ? {} : { prompts: input.prompts },
|
|
11255
|
-
...input.buildModel === undefined ? {} : { build_model: input.buildModel },
|
|
11256
|
-
...input.reportModel === undefined ? {} : { report_model: input.reportModel },
|
|
11257
|
-
...input.reportMinImportance === undefined ? {} : { report_min_importance: input.reportMinImportance },
|
|
11258
|
-
...input.enrichMinImportance === undefined ? {} : { enrich_min_importance: input.enrichMinImportance },
|
|
11259
|
-
...input.webSearch === undefined ? {} : { web_search: input.webSearch },
|
|
11260
|
-
...input.maxSources === undefined ? {} : { max_sources: input.maxSources }
|
|
11261
|
-
}, options);
|
|
11262
|
-
}
|
|
11263
|
-
}
|
|
11264
|
-
|
|
11098
|
+
// src/resources/content/intel/stats.ts
|
|
11265
11099
|
class IntelStatsNamespace extends Resource {
|
|
11266
11100
|
async get(options = {}) {
|
|
11267
11101
|
return this.http.get("/intel_stats", options);
|
|
11268
11102
|
}
|
|
11269
11103
|
}
|
|
11104
|
+
// src/resources/content/intel/types.ts
|
|
11105
|
+
var INTEL_ARTICLE_CATEGORIES = [
|
|
11106
|
+
"incidente",
|
|
11107
|
+
"politica",
|
|
11108
|
+
"comunidade",
|
|
11109
|
+
"sociedade",
|
|
11110
|
+
"internacional",
|
|
11111
|
+
"economia",
|
|
11112
|
+
"outro"
|
|
11113
|
+
];
|
|
11114
|
+
var INTEL_REPORT_KINDS = ["6h", "day", "week", "month"];
|
|
11270
11115
|
var INTEL_IMAGE_PROXY_BASE_URL = "https://wsrv.nl/";
|
|
11271
11116
|
function intelArticleImageUrl(imageUrl, options = {}) {
|
|
11272
11117
|
if (!imageUrl)
|
|
@@ -11276,6 +11121,7 @@ function intelArticleImageUrl(imageUrl, options = {}) {
|
|
|
11276
11121
|
return `${INTEL_IMAGE_PROXY_BASE_URL}?url=${encodeURIComponent(imageUrl)}&w=${width}&q=${quality}&output=webp&we`;
|
|
11277
11122
|
}
|
|
11278
11123
|
|
|
11124
|
+
// src/resources/content/intel/index.ts
|
|
11279
11125
|
class IntelNamespace extends Resource {
|
|
11280
11126
|
articles;
|
|
11281
11127
|
reports;
|
|
@@ -11284,7 +11130,6 @@ class IntelNamespace extends Resource {
|
|
|
11284
11130
|
items;
|
|
11285
11131
|
config;
|
|
11286
11132
|
stats;
|
|
11287
|
-
proxy;
|
|
11288
11133
|
constructor(http) {
|
|
11289
11134
|
super(http);
|
|
11290
11135
|
this.articles = new IntelArticlesNamespace(http);
|
|
@@ -11294,19 +11139,130 @@ class IntelNamespace extends Resource {
|
|
|
11294
11139
|
this.items = new IntelItemsNamespace(http);
|
|
11295
11140
|
this.config = new IntelConfigNamespace(http);
|
|
11296
11141
|
this.stats = new IntelStatsNamespace(http);
|
|
11297
|
-
this.proxy = new IntelProxyNamespace(http);
|
|
11298
11142
|
}
|
|
11299
|
-
|
|
11300
|
-
|
|
11143
|
+
}
|
|
11144
|
+
|
|
11145
|
+
// src/resources/content/jokes.ts
|
|
11146
|
+
var JOKE_FILTER_COLUMNS = Object.freeze([]);
|
|
11147
|
+
|
|
11148
|
+
class JokesNamespace extends Resource {
|
|
11149
|
+
async list(params = {}, options = {}) {
|
|
11150
|
+
return paginate(params, 100, (at) => this.http.get("/jokes", { ...options, query: listQuery(params, at) }));
|
|
11301
11151
|
}
|
|
11302
|
-
async
|
|
11303
|
-
return this.
|
|
11152
|
+
async create(input, options = {}) {
|
|
11153
|
+
return this.http.post("/jokes", input, options);
|
|
11304
11154
|
}
|
|
11305
|
-
|
|
11306
|
-
return this.
|
|
11155
|
+
async update(id, input, options = {}) {
|
|
11156
|
+
return this.http.patch(`/jokes/${encodeURIComponent(String(id))}`, input, options);
|
|
11157
|
+
}
|
|
11158
|
+
async destroy(id, options = {}) {
|
|
11159
|
+
await this.http.delete(`/jokes/${encodeURIComponent(String(id))}`, options);
|
|
11160
|
+
}
|
|
11161
|
+
}
|
|
11162
|
+
|
|
11163
|
+
// src/resources/content/notifications.ts
|
|
11164
|
+
var NOTIFICATION_FILTER_COLUMNS = Object.freeze(["user_id"]);
|
|
11165
|
+
|
|
11166
|
+
class NotificationsNamespace extends Resource {
|
|
11167
|
+
async list(params = {}, options = {}) {
|
|
11168
|
+
return paginate(params, 100, (at) => this.http.get("/notifications", { ...options, query: listQuery(params, at) }));
|
|
11169
|
+
}
|
|
11170
|
+
async unreadCount(options = {}) {
|
|
11171
|
+
const body = await this.http.get("/notifications/unread_count", options);
|
|
11172
|
+
return body.count;
|
|
11173
|
+
}
|
|
11174
|
+
async markAllRead(options = {}) {
|
|
11175
|
+
const body = await this.http.post("/notifications/read_all", undefined, options);
|
|
11176
|
+
return body.count;
|
|
11177
|
+
}
|
|
11178
|
+
async dismiss(id, options = {}) {
|
|
11179
|
+
await this.http.delete(`/notifications/${encodeURIComponent(String(id))}`, options);
|
|
11180
|
+
}
|
|
11181
|
+
}
|
|
11182
|
+
|
|
11183
|
+
// src/resources/content/serviceUsages.ts
|
|
11184
|
+
var SERVICE_USAGE_IDS = [
|
|
11185
|
+
"storage",
|
|
11186
|
+
"tools",
|
|
11187
|
+
"games",
|
|
11188
|
+
"music",
|
|
11189
|
+
"movies",
|
|
11190
|
+
"ai",
|
|
11191
|
+
"account",
|
|
11192
|
+
"tickets",
|
|
11193
|
+
"messages",
|
|
11194
|
+
"blogs",
|
|
11195
|
+
"status",
|
|
11196
|
+
"administration"
|
|
11197
|
+
];
|
|
11198
|
+
|
|
11199
|
+
class ServiceUsagesNamespace extends Resource {
|
|
11200
|
+
async record(serviceId, options = {}) {
|
|
11201
|
+
return this.http.post("/service_usages", { service_id: serviceId }, options);
|
|
11202
|
+
}
|
|
11203
|
+
async top(input = {}, options = {}) {
|
|
11204
|
+
return this.http.get("/service_usages/top", {
|
|
11205
|
+
...options,
|
|
11206
|
+
...input.limit === undefined ? {} : { query: { limit: input.limit } }
|
|
11207
|
+
});
|
|
11208
|
+
}
|
|
11209
|
+
}
|
|
11210
|
+
|
|
11211
|
+
// src/resources/content/servicesStatus.ts
|
|
11212
|
+
var EXTERNAL_SERVICE_SLUGS = ["vocal_separator", "ai", "yt_dlp"];
|
|
11213
|
+
var INTERNAL_SERVICE_SLUGS = [
|
|
11214
|
+
"accounts",
|
|
11215
|
+
"notifications",
|
|
11216
|
+
"storage",
|
|
11217
|
+
"socials",
|
|
11218
|
+
"short_links",
|
|
11219
|
+
"ip_lookup",
|
|
11220
|
+
"jokes",
|
|
11221
|
+
"space_invaders"
|
|
11222
|
+
];
|
|
11223
|
+
var ALL_SERVICE_SLUGS = [...INTERNAL_SERVICE_SLUGS, ...EXTERNAL_SERVICE_SLUGS];
|
|
11224
|
+
var UPTIME_CACHE_SECONDS = 60;
|
|
11225
|
+
var UPTIME_WINDOW_DAYS = 90;
|
|
11226
|
+
|
|
11227
|
+
class ServicesStatusNamespace extends Resource {
|
|
11228
|
+
async current(options = {}) {
|
|
11229
|
+
return this.http.get("/services_status", options);
|
|
11230
|
+
}
|
|
11231
|
+
async uptime(options = {}) {
|
|
11232
|
+
return this.http.get("/services_status/uptime", options);
|
|
11233
|
+
}
|
|
11234
|
+
}
|
|
11235
|
+
|
|
11236
|
+
// src/resources/content/siteConfig.ts
|
|
11237
|
+
class SiteConfigNamespace extends Resource {
|
|
11238
|
+
async get(options = {}) {
|
|
11239
|
+
return this.http.get("/config", options);
|
|
11240
|
+
}
|
|
11241
|
+
}
|
|
11242
|
+
|
|
11243
|
+
// src/resources/content/spaceInvaders.ts
|
|
11244
|
+
var SPACE_INVADERS_GAME_FILTER_COLUMNS = Object.freeze([]);
|
|
11245
|
+
var SPACE_INVADERS_MAX_POINTS_PER_KILL = 10;
|
|
11246
|
+
var SPACE_INVADERS_MAX_KILLS_PER_SECOND = 1;
|
|
11247
|
+
var SPACE_INVADERS_MAX_SESSION_SECONDS = 24 * 60 * 60;
|
|
11248
|
+
var SPACE_INVADERS_LEADERBOARD_SIZE = 100;
|
|
11249
|
+
|
|
11250
|
+
class SpaceInvadersNamespace extends Resource {
|
|
11251
|
+
async leaderboard(options = {}) {
|
|
11252
|
+
return this.http.get("/space_invaders_games/leaderboard", options);
|
|
11253
|
+
}
|
|
11254
|
+
async list(params = {}, options = {}) {
|
|
11255
|
+
return paginate(params, 100, (at) => this.http.get("/space_invaders_games", { ...options, query: listQuery(params, at) }));
|
|
11256
|
+
}
|
|
11257
|
+
async submit(input, options = {}) {
|
|
11258
|
+
return this.http.post("/space_invaders_games", input, options);
|
|
11259
|
+
}
|
|
11260
|
+
async destroy(id, options = {}) {
|
|
11261
|
+
await this.http.delete(`/space_invaders_games/${encodeURIComponent(String(id))}`, options);
|
|
11307
11262
|
}
|
|
11308
11263
|
}
|
|
11309
11264
|
|
|
11265
|
+
// src/resources/content/index.ts
|
|
11310
11266
|
class ContentNamespace extends Resource {
|
|
11311
11267
|
blogs;
|
|
11312
11268
|
notifications;
|
|
@@ -11335,16 +11291,14 @@ class ContentNamespace extends Resource {
|
|
|
11335
11291
|
|
|
11336
11292
|
// src/resources/shortLinks.ts
|
|
11337
11293
|
var SHORT_LINK_BASE_URL = "https://omelhor.site";
|
|
11294
|
+
var SHORT_LINK_FILTER_COLUMNS = Object.freeze(["user_id"]);
|
|
11338
11295
|
var RESOLVE_MAX_PAGES = 20;
|
|
11339
11296
|
var RESOLVE_PAGE_SIZE = 500;
|
|
11340
11297
|
|
|
11341
11298
|
class ShortLinksNamespace extends Resource {
|
|
11342
11299
|
async list(params = {}, options = {}) {
|
|
11343
|
-
const
|
|
11344
|
-
|
|
11345
|
-
const order = params.order ?? "created_at:desc";
|
|
11346
|
-
const load = (at) => this.fetchPage({ ...at, order, ...params.userId === undefined ? {} : { userId: params.userId } }, options);
|
|
11347
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
11300
|
+
const base = { order: "created_at:desc", exactSearch: { user_id: params.userId } };
|
|
11301
|
+
return paginate(params, 100, (at) => this.http.get("/short_links", { ...options, query: listQuery(params, at, base) }));
|
|
11348
11302
|
}
|
|
11349
11303
|
async create(input, options = {}) {
|
|
11350
11304
|
return this.http.post("/short_links", {
|
|
@@ -11363,11 +11317,11 @@ class ShortLinksNamespace extends Resource {
|
|
|
11363
11317
|
}
|
|
11364
11318
|
async resolve(endpoint, options = {}) {
|
|
11365
11319
|
for (let page = 1;page <= RESOLVE_MAX_PAGES; page += 1) {
|
|
11366
|
-
const
|
|
11367
|
-
const hit =
|
|
11320
|
+
const items2 = await this.fetchPage({ page, pageSize: RESOLVE_PAGE_SIZE, order: "created_at:desc" }, options);
|
|
11321
|
+
const hit = items2.find((link) => link.endpoint === endpoint);
|
|
11368
11322
|
if (hit)
|
|
11369
11323
|
return hit;
|
|
11370
|
-
if (
|
|
11324
|
+
if (items2.length < RESOLVE_PAGE_SIZE)
|
|
11371
11325
|
break;
|
|
11372
11326
|
}
|
|
11373
11327
|
throw new OmsError(`No short link of yours has the endpoint "${endpoint}".`, "not_found", { method: "GET", url: this.http.url("/short_links") });
|
|
@@ -11376,12 +11330,9 @@ class ShortLinksNamespace extends Resource {
|
|
|
11376
11330
|
return link.namespace ? `${SHORT_LINK_BASE_URL}/${link.namespace}/${link.endpoint}` : `${SHORT_LINK_BASE_URL}/${link.endpoint}`;
|
|
11377
11331
|
}
|
|
11378
11332
|
async fetchPage(at, options) {
|
|
11379
|
-
const query = {
|
|
11380
|
-
|
|
11381
|
-
|
|
11382
|
-
};
|
|
11383
|
-
const items = await this.http.get("/short_links", { ...options, query });
|
|
11384
|
-
return items ?? [];
|
|
11333
|
+
const query = listQuery({}, at, { order: at.order, exactSearch: { user_id: at.userId } });
|
|
11334
|
+
const items2 = await this.http.get("/short_links", { ...options, query });
|
|
11335
|
+
return items2 ?? [];
|
|
11385
11336
|
}
|
|
11386
11337
|
}
|
|
11387
11338
|
|
|
@@ -11391,8 +11342,8 @@ var DYNAMIC_QR_BASE_URL = `${SHORT_LINK_BASE_URL}/${DYNAMIC_QR_NAMESPACE}`;
|
|
|
11391
11342
|
|
|
11392
11343
|
class DynamicQrsNamespace extends Resource {
|
|
11393
11344
|
async list(options = {}) {
|
|
11394
|
-
const
|
|
11395
|
-
return
|
|
11345
|
+
const items2 = await this.http.get("/dynamic_qrs", options);
|
|
11346
|
+
return items2 ?? [];
|
|
11396
11347
|
}
|
|
11397
11348
|
async create(input, options = {}) {
|
|
11398
11349
|
return this.http.post("/dynamic_qrs", {
|
|
@@ -11534,6 +11485,14 @@ var JOB_TERMINAL_STATUSES = Object.freeze([
|
|
|
11534
11485
|
function isJobTerminal(status) {
|
|
11535
11486
|
return JOB_TERMINAL_STATUSES.includes(status);
|
|
11536
11487
|
}
|
|
11488
|
+
var JOB_FILTER_COLUMNS = Object.freeze([
|
|
11489
|
+
"id",
|
|
11490
|
+
"job_type",
|
|
11491
|
+
"status",
|
|
11492
|
+
"created_at",
|
|
11493
|
+
"updated_at",
|
|
11494
|
+
"finished_at"
|
|
11495
|
+
]);
|
|
11537
11496
|
var DEFAULT_POLL_INTERVAL_MS = 1000;
|
|
11538
11497
|
var MAX_POLL_INTERVAL_MS = 15000;
|
|
11539
11498
|
var POLL_BACKOFF_FACTOR = 1.5;
|
|
@@ -11578,25 +11537,12 @@ async function* watchUntilTerminal(options) {
|
|
|
11578
11537
|
|
|
11579
11538
|
class JobsNamespace extends Resource {
|
|
11580
11539
|
async list(params = {}, options = {}) {
|
|
11581
|
-
const
|
|
11582
|
-
|
|
11583
|
-
if (params.status !== undefined)
|
|
11584
|
-
search["status"] = asFilter(params.status);
|
|
11585
|
-
if (params.jobType !== undefined)
|
|
11586
|
-
search["job_type"] = asFilter(params.jobType);
|
|
11587
|
-
const load = async (page) => await this.http.get("/jobs", {
|
|
11540
|
+
const base = { exactSearch: { status: params.status, job_type: params.jobType } };
|
|
11541
|
+
return paginate(params, 100, (at) => this.http.get("/jobs", {
|
|
11588
11542
|
...options,
|
|
11589
|
-
query:
|
|
11590
|
-
...Object.keys(search).length > 0 ? { search } : {},
|
|
11591
|
-
modifiers: {
|
|
11592
|
-
page: pageModifier(page.page, page.pageSize),
|
|
11593
|
-
...params.order === undefined ? {} : { order: params.order }
|
|
11594
|
-
}
|
|
11595
|
-
},
|
|
11543
|
+
query: listQuery(params, at, base),
|
|
11596
11544
|
headers: noRevalidate(options.headers)
|
|
11597
|
-
})
|
|
11598
|
-
const first = params.page ?? 1;
|
|
11599
|
-
return createPage(await load({ page: first, pageSize }), first, pageSize, load);
|
|
11545
|
+
}));
|
|
11600
11546
|
}
|
|
11601
11547
|
async get(ref, options = {}) {
|
|
11602
11548
|
const { id, watchToken } = jobRef(ref);
|
|
@@ -11641,9 +11587,6 @@ function requestPartOf(options) {
|
|
|
11641
11587
|
...options.retry === undefined ? {} : { retry: options.retry }
|
|
11642
11588
|
};
|
|
11643
11589
|
}
|
|
11644
|
-
function asFilter(value) {
|
|
11645
|
-
return Array.isArray(value) ? [...value] : value;
|
|
11646
|
-
}
|
|
11647
11590
|
function noRevalidate(headers) {
|
|
11648
11591
|
return { "Cache-Control": "no-cache", ...headers ?? {} };
|
|
11649
11592
|
}
|
|
@@ -11660,48 +11603,78 @@ function gaveUp(label, timeoutMs, last) {
|
|
|
11660
11603
|
return new OmsTimeoutError(`Gave up waiting for ${label} after ${timeoutMs}ms.${seen} ` + `The server is still working on it - poll it later with get(), the run was not cancelled.`, { timeoutMs });
|
|
11661
11604
|
}
|
|
11662
11605
|
|
|
11663
|
-
// src/resources/library.ts
|
|
11664
|
-
var BOOK_FORMATS = ["pdf", "epub"];
|
|
11665
|
-
var BOOK_VISIBILITIES = ["private", "unlisted", "public"];
|
|
11666
|
-
var BOOK_ANNOTATION_KINDS = ["highlight", "note", "bookmark", "progress"];
|
|
11667
|
-
var BOOK_MAX_FILE_BYTES = 104857600;
|
|
11668
|
-
var BOOK_UPLOAD_EDGE_LIMIT_BYTES = 1e8;
|
|
11669
|
-
var BOOK_TITLE_MAX_LENGTH = 300;
|
|
11670
|
-
var BOOK_AUTHOR_MAX_LENGTH = 200;
|
|
11671
|
-
var BOOK_MAX_TAGS = 30;
|
|
11672
|
-
var BOOK_TAG_MAX_LENGTH = 40;
|
|
11673
|
-
var BOOK_SHELF_NAME_MAX_LENGTH = 120;
|
|
11674
|
-
var BOOK_SHELF_DESCRIPTION_MAX_LENGTH = 1000;
|
|
11675
|
-
var BOOK_SHELVES_MAX_PER_USER = 100;
|
|
11606
|
+
// src/resources/library/annotations.ts
|
|
11676
11607
|
var BOOK_ANNOTATION_NOTE_MAX_LENGTH = 5000;
|
|
11677
11608
|
var BOOK_ANNOTATION_SELECTED_TEXT_MAX_LENGTH = 8000;
|
|
11678
|
-
var
|
|
11679
|
-
var BOOK_CHAT_MAX_BODY_BYTES = 524288;
|
|
11680
|
-
var BOOK_CHAT_MAX_CONTEXT_CHARS = 12000;
|
|
11681
|
-
var BOOK_CHAT_MAX_HISTORY_MESSAGES = 12;
|
|
11682
|
-
var BOOK_CHAT_MAX_MESSAGE_CHARS = 4000;
|
|
11683
|
-
var BOOK_CHAT_MAX_HISTORY_CHARS = 8000;
|
|
11684
|
-
var ANONYMOUS_BOOK_FILE_RATE_LIMIT_PER_HOUR = 120;
|
|
11609
|
+
var BOOK_ANNOTATION_FILTER_COLUMNS = Object.freeze(["book_id", "kind"]);
|
|
11685
11610
|
|
|
11686
|
-
class
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
this.partial = partial;
|
|
11611
|
+
class LibraryAnnotationsNamespace extends Resource {
|
|
11612
|
+
async list(params = {}, options = {}) {
|
|
11613
|
+
const base = { exactSearch: { book_id: params.bookId, kind: params.kind } };
|
|
11614
|
+
return paginate(params, 100, (at) => this.http.get("/book_annotations", {
|
|
11615
|
+
...options,
|
|
11616
|
+
query: listQuery(params, at, base)
|
|
11617
|
+
}));
|
|
11694
11618
|
}
|
|
11695
|
-
|
|
11696
|
-
|
|
11619
|
+
async forBook(bookId, params = {}, options = {}) {
|
|
11620
|
+
const pageSize = params.pageSize ?? 500;
|
|
11621
|
+
const all = [];
|
|
11622
|
+
let cursor = await this.list({
|
|
11623
|
+
bookId,
|
|
11624
|
+
...params.kinds === undefined ? {} : { kind: params.kinds },
|
|
11625
|
+
pageSize,
|
|
11626
|
+
order: "created_at:asc"
|
|
11627
|
+
}, options);
|
|
11628
|
+
while (cursor) {
|
|
11629
|
+
all.push(...cursor.items);
|
|
11630
|
+
cursor = await cursor.next();
|
|
11631
|
+
}
|
|
11632
|
+
return all;
|
|
11633
|
+
}
|
|
11634
|
+
async progressFor(bookId, options = {}) {
|
|
11635
|
+
const page = await this.list({ bookId, kind: "progress", pageSize: 1 }, options);
|
|
11636
|
+
return page.items[0] ?? null;
|
|
11637
|
+
}
|
|
11638
|
+
async continueReading(limit = 24, options = {}) {
|
|
11639
|
+
const page = await this.list({ kind: "progress", order: "updated_at:desc", pageSize: limit }, options);
|
|
11640
|
+
return page.items;
|
|
11641
|
+
}
|
|
11642
|
+
async create(input, options = {}) {
|
|
11643
|
+
const body = { book_id: input.bookId, kind: input.kind };
|
|
11644
|
+
body["location"] = input.location ?? {};
|
|
11645
|
+
if (input.color !== undefined)
|
|
11646
|
+
body["color"] = input.color;
|
|
11647
|
+
if (input.note !== undefined)
|
|
11648
|
+
body["note"] = input.note;
|
|
11649
|
+
if (input.selectedText !== undefined)
|
|
11650
|
+
body["selected_text"] = input.selectedText;
|
|
11651
|
+
return this.http.post("/book_annotations", body, options);
|
|
11652
|
+
}
|
|
11653
|
+
async update(id, input, options = {}) {
|
|
11654
|
+
const body = {};
|
|
11655
|
+
if (input.color !== undefined)
|
|
11656
|
+
body["color"] = input.color;
|
|
11657
|
+
if (input.note !== undefined)
|
|
11658
|
+
body["note"] = input.note;
|
|
11659
|
+
if (input.location !== undefined)
|
|
11660
|
+
body["location"] = input.location;
|
|
11661
|
+
return this.http.patch(`/book_annotations/${idSegment(id)}`, body, options);
|
|
11662
|
+
}
|
|
11663
|
+
async delete(id, options = {}) {
|
|
11664
|
+
await this.http.delete(`/book_annotations/${idSegment(id)}`, options);
|
|
11697
11665
|
}
|
|
11698
11666
|
}
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
|
|
11667
|
+
|
|
11668
|
+
// src/resources/library/books.ts
|
|
11669
|
+
var BOOK_MAX_FILE_BYTES = 104857600;
|
|
11670
|
+
var BOOK_UPLOAD_EDGE_LIMIT_BYTES = 1e8;
|
|
11671
|
+
var BOOK_TITLE_MAX_LENGTH = 300;
|
|
11672
|
+
var BOOK_AUTHOR_MAX_LENGTH = 200;
|
|
11673
|
+
var BOOK_MAX_TAGS = 30;
|
|
11674
|
+
var BOOK_TAG_MAX_LENGTH = 40;
|
|
11675
|
+
var ANONYMOUS_BOOK_FILE_RATE_LIMIT_PER_HOUR = 120;
|
|
11676
|
+
var BOOK_FILTER_COLUMNS = Object.freeze(["title", "author", "format", "user_id"]);
|
|
11677
|
+
var BOOK_EXTRA_OPTION_KEYS = Object.freeze(["scope", "owner_handle", "tags"]);
|
|
11705
11678
|
function knownByteSize(input) {
|
|
11706
11679
|
if (typeof input === "object" && input !== null && "size" in input && typeof input.size === "number") {
|
|
11707
11680
|
return input.size;
|
|
@@ -11713,9 +11686,6 @@ function knownByteSize(input) {
|
|
|
11713
11686
|
return data.byteLength;
|
|
11714
11687
|
return;
|
|
11715
11688
|
}
|
|
11716
|
-
function idSegment(id) {
|
|
11717
|
-
return encodeURIComponent(String(id));
|
|
11718
|
-
}
|
|
11719
11689
|
function parseContentRange(header) {
|
|
11720
11690
|
if (!header)
|
|
11721
11691
|
return;
|
|
@@ -11727,10 +11697,16 @@ function parseContentRange(header) {
|
|
|
11727
11697
|
|
|
11728
11698
|
class LibraryBooksNamespace extends Resource {
|
|
11729
11699
|
async list(params = {}, options = {}) {
|
|
11730
|
-
const
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11700
|
+
const base = {
|
|
11701
|
+
search: { title: params.title, author: params.author },
|
|
11702
|
+
exactSearch: { format: params.format, user_id: params.userId, id: params.ids },
|
|
11703
|
+
extraOptions: {
|
|
11704
|
+
scope: params.scope,
|
|
11705
|
+
owner_handle: params.ownerHandle,
|
|
11706
|
+
tags: params.tags !== undefined && params.tags.length > 0 ? params.tags : undefined
|
|
11707
|
+
}
|
|
11708
|
+
};
|
|
11709
|
+
return paginate(params, 100, (at) => this.http.get("/books", { ...options, query: listQuery(params, at, base) }));
|
|
11734
11710
|
}
|
|
11735
11711
|
async mine(params = {}, options = {}) {
|
|
11736
11712
|
return this.list({ ...params, scope: "mine" }, options);
|
|
@@ -11820,40 +11796,6 @@ class LibraryBooksNamespace extends Resource {
|
|
|
11820
11796
|
async saveProgress(id, location, options = {}) {
|
|
11821
11797
|
return this.http.post(`/books/${idSegment(id)}/progress`, { location }, options);
|
|
11822
11798
|
}
|
|
11823
|
-
bookQuery(params, at) {
|
|
11824
|
-
const search = { ...params.search ?? {} };
|
|
11825
|
-
if (params.title !== undefined)
|
|
11826
|
-
search["title"] = params.title;
|
|
11827
|
-
if (params.author !== undefined)
|
|
11828
|
-
search["author"] = params.author;
|
|
11829
|
-
const exact = { ...params.exactSearch ?? {} };
|
|
11830
|
-
if (params.format !== undefined)
|
|
11831
|
-
exact["format"] = params.format;
|
|
11832
|
-
if (params.userId !== undefined)
|
|
11833
|
-
exact["user_id"] = params.userId;
|
|
11834
|
-
if (params.ids !== undefined)
|
|
11835
|
-
exact["id"] = [...params.ids];
|
|
11836
|
-
const modifiers = {};
|
|
11837
|
-
if (at)
|
|
11838
|
-
modifiers["page"] = pageModifier(at.page, at.pageSize);
|
|
11839
|
-
if (params.order !== undefined)
|
|
11840
|
-
modifiers["order"] = params.order;
|
|
11841
|
-
if (params.random)
|
|
11842
|
-
modifiers["random"] = true;
|
|
11843
|
-
const extra = {};
|
|
11844
|
-
if (params.scope !== undefined)
|
|
11845
|
-
extra["scope"] = params.scope;
|
|
11846
|
-
if (params.ownerHandle !== undefined)
|
|
11847
|
-
extra["owner_handle"] = params.ownerHandle;
|
|
11848
|
-
if (params.tags !== undefined && params.tags.length > 0)
|
|
11849
|
-
extra["tags"] = [...params.tags];
|
|
11850
|
-
return {
|
|
11851
|
-
...Object.keys(search).length > 0 ? { search } : {},
|
|
11852
|
-
...Object.keys(exact).length > 0 ? { exact_search: exact } : {},
|
|
11853
|
-
...Object.keys(modifiers).length > 0 ? { modifiers } : {},
|
|
11854
|
-
...Object.keys(extra).length > 0 ? { extra_options: extra } : {}
|
|
11855
|
-
};
|
|
11856
|
-
}
|
|
11857
11799
|
updateBody(input) {
|
|
11858
11800
|
const body = {};
|
|
11859
11801
|
if (input.title !== undefined)
|
|
@@ -11894,152 +11836,33 @@ class LibraryBooksNamespace extends Resource {
|
|
|
11894
11836
|
}
|
|
11895
11837
|
}
|
|
11896
11838
|
|
|
11897
|
-
|
|
11898
|
-
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11903
|
-
|
|
11904
|
-
async get(id, options = {}) {
|
|
11905
|
-
return this.http.get(`/book_shelves/${idSegment(id)}`, options);
|
|
11906
|
-
}
|
|
11907
|
-
async create(input, options = {}) {
|
|
11908
|
-
const body = { name: input.name };
|
|
11909
|
-
if (input.description !== undefined)
|
|
11910
|
-
body["description"] = input.description;
|
|
11911
|
-
if (input.visibility !== undefined)
|
|
11912
|
-
body["visibility"] = input.visibility;
|
|
11913
|
-
return this.http.post("/book_shelves", body, options);
|
|
11914
|
-
}
|
|
11915
|
-
async update(id, input, options = {}) {
|
|
11916
|
-
const body = {};
|
|
11917
|
-
if (input.name !== undefined)
|
|
11918
|
-
body["name"] = input.name;
|
|
11919
|
-
if (input.description !== undefined)
|
|
11920
|
-
body["description"] = input.description;
|
|
11921
|
-
if (input.visibility !== undefined)
|
|
11922
|
-
body["visibility"] = input.visibility;
|
|
11923
|
-
if (input.position !== undefined)
|
|
11924
|
-
body["position"] = input.position;
|
|
11925
|
-
return this.http.patch(`/book_shelves/${idSegment(id)}`, body, options);
|
|
11926
|
-
}
|
|
11927
|
-
async delete(id, options = {}) {
|
|
11928
|
-
await this.http.delete(`/book_shelves/${idSegment(id)}`, options);
|
|
11929
|
-
}
|
|
11930
|
-
async addBook(id, bookId, options = {}) {
|
|
11931
|
-
return this.http.post(`/book_shelves/${idSegment(id)}/add_book`, { book_id: bookId }, options);
|
|
11932
|
-
}
|
|
11933
|
-
async removeBook(id, bookId, options = {}) {
|
|
11934
|
-
return this.http.delete(`/book_shelves/${idSegment(id)}/remove_book`, {
|
|
11935
|
-
...options,
|
|
11936
|
-
query: { ...options.query, book_id: bookId }
|
|
11937
|
-
});
|
|
11938
|
-
}
|
|
11939
|
-
async reorder(id, bookIds, options = {}) {
|
|
11940
|
-
if (bookIds.length === 0) {
|
|
11941
|
-
throw new TypeError("reorder needs the complete list of book ids in their new order. An empty list is a 400 server-side, and a " + "PARTIAL list is worse than an error: the books you left out keep their old positions and collide with the new ones.");
|
|
11942
|
-
}
|
|
11943
|
-
return this.http.post(`/book_shelves/${idSegment(id)}/reorder`, { book_ids: [...bookIds] }, options);
|
|
11944
|
-
}
|
|
11945
|
-
shelfQuery(params, at) {
|
|
11946
|
-
const search = { ...params.search ?? {} };
|
|
11947
|
-
const exact = { ...params.exactSearch ?? {} };
|
|
11948
|
-
if (params.userId !== undefined)
|
|
11949
|
-
exact["user_id"] = params.userId;
|
|
11950
|
-
if (params.visibility !== undefined)
|
|
11951
|
-
exact["visibility"] = params.visibility;
|
|
11952
|
-
if (params.ids !== undefined)
|
|
11953
|
-
exact["id"] = [...params.ids];
|
|
11954
|
-
const modifiers = {};
|
|
11955
|
-
if (at)
|
|
11956
|
-
modifiers["page"] = pageModifier(at.page, at.pageSize);
|
|
11957
|
-
if (params.order !== undefined)
|
|
11958
|
-
modifiers["order"] = params.order;
|
|
11959
|
-
return {
|
|
11960
|
-
...Object.keys(search).length > 0 ? { search } : {},
|
|
11961
|
-
...Object.keys(exact).length > 0 ? { exact_search: exact } : {},
|
|
11962
|
-
...Object.keys(modifiers).length > 0 ? { modifiers } : {}
|
|
11963
|
-
};
|
|
11964
|
-
}
|
|
11965
|
-
}
|
|
11839
|
+
// src/resources/library/chat.ts
|
|
11840
|
+
var BOOK_CHAT_RATE_LIMIT_PER_MINUTE = 15;
|
|
11841
|
+
var BOOK_CHAT_MAX_BODY_BYTES = 524288;
|
|
11842
|
+
var BOOK_CHAT_MAX_CONTEXT_CHARS = 12000;
|
|
11843
|
+
var BOOK_CHAT_MAX_HISTORY_MESSAGES = 12;
|
|
11844
|
+
var BOOK_CHAT_MAX_MESSAGE_CHARS = 4000;
|
|
11845
|
+
var BOOK_CHAT_MAX_HISTORY_CHARS = 8000;
|
|
11966
11846
|
|
|
11967
|
-
class
|
|
11968
|
-
|
|
11969
|
-
|
|
11970
|
-
|
|
11971
|
-
|
|
11972
|
-
|
|
11973
|
-
|
|
11974
|
-
|
|
11975
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
11976
|
-
}
|
|
11977
|
-
async forBook(bookId, params = {}, options = {}) {
|
|
11978
|
-
const pageSize = params.pageSize ?? 500;
|
|
11979
|
-
const all = [];
|
|
11980
|
-
let cursor = await this.list({
|
|
11981
|
-
bookId,
|
|
11982
|
-
...params.kinds === undefined ? {} : { kind: params.kinds },
|
|
11983
|
-
pageSize,
|
|
11984
|
-
order: "created_at:asc"
|
|
11985
|
-
}, options);
|
|
11986
|
-
while (cursor) {
|
|
11987
|
-
all.push(...cursor.items);
|
|
11988
|
-
cursor = await cursor.next();
|
|
11989
|
-
}
|
|
11990
|
-
return all;
|
|
11991
|
-
}
|
|
11992
|
-
async progressFor(bookId, options = {}) {
|
|
11993
|
-
const page = await this.list({ bookId, kind: "progress", pageSize: 1 }, options);
|
|
11994
|
-
return page.items[0] ?? null;
|
|
11995
|
-
}
|
|
11996
|
-
async continueReading(limit = 24, options = {}) {
|
|
11997
|
-
const page = await this.list({ kind: "progress", order: "updated_at:desc", pageSize: limit }, options);
|
|
11998
|
-
return page.items;
|
|
11999
|
-
}
|
|
12000
|
-
async create(input, options = {}) {
|
|
12001
|
-
const body = { book_id: input.bookId, kind: input.kind };
|
|
12002
|
-
body["location"] = input.location ?? {};
|
|
12003
|
-
if (input.color !== undefined)
|
|
12004
|
-
body["color"] = input.color;
|
|
12005
|
-
if (input.note !== undefined)
|
|
12006
|
-
body["note"] = input.note;
|
|
12007
|
-
if (input.selectedText !== undefined)
|
|
12008
|
-
body["selected_text"] = input.selectedText;
|
|
12009
|
-
return this.http.post("/book_annotations", body, options);
|
|
12010
|
-
}
|
|
12011
|
-
async update(id, input, options = {}) {
|
|
12012
|
-
const body = {};
|
|
12013
|
-
if (input.color !== undefined)
|
|
12014
|
-
body["color"] = input.color;
|
|
12015
|
-
if (input.note !== undefined)
|
|
12016
|
-
body["note"] = input.note;
|
|
12017
|
-
if (input.location !== undefined)
|
|
12018
|
-
body["location"] = input.location;
|
|
12019
|
-
return this.http.patch(`/book_annotations/${idSegment(id)}`, body, options);
|
|
12020
|
-
}
|
|
12021
|
-
async delete(id, options = {}) {
|
|
12022
|
-
await this.http.delete(`/book_annotations/${idSegment(id)}`, options);
|
|
11847
|
+
class BookChatError extends OmsError {
|
|
11848
|
+
static errorName = "BookChatError";
|
|
11849
|
+
reason;
|
|
11850
|
+
partial;
|
|
11851
|
+
constructor(message, reason, partial, url) {
|
|
11852
|
+
super(message, "server_error", { method: "POST", ...url === undefined ? {} : { url }, attempts: 1 });
|
|
11853
|
+
this.reason = reason;
|
|
11854
|
+
this.partial = partial;
|
|
12023
11855
|
}
|
|
12024
|
-
|
|
12025
|
-
|
|
12026
|
-
const exact = { ...params.exactSearch ?? {} };
|
|
12027
|
-
if (params.bookId !== undefined)
|
|
12028
|
-
exact["book_id"] = params.bookId;
|
|
12029
|
-
if (params.kind !== undefined)
|
|
12030
|
-
exact["kind"] = typeof params.kind === "string" ? params.kind : [...params.kind];
|
|
12031
|
-
const modifiers = {};
|
|
12032
|
-
if (at)
|
|
12033
|
-
modifiers["page"] = pageModifier(at.page, at.pageSize);
|
|
12034
|
-
if (params.order !== undefined)
|
|
12035
|
-
modifiers["order"] = params.order;
|
|
12036
|
-
return {
|
|
12037
|
-
...Object.keys(search).length > 0 ? { search } : {},
|
|
12038
|
-
...Object.keys(exact).length > 0 ? { exact_search: exact } : {},
|
|
12039
|
-
...Object.keys(modifiers).length > 0 ? { modifiers } : {}
|
|
12040
|
-
};
|
|
11856
|
+
toJSON() {
|
|
11857
|
+
return { ...super.toJSON(), reason: this.reason, partialLength: this.partial.length };
|
|
12041
11858
|
}
|
|
12042
11859
|
}
|
|
11860
|
+
function isBookChatBusy(error) {
|
|
11861
|
+
return error instanceof OmsApiError && error.status === 503;
|
|
11862
|
+
}
|
|
11863
|
+
function bookChatIsIncremental() {
|
|
11864
|
+
return supportsResponseStreaming();
|
|
11865
|
+
}
|
|
12043
11866
|
|
|
12044
11867
|
class BookChatNamespace extends Resource {
|
|
12045
11868
|
async* stream(bookId, input, options = {}) {
|
|
@@ -12090,6 +11913,68 @@ class BookChatNamespace extends Resource {
|
|
|
12090
11913
|
}
|
|
12091
11914
|
}
|
|
12092
11915
|
|
|
11916
|
+
// src/resources/library/shelves.ts
|
|
11917
|
+
var BOOK_SHELF_NAME_MAX_LENGTH = 120;
|
|
11918
|
+
var BOOK_SHELF_DESCRIPTION_MAX_LENGTH = 1000;
|
|
11919
|
+
var BOOK_SHELVES_MAX_PER_USER = 100;
|
|
11920
|
+
var BOOK_SHELF_FILTER_COLUMNS = Object.freeze(["user_id", "visibility"]);
|
|
11921
|
+
|
|
11922
|
+
class LibraryShelvesNamespace extends Resource {
|
|
11923
|
+
async list(params = {}, options = {}) {
|
|
11924
|
+
const base = {
|
|
11925
|
+
exactSearch: { user_id: params.userId, visibility: params.visibility, id: params.ids }
|
|
11926
|
+
};
|
|
11927
|
+
return paginate(params, 100, (at) => this.http.get("/book_shelves", { ...options, query: listQuery(params, at, base) }));
|
|
11928
|
+
}
|
|
11929
|
+
async get(id, options = {}) {
|
|
11930
|
+
return this.http.get(`/book_shelves/${idSegment(id)}`, options);
|
|
11931
|
+
}
|
|
11932
|
+
async create(input, options = {}) {
|
|
11933
|
+
const body = { name: input.name };
|
|
11934
|
+
if (input.description !== undefined)
|
|
11935
|
+
body["description"] = input.description;
|
|
11936
|
+
if (input.visibility !== undefined)
|
|
11937
|
+
body["visibility"] = input.visibility;
|
|
11938
|
+
return this.http.post("/book_shelves", body, options);
|
|
11939
|
+
}
|
|
11940
|
+
async update(id, input, options = {}) {
|
|
11941
|
+
const body = {};
|
|
11942
|
+
if (input.name !== undefined)
|
|
11943
|
+
body["name"] = input.name;
|
|
11944
|
+
if (input.description !== undefined)
|
|
11945
|
+
body["description"] = input.description;
|
|
11946
|
+
if (input.visibility !== undefined)
|
|
11947
|
+
body["visibility"] = input.visibility;
|
|
11948
|
+
if (input.position !== undefined)
|
|
11949
|
+
body["position"] = input.position;
|
|
11950
|
+
return this.http.patch(`/book_shelves/${idSegment(id)}`, body, options);
|
|
11951
|
+
}
|
|
11952
|
+
async delete(id, options = {}) {
|
|
11953
|
+
await this.http.delete(`/book_shelves/${idSegment(id)}`, options);
|
|
11954
|
+
}
|
|
11955
|
+
async addBook(id, bookId, options = {}) {
|
|
11956
|
+
return this.http.post(`/book_shelves/${idSegment(id)}/add_book`, { book_id: bookId }, options);
|
|
11957
|
+
}
|
|
11958
|
+
async removeBook(id, bookId, options = {}) {
|
|
11959
|
+
return this.http.delete(`/book_shelves/${idSegment(id)}/remove_book`, {
|
|
11960
|
+
...options,
|
|
11961
|
+
query: { ...options.query, book_id: bookId }
|
|
11962
|
+
});
|
|
11963
|
+
}
|
|
11964
|
+
async reorder(id, bookIds, options = {}) {
|
|
11965
|
+
if (bookIds.length === 0) {
|
|
11966
|
+
throw new TypeError("reorder needs the complete list of book ids in their new order. An empty list is a 400 server-side, and a " + "PARTIAL list is worse than an error: the books you left out keep their old positions and collide with the new ones.");
|
|
11967
|
+
}
|
|
11968
|
+
return this.http.post(`/book_shelves/${idSegment(id)}/reorder`, { book_ids: [...bookIds] }, options);
|
|
11969
|
+
}
|
|
11970
|
+
}
|
|
11971
|
+
|
|
11972
|
+
// src/resources/library/types.ts
|
|
11973
|
+
var BOOK_FORMATS = ["pdf", "epub"];
|
|
11974
|
+
var BOOK_VISIBILITIES = ["private", "unlisted", "public"];
|
|
11975
|
+
var BOOK_ANNOTATION_KINDS = ["highlight", "note", "bookmark", "progress"];
|
|
11976
|
+
|
|
11977
|
+
// src/resources/library/index.ts
|
|
12093
11978
|
class LibraryNamespace extends Resource {
|
|
12094
11979
|
books = new LibraryBooksNamespace(this.http);
|
|
12095
11980
|
shelves = new LibraryShelvesNamespace(this.http);
|
|
@@ -12248,38 +12133,16 @@ async function tokenOf(http) {
|
|
|
12248
12133
|
}
|
|
12249
12134
|
}
|
|
12250
12135
|
|
|
12251
|
-
// src/resources/movies.ts
|
|
12252
|
-
var
|
|
12253
|
-
var
|
|
12254
|
-
var
|
|
12255
|
-
MOVIE_COLLECTION_MANUAL_KIND,
|
|
12256
|
-
MOVIE_COLLECTION_FAVORITES_KIND
|
|
12257
|
-
];
|
|
12136
|
+
// src/resources/movies/addons.ts
|
|
12137
|
+
var MOVIE_ADDON_FILTER_COLUMNS = Object.freeze(["user_id"]);
|
|
12138
|
+
var MOVIE_ADDON_GROUP_FILTER_COLUMNS = Object.freeze([]);
|
|
12139
|
+
var MOVIE_ADDON_GRANT_FILTER_COLUMNS = Object.freeze([]);
|
|
12258
12140
|
var MOVIE_ADDON_GROUP_NAME_MAX_LENGTH = 80;
|
|
12259
|
-
var MOVIE_WATCH_FINISHED_THRESHOLD = 0.95;
|
|
12260
|
-
var MOVIE_WATCH_BULK_LIMIT = 200;
|
|
12261
|
-
var MOVIE_WATCH_LIST_LIMIT = 500;
|
|
12262
|
-
function isSystemMovieCollection(collection) {
|
|
12263
|
-
return collection.kind !== MOVIE_COLLECTION_MANUAL_KIND;
|
|
12264
|
-
}
|
|
12265
|
-
function movieWatchFinished(position, duration) {
|
|
12266
|
-
if (!(duration > 0))
|
|
12267
|
-
return null;
|
|
12268
|
-
return position >= duration * MOVIE_WATCH_FINISHED_THRESHOLD;
|
|
12269
|
-
}
|
|
12270
12141
|
|
|
12271
12142
|
class MovieAddonGroupsNamespace extends Resource {
|
|
12272
12143
|
async list(params = {}, options = {}) {
|
|
12273
|
-
const
|
|
12274
|
-
|
|
12275
|
-
...options,
|
|
12276
|
-
query: {
|
|
12277
|
-
exact_search: { id: params.id },
|
|
12278
|
-
modifiers: { order: params.order, page: pageModifier(page, pageSize) }
|
|
12279
|
-
}
|
|
12280
|
-
});
|
|
12281
|
-
const first = resolvePageNumber(params.page);
|
|
12282
|
-
return createPage(await load({ page: first, pageSize: size }), first, size, load);
|
|
12144
|
+
const base = { exactSearch: { id: params.id } };
|
|
12145
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/movie_addon_groups", { ...options, query: listQuery(params, at, base) }));
|
|
12283
12146
|
}
|
|
12284
12147
|
async create(input, options = {}) {
|
|
12285
12148
|
const name = typeof input === "string" ? input : input.name;
|
|
@@ -12300,16 +12163,8 @@ class MovieAddonGroupsNamespace extends Resource {
|
|
|
12300
12163
|
|
|
12301
12164
|
class MovieAddonGrantsNamespace extends Resource {
|
|
12302
12165
|
async list(params = {}, options = {}) {
|
|
12303
|
-
const
|
|
12304
|
-
|
|
12305
|
-
...options,
|
|
12306
|
-
query: {
|
|
12307
|
-
exact_search: { id: params.id },
|
|
12308
|
-
modifiers: { order: params.order, page: pageModifier(page, pageSize) }
|
|
12309
|
-
}
|
|
12310
|
-
});
|
|
12311
|
-
const first = resolvePageNumber(params.page);
|
|
12312
|
-
return createPage(await load({ page: first, pageSize: size }), first, size, load);
|
|
12166
|
+
const base = { exactSearch: { id: params.id } };
|
|
12167
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/movie_addon_grants", { ...options, query: listQuery(params, at, base) }));
|
|
12313
12168
|
}
|
|
12314
12169
|
async create(input, options = {}) {
|
|
12315
12170
|
const addon = input.movie_addon_id ?? undefined;
|
|
@@ -12334,16 +12189,8 @@ class MovieAddonsNamespace extends Resource {
|
|
|
12334
12189
|
this.grants = new MovieAddonGrantsNamespace(http);
|
|
12335
12190
|
}
|
|
12336
12191
|
async list(params = {}, options = {}) {
|
|
12337
|
-
const
|
|
12338
|
-
|
|
12339
|
-
...options,
|
|
12340
|
-
query: {
|
|
12341
|
-
exact_search: { id: params.id, user_id: params.userId },
|
|
12342
|
-
modifiers: { order: params.order, page: pageModifier(page, pageSize) }
|
|
12343
|
-
}
|
|
12344
|
-
});
|
|
12345
|
-
const first = resolvePageNumber(params.page);
|
|
12346
|
-
return createPage(await load({ page: first, pageSize: size }), first, size, load);
|
|
12192
|
+
const base = { exactSearch: { id: params.id, user_id: params.userId } };
|
|
12193
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/movie_addons", { ...options, query: listQuery(params, at, base) }));
|
|
12347
12194
|
}
|
|
12348
12195
|
async create(input, options = {}) {
|
|
12349
12196
|
assertPresent("manifest_url", input.manifest_url);
|
|
@@ -12355,9 +12202,10 @@ class MovieAddonsNamespace extends Resource {
|
|
|
12355
12202
|
}, options);
|
|
12356
12203
|
}
|
|
12357
12204
|
async update(id, input, options = {}) {
|
|
12358
|
-
|
|
12205
|
+
if (input.manifest_json !== undefined)
|
|
12206
|
+
assertManifest(input.manifest_json);
|
|
12359
12207
|
return this.http.patch(`/movie_addons/${encodeURIComponent(id)}`, {
|
|
12360
|
-
manifest_json: input.manifest_json,
|
|
12208
|
+
...input.manifest_json === undefined ? {} : { manifest_json: input.manifest_json },
|
|
12361
12209
|
..."movie_addon_group_id" in input ? { movie_addon_group_id: input.movie_addon_group_id ?? null } : {},
|
|
12362
12210
|
...input.manifest_url === undefined ? {} : { manifest_url: input.manifest_url }
|
|
12363
12211
|
}, options);
|
|
@@ -12366,31 +12214,57 @@ class MovieAddonsNamespace extends Resource {
|
|
|
12366
12214
|
if (addon.shared) {
|
|
12367
12215
|
throw new OmsError("This addon was shared with you, not installed by you: only its owner can move it between groups.", "invalid_request");
|
|
12368
12216
|
}
|
|
12369
|
-
return this.update(addon.id, {
|
|
12217
|
+
return this.update(addon.id, { movie_addon_group_id: groupId }, options);
|
|
12370
12218
|
}
|
|
12371
12219
|
async delete(id, options = {}) {
|
|
12372
12220
|
await this.http.delete(`/movie_addons/${encodeURIComponent(id)}`, options);
|
|
12373
12221
|
}
|
|
12374
12222
|
}
|
|
12223
|
+
function assertManifest(manifest) {
|
|
12224
|
+
if (manifest === null || typeof manifest !== "object" || Array.isArray(manifest)) {
|
|
12225
|
+
throw new OmsError("manifest_json must be the fetched manifest object.", "invalid_request");
|
|
12226
|
+
}
|
|
12227
|
+
if (Object.keys(manifest).length === 0) {
|
|
12228
|
+
throw new OmsError("manifest_json cannot be empty: the server treats {} as blank and answers 400.", "invalid_request");
|
|
12229
|
+
}
|
|
12230
|
+
}
|
|
12231
|
+
|
|
12232
|
+
// src/resources/movies/collections.ts
|
|
12233
|
+
var MOVIE_COLLECTION_MANUAL_KIND = "manual";
|
|
12234
|
+
var MOVIE_COLLECTION_FAVORITES_KIND = "favorites";
|
|
12235
|
+
var MOVIE_COLLECTION_KINDS = [
|
|
12236
|
+
MOVIE_COLLECTION_MANUAL_KIND,
|
|
12237
|
+
MOVIE_COLLECTION_FAVORITES_KIND
|
|
12238
|
+
];
|
|
12239
|
+
var MOVIE_COLLECTION_FILTER_COLUMNS = Object.freeze(["id", "name", "kind", "created_at", "updated_at"]);
|
|
12240
|
+
var MOVIE_COLLECTION_ITEM_FILTER_COLUMNS = Object.freeze([
|
|
12241
|
+
"id",
|
|
12242
|
+
"movie_collection_id",
|
|
12243
|
+
"movie_type",
|
|
12244
|
+
"movie_id",
|
|
12245
|
+
"position",
|
|
12246
|
+
"created_at",
|
|
12247
|
+
"updated_at"
|
|
12248
|
+
]);
|
|
12249
|
+
function isSystemMovieCollection(collection) {
|
|
12250
|
+
return collection.kind !== MOVIE_COLLECTION_MANUAL_KIND;
|
|
12251
|
+
}
|
|
12375
12252
|
|
|
12376
12253
|
class MovieCollectionItemsNamespace extends Resource {
|
|
12377
|
-
async list(params = {}, options = {}) {
|
|
12378
|
-
const
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
|
|
12382
|
-
|
|
12383
|
-
|
|
12384
|
-
|
|
12385
|
-
movie_type: params.movieType,
|
|
12386
|
-
movie_id: params.movieId,
|
|
12387
|
-
position: params.position
|
|
12388
|
-
},
|
|
12389
|
-
modifiers: { order: params.order, page: pageModifier(page, pageSize) }
|
|
12254
|
+
async list(params = {}, options = {}) {
|
|
12255
|
+
const base = {
|
|
12256
|
+
exactSearch: {
|
|
12257
|
+
id: params.id,
|
|
12258
|
+
movie_collection_id: params.collectionId,
|
|
12259
|
+
movie_type: params.movieType,
|
|
12260
|
+
movie_id: params.movieId,
|
|
12261
|
+
position: params.position
|
|
12390
12262
|
}
|
|
12391
|
-
}
|
|
12392
|
-
|
|
12393
|
-
|
|
12263
|
+
};
|
|
12264
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/movie_collection_items", {
|
|
12265
|
+
...options,
|
|
12266
|
+
query: listQuery(params, at, base)
|
|
12267
|
+
}));
|
|
12394
12268
|
}
|
|
12395
12269
|
async create(input, options = {}) {
|
|
12396
12270
|
assertPresent("movie_collection_id", input.movie_collection_id);
|
|
@@ -12415,17 +12289,8 @@ class MovieCollectionsNamespace extends Resource {
|
|
|
12415
12289
|
this.items = new MovieCollectionItemsNamespace(http);
|
|
12416
12290
|
}
|
|
12417
12291
|
async list(params = {}, options = {}) {
|
|
12418
|
-
const
|
|
12419
|
-
|
|
12420
|
-
...options,
|
|
12421
|
-
query: {
|
|
12422
|
-
search: { name: params.name },
|
|
12423
|
-
exact_search: { id: idFilter(params.id), kind: params.kind },
|
|
12424
|
-
modifiers: { order: params.order, page: pageModifier(page, pageSize) }
|
|
12425
|
-
}
|
|
12426
|
-
});
|
|
12427
|
-
const first = resolvePageNumber(params.page);
|
|
12428
|
-
return createPage(await load({ page: first, pageSize: size }), first, size, load);
|
|
12292
|
+
const base = { search: { name: params.name }, exactSearch: { id: params.id, kind: params.kind } };
|
|
12293
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/movie_collections", { ...options, query: listQuery(params, at, base) }));
|
|
12429
12294
|
}
|
|
12430
12295
|
async favorites(options = {}) {
|
|
12431
12296
|
const page = await this.list({ kind: MOVIE_COLLECTION_FAVORITES_KIND, pageSize: 1 }, options);
|
|
@@ -12450,6 +12315,16 @@ class MovieCollectionsNamespace extends Resource {
|
|
|
12450
12315
|
}
|
|
12451
12316
|
}
|
|
12452
12317
|
|
|
12318
|
+
// src/resources/movies/watchProgress.ts
|
|
12319
|
+
var MOVIE_WATCH_FINISHED_THRESHOLD = 0.95;
|
|
12320
|
+
var MOVIE_WATCH_BULK_LIMIT = 200;
|
|
12321
|
+
var MOVIE_WATCH_LIST_LIMIT = 500;
|
|
12322
|
+
function movieWatchFinished(position, duration) {
|
|
12323
|
+
if (!(duration > 0))
|
|
12324
|
+
return null;
|
|
12325
|
+
return position >= duration * MOVIE_WATCH_FINISHED_THRESHOLD;
|
|
12326
|
+
}
|
|
12327
|
+
|
|
12453
12328
|
class MovieWatchProgressesNamespace extends Resource {
|
|
12454
12329
|
async list(options = {}) {
|
|
12455
12330
|
return this.http.get("/movie_watch_progresses", options);
|
|
@@ -12480,32 +12355,6 @@ class MovieWatchProgressesNamespace extends Resource {
|
|
|
12480
12355
|
});
|
|
12481
12356
|
}
|
|
12482
12357
|
}
|
|
12483
|
-
|
|
12484
|
-
class MoviesNamespace extends Resource {
|
|
12485
|
-
addons;
|
|
12486
|
-
collections;
|
|
12487
|
-
watchProgress;
|
|
12488
|
-
constructor(http) {
|
|
12489
|
-
super(http);
|
|
12490
|
-
this.addons = new MovieAddonsNamespace(http);
|
|
12491
|
-
this.collections = new MovieCollectionsNamespace(http);
|
|
12492
|
-
this.watchProgress = new MovieWatchProgressesNamespace(http);
|
|
12493
|
-
}
|
|
12494
|
-
}
|
|
12495
|
-
function idFilter(value) {
|
|
12496
|
-
if (value === undefined)
|
|
12497
|
-
return;
|
|
12498
|
-
return typeof value === "string" ? value : [...value];
|
|
12499
|
-
}
|
|
12500
|
-
function pickOptional(source, keys) {
|
|
12501
|
-
const out = {};
|
|
12502
|
-
for (const key of keys) {
|
|
12503
|
-
const value = source[key];
|
|
12504
|
-
if (value !== undefined)
|
|
12505
|
-
out[key] = value;
|
|
12506
|
-
}
|
|
12507
|
-
return out;
|
|
12508
|
-
}
|
|
12509
12358
|
function watchProgressBody(input) {
|
|
12510
12359
|
assertPresent("movie_type", input.movie_type);
|
|
12511
12360
|
assertPresent("movie_id", input.movie_id);
|
|
@@ -12529,17 +12378,17 @@ function watchProgressBody(input) {
|
|
|
12529
12378
|
body.finished = input.finished;
|
|
12530
12379
|
return body;
|
|
12531
12380
|
}
|
|
12532
|
-
|
|
12533
|
-
|
|
12534
|
-
|
|
12535
|
-
|
|
12536
|
-
|
|
12537
|
-
|
|
12538
|
-
|
|
12539
|
-
|
|
12540
|
-
|
|
12541
|
-
|
|
12542
|
-
|
|
12381
|
+
|
|
12382
|
+
// src/resources/movies/index.ts
|
|
12383
|
+
class MoviesNamespace extends Resource {
|
|
12384
|
+
addons;
|
|
12385
|
+
collections;
|
|
12386
|
+
watchProgress;
|
|
12387
|
+
constructor(http) {
|
|
12388
|
+
super(http);
|
|
12389
|
+
this.addons = new MovieAddonsNamespace(http);
|
|
12390
|
+
this.collections = new MovieCollectionsNamespace(http);
|
|
12391
|
+
this.watchProgress = new MovieWatchProgressesNamespace(http);
|
|
12543
12392
|
}
|
|
12544
12393
|
}
|
|
12545
12394
|
|
|
@@ -12552,6 +12401,7 @@ var ARTIST_IMAGE_CONTENT_TYPES = [
|
|
|
12552
12401
|
"image/webp",
|
|
12553
12402
|
"image/gif"
|
|
12554
12403
|
];
|
|
12404
|
+
var ARTIST_FILTER_COLUMNS = Object.freeze(["id", "name", "slug", "canonical_name", "created_at"]);
|
|
12555
12405
|
var ARTIST_IMPORT_STATES = ["queued", "running", "complete", "failed"];
|
|
12556
12406
|
var ARTIST_IMPORT_POLL_INTERVAL_MS = 1500;
|
|
12557
12407
|
function isArtistImportTerminal(state) {
|
|
@@ -12567,7 +12417,7 @@ class MusicArtistImportsNamespace extends Resource {
|
|
|
12567
12417
|
});
|
|
12568
12418
|
}
|
|
12569
12419
|
async albums(spotifyArtistId, options = {}) {
|
|
12570
|
-
|
|
12420
|
+
assertPresent("spotifyArtistId", spotifyArtistId);
|
|
12571
12421
|
const body = await this.http.get("/artist_imports/albums", {
|
|
12572
12422
|
timeoutMs: 60000,
|
|
12573
12423
|
...options,
|
|
@@ -12576,7 +12426,7 @@ class MusicArtistImportsNamespace extends Resource {
|
|
|
12576
12426
|
return body.items ?? [];
|
|
12577
12427
|
}
|
|
12578
12428
|
async create(input, options = {}) {
|
|
12579
|
-
|
|
12429
|
+
assertPresent("spotifyArtistId", input.spotifyArtistId);
|
|
12580
12430
|
if (input.albumIds.length === 0) {
|
|
12581
12431
|
throw new OmsError('albumIds is empty. An import with no albums is rejected by the server with 400 "album_ids required".', "invalid_request");
|
|
12582
12432
|
}
|
|
@@ -12601,7 +12451,7 @@ class MusicArtistSyncsNamespace extends Resource {
|
|
|
12601
12451
|
return body.items ?? [];
|
|
12602
12452
|
}
|
|
12603
12453
|
async create(input, options = {}) {
|
|
12604
|
-
|
|
12454
|
+
assertPresent("spotifyArtistId", input.spotifyArtistId);
|
|
12605
12455
|
return this.http.post("/artist_syncs", {
|
|
12606
12456
|
spotify_artist_id: input.spotifyArtistId,
|
|
12607
12457
|
spotify_artist_name: input.spotifyArtistName ?? ""
|
|
@@ -12621,10 +12471,11 @@ class MusicArtistsNamespace extends Resource {
|
|
|
12621
12471
|
this.syncs = new MusicArtistSyncsNamespace(http);
|
|
12622
12472
|
}
|
|
12623
12473
|
async list(params = {}, options = {}) {
|
|
12624
|
-
const
|
|
12625
|
-
|
|
12626
|
-
|
|
12627
|
-
|
|
12474
|
+
const base = {
|
|
12475
|
+
search: { name: params.name },
|
|
12476
|
+
exactSearch: { slug: params.slug, canonical_name: params.canonicalName }
|
|
12477
|
+
};
|
|
12478
|
+
return paginate(params, ARTIST_ROSTER_PAGE_SIZE, (at) => this.http.get("/artists", { ...options, query: listQuery(params, at, base) }));
|
|
12628
12479
|
}
|
|
12629
12480
|
async get(idOrSlug, options = {}) {
|
|
12630
12481
|
return this.http.get(`/artists/${encodeURIComponent(String(idOrSlug))}`, options);
|
|
@@ -12652,18 +12503,6 @@ class MusicArtistsNamespace extends Resource {
|
|
|
12652
12503
|
return this.http.postForm(`/artists/${id}/upload_banner`, { banner }, { retry: false, ...options });
|
|
12653
12504
|
}
|
|
12654
12505
|
}
|
|
12655
|
-
function artistQuery(params, page, pageSize) {
|
|
12656
|
-
return {
|
|
12657
|
-
search: { name: params.name },
|
|
12658
|
-
exact_search: { slug: params.slug, canonical_name: params.canonicalName },
|
|
12659
|
-
modifiers: { order: params.order, page: pageModifier(page, pageSize) }
|
|
12660
|
-
};
|
|
12661
|
-
}
|
|
12662
|
-
function assertPresent2(field, value) {
|
|
12663
|
-
if (typeof value !== "string" || value.trim().length === 0) {
|
|
12664
|
-
throw new OmsError(`${field} is required and cannot be blank.`, "invalid_request");
|
|
12665
|
-
}
|
|
12666
|
-
}
|
|
12667
12506
|
function assertImageSize(field, file2) {
|
|
12668
12507
|
const size = fileSize(file2);
|
|
12669
12508
|
if (size !== undefined && size > ARTIST_IMAGE_MAX_BYTES) {
|
|
@@ -12728,28 +12567,10 @@ class MusicImportsNamespace extends Resource {
|
|
|
12728
12567
|
this.srMachine = new SRMachineNamespace(http);
|
|
12729
12568
|
}
|
|
12730
12569
|
async list(params = {}, options = {}) {
|
|
12731
|
-
const
|
|
12732
|
-
|
|
12733
|
-
|
|
12734
|
-
|
|
12735
|
-
if (params.playlistId !== undefined)
|
|
12736
|
-
search["playlist_id"] = asFilter2(params.playlistId);
|
|
12737
|
-
if (params.userId !== undefined)
|
|
12738
|
-
search["user_id"] = params.userId;
|
|
12739
|
-
if (params.id !== undefined)
|
|
12740
|
-
search["id"] = asFilter2(params.id);
|
|
12741
|
-
const load = async (page) => await this.http.get("/song_imports", {
|
|
12742
|
-
...options,
|
|
12743
|
-
query: {
|
|
12744
|
-
...Object.keys(search).length > 0 ? { search } : {},
|
|
12745
|
-
modifiers: {
|
|
12746
|
-
page: pageModifier(page.page, page.pageSize),
|
|
12747
|
-
...params.order === undefined ? {} : { order: params.order }
|
|
12748
|
-
}
|
|
12749
|
-
}
|
|
12750
|
-
}) ?? [];
|
|
12751
|
-
const first = params.page ?? 1;
|
|
12752
|
-
return createPage(await load({ page: first, pageSize }), first, pageSize, load);
|
|
12570
|
+
const base = {
|
|
12571
|
+
exactSearch: { state: params.state, playlist_id: params.playlistId, user_id: params.userId, id: params.id }
|
|
12572
|
+
};
|
|
12573
|
+
return paginate(params, 100, (at) => this.http.get("/song_imports", { ...options, query: listQuery(params, at, base) }));
|
|
12753
12574
|
}
|
|
12754
12575
|
async get(id, options = {}) {
|
|
12755
12576
|
return this.http.get(`/song_imports/${encodeURIComponent(String(id))}`, options);
|
|
@@ -12920,9 +12741,6 @@ function createBody(input, sourceUrl) {
|
|
|
12920
12741
|
put("position", input.position);
|
|
12921
12742
|
return body;
|
|
12922
12743
|
}
|
|
12923
|
-
function asFilter2(value) {
|
|
12924
|
-
return Array.isArray(value) ? [...value] : value;
|
|
12925
|
-
}
|
|
12926
12744
|
function requestPartOf2(options) {
|
|
12927
12745
|
return {
|
|
12928
12746
|
...options.signal === undefined ? {} : { signal: options.signal },
|
|
@@ -12949,6 +12767,17 @@ var MIX_KINDS = [
|
|
|
12949
12767
|
"time_capsule",
|
|
12950
12768
|
"discoveries"
|
|
12951
12769
|
];
|
|
12770
|
+
var PLAYLIST_FILTER_COLUMNS = Object.freeze(["id", "name", "created_at", "updated_at"]);
|
|
12771
|
+
var PLAYLIST_SONG_FILTER_COLUMNS = Object.freeze([
|
|
12772
|
+
"id",
|
|
12773
|
+
"playlist_id",
|
|
12774
|
+
"song_id",
|
|
12775
|
+
"position",
|
|
12776
|
+
"origin",
|
|
12777
|
+
"hidden",
|
|
12778
|
+
"created_at",
|
|
12779
|
+
"updated_at"
|
|
12780
|
+
]);
|
|
12952
12781
|
function isSystemPlaylist(playlist) {
|
|
12953
12782
|
return playlist.source_kind != null && playlist.source_kind !== "manual";
|
|
12954
12783
|
}
|
|
@@ -12972,11 +12801,8 @@ class MusicPlaylistsNamespace extends Resource {
|
|
|
12972
12801
|
this.plays = new PlayEventsNamespace(http);
|
|
12973
12802
|
}
|
|
12974
12803
|
async list(params = {}, options = {}) {
|
|
12975
|
-
const
|
|
12976
|
-
|
|
12977
|
-
const order = params.order ?? "created_at:desc";
|
|
12978
|
-
const load = (at) => this.fetchPage({ ...at, order, ...params }, options);
|
|
12979
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
12804
|
+
const base = { order: "created_at:desc", search: { name: params.name }, exactSearch: { id: params.ids } };
|
|
12805
|
+
return paginate(params, 100, (at) => this.http.get("/playlists", { ...options, query: listQuery(params, at, base) }));
|
|
12980
12806
|
}
|
|
12981
12807
|
async get(id, options = {}) {
|
|
12982
12808
|
return this.http.get(`/playlists/${encodeURIComponent(String(id))}`, options);
|
|
@@ -13016,24 +12842,24 @@ class MusicPlaylistsNamespace extends Resource {
|
|
|
13016
12842
|
async uploadArtwork(id, artwork, options = {}) {
|
|
13017
12843
|
return this.http.postForm(`/playlists/${encodeURIComponent(String(id))}/upload_artwork`, { artwork }, options);
|
|
13018
12844
|
}
|
|
13019
|
-
async fetchPage(at, options) {
|
|
13020
|
-
const query = {
|
|
13021
|
-
modifiers: { page: pageModifier(at.page, at.pageSize), order: at.order },
|
|
13022
|
-
...at.name === undefined ? {} : { search: { name: at.name } },
|
|
13023
|
-
...at.ids === undefined ? {} : { exact_search: { id: [...at.ids] } }
|
|
13024
|
-
};
|
|
13025
|
-
const items = await this.http.get("/playlists", { ...options, query });
|
|
13026
|
-
return items ?? [];
|
|
13027
|
-
}
|
|
13028
12845
|
}
|
|
13029
12846
|
|
|
13030
12847
|
class PlaylistSongsNamespace extends Resource {
|
|
13031
12848
|
async list(params = {}, options = {}) {
|
|
13032
|
-
const
|
|
13033
|
-
|
|
13034
|
-
|
|
13035
|
-
|
|
13036
|
-
|
|
12849
|
+
const base = {
|
|
12850
|
+
order: "position:asc",
|
|
12851
|
+
exactSearch: {
|
|
12852
|
+
playlist_id: params.playlistId,
|
|
12853
|
+
song_id: params.songId,
|
|
12854
|
+
id: params.ids,
|
|
12855
|
+
origin: params.origin,
|
|
12856
|
+
hidden: params.hidden
|
|
12857
|
+
}
|
|
12858
|
+
};
|
|
12859
|
+
return paginate(params, 100, (at) => this.http.get("/playlist_songs", {
|
|
12860
|
+
...options,
|
|
12861
|
+
query: listQuery(params, at, base)
|
|
12862
|
+
}));
|
|
13037
12863
|
}
|
|
13038
12864
|
async add(playlistId, songId, options = {}) {
|
|
13039
12865
|
return this.http.post("/playlist_songs", { playlist_id: playlistId, song_id: songId }, options);
|
|
@@ -13047,34 +12873,12 @@ class PlaylistSongsNamespace extends Resource {
|
|
|
13047
12873
|
async unhide(rowId, options = {}) {
|
|
13048
12874
|
return this.http.post(`/playlist_songs/${encodeURIComponent(String(rowId))}/unhide`, undefined, options);
|
|
13049
12875
|
}
|
|
13050
|
-
async fetchPage(at, options) {
|
|
13051
|
-
const exact = {};
|
|
13052
|
-
if (at.playlistId !== undefined)
|
|
13053
|
-
exact["playlist_id"] = at.playlistId;
|
|
13054
|
-
if (at.songId !== undefined)
|
|
13055
|
-
exact["song_id"] = at.songId;
|
|
13056
|
-
if (at.ids !== undefined)
|
|
13057
|
-
exact["id"] = [...at.ids];
|
|
13058
|
-
if (at.origin !== undefined)
|
|
13059
|
-
exact["origin"] = at.origin;
|
|
13060
|
-
if (at.hidden !== undefined)
|
|
13061
|
-
exact["hidden"] = at.hidden;
|
|
13062
|
-
const query = {
|
|
13063
|
-
modifiers: { page: pageModifier(at.page, at.pageSize), order: at.order },
|
|
13064
|
-
...Object.keys(exact).length === 0 ? {} : { exact_search: exact }
|
|
13065
|
-
};
|
|
13066
|
-
const items = await this.http.get("/playlist_songs", {
|
|
13067
|
-
...options,
|
|
13068
|
-
query
|
|
13069
|
-
});
|
|
13070
|
-
return items ?? [];
|
|
13071
|
-
}
|
|
13072
12876
|
}
|
|
13073
12877
|
|
|
13074
12878
|
class MusicMixesNamespace extends Resource {
|
|
13075
12879
|
async list(options = {}) {
|
|
13076
|
-
const
|
|
13077
|
-
return
|
|
12880
|
+
const items2 = await this.http.get("/music_mixes", options);
|
|
12881
|
+
return items2 ?? [];
|
|
13078
12882
|
}
|
|
13079
12883
|
async get(slug, options = {}) {
|
|
13080
12884
|
return this.http.get(`/music_mixes/${encodeURIComponent(slug)}`, options);
|
|
@@ -13452,10 +13256,7 @@ function songArtistsLine(song, includeWith = false) {
|
|
|
13452
13256
|
|
|
13453
13257
|
class MusicSongsNamespace extends Resource {
|
|
13454
13258
|
async list(params = {}, options = {}) {
|
|
13455
|
-
|
|
13456
|
-
const pageSize = params.pageSize ?? 100;
|
|
13457
|
-
const load = (at) => this.http.get("/songs", { ...options, query: this.songQuery(params, at) }).then((rows) => rows ?? []);
|
|
13458
|
-
return createPage(await load({ page, pageSize }), page, pageSize, load);
|
|
13259
|
+
return paginate(params, 100, (at) => this.http.get("/songs", { ...options, query: this.songQuery(params, at) }));
|
|
13459
13260
|
}
|
|
13460
13261
|
async get(id, options = {}) {
|
|
13461
13262
|
return this.http.get(`/songs/${encodeURIComponent(String(id))}`, options);
|
|
@@ -13581,33 +13382,12 @@ class MusicSongsNamespace extends Resource {
|
|
|
13581
13382
|
return this.http.get(`/artist_metadata/${encodeURIComponent(name)}`, options);
|
|
13582
13383
|
}
|
|
13583
13384
|
songQuery(params, at) {
|
|
13584
|
-
|
|
13585
|
-
|
|
13586
|
-
search
|
|
13587
|
-
|
|
13588
|
-
|
|
13589
|
-
|
|
13590
|
-
if (params.year !== undefined)
|
|
13591
|
-
exact["year"] = params.year;
|
|
13592
|
-
if (params.ids !== undefined)
|
|
13593
|
-
exact["id"] = params.ids;
|
|
13594
|
-
if (params.artist !== undefined)
|
|
13595
|
-
exact["artist"] = params.artist;
|
|
13596
|
-
const modifiers = {};
|
|
13597
|
-
if (at)
|
|
13598
|
-
modifiers["page"] = pageModifier(at.page, at.pageSize);
|
|
13599
|
-
if (params.order !== undefined)
|
|
13600
|
-
modifiers["order"] = params.order;
|
|
13601
|
-
else if (at)
|
|
13602
|
-
modifiers["order"] = "created_at:asc";
|
|
13603
|
-
if (params.random)
|
|
13604
|
-
modifiers["random"] = true;
|
|
13605
|
-
return {
|
|
13606
|
-
...Object.keys(search).length > 0 ? { search } : {},
|
|
13607
|
-
...Object.keys(exact).length > 0 ? { exact_search: exact } : {},
|
|
13608
|
-
...Object.keys(modifiers).length > 0 ? { modifiers } : {},
|
|
13609
|
-
...params.artistRole === undefined ? {} : { artist_role: params.artistRole }
|
|
13610
|
-
};
|
|
13385
|
+
return listQuery(params, at, {
|
|
13386
|
+
order: at === undefined ? undefined : "created_at:asc",
|
|
13387
|
+
search: { title: params.title },
|
|
13388
|
+
exactSearch: { album: params.album, year: params.year, id: params.ids, artist: params.artist },
|
|
13389
|
+
top: params.artistRole === undefined ? {} : { artist_role: params.artistRole }
|
|
13390
|
+
});
|
|
13611
13391
|
}
|
|
13612
13392
|
updateBody(input) {
|
|
13613
13393
|
const body = {};
|
|
@@ -14096,158 +13876,58 @@ class RealtimeNamespace extends Resource {
|
|
|
14096
13876
|
}
|
|
14097
13877
|
}
|
|
14098
13878
|
|
|
14099
|
-
// src/resources/social.ts
|
|
14100
|
-
var MESSAGE_CONTENT_MAX_LENGTH = 1024;
|
|
14101
|
-
var GROUP_CHAT_MESSAGE_CONTENT_MAX_LENGTH = 4000;
|
|
14102
|
-
var GROUP_CHAT_NAME_MAX_LENGTH = 120;
|
|
13879
|
+
// src/resources/social/types.ts
|
|
14103
13880
|
var MESSAGE_ATTACHMENT_MAX_BYTES = 25 * 1024 * 1024;
|
|
14104
|
-
var MESSAGE_IMAGE_MAX_BYTES = 20 * 1024 * 1024;
|
|
14105
|
-
var MESSAGE_IMAGE_MAX_DIMENSION_PX = 12000;
|
|
14106
|
-
var MESSAGE_IMAGE_MAX_PIXELS = 50000000;
|
|
14107
13881
|
var MESSAGE_EDIT_WINDOW_MS = 15 * 60 * 1000;
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
groupChats;
|
|
14114
|
-
constructor(http) {
|
|
14115
|
-
super(http);
|
|
14116
|
-
this.messages = new DirectMessagesNamespace(http);
|
|
14117
|
-
this.relationships = new RelationshipsNamespace(http);
|
|
14118
|
-
this.groupChats = new GroupChatsNamespace(http);
|
|
14119
|
-
}
|
|
13882
|
+
function canEditMessage(message, now = new Date().getTime()) {
|
|
13883
|
+
const created = new Date(message.created_at).getTime();
|
|
13884
|
+
if (Number.isNaN(created))
|
|
13885
|
+
return false;
|
|
13886
|
+
return now - created <= MESSAGE_EDIT_WINDOW_MS;
|
|
14120
13887
|
}
|
|
14121
13888
|
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
return
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
return
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
|
|
14135
|
-
|
|
14136
|
-
return this.http.get(`/messages/${encodeURIComponent(String(id))}`, options);
|
|
14137
|
-
}
|
|
14138
|
-
async send(input, options = {}) {
|
|
14139
|
-
assertPresent3("receiverId", input.receiverId);
|
|
14140
|
-
const content = input.content ?? "";
|
|
14141
|
-
if (content.length === 0 && input.attachment === undefined) {
|
|
14142
|
-
throw new OmsError("A message needs content or an attachment: `content` is NOT NULL with a presence validation, and the " + "server would answer 400.", "invalid_request");
|
|
14143
|
-
}
|
|
14144
|
-
if (content.length > MESSAGE_CONTENT_MAX_LENGTH) {
|
|
14145
|
-
throw new OmsError(`content is ${content.length} characters; Message validates it at ${MESSAGE_CONTENT_MAX_LENGTH}.`, "invalid_request");
|
|
14146
|
-
}
|
|
14147
|
-
if (input.attachment === undefined) {
|
|
14148
|
-
return this.http.post("/messages", {
|
|
14149
|
-
receiver_id: input.receiverId,
|
|
14150
|
-
content,
|
|
14151
|
-
...input.quotedMessageId === undefined ? {} : { quoted_message_id: input.quotedMessageId }
|
|
14152
|
-
}, options);
|
|
14153
|
-
}
|
|
14154
|
-
assertAttachmentSize("attachment", input.attachment);
|
|
14155
|
-
return this.http.postForm("/messages", {
|
|
14156
|
-
receiver_id: input.receiverId,
|
|
14157
|
-
content,
|
|
14158
|
-
attachment: input.attachment,
|
|
14159
|
-
...input.quotedMessageId === undefined ? {} : { quoted_message_id: input.quotedMessageId }
|
|
14160
|
-
}, options);
|
|
14161
|
-
}
|
|
14162
|
-
async edit(id, content, options = {}) {
|
|
14163
|
-
if (content.length > MESSAGE_CONTENT_MAX_LENGTH) {
|
|
14164
|
-
throw new OmsError(`content is ${content.length} characters; Message validates it at ${MESSAGE_CONTENT_MAX_LENGTH}.`, "invalid_request");
|
|
14165
|
-
}
|
|
14166
|
-
return this.http.patch(`/messages/${encodeURIComponent(String(id))}`, { content }, options);
|
|
14167
|
-
}
|
|
14168
|
-
async delete(id, options = {}) {
|
|
14169
|
-
await this.http.delete(`/messages/${encodeURIComponent(String(id))}`, options);
|
|
14170
|
-
}
|
|
14171
|
-
async attachment(id, options = {}) {
|
|
14172
|
-
const path = `/messages/${encodeURIComponent(String(id))}/attachment`;
|
|
14173
|
-
return followAttachment(this.http, path, "message", options);
|
|
14174
|
-
}
|
|
14175
|
-
async attachmentUrl(id) {
|
|
14176
|
-
const token = await tokenOf2(this.http);
|
|
14177
|
-
const path = `/messages/${encodeURIComponent(String(id))}/attachment`;
|
|
14178
|
-
return this.http.url(path, token === null ? undefined : { token });
|
|
14179
|
-
}
|
|
13889
|
+
// src/internal/attachments.ts
|
|
13890
|
+
function attachmentSize(file2) {
|
|
13891
|
+
if (isNativeFile(file2))
|
|
13892
|
+
return file2.size;
|
|
13893
|
+
if (typeof file2.size === "number")
|
|
13894
|
+
return file2.size;
|
|
13895
|
+
const data = file2.data;
|
|
13896
|
+
if (isNativeFile(data))
|
|
13897
|
+
return data.size;
|
|
13898
|
+
if (typeof Blob === "function" && data instanceof Blob)
|
|
13899
|
+
return data.size;
|
|
13900
|
+
if (data instanceof Uint8Array)
|
|
13901
|
+
return data.byteLength;
|
|
13902
|
+
return;
|
|
14180
13903
|
}
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
|
|
14187
|
-
|
|
14188
|
-
});
|
|
14189
|
-
const first = resolvePageNumber(params.page);
|
|
14190
|
-
return createPage(await load({ page: first, pageSize: size }), first, size, load);
|
|
14191
|
-
}
|
|
14192
|
-
async all(params = {}, limit = 2000, options = {}) {
|
|
14193
|
-
const rows = [];
|
|
14194
|
-
let page = await this.list({ ...params, pageSize: MAX_PAGE_SIZE }, options);
|
|
14195
|
-
for (;; ) {
|
|
14196
|
-
rows.push(...page.items);
|
|
14197
|
-
if (rows.length >= limit)
|
|
14198
|
-
break;
|
|
14199
|
-
const next = await page.next();
|
|
14200
|
-
if (next === null)
|
|
14201
|
-
break;
|
|
14202
|
-
page = next;
|
|
14203
|
-
}
|
|
14204
|
-
return rows.slice(0, limit);
|
|
14205
|
-
}
|
|
14206
|
-
async friends(selfId, options = {}) {
|
|
14207
|
-
const rows = await this.all({ userId: selfId }, 2000, options);
|
|
14208
|
-
const seen = new Set;
|
|
14209
|
-
const out = [];
|
|
14210
|
-
for (const row of rows) {
|
|
14211
|
-
if (row.kind !== "friend" || row.status !== "accepted")
|
|
14212
|
-
continue;
|
|
14213
|
-
const other = counterpart(row, selfId);
|
|
14214
|
-
if (other === undefined || seen.has(other.id))
|
|
14215
|
-
continue;
|
|
14216
|
-
seen.add(other.id);
|
|
14217
|
-
out.push(other);
|
|
13904
|
+
async function followAttachment(http, path, what, options) {
|
|
13905
|
+
try {
|
|
13906
|
+
const response = await http.raw("GET", path, options);
|
|
13907
|
+
return await response.blob();
|
|
13908
|
+
} catch (thrown) {
|
|
13909
|
+
if (thrown instanceof OmsNetworkError && await tokenOf2(http) === null) {
|
|
13910
|
+
throw new OmsError(`The ${what} attachment redirect could not be followed. In a browser, a client built with ` + "`sessionCookie: true` sends credentials, the 302 to object storage arrives there with " + "`Origin: null`, and the store answers a wildcard `Access-Control-Allow-Origin` - which CORS " + "forbids for a credentialed request. Use the matching `attachmentUrl(...)` and put the URL in an " + "<img>, a <video> or an <a download> instead: those follow the redirect with no CORS check.", "unsupported", { method: "GET", url: http.url(path), cause: thrown });
|
|
14218
13911
|
}
|
|
14219
|
-
|
|
14220
|
-
}
|
|
14221
|
-
async incomingRequests(selfId, options = {}) {
|
|
14222
|
-
const rows = await this.all({ userId: selfId }, 2000, options);
|
|
14223
|
-
return rows.filter((r) => r.kind === "friend" && r.status === "pending" && r.accepter_id === selfId);
|
|
14224
|
-
}
|
|
14225
|
-
async outgoingRequests(selfId, options = {}) {
|
|
14226
|
-
const rows = await this.all({ userId: selfId }, 2000, options);
|
|
14227
|
-
return rows.filter((r) => r.kind === "friend" && r.status === "pending" && r.requester_id === selfId);
|
|
14228
|
-
}
|
|
14229
|
-
async blocked(selfId, options = {}) {
|
|
14230
|
-
const rows = await this.all({ userId: selfId }, 2000, options);
|
|
14231
|
-
return rows.filter((r) => r.kind === "block" && r.requester_id === selfId).map((r) => r.accepter).filter((u) => u !== undefined && u !== null);
|
|
14232
|
-
}
|
|
14233
|
-
async create(input, options = {}) {
|
|
14234
|
-
assertPresent3("userId", input.userId);
|
|
14235
|
-
return this.http.post("/relationships", { accepter_id: input.userId, kind: input.kind }, options);
|
|
14236
|
-
}
|
|
14237
|
-
async request(userId, options = {}) {
|
|
14238
|
-
return this.create({ userId, kind: "friend" }, options);
|
|
14239
|
-
}
|
|
14240
|
-
async block(userId, options = {}) {
|
|
14241
|
-
return this.create({ userId, kind: "block" }, options);
|
|
14242
|
-
}
|
|
14243
|
-
async accept(id, options = {}) {
|
|
14244
|
-
return this.http.patch(`/relationships/${encodeURIComponent(String(id))}`, { status: "accepted" }, options);
|
|
13912
|
+
throw thrown;
|
|
14245
13913
|
}
|
|
14246
|
-
|
|
14247
|
-
|
|
13914
|
+
}
|
|
13915
|
+
async function tokenOf2(http) {
|
|
13916
|
+
const provider = http.tokens;
|
|
13917
|
+
if (provider === undefined || typeof provider.getToken !== "function")
|
|
13918
|
+
return null;
|
|
13919
|
+
try {
|
|
13920
|
+
return await provider.getToken() ?? null;
|
|
13921
|
+
} catch {
|
|
13922
|
+
return null;
|
|
14248
13923
|
}
|
|
14249
13924
|
}
|
|
14250
13925
|
|
|
13926
|
+
// src/resources/social/groupChats.ts
|
|
13927
|
+
var GROUP_CHAT_MESSAGE_CONTENT_MAX_LENGTH = 4000;
|
|
13928
|
+
var GROUP_CHAT_NAME_MAX_LENGTH = 120;
|
|
13929
|
+
var GROUP_CHAT_MESSAGE_PAGE_SIZE = 100;
|
|
13930
|
+
|
|
14251
13931
|
class GroupChatsNamespace extends Resource {
|
|
14252
13932
|
messages;
|
|
14253
13933
|
constructor(http) {
|
|
@@ -14261,7 +13941,7 @@ class GroupChatsNamespace extends Resource {
|
|
|
14261
13941
|
return this.http.get(`/group_chats/${encodeURIComponent(id)}`, options);
|
|
14262
13942
|
}
|
|
14263
13943
|
async create(input, options = {}) {
|
|
14264
|
-
|
|
13944
|
+
assertPresent("name", input.name);
|
|
14265
13945
|
return this.http.post("/group_chats", { name: input.name, member_ids: [...input.memberIds ?? []] }, options);
|
|
14266
13946
|
}
|
|
14267
13947
|
async rename(id, name, options = {}) {
|
|
@@ -14271,7 +13951,7 @@ class GroupChatsNamespace extends Resource {
|
|
|
14271
13951
|
return this.http.patch(`/group_chats/${encodeURIComponent(id)}`, { name }, options);
|
|
14272
13952
|
}
|
|
14273
13953
|
async addMember(id, userId, options = {}) {
|
|
14274
|
-
|
|
13954
|
+
assertPresent("userId", userId);
|
|
14275
13955
|
return this.http.post(`/group_chats/${encodeURIComponent(id)}/members`, { user_id: userId }, options);
|
|
14276
13956
|
}
|
|
14277
13957
|
async removeMember(id, userId, options = {}) {
|
|
@@ -14348,68 +14028,97 @@ class GroupChatMessagesNamespace extends Resource {
|
|
|
14348
14028
|
return this.http.url(path, token === null ? undefined : { token });
|
|
14349
14029
|
}
|
|
14350
14030
|
}
|
|
14351
|
-
function counterpart(relationship, selfId) {
|
|
14352
|
-
if (relationship.requester_id === selfId)
|
|
14353
|
-
return relationship.accepter ?? undefined;
|
|
14354
|
-
if (relationship.accepter_id === selfId)
|
|
14355
|
-
return relationship.requester ?? undefined;
|
|
14356
|
-
return;
|
|
14357
|
-
}
|
|
14358
|
-
function isFriendship(relationship) {
|
|
14359
|
-
return relationship.kind === "friend" && relationship.status === "accepted";
|
|
14360
|
-
}
|
|
14361
|
-
function isPendingRequest(relationship) {
|
|
14362
|
-
return relationship.kind === "friend" && relationship.status === "pending";
|
|
14363
|
-
}
|
|
14364
|
-
function isBlock(relationship) {
|
|
14365
|
-
return relationship.kind === "block";
|
|
14366
|
-
}
|
|
14367
14031
|
function isSystemMessage(message) {
|
|
14368
14032
|
return message.system_kind !== null && message.system_kind !== undefined;
|
|
14369
14033
|
}
|
|
14370
|
-
function
|
|
14371
|
-
const
|
|
14372
|
-
if (
|
|
14373
|
-
|
|
14374
|
-
return now - created <= MESSAGE_EDIT_WINDOW_MS;
|
|
14375
|
-
}
|
|
14376
|
-
function messageQuery(params, page, pageSize) {
|
|
14377
|
-
return {
|
|
14378
|
-
search: { content: params.contentContains },
|
|
14379
|
-
exact_search: {
|
|
14380
|
-
sender_id: params.senderId,
|
|
14381
|
-
receiver_id: params.receiverId,
|
|
14382
|
-
...params.unreadOnly === true ? { read_at: null } : {}
|
|
14383
|
-
},
|
|
14384
|
-
extra_options: { user_id: params.userId, other_user_id: params.withUser },
|
|
14385
|
-
modifiers: { order: params.order ?? "created_at:desc", page: pageModifier(page, pageSize) }
|
|
14386
|
-
};
|
|
14387
|
-
}
|
|
14388
|
-
function relationshipQuery(params, page, pageSize) {
|
|
14389
|
-
return {
|
|
14390
|
-
exact_search: { requester_id: params.requesterId, accepter_id: params.accepterId },
|
|
14391
|
-
extra_options: { user_id: params.userId },
|
|
14392
|
-
modifiers: { order: params.order ?? "created_at:desc", page: pageModifier(page, pageSize) }
|
|
14393
|
-
};
|
|
14394
|
-
}
|
|
14395
|
-
function assertPresent3(field, value) {
|
|
14396
|
-
if (typeof value !== "string" || value.trim().length === 0) {
|
|
14397
|
-
throw new OmsError(`${field} is required and cannot be blank.`, "invalid_request");
|
|
14034
|
+
function assertGroupAttachmentSize(field, file2) {
|
|
14035
|
+
const size = attachmentSize(file2);
|
|
14036
|
+
if (size !== undefined && size > MESSAGE_ATTACHMENT_MAX_BYTES) {
|
|
14037
|
+
throw new OmsError(`${field} is ${size} bytes; the server accepts at most ${MESSAGE_ATTACHMENT_MAX_BYTES}.`, "invalid_request");
|
|
14398
14038
|
}
|
|
14399
14039
|
}
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
|
|
14412
|
-
|
|
14040
|
+
|
|
14041
|
+
// src/resources/social/messages.ts
|
|
14042
|
+
var MESSAGE_CONTENT_MAX_LENGTH = 1024;
|
|
14043
|
+
var MESSAGE_IMAGE_MAX_BYTES = 20 * 1024 * 1024;
|
|
14044
|
+
var MESSAGE_IMAGE_MAX_DIMENSION_PX = 12000;
|
|
14045
|
+
var MESSAGE_IMAGE_MAX_PIXELS = 50000000;
|
|
14046
|
+
var MESSAGE_FILTER_COLUMNS = Object.freeze([
|
|
14047
|
+
"id",
|
|
14048
|
+
"created_at",
|
|
14049
|
+
"updated_at",
|
|
14050
|
+
"content",
|
|
14051
|
+
"sender_id",
|
|
14052
|
+
"receiver_id",
|
|
14053
|
+
"read_at"
|
|
14054
|
+
]);
|
|
14055
|
+
var MESSAGE_EXTRA_OPTION_KEYS = Object.freeze(["user_id", "other_user_id"]);
|
|
14056
|
+
|
|
14057
|
+
class DirectMessagesNamespace extends Resource {
|
|
14058
|
+
async list(params = {}, options = {}) {
|
|
14059
|
+
const base = {
|
|
14060
|
+
order: "created_at:desc",
|
|
14061
|
+
search: { content: params.contentContains },
|
|
14062
|
+
exactSearch: {
|
|
14063
|
+
sender_id: params.senderId,
|
|
14064
|
+
receiver_id: params.receiverId,
|
|
14065
|
+
...params.unreadOnly === true ? { read_at: null } : {}
|
|
14066
|
+
},
|
|
14067
|
+
extraOptions: { user_id: params.userId, other_user_id: params.withUser }
|
|
14068
|
+
};
|
|
14069
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/messages", { ...options, query: listQuery(params, at, base) }));
|
|
14070
|
+
}
|
|
14071
|
+
async conversation(userId, params = {}, options = {}) {
|
|
14072
|
+
return this.list({ ...params, withUser: userId }, options);
|
|
14073
|
+
}
|
|
14074
|
+
async conversedUsers(options = {}) {
|
|
14075
|
+
return this.http.get("/messages/conversed_users", options);
|
|
14076
|
+
}
|
|
14077
|
+
async get(id, options = {}) {
|
|
14078
|
+
return this.http.get(`/messages/${encodeURIComponent(String(id))}`, options);
|
|
14079
|
+
}
|
|
14080
|
+
async send(input, options = {}) {
|
|
14081
|
+
assertPresent("receiverId", input.receiverId);
|
|
14082
|
+
const content = input.content ?? "";
|
|
14083
|
+
if (content.length === 0 && input.attachment === undefined) {
|
|
14084
|
+
throw new OmsError("A message needs content or an attachment: `content` is NOT NULL with a presence validation, and the " + "server would answer 400.", "invalid_request");
|
|
14085
|
+
}
|
|
14086
|
+
if (content.length > MESSAGE_CONTENT_MAX_LENGTH) {
|
|
14087
|
+
throw new OmsError(`content is ${content.length} characters; Message validates it at ${MESSAGE_CONTENT_MAX_LENGTH}.`, "invalid_request");
|
|
14088
|
+
}
|
|
14089
|
+
if (input.attachment === undefined) {
|
|
14090
|
+
return this.http.post("/messages", {
|
|
14091
|
+
receiver_id: input.receiverId,
|
|
14092
|
+
content,
|
|
14093
|
+
...input.quotedMessageId === undefined ? {} : { quoted_message_id: input.quotedMessageId }
|
|
14094
|
+
}, options);
|
|
14095
|
+
}
|
|
14096
|
+
assertAttachmentSize("attachment", input.attachment);
|
|
14097
|
+
return this.http.postForm("/messages", {
|
|
14098
|
+
receiver_id: input.receiverId,
|
|
14099
|
+
content,
|
|
14100
|
+
attachment: input.attachment,
|
|
14101
|
+
...input.quotedMessageId === undefined ? {} : { quoted_message_id: input.quotedMessageId }
|
|
14102
|
+
}, options);
|
|
14103
|
+
}
|
|
14104
|
+
async edit(id, content, options = {}) {
|
|
14105
|
+
if (content.length > MESSAGE_CONTENT_MAX_LENGTH) {
|
|
14106
|
+
throw new OmsError(`content is ${content.length} characters; Message validates it at ${MESSAGE_CONTENT_MAX_LENGTH}.`, "invalid_request");
|
|
14107
|
+
}
|
|
14108
|
+
return this.http.patch(`/messages/${encodeURIComponent(String(id))}`, { content }, options);
|
|
14109
|
+
}
|
|
14110
|
+
async delete(id, options = {}) {
|
|
14111
|
+
await this.http.delete(`/messages/${encodeURIComponent(String(id))}`, options);
|
|
14112
|
+
}
|
|
14113
|
+
async attachment(id, options = {}) {
|
|
14114
|
+
const path = `/messages/${encodeURIComponent(String(id))}/attachment`;
|
|
14115
|
+
return followAttachment(this.http, path, "message", options);
|
|
14116
|
+
}
|
|
14117
|
+
async attachmentUrl(id) {
|
|
14118
|
+
const token = await tokenOf2(this.http);
|
|
14119
|
+
const path = `/messages/${encodeURIComponent(String(id))}/attachment`;
|
|
14120
|
+
return this.http.url(path, token === null ? undefined : { token });
|
|
14121
|
+
}
|
|
14413
14122
|
}
|
|
14414
14123
|
function attachmentContentType(file2) {
|
|
14415
14124
|
if (isNativeFile(file2))
|
|
@@ -14435,50 +14144,119 @@ function assertAttachmentSize(field, file2) {
|
|
|
14435
14144
|
throw new OmsError(`${field} is a ${size}-byte image. The controller's cap is ${MESSAGE_ATTACHMENT_MAX_BYTES}, but ` + `ImageProcessors::Message refuses anything over ${MESSAGE_IMAGE_MAX_BYTES} with an error that reaches ` + "the client as a 500 rather than a 400. Resize or recompress it first.", "invalid_request");
|
|
14436
14145
|
}
|
|
14437
14146
|
}
|
|
14438
|
-
|
|
14439
|
-
|
|
14440
|
-
|
|
14441
|
-
|
|
14147
|
+
|
|
14148
|
+
// src/resources/social/relationships.ts
|
|
14149
|
+
var RELATIONSHIP_FILTER_COLUMNS = Object.freeze(["requester_id", "accepter_id"]);
|
|
14150
|
+
var RELATIONSHIP_EXTRA_OPTION_KEYS = Object.freeze(["user_id"]);
|
|
14151
|
+
|
|
14152
|
+
class RelationshipsNamespace extends Resource {
|
|
14153
|
+
async list(params = {}, options = {}) {
|
|
14154
|
+
const base = {
|
|
14155
|
+
order: "created_at:desc",
|
|
14156
|
+
exactSearch: { requester_id: params.requesterId, accepter_id: params.accepterId },
|
|
14157
|
+
extraOptions: { user_id: params.userId }
|
|
14158
|
+
};
|
|
14159
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/relationships", { ...options, query: listQuery(params, at, base) }));
|
|
14442
14160
|
}
|
|
14443
|
-
}
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14161
|
+
async all(params = {}, limit = 2000, options = {}) {
|
|
14162
|
+
const rows = [];
|
|
14163
|
+
let page = await this.list({ ...params, pageSize: MAX_PAGE_SIZE }, options);
|
|
14164
|
+
for (;; ) {
|
|
14165
|
+
rows.push(...page.items);
|
|
14166
|
+
if (rows.length >= limit)
|
|
14167
|
+
break;
|
|
14168
|
+
const next = await page.next();
|
|
14169
|
+
if (next === null)
|
|
14170
|
+
break;
|
|
14171
|
+
page = next;
|
|
14451
14172
|
}
|
|
14452
|
-
|
|
14173
|
+
return rows.slice(0, limit);
|
|
14174
|
+
}
|
|
14175
|
+
async friends(selfId, options = {}) {
|
|
14176
|
+
const rows = await this.all({ userId: selfId }, 2000, options);
|
|
14177
|
+
const seen = new Set;
|
|
14178
|
+
const out = [];
|
|
14179
|
+
for (const row of rows) {
|
|
14180
|
+
if (row.kind !== "friend" || row.status !== "accepted")
|
|
14181
|
+
continue;
|
|
14182
|
+
const other = counterpart(row, selfId);
|
|
14183
|
+
if (other === undefined || seen.has(other.id))
|
|
14184
|
+
continue;
|
|
14185
|
+
seen.add(other.id);
|
|
14186
|
+
out.push(other);
|
|
14187
|
+
}
|
|
14188
|
+
return out;
|
|
14189
|
+
}
|
|
14190
|
+
async incomingRequests(selfId, options = {}) {
|
|
14191
|
+
const rows = await this.all({ userId: selfId }, 2000, options);
|
|
14192
|
+
return rows.filter((r) => r.kind === "friend" && r.status === "pending" && r.accepter_id === selfId);
|
|
14193
|
+
}
|
|
14194
|
+
async outgoingRequests(selfId, options = {}) {
|
|
14195
|
+
const rows = await this.all({ userId: selfId }, 2000, options);
|
|
14196
|
+
return rows.filter((r) => r.kind === "friend" && r.status === "pending" && r.requester_id === selfId);
|
|
14197
|
+
}
|
|
14198
|
+
async blocked(selfId, options = {}) {
|
|
14199
|
+
const rows = await this.all({ userId: selfId }, 2000, options);
|
|
14200
|
+
return rows.filter((r) => r.kind === "block" && r.requester_id === selfId).map((r) => r.accepter).filter((u) => u !== undefined && u !== null);
|
|
14201
|
+
}
|
|
14202
|
+
async create(input, options = {}) {
|
|
14203
|
+
assertPresent("userId", input.userId);
|
|
14204
|
+
return this.http.post("/relationships", { accepter_id: input.userId, kind: input.kind }, options);
|
|
14205
|
+
}
|
|
14206
|
+
async request(userId, options = {}) {
|
|
14207
|
+
return this.create({ userId, kind: "friend" }, options);
|
|
14208
|
+
}
|
|
14209
|
+
async block(userId, options = {}) {
|
|
14210
|
+
return this.create({ userId, kind: "block" }, options);
|
|
14211
|
+
}
|
|
14212
|
+
async accept(id, options = {}) {
|
|
14213
|
+
return this.http.patch(`/relationships/${encodeURIComponent(String(id))}`, { status: "accepted" }, options);
|
|
14214
|
+
}
|
|
14215
|
+
async delete(id, options = {}) {
|
|
14216
|
+
await this.http.delete(`/relationships/${encodeURIComponent(String(id))}`, options);
|
|
14453
14217
|
}
|
|
14454
14218
|
}
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
|
|
14219
|
+
function counterpart(relationship, selfId) {
|
|
14220
|
+
if (relationship.requester_id === selfId)
|
|
14221
|
+
return relationship.accepter ?? undefined;
|
|
14222
|
+
if (relationship.accepter_id === selfId)
|
|
14223
|
+
return relationship.requester ?? undefined;
|
|
14224
|
+
return;
|
|
14225
|
+
}
|
|
14226
|
+
function isFriendship(relationship) {
|
|
14227
|
+
return relationship.kind === "friend" && relationship.status === "accepted";
|
|
14228
|
+
}
|
|
14229
|
+
function isPendingRequest(relationship) {
|
|
14230
|
+
return relationship.kind === "friend" && relationship.status === "pending";
|
|
14231
|
+
}
|
|
14232
|
+
function isBlock(relationship) {
|
|
14233
|
+
return relationship.kind === "block";
|
|
14234
|
+
}
|
|
14235
|
+
|
|
14236
|
+
// src/resources/social/index.ts
|
|
14237
|
+
class SocialNamespace extends Resource {
|
|
14238
|
+
messages;
|
|
14239
|
+
relationships;
|
|
14240
|
+
groupChats;
|
|
14241
|
+
constructor(http) {
|
|
14242
|
+
super(http);
|
|
14243
|
+
this.messages = new DirectMessagesNamespace(http);
|
|
14244
|
+
this.relationships = new RelationshipsNamespace(http);
|
|
14245
|
+
this.groupChats = new GroupChatsNamespace(http);
|
|
14463
14246
|
}
|
|
14464
14247
|
}
|
|
14465
14248
|
|
|
14466
14249
|
// src/resources/storage.ts
|
|
14250
|
+
var FS_NODE_FILTER_COLUMNS = Object.freeze(["id", "created_at", "updated_at", "name", "parent_id"]);
|
|
14251
|
+
var FS_NODE_EXTRA_OPTION_KEYS = Object.freeze(["parent_id", "include_pending"]);
|
|
14252
|
+
|
|
14467
14253
|
class FsGrantsNamespace extends Resource {
|
|
14468
14254
|
async list(params = {}, options = {}) {
|
|
14469
|
-
|
|
14470
|
-
const load = async (page) => await this.http.get("/fs_grants", {
|
|
14255
|
+
return paginate(params, 100, (at) => this.http.get("/fs_grants", {
|
|
14471
14256
|
...options,
|
|
14472
|
-
query:
|
|
14473
|
-
modifiers: {
|
|
14474
|
-
page: pageModifier(page.page, page.pageSize),
|
|
14475
|
-
...params.order === undefined ? {} : { order: params.order }
|
|
14476
|
-
}
|
|
14477
|
-
},
|
|
14257
|
+
query: listQuery(params, at),
|
|
14478
14258
|
headers: noRevalidate2(options.headers)
|
|
14479
|
-
})
|
|
14480
|
-
const first = params.page ?? 1;
|
|
14481
|
-
return createPage(await load({ page: first, pageSize }), first, pageSize, load);
|
|
14259
|
+
}));
|
|
14482
14260
|
}
|
|
14483
14261
|
async get(id, options = {}) {
|
|
14484
14262
|
return this.http.get(`/fs_grants/${encodeURIComponent(id)}`, options);
|
|
@@ -14526,29 +14304,21 @@ class StorageNamespace extends Resource {
|
|
|
14526
14304
|
this.rootsCache = roots;
|
|
14527
14305
|
return roots;
|
|
14528
14306
|
}
|
|
14529
|
-
async list(params, options = {}) {
|
|
14530
|
-
const
|
|
14531
|
-
const
|
|
14532
|
-
const
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14307
|
+
async list(params = {}, options = {}) {
|
|
14308
|
+
const parentId = params.parentId;
|
|
14309
|
+
const foldSelfIn = parentId !== undefined && parentId !== null && params.includeSelf === true;
|
|
14310
|
+
const base = {
|
|
14311
|
+
exactSearch: foldSelfIn || parentId === undefined ? {} : { parent_id: parentId ?? NULL_SENTINEL },
|
|
14312
|
+
extraOptions: {
|
|
14313
|
+
parent_id: foldSelfIn ? parentId : undefined,
|
|
14314
|
+
include_pending: params.includePending ? true : undefined
|
|
14315
|
+
}
|
|
14316
|
+
};
|
|
14317
|
+
return paginate(params, 200, (at) => this.http.get("/fs_nodes", {
|
|
14539
14318
|
...options,
|
|
14540
|
-
query:
|
|
14541
|
-
...foldSelfIn ? {} : { exact_search: { parent_id: parentId ?? NULL_SENTINEL } },
|
|
14542
|
-
...Object.keys(extraOptions).length > 0 ? { extra_options: extraOptions } : {},
|
|
14543
|
-
modifiers: {
|
|
14544
|
-
page: pageModifier(page.page, page.pageSize),
|
|
14545
|
-
...params.order === undefined ? {} : { order: params.order }
|
|
14546
|
-
}
|
|
14547
|
-
},
|
|
14319
|
+
query: listQuery(params, at, base),
|
|
14548
14320
|
headers: noRevalidate2(options.headers)
|
|
14549
|
-
})
|
|
14550
|
-
const first = params.page ?? 1;
|
|
14551
|
-
return createPage(await load({ page: first, pageSize }), first, pageSize, load);
|
|
14321
|
+
}));
|
|
14552
14322
|
}
|
|
14553
14323
|
async get(id, options = {}) {
|
|
14554
14324
|
return this.http.get(`/fs_nodes/${encodeURIComponent(id)}`, options);
|
|
@@ -14805,16 +14575,13 @@ var TICKET_MESSAGE_MAX_LENGTH = 4000;
|
|
|
14805
14575
|
var TICKET_MAX_ATTACHMENTS = 10;
|
|
14806
14576
|
var TICKET_MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;
|
|
14807
14577
|
var TICKET_ATTACHMENT_TYPES = ["image/", "video/"];
|
|
14578
|
+
var TICKET_FILTER_COLUMNS = Object.freeze(["status", "user_id"]);
|
|
14579
|
+
var TICKET_MESSAGE_FILTER_COLUMNS = Object.freeze(["ticket_id", "sender_id", "created_at"]);
|
|
14808
14580
|
|
|
14809
14581
|
class TicketMessagesNamespace extends Resource {
|
|
14810
14582
|
async list(params, options = {}) {
|
|
14811
|
-
const
|
|
14812
|
-
|
|
14813
|
-
...options,
|
|
14814
|
-
query: messageQuery2(params, page, pageSize)
|
|
14815
|
-
});
|
|
14816
|
-
const first = resolvePageNumber(params.page);
|
|
14817
|
-
return createPage(await load({ page: first, pageSize: size }), first, size, load);
|
|
14583
|
+
const base = { exactSearch: { ticket_id: params.ticketId } };
|
|
14584
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/ticket_messages", { ...options, query: listQuery(params, at, base) }));
|
|
14818
14585
|
}
|
|
14819
14586
|
async create(input, options = {}) {
|
|
14820
14587
|
assertLength("content", input.content, TICKET_MESSAGE_MAX_LENGTH);
|
|
@@ -14832,10 +14599,8 @@ class TicketsNamespace extends Resource {
|
|
|
14832
14599
|
this.messages = new TicketMessagesNamespace(http);
|
|
14833
14600
|
}
|
|
14834
14601
|
async list(params = {}, options = {}) {
|
|
14835
|
-
const
|
|
14836
|
-
|
|
14837
|
-
const first = resolvePageNumber(params.page);
|
|
14838
|
-
return createPage(await load({ page: first, pageSize: size }), first, size, load);
|
|
14602
|
+
const base = { exactSearch: { status: params.status, user_id: params.userId } };
|
|
14603
|
+
return paginate(params, DEFAULT_PAGE_SIZE, (at) => this.http.get("/tickets", { ...options, query: listQuery(params, at, base) }));
|
|
14839
14604
|
}
|
|
14840
14605
|
async get(id, options = {}) {
|
|
14841
14606
|
return this.http.get(`/tickets/${id}`, options);
|
|
@@ -14911,24 +14676,39 @@ function base642(bytes) {
|
|
|
14911
14676
|
}
|
|
14912
14677
|
async function encodeAttachments(files) {
|
|
14913
14678
|
if (files.length > TICKET_MAX_ATTACHMENTS) {
|
|
14914
|
-
throw new OmsError(`A ticket takes at most ${TICKET_MAX_ATTACHMENTS} attachments, got ${files.length}
|
|
14679
|
+
throw new OmsError(`A ticket takes at most ${TICKET_MAX_ATTACHMENTS} attachments, got ${files.length}; the server keeps the first ${TICKET_MAX_ATTACHMENTS} and drops the rest silently.`, "invalid_request");
|
|
14915
14680
|
}
|
|
14916
14681
|
const entries = [];
|
|
14917
14682
|
let total = 0;
|
|
14918
14683
|
for (const input of files) {
|
|
14919
|
-
const {
|
|
14684
|
+
const { dataUrl, filename, contentType, size } = await encodeAttachment(input);
|
|
14920
14685
|
if (!TICKET_ATTACHMENT_TYPES.some((prefix) => contentType.startsWith(prefix))) {
|
|
14921
14686
|
throw new OmsError(`Attachment "${filename}" is ${contentType}; a ticket accepts image/* and video/* only.`, "invalid_request");
|
|
14922
14687
|
}
|
|
14923
|
-
total +=
|
|
14688
|
+
total += size;
|
|
14924
14689
|
if (total > TICKET_MAX_ATTACHMENT_BYTES) {
|
|
14925
|
-
throw new OmsError(`Ticket attachments exceed ${TICKET_MAX_ATTACHMENT_BYTES} bytes in total
|
|
14690
|
+
throw new OmsError(`Ticket attachments exceed ${TICKET_MAX_ATTACHMENT_BYTES} bytes in total; the server attaches what fits and drops the rest silently.`, "invalid_request");
|
|
14926
14691
|
}
|
|
14927
|
-
|
|
14928
|
-
entries.push({ data_url: `data:${contentType};base64,${base642(bytes)}`, filename });
|
|
14692
|
+
entries.push({ data_url: dataUrl, filename });
|
|
14929
14693
|
}
|
|
14930
14694
|
return entries;
|
|
14931
14695
|
}
|
|
14696
|
+
var DATA_URL = /^data:([^;,]+)(;[^,]*)?,(.*)$/s;
|
|
14697
|
+
async function encodeAttachment(input) {
|
|
14698
|
+
if ("dataUrl" in input) {
|
|
14699
|
+
const match = DATA_URL.exec(input.dataUrl);
|
|
14700
|
+
if (!match) {
|
|
14701
|
+
throw new OmsError(`Attachment "${input.filename}" is not a data URL.`, "invalid_request");
|
|
14702
|
+
}
|
|
14703
|
+
const payload = match[3] ?? "";
|
|
14704
|
+
const base64Encoded = (match[2] ?? "").split(";").includes("base64");
|
|
14705
|
+
const size = base64Encoded ? Math.floor(payload.length * 3 / 4) - (payload.endsWith("==") ? 2 : payload.endsWith("=") ? 1 : 0) : decodeURIComponent(payload).length;
|
|
14706
|
+
return { dataUrl: input.dataUrl, filename: input.filename, contentType: match[1] ?? "", size };
|
|
14707
|
+
}
|
|
14708
|
+
const { blob, filename, contentType } = await readFileInput(input);
|
|
14709
|
+
const bytes = new Uint8Array(await blob.arrayBuffer());
|
|
14710
|
+
return { dataUrl: `data:${contentType};base64,${base642(bytes)}`, filename, contentType, size: blob.size };
|
|
14711
|
+
}
|
|
14932
14712
|
function pickContext(context) {
|
|
14933
14713
|
const out = {};
|
|
14934
14714
|
for (const key of ["provider", "error", "path", "source"]) {
|
|
@@ -14938,18 +14718,6 @@ function pickContext(context) {
|
|
|
14938
14718
|
}
|
|
14939
14719
|
return out;
|
|
14940
14720
|
}
|
|
14941
|
-
function ticketQuery(params, page, pageSize) {
|
|
14942
|
-
return {
|
|
14943
|
-
exact_search: { status: params.status, user_id: params.userId },
|
|
14944
|
-
modifiers: { order: params.order, page: pageModifier(page, pageSize) }
|
|
14945
|
-
};
|
|
14946
|
-
}
|
|
14947
|
-
function messageQuery2(params, page, pageSize) {
|
|
14948
|
-
return {
|
|
14949
|
-
exact_search: { ticket_id: params.ticketId },
|
|
14950
|
-
modifiers: { order: params.order, page: pageModifier(page, pageSize) }
|
|
14951
|
-
};
|
|
14952
|
-
}
|
|
14953
14721
|
function assertLength(field, value, max) {
|
|
14954
14722
|
if (value.length > max) {
|
|
14955
14723
|
throw new OmsError(`${field} is ${value.length} characters; the maximum is ${max}.`, "invalid_request");
|
|
@@ -15468,7 +15236,7 @@ async function fetchToolArtifact(http, url, options = {}) {
|
|
|
15468
15236
|
}
|
|
15469
15237
|
return response.blob();
|
|
15470
15238
|
}
|
|
15471
|
-
async function awaitToolJob(
|
|
15239
|
+
async function awaitToolJob(jobs2, created, reread, options, label) {
|
|
15472
15240
|
options.onProgress?.(toolProgress(created));
|
|
15473
15241
|
if (typeof created.job_id !== "string" || created.job_id.length === 0) {
|
|
15474
15242
|
return pollUntilTerminal({
|
|
@@ -15480,7 +15248,7 @@ async function awaitToolJob(jobs, created, reread, options, label) {
|
|
|
15480
15248
|
});
|
|
15481
15249
|
}
|
|
15482
15250
|
const watchToken = created.watch_token;
|
|
15483
|
-
const job = await
|
|
15251
|
+
const job = await jobs2.wait({
|
|
15484
15252
|
id: created.job_id,
|
|
15485
15253
|
...typeof watchToken === "string" && watchToken.length > 0 ? { watchToken } : {}
|
|
15486
15254
|
}, options);
|
|
@@ -15646,6 +15414,7 @@ export {
|
|
|
15646
15414
|
passkeyBase64Url,
|
|
15647
15415
|
parseScopes,
|
|
15648
15416
|
parseRetryAfter,
|
|
15417
|
+
paginate,
|
|
15649
15418
|
pages,
|
|
15650
15419
|
pageModifier,
|
|
15651
15420
|
objectStoreFetch,
|
|
@@ -15665,6 +15434,7 @@ export {
|
|
|
15665
15434
|
md5Base64,
|
|
15666
15435
|
manifestEntryFor,
|
|
15667
15436
|
local,
|
|
15437
|
+
listQuery,
|
|
15668
15438
|
jobRef,
|
|
15669
15439
|
jobProgress,
|
|
15670
15440
|
jamStreamName,
|
|
@@ -15735,6 +15505,7 @@ export {
|
|
|
15735
15505
|
VERIFICATION_CODE_LENGTH,
|
|
15736
15506
|
UpscaleNamespace,
|
|
15737
15507
|
UploadManager,
|
|
15508
|
+
USER_FILTER_COLUMNS,
|
|
15738
15509
|
UPTIME_WINDOW_DAYS,
|
|
15739
15510
|
UPTIME_CACHE_SECONDS,
|
|
15740
15511
|
TranscriptionNamespace,
|
|
@@ -15744,8 +15515,10 @@ export {
|
|
|
15744
15515
|
TOOL_TERMINAL_STATUSES,
|
|
15745
15516
|
TICKET_SUBJECT_MAX_LENGTH,
|
|
15746
15517
|
TICKET_MESSAGE_MAX_LENGTH,
|
|
15518
|
+
TICKET_MESSAGE_FILTER_COLUMNS,
|
|
15747
15519
|
TICKET_MAX_ATTACHMENT_BYTES,
|
|
15748
15520
|
TICKET_MAX_ATTACHMENTS,
|
|
15521
|
+
TICKET_FILTER_COLUMNS,
|
|
15749
15522
|
TICKET_ATTACHMENT_TYPES,
|
|
15750
15523
|
StorageRateGate,
|
|
15751
15524
|
StorageNamespace,
|
|
@@ -15762,6 +15535,7 @@ export {
|
|
|
15762
15535
|
SPACE_INVADERS_MAX_POINTS_PER_KILL,
|
|
15763
15536
|
SPACE_INVADERS_MAX_KILLS_PER_SECOND,
|
|
15764
15537
|
SPACE_INVADERS_LEADERBOARD_SIZE,
|
|
15538
|
+
SPACE_INVADERS_GAME_FILTER_COLUMNS,
|
|
15765
15539
|
SONG_ORDER_COLUMNS,
|
|
15766
15540
|
SONG_METADATA_MAX_BYTES,
|
|
15767
15541
|
SONG_IMPORT_TERMINAL_STATES,
|
|
@@ -15773,6 +15547,7 @@ export {
|
|
|
15773
15547
|
SONG_IMPORT_EXTENSIONS,
|
|
15774
15548
|
SONG_FILTER_COLUMNS,
|
|
15775
15549
|
SOCKET_OPEN,
|
|
15550
|
+
SHORT_LINK_FILTER_COLUMNS,
|
|
15776
15551
|
SHORT_LINK_BASE_URL,
|
|
15777
15552
|
SHIPPED_CLIENT_IDS,
|
|
15778
15553
|
SESSION_DEVICE_TYPES,
|
|
@@ -15783,6 +15558,8 @@ export {
|
|
|
15783
15558
|
Resource,
|
|
15784
15559
|
RelationshipsNamespace,
|
|
15785
15560
|
RealtimeNamespace,
|
|
15561
|
+
RELATIONSHIP_FILTER_COLUMNS,
|
|
15562
|
+
RELATIONSHIP_EXTRA_OPTION_KEYS,
|
|
15786
15563
|
QuotasNamespace,
|
|
15787
15564
|
QUOTA_RESOURCES,
|
|
15788
15565
|
PlaylistSongsNamespace,
|
|
@@ -15793,10 +15570,12 @@ export {
|
|
|
15793
15570
|
PLAY_EVENT_SOURCES,
|
|
15794
15571
|
PLAY_EVENT_MAX_LIMIT,
|
|
15795
15572
|
PLAY_EVENT_DEDUPE_WINDOW_MS,
|
|
15573
|
+
PLAYLIST_SONG_FILTER_COLUMNS,
|
|
15796
15574
|
PLAYLIST_SEED_CAP,
|
|
15797
15575
|
PLAYLIST_MANUAL_BLOCK_FLOOR,
|
|
15798
15576
|
PLAYLIST_IMPORT_PREVIEW_HOURLY_LIMIT,
|
|
15799
15577
|
PLAYLIST_IMPORT_PREVIEW_BURST_LIMIT_PER_MINUTE,
|
|
15578
|
+
PLAYLIST_FILTER_COLUMNS,
|
|
15800
15579
|
PART_URL_WINDOW,
|
|
15801
15580
|
OmsTimeoutError,
|
|
15802
15581
|
OmsQuotaError,
|
|
@@ -15820,6 +15599,7 @@ export {
|
|
|
15820
15599
|
NotificationsNamespace,
|
|
15821
15600
|
NotepadsNamespace,
|
|
15822
15601
|
NULL_SENTINEL,
|
|
15602
|
+
NOTIFICATION_FILTER_COLUMNS,
|
|
15823
15603
|
NATIVE_LOOPBACK_REDIRECT_VALUE,
|
|
15824
15604
|
NATIVE_LOOPBACK_REDIRECT_URIS,
|
|
15825
15605
|
MyOauthApplicationsNamespace,
|
|
@@ -15865,12 +15645,19 @@ export {
|
|
|
15865
15645
|
MOVIE_WATCH_BULK_LIMIT,
|
|
15866
15646
|
MOVIE_COLLECTION_MANUAL_KIND,
|
|
15867
15647
|
MOVIE_COLLECTION_KINDS,
|
|
15648
|
+
MOVIE_COLLECTION_ITEM_FILTER_COLUMNS,
|
|
15649
|
+
MOVIE_COLLECTION_FILTER_COLUMNS,
|
|
15868
15650
|
MOVIE_COLLECTION_FAVORITES_KIND,
|
|
15869
15651
|
MOVIE_ADDON_GROUP_NAME_MAX_LENGTH,
|
|
15652
|
+
MOVIE_ADDON_GROUP_FILTER_COLUMNS,
|
|
15653
|
+
MOVIE_ADDON_GRANT_FILTER_COLUMNS,
|
|
15654
|
+
MOVIE_ADDON_FILTER_COLUMNS,
|
|
15870
15655
|
MIX_KINDS,
|
|
15871
15656
|
MESSAGE_IMAGE_MAX_PIXELS,
|
|
15872
15657
|
MESSAGE_IMAGE_MAX_DIMENSION_PX,
|
|
15873
15658
|
MESSAGE_IMAGE_MAX_BYTES,
|
|
15659
|
+
MESSAGE_FILTER_COLUMNS,
|
|
15660
|
+
MESSAGE_EXTRA_OPTION_KEYS,
|
|
15874
15661
|
MESSAGE_EDIT_WINDOW_MS,
|
|
15875
15662
|
MESSAGE_CONTENT_MAX_LENGTH,
|
|
15876
15663
|
MESSAGE_ATTACHMENT_MAX_BYTES,
|
|
@@ -15894,14 +15681,17 @@ export {
|
|
|
15894
15681
|
LINK_TREE_MAX_ITEMS,
|
|
15895
15682
|
LINK_TREE_CV_MAX_BYTES,
|
|
15896
15683
|
LINK_TREE_BASE_URL,
|
|
15684
|
+
LINKED_IDENTITY_FILTER_COLUMNS,
|
|
15897
15685
|
LIKED_SONGS_MAX_LIMIT,
|
|
15898
15686
|
LIKED_SONGS_DEFAULT_LIMIT,
|
|
15899
15687
|
JumpstyleNamespace,
|
|
15900
15688
|
JokesNamespace,
|
|
15901
15689
|
JobsNamespace,
|
|
15902
15690
|
JUMPSTYLE_DENSITIES,
|
|
15691
|
+
JOKE_FILTER_COLUMNS,
|
|
15903
15692
|
JOB_TERMINAL_STATUSES,
|
|
15904
15693
|
JOB_STATUS,
|
|
15694
|
+
JOB_FILTER_COLUMNS,
|
|
15905
15695
|
JAM_UPCOMING_LIMIT,
|
|
15906
15696
|
JAM_SKIP_MODES,
|
|
15907
15697
|
JAM_QUEUE_MODES,
|
|
@@ -15910,22 +15700,23 @@ export {
|
|
|
15910
15700
|
IntelSourcesNamespace,
|
|
15911
15701
|
IntelScriptsNamespace,
|
|
15912
15702
|
IntelReportsNamespace,
|
|
15913
|
-
IntelProxyNamespace,
|
|
15914
15703
|
IntelNamespace,
|
|
15915
15704
|
IntelItemsNamespace,
|
|
15916
15705
|
IntelConfigNamespace,
|
|
15917
15706
|
IntelArticlesNamespace,
|
|
15918
15707
|
INTERNAL_SERVICE_SLUGS,
|
|
15919
|
-
INTEL_UPSTREAM_READ_TIMEOUT_MS,
|
|
15920
|
-
INTEL_UPSTREAM_OPEN_TIMEOUT_MS,
|
|
15921
15708
|
INTEL_SOURCE_HEALTHS,
|
|
15709
|
+
INTEL_SOURCE_FILTER_COLUMNS,
|
|
15922
15710
|
INTEL_SOURCE_DISABLE_AFTER_FAILURES,
|
|
15923
15711
|
INTEL_SCRIPT_MAX_CODE_BYTES,
|
|
15712
|
+
INTEL_SCRIPT_FILTER_COLUMNS,
|
|
15924
15713
|
INTEL_REPORT_KINDS,
|
|
15714
|
+
INTEL_REPORT_FILTER_COLUMNS,
|
|
15925
15715
|
INTEL_PROMPT_KEYS,
|
|
15716
|
+
INTEL_ITEM_FILTER_COLUMNS,
|
|
15926
15717
|
INTEL_IMAGE_PROXY_BASE_URL,
|
|
15718
|
+
INTEL_ARTICLE_FILTER_COLUMNS,
|
|
15927
15719
|
INTEL_ARTICLE_CATEGORIES,
|
|
15928
|
-
INTEL_ALLOWED_PREFIXES,
|
|
15929
15720
|
IDENTITY_PROVIDERS,
|
|
15930
15721
|
GroupChatsNamespace,
|
|
15931
15722
|
GroupChatMessagesNamespace,
|
|
@@ -15937,6 +15728,8 @@ export {
|
|
|
15937
15728
|
FormSubmissionsNamespace,
|
|
15938
15729
|
FeedbacksNamespace,
|
|
15939
15730
|
FS_UPLOAD_RATE_LIMIT,
|
|
15731
|
+
FS_NODE_FILTER_COLUMNS,
|
|
15732
|
+
FS_NODE_EXTRA_OPTION_KEYS,
|
|
15940
15733
|
FS_BULK_JOB_RATE_LIMIT,
|
|
15941
15734
|
FORM_NAMESPACE,
|
|
15942
15735
|
FORM_BASE_URL,
|
|
@@ -15944,6 +15737,7 @@ export {
|
|
|
15944
15737
|
FEEDBACK_MAX_ATTACHMENT_DATA_URL_BYTES,
|
|
15945
15738
|
FEEDBACK_MAX_ATTACHMENTS_TOTAL_BYTES,
|
|
15946
15739
|
FEEDBACK_MAX_ATTACHMENTS,
|
|
15740
|
+
FEEDBACK_FILTER_COLUMNS,
|
|
15947
15741
|
FEEDBACK_DUPLICATE_WINDOW_MS,
|
|
15948
15742
|
FEEDBACK_CREATE_RATE_LIMIT_PER_HOUR,
|
|
15949
15743
|
FEEDBACK_CONTENT_MAX_BYTES,
|
|
@@ -15990,10 +15784,13 @@ export {
|
|
|
15990
15784
|
BOOK_TAG_MAX_LENGTH,
|
|
15991
15785
|
BOOK_SHELVES_MAX_PER_USER,
|
|
15992
15786
|
BOOK_SHELF_NAME_MAX_LENGTH,
|
|
15787
|
+
BOOK_SHELF_FILTER_COLUMNS,
|
|
15993
15788
|
BOOK_SHELF_DESCRIPTION_MAX_LENGTH,
|
|
15994
15789
|
BOOK_MAX_TAGS,
|
|
15995
15790
|
BOOK_MAX_FILE_BYTES,
|
|
15996
15791
|
BOOK_FORMATS,
|
|
15792
|
+
BOOK_FILTER_COLUMNS,
|
|
15793
|
+
BOOK_EXTRA_OPTION_KEYS,
|
|
15997
15794
|
BOOK_CHAT_RATE_LIMIT_PER_MINUTE,
|
|
15998
15795
|
BOOK_CHAT_MAX_MESSAGE_CHARS,
|
|
15999
15796
|
BOOK_CHAT_MAX_HISTORY_MESSAGES,
|
|
@@ -16004,6 +15801,8 @@ export {
|
|
|
16004
15801
|
BOOK_ANNOTATION_SELECTED_TEXT_MAX_LENGTH,
|
|
16005
15802
|
BOOK_ANNOTATION_NOTE_MAX_LENGTH,
|
|
16006
15803
|
BOOK_ANNOTATION_KINDS,
|
|
15804
|
+
BOOK_ANNOTATION_FILTER_COLUMNS,
|
|
15805
|
+
BASE_FILTER_COLUMNS,
|
|
16007
15806
|
AuthorizedApplicationsNamespace,
|
|
16008
15807
|
AuthSessionsNamespace,
|
|
16009
15808
|
AuthNamespace,
|
|
@@ -16025,7 +15824,11 @@ export {
|
|
|
16025
15824
|
ARTIST_IMPORT_POLL_INTERVAL_MS,
|
|
16026
15825
|
ARTIST_IMAGE_MAX_BYTES,
|
|
16027
15826
|
ARTIST_IMAGE_CONTENT_TYPES,
|
|
15827
|
+
ARTIST_FILTER_COLUMNS,
|
|
16028
15828
|
ANONYMOUS_BOOK_FILE_RATE_LIMIT_PER_HOUR,
|
|
16029
15829
|
ANALYSIS_DAILY_WINDOW_DAYS,
|
|
16030
|
-
ALL_SERVICE_SLUGS
|
|
15830
|
+
ALL_SERVICE_SLUGS,
|
|
15831
|
+
ADMIN_VOCAL_SEPARATION_FILTER_COLUMNS,
|
|
15832
|
+
ADMIN_JOB_FILTER_COLUMNS,
|
|
15833
|
+
ACCOUNT_SESSION_FILTER_COLUMNS
|
|
16031
15834
|
};
|