@schematichq/schematic-js 1.5.0 → 1.7.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.
@@ -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
  /**
@@ -276,6 +431,92 @@ export declare interface CompanyCreditBalance {
276
431
  settled: number;
277
432
  }
278
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
+
279
520
  /** A company's lease-aware balance for a single credit type */
280
521
  export declare type CreditBalance = {
281
522
  /** Spendable balance including any open lease hold (remaining + reserved); the number to display to end users */
@@ -329,6 +570,8 @@ declare interface DatastreamCompanyPlan {
329
570
 
330
571
  export declare function DatastreamCompanyPlanFromJSON(json: any): DatastreamCompanyPlan;
331
572
 
573
+ export declare const DEFAULT_INVOICE_QUERY: InvoiceQuery;
574
+
332
575
  export declare type EmptyListenerFn = () => void;
333
576
 
334
577
  /**
@@ -401,6 +644,12 @@ export declare interface EventBodyFlagCheck {
401
644
  * @memberof EventBodyFlagCheck
402
645
  */
403
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;
404
653
  /**
405
654
  * The reason why the value was returned
406
655
  * @type {string}
@@ -578,12 +827,177 @@ declare interface FeatureEntitlement {
578
827
  * @memberof FeatureEntitlement
579
828
  */
580
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>;
581
836
  }
582
837
 
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
+
583
844
  export declare type FlagCheckListenerFn = CheckFlagReturnListenerFn | EmptyListenerFn;
584
845
 
585
846
  export declare type FlagValueListenerFn = BooleanListenerFn | EmptyListenerFn;
586
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
+
587
1001
  /** A record of unique key-value pairs used for identifying a company or user */
588
1002
  export declare type Keys = Record<string, string>;
589
1003
 
@@ -611,10 +1025,31 @@ declare const MetricPeriodMonthReset: {
611
1025
 
612
1026
  declare type MetricPeriodMonthReset = (typeof MetricPeriodMonthReset)[keyof typeof MetricPeriodMonthReset];
613
1027
 
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;
1034
+
614
1035
  export declare type PendingListenerFn = BooleanListenerFn | EmptyListenerFn;
615
1036
 
616
1037
  export declare type PlanListenerFn = CheckPlanReturnListenerFn | EmptyListenerFn;
617
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
+
618
1053
  export declare enum RuleType {
619
1054
  /** A global rule that, if present, will override all other rules for a flag */
620
1055
  GLOBAL_OVERRIDE = "global_override",
@@ -649,9 +1084,9 @@ declare const RuleType_2: {
649
1084
  declare type RuleType_2 = (typeof RuleType_2)[keyof typeof RuleType_2];
650
1085
 
651
1086
  export declare class Schematic {
652
- private additionalHeaders;
1087
+ private _additionalHeaders;
653
1088
  private apiKey;
654
- private apiUrl;
1089
+ private _apiUrl;
655
1090
  private conn;
656
1091
  private context;
657
1092
  private debugEnabled;
@@ -696,6 +1131,8 @@ export declare class Schematic {
696
1131
  private flagCheckDefaults;
697
1132
  private fallbackCheckCache;
698
1133
  constructor(apiKey: string, options?: SchematicOptions);
1134
+ get apiUrl(): string;
1135
+ get additionalHeaders(): Record<string, string>;
699
1136
  /**
700
1137
  * Resolve fallback value according to priority order:
701
1138
  * 1. Callsite fallback value (if provided)
@@ -908,6 +1345,27 @@ export declare class Schematic {
908
1345
  private notifyCreditBalanceListeners;
909
1346
  }
910
1347
 
1348
+ export declare class SchematicApiError extends Error {
1349
+ readonly status: number;
1350
+ readonly path: string;
1351
+ readonly body: unknown;
1352
+ constructor(status: number, path: string, body: unknown);
1353
+ }
1354
+
1355
+ export declare class SchematicBillingClient implements BillingClient {
1356
+ /**
1357
+ * Public so a second client over the same surface can be constructed on
1358
+ * this one rather than minting tokens of its own.
1359
+ */
1360
+ readonly session: SchematicSession;
1361
+ constructor(options?: BillingClientOptions | SchematicSession);
1362
+ get sessionKey(): string | undefined;
1363
+ get sessionStatus(): SessionStatus;
1364
+ setSession(session: SessionInput): void;
1365
+ onSessionChange(listener: (event: SessionEvent) => void): () => void;
1366
+ fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
1367
+ }
1368
+
911
1369
  /** Context for checking flags and sending events */
912
1370
  export declare type SchematicContext = {
913
1371
  company?: Keys;
@@ -964,6 +1422,111 @@ export declare type SchematicOptions = {
964
1422
  flagCheckDefaults?: Record<string, CheckFlagReturn>;
965
1423
  };
966
1424
 
1425
+ /**
1426
+ * Session identity is the (company, user) pair alone: a freshly minted token,
1427
+ * a rebuilt provider closure, and a refresh this session asked for itself are
1428
+ * all the same session. Nothing in a token says who it was minted for, so
1429
+ * that question is the host's to answer.
1430
+ *
1431
+ * Credentials survive a change of session, keyed by pair — switching back to
1432
+ * a company reads with the token already in hand. They do not survive the
1433
+ * session ending: after a sign-out the next person at this page is somebody
1434
+ * else, and nothing minted for the last one is theirs to send.
1435
+ */
1436
+ export declare class SchematicSession {
1437
+ private readonly _apiUrl;
1438
+ private readonly _headers;
1439
+ private readonly _fetch;
1440
+ private _session;
1441
+ private readonly _tokens;
1442
+ private readonly _resolving;
1443
+ /**
1444
+ * Bumped when the session's identity changes, and only then — the object
1445
+ * itself is replaced on every render. Anything asking "is this still the
1446
+ * session I started under?" counts generations rather than comparing.
1447
+ */
1448
+ private _generation;
1449
+ private readonly _listeners;
1450
+ constructor(options?: SessionOptions);
1451
+ get key(): string | undefined;
1452
+ get status(): SessionStatus;
1453
+ /** Only a statement that changes which pair is read counts as a change. */
1454
+ set(session: SessionInput): void;
1455
+ onChange(listener: (event: SessionEvent) => void): () => void;
1456
+ private _emit;
1457
+ private _cached;
1458
+ private _cache;
1459
+ /**
1460
+ * The credential for a session, minted if this one is not held. `force`
1461
+ * retires what is held first: the caller is a request the API has just
1462
+ * rejected.
1463
+ */
1464
+ resolveToken(session: Session, force: boolean): Promise<string>;
1465
+ /**
1466
+ * Sends a request under the active session's credential, refreshing once
1467
+ * and retrying if the API rejects it. Rejects rather than answering when
1468
+ * the session changes while the request is in flight: the rows would
1469
+ * otherwise come back as the answer to a question asked for another pair.
1470
+ */
1471
+ request(path: string, options?: RequestOptions): Promise<unknown>;
1472
+ }
1473
+
1474
+ /**
1475
+ * Who is being read. Users and companies are many-to-many: the same person
1476
+ * reads one company's billing and then another's, and the same company is
1477
+ * read by several people. A token is minted for the pair, so the pair — not
1478
+ * the company alone — is the session's identity.
1479
+ */
1480
+ export declare interface Session {
1481
+ /** The host's name for the company, its id in their own system say. */
1482
+ company: string;
1483
+ /**
1484
+ * The user, where the host mints per (company, user). Left out by a host
1485
+ * whose tokens are company-wide, and then every reader of that company
1486
+ * shares one session.
1487
+ */
1488
+ user?: string;
1489
+ token: AccessToken;
1490
+ }
1491
+
1492
+ /**
1493
+ * What happened to the session, for anything holding data that belongs to
1494
+ * one. `started`: whatever is loaded belongs to the new session — a prefetch
1495
+ * the host seeded before its auth resolved. `changed`: another pair is being
1496
+ * read, and what is loaded belongs to the pair being left. `ended`: nobody is
1497
+ * signed in, and what is loaded belongs to nobody.
1498
+ */
1499
+ export declare type SessionEvent = {
1500
+ type: "started" | "changed" | "ended";
1501
+ };
1502
+
1503
+ /**
1504
+ * Three states that are not interchangeable:
1505
+ *
1506
+ * * `Session` — active: this pair, read with this credential.
1507
+ * * `null` — ended: nobody is signed in; what is loaded is dropped.
1508
+ * * `undefined` — pending: the host's auth has not resolved. It states
1509
+ * nothing, so the session in hand stands.
1510
+ */
1511
+ export declare type SessionInput = Session | null | undefined;
1512
+
1513
+ /**
1514
+ * The pair as one string, for anything that has to compare sessions or key
1515
+ * something by one — a prefetch stating which session it was fetched for, a
1516
+ * store keeping a page per session. Opaque: read it only by equality.
1517
+ */
1518
+ export declare function sessionKey(session: Session): string;
1519
+
1520
+ export declare interface SessionOptions {
1521
+ session?: SessionInput;
1522
+ apiUrl?: string;
1523
+ additionalHeaders?: Record<string, string>;
1524
+ /** Override for tests and non-browser runtimes. */
1525
+ fetch?: typeof fetch;
1526
+ }
1527
+
1528
+ export declare type SessionStatus = "pending" | "active" | "ended";
1529
+
967
1530
  /** Optional type for implementing custom client-side storage */
968
1531
  export declare type StoragePersister = {
969
1532
  setItem(key: string, value: any): void;
@@ -971,6 +1534,15 @@ export declare type StoragePersister = {
971
1534
  removeItem(key: string): void;
972
1535
  };
973
1536
 
1537
+ /**
1538
+ * Sessions whose credentials are kept. A reader switching between the
1539
+ * organizations they belong to walks a handful of them and comes back, and
1540
+ * re-minting on every step is a round trip to the host's token endpoint for
1541
+ * a token this client already holds and has not seen expire. The same
1542
+ * handful the flag cache bounds its contexts at.
1543
+ */
1544
+ export declare const TOKEN_CACHE_SIZE = 10;
1545
+
974
1546
  /**
975
1547
  * A flexible key/value type that can store any type of value on a company or user.
976
1548
  */
@@ -995,4 +1567,35 @@ export declare enum UsagePeriod {
995
1567
  CURRENT_WEEK = "current_week"
996
1568
  }
997
1569
 
1570
+ /**
1571
+ * Schematic API
1572
+ * Schematic API
1573
+ *
1574
+ * The version of the OpenAPI document: 0.1
1575
+ *
1576
+ *
1577
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1578
+ * https://openapi-generator.tech
1579
+ * Do not edit the class manually.
1580
+ */
1581
+ /**
1582
+ *
1583
+ * @export
1584
+ * @interface WarningTier
1585
+ */
1586
+ declare interface WarningTier {
1587
+ /**
1588
+ * A customer-defined identifier for the warning tier
1589
+ * @type {string}
1590
+ * @memberof WarningTier
1591
+ */
1592
+ key: string;
1593
+ /**
1594
+ * The warning threshold, in the entitlement's usage units
1595
+ * @type {number}
1596
+ * @memberof WarningTier
1597
+ */
1598
+ value: number;
1599
+ }
1600
+
998
1601
  export { }