@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/dist/sdk.umd.js
CHANGED
|
@@ -177,6 +177,9 @@
|
|
|
177
177
|
const { postForm, postJson } = requireHttp();
|
|
178
178
|
const { OAuthError } = requireErrors();
|
|
179
179
|
|
|
180
|
+
// In-flight dedup key for client_credentials re-mints (no refresh_token to key on).
|
|
181
|
+
const CLIENT_CREDENTIALS_KEY = Symbol('client_credentials');
|
|
182
|
+
|
|
180
183
|
class OAuthClient {
|
|
181
184
|
/**
|
|
182
185
|
* @param {import('./types').OAuthClientConfig} config
|
|
@@ -315,15 +318,27 @@
|
|
|
315
318
|
return { data: json, updatedTokens: null };
|
|
316
319
|
}
|
|
317
320
|
|
|
318
|
-
// 401:
|
|
319
|
-
//
|
|
320
|
-
//
|
|
321
|
-
|
|
321
|
+
// 401: re-authenticate, then retry once.
|
|
322
|
+
// - User sessions (refresh_token present) use the refresh_token grant. The server
|
|
323
|
+
// rotates the token one-time, so concurrent callers share one in-flight call
|
|
324
|
+
// (a second rotation would get invalid_grant).
|
|
325
|
+
// - Machine-to-machine sessions (no refresh_token, client_secret configured) re-mint
|
|
326
|
+
// via client_credentials, which issues no refresh token to rotate (RFC 6749 §4.4).
|
|
327
|
+
// - With neither a refresh_token nor a client_secret there is nothing to retry with.
|
|
328
|
+
if (!refreshToken && !this._config.clientSecret) {
|
|
329
|
+
throw OAuthError.fromResponse(401, await firstResponse.json());
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
const reauthKey = refreshToken || CLIENT_CREDENTIALS_KEY;
|
|
333
|
+
let pending = this._inFlightRefreshes.get(reauthKey);
|
|
322
334
|
if (!pending) {
|
|
323
|
-
|
|
324
|
-
this.
|
|
335
|
+
const reauth = refreshToken
|
|
336
|
+
? this.refreshAccessToken(refreshToken)
|
|
337
|
+
: this.getClientCredentialsToken();
|
|
338
|
+
pending = reauth.finally(() => {
|
|
339
|
+
this._inFlightRefreshes.delete(reauthKey);
|
|
325
340
|
});
|
|
326
|
-
this._inFlightRefreshes.set(
|
|
341
|
+
this._inFlightRefreshes.set(reauthKey, pending);
|
|
327
342
|
}
|
|
328
343
|
const newTokens = await pending;
|
|
329
344
|
|
|
@@ -460,124 +475,22 @@
|
|
|
460
475
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
461
476
|
return data;
|
|
462
477
|
}
|
|
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
478
|
}
|
|
476
479
|
|
|
477
480
|
class Admin {
|
|
478
481
|
constructor(ctx) { this._ctx = ctx; }
|
|
479
482
|
|
|
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
483
|
async getCategoryLabels(category) {
|
|
495
484
|
this._ctx.requireTokens();
|
|
496
485
|
const path = `/api/v1/admin/category_labels/${encodeURIComponent(category)}`;
|
|
497
486
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
498
487
|
return data;
|
|
499
488
|
}
|
|
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
489
|
}
|
|
570
490
|
|
|
571
491
|
class Company {
|
|
572
492
|
constructor(ctx) { this._ctx = ctx; }
|
|
573
493
|
|
|
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
494
|
async getCompanyById(companyId) {
|
|
582
495
|
this._ctx.requireTokens();
|
|
583
496
|
const path = `/api/v1/company/${encodeURIComponent(companyId)}`;
|
|
@@ -596,31 +509,6 @@
|
|
|
596
509
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
597
510
|
return data;
|
|
598
511
|
}
|
|
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
512
|
}
|
|
625
513
|
|
|
626
514
|
function stripUndef$6(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
@@ -975,6 +863,13 @@
|
|
|
975
863
|
return data;
|
|
976
864
|
}
|
|
977
865
|
|
|
866
|
+
async getCompanyKeywordLists(companyId) {
|
|
867
|
+
this._ctx.requireTokens();
|
|
868
|
+
const path = `/api/v1/keyword/company/${encodeURIComponent(companyId)}`;
|
|
869
|
+
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
870
|
+
return data;
|
|
871
|
+
}
|
|
872
|
+
|
|
978
873
|
async getKeywordFilteringListAndProjectsById(keywordListId) {
|
|
979
874
|
this._ctx.requireTokens();
|
|
980
875
|
const path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}`;
|
|
@@ -1036,6 +931,17 @@
|
|
|
1036
931
|
return data;
|
|
1037
932
|
}
|
|
1038
933
|
|
|
934
|
+
async addCompanyToKeywordFilteringList(keywordListId, { companyId } = {}) {
|
|
935
|
+
this._ctx.requireTokens();
|
|
936
|
+
let path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}/company`;
|
|
937
|
+
const query = new URLSearchParams();
|
|
938
|
+
if (companyId !== undefined) (Array.isArray(companyId) ? companyId : [companyId]).forEach(v => query.append('company_id', v));
|
|
939
|
+
const qs = query.toString();
|
|
940
|
+
if (qs) path += '?' + qs;
|
|
941
|
+
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
|
|
942
|
+
return data;
|
|
943
|
+
}
|
|
944
|
+
|
|
1039
945
|
async requestKeywordListExport(keywordListId) {
|
|
1040
946
|
this._ctx.requireTokens();
|
|
1041
947
|
const path = `/api/v1/keyword/export/${encodeURIComponent(keywordListId)}`;
|
|
@@ -1068,6 +974,17 @@
|
|
|
1068
974
|
return data;
|
|
1069
975
|
}
|
|
1070
976
|
|
|
977
|
+
async removeCompanyFromKeywordFilteringList(keywordListId, { companyId } = {}) {
|
|
978
|
+
this._ctx.requireTokens();
|
|
979
|
+
let path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}/company`;
|
|
980
|
+
const query = new URLSearchParams();
|
|
981
|
+
if (companyId !== undefined) (Array.isArray(companyId) ? companyId : [companyId]).forEach(v => query.append('company_id', v));
|
|
982
|
+
const qs = query.toString();
|
|
983
|
+
if (qs) path += '?' + qs;
|
|
984
|
+
const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
|
|
985
|
+
return data;
|
|
986
|
+
}
|
|
987
|
+
|
|
1071
988
|
async deleteKeywordFilteringListById(keywordListId) {
|
|
1072
989
|
this._ctx.requireTokens();
|
|
1073
990
|
const path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}`;
|
|
@@ -1128,25 +1045,6 @@
|
|
|
1128
1045
|
}
|
|
1129
1046
|
}
|
|
1130
1047
|
|
|
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
1048
|
class OauthToken {
|
|
1151
1049
|
constructor(ctx) { this._ctx = ctx; }
|
|
1152
1050
|
|
|
@@ -1246,6 +1144,17 @@
|
|
|
1246
1144
|
return data;
|
|
1247
1145
|
}
|
|
1248
1146
|
|
|
1147
|
+
async getPhotoIdsByPersons(projectTableName, { personId } = {}) {
|
|
1148
|
+
this._ctx.requireTokens();
|
|
1149
|
+
let path = `/api/v1/person/${encodeURIComponent(projectTableName)}/photos`;
|
|
1150
|
+
const query = new URLSearchParams();
|
|
1151
|
+
if (personId !== undefined) (Array.isArray(personId) ? personId : [personId]).forEach(v => query.append('person_id', v));
|
|
1152
|
+
const qs = query.toString();
|
|
1153
|
+
if (qs) path += '?' + qs;
|
|
1154
|
+
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1155
|
+
return data;
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1249
1158
|
async getAllPersonsFromPhoto(projectTableName, photoId) {
|
|
1250
1159
|
this._ctx.requireTokens();
|
|
1251
1160
|
const path = `/api/v1/person/${encodeURIComponent(projectTableName)}/photo/${encodeURIComponent(photoId)}`;
|
|
@@ -1254,7 +1163,7 @@
|
|
|
1254
1163
|
}
|
|
1255
1164
|
}
|
|
1256
1165
|
|
|
1257
|
-
function stripUndef$
|
|
1166
|
+
function stripUndef$2(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
1258
1167
|
|
|
1259
1168
|
class Projects {
|
|
1260
1169
|
constructor(ctx) { this._ctx = ctx; }
|
|
@@ -1267,7 +1176,7 @@
|
|
|
1267
1176
|
if (models !== undefined) (Array.isArray(models) ? models : [models]).forEach(v => query.append('models', v));
|
|
1268
1177
|
const qs = query.toString();
|
|
1269
1178
|
if (qs) path += '?' + qs;
|
|
1270
|
-
const body = stripUndef$
|
|
1179
|
+
const body = stripUndef$2({
|
|
1271
1180
|
name: name,
|
|
1272
1181
|
private: private_,
|
|
1273
1182
|
type: type,
|
|
@@ -1320,13 +1229,6 @@
|
|
|
1320
1229
|
return data;
|
|
1321
1230
|
}
|
|
1322
1231
|
|
|
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
1232
|
async getProjectById(projectId) {
|
|
1331
1233
|
this._ctx.requireTokens();
|
|
1332
1234
|
const path = `/api/v1/projects/${encodeURIComponent(projectId)}`;
|
|
@@ -1344,7 +1246,7 @@
|
|
|
1344
1246
|
async updateProject(projectId, { private: private_, type, description, directory, name, thumbnail } = {}) {
|
|
1345
1247
|
this._ctx.requireTokens();
|
|
1346
1248
|
const path = `/api/v1/projects/${encodeURIComponent(projectId)}`;
|
|
1347
|
-
const body = stripUndef$
|
|
1249
|
+
const body = stripUndef$2({
|
|
1348
1250
|
private: private_,
|
|
1349
1251
|
type: type,
|
|
1350
1252
|
description: description,
|
|
@@ -1413,13 +1315,6 @@
|
|
|
1413
1315
|
return data;
|
|
1414
1316
|
}
|
|
1415
1317
|
|
|
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
1318
|
async getProjectDataExportUploadStatus(projectTableName, modelName) {
|
|
1424
1319
|
this._ctx.requireTokens();
|
|
1425
1320
|
const path = `/api/v1/projects/${encodeURIComponent(projectTableName)}/upload_status/${encodeURIComponent(modelName)}`;
|
|
@@ -1430,7 +1325,7 @@
|
|
|
1430
1325
|
async addProjectEvent(projectTableName, event, detail = undefined) {
|
|
1431
1326
|
this._ctx.requireTokens();
|
|
1432
1327
|
const path = `/api/v1/projects/${encodeURIComponent(projectTableName)}/event`;
|
|
1433
|
-
const body = stripUndef$
|
|
1328
|
+
const body = stripUndef$2({
|
|
1434
1329
|
event: event,
|
|
1435
1330
|
detail: detail,
|
|
1436
1331
|
});
|
|
@@ -1502,13 +1397,6 @@
|
|
|
1502
1397
|
class Photos {
|
|
1503
1398
|
constructor(ctx) { this._ctx = ctx; }
|
|
1504
1399
|
|
|
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
1400
|
async getPhotoFromProject(tableName, photoId, { keywordListId } = {}) {
|
|
1513
1401
|
this._ctx.requireTokens();
|
|
1514
1402
|
let path = `/api/v1/photos/${encodeURIComponent(tableName)}/${encodeURIComponent(photoId)}`;
|
|
@@ -1567,13 +1455,6 @@
|
|
|
1567
1455
|
return data;
|
|
1568
1456
|
}
|
|
1569
1457
|
|
|
1570
|
-
async getProjectThumbnail(tableName) {
|
|
1571
|
-
this._ctx.requireTokens();
|
|
1572
|
-
const path = `/api/v1/photos_project/${encodeURIComponent(tableName)}`;
|
|
1573
|
-
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1574
|
-
return data;
|
|
1575
|
-
}
|
|
1576
|
-
|
|
1577
1458
|
async updatePhotoInProject({ tableName, photoId, photoData } = {}) {
|
|
1578
1459
|
this._ctx.requireTokens();
|
|
1579
1460
|
let path = `/api/v1/photos_update`;
|
|
@@ -1606,6 +1487,8 @@
|
|
|
1606
1487
|
}
|
|
1607
1488
|
}
|
|
1608
1489
|
|
|
1490
|
+
function stripUndef$1(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
|
|
1491
|
+
|
|
1609
1492
|
class Search {
|
|
1610
1493
|
constructor(ctx) { this._ctx = ctx; }
|
|
1611
1494
|
|
|
@@ -1634,27 +1517,49 @@
|
|
|
1634
1517
|
return data;
|
|
1635
1518
|
}
|
|
1636
1519
|
|
|
1637
|
-
async
|
|
1520
|
+
async searchProjectPhotosParametrized(projectTableName, { andSearchText, orSearchText, notSearchText, city, country, state, albums, dateMin, dateMax, dateNullAnd, dateNullOr, ascOrDesc, bestOfSimilarSetsOnly, splitByTier, lastId, limit } = {}) {
|
|
1638
1521
|
this._ctx.requireTokens();
|
|
1639
|
-
let path = `/api/v1/search/
|
|
1522
|
+
let path = `/api/v1/search/parametrized/${encodeURIComponent(projectTableName)}/`;
|
|
1640
1523
|
const query = new URLSearchParams();
|
|
1641
|
-
if (
|
|
1642
|
-
if (
|
|
1524
|
+
if (andSearchText !== undefined) (Array.isArray(andSearchText) ? andSearchText : [andSearchText]).forEach(v => query.append('and_search_text', v));
|
|
1525
|
+
if (orSearchText !== undefined) (Array.isArray(orSearchText) ? orSearchText : [orSearchText]).forEach(v => query.append('or_search_text', v));
|
|
1526
|
+
if (notSearchText !== undefined) (Array.isArray(notSearchText) ? notSearchText : [notSearchText]).forEach(v => query.append('not_search_text', v));
|
|
1527
|
+
if (city !== undefined) (Array.isArray(city) ? city : [city]).forEach(v => query.append('city', v));
|
|
1528
|
+
if (country !== undefined) (Array.isArray(country) ? country : [country]).forEach(v => query.append('country', v));
|
|
1529
|
+
if (state !== undefined) (Array.isArray(state) ? state : [state]).forEach(v => query.append('state', v));
|
|
1530
|
+
if (albums !== undefined) (Array.isArray(albums) ? albums : [albums]).forEach(v => query.append('albums', v));
|
|
1531
|
+
if (dateMin !== undefined) (Array.isArray(dateMin) ? dateMin : [dateMin]).forEach(v => query.append('date_min', v));
|
|
1532
|
+
if (dateMax !== undefined) (Array.isArray(dateMax) ? dateMax : [dateMax]).forEach(v => query.append('date_max', v));
|
|
1533
|
+
if (dateNullAnd !== undefined) (Array.isArray(dateNullAnd) ? dateNullAnd : [dateNullAnd]).forEach(v => query.append('date_null_and', v));
|
|
1534
|
+
if (dateNullOr !== undefined) (Array.isArray(dateNullOr) ? dateNullOr : [dateNullOr]).forEach(v => query.append('date_null_or', v));
|
|
1535
|
+
if (ascOrDesc !== undefined) (Array.isArray(ascOrDesc) ? ascOrDesc : [ascOrDesc]).forEach(v => query.append('asc_or_desc', v));
|
|
1536
|
+
if (bestOfSimilarSetsOnly !== undefined) (Array.isArray(bestOfSimilarSetsOnly) ? bestOfSimilarSetsOnly : [bestOfSimilarSetsOnly]).forEach(v => query.append('best_of_similar_sets_only', v));
|
|
1537
|
+
if (splitByTier !== undefined) (Array.isArray(splitByTier) ? splitByTier : [splitByTier]).forEach(v => query.append('split_by_tier', v));
|
|
1538
|
+
if (lastId !== undefined) (Array.isArray(lastId) ? lastId : [lastId]).forEach(v => query.append('last_id', v));
|
|
1539
|
+
if (limit !== undefined) (Array.isArray(limit) ? limit : [limit]).forEach(v => query.append('limit', v));
|
|
1643
1540
|
const qs = query.toString();
|
|
1644
1541
|
if (qs) path += '?' + qs;
|
|
1645
1542
|
const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
|
|
1646
1543
|
return data;
|
|
1647
1544
|
}
|
|
1648
1545
|
|
|
1649
|
-
async searchProjectPhotosNaturalLanguage(projectTableName,
|
|
1546
|
+
async searchProjectPhotosNaturalLanguage(projectTableName, searchText, size = undefined, { minCosine, labelMinCosine, labelTopK, labelDelta, bestOfSimilarSetsOnly, splitByTier } = {}) {
|
|
1650
1547
|
this._ctx.requireTokens();
|
|
1651
|
-
let path = `/api/v1/search/
|
|
1548
|
+
let path = `/api/v1/search/natural_language/${encodeURIComponent(projectTableName)}/`;
|
|
1652
1549
|
const query = new URLSearchParams();
|
|
1653
|
-
if (
|
|
1654
|
-
if (
|
|
1550
|
+
if (minCosine !== undefined) (Array.isArray(minCosine) ? minCosine : [minCosine]).forEach(v => query.append('min_cosine', v));
|
|
1551
|
+
if (labelMinCosine !== undefined) (Array.isArray(labelMinCosine) ? labelMinCosine : [labelMinCosine]).forEach(v => query.append('label_min_cosine', v));
|
|
1552
|
+
if (labelTopK !== undefined) (Array.isArray(labelTopK) ? labelTopK : [labelTopK]).forEach(v => query.append('label_top_k', v));
|
|
1553
|
+
if (labelDelta !== undefined) (Array.isArray(labelDelta) ? labelDelta : [labelDelta]).forEach(v => query.append('label_delta', v));
|
|
1554
|
+
if (bestOfSimilarSetsOnly !== undefined) (Array.isArray(bestOfSimilarSetsOnly) ? bestOfSimilarSetsOnly : [bestOfSimilarSetsOnly]).forEach(v => query.append('best_of_similar_sets_only', v));
|
|
1555
|
+
if (splitByTier !== undefined) (Array.isArray(splitByTier) ? splitByTier : [splitByTier]).forEach(v => query.append('split_by_tier', v));
|
|
1655
1556
|
const qs = query.toString();
|
|
1656
1557
|
if (qs) path += '?' + qs;
|
|
1657
|
-
const
|
|
1558
|
+
const body = stripUndef$1({
|
|
1559
|
+
search_text: searchText,
|
|
1560
|
+
size: size,
|
|
1561
|
+
});
|
|
1562
|
+
const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, body);
|
|
1658
1563
|
return data;
|
|
1659
1564
|
}
|
|
1660
1565
|
|
|
@@ -1782,18 +1687,6 @@
|
|
|
1782
1687
|
return data;
|
|
1783
1688
|
}
|
|
1784
1689
|
|
|
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
1690
|
async updateUser(userId, { name, email, password, companyId, accountType, profilePicture, location, phoneNumber, birthday } = {}) {
|
|
1798
1691
|
this._ctx.requireTokens();
|
|
1799
1692
|
const path = `/api/v1/users/${encodeURIComponent(userId)}`;
|
|
@@ -1812,24 +1705,6 @@
|
|
|
1812
1705
|
return data;
|
|
1813
1706
|
}
|
|
1814
1707
|
|
|
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
1708
|
async deleteUser(userId, { newCompanyOwnerId } = {}) {
|
|
1834
1709
|
this._ctx.requireTokens();
|
|
1835
1710
|
let path = `/api/v1/users/delete/${encodeURIComponent(userId)}`;
|
|
@@ -1912,7 +1787,6 @@
|
|
|
1912
1787
|
this.health = new Health(_ctx);
|
|
1913
1788
|
this.keywords = new Keywords(_ctx);
|
|
1914
1789
|
this.oAuthAuthorization = new OauthAuthorization(_ctx);
|
|
1915
|
-
this.oAuthClients = new OauthClients(_ctx);
|
|
1916
1790
|
this.oAuthToken = new OauthToken(_ctx);
|
|
1917
1791
|
this.oauthLogin = new OauthLogin(_ctx);
|
|
1918
1792
|
this.person = new Person(_ctx);
|
|
@@ -1965,7 +1839,6 @@
|
|
|
1965
1839
|
exports.OAuthError = OAuthError;
|
|
1966
1840
|
exports.OAuthErrorCode = OAuthErrorCode;
|
|
1967
1841
|
exports.OauthAuthorization = OauthAuthorization;
|
|
1968
|
-
exports.OauthClients = OauthClients;
|
|
1969
1842
|
exports.OauthLogin = OauthLogin;
|
|
1970
1843
|
exports.OauthToken = OauthToken;
|
|
1971
1844
|
exports.Person = Person;
|
package/package.json
CHANGED
|
@@ -1,27 +1,40 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mediaviz/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
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",
|
|
7
13
|
"browser": "./dist/sdk.umd.js",
|
|
14
|
+
"types": "./dist/sdk.d.ts",
|
|
8
15
|
"exports": {
|
|
9
16
|
".": {
|
|
10
17
|
"browser": "./dist/sdk.umd.js",
|
|
11
|
-
"import":
|
|
12
|
-
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/sdk.esm.d.ts",
|
|
20
|
+
"default": "./dist/sdk.esm.js"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/sdk.d.cts",
|
|
24
|
+
"default": "./dist/sdk.cjs"
|
|
25
|
+
},
|
|
13
26
|
"default": "./dist/sdk.cjs"
|
|
14
27
|
}
|
|
15
28
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
29
|
+
"files": [
|
|
30
|
+
"dist",
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"README.md"
|
|
33
|
+
],
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
18
36
|
},
|
|
19
37
|
"optionalDependencies": {
|
|
20
38
|
"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
39
|
}
|
|
27
40
|
}
|