@schematichq/schematic-react 1.4.1 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -1
- package/dist/schematic-react.cjs.js +2266 -200
- package/dist/schematic-react.d.ts +847 -22
- package/dist/schematic-react.esm.js +2267 -201
- package/package.json +27 -31
|
@@ -1,9 +1,234 @@
|
|
|
1
1
|
import { default as React_2 } from 'react';
|
|
2
2
|
|
|
3
|
+
export declare type AccessToken = string | AccessTokenProvider;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The machinery every temporary-access-token surface shares: which session is
|
|
7
|
+
* being read, the credential for it, and the request that carries it. It
|
|
8
|
+
* knows nothing about invoices, subscriptions, or checkout — a domain client
|
|
9
|
+
* (see `SchematicBillingClient`) is constructed over it, and several may
|
|
10
|
+
* share one session rather than each minting tokens of its own.
|
|
11
|
+
*/
|
|
12
|
+
/** Called once per session, and again when a request comes back 401. */
|
|
13
|
+
export declare type AccessTokenProvider = () => Promise<string | AccessTokenResult>;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* A bare token, or one that says when it expires and who it was minted for.
|
|
17
|
+
* `company`/`user` are the host restating the pair it asked for; stated, they
|
|
18
|
+
* are checked against the session the resolution was started for.
|
|
19
|
+
*/
|
|
20
|
+
declare interface AccessTokenResult {
|
|
21
|
+
token: string;
|
|
22
|
+
expiresAt?: Date | string | null;
|
|
23
|
+
company?: string;
|
|
24
|
+
user?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
3
27
|
declare type BaseSchematicProviderProps = Omit<SchematicJS.SchematicOptions, "client" | "publishableKey" | "useWebSocket"> & {
|
|
4
28
|
children: React_2.ReactNode;
|
|
29
|
+
/**
|
|
30
|
+
* The billing session: which (company, user) pair the `/company/*`
|
|
31
|
+
* endpoints are read for and the credential for it, `null` when nobody is
|
|
32
|
+
* signed in, and `undefined` while the host is finding out. Held alongside
|
|
33
|
+
* the publishable key, which keeps serving flags.
|
|
34
|
+
*/
|
|
35
|
+
session?: SessionInput;
|
|
36
|
+
/** A billing client; schematic-js supplies one when omitted. */
|
|
37
|
+
billingClient?: BillingClient;
|
|
38
|
+
/**
|
|
39
|
+
* Prefetched billing data, so the first render is complete (SSR). Rows
|
|
40
|
+
* stamped with their session paint on the first render only if `session`
|
|
41
|
+
* is stated on that render; under `undefined` they are held until it
|
|
42
|
+
* starts. State the pair on the first client render — `token` may be an
|
|
43
|
+
* async provider — or hydration will not match.
|
|
44
|
+
*/
|
|
45
|
+
initialData?: BillingData;
|
|
46
|
+
} & SchematicI18nConfig;
|
|
47
|
+
|
|
48
|
+
declare namespace billingApi {
|
|
49
|
+
export {
|
|
50
|
+
instanceOfApiError,
|
|
51
|
+
ApiErrorFromJSON,
|
|
52
|
+
ApiErrorFromJSONTyped,
|
|
53
|
+
ApiErrorToJSON,
|
|
54
|
+
ApiErrorToJSONTyped,
|
|
55
|
+
ApiError,
|
|
56
|
+
instanceOfCompanyInvoiceResponseData,
|
|
57
|
+
CompanyInvoiceResponseDataFromJSON,
|
|
58
|
+
CompanyInvoiceResponseDataFromJSONTyped,
|
|
59
|
+
CompanyInvoiceResponseDataToJSON,
|
|
60
|
+
CompanyInvoiceResponseDataToJSONTyped,
|
|
61
|
+
CompanyInvoiceResponseData,
|
|
62
|
+
instanceOfCompanyInvoicesResponseData,
|
|
63
|
+
CompanyInvoicesResponseDataFromJSON,
|
|
64
|
+
CompanyInvoicesResponseDataFromJSONTyped,
|
|
65
|
+
CompanyInvoicesResponseDataToJSON,
|
|
66
|
+
CompanyInvoicesResponseDataToJSONTyped,
|
|
67
|
+
CompanyInvoicesResponseData,
|
|
68
|
+
instanceOfGetCompanyInvoicesParams,
|
|
69
|
+
GetCompanyInvoicesParamsFromJSON,
|
|
70
|
+
GetCompanyInvoicesParamsFromJSONTyped,
|
|
71
|
+
GetCompanyInvoicesParamsToJSON,
|
|
72
|
+
GetCompanyInvoicesParamsToJSONTyped,
|
|
73
|
+
GetCompanyInvoicesParams,
|
|
74
|
+
instanceOfGetCompanyInvoicesResponse,
|
|
75
|
+
GetCompanyInvoicesResponseFromJSON,
|
|
76
|
+
GetCompanyInvoicesResponseFromJSONTyped,
|
|
77
|
+
GetCompanyInvoicesResponseToJSON,
|
|
78
|
+
GetCompanyInvoicesResponseToJSONTyped,
|
|
79
|
+
GetCompanyInvoicesResponse,
|
|
80
|
+
instanceOfInvoiceStatus,
|
|
81
|
+
InvoiceStatusFromJSON,
|
|
82
|
+
InvoiceStatusFromJSONTyped,
|
|
83
|
+
InvoiceStatusToJSON,
|
|
84
|
+
InvoiceStatusToJSONTyped,
|
|
85
|
+
InvoiceStatus
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* What a reader of billing data can ask for. Subscription and usage — the
|
|
91
|
+
* rest of what `hydrate` serves — and the checkout calls that change them
|
|
92
|
+
* join this interface as their endpoints ship.
|
|
93
|
+
*/
|
|
94
|
+
export declare interface BillingClient {
|
|
95
|
+
fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
|
|
96
|
+
readonly sessionStatus: SessionStatus;
|
|
97
|
+
readonly sessionKey: string | undefined;
|
|
98
|
+
setSession(session: SessionInput): void;
|
|
99
|
+
onSessionChange(listener: (event: SessionEvent) => void): () => void;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
declare type BillingClientOptions = SessionOptions;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* A prefetch or fixture. An omitted key reports as pending; a keyed resource
|
|
106
|
+
* seeds under `params`, or its defaults when absent, so a prefetch for a
|
|
107
|
+
* non-default query is claimed rather than refetched by the element.
|
|
108
|
+
*/
|
|
109
|
+
export declare type BillingData = {
|
|
110
|
+
[K in BillingResourceName]?: BillingResources[K];
|
|
111
|
+
} & {
|
|
112
|
+
params?: Partial<BillingResourceParams>;
|
|
113
|
+
/**
|
|
114
|
+
* A prefetch outlives the render that made it — a cached page, a session
|
|
115
|
+
* resolving to somebody else — so a store adopts it only for the session
|
|
116
|
+
* it names. `fetchBillingData` fills it in; a fixture need not.
|
|
117
|
+
*/
|
|
118
|
+
sessionKey?: string;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export declare function BillingDataProvider({ children, data, locale, onLoadMoreInvoices, onMissingString, onRefetch, status, strings, translate, }: BillingDataProviderProps): React_2.JSX.Element;
|
|
122
|
+
|
|
123
|
+
declare interface BillingDataProviderDataProps {
|
|
124
|
+
/** A missing key reports as pending. */
|
|
125
|
+
data: BillingData;
|
|
126
|
+
/** Simulated loading / failure per resource; wins over `data`. */
|
|
127
|
+
status?: BillingDataStatus;
|
|
128
|
+
onRefetch?: (name: BillingResourceName) => void;
|
|
129
|
+
onLoadMoreInvoices?: (query: InvoiceQuery) => void;
|
|
130
|
+
children?: React_2.ReactNode;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Feeds the billing hooks from plain data with no fetching: fixtures,
|
|
135
|
+
* stories, tests, or a fully prefetched page. The i18n props configure a
|
|
136
|
+
* `SchematicI18nProvider` around the children and never touch the data seam.
|
|
137
|
+
*/
|
|
138
|
+
export declare type BillingDataProviderProps = BillingDataProviderDataProps & SchematicI18nConfig;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* The seam between the hooks and whatever supplies data: the provider's
|
|
142
|
+
* store, a server prefetch, or fixtures.
|
|
143
|
+
*/
|
|
144
|
+
export declare interface BillingDataSource {
|
|
145
|
+
/**
|
|
146
|
+
* Sources that hold one value per resource (fixtures, prefetch) serve it
|
|
147
|
+
* for every parameter set.
|
|
148
|
+
*/
|
|
149
|
+
subscribe<K extends BillingResourceName>(name: K, params: BillingResourceParams[K], listener: () => void): () => void;
|
|
150
|
+
handle<K extends BillingResourceName>(name: K, params: BillingResourceParams[K]): ResourceHandle<BillingResources[K]>;
|
|
151
|
+
/** Never rejects: a failure lands on the resource's `error`. */
|
|
152
|
+
loadMoreInvoices: (query: InvoiceQuery) => Promise<void>;
|
|
153
|
+
invalidateAll: () => void;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Per-resource status overrides, for fixtures that simulate loading and failure. */
|
|
157
|
+
export declare type BillingDataStatus = {
|
|
158
|
+
[K in BillingResourceName]?: {
|
|
159
|
+
isPending?: boolean;
|
|
160
|
+
error?: Error;
|
|
161
|
+
};
|
|
5
162
|
};
|
|
6
163
|
|
|
164
|
+
declare interface BillingPrefetchOptions {
|
|
165
|
+
names?: BillingResourceName[];
|
|
166
|
+
/** The invoice query to prefetch for; the element must ask the same one. */
|
|
167
|
+
invoices?: InvoiceQuery;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Provides the billing hooks from a `BillingStore` over a `BillingClient`.
|
|
172
|
+
* Rendered by `SchematicProvider`; usable on its own with a client.
|
|
173
|
+
*/
|
|
174
|
+
export declare function BillingProvider({ billingClient, children, initialData, locale, onMissingString, session, strings, translate, }: BillingProviderProps): React_2.JSX.Element;
|
|
175
|
+
|
|
176
|
+
declare interface BillingProviderDataProps {
|
|
177
|
+
/**
|
|
178
|
+
* Required: this provider does not build one, and without it every hook
|
|
179
|
+
* reports the missing-source error and `session` has nowhere to go.
|
|
180
|
+
* `SchematicProvider` constructs one from its publishable key and renders
|
|
181
|
+
* this underneath, which is the usual path.
|
|
182
|
+
*/
|
|
183
|
+
billingClient?: BillingClient;
|
|
184
|
+
/**
|
|
185
|
+
* Read once, at mount. A prefetch stamped with its session paints on the
|
|
186
|
+
* first render only if `session` is stated on that render; under
|
|
187
|
+
* `undefined` it is held until the session starts. On a server-rendered
|
|
188
|
+
* page, state the pair on the first client render — `token` may be an
|
|
189
|
+
* async provider — or hydration will not match.
|
|
190
|
+
*/
|
|
191
|
+
initialData?: BillingData;
|
|
192
|
+
/**
|
|
193
|
+
* Who is being read, and the credential for it: `{ company, user?, token }`
|
|
194
|
+
* while someone is signed in, `null` when nobody is, and `undefined` while
|
|
195
|
+
* the host is still finding out.
|
|
196
|
+
*
|
|
197
|
+
* The (company, user) pair is the identity, so a token that rotates — a
|
|
198
|
+
* provider called again, a closure rebuilt on a render — is the same
|
|
199
|
+
* session and keeps what is loaded, while another pair drops it.
|
|
200
|
+
* `undefined` states nothing, which is what an auth resolving
|
|
201
|
+
* asynchronously renders first.
|
|
202
|
+
*/
|
|
203
|
+
session?: SessionInput;
|
|
204
|
+
children?: React_2.ReactNode;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* The i18n props are forwarded to a `SchematicI18nProvider` and never reach
|
|
209
|
+
* the data seam.
|
|
210
|
+
*/
|
|
211
|
+
export declare type BillingProviderProps = BillingProviderDataProps & SchematicI18nConfig;
|
|
212
|
+
|
|
213
|
+
export declare type BillingResourceName = keyof BillingResources;
|
|
214
|
+
|
|
215
|
+
/** `Record<string, never>` marks a singleton; anything else is keyed. */
|
|
216
|
+
export declare interface BillingResourceParams {
|
|
217
|
+
invoices: InvoiceQuery;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Nothing in the store, the hooks, or the resource keys may be addressed by
|
|
222
|
+
* company or user id: users and companies are many-to-many, and a token names
|
|
223
|
+
* the pair. What is loaded belongs to the session it was read under — the
|
|
224
|
+
* pair, as `sessionKey` writes it — and a store that keeps more than one
|
|
225
|
+
* session's data keys it by that and serves only the active one.
|
|
226
|
+
*/
|
|
227
|
+
export declare interface BillingResources {
|
|
228
|
+
/** `GET /company/invoices?limit&offset&include_pending`. */
|
|
229
|
+
invoices: InvoicePage;
|
|
230
|
+
}
|
|
231
|
+
|
|
7
232
|
declare type BooleanListenerFn = (value: boolean) => void;
|
|
8
233
|
|
|
9
234
|
/**
|
|
@@ -73,11 +298,11 @@ declare interface CheckFlagResponseData {
|
|
|
73
298
|
featureUsageEvent?: string | null;
|
|
74
299
|
/**
|
|
75
300
|
* Deprecated: Use Entitlement.MetricPeriod instead.
|
|
76
|
-
* @type {
|
|
301
|
+
* @type {MetricPeriod}
|
|
77
302
|
* @memberof CheckFlagResponseData
|
|
78
303
|
* @deprecated
|
|
79
304
|
*/
|
|
80
|
-
featureUsagePeriod?:
|
|
305
|
+
featureUsagePeriod?: MetricPeriod | null;
|
|
81
306
|
/**
|
|
82
307
|
* Deprecated: Use Entitlement.MetricResetAt instead.
|
|
83
308
|
* @type {Date}
|
|
@@ -111,10 +336,10 @@ declare interface CheckFlagResponseData {
|
|
|
111
336
|
ruleId?: string | null;
|
|
112
337
|
/**
|
|
113
338
|
* If a rule was found, its type
|
|
114
|
-
* @type {
|
|
339
|
+
* @type {RuleType}
|
|
115
340
|
* @memberof CheckFlagResponseData
|
|
116
341
|
*/
|
|
117
|
-
ruleType?:
|
|
342
|
+
ruleType?: RuleType_2 | null;
|
|
118
343
|
/**
|
|
119
344
|
* If user keys were provided and matched a user, its ID
|
|
120
345
|
* @type {string}
|
|
@@ -136,8 +361,14 @@ export declare type CheckFlagReturn = {
|
|
|
136
361
|
featureUsageExceeded?: boolean;
|
|
137
362
|
/** If company keys were provided and matched a company, its ID */
|
|
138
363
|
companyId?: string;
|
|
139
|
-
/** If the company has a credit-based entitlement for this feature, the
|
|
364
|
+
/** If the company has a credit-based entitlement for this feature, the ID of the credit */
|
|
365
|
+
creditId?: string;
|
|
366
|
+
/** If the company has a credit-based entitlement for this feature, the credit available to fund new consumption excluding any open lease hold (the value lease-holding SDKs gate on) */
|
|
140
367
|
creditRemaining?: number;
|
|
368
|
+
/** If the company has a credit-based entitlement for this feature, the unspent amount held by an open credit lease, 0 when none is open */
|
|
369
|
+
creditReserved?: number;
|
|
370
|
+
/** If the company has a credit-based entitlement for this feature, the spendable balance including any open lease hold (creditRemaining + creditReserved); the number to display to end users */
|
|
371
|
+
creditSettled?: number;
|
|
141
372
|
/** If an error occurred while checking the flag, the error message */
|
|
142
373
|
error?: string;
|
|
143
374
|
/** If a numeric feature entitlement rule was matched, its allocation */
|
|
@@ -198,6 +429,14 @@ declare interface CheckFlagsResponse {
|
|
|
198
429
|
* @interface CheckFlagsResponseData
|
|
199
430
|
*/
|
|
200
431
|
declare interface CheckFlagsResponseData {
|
|
432
|
+
/**
|
|
433
|
+
* Lease-aware credit balances keyed by credit ID, covering every credit type the company holds a balance in
|
|
434
|
+
* @type {{ [key: string]: CompanyCreditBalance; }}
|
|
435
|
+
* @memberof CheckFlagsResponseData
|
|
436
|
+
*/
|
|
437
|
+
creditBalances?: {
|
|
438
|
+
[key: string]: CompanyCreditBalance;
|
|
439
|
+
};
|
|
201
440
|
/**
|
|
202
441
|
*
|
|
203
442
|
* @type {Array<CheckFlagResponseData>}
|
|
@@ -231,6 +470,112 @@ declare const CheckPlanReturnFromJSON: (json: any) => CheckPlanReturn;
|
|
|
231
470
|
|
|
232
471
|
declare type CheckPlanReturnListenerFn = (value: CheckPlanReturn) => void;
|
|
233
472
|
|
|
473
|
+
/**
|
|
474
|
+
* Schematic API
|
|
475
|
+
* Schematic API
|
|
476
|
+
*
|
|
477
|
+
* The version of the OpenAPI document: 0.1
|
|
478
|
+
*
|
|
479
|
+
*
|
|
480
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
481
|
+
* https://openapi-generator.tech
|
|
482
|
+
* Do not edit the class manually.
|
|
483
|
+
*/
|
|
484
|
+
/**
|
|
485
|
+
*
|
|
486
|
+
* @export
|
|
487
|
+
* @interface CompanyCreditBalance
|
|
488
|
+
*/
|
|
489
|
+
export declare interface CompanyCreditBalance {
|
|
490
|
+
/**
|
|
491
|
+
* Remaining credit, excluding any open lease hold (the value SDKs gate on)
|
|
492
|
+
* @type {number}
|
|
493
|
+
* @memberof CompanyCreditBalance
|
|
494
|
+
*/
|
|
495
|
+
remaining: number;
|
|
496
|
+
/**
|
|
497
|
+
* Amount held by the company's open credit lease, 0 when none is open
|
|
498
|
+
* @type {number}
|
|
499
|
+
* @memberof CompanyCreditBalance
|
|
500
|
+
*/
|
|
501
|
+
reserved: number;
|
|
502
|
+
/**
|
|
503
|
+
* Spendable balance including the open lease hold (remaining + reserved)
|
|
504
|
+
* @type {number}
|
|
505
|
+
* @memberof CompanyCreditBalance
|
|
506
|
+
*/
|
|
507
|
+
settled: number;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
*
|
|
512
|
+
* @export
|
|
513
|
+
* @interface CompanyInvoiceResponseData
|
|
514
|
+
*/
|
|
515
|
+
declare interface CompanyInvoiceResponseData {
|
|
516
|
+
/**
|
|
517
|
+
*
|
|
518
|
+
* @type {number}
|
|
519
|
+
* @memberof CompanyInvoiceResponseData
|
|
520
|
+
*/
|
|
521
|
+
amountDue: number;
|
|
522
|
+
/**
|
|
523
|
+
*
|
|
524
|
+
* @type {Date}
|
|
525
|
+
* @memberof CompanyInvoiceResponseData
|
|
526
|
+
*/
|
|
527
|
+
createdAt: Date;
|
|
528
|
+
/**
|
|
529
|
+
*
|
|
530
|
+
* @type {string}
|
|
531
|
+
* @memberof CompanyInvoiceResponseData
|
|
532
|
+
*/
|
|
533
|
+
currency: string;
|
|
534
|
+
/**
|
|
535
|
+
*
|
|
536
|
+
* @type {Date}
|
|
537
|
+
* @memberof CompanyInvoiceResponseData
|
|
538
|
+
*/
|
|
539
|
+
dueDate?: Date | null;
|
|
540
|
+
/**
|
|
541
|
+
*
|
|
542
|
+
* @type {string}
|
|
543
|
+
* @memberof CompanyInvoiceResponseData
|
|
544
|
+
*/
|
|
545
|
+
id: string;
|
|
546
|
+
/**
|
|
547
|
+
*
|
|
548
|
+
* @type {InvoiceStatus}
|
|
549
|
+
* @memberof CompanyInvoiceResponseData
|
|
550
|
+
*/
|
|
551
|
+
status?: InvoiceStatus | null;
|
|
552
|
+
/**
|
|
553
|
+
*
|
|
554
|
+
* @type {string}
|
|
555
|
+
* @memberof CompanyInvoiceResponseData
|
|
556
|
+
*/
|
|
557
|
+
url?: string | null;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/** A company's lease-aware balance for a single credit type */
|
|
561
|
+
export declare type CreditBalance = {
|
|
562
|
+
/** Spendable balance including any open lease hold (remaining + reserved); the number to display to end users */
|
|
563
|
+
settled: number;
|
|
564
|
+
/** Remaining credit excluding any open lease hold (the value lease-holding SDKs gate on) */
|
|
565
|
+
remaining: number;
|
|
566
|
+
/** Amount held by the company's open credit lease, 0 when none is open */
|
|
567
|
+
reserved: number;
|
|
568
|
+
};
|
|
569
|
+
|
|
570
|
+
declare type CreditBalanceListenerFn = CreditBalancesListenerFn | EmptyListenerFn;
|
|
571
|
+
|
|
572
|
+
/** A company's lease-aware credit balances keyed by credit ID */
|
|
573
|
+
export declare type CreditBalances = Record<string, CreditBalance>;
|
|
574
|
+
|
|
575
|
+
declare const CreditBalancesFromJSON: (json: any) => CreditBalances;
|
|
576
|
+
|
|
577
|
+
declare type CreditBalancesListenerFn = (value: CreditBalances) => void;
|
|
578
|
+
|
|
234
579
|
/**
|
|
235
580
|
*
|
|
236
581
|
* @export
|
|
@@ -265,6 +610,8 @@ declare interface DatastreamCompanyPlan {
|
|
|
265
610
|
|
|
266
611
|
declare function DatastreamCompanyPlanFromJSON(json: any): DatastreamCompanyPlan;
|
|
267
612
|
|
|
613
|
+
export declare const DEFAULT_INVOICE_QUERY: InvoiceQuery;
|
|
614
|
+
|
|
268
615
|
declare type EmptyListenerFn = () => void;
|
|
269
616
|
|
|
270
617
|
/**
|
|
@@ -337,6 +684,12 @@ declare interface EventBodyFlagCheck {
|
|
|
337
684
|
* @memberof EventBodyFlagCheck
|
|
338
685
|
*/
|
|
339
686
|
flagKey: string;
|
|
687
|
+
/**
|
|
688
|
+
* Whether the check was a preflight, asking whether an action would be allowed rather than reporting one that happened. Absent on ordinary checks
|
|
689
|
+
* @type {boolean}
|
|
690
|
+
* @memberof EventBodyFlagCheck
|
|
691
|
+
*/
|
|
692
|
+
preflight?: boolean;
|
|
340
693
|
/**
|
|
341
694
|
* The reason why the value was returned
|
|
342
695
|
* @type {string}
|
|
@@ -412,6 +765,12 @@ declare interface FeatureEntitlement {
|
|
|
412
765
|
* @memberof FeatureEntitlement
|
|
413
766
|
*/
|
|
414
767
|
allocation?: number | null;
|
|
768
|
+
/**
|
|
769
|
+
* If the company has a credit-based entitlement for this feature, the credit cost per unit of usage
|
|
770
|
+
* @type {number}
|
|
771
|
+
* @memberof FeatureEntitlement
|
|
772
|
+
*/
|
|
773
|
+
consumptionRate?: number | null;
|
|
415
774
|
/**
|
|
416
775
|
* If the company has a credit-based entitlement for this feature, the ID of the credit
|
|
417
776
|
* @type {string}
|
|
@@ -419,11 +778,23 @@ declare interface FeatureEntitlement {
|
|
|
419
778
|
*/
|
|
420
779
|
creditId?: string | null;
|
|
421
780
|
/**
|
|
422
|
-
* If the company has a credit-based entitlement for this feature, the
|
|
781
|
+
* If the company has a credit-based entitlement for this feature, the credit available to fund new consumption or a new lease hold — open lease holds are excluded. Clients that hold a lease should gate on this plus their own unspent hold; clients with no lease awareness should use credit_settled instead
|
|
423
782
|
* @type {number}
|
|
424
783
|
* @memberof FeatureEntitlement
|
|
425
784
|
*/
|
|
426
785
|
creditRemaining?: number | null;
|
|
786
|
+
/**
|
|
787
|
+
* If the company has a credit-based entitlement for this feature, the unspent amount held by an open credit lease. Returns to credit_remaining when the lease is released
|
|
788
|
+
* @type {number}
|
|
789
|
+
* @memberof FeatureEntitlement
|
|
790
|
+
*/
|
|
791
|
+
creditReserved?: number | null;
|
|
792
|
+
/**
|
|
793
|
+
* If the company has a credit-based entitlement for this feature, the balance net of actual consumption, unaffected by open lease holds (credit_remaining plus credit_reserved). The number to display to end users
|
|
794
|
+
* @type {number}
|
|
795
|
+
* @memberof FeatureEntitlement
|
|
796
|
+
*/
|
|
797
|
+
creditSettled?: number | null;
|
|
427
798
|
/**
|
|
428
799
|
* If the company has a credit-based entitlement for this feature, the total credit amount
|
|
429
800
|
* @type {number}
|
|
@@ -442,6 +813,12 @@ declare interface FeatureEntitlement {
|
|
|
442
813
|
* @memberof FeatureEntitlement
|
|
443
814
|
*/
|
|
444
815
|
eventName?: string | null;
|
|
816
|
+
/**
|
|
817
|
+
* For event-based or credit-metered feature entitlements, the event subtype whose usage is tracked
|
|
818
|
+
* @type {string}
|
|
819
|
+
* @memberof FeatureEntitlement
|
|
820
|
+
*/
|
|
821
|
+
eventSubtype?: string | null;
|
|
445
822
|
/**
|
|
446
823
|
* The ID of the feature
|
|
447
824
|
* @type {string}
|
|
@@ -456,10 +833,10 @@ declare interface FeatureEntitlement {
|
|
|
456
833
|
featureKey: string;
|
|
457
834
|
/**
|
|
458
835
|
* For event-based feature entitlements, the period over which usage is tracked
|
|
459
|
-
* @type {
|
|
836
|
+
* @type {MetricPeriod}
|
|
460
837
|
* @memberof FeatureEntitlement
|
|
461
838
|
*/
|
|
462
|
-
metricPeriod?:
|
|
839
|
+
metricPeriod?: MetricPeriod | null;
|
|
463
840
|
/**
|
|
464
841
|
* For event-based feature entitlements, when the usage period will reset
|
|
465
842
|
* @type {Date}
|
|
@@ -468,10 +845,10 @@ declare interface FeatureEntitlement {
|
|
|
468
845
|
metricResetAt?: Date | null;
|
|
469
846
|
/**
|
|
470
847
|
* For event-based feature entitlements that have a monthly period, whether that monthly reset is based on the calendar month or a billing cycle
|
|
471
|
-
* @type {
|
|
848
|
+
* @type {MetricPeriodMonthReset}
|
|
472
849
|
* @memberof FeatureEntitlement
|
|
473
850
|
*/
|
|
474
|
-
monthReset?:
|
|
851
|
+
monthReset?: MetricPeriodMonthReset | null;
|
|
475
852
|
/**
|
|
476
853
|
* For usage-based pricing, the soft limit for overage charges or the next tier boundary
|
|
477
854
|
* @type {number}
|
|
@@ -490,41 +867,143 @@ declare interface FeatureEntitlement {
|
|
|
490
867
|
* @memberof FeatureEntitlement
|
|
491
868
|
*/
|
|
492
869
|
valueType: EntitlementValueType;
|
|
870
|
+
/**
|
|
871
|
+
* Customer-defined usage warning thresholds configured on this entitlement
|
|
872
|
+
* @type {Array<WarningTier>}
|
|
873
|
+
* @memberof FeatureEntitlement
|
|
874
|
+
*/
|
|
875
|
+
warningTiers?: Array<WarningTier>;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* Server prefetch for a provider's `initialData`. A resource that fails is
|
|
880
|
+
* left out rather than thrown, so one of them cannot block a page.
|
|
881
|
+
*/
|
|
882
|
+
declare function fetchBillingData(client: BillingClient, options?: BillingPrefetchOptions): Promise<BillingData>;
|
|
883
|
+
|
|
884
|
+
declare type FlagCheckListenerFn = CheckFlagReturnListenerFn | EmptyListenerFn;
|
|
885
|
+
|
|
886
|
+
declare type FlagValueListenerFn = BooleanListenerFn | EmptyListenerFn;
|
|
887
|
+
|
|
888
|
+
export declare type Invoice = CompanyInvoiceResponseData;
|
|
889
|
+
|
|
890
|
+
/** A `limit` above this is a 400 (PaginationFilter in schematic-api). */
|
|
891
|
+
declare const INVOICE_MAX_PAGE_SIZE = 250;
|
|
892
|
+
|
|
893
|
+
export declare const INVOICE_PAGE_SIZE = 12;
|
|
894
|
+
|
|
895
|
+
export declare interface InvoicePage {
|
|
896
|
+
invoices: Invoice[];
|
|
897
|
+
/** Matching the query on the server, not the number loaded here. */
|
|
898
|
+
count: number;
|
|
899
|
+
hasMore: boolean;
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
/** Each distinct query is its own row set with its own paging. */
|
|
903
|
+
export declare interface InvoiceQuery {
|
|
904
|
+
/** Include unpaid invoices that are not yet due. Default false. */
|
|
905
|
+
includePending?: boolean;
|
|
493
906
|
}
|
|
494
907
|
|
|
908
|
+
export declare interface InvoicesHandle extends ResourceHandle<InvoicePage> {
|
|
909
|
+
/**
|
|
910
|
+
* Requests the next page; appended to `data.invoices` when it arrives.
|
|
911
|
+
* `isPending` is true while it is on the wire and `error` records a
|
|
912
|
+
* failure, so a caller can track both without awaiting — the promise
|
|
913
|
+
* never rejects.
|
|
914
|
+
*/
|
|
915
|
+
loadMore: () => Promise<void>;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
declare interface InvoicesRequest extends InvoiceQuery {
|
|
919
|
+
limit: number;
|
|
920
|
+
offset: number;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* The rows asked for, and how many the query matches in total. `hasMore` is
|
|
925
|
+
* the page's, and only the caller knows its offset.
|
|
926
|
+
*/
|
|
927
|
+
declare type InvoicesResult = Omit<InvoicePage, "hasMore">;
|
|
928
|
+
|
|
929
|
+
/**
|
|
930
|
+
*
|
|
931
|
+
* @export
|
|
932
|
+
*/
|
|
933
|
+
export declare const InvoiceStatus: {
|
|
934
|
+
readonly Draft: "draft";
|
|
935
|
+
readonly Open: "open";
|
|
936
|
+
readonly Paid: "paid";
|
|
937
|
+
readonly Uncollectible: "uncollectible";
|
|
938
|
+
readonly Void: "void";
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
export declare type InvoiceStatus = (typeof InvoiceStatus)[keyof typeof InvoiceStatus];
|
|
942
|
+
|
|
943
|
+
/** A record of unique key-value pairs used for identifying a company or user */
|
|
944
|
+
export declare type Keys = Record<string, string>;
|
|
945
|
+
|
|
495
946
|
/**
|
|
947
|
+
*
|
|
496
948
|
* @export
|
|
497
949
|
*/
|
|
498
|
-
declare const
|
|
950
|
+
declare const MetricPeriod: {
|
|
499
951
|
readonly AllTime: "all_time";
|
|
500
952
|
readonly CurrentDay: "current_day";
|
|
501
953
|
readonly CurrentMonth: "current_month";
|
|
502
954
|
readonly CurrentWeek: "current_week";
|
|
503
955
|
};
|
|
504
956
|
|
|
505
|
-
declare type
|
|
957
|
+
declare type MetricPeriod = (typeof MetricPeriod)[keyof typeof MetricPeriod];
|
|
506
958
|
|
|
507
959
|
/**
|
|
960
|
+
*
|
|
508
961
|
* @export
|
|
509
962
|
*/
|
|
510
|
-
declare const
|
|
511
|
-
readonly FirstOfMonth: "first_of_month";
|
|
963
|
+
declare const MetricPeriodMonthReset: {
|
|
512
964
|
readonly BillingCycle: "billing_cycle";
|
|
965
|
+
readonly FirstOfMonth: "first_of_month";
|
|
513
966
|
};
|
|
514
967
|
|
|
515
|
-
declare type
|
|
516
|
-
|
|
517
|
-
declare type FlagCheckListenerFn = CheckFlagReturnListenerFn | EmptyListenerFn;
|
|
968
|
+
declare type MetricPeriodMonthReset = (typeof MetricPeriodMonthReset)[keyof typeof MetricPeriodMonthReset];
|
|
518
969
|
|
|
519
|
-
|
|
970
|
+
/**
|
|
971
|
+
* Keeps only the fields the request reads. The store keys a row set by the
|
|
972
|
+
* query's shape, so a field the API never sees would key a row set of its
|
|
973
|
+
* own, and a varying one a row set per render. schematic-js's normalizer
|
|
974
|
+
* passes unknown fields through; this export shadows it on purpose.
|
|
975
|
+
*/
|
|
976
|
+
export declare function normalizeInvoiceQuery(query: InvoiceQuery): InvoiceQuery;
|
|
520
977
|
|
|
521
|
-
/**
|
|
522
|
-
|
|
978
|
+
/**
|
|
979
|
+
* The store keys a resource by the query's shape, so without this
|
|
980
|
+
* `{ includePending: false }` is a different row set from `{}` — it would
|
|
981
|
+
* miss the seed and refetch rows identical to those already on screen.
|
|
982
|
+
*/
|
|
983
|
+
declare function normalizeInvoiceQuery_2(query: InvoiceQuery): InvoiceQuery;
|
|
523
984
|
|
|
524
985
|
declare type PendingListenerFn = BooleanListenerFn | EmptyListenerFn;
|
|
525
986
|
|
|
526
987
|
declare type PlanListenerFn = CheckPlanReturnListenerFn | EmptyListenerFn;
|
|
527
988
|
|
|
989
|
+
declare interface RequestOptions {
|
|
990
|
+
method?: string;
|
|
991
|
+
body?: unknown;
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
export declare interface ResourceHandle<T> extends ResourceState<T> {
|
|
995
|
+
refetch: () => void;
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
export declare interface ResourceState<T> {
|
|
999
|
+
/** `undefined` until the first successful load; retained across later errors. */
|
|
1000
|
+
data: T | undefined;
|
|
1001
|
+
/** The latest failure; cleared by the next success. */
|
|
1002
|
+
error: Error | undefined;
|
|
1003
|
+
/** A request is in flight and no data has arrived yet, or a refetch is running. */
|
|
1004
|
+
isPending: boolean;
|
|
1005
|
+
}
|
|
1006
|
+
|
|
528
1007
|
export declare enum RuleType {
|
|
529
1008
|
/** A global rule that, if present, will override all other rules for a flag */
|
|
530
1009
|
GLOBAL_OVERRIDE = "global_override",
|
|
@@ -542,10 +1021,26 @@ export declare enum RuleType {
|
|
|
542
1021
|
DEFAULT = "default"
|
|
543
1022
|
}
|
|
544
1023
|
|
|
1024
|
+
/**
|
|
1025
|
+
*
|
|
1026
|
+
* @export
|
|
1027
|
+
*/
|
|
1028
|
+
declare const RuleType_2: {
|
|
1029
|
+
readonly CompanyOverride: "company_override";
|
|
1030
|
+
readonly CompanyOverrideUsageExceeded: "company_override_usage_exceeded";
|
|
1031
|
+
readonly Default: "default";
|
|
1032
|
+
readonly GlobalOverride: "global_override";
|
|
1033
|
+
readonly PlanEntitlement: "plan_entitlement";
|
|
1034
|
+
readonly PlanEntitlementUsageExceeded: "plan_entitlement_usage_exceeded";
|
|
1035
|
+
readonly Standard: "standard";
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
declare type RuleType_2 = (typeof RuleType_2)[keyof typeof RuleType_2];
|
|
1039
|
+
|
|
545
1040
|
export declare class Schematic {
|
|
546
|
-
private
|
|
1041
|
+
private _additionalHeaders;
|
|
547
1042
|
private apiKey;
|
|
548
|
-
private
|
|
1043
|
+
private _apiUrl;
|
|
549
1044
|
private conn;
|
|
550
1045
|
private context;
|
|
551
1046
|
private debugEnabled;
|
|
@@ -558,11 +1053,17 @@ export declare class Schematic {
|
|
|
558
1053
|
private isPending;
|
|
559
1054
|
private isPendingListeners;
|
|
560
1055
|
private planListeners;
|
|
1056
|
+
private creditBalanceListeners;
|
|
561
1057
|
private storage;
|
|
1058
|
+
private persistFlagState;
|
|
1059
|
+
private flagStateCacheKey;
|
|
1060
|
+
private flagStateCacheMaxAgeMs;
|
|
1061
|
+
private cachedFlagState;
|
|
562
1062
|
private useWebSocket;
|
|
563
1063
|
private checks;
|
|
564
1064
|
private featureUsageEventMap;
|
|
565
1065
|
private planChecks;
|
|
1066
|
+
private creditBalances;
|
|
566
1067
|
private webSocketUrl;
|
|
567
1068
|
private webSocketConnectionTimeout;
|
|
568
1069
|
private webSocketReconnect;
|
|
@@ -584,6 +1085,8 @@ export declare class Schematic {
|
|
|
584
1085
|
private flagCheckDefaults;
|
|
585
1086
|
private fallbackCheckCache;
|
|
586
1087
|
constructor(apiKey: string, options?: SchematicOptions);
|
|
1088
|
+
get apiUrl(): string;
|
|
1089
|
+
get additionalHeaders(): Record<string, string>;
|
|
587
1090
|
/**
|
|
588
1091
|
* Resolve fallback value according to priority order:
|
|
589
1092
|
* 1. Callsite fallback value (if provided)
|
|
@@ -669,6 +1172,13 @@ export declare class Schematic {
|
|
|
669
1172
|
private stopRetryTimer;
|
|
670
1173
|
private flushEventQueue;
|
|
671
1174
|
private getAnonymousId;
|
|
1175
|
+
private hasCachedValuesForContext;
|
|
1176
|
+
private readFlagStateCache;
|
|
1177
|
+
private reviveCachedCheck;
|
|
1178
|
+
private reviveCachedPlan;
|
|
1179
|
+
private reviveCachedCreditBalances;
|
|
1180
|
+
private hydrateFlagStateFromCache;
|
|
1181
|
+
private persistContextToCache;
|
|
672
1182
|
private handleEvent;
|
|
673
1183
|
private sendEvent;
|
|
674
1184
|
private storeEvent;
|
|
@@ -768,6 +1278,10 @@ export declare class Schematic {
|
|
|
768
1278
|
addIsPendingListener: (listener: PendingListenerFn) => () => void;
|
|
769
1279
|
private setIsPending;
|
|
770
1280
|
getPlan: () => CheckPlanReturn | undefined;
|
|
1281
|
+
/** Get the company's lease-aware credit balances for the current context, keyed by credit ID */
|
|
1282
|
+
getCreditBalances: () => CreditBalances;
|
|
1283
|
+
/** Get the company's lease-aware balance for a single credit type in the current context */
|
|
1284
|
+
getCreditBalance: (creditId: string) => CreditBalance | undefined;
|
|
771
1285
|
getFlagCheck: (flagKey: string) => CheckFlagReturn | undefined;
|
|
772
1286
|
getFlagValue: (flagKey: string) => boolean | undefined;
|
|
773
1287
|
/** Register an event listener that will be notified with the boolean value for a given flag when this value changes */
|
|
@@ -775,11 +1289,35 @@ export declare class Schematic {
|
|
|
775
1289
|
/** Register an event listener that will be notified with the full flag check response for a given flag whenever this value changes */
|
|
776
1290
|
addFlagCheckListener: (flagKey: string, listener: FlagCheckListenerFn) => () => void;
|
|
777
1291
|
addPlanListener: (listener: PlanListenerFn) => () => void;
|
|
1292
|
+
/** Register an event listener that will be notified with the company's credit balances (keyed by credit ID) whenever they change */
|
|
1293
|
+
addCreditBalanceListener: (listener: CreditBalanceListenerFn) => () => void;
|
|
778
1294
|
private notifyFlagCheckListeners;
|
|
779
1295
|
/** Add or update a CheckFlagReturn in the featureUsageEventMap */
|
|
780
1296
|
private updateFeatureUsageEventMap;
|
|
781
1297
|
private notifyFlagValueListeners;
|
|
782
1298
|
private notifyPlanListeners;
|
|
1299
|
+
private notifyCreditBalanceListeners;
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
declare class SchematicApiError extends Error {
|
|
1303
|
+
readonly status: number;
|
|
1304
|
+
readonly path: string;
|
|
1305
|
+
readonly body: unknown;
|
|
1306
|
+
constructor(status: number, path: string, body: unknown);
|
|
1307
|
+
}
|
|
1308
|
+
|
|
1309
|
+
declare class SchematicBillingClient implements BillingClient {
|
|
1310
|
+
/**
|
|
1311
|
+
* Public so a second client over the same surface can be constructed on
|
|
1312
|
+
* this one rather than minting tokens of its own.
|
|
1313
|
+
*/
|
|
1314
|
+
readonly session: SchematicSession;
|
|
1315
|
+
constructor(options?: BillingClientOptions | SchematicSession);
|
|
1316
|
+
get sessionKey(): string | undefined;
|
|
1317
|
+
get sessionStatus(): SessionStatus;
|
|
1318
|
+
setSession(session: SessionInput): void;
|
|
1319
|
+
onSessionChange(listener: (event: SessionEvent) => void): () => void;
|
|
1320
|
+
fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
|
|
783
1321
|
}
|
|
784
1322
|
|
|
785
1323
|
/** Context for checking flags and sending events */
|
|
@@ -792,16 +1330,65 @@ declare interface SchematicContextProps {
|
|
|
792
1330
|
client: SchematicJS.Schematic;
|
|
793
1331
|
}
|
|
794
1332
|
|
|
1333
|
+
/** A company's credit balance for a single credit type, plus a loading flag */
|
|
1334
|
+
export declare type SchematicCreditBalance = {
|
|
1335
|
+
/** The spendable balance; 0 while loading or when the company holds no balance in this credit */
|
|
1336
|
+
balance: number;
|
|
1337
|
+
/** True while the balance is still loading and no value has arrived yet */
|
|
1338
|
+
isLoading: boolean;
|
|
1339
|
+
};
|
|
1340
|
+
|
|
795
1341
|
export declare interface SchematicHookOpts {
|
|
796
1342
|
client?: SchematicJS.Schematic;
|
|
797
1343
|
}
|
|
798
1344
|
|
|
1345
|
+
export declare interface SchematicI18nConfig {
|
|
1346
|
+
/** BCP 47 tag the elements format in; defaults to the runtime's locale. */
|
|
1347
|
+
locale?: string;
|
|
1348
|
+
/** Routes element copy to the host's i18n stack — pass i18next's `t`. */
|
|
1349
|
+
translate?: Translate;
|
|
1350
|
+
/**
|
|
1351
|
+
* Copy by key, for a host renaming strings rather than translating them.
|
|
1352
|
+
* Wins over `translate`; an element's own `strings` prop wins over both.
|
|
1353
|
+
*/
|
|
1354
|
+
strings?: StringOverrides;
|
|
1355
|
+
/** Reports a mis-wired catalogue that would otherwise look correct. */
|
|
1356
|
+
onMissingString?: (key: string) => void;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1359
|
+
export declare const SchematicI18nContext: React_2.Context<SchematicI18nConfig>;
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* `SchematicProvider` renders one of these, so most hosts never name it.
|
|
1363
|
+
* Nesting merges rather than replaces: a provider setting only `locale`
|
|
1364
|
+
* keeps the translator above it, and `strings` layers key by key.
|
|
1365
|
+
*/
|
|
1366
|
+
export declare function SchematicI18nProvider({ children, locale, onMissingString, strings, translate, }: SchematicI18nProviderProps): React_2.JSX.Element;
|
|
1367
|
+
|
|
1368
|
+
export declare interface SchematicI18nProviderProps extends SchematicI18nConfig {
|
|
1369
|
+
children?: React_2.ReactNode;
|
|
1370
|
+
}
|
|
1371
|
+
|
|
799
1372
|
declare namespace SchematicJS {
|
|
800
1373
|
export {
|
|
801
1374
|
CheckFlagResponseFromJSON,
|
|
802
1375
|
CheckFlagsResponseFromJSON,
|
|
803
1376
|
DatastreamCompanyPlanFromJSON,
|
|
804
1377
|
EventBodyFlagCheckToJSON,
|
|
1378
|
+
fetchBillingData,
|
|
1379
|
+
normalizeInvoiceQuery_2 as normalizeInvoiceQuery,
|
|
1380
|
+
sessionKey,
|
|
1381
|
+
AccessToken,
|
|
1382
|
+
AccessTokenProvider,
|
|
1383
|
+
AccessTokenResult,
|
|
1384
|
+
billingApi,
|
|
1385
|
+
BillingClient,
|
|
1386
|
+
BillingClientOptions,
|
|
1387
|
+
BillingData,
|
|
1388
|
+
BillingPrefetchOptions,
|
|
1389
|
+
BillingResourceName,
|
|
1390
|
+
BillingResourceParams,
|
|
1391
|
+
BillingResources,
|
|
805
1392
|
BooleanListenerFn,
|
|
806
1393
|
CheckFlagResponseData,
|
|
807
1394
|
CheckFlagReturn,
|
|
@@ -811,6 +1398,14 @@ declare namespace SchematicJS {
|
|
|
811
1398
|
CheckPlanReturn,
|
|
812
1399
|
CheckPlanReturnFromJSON,
|
|
813
1400
|
CheckPlanReturnListenerFn,
|
|
1401
|
+
CompanyCreditBalance,
|
|
1402
|
+
CompanyInvoiceResponseData,
|
|
1403
|
+
CreditBalance,
|
|
1404
|
+
CreditBalanceListenerFn,
|
|
1405
|
+
CreditBalances,
|
|
1406
|
+
CreditBalancesFromJSON,
|
|
1407
|
+
CreditBalancesListenerFn,
|
|
1408
|
+
DEFAULT_INVOICE_QUERY,
|
|
814
1409
|
EmptyListenerFn,
|
|
815
1410
|
Event_2 as Event,
|
|
816
1411
|
EventBody,
|
|
@@ -820,14 +1415,33 @@ declare namespace SchematicJS {
|
|
|
820
1415
|
EventType,
|
|
821
1416
|
FlagCheckListenerFn,
|
|
822
1417
|
FlagValueListenerFn,
|
|
1418
|
+
Invoice,
|
|
1419
|
+
INVOICE_MAX_PAGE_SIZE,
|
|
1420
|
+
INVOICE_PAGE_SIZE,
|
|
1421
|
+
InvoicePage,
|
|
1422
|
+
InvoiceQuery,
|
|
1423
|
+
InvoicesRequest,
|
|
1424
|
+
InvoicesResult,
|
|
1425
|
+
InvoiceStatus,
|
|
823
1426
|
Keys,
|
|
824
1427
|
PendingListenerFn,
|
|
825
1428
|
PlanListenerFn,
|
|
1429
|
+
RequestOptions,
|
|
1430
|
+
ResourceState,
|
|
826
1431
|
RuleType,
|
|
827
1432
|
Schematic,
|
|
1433
|
+
SchematicApiError,
|
|
1434
|
+
SchematicBillingClient,
|
|
828
1435
|
SchematicContext,
|
|
829
1436
|
SchematicOptions,
|
|
1437
|
+
SchematicSession,
|
|
1438
|
+
Session,
|
|
1439
|
+
SessionEvent,
|
|
1440
|
+
SessionInput,
|
|
1441
|
+
SessionOptions,
|
|
1442
|
+
SessionStatus,
|
|
830
1443
|
StoragePersister,
|
|
1444
|
+
TOKEN_CACHE_SIZE,
|
|
831
1445
|
Traits,
|
|
832
1446
|
TrialStatus,
|
|
833
1447
|
UsagePeriod
|
|
@@ -850,6 +1464,12 @@ export declare type SchematicOptions = {
|
|
|
850
1464
|
offline?: boolean;
|
|
851
1465
|
/** Optionally provide a custom storage persister for client-side storage */
|
|
852
1466
|
storage?: StoragePersister;
|
|
1467
|
+
/** Persist flag check results (and plan) keyed by context to the storage persister so subsequent page loads can boot with last-known values rather than fallbacks. Defaults to true; set false to disable.
|
|
1468
|
+
*
|
|
1469
|
+
* When a cache hit is found on `setContext`, `isPending` flips to false synchronously even if the cache only contains a subset of the flags the app subscribes to — uncached flags will resolve via configured fallbacks (`flagCheckDefaults`/`flagValueDefaults`) until the WebSocket reconciles. */
|
|
1470
|
+
persistFlagState?: boolean;
|
|
1471
|
+
/** Maximum age (ms) of a persisted cache entry before it is treated as stale on hydration. Per-context; older entries are dropped at construction time and on the next persist. Defaults to 7 days. */
|
|
1472
|
+
flagStateCacheMaxAgeMs?: number;
|
|
853
1473
|
/** Use a WebSocket connection for real-time flag checks; if using this, run the cleanup function to close the connection */
|
|
854
1474
|
useWebSocket?: boolean;
|
|
855
1475
|
/** Optionally provide a custom WebSocket URL */
|
|
@@ -892,6 +1512,111 @@ declare type SchematicProviderPropsWithPublishableKey = BaseSchematicProviderPro
|
|
|
892
1512
|
publishableKey: string;
|
|
893
1513
|
};
|
|
894
1514
|
|
|
1515
|
+
/**
|
|
1516
|
+
* Session identity is the (company, user) pair alone: a freshly minted token,
|
|
1517
|
+
* a rebuilt provider closure, and a refresh this session asked for itself are
|
|
1518
|
+
* all the same session. Nothing in a token says who it was minted for, so
|
|
1519
|
+
* that question is the host's to answer.
|
|
1520
|
+
*
|
|
1521
|
+
* Credentials survive a change of session, keyed by pair — switching back to
|
|
1522
|
+
* a company reads with the token already in hand. They do not survive the
|
|
1523
|
+
* session ending: after a sign-out the next person at this page is somebody
|
|
1524
|
+
* else, and nothing minted for the last one is theirs to send.
|
|
1525
|
+
*/
|
|
1526
|
+
declare class SchematicSession {
|
|
1527
|
+
private readonly _apiUrl;
|
|
1528
|
+
private readonly _headers;
|
|
1529
|
+
private readonly _fetch;
|
|
1530
|
+
private _session;
|
|
1531
|
+
private readonly _tokens;
|
|
1532
|
+
private readonly _resolving;
|
|
1533
|
+
/**
|
|
1534
|
+
* Bumped when the session's identity changes, and only then — the object
|
|
1535
|
+
* itself is replaced on every render. Anything asking "is this still the
|
|
1536
|
+
* session I started under?" counts generations rather than comparing.
|
|
1537
|
+
*/
|
|
1538
|
+
private _generation;
|
|
1539
|
+
private readonly _listeners;
|
|
1540
|
+
constructor(options?: SessionOptions);
|
|
1541
|
+
get key(): string | undefined;
|
|
1542
|
+
get status(): SessionStatus;
|
|
1543
|
+
/** Only a statement that changes which pair is read counts as a change. */
|
|
1544
|
+
set(session: SessionInput): void;
|
|
1545
|
+
onChange(listener: (event: SessionEvent) => void): () => void;
|
|
1546
|
+
private _emit;
|
|
1547
|
+
private _cached;
|
|
1548
|
+
private _cache;
|
|
1549
|
+
/**
|
|
1550
|
+
* The credential for a session, minted if this one is not held. `force`
|
|
1551
|
+
* retires what is held first: the caller is a request the API has just
|
|
1552
|
+
* rejected.
|
|
1553
|
+
*/
|
|
1554
|
+
resolveToken(session: Session, force: boolean): Promise<string>;
|
|
1555
|
+
/**
|
|
1556
|
+
* Sends a request under the active session's credential, refreshing once
|
|
1557
|
+
* and retrying if the API rejects it. Rejects rather than answering when
|
|
1558
|
+
* the session changes while the request is in flight: the rows would
|
|
1559
|
+
* otherwise come back as the answer to a question asked for another pair.
|
|
1560
|
+
*/
|
|
1561
|
+
request(path: string, options?: RequestOptions): Promise<unknown>;
|
|
1562
|
+
}
|
|
1563
|
+
|
|
1564
|
+
/**
|
|
1565
|
+
* Who is being read. Users and companies are many-to-many: the same person
|
|
1566
|
+
* reads one company's billing and then another's, and the same company is
|
|
1567
|
+
* read by several people. A token is minted for the pair, so the pair — not
|
|
1568
|
+
* the company alone — is the session's identity.
|
|
1569
|
+
*/
|
|
1570
|
+
export declare interface Session {
|
|
1571
|
+
/** The host's name for the company, its id in their own system say. */
|
|
1572
|
+
company: string;
|
|
1573
|
+
/**
|
|
1574
|
+
* The user, where the host mints per (company, user). Left out by a host
|
|
1575
|
+
* whose tokens are company-wide, and then every reader of that company
|
|
1576
|
+
* shares one session.
|
|
1577
|
+
*/
|
|
1578
|
+
user?: string;
|
|
1579
|
+
token: AccessToken;
|
|
1580
|
+
}
|
|
1581
|
+
|
|
1582
|
+
/**
|
|
1583
|
+
* What happened to the session, for anything holding data that belongs to
|
|
1584
|
+
* one. `started`: whatever is loaded belongs to the new session — a prefetch
|
|
1585
|
+
* the host seeded before its auth resolved. `changed`: another pair is being
|
|
1586
|
+
* read, and what is loaded belongs to the pair being left. `ended`: nobody is
|
|
1587
|
+
* signed in, and what is loaded belongs to nobody.
|
|
1588
|
+
*/
|
|
1589
|
+
export declare type SessionEvent = {
|
|
1590
|
+
type: "started" | "changed" | "ended";
|
|
1591
|
+
};
|
|
1592
|
+
|
|
1593
|
+
/**
|
|
1594
|
+
* Three states that are not interchangeable:
|
|
1595
|
+
*
|
|
1596
|
+
* * `Session` — active: this pair, read with this credential.
|
|
1597
|
+
* * `null` — ended: nobody is signed in; what is loaded is dropped.
|
|
1598
|
+
* * `undefined` — pending: the host's auth has not resolved. It states
|
|
1599
|
+
* nothing, so the session in hand stands.
|
|
1600
|
+
*/
|
|
1601
|
+
export declare type SessionInput = Session | null | undefined;
|
|
1602
|
+
|
|
1603
|
+
/**
|
|
1604
|
+
* The pair as one string, for anything that has to compare sessions or key
|
|
1605
|
+
* something by one — a prefetch stating which session it was fetched for, a
|
|
1606
|
+
* store keeping a page per session. Opaque: read it only by equality.
|
|
1607
|
+
*/
|
|
1608
|
+
declare function sessionKey(session: Session): string;
|
|
1609
|
+
|
|
1610
|
+
declare interface SessionOptions {
|
|
1611
|
+
session?: SessionInput;
|
|
1612
|
+
apiUrl?: string;
|
|
1613
|
+
additionalHeaders?: Record<string, string>;
|
|
1614
|
+
/** Override for tests and non-browser runtimes. */
|
|
1615
|
+
fetch?: typeof fetch;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
export declare type SessionStatus = "pending" | "active" | "ended";
|
|
1619
|
+
|
|
895
1620
|
/** Optional type for implementing custom client-side storage */
|
|
896
1621
|
export declare type StoragePersister = {
|
|
897
1622
|
setItem(key: string, value: any): void;
|
|
@@ -899,11 +1624,44 @@ export declare type StoragePersister = {
|
|
|
899
1624
|
removeItem(key: string): void;
|
|
900
1625
|
};
|
|
901
1626
|
|
|
1627
|
+
/** Copy overrides by key. Keys are the element package's `StringKey`s. */
|
|
1628
|
+
export declare type StringOverrides = Record<string, string | undefined>;
|
|
1629
|
+
|
|
1630
|
+
/**
|
|
1631
|
+
* Sessions whose credentials are kept. A reader switching between the
|
|
1632
|
+
* organizations they belong to walks a handful of them and comes back, and
|
|
1633
|
+
* re-minting on every step is a round trip to the host's token endpoint for
|
|
1634
|
+
* a token this client already holds and has not seen expire. The same
|
|
1635
|
+
* handful the flag cache bounds its contexts at.
|
|
1636
|
+
*/
|
|
1637
|
+
declare const TOKEN_CACHE_SIZE = 10;
|
|
1638
|
+
|
|
902
1639
|
/**
|
|
903
1640
|
* A flexible key/value type that can store any type of value on a company or user.
|
|
904
1641
|
*/
|
|
905
1642
|
export declare type Traits = Record<string, any>;
|
|
906
1643
|
|
|
1644
|
+
/**
|
|
1645
|
+
* Locale and copy live in their own context, not on the billing data source:
|
|
1646
|
+
* a host's `t` changes identity whenever its language does, and a source
|
|
1647
|
+
* rebuilt for that takes its cached snapshots with it, leaving
|
|
1648
|
+
* `useSyncExternalStore` a new handle every render.
|
|
1649
|
+
*
|
|
1650
|
+
* Nothing here interprets a key — the element package owns the key list and
|
|
1651
|
+
* the English copy.
|
|
1652
|
+
*/
|
|
1653
|
+
/**
|
|
1654
|
+
* Shaped like i18next's `t` so `translate={t}` is the whole integration.
|
|
1655
|
+
* `vars` reaches it as the options object, which is what lets `{ count }`
|
|
1656
|
+
* resolve a language's plural forms in the host's own stack rather than in
|
|
1657
|
+
* ours.
|
|
1658
|
+
*
|
|
1659
|
+
* Returning `undefined` means "no translation" and the caller falls back to
|
|
1660
|
+
* its English default. Elements also pass a sentinel `defaultValue`, so a stack
|
|
1661
|
+
* that answers every key with something still reports a real miss.
|
|
1662
|
+
*/
|
|
1663
|
+
export declare type Translate = (key: string, vars?: Record<string, unknown>) => string | undefined;
|
|
1664
|
+
|
|
907
1665
|
/**
|
|
908
1666
|
*
|
|
909
1667
|
* @export
|
|
@@ -923,12 +1681,38 @@ export declare enum UsagePeriod {
|
|
|
923
1681
|
CURRENT_WEEK = "current_week"
|
|
924
1682
|
}
|
|
925
1683
|
|
|
1684
|
+
export declare function useBillingDataSource(): BillingDataSource;
|
|
1685
|
+
|
|
1686
|
+
/** Reloads every loaded billing resource (after a plan change, for instance). */
|
|
1687
|
+
export declare function useInvalidateBillingData(): () => void;
|
|
1688
|
+
|
|
1689
|
+
/**
|
|
1690
|
+
* The invoice list for `query`. Each distinct query is its own list with its
|
|
1691
|
+
* own paging; an inline object literal is fine, the hook keys by value.
|
|
1692
|
+
*/
|
|
1693
|
+
export declare function useInvoices(query?: InvoiceQuery): InvoicesHandle;
|
|
1694
|
+
|
|
926
1695
|
export declare const useSchematic: () => SchematicContextProps;
|
|
927
1696
|
|
|
928
1697
|
export declare const useSchematicContext: (opts?: SchematicHookOpts) => {
|
|
929
1698
|
setContext: (context: SchematicJS.SchematicContext) => Promise<void>;
|
|
930
1699
|
};
|
|
931
1700
|
|
|
1701
|
+
/**
|
|
1702
|
+
* Returns a company's live, lease-aware credit balance for a single credit type.
|
|
1703
|
+
*
|
|
1704
|
+
* Surfaces the spendable `settled` balance, sourced from the streamed
|
|
1705
|
+
* `credit_balances` map (keyed by credit ID). It re-renders as partials arrive
|
|
1706
|
+
* over the DataStream, so it stays accurate during an open lease — when the raw
|
|
1707
|
+
* `remaining` would otherwise read stale / falsely "exhausted".
|
|
1708
|
+
*
|
|
1709
|
+
* `creditId` accepts `undefined` so it can be fed straight from an
|
|
1710
|
+
* entitlement's `creditId`, which is undefined until the check arrives and for
|
|
1711
|
+
* features that are not credit-based. While the ID is undefined the hook
|
|
1712
|
+
* reports the client's loading state and a balance of 0.
|
|
1713
|
+
*/
|
|
1714
|
+
export declare const useSchematicCreditBalance: (creditId: string | undefined, opts?: SchematicHookOpts) => SchematicCreditBalance;
|
|
1715
|
+
|
|
932
1716
|
export declare const useSchematicEntitlement: (key: string, opts?: UseSchematicFlagOpts) => SchematicJS.CheckFlagReturn;
|
|
933
1717
|
|
|
934
1718
|
export declare const useSchematicEvents: (opts?: SchematicHookOpts) => {
|
|
@@ -942,12 +1726,53 @@ export declare type UseSchematicFlagOpts = SchematicHookOpts & {
|
|
|
942
1726
|
fallback?: boolean;
|
|
943
1727
|
};
|
|
944
1728
|
|
|
1729
|
+
/** Empty, never undefined, outside a provider. */
|
|
1730
|
+
export declare function useSchematicI18n(): SchematicI18nConfig;
|
|
1731
|
+
|
|
945
1732
|
export declare const useSchematicIsPending: (opts?: SchematicHookOpts) => boolean;
|
|
946
1733
|
|
|
1734
|
+
/** Unresolved: elements call `useResolvedLocale`, which applies the fallback. */
|
|
1735
|
+
export declare function useSchematicLocale(): string | undefined;
|
|
1736
|
+
|
|
947
1737
|
export declare const useSchematicPlan: (opts?: UseSchematicPlanOpts) => SchematicJS.CheckPlanReturn | undefined;
|
|
948
1738
|
|
|
949
1739
|
export declare type UseSchematicPlanOpts = SchematicHookOpts & {
|
|
950
1740
|
fallback?: SchematicJS.CheckPlanReturn;
|
|
951
1741
|
};
|
|
952
1742
|
|
|
1743
|
+
export declare function useSchematicStrings(): StringOverrides | undefined;
|
|
1744
|
+
|
|
1745
|
+
export declare function useSchematicTranslate(): Translate | undefined;
|
|
1746
|
+
|
|
1747
|
+
/**
|
|
1748
|
+
* Schematic API
|
|
1749
|
+
* Schematic API
|
|
1750
|
+
*
|
|
1751
|
+
* The version of the OpenAPI document: 0.1
|
|
1752
|
+
*
|
|
1753
|
+
*
|
|
1754
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
1755
|
+
* https://openapi-generator.tech
|
|
1756
|
+
* Do not edit the class manually.
|
|
1757
|
+
*/
|
|
1758
|
+
/**
|
|
1759
|
+
*
|
|
1760
|
+
* @export
|
|
1761
|
+
* @interface WarningTier
|
|
1762
|
+
*/
|
|
1763
|
+
declare interface WarningTier {
|
|
1764
|
+
/**
|
|
1765
|
+
* A customer-defined identifier for the warning tier
|
|
1766
|
+
* @type {string}
|
|
1767
|
+
* @memberof WarningTier
|
|
1768
|
+
*/
|
|
1769
|
+
key: string;
|
|
1770
|
+
/**
|
|
1771
|
+
* The warning threshold, in the entitlement's usage units
|
|
1772
|
+
* @type {number}
|
|
1773
|
+
* @memberof WarningTier
|
|
1774
|
+
*/
|
|
1775
|
+
value: number;
|
|
1776
|
+
}
|
|
1777
|
+
|
|
953
1778
|
export { }
|