@schematichq/schematic-js 1.4.0 → 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 +18 -1
- package/dist/schematic.browser.js +2 -2
- package/dist/schematic.cjs.js +1267 -36
- package/dist/schematic.d.ts +760 -21
- package/dist/schematic.esm.js +1271 -36
- package/package.json +26 -28
package/dist/schematic.d.ts
CHANGED
|
@@ -1,3 +1,158 @@
|
|
|
1
|
+
export declare type AccessToken = string | AccessTokenProvider;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The machinery every temporary-access-token surface shares: which session is
|
|
5
|
+
* being read, the credential for it, and the request that carries it. It
|
|
6
|
+
* knows nothing about invoices, subscriptions, or checkout — a domain client
|
|
7
|
+
* (see `SchematicBillingClient`) is constructed over it, and several may
|
|
8
|
+
* share one session rather than each minting tokens of its own.
|
|
9
|
+
*/
|
|
10
|
+
/** Called once per session, and again when a request comes back 401. */
|
|
11
|
+
export declare type AccessTokenProvider = () => Promise<string | AccessTokenResult>;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A bare token, or one that says when it expires and who it was minted for.
|
|
15
|
+
* `company`/`user` are the host restating the pair it asked for; stated, they
|
|
16
|
+
* are checked against the session the resolution was started for.
|
|
17
|
+
*/
|
|
18
|
+
export declare interface AccessTokenResult {
|
|
19
|
+
token: string;
|
|
20
|
+
expiresAt?: Date | string | null;
|
|
21
|
+
company?: string;
|
|
22
|
+
user?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Schematic API
|
|
27
|
+
* Schematic API
|
|
28
|
+
*
|
|
29
|
+
* The version of the OpenAPI document: 0.1
|
|
30
|
+
*
|
|
31
|
+
*
|
|
32
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
33
|
+
* https://openapi-generator.tech
|
|
34
|
+
* Do not edit the class manually.
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @export
|
|
39
|
+
* @interface ApiError
|
|
40
|
+
*/
|
|
41
|
+
declare interface ApiError {
|
|
42
|
+
/**
|
|
43
|
+
* Error message
|
|
44
|
+
* @type {string}
|
|
45
|
+
* @memberof ApiError
|
|
46
|
+
*/
|
|
47
|
+
error: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare function ApiErrorFromJSON(json: any): ApiError;
|
|
51
|
+
|
|
52
|
+
declare function ApiErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): ApiError;
|
|
53
|
+
|
|
54
|
+
declare function ApiErrorToJSON(json: any): ApiError;
|
|
55
|
+
|
|
56
|
+
declare function ApiErrorToJSONTyped(value?: ApiError | null, ignoreDiscriminator?: boolean): any;
|
|
57
|
+
|
|
58
|
+
export declare namespace billingApi {
|
|
59
|
+
export {
|
|
60
|
+
instanceOfApiError,
|
|
61
|
+
ApiErrorFromJSON,
|
|
62
|
+
ApiErrorFromJSONTyped,
|
|
63
|
+
ApiErrorToJSON,
|
|
64
|
+
ApiErrorToJSONTyped,
|
|
65
|
+
ApiError,
|
|
66
|
+
instanceOfCompanyInvoiceResponseData,
|
|
67
|
+
CompanyInvoiceResponseDataFromJSON,
|
|
68
|
+
CompanyInvoiceResponseDataFromJSONTyped,
|
|
69
|
+
CompanyInvoiceResponseDataToJSON,
|
|
70
|
+
CompanyInvoiceResponseDataToJSONTyped,
|
|
71
|
+
CompanyInvoiceResponseData,
|
|
72
|
+
instanceOfCompanyInvoicesResponseData,
|
|
73
|
+
CompanyInvoicesResponseDataFromJSON,
|
|
74
|
+
CompanyInvoicesResponseDataFromJSONTyped,
|
|
75
|
+
CompanyInvoicesResponseDataToJSON,
|
|
76
|
+
CompanyInvoicesResponseDataToJSONTyped,
|
|
77
|
+
CompanyInvoicesResponseData,
|
|
78
|
+
instanceOfGetCompanyInvoicesParams,
|
|
79
|
+
GetCompanyInvoicesParamsFromJSON,
|
|
80
|
+
GetCompanyInvoicesParamsFromJSONTyped,
|
|
81
|
+
GetCompanyInvoicesParamsToJSON,
|
|
82
|
+
GetCompanyInvoicesParamsToJSONTyped,
|
|
83
|
+
GetCompanyInvoicesParams,
|
|
84
|
+
instanceOfGetCompanyInvoicesResponse,
|
|
85
|
+
GetCompanyInvoicesResponseFromJSON,
|
|
86
|
+
GetCompanyInvoicesResponseFromJSONTyped,
|
|
87
|
+
GetCompanyInvoicesResponseToJSON,
|
|
88
|
+
GetCompanyInvoicesResponseToJSONTyped,
|
|
89
|
+
GetCompanyInvoicesResponse,
|
|
90
|
+
instanceOfInvoiceStatus,
|
|
91
|
+
InvoiceStatusFromJSON,
|
|
92
|
+
InvoiceStatusFromJSONTyped,
|
|
93
|
+
InvoiceStatusToJSON,
|
|
94
|
+
InvoiceStatusToJSONTyped,
|
|
95
|
+
InvoiceStatus
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* What a reader of billing data can ask for. Subscription and usage — the
|
|
101
|
+
* rest of what `hydrate` serves — and the checkout calls that change them
|
|
102
|
+
* join this interface as their endpoints ship.
|
|
103
|
+
*/
|
|
104
|
+
export declare interface BillingClient {
|
|
105
|
+
fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
|
|
106
|
+
readonly sessionStatus: SessionStatus;
|
|
107
|
+
readonly sessionKey: string | undefined;
|
|
108
|
+
setSession(session: SessionInput): void;
|
|
109
|
+
onSessionChange(listener: (event: SessionEvent) => void): () => void;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export declare type BillingClientOptions = SessionOptions;
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* A prefetch or fixture. An omitted key reports as pending; a keyed resource
|
|
116
|
+
* seeds under `params`, or its defaults when absent, so a prefetch for a
|
|
117
|
+
* non-default query is claimed rather than refetched by the element.
|
|
118
|
+
*/
|
|
119
|
+
export declare type BillingData = {
|
|
120
|
+
[K in BillingResourceName]?: BillingResources[K];
|
|
121
|
+
} & {
|
|
122
|
+
params?: Partial<BillingResourceParams>;
|
|
123
|
+
/**
|
|
124
|
+
* A prefetch outlives the render that made it — a cached page, a session
|
|
125
|
+
* resolving to somebody else — so a store adopts it only for the session
|
|
126
|
+
* it names. `fetchBillingData` fills it in; a fixture need not.
|
|
127
|
+
*/
|
|
128
|
+
sessionKey?: string;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export declare interface BillingPrefetchOptions {
|
|
132
|
+
names?: BillingResourceName[];
|
|
133
|
+
/** The invoice query to prefetch for; the element must ask the same one. */
|
|
134
|
+
invoices?: InvoiceQuery;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export declare type BillingResourceName = keyof BillingResources;
|
|
138
|
+
|
|
139
|
+
/** `Record<string, never>` marks a singleton; anything else is keyed. */
|
|
140
|
+
export declare interface BillingResourceParams {
|
|
141
|
+
invoices: InvoiceQuery;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Nothing in the store, the hooks, or the resource keys may be addressed by
|
|
146
|
+
* company or user id: users and companies are many-to-many, and a token names
|
|
147
|
+
* the pair. What is loaded belongs to the session it was read under — the
|
|
148
|
+
* pair, as `sessionKey` writes it — and a store that keeps more than one
|
|
149
|
+
* session's data keys it by that and serves only the active one.
|
|
150
|
+
*/
|
|
151
|
+
export declare interface BillingResources {
|
|
152
|
+
/** `GET /company/invoices?limit&offset&include_pending`. */
|
|
153
|
+
invoices: InvoicePage;
|
|
154
|
+
}
|
|
155
|
+
|
|
1
156
|
export declare type BooleanListenerFn = (value: boolean) => void;
|
|
2
157
|
|
|
3
158
|
/**
|
|
@@ -67,11 +222,11 @@ export declare interface CheckFlagResponseData {
|
|
|
67
222
|
featureUsageEvent?: string | null;
|
|
68
223
|
/**
|
|
69
224
|
* Deprecated: Use Entitlement.MetricPeriod instead.
|
|
70
|
-
* @type {
|
|
225
|
+
* @type {MetricPeriod}
|
|
71
226
|
* @memberof CheckFlagResponseData
|
|
72
227
|
* @deprecated
|
|
73
228
|
*/
|
|
74
|
-
featureUsagePeriod?:
|
|
229
|
+
featureUsagePeriod?: MetricPeriod | null;
|
|
75
230
|
/**
|
|
76
231
|
* Deprecated: Use Entitlement.MetricResetAt instead.
|
|
77
232
|
* @type {Date}
|
|
@@ -105,10 +260,10 @@ export declare interface CheckFlagResponseData {
|
|
|
105
260
|
ruleId?: string | null;
|
|
106
261
|
/**
|
|
107
262
|
* If a rule was found, its type
|
|
108
|
-
* @type {
|
|
263
|
+
* @type {RuleType}
|
|
109
264
|
* @memberof CheckFlagResponseData
|
|
110
265
|
*/
|
|
111
|
-
ruleType?:
|
|
266
|
+
ruleType?: RuleType_2 | null;
|
|
112
267
|
/**
|
|
113
268
|
* If user keys were provided and matched a user, its ID
|
|
114
269
|
* @type {string}
|
|
@@ -130,8 +285,14 @@ export declare type CheckFlagReturn = {
|
|
|
130
285
|
featureUsageExceeded?: boolean;
|
|
131
286
|
/** If company keys were provided and matched a company, its ID */
|
|
132
287
|
companyId?: string;
|
|
133
|
-
/** If the company has a credit-based entitlement for this feature, the
|
|
288
|
+
/** If the company has a credit-based entitlement for this feature, the ID of the credit */
|
|
289
|
+
creditId?: string;
|
|
290
|
+
/** 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) */
|
|
134
291
|
creditRemaining?: number;
|
|
292
|
+
/** 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 */
|
|
293
|
+
creditReserved?: number;
|
|
294
|
+
/** 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 */
|
|
295
|
+
creditSettled?: number;
|
|
135
296
|
/** If an error occurred while checking the flag, the error message */
|
|
136
297
|
error?: string;
|
|
137
298
|
/** If a numeric feature entitlement rule was matched, its allocation */
|
|
@@ -192,6 +353,14 @@ declare interface CheckFlagsResponse {
|
|
|
192
353
|
* @interface CheckFlagsResponseData
|
|
193
354
|
*/
|
|
194
355
|
declare interface CheckFlagsResponseData {
|
|
356
|
+
/**
|
|
357
|
+
* Lease-aware credit balances keyed by credit ID, covering every credit type the company holds a balance in
|
|
358
|
+
* @type {{ [key: string]: CompanyCreditBalance; }}
|
|
359
|
+
* @memberof CheckFlagsResponseData
|
|
360
|
+
*/
|
|
361
|
+
creditBalances?: {
|
|
362
|
+
[key: string]: CompanyCreditBalance;
|
|
363
|
+
};
|
|
195
364
|
/**
|
|
196
365
|
*
|
|
197
366
|
* @type {Array<CheckFlagResponseData>}
|
|
@@ -225,6 +394,148 @@ export declare const CheckPlanReturnFromJSON: (json: any) => CheckPlanReturn;
|
|
|
225
394
|
|
|
226
395
|
export declare type CheckPlanReturnListenerFn = (value: CheckPlanReturn) => void;
|
|
227
396
|
|
|
397
|
+
/**
|
|
398
|
+
* Schematic API
|
|
399
|
+
* Schematic API
|
|
400
|
+
*
|
|
401
|
+
* The version of the OpenAPI document: 0.1
|
|
402
|
+
*
|
|
403
|
+
*
|
|
404
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
405
|
+
* https://openapi-generator.tech
|
|
406
|
+
* Do not edit the class manually.
|
|
407
|
+
*/
|
|
408
|
+
/**
|
|
409
|
+
*
|
|
410
|
+
* @export
|
|
411
|
+
* @interface CompanyCreditBalance
|
|
412
|
+
*/
|
|
413
|
+
export declare interface CompanyCreditBalance {
|
|
414
|
+
/**
|
|
415
|
+
* Remaining credit, excluding any open lease hold (the value SDKs gate on)
|
|
416
|
+
* @type {number}
|
|
417
|
+
* @memberof CompanyCreditBalance
|
|
418
|
+
*/
|
|
419
|
+
remaining: number;
|
|
420
|
+
/**
|
|
421
|
+
* Amount held by the company's open credit lease, 0 when none is open
|
|
422
|
+
* @type {number}
|
|
423
|
+
* @memberof CompanyCreditBalance
|
|
424
|
+
*/
|
|
425
|
+
reserved: number;
|
|
426
|
+
/**
|
|
427
|
+
* Spendable balance including the open lease hold (remaining + reserved)
|
|
428
|
+
* @type {number}
|
|
429
|
+
* @memberof CompanyCreditBalance
|
|
430
|
+
*/
|
|
431
|
+
settled: number;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
*
|
|
436
|
+
* @export
|
|
437
|
+
* @interface CompanyInvoiceResponseData
|
|
438
|
+
*/
|
|
439
|
+
export declare interface CompanyInvoiceResponseData {
|
|
440
|
+
/**
|
|
441
|
+
*
|
|
442
|
+
* @type {number}
|
|
443
|
+
* @memberof CompanyInvoiceResponseData
|
|
444
|
+
*/
|
|
445
|
+
amountDue: number;
|
|
446
|
+
/**
|
|
447
|
+
*
|
|
448
|
+
* @type {Date}
|
|
449
|
+
* @memberof CompanyInvoiceResponseData
|
|
450
|
+
*/
|
|
451
|
+
createdAt: Date;
|
|
452
|
+
/**
|
|
453
|
+
*
|
|
454
|
+
* @type {string}
|
|
455
|
+
* @memberof CompanyInvoiceResponseData
|
|
456
|
+
*/
|
|
457
|
+
currency: string;
|
|
458
|
+
/**
|
|
459
|
+
*
|
|
460
|
+
* @type {Date}
|
|
461
|
+
* @memberof CompanyInvoiceResponseData
|
|
462
|
+
*/
|
|
463
|
+
dueDate?: Date | null;
|
|
464
|
+
/**
|
|
465
|
+
*
|
|
466
|
+
* @type {string}
|
|
467
|
+
* @memberof CompanyInvoiceResponseData
|
|
468
|
+
*/
|
|
469
|
+
id: string;
|
|
470
|
+
/**
|
|
471
|
+
*
|
|
472
|
+
* @type {InvoiceStatus}
|
|
473
|
+
* @memberof CompanyInvoiceResponseData
|
|
474
|
+
*/
|
|
475
|
+
status?: InvoiceStatus | null;
|
|
476
|
+
/**
|
|
477
|
+
*
|
|
478
|
+
* @type {string}
|
|
479
|
+
* @memberof CompanyInvoiceResponseData
|
|
480
|
+
*/
|
|
481
|
+
url?: string | null;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
declare function CompanyInvoiceResponseDataFromJSON(json: any): CompanyInvoiceResponseData;
|
|
485
|
+
|
|
486
|
+
declare function CompanyInvoiceResponseDataFromJSONTyped(json: any, ignoreDiscriminator: boolean): CompanyInvoiceResponseData;
|
|
487
|
+
|
|
488
|
+
declare function CompanyInvoiceResponseDataToJSON(json: any): CompanyInvoiceResponseData;
|
|
489
|
+
|
|
490
|
+
declare function CompanyInvoiceResponseDataToJSONTyped(value?: CompanyInvoiceResponseData | null, ignoreDiscriminator?: boolean): any;
|
|
491
|
+
|
|
492
|
+
/**
|
|
493
|
+
*
|
|
494
|
+
* @export
|
|
495
|
+
* @interface CompanyInvoicesResponseData
|
|
496
|
+
*/
|
|
497
|
+
declare interface CompanyInvoicesResponseData {
|
|
498
|
+
/**
|
|
499
|
+
*
|
|
500
|
+
* @type {number}
|
|
501
|
+
* @memberof CompanyInvoicesResponseData
|
|
502
|
+
*/
|
|
503
|
+
count: number;
|
|
504
|
+
/**
|
|
505
|
+
*
|
|
506
|
+
* @type {Array<CompanyInvoiceResponseData>}
|
|
507
|
+
* @memberof CompanyInvoicesResponseData
|
|
508
|
+
*/
|
|
509
|
+
invoices: Array<CompanyInvoiceResponseData>;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
declare function CompanyInvoicesResponseDataFromJSON(json: any): CompanyInvoicesResponseData;
|
|
513
|
+
|
|
514
|
+
declare function CompanyInvoicesResponseDataFromJSONTyped(json: any, ignoreDiscriminator: boolean): CompanyInvoicesResponseData;
|
|
515
|
+
|
|
516
|
+
declare function CompanyInvoicesResponseDataToJSON(json: any): CompanyInvoicesResponseData;
|
|
517
|
+
|
|
518
|
+
declare function CompanyInvoicesResponseDataToJSONTyped(value?: CompanyInvoicesResponseData | null, ignoreDiscriminator?: boolean): any;
|
|
519
|
+
|
|
520
|
+
/** A company's lease-aware balance for a single credit type */
|
|
521
|
+
export declare type CreditBalance = {
|
|
522
|
+
/** Spendable balance including any open lease hold (remaining + reserved); the number to display to end users */
|
|
523
|
+
settled: number;
|
|
524
|
+
/** Remaining credit excluding any open lease hold (the value lease-holding SDKs gate on) */
|
|
525
|
+
remaining: number;
|
|
526
|
+
/** Amount held by the company's open credit lease, 0 when none is open */
|
|
527
|
+
reserved: number;
|
|
528
|
+
};
|
|
529
|
+
|
|
530
|
+
export declare type CreditBalanceListenerFn = CreditBalancesListenerFn | EmptyListenerFn;
|
|
531
|
+
|
|
532
|
+
/** A company's lease-aware credit balances keyed by credit ID */
|
|
533
|
+
export declare type CreditBalances = Record<string, CreditBalance>;
|
|
534
|
+
|
|
535
|
+
export declare const CreditBalancesFromJSON: (json: any) => CreditBalances;
|
|
536
|
+
|
|
537
|
+
export declare type CreditBalancesListenerFn = (value: CreditBalances) => void;
|
|
538
|
+
|
|
228
539
|
/**
|
|
229
540
|
*
|
|
230
541
|
* @export
|
|
@@ -259,6 +570,8 @@ declare interface DatastreamCompanyPlan {
|
|
|
259
570
|
|
|
260
571
|
export declare function DatastreamCompanyPlanFromJSON(json: any): DatastreamCompanyPlan;
|
|
261
572
|
|
|
573
|
+
export declare const DEFAULT_INVOICE_QUERY: InvoiceQuery;
|
|
574
|
+
|
|
262
575
|
export declare type EmptyListenerFn = () => void;
|
|
263
576
|
|
|
264
577
|
/**
|
|
@@ -331,6 +644,12 @@ export declare interface EventBodyFlagCheck {
|
|
|
331
644
|
* @memberof EventBodyFlagCheck
|
|
332
645
|
*/
|
|
333
646
|
flagKey: string;
|
|
647
|
+
/**
|
|
648
|
+
* Whether the check was a preflight, asking whether an action would be allowed rather than reporting one that happened. Absent on ordinary checks
|
|
649
|
+
* @type {boolean}
|
|
650
|
+
* @memberof EventBodyFlagCheck
|
|
651
|
+
*/
|
|
652
|
+
preflight?: boolean;
|
|
334
653
|
/**
|
|
335
654
|
* The reason why the value was returned
|
|
336
655
|
* @type {string}
|
|
@@ -406,6 +725,12 @@ declare interface FeatureEntitlement {
|
|
|
406
725
|
* @memberof FeatureEntitlement
|
|
407
726
|
*/
|
|
408
727
|
allocation?: number | null;
|
|
728
|
+
/**
|
|
729
|
+
* If the company has a credit-based entitlement for this feature, the credit cost per unit of usage
|
|
730
|
+
* @type {number}
|
|
731
|
+
* @memberof FeatureEntitlement
|
|
732
|
+
*/
|
|
733
|
+
consumptionRate?: number | null;
|
|
409
734
|
/**
|
|
410
735
|
* If the company has a credit-based entitlement for this feature, the ID of the credit
|
|
411
736
|
* @type {string}
|
|
@@ -413,11 +738,23 @@ declare interface FeatureEntitlement {
|
|
|
413
738
|
*/
|
|
414
739
|
creditId?: string | null;
|
|
415
740
|
/**
|
|
416
|
-
* If the company has a credit-based entitlement for this feature, the
|
|
741
|
+
* 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
|
|
417
742
|
* @type {number}
|
|
418
743
|
* @memberof FeatureEntitlement
|
|
419
744
|
*/
|
|
420
745
|
creditRemaining?: number | null;
|
|
746
|
+
/**
|
|
747
|
+
* 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
|
|
748
|
+
* @type {number}
|
|
749
|
+
* @memberof FeatureEntitlement
|
|
750
|
+
*/
|
|
751
|
+
creditReserved?: number | null;
|
|
752
|
+
/**
|
|
753
|
+
* 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
|
|
754
|
+
* @type {number}
|
|
755
|
+
* @memberof FeatureEntitlement
|
|
756
|
+
*/
|
|
757
|
+
creditSettled?: number | null;
|
|
421
758
|
/**
|
|
422
759
|
* If the company has a credit-based entitlement for this feature, the total credit amount
|
|
423
760
|
* @type {number}
|
|
@@ -436,6 +773,12 @@ declare interface FeatureEntitlement {
|
|
|
436
773
|
* @memberof FeatureEntitlement
|
|
437
774
|
*/
|
|
438
775
|
eventName?: string | null;
|
|
776
|
+
/**
|
|
777
|
+
* For event-based or credit-metered feature entitlements, the event subtype whose usage is tracked
|
|
778
|
+
* @type {string}
|
|
779
|
+
* @memberof FeatureEntitlement
|
|
780
|
+
*/
|
|
781
|
+
eventSubtype?: string | null;
|
|
439
782
|
/**
|
|
440
783
|
* The ID of the feature
|
|
441
784
|
* @type {string}
|
|
@@ -450,10 +793,10 @@ declare interface FeatureEntitlement {
|
|
|
450
793
|
featureKey: string;
|
|
451
794
|
/**
|
|
452
795
|
* For event-based feature entitlements, the period over which usage is tracked
|
|
453
|
-
* @type {
|
|
796
|
+
* @type {MetricPeriod}
|
|
454
797
|
* @memberof FeatureEntitlement
|
|
455
798
|
*/
|
|
456
|
-
metricPeriod?:
|
|
799
|
+
metricPeriod?: MetricPeriod | null;
|
|
457
800
|
/**
|
|
458
801
|
* For event-based feature entitlements, when the usage period will reset
|
|
459
802
|
* @type {Date}
|
|
@@ -462,10 +805,10 @@ declare interface FeatureEntitlement {
|
|
|
462
805
|
metricResetAt?: Date | null;
|
|
463
806
|
/**
|
|
464
807
|
* For event-based feature entitlements that have a monthly period, whether that monthly reset is based on the calendar month or a billing cycle
|
|
465
|
-
* @type {
|
|
808
|
+
* @type {MetricPeriodMonthReset}
|
|
466
809
|
* @memberof FeatureEntitlement
|
|
467
810
|
*/
|
|
468
|
-
monthReset?:
|
|
811
|
+
monthReset?: MetricPeriodMonthReset | null;
|
|
469
812
|
/**
|
|
470
813
|
* For usage-based pricing, the soft limit for overage charges or the next tier boundary
|
|
471
814
|
* @type {number}
|
|
@@ -484,41 +827,229 @@ declare interface FeatureEntitlement {
|
|
|
484
827
|
* @memberof FeatureEntitlement
|
|
485
828
|
*/
|
|
486
829
|
valueType: EntitlementValueType;
|
|
830
|
+
/**
|
|
831
|
+
* Customer-defined usage warning thresholds configured on this entitlement
|
|
832
|
+
* @type {Array<WarningTier>}
|
|
833
|
+
* @memberof FeatureEntitlement
|
|
834
|
+
*/
|
|
835
|
+
warningTiers?: Array<WarningTier>;
|
|
487
836
|
}
|
|
488
837
|
|
|
489
838
|
/**
|
|
839
|
+
* Server prefetch for a provider's `initialData`. A resource that fails is
|
|
840
|
+
* left out rather than thrown, so one of them cannot block a page.
|
|
841
|
+
*/
|
|
842
|
+
export declare function fetchBillingData(client: BillingClient, options?: BillingPrefetchOptions): Promise<BillingData>;
|
|
843
|
+
|
|
844
|
+
export declare type FlagCheckListenerFn = CheckFlagReturnListenerFn | EmptyListenerFn;
|
|
845
|
+
|
|
846
|
+
export declare type FlagValueListenerFn = BooleanListenerFn | EmptyListenerFn;
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Schematic API
|
|
850
|
+
* Schematic API
|
|
851
|
+
*
|
|
852
|
+
* The version of the OpenAPI document: 0.1
|
|
853
|
+
*
|
|
854
|
+
*
|
|
855
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
856
|
+
* https://openapi-generator.tech
|
|
857
|
+
* Do not edit the class manually.
|
|
858
|
+
*/
|
|
859
|
+
/**
|
|
860
|
+
* Input parameters
|
|
861
|
+
* @export
|
|
862
|
+
* @interface GetCompanyInvoicesParams
|
|
863
|
+
*/
|
|
864
|
+
declare interface GetCompanyInvoicesParams {
|
|
865
|
+
/**
|
|
866
|
+
* Include unpaid invoices that are not yet due. The default set is time-varying — an invoice passing its due date enters it and shifts later offsets — so page from the response count and stop on an empty page.
|
|
867
|
+
* @type {boolean}
|
|
868
|
+
* @memberof GetCompanyInvoicesParams
|
|
869
|
+
*/
|
|
870
|
+
includePending?: boolean;
|
|
871
|
+
/**
|
|
872
|
+
* Page limit (default 100)
|
|
873
|
+
* @type {number}
|
|
874
|
+
* @memberof GetCompanyInvoicesParams
|
|
875
|
+
*/
|
|
876
|
+
limit?: number;
|
|
877
|
+
/**
|
|
878
|
+
* Page offset (default 0)
|
|
879
|
+
* @type {number}
|
|
880
|
+
* @memberof GetCompanyInvoicesParams
|
|
881
|
+
*/
|
|
882
|
+
offset?: number;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
declare function GetCompanyInvoicesParamsFromJSON(json: any): GetCompanyInvoicesParams;
|
|
886
|
+
|
|
887
|
+
declare function GetCompanyInvoicesParamsFromJSONTyped(json: any, ignoreDiscriminator: boolean): GetCompanyInvoicesParams;
|
|
888
|
+
|
|
889
|
+
declare function GetCompanyInvoicesParamsToJSON(json: any): GetCompanyInvoicesParams;
|
|
890
|
+
|
|
891
|
+
declare function GetCompanyInvoicesParamsToJSONTyped(value?: GetCompanyInvoicesParams | null, ignoreDiscriminator?: boolean): any;
|
|
892
|
+
|
|
893
|
+
/**
|
|
894
|
+
*
|
|
895
|
+
* @export
|
|
896
|
+
* @interface GetCompanyInvoicesResponse
|
|
897
|
+
*/
|
|
898
|
+
declare interface GetCompanyInvoicesResponse {
|
|
899
|
+
/**
|
|
900
|
+
*
|
|
901
|
+
* @type {CompanyInvoicesResponseData}
|
|
902
|
+
* @memberof GetCompanyInvoicesResponse
|
|
903
|
+
*/
|
|
904
|
+
data: CompanyInvoicesResponseData;
|
|
905
|
+
/**
|
|
906
|
+
*
|
|
907
|
+
* @type {GetCompanyInvoicesParams}
|
|
908
|
+
* @memberof GetCompanyInvoicesResponse
|
|
909
|
+
*/
|
|
910
|
+
params: GetCompanyInvoicesParams;
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
declare function GetCompanyInvoicesResponseFromJSON(json: any): GetCompanyInvoicesResponse;
|
|
914
|
+
|
|
915
|
+
declare function GetCompanyInvoicesResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): GetCompanyInvoicesResponse;
|
|
916
|
+
|
|
917
|
+
declare function GetCompanyInvoicesResponseToJSON(json: any): GetCompanyInvoicesResponse;
|
|
918
|
+
|
|
919
|
+
declare function GetCompanyInvoicesResponseToJSONTyped(value?: GetCompanyInvoicesResponse | null, ignoreDiscriminator?: boolean): any;
|
|
920
|
+
|
|
921
|
+
/**
|
|
922
|
+
* Check if a given object implements the ApiError interface.
|
|
923
|
+
*/
|
|
924
|
+
declare function instanceOfApiError(value: object): value is ApiError;
|
|
925
|
+
|
|
926
|
+
/**
|
|
927
|
+
* Check if a given object implements the CompanyInvoiceResponseData interface.
|
|
928
|
+
*/
|
|
929
|
+
declare function instanceOfCompanyInvoiceResponseData(value: object): value is CompanyInvoiceResponseData;
|
|
930
|
+
|
|
931
|
+
/**
|
|
932
|
+
* Check if a given object implements the CompanyInvoicesResponseData interface.
|
|
933
|
+
*/
|
|
934
|
+
declare function instanceOfCompanyInvoicesResponseData(value: object): value is CompanyInvoicesResponseData;
|
|
935
|
+
|
|
936
|
+
/**
|
|
937
|
+
* Check if a given object implements the GetCompanyInvoicesParams interface.
|
|
938
|
+
*/
|
|
939
|
+
declare function instanceOfGetCompanyInvoicesParams(value: object): value is GetCompanyInvoicesParams;
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* Check if a given object implements the GetCompanyInvoicesResponse interface.
|
|
943
|
+
*/
|
|
944
|
+
declare function instanceOfGetCompanyInvoicesResponse(value: object): value is GetCompanyInvoicesResponse;
|
|
945
|
+
|
|
946
|
+
declare function instanceOfInvoiceStatus(value: any): boolean;
|
|
947
|
+
|
|
948
|
+
export declare type Invoice = CompanyInvoiceResponseData;
|
|
949
|
+
|
|
950
|
+
/** A `limit` above this is a 400 (PaginationFilter in schematic-api). */
|
|
951
|
+
export declare const INVOICE_MAX_PAGE_SIZE = 250;
|
|
952
|
+
|
|
953
|
+
export declare const INVOICE_PAGE_SIZE = 12;
|
|
954
|
+
|
|
955
|
+
export declare interface InvoicePage {
|
|
956
|
+
invoices: Invoice[];
|
|
957
|
+
/** Matching the query on the server, not the number loaded here. */
|
|
958
|
+
count: number;
|
|
959
|
+
hasMore: boolean;
|
|
960
|
+
}
|
|
961
|
+
|
|
962
|
+
/** Each distinct query is its own row set with its own paging. */
|
|
963
|
+
export declare interface InvoiceQuery {
|
|
964
|
+
/** Include unpaid invoices that are not yet due. Default false. */
|
|
965
|
+
includePending?: boolean;
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
export declare interface InvoicesRequest extends InvoiceQuery {
|
|
969
|
+
limit: number;
|
|
970
|
+
offset: number;
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* The rows asked for, and how many the query matches in total. `hasMore` is
|
|
975
|
+
* the page's, and only the caller knows its offset.
|
|
976
|
+
*/
|
|
977
|
+
export declare type InvoicesResult = Omit<InvoicePage, "hasMore">;
|
|
978
|
+
|
|
979
|
+
/**
|
|
980
|
+
*
|
|
981
|
+
* @export
|
|
982
|
+
*/
|
|
983
|
+
export declare const InvoiceStatus: {
|
|
984
|
+
readonly Draft: "draft";
|
|
985
|
+
readonly Open: "open";
|
|
986
|
+
readonly Paid: "paid";
|
|
987
|
+
readonly Uncollectible: "uncollectible";
|
|
988
|
+
readonly Void: "void";
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
export declare type InvoiceStatus = (typeof InvoiceStatus)[keyof typeof InvoiceStatus];
|
|
992
|
+
|
|
993
|
+
declare function InvoiceStatusFromJSON(json: any): InvoiceStatus;
|
|
994
|
+
|
|
995
|
+
declare function InvoiceStatusFromJSONTyped(json: any, ignoreDiscriminator: boolean): InvoiceStatus;
|
|
996
|
+
|
|
997
|
+
declare function InvoiceStatusToJSON(value?: InvoiceStatus | null): any;
|
|
998
|
+
|
|
999
|
+
declare function InvoiceStatusToJSONTyped(value: any, ignoreDiscriminator: boolean): InvoiceStatus;
|
|
1000
|
+
|
|
1001
|
+
/** A record of unique key-value pairs used for identifying a company or user */
|
|
1002
|
+
export declare type Keys = Record<string, string>;
|
|
1003
|
+
|
|
1004
|
+
/**
|
|
1005
|
+
*
|
|
490
1006
|
* @export
|
|
491
1007
|
*/
|
|
492
|
-
declare const
|
|
1008
|
+
declare const MetricPeriod: {
|
|
493
1009
|
readonly AllTime: "all_time";
|
|
494
1010
|
readonly CurrentDay: "current_day";
|
|
495
1011
|
readonly CurrentMonth: "current_month";
|
|
496
1012
|
readonly CurrentWeek: "current_week";
|
|
497
1013
|
};
|
|
498
1014
|
|
|
499
|
-
declare type
|
|
1015
|
+
declare type MetricPeriod = (typeof MetricPeriod)[keyof typeof MetricPeriod];
|
|
500
1016
|
|
|
501
1017
|
/**
|
|
1018
|
+
*
|
|
502
1019
|
* @export
|
|
503
1020
|
*/
|
|
504
|
-
declare const
|
|
505
|
-
readonly FirstOfMonth: "first_of_month";
|
|
1021
|
+
declare const MetricPeriodMonthReset: {
|
|
506
1022
|
readonly BillingCycle: "billing_cycle";
|
|
1023
|
+
readonly FirstOfMonth: "first_of_month";
|
|
507
1024
|
};
|
|
508
1025
|
|
|
509
|
-
declare type
|
|
510
|
-
|
|
511
|
-
export declare type FlagCheckListenerFn = CheckFlagReturnListenerFn | EmptyListenerFn;
|
|
512
|
-
|
|
513
|
-
export declare type FlagValueListenerFn = BooleanListenerFn | EmptyListenerFn;
|
|
1026
|
+
declare type MetricPeriodMonthReset = (typeof MetricPeriodMonthReset)[keyof typeof MetricPeriodMonthReset];
|
|
514
1027
|
|
|
515
|
-
/**
|
|
516
|
-
|
|
1028
|
+
/**
|
|
1029
|
+
* The store keys a resource by the query's shape, so without this
|
|
1030
|
+
* `{ includePending: false }` is a different row set from `{}` — it would
|
|
1031
|
+
* miss the seed and refetch rows identical to those already on screen.
|
|
1032
|
+
*/
|
|
1033
|
+
export declare function normalizeInvoiceQuery(query: InvoiceQuery): InvoiceQuery;
|
|
517
1034
|
|
|
518
1035
|
export declare type PendingListenerFn = BooleanListenerFn | EmptyListenerFn;
|
|
519
1036
|
|
|
520
1037
|
export declare type PlanListenerFn = CheckPlanReturnListenerFn | EmptyListenerFn;
|
|
521
1038
|
|
|
1039
|
+
export declare interface RequestOptions {
|
|
1040
|
+
method?: string;
|
|
1041
|
+
body?: unknown;
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
export declare interface ResourceState<T> {
|
|
1045
|
+
/** `undefined` until the first successful load; retained across later errors. */
|
|
1046
|
+
data: T | undefined;
|
|
1047
|
+
/** The latest failure; cleared by the next success. */
|
|
1048
|
+
error: Error | undefined;
|
|
1049
|
+
/** A request is in flight and no data has arrived yet, or a refetch is running. */
|
|
1050
|
+
isPending: boolean;
|
|
1051
|
+
}
|
|
1052
|
+
|
|
522
1053
|
export declare enum RuleType {
|
|
523
1054
|
/** A global rule that, if present, will override all other rules for a flag */
|
|
524
1055
|
GLOBAL_OVERRIDE = "global_override",
|
|
@@ -536,6 +1067,22 @@ export declare enum RuleType {
|
|
|
536
1067
|
DEFAULT = "default"
|
|
537
1068
|
}
|
|
538
1069
|
|
|
1070
|
+
/**
|
|
1071
|
+
*
|
|
1072
|
+
* @export
|
|
1073
|
+
*/
|
|
1074
|
+
declare const RuleType_2: {
|
|
1075
|
+
readonly CompanyOverride: "company_override";
|
|
1076
|
+
readonly CompanyOverrideUsageExceeded: "company_override_usage_exceeded";
|
|
1077
|
+
readonly Default: "default";
|
|
1078
|
+
readonly GlobalOverride: "global_override";
|
|
1079
|
+
readonly PlanEntitlement: "plan_entitlement";
|
|
1080
|
+
readonly PlanEntitlementUsageExceeded: "plan_entitlement_usage_exceeded";
|
|
1081
|
+
readonly Standard: "standard";
|
|
1082
|
+
};
|
|
1083
|
+
|
|
1084
|
+
declare type RuleType_2 = (typeof RuleType_2)[keyof typeof RuleType_2];
|
|
1085
|
+
|
|
539
1086
|
export declare class Schematic {
|
|
540
1087
|
private additionalHeaders;
|
|
541
1088
|
private apiKey;
|
|
@@ -552,11 +1099,17 @@ export declare class Schematic {
|
|
|
552
1099
|
private isPending;
|
|
553
1100
|
private isPendingListeners;
|
|
554
1101
|
private planListeners;
|
|
1102
|
+
private creditBalanceListeners;
|
|
555
1103
|
private storage;
|
|
1104
|
+
private persistFlagState;
|
|
1105
|
+
private flagStateCacheKey;
|
|
1106
|
+
private flagStateCacheMaxAgeMs;
|
|
1107
|
+
private cachedFlagState;
|
|
556
1108
|
private useWebSocket;
|
|
557
1109
|
private checks;
|
|
558
1110
|
private featureUsageEventMap;
|
|
559
1111
|
private planChecks;
|
|
1112
|
+
private creditBalances;
|
|
560
1113
|
private webSocketUrl;
|
|
561
1114
|
private webSocketConnectionTimeout;
|
|
562
1115
|
private webSocketReconnect;
|
|
@@ -663,6 +1216,13 @@ export declare class Schematic {
|
|
|
663
1216
|
private stopRetryTimer;
|
|
664
1217
|
private flushEventQueue;
|
|
665
1218
|
private getAnonymousId;
|
|
1219
|
+
private hasCachedValuesForContext;
|
|
1220
|
+
private readFlagStateCache;
|
|
1221
|
+
private reviveCachedCheck;
|
|
1222
|
+
private reviveCachedPlan;
|
|
1223
|
+
private reviveCachedCreditBalances;
|
|
1224
|
+
private hydrateFlagStateFromCache;
|
|
1225
|
+
private persistContextToCache;
|
|
666
1226
|
private handleEvent;
|
|
667
1227
|
private sendEvent;
|
|
668
1228
|
private storeEvent;
|
|
@@ -762,6 +1322,10 @@ export declare class Schematic {
|
|
|
762
1322
|
addIsPendingListener: (listener: PendingListenerFn) => () => void;
|
|
763
1323
|
private setIsPending;
|
|
764
1324
|
getPlan: () => CheckPlanReturn | undefined;
|
|
1325
|
+
/** Get the company's lease-aware credit balances for the current context, keyed by credit ID */
|
|
1326
|
+
getCreditBalances: () => CreditBalances;
|
|
1327
|
+
/** Get the company's lease-aware balance for a single credit type in the current context */
|
|
1328
|
+
getCreditBalance: (creditId: string) => CreditBalance | undefined;
|
|
765
1329
|
getFlagCheck: (flagKey: string) => CheckFlagReturn | undefined;
|
|
766
1330
|
getFlagValue: (flagKey: string) => boolean | undefined;
|
|
767
1331
|
/** Register an event listener that will be notified with the boolean value for a given flag when this value changes */
|
|
@@ -769,11 +1333,35 @@ export declare class Schematic {
|
|
|
769
1333
|
/** Register an event listener that will be notified with the full flag check response for a given flag whenever this value changes */
|
|
770
1334
|
addFlagCheckListener: (flagKey: string, listener: FlagCheckListenerFn) => () => void;
|
|
771
1335
|
addPlanListener: (listener: PlanListenerFn) => () => void;
|
|
1336
|
+
/** Register an event listener that will be notified with the company's credit balances (keyed by credit ID) whenever they change */
|
|
1337
|
+
addCreditBalanceListener: (listener: CreditBalanceListenerFn) => () => void;
|
|
772
1338
|
private notifyFlagCheckListeners;
|
|
773
1339
|
/** Add or update a CheckFlagReturn in the featureUsageEventMap */
|
|
774
1340
|
private updateFeatureUsageEventMap;
|
|
775
1341
|
private notifyFlagValueListeners;
|
|
776
1342
|
private notifyPlanListeners;
|
|
1343
|
+
private notifyCreditBalanceListeners;
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
export declare class SchematicApiError extends Error {
|
|
1347
|
+
readonly status: number;
|
|
1348
|
+
readonly path: string;
|
|
1349
|
+
readonly body: unknown;
|
|
1350
|
+
constructor(status: number, path: string, body: unknown);
|
|
1351
|
+
}
|
|
1352
|
+
|
|
1353
|
+
export declare class SchematicBillingClient implements BillingClient {
|
|
1354
|
+
/**
|
|
1355
|
+
* Public so a second client over the same surface can be constructed on
|
|
1356
|
+
* this one rather than minting tokens of its own.
|
|
1357
|
+
*/
|
|
1358
|
+
readonly session: SchematicSession;
|
|
1359
|
+
constructor(options?: BillingClientOptions | SchematicSession);
|
|
1360
|
+
get sessionKey(): string | undefined;
|
|
1361
|
+
get sessionStatus(): SessionStatus;
|
|
1362
|
+
setSession(session: SessionInput): void;
|
|
1363
|
+
onSessionChange(listener: (event: SessionEvent) => void): () => void;
|
|
1364
|
+
fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
|
|
777
1365
|
}
|
|
778
1366
|
|
|
779
1367
|
/** Context for checking flags and sending events */
|
|
@@ -798,6 +1386,12 @@ export declare type SchematicOptions = {
|
|
|
798
1386
|
offline?: boolean;
|
|
799
1387
|
/** Optionally provide a custom storage persister for client-side storage */
|
|
800
1388
|
storage?: StoragePersister;
|
|
1389
|
+
/** 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.
|
|
1390
|
+
*
|
|
1391
|
+
* 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. */
|
|
1392
|
+
persistFlagState?: boolean;
|
|
1393
|
+
/** 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. */
|
|
1394
|
+
flagStateCacheMaxAgeMs?: number;
|
|
801
1395
|
/** Use a WebSocket connection for real-time flag checks; if using this, run the cleanup function to close the connection */
|
|
802
1396
|
useWebSocket?: boolean;
|
|
803
1397
|
/** Optionally provide a custom WebSocket URL */
|
|
@@ -826,6 +1420,111 @@ export declare type SchematicOptions = {
|
|
|
826
1420
|
flagCheckDefaults?: Record<string, CheckFlagReturn>;
|
|
827
1421
|
};
|
|
828
1422
|
|
|
1423
|
+
/**
|
|
1424
|
+
* Session identity is the (company, user) pair alone: a freshly minted token,
|
|
1425
|
+
* a rebuilt provider closure, and a refresh this session asked for itself are
|
|
1426
|
+
* all the same session. Nothing in a token says who it was minted for, so
|
|
1427
|
+
* that question is the host's to answer.
|
|
1428
|
+
*
|
|
1429
|
+
* Credentials survive a change of session, keyed by pair — switching back to
|
|
1430
|
+
* a company reads with the token already in hand. They do not survive the
|
|
1431
|
+
* session ending: after a sign-out the next person at this page is somebody
|
|
1432
|
+
* else, and nothing minted for the last one is theirs to send.
|
|
1433
|
+
*/
|
|
1434
|
+
export declare class SchematicSession {
|
|
1435
|
+
private readonly _apiUrl;
|
|
1436
|
+
private readonly _headers;
|
|
1437
|
+
private readonly _fetch;
|
|
1438
|
+
private _session;
|
|
1439
|
+
private readonly _tokens;
|
|
1440
|
+
private readonly _resolving;
|
|
1441
|
+
/**
|
|
1442
|
+
* Bumped when the session's identity changes, and only then — the object
|
|
1443
|
+
* itself is replaced on every render. Anything asking "is this still the
|
|
1444
|
+
* session I started under?" counts generations rather than comparing.
|
|
1445
|
+
*/
|
|
1446
|
+
private _generation;
|
|
1447
|
+
private readonly _listeners;
|
|
1448
|
+
constructor(options?: SessionOptions);
|
|
1449
|
+
get key(): string | undefined;
|
|
1450
|
+
get status(): SessionStatus;
|
|
1451
|
+
/** Only a statement that changes which pair is read counts as a change. */
|
|
1452
|
+
set(session: SessionInput): void;
|
|
1453
|
+
onChange(listener: (event: SessionEvent) => void): () => void;
|
|
1454
|
+
private _emit;
|
|
1455
|
+
private _cached;
|
|
1456
|
+
private _cache;
|
|
1457
|
+
/**
|
|
1458
|
+
* The credential for a session, minted if this one is not held. `force`
|
|
1459
|
+
* retires what is held first: the caller is a request the API has just
|
|
1460
|
+
* rejected.
|
|
1461
|
+
*/
|
|
1462
|
+
resolveToken(session: Session, force: boolean): Promise<string>;
|
|
1463
|
+
/**
|
|
1464
|
+
* Sends a request under the active session's credential, refreshing once
|
|
1465
|
+
* and retrying if the API rejects it. Rejects rather than answering when
|
|
1466
|
+
* the session changes while the request is in flight: the rows would
|
|
1467
|
+
* otherwise come back as the answer to a question asked for another pair.
|
|
1468
|
+
*/
|
|
1469
|
+
request(path: string, options?: RequestOptions): Promise<unknown>;
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
/**
|
|
1473
|
+
* Who is being read. Users and companies are many-to-many: the same person
|
|
1474
|
+
* reads one company's billing and then another's, and the same company is
|
|
1475
|
+
* read by several people. A token is minted for the pair, so the pair — not
|
|
1476
|
+
* the company alone — is the session's identity.
|
|
1477
|
+
*/
|
|
1478
|
+
export declare interface Session {
|
|
1479
|
+
/** The host's name for the company, its id in their own system say. */
|
|
1480
|
+
company: string;
|
|
1481
|
+
/**
|
|
1482
|
+
* The user, where the host mints per (company, user). Left out by a host
|
|
1483
|
+
* whose tokens are company-wide, and then every reader of that company
|
|
1484
|
+
* shares one session.
|
|
1485
|
+
*/
|
|
1486
|
+
user?: string;
|
|
1487
|
+
token: AccessToken;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
/**
|
|
1491
|
+
* What happened to the session, for anything holding data that belongs to
|
|
1492
|
+
* one. `started`: whatever is loaded belongs to the new session — a prefetch
|
|
1493
|
+
* the host seeded before its auth resolved. `changed`: another pair is being
|
|
1494
|
+
* read, and what is loaded belongs to the pair being left. `ended`: nobody is
|
|
1495
|
+
* signed in, and what is loaded belongs to nobody.
|
|
1496
|
+
*/
|
|
1497
|
+
export declare type SessionEvent = {
|
|
1498
|
+
type: "started" | "changed" | "ended";
|
|
1499
|
+
};
|
|
1500
|
+
|
|
1501
|
+
/**
|
|
1502
|
+
* Three states that are not interchangeable:
|
|
1503
|
+
*
|
|
1504
|
+
* * `Session` — active: this pair, read with this credential.
|
|
1505
|
+
* * `null` — ended: nobody is signed in; what is loaded is dropped.
|
|
1506
|
+
* * `undefined` — pending: the host's auth has not resolved. It states
|
|
1507
|
+
* nothing, so the session in hand stands.
|
|
1508
|
+
*/
|
|
1509
|
+
export declare type SessionInput = Session | null | undefined;
|
|
1510
|
+
|
|
1511
|
+
/**
|
|
1512
|
+
* The pair as one string, for anything that has to compare sessions or key
|
|
1513
|
+
* something by one — a prefetch stating which session it was fetched for, a
|
|
1514
|
+
* store keeping a page per session. Opaque: read it only by equality.
|
|
1515
|
+
*/
|
|
1516
|
+
export declare function sessionKey(session: Session): string;
|
|
1517
|
+
|
|
1518
|
+
export declare interface SessionOptions {
|
|
1519
|
+
session?: SessionInput;
|
|
1520
|
+
apiUrl?: string;
|
|
1521
|
+
additionalHeaders?: Record<string, string>;
|
|
1522
|
+
/** Override for tests and non-browser runtimes. */
|
|
1523
|
+
fetch?: typeof fetch;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
export declare type SessionStatus = "pending" | "active" | "ended";
|
|
1527
|
+
|
|
829
1528
|
/** Optional type for implementing custom client-side storage */
|
|
830
1529
|
export declare type StoragePersister = {
|
|
831
1530
|
setItem(key: string, value: any): void;
|
|
@@ -833,6 +1532,15 @@ export declare type StoragePersister = {
|
|
|
833
1532
|
removeItem(key: string): void;
|
|
834
1533
|
};
|
|
835
1534
|
|
|
1535
|
+
/**
|
|
1536
|
+
* Sessions whose credentials are kept. A reader switching between the
|
|
1537
|
+
* organizations they belong to walks a handful of them and comes back, and
|
|
1538
|
+
* re-minting on every step is a round trip to the host's token endpoint for
|
|
1539
|
+
* a token this client already holds and has not seen expire. The same
|
|
1540
|
+
* handful the flag cache bounds its contexts at.
|
|
1541
|
+
*/
|
|
1542
|
+
export declare const TOKEN_CACHE_SIZE = 10;
|
|
1543
|
+
|
|
836
1544
|
/**
|
|
837
1545
|
* A flexible key/value type that can store any type of value on a company or user.
|
|
838
1546
|
*/
|
|
@@ -857,4 +1565,35 @@ export declare enum UsagePeriod {
|
|
|
857
1565
|
CURRENT_WEEK = "current_week"
|
|
858
1566
|
}
|
|
859
1567
|
|
|
1568
|
+
/**
|
|
1569
|
+
* Schematic API
|
|
1570
|
+
* Schematic API
|
|
1571
|
+
*
|
|
1572
|
+
* The version of the OpenAPI document: 0.1
|
|
1573
|
+
*
|
|
1574
|
+
*
|
|
1575
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
1576
|
+
* https://openapi-generator.tech
|
|
1577
|
+
* Do not edit the class manually.
|
|
1578
|
+
*/
|
|
1579
|
+
/**
|
|
1580
|
+
*
|
|
1581
|
+
* @export
|
|
1582
|
+
* @interface WarningTier
|
|
1583
|
+
*/
|
|
1584
|
+
declare interface WarningTier {
|
|
1585
|
+
/**
|
|
1586
|
+
* A customer-defined identifier for the warning tier
|
|
1587
|
+
* @type {string}
|
|
1588
|
+
* @memberof WarningTier
|
|
1589
|
+
*/
|
|
1590
|
+
key: string;
|
|
1591
|
+
/**
|
|
1592
|
+
* The warning threshold, in the entitlement's usage units
|
|
1593
|
+
* @type {number}
|
|
1594
|
+
* @memberof WarningTier
|
|
1595
|
+
*/
|
|
1596
|
+
value: number;
|
|
1597
|
+
}
|
|
1598
|
+
|
|
860
1599
|
export { }
|