@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.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/dist/sdk.cjs +99 -226
  3. package/dist/sdk.d.cts +503 -0
  4. package/dist/sdk.d.ts +503 -0
  5. package/dist/sdk.esm.d.ts +503 -0
  6. package/dist/sdk.esm.js +100 -226
  7. package/dist/sdk.umd.js +99 -226
  8. package/package.json +23 -10
  9. package/MediaViz.js +0 -126
  10. package/_oauth.js +0 -3
  11. package/admin.js +0 -93
  12. package/ai_model_credits.js +0 -22
  13. package/company.js +0 -54
  14. package/curated_albums.js +0 -85
  15. package/custom_albums.js +0 -78
  16. package/email_tokens.js +0 -64
  17. package/errors.js +0 -81
  18. package/health.js +0 -20
  19. package/index.js +0 -21
  20. package/keywords.js +0 -123
  21. package/oauth/.prettierrc +0 -6
  22. package/oauth/README.md +0 -76
  23. package/oauth/browser-smoke-test.html +0 -45
  24. package/oauth/implementation_plan.json +0 -106
  25. package/oauth/package-lock.json +0 -5236
  26. package/oauth/package.json +0 -28
  27. package/oauth/rollup.config.js +0 -21
  28. package/oauth/smoke-test.js +0 -27
  29. package/oauth/spec.md +0 -187
  30. package/oauth/src/__tests__/browser-smoke-test.test.js +0 -38
  31. package/oauth/src/__tests__/client.test.js +0 -556
  32. package/oauth/src/__tests__/errors.test.js +0 -73
  33. package/oauth/src/__tests__/http.test.js +0 -102
  34. package/oauth/src/__tests__/index.test.js +0 -53
  35. package/oauth/src/__tests__/package-fields.test.js +0 -29
  36. package/oauth/src/__tests__/pkce.test.js +0 -55
  37. package/oauth/src/__tests__/rollup-build.test.js +0 -58
  38. package/oauth/src/__tests__/smoke-test.test.js +0 -26
  39. package/oauth/src/__tests__/types.test.js +0 -29
  40. package/oauth/src/client.js +0 -180
  41. package/oauth/src/errors.js +0 -32
  42. package/oauth/src/http.js +0 -52
  43. package/oauth/src/index.js +0 -7
  44. package/oauth/src/pkce.js +0 -50
  45. package/oauth/src/types.js +0 -67
  46. package/oauth_authorization.js +0 -53
  47. package/oauth_clients.js +0 -18
  48. package/oauth_login.js +0 -24
  49. package/oauth_token.js +0 -30
  50. package/person.js +0 -54
  51. package/photos.js +0 -106
  52. package/photoupload.js +0 -55
  53. package/projects.js +0 -191
  54. package/rollup.config.js +0 -12
  55. package/search.js +0 -99
  56. package/users.js +0 -137
package/dist/sdk.esm.js CHANGED
@@ -171,6 +171,9 @@ function requireClient () {
171
171
  const { postForm, postJson } = requireHttp();
172
172
  const { OAuthError } = requireErrors();
173
173
 
174
+ // In-flight dedup key for client_credentials re-mints (no refresh_token to key on).
175
+ const CLIENT_CREDENTIALS_KEY = Symbol('client_credentials');
176
+
174
177
  class OAuthClient {
175
178
  /**
176
179
  * @param {import('./types').OAuthClientConfig} config
@@ -309,15 +312,27 @@ function requireClient () {
309
312
  return { data: json, updatedTokens: null };
310
313
  }
311
314
 
312
- // 401: attempt refresh — propagate OAuthError if refresh fails.
313
- // Concurrent request() callers with the same refresh_token share one in-flight
314
- // call so the server only sees one rotation (the second would get invalid_grant).
315
- let pending = this._inFlightRefreshes.get(refreshToken);
315
+ // 401: re-authenticate, then retry once.
316
+ // - User sessions (refresh_token present) use the refresh_token grant. The server
317
+ // rotates the token one-time, so concurrent callers share one in-flight call
318
+ // (a second rotation would get invalid_grant).
319
+ // - Machine-to-machine sessions (no refresh_token, client_secret configured) re-mint
320
+ // via client_credentials, which issues no refresh token to rotate (RFC 6749 §4.4).
321
+ // - With neither a refresh_token nor a client_secret there is nothing to retry with.
322
+ if (!refreshToken && !this._config.clientSecret) {
323
+ throw OAuthError.fromResponse(401, await firstResponse.json());
324
+ }
325
+
326
+ const reauthKey = refreshToken || CLIENT_CREDENTIALS_KEY;
327
+ let pending = this._inFlightRefreshes.get(reauthKey);
316
328
  if (!pending) {
317
- pending = this.refreshAccessToken(refreshToken).finally(() => {
318
- this._inFlightRefreshes.delete(refreshToken);
329
+ const reauth = refreshToken
330
+ ? this.refreshAccessToken(refreshToken)
331
+ : this.getClientCredentialsToken();
332
+ pending = reauth.finally(() => {
333
+ this._inFlightRefreshes.delete(reauthKey);
319
334
  });
320
- this._inFlightRefreshes.set(refreshToken, pending);
335
+ this._inFlightRefreshes.set(reauthKey, pending);
321
336
  }
322
337
  const newTokens = await pending;
323
338
 
@@ -454,124 +469,22 @@ class AiModelCredits {
454
469
  const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
455
470
  return data;
456
471
  }
457
-
458
- async upsertModelCreditRelationship({ modelName, newCreditValue } = {}) {
459
- this._ctx.requireTokens();
460
- let path = `/api/v1/model_credit/upsert`;
461
- const query = new URLSearchParams();
462
- if (modelName !== undefined) (Array.isArray(modelName) ? modelName : [modelName]).forEach(v => query.append('model_name', v));
463
- if (newCreditValue !== undefined) (Array.isArray(newCreditValue) ? newCreditValue : [newCreditValue]).forEach(v => query.append('new_credit_value', v));
464
- const qs = query.toString();
465
- if (qs) path += '?' + qs;
466
- const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
467
- return data;
468
- }
469
472
  }
470
473
 
471
474
  class Admin {
472
475
  constructor(ctx) { this._ctx = ctx; }
473
476
 
474
- async insertLabelCategoryMatrix() {
475
- this._ctx.requireTokens();
476
- const path = `/api/v1/admin/insert_label_category_matrix`;
477
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
478
- return data;
479
- }
480
-
481
- async generateMidLevelCategoryKeywordAlignment() {
482
- this._ctx.requireTokens();
483
- const path = `/api/v1/admin/generate_mid_level_category_keyword_alignment`;
484
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
485
- return data;
486
- }
487
-
488
477
  async getCategoryLabels(category) {
489
478
  this._ctx.requireTokens();
490
479
  const path = `/api/v1/admin/category_labels/${encodeURIComponent(category)}`;
491
480
  const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
492
481
  return data;
493
482
  }
494
-
495
- async adminDumpCompanyNlpIndex(companyId) {
496
- this._ctx.requireTokens();
497
- const path = `/api/v1/admin/dump_company_nlp_index/${encodeURIComponent(companyId)}`;
498
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
499
- return data;
500
- }
501
-
502
- async getAllKeywordGroupsAndSubgroups() {
503
- this._ctx.requireTokens();
504
- const path = `/api/v1/admin/keyword_group`;
505
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
506
- return data;
507
- }
508
-
509
- async getKeywordGroupsLabelsByKeywordGroup(keywordGroup, { subgroup } = {}) {
510
- this._ctx.requireTokens();
511
- let path = `/api/v1/admin/keyword_group/${encodeURIComponent(keywordGroup)}/`;
512
- const query = new URLSearchParams();
513
- if (subgroup !== undefined) (Array.isArray(subgroup) ? subgroup : [subgroup]).forEach(v => query.append('subgroup', v));
514
- const qs = query.toString();
515
- if (qs) path += '?' + qs;
516
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
517
- return data;
518
- }
519
-
520
- async adminCreateCompanyNlpIndexes({ companyIds } = {}) {
521
- this._ctx.requireTokens();
522
- let path = `/api/v1/admin/create_company_nlp_indexes/`;
523
- const query = new URLSearchParams();
524
- if (companyIds !== undefined) (Array.isArray(companyIds) ? companyIds : [companyIds]).forEach(v => query.append('company_ids', v));
525
- const qs = query.toString();
526
- if (qs) path += '?' + qs;
527
- const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
528
- return data;
529
- }
530
-
531
- async adminDeleteCompanyNlpIndexes({ companyIds } = {}) {
532
- this._ctx.requireTokens();
533
- let path = `/api/v1/admin/delete_company_nlp_indexes/`;
534
- const query = new URLSearchParams();
535
- if (companyIds !== undefined) (Array.isArray(companyIds) ? companyIds : [companyIds]).forEach(v => query.append('company_ids', v));
536
- const qs = query.toString();
537
- if (qs) path += '?' + qs;
538
- const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
539
- return data;
540
- }
541
-
542
- async adminDeleteUserProjects({ userIds } = {}) {
543
- this._ctx.requireTokens();
544
- let path = `/api/v1/admin/delete_user_projects/`;
545
- const query = new URLSearchParams();
546
- if (userIds !== undefined) (Array.isArray(userIds) ? userIds : [userIds]).forEach(v => query.append('user_ids', v));
547
- const qs = query.toString();
548
- if (qs) path += '?' + qs;
549
- const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
550
- return data;
551
- }
552
-
553
- async adminDeleteUser({ userIds } = {}) {
554
- this._ctx.requireTokens();
555
- let path = `/api/v1/admin/delete_user/`;
556
- const query = new URLSearchParams();
557
- if (userIds !== undefined) (Array.isArray(userIds) ? userIds : [userIds]).forEach(v => query.append('user_ids', v));
558
- const qs = query.toString();
559
- if (qs) path += '?' + qs;
560
- const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
561
- return data;
562
- }
563
483
  }
564
484
 
565
485
  class Company {
566
486
  constructor(ctx) { this._ctx = ctx; }
567
487
 
568
- async getAllCompanies() {
569
- this._ctx.requireTokens();
570
- const path = `/api/v1/company/`;
571
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
572
- return data;
573
- }
574
-
575
488
  async getCompanyById(companyId) {
576
489
  this._ctx.requireTokens();
577
490
  const path = `/api/v1/company/${encodeURIComponent(companyId)}`;
@@ -590,31 +503,6 @@ class Company {
590
503
  const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
591
504
  return data;
592
505
  }
593
-
594
- async adminListActiveCompanyTokens() {
595
- this._ctx.requireTokens();
596
- const path = `/api/v1/company/admin_create/`;
597
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
598
- return data;
599
- }
600
-
601
- async adminCreateCompanyToken({ email } = {}) {
602
- this._ctx.requireTokens();
603
- let path = `/api/v1/company/admin_create/`;
604
- const query = new URLSearchParams();
605
- if (email !== undefined) (Array.isArray(email) ? email : [email]).forEach(v => query.append('email', v));
606
- const qs = query.toString();
607
- if (qs) path += '?' + qs;
608
- const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
609
- return data;
610
- }
611
-
612
- async adminRevokeCompanyToken(tokenId) {
613
- this._ctx.requireTokens();
614
- const path = `/api/v1/company/admin_create/${encodeURIComponent(tokenId)}/revoke/`;
615
- const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
616
- return data;
617
- }
618
506
  }
619
507
 
620
508
  function stripUndef$6(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
@@ -969,6 +857,13 @@ class Keywords {
969
857
  return data;
970
858
  }
971
859
 
860
+ async getCompanyKeywordLists(companyId) {
861
+ this._ctx.requireTokens();
862
+ const path = `/api/v1/keyword/company/${encodeURIComponent(companyId)}`;
863
+ const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
864
+ return data;
865
+ }
866
+
972
867
  async getKeywordFilteringListAndProjectsById(keywordListId) {
973
868
  this._ctx.requireTokens();
974
869
  const path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}`;
@@ -1030,6 +925,17 @@ class Keywords {
1030
925
  return data;
1031
926
  }
1032
927
 
928
+ async addCompanyToKeywordFilteringList(keywordListId, { companyId } = {}) {
929
+ this._ctx.requireTokens();
930
+ let path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}/company`;
931
+ const query = new URLSearchParams();
932
+ if (companyId !== undefined) (Array.isArray(companyId) ? companyId : [companyId]).forEach(v => query.append('company_id', v));
933
+ const qs = query.toString();
934
+ if (qs) path += '?' + qs;
935
+ const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
936
+ return data;
937
+ }
938
+
1033
939
  async requestKeywordListExport(keywordListId) {
1034
940
  this._ctx.requireTokens();
1035
941
  const path = `/api/v1/keyword/export/${encodeURIComponent(keywordListId)}`;
@@ -1062,6 +968,17 @@ class Keywords {
1062
968
  return data;
1063
969
  }
1064
970
 
971
+ async removeCompanyFromKeywordFilteringList(keywordListId, { companyId } = {}) {
972
+ this._ctx.requireTokens();
973
+ let path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}/company`;
974
+ const query = new URLSearchParams();
975
+ if (companyId !== undefined) (Array.isArray(companyId) ? companyId : [companyId]).forEach(v => query.append('company_id', v));
976
+ const qs = query.toString();
977
+ if (qs) path += '?' + qs;
978
+ const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
979
+ return data;
980
+ }
981
+
1065
982
  async deleteKeywordFilteringListById(keywordListId) {
1066
983
  this._ctx.requireTokens();
1067
984
  const path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}`;
@@ -1122,25 +1039,6 @@ class OauthAuthorization {
1122
1039
  }
1123
1040
  }
1124
1041
 
1125
- function stripUndef$2(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
1126
-
1127
- class OauthClients {
1128
- constructor(ctx) { this._ctx = ctx; }
1129
-
1130
- async createClient(clientName, clientType, redirectUris, isFirstParty) {
1131
- this._ctx.requireTokens();
1132
- const path = `/oauth/clients`;
1133
- const body = stripUndef$2({
1134
- client_name: clientName,
1135
- client_type: clientType,
1136
- redirect_uris: redirectUris,
1137
- is_first_party: isFirstParty,
1138
- });
1139
- const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, body);
1140
- return data;
1141
- }
1142
- }
1143
-
1144
1042
  class OauthToken {
1145
1043
  constructor(ctx) { this._ctx = ctx; }
1146
1044
 
@@ -1240,6 +1138,17 @@ class Person {
1240
1138
  return data;
1241
1139
  }
1242
1140
 
1141
+ async getPhotoIdsByPersons(projectTableName, { personId } = {}) {
1142
+ this._ctx.requireTokens();
1143
+ let path = `/api/v1/person/${encodeURIComponent(projectTableName)}/photos`;
1144
+ const query = new URLSearchParams();
1145
+ if (personId !== undefined) (Array.isArray(personId) ? personId : [personId]).forEach(v => query.append('person_id', v));
1146
+ const qs = query.toString();
1147
+ if (qs) path += '?' + qs;
1148
+ const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1149
+ return data;
1150
+ }
1151
+
1243
1152
  async getAllPersonsFromPhoto(projectTableName, photoId) {
1244
1153
  this._ctx.requireTokens();
1245
1154
  const path = `/api/v1/person/${encodeURIComponent(projectTableName)}/photo/${encodeURIComponent(photoId)}`;
@@ -1248,7 +1157,7 @@ class Person {
1248
1157
  }
1249
1158
  }
1250
1159
 
1251
- function stripUndef$1(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
1160
+ function stripUndef$2(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
1252
1161
 
1253
1162
  class Projects {
1254
1163
  constructor(ctx) { this._ctx = ctx; }
@@ -1261,7 +1170,7 @@ class Projects {
1261
1170
  if (models !== undefined) (Array.isArray(models) ? models : [models]).forEach(v => query.append('models', v));
1262
1171
  const qs = query.toString();
1263
1172
  if (qs) path += '?' + qs;
1264
- const body = stripUndef$1({
1173
+ const body = stripUndef$2({
1265
1174
  name: name,
1266
1175
  private: private_,
1267
1176
  type: type,
@@ -1314,13 +1223,6 @@ class Projects {
1314
1223
  return data;
1315
1224
  }
1316
1225
 
1317
- async getAllUserProjectsAdmin(userId) {
1318
- this._ctx.requireTokens();
1319
- const path = `/api/v1/projects/admin/user/${encodeURIComponent(userId)}`;
1320
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1321
- return data;
1322
- }
1323
-
1324
1226
  async getProjectById(projectId) {
1325
1227
  this._ctx.requireTokens();
1326
1228
  const path = `/api/v1/projects/${encodeURIComponent(projectId)}`;
@@ -1338,7 +1240,7 @@ class Projects {
1338
1240
  async updateProject(projectId, { private: private_, type, description, directory, name, thumbnail } = {}) {
1339
1241
  this._ctx.requireTokens();
1340
1242
  const path = `/api/v1/projects/${encodeURIComponent(projectId)}`;
1341
- const body = stripUndef$1({
1243
+ const body = stripUndef$2({
1342
1244
  private: private_,
1343
1245
  type: type,
1344
1246
  description: description,
@@ -1407,13 +1309,6 @@ class Projects {
1407
1309
  return data;
1408
1310
  }
1409
1311
 
1410
- async requestProjectAdminExport(projectTableName) {
1411
- this._ctx.requireTokens();
1412
- const path = `/api/v1/projects_admin_export/${encodeURIComponent(projectTableName)}`;
1413
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1414
- return data;
1415
- }
1416
-
1417
1312
  async getProjectDataExportUploadStatus(projectTableName, modelName) {
1418
1313
  this._ctx.requireTokens();
1419
1314
  const path = `/api/v1/projects/${encodeURIComponent(projectTableName)}/upload_status/${encodeURIComponent(modelName)}`;
@@ -1424,7 +1319,7 @@ class Projects {
1424
1319
  async addProjectEvent(projectTableName, event, detail = undefined) {
1425
1320
  this._ctx.requireTokens();
1426
1321
  const path = `/api/v1/projects/${encodeURIComponent(projectTableName)}/event`;
1427
- const body = stripUndef$1({
1322
+ const body = stripUndef$2({
1428
1323
  event: event,
1429
1324
  detail: detail,
1430
1325
  });
@@ -1496,13 +1391,6 @@ class Photoupload {
1496
1391
  class Photos {
1497
1392
  constructor(ctx) { this._ctx = ctx; }
1498
1393
 
1499
- async addPhotoToProject({ photo, tableName, sourceResolutionX, sourceResolutionY, dateTaken, latitude, longitude, filePath, title, clientSideId }) {
1500
- this._ctx.requireTokens();
1501
- const path = `/api/v1/photos/`;
1502
- 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 });
1503
- return data;
1504
- }
1505
-
1506
1394
  async getPhotoFromProject(tableName, photoId, { keywordListId } = {}) {
1507
1395
  this._ctx.requireTokens();
1508
1396
  let path = `/api/v1/photos/${encodeURIComponent(tableName)}/${encodeURIComponent(photoId)}`;
@@ -1561,13 +1449,6 @@ class Photos {
1561
1449
  return data;
1562
1450
  }
1563
1451
 
1564
- async getProjectThumbnail(tableName) {
1565
- this._ctx.requireTokens();
1566
- const path = `/api/v1/photos_project/${encodeURIComponent(tableName)}`;
1567
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1568
- return data;
1569
- }
1570
-
1571
1452
  async updatePhotoInProject({ tableName, photoId, photoData } = {}) {
1572
1453
  this._ctx.requireTokens();
1573
1454
  let path = `/api/v1/photos_update`;
@@ -1600,6 +1481,8 @@ class Photos {
1600
1481
  }
1601
1482
  }
1602
1483
 
1484
+ function stripUndef$1(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
1485
+
1603
1486
  class Search {
1604
1487
  constructor(ctx) { this._ctx = ctx; }
1605
1488
 
@@ -1628,27 +1511,49 @@ class Search {
1628
1511
  return data;
1629
1512
  }
1630
1513
 
1631
- async searchProjectPhotosText(projectTableName, { q, size } = {}) {
1514
+ async searchProjectPhotosParametrized(projectTableName, { andSearchText, orSearchText, notSearchText, city, country, state, albums, dateMin, dateMax, dateNullAnd, dateNullOr, ascOrDesc, bestOfSimilarSetsOnly, splitByTier, lastId, limit } = {}) {
1632
1515
  this._ctx.requireTokens();
1633
- let path = `/api/v1/search/text/${encodeURIComponent(projectTableName)}/`;
1516
+ let path = `/api/v1/search/parametrized/${encodeURIComponent(projectTableName)}/`;
1634
1517
  const query = new URLSearchParams();
1635
- if (q !== undefined) (Array.isArray(q) ? q : [q]).forEach(v => query.append('q', v));
1636
- if (size !== undefined) (Array.isArray(size) ? size : [size]).forEach(v => query.append('size', v));
1518
+ if (andSearchText !== undefined) (Array.isArray(andSearchText) ? andSearchText : [andSearchText]).forEach(v => query.append('and_search_text', v));
1519
+ if (orSearchText !== undefined) (Array.isArray(orSearchText) ? orSearchText : [orSearchText]).forEach(v => query.append('or_search_text', v));
1520
+ if (notSearchText !== undefined) (Array.isArray(notSearchText) ? notSearchText : [notSearchText]).forEach(v => query.append('not_search_text', v));
1521
+ if (city !== undefined) (Array.isArray(city) ? city : [city]).forEach(v => query.append('city', v));
1522
+ if (country !== undefined) (Array.isArray(country) ? country : [country]).forEach(v => query.append('country', v));
1523
+ if (state !== undefined) (Array.isArray(state) ? state : [state]).forEach(v => query.append('state', v));
1524
+ if (albums !== undefined) (Array.isArray(albums) ? albums : [albums]).forEach(v => query.append('albums', v));
1525
+ if (dateMin !== undefined) (Array.isArray(dateMin) ? dateMin : [dateMin]).forEach(v => query.append('date_min', v));
1526
+ if (dateMax !== undefined) (Array.isArray(dateMax) ? dateMax : [dateMax]).forEach(v => query.append('date_max', v));
1527
+ if (dateNullAnd !== undefined) (Array.isArray(dateNullAnd) ? dateNullAnd : [dateNullAnd]).forEach(v => query.append('date_null_and', v));
1528
+ if (dateNullOr !== undefined) (Array.isArray(dateNullOr) ? dateNullOr : [dateNullOr]).forEach(v => query.append('date_null_or', v));
1529
+ if (ascOrDesc !== undefined) (Array.isArray(ascOrDesc) ? ascOrDesc : [ascOrDesc]).forEach(v => query.append('asc_or_desc', v));
1530
+ if (bestOfSimilarSetsOnly !== undefined) (Array.isArray(bestOfSimilarSetsOnly) ? bestOfSimilarSetsOnly : [bestOfSimilarSetsOnly]).forEach(v => query.append('best_of_similar_sets_only', v));
1531
+ if (splitByTier !== undefined) (Array.isArray(splitByTier) ? splitByTier : [splitByTier]).forEach(v => query.append('split_by_tier', v));
1532
+ if (lastId !== undefined) (Array.isArray(lastId) ? lastId : [lastId]).forEach(v => query.append('last_id', v));
1533
+ if (limit !== undefined) (Array.isArray(limit) ? limit : [limit]).forEach(v => query.append('limit', v));
1637
1534
  const qs = query.toString();
1638
1535
  if (qs) path += '?' + qs;
1639
1536
  const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1640
1537
  return data;
1641
1538
  }
1642
1539
 
1643
- async searchProjectPhotosNaturalLanguage(projectTableName, { searchText, size } = {}) {
1540
+ async searchProjectPhotosNaturalLanguage(projectTableName, searchText, size = undefined, { minCosine, labelMinCosine, labelTopK, labelDelta, bestOfSimilarSetsOnly, splitByTier } = {}) {
1644
1541
  this._ctx.requireTokens();
1645
- let path = `/api/v1/search/nl/${encodeURIComponent(projectTableName)}/`;
1542
+ let path = `/api/v1/search/natural_language/${encodeURIComponent(projectTableName)}/`;
1646
1543
  const query = new URLSearchParams();
1647
- if (searchText !== undefined) (Array.isArray(searchText) ? searchText : [searchText]).forEach(v => query.append('search_text', v));
1648
- if (size !== undefined) (Array.isArray(size) ? size : [size]).forEach(v => query.append('size', v));
1544
+ if (minCosine !== undefined) (Array.isArray(minCosine) ? minCosine : [minCosine]).forEach(v => query.append('min_cosine', v));
1545
+ if (labelMinCosine !== undefined) (Array.isArray(labelMinCosine) ? labelMinCosine : [labelMinCosine]).forEach(v => query.append('label_min_cosine', v));
1546
+ if (labelTopK !== undefined) (Array.isArray(labelTopK) ? labelTopK : [labelTopK]).forEach(v => query.append('label_top_k', v));
1547
+ if (labelDelta !== undefined) (Array.isArray(labelDelta) ? labelDelta : [labelDelta]).forEach(v => query.append('label_delta', v));
1548
+ if (bestOfSimilarSetsOnly !== undefined) (Array.isArray(bestOfSimilarSetsOnly) ? bestOfSimilarSetsOnly : [bestOfSimilarSetsOnly]).forEach(v => query.append('best_of_similar_sets_only', v));
1549
+ if (splitByTier !== undefined) (Array.isArray(splitByTier) ? splitByTier : [splitByTier]).forEach(v => query.append('split_by_tier', v));
1649
1550
  const qs = query.toString();
1650
1551
  if (qs) path += '?' + qs;
1651
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1552
+ const body = stripUndef$1({
1553
+ search_text: searchText,
1554
+ size: size,
1555
+ });
1556
+ const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, body);
1652
1557
  return data;
1653
1558
  }
1654
1559
 
@@ -1776,18 +1681,6 @@ class Users {
1776
1681
  return data;
1777
1682
  }
1778
1683
 
1779
- async getAllUsers(ascOrDesc, { lastId, limit } = {}) {
1780
- this._ctx.requireTokens();
1781
- let path = `/api/v1/users/admin/sort/${encodeURIComponent(ascOrDesc)}/`;
1782
- const query = new URLSearchParams();
1783
- if (lastId !== undefined) (Array.isArray(lastId) ? lastId : [lastId]).forEach(v => query.append('last_id', v));
1784
- if (limit !== undefined) (Array.isArray(limit) ? limit : [limit]).forEach(v => query.append('limit', v));
1785
- const qs = query.toString();
1786
- if (qs) path += '?' + qs;
1787
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1788
- return data;
1789
- }
1790
-
1791
1684
  async updateUser(userId, { name, email, password, companyId, accountType, profilePicture, location, phoneNumber, birthday } = {}) {
1792
1685
  this._ctx.requireTokens();
1793
1686
  const path = `/api/v1/users/${encodeURIComponent(userId)}`;
@@ -1806,24 +1699,6 @@ class Users {
1806
1699
  return data;
1807
1700
  }
1808
1701
 
1809
- async updateUserByAdmin(userId, { name, email, password, companyId, accountType, profilePicture, location, phoneNumber, birthday } = {}) {
1810
- this._ctx.requireTokens();
1811
- const path = `/api/v1/users/admin/${encodeURIComponent(userId)}`;
1812
- const body = stripUndef({
1813
- name: name,
1814
- email: email,
1815
- password: password,
1816
- company_id: companyId,
1817
- account_type: accountType,
1818
- profile_picture: profilePicture,
1819
- location: location,
1820
- phone_number: phoneNumber,
1821
- birthday: birthday,
1822
- });
1823
- const { data } = await this._ctx.client.request(path, 'PUT', this._ctx.accessToken, this._ctx.refreshToken, body);
1824
- return data;
1825
- }
1826
-
1827
1702
  async deleteUser(userId, { newCompanyOwnerId } = {}) {
1828
1703
  this._ctx.requireTokens();
1829
1704
  let path = `/api/v1/users/delete/${encodeURIComponent(userId)}`;
@@ -1906,7 +1781,6 @@ class MediaViz {
1906
1781
  this.health = new Health(_ctx);
1907
1782
  this.keywords = new Keywords(_ctx);
1908
1783
  this.oAuthAuthorization = new OauthAuthorization(_ctx);
1909
- this.oAuthClients = new OauthClients(_ctx);
1910
1784
  this.oAuthToken = new OauthToken(_ctx);
1911
1785
  this.oauthLogin = new OauthLogin(_ctx);
1912
1786
  this.person = new Person(_ctx);
@@ -1944,4 +1818,4 @@ class MediaViz {
1944
1818
  get refreshToken() { return this._refreshToken; }
1945
1819
  }
1946
1820
 
1947
- export { Admin, AiModelCredits, ApiError, Company, CuratedAlbums, CustomAlbums, EmailTokens, Health, Keywords, MediaViz, NotFoundError, OAuthClient, OAuthError, OAuthErrorCode, OauthAuthorization, OauthClients, OauthLogin, OauthToken, Person, Photos, Photoupload, Projects, RateLimitError, Search, ServerError, Users, ValidationError, handleResponse };
1821
+ export { Admin, AiModelCredits, ApiError, Company, CuratedAlbums, CustomAlbums, EmailTokens, Health, Keywords, MediaViz, NotFoundError, OAuthClient, OAuthError, OAuthErrorCode, OauthAuthorization, OauthLogin, OauthToken, Person, Photos, Photoupload, Projects, RateLimitError, Search, ServerError, Users, ValidationError, handleResponse };