@flashbacktech/tsclient 0.4.62 → 0.4.64

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.d.cts CHANGED
@@ -426,6 +426,30 @@ interface InviteOrgResult {
426
426
  organization: Organization;
427
427
  owner: OrganizationUser;
428
428
  }
429
+ /**
430
+ * One outstanding org or member invite, as surfaced by the platform-admin
431
+ * invite-management list (GET /admin/org-invites). Reconstructed server-side
432
+ * from the latest ORG_INVITE token joined to the invited user + org — there is
433
+ * no dedicated invite table. `status` is derived: a validated user has
434
+ * `redeemed`; otherwise `pending` until `expiresAt`, then `expired`.
435
+ */
436
+ interface OrgInvite {
437
+ userId: string;
438
+ email: string;
439
+ name: string;
440
+ lastName?: string;
441
+ orgId: string;
442
+ orgName: string;
443
+ /** Org role integer of the invitee (255 = Owner for founding-owner invites). */
444
+ orgRole?: number | null;
445
+ status: 'pending' | 'redeemed' | 'expired';
446
+ /** Token mint time, ISO-8601. Treated as "invited at". */
447
+ invitedAt: string;
448
+ /** Invite link expiry, ISO-8601. */
449
+ expiresAt: string;
450
+ /** When the invite was consumed, ISO-8601, or null while unredeemed. */
451
+ redeemedAt?: string | null;
452
+ }
429
453
  interface SimpleOrgResponse {
430
454
  success: boolean;
431
455
  message?: string;
@@ -533,6 +557,26 @@ declare class OrganizationClient {
533
557
  * ADMIN_ORGANIZATION; 409 when the owner email already exists.
534
558
  */
535
559
  inviteOrg(body: InviteOrgRequest): Promise<InviteOrgResult>;
560
+ /**
561
+ * Platform-admin only: list every outstanding org + member invite (founding-
562
+ * owner invites from `inviteOrg` and members added via `addUserToOrg`) with
563
+ * derived status, newest first. Cancelled invites (soft-deleted) and live
564
+ * non-invited orgs are excluded. Returns 403 unless platform admin.
565
+ */
566
+ listOrgInvites(): Promise<OrgInvite[]>;
567
+ /**
568
+ * Platform-admin only: re-send an invite — mints a fresh 7-day token and
569
+ * re-emails the link. Returns 403 unless platform admin; 404 when no pending
570
+ * invite exists; 409 once the invite has been redeemed.
571
+ */
572
+ resendOrgInvite(userId: string): Promise<SimpleOrgResponse>;
573
+ /**
574
+ * Platform-admin only: cancel a pending invite. Soft-deletes the invited user
575
+ * (and the shell org, for a never-redeemed founding-owner invite with no other
576
+ * members) and revokes the token, freeing the email for re-invite. Returns 403
577
+ * unless platform admin; 404 when absent; 409 once the invite has been redeemed.
578
+ */
579
+ cancelOrgInvite(userId: string): Promise<SimpleOrgResponse>;
536
580
  /**
537
581
  * Platform-admin only: enable or disable the debug surface for an org.
538
582
  * Returns the updated org entry with the new allowDebug value.
@@ -1883,6 +1927,15 @@ interface Subscription {
1883
1927
  capabilities: SubscriptionCapability[];
1884
1928
  }
1885
1929
  /** The org's currently active subscription (GET /subscriptions/my). */
1930
+ /**
1931
+ * A pending plan change deferred to the period boundary (a downgrade).
1932
+ * effectiveAt is when the lower plan takes over (= current period end).
1933
+ */
1934
+ interface ScheduledChange {
1935
+ toSubscriptionId: string;
1936
+ toSubscriptionName: string;
1937
+ effectiveAt: string;
1938
+ }
1886
1939
  interface OrgSubscription {
1887
1940
  id: string;
1888
1941
  name: string;
@@ -1894,7 +1947,10 @@ interface OrgSubscription {
1894
1947
  dateFrom: string;
1895
1948
  dateTo: string | null;
1896
1949
  status: string;
1950
+ /** false once a cancel-at-period-end is pending (active until dateTo). */
1897
1951
  autoRenew: boolean;
1952
+ /** Set when a downgrade is scheduled for the period boundary. */
1953
+ scheduledChange?: ScheduledChange | null;
1898
1954
  }
1899
1955
  interface BuySubscriptionRequest {
1900
1956
  subscriptionPeriodId: string;
@@ -1909,6 +1965,29 @@ interface BuySubscriptionResponse {
1909
1965
  name: string;
1910
1966
  } | null;
1911
1967
  isFreeSubscription?: boolean;
1968
+ /** Set when the change was a deferred downgrade (no charge now). */
1969
+ scheduledChange?: ScheduledChange | null;
1970
+ message?: string;
1971
+ }
1972
+ /** Request body for POST /subscriptions/preview-change. */
1973
+ interface PreviewChangeRequest {
1974
+ subscriptionPeriodId: string;
1975
+ }
1976
+ /**
1977
+ * Estimate of a plan change's impact, for the confirmation modal.
1978
+ * kind: "new" (first purchase via Checkout) | "upgrade" | "downgrade".
1979
+ * proratedChargeMicros is an estimate when estimated=true.
1980
+ */
1981
+ interface PreviewChangeResponse {
1982
+ success: boolean;
1983
+ kind: 'new' | 'upgrade' | 'downgrade';
1984
+ proratedChargeMicros: number;
1985
+ creditDeltaMicros: number;
1986
+ newFullPriceMicros: number;
1987
+ effectiveAt?: string;
1988
+ nextRenewalAt?: string;
1989
+ estimated: boolean;
1990
+ error_code?: string;
1912
1991
  message?: string;
1913
1992
  }
1914
1993
  interface CancelSubscriptionResponse {
@@ -1948,6 +2027,13 @@ interface CreditBalance {
1948
2027
  subscriptionCreditMicros: number;
1949
2028
  subscriptionCreditExpiresAt: string | null;
1950
2029
  totalActiveMicros: number;
2030
+ /**
2031
+ * Subscription bucket AFTER expiry is applied (0 once expired). Display
2032
+ * THIS for the "Subscription" credit card so a lapsed/cancelled plan
2033
+ * never shows stale credits. (subscriptionCreditMicros is the raw stored
2034
+ * value, which can be non-zero past expiry until the next write.)
2035
+ */
2036
+ activeSubscriptionMicros: number;
1951
2037
  }
1952
2038
  /** Source of a credit ledger row. Matches the kind enum from migration 0017. */
1953
2039
  type CreditTransactionKind = 'grant_initial' | 'grant_renewal' | 'grant_pack' | 'debit_llm' | 'debit_sandbox' | 'debit_llm_platform' | 'meter_llm_byok' | 'admin_adjust';
@@ -2075,6 +2161,12 @@ declare class SubscriptionsClient {
2075
2161
  listCatalog(): Promise<Subscription[]>;
2076
2162
  getMine(): Promise<OrgSubscription | null>;
2077
2163
  buy(body: BuySubscriptionRequest): Promise<BuySubscriptionResponse>;
2164
+ /**
2165
+ * Preview the cost/credit impact of a plan change (pro-rated charge,
2166
+ * credit delta, effective dates) for the confirmation modal — no change
2167
+ * is made. kind="new" means a first purchase that would go via Checkout.
2168
+ */
2169
+ previewChange(body: PreviewChangeRequest): Promise<PreviewChangeResponse>;
2078
2170
  cancel(): Promise<CancelSubscriptionResponse>;
2079
2171
  listPayments(): Promise<Payment[]>;
2080
2172
  /** Stripe-hosted billing portal URL. */
@@ -2610,4 +2702,4 @@ declare class NotImplementedError extends Error {
2610
2702
  constructor(method: string);
2611
2703
  }
2612
2704
 
2613
- export { type AcceptInviteRequest, AccessType, type AcquireScanLeaseRequest, type AcquireScanLeaseResponse, type ActionCategory, type ActivateRequest, type AddMemberRequest, type AddUserToOrgRequest, type AddUserToOrgResult, type AdjustOrgCreditsRequest, type AdjustOrgCreditsResult, type AnswerChatQuestionRequest, type AnswerChatQuestionResponse, type AppendProgramConfigRequest, type AssociatedOrg, type AuthUser, BaseClient, type BaseClientOptions, type BillingProgramConfig, type BudgetScope, BudgetsClient, type BuyCreditPackRequest, type BuyCreditPackResponse, type BuyCustomCreditRequest, type BuyCustomCreditResponse, type BuySubscriptionRequest, type BuySubscriptionResponse, CAP_AI, CAP_COMPUTE, CAP_GENERAL, CAP_NOTIFY, CAP_STORAGE, CAP_VCS, type CancelChatTurnResponse, type CancelSubscriptionResponse, type ChatAssistantMessagePayload, type ChatBillingRefuseCode, type ChatBillingRefuseError, type ChatBudget, type ChatCheckpointedPayload, type ChatCompactionFiredPayload, type ChatDonePayload, type ChatEvent, type ChatEventType, type ChatFeedback, type ChatFeedbackEnvelope, type ChatMessage, type ChatMessageKind, type ChatMessageRole, type ChatNarrationPayload, type ChatPhase, type ChatPhasePayload, type ChatPlanDraftPayload, type ChatQuestionPayload, type ChatSchedule, type ChatScheduleEnvelope, type ChatScheduleNotifyOn, type ChatScheduleRunStatus, type ChatScope, type ChatSession, type ChatSessionSource, type ChatSessionTitlePayload, type ChatStepEventPayload, type ChatStepProgressPayload, type ChatStreamHandle, type ChatToolCallConfirmationRequiredPayload, type ChatToolCallFinishedPayload, type ChatToolCallStartedPayload, type ChatTurnStatus, type ClarificationOption, CloudAgentClient, type CloudAgentClientOptions, type CloudResource, type CloudResourceContainerRef, type CloudResourceEdge, type CloudScanHistory, type CloudScanLease, type ConfirmChatToolCallRequest, type ConfirmChatToolCallResponse, type CreateAgentTemplateRequest, type CreateChatScheduleRequest, type CreateChatSessionRequest, type CreateChatSessionResponse, type CreateCredentialRequest, type CreateGatewayTokenRequest, type CreateGatewayTokenResponse, type CreateOrganizationRequest, type CreateOrganizationUserRequest, type CreateProjectRequest, type CreateSandboxRequest, type CreateScheduledTaskRequest, type Credential, type CreditBalance, type CreditPack, type CreditTransaction, type CreditTransactionKind, type CreditTransactionType, type CustomCreditPurchaseConfig, type DebugPayload, type DebugReceipt, type EffectiveChatBudget, type ExchangeCodeRequest, type FieldSpec, type FieldType, type FineTuneParams, type GatewayToken, type GeneratePayoutsRequest, type GetChatSessionResponse, type GetUsageSummaryQuery, type GetUsageSummaryResponse, HttpError, type ImpersonationProvider, type InviteOrgRequest, type InviteOrgResult, type ListAgentTemplatesQuery, type ListAgentTemplatesResponse, type ListChatFeedbackResponse, type ListChatScheduleRunsResponse, type ListChatSchedulesResponse, type ListChatSessionsQuery, type ListChatSessionsResponse, type ListCredentialsQuery, type ListCreditsTransactionsQuery, type ListCreditsTransactionsResponse, type ListPaymentsResponse, type ListSandboxesQuery, type ListScanHistoryQuery, type ListScanHistoryResponse, type ListScheduledTasksQuery, type ListScheduledTasksResponse, type LoginRequest, type MFASetupResponse, type MFASimpleResponse, type MFAStatus, MFAType, type MFAVerifyLoginRequest, type MFAVerifyLoginResponse, type MFAVerifySetupRequest, type MagicLinkActivateRequest, type MagicLinkSendResponse, type MintReferralCodeRequest, type ModeType, type MonthlyCreditStats, NotImplementedError, type NotifyChannelOption, type NotifyEventType, type NotifySubscription, type OpenChatStreamOptions, type OrgBudget, type OrgCreditBalance, type OrgNotifySubscriptions, type OrgRef, OrgRoles, type OrgSearchResult, type OrgSubscription, type Organization, type OrganizationUser, PROVIDER_CATALOG, type Payment, type PeekScanLeaseResponse, type PostChatMessageRequest, type PostChatMessageResponse, type Project, type ProjectMember, type ProviderID, type ProviderSpec, ProviderType, type PublicConfig, type Query, type ReconcileScope, type ReconcileTuple, type RedeemReferralCodeRequest, type ReferralAdminOverview, type ReferralAdminStats, type ReferralCode, type ReferralRedemption, type ReferralRedemptionAdmin, type ReferralStats, ReferralsClient, type RefreshRequest, type RegisterRequest, type RequestOptions, ResellerClient, type ResellerCommission, type ResellerPayout, type ResellerPerformance, type ResetPasswordRequest, type ResourceTreeCategory, type ResourceTreeCredential, type ResourceTreeGrouping, type ResourceTreeResource, type ResourceTreeResponse, ResourcesClient, type Sandbox, type SandboxCredential, type ScanInProgressError, type ScheduledTask, type ScopedBudget, type SessionResponse, type SessionTokens, type SetOrgNotifySubscriptionsRequest, type SetResellerRequest, type SimpleAgentResponse, type SimpleKeysResponse, type SimpleOrgResponse, type SimpleResponse$2 as SimpleResponse, type StorageType, type SubgraphDirection, type SubgraphRequest, type SubgraphResponse, type SubmitChatFeedbackRequest, type Subscription, type SubscriptionCapability, type SubscriptionPeriod, type SystemEvent, type SystemEventQuery, type SystemEventQueryResponse, type SystemEventReadResponse, type Template, type TokenProvider, type UnauthorizedHandler, type UpdateChatBudgetRequest, type UpdateChatScheduleRequest, type UpdateCostLimitRequest, type UpdateCredentialRequest, type UpdateMemberRoleRequest, type UpdateOrgBudgetRequest, type UpdateOrgUserRequest, type UpdateOrganizationRequest, type UpdatePayoutRequest, type UpdateProjectRequest, type UpdateSandboxRequest, type UpdateScopedBudgetRequest, type UpdateUserRequest, type UpdateUserResponse, type UsageBucket, type UsageByModelQuery, type UsageByModelResponse, type UsageByModelRow, type UsageCostSplit, type UsageReportQuery, type UsageReportResponse, type UsageSummary, type UsageSummaryQuery, type UsageSummaryResponse, type UsageTotals, type UsageWindow, type UserProfile, type UserSummary, computeDisplayHint, getProvider, getValueAt, isMetadataPath, isSecretPath, listProviders, metadataKey, setValueAt, usdMicros, validate };
2705
+ export { type AcceptInviteRequest, AccessType, type AcquireScanLeaseRequest, type AcquireScanLeaseResponse, type ActionCategory, type ActivateRequest, type AddMemberRequest, type AddUserToOrgRequest, type AddUserToOrgResult, type AdjustOrgCreditsRequest, type AdjustOrgCreditsResult, type AnswerChatQuestionRequest, type AnswerChatQuestionResponse, type AppendProgramConfigRequest, type AssociatedOrg, type AuthUser, BaseClient, type BaseClientOptions, type BillingProgramConfig, type BudgetScope, BudgetsClient, type BuyCreditPackRequest, type BuyCreditPackResponse, type BuyCustomCreditRequest, type BuyCustomCreditResponse, type BuySubscriptionRequest, type BuySubscriptionResponse, CAP_AI, CAP_COMPUTE, CAP_GENERAL, CAP_NOTIFY, CAP_STORAGE, CAP_VCS, type CancelChatTurnResponse, type CancelSubscriptionResponse, type ChatAssistantMessagePayload, type ChatBillingRefuseCode, type ChatBillingRefuseError, type ChatBudget, type ChatCheckpointedPayload, type ChatCompactionFiredPayload, type ChatDonePayload, type ChatEvent, type ChatEventType, type ChatFeedback, type ChatFeedbackEnvelope, type ChatMessage, type ChatMessageKind, type ChatMessageRole, type ChatNarrationPayload, type ChatPhase, type ChatPhasePayload, type ChatPlanDraftPayload, type ChatQuestionPayload, type ChatSchedule, type ChatScheduleEnvelope, type ChatScheduleNotifyOn, type ChatScheduleRunStatus, type ChatScope, type ChatSession, type ChatSessionSource, type ChatSessionTitlePayload, type ChatStepEventPayload, type ChatStepProgressPayload, type ChatStreamHandle, type ChatToolCallConfirmationRequiredPayload, type ChatToolCallFinishedPayload, type ChatToolCallStartedPayload, type ChatTurnStatus, type ClarificationOption, CloudAgentClient, type CloudAgentClientOptions, type CloudResource, type CloudResourceContainerRef, type CloudResourceEdge, type CloudScanHistory, type CloudScanLease, type ConfirmChatToolCallRequest, type ConfirmChatToolCallResponse, type CreateAgentTemplateRequest, type CreateChatScheduleRequest, type CreateChatSessionRequest, type CreateChatSessionResponse, type CreateCredentialRequest, type CreateGatewayTokenRequest, type CreateGatewayTokenResponse, type CreateOrganizationRequest, type CreateOrganizationUserRequest, type CreateProjectRequest, type CreateSandboxRequest, type CreateScheduledTaskRequest, type Credential, type CreditBalance, type CreditPack, type CreditTransaction, type CreditTransactionKind, type CreditTransactionType, type CustomCreditPurchaseConfig, type DebugPayload, type DebugReceipt, type EffectiveChatBudget, type ExchangeCodeRequest, type FieldSpec, type FieldType, type FineTuneParams, type GatewayToken, type GeneratePayoutsRequest, type GetChatSessionResponse, type GetUsageSummaryQuery, type GetUsageSummaryResponse, HttpError, type ImpersonationProvider, type InviteOrgRequest, type InviteOrgResult, type ListAgentTemplatesQuery, type ListAgentTemplatesResponse, type ListChatFeedbackResponse, type ListChatScheduleRunsResponse, type ListChatSchedulesResponse, type ListChatSessionsQuery, type ListChatSessionsResponse, type ListCredentialsQuery, type ListCreditsTransactionsQuery, type ListCreditsTransactionsResponse, type ListPaymentsResponse, type ListSandboxesQuery, type ListScanHistoryQuery, type ListScanHistoryResponse, type ListScheduledTasksQuery, type ListScheduledTasksResponse, type LoginRequest, type MFASetupResponse, type MFASimpleResponse, type MFAStatus, MFAType, type MFAVerifyLoginRequest, type MFAVerifyLoginResponse, type MFAVerifySetupRequest, type MagicLinkActivateRequest, type MagicLinkSendResponse, type MintReferralCodeRequest, type ModeType, type MonthlyCreditStats, NotImplementedError, type NotifyChannelOption, type NotifyEventType, type NotifySubscription, type OpenChatStreamOptions, type OrgBudget, type OrgCreditBalance, type OrgInvite, type OrgNotifySubscriptions, type OrgRef, OrgRoles, type OrgSearchResult, type OrgSubscription, type Organization, type OrganizationUser, PROVIDER_CATALOG, type Payment, type PeekScanLeaseResponse, type PostChatMessageRequest, type PostChatMessageResponse, type PreviewChangeRequest, type PreviewChangeResponse, type Project, type ProjectMember, type ProviderID, type ProviderSpec, ProviderType, type PublicConfig, type Query, type ReconcileScope, type ReconcileTuple, type RedeemReferralCodeRequest, type ReferralAdminOverview, type ReferralAdminStats, type ReferralCode, type ReferralRedemption, type ReferralRedemptionAdmin, type ReferralStats, ReferralsClient, type RefreshRequest, type RegisterRequest, type RequestOptions, ResellerClient, type ResellerCommission, type ResellerPayout, type ResellerPerformance, type ResetPasswordRequest, type ResourceTreeCategory, type ResourceTreeCredential, type ResourceTreeGrouping, type ResourceTreeResource, type ResourceTreeResponse, ResourcesClient, type Sandbox, type SandboxCredential, type ScanInProgressError, type ScheduledChange, type ScheduledTask, type ScopedBudget, type SessionResponse, type SessionTokens, type SetOrgNotifySubscriptionsRequest, type SetResellerRequest, type SimpleAgentResponse, type SimpleKeysResponse, type SimpleOrgResponse, type SimpleResponse$2 as SimpleResponse, type StorageType, type SubgraphDirection, type SubgraphRequest, type SubgraphResponse, type SubmitChatFeedbackRequest, type Subscription, type SubscriptionCapability, type SubscriptionPeriod, type SystemEvent, type SystemEventQuery, type SystemEventQueryResponse, type SystemEventReadResponse, type Template, type TokenProvider, type UnauthorizedHandler, type UpdateChatBudgetRequest, type UpdateChatScheduleRequest, type UpdateCostLimitRequest, type UpdateCredentialRequest, type UpdateMemberRoleRequest, type UpdateOrgBudgetRequest, type UpdateOrgUserRequest, type UpdateOrganizationRequest, type UpdatePayoutRequest, type UpdateProjectRequest, type UpdateSandboxRequest, type UpdateScopedBudgetRequest, type UpdateUserRequest, type UpdateUserResponse, type UsageBucket, type UsageByModelQuery, type UsageByModelResponse, type UsageByModelRow, type UsageCostSplit, type UsageReportQuery, type UsageReportResponse, type UsageSummary, type UsageSummaryQuery, type UsageSummaryResponse, type UsageTotals, type UsageWindow, type UserProfile, type UserSummary, computeDisplayHint, getProvider, getValueAt, isMetadataPath, isSecretPath, listProviders, metadataKey, setValueAt, usdMicros, validate };
package/dist/index.d.ts CHANGED
@@ -426,6 +426,30 @@ interface InviteOrgResult {
426
426
  organization: Organization;
427
427
  owner: OrganizationUser;
428
428
  }
429
+ /**
430
+ * One outstanding org or member invite, as surfaced by the platform-admin
431
+ * invite-management list (GET /admin/org-invites). Reconstructed server-side
432
+ * from the latest ORG_INVITE token joined to the invited user + org — there is
433
+ * no dedicated invite table. `status` is derived: a validated user has
434
+ * `redeemed`; otherwise `pending` until `expiresAt`, then `expired`.
435
+ */
436
+ interface OrgInvite {
437
+ userId: string;
438
+ email: string;
439
+ name: string;
440
+ lastName?: string;
441
+ orgId: string;
442
+ orgName: string;
443
+ /** Org role integer of the invitee (255 = Owner for founding-owner invites). */
444
+ orgRole?: number | null;
445
+ status: 'pending' | 'redeemed' | 'expired';
446
+ /** Token mint time, ISO-8601. Treated as "invited at". */
447
+ invitedAt: string;
448
+ /** Invite link expiry, ISO-8601. */
449
+ expiresAt: string;
450
+ /** When the invite was consumed, ISO-8601, or null while unredeemed. */
451
+ redeemedAt?: string | null;
452
+ }
429
453
  interface SimpleOrgResponse {
430
454
  success: boolean;
431
455
  message?: string;
@@ -533,6 +557,26 @@ declare class OrganizationClient {
533
557
  * ADMIN_ORGANIZATION; 409 when the owner email already exists.
534
558
  */
535
559
  inviteOrg(body: InviteOrgRequest): Promise<InviteOrgResult>;
560
+ /**
561
+ * Platform-admin only: list every outstanding org + member invite (founding-
562
+ * owner invites from `inviteOrg` and members added via `addUserToOrg`) with
563
+ * derived status, newest first. Cancelled invites (soft-deleted) and live
564
+ * non-invited orgs are excluded. Returns 403 unless platform admin.
565
+ */
566
+ listOrgInvites(): Promise<OrgInvite[]>;
567
+ /**
568
+ * Platform-admin only: re-send an invite — mints a fresh 7-day token and
569
+ * re-emails the link. Returns 403 unless platform admin; 404 when no pending
570
+ * invite exists; 409 once the invite has been redeemed.
571
+ */
572
+ resendOrgInvite(userId: string): Promise<SimpleOrgResponse>;
573
+ /**
574
+ * Platform-admin only: cancel a pending invite. Soft-deletes the invited user
575
+ * (and the shell org, for a never-redeemed founding-owner invite with no other
576
+ * members) and revokes the token, freeing the email for re-invite. Returns 403
577
+ * unless platform admin; 404 when absent; 409 once the invite has been redeemed.
578
+ */
579
+ cancelOrgInvite(userId: string): Promise<SimpleOrgResponse>;
536
580
  /**
537
581
  * Platform-admin only: enable or disable the debug surface for an org.
538
582
  * Returns the updated org entry with the new allowDebug value.
@@ -1883,6 +1927,15 @@ interface Subscription {
1883
1927
  capabilities: SubscriptionCapability[];
1884
1928
  }
1885
1929
  /** The org's currently active subscription (GET /subscriptions/my). */
1930
+ /**
1931
+ * A pending plan change deferred to the period boundary (a downgrade).
1932
+ * effectiveAt is when the lower plan takes over (= current period end).
1933
+ */
1934
+ interface ScheduledChange {
1935
+ toSubscriptionId: string;
1936
+ toSubscriptionName: string;
1937
+ effectiveAt: string;
1938
+ }
1886
1939
  interface OrgSubscription {
1887
1940
  id: string;
1888
1941
  name: string;
@@ -1894,7 +1947,10 @@ interface OrgSubscription {
1894
1947
  dateFrom: string;
1895
1948
  dateTo: string | null;
1896
1949
  status: string;
1950
+ /** false once a cancel-at-period-end is pending (active until dateTo). */
1897
1951
  autoRenew: boolean;
1952
+ /** Set when a downgrade is scheduled for the period boundary. */
1953
+ scheduledChange?: ScheduledChange | null;
1898
1954
  }
1899
1955
  interface BuySubscriptionRequest {
1900
1956
  subscriptionPeriodId: string;
@@ -1909,6 +1965,29 @@ interface BuySubscriptionResponse {
1909
1965
  name: string;
1910
1966
  } | null;
1911
1967
  isFreeSubscription?: boolean;
1968
+ /** Set when the change was a deferred downgrade (no charge now). */
1969
+ scheduledChange?: ScheduledChange | null;
1970
+ message?: string;
1971
+ }
1972
+ /** Request body for POST /subscriptions/preview-change. */
1973
+ interface PreviewChangeRequest {
1974
+ subscriptionPeriodId: string;
1975
+ }
1976
+ /**
1977
+ * Estimate of a plan change's impact, for the confirmation modal.
1978
+ * kind: "new" (first purchase via Checkout) | "upgrade" | "downgrade".
1979
+ * proratedChargeMicros is an estimate when estimated=true.
1980
+ */
1981
+ interface PreviewChangeResponse {
1982
+ success: boolean;
1983
+ kind: 'new' | 'upgrade' | 'downgrade';
1984
+ proratedChargeMicros: number;
1985
+ creditDeltaMicros: number;
1986
+ newFullPriceMicros: number;
1987
+ effectiveAt?: string;
1988
+ nextRenewalAt?: string;
1989
+ estimated: boolean;
1990
+ error_code?: string;
1912
1991
  message?: string;
1913
1992
  }
1914
1993
  interface CancelSubscriptionResponse {
@@ -1948,6 +2027,13 @@ interface CreditBalance {
1948
2027
  subscriptionCreditMicros: number;
1949
2028
  subscriptionCreditExpiresAt: string | null;
1950
2029
  totalActiveMicros: number;
2030
+ /**
2031
+ * Subscription bucket AFTER expiry is applied (0 once expired). Display
2032
+ * THIS for the "Subscription" credit card so a lapsed/cancelled plan
2033
+ * never shows stale credits. (subscriptionCreditMicros is the raw stored
2034
+ * value, which can be non-zero past expiry until the next write.)
2035
+ */
2036
+ activeSubscriptionMicros: number;
1951
2037
  }
1952
2038
  /** Source of a credit ledger row. Matches the kind enum from migration 0017. */
1953
2039
  type CreditTransactionKind = 'grant_initial' | 'grant_renewal' | 'grant_pack' | 'debit_llm' | 'debit_sandbox' | 'debit_llm_platform' | 'meter_llm_byok' | 'admin_adjust';
@@ -2075,6 +2161,12 @@ declare class SubscriptionsClient {
2075
2161
  listCatalog(): Promise<Subscription[]>;
2076
2162
  getMine(): Promise<OrgSubscription | null>;
2077
2163
  buy(body: BuySubscriptionRequest): Promise<BuySubscriptionResponse>;
2164
+ /**
2165
+ * Preview the cost/credit impact of a plan change (pro-rated charge,
2166
+ * credit delta, effective dates) for the confirmation modal — no change
2167
+ * is made. kind="new" means a first purchase that would go via Checkout.
2168
+ */
2169
+ previewChange(body: PreviewChangeRequest): Promise<PreviewChangeResponse>;
2078
2170
  cancel(): Promise<CancelSubscriptionResponse>;
2079
2171
  listPayments(): Promise<Payment[]>;
2080
2172
  /** Stripe-hosted billing portal URL. */
@@ -2610,4 +2702,4 @@ declare class NotImplementedError extends Error {
2610
2702
  constructor(method: string);
2611
2703
  }
2612
2704
 
2613
- export { type AcceptInviteRequest, AccessType, type AcquireScanLeaseRequest, type AcquireScanLeaseResponse, type ActionCategory, type ActivateRequest, type AddMemberRequest, type AddUserToOrgRequest, type AddUserToOrgResult, type AdjustOrgCreditsRequest, type AdjustOrgCreditsResult, type AnswerChatQuestionRequest, type AnswerChatQuestionResponse, type AppendProgramConfigRequest, type AssociatedOrg, type AuthUser, BaseClient, type BaseClientOptions, type BillingProgramConfig, type BudgetScope, BudgetsClient, type BuyCreditPackRequest, type BuyCreditPackResponse, type BuyCustomCreditRequest, type BuyCustomCreditResponse, type BuySubscriptionRequest, type BuySubscriptionResponse, CAP_AI, CAP_COMPUTE, CAP_GENERAL, CAP_NOTIFY, CAP_STORAGE, CAP_VCS, type CancelChatTurnResponse, type CancelSubscriptionResponse, type ChatAssistantMessagePayload, type ChatBillingRefuseCode, type ChatBillingRefuseError, type ChatBudget, type ChatCheckpointedPayload, type ChatCompactionFiredPayload, type ChatDonePayload, type ChatEvent, type ChatEventType, type ChatFeedback, type ChatFeedbackEnvelope, type ChatMessage, type ChatMessageKind, type ChatMessageRole, type ChatNarrationPayload, type ChatPhase, type ChatPhasePayload, type ChatPlanDraftPayload, type ChatQuestionPayload, type ChatSchedule, type ChatScheduleEnvelope, type ChatScheduleNotifyOn, type ChatScheduleRunStatus, type ChatScope, type ChatSession, type ChatSessionSource, type ChatSessionTitlePayload, type ChatStepEventPayload, type ChatStepProgressPayload, type ChatStreamHandle, type ChatToolCallConfirmationRequiredPayload, type ChatToolCallFinishedPayload, type ChatToolCallStartedPayload, type ChatTurnStatus, type ClarificationOption, CloudAgentClient, type CloudAgentClientOptions, type CloudResource, type CloudResourceContainerRef, type CloudResourceEdge, type CloudScanHistory, type CloudScanLease, type ConfirmChatToolCallRequest, type ConfirmChatToolCallResponse, type CreateAgentTemplateRequest, type CreateChatScheduleRequest, type CreateChatSessionRequest, type CreateChatSessionResponse, type CreateCredentialRequest, type CreateGatewayTokenRequest, type CreateGatewayTokenResponse, type CreateOrganizationRequest, type CreateOrganizationUserRequest, type CreateProjectRequest, type CreateSandboxRequest, type CreateScheduledTaskRequest, type Credential, type CreditBalance, type CreditPack, type CreditTransaction, type CreditTransactionKind, type CreditTransactionType, type CustomCreditPurchaseConfig, type DebugPayload, type DebugReceipt, type EffectiveChatBudget, type ExchangeCodeRequest, type FieldSpec, type FieldType, type FineTuneParams, type GatewayToken, type GeneratePayoutsRequest, type GetChatSessionResponse, type GetUsageSummaryQuery, type GetUsageSummaryResponse, HttpError, type ImpersonationProvider, type InviteOrgRequest, type InviteOrgResult, type ListAgentTemplatesQuery, type ListAgentTemplatesResponse, type ListChatFeedbackResponse, type ListChatScheduleRunsResponse, type ListChatSchedulesResponse, type ListChatSessionsQuery, type ListChatSessionsResponse, type ListCredentialsQuery, type ListCreditsTransactionsQuery, type ListCreditsTransactionsResponse, type ListPaymentsResponse, type ListSandboxesQuery, type ListScanHistoryQuery, type ListScanHistoryResponse, type ListScheduledTasksQuery, type ListScheduledTasksResponse, type LoginRequest, type MFASetupResponse, type MFASimpleResponse, type MFAStatus, MFAType, type MFAVerifyLoginRequest, type MFAVerifyLoginResponse, type MFAVerifySetupRequest, type MagicLinkActivateRequest, type MagicLinkSendResponse, type MintReferralCodeRequest, type ModeType, type MonthlyCreditStats, NotImplementedError, type NotifyChannelOption, type NotifyEventType, type NotifySubscription, type OpenChatStreamOptions, type OrgBudget, type OrgCreditBalance, type OrgNotifySubscriptions, type OrgRef, OrgRoles, type OrgSearchResult, type OrgSubscription, type Organization, type OrganizationUser, PROVIDER_CATALOG, type Payment, type PeekScanLeaseResponse, type PostChatMessageRequest, type PostChatMessageResponse, type Project, type ProjectMember, type ProviderID, type ProviderSpec, ProviderType, type PublicConfig, type Query, type ReconcileScope, type ReconcileTuple, type RedeemReferralCodeRequest, type ReferralAdminOverview, type ReferralAdminStats, type ReferralCode, type ReferralRedemption, type ReferralRedemptionAdmin, type ReferralStats, ReferralsClient, type RefreshRequest, type RegisterRequest, type RequestOptions, ResellerClient, type ResellerCommission, type ResellerPayout, type ResellerPerformance, type ResetPasswordRequest, type ResourceTreeCategory, type ResourceTreeCredential, type ResourceTreeGrouping, type ResourceTreeResource, type ResourceTreeResponse, ResourcesClient, type Sandbox, type SandboxCredential, type ScanInProgressError, type ScheduledTask, type ScopedBudget, type SessionResponse, type SessionTokens, type SetOrgNotifySubscriptionsRequest, type SetResellerRequest, type SimpleAgentResponse, type SimpleKeysResponse, type SimpleOrgResponse, type SimpleResponse$2 as SimpleResponse, type StorageType, type SubgraphDirection, type SubgraphRequest, type SubgraphResponse, type SubmitChatFeedbackRequest, type Subscription, type SubscriptionCapability, type SubscriptionPeriod, type SystemEvent, type SystemEventQuery, type SystemEventQueryResponse, type SystemEventReadResponse, type Template, type TokenProvider, type UnauthorizedHandler, type UpdateChatBudgetRequest, type UpdateChatScheduleRequest, type UpdateCostLimitRequest, type UpdateCredentialRequest, type UpdateMemberRoleRequest, type UpdateOrgBudgetRequest, type UpdateOrgUserRequest, type UpdateOrganizationRequest, type UpdatePayoutRequest, type UpdateProjectRequest, type UpdateSandboxRequest, type UpdateScopedBudgetRequest, type UpdateUserRequest, type UpdateUserResponse, type UsageBucket, type UsageByModelQuery, type UsageByModelResponse, type UsageByModelRow, type UsageCostSplit, type UsageReportQuery, type UsageReportResponse, type UsageSummary, type UsageSummaryQuery, type UsageSummaryResponse, type UsageTotals, type UsageWindow, type UserProfile, type UserSummary, computeDisplayHint, getProvider, getValueAt, isMetadataPath, isSecretPath, listProviders, metadataKey, setValueAt, usdMicros, validate };
2705
+ export { type AcceptInviteRequest, AccessType, type AcquireScanLeaseRequest, type AcquireScanLeaseResponse, type ActionCategory, type ActivateRequest, type AddMemberRequest, type AddUserToOrgRequest, type AddUserToOrgResult, type AdjustOrgCreditsRequest, type AdjustOrgCreditsResult, type AnswerChatQuestionRequest, type AnswerChatQuestionResponse, type AppendProgramConfigRequest, type AssociatedOrg, type AuthUser, BaseClient, type BaseClientOptions, type BillingProgramConfig, type BudgetScope, BudgetsClient, type BuyCreditPackRequest, type BuyCreditPackResponse, type BuyCustomCreditRequest, type BuyCustomCreditResponse, type BuySubscriptionRequest, type BuySubscriptionResponse, CAP_AI, CAP_COMPUTE, CAP_GENERAL, CAP_NOTIFY, CAP_STORAGE, CAP_VCS, type CancelChatTurnResponse, type CancelSubscriptionResponse, type ChatAssistantMessagePayload, type ChatBillingRefuseCode, type ChatBillingRefuseError, type ChatBudget, type ChatCheckpointedPayload, type ChatCompactionFiredPayload, type ChatDonePayload, type ChatEvent, type ChatEventType, type ChatFeedback, type ChatFeedbackEnvelope, type ChatMessage, type ChatMessageKind, type ChatMessageRole, type ChatNarrationPayload, type ChatPhase, type ChatPhasePayload, type ChatPlanDraftPayload, type ChatQuestionPayload, type ChatSchedule, type ChatScheduleEnvelope, type ChatScheduleNotifyOn, type ChatScheduleRunStatus, type ChatScope, type ChatSession, type ChatSessionSource, type ChatSessionTitlePayload, type ChatStepEventPayload, type ChatStepProgressPayload, type ChatStreamHandle, type ChatToolCallConfirmationRequiredPayload, type ChatToolCallFinishedPayload, type ChatToolCallStartedPayload, type ChatTurnStatus, type ClarificationOption, CloudAgentClient, type CloudAgentClientOptions, type CloudResource, type CloudResourceContainerRef, type CloudResourceEdge, type CloudScanHistory, type CloudScanLease, type ConfirmChatToolCallRequest, type ConfirmChatToolCallResponse, type CreateAgentTemplateRequest, type CreateChatScheduleRequest, type CreateChatSessionRequest, type CreateChatSessionResponse, type CreateCredentialRequest, type CreateGatewayTokenRequest, type CreateGatewayTokenResponse, type CreateOrganizationRequest, type CreateOrganizationUserRequest, type CreateProjectRequest, type CreateSandboxRequest, type CreateScheduledTaskRequest, type Credential, type CreditBalance, type CreditPack, type CreditTransaction, type CreditTransactionKind, type CreditTransactionType, type CustomCreditPurchaseConfig, type DebugPayload, type DebugReceipt, type EffectiveChatBudget, type ExchangeCodeRequest, type FieldSpec, type FieldType, type FineTuneParams, type GatewayToken, type GeneratePayoutsRequest, type GetChatSessionResponse, type GetUsageSummaryQuery, type GetUsageSummaryResponse, HttpError, type ImpersonationProvider, type InviteOrgRequest, type InviteOrgResult, type ListAgentTemplatesQuery, type ListAgentTemplatesResponse, type ListChatFeedbackResponse, type ListChatScheduleRunsResponse, type ListChatSchedulesResponse, type ListChatSessionsQuery, type ListChatSessionsResponse, type ListCredentialsQuery, type ListCreditsTransactionsQuery, type ListCreditsTransactionsResponse, type ListPaymentsResponse, type ListSandboxesQuery, type ListScanHistoryQuery, type ListScanHistoryResponse, type ListScheduledTasksQuery, type ListScheduledTasksResponse, type LoginRequest, type MFASetupResponse, type MFASimpleResponse, type MFAStatus, MFAType, type MFAVerifyLoginRequest, type MFAVerifyLoginResponse, type MFAVerifySetupRequest, type MagicLinkActivateRequest, type MagicLinkSendResponse, type MintReferralCodeRequest, type ModeType, type MonthlyCreditStats, NotImplementedError, type NotifyChannelOption, type NotifyEventType, type NotifySubscription, type OpenChatStreamOptions, type OrgBudget, type OrgCreditBalance, type OrgInvite, type OrgNotifySubscriptions, type OrgRef, OrgRoles, type OrgSearchResult, type OrgSubscription, type Organization, type OrganizationUser, PROVIDER_CATALOG, type Payment, type PeekScanLeaseResponse, type PostChatMessageRequest, type PostChatMessageResponse, type PreviewChangeRequest, type PreviewChangeResponse, type Project, type ProjectMember, type ProviderID, type ProviderSpec, ProviderType, type PublicConfig, type Query, type ReconcileScope, type ReconcileTuple, type RedeemReferralCodeRequest, type ReferralAdminOverview, type ReferralAdminStats, type ReferralCode, type ReferralRedemption, type ReferralRedemptionAdmin, type ReferralStats, ReferralsClient, type RefreshRequest, type RegisterRequest, type RequestOptions, ResellerClient, type ResellerCommission, type ResellerPayout, type ResellerPerformance, type ResetPasswordRequest, type ResourceTreeCategory, type ResourceTreeCredential, type ResourceTreeGrouping, type ResourceTreeResource, type ResourceTreeResponse, ResourcesClient, type Sandbox, type SandboxCredential, type ScanInProgressError, type ScheduledChange, type ScheduledTask, type ScopedBudget, type SessionResponse, type SessionTokens, type SetOrgNotifySubscriptionsRequest, type SetResellerRequest, type SimpleAgentResponse, type SimpleKeysResponse, type SimpleOrgResponse, type SimpleResponse$2 as SimpleResponse, type StorageType, type SubgraphDirection, type SubgraphRequest, type SubgraphResponse, type SubmitChatFeedbackRequest, type Subscription, type SubscriptionCapability, type SubscriptionPeriod, type SystemEvent, type SystemEventQuery, type SystemEventQueryResponse, type SystemEventReadResponse, type Template, type TokenProvider, type UnauthorizedHandler, type UpdateChatBudgetRequest, type UpdateChatScheduleRequest, type UpdateCostLimitRequest, type UpdateCredentialRequest, type UpdateMemberRoleRequest, type UpdateOrgBudgetRequest, type UpdateOrgUserRequest, type UpdateOrganizationRequest, type UpdatePayoutRequest, type UpdateProjectRequest, type UpdateSandboxRequest, type UpdateScopedBudgetRequest, type UpdateUserRequest, type UpdateUserResponse, type UsageBucket, type UsageByModelQuery, type UsageByModelResponse, type UsageByModelRow, type UsageCostSplit, type UsageReportQuery, type UsageReportResponse, type UsageSummary, type UsageSummaryQuery, type UsageSummaryResponse, type UsageTotals, type UsageWindow, type UserProfile, type UserSummary, computeDisplayHint, getProvider, getValueAt, isMetadataPath, isSecretPath, listProviders, metadataKey, setValueAt, usdMicros, validate };
package/dist/index.js CHANGED
@@ -333,6 +333,33 @@ var OrganizationClient = class {
333
333
  );
334
334
  return unwrapData(res);
335
335
  }
336
+ /**
337
+ * Platform-admin only: list every outstanding org + member invite (founding-
338
+ * owner invites from `inviteOrg` and members added via `addUserToOrg`) with
339
+ * derived status, newest first. Cancelled invites (soft-deleted) and live
340
+ * non-invited orgs are excluded. Returns 403 unless platform admin.
341
+ */
342
+ async listOrgInvites() {
343
+ const res = await this.http.get("/admin/org-invites");
344
+ return res.data ?? [];
345
+ }
346
+ /**
347
+ * Platform-admin only: re-send an invite — mints a fresh 7-day token and
348
+ * re-emails the link. Returns 403 unless platform admin; 404 when no pending
349
+ * invite exists; 409 once the invite has been redeemed.
350
+ */
351
+ resendOrgInvite(userId) {
352
+ return this.http.post(`/admin/org-invites/${userId}/resend`, {});
353
+ }
354
+ /**
355
+ * Platform-admin only: cancel a pending invite. Soft-deletes the invited user
356
+ * (and the shell org, for a never-redeemed founding-owner invite with no other
357
+ * members) and revokes the token, freeing the email for re-invite. Returns 403
358
+ * unless platform admin; 404 when absent; 409 once the invite has been redeemed.
359
+ */
360
+ cancelOrgInvite(userId) {
361
+ return this.http.post(`/admin/org-invites/${userId}/cancel`, {});
362
+ }
336
363
  /**
337
364
  * Platform-admin only: enable or disable the debug surface for an org.
338
365
  * Returns the updated org entry with the new allowDebug value.
@@ -1091,6 +1118,14 @@ var SubscriptionsClient = class {
1091
1118
  buy(body) {
1092
1119
  return this.http.post("/subscriptions/buy", { body });
1093
1120
  }
1121
+ /**
1122
+ * Preview the cost/credit impact of a plan change (pro-rated charge,
1123
+ * credit delta, effective dates) for the confirmation modal — no change
1124
+ * is made. kind="new" means a first purchase that would go via Checkout.
1125
+ */
1126
+ previewChange(body) {
1127
+ return this.http.post("/subscriptions/preview-change", { body });
1128
+ }
1094
1129
  cancel() {
1095
1130
  return this.http.post("/subscriptions/cancel", {});
1096
1131
  }