@dvina/sdk 3.3.124

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 (87) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +449 -0
  3. package/dist/_generated_documents-DF34ZUJ3.js +4 -0
  4. package/dist/_generated_documents-DF34ZUJ3.js.map +1 -0
  5. package/dist/_generated_documents-W4RHWJ4B.cjs +2041 -0
  6. package/dist/_generated_documents-W4RHWJ4B.cjs.map +1 -0
  7. package/dist/adapters/angular/index.cjs +163 -0
  8. package/dist/adapters/angular/index.cjs.map +1 -0
  9. package/dist/adapters/angular/index.d.cts +254 -0
  10. package/dist/adapters/angular/index.d.ts +254 -0
  11. package/dist/adapters/angular/index.js +159 -0
  12. package/dist/adapters/angular/index.js.map +1 -0
  13. package/dist/adapters/react/index.cjs +51 -0
  14. package/dist/adapters/react/index.cjs.map +1 -0
  15. package/dist/adapters/react/index.d.cts +62 -0
  16. package/dist/adapters/react/index.d.ts +62 -0
  17. package/dist/adapters/react/index.js +49 -0
  18. package/dist/adapters/react/index.js.map +1 -0
  19. package/dist/billing/index.cjs +26 -0
  20. package/dist/billing/index.cjs.map +1 -0
  21. package/dist/billing/index.d.cts +338 -0
  22. package/dist/billing/index.d.ts +338 -0
  23. package/dist/billing/index.js +5 -0
  24. package/dist/billing/index.js.map +1 -0
  25. package/dist/chunk-4QKWHQT2.cjs +104 -0
  26. package/dist/chunk-4QKWHQT2.cjs.map +1 -0
  27. package/dist/chunk-5WRI5ZAA.js +29 -0
  28. package/dist/chunk-5WRI5ZAA.js.map +1 -0
  29. package/dist/chunk-7JUBGIQ2.js +1008 -0
  30. package/dist/chunk-7JUBGIQ2.js.map +1 -0
  31. package/dist/chunk-7XBJ77RJ.js +103 -0
  32. package/dist/chunk-7XBJ77RJ.js.map +1 -0
  33. package/dist/chunk-DHUFVGJR.cjs +20389 -0
  34. package/dist/chunk-DHUFVGJR.cjs.map +1 -0
  35. package/dist/chunk-DZUJEN5N.cjs +32 -0
  36. package/dist/chunk-DZUJEN5N.cjs.map +1 -0
  37. package/dist/chunk-GDK2HJTF.cjs +1346 -0
  38. package/dist/chunk-GDK2HJTF.cjs.map +1 -0
  39. package/dist/chunk-KG3GNTYI.js +1339 -0
  40. package/dist/chunk-KG3GNTYI.js.map +1 -0
  41. package/dist/chunk-KV5SP7RP.cjs +114 -0
  42. package/dist/chunk-KV5SP7RP.cjs.map +1 -0
  43. package/dist/chunk-NPIKZKLU.cjs +27 -0
  44. package/dist/chunk-NPIKZKLU.cjs.map +1 -0
  45. package/dist/chunk-OAAZZUYL.cjs +1517 -0
  46. package/dist/chunk-OAAZZUYL.cjs.map +1 -0
  47. package/dist/chunk-P4BYTXZ7.js +98 -0
  48. package/dist/chunk-P4BYTXZ7.js.map +1 -0
  49. package/dist/chunk-PDM2KR7T.js +392 -0
  50. package/dist/chunk-PDM2KR7T.js.map +1 -0
  51. package/dist/chunk-QOZI2HY5.js +24 -0
  52. package/dist/chunk-QOZI2HY5.js.map +1 -0
  53. package/dist/chunk-RFBLNKW6.js +20035 -0
  54. package/dist/chunk-RFBLNKW6.js.map +1 -0
  55. package/dist/chunk-UELAE75E.cjs +408 -0
  56. package/dist/chunk-UELAE75E.cjs.map +1 -0
  57. package/dist/client-9Rwj21T9.d.cts +77 -0
  58. package/dist/client-Bskq7sc_.d.ts +77 -0
  59. package/dist/client-CLhQragb.d.cts +446 -0
  60. package/dist/client-CLhQragb.d.ts +446 -0
  61. package/dist/error-CsVoUTY8.d.cts +95 -0
  62. package/dist/error-CsVoUTY8.d.ts +95 -0
  63. package/dist/index-BrGSfyXq.d.cts +79 -0
  64. package/dist/index-zPcVLagO.d.ts +79 -0
  65. package/dist/index.cjs +1675 -0
  66. package/dist/index.cjs.map +1 -0
  67. package/dist/index.d.cts +9943 -0
  68. package/dist/index.d.ts +9943 -0
  69. package/dist/index.js +10 -0
  70. package/dist/index.js.map +1 -0
  71. package/dist/inference/index.cjs +70 -0
  72. package/dist/inference/index.cjs.map +1 -0
  73. package/dist/inference/index.d.cts +80 -0
  74. package/dist/inference/index.d.ts +80 -0
  75. package/dist/inference/index.js +5 -0
  76. package/dist/inference/index.js.map +1 -0
  77. package/dist/pagination/index.cjs +34 -0
  78. package/dist/pagination/index.cjs.map +1 -0
  79. package/dist/pagination/index.d.cts +6 -0
  80. package/dist/pagination/index.d.ts +6 -0
  81. package/dist/pagination/index.js +5 -0
  82. package/dist/pagination/index.js.map +1 -0
  83. package/dist/sync-engine-DVKQO-1-.d.cts +423 -0
  84. package/dist/sync-engine-cLwTqdjv.d.ts +423 -0
  85. package/dist/types-2RotD0Ab.d.cts +102 -0
  86. package/dist/types-2RotD0Ab.d.ts +102 -0
  87. package/package.json +143 -0
@@ -0,0 +1,49 @@
1
+ import '../../chunk-5WRI5ZAA.js';
2
+ import { useMemo, useState, useRef, useEffect } from 'react';
3
+
4
+ function useLiveQuery(factory, deps) {
5
+ const ref = useMemo(factory, deps);
6
+ const [value, setValue] = useState(ref.current);
7
+ if (process.env.NODE_ENV !== "production") {
8
+ const changeCount = useRef(0);
9
+ const lastChangeTime = useRef(Date.now());
10
+ const now = Date.now();
11
+ if (ref !== void 0) {
12
+ const elapsed = now - lastChangeTime.current;
13
+ if (elapsed < 1e3) {
14
+ changeCount.current++;
15
+ } else {
16
+ changeCount.current = 1;
17
+ }
18
+ lastChangeTime.current = now;
19
+ if (changeCount.current > 10) {
20
+ console.warn(
21
+ "useLiveQuery: query ref was recreated more than 10 times within 1 second. This usually means the dependency array is unstable (e.g. a new object/array created every render). Ensure deps contain only primitive values or stable references."
22
+ );
23
+ changeCount.current = 0;
24
+ }
25
+ }
26
+ }
27
+ useEffect(() => {
28
+ let active = true;
29
+ setValue(ref.current);
30
+ (async () => {
31
+ try {
32
+ for await (const v of ref) {
33
+ if (!active) break;
34
+ setValue(v);
35
+ }
36
+ } catch {
37
+ }
38
+ })();
39
+ return () => {
40
+ active = false;
41
+ ref.dispose();
42
+ };
43
+ }, [ref]);
44
+ return value;
45
+ }
46
+
47
+ export { useLiveQuery };
48
+ //# sourceMappingURL=index.js.map
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/adapters/react/index.ts"],"names":[],"mappings":";;;AA2DO,SAAS,YAAA,CAAgB,SAAiC,IAAA,EAAyC;AAEzG,EAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,OAAA,EAAS,IAAI,CAAA;AAEjC,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAI,QAAA,CAAwB,IAAI,OAAO,CAAA;AAG7D,EAAA,IAAI,OAAA,CAAQ,GAAA,CAAI,QAAA,KAAa,YAAA,EAAc;AAE1C,IAAA,MAAM,WAAA,GAAc,OAAO,CAAC,CAAA;AAE5B,IAAA,MAAM,cAAA,GAAiB,MAAA,CAAO,IAAA,CAAK,GAAA,EAAK,CAAA;AAExC,IAAA,MAAM,GAAA,GAAM,KAAK,GAAA,EAAI;AACrB,IAAA,IAAI,QAAQ,MAAA,EAAW;AACtB,MAAA,MAAM,OAAA,GAAU,MAAM,cAAA,CAAe,OAAA;AACrC,MAAA,IAAI,UAAU,GAAA,EAAM;AACnB,QAAA,WAAA,CAAY,OAAA,EAAA;AAAA,MACb,CAAA,MAAO;AACN,QAAA,WAAA,CAAY,OAAA,GAAU,CAAA;AAAA,MACvB;AACA,MAAA,cAAA,CAAe,OAAA,GAAU,GAAA;AAEzB,MAAA,IAAI,WAAA,CAAY,UAAU,EAAA,EAAI;AAC7B,QAAA,OAAA,CAAQ,IAAA;AAAA,UACP;AAAA,SAGD;AACA,QAAA,WAAA,CAAY,OAAA,GAAU,CAAA;AAAA,MACvB;AAAA,IACD;AAAA,EACD;AAEA,EAAA,SAAA,CAAU,MAAM;AACf,IAAA,IAAI,MAAA,GAAS,IAAA;AAGb,IAAA,QAAA,CAAS,IAAI,OAAO,CAAA;AAEpB,IAAA,CAAC,YAAY;AACZ,MAAA,IAAI;AACH,QAAA,WAAA,MAAiB,KAAK,GAAA,EAAK;AAC1B,UAAA,IAAI,CAAC,MAAA,EAAQ;AACb,UAAA,QAAA,CAAS,CAAC,CAAA;AAAA,QACX;AAAA,MACD,CAAA,CAAA,MAAQ;AAAA,MAER;AAAA,IACD,CAAA,GAAG;AAEH,IAAA,OAAO,MAAM;AACZ,MAAA,MAAA,GAAS,KAAA;AACT,MAAA,GAAA,CAAI,OAAA,EAAQ;AAAA,IACb,CAAA;AAAA,EACD,CAAA,EAAG,CAAC,GAAG,CAAC,CAAA;AAER,EAAA,OAAO,KAAA;AACR","file":"index.js","sourcesContent":["/**\n * React adapter for @dvina/sdk.\n *\n * Converts DvinaQueryRef (AsyncIterable) into React state via hooks.\n *\n * @example\n * ```tsx\n * import { useLiveQuery } from '@dvina/sdk/react';\n *\n * function ReportsPage() {\n * const reports = useLiveQuery(() => sdk.reports({ first: 20 }).watch(), []);\n * return (\n * <ul>\n * {reports?.nodes.map(r => <li key={r.id}>{r.name}</li>)}\n * </ul>\n * );\n * }\n * ```\n *\n * @packageDocumentation\n */\n\nimport { useState, useEffect, useMemo, useRef } from 'react';\nimport type { DvinaQueryRef } from '../../types.js';\n\n/**\n * React hook that subscribes to a `DvinaQueryRef` (AsyncIterable) and\n * returns its latest value as React state.\n *\n * Accepts a **factory function** that creates the query ref, along with a\n * dependency array. The factory is memoized internally — the ref is only\n * recreated when the dependencies change, preventing infinite\n * dispose-subscribe loops that would occur with inline `.watch()` calls.\n *\n * The component re-renders whenever the query ref emits a new value.\n * Cleanup (disposal of the subscription) happens automatically when the\n * component unmounts or when dependencies change.\n *\n * @param factory - A function that returns a DvinaQueryRef (e.g. `() => sdk.reports().watch()`)\n * @param deps - Dependency array controlling when the ref is recreated (same semantics as `useMemo`)\n * @returns The latest value from the query ref, or `undefined` if not yet loaded\n *\n * @example\n * ```tsx\n * // Static query — ref created once\n * function ReportsPage() {\n * const reports = useLiveQuery(() => sdk.reports({ first: 20 }).watch(), []);\n * if (!reports) return <div>Loading...</div>;\n * return <ul>{reports.nodes.map(r => <li key={r.id}>{r.name}</li>)}</ul>;\n * }\n *\n * // Reactive query — ref recreated when `id` changes\n * function ReportDetail({ id }: { id: string }) {\n * const report = useLiveQuery(() => sdk.report({ id }).watch(), [id]);\n * if (!report) return <div>Loading...</div>;\n * return <h1>{report.name}</h1>;\n * }\n * ```\n */\nexport function useLiveQuery<T>(factory: () => DvinaQueryRef<T>, deps: readonly unknown[]): T | undefined {\n\t// eslint-disable-next-line react-hooks/exhaustive-deps -- deps are forwarded from the caller\n\tconst ref = useMemo(factory, deps);\n\n\tconst [value, setValue] = useState<T | undefined>(ref.current);\n\n\t// Track rapid ref changes in dev mode to warn about missing deps\n\tif (process.env.NODE_ENV !== 'production') {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks -- dev-only, always runs in dev\n\t\tconst changeCount = useRef(0);\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst lastChangeTime = useRef(Date.now());\n\n\t\tconst now = Date.now();\n\t\tif (ref !== undefined) {\n\t\t\tconst elapsed = now - lastChangeTime.current;\n\t\t\tif (elapsed < 1000) {\n\t\t\t\tchangeCount.current++;\n\t\t\t} else {\n\t\t\t\tchangeCount.current = 1;\n\t\t\t}\n\t\t\tlastChangeTime.current = now;\n\n\t\t\tif (changeCount.current > 10) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t'useLiveQuery: query ref was recreated more than 10 times within 1 second. ' +\n\t\t\t\t\t\t'This usually means the dependency array is unstable (e.g. a new object/array ' +\n\t\t\t\t\t\t'created every render). Ensure deps contain only primitive values or stable references.',\n\t\t\t\t);\n\t\t\t\tchangeCount.current = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\tuseEffect(() => {\n\t\tlet active = true;\n\n\t\t// Sync initial value in case it changed between render and effect\n\t\tsetValue(ref.current);\n\n\t\t(async () => {\n\t\t\ttry {\n\t\t\t\tfor await (const v of ref) {\n\t\t\t\t\tif (!active) break;\n\t\t\t\t\tsetValue(v);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// Query ref was disposed or errored — state keeps its last value\n\t\t\t}\n\t\t})();\n\n\t\treturn () => {\n\t\t\tactive = false;\n\t\t\tref.dispose();\n\t\t};\n\t}, [ref]);\n\n\treturn value;\n}\n"]}
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+
3
+ var chunkGDK2HJTF_cjs = require('../chunk-GDK2HJTF.cjs');
4
+ require('../chunk-KV5SP7RP.cjs');
5
+ require('../chunk-DZUJEN5N.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "BillingClient", {
10
+ enumerable: true,
11
+ get: function () { return chunkGDK2HJTF_cjs.BillingClient; }
12
+ });
13
+ Object.defineProperty(exports, "EntitlementTier", {
14
+ enumerable: true,
15
+ get: function () { return chunkGDK2HJTF_cjs.EntitlementTier; }
16
+ });
17
+ Object.defineProperty(exports, "SubscriptionCycle", {
18
+ enumerable: true,
19
+ get: function () { return chunkGDK2HJTF_cjs.SubscriptionCycle; }
20
+ });
21
+ Object.defineProperty(exports, "SubscriptionProvider", {
22
+ enumerable: true,
23
+ get: function () { return chunkGDK2HJTF_cjs.SubscriptionProvider; }
24
+ });
25
+ //# sourceMappingURL=index.cjs.map
26
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,338 @@
1
+ import { D as DvinaError } from '../error-CsVoUTY8.cjs';
2
+
3
+ type Maybe<T> = T | null;
4
+ type Exact<T extends {
5
+ [key: string]: unknown;
6
+ }> = {
7
+ [K in keyof T]: T[K];
8
+ };
9
+ /** All built-in and custom scalars, mapped to their actual values */
10
+ type Scalars = {
11
+ ID: string;
12
+ String: string;
13
+ Boolean: boolean;
14
+ Int: number;
15
+ Float: number;
16
+ /** A date-time string at UTC, such as 2019-12-03T09:54:33Z, compliant with the date-time format. */
17
+ DateTime: any;
18
+ /** 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
+ JSONObject: any;
20
+ };
21
+ type EntitlementDetail = {
22
+ canAddReport: Scalars['Boolean'];
23
+ canAddUser: Scalars['Boolean'];
24
+ canUseApi: Scalars['Boolean'];
25
+ capacity?: Maybe<Scalars['Int']>;
26
+ deepAnalysisCharacterLimit?: Maybe<Scalars['Float']>;
27
+ deepAnalysisTokenLimit?: Maybe<Scalars['Float']>;
28
+ hardTokenUsageLimit?: Maybe<Scalars['Float']>;
29
+ maxStructuredSize?: Maybe<Scalars['Int']>;
30
+ maxUnstructuredSize?: Maybe<Scalars['Int']>;
31
+ minUsers?: Maybe<Scalars['Int']>;
32
+ softTokenUsageLimit?: Maybe<Scalars['Float']>;
33
+ sourceTypes?: Maybe<Array<Scalars['String']>>;
34
+ team: Scalars['Boolean'];
35
+ };
36
+ declare enum EntitlementTier {
37
+ Enterprise = "enterprise",
38
+ Free = "free",
39
+ Max = "max",
40
+ Plus = "plus",
41
+ Pro = "pro"
42
+ }
43
+ type Plan = {
44
+ entitlements: EntitlementDetail;
45
+ features?: Maybe<Array<Scalars['JSONObject']>>;
46
+ id: Scalars['String'];
47
+ name: Scalars['String'];
48
+ prices: Array<Price>;
49
+ tier?: Maybe<EntitlementTier>;
50
+ };
51
+ type Price = {
52
+ amount?: Maybe<Scalars['Float']>;
53
+ currency: Scalars['String'];
54
+ id: Scalars['String'];
55
+ interval?: Maybe<SubscriptionCycle>;
56
+ };
57
+ type ScheduledChange = {
58
+ effectiveDate?: Maybe<Scalars['DateTime']>;
59
+ newCycle?: Maybe<SubscriptionCycle>;
60
+ newSeats?: Maybe<Scalars['Int']>;
61
+ newTier?: Maybe<EntitlementTier>;
62
+ };
63
+ declare enum SubscriptionCycle {
64
+ Daily = "DAILY",
65
+ Monthly = "MONTHLY",
66
+ Weekly = "WEEKLY",
67
+ Yearly = "YEARLY"
68
+ }
69
+ declare enum SubscriptionProvider {
70
+ Revcat = "REVCAT",
71
+ Stripe = "STRIPE"
72
+ }
73
+ type WorkspaceSubscription = {
74
+ cancelAtPeriodEnd?: Maybe<Scalars['Boolean']>;
75
+ currentPeriodEnd?: Maybe<Scalars['DateTime']>;
76
+ currentPeriodStart?: Maybe<Scalars['DateTime']>;
77
+ cycle?: Maybe<SubscriptionCycle>;
78
+ provider?: Maybe<SubscriptionProvider>;
79
+ scheduledChange?: Maybe<ScheduledChange>;
80
+ seats: Scalars['Int'];
81
+ tier: EntitlementTier;
82
+ };
83
+ type PlanQueryVariables = Exact<{
84
+ id: Scalars['String'];
85
+ }>;
86
+ type PlanFragmentFragment = {
87
+ id: string;
88
+ name: string;
89
+ tier?: EntitlementTier | null;
90
+ features?: Array<any> | null;
91
+ prices: Array<{
92
+ id: string;
93
+ currency: string;
94
+ amount?: number | null;
95
+ interval?: SubscriptionCycle | null;
96
+ }>;
97
+ entitlements: {
98
+ canAddUser: boolean;
99
+ minUsers?: number | null;
100
+ team: boolean;
101
+ capacity?: number | null;
102
+ sourceTypes?: Array<string> | null;
103
+ softTokenUsageLimit?: number | null;
104
+ hardTokenUsageLimit?: number | null;
105
+ canAddReport: boolean;
106
+ canUseApi: boolean;
107
+ maxStructuredSize?: number | null;
108
+ maxUnstructuredSize?: number | null;
109
+ deepAnalysisTokenLimit?: number | null;
110
+ deepAnalysisCharacterLimit?: number | null;
111
+ };
112
+ };
113
+ type SubscriptionForManagerQueryVariables = Exact<{
114
+ workspaceId: Scalars['String'];
115
+ }>;
116
+ type SubscriptionEntitlementsForManagerQueryVariables = Exact<{
117
+ workspaceId: Scalars['String'];
118
+ }>;
119
+ type UpgradePlanMutationVariables = Exact<{
120
+ targetPriceId: Scalars['String'];
121
+ }>;
122
+ type DowngradePlanMutationVariables = Exact<{
123
+ targetPriceId: Scalars['String'];
124
+ }>;
125
+ type AddSeatsMutationVariables = Exact<{
126
+ additionalSeats: Scalars['Int'];
127
+ }>;
128
+ type ChangeBillingCycleMutationVariables = Exact<{
129
+ targetPriceId: Scalars['String'];
130
+ }>;
131
+ type RemoveSeatsMutationVariables = Exact<{
132
+ seatsToRemove: Scalars['Int'];
133
+ }>;
134
+ type CancelSubscriptionForManagerMutationVariables = Exact<{
135
+ workspaceId: Scalars['String'];
136
+ }>;
137
+ type ReactivateSubscriptionForManagerMutationVariables = Exact<{
138
+ workspaceId: Scalars['String'];
139
+ }>;
140
+ type CreateCustomerMutationVariables = Exact<{
141
+ name: Scalars['String'];
142
+ email: Scalars['String'];
143
+ workspaceId: Scalars['String'];
144
+ userId: Scalars['String'];
145
+ }>;
146
+ type CreateCheckoutSessionMutationVariables = Exact<{
147
+ priceId: Scalars['String'];
148
+ successUrl: Scalars['String'];
149
+ cancelUrl: Scalars['String'];
150
+ }>;
151
+ type CreateCustomerPortalSessionMutationVariables = Exact<{
152
+ returnUrl: Scalars['String'];
153
+ }>;
154
+
155
+ interface BillingClientOptions {
156
+ /** Full billing GraphQL HTTP URL (e.g. 'https://billing.dvina.ai/graphql') */
157
+ billingHttpUrl: string;
158
+ /** Full billing SSE URL (e.g. 'https://billing.dvina.ai/subscriptions/stream') */
159
+ billingSseUrl: string;
160
+ /** Token callback — shared with the main SDK */
161
+ getToken: (options?: {
162
+ forceRefresh?: boolean;
163
+ }) => Promise<string>;
164
+ /** Global error callback — threaded from DvinaSdkOptions */
165
+ onError?: (error: DvinaError) => void;
166
+ }
167
+ declare class BillingClient {
168
+ private readonly http;
169
+ private readonly options;
170
+ private readonly activeAbortControllers;
171
+ constructor(options: BillingClientOptions);
172
+ /**
173
+ * Terminate all active SSE streams.
174
+ * Call this on logout or SDK teardown to prevent lingering connections.
175
+ */
176
+ destroy(): void;
177
+ get plans(): {
178
+ list: () => Promise<{
179
+ id: string;
180
+ name: string;
181
+ tier?: EntitlementTier | null;
182
+ features?: Array<any> | null;
183
+ prices: Array<{
184
+ id: string;
185
+ currency: string;
186
+ amount?: number | null;
187
+ interval?: SubscriptionCycle | null;
188
+ }>;
189
+ entitlements: {
190
+ canAddUser: boolean;
191
+ minUsers?: number | null;
192
+ team: boolean;
193
+ capacity?: number | null;
194
+ sourceTypes?: Array<string> | null;
195
+ softTokenUsageLimit?: number | null;
196
+ hardTokenUsageLimit?: number | null;
197
+ canAddReport: boolean;
198
+ canUseApi: boolean;
199
+ maxStructuredSize?: number | null;
200
+ maxUnstructuredSize?: number | null;
201
+ deepAnalysisTokenLimit?: number | null;
202
+ deepAnalysisCharacterLimit?: number | null;
203
+ };
204
+ }[]>;
205
+ get: (variables: PlanQueryVariables) => Promise<{
206
+ id: string;
207
+ name: string;
208
+ tier?: EntitlementTier | null;
209
+ features?: Array<any> | null;
210
+ prices: Array<{
211
+ id: string;
212
+ currency: string;
213
+ amount?: number | null;
214
+ interval?: SubscriptionCycle | null;
215
+ }>;
216
+ entitlements: {
217
+ canAddUser: boolean;
218
+ minUsers?: number | null;
219
+ team: boolean;
220
+ capacity?: number | null;
221
+ sourceTypes?: Array<string> | null;
222
+ softTokenUsageLimit?: number | null;
223
+ hardTokenUsageLimit?: number | null;
224
+ canAddReport: boolean;
225
+ canUseApi: boolean;
226
+ maxStructuredSize?: number | null;
227
+ maxUnstructuredSize?: number | null;
228
+ deepAnalysisTokenLimit?: number | null;
229
+ deepAnalysisCharacterLimit?: number | null;
230
+ };
231
+ } | null | undefined>;
232
+ entitlements: () => Promise<Record<EntitlementTier, EntitlementDetail>>;
233
+ tierOrders: () => Promise<any>;
234
+ };
235
+ get subscription(): {
236
+ get: () => Promise<{
237
+ tier: EntitlementTier;
238
+ provider?: SubscriptionProvider | null;
239
+ cycle?: SubscriptionCycle | null;
240
+ seats: number;
241
+ cancelAtPeriodEnd?: boolean | null;
242
+ currentPeriodStart?: any | null;
243
+ currentPeriodEnd?: any | null;
244
+ scheduledChange?: {
245
+ effectiveDate?: any | null;
246
+ newTier?: EntitlementTier | null;
247
+ newSeats?: number | null;
248
+ newCycle?: SubscriptionCycle | null;
249
+ } | null;
250
+ }>;
251
+ entitlements: () => Promise<{
252
+ canAddUser: boolean;
253
+ minUsers?: number | null;
254
+ team: boolean;
255
+ capacity?: number | null;
256
+ sourceTypes?: Array<string> | null;
257
+ softTokenUsageLimit?: number | null;
258
+ hardTokenUsageLimit?: number | null;
259
+ canAddReport: boolean;
260
+ canUseApi: boolean;
261
+ maxStructuredSize?: number | null;
262
+ maxUnstructuredSize?: number | null;
263
+ deepAnalysisTokenLimit?: number | null;
264
+ deepAnalysisCharacterLimit?: number | null;
265
+ }>;
266
+ upgrade: (variables: UpgradePlanMutationVariables) => Promise<boolean>;
267
+ prorationAmount: (variables: {
268
+ targetPriceId: string;
269
+ }) => Promise<number>;
270
+ downgrade: (variables: DowngradePlanMutationVariables) => Promise<boolean>;
271
+ changeBillingCycle: (variables: ChangeBillingCycleMutationVariables) => Promise<boolean>;
272
+ cancel: () => Promise<boolean>;
273
+ reactivate: () => Promise<boolean>;
274
+ releaseSchedule: () => Promise<boolean>;
275
+ /**
276
+ * Subscribe to real-time subscription updates via SSE.
277
+ * Returns an AsyncIterable that yields WorkspaceSubscription snapshots.
278
+ * Automatically reconnects with exponential backoff and token refresh on auth errors.
279
+ */
280
+ updates: () => AsyncIterable<WorkspaceSubscription>;
281
+ };
282
+ get seats(): {
283
+ add: (variables: AddSeatsMutationVariables) => Promise<boolean>;
284
+ remove: (variables: RemoveSeatsMutationVariables) => Promise<boolean>;
285
+ };
286
+ get session(): {
287
+ createSession: (variables: CreateCheckoutSessionMutationVariables) => Promise<{
288
+ url: string;
289
+ }>;
290
+ createCustomerPortalSession: (variables: CreateCustomerPortalSessionMutationVariables) => Promise<{
291
+ url: string;
292
+ }>;
293
+ };
294
+ get management(): {
295
+ subscription: (variables: SubscriptionForManagerQueryVariables) => Promise<{
296
+ tier: EntitlementTier;
297
+ provider?: SubscriptionProvider | null;
298
+ cycle?: SubscriptionCycle | null;
299
+ seats: number;
300
+ cancelAtPeriodEnd?: boolean | null;
301
+ currentPeriodStart?: any | null;
302
+ currentPeriodEnd?: any | null;
303
+ scheduledChange?: {
304
+ effectiveDate?: any | null;
305
+ newTier?: EntitlementTier | null;
306
+ newSeats?: number | null;
307
+ newCycle?: SubscriptionCycle | null;
308
+ } | null;
309
+ }>;
310
+ entitlements: (variables: SubscriptionEntitlementsForManagerQueryVariables) => Promise<{
311
+ canAddUser: boolean;
312
+ minUsers?: number | null;
313
+ team: boolean;
314
+ capacity?: number | null;
315
+ sourceTypes?: Array<string> | null;
316
+ softTokenUsageLimit?: number | null;
317
+ hardTokenUsageLimit?: number | null;
318
+ canAddReport: boolean;
319
+ canUseApi: boolean;
320
+ maxStructuredSize?: number | null;
321
+ maxUnstructuredSize?: number | null;
322
+ deepAnalysisTokenLimit?: number | null;
323
+ deepAnalysisCharacterLimit?: number | null;
324
+ }>;
325
+ cancel: (variables: CancelSubscriptionForManagerMutationVariables) => Promise<boolean>;
326
+ reactivate: (variables: ReactivateSubscriptionForManagerMutationVariables) => Promise<boolean>;
327
+ createCustomer: (variables: CreateCustomerMutationVariables) => Promise<string>;
328
+ };
329
+ private request;
330
+ /**
331
+ * Create an SSE stream that connects to the billing SSE endpoint.
332
+ * Reconnects automatically with exponential backoff.
333
+ * On 401/403, refreshes the token and retries with a short delay.
334
+ */
335
+ private createSseStream;
336
+ }
337
+
338
+ export { BillingClient, type BillingClientOptions, type EntitlementDetail, EntitlementTier, type Plan, type PlanFragmentFragment as PlanFragment, type Price, type ScheduledChange, SubscriptionCycle, SubscriptionProvider, type WorkspaceSubscription };