@visgate_ai/client 0.3.5 → 0.4.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/dist/index.cjs CHANGED
@@ -427,6 +427,17 @@ var Deployments = class {
427
427
  });
428
428
  return data;
429
429
  }
430
+ /**
431
+ * Get RunPod job status. Use when run() returns status IN_QUEUE or RUNNING
432
+ * so you can poll until COMPLETED and read output (e.g. image URL).
433
+ */
434
+ async getStatus(deploymentId, jobId) {
435
+ const data = await this._client._request(
436
+ "GET",
437
+ `/deployments/${encodeURIComponent(deploymentId)}/status/${encodeURIComponent(jobId)}`
438
+ );
439
+ return data;
440
+ }
430
441
  async getLogs(deploymentId) {
431
442
  const data = await this._client._request(
432
443
  "GET",
@@ -539,6 +550,171 @@ var HfModels = class {
539
550
  }
540
551
  };
541
552
 
553
+ // src/resources/invitations.ts
554
+ function invitationFromResponse(data) {
555
+ return {
556
+ id: data.id ?? "",
557
+ organizationId: data.organization_id ?? "",
558
+ organizationName: data.organization_name ?? "",
559
+ email: data.email ?? "",
560
+ role: data.role ?? "member",
561
+ status: data.status ?? "pending",
562
+ invitedByEmail: data.invited_by_email ?? "",
563
+ createdAt: data.created_at ?? "",
564
+ expiresAt: data.expires_at ?? ""
565
+ };
566
+ }
567
+ var Invitations = class {
568
+ constructor(client) {
569
+ this.client = client;
570
+ }
571
+ /** Create an invitation to join an organization. */
572
+ async create(orgId, email, role) {
573
+ const data = await this.client._request("POST", `/organizations/${encodeURIComponent(orgId)}/invitations`, {
574
+ body: JSON.stringify({ email, role })
575
+ });
576
+ return invitationFromResponse(data);
577
+ }
578
+ /** List pending invitations for an organization. */
579
+ async listForOrg(orgId) {
580
+ const data = await this.client._request("GET", `/organizations/${encodeURIComponent(orgId)}/invitations`);
581
+ return data.map(invitationFromResponse);
582
+ }
583
+ /** Cancel a pending invitation. */
584
+ async cancel(orgId, inviteId) {
585
+ await this.client._request("DELETE", `/organizations/${encodeURIComponent(orgId)}/invitations/${encodeURIComponent(inviteId)}`);
586
+ }
587
+ /** List pending invitations for the current user. */
588
+ async listPending() {
589
+ const data = await this.client._request("GET", "/invitations/pending");
590
+ return data.map(invitationFromResponse);
591
+ }
592
+ /** Accept a pending invitation. */
593
+ async accept(inviteId) {
594
+ return await this.client._request("POST", `/invitations/${encodeURIComponent(inviteId)}/accept`);
595
+ }
596
+ /** Decline a pending invitation. */
597
+ async decline(inviteId) {
598
+ return await this.client._request("POST", `/invitations/${encodeURIComponent(inviteId)}/decline`);
599
+ }
600
+ };
601
+
602
+ // src/resources/members.ts
603
+ function memberFromResponse(data) {
604
+ return {
605
+ id: data.id ?? "",
606
+ userId: data.user_id ?? "",
607
+ email: data.email ?? "",
608
+ displayName: data.display_name ?? "",
609
+ role: data.role ?? "member",
610
+ joinedAt: data.joined_at ?? ""
611
+ };
612
+ }
613
+ var Members = class {
614
+ constructor(client) {
615
+ this.client = client;
616
+ }
617
+ /** List all members of an organization. */
618
+ async list(orgId) {
619
+ const data = await this.client._request("GET", `/organizations/${encodeURIComponent(orgId)}/members`);
620
+ return data.map(memberFromResponse);
621
+ }
622
+ /** Change a member's role. */
623
+ async changeRole(orgId, userId, role) {
624
+ return await this.client._request("PUT", `/organizations/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}/role`, {
625
+ body: JSON.stringify({ role })
626
+ });
627
+ }
628
+ /** Remove a member from the organization. */
629
+ async remove(orgId, userId) {
630
+ await this.client._request("DELETE", `/organizations/${encodeURIComponent(orgId)}/members/${encodeURIComponent(userId)}`);
631
+ }
632
+ /** Leave an organization voluntarily. */
633
+ async leave(orgId) {
634
+ return await this.client._request("POST", `/organizations/${encodeURIComponent(orgId)}/leave`);
635
+ }
636
+ /** Transfer ownership to another member. */
637
+ async transferOwnership(orgId, targetUserId) {
638
+ return await this.client._request("POST", `/organizations/${encodeURIComponent(orgId)}/transfer-ownership`, {
639
+ body: JSON.stringify({ target_user_id: targetUserId })
640
+ });
641
+ }
642
+ };
643
+
644
+ // src/resources/organizations.ts
645
+ function organizationFromResponse(data) {
646
+ return {
647
+ id: data.id ?? "",
648
+ name: data.name ?? "",
649
+ slug: data.slug ?? null,
650
+ tier: data.tier ?? "free",
651
+ balanceMicro: data.balance_micro ?? 0,
652
+ balanceDollars: data.balance_dollars ?? 0,
653
+ isPersonal: data.is_personal ?? false,
654
+ memberCount: data.member_count ?? 1,
655
+ role: data.role ?? "member",
656
+ permissions: data.permissions ?? []
657
+ };
658
+ }
659
+ function organizationSummaryFromResponse(data) {
660
+ return {
661
+ id: data.id ?? "",
662
+ name: data.name ?? "",
663
+ slug: data.slug ?? null,
664
+ role: data.role ?? "member",
665
+ isPersonal: data.is_personal ?? false
666
+ };
667
+ }
668
+ var Organizations = class {
669
+ constructor(client) {
670
+ this.client = client;
671
+ }
672
+ /** List all organizations the current user belongs to. */
673
+ async list() {
674
+ const data = await this.client._request("GET", "/organizations");
675
+ return data.map(organizationSummaryFromResponse);
676
+ }
677
+ /** Get organization details by ID. */
678
+ async get(orgId) {
679
+ const data = await this.client._request("GET", `/organizations/${encodeURIComponent(orgId)}`);
680
+ return organizationFromResponse(data);
681
+ }
682
+ /** Resolve slug to organization. */
683
+ async getBySlug(slug) {
684
+ return await this.client._request("GET", `/organizations/by-slug/${encodeURIComponent(slug)}`);
685
+ }
686
+ /** Create a new non-personal organization. */
687
+ async create(name) {
688
+ const data = await this.client._request("POST", "/organizations", {
689
+ body: JSON.stringify({ name })
690
+ });
691
+ return organizationFromResponse(data);
692
+ }
693
+ /** Update organization name and/or slug. */
694
+ async update(orgId, updates) {
695
+ const data = await this.client._request("PUT", `/organizations/${encodeURIComponent(orgId)}`, {
696
+ body: JSON.stringify(updates)
697
+ });
698
+ return organizationFromResponse(data);
699
+ }
700
+ /** Delete a non-personal organization. */
701
+ async delete(orgId) {
702
+ await this.client._request("DELETE", `/organizations/${encodeURIComponent(orgId)}`);
703
+ }
704
+ /** Get configurable member permissions for this organization. */
705
+ async getPermissions(orgId) {
706
+ const data = await this.client._request("GET", `/organizations/${encodeURIComponent(orgId)}/permissions`);
707
+ return { permissions: data.permissions ?? [] };
708
+ }
709
+ /** Update configurable member permissions for this organization. */
710
+ async updatePermissions(orgId, permissions) {
711
+ const data = await this.client._request("PUT", `/organizations/${encodeURIComponent(orgId)}/permissions`, {
712
+ body: JSON.stringify({ permissions })
713
+ });
714
+ return { permissions: data.permissions ?? [] };
715
+ }
716
+ };
717
+
542
718
  // src/resources/providers.ts
543
719
  function providerKeyInfoFromResponse(data) {
544
720
  return {
@@ -885,6 +1061,7 @@ var Client = class {
885
1061
  this.baseUrl = (options.proxyUrl ?? options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "");
886
1062
  this.timeout = options.timeout ?? DEFAULT_TIMEOUT;
887
1063
  this.maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
1064
+ this._orgId = options.orgId ?? null;
888
1065
  this.headers = buildHeaders(this.apiKey, options.proxyUrl ? {} : {
889
1066
  falKey: options.falKey,
890
1067
  replicateKey: options.replicateKey,
@@ -900,8 +1077,24 @@ var Client = class {
900
1077
  this.deployments = new Deployments(this);
901
1078
  this.hfModels = new HfModels();
902
1079
  this.billing = new Billing(this);
1080
+ this.organizations = new Organizations(this);
1081
+ this.members = new Members(this);
1082
+ this.invitations = new Invitations(this);
903
1083
  this._generate = new Generate(this);
904
1084
  }
1085
+ /**
1086
+ * Set the organization context for subsequent requests.
1087
+ * Sent as X-Org-Id header on every request.
1088
+ */
1089
+ setOrgId(orgId) {
1090
+ this._orgId = orgId;
1091
+ }
1092
+ /**
1093
+ * Get the current organization context.
1094
+ */
1095
+ getOrgId() {
1096
+ return this._orgId;
1097
+ }
905
1098
  /**
906
1099
  * Generate an image with a single call.
907
1100
  */
@@ -925,6 +1118,9 @@ var Client = class {
925
1118
  const token = await Promise.resolve(this.getToken());
926
1119
  headers = { ...headers, Authorization: `Bearer ${token}` };
927
1120
  }
1121
+ if (this._orgId) {
1122
+ headers["X-Org-Id"] = this._orgId;
1123
+ }
928
1124
  const fetchInit = {
929
1125
  method,
930
1126
  ...init,
@@ -998,7 +1194,10 @@ exports.Deployments = Deployments;
998
1194
  exports.Generate = Generate;
999
1195
  exports.HfModels = HfModels;
1000
1196
  exports.Images = Images;
1197
+ exports.Invitations = Invitations;
1198
+ exports.Members = Members;
1001
1199
  exports.Models = Models;
1200
+ exports.Organizations = Organizations;
1002
1201
  exports.ProviderError = ProviderError;
1003
1202
  exports.Providers = Providers;
1004
1203
  exports.RateLimitError = RateLimitError;
@@ -1021,9 +1220,13 @@ exports.deploymentLogsResponseFromResponse = deploymentLogsResponseFromResponse;
1021
1220
  exports.featuredSectionFromResponse = featuredSectionFromResponse;
1022
1221
  exports.generateResultFromResponse = generateResultFromResponse;
1023
1222
  exports.imageResultFromResponse = imageResultFromResponse;
1223
+ exports.invitationFromResponse = invitationFromResponse;
1224
+ exports.memberFromResponse = memberFromResponse;
1024
1225
  exports.modelInfoFromResponse = modelInfoFromResponse;
1025
1226
  exports.modelPricingFromResponse = modelPricingFromResponse;
1026
1227
  exports.modelsResponseFromResponse = modelsResponseFromResponse;
1228
+ exports.organizationFromResponse = organizationFromResponse;
1229
+ exports.organizationSummaryFromResponse = organizationSummaryFromResponse;
1027
1230
  exports.pricingResponseFromResponse = pricingResponseFromResponse;
1028
1231
  exports.providerBalanceItemFromResponse = providerBalanceItemFromResponse;
1029
1232
  exports.providerBalancesResponseFromResponse = providerBalancesResponseFromResponse;