@schematichq/schematic-vue 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,9 +1,246 @@
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
+ instanceOfBillingProviderType,
41
+ BillingProviderTypeFromJSON,
42
+ BillingProviderTypeFromJSONTyped,
43
+ BillingProviderTypeToJSON,
44
+ BillingProviderTypeToJSONTyped,
45
+ BillingProviderType,
46
+ instanceOfCompanyDiscountResponseData,
47
+ CompanyDiscountResponseDataFromJSON,
48
+ CompanyDiscountResponseDataFromJSONTyped,
49
+ CompanyDiscountResponseDataToJSON,
50
+ CompanyDiscountResponseDataToJSONTyped,
51
+ CompanyDiscountResponseData,
52
+ instanceOfCompanyInvoiceResponseData,
53
+ CompanyInvoiceResponseDataFromJSON,
54
+ CompanyInvoiceResponseDataFromJSONTyped,
55
+ CompanyInvoiceResponseDataToJSON,
56
+ CompanyInvoiceResponseDataToJSONTyped,
57
+ CompanyInvoiceResponseData,
58
+ instanceOfCompanyInvoicesResponseData,
59
+ CompanyInvoicesResponseDataFromJSON,
60
+ CompanyInvoicesResponseDataFromJSONTyped,
61
+ CompanyInvoicesResponseDataToJSON,
62
+ CompanyInvoicesResponseDataToJSONTyped,
63
+ CompanyInvoicesResponseData,
64
+ instanceOfCompanyPaymentMethodResponseData,
65
+ CompanyPaymentMethodResponseDataFromJSON,
66
+ CompanyPaymentMethodResponseDataFromJSONTyped,
67
+ CompanyPaymentMethodResponseDataToJSON,
68
+ CompanyPaymentMethodResponseDataToJSONTyped,
69
+ CompanyPaymentMethodResponseData,
70
+ instanceOfCompanyPaymentMethodsResponseData,
71
+ CompanyPaymentMethodsResponseDataFromJSON,
72
+ CompanyPaymentMethodsResponseDataFromJSONTyped,
73
+ CompanyPaymentMethodsResponseDataToJSON,
74
+ CompanyPaymentMethodsResponseDataToJSONTyped,
75
+ CompanyPaymentMethodsResponseData,
76
+ instanceOfCompanyUpcomingInvoiceResponseData,
77
+ CompanyUpcomingInvoiceResponseDataFromJSON,
78
+ CompanyUpcomingInvoiceResponseDataFromJSONTyped,
79
+ CompanyUpcomingInvoiceResponseDataToJSON,
80
+ CompanyUpcomingInvoiceResponseDataToJSONTyped,
81
+ CompanyUpcomingInvoiceResponseData,
82
+ instanceOfCreateSetupIntentResponse,
83
+ CreateSetupIntentResponseFromJSON,
84
+ CreateSetupIntentResponseFromJSONTyped,
85
+ CreateSetupIntentResponseToJSON,
86
+ CreateSetupIntentResponseToJSONTyped,
87
+ CreateSetupIntentResponse,
88
+ instanceOfDeletePaymentMethodResponse,
89
+ DeletePaymentMethodResponseFromJSON,
90
+ DeletePaymentMethodResponseFromJSONTyped,
91
+ DeletePaymentMethodResponseToJSON,
92
+ DeletePaymentMethodResponseToJSONTyped,
93
+ DeletePaymentMethodResponse,
94
+ instanceOfDeleteResponse,
95
+ DeleteResponseFromJSON,
96
+ DeleteResponseFromJSONTyped,
97
+ DeleteResponseToJSON,
98
+ DeleteResponseToJSONTyped,
99
+ DeleteResponse,
100
+ instanceOfGetCompanyInvoicesParams,
101
+ GetCompanyInvoicesParamsFromJSON,
102
+ GetCompanyInvoicesParamsFromJSONTyped,
103
+ GetCompanyInvoicesParamsToJSON,
104
+ GetCompanyInvoicesParamsToJSONTyped,
105
+ GetCompanyInvoicesParams,
106
+ instanceOfGetCompanyInvoicesResponse,
107
+ GetCompanyInvoicesResponseFromJSON,
108
+ GetCompanyInvoicesResponseFromJSONTyped,
109
+ GetCompanyInvoicesResponseToJSON,
110
+ GetCompanyInvoicesResponseToJSONTyped,
111
+ GetCompanyInvoicesResponse,
112
+ instanceOfGetCompanyPaymentMethodsResponse,
113
+ GetCompanyPaymentMethodsResponseFromJSON,
114
+ GetCompanyPaymentMethodsResponseFromJSONTyped,
115
+ GetCompanyPaymentMethodsResponseToJSON,
116
+ GetCompanyPaymentMethodsResponseToJSONTyped,
117
+ GetCompanyPaymentMethodsResponse,
118
+ instanceOfGetCompanyUpcomingInvoiceResponse,
119
+ GetCompanyUpcomingInvoiceResponseFromJSON,
120
+ GetCompanyUpcomingInvoiceResponseFromJSONTyped,
121
+ GetCompanyUpcomingInvoiceResponseToJSON,
122
+ GetCompanyUpcomingInvoiceResponseToJSONTyped,
123
+ GetCompanyUpcomingInvoiceResponse,
124
+ instanceOfInvoiceStatus,
125
+ InvoiceStatusFromJSON,
126
+ InvoiceStatusFromJSONTyped,
127
+ InvoiceStatusToJSON,
128
+ InvoiceStatusToJSONTyped,
129
+ InvoiceStatus,
130
+ instanceOfPaymentMethodResponseData,
131
+ PaymentMethodResponseDataFromJSON,
132
+ PaymentMethodResponseDataFromJSONTyped,
133
+ PaymentMethodResponseDataToJSON,
134
+ PaymentMethodResponseDataToJSONTyped,
135
+ PaymentMethodResponseData,
136
+ instanceOfSetupIntentResponseData,
137
+ SetupIntentResponseDataFromJSON,
138
+ SetupIntentResponseDataFromJSONTyped,
139
+ SetupIntentResponseDataToJSON,
140
+ SetupIntentResponseDataToJSONTyped,
141
+ SetupIntentResponseData,
142
+ instanceOfUpdatePaymentMethodRequestBody,
143
+ UpdatePaymentMethodRequestBodyFromJSON,
144
+ UpdatePaymentMethodRequestBodyFromJSONTyped,
145
+ UpdatePaymentMethodRequestBodyToJSON,
146
+ UpdatePaymentMethodRequestBodyToJSONTyped,
147
+ UpdatePaymentMethodRequestBody,
148
+ instanceOfUpdatePaymentMethodResponse,
149
+ UpdatePaymentMethodResponseFromJSON,
150
+ UpdatePaymentMethodResponseFromJSONTyped,
151
+ UpdatePaymentMethodResponseToJSON,
152
+ UpdatePaymentMethodResponseToJSONTyped,
153
+ UpdatePaymentMethodResponse
154
+ }
155
+ }
156
+
157
+ /**
158
+ * What a reader of billing data can ask for, and the few writes beside it.
159
+ * Subscription and usage — the rest of what `hydrate` serves — and the
160
+ * checkout calls that change them join this interface as their endpoints
161
+ * ship.
162
+ */
163
+ declare interface BillingClient {
164
+ fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
165
+ /** `null` when the company has no next bill. */
166
+ fetchUpcomingInvoice(): Promise<UpcomingInvoice | null>;
167
+ /** Empty when the company has no method on file. */
168
+ fetchPaymentMethods(): Promise<PaymentMethod[]>;
169
+ /** What a provider's card form is mounted with to add a method. */
170
+ createSetupIntent(): Promise<SetupIntent>;
171
+ /** Makes the method the default, by the provider's id (`externalId`). */
172
+ updatePaymentMethod(externalId: string): Promise<void>;
173
+ /** Removes the method, by Schematic's id (`id`). */
174
+ deletePaymentMethod(id: string): Promise<void>;
175
+ readonly sessionStatus: SessionStatus;
176
+ readonly sessionKey: string | undefined;
177
+ setSession(session: SessionInput): void;
178
+ onSessionChange(listener: (event: SessionEvent) => void): () => void;
179
+ }
180
+
181
+ declare type BillingClientOptions = SessionOptions;
182
+
183
+ /**
184
+ * A prefetch or fixture. An omitted key reports as pending; a keyed resource
185
+ * seeds under `params`, or its defaults when absent, so a prefetch for a
186
+ * non-default query is claimed rather than refetched by the element.
187
+ */
188
+ declare type BillingData = {
189
+ [K in BillingResourceName]?: BillingResources[K];
190
+ } & {
191
+ params?: Partial<BillingResourceParams>;
192
+ /**
193
+ * A prefetch outlives the render that made it — a cached page, a session
194
+ * resolving to somebody else — so a store adopts it only for the session
195
+ * it names. `fetchBillingData` fills it in; a fixture need not.
196
+ */
197
+ sessionKey?: string;
198
+ };
199
+
200
+ declare interface BillingPrefetchOptions {
201
+ /**
202
+ * The resources the page renders, and no default: each one is a request
203
+ * on the server — the upcoming invoice is a live provider preview — and
204
+ * the list grows with every element, so a page names what it needs rather
205
+ * than paying for everything.
206
+ */
207
+ names: BillingResourceName[];
208
+ /** The invoice query to prefetch for; the element must ask the same one. */
209
+ invoices?: InvoiceQuery;
210
+ }
211
+
212
+ declare type BillingResourceName = keyof BillingResources;
213
+
214
+ /** `Record<string, never>` marks a singleton; anything else is keyed. */
215
+ declare interface BillingResourceParams {
216
+ invoices: InvoiceQuery;
217
+ upcomingInvoice: Record<string, never>;
218
+ paymentMethods: Record<string, never>;
219
+ }
220
+
221
+ /**
222
+ * Nothing in the store, the hooks, or the resource keys may be addressed by
223
+ * company or user id: users and companies are many-to-many, and a token names
224
+ * the pair. What is loaded belongs to the session it was read under — the
225
+ * pair, as `sessionKey` writes it — and a store that keeps more than one
226
+ * session's data keys it by that and serves only the active one.
227
+ */
228
+ declare interface BillingResources {
229
+ /** `GET /company/invoices?limit&offset&include_pending`. */
230
+ invoices: InvoicePage;
231
+ /**
232
+ * `GET /company/upcoming-invoice`. `null` is a loaded value — the company
233
+ * has no next bill, which the endpoint reports as a 204 — so only
234
+ * `undefined` means the resource has not loaded.
235
+ */
236
+ upcomingInvoice: UpcomingInvoice | null;
237
+ /**
238
+ * `GET /company/payment-methods`. Empty is a loaded value — the company
239
+ * has no method on file — so only `undefined` means not loaded.
240
+ */
241
+ paymentMethods: PaymentMethod[];
242
+ }
243
+
7
244
  declare type BooleanListenerFn = (value: boolean) => void;
8
245
 
9
246
  /**
@@ -172,6 +409,8 @@ export declare type CheckFlagReturn = {
172
409
  userId?: string;
173
410
  /** A boolean flag check result; for feature entitlements, this represents whether further consumption of the feature is permitted */
174
411
  value: boolean;
412
+ /** Customer-defined usage warning thresholds configured on this entitlement */
413
+ warningTiers?: WarningTier[];
175
414
  };
176
415
 
177
416
  declare const CheckFlagReturnFromJSON: (json: any) => CheckFlagReturn;
@@ -212,6 +451,12 @@ declare interface CheckFlagsResponseData {
212
451
  creditBalances?: {
213
452
  [key: string]: CompanyCreditBalance;
214
453
  };
454
+ /**
455
+ * Credit spend policies binding the evaluated company and user; empty when none bind. Each response carries the whole set, so replace any previously received set with it. Advisory: the flag values do not reflect them, since a check names no draw amount
456
+ * @type {Array<CreditSpendPolicy>}
457
+ * @memberof CheckFlagsResponseData
458
+ */
459
+ creditSpendPolicies: Array<CreditSpendPolicy_2>;
215
460
  /**
216
461
  *
217
462
  * @type {Array<CheckFlagResponseData>}
@@ -282,6 +527,270 @@ export declare interface CompanyCreditBalance {
282
527
  settled: number;
283
528
  }
284
529
 
530
+ /**
531
+ * Schematic API
532
+ * Schematic API
533
+ *
534
+ * The version of the OpenAPI document: 0.1
535
+ *
536
+ *
537
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
538
+ * https://openapi-generator.tech
539
+ * Do not edit the class manually.
540
+ */
541
+ /**
542
+ *
543
+ * @export
544
+ * @interface CompanyDiscountResponseData
545
+ */
546
+ declare interface CompanyDiscountResponseData {
547
+ /**
548
+ *
549
+ * @type {number}
550
+ * @memberof CompanyDiscountResponseData
551
+ */
552
+ amountOff?: number | null;
553
+ /**
554
+ *
555
+ * @type {string}
556
+ * @memberof CompanyDiscountResponseData
557
+ */
558
+ couponName: string;
559
+ /**
560
+ *
561
+ * @type {string}
562
+ * @memberof CompanyDiscountResponseData
563
+ */
564
+ currency?: string | null;
565
+ /**
566
+ *
567
+ * @type {string}
568
+ * @memberof CompanyDiscountResponseData
569
+ */
570
+ customerFacingCode?: string | null;
571
+ /**
572
+ * Provider vocabulary: once, repeating, or forever.
573
+ * @type {string}
574
+ * @memberof CompanyDiscountResponseData
575
+ */
576
+ duration: string;
577
+ /**
578
+ *
579
+ * @type {number}
580
+ * @memberof CompanyDiscountResponseData
581
+ */
582
+ durationInMonths?: number | null;
583
+ /**
584
+ *
585
+ * @type {number}
586
+ * @memberof CompanyDiscountResponseData
587
+ */
588
+ percentOff?: number | null;
589
+ }
590
+
591
+ /**
592
+ *
593
+ * @export
594
+ * @interface CompanyInvoiceResponseData
595
+ */
596
+ declare interface CompanyInvoiceResponseData {
597
+ /**
598
+ *
599
+ * @type {number}
600
+ * @memberof CompanyInvoiceResponseData
601
+ */
602
+ amountDue: number;
603
+ /**
604
+ *
605
+ * @type {Date}
606
+ * @memberof CompanyInvoiceResponseData
607
+ */
608
+ createdAt: Date;
609
+ /**
610
+ *
611
+ * @type {string}
612
+ * @memberof CompanyInvoiceResponseData
613
+ */
614
+ currency: string;
615
+ /**
616
+ *
617
+ * @type {Date}
618
+ * @memberof CompanyInvoiceResponseData
619
+ */
620
+ dueDate?: Date | null;
621
+ /**
622
+ *
623
+ * @type {string}
624
+ * @memberof CompanyInvoiceResponseData
625
+ */
626
+ id: string;
627
+ /**
628
+ *
629
+ * @type {InvoiceStatus}
630
+ * @memberof CompanyInvoiceResponseData
631
+ */
632
+ status?: InvoiceStatus | null;
633
+ /**
634
+ *
635
+ * @type {string}
636
+ * @memberof CompanyInvoiceResponseData
637
+ */
638
+ url?: string | null;
639
+ }
640
+
641
+ /**
642
+ * Schematic API
643
+ * Schematic API
644
+ *
645
+ * The version of the OpenAPI document: 0.1
646
+ *
647
+ *
648
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
649
+ * https://openapi-generator.tech
650
+ * Do not edit the class manually.
651
+ */
652
+ /**
653
+ *
654
+ * @export
655
+ * @interface CompanyPaymentMethodResponseData
656
+ */
657
+ declare interface CompanyPaymentMethodResponseData {
658
+ /**
659
+ *
660
+ * @type {string}
661
+ * @memberof CompanyPaymentMethodResponseData
662
+ */
663
+ accountLast4?: string | null;
664
+ /**
665
+ *
666
+ * @type {string}
667
+ * @memberof CompanyPaymentMethodResponseData
668
+ */
669
+ accountName?: string | null;
670
+ /**
671
+ *
672
+ * @type {string}
673
+ * @memberof CompanyPaymentMethodResponseData
674
+ */
675
+ bankName?: string | null;
676
+ /**
677
+ *
678
+ * @type {string}
679
+ * @memberof CompanyPaymentMethodResponseData
680
+ */
681
+ billingEmail?: string | null;
682
+ /**
683
+ *
684
+ * @type {string}
685
+ * @memberof CompanyPaymentMethodResponseData
686
+ */
687
+ billingName?: string | null;
688
+ /**
689
+ * Whether DELETE /checkout/paymentmethod/:id would succeed. False only for the sole method while an active paid subscription needs it; the default can be removed like any other.
690
+ * @type {boolean}
691
+ * @memberof CompanyPaymentMethodResponseData
692
+ */
693
+ canRemove: boolean;
694
+ /**
695
+ *
696
+ * @type {string}
697
+ * @memberof CompanyPaymentMethodResponseData
698
+ */
699
+ cardBrand?: string | null;
700
+ /**
701
+ *
702
+ * @type {number}
703
+ * @memberof CompanyPaymentMethodResponseData
704
+ */
705
+ cardExpMonth?: number | null;
706
+ /**
707
+ *
708
+ * @type {number}
709
+ * @memberof CompanyPaymentMethodResponseData
710
+ */
711
+ cardExpYear?: number | null;
712
+ /**
713
+ *
714
+ * @type {string}
715
+ * @memberof CompanyPaymentMethodResponseData
716
+ */
717
+ cardLast4?: string | null;
718
+ /**
719
+ *
720
+ * @type {string}
721
+ * @memberof CompanyPaymentMethodResponseData
722
+ */
723
+ externalId: string;
724
+ /**
725
+ *
726
+ * @type {string}
727
+ * @memberof CompanyPaymentMethodResponseData
728
+ */
729
+ id: string;
730
+ /**
731
+ * Whether this is the method the company is billed with: the subscription's own when it has one, else the customer default. At most one method is the default.
732
+ * @type {boolean}
733
+ * @memberof CompanyPaymentMethodResponseData
734
+ */
735
+ isDefault: boolean;
736
+ /**
737
+ * The Stripe payment method type, such as card or us_bank_account.
738
+ * @type {string}
739
+ * @memberof CompanyPaymentMethodResponseData
740
+ */
741
+ type: string;
742
+ }
743
+
744
+ /**
745
+ *
746
+ * @export
747
+ * @interface CompanyUpcomingInvoiceResponseData
748
+ */
749
+ declare interface CompanyUpcomingInvoiceResponseData {
750
+ /**
751
+ *
752
+ * @type {number}
753
+ * @memberof CompanyUpcomingInvoiceResponseData
754
+ */
755
+ amountDue: number;
756
+ /**
757
+ *
758
+ * @type {string}
759
+ * @memberof CompanyUpcomingInvoiceResponseData
760
+ */
761
+ currency: string;
762
+ /**
763
+ * How much of the company's existing balance this invoice consumes.
764
+ * @type {number}
765
+ * @memberof CompanyUpcomingInvoiceResponseData
766
+ */
767
+ customerBalanceApplied: number;
768
+ /**
769
+ * Balance left over after this invoice.
770
+ * @type {number}
771
+ * @memberof CompanyUpcomingInvoiceResponseData
772
+ */
773
+ customerBalanceRemaining: number;
774
+ /**
775
+ * The subscription's active discounts, to show beside the bill. Informational: the amounts come from the provider's preview and already reflect whatever it applied, so subtotal less these need not equal amount_due.
776
+ * @type {Array<CompanyDiscountResponseData>}
777
+ * @memberof CompanyUpcomingInvoiceResponseData
778
+ */
779
+ discounts: Array<CompanyDiscountResponseData>;
780
+ /**
781
+ *
782
+ * @type {Date}
783
+ * @memberof CompanyUpcomingInvoiceResponseData
784
+ */
785
+ dueDate?: Date | null;
786
+ /**
787
+ * Amount before discounts and tax.
788
+ * @type {number}
789
+ * @memberof CompanyUpcomingInvoiceResponseData
790
+ */
791
+ subtotal: number;
792
+ }
793
+
285
794
  /** A company's lease-aware balance for a single credit type */
286
795
  export declare type CreditBalance = {
287
796
  /** Spendable balance including any open lease hold (remaining + reserved); the number to display to end users */
@@ -301,6 +810,153 @@ declare const CreditBalancesFromJSON: (json: any) => CreditBalances;
301
810
 
302
811
  declare type CreditBalancesListenerFn = (value: CreditBalances) => void;
303
812
 
813
+ /** Every spend policy binding the current context, company-scope first */
814
+ export declare type CreditSpendPolicies = CreditSpendPolicy[];
815
+
816
+ /** Compare two policy sets by value, so an unchanged restream skips the notify. */
817
+ declare const creditSpendPoliciesEqual: (a: CreditSpendPolicies, b: CreditSpendPolicies) => boolean;
818
+
819
+ declare const CreditSpendPoliciesFromJSON: (json: any) => CreditSpendPolicies;
820
+
821
+ declare type CreditSpendPoliciesListenerFn = (value: CreditSpendPolicies) => void;
822
+
823
+ /** One limit on spending a credit */
824
+ export declare type CreditSpendPolicy = {
825
+ id: string;
826
+ creditId: string;
827
+ kind: CreditSpendPolicyKind;
828
+ scope: CreditSpendPolicyScope;
829
+ label?: string;
830
+ /** The ceiling, in credits */
831
+ limit: number;
832
+ /** How much of the limit is already spent in the current period; 0 for per_draw */
833
+ consumed: number;
834
+ /** For windowed kinds, when the current period ends and consumed no longer applies */
835
+ resetsAt?: Date;
836
+ /** Set for windowed kinds only */
837
+ window?: CreditSpendWindow;
838
+ };
839
+
840
+ /**
841
+ *
842
+ * @export
843
+ * @interface CreditSpendPolicy
844
+ */
845
+ declare interface CreditSpendPolicy_2 {
846
+ /**
847
+ * How much of the limit is already spent in the current period
848
+ * @type {number}
849
+ * @memberof CreditSpendPolicy
850
+ */
851
+ consumed?: number;
852
+ /**
853
+ * The credit the policy limits
854
+ * @type {string}
855
+ * @memberof CreditSpendPolicy
856
+ */
857
+ creditId: string;
858
+ /**
859
+ * The ID of the policy
860
+ * @type {string}
861
+ * @memberof CreditSpendPolicy
862
+ */
863
+ id: string;
864
+ /**
865
+ * How the limit is applied
866
+ * @type {string}
867
+ * @memberof CreditSpendPolicy
868
+ */
869
+ kind: string;
870
+ /**
871
+ * The name the account gave the policy
872
+ * @type {string}
873
+ * @memberof CreditSpendPolicy
874
+ */
875
+ label?: string | null;
876
+ /**
877
+ * The ceiling, in credits
878
+ * @type {number}
879
+ * @memberof CreditSpendPolicy
880
+ */
881
+ limit: number;
882
+ /**
883
+ * For a windowed limit, when the current period ends and consumed no longer applies
884
+ * @type {Date}
885
+ * @memberof CreditSpendPolicy
886
+ */
887
+ resetsAt?: Date | null;
888
+ /**
889
+ * Whether the policy limits the company or one user
890
+ * @type {CreditSpendPolicyScope}
891
+ * @memberof CreditSpendPolicy
892
+ */
893
+ scope: CreditSpendPolicyScope_2;
894
+ /**
895
+ * For a windowed limit, the period it accumulates over
896
+ * @type {CreditSpendWindow}
897
+ * @memberof CreditSpendPolicy
898
+ */
899
+ window?: CreditSpendWindow_2;
900
+ }
901
+
902
+ /** How a spend policy applies its limit. Unknown kinds are carried, not dropped:
903
+ * the server may ship a kind this SDK version predates. */
904
+ export declare type CreditSpendPolicyKind = "per_draw" | "window" | (string & {});
905
+
906
+ declare type CreditSpendPolicyListenerFn = CreditSpendPoliciesListenerFn | EmptyListenerFn;
907
+
908
+ /** Whether a spend policy limits the company or one user */
909
+ export declare type CreditSpendPolicyScope = "company" | "user" | (string & {});
910
+
911
+ /**
912
+ *
913
+ * @export
914
+ */
915
+ declare const CreditSpendPolicyScope_2: {
916
+ readonly Company: "company";
917
+ readonly User: "user";
918
+ readonly Group: "group";
919
+ };
920
+
921
+ declare type CreditSpendPolicyScope_2 = (typeof CreditSpendPolicyScope_2)[keyof typeof CreditSpendPolicyScope_2];
922
+
923
+ /** The period a windowed spend policy accumulates over */
924
+ export declare type CreditSpendWindow = {
925
+ unit: string;
926
+ count: number;
927
+ };
928
+
929
+ /**
930
+ * Schematic API
931
+ * Schematic API
932
+ *
933
+ * The version of the OpenAPI document: 0.1
934
+ *
935
+ *
936
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
937
+ * https://openapi-generator.tech
938
+ * Do not edit the class manually.
939
+ */
940
+ /**
941
+ *
942
+ * @export
943
+ * @interface CreditSpendWindow
944
+ */
945
+ declare interface CreditSpendWindow_2 {
946
+ /**
947
+ * How many units make up one period
948
+ * @type {number}
949
+ * @memberof CreditSpendWindow
950
+ */
951
+ count: number;
952
+ /**
953
+ * The period the limit accumulates over
954
+ * @type {string}
955
+ * @memberof CreditSpendWindow
956
+ */
957
+ unit: string;
958
+ }
959
+
304
960
  /**
305
961
  *
306
962
  * @export
@@ -335,6 +991,10 @@ declare interface DatastreamCompanyPlan {
335
991
 
336
992
  declare function DatastreamCompanyPlanFromJSON(json: any): DatastreamCompanyPlan;
337
993
 
994
+ declare const DEFAULT_INVOICE_QUERY: InvoiceQuery;
995
+
996
+ declare type Discount = CompanyDiscountResponseData;
997
+
338
998
  declare type EmptyListenerFn = () => void;
339
999
 
340
1000
  /**
@@ -407,6 +1067,12 @@ declare interface EventBodyFlagCheck {
407
1067
  * @memberof EventBodyFlagCheck
408
1068
  */
409
1069
  flagKey: string;
1070
+ /**
1071
+ * Whether the check was a preflight, asking whether an action would be allowed rather than reporting one that happened. Absent on ordinary checks
1072
+ * @type {boolean}
1073
+ * @memberof EventBodyFlagCheck
1074
+ */
1075
+ preflight?: boolean;
410
1076
  /**
411
1077
  * The reason why the value was returned
412
1078
  * @type {string}
@@ -584,12 +1250,69 @@ declare interface FeatureEntitlement {
584
1250
  * @memberof FeatureEntitlement
585
1251
  */
586
1252
  valueType: EntitlementValueType;
1253
+ /**
1254
+ * Customer-defined usage warning thresholds configured on this entitlement
1255
+ * @type {Array<WarningTier>}
1256
+ * @memberof FeatureEntitlement
1257
+ */
1258
+ warningTiers?: Array<WarningTier>;
587
1259
  }
588
1260
 
1261
+ /**
1262
+ * Server prefetch for a provider's `initialData`. A resource that fails is
1263
+ * left out rather than thrown, so one of them cannot block a page.
1264
+ */
1265
+ declare function fetchBillingData(client: BillingClient, options: BillingPrefetchOptions): Promise<BillingData>;
1266
+
589
1267
  declare type FlagCheckListenerFn = CheckFlagReturnListenerFn | EmptyListenerFn;
590
1268
 
591
1269
  declare type FlagValueListenerFn = BooleanListenerFn | EmptyListenerFn;
592
1270
 
1271
+ declare type Invoice = CompanyInvoiceResponseData;
1272
+
1273
+ /** A `limit` above this is a 400 (PaginationFilter in schematic-api). */
1274
+ declare const INVOICE_MAX_PAGE_SIZE = 250;
1275
+
1276
+ declare const INVOICE_PAGE_SIZE = 12;
1277
+
1278
+ declare interface InvoicePage {
1279
+ invoices: Invoice[];
1280
+ /** Matching the query on the server, not the number loaded here. */
1281
+ count: number;
1282
+ hasMore: boolean;
1283
+ }
1284
+
1285
+ /** Each distinct query is its own row set with its own paging. */
1286
+ declare interface InvoiceQuery {
1287
+ /** Include unpaid invoices that are not yet due. Default false. */
1288
+ includePending?: boolean;
1289
+ }
1290
+
1291
+ declare interface InvoicesRequest extends InvoiceQuery {
1292
+ limit: number;
1293
+ offset: number;
1294
+ }
1295
+
1296
+ /**
1297
+ * The rows asked for, and how many the query matches in total. `hasMore` is
1298
+ * the page's, and only the caller knows its offset.
1299
+ */
1300
+ declare type InvoicesResult = Omit<InvoicePage, "hasMore">;
1301
+
1302
+ /**
1303
+ *
1304
+ * @export
1305
+ */
1306
+ declare const InvoiceStatus: {
1307
+ readonly Draft: "draft";
1308
+ readonly Open: "open";
1309
+ readonly Paid: "paid";
1310
+ readonly Uncollectible: "uncollectible";
1311
+ readonly Void: "void";
1312
+ };
1313
+
1314
+ declare type InvoiceStatus = (typeof InvoiceStatus)[keyof typeof InvoiceStatus];
1315
+
593
1316
  /** A record of unique key-value pairs used for identifying a company or user */
594
1317
  export declare type Keys = Record<string, string>;
595
1318
 
@@ -617,10 +1340,53 @@ declare const MetricPeriodMonthReset: {
617
1340
 
618
1341
  declare type MetricPeriodMonthReset = (typeof MetricPeriodMonthReset)[keyof typeof MetricPeriodMonthReset];
619
1342
 
1343
+ /**
1344
+ * The store keys a resource by the query's shape, so without this
1345
+ * `{ includePending: false }` is a different row set from `{}` — it would
1346
+ * miss the seed and refetch rows identical to those already on screen.
1347
+ */
1348
+ declare function normalizeInvoiceQuery(query: InvoiceQuery): InvoiceQuery;
1349
+
1350
+ /**
1351
+ * One way the company pays. Two flags the server has already decided, so a
1352
+ * consumer never re-derives a provider's rules:
1353
+ *
1354
+ * * `isDefault` — the subscription's default method, or, when the
1355
+ * subscription names none, the customer's.
1356
+ * * `canRemove` — whether a delete would be accepted; the server's rule,
1357
+ * not `!isDefault`.
1358
+ *
1359
+ * `id` is Schematic's, and is what a delete takes; `externalId` is the
1360
+ * provider's, and is what making it the default takes.
1361
+ */
1362
+ declare type PaymentMethod = CompanyPaymentMethodResponseData;
1363
+
620
1364
  declare type PendingListenerFn = BooleanListenerFn | EmptyListenerFn;
621
1365
 
622
1366
  declare type PlanListenerFn = CheckPlanReturnListenerFn | EmptyListenerFn;
623
1367
 
1368
+ declare interface RequestOptions {
1369
+ method?: string;
1370
+ body?: unknown;
1371
+ /**
1372
+ * Success statuses that carry no body — a 204 for a resource that is
1373
+ * legitimately absent. The request resolves `undefined` for them, which
1374
+ * is distinct from a body that parsed to `null`. A 401 is never one — the
1375
+ * refresh and retry run first, and only what comes back from that is
1376
+ * judged.
1377
+ */
1378
+ noContentOn?: number[];
1379
+ }
1380
+
1381
+ declare interface ResourceState<T> {
1382
+ /** `undefined` until the first successful load; retained across later errors. */
1383
+ data: T | undefined;
1384
+ /** The latest failure; cleared by the next success. */
1385
+ error: Error | undefined;
1386
+ /** A request is in flight and no data has arrived yet, or a refetch is running. */
1387
+ isPending: boolean;
1388
+ }
1389
+
624
1390
  export declare enum RuleType {
625
1391
  /** A global rule that, if present, will override all other rules for a flag */
626
1392
  GLOBAL_OVERRIDE = "global_override",
@@ -655,9 +1421,9 @@ declare const RuleType_2: {
655
1421
  declare type RuleType_2 = (typeof RuleType_2)[keyof typeof RuleType_2];
656
1422
 
657
1423
  export declare class Schematic {
658
- private additionalHeaders;
1424
+ private _additionalHeaders;
659
1425
  private apiKey;
660
- private apiUrl;
1426
+ private _apiUrl;
661
1427
  private conn;
662
1428
  private context;
663
1429
  private debugEnabled;
@@ -671,6 +1437,7 @@ export declare class Schematic {
671
1437
  private isPendingListeners;
672
1438
  private planListeners;
673
1439
  private creditBalanceListeners;
1440
+ private creditSpendPolicyListeners;
674
1441
  private storage;
675
1442
  private persistFlagState;
676
1443
  private flagStateCacheKey;
@@ -681,6 +1448,7 @@ export declare class Schematic {
681
1448
  private featureUsageEventMap;
682
1449
  private planChecks;
683
1450
  private creditBalances;
1451
+ private creditSpendPolicies;
684
1452
  private webSocketUrl;
685
1453
  private webSocketConnectionTimeout;
686
1454
  private webSocketReconnect;
@@ -702,6 +1470,8 @@ export declare class Schematic {
702
1470
  private flagCheckDefaults;
703
1471
  private fallbackCheckCache;
704
1472
  constructor(apiKey: string, options?: SchematicOptions);
1473
+ get apiUrl(): string;
1474
+ get additionalHeaders(): Record<string, string>;
705
1475
  /**
706
1476
  * Resolve fallback value according to priority order:
707
1477
  * 1. Callsite fallback value (if provided)
@@ -897,6 +1667,10 @@ export declare class Schematic {
897
1667
  getCreditBalances: () => CreditBalances;
898
1668
  /** Get the company's lease-aware balance for a single credit type in the current context */
899
1669
  getCreditBalance: (creditId: string) => CreditBalance | undefined;
1670
+ /** Get every credit spend policy binding the current context, company-scope first */
1671
+ getCreditSpendPolicies: () => CreditSpendPolicies;
1672
+ /** Get the spend policies binding a single credit type in the current context */
1673
+ getCreditSpendPoliciesForCredit: (creditId: string) => CreditSpendPolicies;
900
1674
  getFlagCheck: (flagKey: string) => CheckFlagReturn | undefined;
901
1675
  getFlagValue: (flagKey: string) => boolean | undefined;
902
1676
  /** Register an event listener that will be notified with the boolean value for a given flag when this value changes */
@@ -906,14 +1680,43 @@ export declare class Schematic {
906
1680
  addPlanListener: (listener: PlanListenerFn) => () => void;
907
1681
  /** Register an event listener that will be notified with the company's credit balances (keyed by credit ID) whenever they change */
908
1682
  addCreditBalanceListener: (listener: CreditBalanceListenerFn) => () => void;
1683
+ /** Register an event listener that will be notified with the context's credit spend policies whenever the set changes */
1684
+ addCreditSpendPolicyListener: (listener: CreditSpendPolicyListenerFn) => () => void;
909
1685
  private notifyFlagCheckListeners;
910
1686
  /** Add or update a CheckFlagReturn in the featureUsageEventMap */
911
1687
  private updateFeatureUsageEventMap;
912
1688
  private notifyFlagValueListeners;
913
1689
  private notifyPlanListeners;
1690
+ private notifyCreditSpendPolicyListeners;
914
1691
  private notifyCreditBalanceListeners;
915
1692
  }
916
1693
 
1694
+ declare class SchematicApiError extends Error {
1695
+ readonly status: number;
1696
+ readonly path: string;
1697
+ readonly body: unknown;
1698
+ constructor(status: number, path: string, body: unknown);
1699
+ }
1700
+
1701
+ declare class SchematicBillingClient implements BillingClient {
1702
+ /**
1703
+ * Public so a second client over the same surface can be constructed on
1704
+ * this one rather than minting tokens of its own.
1705
+ */
1706
+ readonly session: SchematicSession;
1707
+ constructor(options?: BillingClientOptions | SchematicSession);
1708
+ get sessionKey(): string | undefined;
1709
+ get sessionStatus(): SessionStatus;
1710
+ setSession(session: SessionInput): void;
1711
+ onSessionChange(listener: (event: SessionEvent) => void): () => void;
1712
+ fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
1713
+ fetchUpcomingInvoice(): Promise<UpcomingInvoice | null>;
1714
+ fetchPaymentMethods(): Promise<PaymentMethod[]>;
1715
+ createSetupIntent(): Promise<SetupIntent>;
1716
+ updatePaymentMethod(externalId: string): Promise<void>;
1717
+ deletePaymentMethod(id: string): Promise<void>;
1718
+ }
1719
+
917
1720
  export declare interface SchematicComposableOpts {
918
1721
  client?: SchematicJS.Schematic;
919
1722
  }
@@ -934,6 +1737,20 @@ declare namespace SchematicJS {
934
1737
  CheckFlagsResponseFromJSON,
935
1738
  DatastreamCompanyPlanFromJSON,
936
1739
  EventBodyFlagCheckToJSON,
1740
+ fetchBillingData,
1741
+ normalizeInvoiceQuery,
1742
+ sessionKey,
1743
+ AccessToken,
1744
+ AccessTokenProvider,
1745
+ AccessTokenResult,
1746
+ billingApi,
1747
+ BillingClient,
1748
+ BillingClientOptions,
1749
+ BillingData,
1750
+ BillingPrefetchOptions,
1751
+ BillingResourceName,
1752
+ BillingResourceParams,
1753
+ BillingResources,
937
1754
  BooleanListenerFn,
938
1755
  CheckFlagResponseData,
939
1756
  CheckFlagReturn,
@@ -944,11 +1761,26 @@ declare namespace SchematicJS {
944
1761
  CheckPlanReturnFromJSON,
945
1762
  CheckPlanReturnListenerFn,
946
1763
  CompanyCreditBalance,
1764
+ CompanyDiscountResponseData,
1765
+ CompanyInvoiceResponseData,
1766
+ CompanyPaymentMethodResponseData,
1767
+ CompanyUpcomingInvoiceResponseData,
947
1768
  CreditBalance,
948
1769
  CreditBalanceListenerFn,
949
1770
  CreditBalances,
950
1771
  CreditBalancesFromJSON,
951
1772
  CreditBalancesListenerFn,
1773
+ CreditSpendPolicies,
1774
+ creditSpendPoliciesEqual,
1775
+ CreditSpendPoliciesFromJSON,
1776
+ CreditSpendPoliciesListenerFn,
1777
+ CreditSpendPolicy,
1778
+ CreditSpendPolicyKind,
1779
+ CreditSpendPolicyListenerFn,
1780
+ CreditSpendPolicyScope,
1781
+ CreditSpendWindow,
1782
+ DEFAULT_INVOICE_QUERY,
1783
+ Discount,
952
1784
  EmptyListenerFn,
953
1785
  Event_2 as Event,
954
1786
  EventBody,
@@ -958,17 +1790,42 @@ declare namespace SchematicJS {
958
1790
  EventType,
959
1791
  FlagCheckListenerFn,
960
1792
  FlagValueListenerFn,
1793
+ Invoice,
1794
+ INVOICE_MAX_PAGE_SIZE,
1795
+ INVOICE_PAGE_SIZE,
1796
+ InvoicePage,
1797
+ InvoiceQuery,
1798
+ InvoicesRequest,
1799
+ InvoicesResult,
1800
+ InvoiceStatus,
961
1801
  Keys,
1802
+ PaymentMethod,
962
1803
  PendingListenerFn,
963
1804
  PlanListenerFn,
1805
+ RequestOptions,
1806
+ ResourceState,
964
1807
  RuleType,
965
1808
  Schematic,
1809
+ SchematicApiError,
1810
+ SchematicBillingClient,
966
1811
  SchematicContext,
967
1812
  SchematicOptions,
1813
+ SchematicSession,
1814
+ Session,
1815
+ SessionEvent,
1816
+ SessionInput,
1817
+ SessionOptions,
1818
+ SessionStatus,
1819
+ SetupIntent,
1820
+ SetupIntentResponseData,
1821
+ SINGLETON,
968
1822
  StoragePersister,
1823
+ TOKEN_CACHE_SIZE,
969
1824
  Traits,
970
1825
  TrialStatus,
971
- UsagePeriod
1826
+ UpcomingInvoice,
1827
+ UsagePeriod,
1828
+ WarningTier
972
1829
  }
973
1830
  }
974
1831
 
@@ -1051,6 +1908,160 @@ declare type SchematicPluginOptionsWithPublishableKey = BaseSchematicPluginOptio
1051
1908
  publishableKey: string;
1052
1909
  };
1053
1910
 
1911
+ /**
1912
+ * Session identity is the (company, user) pair alone: a freshly minted token,
1913
+ * a rebuilt provider closure, and a refresh this session asked for itself are
1914
+ * all the same session. Nothing in a token says who it was minted for, so
1915
+ * that question is the host's to answer.
1916
+ *
1917
+ * Credentials survive a change of session, keyed by pair — switching back to
1918
+ * a company reads with the token already in hand. They do not survive the
1919
+ * session ending: after a sign-out the next person at this page is somebody
1920
+ * else, and nothing minted for the last one is theirs to send.
1921
+ */
1922
+ declare class SchematicSession {
1923
+ private readonly _apiUrl;
1924
+ private readonly _headers;
1925
+ private readonly _fetch;
1926
+ private _session;
1927
+ private readonly _tokens;
1928
+ private readonly _resolving;
1929
+ /**
1930
+ * Bumped when the session's identity changes, and only then — the object
1931
+ * itself is replaced on every render. Anything asking "is this still the
1932
+ * session I started under?" counts generations rather than comparing.
1933
+ */
1934
+ private _generation;
1935
+ private readonly _listeners;
1936
+ constructor(options?: SessionOptions);
1937
+ get key(): string | undefined;
1938
+ get status(): SessionStatus;
1939
+ /** Only a statement that changes which pair is read counts as a change. */
1940
+ set(session: SessionInput): void;
1941
+ onChange(listener: (event: SessionEvent) => void): () => void;
1942
+ private _emit;
1943
+ private _cached;
1944
+ private _cache;
1945
+ /**
1946
+ * The credential for a session, minted if this one is not held. `force`
1947
+ * retires what is held first: the caller is a request the API has just
1948
+ * rejected.
1949
+ */
1950
+ resolveToken(session: Session, force: boolean): Promise<string>;
1951
+ /**
1952
+ * Sends a request under the active session's credential, refreshing once
1953
+ * and retrying if the API rejects it. Rejects rather than answering when
1954
+ * the session changes while the request is in flight: the rows would
1955
+ * otherwise come back as the answer to a question asked for another pair.
1956
+ */
1957
+ request(path: string, options?: RequestOptions): Promise<unknown>;
1958
+ }
1959
+
1960
+ /**
1961
+ * Who is being read. Users and companies are many-to-many: the same person
1962
+ * reads one company's billing and then another's, and the same company is
1963
+ * read by several people. A token is minted for the pair, so the pair — not
1964
+ * the company alone — is the session's identity.
1965
+ */
1966
+ declare interface Session {
1967
+ /** The host's name for the company, its id in their own system say. */
1968
+ company: string;
1969
+ /**
1970
+ * The user, where the host mints per (company, user). Left out by a host
1971
+ * whose tokens are company-wide, and then every reader of that company
1972
+ * shares one session.
1973
+ */
1974
+ user?: string;
1975
+ token: AccessToken;
1976
+ }
1977
+
1978
+ /**
1979
+ * What happened to the session, for anything holding data that belongs to
1980
+ * one. `started`: whatever is loaded belongs to the new session — a prefetch
1981
+ * the host seeded before its auth resolved. `changed`: another pair is being
1982
+ * read, and what is loaded belongs to the pair being left. `ended`: nobody is
1983
+ * signed in, and what is loaded belongs to nobody.
1984
+ */
1985
+ declare type SessionEvent = {
1986
+ type: "started" | "changed" | "ended";
1987
+ };
1988
+
1989
+ /**
1990
+ * Three states that are not interchangeable:
1991
+ *
1992
+ * * `Session` — active: this pair, read with this credential.
1993
+ * * `null` — ended: nobody is signed in; what is loaded is dropped.
1994
+ * * `undefined` — pending: the host's auth has not resolved. It states
1995
+ * nothing, so the session in hand stands.
1996
+ */
1997
+ declare type SessionInput = Session | null | undefined;
1998
+
1999
+ /**
2000
+ * The pair as one string, for anything that has to compare sessions or key
2001
+ * something by one — a prefetch stating which session it was fetched for, a
2002
+ * store keeping a page per session. Opaque: read it only by equality.
2003
+ */
2004
+ declare function sessionKey(session: Session): string;
2005
+
2006
+ declare interface SessionOptions {
2007
+ session?: SessionInput;
2008
+ apiUrl?: string;
2009
+ additionalHeaders?: Record<string, string>;
2010
+ /** Override for tests and non-browser runtimes. */
2011
+ fetch?: typeof fetch;
2012
+ }
2013
+
2014
+ declare type SessionStatus = "pending" | "active" | "ended";
2015
+
2016
+ /** What a provider's card form is mounted with to add a method. */
2017
+ declare type SetupIntent = SetupIntentResponseData;
2018
+
2019
+ /**
2020
+ * Schematic API
2021
+ * Schematic API
2022
+ *
2023
+ * The version of the OpenAPI document: 0.1
2024
+ *
2025
+ *
2026
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
2027
+ * https://openapi-generator.tech
2028
+ * Do not edit the class manually.
2029
+ */
2030
+ /**
2031
+ *
2032
+ * @export
2033
+ * @interface SetupIntentResponseData
2034
+ */
2035
+ declare interface SetupIntentResponseData {
2036
+ /**
2037
+ *
2038
+ * @type {string}
2039
+ * @memberof SetupIntentResponseData
2040
+ */
2041
+ accountId?: string | null;
2042
+ /**
2043
+ *
2044
+ * @type {string}
2045
+ * @memberof SetupIntentResponseData
2046
+ */
2047
+ publishableKey?: string | null;
2048
+ /**
2049
+ *
2050
+ * @type {string}
2051
+ * @memberof SetupIntentResponseData
2052
+ */
2053
+ schematicPublishableKey: string;
2054
+ /**
2055
+ *
2056
+ * @type {string}
2057
+ * @memberof SetupIntentResponseData
2058
+ */
2059
+ setupIntentClientSecret?: string | null;
2060
+ }
2061
+
2062
+ /** The params of every singleton resource. */
2063
+ declare const SINGLETON: Record<string, never>;
2064
+
1054
2065
  /** Optional type for implementing custom client-side storage */
1055
2066
  export declare type StoragePersister = {
1056
2067
  setItem(key: string, value: any): void;
@@ -1058,6 +2069,15 @@ export declare type StoragePersister = {
1058
2069
  removeItem(key: string): void;
1059
2070
  };
1060
2071
 
2072
+ /**
2073
+ * Sessions whose credentials are kept. A reader switching between the
2074
+ * organizations they belong to walks a handful of them and comes back, and
2075
+ * re-minting on every step is a round trip to the host's token endpoint for
2076
+ * a token this client already holds and has not seen expire. The same
2077
+ * handful the flag cache bounds its contexts at.
2078
+ */
2079
+ declare const TOKEN_CACHE_SIZE = 10;
2080
+
1061
2081
  /**
1062
2082
  * A flexible key/value type that can store any type of value on a company or user.
1063
2083
  */
@@ -1075,6 +2095,8 @@ declare const TrialStatus: {
1075
2095
 
1076
2096
  declare type TrialStatus = (typeof TrialStatus)[keyof typeof TrialStatus];
1077
2097
 
2098
+ declare type UpcomingInvoice = CompanyUpcomingInvoiceResponseData;
2099
+
1078
2100
  export declare enum UsagePeriod {
1079
2101
  ALL_TIME = "all_time",
1080
2102
  CURRENT_DAY = "current_day",
@@ -1123,9 +2145,12 @@ export declare const useSchematicContext: (opts?: SchematicComposableOpts) => {
1123
2145
  * `remaining` would otherwise read stale / falsely "exhausted".
1124
2146
  *
1125
2147
  * The credit ID is available on a feature's entitlement: `useSchematicEntitlement(key)`
1126
- * returns `creditId` for credit-based features.
2148
+ * returns `creditId` for credit-based features. Pass that computed ref straight
2149
+ * in; the composable unwraps a ref, a getter, or a plain string, and re-keys to
2150
+ * the new credit when the source changes. While the ID is undefined it reports
2151
+ * the client's loading state and a balance of 0.
1127
2152
  *
1128
- * @param creditId - The credit ID to read the balance for
2153
+ * @param creditId - The credit ID to read the balance for, as a ref, a getter, or a plain string
1129
2154
  * @param opts - Optional configuration including a client override
1130
2155
  * @returns Object with `balance` and `isLoading` computed refs
1131
2156
  *
@@ -1133,18 +2158,67 @@ export declare const useSchematicContext: (opts?: SchematicComposableOpts) => {
1133
2158
  * ```typescript
1134
2159
  * const { balance, isLoading } = useSchematicCreditBalance('credit-id')
1135
2160
  *
2161
+ * // Or keyed off an entitlement, without unwrapping it yourself
2162
+ * const { creditId } = useSchematicEntitlement('my-flag-key')
2163
+ * const { balance } = useSchematicCreditBalance(creditId)
2164
+ *
1136
2165
  * // In template
1137
2166
  * <div v-if="isLoading">Loading…</div>
1138
2167
  * <div v-else>{{ balance }} credits remaining</div>
1139
2168
  * ```
1140
2169
  */
1141
- export declare const useSchematicCreditBalance: (creditId: string, opts?: SchematicComposableOpts) => {
2170
+ export declare const useSchematicCreditBalance: (creditId: MaybeRefOrGetter<string | undefined>, opts?: SchematicComposableOpts) => {
1142
2171
  /** The spendable balance; 0 while loading or when the company holds no balance in this credit */
1143
2172
  balance: ComputedRef<number>;
1144
2173
  /** True while the balance is still loading and no value has arrived yet */
1145
2174
  isLoading: ComputedRef<boolean>;
1146
2175
  };
1147
2176
 
2177
+ /**
2178
+ * Get every credit spend policy binding the current context.
2179
+ * Returns reactive computed refs for the policies and a loading flag.
2180
+ *
2181
+ * Company-scope policies come first, then the user's own. The list updates
2182
+ * as partials arrive over the DataStream, so a policy edited or deleted in the
2183
+ * dashboard reaches the component without a refetch. A window policy also
2184
+ * carries `consumed` and `resetsAt`, which update as credits are spent.
2185
+ *
2186
+ * @param opts - Optional configuration including a client override
2187
+ * @returns Object with `policies` and `isLoading` computed refs
2188
+ *
2189
+ * @example
2190
+ * ```typescript
2191
+ * const { policies, isLoading } = useSchematicCreditSpendPolicies()
2192
+ *
2193
+ * // In template
2194
+ * <div v-if="isLoading">Loading…</div>
2195
+ * <ul v-else>
2196
+ * <li v-for="policy in policies" :key="policy.id">
2197
+ * {{ policy.scope }} limit: {{ policy.limit }} credits
2198
+ * </li>
2199
+ * </ul>
2200
+ * ```
2201
+ */
2202
+ export declare const useSchematicCreditSpendPolicies: (opts?: SchematicComposableOpts) => {
2203
+ /** Company-scope policies first, then the user's own; empty when none bind */
2204
+ policies: ComputedRef< {
2205
+ id: string;
2206
+ creditId: string;
2207
+ kind: SchematicJS.CreditSpendPolicyKind;
2208
+ scope: SchematicJS.CreditSpendPolicyScope;
2209
+ label?: string | undefined;
2210
+ limit: number;
2211
+ consumed: number;
2212
+ resetsAt?: Date | undefined;
2213
+ window?: {
2214
+ unit: string;
2215
+ count: number;
2216
+ } | undefined;
2217
+ }[]>;
2218
+ /** True while the policies are still loading and nothing has arrived yet */
2219
+ isLoading: ComputedRef<boolean>;
2220
+ };
2221
+
1148
2222
  /**
1149
2223
  * Check feature entitlement with usage details
1150
2224
  * Returns reactive refs for flag value, usage, allocation, and exceeded status
@@ -1190,6 +2264,10 @@ export declare const useSchematicEntitlement: (key: string, opts?: UseSchematicF
1190
2264
  softLimit?: number | undefined;
1191
2265
  userId?: string | undefined;
1192
2266
  value: boolean;
2267
+ warningTiers?: {
2268
+ key: string;
2269
+ value: number;
2270
+ }[] | undefined;
1193
2271
  }>;
1194
2272
  value: ComputedRef<boolean>;
1195
2273
  flag: ComputedRef<string>;
@@ -1199,10 +2277,19 @@ export declare const useSchematicEntitlement: (key: string, opts?: UseSchematicF
1199
2277
  featureUsageExceeded: ComputedRef<boolean | undefined>;
1200
2278
  featureUsageEvent: ComputedRef<string | undefined>;
1201
2279
  featureUsagePeriod: ComputedRef<SchematicJS.UsagePeriod | undefined>;
2280
+ softLimit: ComputedRef<number | undefined>;
2281
+ warningTiers: ComputedRef< {
2282
+ key: string;
2283
+ value: number;
2284
+ }[] | undefined>;
1202
2285
  flagId: ComputedRef<string | undefined>;
1203
2286
  ruleId: ComputedRef<string | undefined>;
1204
2287
  companyId: ComputedRef<string | undefined>;
1205
2288
  userId: ComputedRef<string | undefined>;
2289
+ creditId: ComputedRef<string | undefined>;
2290
+ creditSettled: ComputedRef<number | undefined>;
2291
+ creditRemaining: ComputedRef<number | undefined>;
2292
+ creditReserved: ComputedRef<number | undefined>;
1206
2293
  };
1207
2294
 
1208
2295
  /**
@@ -1292,4 +2379,35 @@ export declare type UseSchematicPlanOpts = SchematicComposableOpts & {
1292
2379
  fallback?: SchematicJS.CheckPlanReturn;
1293
2380
  };
1294
2381
 
2382
+ /**
2383
+ * Schematic API
2384
+ * Schematic API
2385
+ *
2386
+ * The version of the OpenAPI document: 0.1
2387
+ *
2388
+ *
2389
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
2390
+ * https://openapi-generator.tech
2391
+ * Do not edit the class manually.
2392
+ */
2393
+ /**
2394
+ *
2395
+ * @export
2396
+ * @interface WarningTier
2397
+ */
2398
+ export declare interface WarningTier {
2399
+ /**
2400
+ * A customer-defined identifier for the warning tier
2401
+ * @type {string}
2402
+ * @memberof WarningTier
2403
+ */
2404
+ key: string;
2405
+ /**
2406
+ * The warning threshold, in the entitlement's usage units
2407
+ * @type {number}
2408
+ * @memberof WarningTier
2409
+ */
2410
+ value: number;
2411
+ }
2412
+
1295
2413
  export { }