@mediaviz/sdk 0.1.0 → 1.0.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/dist/sdk.cjs +21 -260
  3. package/dist/sdk.esm.js +22 -259
  4. package/dist/sdk.umd.js +21 -260
  5. package/package.json +15 -1
  6. package/MediaViz.js +0 -126
  7. package/_oauth.js +0 -3
  8. package/admin.js +0 -93
  9. package/ai_model_credits.js +0 -22
  10. package/company.js +0 -54
  11. package/curated_albums.js +0 -85
  12. package/custom_albums.js +0 -78
  13. package/email_tokens.js +0 -64
  14. package/errors.js +0 -81
  15. package/health.js +0 -20
  16. package/index.js +0 -21
  17. package/keywords.js +0 -123
  18. package/oauth/.prettierrc +0 -6
  19. package/oauth/README.md +0 -76
  20. package/oauth/browser-smoke-test.html +0 -45
  21. package/oauth/implementation_plan.json +0 -106
  22. package/oauth/package-lock.json +0 -5236
  23. package/oauth/package.json +0 -28
  24. package/oauth/rollup.config.js +0 -21
  25. package/oauth/smoke-test.js +0 -27
  26. package/oauth/spec.md +0 -187
  27. package/oauth/src/__tests__/browser-smoke-test.test.js +0 -38
  28. package/oauth/src/__tests__/client.test.js +0 -556
  29. package/oauth/src/__tests__/errors.test.js +0 -73
  30. package/oauth/src/__tests__/http.test.js +0 -102
  31. package/oauth/src/__tests__/index.test.js +0 -53
  32. package/oauth/src/__tests__/package-fields.test.js +0 -29
  33. package/oauth/src/__tests__/pkce.test.js +0 -55
  34. package/oauth/src/__tests__/rollup-build.test.js +0 -58
  35. package/oauth/src/__tests__/smoke-test.test.js +0 -26
  36. package/oauth/src/__tests__/types.test.js +0 -29
  37. package/oauth/src/client.js +0 -180
  38. package/oauth/src/errors.js +0 -32
  39. package/oauth/src/http.js +0 -52
  40. package/oauth/src/index.js +0 -7
  41. package/oauth/src/pkce.js +0 -50
  42. package/oauth/src/types.js +0 -67
  43. package/oauth_authorization.js +0 -53
  44. package/oauth_clients.js +0 -18
  45. package/oauth_login.js +0 -24
  46. package/oauth_token.js +0 -30
  47. package/person.js +0 -54
  48. package/photos.js +0 -106
  49. package/photoupload.js +0 -55
  50. package/projects.js +0 -191
  51. package/rollup.config.js +0 -12
  52. package/search.js +0 -99
  53. package/users.js +0 -137
package/dist/sdk.umd.js CHANGED
@@ -460,124 +460,11 @@
460
460
  const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
461
461
  return data;
462
462
  }
463
-
464
- async upsertModelCreditRelationship({ modelName, newCreditValue } = {}) {
465
- this._ctx.requireTokens();
466
- let path = `/api/v1/model_credit/upsert`;
467
- const query = new URLSearchParams();
468
- if (modelName !== undefined) (Array.isArray(modelName) ? modelName : [modelName]).forEach(v => query.append('model_name', v));
469
- if (newCreditValue !== undefined) (Array.isArray(newCreditValue) ? newCreditValue : [newCreditValue]).forEach(v => query.append('new_credit_value', v));
470
- const qs = query.toString();
471
- if (qs) path += '?' + qs;
472
- const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
473
- return data;
474
- }
475
- }
476
-
477
- class Admin {
478
- constructor(ctx) { this._ctx = ctx; }
479
-
480
- async insertLabelCategoryMatrix() {
481
- this._ctx.requireTokens();
482
- const path = `/api/v1/admin/insert_label_category_matrix`;
483
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
484
- return data;
485
- }
486
-
487
- async generateMidLevelCategoryKeywordAlignment() {
488
- this._ctx.requireTokens();
489
- const path = `/api/v1/admin/generate_mid_level_category_keyword_alignment`;
490
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
491
- return data;
492
- }
493
-
494
- async getCategoryLabels(category) {
495
- this._ctx.requireTokens();
496
- const path = `/api/v1/admin/category_labels/${encodeURIComponent(category)}`;
497
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
498
- return data;
499
- }
500
-
501
- async adminDumpCompanyNlpIndex(companyId) {
502
- this._ctx.requireTokens();
503
- const path = `/api/v1/admin/dump_company_nlp_index/${encodeURIComponent(companyId)}`;
504
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
505
- return data;
506
- }
507
-
508
- async getAllKeywordGroupsAndSubgroups() {
509
- this._ctx.requireTokens();
510
- const path = `/api/v1/admin/keyword_group`;
511
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
512
- return data;
513
- }
514
-
515
- async getKeywordGroupsLabelsByKeywordGroup(keywordGroup, { subgroup } = {}) {
516
- this._ctx.requireTokens();
517
- let path = `/api/v1/admin/keyword_group/${encodeURIComponent(keywordGroup)}/`;
518
- const query = new URLSearchParams();
519
- if (subgroup !== undefined) (Array.isArray(subgroup) ? subgroup : [subgroup]).forEach(v => query.append('subgroup', v));
520
- const qs = query.toString();
521
- if (qs) path += '?' + qs;
522
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
523
- return data;
524
- }
525
-
526
- async adminCreateCompanyNlpIndexes({ companyIds } = {}) {
527
- this._ctx.requireTokens();
528
- let path = `/api/v1/admin/create_company_nlp_indexes/`;
529
- const query = new URLSearchParams();
530
- if (companyIds !== undefined) (Array.isArray(companyIds) ? companyIds : [companyIds]).forEach(v => query.append('company_ids', v));
531
- const qs = query.toString();
532
- if (qs) path += '?' + qs;
533
- const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
534
- return data;
535
- }
536
-
537
- async adminDeleteCompanyNlpIndexes({ companyIds } = {}) {
538
- this._ctx.requireTokens();
539
- let path = `/api/v1/admin/delete_company_nlp_indexes/`;
540
- const query = new URLSearchParams();
541
- if (companyIds !== undefined) (Array.isArray(companyIds) ? companyIds : [companyIds]).forEach(v => query.append('company_ids', v));
542
- const qs = query.toString();
543
- if (qs) path += '?' + qs;
544
- const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
545
- return data;
546
- }
547
-
548
- async adminDeleteUserProjects({ userIds } = {}) {
549
- this._ctx.requireTokens();
550
- let path = `/api/v1/admin/delete_user_projects/`;
551
- const query = new URLSearchParams();
552
- if (userIds !== undefined) (Array.isArray(userIds) ? userIds : [userIds]).forEach(v => query.append('user_ids', v));
553
- const qs = query.toString();
554
- if (qs) path += '?' + qs;
555
- const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
556
- return data;
557
- }
558
-
559
- async adminDeleteUser({ userIds } = {}) {
560
- this._ctx.requireTokens();
561
- let path = `/api/v1/admin/delete_user/`;
562
- const query = new URLSearchParams();
563
- if (userIds !== undefined) (Array.isArray(userIds) ? userIds : [userIds]).forEach(v => query.append('user_ids', v));
564
- const qs = query.toString();
565
- if (qs) path += '?' + qs;
566
- const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
567
- return data;
568
- }
569
463
  }
570
464
 
571
465
  class Company {
572
466
  constructor(ctx) { this._ctx = ctx; }
573
467
 
574
- async getAllCompanies() {
575
- this._ctx.requireTokens();
576
- const path = `/api/v1/company/`;
577
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
578
- return data;
579
- }
580
-
581
468
  async getCompanyById(companyId) {
582
469
  this._ctx.requireTokens();
583
470
  const path = `/api/v1/company/${encodeURIComponent(companyId)}`;
@@ -596,34 +483,9 @@
596
483
  const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
597
484
  return data;
598
485
  }
599
-
600
- async adminListActiveCompanyTokens() {
601
- this._ctx.requireTokens();
602
- const path = `/api/v1/company/admin_create/`;
603
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
604
- return data;
605
- }
606
-
607
- async adminCreateCompanyToken({ email } = {}) {
608
- this._ctx.requireTokens();
609
- let path = `/api/v1/company/admin_create/`;
610
- const query = new URLSearchParams();
611
- if (email !== undefined) (Array.isArray(email) ? email : [email]).forEach(v => query.append('email', v));
612
- const qs = query.toString();
613
- if (qs) path += '?' + qs;
614
- const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
615
- return data;
616
- }
617
-
618
- async adminRevokeCompanyToken(tokenId) {
619
- this._ctx.requireTokens();
620
- const path = `/api/v1/company/admin_create/${encodeURIComponent(tokenId)}/revoke/`;
621
- const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken);
622
- return data;
623
- }
624
486
  }
625
487
 
626
- function stripUndef$6(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
488
+ function stripUndef$5(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
627
489
 
628
490
  class CuratedAlbums {
629
491
  constructor(ctx) { this._ctx = ctx; }
@@ -631,7 +493,7 @@
631
493
  async createCuratedAlbum(projectTableName, name, description = undefined, confidenceValue = undefined) {
632
494
  this._ctx.requireTokens();
633
495
  const path = `/api/v1/curated_album/project/${encodeURIComponent(projectTableName)}`;
634
- const body = stripUndef$6({
496
+ const body = stripUndef$5({
635
497
  name: name,
636
498
  description: description,
637
499
  confidence_value: confidenceValue,
@@ -685,7 +547,7 @@
685
547
  async updateCuratedAlbum(albumId, { name, description, confidenceValue } = {}) {
686
548
  this._ctx.requireTokens();
687
549
  const path = `/api/v1/curated_album/${encodeURIComponent(albumId)}`;
688
- const body = stripUndef$6({
550
+ const body = stripUndef$5({
689
551
  name: name,
690
552
  description: description,
691
553
  confidence_value: confidenceValue,
@@ -709,7 +571,7 @@
709
571
  }
710
572
  }
711
573
 
712
- function stripUndef$5(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
574
+ function stripUndef$4(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
713
575
 
714
576
  class CustomAlbums {
715
577
  constructor(ctx) { this._ctx = ctx; }
@@ -757,7 +619,7 @@
757
619
  async createProjectCustomAlbum(projectTableName, { name, description, photoIdInclusionList, photoIdRemovalList } = {}) {
758
620
  this._ctx.requireTokens();
759
621
  const path = `/api/v1/custom_album/project/${encodeURIComponent(projectTableName)}`;
760
- const body = stripUndef$5({
622
+ const body = stripUndef$4({
761
623
  name: name,
762
624
  description: description,
763
625
  photo_id_inclusion_list: photoIdInclusionList,
@@ -770,7 +632,7 @@
770
632
  async updateCustomAlbum(albumId, { name, description, photoIdInclusionList, photoIdRemovalList } = {}) {
771
633
  this._ctx.requireTokens();
772
634
  const path = `/api/v1/custom_album/${encodeURIComponent(albumId)}`;
773
- const body = stripUndef$5({
635
+ const body = stripUndef$4({
774
636
  name: name,
775
637
  description: description,
776
638
  photo_id_inclusion_list: photoIdInclusionList,
@@ -870,7 +732,7 @@
870
732
  }
871
733
  }
872
734
 
873
- function stripUndef$4(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
735
+ function stripUndef$3(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
874
736
 
875
737
  class EmailTokens {
876
738
  constructor(ctx) { this._ctx = ctx; }
@@ -901,7 +763,7 @@
901
763
  }
902
764
 
903
765
  async validateToken(token) {
904
- const body = stripUndef$4({
766
+ const body = stripUndef$3({
905
767
  token: token,
906
768
  });
907
769
  const resp = await fetch(this._ctx.baseUrl + `/api/v1/validate-token`, {
@@ -913,7 +775,7 @@
913
775
  }
914
776
 
915
777
  async resetPassword(token, newPassword) {
916
- const body = stripUndef$4({
778
+ const body = stripUndef$3({
917
779
  token: token,
918
780
  new_password: newPassword,
919
781
  });
@@ -952,7 +814,7 @@
952
814
  }
953
815
  }
954
816
 
955
- function stripUndef$3(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
817
+ function stripUndef$2(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
956
818
 
957
819
  class Keywords {
958
820
  constructor(ctx) { this._ctx = ctx; }
@@ -960,7 +822,7 @@
960
822
  async createKeywordFilteringList(name, projectList = undefined) {
961
823
  this._ctx.requireTokens();
962
824
  const path = `/api/v1/keyword/`;
963
- const body = stripUndef$3({
825
+ const body = stripUndef$2({
964
826
  name: name,
965
827
  project_list: projectList,
966
828
  });
@@ -1006,7 +868,7 @@
1006
868
  async updateKeywordFilteringListLabels(keywordListId, listKeywordsToInclude, listKeywordsToExclude) {
1007
869
  this._ctx.requireTokens();
1008
870
  const path = `/api/v1/keyword/${encodeURIComponent(keywordListId)}`;
1009
- const body = stripUndef$3({
871
+ const body = stripUndef$2({
1010
872
  list_keywords_to_include: listKeywordsToInclude,
1011
873
  list_keywords_to_exclude: listKeywordsToExclude,
1012
874
  });
@@ -1017,7 +879,7 @@
1017
879
  async updateKeywordFilteringListDetails(keywordListId, { name, projectList } = {}) {
1018
880
  this._ctx.requireTokens();
1019
881
  const path = `/api/v1/keyword/details/${encodeURIComponent(keywordListId)}`;
1020
- const body = stripUndef$3({
882
+ const body = stripUndef$2({
1021
883
  name: name,
1022
884
  project_list: projectList,
1023
885
  });
@@ -1128,25 +990,6 @@
1128
990
  }
1129
991
  }
1130
992
 
1131
- function stripUndef$2(o) { const r = {}; for (const k in o) if (o[k] !== undefined) r[k] = o[k]; return r; }
1132
-
1133
- class OauthClients {
1134
- constructor(ctx) { this._ctx = ctx; }
1135
-
1136
- async createClient(clientName, clientType, redirectUris, isFirstParty) {
1137
- this._ctx.requireTokens();
1138
- const path = `/oauth/clients`;
1139
- const body = stripUndef$2({
1140
- client_name: clientName,
1141
- client_type: clientType,
1142
- redirect_uris: redirectUris,
1143
- is_first_party: isFirstParty,
1144
- });
1145
- const { data } = await this._ctx.client.request(path, 'POST', this._ctx.accessToken, this._ctx.refreshToken, body);
1146
- return data;
1147
- }
1148
- }
1149
-
1150
993
  class OauthToken {
1151
994
  constructor(ctx) { this._ctx = ctx; }
1152
995
 
@@ -1320,13 +1163,6 @@
1320
1163
  return data;
1321
1164
  }
1322
1165
 
1323
- async getAllUserProjectsAdmin(userId) {
1324
- this._ctx.requireTokens();
1325
- const path = `/api/v1/projects/admin/user/${encodeURIComponent(userId)}`;
1326
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1327
- return data;
1328
- }
1329
-
1330
1166
  async getProjectById(projectId) {
1331
1167
  this._ctx.requireTokens();
1332
1168
  const path = `/api/v1/projects/${encodeURIComponent(projectId)}`;
@@ -1413,13 +1249,6 @@
1413
1249
  return data;
1414
1250
  }
1415
1251
 
1416
- async requestProjectAdminExport(projectTableName) {
1417
- this._ctx.requireTokens();
1418
- const path = `/api/v1/projects_admin_export/${encodeURIComponent(projectTableName)}`;
1419
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1420
- return data;
1421
- }
1422
-
1423
1252
  async getProjectDataExportUploadStatus(projectTableName, modelName) {
1424
1253
  this._ctx.requireTokens();
1425
1254
  const path = `/api/v1/projects/${encodeURIComponent(projectTableName)}/upload_status/${encodeURIComponent(modelName)}`;
@@ -1449,18 +1278,18 @@
1449
1278
  class Photoupload {
1450
1279
  constructor(ctx) { this._ctx = ctx; this._caches = {}; }
1451
1280
 
1452
- async uploadPhotoToMediaviz(companyId, userId, projectTableName, title, { fileContent, mimetype, filePath }, { clientSideId, blur, colors, faceRecognition, imageDescribe, imageClassification, imageComparison, size, sourceResolutionX, sourceResolutionY, dateTaken, latitude, longitude, ocr } = {}) {
1281
+ async uploadPhotoToMediaviz({ fileContent, mimetype, filePath }, { companyId, userId, projectTableName, clientSideId, title, blur, colors, faceRecognition, imageDescribe, imageClassification, imageComparison, size, sourceResolutionX, sourceResolutionY, dateTaken, latitude, longitude, bucketName, photoIndex } = {}) {
1453
1282
  this._ctx.requireTokens();
1454
1283
  const baseUrl = this._ctx.requireHost('photoUpload');
1455
1284
  const headers = {
1456
1285
  'Content-Type': 'application/json',
1457
1286
  'Authorization': this._ctx.accessToken,
1458
- 'x-company-id': companyId,
1459
- 'x-user-id': userId,
1460
- 'x-project-table-name': projectTableName,
1461
- 'x-title': title,
1462
1287
  };
1288
+ if (companyId !== undefined) headers['x-company-id'] = companyId;
1289
+ if (userId !== undefined) headers['x-user-id'] = userId;
1290
+ if (projectTableName !== undefined) headers['x-project-table-name'] = projectTableName;
1463
1291
  if (clientSideId !== undefined) headers['x-client-side-id'] = clientSideId;
1292
+ if (title !== undefined) headers['x-title'] = title;
1464
1293
  if (blur !== undefined) headers['x-blur'] = blur;
1465
1294
  if (colors !== undefined) headers['x-colors'] = colors;
1466
1295
  if (faceRecognition !== undefined) headers['x-face-recognition'] = faceRecognition;
@@ -1473,7 +1302,8 @@
1473
1302
  if (dateTaken !== undefined) headers['x-date-taken'] = dateTaken;
1474
1303
  if (latitude !== undefined) headers['x-latitude'] = latitude;
1475
1304
  if (longitude !== undefined) headers['x-longitude'] = longitude;
1476
- if (ocr !== undefined) headers['x-ocr'] = ocr;
1305
+ if (bucketName !== undefined) headers['x-bucket-name'] = bucketName;
1306
+ if (photoIndex !== undefined) headers['x-photo-index'] = photoIndex;
1477
1307
  const resp = await fetch(baseUrl + `/photo_upload`, {
1478
1308
  method: 'POST',
1479
1309
  headers,
@@ -1493,7 +1323,7 @@
1493
1323
  this._caches['_get_template'].set(_cacheKey_get_template, template);
1494
1324
  }
1495
1325
 
1496
- const upload_result = await this.uploadPhotoToMediaviz(companyId, userId, projectTableName, photo.title, { fileContent: photo.fileContent, mimetype: photo.mimetype, filePath: photo.filePath }, { clientSideId: photo.clientSideId, blur: photo.blur, colors: photo.colors, faceRecognition: photo.faceRecognition, imageDescribe: photo.imageDescribe, imageClassification: photo.imageClassification, imageComparison: photo.imageComparison, size: photo.size, sourceResolutionX: photo.sourceResolutionX, sourceResolutionY: photo.sourceResolutionY, dateTaken: photo.dateTaken, latitude: photo.latitude, longitude: photo.longitude });
1326
+ const upload_result = await this.uploadPhotoToMediaviz({ fileContent: photo.fileContent, mimetype: photo.mimetype, filePath: photo.filePath }, { companyId: companyId, userId: userId, projectTableName: projectTableName, clientSideId: photo.clientSideId, title: photo.title, blur: photo.blur, colors: photo.colors, faceRecognition: photo.faceRecognition, imageDescribe: photo.imageDescribe, imageClassification: photo.imageClassification, imageComparison: photo.imageComparison, size: photo.size, sourceResolutionX: photo.sourceResolutionX, sourceResolutionY: photo.sourceResolutionY, dateTaken: photo.dateTaken, latitude: photo.latitude, longitude: photo.longitude, bucketName: template.bucket_name, photoIndex: photoIndex });
1497
1327
 
1498
1328
  return upload_result;
1499
1329
  }
@@ -1634,30 +1464,6 @@
1634
1464
  return data;
1635
1465
  }
1636
1466
 
1637
- async searchProjectPhotosText(projectTableName, { q, size } = {}) {
1638
- this._ctx.requireTokens();
1639
- let path = `/api/v1/search/text/${encodeURIComponent(projectTableName)}/`;
1640
- const query = new URLSearchParams();
1641
- if (q !== undefined) (Array.isArray(q) ? q : [q]).forEach(v => query.append('q', v));
1642
- if (size !== undefined) (Array.isArray(size) ? size : [size]).forEach(v => query.append('size', v));
1643
- const qs = query.toString();
1644
- if (qs) path += '?' + qs;
1645
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1646
- return data;
1647
- }
1648
-
1649
- async searchProjectPhotosNaturalLanguage(projectTableName, { searchText, size } = {}) {
1650
- this._ctx.requireTokens();
1651
- let path = `/api/v1/search/nl/${encodeURIComponent(projectTableName)}/`;
1652
- const query = new URLSearchParams();
1653
- if (searchText !== undefined) (Array.isArray(searchText) ? searchText : [searchText]).forEach(v => query.append('search_text', v));
1654
- if (size !== undefined) (Array.isArray(size) ? size : [size]).forEach(v => query.append('size', v));
1655
- const qs = query.toString();
1656
- if (qs) path += '?' + qs;
1657
- const { data } = await this._ctx.client.request(path, 'GET', this._ctx.accessToken, this._ctx.refreshToken);
1658
- return data;
1659
- }
1660
-
1661
1467
  async getProjectSavedSearches(projectTableName) {
1662
1468
  this._ctx.requireTokens();
1663
1469
  const path = `/api/v1/search/saved/${encodeURIComponent(projectTableName)}/`;
@@ -1782,18 +1588,6 @@
1782
1588
  return data;
1783
1589
  }
1784
1590
 
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
1591
  async updateUser(userId, { name, email, password, companyId, accountType, profilePicture, location, phoneNumber, birthday } = {}) {
1798
1592
  this._ctx.requireTokens();
1799
1593
  const path = `/api/v1/users/${encodeURIComponent(userId)}`;
@@ -1811,35 +1605,6 @@
1811
1605
  const { data } = await this._ctx.client.request(path, 'PUT', this._ctx.accessToken, this._ctx.refreshToken, body);
1812
1606
  return data;
1813
1607
  }
1814
-
1815
- async updateUserByAdmin(userId, { name, email, password, companyId, accountType, profilePicture, location, phoneNumber, birthday } = {}) {
1816
- this._ctx.requireTokens();
1817
- const path = `/api/v1/users/admin/${encodeURIComponent(userId)}`;
1818
- const body = stripUndef({
1819
- name: name,
1820
- email: email,
1821
- password: password,
1822
- company_id: companyId,
1823
- account_type: accountType,
1824
- profile_picture: profilePicture,
1825
- location: location,
1826
- phone_number: phoneNumber,
1827
- birthday: birthday,
1828
- });
1829
- const { data } = await this._ctx.client.request(path, 'PUT', this._ctx.accessToken, this._ctx.refreshToken, body);
1830
- return data;
1831
- }
1832
-
1833
- async deleteUser(userId, { newCompanyOwnerId } = {}) {
1834
- this._ctx.requireTokens();
1835
- let path = `/api/v1/users/delete/${encodeURIComponent(userId)}`;
1836
- const query = new URLSearchParams();
1837
- if (newCompanyOwnerId !== undefined) (Array.isArray(newCompanyOwnerId) ? newCompanyOwnerId : [newCompanyOwnerId]).forEach(v => query.append('new_company_owner_id', v));
1838
- const qs = query.toString();
1839
- if (qs) path += '?' + qs;
1840
- const { data } = await this._ctx.client.request(path, 'DELETE', this._ctx.accessToken, this._ctx.refreshToken);
1841
- return data;
1842
- }
1843
1608
  }
1844
1609
 
1845
1610
  // Auto-generated — do not edit
@@ -1904,7 +1669,6 @@
1904
1669
 
1905
1670
  const _ctx = new _Context(this);
1906
1671
  this.aiModelCredits = new AiModelCredits(_ctx);
1907
- this.admin = new Admin(_ctx);
1908
1672
  this.company = new Company(_ctx);
1909
1673
  this.curatedAlbums = new CuratedAlbums(_ctx);
1910
1674
  this.customAlbums = new CustomAlbums(_ctx);
@@ -1912,7 +1676,6 @@
1912
1676
  this.health = new Health(_ctx);
1913
1677
  this.keywords = new Keywords(_ctx);
1914
1678
  this.oAuthAuthorization = new OauthAuthorization(_ctx);
1915
- this.oAuthClients = new OauthClients(_ctx);
1916
1679
  this.oAuthToken = new OauthToken(_ctx);
1917
1680
  this.oauthLogin = new OauthLogin(_ctx);
1918
1681
  this.person = new Person(_ctx);
@@ -1950,7 +1713,6 @@
1950
1713
  get refreshToken() { return this._refreshToken; }
1951
1714
  }
1952
1715
 
1953
- exports.Admin = Admin;
1954
1716
  exports.AiModelCredits = AiModelCredits;
1955
1717
  exports.ApiError = ApiError;
1956
1718
  exports.Company = Company;
@@ -1965,7 +1727,6 @@
1965
1727
  exports.OAuthError = OAuthError;
1966
1728
  exports.OAuthErrorCode = OAuthErrorCode;
1967
1729
  exports.OauthAuthorization = OauthAuthorization;
1968
- exports.OauthClients = OauthClients;
1969
1730
  exports.OauthLogin = OauthLogin;
1970
1731
  exports.OauthToken = OauthToken;
1971
1732
  exports.Person = Person;
package/package.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "name": "@mediaviz/sdk",
3
- "version": "0.1.0",
3
+ "version": "1.0.60",
4
+ "description": "MediaViz JavaScript SDK \u2014 auto-generated public endpoint client.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/mediaviz/mediaviz_sdk"
9
+ },
4
10
  "type": "module",
5
11
  "main": "./dist/sdk.cjs",
6
12
  "module": "./dist/sdk.esm.js",
@@ -13,6 +19,14 @@
13
19
  "default": "./dist/sdk.cjs"
14
20
  }
15
21
  },
22
+ "files": [
23
+ "dist",
24
+ "LICENSE",
25
+ "README.md"
26
+ ],
27
+ "publishConfig": {
28
+ "access": "public"
29
+ },
16
30
  "scripts": {
17
31
  "build": "rollup -c"
18
32
  },
package/MediaViz.js DELETED
@@ -1,126 +0,0 @@
1
- // Auto-generated — do not edit
2
- import { OAuthClient } from './_oauth.js';
3
- import { AiModelCredits } from './ai_model_credits.js';
4
- import { Admin } from './admin.js';
5
- import { Company } from './company.js';
6
- import { CuratedAlbums } from './curated_albums.js';
7
- import { CustomAlbums } from './custom_albums.js';
8
- import { EmailTokens } from './email_tokens.js';
9
- import { Health } from './health.js';
10
- import { Keywords } from './keywords.js';
11
- import { OauthAuthorization } from './oauth_authorization.js';
12
- import { OauthClients } from './oauth_clients.js';
13
- import { OauthToken } from './oauth_token.js';
14
- import { OauthLogin } from './oauth_login.js';
15
- import { Person } from './person.js';
16
- import { Photoupload } from './photoupload.js';
17
- import { Photos } from './photos.js';
18
- import { Projects } from './projects.js';
19
- import { Search } from './search.js';
20
- import { Users } from './users.js';
21
-
22
- function _env(key) {
23
- if (typeof process !== 'undefined' && process.env) return process.env[key];
24
- return undefined;
25
- }
26
-
27
- class _Context {
28
- constructor(mv) { this._mv = mv; }
29
- get client() { return this._mv._oauthClient; }
30
- get accessToken() { return this._mv._accessToken; }
31
- get refreshToken() { return this._mv._refreshToken; }
32
- get baseUrl() { return this._mv._config.baseUrl; }
33
- get hosts() { return this._mv._hosts; }
34
- requireHost(key) {
35
- const url = this._mv._hosts[key];
36
- if (!url) throw new Error(`Host '${key}' not configured. Pass hosts.${key} in MediaViz constructor or set the corresponding env var.`);
37
- return url;
38
- }
39
- requireTokens() {
40
- if (!this._mv._accessToken) throw new Error('Not authenticated. Call authenticate(), handleCallback(), or setTokens() first.');
41
- }
42
- }
43
-
44
- class _TokenTrackingClient {
45
- constructor(mv, inner) { this._mv = mv; this._inner = inner; }
46
- async request(url, method, accessToken, refreshToken, body) {
47
- const onRefreshSuccess = (newTokens) => {
48
- this._mv._accessToken = newTokens.access_token;
49
- this._mv._refreshToken = newTokens.refresh_token;
50
- if (this._mv._onTokenRefresh) this._mv._onTokenRefresh(newTokens);
51
- };
52
- return this._inner.request(url, method, accessToken, refreshToken, body, onRefreshSuccess);
53
- }
54
- }
55
-
56
- export class MediaViz {
57
- constructor(config = {}) {
58
- this._config = {
59
- clientId: config.clientId ?? _env('MEDIAVIZ_CLIENT_ID'),
60
- clientSecret: config.clientSecret ?? _env('MEDIAVIZ_CLIENT_SECRET'),
61
- baseUrl: config.baseUrl ?? _env('MEDIAVIZ_BASE_URL') ?? 'https://api.mediaviz.ai',
62
- redirectUri: config.redirectUri ?? _env('MEDIAVIZ_REDIRECT_URI'),
63
- };
64
- this._hosts = {
65
- photoUpload: config.hosts?.photoUpload ?? _env('MEDIAVIZ_PHOTO_UPLOAD_URL'),
66
- ...(config.hosts || {}),
67
- };
68
- this._accessToken = config.accessToken ?? null;
69
- this._refreshToken = config.refreshToken ?? null;
70
- this._onTokenRefresh = config.onTokenRefresh ?? null;
71
-
72
- const _inner = new OAuthClient({
73
- clientId: this._config.clientId,
74
- clientSecret: this._config.clientSecret,
75
- baseUrl: this._config.baseUrl,
76
- redirectUri: this._config.redirectUri,
77
- });
78
- this._oauthClient = new _TokenTrackingClient(this, _inner);
79
-
80
- const _ctx = new _Context(this);
81
- this.aiModelCredits = new AiModelCredits(_ctx);
82
- this.admin = new Admin(_ctx);
83
- this.company = new Company(_ctx);
84
- this.curatedAlbums = new CuratedAlbums(_ctx);
85
- this.customAlbums = new CustomAlbums(_ctx);
86
- this.emailTokens = new EmailTokens(_ctx);
87
- this.health = new Health(_ctx);
88
- this.keywords = new Keywords(_ctx);
89
- this.oAuthAuthorization = new OauthAuthorization(_ctx);
90
- this.oAuthClients = new OauthClients(_ctx);
91
- this.oAuthToken = new OauthToken(_ctx);
92
- this.oauthLogin = new OauthLogin(_ctx);
93
- this.person = new Person(_ctx);
94
- this.photoUpload = new Photoupload(_ctx);
95
- this.photos = new Photos(_ctx);
96
- this.projects = new Projects(_ctx);
97
- this.search = new Search(_ctx);
98
- this.users = new Users(_ctx);
99
- }
100
-
101
- async authenticate() {
102
- const tokens = await this._oauthClient._inner.getClientCredentialsToken();
103
- this._accessToken = tokens.access_token;
104
- this._refreshToken = tokens.refresh_token ?? null;
105
- return tokens;
106
- }
107
-
108
- async getAuthorizationUrl(state) {
109
- return this._oauthClient._inner.generateAuthorizationUrl(state);
110
- }
111
-
112
- async handleCallback(code, codeVerifier) {
113
- const tokens = await this._oauthClient._inner.exchangeCode(code, codeVerifier);
114
- this._accessToken = tokens.access_token;
115
- this._refreshToken = tokens.refresh_token;
116
- return tokens;
117
- }
118
-
119
- setTokens(accessToken, refreshToken) {
120
- this._accessToken = accessToken;
121
- this._refreshToken = refreshToken;
122
- }
123
-
124
- get accessToken() { return this._accessToken; }
125
- get refreshToken() { return this._refreshToken; }
126
- }
package/_oauth.js DELETED
@@ -1,3 +0,0 @@
1
- // Auto-generated — do not edit
2
- import _oauth from './oauth/src/index.js';
3
- export const { OAuthClient, OAuthError, OAuthErrorCode } = _oauth;