@mediaviz/sdk 0.1.0 → 1.0.59
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/LICENSE +21 -0
- package/dist/sdk.cjs +33 -240
- package/dist/sdk.esm.js +34 -239
- package/dist/sdk.umd.js +33 -240
- package/package.json +14 -8
- package/MediaViz.js +0 -126
- package/_oauth.js +0 -3
- package/admin.js +0 -93
- package/ai_model_credits.js +0 -22
- package/company.js +0 -54
- package/curated_albums.js +0 -85
- package/custom_albums.js +0 -78
- package/email_tokens.js +0 -64
- package/errors.js +0 -81
- package/health.js +0 -20
- package/index.js +0 -21
- package/keywords.js +0 -123
- package/oauth/.prettierrc +0 -6
- package/oauth/README.md +0 -76
- package/oauth/browser-smoke-test.html +0 -45
- package/oauth/implementation_plan.json +0 -106
- package/oauth/package-lock.json +0 -5236
- package/oauth/package.json +0 -28
- package/oauth/rollup.config.js +0 -21
- package/oauth/smoke-test.js +0 -27
- package/oauth/spec.md +0 -187
- package/oauth/src/__tests__/browser-smoke-test.test.js +0 -38
- package/oauth/src/__tests__/client.test.js +0 -556
- package/oauth/src/__tests__/errors.test.js +0 -73
- package/oauth/src/__tests__/http.test.js +0 -102
- package/oauth/src/__tests__/index.test.js +0 -53
- package/oauth/src/__tests__/package-fields.test.js +0 -29
- package/oauth/src/__tests__/pkce.test.js +0 -55
- package/oauth/src/__tests__/rollup-build.test.js +0 -58
- package/oauth/src/__tests__/smoke-test.test.js +0 -26
- package/oauth/src/__tests__/types.test.js +0 -29
- package/oauth/src/client.js +0 -180
- package/oauth/src/errors.js +0 -32
- package/oauth/src/http.js +0 -52
- package/oauth/src/index.js +0 -7
- package/oauth/src/pkce.js +0 -50
- package/oauth/src/types.js +0 -67
- package/oauth_authorization.js +0 -53
- package/oauth_clients.js +0 -18
- package/oauth_login.js +0 -24
- package/oauth_token.js +0 -30
- package/person.js +0 -54
- package/photos.js +0 -106
- package/photoupload.js +0 -55
- package/projects.js +0 -191
- package/rollup.config.js +0 -12
- package/search.js +0 -99
- package/users.js +0 -137
package/dist/sdk.umd.js
CHANGED
|
@@ -460,124 +460,11 @@
|
|
|
460
460
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
461
461
|
return data;
|
|
462
462
|
}
|
|
463
|
-
|
|
464
|
-
async upsertModelCreditRelationship({ modelName, newCreditValue } = {}) {
|
|
465
|
-
this._ctx.requireTokens();
|
|
466
|
-
let path = `/api/v1/model_credit/upsert`;
|
|
467
|
-
const query = new URLSearchParams();
|
|
468
|
-
if (modelName !== undefined) (Array.isArray(modelName) ? modelName : [modelName]).forEach(v => query.append('model_name', v));
|
|
469
|
-
if (newCreditValue !== undefined) (Array.isArray(newCreditValue) ? newCreditValue : [newCreditValue]).forEach(v => query.append('new_credit_value', v));
|
|
470
|
-
const qs = query.toString();
|
|
471
|
-
if (qs) path += '?' + qs;
|
|
472
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
473
|
-
return data;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
class Admin {
|
|
478
|
-
constructor(ctx) { this._ctx = ctx; }
|
|
479
|
-
|
|
480
|
-
async insertLabelCategoryMatrix() {
|
|
481
|
-
this._ctx.requireTokens();
|
|
482
|
-
const path = `/api/v1/admin/insert_label_category_matrix`;
|
|
483
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
484
|
-
return data;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
async generateMidLevelCategoryKeywordAlignment() {
|
|
488
|
-
this._ctx.requireTokens();
|
|
489
|
-
const path = `/api/v1/admin/generate_mid_level_category_keyword_alignment`;
|
|
490
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
491
|
-
return data;
|
|
492
|
-
}
|
|
493
|
-
|
|
494
|
-
async getCategoryLabels(category) {
|
|
495
|
-
this._ctx.requireTokens();
|
|
496
|
-
const path = `/api/v1/admin/category_labels/${encodeURIComponent(category)}`;
|
|
497
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
498
|
-
return data;
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
async adminDumpCompanyNlpIndex(companyId) {
|
|
502
|
-
this._ctx.requireTokens();
|
|
503
|
-
const path = `/api/v1/admin/dump_company_nlp_index/${encodeURIComponent(companyId)}`;
|
|
504
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
505
|
-
return data;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
async getAllKeywordGroupsAndSubgroups() {
|
|
509
|
-
this._ctx.requireTokens();
|
|
510
|
-
const path = `/api/v1/admin/keyword_group`;
|
|
511
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
512
|
-
return data;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
async getKeywordGroupsLabelsByKeywordGroup(keywordGroup, { subgroup } = {}) {
|
|
516
|
-
this._ctx.requireTokens();
|
|
517
|
-
let path = `/api/v1/admin/keyword_group/${encodeURIComponent(keywordGroup)}/`;
|
|
518
|
-
const query = new URLSearchParams();
|
|
519
|
-
if (subgroup !== undefined) (Array.isArray(subgroup) ? subgroup : [subgroup]).forEach(v => query.append('subgroup', v));
|
|
520
|
-
const qs = query.toString();
|
|
521
|
-
if (qs) path += '?' + qs;
|
|
522
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
523
|
-
return data;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
async adminCreateCompanyNlpIndexes({ companyIds } = {}) {
|
|
527
|
-
this._ctx.requireTokens();
|
|
528
|
-
let path = `/api/v1/admin/create_company_nlp_indexes/`;
|
|
529
|
-
const query = new URLSearchParams();
|
|
530
|
-
if (companyIds !== undefined) (Array.isArray(companyIds) ? companyIds : [companyIds]).forEach(v => query.append('company_ids', v));
|
|
531
|
-
const qs = query.toString();
|
|
532
|
-
if (qs) path += '?' + qs;
|
|
533
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
534
|
-
return data;
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
async adminDeleteCompanyNlpIndexes({ companyIds } = {}) {
|
|
538
|
-
this._ctx.requireTokens();
|
|
539
|
-
let path = `/api/v1/admin/delete_company_nlp_indexes/`;
|
|
540
|
-
const query = new URLSearchParams();
|
|
541
|
-
if (companyIds !== undefined) (Array.isArray(companyIds) ? companyIds : [companyIds]).forEach(v => query.append('company_ids', v));
|
|
542
|
-
const qs = query.toString();
|
|
543
|
-
if (qs) path += '?' + qs;
|
|
544
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
545
|
-
return data;
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
async adminDeleteUserProjects({ userIds } = {}) {
|
|
549
|
-
this._ctx.requireTokens();
|
|
550
|
-
let path = `/api/v1/admin/delete_user_projects/`;
|
|
551
|
-
const query = new URLSearchParams();
|
|
552
|
-
if (userIds !== undefined) (Array.isArray(userIds) ? userIds : [userIds]).forEach(v => query.append('user_ids', v));
|
|
553
|
-
const qs = query.toString();
|
|
554
|
-
if (qs) path += '?' + qs;
|
|
555
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
556
|
-
return data;
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
async adminDeleteUser({ userIds } = {}) {
|
|
560
|
-
this._ctx.requireTokens();
|
|
561
|
-
let path = `/api/v1/admin/delete_user/`;
|
|
562
|
-
const query = new URLSearchParams();
|
|
563
|
-
if (userIds !== undefined) (Array.isArray(userIds) ? userIds : [userIds]).forEach(v => query.append('user_ids', v));
|
|
564
|
-
const qs = query.toString();
|
|
565
|
-
if (qs) path += '?' + qs;
|
|
566
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
567
|
-
return data;
|
|
568
|
-
}
|
|
569
463
|
}
|
|
570
464
|
|
|
571
465
|
class Company {
|
|
572
466
|
constructor(ctx) { this._ctx = ctx; }
|
|
573
467
|
|
|
574
|
-
async getAllCompanies() {
|
|
575
|
-
this._ctx.requireTokens();
|
|
576
|
-
const path = `/api/v1/company/`;
|
|
577
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
578
|
-
return data;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
468
|
async getCompanyById(companyId) {
|
|
582
469
|
this._ctx.requireTokens();
|
|
583
470
|
const path = `/api/v1/company/${encodeURIComponent(companyId)}`;
|
|
@@ -596,31 +483,6 @@
|
|
|
596
483
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
597
484
|
return data;
|
|
598
485
|
}
|
|
599
|
-
|
|
600
|
-
async adminListActiveCompanyTokens() {
|
|
601
|
-
this._ctx.requireTokens();
|
|
602
|
-
const path = `/api/v1/company/admin_create/`;
|
|
603
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
604
|
-
return data;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
async adminCreateCompanyToken({ email } = {}) {
|
|
608
|
-
this._ctx.requireTokens();
|
|
609
|
-
let path = `/api/v1/company/admin_create/`;
|
|
610
|
-
const query = new URLSearchParams();
|
|
611
|
-
if (email !== undefined) (Array.isArray(email) ? email : [email]).forEach(v => query.append('email', v));
|
|
612
|
-
const qs = query.toString();
|
|
613
|
-
if (qs) path += '?' + qs;
|
|
614
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
615
|
-
return data;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
async adminRevokeCompanyToken(tokenId) {
|
|
619
|
-
this._ctx.requireTokens();
|
|
620
|
-
const path = `/api/v1/company/admin_create/${encodeURIComponent(tokenId)}/revoke/`;
|
|
621
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
622
|
-
return data;
|
|
623
|
-
}
|
|
624
486
|
}
|
|
625
487
|
|
|
626
488
|
function stripUndef$6(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
@@ -1128,25 +990,6 @@
|
|
|
1128
990
|
}
|
|
1129
991
|
}
|
|
1130
992
|
|
|
1131
|
-
function stripUndef$2(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
1132
|
-
|
|
1133
|
-
class OauthClients {
|
|
1134
|
-
constructor(ctx) { this._ctx = ctx; }
|
|
1135
|
-
|
|
1136
|
-
async createClient(clientName, clientType, redirectUris, isFirstParty) {
|
|
1137
|
-
this._ctx.requireTokens();
|
|
1138
|
-
const path = `/oauth/clients`;
|
|
1139
|
-
const body = stripUndef$2({
|
|
1140
|
-
client_name: clientName,
|
|
1141
|
-
client_type: clientType,
|
|
1142
|
-
redirect_uris: redirectUris,
|
|
1143
|
-
is_first_party: isFirstParty,
|
|
1144
|
-
});
|
|
1145
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1146
|
-
return data;
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
|
|
1150
993
|
class OauthToken {
|
|
1151
994
|
constructor(ctx) { this._ctx = ctx; }
|
|
1152
995
|
|
|
@@ -1254,7 +1097,7 @@
|
|
|
1254
1097
|
}
|
|
1255
1098
|
}
|
|
1256
1099
|
|
|
1257
|
-
function stripUndef$
|
|
1100
|
+
function stripUndef$2(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
1258
1101
|
|
|
1259
1102
|
class Projects {
|
|
1260
1103
|
constructor(ctx) { this._ctx = ctx; }
|
|
@@ -1267,7 +1110,7 @@
|
|
|
1267
1110
|
if (models !== undefined) (Array.isArray(models) ? models : [models]).forEach(v => query.append('models', v));
|
|
1268
1111
|
const qs = query.toString();
|
|
1269
1112
|
if (qs) path += '?' + qs;
|
|
1270
|
-
const body = stripUndef$
|
|
1113
|
+
const body = stripUndef$2({
|
|
1271
1114
|
name: name,
|
|
1272
1115
|
private: private_,
|
|
1273
1116
|
type: type,
|
|
@@ -1320,13 +1163,6 @@
|
|
|
1320
1163
|
return data;
|
|
1321
1164
|
}
|
|
1322
1165
|
|
|
1323
|
-
async getAllUserProjectsAdmin(userId) {
|
|
1324
|
-
this._ctx.requireTokens();
|
|
1325
|
-
const path = `/api/v1/projects/admin/user/${encodeURIComponent(userId)}`;
|
|
1326
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1327
|
-
return data;
|
|
1328
|
-
}
|
|
1329
|
-
|
|
1330
1166
|
async getProjectById(projectId) {
|
|
1331
1167
|
this._ctx.requireTokens();
|
|
1332
1168
|
const path = `/api/v1/projects/${encodeURIComponent(projectId)}`;
|
|
@@ -1344,7 +1180,7 @@
|
|
|
1344
1180
|
async updateProject(projectId, { private: private_, type, description, directory, name, thumbnail } = {}) {
|
|
1345
1181
|
this._ctx.requireTokens();
|
|
1346
1182
|
const path = `/api/v1/projects/${encodeURIComponent(projectId)}`;
|
|
1347
|
-
const body = stripUndef$
|
|
1183
|
+
const body = stripUndef$2({
|
|
1348
1184
|
private: private_,
|
|
1349
1185
|
type: type,
|
|
1350
1186
|
description: description,
|
|
@@ -1413,13 +1249,6 @@
|
|
|
1413
1249
|
return data;
|
|
1414
1250
|
}
|
|
1415
1251
|
|
|
1416
|
-
async requestProjectAdminExport(projectTableName) {
|
|
1417
|
-
this._ctx.requireTokens();
|
|
1418
|
-
const path = `/api/v1/projects_admin_export/${encodeURIComponent(projectTableName)}`;
|
|
1419
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1420
|
-
return data;
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1423
1252
|
async getProjectDataExportUploadStatus(projectTableName, modelName) {
|
|
1424
1253
|
this._ctx.requireTokens();
|
|
1425
1254
|
const path = `/api/v1/projects/${encodeURIComponent(projectTableName)}/upload_status/${encodeURIComponent(modelName)}`;
|
|
@@ -1430,7 +1259,7 @@
|
|
|
1430
1259
|
async addProjectEvent(projectTableName, event, detail = undefined) {
|
|
1431
1260
|
this._ctx.requireTokens();
|
|
1432
1261
|
const path = `/api/v1/projects/${encodeURIComponent(projectTableName)}/event`;
|
|
1433
|
-
const body = stripUndef$
|
|
1262
|
+
const body = stripUndef$2({
|
|
1434
1263
|
event: event,
|
|
1435
1264
|
detail: detail,
|
|
1436
1265
|
});
|
|
@@ -1502,13 +1331,6 @@
|
|
|
1502
1331
|
class Photos {
|
|
1503
1332
|
constructor(ctx) { this._ctx = ctx; }
|
|
1504
1333
|
|
|
1505
|
-
async addPhotoToProject({ photo, tableName, sourceResolutionX, sourceResolutionY, dateTaken, latitude, longitude, filePath, title, clientSideId }) {
|
|
1506
|
-
this._ctx.requireTokens();
|
|
1507
|
-
const path = `/api/v1/photos/`;
|
|
1508
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, { photo, table_name: tableName, source_resolution_x: sourceResolutionX, source_resolution_y: sourceResolutionY, date_taken: dateTaken, latitude, longitude, file_path: filePath, title, client_side_id: clientSideId });
|
|
1509
|
-
return data;
|
|
1510
|
-
}
|
|
1511
|
-
|
|
1512
1334
|
async getPhotoFromProject(tableName, photoId, { keywordListId } = {}) {
|
|
1513
1335
|
this._ctx.requireTokens();
|
|
1514
1336
|
let path = `/api/v1/photos/${encodeURIComponent(tableName)}/${encodeURIComponent(photoId)}`;
|
|
@@ -1606,6 +1428,8 @@
|
|
|
1606
1428
|
}
|
|
1607
1429
|
}
|
|
1608
1430
|
|
|
1431
|
+
function stripUndef$1(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
1432
|
+
|
|
1609
1433
|
class Search {
|
|
1610
1434
|
constructor(ctx) { this._ctx = ctx; }
|
|
1611
1435
|
|
|
@@ -1634,27 +1458,41 @@
|
|
|
1634
1458
|
return data;
|
|
1635
1459
|
}
|
|
1636
1460
|
|
|
1637
|
-
async searchProjectPhotosText(projectTableName,
|
|
1461
|
+
async searchProjectPhotosText(projectTableName, searchText, size = undefined) {
|
|
1638
1462
|
this._ctx.requireTokens();
|
|
1639
|
-
|
|
1640
|
-
const
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1463
|
+
const path = `/api/v1/search/text/${encodeURIComponent(projectTableName)}/`;
|
|
1464
|
+
const body = stripUndef$1({
|
|
1465
|
+
search_text: searchText,
|
|
1466
|
+
size: size,
|
|
1467
|
+
});
|
|
1468
|
+
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1469
|
+
return data;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
async searchProjectPhotosNaturalLanguage(projectTableName, searchText, size = undefined) {
|
|
1473
|
+
this._ctx.requireTokens();
|
|
1474
|
+
const path = `/api/v1/search/nl/${encodeURIComponent(projectTableName)}/`;
|
|
1475
|
+
const body = stripUndef$1({
|
|
1476
|
+
search_text: searchText,
|
|
1477
|
+
size: size,
|
|
1478
|
+
});
|
|
1479
|
+
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1646
1480
|
return data;
|
|
1647
1481
|
}
|
|
1648
1482
|
|
|
1649
|
-
async
|
|
1483
|
+
async searchProjectPhotosNaturalLanguageHybrid(projectTableName, searchText, size = undefined, { blend, minCosine } = {}) {
|
|
1650
1484
|
this._ctx.requireTokens();
|
|
1651
|
-
let path = `/api/v1/search/
|
|
1485
|
+
let path = `/api/v1/search/nl_hybrid/${encodeURIComponent(projectTableName)}/`;
|
|
1652
1486
|
const query = new URLSearchParams();
|
|
1653
|
-
if (
|
|
1654
|
-
if (
|
|
1487
|
+
if (blend !== undefined) (Array.isArray(blend) ? blend : [blend]).forEach(v => query.append('blend', v));
|
|
1488
|
+
if (minCosine !== undefined) (Array.isArray(minCosine) ? minCosine : [minCosine]).forEach(v => query.append('min_cosine', v));
|
|
1655
1489
|
const qs = query.toString();
|
|
1656
1490
|
if (qs) path += '?' + qs;
|
|
1657
|
-
const
|
|
1491
|
+
const body = stripUndef$1({
|
|
1492
|
+
search_text: searchText,
|
|
1493
|
+
size: size,
|
|
1494
|
+
});
|
|
1495
|
+
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1658
1496
|
return data;
|
|
1659
1497
|
}
|
|
1660
1498
|
|
|
@@ -1782,18 +1620,6 @@
|
|
|
1782
1620
|
return data;
|
|
1783
1621
|
}
|
|
1784
1622
|
|
|
1785
|
-
async getAllUsers(ascOrDesc, { lastId, limit } = {}) {
|
|
1786
|
-
this._ctx.requireTokens();
|
|
1787
|
-
let path = `/api/v1/users/admin/sort/${encodeURIComponent(ascOrDesc)}/`;
|
|
1788
|
-
const query = new URLSearchParams();
|
|
1789
|
-
if (lastId !== undefined) (Array.isArray(lastId) ? lastId : [lastId]).forEach(v => query.append('last_id', v));
|
|
1790
|
-
if (limit !== undefined) (Array.isArray(limit) ? limit : [limit]).forEach(v => query.append('limit', v));
|
|
1791
|
-
const qs = query.toString();
|
|
1792
|
-
if (qs) path += '?' + qs;
|
|
1793
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1794
|
-
return data;
|
|
1795
|
-
}
|
|
1796
|
-
|
|
1797
1623
|
async updateUser(userId, { name, email, password, companyId, accountType, profilePicture, location, phoneNumber, birthday } = {}) {
|
|
1798
1624
|
this._ctx.requireTokens();
|
|
1799
1625
|
const path = `/api/v1/users/${encodeURIComponent(userId)}`;
|
|
@@ -1811,35 +1637,6 @@
|
|
|
1811
1637
|
const { data } = await this._ctx.client.request(path, 'PUT', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1812
1638
|
return data;
|
|
1813
1639
|
}
|
|
1814
|
-
|
|
1815
|
-
async updateUserByAdmin(userId, { name, email, password, companyId, accountType, profilePicture, location, phoneNumber, birthday } = {}) {
|
|
1816
|
-
this._ctx.requireTokens();
|
|
1817
|
-
const path = `/api/v1/users/admin/${encodeURIComponent(userId)}`;
|
|
1818
|
-
const body = stripUndef({
|
|
1819
|
-
name: name,
|
|
1820
|
-
email: email,
|
|
1821
|
-
password: password,
|
|
1822
|
-
company_id: companyId,
|
|
1823
|
-
account_type: accountType,
|
|
1824
|
-
profile_picture: profilePicture,
|
|
1825
|
-
location: location,
|
|
1826
|
-
phone_number: phoneNumber,
|
|
1827
|
-
birthday: birthday,
|
|
1828
|
-
});
|
|
1829
|
-
const { data } = await this._ctx.client.request(path, 'PUT', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1830
|
-
return data;
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
async deleteUser(userId, { newCompanyOwnerId } = {}) {
|
|
1834
|
-
this._ctx.requireTokens();
|
|
1835
|
-
let path = `/api/v1/users/delete/${encodeURIComponent(userId)}`;
|
|
1836
|
-
const query = new URLSearchParams();
|
|
1837
|
-
if (newCompanyOwnerId !== undefined) (Array.isArray(newCompanyOwnerId) ? newCompanyOwnerId : [newCompanyOwnerId]).forEach(v => query.append('new_company_owner_id', v));
|
|
1838
|
-
const qs = query.toString();
|
|
1839
|
-
if (qs) path += '?' + qs;
|
|
1840
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1841
|
-
return data;
|
|
1842
|
-
}
|
|
1843
1640
|
}
|
|
1844
1641
|
|
|
1845
1642
|
// Auto-generated — do not edit
|
|
@@ -1904,7 +1701,6 @@
|
|
|
1904
1701
|
|
|
1905
1702
|
const _ctx = new _Context(this);
|
|
1906
1703
|
this.aiModelCredits = new AiModelCredits(_ctx);
|
|
1907
|
-
this.admin = new Admin(_ctx);
|
|
1908
1704
|
this.company = new Company(_ctx);
|
|
1909
1705
|
this.curatedAlbums = new CuratedAlbums(_ctx);
|
|
1910
1706
|
this.customAlbums = new CustomAlbums(_ctx);
|
|
@@ -1912,7 +1708,6 @@
|
|
|
1912
1708
|
this.health = new Health(_ctx);
|
|
1913
1709
|
this.keywords = new Keywords(_ctx);
|
|
1914
1710
|
this.oAuthAuthorization = new OauthAuthorization(_ctx);
|
|
1915
|
-
this.oAuthClients = new OauthClients(_ctx);
|
|
1916
1711
|
this.oAuthToken = new OauthToken(_ctx);
|
|
1917
1712
|
this.oauthLogin = new OauthLogin(_ctx);
|
|
1918
1713
|
this.person = new Person(_ctx);
|
|
@@ -1950,7 +1745,6 @@
|
|
|
1950
1745
|
get refreshToken() { return this._refreshToken; }
|
|
1951
1746
|
}
|
|
1952
1747
|
|
|
1953
|
-
exports.Admin = Admin;
|
|
1954
1748
|
exports.AiModelCredits = AiModelCredits;
|
|
1955
1749
|
exports.ApiError = ApiError;
|
|
1956
1750
|
exports.Company = Company;
|
|
@@ -1965,7 +1759,6 @@
|
|
|
1965
1759
|
exports.OAuthError = OAuthError;
|
|
1966
1760
|
exports.OAuthErrorCode = OAuthErrorCode;
|
|
1967
1761
|
exports.OauthAuthorization = OauthAuthorization;
|
|
1968
|
-
exports.OauthClients = OauthClients;
|
|
1969
1762
|
exports.OauthLogin = OauthLogin;
|
|
1970
1763
|
exports.OauthToken = OauthToken;
|
|
1971
1764
|
exports.Person = Person;
|
package/package.json
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mediaviz/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.59",
|
|
4
|
+
"description": "MediaViz JavaScript SDK \u2014 auto-generated public endpoint client.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/mediaviz/mediaviz_sdk"
|
|
9
|
+
},
|
|
4
10
|
"type": "module",
|
|
5
11
|
"main": "./dist/sdk.cjs",
|
|
6
12
|
"module": "./dist/sdk.esm.js",
|
|
@@ -13,15 +19,15 @@
|
|
|
13
19
|
"default": "./dist/sdk.cjs"
|
|
14
20
|
}
|
|
15
21
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
22
|
+
"files": [
|
|
23
|
+
"dist",
|
|
24
|
+
"LICENSE",
|
|
25
|
+
"README.md"
|
|
26
|
+
],
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"access": "public"
|
|
18
29
|
},
|
|
19
30
|
"optionalDependencies": {
|
|
20
31
|
"sharp": "^0.33.0"
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"rollup": "^4.0.0",
|
|
24
|
-
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
25
|
-
"@rollup/plugin-commonjs": "^29.0.0"
|
|
26
32
|
}
|
|
27
33
|
}
|
package/MediaViz.js
DELETED
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// Auto-generated — do not edit
|
|
2
|
-
import { OAuthClient } from './_oauth.js';
|
|
3
|
-
import { AiModelCredits } from './ai_model_credits.js';
|
|
4
|
-
import { Admin } from './admin.js';
|
|
5
|
-
import { Company } from './company.js';
|
|
6
|
-
import { CuratedAlbums } from './curated_albums.js';
|
|
7
|
-
import { CustomAlbums } from './custom_albums.js';
|
|
8
|
-
import { EmailTokens } from './email_tokens.js';
|
|
9
|
-
import { Health } from './health.js';
|
|
10
|
-
import { Keywords } from './keywords.js';
|
|
11
|
-
import { OauthAuthorization } from './oauth_authorization.js';
|
|
12
|
-
import { OauthClients } from './oauth_clients.js';
|
|
13
|
-
import { OauthToken } from './oauth_token.js';
|
|
14
|
-
import { OauthLogin } from './oauth_login.js';
|
|
15
|
-
import { Person } from './person.js';
|
|
16
|
-
import { Photoupload } from './photoupload.js';
|
|
17
|
-
import { Photos } from './photos.js';
|
|
18
|
-
import { Projects } from './projects.js';
|
|
19
|
-
import { Search } from './search.js';
|
|
20
|
-
import { Users } from './users.js';
|
|
21
|
-
|
|
22
|
-
function _env(key) {
|
|
23
|
-
if (typeof process !== 'undefined' && process.env) return process.env[key];
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
class _Context {
|
|
28
|
-
constructor(mv) { this._mv = mv; }
|
|
29
|
-
get client() { return this._mv._oauthClient; }
|
|
30
|
-
get accessToken() { return this._mv._accessToken; }
|
|
31
|
-
get refreshToken() { return this._mv._refreshToken; }
|
|
32
|
-
get baseUrl() { return this._mv._config.baseUrl; }
|
|
33
|
-
get hosts() { return this._mv._hosts; }
|
|
34
|
-
requireHost(key) {
|
|
35
|
-
const url = this._mv._hosts[key];
|
|
36
|
-
if (!url) throw new Error(`Host '${key}' not configured. Pass hosts.${key} in MediaViz constructor or set the corresponding env var.`);
|
|
37
|
-
return url;
|
|
38
|
-
}
|
|
39
|
-
requireTokens() {
|
|
40
|
-
if (!this._mv._accessToken) throw new Error('Not authenticated. Call authenticate(), handleCallback(), or setTokens() first.');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
class _TokenTrackingClient {
|
|
45
|
-
constructor(mv, inner) { this._mv = mv; this._inner = inner; }
|
|
46
|
-
async request(url, method, accessToken, refreshToken, body) {
|
|
47
|
-
const onRefreshSuccess = (newTokens) => {
|
|
48
|
-
this._mv._accessToken = newTokens.access_token;
|
|
49
|
-
this._mv._refreshToken = newTokens.refresh_token;
|
|
50
|
-
if (this._mv._onTokenRefresh) this._mv._onTokenRefresh(newTokens);
|
|
51
|
-
};
|
|
52
|
-
return this._inner.request(url, method, accessToken, refreshToken, body, onRefreshSuccess);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export class MediaViz {
|
|
57
|
-
constructor(config = {}) {
|
|
58
|
-
this._config = {
|
|
59
|
-
clientId: config.clientId ?? _env('MEDIAVIZ_CLIENT_ID'),
|
|
60
|
-
clientSecret: config.clientSecret ?? _env('MEDIAVIZ_CLIENT_SECRET'),
|
|
61
|
-
baseUrl: config.baseUrl ?? _env('MEDIAVIZ_BASE_URL') ?? 'https://api.mediaviz.ai',
|
|
62
|
-
redirectUri: config.redirectUri ?? _env('MEDIAVIZ_REDIRECT_URI'),
|
|
63
|
-
};
|
|
64
|
-
this._hosts = {
|
|
65
|
-
photoUpload: config.hosts?.photoUpload ?? _env('MEDIAVIZ_PHOTO_UPLOAD_URL'),
|
|
66
|
-
...(config.hosts || {}),
|
|
67
|
-
};
|
|
68
|
-
this._accessToken = config.accessToken ?? null;
|
|
69
|
-
this._refreshToken = config.refreshToken ?? null;
|
|
70
|
-
this._onTokenRefresh = config.onTokenRefresh ?? null;
|
|
71
|
-
|
|
72
|
-
const _inner = new OAuthClient({
|
|
73
|
-
clientId: this._config.clientId,
|
|
74
|
-
clientSecret: this._config.clientSecret,
|
|
75
|
-
baseUrl: this._config.baseUrl,
|
|
76
|
-
redirectUri: this._config.redirectUri,
|
|
77
|
-
});
|
|
78
|
-
this._oauthClient = new _TokenTrackingClient(this, _inner);
|
|
79
|
-
|
|
80
|
-
const _ctx = new _Context(this);
|
|
81
|
-
this.aiModelCredits = new AiModelCredits(_ctx);
|
|
82
|
-
this.admin = new Admin(_ctx);
|
|
83
|
-
this.company = new Company(_ctx);
|
|
84
|
-
this.curatedAlbums = new CuratedAlbums(_ctx);
|
|
85
|
-
this.customAlbums = new CustomAlbums(_ctx);
|
|
86
|
-
this.emailTokens = new EmailTokens(_ctx);
|
|
87
|
-
this.health = new Health(_ctx);
|
|
88
|
-
this.keywords = new Keywords(_ctx);
|
|
89
|
-
this.oAuthAuthorization = new OauthAuthorization(_ctx);
|
|
90
|
-
this.oAuthClients = new OauthClients(_ctx);
|
|
91
|
-
this.oAuthToken = new OauthToken(_ctx);
|
|
92
|
-
this.oauthLogin = new OauthLogin(_ctx);
|
|
93
|
-
this.person = new Person(_ctx);
|
|
94
|
-
this.photoUpload = new Photoupload(_ctx);
|
|
95
|
-
this.photos = new Photos(_ctx);
|
|
96
|
-
this.projects = new Projects(_ctx);
|
|
97
|
-
this.search = new Search(_ctx);
|
|
98
|
-
this.users = new Users(_ctx);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
async authenticate() {
|
|
102
|
-
const tokens = await this._oauthClient._inner.getClientCredentialsToken();
|
|
103
|
-
this._accessToken = tokens.access_token;
|
|
104
|
-
this._refreshToken = tokens.refresh_token ?? null;
|
|
105
|
-
return tokens;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
async getAuthorizationUrl(state) {
|
|
109
|
-
return this._oauthClient._inner.generateAuthorizationUrl(state);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
async handleCallback(code, codeVerifier) {
|
|
113
|
-
const tokens = await this._oauthClient._inner.exchangeCode(code, codeVerifier);
|
|
114
|
-
this._accessToken = tokens.access_token;
|
|
115
|
-
this._refreshToken = tokens.refresh_token;
|
|
116
|
-
return tokens;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
setTokens(accessToken, refreshToken) {
|
|
120
|
-
this._accessToken = accessToken;
|
|
121
|
-
this._refreshToken = refreshToken;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
get accessToken() { return this._accessToken; }
|
|
125
|
-
get refreshToken() { return this._refreshToken; }
|
|
126
|
-
}
|
package/_oauth.js
DELETED
package/admin.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
export class Admin {
|
|
2
|
-
constructor(ctx) { this._ctx = ctx; }
|
|
3
|
-
|
|
4
|
-
async insertLabelCategoryMatrix() {
|
|
5
|
-
this._ctx.requireTokens();
|
|
6
|
-
const path = `/api/v1/admin/insert_label_category_matrix`;
|
|
7
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
8
|
-
return data;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
async generateMidLevelCategoryKeywordAlignment() {
|
|
12
|
-
this._ctx.requireTokens();
|
|
13
|
-
const path = `/api/v1/admin/generate_mid_level_category_keyword_alignment`;
|
|
14
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
15
|
-
return data;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async getCategoryLabels(category) {
|
|
19
|
-
this._ctx.requireTokens();
|
|
20
|
-
const path = `/api/v1/admin/category_labels/${encodeURIComponent(category)}`;
|
|
21
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
22
|
-
return data;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
async adminDumpCompanyNlpIndex(companyId) {
|
|
26
|
-
this._ctx.requireTokens();
|
|
27
|
-
const path = `/api/v1/admin/dump_company_nlp_index/${encodeURIComponent(companyId)}`;
|
|
28
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
29
|
-
return data;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
async getAllKeywordGroupsAndSubgroups() {
|
|
33
|
-
this._ctx.requireTokens();
|
|
34
|
-
const path = `/api/v1/admin/keyword_group`;
|
|
35
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
36
|
-
return data;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async getKeywordGroupsLabelsByKeywordGroup(keywordGroup, { subgroup } = {}) {
|
|
40
|
-
this._ctx.requireTokens();
|
|
41
|
-
let path = `/api/v1/admin/keyword_group/${encodeURIComponent(keywordGroup)}/`;
|
|
42
|
-
const query = new URLSearchParams();
|
|
43
|
-
if (subgroup !== undefined) (Array.isArray(subgroup) ? subgroup : [subgroup]).forEach(v => query.append('subgroup', v));
|
|
44
|
-
const qs = query.toString();
|
|
45
|
-
if (qs) path += '?' + qs;
|
|
46
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
47
|
-
return data;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
async adminCreateCompanyNlpIndexes({ companyIds } = {}) {
|
|
51
|
-
this._ctx.requireTokens();
|
|
52
|
-
let path = `/api/v1/admin/create_company_nlp_indexes/`;
|
|
53
|
-
const query = new URLSearchParams();
|
|
54
|
-
if (companyIds !== undefined) (Array.isArray(companyIds) ? companyIds : [companyIds]).forEach(v => query.append('company_ids', v));
|
|
55
|
-
const qs = query.toString();
|
|
56
|
-
if (qs) path += '?' + qs;
|
|
57
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
58
|
-
return data;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async adminDeleteCompanyNlpIndexes({ companyIds } = {}) {
|
|
62
|
-
this._ctx.requireTokens();
|
|
63
|
-
let path = `/api/v1/admin/delete_company_nlp_indexes/`;
|
|
64
|
-
const query = new URLSearchParams();
|
|
65
|
-
if (companyIds !== undefined) (Array.isArray(companyIds) ? companyIds : [companyIds]).forEach(v => query.append('company_ids', v));
|
|
66
|
-
const qs = query.toString();
|
|
67
|
-
if (qs) path += '?' + qs;
|
|
68
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
69
|
-
return data;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async adminDeleteUserProjects({ userIds } = {}) {
|
|
73
|
-
this._ctx.requireTokens();
|
|
74
|
-
let path = `/api/v1/admin/delete_user_projects/`;
|
|
75
|
-
const query = new URLSearchParams();
|
|
76
|
-
if (userIds !== undefined) (Array.isArray(userIds) ? userIds : [userIds]).forEach(v => query.append('user_ids', v));
|
|
77
|
-
const qs = query.toString();
|
|
78
|
-
if (qs) path += '?' + qs;
|
|
79
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
80
|
-
return data;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
async adminDeleteUser({ userIds } = {}) {
|
|
84
|
-
this._ctx.requireTokens();
|
|
85
|
-
let path = `/api/v1/admin/delete_user/`;
|
|
86
|
-
const query = new URLSearchParams();
|
|
87
|
-
if (userIds !== undefined) (Array.isArray(userIds) ? userIds : [userIds]).forEach(v => query.append('user_ids', v));
|
|
88
|
-
const qs = query.toString();
|
|
89
|
-
if (qs) path += '?' + qs;
|
|
90
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
91
|
-
return data;
|
|
92
|
-
}
|
|
93
|
-
}
|