@schematichq/schematic-react 1.8.0 → 1.10.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.
@@ -45,6 +45,20 @@ declare type BaseSchematicProviderProps = Omit<SchematicJS.SchematicOptions, "cl
45
45
  initialData?: BillingData;
46
46
  } & SchematicI18nConfig;
47
47
 
48
+ /**
49
+ * The writes a source can carry out. Each rejects with the failure; a source
50
+ * that reads only (a prefetch with no client) leaves the object off, and the
51
+ * hooks reject every write with `BILLING_ACTION_UNAVAILABLE_MESSAGE`.
52
+ */
53
+ export declare interface BillingActions {
54
+ /** Makes `externalId` the default payment method and reloads the list. */
55
+ setDefaultPaymentMethod(externalId: string): Promise<void>;
56
+ /** Removes payment method `id` and reloads the list. */
57
+ removePaymentMethod(id: string): Promise<void>;
58
+ /** Mints a new setup intent every call; nothing is cached. */
59
+ createSetupIntent(): Promise<SetupIntent>;
60
+ }
61
+
48
62
  declare namespace billingApi {
49
63
  export {
50
64
  instanceOfApiError,
@@ -53,6 +67,12 @@ declare namespace billingApi {
53
67
  ApiErrorToJSON,
54
68
  ApiErrorToJSONTyped,
55
69
  ApiError,
70
+ instanceOfBillingProviderType,
71
+ BillingProviderTypeFromJSON,
72
+ BillingProviderTypeFromJSONTyped,
73
+ BillingProviderTypeToJSON,
74
+ BillingProviderTypeToJSONTyped,
75
+ BillingProviderType,
56
76
  instanceOfCompanyDiscountResponseData,
57
77
  CompanyDiscountResponseDataFromJSON,
58
78
  CompanyDiscountResponseDataFromJSONTyped,
@@ -71,12 +91,42 @@ declare namespace billingApi {
71
91
  CompanyInvoicesResponseDataToJSON,
72
92
  CompanyInvoicesResponseDataToJSONTyped,
73
93
  CompanyInvoicesResponseData,
94
+ instanceOfCompanyPaymentMethodResponseData,
95
+ CompanyPaymentMethodResponseDataFromJSON,
96
+ CompanyPaymentMethodResponseDataFromJSONTyped,
97
+ CompanyPaymentMethodResponseDataToJSON,
98
+ CompanyPaymentMethodResponseDataToJSONTyped,
99
+ CompanyPaymentMethodResponseData,
100
+ instanceOfCompanyPaymentMethodsResponseData,
101
+ CompanyPaymentMethodsResponseDataFromJSON,
102
+ CompanyPaymentMethodsResponseDataFromJSONTyped,
103
+ CompanyPaymentMethodsResponseDataToJSON,
104
+ CompanyPaymentMethodsResponseDataToJSONTyped,
105
+ CompanyPaymentMethodsResponseData,
74
106
  instanceOfCompanyUpcomingInvoiceResponseData,
75
107
  CompanyUpcomingInvoiceResponseDataFromJSON,
76
108
  CompanyUpcomingInvoiceResponseDataFromJSONTyped,
77
109
  CompanyUpcomingInvoiceResponseDataToJSON,
78
110
  CompanyUpcomingInvoiceResponseDataToJSONTyped,
79
111
  CompanyUpcomingInvoiceResponseData,
112
+ instanceOfCreateSetupIntentResponse,
113
+ CreateSetupIntentResponseFromJSON,
114
+ CreateSetupIntentResponseFromJSONTyped,
115
+ CreateSetupIntentResponseToJSON,
116
+ CreateSetupIntentResponseToJSONTyped,
117
+ CreateSetupIntentResponse,
118
+ instanceOfDeletePaymentMethodResponse,
119
+ DeletePaymentMethodResponseFromJSON,
120
+ DeletePaymentMethodResponseFromJSONTyped,
121
+ DeletePaymentMethodResponseToJSON,
122
+ DeletePaymentMethodResponseToJSONTyped,
123
+ DeletePaymentMethodResponse,
124
+ instanceOfDeleteResponse,
125
+ DeleteResponseFromJSON,
126
+ DeleteResponseFromJSONTyped,
127
+ DeleteResponseToJSON,
128
+ DeleteResponseToJSONTyped,
129
+ DeleteResponse,
80
130
  instanceOfGetCompanyInvoicesParams,
81
131
  GetCompanyInvoicesParamsFromJSON,
82
132
  GetCompanyInvoicesParamsFromJSONTyped,
@@ -89,6 +139,12 @@ declare namespace billingApi {
89
139
  GetCompanyInvoicesResponseToJSON,
90
140
  GetCompanyInvoicesResponseToJSONTyped,
91
141
  GetCompanyInvoicesResponse,
142
+ instanceOfGetCompanyPaymentMethodsResponse,
143
+ GetCompanyPaymentMethodsResponseFromJSON,
144
+ GetCompanyPaymentMethodsResponseFromJSONTyped,
145
+ GetCompanyPaymentMethodsResponseToJSON,
146
+ GetCompanyPaymentMethodsResponseToJSONTyped,
147
+ GetCompanyPaymentMethodsResponse,
92
148
  instanceOfGetCompanyUpcomingInvoiceResponse,
93
149
  GetCompanyUpcomingInvoiceResponseFromJSON,
94
150
  GetCompanyUpcomingInvoiceResponseFromJSONTyped,
@@ -100,19 +156,52 @@ declare namespace billingApi {
100
156
  InvoiceStatusFromJSONTyped,
101
157
  InvoiceStatusToJSON,
102
158
  InvoiceStatusToJSONTyped,
103
- InvoiceStatus
159
+ InvoiceStatus,
160
+ instanceOfPaymentMethodResponseData,
161
+ PaymentMethodResponseDataFromJSON,
162
+ PaymentMethodResponseDataFromJSONTyped,
163
+ PaymentMethodResponseDataToJSON,
164
+ PaymentMethodResponseDataToJSONTyped,
165
+ PaymentMethodResponseData,
166
+ instanceOfSetupIntentResponseData,
167
+ SetupIntentResponseDataFromJSON,
168
+ SetupIntentResponseDataFromJSONTyped,
169
+ SetupIntentResponseDataToJSON,
170
+ SetupIntentResponseDataToJSONTyped,
171
+ SetupIntentResponseData,
172
+ instanceOfUpdatePaymentMethodRequestBody,
173
+ UpdatePaymentMethodRequestBodyFromJSON,
174
+ UpdatePaymentMethodRequestBodyFromJSONTyped,
175
+ UpdatePaymentMethodRequestBodyToJSON,
176
+ UpdatePaymentMethodRequestBodyToJSONTyped,
177
+ UpdatePaymentMethodRequestBody,
178
+ instanceOfUpdatePaymentMethodResponse,
179
+ UpdatePaymentMethodResponseFromJSON,
180
+ UpdatePaymentMethodResponseFromJSONTyped,
181
+ UpdatePaymentMethodResponseToJSON,
182
+ UpdatePaymentMethodResponseToJSONTyped,
183
+ UpdatePaymentMethodResponse
104
184
  }
105
185
  }
106
186
 
107
187
  /**
108
- * What a reader of billing data can ask for. Subscription and usage — the
109
- * rest of what `hydrate` serves — and the checkout calls that change them
110
- * join this interface as their endpoints ship.
188
+ * What a reader of billing data can ask for, and the few writes beside it.
189
+ * Subscription and usage — the rest of what `hydrate` serves — and the
190
+ * checkout calls that change them join this interface as their endpoints
191
+ * ship.
111
192
  */
112
193
  declare interface BillingClient {
113
194
  fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
114
195
  /** `null` when the company has no next bill. */
115
196
  fetchUpcomingInvoice(): Promise<UpcomingInvoice | null>;
197
+ /** Empty when the company has no method on file. */
198
+ fetchPaymentMethods(): Promise<PaymentMethod[]>;
199
+ /** What a provider's card form is mounted with to add a method. */
200
+ createSetupIntent(): Promise<SetupIntent>;
201
+ /** Makes the method the default, by the provider's id (`externalId`). */
202
+ updatePaymentMethod(externalId: string): Promise<void>;
203
+ /** Removes the method, by Schematic's id (`id`). */
204
+ deletePaymentMethod(id: string): Promise<void>;
116
205
  readonly sessionStatus: SessionStatus;
117
206
  readonly sessionKey: string | undefined;
118
207
  setSession(session: SessionInput): void;
@@ -138,7 +227,7 @@ export declare type BillingData = {
138
227
  sessionKey?: string;
139
228
  };
140
229
 
141
- export declare function BillingDataProvider({ children, data, locale, onLoadMoreInvoices, onMissingString, onRefetch, status, strings, translate, }: BillingDataProviderProps): React_2.JSX.Element;
230
+ export declare function BillingDataProvider({ actions, children, data, locale, onLoadMoreInvoices, onMissingString, onRefetch, status, strings, translate, }: BillingDataProviderProps): React_2.JSX.Element;
142
231
 
143
232
  declare interface BillingDataProviderDataProps {
144
233
  /** A missing key reports as pending. */
@@ -147,6 +236,13 @@ declare interface BillingDataProviderDataProps {
147
236
  status?: BillingDataStatus;
148
237
  onRefetch?: (name: BillingResourceName) => void;
149
238
  onLoadMoreInvoices?: (query: InvoiceQuery) => void;
239
+ /**
240
+ * What the write hooks call. Each rejects on its own; an action left out
241
+ * rejects with `BILLING_ACTION_UNAVAILABLE_MESSAGE`. Nothing here touches
242
+ * `data`: a fixture that wants the list to change after a write hands in
243
+ * new `data`.
244
+ */
245
+ actions?: Partial<BillingActions>;
150
246
  children?: React_2.ReactNode;
151
247
  }
152
248
 
@@ -171,6 +267,8 @@ export declare interface BillingDataSource {
171
267
  /** Never rejects: a failure lands on the resource's `error`. */
172
268
  loadMoreInvoices: (query: InvoiceQuery) => Promise<void>;
173
269
  invalidateAll: () => void;
270
+ /** Absent on a source that only reads. */
271
+ actions?: BillingActions;
174
272
  }
175
273
 
176
274
  /** Per-resource status overrides, for fixtures that simulate loading and failure. */
@@ -200,13 +298,14 @@ declare interface BillingPrefetchOptions {
200
298
  export declare function BillingProvider({ billingClient, children, initialData, locale, onMissingString, session, strings, translate, }: BillingProviderProps): React_2.JSX.Element;
201
299
 
202
300
  /**
203
- * What `BillingProvider` asks of its client: the session it reads under, and
204
- * the fetch behind each resource above. schematic-js's `SchematicBillingClient`
301
+ * What `BillingProvider` asks of its client: the session it reads under, the
302
+ * fetch behind each resource above, and the payment-method actions the hooks
303
+ * expose. schematic-js's `SchematicBillingClient`
205
304
  * satisfies it, and so does a host's own client that implements only this
206
305
  * much. Named apart from schematic-js's `BillingClient`, which is the whole
207
306
  * interface; this is the part the hooks here call.
208
307
  */
209
- export declare type BillingProviderClient = Pick<BillingClient, "sessionStatus" | "sessionKey" | "setSession" | "onSessionChange" | "fetchInvoices" | "fetchUpcomingInvoice">;
308
+ export declare type BillingProviderClient = Pick<BillingClient, "sessionStatus" | "sessionKey" | "setSession" | "onSessionChange" | "fetchInvoices" | "fetchUpcomingInvoice" | "fetchPaymentMethods" | "createSetupIntent" | "updatePaymentMethod" | "deletePaymentMethod">;
210
309
 
211
310
  declare interface BillingProviderDataProps {
212
311
  /**
@@ -246,7 +345,7 @@ declare interface BillingProviderDataProps {
246
345
  export declare type BillingProviderProps = BillingProviderDataProps & SchematicI18nConfig;
247
346
 
248
347
  /** The resources this package serves; a key of schematic-js's contract. */
249
- export declare type BillingResourceName = "invoices" | "upcomingInvoice";
348
+ export declare type BillingResourceName = "invoices" | "upcomingInvoice" | "paymentMethods";
250
349
 
251
350
  declare type BillingResourceName_2 = keyof BillingResources_2;
252
351
 
@@ -256,6 +355,7 @@ export declare type BillingResourceParams = Pick<BillingResourceParams_2, Billin
256
355
  declare interface BillingResourceParams_2 {
257
356
  invoices: InvoiceQuery;
258
357
  upcomingInvoice: Record<string, never>;
358
+ paymentMethods: Record<string, never>;
259
359
  }
260
360
 
261
361
  export declare type BillingResources = Pick<BillingResources_2, BillingResourceName>;
@@ -276,6 +376,11 @@ declare interface BillingResources_2 {
276
376
  * `undefined` means the resource has not loaded.
277
377
  */
278
378
  upcomingInvoice: UpcomingInvoice | null;
379
+ /**
380
+ * `GET /company/payment-methods`. Empty is a loaded value — the company
381
+ * has no method on file — so only `undefined` means not loaded.
382
+ */
383
+ paymentMethods: PaymentMethod[];
279
384
  }
280
385
 
281
386
  declare type BooleanListenerFn = (value: boolean) => void;
@@ -488,6 +593,12 @@ declare interface CheckFlagsResponseData {
488
593
  creditBalances?: {
489
594
  [key: string]: CompanyCreditBalance;
490
595
  };
596
+ /**
597
+ * 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
598
+ * @type {Array<CreditSpendPolicy>}
599
+ * @memberof CheckFlagsResponseData
600
+ */
601
+ creditSpendPolicies: Array<CreditSpendPolicy_2>;
491
602
  /**
492
603
  *
493
604
  * @type {Array<CheckFlagResponseData>}
@@ -669,6 +780,109 @@ declare interface CompanyInvoiceResponseData {
669
780
  url?: string | null;
670
781
  }
671
782
 
783
+ /**
784
+ * Schematic API
785
+ * Schematic API
786
+ *
787
+ * The version of the OpenAPI document: 0.1
788
+ *
789
+ *
790
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
791
+ * https://openapi-generator.tech
792
+ * Do not edit the class manually.
793
+ */
794
+ /**
795
+ *
796
+ * @export
797
+ * @interface CompanyPaymentMethodResponseData
798
+ */
799
+ declare interface CompanyPaymentMethodResponseData {
800
+ /**
801
+ *
802
+ * @type {string}
803
+ * @memberof CompanyPaymentMethodResponseData
804
+ */
805
+ accountLast4?: string | null;
806
+ /**
807
+ *
808
+ * @type {string}
809
+ * @memberof CompanyPaymentMethodResponseData
810
+ */
811
+ accountName?: string | null;
812
+ /**
813
+ *
814
+ * @type {string}
815
+ * @memberof CompanyPaymentMethodResponseData
816
+ */
817
+ bankName?: string | null;
818
+ /**
819
+ *
820
+ * @type {string}
821
+ * @memberof CompanyPaymentMethodResponseData
822
+ */
823
+ billingEmail?: string | null;
824
+ /**
825
+ *
826
+ * @type {string}
827
+ * @memberof CompanyPaymentMethodResponseData
828
+ */
829
+ billingName?: string | null;
830
+ /**
831
+ * 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.
832
+ * @type {boolean}
833
+ * @memberof CompanyPaymentMethodResponseData
834
+ */
835
+ canRemove: boolean;
836
+ /**
837
+ *
838
+ * @type {string}
839
+ * @memberof CompanyPaymentMethodResponseData
840
+ */
841
+ cardBrand?: string | null;
842
+ /**
843
+ *
844
+ * @type {number}
845
+ * @memberof CompanyPaymentMethodResponseData
846
+ */
847
+ cardExpMonth?: number | null;
848
+ /**
849
+ *
850
+ * @type {number}
851
+ * @memberof CompanyPaymentMethodResponseData
852
+ */
853
+ cardExpYear?: number | null;
854
+ /**
855
+ *
856
+ * @type {string}
857
+ * @memberof CompanyPaymentMethodResponseData
858
+ */
859
+ cardLast4?: string | null;
860
+ /**
861
+ *
862
+ * @type {string}
863
+ * @memberof CompanyPaymentMethodResponseData
864
+ */
865
+ externalId: string;
866
+ /**
867
+ *
868
+ * @type {string}
869
+ * @memberof CompanyPaymentMethodResponseData
870
+ */
871
+ id: string;
872
+ /**
873
+ * 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.
874
+ * @type {boolean}
875
+ * @memberof CompanyPaymentMethodResponseData
876
+ */
877
+ isDefault: boolean;
878
+ /**
879
+ * The Stripe payment method type, such as card or us_bank_account.
880
+ * @type {string}
881
+ * @memberof CompanyPaymentMethodResponseData
882
+ */
883
+ type: string;
884
+ }
885
+
672
886
  /**
673
887
  *
674
888
  * @export
@@ -700,7 +914,7 @@ declare interface CompanyUpcomingInvoiceResponseData {
700
914
  */
701
915
  customerBalanceRemaining: number;
702
916
  /**
703
- * Only active discounts that reduce the bill.
917
+ * 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.
704
918
  * @type {Array<CompanyDiscountResponseData>}
705
919
  * @memberof CompanyUpcomingInvoiceResponseData
706
920
  */
@@ -738,6 +952,153 @@ declare const CreditBalancesFromJSON: (json: any) => CreditBalances;
738
952
 
739
953
  declare type CreditBalancesListenerFn = (value: CreditBalances) => void;
740
954
 
955
+ /** Every spend policy binding the current context, company-scope first */
956
+ export declare type CreditSpendPolicies = CreditSpendPolicy[];
957
+
958
+ /** Compare two policy sets by value, so an unchanged restream skips the notify. */
959
+ declare const creditSpendPoliciesEqual: (a: CreditSpendPolicies, b: CreditSpendPolicies) => boolean;
960
+
961
+ declare const CreditSpendPoliciesFromJSON: (json: any) => CreditSpendPolicies;
962
+
963
+ declare type CreditSpendPoliciesListenerFn = (value: CreditSpendPolicies) => void;
964
+
965
+ /** One limit on spending a credit */
966
+ export declare type CreditSpendPolicy = {
967
+ id: string;
968
+ creditId: string;
969
+ kind: CreditSpendPolicyKind;
970
+ scope: CreditSpendPolicyScope;
971
+ label?: string;
972
+ /** The ceiling, in credits */
973
+ limit: number;
974
+ /** How much of the limit is already spent in the current period; 0 for per_draw */
975
+ consumed: number;
976
+ /** For windowed kinds, when the current period ends and consumed no longer applies */
977
+ resetsAt?: Date;
978
+ /** Set for windowed kinds only */
979
+ window?: CreditSpendWindow;
980
+ };
981
+
982
+ /**
983
+ *
984
+ * @export
985
+ * @interface CreditSpendPolicy
986
+ */
987
+ declare interface CreditSpendPolicy_2 {
988
+ /**
989
+ * How much of the limit is already spent in the current period
990
+ * @type {number}
991
+ * @memberof CreditSpendPolicy
992
+ */
993
+ consumed?: number;
994
+ /**
995
+ * The credit the policy limits
996
+ * @type {string}
997
+ * @memberof CreditSpendPolicy
998
+ */
999
+ creditId: string;
1000
+ /**
1001
+ * The ID of the policy
1002
+ * @type {string}
1003
+ * @memberof CreditSpendPolicy
1004
+ */
1005
+ id: string;
1006
+ /**
1007
+ * How the limit is applied
1008
+ * @type {string}
1009
+ * @memberof CreditSpendPolicy
1010
+ */
1011
+ kind: string;
1012
+ /**
1013
+ * The name the account gave the policy
1014
+ * @type {string}
1015
+ * @memberof CreditSpendPolicy
1016
+ */
1017
+ label?: string | null;
1018
+ /**
1019
+ * The ceiling, in credits
1020
+ * @type {number}
1021
+ * @memberof CreditSpendPolicy
1022
+ */
1023
+ limit: number;
1024
+ /**
1025
+ * For a windowed limit, when the current period ends and consumed no longer applies
1026
+ * @type {Date}
1027
+ * @memberof CreditSpendPolicy
1028
+ */
1029
+ resetsAt?: Date | null;
1030
+ /**
1031
+ * Whether the policy limits the company or one user
1032
+ * @type {CreditSpendPolicyScope}
1033
+ * @memberof CreditSpendPolicy
1034
+ */
1035
+ scope: CreditSpendPolicyScope_2;
1036
+ /**
1037
+ * For a windowed limit, the period it accumulates over
1038
+ * @type {CreditSpendWindow}
1039
+ * @memberof CreditSpendPolicy
1040
+ */
1041
+ window?: CreditSpendWindow_2;
1042
+ }
1043
+
1044
+ /** How a spend policy applies its limit. Unknown kinds are carried, not dropped:
1045
+ * the server may ship a kind this SDK version predates. */
1046
+ export declare type CreditSpendPolicyKind = "per_draw" | "window" | (string & {});
1047
+
1048
+ declare type CreditSpendPolicyListenerFn = CreditSpendPoliciesListenerFn | EmptyListenerFn;
1049
+
1050
+ /** Whether a spend policy limits the company or one user */
1051
+ export declare type CreditSpendPolicyScope = "company" | "user" | (string & {});
1052
+
1053
+ /**
1054
+ *
1055
+ * @export
1056
+ */
1057
+ declare const CreditSpendPolicyScope_2: {
1058
+ readonly Company: "company";
1059
+ readonly User: "user";
1060
+ readonly Group: "group";
1061
+ };
1062
+
1063
+ declare type CreditSpendPolicyScope_2 = (typeof CreditSpendPolicyScope_2)[keyof typeof CreditSpendPolicyScope_2];
1064
+
1065
+ /** The period a windowed spend policy accumulates over */
1066
+ export declare type CreditSpendWindow = {
1067
+ unit: string;
1068
+ count: number;
1069
+ };
1070
+
1071
+ /**
1072
+ * Schematic API
1073
+ * Schematic API
1074
+ *
1075
+ * The version of the OpenAPI document: 0.1
1076
+ *
1077
+ *
1078
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1079
+ * https://openapi-generator.tech
1080
+ * Do not edit the class manually.
1081
+ */
1082
+ /**
1083
+ *
1084
+ * @export
1085
+ * @interface CreditSpendWindow
1086
+ */
1087
+ declare interface CreditSpendWindow_2 {
1088
+ /**
1089
+ * How many units make up one period
1090
+ * @type {number}
1091
+ * @memberof CreditSpendWindow
1092
+ */
1093
+ count: number;
1094
+ /**
1095
+ * The period the limit accumulates over
1096
+ * @type {string}
1097
+ * @memberof CreditSpendWindow
1098
+ */
1099
+ unit: string;
1100
+ }
1101
+
741
1102
  /**
742
1103
  *
743
1104
  * @export
@@ -1146,6 +1507,35 @@ export declare function normalizeInvoiceQuery(query: InvoiceQuery): InvoiceQuery
1146
1507
  */
1147
1508
  declare function normalizeInvoiceQuery_2(query: InvoiceQuery): InvoiceQuery;
1148
1509
 
1510
+ /**
1511
+ * One way the company pays. Two flags the server has already decided, so a
1512
+ * consumer never re-derives a provider's rules:
1513
+ *
1514
+ * * `isDefault` — the subscription's default method, or, when the
1515
+ * subscription names none, the customer's.
1516
+ * * `canRemove` — whether a delete would be accepted; the server's rule,
1517
+ * not `!isDefault`.
1518
+ *
1519
+ * `id` is Schematic's, and is what a delete takes; `externalId` is the
1520
+ * provider's, and is what making it the default takes.
1521
+ */
1522
+ export declare type PaymentMethod = CompanyPaymentMethodResponseData;
1523
+
1524
+ export declare interface PaymentMethodsHandle extends ResourceHandle<PaymentMethod[]> {
1525
+ /**
1526
+ * Makes `externalId` the default; `data` reloads once it has. Rejects
1527
+ * with the failure and records it on `mutationError`, so a caller can
1528
+ * await it or read it, whichever the component does.
1529
+ */
1530
+ setDefault: (externalId: string) => Promise<void>;
1531
+ /** Removes payment method `id`; `data` reloads once it has. Rejects as `setDefault` does. */
1532
+ remove: (id: string) => Promise<void>;
1533
+ /** A write is in flight. Distinct from `isPending`, which is the list loading. */
1534
+ isMutating: boolean;
1535
+ /** The last write's failure; cleared when the next write starts. */
1536
+ mutationError: Error | undefined;
1537
+ }
1538
+
1149
1539
  declare type PendingListenerFn = BooleanListenerFn | EmptyListenerFn;
1150
1540
 
1151
1541
  declare type PlanListenerFn = CheckPlanReturnListenerFn | EmptyListenerFn;
@@ -1226,6 +1616,7 @@ export declare class Schematic {
1226
1616
  private isPendingListeners;
1227
1617
  private planListeners;
1228
1618
  private creditBalanceListeners;
1619
+ private creditSpendPolicyListeners;
1229
1620
  private storage;
1230
1621
  private persistFlagState;
1231
1622
  private flagStateCacheKey;
@@ -1236,6 +1627,7 @@ export declare class Schematic {
1236
1627
  private featureUsageEventMap;
1237
1628
  private planChecks;
1238
1629
  private creditBalances;
1630
+ private creditSpendPolicies;
1239
1631
  private webSocketUrl;
1240
1632
  private webSocketConnectionTimeout;
1241
1633
  private webSocketReconnect;
@@ -1454,6 +1846,10 @@ export declare class Schematic {
1454
1846
  getCreditBalances: () => CreditBalances;
1455
1847
  /** Get the company's lease-aware balance for a single credit type in the current context */
1456
1848
  getCreditBalance: (creditId: string) => CreditBalance | undefined;
1849
+ /** Get every credit spend policy binding the current context, company-scope first */
1850
+ getCreditSpendPolicies: () => CreditSpendPolicies;
1851
+ /** Get the spend policies binding a single credit type in the current context */
1852
+ getCreditSpendPoliciesForCredit: (creditId: string) => CreditSpendPolicies;
1457
1853
  getFlagCheck: (flagKey: string) => CheckFlagReturn | undefined;
1458
1854
  getFlagValue: (flagKey: string) => boolean | undefined;
1459
1855
  /** Register an event listener that will be notified with the boolean value for a given flag when this value changes */
@@ -1463,11 +1859,14 @@ export declare class Schematic {
1463
1859
  addPlanListener: (listener: PlanListenerFn) => () => void;
1464
1860
  /** Register an event listener that will be notified with the company's credit balances (keyed by credit ID) whenever they change */
1465
1861
  addCreditBalanceListener: (listener: CreditBalanceListenerFn) => () => void;
1862
+ /** Register an event listener that will be notified with the context's credit spend policies whenever the set changes */
1863
+ addCreditSpendPolicyListener: (listener: CreditSpendPolicyListenerFn) => () => void;
1466
1864
  private notifyFlagCheckListeners;
1467
1865
  /** Add or update a CheckFlagReturn in the featureUsageEventMap */
1468
1866
  private updateFeatureUsageEventMap;
1469
1867
  private notifyFlagValueListeners;
1470
1868
  private notifyPlanListeners;
1869
+ private notifyCreditSpendPolicyListeners;
1471
1870
  private notifyCreditBalanceListeners;
1472
1871
  }
1473
1872
 
@@ -1491,6 +1890,10 @@ declare class SchematicBillingClient implements BillingClient {
1491
1890
  onSessionChange(listener: (event: SessionEvent) => void): () => void;
1492
1891
  fetchInvoices(params: InvoicesRequest): Promise<InvoicesResult>;
1493
1892
  fetchUpcomingInvoice(): Promise<UpcomingInvoice | null>;
1893
+ fetchPaymentMethods(): Promise<PaymentMethod[]>;
1894
+ createSetupIntent(): Promise<SetupIntent>;
1895
+ updatePaymentMethod(externalId: string): Promise<void>;
1896
+ deletePaymentMethod(id: string): Promise<void>;
1494
1897
  }
1495
1898
 
1496
1899
  /** Context for checking flags and sending events */
@@ -1511,6 +1914,14 @@ export declare type SchematicCreditBalance = {
1511
1914
  isLoading: boolean;
1512
1915
  };
1513
1916
 
1917
+ /** The credit spend policies binding the current context, plus a loading flag */
1918
+ export declare type SchematicCreditSpendPolicies = {
1919
+ /** Company-scope policies first, then the actor's own; empty when none bind */
1920
+ policies: SchematicJS.CreditSpendPolicies;
1921
+ /** True while the policies are still loading and nothing has arrived yet */
1922
+ isLoading: boolean;
1923
+ };
1924
+
1514
1925
  export declare interface SchematicHookOpts {
1515
1926
  client?: SchematicJS.Schematic;
1516
1927
  }
@@ -1574,12 +1985,22 @@ declare namespace SchematicJS {
1574
1985
  CompanyCreditBalance,
1575
1986
  CompanyDiscountResponseData,
1576
1987
  CompanyInvoiceResponseData,
1988
+ CompanyPaymentMethodResponseData,
1577
1989
  CompanyUpcomingInvoiceResponseData,
1578
1990
  CreditBalance,
1579
1991
  CreditBalanceListenerFn,
1580
1992
  CreditBalances,
1581
1993
  CreditBalancesFromJSON,
1582
1994
  CreditBalancesListenerFn,
1995
+ CreditSpendPolicies,
1996
+ creditSpendPoliciesEqual,
1997
+ CreditSpendPoliciesFromJSON,
1998
+ CreditSpendPoliciesListenerFn,
1999
+ CreditSpendPolicy,
2000
+ CreditSpendPolicyKind,
2001
+ CreditSpendPolicyListenerFn,
2002
+ CreditSpendPolicyScope,
2003
+ CreditSpendWindow,
1583
2004
  DEFAULT_INVOICE_QUERY,
1584
2005
  Discount,
1585
2006
  EmptyListenerFn,
@@ -1600,6 +2021,7 @@ declare namespace SchematicJS {
1600
2021
  InvoicesResult,
1601
2022
  InvoiceStatus,
1602
2023
  Keys,
2024
+ PaymentMethod,
1603
2025
  PendingListenerFn,
1604
2026
  PlanListenerFn,
1605
2027
  RequestOptions,
@@ -1616,6 +2038,8 @@ declare namespace SchematicJS {
1616
2038
  SessionInput,
1617
2039
  SessionOptions,
1618
2040
  SessionStatus,
2041
+ SetupIntent,
2042
+ SetupIntentResponseData,
1619
2043
  SINGLETON,
1620
2044
  StoragePersister,
1621
2045
  TOKEN_CACHE_SIZE,
@@ -1796,6 +2220,57 @@ declare interface SessionOptions {
1796
2220
 
1797
2221
  export declare type SessionStatus = "pending" | "active" | "ended";
1798
2222
 
2223
+ /** What a provider's card form is mounted with to add a method. */
2224
+ export declare type SetupIntent = SetupIntentResponseData;
2225
+
2226
+ export declare interface SetupIntentHandle {
2227
+ /** A new intent every call: an intent is single-use, so none is kept. */
2228
+ create: () => Promise<SetupIntent>;
2229
+ }
2230
+
2231
+ /**
2232
+ * Schematic API
2233
+ * Schematic API
2234
+ *
2235
+ * The version of the OpenAPI document: 0.1
2236
+ *
2237
+ *
2238
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
2239
+ * https://openapi-generator.tech
2240
+ * Do not edit the class manually.
2241
+ */
2242
+ /**
2243
+ *
2244
+ * @export
2245
+ * @interface SetupIntentResponseData
2246
+ */
2247
+ declare interface SetupIntentResponseData {
2248
+ /**
2249
+ *
2250
+ * @type {string}
2251
+ * @memberof SetupIntentResponseData
2252
+ */
2253
+ accountId?: string | null;
2254
+ /**
2255
+ *
2256
+ * @type {string}
2257
+ * @memberof SetupIntentResponseData
2258
+ */
2259
+ publishableKey?: string | null;
2260
+ /**
2261
+ *
2262
+ * @type {string}
2263
+ * @memberof SetupIntentResponseData
2264
+ */
2265
+ schematicPublishableKey: string;
2266
+ /**
2267
+ *
2268
+ * @type {string}
2269
+ * @memberof SetupIntentResponseData
2270
+ */
2271
+ setupIntentClientSecret?: string | null;
2272
+ }
2273
+
1799
2274
  /** The params of every singleton resource. */
1800
2275
  export declare const SINGLETON: Record<string, never>;
1801
2276
 
@@ -1876,6 +2351,19 @@ export declare function useInvalidateBillingData(): () => void;
1876
2351
  */
1877
2352
  export declare function useInvoices(query?: InvoiceQuery): InvoicesHandle;
1878
2353
 
2354
+ /**
2355
+ * The company's payment methods, with the writes on them. `data` is the
2356
+ * list, `isPending` and `error` its load, and `isMutating` and
2357
+ * `mutationError` the last write; a write's failure never lands on `error`,
2358
+ * which stays the list's own.
2359
+ *
2360
+ * Writes are not coalesced: a second call while one is in flight runs too,
2361
+ * the store reloads the list after each, and `isMutating` stays true until
2362
+ * the last lands. A component that wants one at a time disables its buttons
2363
+ * on `isMutating`.
2364
+ */
2365
+ export declare function usePaymentMethods(): PaymentMethodsHandle;
2366
+
1879
2367
  export declare const useSchematic: () => SchematicContextProps;
1880
2368
 
1881
2369
  export declare const useSchematicContext: (opts?: SchematicHookOpts) => {
@@ -1897,6 +2385,11 @@ export declare const useSchematicContext: (opts?: SchematicHookOpts) => {
1897
2385
  */
1898
2386
  export declare const useSchematicCreditBalance: (creditId: string | undefined, opts?: SchematicHookOpts) => SchematicCreditBalance;
1899
2387
 
2388
+ /** Every credit spend policy binding the current context, company-scope first.
2389
+ * Streams over the websocket, so an edit in the dashboard lands here without a
2390
+ * refetch. */
2391
+ export declare const useSchematicCreditSpendPolicies: (opts?: SchematicHookOpts) => SchematicCreditSpendPolicies;
2392
+
1900
2393
  export declare const useSchematicEntitlement: (key: string, opts?: UseSchematicFlagOpts) => SchematicJS.CheckFlagReturn;
1901
2394
 
1902
2395
  export declare const useSchematicEvents: (opts?: SchematicHookOpts) => {
@@ -1928,6 +2421,14 @@ export declare function useSchematicStrings(): StringOverrides | undefined;
1928
2421
 
1929
2422
  export declare function useSchematicTranslate(): Translate | undefined;
1930
2423
 
2424
+ /**
2425
+ * Mints setup intents for adding a payment method. Subscribes to no
2426
+ * resource, reports no state, and rejects with the failure. Once the
2427
+ * provider confirms the intent, the list is reloaded by whoever adds the
2428
+ * method — `refetch` on `usePaymentMethods`, or `useInvalidateBillingData`.
2429
+ */
2430
+ export declare function useSetupIntent(): SetupIntentHandle;
2431
+
1931
2432
  /**
1932
2433
  * The company's next bill. `data` is `null` when there is nothing to bill —
1933
2434
  * no subscription, which the endpoint reports as a 204 — so an element can