@mediaviz/sdk 0.1.0 → 1.0.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/LICENSE +21 -0
- package/dist/sdk.cjs +99 -226
- package/dist/sdk.d.cts +503 -0
- package/dist/sdk.d.ts +503 -0
- package/dist/sdk.esm.d.ts +503 -0
- package/dist/sdk.esm.js +100 -226
- package/dist/sdk.umd.js +99 -226
- package/package.json +23 -10
- 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
|
@@ -173,6 +173,9 @@ function requireClient () {
|
|
|
173
173
|
const { postForm, postJson } = requireHttp();
|
|
174
174
|
const { OAuthError } = requireErrors();
|
|
175
175
|
|
|
176
|
+
// In-flight dedup key for client_credentials re-mints (no refresh_token to key on).
|
|
177
|
+
const CLIENT_CREDENTIALS_KEY = Symbol('client_credentials');
|
|
178
|
+
|
|
176
179
|
class OAuthClient {
|
|
177
180
|
/**
|
|
178
181
|
* @param {import('./types').OAuthClientConfig} config
|
|
@@ -311,15 +314,27 @@ function requireClient () {
|
|
|
311
314
|
return { data: json, updatedTokens: null };
|
|
312
315
|
}
|
|
313
316
|
|
|
314
|
-
// 401:
|
|
315
|
-
//
|
|
316
|
-
//
|
|
317
|
-
|
|
317
|
+
// 401: re-authenticate, then retry once.
|
|
318
|
+
// - User sessions (refresh_token present) use the refresh_token grant. The server
|
|
319
|
+
// rotates the token one-time, so concurrent callers share one in-flight call
|
|
320
|
+
// (a second rotation would get invalid_grant).
|
|
321
|
+
// - Machine-to-machine sessions (no refresh_token, client_secret configured) re-mint
|
|
322
|
+
// via client_credentials, which issues no refresh token to rotate (RFC 6749 §4.4).
|
|
323
|
+
// - With neither a refresh_token nor a client_secret there is nothing to retry with.
|
|
324
|
+
if (!refreshToken && !this._config.clientSecret) {
|
|
325
|
+
throw OAuthError.fromResponse(401, await firstResponse.json());
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
const reauthKey = refreshToken || CLIENT_CREDENTIALS_KEY;
|
|
329
|
+
let pending = this._inFlightRefreshes.get(reauthKey);
|
|
318
330
|
if (!pending) {
|
|
319
|
-
|
|
320
|
-
this.
|
|
331
|
+
const reauth = refreshToken
|
|
332
|
+
? this.refreshAccessToken(refreshToken)
|
|
333
|
+
: this.getClientCredentialsToken();
|
|
334
|
+
pending = reauth.finally(() => {
|
|
335
|
+
this._inFlightRefreshes.delete(reauthKey);
|
|
321
336
|
});
|
|
322
|
-
this._inFlightRefreshes.set(
|
|
337
|
+
this._inFlightRefreshes.set(reauthKey, pending);
|
|
323
338
|
}
|
|
324
339
|
const newTokens = await pending;
|
|
325
340
|
|
|
@@ -456,124 +471,22 @@ class AiModelCredits {
|
|
|
456
471
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
457
472
|
return data;
|
|
458
473
|
}
|
|
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
474
|
}
|
|
472
475
|
|
|
473
476
|
class Admin {
|
|
474
477
|
constructor(ctx) { this._ctx = ctx; }
|
|
475
478
|
|
|
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
479
|
async getCategoryLabels(category) {
|
|
491
480
|
this._ctx.requireTokens();
|
|
492
481
|
const path = `/api/v1/admin/category_labels/${encodeURIComponent(category)}`;
|
|
493
482
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
494
483
|
return data;
|
|
495
484
|
}
|
|
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
485
|
}
|
|
566
486
|
|
|
567
487
|
class Company {
|
|
568
488
|
constructor(ctx) { this._ctx = ctx; }
|
|
569
489
|
|
|
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
490
|
async getCompanyById(companyId) {
|
|
578
491
|
this._ctx.requireTokens();
|
|
579
492
|
const path = `/api/v1/company/${encodeURIComponent(companyId)}`;
|
|
@@ -592,31 +505,6 @@ class Company {
|
|
|
592
505
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
593
506
|
return data;
|
|
594
507
|
}
|
|
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
508
|
}
|
|
621
509
|
|
|
622
510
|
function stripUndef$6(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
@@ -971,6 +859,13 @@ class Keywords {
|
|
|
971
859
|
return data;
|
|
972
860
|
}
|
|
973
861
|
|
|
862
|
+
async getCompanyKeywordLists(companyId) {
|
|
863
|
+
this._ctx.requireTokens();
|
|
864
|
+
const path = `/api/v1/keyword/company/${encodeURIComponent(companyId)}`;
|
|
865
|
+
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
866
|
+
return data;
|
|
867
|
+
}
|
|
868
|
+
|
|
974
869
|
async getKeywordFilteringListAndProjectsById(keywordListId) {
|
|
975
870
|
this._ctx.requireTokens();
|
|
976
871
|
const path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}`;
|
|
@@ -1032,6 +927,17 @@ class Keywords {
|
|
|
1032
927
|
return data;
|
|
1033
928
|
}
|
|
1034
929
|
|
|
930
|
+
async addCompanyToKeywordFilteringList(keywordListId, { companyId } = {}) {
|
|
931
|
+
this._ctx.requireTokens();
|
|
932
|
+
let path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}/company`;
|
|
933
|
+
const query = new URLSearchParams();
|
|
934
|
+
if (companyId !== undefined) (Array.isArray(companyId) ? companyId : [companyId]).forEach(v => query.append('company_id', v));
|
|
935
|
+
const qs = query.toString();
|
|
936
|
+
if (qs) path += '?' + qs;
|
|
937
|
+
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
938
|
+
return data;
|
|
939
|
+
}
|
|
940
|
+
|
|
1035
941
|
async requestKeywordListExport(keywordListId) {
|
|
1036
942
|
this._ctx.requireTokens();
|
|
1037
943
|
const path = `/api/v1/keyword/export/${encodeURIComponent(keywordListId)}`;
|
|
@@ -1064,6 +970,17 @@ class Keywords {
|
|
|
1064
970
|
return data;
|
|
1065
971
|
}
|
|
1066
972
|
|
|
973
|
+
async removeCompanyFromKeywordFilteringList(keywordListId, { companyId } = {}) {
|
|
974
|
+
this._ctx.requireTokens();
|
|
975
|
+
let path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}/company`;
|
|
976
|
+
const query = new URLSearchParams();
|
|
977
|
+
if (companyId !== undefined) (Array.isArray(companyId) ? companyId : [companyId]).forEach(v => query.append('company_id', v));
|
|
978
|
+
const qs = query.toString();
|
|
979
|
+
if (qs) path += '?' + qs;
|
|
980
|
+
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
981
|
+
return data;
|
|
982
|
+
}
|
|
983
|
+
|
|
1067
984
|
async deleteKeywordFilteringListById(keywordListId) {
|
|
1068
985
|
this._ctx.requireTokens();
|
|
1069
986
|
const path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}`;
|
|
@@ -1124,25 +1041,6 @@ class OauthAuthorization {
|
|
|
1124
1041
|
}
|
|
1125
1042
|
}
|
|
1126
1043
|
|
|
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
1044
|
class OauthToken {
|
|
1147
1045
|
constructor(ctx) { this._ctx = ctx; }
|
|
1148
1046
|
|
|
@@ -1242,6 +1140,17 @@ class Person {
|
|
|
1242
1140
|
return data;
|
|
1243
1141
|
}
|
|
1244
1142
|
|
|
1143
|
+
async getPhotoIdsByPersons(projectTableName, { personId } = {}) {
|
|
1144
|
+
this._ctx.requireTokens();
|
|
1145
|
+
let path = `/api/v1/person/${encodeURIComponent(projectTableName)}/photos`;
|
|
1146
|
+
const query = new URLSearchParams();
|
|
1147
|
+
if (personId !== undefined) (Array.isArray(personId) ? personId : [personId]).forEach(v => query.append('person_id', v));
|
|
1148
|
+
const qs = query.toString();
|
|
1149
|
+
if (qs) path += '?' + qs;
|
|
1150
|
+
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1151
|
+
return data;
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1245
1154
|
async getAllPersonsFromPhoto(projectTableName, photoId) {
|
|
1246
1155
|
this._ctx.requireTokens();
|
|
1247
1156
|
const path = `/api/v1/person/${encodeURIComponent(projectTableName)}/photo/${encodeURIComponent(photoId)}`;
|
|
@@ -1250,7 +1159,7 @@ class Person {
|
|
|
1250
1159
|
}
|
|
1251
1160
|
}
|
|
1252
1161
|
|
|
1253
|
-
function stripUndef$
|
|
1162
|
+
function stripUndef$2(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
1254
1163
|
|
|
1255
1164
|
class Projects {
|
|
1256
1165
|
constructor(ctx) { this._ctx = ctx; }
|
|
@@ -1263,7 +1172,7 @@ class Projects {
|
|
|
1263
1172
|
if (models !== undefined) (Array.isArray(models) ? models : [models]).forEach(v => query.append('models', v));
|
|
1264
1173
|
const qs = query.toString();
|
|
1265
1174
|
if (qs) path += '?' + qs;
|
|
1266
|
-
const body = stripUndef$
|
|
1175
|
+
const body = stripUndef$2({
|
|
1267
1176
|
name: name,
|
|
1268
1177
|
private: private_,
|
|
1269
1178
|
type: type,
|
|
@@ -1316,13 +1225,6 @@ class Projects {
|
|
|
1316
1225
|
return data;
|
|
1317
1226
|
}
|
|
1318
1227
|
|
|
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
1228
|
async getProjectById(projectId) {
|
|
1327
1229
|
this._ctx.requireTokens();
|
|
1328
1230
|
const path = `/api/v1/projects/${encodeURIComponent(projectId)}`;
|
|
@@ -1340,7 +1242,7 @@ class Projects {
|
|
|
1340
1242
|
async updateProject(projectId, { private: private_, type, description, directory, name, thumbnail } = {}) {
|
|
1341
1243
|
this._ctx.requireTokens();
|
|
1342
1244
|
const path = `/api/v1/projects/${encodeURIComponent(projectId)}`;
|
|
1343
|
-
const body = stripUndef$
|
|
1245
|
+
const body = stripUndef$2({
|
|
1344
1246
|
private: private_,
|
|
1345
1247
|
type: type,
|
|
1346
1248
|
description: description,
|
|
@@ -1409,13 +1311,6 @@ class Projects {
|
|
|
1409
1311
|
return data;
|
|
1410
1312
|
}
|
|
1411
1313
|
|
|
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
1314
|
async getProjectDataExportUploadStatus(projectTableName, modelName) {
|
|
1420
1315
|
this._ctx.requireTokens();
|
|
1421
1316
|
const path = `/api/v1/projects/${encodeURIComponent(projectTableName)}/upload_status/${encodeURIComponent(modelName)}`;
|
|
@@ -1426,7 +1321,7 @@ class Projects {
|
|
|
1426
1321
|
async addProjectEvent(projectTableName, event, detail = undefined) {
|
|
1427
1322
|
this._ctx.requireTokens();
|
|
1428
1323
|
const path = `/api/v1/projects/${encodeURIComponent(projectTableName)}/event`;
|
|
1429
|
-
const body = stripUndef$
|
|
1324
|
+
const body = stripUndef$2({
|
|
1430
1325
|
event: event,
|
|
1431
1326
|
detail: detail,
|
|
1432
1327
|
});
|
|
@@ -1498,13 +1393,6 @@ class Photoupload {
|
|
|
1498
1393
|
class Photos {
|
|
1499
1394
|
constructor(ctx) { this._ctx = ctx; }
|
|
1500
1395
|
|
|
1501
|
-
async addPhotoToProject({ photo, tableName, sourceResolutionX, sourceResolutionY, dateTaken, latitude, longitude, filePath, title, clientSideId }) {
|
|
1502
|
-
this._ctx.requireTokens();
|
|
1503
|
-
const path = `/api/v1/photos/`;
|
|
1504
|
-
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 });
|
|
1505
|
-
return data;
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
1396
|
async getPhotoFromProject(tableName, photoId, { keywordListId } = {}) {
|
|
1509
1397
|
this._ctx.requireTokens();
|
|
1510
1398
|
let path = `/api/v1/photos/${encodeURIComponent(tableName)}/${encodeURIComponent(photoId)}`;
|
|
@@ -1563,13 +1451,6 @@ class Photos {
|
|
|
1563
1451
|
return data;
|
|
1564
1452
|
}
|
|
1565
1453
|
|
|
1566
|
-
async getProjectThumbnail(tableName) {
|
|
1567
|
-
this._ctx.requireTokens();
|
|
1568
|
-
const path = `/api/v1/photos_project/${encodeURIComponent(tableName)}`;
|
|
1569
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1570
|
-
return data;
|
|
1571
|
-
}
|
|
1572
|
-
|
|
1573
1454
|
async updatePhotoInProject({ tableName, photoId, photoData } = {}) {
|
|
1574
1455
|
this._ctx.requireTokens();
|
|
1575
1456
|
let path = `/api/v1/photos_update`;
|
|
@@ -1602,6 +1483,8 @@ class Photos {
|
|
|
1602
1483
|
}
|
|
1603
1484
|
}
|
|
1604
1485
|
|
|
1486
|
+
function stripUndef$1(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
1487
|
+
|
|
1605
1488
|
class Search {
|
|
1606
1489
|
constructor(ctx) { this._ctx = ctx; }
|
|
1607
1490
|
|
|
@@ -1630,27 +1513,49 @@ class Search {
|
|
|
1630
1513
|
return data;
|
|
1631
1514
|
}
|
|
1632
1515
|
|
|
1633
|
-
async
|
|
1516
|
+
async searchProjectPhotosParametrized(projectTableName, { andSearchText, orSearchText, notSearchText, city, country, state, albums, dateMin, dateMax, dateNullAnd, dateNullOr, ascOrDesc, bestOfSimilarSetsOnly, splitByTier, lastId, limit } = {}) {
|
|
1634
1517
|
this._ctx.requireTokens();
|
|
1635
|
-
let path = `/api/v1/search/
|
|
1518
|
+
let path = `/api/v1/search/parametrized/${encodeURIComponent(projectTableName)}/`;
|
|
1636
1519
|
const query = new URLSearchParams();
|
|
1637
|
-
if (
|
|
1638
|
-
if (
|
|
1520
|
+
if (andSearchText !== undefined) (Array.isArray(andSearchText) ? andSearchText : [andSearchText]).forEach(v => query.append('and_search_text', v));
|
|
1521
|
+
if (orSearchText !== undefined) (Array.isArray(orSearchText) ? orSearchText : [orSearchText]).forEach(v => query.append('or_search_text', v));
|
|
1522
|
+
if (notSearchText !== undefined) (Array.isArray(notSearchText) ? notSearchText : [notSearchText]).forEach(v => query.append('not_search_text', v));
|
|
1523
|
+
if (city !== undefined) (Array.isArray(city) ? city : [city]).forEach(v => query.append('city', v));
|
|
1524
|
+
if (country !== undefined) (Array.isArray(country) ? country : [country]).forEach(v => query.append('country', v));
|
|
1525
|
+
if (state !== undefined) (Array.isArray(state) ? state : [state]).forEach(v => query.append('state', v));
|
|
1526
|
+
if (albums !== undefined) (Array.isArray(albums) ? albums : [albums]).forEach(v => query.append('albums', v));
|
|
1527
|
+
if (dateMin !== undefined) (Array.isArray(dateMin) ? dateMin : [dateMin]).forEach(v => query.append('date_min', v));
|
|
1528
|
+
if (dateMax !== undefined) (Array.isArray(dateMax) ? dateMax : [dateMax]).forEach(v => query.append('date_max', v));
|
|
1529
|
+
if (dateNullAnd !== undefined) (Array.isArray(dateNullAnd) ? dateNullAnd : [dateNullAnd]).forEach(v => query.append('date_null_and', v));
|
|
1530
|
+
if (dateNullOr !== undefined) (Array.isArray(dateNullOr) ? dateNullOr : [dateNullOr]).forEach(v => query.append('date_null_or', v));
|
|
1531
|
+
if (ascOrDesc !== undefined) (Array.isArray(ascOrDesc) ? ascOrDesc : [ascOrDesc]).forEach(v => query.append('asc_or_desc', v));
|
|
1532
|
+
if (bestOfSimilarSetsOnly !== undefined) (Array.isArray(bestOfSimilarSetsOnly) ? bestOfSimilarSetsOnly : [bestOfSimilarSetsOnly]).forEach(v => query.append('best_of_similar_sets_only', v));
|
|
1533
|
+
if (splitByTier !== undefined) (Array.isArray(splitByTier) ? splitByTier : [splitByTier]).forEach(v => query.append('split_by_tier', v));
|
|
1534
|
+
if (lastId !== undefined) (Array.isArray(lastId) ? lastId : [lastId]).forEach(v => query.append('last_id', v));
|
|
1535
|
+
if (limit !== undefined) (Array.isArray(limit) ? limit : [limit]).forEach(v => query.append('limit', v));
|
|
1639
1536
|
const qs = query.toString();
|
|
1640
1537
|
if (qs) path += '?' + qs;
|
|
1641
1538
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1642
1539
|
return data;
|
|
1643
1540
|
}
|
|
1644
1541
|
|
|
1645
|
-
async searchProjectPhotosNaturalLanguage(projectTableName,
|
|
1542
|
+
async searchProjectPhotosNaturalLanguage(projectTableName, searchText, size = undefined, { minCosine, labelMinCosine, labelTopK, labelDelta, bestOfSimilarSetsOnly, splitByTier } = {}) {
|
|
1646
1543
|
this._ctx.requireTokens();
|
|
1647
|
-
let path = `/api/v1/search/
|
|
1544
|
+
let path = `/api/v1/search/natural_language/${encodeURIComponent(projectTableName)}/`;
|
|
1648
1545
|
const query = new URLSearchParams();
|
|
1649
|
-
if (
|
|
1650
|
-
if (
|
|
1546
|
+
if (minCosine !== undefined) (Array.isArray(minCosine) ? minCosine : [minCosine]).forEach(v => query.append('min_cosine', v));
|
|
1547
|
+
if (labelMinCosine !== undefined) (Array.isArray(labelMinCosine) ? labelMinCosine : [labelMinCosine]).forEach(v => query.append('label_min_cosine', v));
|
|
1548
|
+
if (labelTopK !== undefined) (Array.isArray(labelTopK) ? labelTopK : [labelTopK]).forEach(v => query.append('label_top_k', v));
|
|
1549
|
+
if (labelDelta !== undefined) (Array.isArray(labelDelta) ? labelDelta : [labelDelta]).forEach(v => query.append('label_delta', v));
|
|
1550
|
+
if (bestOfSimilarSetsOnly !== undefined) (Array.isArray(bestOfSimilarSetsOnly) ? bestOfSimilarSetsOnly : [bestOfSimilarSetsOnly]).forEach(v => query.append('best_of_similar_sets_only', v));
|
|
1551
|
+
if (splitByTier !== undefined) (Array.isArray(splitByTier) ? splitByTier : [splitByTier]).forEach(v => query.append('split_by_tier', v));
|
|
1651
1552
|
const qs = query.toString();
|
|
1652
1553
|
if (qs) path += '?' + qs;
|
|
1653
|
-
const
|
|
1554
|
+
const body = stripUndef$1({
|
|
1555
|
+
search_text: searchText,
|
|
1556
|
+
size: size,
|
|
1557
|
+
});
|
|
1558
|
+
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1654
1559
|
return data;
|
|
1655
1560
|
}
|
|
1656
1561
|
|
|
@@ -1778,18 +1683,6 @@ class Users {
|
|
|
1778
1683
|
return data;
|
|
1779
1684
|
}
|
|
1780
1685
|
|
|
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
1686
|
async updateUser(userId, { name, email, password, companyId, accountType, profilePicture, location, phoneNumber, birthday } = {}) {
|
|
1794
1687
|
this._ctx.requireTokens();
|
|
1795
1688
|
const path = `/api/v1/users/${encodeURIComponent(userId)}`;
|
|
@@ -1808,24 +1701,6 @@ class Users {
|
|
|
1808
1701
|
return data;
|
|
1809
1702
|
}
|
|
1810
1703
|
|
|
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
1704
|
async deleteUser(userId, { newCompanyOwnerId } = {}) {
|
|
1830
1705
|
this._ctx.requireTokens();
|
|
1831
1706
|
let path = `/api/v1/users/delete/${encodeURIComponent(userId)}`;
|
|
@@ -1908,7 +1783,6 @@ class MediaViz {
|
|
|
1908
1783
|
this.health = new Health(_ctx);
|
|
1909
1784
|
this.keywords = new Keywords(_ctx);
|
|
1910
1785
|
this.oAuthAuthorization = new OauthAuthorization(_ctx);
|
|
1911
|
-
this.oAuthClients = new OauthClients(_ctx);
|
|
1912
1786
|
this.oAuthToken = new OauthToken(_ctx);
|
|
1913
1787
|
this.oauthLogin = new OauthLogin(_ctx);
|
|
1914
1788
|
this.person = new Person(_ctx);
|
|
@@ -1961,7 +1835,6 @@ exports.OAuthClient = OAuthClient;
|
|
|
1961
1835
|
exports.OAuthError = OAuthError;
|
|
1962
1836
|
exports.OAuthErrorCode = OAuthErrorCode;
|
|
1963
1837
|
exports.OauthAuthorization = OauthAuthorization;
|
|
1964
|
-
exports.OauthClients = OauthClients;
|
|
1965
1838
|
exports.OauthLogin = OauthLogin;
|
|
1966
1839
|
exports.OauthToken = OauthToken;
|
|
1967
1840
|
exports.Person = Person;
|