@mediaviz/sdk 0.1.0 → 1.0.60
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 +21 -260
- package/dist/sdk.esm.js +22 -259
- package/dist/sdk.umd.js +21 -260
- package/package.json +15 -1
- 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/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 MediaViz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/sdk.cjs
CHANGED
|
@@ -456,124 +456,11 @@ class AiModelCredits {
|
|
|
456
456
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
457
457
|
return data;
|
|
458
458
|
}
|
|
459
|
-
|
|
460
|
-
async upsertModelCreditRelationship({ modelName, newCreditValue } = {}) {
|
|
461
|
-
this._ctx.requireTokens();
|
|
462
|
-
let path = `/api/v1/model_credit/upsert`;
|
|
463
|
-
const query = new URLSearchParams();
|
|
464
|
-
if (modelName !== undefined) (Array.isArray(modelName) ? modelName : [modelName]).forEach(v => query.append('model_name', v));
|
|
465
|
-
if (newCreditValue !== undefined) (Array.isArray(newCreditValue) ? newCreditValue : [newCreditValue]).forEach(v => query.append('new_credit_value', v));
|
|
466
|
-
const qs = query.toString();
|
|
467
|
-
if (qs) path += '?' + qs;
|
|
468
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
469
|
-
return data;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
class Admin {
|
|
474
|
-
constructor(ctx) { this._ctx = ctx; }
|
|
475
|
-
|
|
476
|
-
async insertLabelCategoryMatrix() {
|
|
477
|
-
this._ctx.requireTokens();
|
|
478
|
-
const path = `/api/v1/admin/insert_label_category_matrix`;
|
|
479
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
480
|
-
return data;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
async generateMidLevelCategoryKeywordAlignment() {
|
|
484
|
-
this._ctx.requireTokens();
|
|
485
|
-
const path = `/api/v1/admin/generate_mid_level_category_keyword_alignment`;
|
|
486
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
487
|
-
return data;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
async getCategoryLabels(category) {
|
|
491
|
-
this._ctx.requireTokens();
|
|
492
|
-
const path = `/api/v1/admin/category_labels/${encodeURIComponent(category)}`;
|
|
493
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
494
|
-
return data;
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
async adminDumpCompanyNlpIndex(companyId) {
|
|
498
|
-
this._ctx.requireTokens();
|
|
499
|
-
const path = `/api/v1/admin/dump_company_nlp_index/${encodeURIComponent(companyId)}`;
|
|
500
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
501
|
-
return data;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
async getAllKeywordGroupsAndSubgroups() {
|
|
505
|
-
this._ctx.requireTokens();
|
|
506
|
-
const path = `/api/v1/admin/keyword_group`;
|
|
507
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
508
|
-
return data;
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
async getKeywordGroupsLabelsByKeywordGroup(keywordGroup, { subgroup } = {}) {
|
|
512
|
-
this._ctx.requireTokens();
|
|
513
|
-
let path = `/api/v1/admin/keyword_group/${encodeURIComponent(keywordGroup)}/`;
|
|
514
|
-
const query = new URLSearchParams();
|
|
515
|
-
if (subgroup !== undefined) (Array.isArray(subgroup) ? subgroup : [subgroup]).forEach(v => query.append('subgroup', v));
|
|
516
|
-
const qs = query.toString();
|
|
517
|
-
if (qs) path += '?' + qs;
|
|
518
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
519
|
-
return data;
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
async adminCreateCompanyNlpIndexes({ companyIds } = {}) {
|
|
523
|
-
this._ctx.requireTokens();
|
|
524
|
-
let path = `/api/v1/admin/create_company_nlp_indexes/`;
|
|
525
|
-
const query = new URLSearchParams();
|
|
526
|
-
if (companyIds !== undefined) (Array.isArray(companyIds) ? companyIds : [companyIds]).forEach(v => query.append('company_ids', v));
|
|
527
|
-
const qs = query.toString();
|
|
528
|
-
if (qs) path += '?' + qs;
|
|
529
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
530
|
-
return data;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
async adminDeleteCompanyNlpIndexes({ companyIds } = {}) {
|
|
534
|
-
this._ctx.requireTokens();
|
|
535
|
-
let path = `/api/v1/admin/delete_company_nlp_indexes/`;
|
|
536
|
-
const query = new URLSearchParams();
|
|
537
|
-
if (companyIds !== undefined) (Array.isArray(companyIds) ? companyIds : [companyIds]).forEach(v => query.append('company_ids', v));
|
|
538
|
-
const qs = query.toString();
|
|
539
|
-
if (qs) path += '?' + qs;
|
|
540
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
541
|
-
return data;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
async adminDeleteUserProjects({ userIds } = {}) {
|
|
545
|
-
this._ctx.requireTokens();
|
|
546
|
-
let path = `/api/v1/admin/delete_user_projects/`;
|
|
547
|
-
const query = new URLSearchParams();
|
|
548
|
-
if (userIds !== undefined) (Array.isArray(userIds) ? userIds : [userIds]).forEach(v => query.append('user_ids', v));
|
|
549
|
-
const qs = query.toString();
|
|
550
|
-
if (qs) path += '?' + qs;
|
|
551
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
552
|
-
return data;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
async adminDeleteUser({ userIds } = {}) {
|
|
556
|
-
this._ctx.requireTokens();
|
|
557
|
-
let path = `/api/v1/admin/delete_user/`;
|
|
558
|
-
const query = new URLSearchParams();
|
|
559
|
-
if (userIds !== undefined) (Array.isArray(userIds) ? userIds : [userIds]).forEach(v => query.append('user_ids', v));
|
|
560
|
-
const qs = query.toString();
|
|
561
|
-
if (qs) path += '?' + qs;
|
|
562
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
563
|
-
return data;
|
|
564
|
-
}
|
|
565
459
|
}
|
|
566
460
|
|
|
567
461
|
class Company {
|
|
568
462
|
constructor(ctx) { this._ctx = ctx; }
|
|
569
463
|
|
|
570
|
-
async getAllCompanies() {
|
|
571
|
-
this._ctx.requireTokens();
|
|
572
|
-
const path = `/api/v1/company/`;
|
|
573
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
574
|
-
return data;
|
|
575
|
-
}
|
|
576
|
-
|
|
577
464
|
async getCompanyById(companyId) {
|
|
578
465
|
this._ctx.requireTokens();
|
|
579
466
|
const path = `/api/v1/company/${encodeURIComponent(companyId)}`;
|
|
@@ -592,34 +479,9 @@ class Company {
|
|
|
592
479
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
593
480
|
return data;
|
|
594
481
|
}
|
|
595
|
-
|
|
596
|
-
async adminListActiveCompanyTokens() {
|
|
597
|
-
this._ctx.requireTokens();
|
|
598
|
-
const path = `/api/v1/company/admin_create/`;
|
|
599
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
600
|
-
return data;
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
async adminCreateCompanyToken({ email } = {}) {
|
|
604
|
-
this._ctx.requireTokens();
|
|
605
|
-
let path = `/api/v1/company/admin_create/`;
|
|
606
|
-
const query = new URLSearchParams();
|
|
607
|
-
if (email !== undefined) (Array.isArray(email) ? email : [email]).forEach(v => query.append('email', v));
|
|
608
|
-
const qs = query.toString();
|
|
609
|
-
if (qs) path += '?' + qs;
|
|
610
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
611
|
-
return data;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
async adminRevokeCompanyToken(tokenId) {
|
|
615
|
-
this._ctx.requireTokens();
|
|
616
|
-
const path = `/api/v1/company/admin_create/${encodeURIComponent(tokenId)}/revoke/`;
|
|
617
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
618
|
-
return data;
|
|
619
|
-
}
|
|
620
482
|
}
|
|
621
483
|
|
|
622
|
-
function stripUndef$
|
|
484
|
+
function stripUndef$5(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
623
485
|
|
|
624
486
|
class CuratedAlbums {
|
|
625
487
|
constructor(ctx) { this._ctx = ctx; }
|
|
@@ -627,7 +489,7 @@ class CuratedAlbums {
|
|
|
627
489
|
async createCuratedAlbum(projectTableName, name, description = undefined, confidenceValue = undefined) {
|
|
628
490
|
this._ctx.requireTokens();
|
|
629
491
|
const path = `/api/v1/curated_album/project/${encodeURIComponent(projectTableName)}`;
|
|
630
|
-
const body = stripUndef$
|
|
492
|
+
const body = stripUndef$5({
|
|
631
493
|
name: name,
|
|
632
494
|
description: description,
|
|
633
495
|
confidence_value: confidenceValue,
|
|
@@ -681,7 +543,7 @@ class CuratedAlbums {
|
|
|
681
543
|
async updateCuratedAlbum(albumId, { name, description, confidenceValue } = {}) {
|
|
682
544
|
this._ctx.requireTokens();
|
|
683
545
|
const path = `/api/v1/curated_album/${encodeURIComponent(albumId)}`;
|
|
684
|
-
const body = stripUndef$
|
|
546
|
+
const body = stripUndef$5({
|
|
685
547
|
name: name,
|
|
686
548
|
description: description,
|
|
687
549
|
confidence_value: confidenceValue,
|
|
@@ -705,7 +567,7 @@ class CuratedAlbums {
|
|
|
705
567
|
}
|
|
706
568
|
}
|
|
707
569
|
|
|
708
|
-
function stripUndef$
|
|
570
|
+
function stripUndef$4(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
709
571
|
|
|
710
572
|
class CustomAlbums {
|
|
711
573
|
constructor(ctx) { this._ctx = ctx; }
|
|
@@ -753,7 +615,7 @@ class CustomAlbums {
|
|
|
753
615
|
async createProjectCustomAlbum(projectTableName, { name, description, photoIdInclusionList, photoIdRemovalList } = {}) {
|
|
754
616
|
this._ctx.requireTokens();
|
|
755
617
|
const path = `/api/v1/custom_album/project/${encodeURIComponent(projectTableName)}`;
|
|
756
|
-
const body = stripUndef$
|
|
618
|
+
const body = stripUndef$4({
|
|
757
619
|
name: name,
|
|
758
620
|
description: description,
|
|
759
621
|
photo_id_inclusion_list: photoIdInclusionList,
|
|
@@ -766,7 +628,7 @@ class CustomAlbums {
|
|
|
766
628
|
async updateCustomAlbum(albumId, { name, description, photoIdInclusionList, photoIdRemovalList } = {}) {
|
|
767
629
|
this._ctx.requireTokens();
|
|
768
630
|
const path = `/api/v1/custom_album/${encodeURIComponent(albumId)}`;
|
|
769
|
-
const body = stripUndef$
|
|
631
|
+
const body = stripUndef$4({
|
|
770
632
|
name: name,
|
|
771
633
|
description: description,
|
|
772
634
|
photo_id_inclusion_list: photoIdInclusionList,
|
|
@@ -866,7 +728,7 @@ async function handleResponse(response) {
|
|
|
866
728
|
}
|
|
867
729
|
}
|
|
868
730
|
|
|
869
|
-
function stripUndef$
|
|
731
|
+
function stripUndef$3(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
870
732
|
|
|
871
733
|
class EmailTokens {
|
|
872
734
|
constructor(ctx) { this._ctx = ctx; }
|
|
@@ -897,7 +759,7 @@ class EmailTokens {
|
|
|
897
759
|
}
|
|
898
760
|
|
|
899
761
|
async validateToken(token) {
|
|
900
|
-
const body = stripUndef$
|
|
762
|
+
const body = stripUndef$3({
|
|
901
763
|
token: token,
|
|
902
764
|
});
|
|
903
765
|
const resp = await fetch(this._ctx.baseUrl + `/api/v1/validate-token`, {
|
|
@@ -909,7 +771,7 @@ class EmailTokens {
|
|
|
909
771
|
}
|
|
910
772
|
|
|
911
773
|
async resetPassword(token, newPassword) {
|
|
912
|
-
const body = stripUndef$
|
|
774
|
+
const body = stripUndef$3({
|
|
913
775
|
token: token,
|
|
914
776
|
new_password: newPassword,
|
|
915
777
|
});
|
|
@@ -948,7 +810,7 @@ class Health {
|
|
|
948
810
|
}
|
|
949
811
|
}
|
|
950
812
|
|
|
951
|
-
function stripUndef$
|
|
813
|
+
function stripUndef$2(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
952
814
|
|
|
953
815
|
class Keywords {
|
|
954
816
|
constructor(ctx) { this._ctx = ctx; }
|
|
@@ -956,7 +818,7 @@ class Keywords {
|
|
|
956
818
|
async createKeywordFilteringList(name, projectList = undefined) {
|
|
957
819
|
this._ctx.requireTokens();
|
|
958
820
|
const path = `/api/v1/keyword/`;
|
|
959
|
-
const body = stripUndef$
|
|
821
|
+
const body = stripUndef$2({
|
|
960
822
|
name: name,
|
|
961
823
|
project_list: projectList,
|
|
962
824
|
});
|
|
@@ -1002,7 +864,7 @@ class Keywords {
|
|
|
1002
864
|
async updateKeywordFilteringListLabels(keywordListId, listKeywordsToInclude, listKeywordsToExclude) {
|
|
1003
865
|
this._ctx.requireTokens();
|
|
1004
866
|
const path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}`;
|
|
1005
|
-
const body = stripUndef$
|
|
867
|
+
const body = stripUndef$2({
|
|
1006
868
|
list_keywords_to_include: listKeywordsToInclude,
|
|
1007
869
|
list_keywords_to_exclude: listKeywordsToExclude,
|
|
1008
870
|
});
|
|
@@ -1013,7 +875,7 @@ class Keywords {
|
|
|
1013
875
|
async updateKeywordFilteringListDetails(keywordListId, { name, projectList } = {}) {
|
|
1014
876
|
this._ctx.requireTokens();
|
|
1015
877
|
const path = `/api/v1/keyword/details/${encodeURIComponent(keywordListId)}`;
|
|
1016
|
-
const body = stripUndef$
|
|
878
|
+
const body = stripUndef$2({
|
|
1017
879
|
name: name,
|
|
1018
880
|
project_list: projectList,
|
|
1019
881
|
});
|
|
@@ -1124,25 +986,6 @@ class OauthAuthorization {
|
|
|
1124
986
|
}
|
|
1125
987
|
}
|
|
1126
988
|
|
|
1127
|
-
function stripUndef$2(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
1128
|
-
|
|
1129
|
-
class OauthClients {
|
|
1130
|
-
constructor(ctx) { this._ctx = ctx; }
|
|
1131
|
-
|
|
1132
|
-
async createClient(clientName, clientType, redirectUris, isFirstParty) {
|
|
1133
|
-
this._ctx.requireTokens();
|
|
1134
|
-
const path = `/oauth/clients`;
|
|
1135
|
-
const body = stripUndef$2({
|
|
1136
|
-
client_name: clientName,
|
|
1137
|
-
client_type: clientType,
|
|
1138
|
-
redirect_uris: redirectUris,
|
|
1139
|
-
is_first_party: isFirstParty,
|
|
1140
|
-
});
|
|
1141
|
-
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1142
|
-
return data;
|
|
1143
|
-
}
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
989
|
class OauthToken {
|
|
1147
990
|
constructor(ctx) { this._ctx = ctx; }
|
|
1148
991
|
|
|
@@ -1316,13 +1159,6 @@ class Projects {
|
|
|
1316
1159
|
return data;
|
|
1317
1160
|
}
|
|
1318
1161
|
|
|
1319
|
-
async getAllUserProjectsAdmin(userId) {
|
|
1320
|
-
this._ctx.requireTokens();
|
|
1321
|
-
const path = `/api/v1/projects/admin/user/${encodeURIComponent(userId)}`;
|
|
1322
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1323
|
-
return data;
|
|
1324
|
-
}
|
|
1325
|
-
|
|
1326
1162
|
async getProjectById(projectId) {
|
|
1327
1163
|
this._ctx.requireTokens();
|
|
1328
1164
|
const path = `/api/v1/projects/${encodeURIComponent(projectId)}`;
|
|
@@ -1409,13 +1245,6 @@ class Projects {
|
|
|
1409
1245
|
return data;
|
|
1410
1246
|
}
|
|
1411
1247
|
|
|
1412
|
-
async requestProjectAdminExport(projectTableName) {
|
|
1413
|
-
this._ctx.requireTokens();
|
|
1414
|
-
const path = `/api/v1/projects_admin_export/${encodeURIComponent(projectTableName)}`;
|
|
1415
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1416
|
-
return data;
|
|
1417
|
-
}
|
|
1418
|
-
|
|
1419
1248
|
async getProjectDataExportUploadStatus(projectTableName, modelName) {
|
|
1420
1249
|
this._ctx.requireTokens();
|
|
1421
1250
|
const path = `/api/v1/projects/${encodeURIComponent(projectTableName)}/upload_status/${encodeURIComponent(modelName)}`;
|
|
@@ -1445,18 +1274,18 @@ class Projects {
|
|
|
1445
1274
|
class Photoupload {
|
|
1446
1275
|
constructor(ctx) { this._ctx = ctx; this._caches = {}; }
|
|
1447
1276
|
|
|
1448
|
-
async uploadPhotoToMediaviz(
|
|
1277
|
+
async uploadPhotoToMediaviz({ fileContent, mimetype, filePath }, { companyId, userId, projectTableName, clientSideId, title, blur, colors, faceRecognition, imageDescribe, imageClassification, imageComparison, size, sourceResolutionX, sourceResolutionY, dateTaken, latitude, longitude, bucketName, photoIndex } = {}) {
|
|
1449
1278
|
this._ctx.requireTokens();
|
|
1450
1279
|
const baseUrl = this._ctx.requireHost('photoUpload');
|
|
1451
1280
|
const headers = {
|
|
1452
1281
|
'Content-Type': 'application/json',
|
|
1453
1282
|
'Authorization': this._ctx.accessToken,
|
|
1454
|
-
'x-company-id': companyId,
|
|
1455
|
-
'x-user-id': userId,
|
|
1456
|
-
'x-project-table-name': projectTableName,
|
|
1457
|
-
'x-title': title,
|
|
1458
1283
|
};
|
|
1284
|
+
if (companyId !== undefined) headers['x-company-id'] = companyId;
|
|
1285
|
+
if (userId !== undefined) headers['x-user-id'] = userId;
|
|
1286
|
+
if (projectTableName !== undefined) headers['x-project-table-name'] = projectTableName;
|
|
1459
1287
|
if (clientSideId !== undefined) headers['x-client-side-id'] = clientSideId;
|
|
1288
|
+
if (title !== undefined) headers['x-title'] = title;
|
|
1460
1289
|
if (blur !== undefined) headers['x-blur'] = blur;
|
|
1461
1290
|
if (colors !== undefined) headers['x-colors'] = colors;
|
|
1462
1291
|
if (faceRecognition !== undefined) headers['x-face-recognition'] = faceRecognition;
|
|
@@ -1469,7 +1298,8 @@ class Photoupload {
|
|
|
1469
1298
|
if (dateTaken !== undefined) headers['x-date-taken'] = dateTaken;
|
|
1470
1299
|
if (latitude !== undefined) headers['x-latitude'] = latitude;
|
|
1471
1300
|
if (longitude !== undefined) headers['x-longitude'] = longitude;
|
|
1472
|
-
if (
|
|
1301
|
+
if (bucketName !== undefined) headers['x-bucket-name'] = bucketName;
|
|
1302
|
+
if (photoIndex !== undefined) headers['x-photo-index'] = photoIndex;
|
|
1473
1303
|
const resp = await fetch(baseUrl + `/photo_upload`, {
|
|
1474
1304
|
method: 'POST',
|
|
1475
1305
|
headers,
|
|
@@ -1489,7 +1319,7 @@ class Photoupload {
|
|
|
1489
1319
|
this._caches['_get_template'].set(_cacheKey_get_template, template);
|
|
1490
1320
|
}
|
|
1491
1321
|
|
|
1492
|
-
const upload_result = await this.uploadPhotoToMediaviz(
|
|
1322
|
+
const upload_result = await this.uploadPhotoToMediaviz({ fileContent: photo.fileContent, mimetype: photo.mimetype, filePath: photo.filePath }, { companyId: companyId, userId: userId, projectTableName: projectTableName, clientSideId: photo.clientSideId, title: photo.title, blur: photo.blur, colors: photo.colors, faceRecognition: photo.faceRecognition, imageDescribe: photo.imageDescribe, imageClassification: photo.imageClassification, imageComparison: photo.imageComparison, size: photo.size, sourceResolutionX: photo.sourceResolutionX, sourceResolutionY: photo.sourceResolutionY, dateTaken: photo.dateTaken, latitude: photo.latitude, longitude: photo.longitude, bucketName: template.bucket_name, photoIndex: photoIndex });
|
|
1493
1323
|
|
|
1494
1324
|
return upload_result;
|
|
1495
1325
|
}
|
|
@@ -1630,30 +1460,6 @@ class Search {
|
|
|
1630
1460
|
return data;
|
|
1631
1461
|
}
|
|
1632
1462
|
|
|
1633
|
-
async searchProjectPhotosText(projectTableName, { q, size } = {}) {
|
|
1634
|
-
this._ctx.requireTokens();
|
|
1635
|
-
let path = `/api/v1/search/text/${encodeURIComponent(projectTableName)}/`;
|
|
1636
|
-
const query = new URLSearchParams();
|
|
1637
|
-
if (q !== undefined) (Array.isArray(q) ? q : [q]).forEach(v => query.append('q', v));
|
|
1638
|
-
if (size !== undefined) (Array.isArray(size) ? size : [size]).forEach(v => query.append('size', v));
|
|
1639
|
-
const qs = query.toString();
|
|
1640
|
-
if (qs) path += '?' + qs;
|
|
1641
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1642
|
-
return data;
|
|
1643
|
-
}
|
|
1644
|
-
|
|
1645
|
-
async searchProjectPhotosNaturalLanguage(projectTableName, { searchText, size } = {}) {
|
|
1646
|
-
this._ctx.requireTokens();
|
|
1647
|
-
let path = `/api/v1/search/nl/${encodeURIComponent(projectTableName)}/`;
|
|
1648
|
-
const query = new URLSearchParams();
|
|
1649
|
-
if (searchText !== undefined) (Array.isArray(searchText) ? searchText : [searchText]).forEach(v => query.append('search_text', v));
|
|
1650
|
-
if (size !== undefined) (Array.isArray(size) ? size : [size]).forEach(v => query.append('size', v));
|
|
1651
|
-
const qs = query.toString();
|
|
1652
|
-
if (qs) path += '?' + qs;
|
|
1653
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1654
|
-
return data;
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
1463
|
async getProjectSavedSearches(projectTableName) {
|
|
1658
1464
|
this._ctx.requireTokens();
|
|
1659
1465
|
const path = `/api/v1/search/saved/${encodeURIComponent(projectTableName)}/`;
|
|
@@ -1778,18 +1584,6 @@ class Users {
|
|
|
1778
1584
|
return data;
|
|
1779
1585
|
}
|
|
1780
1586
|
|
|
1781
|
-
async getAllUsers(ascOrDesc, { lastId, limit } = {}) {
|
|
1782
|
-
this._ctx.requireTokens();
|
|
1783
|
-
let path = `/api/v1/users/admin/sort/${encodeURIComponent(ascOrDesc)}/`;
|
|
1784
|
-
const query = new URLSearchParams();
|
|
1785
|
-
if (lastId !== undefined) (Array.isArray(lastId) ? lastId : [lastId]).forEach(v => query.append('last_id', v));
|
|
1786
|
-
if (limit !== undefined) (Array.isArray(limit) ? limit : [limit]).forEach(v => query.append('limit', v));
|
|
1787
|
-
const qs = query.toString();
|
|
1788
|
-
if (qs) path += '?' + qs;
|
|
1789
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1790
|
-
return data;
|
|
1791
|
-
}
|
|
1792
|
-
|
|
1793
1587
|
async updateUser(userId, { name, email, password, companyId, accountType, profilePicture, location, phoneNumber, birthday } = {}) {
|
|
1794
1588
|
this._ctx.requireTokens();
|
|
1795
1589
|
const path = `/api/v1/users/${encodeURIComponent(userId)}`;
|
|
@@ -1807,35 +1601,6 @@ class Users {
|
|
|
1807
1601
|
const { data } = await this._ctx.client.request(path, 'PUT', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1808
1602
|
return data;
|
|
1809
1603
|
}
|
|
1810
|
-
|
|
1811
|
-
async updateUserByAdmin(userId, { name, email, password, companyId, accountType, profilePicture, location, phoneNumber, birthday } = {}) {
|
|
1812
|
-
this._ctx.requireTokens();
|
|
1813
|
-
const path = `/api/v1/users/admin/${encodeURIComponent(userId)}`;
|
|
1814
|
-
const body = stripUndef({
|
|
1815
|
-
name: name,
|
|
1816
|
-
email: email,
|
|
1817
|
-
password: password,
|
|
1818
|
-
company_id: companyId,
|
|
1819
|
-
account_type: accountType,
|
|
1820
|
-
profile_picture: profilePicture,
|
|
1821
|
-
location: location,
|
|
1822
|
-
phone_number: phoneNumber,
|
|
1823
|
-
birthday: birthday,
|
|
1824
|
-
});
|
|
1825
|
-
const { data } = await this._ctx.client.request(path, 'PUT', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1826
|
-
return data;
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
async deleteUser(userId, { newCompanyOwnerId } = {}) {
|
|
1830
|
-
this._ctx.requireTokens();
|
|
1831
|
-
let path = `/api/v1/users/delete/${encodeURIComponent(userId)}`;
|
|
1832
|
-
const query = new URLSearchParams();
|
|
1833
|
-
if (newCompanyOwnerId !== undefined) (Array.isArray(newCompanyOwnerId) ? newCompanyOwnerId : [newCompanyOwnerId]).forEach(v => query.append('new_company_owner_id', v));
|
|
1834
|
-
const qs = query.toString();
|
|
1835
|
-
if (qs) path += '?' + qs;
|
|
1836
|
-
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1837
|
-
return data;
|
|
1838
|
-
}
|
|
1839
1604
|
}
|
|
1840
1605
|
|
|
1841
1606
|
// Auto-generated — do not edit
|
|
@@ -1900,7 +1665,6 @@ class MediaViz {
|
|
|
1900
1665
|
|
|
1901
1666
|
const _ctx = new _Context(this);
|
|
1902
1667
|
this.aiModelCredits = new AiModelCredits(_ctx);
|
|
1903
|
-
this.admin = new Admin(_ctx);
|
|
1904
1668
|
this.company = new Company(_ctx);
|
|
1905
1669
|
this.curatedAlbums = new CuratedAlbums(_ctx);
|
|
1906
1670
|
this.customAlbums = new CustomAlbums(_ctx);
|
|
@@ -1908,7 +1672,6 @@ class MediaViz {
|
|
|
1908
1672
|
this.health = new Health(_ctx);
|
|
1909
1673
|
this.keywords = new Keywords(_ctx);
|
|
1910
1674
|
this.oAuthAuthorization = new OauthAuthorization(_ctx);
|
|
1911
|
-
this.oAuthClients = new OauthClients(_ctx);
|
|
1912
1675
|
this.oAuthToken = new OauthToken(_ctx);
|
|
1913
1676
|
this.oauthLogin = new OauthLogin(_ctx);
|
|
1914
1677
|
this.person = new Person(_ctx);
|
|
@@ -1946,7 +1709,6 @@ class MediaViz {
|
|
|
1946
1709
|
get refreshToken() { return this._refreshToken; }
|
|
1947
1710
|
}
|
|
1948
1711
|
|
|
1949
|
-
exports.Admin = Admin;
|
|
1950
1712
|
exports.AiModelCredits = AiModelCredits;
|
|
1951
1713
|
exports.ApiError = ApiError;
|
|
1952
1714
|
exports.Company = Company;
|
|
@@ -1961,7 +1723,6 @@ exports.OAuthClient = OAuthClient;
|
|
|
1961
1723
|
exports.OAuthError = OAuthError;
|
|
1962
1724
|
exports.OAuthErrorCode = OAuthErrorCode;
|
|
1963
1725
|
exports.OauthAuthorization = OauthAuthorization;
|
|
1964
|
-
exports.OauthClients = OauthClients;
|
|
1965
1726
|
exports.OauthLogin = OauthLogin;
|
|
1966
1727
|
exports.OauthToken = OauthToken;
|
|
1967
1728
|
exports.Person = Person;
|