@schematichq/schematic-vue 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 +108 -1
- package/dist/schematic-vue.cjs.js +1077 -43
- package/dist/schematic-vue.d.ts +853 -24
- package/dist/schematic-vue.esm.js +1085 -44
- package/package.json +23 -26
package/dist/schematic-vue.d.ts
CHANGED
|
@@ -1,9 +1,165 @@
|
|
|
1
1
|
import { App } from 'vue';
|
|
2
2
|
import { ComputedRef } from 'vue';
|
|
3
|
+
import { MaybeRefOrGetter } from 'vue';
|
|
3
4
|
import { Ref } from 'vue';
|
|
4
5
|
|
|
6
|
+
declare type AccessToken = string | AccessTokenProvider;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The machinery every temporary-access-token surface shares: which session is
|
|
10
|
+
* being read, the credential for it, and the request that carries it. It
|
|
11
|
+
* knows nothing about invoices, subscriptions, or checkout — a domain client
|
|
12
|
+
* (see `SchematicBillingClient`) is constructed over it, and several may
|
|
13
|
+
* share one session rather than each minting tokens of its own.
|
|
14
|
+
*/
|
|
15
|
+
/** Called once per session, and again when a request comes back 401. */
|
|
16
|
+
declare type AccessTokenProvider = () => Promise<string | AccessTokenResult>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A bare token, or one that says when it expires and who it was minted for.
|
|
20
|
+
* `company`/`user` are the host restating the pair it asked for; stated, they
|
|
21
|
+
* are checked against the session the resolution was started for.
|
|
22
|
+
*/
|
|
23
|
+
declare interface AccessTokenResult {
|
|
24
|
+
token: string;
|
|
25
|
+
expiresAt?: Date | string | null;
|
|
26
|
+
company?: string;
|
|
27
|
+
user?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
5
30
|
declare type BaseSchematicPluginOptions = Omit<SchematicJS.SchematicOptions, "client" | "publishableKey">;
|
|
6
31
|
|
|
32
|
+
declare namespace billingApi {
|
|
33
|
+
export {
|
|
34
|
+
instanceOfApiError,
|
|
35
|
+
ApiErrorFromJSON,
|
|
36
|
+
ApiErrorFromJSONTyped,
|
|
37
|
+
ApiErrorToJSON,
|
|
38
|
+
ApiErrorToJSONTyped,
|
|
39
|
+
ApiError,
|
|
40
|
+
instanceOfCompanyDiscountResponseData,
|
|
41
|
+
CompanyDiscountResponseDataFromJSON,
|
|
42
|
+
CompanyDiscountResponseDataFromJSONTyped,
|
|
43
|
+
CompanyDiscountResponseDataToJSON,
|
|
44
|
+
CompanyDiscountResponseDataToJSONTyped,
|
|
45
|
+
CompanyDiscountResponseData,
|
|
46
|
+
instanceOfCompanyInvoiceResponseData,
|
|
47
|
+
CompanyInvoiceResponseDataFromJSON,
|
|
48
|
+
CompanyInvoiceResponseDataFromJSONTyped,
|
|
49
|
+
CompanyInvoiceResponseDataToJSON,
|
|
50
|
+
CompanyInvoiceResponseDataToJSONTyped,
|
|
51
|
+
CompanyInvoiceResponseData,
|
|
52
|
+
instanceOfCompanyInvoicesResponseData,
|
|
53
|
+
CompanyInvoicesResponseDataFromJSON,
|
|
54
|
+
CompanyInvoicesResponseDataFromJSONTyped,
|
|
55
|
+
CompanyInvoicesResponseDataToJSON,
|
|
56
|
+
CompanyInvoicesResponseDataToJSONTyped,
|
|
57
|
+
CompanyInvoicesResponseData,
|
|
58
|
+
instanceOfCompanyUpcomingInvoiceResponseData,
|
|
59
|
+
CompanyUpcomingInvoiceResponseDataFromJSON,
|
|
60
|
+
CompanyUpcomingInvoiceResponseDataFromJSONTyped,
|
|
61
|
+
CompanyUpcomingInvoiceResponseDataToJSON,
|
|
62
|
+
CompanyUpcomingInvoiceResponseDataToJSONTyped,
|
|
63
|
+
CompanyUpcomingInvoiceResponseData,
|
|
64
|
+
instanceOfGetCompanyInvoicesParams,
|
|
65
|
+
GetCompanyInvoicesParamsFromJSON,
|
|
66
|
+
GetCompanyInvoicesParamsFromJSONTyped,
|
|
67
|
+
GetCompanyInvoicesParamsToJSON,
|
|
68
|
+
GetCompanyInvoicesParamsToJSONTyped,
|
|
69
|
+
GetCompanyInvoicesParams,
|
|
70
|
+
instanceOfGetCompanyInvoicesResponse,
|
|
71
|
+
GetCompanyInvoicesResponseFromJSON,
|
|
72
|
+
GetCompanyInvoicesResponseFromJSONTyped,
|
|
73
|
+
GetCompanyInvoicesResponseToJSON,
|
|
74
|
+
GetCompanyInvoicesResponseToJSONTyped,
|
|
75
|
+
GetCompanyInvoicesResponse,
|
|
76
|
+
instanceOfGetCompanyUpcomingInvoiceResponse,
|
|
77
|
+
GetCompanyUpcomingInvoiceResponseFromJSON,
|
|
78
|
+
GetCompanyUpcomingInvoiceResponseFromJSONTyped,
|
|
79
|
+
GetCompanyUpcomingInvoiceResponseToJSON,
|
|
80
|
+
GetCompanyUpcomingInvoiceResponseToJSONTyped,
|
|
81
|
+
GetCompanyUpcomingInvoiceResponse,
|
|
82
|
+
instanceOfInvoiceStatus,
|
|
83
|
+
InvoiceStatusFromJSON,
|
|
84
|
+
InvoiceStatusFromJSONTyped,
|
|
85
|
+
InvoiceStatusToJSON,
|
|
86
|
+
InvoiceStatusToJSONTyped,
|
|
87
|
+
InvoiceStatus
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* What a reader of billing data can ask for. Subscription and usage — the
|
|
93
|
+
* rest of what `hydrate` serves — and the checkout calls that change them
|
|
94
|
+
* join this interface as their endpoints ship.
|
|
95
|
+
*/
|
|
96
|
+
declare interface BillingClient {
|
|
97
|
+
fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
|
|
98
|
+
/** `null` when the company has no next bill. */
|
|
99
|
+
fetchUpcomingInvoice(): Promise<UpcomingInvoice | null>;
|
|
100
|
+
readonly sessionStatus: SessionStatus;
|
|
101
|
+
readonly sessionKey: string | undefined;
|
|
102
|
+
setSession(session: SessionInput): void;
|
|
103
|
+
onSessionChange(listener: (event: SessionEvent) => void): () => void;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
declare type BillingClientOptions = SessionOptions;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* A prefetch or fixture. An omitted key reports as pending; a keyed resource
|
|
110
|
+
* seeds under `params`, or its defaults when absent, so a prefetch for a
|
|
111
|
+
* non-default query is claimed rather than refetched by the element.
|
|
112
|
+
*/
|
|
113
|
+
declare type BillingData = {
|
|
114
|
+
[K in BillingResourceName]?: BillingResources[K];
|
|
115
|
+
} & {
|
|
116
|
+
params?: Partial<BillingResourceParams>;
|
|
117
|
+
/**
|
|
118
|
+
* A prefetch outlives the render that made it — a cached page, a session
|
|
119
|
+
* resolving to somebody else — so a store adopts it only for the session
|
|
120
|
+
* it names. `fetchBillingData` fills it in; a fixture need not.
|
|
121
|
+
*/
|
|
122
|
+
sessionKey?: string;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
declare interface BillingPrefetchOptions {
|
|
126
|
+
/**
|
|
127
|
+
* The resources the page renders, and no default: each one is a request
|
|
128
|
+
* on the server — the upcoming invoice is a live provider preview — and
|
|
129
|
+
* the list grows with every element, so a page names what it needs rather
|
|
130
|
+
* than paying for everything.
|
|
131
|
+
*/
|
|
132
|
+
names: BillingResourceName[];
|
|
133
|
+
/** The invoice query to prefetch for; the element must ask the same one. */
|
|
134
|
+
invoices?: InvoiceQuery;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
declare type BillingResourceName = keyof BillingResources;
|
|
138
|
+
|
|
139
|
+
/** `Record<string, never>` marks a singleton; anything else is keyed. */
|
|
140
|
+
declare interface BillingResourceParams {
|
|
141
|
+
invoices: InvoiceQuery;
|
|
142
|
+
upcomingInvoice: Record<string, never>;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Nothing in the store, the hooks, or the resource keys may be addressed by
|
|
147
|
+
* company or user id: users and companies are many-to-many, and a token names
|
|
148
|
+
* the pair. What is loaded belongs to the session it was read under — the
|
|
149
|
+
* pair, as `sessionKey` writes it — and a store that keeps more than one
|
|
150
|
+
* session's data keys it by that and serves only the active one.
|
|
151
|
+
*/
|
|
152
|
+
declare interface BillingResources {
|
|
153
|
+
/** `GET /company/invoices?limit&offset&include_pending`. */
|
|
154
|
+
invoices: InvoicePage;
|
|
155
|
+
/**
|
|
156
|
+
* `GET /company/upcoming-invoice`. `null` is a loaded value — the company
|
|
157
|
+
* has no next bill, which the endpoint reports as a 204 — so only
|
|
158
|
+
* `undefined` means the resource has not loaded.
|
|
159
|
+
*/
|
|
160
|
+
upcomingInvoice: UpcomingInvoice | null;
|
|
161
|
+
}
|
|
162
|
+
|
|
7
163
|
declare type BooleanListenerFn = (value: boolean) => void;
|
|
8
164
|
|
|
9
165
|
/**
|
|
@@ -73,11 +229,11 @@ declare interface CheckFlagResponseData {
|
|
|
73
229
|
featureUsageEvent?: string | null;
|
|
74
230
|
/**
|
|
75
231
|
* Deprecated: Use Entitlement.MetricPeriod instead.
|
|
76
|
-
* @type {
|
|
232
|
+
* @type {MetricPeriod}
|
|
77
233
|
* @memberof CheckFlagResponseData
|
|
78
234
|
* @deprecated
|
|
79
235
|
*/
|
|
80
|
-
featureUsagePeriod?:
|
|
236
|
+
featureUsagePeriod?: MetricPeriod | null;
|
|
81
237
|
/**
|
|
82
238
|
* Deprecated: Use Entitlement.MetricResetAt instead.
|
|
83
239
|
* @type {Date}
|
|
@@ -111,10 +267,10 @@ declare interface CheckFlagResponseData {
|
|
|
111
267
|
ruleId?: string | null;
|
|
112
268
|
/**
|
|
113
269
|
* If a rule was found, its type
|
|
114
|
-
* @type {
|
|
270
|
+
* @type {RuleType}
|
|
115
271
|
* @memberof CheckFlagResponseData
|
|
116
272
|
*/
|
|
117
|
-
ruleType?:
|
|
273
|
+
ruleType?: RuleType_2 | null;
|
|
118
274
|
/**
|
|
119
275
|
* If user keys were provided and matched a user, its ID
|
|
120
276
|
* @type {string}
|
|
@@ -136,8 +292,14 @@ export declare type CheckFlagReturn = {
|
|
|
136
292
|
featureUsageExceeded?: boolean;
|
|
137
293
|
/** If company keys were provided and matched a company, its ID */
|
|
138
294
|
companyId?: string;
|
|
139
|
-
/** If the company has a credit-based entitlement for this feature, the
|
|
295
|
+
/** If the company has a credit-based entitlement for this feature, the ID of the credit */
|
|
296
|
+
creditId?: string;
|
|
297
|
+
/** 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
298
|
creditRemaining?: number;
|
|
299
|
+
/** 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 */
|
|
300
|
+
creditReserved?: number;
|
|
301
|
+
/** 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 */
|
|
302
|
+
creditSettled?: number;
|
|
141
303
|
/** If an error occurred while checking the flag, the error message */
|
|
142
304
|
error?: string;
|
|
143
305
|
/** If a numeric feature entitlement rule was matched, its allocation */
|
|
@@ -166,6 +328,8 @@ export declare type CheckFlagReturn = {
|
|
|
166
328
|
userId?: string;
|
|
167
329
|
/** A boolean flag check result; for feature entitlements, this represents whether further consumption of the feature is permitted */
|
|
168
330
|
value: boolean;
|
|
331
|
+
/** Customer-defined usage warning thresholds configured on this entitlement */
|
|
332
|
+
warningTiers?: WarningTier[];
|
|
169
333
|
};
|
|
170
334
|
|
|
171
335
|
declare const CheckFlagReturnFromJSON: (json: any) => CheckFlagReturn;
|
|
@@ -198,6 +362,14 @@ declare interface CheckFlagsResponse {
|
|
|
198
362
|
* @interface CheckFlagsResponseData
|
|
199
363
|
*/
|
|
200
364
|
declare interface CheckFlagsResponseData {
|
|
365
|
+
/**
|
|
366
|
+
* Lease-aware credit balances keyed by credit ID, covering every credit type the company holds a balance in
|
|
367
|
+
* @type {{ [key: string]: CompanyCreditBalance; }}
|
|
368
|
+
* @memberof CheckFlagsResponseData
|
|
369
|
+
*/
|
|
370
|
+
creditBalances?: {
|
|
371
|
+
[key: string]: CompanyCreditBalance;
|
|
372
|
+
};
|
|
201
373
|
/**
|
|
202
374
|
*
|
|
203
375
|
* @type {Array<CheckFlagResponseData>}
|
|
@@ -231,6 +403,223 @@ declare const CheckPlanReturnFromJSON: (json: any) => CheckPlanReturn;
|
|
|
231
403
|
|
|
232
404
|
declare type CheckPlanReturnListenerFn = (value: CheckPlanReturn) => void;
|
|
233
405
|
|
|
406
|
+
/**
|
|
407
|
+
* Schematic API
|
|
408
|
+
* Schematic API
|
|
409
|
+
*
|
|
410
|
+
* The version of the OpenAPI document: 0.1
|
|
411
|
+
*
|
|
412
|
+
*
|
|
413
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
414
|
+
* https://openapi-generator.tech
|
|
415
|
+
* Do not edit the class manually.
|
|
416
|
+
*/
|
|
417
|
+
/**
|
|
418
|
+
*
|
|
419
|
+
* @export
|
|
420
|
+
* @interface CompanyCreditBalance
|
|
421
|
+
*/
|
|
422
|
+
export declare interface CompanyCreditBalance {
|
|
423
|
+
/**
|
|
424
|
+
* Remaining credit, excluding any open lease hold (the value SDKs gate on)
|
|
425
|
+
* @type {number}
|
|
426
|
+
* @memberof CompanyCreditBalance
|
|
427
|
+
*/
|
|
428
|
+
remaining: number;
|
|
429
|
+
/**
|
|
430
|
+
* Amount held by the company's open credit lease, 0 when none is open
|
|
431
|
+
* @type {number}
|
|
432
|
+
* @memberof CompanyCreditBalance
|
|
433
|
+
*/
|
|
434
|
+
reserved: number;
|
|
435
|
+
/**
|
|
436
|
+
* Spendable balance including the open lease hold (remaining + reserved)
|
|
437
|
+
* @type {number}
|
|
438
|
+
* @memberof CompanyCreditBalance
|
|
439
|
+
*/
|
|
440
|
+
settled: number;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Schematic API
|
|
445
|
+
* Schematic API
|
|
446
|
+
*
|
|
447
|
+
* The version of the OpenAPI document: 0.1
|
|
448
|
+
*
|
|
449
|
+
*
|
|
450
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
451
|
+
* https://openapi-generator.tech
|
|
452
|
+
* Do not edit the class manually.
|
|
453
|
+
*/
|
|
454
|
+
/**
|
|
455
|
+
*
|
|
456
|
+
* @export
|
|
457
|
+
* @interface CompanyDiscountResponseData
|
|
458
|
+
*/
|
|
459
|
+
declare interface CompanyDiscountResponseData {
|
|
460
|
+
/**
|
|
461
|
+
*
|
|
462
|
+
* @type {number}
|
|
463
|
+
* @memberof CompanyDiscountResponseData
|
|
464
|
+
*/
|
|
465
|
+
amountOff?: number | null;
|
|
466
|
+
/**
|
|
467
|
+
*
|
|
468
|
+
* @type {string}
|
|
469
|
+
* @memberof CompanyDiscountResponseData
|
|
470
|
+
*/
|
|
471
|
+
couponName: string;
|
|
472
|
+
/**
|
|
473
|
+
*
|
|
474
|
+
* @type {string}
|
|
475
|
+
* @memberof CompanyDiscountResponseData
|
|
476
|
+
*/
|
|
477
|
+
currency?: string | null;
|
|
478
|
+
/**
|
|
479
|
+
*
|
|
480
|
+
* @type {string}
|
|
481
|
+
* @memberof CompanyDiscountResponseData
|
|
482
|
+
*/
|
|
483
|
+
customerFacingCode?: string | null;
|
|
484
|
+
/**
|
|
485
|
+
* Provider vocabulary: once, repeating, or forever.
|
|
486
|
+
* @type {string}
|
|
487
|
+
* @memberof CompanyDiscountResponseData
|
|
488
|
+
*/
|
|
489
|
+
duration: string;
|
|
490
|
+
/**
|
|
491
|
+
*
|
|
492
|
+
* @type {number}
|
|
493
|
+
* @memberof CompanyDiscountResponseData
|
|
494
|
+
*/
|
|
495
|
+
durationInMonths?: number | null;
|
|
496
|
+
/**
|
|
497
|
+
*
|
|
498
|
+
* @type {number}
|
|
499
|
+
* @memberof CompanyDiscountResponseData
|
|
500
|
+
*/
|
|
501
|
+
percentOff?: number | null;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
*
|
|
506
|
+
* @export
|
|
507
|
+
* @interface CompanyInvoiceResponseData
|
|
508
|
+
*/
|
|
509
|
+
declare interface CompanyInvoiceResponseData {
|
|
510
|
+
/**
|
|
511
|
+
*
|
|
512
|
+
* @type {number}
|
|
513
|
+
* @memberof CompanyInvoiceResponseData
|
|
514
|
+
*/
|
|
515
|
+
amountDue: number;
|
|
516
|
+
/**
|
|
517
|
+
*
|
|
518
|
+
* @type {Date}
|
|
519
|
+
* @memberof CompanyInvoiceResponseData
|
|
520
|
+
*/
|
|
521
|
+
createdAt: Date;
|
|
522
|
+
/**
|
|
523
|
+
*
|
|
524
|
+
* @type {string}
|
|
525
|
+
* @memberof CompanyInvoiceResponseData
|
|
526
|
+
*/
|
|
527
|
+
currency: string;
|
|
528
|
+
/**
|
|
529
|
+
*
|
|
530
|
+
* @type {Date}
|
|
531
|
+
* @memberof CompanyInvoiceResponseData
|
|
532
|
+
*/
|
|
533
|
+
dueDate?: Date | null;
|
|
534
|
+
/**
|
|
535
|
+
*
|
|
536
|
+
* @type {string}
|
|
537
|
+
* @memberof CompanyInvoiceResponseData
|
|
538
|
+
*/
|
|
539
|
+
id: string;
|
|
540
|
+
/**
|
|
541
|
+
*
|
|
542
|
+
* @type {InvoiceStatus}
|
|
543
|
+
* @memberof CompanyInvoiceResponseData
|
|
544
|
+
*/
|
|
545
|
+
status?: InvoiceStatus | null;
|
|
546
|
+
/**
|
|
547
|
+
*
|
|
548
|
+
* @type {string}
|
|
549
|
+
* @memberof CompanyInvoiceResponseData
|
|
550
|
+
*/
|
|
551
|
+
url?: string | null;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
/**
|
|
555
|
+
*
|
|
556
|
+
* @export
|
|
557
|
+
* @interface CompanyUpcomingInvoiceResponseData
|
|
558
|
+
*/
|
|
559
|
+
declare interface CompanyUpcomingInvoiceResponseData {
|
|
560
|
+
/**
|
|
561
|
+
*
|
|
562
|
+
* @type {number}
|
|
563
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
564
|
+
*/
|
|
565
|
+
amountDue: number;
|
|
566
|
+
/**
|
|
567
|
+
*
|
|
568
|
+
* @type {string}
|
|
569
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
570
|
+
*/
|
|
571
|
+
currency: string;
|
|
572
|
+
/**
|
|
573
|
+
* How much of the company's existing balance this invoice consumes.
|
|
574
|
+
* @type {number}
|
|
575
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
576
|
+
*/
|
|
577
|
+
customerBalanceApplied: number;
|
|
578
|
+
/**
|
|
579
|
+
* Balance left over after this invoice.
|
|
580
|
+
* @type {number}
|
|
581
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
582
|
+
*/
|
|
583
|
+
customerBalanceRemaining: number;
|
|
584
|
+
/**
|
|
585
|
+
* Only active discounts that reduce the bill.
|
|
586
|
+
* @type {Array<CompanyDiscountResponseData>}
|
|
587
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
588
|
+
*/
|
|
589
|
+
discounts: Array<CompanyDiscountResponseData>;
|
|
590
|
+
/**
|
|
591
|
+
*
|
|
592
|
+
* @type {Date}
|
|
593
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
594
|
+
*/
|
|
595
|
+
dueDate?: Date | null;
|
|
596
|
+
/**
|
|
597
|
+
* Amount before discounts and tax.
|
|
598
|
+
* @type {number}
|
|
599
|
+
* @memberof CompanyUpcomingInvoiceResponseData
|
|
600
|
+
*/
|
|
601
|
+
subtotal: number;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/** A company's lease-aware balance for a single credit type */
|
|
605
|
+
export declare type CreditBalance = {
|
|
606
|
+
/** Spendable balance including any open lease hold (remaining + reserved); the number to display to end users */
|
|
607
|
+
settled: number;
|
|
608
|
+
/** Remaining credit excluding any open lease hold (the value lease-holding SDKs gate on) */
|
|
609
|
+
remaining: number;
|
|
610
|
+
/** Amount held by the company's open credit lease, 0 when none is open */
|
|
611
|
+
reserved: number;
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
declare type CreditBalanceListenerFn = CreditBalancesListenerFn | EmptyListenerFn;
|
|
615
|
+
|
|
616
|
+
/** A company's lease-aware credit balances keyed by credit ID */
|
|
617
|
+
export declare type CreditBalances = Record<string, CreditBalance>;
|
|
618
|
+
|
|
619
|
+
declare const CreditBalancesFromJSON: (json: any) => CreditBalances;
|
|
620
|
+
|
|
621
|
+
declare type CreditBalancesListenerFn = (value: CreditBalances) => void;
|
|
622
|
+
|
|
234
623
|
/**
|
|
235
624
|
*
|
|
236
625
|
* @export
|
|
@@ -265,6 +654,10 @@ declare interface DatastreamCompanyPlan {
|
|
|
265
654
|
|
|
266
655
|
declare function DatastreamCompanyPlanFromJSON(json: any): DatastreamCompanyPlan;
|
|
267
656
|
|
|
657
|
+
declare const DEFAULT_INVOICE_QUERY: InvoiceQuery;
|
|
658
|
+
|
|
659
|
+
declare type Discount = CompanyDiscountResponseData;
|
|
660
|
+
|
|
268
661
|
declare type EmptyListenerFn = () => void;
|
|
269
662
|
|
|
270
663
|
/**
|
|
@@ -337,6 +730,12 @@ declare interface EventBodyFlagCheck {
|
|
|
337
730
|
* @memberof EventBodyFlagCheck
|
|
338
731
|
*/
|
|
339
732
|
flagKey: string;
|
|
733
|
+
/**
|
|
734
|
+
* Whether the check was a preflight, asking whether an action would be allowed rather than reporting one that happened. Absent on ordinary checks
|
|
735
|
+
* @type {boolean}
|
|
736
|
+
* @memberof EventBodyFlagCheck
|
|
737
|
+
*/
|
|
738
|
+
preflight?: boolean;
|
|
340
739
|
/**
|
|
341
740
|
* The reason why the value was returned
|
|
342
741
|
* @type {string}
|
|
@@ -412,6 +811,12 @@ declare interface FeatureEntitlement {
|
|
|
412
811
|
* @memberof FeatureEntitlement
|
|
413
812
|
*/
|
|
414
813
|
allocation?: number | null;
|
|
814
|
+
/**
|
|
815
|
+
* If the company has a credit-based entitlement for this feature, the credit cost per unit of usage
|
|
816
|
+
* @type {number}
|
|
817
|
+
* @memberof FeatureEntitlement
|
|
818
|
+
*/
|
|
819
|
+
consumptionRate?: number | null;
|
|
415
820
|
/**
|
|
416
821
|
* If the company has a credit-based entitlement for this feature, the ID of the credit
|
|
417
822
|
* @type {string}
|
|
@@ -419,11 +824,23 @@ declare interface FeatureEntitlement {
|
|
|
419
824
|
*/
|
|
420
825
|
creditId?: string | null;
|
|
421
826
|
/**
|
|
422
|
-
* If the company has a credit-based entitlement for this feature, the
|
|
827
|
+
* 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
828
|
* @type {number}
|
|
424
829
|
* @memberof FeatureEntitlement
|
|
425
830
|
*/
|
|
426
831
|
creditRemaining?: number | null;
|
|
832
|
+
/**
|
|
833
|
+
* 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
|
|
834
|
+
* @type {number}
|
|
835
|
+
* @memberof FeatureEntitlement
|
|
836
|
+
*/
|
|
837
|
+
creditReserved?: number | null;
|
|
838
|
+
/**
|
|
839
|
+
* 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
|
|
840
|
+
* @type {number}
|
|
841
|
+
* @memberof FeatureEntitlement
|
|
842
|
+
*/
|
|
843
|
+
creditSettled?: number | null;
|
|
427
844
|
/**
|
|
428
845
|
* If the company has a credit-based entitlement for this feature, the total credit amount
|
|
429
846
|
* @type {number}
|
|
@@ -442,6 +859,12 @@ declare interface FeatureEntitlement {
|
|
|
442
859
|
* @memberof FeatureEntitlement
|
|
443
860
|
*/
|
|
444
861
|
eventName?: string | null;
|
|
862
|
+
/**
|
|
863
|
+
* For event-based or credit-metered feature entitlements, the event subtype whose usage is tracked
|
|
864
|
+
* @type {string}
|
|
865
|
+
* @memberof FeatureEntitlement
|
|
866
|
+
*/
|
|
867
|
+
eventSubtype?: string | null;
|
|
445
868
|
/**
|
|
446
869
|
* The ID of the feature
|
|
447
870
|
* @type {string}
|
|
@@ -456,10 +879,10 @@ declare interface FeatureEntitlement {
|
|
|
456
879
|
featureKey: string;
|
|
457
880
|
/**
|
|
458
881
|
* For event-based feature entitlements, the period over which usage is tracked
|
|
459
|
-
* @type {
|
|
882
|
+
* @type {MetricPeriod}
|
|
460
883
|
* @memberof FeatureEntitlement
|
|
461
884
|
*/
|
|
462
|
-
metricPeriod?:
|
|
885
|
+
metricPeriod?: MetricPeriod | null;
|
|
463
886
|
/**
|
|
464
887
|
* For event-based feature entitlements, when the usage period will reset
|
|
465
888
|
* @type {Date}
|
|
@@ -468,10 +891,10 @@ declare interface FeatureEntitlement {
|
|
|
468
891
|
metricResetAt?: Date | null;
|
|
469
892
|
/**
|
|
470
893
|
* 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 {
|
|
894
|
+
* @type {MetricPeriodMonthReset}
|
|
472
895
|
* @memberof FeatureEntitlement
|
|
473
896
|
*/
|
|
474
|
-
monthReset?:
|
|
897
|
+
monthReset?: MetricPeriodMonthReset | null;
|
|
475
898
|
/**
|
|
476
899
|
* For usage-based pricing, the soft limit for overage charges or the next tier boundary
|
|
477
900
|
* @type {number}
|
|
@@ -490,41 +913,129 @@ declare interface FeatureEntitlement {
|
|
|
490
913
|
* @memberof FeatureEntitlement
|
|
491
914
|
*/
|
|
492
915
|
valueType: EntitlementValueType;
|
|
916
|
+
/**
|
|
917
|
+
* Customer-defined usage warning thresholds configured on this entitlement
|
|
918
|
+
* @type {Array<WarningTier>}
|
|
919
|
+
* @memberof FeatureEntitlement
|
|
920
|
+
*/
|
|
921
|
+
warningTiers?: Array<WarningTier>;
|
|
493
922
|
}
|
|
494
923
|
|
|
495
924
|
/**
|
|
925
|
+
* Server prefetch for a provider's `initialData`. A resource that fails is
|
|
926
|
+
* left out rather than thrown, so one of them cannot block a page.
|
|
927
|
+
*/
|
|
928
|
+
declare function fetchBillingData(client: BillingClient, options: BillingPrefetchOptions): Promise<BillingData>;
|
|
929
|
+
|
|
930
|
+
declare type FlagCheckListenerFn = CheckFlagReturnListenerFn | EmptyListenerFn;
|
|
931
|
+
|
|
932
|
+
declare type FlagValueListenerFn = BooleanListenerFn | EmptyListenerFn;
|
|
933
|
+
|
|
934
|
+
declare type Invoice = CompanyInvoiceResponseData;
|
|
935
|
+
|
|
936
|
+
/** A `limit` above this is a 400 (PaginationFilter in schematic-api). */
|
|
937
|
+
declare const INVOICE_MAX_PAGE_SIZE = 250;
|
|
938
|
+
|
|
939
|
+
declare const INVOICE_PAGE_SIZE = 12;
|
|
940
|
+
|
|
941
|
+
declare interface InvoicePage {
|
|
942
|
+
invoices: Invoice[];
|
|
943
|
+
/** Matching the query on the server, not the number loaded here. */
|
|
944
|
+
count: number;
|
|
945
|
+
hasMore: boolean;
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
/** Each distinct query is its own row set with its own paging. */
|
|
949
|
+
declare interface InvoiceQuery {
|
|
950
|
+
/** Include unpaid invoices that are not yet due. Default false. */
|
|
951
|
+
includePending?: boolean;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
declare interface InvoicesRequest extends InvoiceQuery {
|
|
955
|
+
limit: number;
|
|
956
|
+
offset: number;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/**
|
|
960
|
+
* The rows asked for, and how many the query matches in total. `hasMore` is
|
|
961
|
+
* the page's, and only the caller knows its offset.
|
|
962
|
+
*/
|
|
963
|
+
declare type InvoicesResult = Omit<InvoicePage, "hasMore">;
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
*
|
|
967
|
+
* @export
|
|
968
|
+
*/
|
|
969
|
+
declare const InvoiceStatus: {
|
|
970
|
+
readonly Draft: "draft";
|
|
971
|
+
readonly Open: "open";
|
|
972
|
+
readonly Paid: "paid";
|
|
973
|
+
readonly Uncollectible: "uncollectible";
|
|
974
|
+
readonly Void: "void";
|
|
975
|
+
};
|
|
976
|
+
|
|
977
|
+
declare type InvoiceStatus = (typeof InvoiceStatus)[keyof typeof InvoiceStatus];
|
|
978
|
+
|
|
979
|
+
/** A record of unique key-value pairs used for identifying a company or user */
|
|
980
|
+
export declare type Keys = Record<string, string>;
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
*
|
|
496
984
|
* @export
|
|
497
985
|
*/
|
|
498
|
-
declare const
|
|
986
|
+
declare const MetricPeriod: {
|
|
499
987
|
readonly AllTime: "all_time";
|
|
500
988
|
readonly CurrentDay: "current_day";
|
|
501
989
|
readonly CurrentMonth: "current_month";
|
|
502
990
|
readonly CurrentWeek: "current_week";
|
|
503
991
|
};
|
|
504
992
|
|
|
505
|
-
declare type
|
|
993
|
+
declare type MetricPeriod = (typeof MetricPeriod)[keyof typeof MetricPeriod];
|
|
506
994
|
|
|
507
995
|
/**
|
|
996
|
+
*
|
|
508
997
|
* @export
|
|
509
998
|
*/
|
|
510
|
-
declare const
|
|
511
|
-
readonly FirstOfMonth: "first_of_month";
|
|
999
|
+
declare const MetricPeriodMonthReset: {
|
|
512
1000
|
readonly BillingCycle: "billing_cycle";
|
|
1001
|
+
readonly FirstOfMonth: "first_of_month";
|
|
513
1002
|
};
|
|
514
1003
|
|
|
515
|
-
declare type
|
|
1004
|
+
declare type MetricPeriodMonthReset = (typeof MetricPeriodMonthReset)[keyof typeof MetricPeriodMonthReset];
|
|
516
1005
|
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
1006
|
+
/**
|
|
1007
|
+
* The store keys a resource by the query's shape, so without this
|
|
1008
|
+
* `{ includePending: false }` is a different row set from `{}` — it would
|
|
1009
|
+
* miss the seed and refetch rows identical to those already on screen.
|
|
1010
|
+
*/
|
|
1011
|
+
declare function normalizeInvoiceQuery(query: InvoiceQuery): InvoiceQuery;
|
|
523
1012
|
|
|
524
1013
|
declare type PendingListenerFn = BooleanListenerFn | EmptyListenerFn;
|
|
525
1014
|
|
|
526
1015
|
declare type PlanListenerFn = CheckPlanReturnListenerFn | EmptyListenerFn;
|
|
527
1016
|
|
|
1017
|
+
declare interface RequestOptions {
|
|
1018
|
+
method?: string;
|
|
1019
|
+
body?: unknown;
|
|
1020
|
+
/**
|
|
1021
|
+
* Success statuses that carry no body — a 204 for a resource that is
|
|
1022
|
+
* legitimately absent. The request resolves `undefined` for them, which
|
|
1023
|
+
* is distinct from a body that parsed to `null`. A 401 is never one — the
|
|
1024
|
+
* refresh and retry run first, and only what comes back from that is
|
|
1025
|
+
* judged.
|
|
1026
|
+
*/
|
|
1027
|
+
noContentOn?: number[];
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
declare interface ResourceState<T> {
|
|
1031
|
+
/** `undefined` until the first successful load; retained across later errors. */
|
|
1032
|
+
data: T | undefined;
|
|
1033
|
+
/** The latest failure; cleared by the next success. */
|
|
1034
|
+
error: Error | undefined;
|
|
1035
|
+
/** A request is in flight and no data has arrived yet, or a refetch is running. */
|
|
1036
|
+
isPending: boolean;
|
|
1037
|
+
}
|
|
1038
|
+
|
|
528
1039
|
export declare enum RuleType {
|
|
529
1040
|
/** A global rule that, if present, will override all other rules for a flag */
|
|
530
1041
|
GLOBAL_OVERRIDE = "global_override",
|
|
@@ -542,10 +1053,26 @@ export declare enum RuleType {
|
|
|
542
1053
|
DEFAULT = "default"
|
|
543
1054
|
}
|
|
544
1055
|
|
|
1056
|
+
/**
|
|
1057
|
+
*
|
|
1058
|
+
* @export
|
|
1059
|
+
*/
|
|
1060
|
+
declare const RuleType_2: {
|
|
1061
|
+
readonly CompanyOverride: "company_override";
|
|
1062
|
+
readonly CompanyOverrideUsageExceeded: "company_override_usage_exceeded";
|
|
1063
|
+
readonly Default: "default";
|
|
1064
|
+
readonly GlobalOverride: "global_override";
|
|
1065
|
+
readonly PlanEntitlement: "plan_entitlement";
|
|
1066
|
+
readonly PlanEntitlementUsageExceeded: "plan_entitlement_usage_exceeded";
|
|
1067
|
+
readonly Standard: "standard";
|
|
1068
|
+
};
|
|
1069
|
+
|
|
1070
|
+
declare type RuleType_2 = (typeof RuleType_2)[keyof typeof RuleType_2];
|
|
1071
|
+
|
|
545
1072
|
export declare class Schematic {
|
|
546
|
-
private
|
|
1073
|
+
private _additionalHeaders;
|
|
547
1074
|
private apiKey;
|
|
548
|
-
private
|
|
1075
|
+
private _apiUrl;
|
|
549
1076
|
private conn;
|
|
550
1077
|
private context;
|
|
551
1078
|
private debugEnabled;
|
|
@@ -558,11 +1085,17 @@ export declare class Schematic {
|
|
|
558
1085
|
private isPending;
|
|
559
1086
|
private isPendingListeners;
|
|
560
1087
|
private planListeners;
|
|
1088
|
+
private creditBalanceListeners;
|
|
561
1089
|
private storage;
|
|
1090
|
+
private persistFlagState;
|
|
1091
|
+
private flagStateCacheKey;
|
|
1092
|
+
private flagStateCacheMaxAgeMs;
|
|
1093
|
+
private cachedFlagState;
|
|
562
1094
|
private useWebSocket;
|
|
563
1095
|
private checks;
|
|
564
1096
|
private featureUsageEventMap;
|
|
565
1097
|
private planChecks;
|
|
1098
|
+
private creditBalances;
|
|
566
1099
|
private webSocketUrl;
|
|
567
1100
|
private webSocketConnectionTimeout;
|
|
568
1101
|
private webSocketReconnect;
|
|
@@ -584,6 +1117,8 @@ export declare class Schematic {
|
|
|
584
1117
|
private flagCheckDefaults;
|
|
585
1118
|
private fallbackCheckCache;
|
|
586
1119
|
constructor(apiKey: string, options?: SchematicOptions);
|
|
1120
|
+
get apiUrl(): string;
|
|
1121
|
+
get additionalHeaders(): Record<string, string>;
|
|
587
1122
|
/**
|
|
588
1123
|
* Resolve fallback value according to priority order:
|
|
589
1124
|
* 1. Callsite fallback value (if provided)
|
|
@@ -669,6 +1204,13 @@ export declare class Schematic {
|
|
|
669
1204
|
private stopRetryTimer;
|
|
670
1205
|
private flushEventQueue;
|
|
671
1206
|
private getAnonymousId;
|
|
1207
|
+
private hasCachedValuesForContext;
|
|
1208
|
+
private readFlagStateCache;
|
|
1209
|
+
private reviveCachedCheck;
|
|
1210
|
+
private reviveCachedPlan;
|
|
1211
|
+
private reviveCachedCreditBalances;
|
|
1212
|
+
private hydrateFlagStateFromCache;
|
|
1213
|
+
private persistContextToCache;
|
|
672
1214
|
private handleEvent;
|
|
673
1215
|
private sendEvent;
|
|
674
1216
|
private storeEvent;
|
|
@@ -768,6 +1310,10 @@ export declare class Schematic {
|
|
|
768
1310
|
addIsPendingListener: (listener: PendingListenerFn) => () => void;
|
|
769
1311
|
private setIsPending;
|
|
770
1312
|
getPlan: () => CheckPlanReturn | undefined;
|
|
1313
|
+
/** Get the company's lease-aware credit balances for the current context, keyed by credit ID */
|
|
1314
|
+
getCreditBalances: () => CreditBalances;
|
|
1315
|
+
/** Get the company's lease-aware balance for a single credit type in the current context */
|
|
1316
|
+
getCreditBalance: (creditId: string) => CreditBalance | undefined;
|
|
771
1317
|
getFlagCheck: (flagKey: string) => CheckFlagReturn | undefined;
|
|
772
1318
|
getFlagValue: (flagKey: string) => boolean | undefined;
|
|
773
1319
|
/** Register an event listener that will be notified with the boolean value for a given flag when this value changes */
|
|
@@ -775,11 +1321,36 @@ export declare class Schematic {
|
|
|
775
1321
|
/** Register an event listener that will be notified with the full flag check response for a given flag whenever this value changes */
|
|
776
1322
|
addFlagCheckListener: (flagKey: string, listener: FlagCheckListenerFn) => () => void;
|
|
777
1323
|
addPlanListener: (listener: PlanListenerFn) => () => void;
|
|
1324
|
+
/** Register an event listener that will be notified with the company's credit balances (keyed by credit ID) whenever they change */
|
|
1325
|
+
addCreditBalanceListener: (listener: CreditBalanceListenerFn) => () => void;
|
|
778
1326
|
private notifyFlagCheckListeners;
|
|
779
1327
|
/** Add or update a CheckFlagReturn in the featureUsageEventMap */
|
|
780
1328
|
private updateFeatureUsageEventMap;
|
|
781
1329
|
private notifyFlagValueListeners;
|
|
782
1330
|
private notifyPlanListeners;
|
|
1331
|
+
private notifyCreditBalanceListeners;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
declare class SchematicApiError extends Error {
|
|
1335
|
+
readonly status: number;
|
|
1336
|
+
readonly path: string;
|
|
1337
|
+
readonly body: unknown;
|
|
1338
|
+
constructor(status: number, path: string, body: unknown);
|
|
1339
|
+
}
|
|
1340
|
+
|
|
1341
|
+
declare class SchematicBillingClient implements BillingClient {
|
|
1342
|
+
/**
|
|
1343
|
+
* Public so a second client over the same surface can be constructed on
|
|
1344
|
+
* this one rather than minting tokens of its own.
|
|
1345
|
+
*/
|
|
1346
|
+
readonly session: SchematicSession;
|
|
1347
|
+
constructor(options?: BillingClientOptions | SchematicSession);
|
|
1348
|
+
get sessionKey(): string | undefined;
|
|
1349
|
+
get sessionStatus(): SessionStatus;
|
|
1350
|
+
setSession(session: SessionInput): void;
|
|
1351
|
+
onSessionChange(listener: (event: SessionEvent) => void): () => void;
|
|
1352
|
+
fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
|
|
1353
|
+
fetchUpcomingInvoice(): Promise<UpcomingInvoice | null>;
|
|
783
1354
|
}
|
|
784
1355
|
|
|
785
1356
|
export declare interface SchematicComposableOpts {
|
|
@@ -802,6 +1373,20 @@ declare namespace SchematicJS {
|
|
|
802
1373
|
CheckFlagsResponseFromJSON,
|
|
803
1374
|
DatastreamCompanyPlanFromJSON,
|
|
804
1375
|
EventBodyFlagCheckToJSON,
|
|
1376
|
+
fetchBillingData,
|
|
1377
|
+
normalizeInvoiceQuery,
|
|
1378
|
+
sessionKey,
|
|
1379
|
+
AccessToken,
|
|
1380
|
+
AccessTokenProvider,
|
|
1381
|
+
AccessTokenResult,
|
|
1382
|
+
billingApi,
|
|
1383
|
+
BillingClient,
|
|
1384
|
+
BillingClientOptions,
|
|
1385
|
+
BillingData,
|
|
1386
|
+
BillingPrefetchOptions,
|
|
1387
|
+
BillingResourceName,
|
|
1388
|
+
BillingResourceParams,
|
|
1389
|
+
BillingResources,
|
|
805
1390
|
BooleanListenerFn,
|
|
806
1391
|
CheckFlagResponseData,
|
|
807
1392
|
CheckFlagReturn,
|
|
@@ -811,6 +1396,17 @@ declare namespace SchematicJS {
|
|
|
811
1396
|
CheckPlanReturn,
|
|
812
1397
|
CheckPlanReturnFromJSON,
|
|
813
1398
|
CheckPlanReturnListenerFn,
|
|
1399
|
+
CompanyCreditBalance,
|
|
1400
|
+
CompanyDiscountResponseData,
|
|
1401
|
+
CompanyInvoiceResponseData,
|
|
1402
|
+
CompanyUpcomingInvoiceResponseData,
|
|
1403
|
+
CreditBalance,
|
|
1404
|
+
CreditBalanceListenerFn,
|
|
1405
|
+
CreditBalances,
|
|
1406
|
+
CreditBalancesFromJSON,
|
|
1407
|
+
CreditBalancesListenerFn,
|
|
1408
|
+
DEFAULT_INVOICE_QUERY,
|
|
1409
|
+
Discount,
|
|
814
1410
|
EmptyListenerFn,
|
|
815
1411
|
Event_2 as Event,
|
|
816
1412
|
EventBody,
|
|
@@ -820,17 +1416,39 @@ declare namespace SchematicJS {
|
|
|
820
1416
|
EventType,
|
|
821
1417
|
FlagCheckListenerFn,
|
|
822
1418
|
FlagValueListenerFn,
|
|
1419
|
+
Invoice,
|
|
1420
|
+
INVOICE_MAX_PAGE_SIZE,
|
|
1421
|
+
INVOICE_PAGE_SIZE,
|
|
1422
|
+
InvoicePage,
|
|
1423
|
+
InvoiceQuery,
|
|
1424
|
+
InvoicesRequest,
|
|
1425
|
+
InvoicesResult,
|
|
1426
|
+
InvoiceStatus,
|
|
823
1427
|
Keys,
|
|
824
1428
|
PendingListenerFn,
|
|
825
1429
|
PlanListenerFn,
|
|
1430
|
+
RequestOptions,
|
|
1431
|
+
ResourceState,
|
|
826
1432
|
RuleType,
|
|
827
1433
|
Schematic,
|
|
1434
|
+
SchematicApiError,
|
|
1435
|
+
SchematicBillingClient,
|
|
828
1436
|
SchematicContext,
|
|
829
1437
|
SchematicOptions,
|
|
1438
|
+
SchematicSession,
|
|
1439
|
+
Session,
|
|
1440
|
+
SessionEvent,
|
|
1441
|
+
SessionInput,
|
|
1442
|
+
SessionOptions,
|
|
1443
|
+
SessionStatus,
|
|
1444
|
+
SINGLETON,
|
|
830
1445
|
StoragePersister,
|
|
1446
|
+
TOKEN_CACHE_SIZE,
|
|
831
1447
|
Traits,
|
|
832
1448
|
TrialStatus,
|
|
833
|
-
|
|
1449
|
+
UpcomingInvoice,
|
|
1450
|
+
UsagePeriod,
|
|
1451
|
+
WarningTier
|
|
834
1452
|
}
|
|
835
1453
|
}
|
|
836
1454
|
|
|
@@ -850,6 +1468,12 @@ export declare type SchematicOptions = {
|
|
|
850
1468
|
offline?: boolean;
|
|
851
1469
|
/** Optionally provide a custom storage persister for client-side storage */
|
|
852
1470
|
storage?: StoragePersister;
|
|
1471
|
+
/** 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.
|
|
1472
|
+
*
|
|
1473
|
+
* 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. */
|
|
1474
|
+
persistFlagState?: boolean;
|
|
1475
|
+
/** 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. */
|
|
1476
|
+
flagStateCacheMaxAgeMs?: number;
|
|
853
1477
|
/** Use a WebSocket connection for real-time flag checks; if using this, run the cleanup function to close the connection */
|
|
854
1478
|
useWebSocket?: boolean;
|
|
855
1479
|
/** Optionally provide a custom WebSocket URL */
|
|
@@ -907,6 +1531,114 @@ declare type SchematicPluginOptionsWithPublishableKey = BaseSchematicPluginOptio
|
|
|
907
1531
|
publishableKey: string;
|
|
908
1532
|
};
|
|
909
1533
|
|
|
1534
|
+
/**
|
|
1535
|
+
* Session identity is the (company, user) pair alone: a freshly minted token,
|
|
1536
|
+
* a rebuilt provider closure, and a refresh this session asked for itself are
|
|
1537
|
+
* all the same session. Nothing in a token says who it was minted for, so
|
|
1538
|
+
* that question is the host's to answer.
|
|
1539
|
+
*
|
|
1540
|
+
* Credentials survive a change of session, keyed by pair — switching back to
|
|
1541
|
+
* a company reads with the token already in hand. They do not survive the
|
|
1542
|
+
* session ending: after a sign-out the next person at this page is somebody
|
|
1543
|
+
* else, and nothing minted for the last one is theirs to send.
|
|
1544
|
+
*/
|
|
1545
|
+
declare class SchematicSession {
|
|
1546
|
+
private readonly _apiUrl;
|
|
1547
|
+
private readonly _headers;
|
|
1548
|
+
private readonly _fetch;
|
|
1549
|
+
private _session;
|
|
1550
|
+
private readonly _tokens;
|
|
1551
|
+
private readonly _resolving;
|
|
1552
|
+
/**
|
|
1553
|
+
* Bumped when the session's identity changes, and only then — the object
|
|
1554
|
+
* itself is replaced on every render. Anything asking "is this still the
|
|
1555
|
+
* session I started under?" counts generations rather than comparing.
|
|
1556
|
+
*/
|
|
1557
|
+
private _generation;
|
|
1558
|
+
private readonly _listeners;
|
|
1559
|
+
constructor(options?: SessionOptions);
|
|
1560
|
+
get key(): string | undefined;
|
|
1561
|
+
get status(): SessionStatus;
|
|
1562
|
+
/** Only a statement that changes which pair is read counts as a change. */
|
|
1563
|
+
set(session: SessionInput): void;
|
|
1564
|
+
onChange(listener: (event: SessionEvent) => void): () => void;
|
|
1565
|
+
private _emit;
|
|
1566
|
+
private _cached;
|
|
1567
|
+
private _cache;
|
|
1568
|
+
/**
|
|
1569
|
+
* The credential for a session, minted if this one is not held. `force`
|
|
1570
|
+
* retires what is held first: the caller is a request the API has just
|
|
1571
|
+
* rejected.
|
|
1572
|
+
*/
|
|
1573
|
+
resolveToken(session: Session, force: boolean): Promise<string>;
|
|
1574
|
+
/**
|
|
1575
|
+
* Sends a request under the active session's credential, refreshing once
|
|
1576
|
+
* and retrying if the API rejects it. Rejects rather than answering when
|
|
1577
|
+
* the session changes while the request is in flight: the rows would
|
|
1578
|
+
* otherwise come back as the answer to a question asked for another pair.
|
|
1579
|
+
*/
|
|
1580
|
+
request(path: string, options?: RequestOptions): Promise<unknown>;
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
/**
|
|
1584
|
+
* Who is being read. Users and companies are many-to-many: the same person
|
|
1585
|
+
* reads one company's billing and then another's, and the same company is
|
|
1586
|
+
* read by several people. A token is minted for the pair, so the pair — not
|
|
1587
|
+
* the company alone — is the session's identity.
|
|
1588
|
+
*/
|
|
1589
|
+
declare interface Session {
|
|
1590
|
+
/** The host's name for the company, its id in their own system say. */
|
|
1591
|
+
company: string;
|
|
1592
|
+
/**
|
|
1593
|
+
* The user, where the host mints per (company, user). Left out by a host
|
|
1594
|
+
* whose tokens are company-wide, and then every reader of that company
|
|
1595
|
+
* shares one session.
|
|
1596
|
+
*/
|
|
1597
|
+
user?: string;
|
|
1598
|
+
token: AccessToken;
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
/**
|
|
1602
|
+
* What happened to the session, for anything holding data that belongs to
|
|
1603
|
+
* one. `started`: whatever is loaded belongs to the new session — a prefetch
|
|
1604
|
+
* the host seeded before its auth resolved. `changed`: another pair is being
|
|
1605
|
+
* read, and what is loaded belongs to the pair being left. `ended`: nobody is
|
|
1606
|
+
* signed in, and what is loaded belongs to nobody.
|
|
1607
|
+
*/
|
|
1608
|
+
declare type SessionEvent = {
|
|
1609
|
+
type: "started" | "changed" | "ended";
|
|
1610
|
+
};
|
|
1611
|
+
|
|
1612
|
+
/**
|
|
1613
|
+
* Three states that are not interchangeable:
|
|
1614
|
+
*
|
|
1615
|
+
* * `Session` — active: this pair, read with this credential.
|
|
1616
|
+
* * `null` — ended: nobody is signed in; what is loaded is dropped.
|
|
1617
|
+
* * `undefined` — pending: the host's auth has not resolved. It states
|
|
1618
|
+
* nothing, so the session in hand stands.
|
|
1619
|
+
*/
|
|
1620
|
+
declare type SessionInput = Session | null | undefined;
|
|
1621
|
+
|
|
1622
|
+
/**
|
|
1623
|
+
* The pair as one string, for anything that has to compare sessions or key
|
|
1624
|
+
* something by one — a prefetch stating which session it was fetched for, a
|
|
1625
|
+
* store keeping a page per session. Opaque: read it only by equality.
|
|
1626
|
+
*/
|
|
1627
|
+
declare function sessionKey(session: Session): string;
|
|
1628
|
+
|
|
1629
|
+
declare interface SessionOptions {
|
|
1630
|
+
session?: SessionInput;
|
|
1631
|
+
apiUrl?: string;
|
|
1632
|
+
additionalHeaders?: Record<string, string>;
|
|
1633
|
+
/** Override for tests and non-browser runtimes. */
|
|
1634
|
+
fetch?: typeof fetch;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
declare type SessionStatus = "pending" | "active" | "ended";
|
|
1638
|
+
|
|
1639
|
+
/** The params of every singleton resource. */
|
|
1640
|
+
declare const SINGLETON: Record<string, never>;
|
|
1641
|
+
|
|
910
1642
|
/** Optional type for implementing custom client-side storage */
|
|
911
1643
|
export declare type StoragePersister = {
|
|
912
1644
|
setItem(key: string, value: any): void;
|
|
@@ -914,6 +1646,15 @@ export declare type StoragePersister = {
|
|
|
914
1646
|
removeItem(key: string): void;
|
|
915
1647
|
};
|
|
916
1648
|
|
|
1649
|
+
/**
|
|
1650
|
+
* Sessions whose credentials are kept. A reader switching between the
|
|
1651
|
+
* organizations they belong to walks a handful of them and comes back, and
|
|
1652
|
+
* re-minting on every step is a round trip to the host's token endpoint for
|
|
1653
|
+
* a token this client already holds and has not seen expire. The same
|
|
1654
|
+
* handful the flag cache bounds its contexts at.
|
|
1655
|
+
*/
|
|
1656
|
+
declare const TOKEN_CACHE_SIZE = 10;
|
|
1657
|
+
|
|
917
1658
|
/**
|
|
918
1659
|
* A flexible key/value type that can store any type of value on a company or user.
|
|
919
1660
|
*/
|
|
@@ -931,6 +1672,8 @@ declare const TrialStatus: {
|
|
|
931
1672
|
|
|
932
1673
|
declare type TrialStatus = (typeof TrialStatus)[keyof typeof TrialStatus];
|
|
933
1674
|
|
|
1675
|
+
declare type UpcomingInvoice = CompanyUpcomingInvoiceResponseData;
|
|
1676
|
+
|
|
934
1677
|
export declare enum UsagePeriod {
|
|
935
1678
|
ALL_TIME = "all_time",
|
|
936
1679
|
CURRENT_DAY = "current_day",
|
|
@@ -969,6 +1712,45 @@ export declare const useSchematicContext: (opts?: SchematicComposableOpts) => {
|
|
|
969
1712
|
setContext: (context: SchematicJS.SchematicContext) => Promise<void>;
|
|
970
1713
|
};
|
|
971
1714
|
|
|
1715
|
+
/**
|
|
1716
|
+
* Get a company's live, lease-aware credit balance for a single credit type.
|
|
1717
|
+
* Returns reactive computed refs for the balance and a loading flag.
|
|
1718
|
+
*
|
|
1719
|
+
* Surfaces the spendable `settled` balance, sourced from the streamed credit
|
|
1720
|
+
* balances map (keyed by credit ID). It updates as partials arrive over the
|
|
1721
|
+
* DataStream, so it stays accurate during an open lease — when the raw
|
|
1722
|
+
* `remaining` would otherwise read stale / falsely "exhausted".
|
|
1723
|
+
*
|
|
1724
|
+
* The credit ID is available on a feature's entitlement: `useSchematicEntitlement(key)`
|
|
1725
|
+
* returns `creditId` for credit-based features. Pass that computed ref straight
|
|
1726
|
+
* in; the composable unwraps a ref, a getter, or a plain string, and re-keys to
|
|
1727
|
+
* the new credit when the source changes. While the ID is undefined it reports
|
|
1728
|
+
* the client's loading state and a balance of 0.
|
|
1729
|
+
*
|
|
1730
|
+
* @param creditId - The credit ID to read the balance for, as a ref, a getter, or a plain string
|
|
1731
|
+
* @param opts - Optional configuration including a client override
|
|
1732
|
+
* @returns Object with `balance` and `isLoading` computed refs
|
|
1733
|
+
*
|
|
1734
|
+
* @example
|
|
1735
|
+
* ```typescript
|
|
1736
|
+
* const { balance, isLoading } = useSchematicCreditBalance('credit-id')
|
|
1737
|
+
*
|
|
1738
|
+
* // Or keyed off an entitlement, without unwrapping it yourself
|
|
1739
|
+
* const { creditId } = useSchematicEntitlement('my-flag-key')
|
|
1740
|
+
* const { balance } = useSchematicCreditBalance(creditId)
|
|
1741
|
+
*
|
|
1742
|
+
* // In template
|
|
1743
|
+
* <div v-if="isLoading">Loading…</div>
|
|
1744
|
+
* <div v-else>{{ balance }} credits remaining</div>
|
|
1745
|
+
* ```
|
|
1746
|
+
*/
|
|
1747
|
+
export declare const useSchematicCreditBalance: (creditId: MaybeRefOrGetter<string | undefined>, opts?: SchematicComposableOpts) => {
|
|
1748
|
+
/** The spendable balance; 0 while loading or when the company holds no balance in this credit */
|
|
1749
|
+
balance: ComputedRef<number>;
|
|
1750
|
+
/** True while the balance is still loading and no value has arrived yet */
|
|
1751
|
+
isLoading: ComputedRef<boolean>;
|
|
1752
|
+
};
|
|
1753
|
+
|
|
972
1754
|
/**
|
|
973
1755
|
* Check feature entitlement with usage details
|
|
974
1756
|
* Returns reactive refs for flag value, usage, allocation, and exceeded status
|
|
@@ -996,7 +1778,10 @@ export declare const useSchematicEntitlement: (key: string, opts?: UseSchematicF
|
|
|
996
1778
|
check: ComputedRef< {
|
|
997
1779
|
featureUsageExceeded?: boolean | undefined;
|
|
998
1780
|
companyId?: string | undefined;
|
|
1781
|
+
creditId?: string | undefined;
|
|
999
1782
|
creditRemaining?: number | undefined;
|
|
1783
|
+
creditReserved?: number | undefined;
|
|
1784
|
+
creditSettled?: number | undefined;
|
|
1000
1785
|
error?: string | undefined;
|
|
1001
1786
|
featureAllocation?: number | undefined;
|
|
1002
1787
|
featureUsage?: number | undefined;
|
|
@@ -1011,6 +1796,10 @@ export declare const useSchematicEntitlement: (key: string, opts?: UseSchematicF
|
|
|
1011
1796
|
softLimit?: number | undefined;
|
|
1012
1797
|
userId?: string | undefined;
|
|
1013
1798
|
value: boolean;
|
|
1799
|
+
warningTiers?: {
|
|
1800
|
+
key: string;
|
|
1801
|
+
value: number;
|
|
1802
|
+
}[] | undefined;
|
|
1014
1803
|
}>;
|
|
1015
1804
|
value: ComputedRef<boolean>;
|
|
1016
1805
|
flag: ComputedRef<string>;
|
|
@@ -1020,10 +1809,19 @@ export declare const useSchematicEntitlement: (key: string, opts?: UseSchematicF
|
|
|
1020
1809
|
featureUsageExceeded: ComputedRef<boolean | undefined>;
|
|
1021
1810
|
featureUsageEvent: ComputedRef<string | undefined>;
|
|
1022
1811
|
featureUsagePeriod: ComputedRef<SchematicJS.UsagePeriod | undefined>;
|
|
1812
|
+
softLimit: ComputedRef<number | undefined>;
|
|
1813
|
+
warningTiers: ComputedRef< {
|
|
1814
|
+
key: string;
|
|
1815
|
+
value: number;
|
|
1816
|
+
}[] | undefined>;
|
|
1023
1817
|
flagId: ComputedRef<string | undefined>;
|
|
1024
1818
|
ruleId: ComputedRef<string | undefined>;
|
|
1025
1819
|
companyId: ComputedRef<string | undefined>;
|
|
1026
1820
|
userId: ComputedRef<string | undefined>;
|
|
1821
|
+
creditId: ComputedRef<string | undefined>;
|
|
1822
|
+
creditSettled: ComputedRef<number | undefined>;
|
|
1823
|
+
creditRemaining: ComputedRef<number | undefined>;
|
|
1824
|
+
creditReserved: ComputedRef<number | undefined>;
|
|
1027
1825
|
};
|
|
1028
1826
|
|
|
1029
1827
|
/**
|
|
@@ -1113,4 +1911,35 @@ export declare type UseSchematicPlanOpts = SchematicComposableOpts & {
|
|
|
1113
1911
|
fallback?: SchematicJS.CheckPlanReturn;
|
|
1114
1912
|
};
|
|
1115
1913
|
|
|
1914
|
+
/**
|
|
1915
|
+
* Schematic API
|
|
1916
|
+
* Schematic API
|
|
1917
|
+
*
|
|
1918
|
+
* The version of the OpenAPI document: 0.1
|
|
1919
|
+
*
|
|
1920
|
+
*
|
|
1921
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
1922
|
+
* https://openapi-generator.tech
|
|
1923
|
+
* Do not edit the class manually.
|
|
1924
|
+
*/
|
|
1925
|
+
/**
|
|
1926
|
+
*
|
|
1927
|
+
* @export
|
|
1928
|
+
* @interface WarningTier
|
|
1929
|
+
*/
|
|
1930
|
+
export declare interface WarningTier {
|
|
1931
|
+
/**
|
|
1932
|
+
* A customer-defined identifier for the warning tier
|
|
1933
|
+
* @type {string}
|
|
1934
|
+
* @memberof WarningTier
|
|
1935
|
+
*/
|
|
1936
|
+
key: string;
|
|
1937
|
+
/**
|
|
1938
|
+
* The warning threshold, in the entitlement's usage units
|
|
1939
|
+
* @type {number}
|
|
1940
|
+
* @memberof WarningTier
|
|
1941
|
+
*/
|
|
1942
|
+
value: number;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1116
1945
|
export { }
|