@dvina/sdk 4.1.112 → 4.1.177

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +37 -134
  2. package/dist/_generated_documents-NJ7MUHI5.js +1 -0
  3. package/dist/_generated_sdk-Bbsz63VY.d.ts +17325 -0
  4. package/dist/adapters/react/index.d.ts +36 -24
  5. package/dist/adapters/react/index.js +1 -1
  6. package/dist/ai/index.d.ts +570 -0
  7. package/dist/ai/index.js +3 -0
  8. package/dist/billing/index.d.ts +43 -15
  9. package/dist/billing/index.js +1 -1
  10. package/dist/chunk-32KGDH2Q.js +1 -0
  11. package/dist/chunk-37LLNIGO.js +1 -0
  12. package/dist/chunk-OCM5W3JH.js +1 -0
  13. package/dist/chunk-UMSYDBV7.js +1 -0
  14. package/dist/chunk-W764PDVJ.js +31 -0
  15. package/dist/{sync-engine-DYHreGOv.d.ts → connection-ClMdDUce.d.ts} +223 -11
  16. package/dist/{error-CsVoUTY8.d.ts → error-Bk0Jmuzd.d.ts} +11 -3
  17. package/dist/index.d.ts +24 -3563
  18. package/dist/index.js +4 -1
  19. package/dist/package.json +8 -13
  20. package/dist/pagination/index.d.ts +18 -4
  21. package/dist/pagination/index.js +1 -1
  22. package/dist/{types-Chg8ASmf.d.ts → types-BfiQdtra.d.ts} +1 -9
  23. package/package.json +26 -21
  24. package/dist/_generated_documents-54JPKRBN.js +0 -1
  25. package/dist/adapters/angular/index.d.ts +0 -254
  26. package/dist/adapters/angular/index.js +0 -1
  27. package/dist/chunk-5E7LX4YQ.js +0 -1
  28. package/dist/chunk-G34ETQUN.js +0 -1
  29. package/dist/chunk-H3TI6B7T.js +0 -1
  30. package/dist/chunk-IFSDIGN6.js +0 -1
  31. package/dist/chunk-IIQ3WGOJ.js +0 -1
  32. package/dist/chunk-QNQ3WSMR.js +0 -5
  33. package/dist/chunk-YUQTEBYO.js +0 -31
  34. package/dist/client-Bb2gD6Iz.d.ts +0 -488
  35. package/dist/client-Bqi7gjM0.d.ts +0 -7987
  36. package/dist/index-DoGg4ya_.d.ts +0 -79
  37. package/dist/inference/index.d.ts +0 -80
  38. package/dist/inference/index.js +0 -1
@@ -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};
@@ -1,6 +1,7 @@
1
- import { D as DvinaError } from '../error-CsVoUTY8.js';
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
- cancel: () => Promise<boolean>;
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 };
@@ -1 +1 @@
1
- export{h as BillingClient,e as EntitlementTier,f as SubscriptionCycle,g as SubscriptionProvider}from'../chunk-YUQTEBYO.js';import'../chunk-5E7LX4YQ.js';import'../chunk-EK7ODJWE.js';
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};