@dvina/sdk 4.1.111 → 4.1.173
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/README.md +37 -134
- package/dist/_generated_documents-6WGCKLGZ.js +1 -0
- package/dist/_generated_sdk-7_X86mtI.d.ts +17341 -0
- package/dist/adapters/react/index.d.ts +36 -24
- package/dist/adapters/react/index.js +1 -1
- package/dist/ai/index.d.ts +570 -0
- package/dist/ai/index.js +3 -0
- package/dist/billing/index.d.ts +43 -15
- package/dist/billing/index.js +1 -1
- package/dist/chunk-32KGDH2Q.js +1 -0
- package/dist/chunk-37LLNIGO.js +1 -0
- package/dist/chunk-OCM5W3JH.js +1 -0
- package/dist/chunk-W764PDVJ.js +31 -0
- package/dist/chunk-Z2ADTQ64.js +1 -0
- package/dist/{sync-engine-DYHreGOv.d.ts → connection-ClMdDUce.d.ts} +223 -11
- package/dist/{error-CsVoUTY8.d.ts → error-Bk0Jmuzd.d.ts} +11 -3
- package/dist/index.d.ts +24 -3523
- package/dist/index.js +4 -1
- package/dist/package.json +8 -13
- package/dist/pagination/index.d.ts +18 -4
- package/dist/pagination/index.js +1 -1
- package/dist/{types-Chg8ASmf.d.ts → types-BfiQdtra.d.ts} +1 -9
- package/package.json +26 -21
- package/dist/_generated_documents-HFKWCKIO.js +0 -1
- package/dist/adapters/angular/index.d.ts +0 -254
- package/dist/adapters/angular/index.js +0 -1
- package/dist/chunk-2EXM4BMP.js +0 -1
- package/dist/chunk-5E7LX4YQ.js +0 -1
- package/dist/chunk-G34ETQUN.js +0 -1
- package/dist/chunk-H3TI6B7T.js +0 -1
- package/dist/chunk-IIQ3WGOJ.js +0 -1
- package/dist/chunk-V5FAQENQ.js +0 -5
- package/dist/chunk-YUQTEBYO.js +0 -31
- package/dist/client-Bb2gD6Iz.d.ts +0 -488
- package/dist/client-OupfxAUq.d.ts +0 -7949
- package/dist/index-DoGg4ya_.d.ts +0 -79
- package/dist/inference/index.d.ts +0 -80
- package/dist/inference/index.js +0 -1
package/dist/ai/index.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import {a}from'../chunk-32KGDH2Q.js';import {b,c as c$1}from'../chunk-37LLNIGO.js';import'../chunk-EK7ODJWE.js';import {DefaultChatTransport}from'ai';var w="replay";function S(e,{keepsReply:t}={}){let a=`${e.apiUrl.replace(/\/+$/,"")}/api/chat`,n=g(l(e)),r=async(s,o)=>{let i=await n(s,o);return !((o?.method??"GET")==="GET"&&String(s).endsWith("/stream"))||!i.ok||!i.body||!t?.()?i:new Response(i.body.pipeThrough(k()),i)};return new DefaultChatTransport({api:a,fetch:r,prepareSendMessagesRequest:({id:s,messages:o,trigger:i,messageId:u,body:b})=>({api:`${a}/${encodeURIComponent(s)}`,body:{...b,trigger:i,messageId:u,message:o[o.length-1]}}),prepareReconnectToStreamRequest:({id:s})=>({api:`${a}/${encodeURIComponent(s)}/stream`})})}function x(e){return new DefaultChatTransport({api:`${e.apiUrl.replace(/\/+$/,"")}/api/temporary-chat`,fetch:g(l(e))})}var _=[1e3,2e3,4e3,8e3,15e3,3e4],E=429,P=6e4;function g(e,t=_,a=[503]){return async(n,r)=>{for(let s of t){let o=await e(n,r).catch(u=>{if(r?.signal?.aborted||!(u instanceof TypeError))throw u;return null}),i=o?.status===E;if(o&&!i&&!a.includes(o.status))return o;await o?.body?.cancel().catch(()=>{}),await O(i?R(o,s):s,r?.signal??void 0);}return e(n,r)}}function R(e,t){let a=Number.NaN;return e.headers.forEach((n,r)=>{Number.isNaN(a)&&r.toLowerCase().startsWith("retry-after")&&(a=Number(n));}),Number.isFinite(a)&&a>0?Math.min(Math.max(a*1e3,t),P):t}function O(e,t){return new Promise((a,n)=>{if(t?.aborted)return n(t.reason);let r=setTimeout(()=>{t?.removeEventListener("abort",s),a();},e),s=()=>{clearTimeout(r),n(t?.reason);};t?.addEventListener("abort",s,{once:true});})}var U=a();function l(e){let t=e.fetch??globalThis.fetch.bind(globalThis),a=async(n,r,s)=>{let o=new Headers(r?.headers);o.set("Authorization",`Bearer ${await e.getToken({forceRefresh:s})}`);let i=U();i&&!o.has("x-user-timezone")&&o.set("x-user-timezone",i);let u=e.getLanguage?.();return u&&!o.has("x-preferred-language")&&o.set("x-preferred-language",u),t(n,{...r,headers:o})};return async(n,r)=>{let s=await a(n,r,false);return s.status===401?a(n,r,true):s}}function k(){let e=new TextDecoder,t=new TextEncoder,a="",n=r=>!r.split(/\r?\n/).some(s=>s===`event: ${w}`);return new TransformStream({transform(r,s){a+=e.decode(r,{stream:true});let o=a.split(/\r?\n\r?\n/);a=o.pop()??"";let i=o.filter(n).map(u=>`${u}
|
|
2
|
+
|
|
3
|
+
`).join("");i&&s.enqueue(t.encode(i));},flush(r){a+=e.decode(),a&&n(a)&&r.enqueue(t.encode(a));}})}async function I(e,t,a,n){await p(()=>e.sendChatMessageWhileRunning({chatId:t,message:a}),{statuses:F,signal:n});}async function N(e,t){let a=await p(()=>e.chatNextPrompt({chatId:t}),{delaysMs:[1e3,3e3]});return typeof a=="string"&&a.trim()?a:null}async function L(e,t){await p(()=>e.stopChat({chatId:t}),{statuses:c});}async function z(e,t,a){await p(()=>e.grantChatApproval({chatId:t,toolName:a}),{statuses:c,signal:AbortSignal.timeout(C)});}function G(e,t,a,n){return A(()=>e.respondChatApproval({chatId:t,toolCallId:a,approved:n.approved,always:n.always}))}function j(e,t,a,n){return A(()=>e.answerChatQuestion({chatId:t,toolCallId:a,answers:n}))}async function W(e){await e.returnToMainChat();}async function $(e){return {started:await e.startChatDay()}}async function A(e){try{return await p(e,{statuses:c,signal:AbortSignal.timeout(C)}),"sent"}catch(t){if(Y(t))return "answered-elsewhere";throw t}}function Y(e){return e instanceof b&&e.errors.some(t=>t.message===D||t.extensions?.code===D)}var D="NOT_WAITING",Q=[1e3,2e3,4e3,8e3,15e3,3e4],q=[503],F=[500,502,503,504],c=[502,503,504],C=9e4,y=0;async function p(e,{delaysMs:t=Q,statuses:a=q,signal:n}={}){let r=s=>s instanceof c$1&&(s.status===y||a.includes(s.status??y));for(let s of t){try{return await T(e(),n)}catch(o){if(n?.aborted||!r(o))throw o}await X(s,n);}return T(e(),n)}function T(e,t){return t?t.aborted?Promise.reject(t.reason):new Promise((a,n)=>{let r=()=>n(t.reason);t.addEventListener("abort",r,{once:true}),e.then(a,n).finally(()=>t.removeEventListener("abort",r));}):e}function X(e,t){return new Promise((a,n)=>{if(t?.aborted)return n(t.reason);let r=setTimeout(()=>{t?.removeEventListener("abort",s),a();},e),s=()=>{clearTimeout(r),n(t?.reason);};t?.addEventListener("abort",s,{once:true});})}function d(e){return {id:e.id,role:e.role,parts:e.parts??[],...e.metadata?{metadata:e.metadata}:{}}}function B(e){let{pageInfo:t}=e;return {messages:e.nodes.map(d),hasOlder:t.hasPreviousPage,hasNewer:t.hasNextPage,...t.startCursor?{startCursor:t.startCursor}:{},...t.endCursor?{endCursor:t.endCursor}:{}}}var M=200;async function H(e,t,{pageSize:a=M}={}){let n=[],r;for(;;){let s=await e.chatMessages({...t,first:a,after:r}).fetch();n.push(...s.nodes.map(d));let o=s.pageInfo.endCursor??void 0;if(!s.pageInfo.hasNextPage||!o||o===r)return n;r=o;}}function V(e){if(!e||typeof e!="object"||!("dvinaLazyOutput"in e))return null;let t=e.dvinaLazyOutput;if(!t||typeof t!="object")return null;let{bytes:a,preview:n,urls:r}=t;return {bytes:typeof a=="number"?a:0,preview:typeof n=="string"?n:"",urls:Array.isArray(r)?r.filter(s=>typeof s=="string"):[]}}export{M as MAX_MESSAGE_PAGE,j as answerDvinaQuestion,S as createDvinaChatTransport,x as createDvinaTemporaryChatTransport,B as dvinaMessagePageOf,d as dvinaUIMessageOf,H as fetchAllDvinaChatMessages,N as fetchDvinaNextPrompt,z as grantDvinaTaskApproval,V as lazyToolOutputOf,I as postDvinaChatMessage,G as respondDvinaApproval,W as returnToDvinaMainChat,$ as startDvinaDay,L as stopDvinaChat};
|
package/dist/billing/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as DvinaError } from '../error-Bk0Jmuzd.js';
|
|
2
2
|
|
|
3
3
|
type Maybe<T> = T | null;
|
|
4
|
+
type InputMaybe<T> = Maybe<T>;
|
|
4
5
|
type Exact<T extends {
|
|
5
6
|
[key: string]: unknown;
|
|
6
7
|
}> = {
|
|
@@ -18,13 +19,24 @@ type Scalars = {
|
|
|
18
19
|
/** The `JSONObject` scalar type represents JSON objects as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf). */
|
|
19
20
|
JSONObject: any;
|
|
20
21
|
};
|
|
22
|
+
declare enum CancelReason {
|
|
23
|
+
HitLimits = "HIT_LIMITS",
|
|
24
|
+
MissingFeature = "MISSING_FEATURE",
|
|
25
|
+
NotUsing = "NOT_USING",
|
|
26
|
+
Other = "OTHER",
|
|
27
|
+
Quality = "QUALITY",
|
|
28
|
+
Switching = "SWITCHING",
|
|
29
|
+
TooExpensive = "TOO_EXPENSIVE"
|
|
30
|
+
}
|
|
31
|
+
type CheckoutTrial = {
|
|
32
|
+
days: Scalars['Int'];
|
|
33
|
+
tier: EntitlementTier;
|
|
34
|
+
};
|
|
21
35
|
type EntitlementDetail = {
|
|
22
36
|
canAddReport: Scalars['Boolean'];
|
|
23
37
|
canAddUser: Scalars['Boolean'];
|
|
24
38
|
canUseApi: Scalars['Boolean'];
|
|
25
39
|
capacity?: Maybe<Scalars['Int']>;
|
|
26
|
-
deepAnalysisCharacterLimit?: Maybe<Scalars['Float']>;
|
|
27
|
-
deepAnalysisTokenLimit?: Maybe<Scalars['Float']>;
|
|
28
40
|
hardTokenUsageLimit?: Maybe<Scalars['Float']>;
|
|
29
41
|
maxStructuredSize?: Maybe<Scalars['Int']>;
|
|
30
42
|
maxUnstructuredSize?: Maybe<Scalars['Int']>;
|
|
@@ -62,6 +74,12 @@ type PriceCampaign = {
|
|
|
62
74
|
originalAmount: Scalars['Float'];
|
|
63
75
|
percentOff?: Maybe<Scalars['Float']>;
|
|
64
76
|
};
|
|
77
|
+
type RetentionOffers = {
|
|
78
|
+
discountMonths?: Maybe<Scalars['Int']>;
|
|
79
|
+
discountPercent?: Maybe<Scalars['Int']>;
|
|
80
|
+
/** Days of a pause, if one can be offered. */
|
|
81
|
+
pauseDays?: Maybe<Scalars['Int']>;
|
|
82
|
+
};
|
|
65
83
|
type ScheduledChange = {
|
|
66
84
|
effectiveDate?: Maybe<Scalars['DateTime']>;
|
|
67
85
|
newCycle?: Maybe<SubscriptionCycle>;
|
|
@@ -83,6 +101,7 @@ type WorkspaceSubscription = {
|
|
|
83
101
|
currentPeriodEnd?: Maybe<Scalars['DateTime']>;
|
|
84
102
|
currentPeriodStart?: Maybe<Scalars['DateTime']>;
|
|
85
103
|
cycle?: Maybe<SubscriptionCycle>;
|
|
104
|
+
pausedUntil?: Maybe<Scalars['DateTime']>;
|
|
86
105
|
provider?: Maybe<SubscriptionProvider>;
|
|
87
106
|
scheduledChange?: Maybe<ScheduledChange>;
|
|
88
107
|
seats: Scalars['Int'];
|
|
@@ -121,8 +140,6 @@ type PlanFragmentFragment = {
|
|
|
121
140
|
canUseApi: boolean;
|
|
122
141
|
maxStructuredSize?: number | null;
|
|
123
142
|
maxUnstructuredSize?: number | null;
|
|
124
|
-
deepAnalysisTokenLimit?: number | null;
|
|
125
|
-
deepAnalysisCharacterLimit?: number | null;
|
|
126
143
|
};
|
|
127
144
|
};
|
|
128
145
|
type SubscriptionForManagerQueryVariables = Exact<{
|
|
@@ -146,6 +163,10 @@ type ChangeBillingCycleMutationVariables = Exact<{
|
|
|
146
163
|
type RemoveSeatsMutationVariables = Exact<{
|
|
147
164
|
seatsToRemove: Scalars['Int'];
|
|
148
165
|
}>;
|
|
166
|
+
type CancelSubscriptionMutationVariables = Exact<{
|
|
167
|
+
reason?: InputMaybe<CancelReason>;
|
|
168
|
+
comment?: InputMaybe<Scalars['String']>;
|
|
169
|
+
}>;
|
|
149
170
|
type CancelSubscriptionForManagerMutationVariables = Exact<{
|
|
150
171
|
workspaceId: Scalars['String'];
|
|
151
172
|
}>;
|
|
@@ -221,8 +242,6 @@ declare class BillingClient {
|
|
|
221
242
|
canUseApi: boolean;
|
|
222
243
|
maxStructuredSize?: number | null;
|
|
223
244
|
maxUnstructuredSize?: number | null;
|
|
224
|
-
deepAnalysisTokenLimit?: number | null;
|
|
225
|
-
deepAnalysisCharacterLimit?: number | null;
|
|
226
245
|
};
|
|
227
246
|
}[]>;
|
|
228
247
|
get: (variables: PlanQueryVariables) => Promise<{
|
|
@@ -255,8 +274,6 @@ declare class BillingClient {
|
|
|
255
274
|
canUseApi: boolean;
|
|
256
275
|
maxStructuredSize?: number | null;
|
|
257
276
|
maxUnstructuredSize?: number | null;
|
|
258
|
-
deepAnalysisTokenLimit?: number | null;
|
|
259
|
-
deepAnalysisCharacterLimit?: number | null;
|
|
260
277
|
};
|
|
261
278
|
} | null | undefined>;
|
|
262
279
|
entitlements: () => Promise<Record<EntitlementTier, EntitlementDetail>>;
|
|
@@ -271,6 +288,7 @@ declare class BillingClient {
|
|
|
271
288
|
cancelAtPeriodEnd?: boolean | null;
|
|
272
289
|
currentPeriodStart?: any | null;
|
|
273
290
|
currentPeriodEnd?: any | null;
|
|
291
|
+
pausedUntil?: any | null;
|
|
274
292
|
scheduledChange?: {
|
|
275
293
|
effectiveDate?: any | null;
|
|
276
294
|
newTier?: EntitlementTier | null;
|
|
@@ -290,16 +308,28 @@ declare class BillingClient {
|
|
|
290
308
|
canUseApi: boolean;
|
|
291
309
|
maxStructuredSize?: number | null;
|
|
292
310
|
maxUnstructuredSize?: number | null;
|
|
293
|
-
deepAnalysisTokenLimit?: number | null;
|
|
294
|
-
deepAnalysisCharacterLimit?: number | null;
|
|
295
311
|
}>;
|
|
312
|
+
/** The free trial a checkout would get now (plan and days); null when there is none. */
|
|
313
|
+
checkoutTrial: () => Promise<{
|
|
314
|
+
tier: EntitlementTier;
|
|
315
|
+
days: number;
|
|
316
|
+
} | null>;
|
|
296
317
|
upgrade: (variables: UpgradePlanMutationVariables) => Promise<boolean>;
|
|
297
318
|
prorationAmount: (variables: {
|
|
298
319
|
targetPriceId: string;
|
|
299
320
|
}) => Promise<number>;
|
|
300
321
|
downgrade: (variables: DowngradePlanMutationVariables) => Promise<boolean>;
|
|
301
322
|
changeBillingCycle: (variables: ChangeBillingCycleMutationVariables) => Promise<boolean>;
|
|
302
|
-
|
|
323
|
+
/** Cancels at the end of the period; the reason and comment go to Stripe's cancellation details. */
|
|
324
|
+
cancel: (variables?: CancelSubscriptionMutationVariables) => Promise<boolean>;
|
|
325
|
+
/** The pause and discount the cancellation flow can still offer; null for store subscriptions or once taken. */
|
|
326
|
+
retentionOffers: () => Promise<{
|
|
327
|
+
pauseDays?: number | null;
|
|
328
|
+
discountPercent?: number | null;
|
|
329
|
+
discountMonths?: number | null;
|
|
330
|
+
} | null>;
|
|
331
|
+
pause: () => Promise<boolean>;
|
|
332
|
+
applyRetentionDiscount: () => Promise<boolean>;
|
|
303
333
|
reactivate: () => Promise<boolean>;
|
|
304
334
|
releaseSchedule: () => Promise<boolean>;
|
|
305
335
|
updates: () => AsyncIterable<WorkspaceSubscription>;
|
|
@@ -344,8 +374,6 @@ declare class BillingClient {
|
|
|
344
374
|
canUseApi: boolean;
|
|
345
375
|
maxStructuredSize?: number | null;
|
|
346
376
|
maxUnstructuredSize?: number | null;
|
|
347
|
-
deepAnalysisTokenLimit?: number | null;
|
|
348
|
-
deepAnalysisCharacterLimit?: number | null;
|
|
349
377
|
}>;
|
|
350
378
|
cancel: (variables: CancelSubscriptionForManagerMutationVariables) => Promise<boolean>;
|
|
351
379
|
reactivate: (variables: ReactivateSubscriptionForManagerMutationVariables) => Promise<boolean>;
|
|
@@ -354,4 +382,4 @@ declare class BillingClient {
|
|
|
354
382
|
private request;
|
|
355
383
|
}
|
|
356
384
|
|
|
357
|
-
export { BillingClient, type BillingClientOptions, type EntitlementDetail, EntitlementTier, type Plan, type PlanFragmentFragment as PlanFragment, type Price, type ScheduledChange, SubscriptionCycle, SubscriptionProvider, type WorkspaceSubscription };
|
|
385
|
+
export { BillingClient, type BillingClientOptions, CancelReason, type CheckoutTrial, type EntitlementDetail, EntitlementTier, type Plan, type PlanFragmentFragment as PlanFragment, type Price, type RetentionOffers, type ScheduledChange, SubscriptionCycle, SubscriptionProvider, type WorkspaceSubscription };
|
package/dist/billing/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{
|
|
1
|
+
export{j as BillingClient,f as CancelReason,g as EntitlementTier,h as SubscriptionCycle,i as SubscriptionProvider}from'../chunk-W764PDVJ.js';import'../chunk-37LLNIGO.js';import'../chunk-EK7ODJWE.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(n){if(typeof n!="string")return;let e=n.trim();if(!(!e||e.length>100))try{return Intl.DateTimeFormat(void 0,{timeZone:e}),e}catch{return}}function r(){return ()=>{if(!(!i()||typeof Intl>"u"||typeof Intl.DateTimeFormat!="function"))return t(Intl.DateTimeFormat().resolvedOptions().timeZone)}}function i(){return typeof window<"u"&&typeof document<"u"}export{r as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o=class extends Error{cause;constructor(n,r){super(n),this.name="DvinaError",this.cause=r;}},s=class extends o{errors;query;variables;constructor(n,r,t){let i=n.map(l=>l.message).join("; ")||"Unknown GraphQL error";super(i),this.name="DvinaGraphQLError",this.errors=n,this.query=r,this.variables=t;}},d=class extends o{status;constructor(n,r,t){super(n,t),this.name="DvinaNetworkError",this.status=r;}},p=class extends o{failedToken;constructor(n="Authentication failed",r,t){super(n,typeof r=="string"?t:r),this.name="DvinaAuthenticationError",this.failedToken=typeof r=="string"?r:void 0;}},_=class extends o{status=403;constructor(n="Forbidden",r){super(n,r),this.name="DvinaForbiddenError";}},E={SESSION_TOKEN_LIMIT_REACHED:"SESSION_TOKEN_LIMIT_REACHED",STORAGE_LIMIT_REACHED:"STORAGE_LIMIT_REACHED",DEEP_ANALYSIS_LIMIT_EXCEEDED:"DEEP_ANALYSIS_LIMIT_EXCEEDED",PLAN_DETAIL_RESTRICTION:"PLAN_DETAIL_RESTRICTION",RESOURCE_NOT_FOUND:"RESOURCE_NOT_FOUND"},I=new Set([E.PLAN_DETAIL_RESTRICTION,E.STORAGE_LIMIT_REACHED,E.DEEP_ANALYSIS_LIMIT_EXCEEDED]),c=class extends s{restrictionCode;constructor(n,r,t,i){super(n,t,i),this.name="DvinaPlanRestrictionError",this.restrictionCode=r;}},a=class extends s{constructor(n,r,t){super(n,r,t),this.name="DvinaTokenLimitError";}},u=class extends s{constructor(n,r,t){super(n,r,t),this.name="DvinaNotFoundError";}};function R(e){for(let n of e){let r=n.extensions?.code;if(r!=null)return String(r).toUpperCase()}}function L(e,n,r){let t=R(e);return t===E.SESSION_TOKEN_LIMIT_REACHED?new a(e,n,r):t===E.RESOURCE_NOT_FOUND?new u(e,n,r):t&&I.has(t)?new c(e,t,n,r):new s(e,n,r)}export{o as a,s as b,d as c,p as d,_ as e,E as f,c as g,a as h,u as i,R as j,L as k};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r=class{_request;_syncEngine;_baseUrl;constructor(e,n,a){this._request=e,this._syncEngine=n,this._baseUrl=a;}};var u=50;function h(t){return {...t,first:t.first??(t.after?u:void 0),last:t.last??(t.before?u:void 0)}}var o=class{hasNextPage;hasPreviousPage;startCursor;endCursor;constructor(e){this.hasNextPage=e.hasNextPage,this.hasPreviousPage=e.hasPreviousPage,this.startCursor=e.startCursor,this.endCursor=e.endCursor;}},i=class extends r{pageInfo;nodes;totalCount;constructor(e){super(e),this.pageInfo=new o({hasNextPage:false,hasPreviousPage:false}),this.nodes=[];}},s=class extends i{_fetch;constructor(e,n,a,c,p){super(e),this._fetch=n,this.nodes=a,this.pageInfo=c,this.totalCount=p;}async fetchNext(e){if(this.pageInfo.hasNextPage){let n=await this._fetch({after:this.pageInfo.endCursor},e);n&&(this.nodes=[...this.nodes,...n.nodes],this.pageInfo.endCursor=n.pageInfo.endCursor??this.pageInfo.endCursor,this.pageInfo.hasNextPage=n.pageInfo.hasNextPage);}return this}async fetchPrevious(e){if(this.pageInfo.hasPreviousPage){let n=await this._fetch({before:this.pageInfo.startCursor},e);n&&(this.nodes=[...n.nodes,...this.nodes],this.pageInfo.startCursor=n.pageInfo.startCursor??this.pageInfo.startCursor,this.pageInfo.hasPreviousPage=n.pageInfo.hasPreviousPage);}return this}};function f(t){return t.nodes}function g(t,e){return new s(t._request,e._fetch,[...t.nodes,...e.nodes],new o({hasNextPage:e.pageInfo.hasNextPage,hasPreviousPage:t.pageInfo.hasPreviousPage,startCursor:t.pageInfo.startCursor,endCursor:e.pageInfo.endCursor}),e.totalCount??t.totalCount)}export{r as a,h as b,o as c,i as d,s as e,f,g};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {f,d,c,a,k,e}from'./chunk-37LLNIGO.js';var A=new WeakMap;async function F(e,n){let t=A.get(e);if(!t){let a=e({forceRefresh:true}).finally(()=>{A.get(e)===a&&A.delete(e);});A.set(e,a),t=a;}let i=await t;if(n&&i===n)throw new d("Token refresh did not produce a new token",n);return i}var Le=1e3,$=1e3,_e=3,Qe=3e4;function qe(e,n=Math.random){return Math.floor(n()*e)}function Be(e){return e instanceof Error&&e.name==="AbortError"}function _(){return Date.now()}var x=class{constructor(n){this.options=n;}abortController;abortReason;attemptPromise;closed=false;consecutiveAuthFailures=0;forceRefreshNext=false;lastActivityAt=null;lastConnectedAt=null;lastError;reconnectAttempt=0;reconnectTimer;restartAfterCurrentAttempt=false;state="idle";staleTimer;shouldRun=false;get snapshot(){return {consecutiveAuthFailures:this.consecutiveAuthFailures,id:this.options.id,kind:this.options.kind,lastActivityAt:this.lastActivityAt,lastConnectedAt:this.lastConnectedAt,lastError:this.lastError,reconnectAttempt:this.reconnectAttempt,state:this.state}}async start(){if(this.closed)throw new Error(`Connection '${this.options.kind}:${this.options.id}' is closed`);return this.shouldRun=true,this.clearReconnectTimer(),this.attemptPromise&&this.abortReason&&(this.restartAfterCurrentAttempt=true),this.ensureAttempt()}stop(){this.shouldRun=false,this.restartAfterCurrentAttempt=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.abort("manual"),this.setState("idle");}close(){this.closed=true,this.shouldRun=false,this.restartAfterCurrentAttempt=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.abort("manual"),this.setState("closed");}reconnect(){if(!(this.closed||this.isHealthy()||this.state==="connecting")){if(this.shouldRun=true,this.clearReconnectTimer(),this.clearStaleTimer(),this.abortController){this.restartAfterCurrentAttempt=true,this.abort("restart");return}this.ensureAttempt();}}ensureAttempt(){if(!this.shouldRun||this.closed)return Promise.resolve();if(!this.attemptPromise){let n=this.runAttempt().finally(()=>{this.attemptPromise===n&&(this.attemptPromise=void 0),this.restartAfterCurrentAttempt&&this.shouldRun&&!this.closed&&(this.restartAfterCurrentAttempt=false,this.ensureAttempt());});this.attemptPromise=n;}return this.attemptPromise}async runAttempt(){if(!this.shouldRun||this.closed)return;let n=this.lastConnectedAt!==null||this.reconnectAttempt>0;this.setState("connecting"),this.lastError=void 0,this.abortReason=void 0;let t=new AbortController;this.abortController=t;try{let i=this.forceRefreshNext?await F(this.options.getToken):await this.options.getToken(void 0);if(this.forceRefreshNext=!1,await this.options.dial({isReconnect:n,markActivity:()=>this.markActivity(),markConnected:()=>this.markConnected(),requestTokenRefresh:()=>{this.forceRefreshNext=!0;},signal:t.signal,token:i}),!this.shouldRun||this.closed)return;this.scheduleReconnect("end");}catch(i){if(Be(i)){this.abortReason==="stale"&&this.shouldRun&&!this.closed&&this.scheduleReconnect("end");return}if(!this.shouldRun||this.closed)return;this.handleFailure(i);}finally{this.abortController===t&&(this.abortController=void 0),this.abortReason=void 0;}}handleFailure(n){if(this.lastError=n,n instanceof d||this.options.isFatalError?.(n)){this.shouldRun=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.setState("failed"),this.options.onFatalError?.(n);return}if(this.options.isAuthError?.(n)??false){if(this.consecutiveAuthFailures+=1,this.forceRefreshNext=true,this.setState("reconnecting"),this.consecutiveAuthFailures>=(this.options.maxConsecutiveAuthFailures??_e)){this.shouldRun=false,this.clearReconnectTimer(),this.clearStaleTimer(),this.setState("failed"),this.options.onFatalError?.(n);return}this.scheduleReconnect("auth");return}this.consecutiveAuthFailures=0,typeof navigator<"u"&&"onLine"in navigator&&navigator.onLine===false?this.setState("offline"):this.setState("reconnecting"),this.scheduleReconnect("failure");}scheduleReconnect(n){if(!this.shouldRun||this.closed)return;this.clearReconnectTimer(),this.clearStaleTimer();let t=n==="auth"?this.options.authRetryDelayMs??Le:n==="failure"?this.nextReconnectDelay():this.options.baseReconnectDelayMs??$;this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=void 0,this.ensureAttempt();},t);}nextReconnectDelay(){let n=this.options.baseReconnectDelayMs??$,t=this.options.maxReconnectDelayMs??Qe,i=Math.min(n*Math.pow(2,this.reconnectAttempt),t);return this.reconnectAttempt+=1,this.options.jitter==="full"?qe(i):i}isHealthy(){if(this.state!=="connected"||!this.abortController)return false;let n=this.options.staleTimeoutMs;return !n||n<=0?true:this.lastActivityAt!==null&&_()-this.lastActivityAt<n}markConnected(){this.consecutiveAuthFailures=0,this.reconnectAttempt=0,this.lastConnectedAt=_(),this.setState("connected"),this.markActivity();}markActivity(){this.lastActivityAt=_(),this.armStaleTimer();}armStaleTimer(){this.clearStaleTimer();let n=this.options.staleTimeoutMs;!n||n<=0||this.state!=="connected"||(this.staleTimer=setTimeout(()=>{!this.shouldRun||this.closed||!this.abortController||(this.setState("stale"),this.abort("stale"));},n));}clearReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=void 0);}clearStaleTimer(){this.staleTimer&&(clearTimeout(this.staleTimer),this.staleTimer=void 0);}abort(n){this.abortController&&(this.abortReason=n,this.abortController.abort(),this.abortController=void 0);}setState(n){this.state!==n&&(this.state=n,this.options.onStateChange?.(this.snapshot));}};var je=(u=>(u.HitLimits="HIT_LIMITS",u.MissingFeature="MISSING_FEATURE",u.NotUsing="NOT_USING",u.Other="OTHER",u.Quality="QUALITY",u.Switching="SWITCHING",u.TooExpensive="TOO_EXPENSIVE",u))(je||{}),Ge=(o=>(o.Enterprise="enterprise",o.Free="free",o.Max="max",o.Plus="plus",o.Pro="pro",o))(Ge||{}),He=(a=>(a.Daily="DAILY",a.Monthly="MONTHLY",a.Weekly="WEEKLY",a.Yearly="YEARLY",a))(He||{}),We=(t=>(t.Revcat="REVCAT",t.Stripe="STRIPE",t))(We||{});var Z={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Plans"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"plans"},selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"PlanFragment"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"PlanFragment"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"Plan"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"prices"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"currency"}},{kind:"Field",name:{kind:"Name",value:"amount"}},{kind:"Field",name:{kind:"Name",value:"interval"}},{kind:"Field",name:{kind:"Name",value:"campaign"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"originalAmount"}},{kind:"Field",name:{kind:"Name",value:"discountedAmount"}},{kind:"Field",name:{kind:"Name",value:"percentOff"}},{kind:"Field",name:{kind:"Name",value:"expiresAt"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"entitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}},{kind:"Field",name:{kind:"Name",value:"features"}}]}}]},K={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Plan"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"plan"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"PlanFragment"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"PlanFragment"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"Plan"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"prices"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"currency"}},{kind:"Field",name:{kind:"Name",value:"amount"}},{kind:"Field",name:{kind:"Name",value:"interval"}},{kind:"Field",name:{kind:"Name",value:"campaign"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"originalAmount"}},{kind:"Field",name:{kind:"Name",value:"discountedAmount"}},{kind:"Field",name:{kind:"Name",value:"percentOff"}},{kind:"Field",name:{kind:"Name",value:"expiresAt"}}]}}]}},{kind:"Field",name:{kind:"Name",value:"entitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}},{kind:"Field",name:{kind:"Name",value:"features"}}]}}]},ee={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"TierOrders"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tierOrders"}}]}}]},ne={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Entitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"entitlements"}}]}}]},te={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"Subscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"provider"}},{kind:"Field",name:{kind:"Name",value:"cycle"}},{kind:"Field",name:{kind:"Name",value:"seats"}},{kind:"Field",name:{kind:"Name",value:"cancelAtPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodStart"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"pausedUntil"}},{kind:"Field",name:{kind:"Name",value:"scheduledChange"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"effectiveDate"}},{kind:"Field",name:{kind:"Name",value:"newTier"}},{kind:"Field",name:{kind:"Name",value:"newSeats"}},{kind:"Field",name:{kind:"Name",value:"newCycle"}}]}}]}}]}}]},ie={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SubscriptionForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscriptionForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"provider"}},{kind:"Field",name:{kind:"Name",value:"cycle"}},{kind:"Field",name:{kind:"Name",value:"seats"}},{kind:"Field",name:{kind:"Name",value:"cancelAtPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodStart"}},{kind:"Field",name:{kind:"Name",value:"currentPeriodEnd"}},{kind:"Field",name:{kind:"Name",value:"scheduledChange"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"effectiveDate"}},{kind:"Field",name:{kind:"Name",value:"newTier"}},{kind:"Field",name:{kind:"Name",value:"newSeats"}},{kind:"Field",name:{kind:"Name",value:"newCycle"}}]}}]}}]}}]},ae={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SubscriptionEntitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscriptionEntitlements"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}}]}}]},re={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"SubscriptionEntitlementsForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscriptionEntitlementsForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"canAddUser"}},{kind:"Field",name:{kind:"Name",value:"minUsers"}},{kind:"Field",name:{kind:"Name",value:"team"}},{kind:"Field",name:{kind:"Name",value:"capacity"}},{kind:"Field",name:{kind:"Name",value:"sourceTypes"}},{kind:"Field",name:{kind:"Name",value:"softTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"hardTokenUsageLimit"}},{kind:"Field",name:{kind:"Name",value:"canAddReport"}},{kind:"Field",name:{kind:"Name",value:"canUseApi"}},{kind:"Field",name:{kind:"Name",value:"maxStructuredSize"}},{kind:"Field",name:{kind:"Name",value:"maxUnstructuredSize"}}]}}]}}]},oe={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ProrationAmount"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"prorationAmount"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},se={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"UpgradePlan"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"upgradePlan"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},le={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DowngradePlan"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"downgradePlan"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},ue={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"AddSeats"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"additionalSeats"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"addSeats"},arguments:[{kind:"Argument",name:{kind:"Name",value:"additionalSeats"},value:{kind:"Variable",name:{kind:"Name",value:"additionalSeats"}}}]}]}}]},ce={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ChangeBillingCycle"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"changeBillingCycle"},arguments:[{kind:"Argument",name:{kind:"Name",value:"targetPriceId"},value:{kind:"Variable",name:{kind:"Name",value:"targetPriceId"}}}]}]}}]},de={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"RemoveSeats"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"seatsToRemove"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"removeSeats"},arguments:[{kind:"Argument",name:{kind:"Name",value:"seatsToRemove"},value:{kind:"Variable",name:{kind:"Name",value:"seatsToRemove"}}}]}]}}]},me={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelSubscription"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"reason"}},type:{kind:"NamedType",name:{kind:"Name",value:"CancelReason"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"comment"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancelSubscription"},arguments:[{kind:"Argument",name:{kind:"Name",value:"reason"},value:{kind:"Variable",name:{kind:"Name",value:"reason"}}},{kind:"Argument",name:{kind:"Name",value:"comment"},value:{kind:"Variable",name:{kind:"Name",value:"comment"}}}]}]}}]},pe={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"RetentionOffers"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"retentionOffers"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"pauseDays"}},{kind:"Field",name:{kind:"Name",value:"discountPercent"}},{kind:"Field",name:{kind:"Name",value:"discountMonths"}}]}}]}}]},ke={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"PauseSubscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"pauseSubscription"}}]}}]},Se={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ApplyRetentionDiscount"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"applyRetentionDiscount"}}]}}]},ye={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ReactivateSubscription"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"reactivateSubscription"}}]}}]},fe={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelSubscriptionForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancelSubscriptionForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}]}]}}]},ve={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ReactivateSubscriptionForManager"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"reactivateSubscriptionForManager"},arguments:[{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}}]}]}}]},be={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateCustomer"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"name"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"email"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"userId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createCustomer"},arguments:[{kind:"Argument",name:{kind:"Name",value:"name"},value:{kind:"Variable",name:{kind:"Name",value:"name"}}},{kind:"Argument",name:{kind:"Name",value:"email"},value:{kind:"Variable",name:{kind:"Name",value:"email"}}},{kind:"Argument",name:{kind:"Name",value:"workspaceId"},value:{kind:"Variable",name:{kind:"Name",value:"workspaceId"}}},{kind:"Argument",name:{kind:"Name",value:"userId"},value:{kind:"Variable",name:{kind:"Name",value:"userId"}}}]}]}}]},he={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"ReleaseSchedule"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"releaseSchedule"}}]}}]},ge={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateCheckoutSession"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"priceId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"successUrl"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"cancelUrl"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createCheckoutSession"},arguments:[{kind:"Argument",name:{kind:"Name",value:"priceId"},value:{kind:"Variable",name:{kind:"Name",value:"priceId"}}},{kind:"Argument",name:{kind:"Name",value:"successUrl"},value:{kind:"Variable",name:{kind:"Name",value:"successUrl"}}},{kind:"Argument",name:{kind:"Name",value:"cancelUrl"},value:{kind:"Variable",name:{kind:"Name",value:"cancelUrl"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"url"}}]}}]}}]},Ne={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateCustomerPortalSession"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"returnUrl"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"createCustomerPortalSession"},arguments:[{kind:"Argument",name:{kind:"Name",value:"returnUrl"},value:{kind:"Variable",name:{kind:"Name",value:"returnUrl"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"url"}}]}}]}}]},Te={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"CheckoutTrial"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"checkoutTrial"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tier"}},{kind:"Field",name:{kind:"Name",value:"days"}}]}}]}}]};function De(e,n){throw new Error(n)}var q={Name:[],Document:["definitions"],OperationDefinition:["name","variableDefinitions","directives","selectionSet"],VariableDefinition:["variable","type","defaultValue","directives"],Variable:["name"],SelectionSet:["selections"],Field:["alias","name","arguments","directives","selectionSet"],Argument:["name","value"],FragmentSpread:["name","directives"],InlineFragment:["typeCondition","directives","selectionSet"],FragmentDefinition:["name","variableDefinitions","typeCondition","directives","selectionSet"],IntValue:[],FloatValue:[],StringValue:[],BooleanValue:[],NullValue:[],EnumValue:[],ListValue:["values"],ObjectValue:["fields"],ObjectField:["name","value"],Directive:["name","arguments"],NamedType:["name"],ListType:["type"],NonNullType:["type"],SchemaDefinition:["description","directives","operationTypes"],OperationTypeDefinition:["type"],ScalarTypeDefinition:["description","name","directives"],ObjectTypeDefinition:["description","name","interfaces","directives","fields"],FieldDefinition:["description","name","arguments","type","directives"],InputValueDefinition:["description","name","type","defaultValue","directives"],InterfaceTypeDefinition:["description","name","interfaces","directives","fields"],UnionTypeDefinition:["description","name","directives","types"],EnumTypeDefinition:["description","name","directives","values"],EnumValueDefinition:["description","name","directives"],InputObjectTypeDefinition:["description","name","directives","fields"],DirectiveDefinition:["description","name","arguments","locations"],SchemaExtension:["directives","operationTypes"],ScalarTypeExtension:["name","directives"],ObjectTypeExtension:["name","interfaces","directives","fields"],InterfaceTypeExtension:["name","interfaces","directives","fields"],UnionTypeExtension:["name","directives","types"],EnumTypeExtension:["name","directives","values"],InputObjectTypeExtension:["name","directives","fields"]},Ye=new Set(Object.keys(q));function B(e){let n=e?.kind;return typeof n=="string"&&Ye.has(n)}var Q;(function(e){e.QUERY="query",e.MUTATION="mutation",e.SUBSCRIPTION="subscription";})(Q||(Q={}));var T;(function(e){e.NAME="Name",e.DOCUMENT="Document",e.OPERATION_DEFINITION="OperationDefinition",e.VARIABLE_DEFINITION="VariableDefinition",e.SELECTION_SET="SelectionSet",e.FIELD="Field",e.ARGUMENT="Argument",e.FRAGMENT_SPREAD="FragmentSpread",e.INLINE_FRAGMENT="InlineFragment",e.FRAGMENT_DEFINITION="FragmentDefinition",e.VARIABLE="Variable",e.INT="IntValue",e.FLOAT="FloatValue",e.STRING="StringValue",e.BOOLEAN="BooleanValue",e.NULL="NullValue",e.ENUM="EnumValue",e.LIST="ListValue",e.OBJECT="ObjectValue",e.OBJECT_FIELD="ObjectField",e.DIRECTIVE="Directive",e.NAMED_TYPE="NamedType",e.LIST_TYPE="ListType",e.NON_NULL_TYPE="NonNullType",e.SCHEMA_DEFINITION="SchemaDefinition",e.OPERATION_TYPE_DEFINITION="OperationTypeDefinition",e.SCALAR_TYPE_DEFINITION="ScalarTypeDefinition",e.OBJECT_TYPE_DEFINITION="ObjectTypeDefinition",e.FIELD_DEFINITION="FieldDefinition",e.INPUT_VALUE_DEFINITION="InputValueDefinition",e.INTERFACE_TYPE_DEFINITION="InterfaceTypeDefinition",e.UNION_TYPE_DEFINITION="UnionTypeDefinition",e.ENUM_TYPE_DEFINITION="EnumTypeDefinition",e.ENUM_VALUE_DEFINITION="EnumValueDefinition",e.INPUT_OBJECT_TYPE_DEFINITION="InputObjectTypeDefinition",e.DIRECTIVE_DEFINITION="DirectiveDefinition",e.SCHEMA_EXTENSION="SchemaExtension",e.SCALAR_TYPE_EXTENSION="ScalarTypeExtension",e.OBJECT_TYPE_EXTENSION="ObjectTypeExtension",e.INTERFACE_TYPE_EXTENSION="InterfaceTypeExtension",e.UNION_TYPE_EXTENSION="UnionTypeExtension",e.ENUM_TYPE_EXTENSION="EnumTypeExtension",e.INPUT_OBJECT_TYPE_EXTENSION="InputObjectTypeExtension";})(T||(T={}));function j(e){return e===9||e===32}function Ee(e,n){let t=e.replace(/"""/g,'\\"""'),i=t.split(/\r\n|[\n\r]/g),a=i.length===1,o=i.length>1&&i.slice(1).every(h=>h.length===0||j(h.charCodeAt(0))),c=t.endsWith('\\"""'),u=e.endsWith('"')&&!c,d=e.endsWith("\\"),s=u||d,m=(!a||e.length>70||s||o||c),p="",y=a&&j(e.charCodeAt(0));return (m&&!y||o)&&(p+=`
|
|
2
|
+
`),p+=t,(m||s)&&(p+=`
|
|
3
|
+
`),'"""'+p+'"""'}function Ae(e){return R(e,[])}function R(e,n){switch(typeof e){case "string":return JSON.stringify(e);case "function":return e.name?`[function ${e.name}]`:"[function]";case "object":return ze(e,n);default:return String(e)}}function ze(e,n){if(e===null)return "null";if(n.includes(e))return "[Circular]";let t=[...n,e];if(Xe(e)){let i=e.toJSON();if(i!==e)return typeof i=="string"?i:R(i,t)}else if(Array.isArray(e))return $e(e,t);return Je(e,t)}function Xe(e){return typeof e.toJSON=="function"}function Je(e,n){let t=Object.entries(e);return t.length===0?"{}":n.length>2?"["+Ze(e)+"]":"{ "+t.map(([a,o])=>a+": "+R(o,n)).join(", ")+" }"}function $e(e,n){if(e.length===0)return "[]";if(n.length>2)return "[Array]";let t=Math.min(10,e.length),i=e.length-t,a=[];for(let o=0;o<t;++o)a.push(R(e[o],n));return i===1?a.push("... 1 more item"):i>1&&a.push(`... ${i} more items`),"["+a.join(", ")+"]"}function Ze(e){let n=Object.prototype.toString.call(e).replace(/^\[object /,"").replace(/]$/,"");if(n==="Object"&&typeof e.constructor=="function"){let t=e.constructor.name;if(typeof t=="string"&&t!=="")return t}return n}function Fe(e){return `"${e.replace(Ke,en)}"`}var Ke=/[\x00-\x1f\x22\x5c\x7f-\x9f]/g;function en(e){return nn[e.charCodeAt(0)]}var nn=["\\u0000","\\u0001","\\u0002","\\u0003","\\u0004","\\u0005","\\u0006","\\u0007","\\b","\\t","\\n","\\u000B","\\f","\\r","\\u000E","\\u000F","\\u0010","\\u0011","\\u0012","\\u0013","\\u0014","\\u0015","\\u0016","\\u0017","\\u0018","\\u0019","\\u001A","\\u001B","\\u001C","\\u001D","\\u001E","\\u001F","","",'\\"',"","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\\\","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","\\u007F","\\u0080","\\u0081","\\u0082","\\u0083","\\u0084","\\u0085","\\u0086","\\u0087","\\u0088","\\u0089","\\u008A","\\u008B","\\u008C","\\u008D","\\u008E","\\u008F","\\u0090","\\u0091","\\u0092","\\u0093","\\u0094","\\u0095","\\u0096","\\u0097","\\u0098","\\u0099","\\u009A","\\u009B","\\u009C","\\u009D","\\u009E","\\u009F"];var G=Object.freeze({});function C(e,n,t=q){let i=new Map;for(let f of Object.values(T))i.set(f,H(n,f));let a,o=Array.isArray(e),c=[e],u=-1,d=[],s=e,m,p,y=[],h=[];do{u++;let f=u===c.length,Y=f&&d.length!==0;if(f){if(m=h.length===0?void 0:y[y.length-1],s=p,p=h.pop(),Y)if(o){s=s.slice();let b=0;for(let[U,z]of d){let X=U-b;z===null?(s.splice(X,1),b++):s[X]=z;}}else {s=Object.defineProperties({},Object.getOwnPropertyDescriptors(s));for(let[b,U]of d)s[b]=U;}u=a.index,c=a.keys,d=a.edits,o=a.inArray,a=a.prev;}else if(p){if(m=o?u:c[u],s=p[m],s==null)continue;y.push(m);}let v;if(!Array.isArray(s)){var O,P;B(s)||De(false,`Invalid AST Node: ${Ae(s)}.`);let b=f?(O=i.get(s.kind))===null||O===void 0?void 0:O.leave:(P=i.get(s.kind))===null||P===void 0?void 0:P.enter;if(v=b?.call(n,s,m,p,y,h),v===G)break;if(v===false){if(!f){y.pop();continue}}else if(v!==void 0&&(d.push([m,v]),!f))if(B(v))s=v;else {y.pop();continue}}if(v===void 0&&Y&&d.push([m,s]),f)y.pop();else {var w;a={inArray:o,index:u,keys:c,edits:d,prev:a},o=Array.isArray(s),c=o?s:(w=t[s.kind])!==null&&w!==void 0?w:[],u=-1,d=[],p&&h.push(p),p=s;}}while(a!==void 0);return d.length!==0?d[d.length-1][1]:e}function H(e,n){let t=e[n];return typeof t=="object"?t:typeof t=="function"?{enter:t,leave:void 0}:{enter:e.enter,leave:e.leave}}function I(e){return C(e,an)}var tn=80,an={Name:{leave:e=>e.value},Variable:{leave:e=>"$"+e.name},Document:{leave:e=>r(e.definitions,`
|
|
4
|
+
|
|
5
|
+
`)},OperationDefinition:{leave(e){let n=l("(",r(e.variableDefinitions,", "),")"),t=r([e.operation,r([e.name,n]),r(e.directives," ")]," ");return (t==="query"?"":t+" ")+e.selectionSet}},VariableDefinition:{leave:({variable:e,type:n,defaultValue:t,directives:i})=>e+": "+n+l(" = ",t)+l(" ",r(i," "))},SelectionSet:{leave:({selections:e})=>S(e)},Field:{leave({alias:e,name:n,arguments:t,directives:i,selectionSet:a}){let o=l("",e,": ")+n,c=o+l("(",r(t,", "),")");return c.length>tn&&(c=o+l(`(
|
|
6
|
+
`,M(r(t,`
|
|
7
|
+
`)),`
|
|
8
|
+
)`)),r([c,r(i," "),a]," ")}},Argument:{leave:({name:e,value:n})=>e+": "+n},FragmentSpread:{leave:({name:e,directives:n})=>"..."+e+l(" ",r(n," "))},InlineFragment:{leave:({typeCondition:e,directives:n,selectionSet:t})=>r(["...",l("on ",e),r(n," "),t]," ")},FragmentDefinition:{leave:({name:e,typeCondition:n,variableDefinitions:t,directives:i,selectionSet:a})=>`fragment ${e}${l("(",r(t,", "),")")} on ${n} ${l("",r(i," ")," ")}`+a},IntValue:{leave:({value:e})=>e},FloatValue:{leave:({value:e})=>e},StringValue:{leave:({value:e,block:n})=>n?Ee(e):Fe(e)},BooleanValue:{leave:({value:e})=>e?"true":"false"},NullValue:{leave:()=>"null"},EnumValue:{leave:({value:e})=>e},ListValue:{leave:({values:e})=>"["+r(e,", ")+"]"},ObjectValue:{leave:({fields:e})=>"{"+r(e,", ")+"}"},ObjectField:{leave:({name:e,value:n})=>e+": "+n},Directive:{leave:({name:e,arguments:n})=>"@"+e+l("(",r(n,", "),")")},NamedType:{leave:({name:e})=>e},ListType:{leave:({type:e})=>"["+e+"]"},NonNullType:{leave:({type:e})=>e+"!"},SchemaDefinition:{leave:({description:e,directives:n,operationTypes:t})=>l("",e,`
|
|
9
|
+
`)+r(["schema",r(n," "),S(t)]," ")},OperationTypeDefinition:{leave:({operation:e,type:n})=>e+": "+n},ScalarTypeDefinition:{leave:({description:e,name:n,directives:t})=>l("",e,`
|
|
10
|
+
`)+r(["scalar",n,r(t," ")]," ")},ObjectTypeDefinition:{leave:({description:e,name:n,interfaces:t,directives:i,fields:a})=>l("",e,`
|
|
11
|
+
`)+r(["type",n,l("implements ",r(t," & ")),r(i," "),S(a)]," ")},FieldDefinition:{leave:({description:e,name:n,arguments:t,type:i,directives:a})=>l("",e,`
|
|
12
|
+
`)+n+(xe(t)?l(`(
|
|
13
|
+
`,M(r(t,`
|
|
14
|
+
`)),`
|
|
15
|
+
)`):l("(",r(t,", "),")"))+": "+i+l(" ",r(a," "))},InputValueDefinition:{leave:({description:e,name:n,type:t,defaultValue:i,directives:a})=>l("",e,`
|
|
16
|
+
`)+r([n+": "+t,l("= ",i),r(a," ")]," ")},InterfaceTypeDefinition:{leave:({description:e,name:n,interfaces:t,directives:i,fields:a})=>l("",e,`
|
|
17
|
+
`)+r(["interface",n,l("implements ",r(t," & ")),r(i," "),S(a)]," ")},UnionTypeDefinition:{leave:({description:e,name:n,directives:t,types:i})=>l("",e,`
|
|
18
|
+
`)+r(["union",n,r(t," "),l("= ",r(i," | "))]," ")},EnumTypeDefinition:{leave:({description:e,name:n,directives:t,values:i})=>l("",e,`
|
|
19
|
+
`)+r(["enum",n,r(t," "),S(i)]," ")},EnumValueDefinition:{leave:({description:e,name:n,directives:t})=>l("",e,`
|
|
20
|
+
`)+r([n,r(t," ")]," ")},InputObjectTypeDefinition:{leave:({description:e,name:n,directives:t,fields:i})=>l("",e,`
|
|
21
|
+
`)+r(["input",n,r(t," "),S(i)]," ")},DirectiveDefinition:{leave:({description:e,name:n,arguments:t,repeatable:i,locations:a})=>l("",e,`
|
|
22
|
+
`)+"directive @"+n+(xe(t)?l(`(
|
|
23
|
+
`,M(r(t,`
|
|
24
|
+
`)),`
|
|
25
|
+
)`):l("(",r(t,", "),")"))+(i?" repeatable":"")+" on "+r(a," | ")},SchemaExtension:{leave:({directives:e,operationTypes:n})=>r(["extend schema",r(e," "),S(n)]," ")},ScalarTypeExtension:{leave:({name:e,directives:n})=>r(["extend scalar",e,r(n," ")]," ")},ObjectTypeExtension:{leave:({name:e,interfaces:n,directives:t,fields:i})=>r(["extend type",e,l("implements ",r(n," & ")),r(t," "),S(i)]," ")},InterfaceTypeExtension:{leave:({name:e,interfaces:n,directives:t,fields:i})=>r(["extend interface",e,l("implements ",r(n," & ")),r(t," "),S(i)]," ")},UnionTypeExtension:{leave:({name:e,directives:n,types:t})=>r(["extend union",e,r(n," "),l("= ",r(t," | "))]," ")},EnumTypeExtension:{leave:({name:e,directives:n,values:t})=>r(["extend enum",e,r(n," "),S(t)]," ")},InputObjectTypeExtension:{leave:({name:e,directives:n,fields:t})=>r(["extend input",e,r(n," "),S(t)]," ")}};function r(e,n=""){var t;return (t=e?.filter(i=>i).join(n))!==null&&t!==void 0?t:""}function S(e){return l(`{
|
|
26
|
+
`,M(r(e,`
|
|
27
|
+
`)),`
|
|
28
|
+
}`)}function l(e,n,t=""){return n!=null&&n!==""?e+n+t:""}function M(e){return l(" ",e.replace(/\n/g,`
|
|
29
|
+
`))}function xe(e){var n;return (n=e?.some(t=>t.includes(`
|
|
30
|
+
`)))!==null&&n!==void 0?n:false}var Re=new WeakMap;function V(e){let n=Re.get(e);return n||(n=I(e),Re.set(e,n)),n}var sn=new Set([f.SESSION_TOKEN_LIMIT_REACHED,f.STORAGE_LIMIT_REACHED,f.DEEP_ANALYSIS_LIMIT_EXCEEDED,f.PLAN_DETAIL_RESTRICTION,f.RESOURCE_NOT_FOUND]);function Me(e,n){if(e)for(let t of e){let i=t.extensions?.code;if(i==null)continue;if(i===4401||i==="4401")return true;let a=String(i).toUpperCase();if(sn.has(a))return false;if(a==="UNAUTHORIZED"||a==="UNAUTHENTICATED"||t.message==="Unauthorized")return true}return false}async function Ie(e$1,n,t){let i=await e$1.getToken(),a=e$1.getLanguage(),o=e$1.getPlatform?.(),c$1=e$1.getUserTimezone?.(),u={"Content-Type":"application/json",Authorization:`Bearer ${i}`};a&&(u["x-preferred-language"]=a),o&&(u["x-platform"]=o),c$1&&(u["x-user-timezone"]=c$1);let d$1=JSON.stringify({query:V(n),variables:t}),s;try{s=await fetch(e$1.url,{method:"POST",headers:u,body:d$1});}catch(m){throw m instanceof Error&&m.name==="AbortError"?m:new c(m instanceof Error?m.message:"Network request failed before reaching the server",0)}if(!s.ok)throw s.status===401?new d(`Authentication failed with status ${s.status}`,i):s.status===403?new e("Request refused with status 403"):new c(`HTTP ${s.status}: ${s.statusText}`,s.status);return {response:await s.json(),usedToken:i}}var ln=4,un=1e3;function Ve(e){async function n(t,i,a$1=0,o=true){let c$1;try{c$1=await Ie(e,t,i);}catch(s){if(s instanceof d)return Ce(t,i,e,s.failedToken,o);if(s instanceof c&&s.status===0&&a$1<ln)return await dn(un*(a$1+1)),n(t,i,a$1+1,o);throw o&&s instanceof a&&e.onError?.(s),s}let{response:u,usedToken:d$1}=c$1;if(Me(u.errors))return Ce(t,i,e,d$1,o);if(u.errors?.length&&!u.data){let s=k(u.errors,V(t),i);throw o&&e.onError?.(s),s}if(!u.data){let s=k([{message:"No data returned from server"}],V(t),i);throw o&&e.onError?.(s),s}return u.data}return {request:(t,i,a)=>n(t,i,0,a?.reportErrors??true)}}async function Ce(e,n,t,i,a=true){try{await F(t.getToken,i);}catch{let o=new d("Token refresh failed");throw t.onError?.(o),o}return cn(t,e,n,a)}async function cn(e,n,t,i=true){let a$1;try{a$1=await Ie(e,n,t);}catch(c){if(c instanceof d){let u=new d("Authentication failed after token refresh");throw e.onError?.(u),u}throw i&&c instanceof a&&e.onError?.(c),c}let{response:o}=a$1;if(Me(o.errors)){let c=new d("Authentication failed after token refresh");throw e.onError?.(c),c}if(o.errors?.length&&!o.data){let c=k(o.errors,V(n),t);throw i&&e.onError?.(c),c}return o.data}function dn(e){return new Promise(n=>setTimeout(n,e))}async function Oe(e,n,t){let i=e.getReader(),a=new TextDecoder,o="";try{for(;!n.aborted;){let{done:c,value:u}=await i.read();if(c)break;t.onChunk?.(),o+=a.decode(u,{stream:!0});let d=o.split(/(?:\r\n|\r|\n){2}/);o=d.pop()??"";for(let s of d)t.onEventBlock(s.trim());}}finally{i.releaseLock();}}var Pe=1e3,mn=3e4,pn=3,kn=35e3,D=class extends Error{constructor(t){super(`Billing SSE auth failed: ${t}`);this.status=t;this.name="BillingAuthStreamError";}};function we(e){let n=e instanceof c?e.status:void 0;return n!==void 0&&n>=400&&n<500&&n!==408&&n!==429}var W=class{constructor(n,t){this.options=n;this.onClose=t;this.supervisor=new x({authRetryDelayMs:Pe,baseReconnectDelayMs:Pe,getToken:n.getToken,id:`billing-${Math.random().toString(36).slice(2)}`,isAuthError:i=>i instanceof D,isFatalError:we,kind:"billing-sse",maxConsecutiveAuthFailures:pn,maxReconnectDelayMs:mn,onFatalError:i=>{this.options.onError?.(we(i)?i:new d("Billing SSE stream authentication failed permanently")),this.close();},staleTimeoutMs:kn,dial:async i=>{let a=await fetch(this.options.billingSseUrl,{method:"GET",headers:{Authorization:`Bearer ${i.token}`,Accept:"text/event-stream","Cache-Control":"no-cache"},signal:i.signal});if(!a.ok)throw a.status===401||a.status===403?new D(a.status):new c(`Billing SSE failed: ${a.status} ${a.statusText}`,a.status);if(!a.body)throw new Error("Billing SSE response has no body");i.markConnected(),await Oe(a.body,i.signal,{onChunk:()=>i.markActivity(),onEventBlock:o=>this.processEventBlock(o,i.requestTokenRefresh)});}});}abortFinished=false;queue=[];pendingResolve=null;supervisor;start(){this.supervisor.start();}reconnect(){this.abortFinished||this.supervisor.reconnect();}next(){return this.queue.length>0?Promise.resolve({value:this.queue.shift(),done:false}):this.abortFinished?Promise.resolve({value:void 0,done:true}):new Promise(n=>{this.pendingResolve=n;})}return(){return this.close(),Promise.resolve({value:void 0,done:true})}[Symbol.asyncIterator](){return this}close(){this.abortFinished||(this.abortFinished=true,this.supervisor.close(),this.pendingResolve&&(this.pendingResolve({value:void 0,done:true}),this.pendingResolve=null),this.onClose(this));}push(n){if(!this.abortFinished){if(this.pendingResolve){this.pendingResolve({value:n,done:false}),this.pendingResolve=null;return}this.queue.length=0,this.queue.push(n);}}processEventBlock(n,t){if(!n||n.startsWith(":"))return;let i,a=[];for(let o of n.split(/\r\n|\r|\n/))o.startsWith("event: ")?i=o.slice(7).trim():o.startsWith("data: ")&&a.push(o.slice(6));if(i==="token-expired")throw t(),new D(401);if(!(i!=="subscription"||a.length===0))try{let o=JSON.parse(a.join(`
|
|
31
|
+
`));this.push(o);}catch{}}},Ue=class{http;options;activeUpdateStreams=new Set;constructor(n){this.options=n,this.http=Ve({url:n.billingHttpUrl,getToken:n.getToken,getLanguage:()=>{},onError:n.onError});}destroy(){for(let n of Array.from(this.activeUpdateStreams))n.close();this.activeUpdateStreams.clear();}reconnectAll(){for(let n of this.activeUpdateStreams)n.reconnect();}get plans(){return {list:async()=>(await this.request(Z)).plans,get:async n=>(await this.request(K,n)).plan,entitlements:async()=>(await this.request(ne)).entitlements,tierOrders:async()=>(await this.request(ee)).tierOrders}}get subscription(){return {get:async()=>(await this.request(te)).subscription,entitlements:async()=>(await this.request(ae)).subscriptionEntitlements,checkoutTrial:async()=>(await this.request(Te)).checkoutTrial??null,upgrade:async n=>(await this.request(se,n)).upgradePlan,prorationAmount:async n=>(await this.request(oe,n)).prorationAmount,downgrade:async n=>(await this.request(le,n)).downgradePlan,changeBillingCycle:async n=>(await this.request(ce,n)).changeBillingCycle,cancel:async(n={})=>(await this.request(me,n)).cancelSubscription,retentionOffers:async()=>(await this.request(pe)).retentionOffers??null,pause:async()=>(await this.request(ke)).pauseSubscription,applyRetentionDiscount:async()=>(await this.request(Se)).applyRetentionDiscount,reactivate:async()=>(await this.request(ye)).reactivateSubscription,releaseSchedule:async()=>(await this.request(he)).releaseSchedule,updates:()=>{let n=new W(this.options,t=>{this.activeUpdateStreams.delete(t);});return this.activeUpdateStreams.add(n),n.start(),n}}}get seats(){return {add:async n=>(await this.request(ue,n)).addSeats,remove:async n=>(await this.request(de,n)).removeSeats}}get session(){return {createSession:async n=>(await this.request(ge,n)).createCheckoutSession,createCustomerPortalSession:async n=>(await this.request(Ne,n)).createCustomerPortalSession}}get management(){return {subscription:async n=>(await this.request(ie,n)).subscriptionForManager,entitlements:async n=>(await this.request(re,n)).subscriptionEntitlementsForManager,cancel:async n=>(await this.request(fe,n)).cancelSubscriptionForManager,reactivate:async n=>(await this.request(ve,n)).reactivateSubscriptionForManager,createCustomer:async n=>(await this.request(be,n)).createCustomer}}request(n,t){return this.http.request(n,t)}};export{T as a,C as b,F as c,Ve as d,qe as e,je as f,Ge as g,He as h,We as i,Ue as j};
|