@schematichq/schematic-react 1.9.0 → 1.11.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.
@@ -67,18 +67,78 @@ declare namespace billingApi {
67
67
  ApiErrorToJSON,
68
68
  ApiErrorToJSONTyped,
69
69
  ApiError,
70
+ instanceOfBillingPlanCreditGrantResetCadence,
71
+ BillingPlanCreditGrantResetCadenceFromJSON,
72
+ BillingPlanCreditGrantResetCadenceFromJSONTyped,
73
+ BillingPlanCreditGrantResetCadenceToJSON,
74
+ BillingPlanCreditGrantResetCadenceToJSONTyped,
75
+ BillingPlanCreditGrantResetCadence,
76
+ instanceOfBillingPriceScheme,
77
+ BillingPriceSchemeFromJSON,
78
+ BillingPriceSchemeFromJSONTyped,
79
+ BillingPriceSchemeToJSON,
80
+ BillingPriceSchemeToJSONTyped,
81
+ BillingPriceScheme,
82
+ instanceOfBillingProductPriceInterval,
83
+ BillingProductPriceIntervalFromJSON,
84
+ BillingProductPriceIntervalFromJSONTyped,
85
+ BillingProductPriceIntervalToJSON,
86
+ BillingProductPriceIntervalToJSONTyped,
87
+ BillingProductPriceInterval,
70
88
  instanceOfBillingProviderType,
71
89
  BillingProviderTypeFromJSON,
72
90
  BillingProviderTypeFromJSONTyped,
73
91
  BillingProviderTypeToJSON,
74
92
  BillingProviderTypeToJSONTyped,
75
93
  BillingProviderType,
94
+ instanceOfBillingTiersMode,
95
+ BillingTiersModeFromJSON,
96
+ BillingTiersModeFromJSONTyped,
97
+ BillingTiersModeToJSON,
98
+ BillingTiersModeToJSONTyped,
99
+ BillingTiersMode,
100
+ instanceOfCatalogCreditGrantResponseData,
101
+ CatalogCreditGrantResponseDataFromJSON,
102
+ CatalogCreditGrantResponseDataFromJSONTyped,
103
+ CatalogCreditGrantResponseDataToJSON,
104
+ CatalogCreditGrantResponseDataToJSONTyped,
105
+ CatalogCreditGrantResponseData,
106
+ instanceOfCatalogPriceResponseData,
107
+ CatalogPriceResponseDataFromJSON,
108
+ CatalogPriceResponseDataFromJSONTyped,
109
+ CatalogPriceResponseDataToJSON,
110
+ CatalogPriceResponseDataToJSONTyped,
111
+ CatalogPriceResponseData,
112
+ instanceOfCatalogPriceTierResponseData,
113
+ CatalogPriceTierResponseDataFromJSON,
114
+ CatalogPriceTierResponseDataFromJSONTyped,
115
+ CatalogPriceTierResponseDataToJSON,
116
+ CatalogPriceTierResponseDataToJSONTyped,
117
+ CatalogPriceTierResponseData,
76
118
  instanceOfCompanyDiscountResponseData,
77
119
  CompanyDiscountResponseDataFromJSON,
78
120
  CompanyDiscountResponseDataFromJSONTyped,
79
121
  CompanyDiscountResponseDataToJSON,
80
122
  CompanyDiscountResponseDataToJSONTyped,
81
123
  CompanyDiscountResponseData,
124
+ instanceOfCompanyFeatureUsageListResponseData,
125
+ CompanyFeatureUsageListResponseDataFromJSON,
126
+ CompanyFeatureUsageListResponseDataFromJSONTyped,
127
+ CompanyFeatureUsageListResponseDataToJSON,
128
+ CompanyFeatureUsageListResponseDataToJSONTyped,
129
+ CompanyFeatureUsageListResponseData,
130
+ instanceOfCompanyFeatureUsageResponseData,
131
+ CompanyFeatureUsageResponseDataFromJSON,
132
+ CompanyFeatureUsageResponseDataFromJSONTyped,
133
+ CompanyFeatureUsageResponseDataToJSON,
134
+ CompanyFeatureUsageResponseDataToJSONTyped,
135
+ CompanyFeatureUsageResponseData,
136
+ instanceOfCompanyFeatureUserUsageResponseData,
137
+ CompanyFeatureUserUsageResponseDataFromJSON,
138
+ CompanyFeatureUserUsageResponseDataFromJSONTyped,
139
+ CompanyFeatureUserUsageResponseDataToJSON,
140
+ CompanyFeatureUserUsageResponseDataToJSONTyped,
141
+ CompanyFeatureUserUsageResponseData,
82
142
  instanceOfCompanyInvoiceResponseData,
83
143
  CompanyInvoiceResponseDataFromJSON,
84
144
  CompanyInvoiceResponseDataFromJSONTyped,
@@ -109,6 +169,12 @@ declare namespace billingApi {
109
169
  CompanyUpcomingInvoiceResponseDataToJSON,
110
170
  CompanyUpcomingInvoiceResponseDataToJSONTyped,
111
171
  CompanyUpcomingInvoiceResponseData,
172
+ instanceOfCompanyUserUsageResponseData,
173
+ CompanyUserUsageResponseDataFromJSON,
174
+ CompanyUserUsageResponseDataFromJSONTyped,
175
+ CompanyUserUsageResponseDataToJSON,
176
+ CompanyUserUsageResponseDataToJSONTyped,
177
+ CompanyUserUsageResponseData,
112
178
  instanceOfCreateSetupIntentResponse,
113
179
  CreateSetupIntentResponseFromJSON,
114
180
  CreateSetupIntentResponseFromJSONTyped,
@@ -127,6 +193,48 @@ declare namespace billingApi {
127
193
  DeleteResponseToJSON,
128
194
  DeleteResponseToJSONTyped,
129
195
  DeleteResponse,
196
+ instanceOfEntitlementPriceBehavior,
197
+ EntitlementPriceBehaviorFromJSON,
198
+ EntitlementPriceBehaviorFromJSONTyped,
199
+ EntitlementPriceBehaviorToJSON,
200
+ EntitlementPriceBehaviorToJSONTyped,
201
+ EntitlementPriceBehavior,
202
+ instanceOfEntitlementType,
203
+ EntitlementTypeFromJSON,
204
+ EntitlementTypeFromJSONTyped,
205
+ EntitlementTypeToJSON,
206
+ EntitlementTypeToJSONTyped,
207
+ EntitlementType,
208
+ instanceOfEntitlementValueType,
209
+ EntitlementValueTypeFromJSON,
210
+ EntitlementValueTypeFromJSONTyped,
211
+ EntitlementValueTypeToJSON,
212
+ EntitlementValueTypeToJSONTyped,
213
+ EntitlementValueType_2 as EntitlementValueType,
214
+ instanceOfFeatureType,
215
+ FeatureTypeFromJSON,
216
+ FeatureTypeFromJSONTyped,
217
+ FeatureTypeToJSON,
218
+ FeatureTypeToJSONTyped,
219
+ FeatureType,
220
+ instanceOfGetCompanyFeatureUsageResponse,
221
+ GetCompanyFeatureUsageResponseFromJSON,
222
+ GetCompanyFeatureUsageResponseFromJSONTyped,
223
+ GetCompanyFeatureUsageResponseToJSON,
224
+ GetCompanyFeatureUsageResponseToJSONTyped,
225
+ GetCompanyFeatureUsageResponse,
226
+ instanceOfGetCompanyFeatureUserUsageParams,
227
+ GetCompanyFeatureUserUsageParamsFromJSON,
228
+ GetCompanyFeatureUserUsageParamsFromJSONTyped,
229
+ GetCompanyFeatureUserUsageParamsToJSON,
230
+ GetCompanyFeatureUserUsageParamsToJSONTyped,
231
+ GetCompanyFeatureUserUsageParams,
232
+ instanceOfGetCompanyFeatureUserUsageResponse,
233
+ GetCompanyFeatureUserUsageResponseFromJSON,
234
+ GetCompanyFeatureUserUsageResponseFromJSONTyped,
235
+ GetCompanyFeatureUserUsageResponseToJSON,
236
+ GetCompanyFeatureUserUsageResponseToJSONTyped,
237
+ GetCompanyFeatureUserUsageResponse,
130
238
  instanceOfGetCompanyInvoicesParams,
131
239
  GetCompanyInvoicesParamsFromJSON,
132
240
  GetCompanyInvoicesParamsFromJSONTyped,
@@ -157,12 +265,30 @@ declare namespace billingApi {
157
265
  InvoiceStatusToJSON,
158
266
  InvoiceStatusToJSONTyped,
159
267
  InvoiceStatus,
268
+ instanceOfMetricPeriod,
269
+ MetricPeriodFromJSON,
270
+ MetricPeriodFromJSONTyped,
271
+ MetricPeriodToJSON,
272
+ MetricPeriodToJSONTyped,
273
+ MetricPeriod_2 as MetricPeriod,
274
+ instanceOfMetricPeriodMonthReset,
275
+ MetricPeriodMonthResetFromJSON,
276
+ MetricPeriodMonthResetFromJSONTyped,
277
+ MetricPeriodMonthResetToJSON,
278
+ MetricPeriodMonthResetToJSONTyped,
279
+ MetricPeriodMonthReset_2 as MetricPeriodMonthReset,
160
280
  instanceOfPaymentMethodResponseData,
161
281
  PaymentMethodResponseDataFromJSON,
162
282
  PaymentMethodResponseDataFromJSONTyped,
163
283
  PaymentMethodResponseDataToJSON,
164
284
  PaymentMethodResponseDataToJSONTyped,
165
285
  PaymentMethodResponseData,
286
+ instanceOfPlanCreditGrantScaling,
287
+ PlanCreditGrantScalingFromJSON,
288
+ PlanCreditGrantScalingFromJSONTyped,
289
+ PlanCreditGrantScalingToJSON,
290
+ PlanCreditGrantScalingToJSONTyped,
291
+ PlanCreditGrantScaling,
166
292
  instanceOfSetupIntentResponseData,
167
293
  SetupIntentResponseDataFromJSON,
168
294
  SetupIntentResponseDataFromJSONTyped,
@@ -202,6 +328,10 @@ declare interface BillingClient {
202
328
  updatePaymentMethod(externalId: string): Promise<void>;
203
329
  /** Removes the method, by Schematic's id (`id`). */
204
330
  deletePaymentMethod(id: string): Promise<void>;
331
+ /** Empty when the company is entitled to nothing. */
332
+ fetchFeatureUsage(): Promise<FeatureUsage[]>;
333
+ /** One event-based feature's usage by user over its metric period. */
334
+ fetchFeatureUserUsage(params: FeatureUserUsageRequest): Promise<FeatureUserUsage>;
205
335
  readonly sessionStatus: SessionStatus;
206
336
  readonly sessionKey: string | undefined;
207
337
  setSession(session: SessionInput): void;
@@ -227,11 +357,13 @@ export declare type BillingData = {
227
357
  sessionKey?: string;
228
358
  };
229
359
 
230
- export declare function BillingDataProvider({ actions, children, data, locale, onLoadMoreInvoices, onMissingString, onRefetch, status, strings, translate, }: BillingDataProviderProps): React_2.JSX.Element;
360
+ export declare function BillingDataProvider({ actions, children, data, featureUserUsage, locale, onLoadMoreInvoices, onMissingString, onRefetch, status, strings, translate, }: BillingDataProviderProps): React_2.JSX.Element;
231
361
 
232
362
  declare interface BillingDataProviderDataProps {
233
363
  /** A missing key reports as pending. */
234
364
  data: BillingData;
365
+ /** Usage by user, by feature id; a feature left out reports as pending. */
366
+ featureUserUsage?: Record<string, FeatureUserUsage>;
235
367
  /** Simulated loading / failure per resource; wins over `data`. */
236
368
  status?: BillingDataStatus;
237
369
  onRefetch?: (name: BillingResourceName) => void;
@@ -264,6 +396,13 @@ export declare interface BillingDataSource {
264
396
  */
265
397
  subscribe<K extends BillingResourceName>(name: K, params: BillingResourceParams[K], listener: () => void): () => void;
266
398
  handle<K extends BillingResourceName>(name: K, params: BillingResourceParams[K]): ResourceHandle<BillingResources[K]>;
399
+ /**
400
+ * One feature's usage by user. Keyed by feature, so it sits beside the
401
+ * named resources rather than among them: a source that holds one value
402
+ * per name has no slot for it.
403
+ */
404
+ subscribeFeatureUserUsage(featureId: string, listener: () => void): () => void;
405
+ featureUserUsage(featureId: string): ResourceHandle<FeatureUserUsage>;
267
406
  /** Never rejects: a failure lands on the resource's `error`. */
268
407
  loadMoreInvoices: (query: InvoiceQuery) => Promise<void>;
269
408
  invalidateAll: () => void;
@@ -279,6 +418,21 @@ export declare type BillingDataStatus = {
279
418
  };
280
419
  };
281
420
 
421
+ /**
422
+ *
423
+ * @export
424
+ */
425
+ declare const BillingPlanCreditGrantResetCadence: {
426
+ readonly Daily: "daily";
427
+ readonly Every6Months: "every_6_months";
428
+ readonly Monthly: "monthly";
429
+ readonly Quarterly: "quarterly";
430
+ readonly Weekly: "weekly";
431
+ readonly Yearly: "yearly";
432
+ };
433
+
434
+ declare type BillingPlanCreditGrantResetCadence = (typeof BillingPlanCreditGrantResetCadence)[keyof typeof BillingPlanCreditGrantResetCadence];
435
+
282
436
  declare interface BillingPrefetchOptions {
283
437
  /**
284
438
  * The resources the page renders, and no default: each one is a request
@@ -291,6 +445,30 @@ declare interface BillingPrefetchOptions {
291
445
  invoices?: InvoiceQuery;
292
446
  }
293
447
 
448
+ /**
449
+ *
450
+ * @export
451
+ */
452
+ declare const BillingPriceScheme: {
453
+ readonly PerUnit: "per_unit";
454
+ readonly Tiered: "tiered";
455
+ };
456
+
457
+ declare type BillingPriceScheme = (typeof BillingPriceScheme)[keyof typeof BillingPriceScheme];
458
+
459
+ /**
460
+ *
461
+ * @export
462
+ */
463
+ declare const BillingProductPriceInterval: {
464
+ readonly Day: "day";
465
+ readonly Month: "month";
466
+ readonly OneTime: "one-time";
467
+ readonly Year: "year";
468
+ };
469
+
470
+ declare type BillingProductPriceInterval = (typeof BillingProductPriceInterval)[keyof typeof BillingProductPriceInterval];
471
+
294
472
  /**
295
473
  * Provides the billing hooks from a `BillingStore` over a `BillingProviderClient`.
296
474
  * Rendered by `SchematicProvider`; usable on its own with a client.
@@ -305,7 +483,7 @@ export declare function BillingProvider({ billingClient, children, initialData,
305
483
  * much. Named apart from schematic-js's `BillingClient`, which is the whole
306
484
  * interface; this is the part the hooks here call.
307
485
  */
308
- export declare type BillingProviderClient = Pick<BillingClient, "sessionStatus" | "sessionKey" | "setSession" | "onSessionChange" | "fetchInvoices" | "fetchUpcomingInvoice" | "fetchPaymentMethods" | "createSetupIntent" | "updatePaymentMethod" | "deletePaymentMethod">;
486
+ export declare type BillingProviderClient = Pick<BillingClient, "sessionStatus" | "sessionKey" | "setSession" | "onSessionChange" | "fetchInvoices" | "fetchUpcomingInvoice" | "fetchPaymentMethods" | "createSetupIntent" | "updatePaymentMethod" | "deletePaymentMethod" | "fetchFeatureUsage" | "fetchFeatureUserUsage">;
309
487
 
310
488
  declare interface BillingProviderDataProps {
311
489
  /**
@@ -345,7 +523,7 @@ declare interface BillingProviderDataProps {
345
523
  export declare type BillingProviderProps = BillingProviderDataProps & SchematicI18nConfig;
346
524
 
347
525
  /** The resources this package serves; a key of schematic-js's contract. */
348
- export declare type BillingResourceName = "invoices" | "upcomingInvoice" | "paymentMethods";
526
+ export declare type BillingResourceName = "invoices" | "upcomingInvoice" | "paymentMethods" | "featureUsage";
349
527
 
350
528
  declare type BillingResourceName_2 = keyof BillingResources_2;
351
529
 
@@ -356,6 +534,7 @@ declare interface BillingResourceParams_2 {
356
534
  invoices: InvoiceQuery;
357
535
  upcomingInvoice: Record<string, never>;
358
536
  paymentMethods: Record<string, never>;
537
+ featureUsage: Record<string, never>;
359
538
  }
360
539
 
361
540
  export declare type BillingResources = Pick<BillingResources_2, BillingResourceName>;
@@ -381,10 +560,223 @@ declare interface BillingResources_2 {
381
560
  * has no method on file — so only `undefined` means not loaded.
382
561
  */
383
562
  paymentMethods: PaymentMethod[];
563
+ /**
564
+ * `GET /company/usage`. Empty is a loaded value — the company is entitled
565
+ * to nothing — so only `undefined` means not loaded.
566
+ */
567
+ featureUsage: FeatureUsage[];
384
568
  }
385
569
 
570
+ /**
571
+ *
572
+ * @export
573
+ */
574
+ declare const BillingTiersMode: {
575
+ readonly Graduated: "graduated";
576
+ readonly Volume: "volume";
577
+ };
578
+
579
+ declare type BillingTiersMode = (typeof BillingTiersMode)[keyof typeof BillingTiersMode];
580
+
386
581
  declare type BooleanListenerFn = (value: boolean) => void;
387
582
 
583
+ /**
584
+ *
585
+ * @export
586
+ * @interface CatalogCreditGrantResponseData
587
+ */
588
+ declare interface CatalogCreditGrantResponseData {
589
+ /**
590
+ * Flat credit amount granted to the company regardless of scaling.
591
+ * @type {number}
592
+ * @memberof CatalogCreditGrantResponseData
593
+ */
594
+ companyCreditAmount: number;
595
+ /**
596
+ * Credits granted; for per_license scaling this is the amount per license unit.
597
+ * @type {number}
598
+ * @memberof CatalogCreditGrantResponseData
599
+ */
600
+ creditAmount: number;
601
+ /**
602
+ *
603
+ * @type {string}
604
+ * @memberof CatalogCreditGrantResponseData
605
+ */
606
+ creditIcon?: string | null;
607
+ /**
608
+ *
609
+ * @type {string}
610
+ * @memberof CatalogCreditGrantResponseData
611
+ */
612
+ creditId: string;
613
+ /**
614
+ *
615
+ * @type {string}
616
+ * @memberof CatalogCreditGrantResponseData
617
+ */
618
+ creditName: string;
619
+ /**
620
+ *
621
+ * @type {string}
622
+ * @memberof CatalogCreditGrantResponseData
623
+ */
624
+ creditPluralName?: string | null;
625
+ /**
626
+ *
627
+ * @type {string}
628
+ * @memberof CatalogCreditGrantResponseData
629
+ */
630
+ creditSingularName?: string | null;
631
+ /**
632
+ *
633
+ * @type {string}
634
+ * @memberof CatalogCreditGrantResponseData
635
+ */
636
+ id: string;
637
+ /**
638
+ *
639
+ * @type {string}
640
+ * @memberof CatalogCreditGrantResponseData
641
+ */
642
+ licenseId?: string | null;
643
+ /**
644
+ *
645
+ * @type {BillingPlanCreditGrantResetCadence}
646
+ * @memberof CatalogCreditGrantResponseData
647
+ */
648
+ resetCadence?: BillingPlanCreditGrantResetCadence | null;
649
+ /**
650
+ *
651
+ * @type {PlanCreditGrantScaling}
652
+ * @memberof CatalogCreditGrantResponseData
653
+ */
654
+ scaling: PlanCreditGrantScaling;
655
+ }
656
+
657
+ /**
658
+ *
659
+ * @export
660
+ * @interface CatalogPriceResponseData
661
+ */
662
+ declare interface CatalogPriceResponseData {
663
+ /**
664
+ *
665
+ * @type {string}
666
+ * @memberof CatalogPriceResponseData
667
+ */
668
+ currency: string;
669
+ /**
670
+ *
671
+ * @type {string}
672
+ * @memberof CatalogPriceResponseData
673
+ */
674
+ id: string;
675
+ /**
676
+ *
677
+ * @type {BillingProductPriceInterval}
678
+ * @memberof CatalogPriceResponseData
679
+ */
680
+ interval: BillingProductPriceInterval;
681
+ /**
682
+ *
683
+ * @type {number}
684
+ * @memberof CatalogPriceResponseData
685
+ */
686
+ intervalCount: number;
687
+ /**
688
+ * Per-unit price of the final tier, precomputed for overage display.
689
+ * @type {string}
690
+ * @memberof CatalogPriceResponseData
691
+ */
692
+ overageUnitPriceDecimal?: string | null;
693
+ /**
694
+ * Units covered per priced package; a price of $10 with package_size 1000 charges $10 per 1000 units.
695
+ * @type {number}
696
+ * @memberof CatalogPriceResponseData
697
+ */
698
+ packageSize: number;
699
+ /**
700
+ *
701
+ * @type {number}
702
+ * @memberof CatalogPriceResponseData
703
+ */
704
+ price: number;
705
+ /**
706
+ *
707
+ * @type {string}
708
+ * @memberof CatalogPriceResponseData
709
+ */
710
+ priceDecimal?: string | null;
711
+ /**
712
+ *
713
+ * @type {Array<CatalogPriceTierResponseData>}
714
+ * @memberof CatalogPriceResponseData
715
+ */
716
+ priceTiers: Array<CatalogPriceTierResponseData>;
717
+ /**
718
+ *
719
+ * @type {BillingPriceScheme}
720
+ * @memberof CatalogPriceResponseData
721
+ */
722
+ scheme: BillingPriceScheme;
723
+ /**
724
+ *
725
+ * @type {BillingTiersMode}
726
+ * @memberof CatalogPriceResponseData
727
+ */
728
+ tiersMode?: BillingTiersMode | null;
729
+ }
730
+
731
+ /**
732
+ * Schematic API
733
+ * Schematic API
734
+ *
735
+ * The version of the OpenAPI document: 0.1
736
+ *
737
+ *
738
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
739
+ * https://openapi-generator.tech
740
+ * Do not edit the class manually.
741
+ */
742
+ /**
743
+ *
744
+ * @export
745
+ * @interface CatalogPriceTierResponseData
746
+ */
747
+ declare interface CatalogPriceTierResponseData {
748
+ /**
749
+ *
750
+ * @type {number}
751
+ * @memberof CatalogPriceTierResponseData
752
+ */
753
+ flatPrice?: number | null;
754
+ /**
755
+ * Lower bound of the tier (inclusive).
756
+ * @type {number}
757
+ * @memberof CatalogPriceTierResponseData
758
+ */
759
+ from: number;
760
+ /**
761
+ *
762
+ * @type {number}
763
+ * @memberof CatalogPriceTierResponseData
764
+ */
765
+ perUnitPrice?: number | null;
766
+ /**
767
+ *
768
+ * @type {string}
769
+ * @memberof CatalogPriceTierResponseData
770
+ */
771
+ perUnitPriceDecimal?: string | null;
772
+ /**
773
+ * Upper bound of the tier (inclusive); null means unbounded.
774
+ * @type {number}
775
+ * @memberof CatalogPriceTierResponseData
776
+ */
777
+ to?: number | null;
778
+ }
779
+
388
780
  /**
389
781
  *
390
782
  * @export
@@ -593,6 +985,12 @@ declare interface CheckFlagsResponseData {
593
985
  creditBalances?: {
594
986
  [key: string]: CompanyCreditBalance;
595
987
  };
988
+ /**
989
+ * 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
990
+ * @type {Array<CreditSpendPolicy>}
991
+ * @memberof CheckFlagsResponseData
992
+ */
993
+ creditSpendPolicies: Array<CreditSpendPolicy_2>;
596
994
  /**
597
995
  *
598
996
  * @type {Array<CheckFlagResponseData>}
@@ -683,45 +1081,295 @@ declare interface CompanyDiscountResponseData {
683
1081
  /**
684
1082
  *
685
1083
  * @type {number}
686
- * @memberof CompanyDiscountResponseData
1084
+ * @memberof CompanyDiscountResponseData
1085
+ */
1086
+ amountOff?: number | null;
1087
+ /**
1088
+ *
1089
+ * @type {string}
1090
+ * @memberof CompanyDiscountResponseData
1091
+ */
1092
+ couponName: string;
1093
+ /**
1094
+ *
1095
+ * @type {string}
1096
+ * @memberof CompanyDiscountResponseData
1097
+ */
1098
+ currency?: string | null;
1099
+ /**
1100
+ *
1101
+ * @type {string}
1102
+ * @memberof CompanyDiscountResponseData
1103
+ */
1104
+ customerFacingCode?: string | null;
1105
+ /**
1106
+ * Provider vocabulary: once, repeating, or forever.
1107
+ * @type {string}
1108
+ * @memberof CompanyDiscountResponseData
1109
+ */
1110
+ duration: string;
1111
+ /**
1112
+ *
1113
+ * @type {number}
1114
+ * @memberof CompanyDiscountResponseData
1115
+ */
1116
+ durationInMonths?: number | null;
1117
+ /**
1118
+ *
1119
+ * @type {number}
1120
+ * @memberof CompanyDiscountResponseData
1121
+ */
1122
+ percentOff?: number | null;
1123
+ }
1124
+
1125
+ /**
1126
+ *
1127
+ * @export
1128
+ * @interface CompanyFeatureUsageResponseData
1129
+ */
1130
+ declare interface CompanyFeatureUsageResponseData {
1131
+ /**
1132
+ * Whether the company may use the feature right now.
1133
+ * @type {boolean}
1134
+ * @memberof CompanyFeatureUsageResponseData
1135
+ */
1136
+ access: boolean;
1137
+ /**
1138
+ * The entitlement's own limit before any price behavior applies: the numeric value, or the trait's value for a trait-based entitlement. For a credit entitlement, the credits granted in the current billing period (all time without a subscription). Null for unlimited and boolean entitlements.
1139
+ * @type {number}
1140
+ * @memberof CompanyFeatureUsageResponseData
1141
+ */
1142
+ allocation?: number | null;
1143
+ /**
1144
+ * Set when entitlement_type is company_override.
1145
+ * @type {string}
1146
+ * @memberof CompanyFeatureUsageResponseData
1147
+ */
1148
+ companyOverrideId?: string | null;
1149
+ /**
1150
+ * Credits consumed per unit of usage, for entitlements that burn credits.
1151
+ * @type {number}
1152
+ * @memberof CompanyFeatureUsageResponseData
1153
+ */
1154
+ consumptionRate?: number | null;
1155
+ /**
1156
+ *
1157
+ * @type {string}
1158
+ * @memberof CompanyFeatureUsageResponseData
1159
+ */
1160
+ creditIcon?: string | null;
1161
+ /**
1162
+ *
1163
+ * @type {string}
1164
+ * @memberof CompanyFeatureUsageResponseData
1165
+ */
1166
+ creditId?: string | null;
1167
+ /**
1168
+ *
1169
+ * @type {string}
1170
+ * @memberof CompanyFeatureUsageResponseData
1171
+ */
1172
+ creditName?: string | null;
1173
+ /**
1174
+ *
1175
+ * @type {string}
1176
+ * @memberof CompanyFeatureUsageResponseData
1177
+ */
1178
+ creditPluralName?: string | null;
1179
+ /**
1180
+ *
1181
+ * @type {string}
1182
+ * @memberof CompanyFeatureUsageResponseData
1183
+ */
1184
+ creditSingularName?: string | null;
1185
+ /**
1186
+ * What the feature costs at price, in its minor units: the allocation for pay_in_advance, usage for tier and pay_as_you_go, and usage above soft_limit for overage. Null when there is no price, the price behavior bills nothing, or there is nothing yet to bill it on (no allocation for pay_in_advance, unknown usage for tier, no usage for pay_as_you_go and overage); tier at zero usage, and overage within soft_limit, cost 0.
1187
+ * @type {number}
1188
+ * @memberof CompanyFeatureUsageResponseData
1189
+ */
1190
+ currentCost?: number | null;
1191
+ /**
1192
+ *
1193
+ * @type {EntitlementType}
1194
+ * @memberof CompanyFeatureUsageResponseData
1195
+ */
1196
+ entitlementType: EntitlementType;
1197
+ /**
1198
+ * When a company override ends; plan entitlements do not expire.
1199
+ * @type {Date}
1200
+ * @memberof CompanyFeatureUsageResponseData
1201
+ */
1202
+ expiresAt?: Date | null;
1203
+ /**
1204
+ *
1205
+ * @type {string}
1206
+ * @memberof CompanyFeatureUsageResponseData
1207
+ */
1208
+ featureDescription: string;
1209
+ /**
1210
+ *
1211
+ * @type {string}
1212
+ * @memberof CompanyFeatureUsageResponseData
1213
+ */
1214
+ featureIcon: string;
1215
+ /**
1216
+ *
1217
+ * @type {string}
1218
+ * @memberof CompanyFeatureUsageResponseData
1219
+ */
1220
+ featureId: string;
1221
+ /**
1222
+ *
1223
+ * @type {string}
1224
+ * @memberof CompanyFeatureUsageResponseData
1225
+ */
1226
+ featureName: string;
1227
+ /**
1228
+ *
1229
+ * @type {string}
1230
+ * @memberof CompanyFeatureUsageResponseData
1231
+ */
1232
+ featurePluralName?: string | null;
1233
+ /**
1234
+ *
1235
+ * @type {string}
1236
+ * @memberof CompanyFeatureUsageResponseData
1237
+ */
1238
+ featureSingularName?: string | null;
1239
+ /**
1240
+ *
1241
+ * @type {FeatureType}
1242
+ * @memberof CompanyFeatureUsageResponseData
1243
+ */
1244
+ featureType: FeatureType;
1245
+ /**
1246
+ *
1247
+ * @type {string}
1248
+ * @memberof CompanyFeatureUsageResponseData
1249
+ */
1250
+ licenseId?: string | null;
1251
+ /**
1252
+ *
1253
+ * @type {MetricPeriod}
1254
+ * @memberof CompanyFeatureUsageResponseData
1255
+ */
1256
+ metricPeriod?: MetricPeriod_2 | null;
1257
+ /**
1258
+ *
1259
+ * @type {MetricPeriodMonthReset}
1260
+ * @memberof CompanyFeatureUsageResponseData
1261
+ */
1262
+ metricPeriodMonthReset?: MetricPeriodMonthReset_2 | null;
1263
+ /**
1264
+ * The plan's credit grants that scale with the license this feature counts.
1265
+ * @type {Array<CatalogCreditGrantResponseData>}
1266
+ * @memberof CompanyFeatureUsageResponseData
1267
+ */
1268
+ perLicenseCreditGrants: Array<CatalogCreditGrantResponseData>;
1269
+ /**
1270
+ * Set when entitlement_type is plan_entitlement.
1271
+ * @type {string}
1272
+ * @memberof CompanyFeatureUsageResponseData
1273
+ */
1274
+ planEntitlementId?: string | null;
1275
+ /**
1276
+ * The metered price the company is billed at: the slot for its billing period, in the subscription's currency, or in none when the price predates multi-currency (any currency without a subscription). Null when the feature has no such price for that period.
1277
+ * @type {CatalogPriceResponseData}
1278
+ * @memberof CompanyFeatureUsageResponseData
1279
+ */
1280
+ price?: CatalogPriceResponseData;
1281
+ /**
1282
+ *
1283
+ * @type {EntitlementPriceBehavior}
1284
+ * @memberof CompanyFeatureUsageResponseData
1285
+ */
1286
+ priceBehavior?: EntitlementPriceBehavior | null;
1287
+ /**
1288
+ * When the usage metric next resets.
1289
+ * @type {Date}
1290
+ * @memberof CompanyFeatureUsageResponseData
1291
+ */
1292
+ resetsAt?: Date | null;
1293
+ /**
1294
+ *
1295
+ * @type {number}
1296
+ * @memberof CompanyFeatureUsageResponseData
1297
+ */
1298
+ softLimit?: number | null;
1299
+ /**
1300
+ * Usage in the current metric period; null for features that are not metered.
1301
+ * @type {number}
1302
+ * @memberof CompanyFeatureUsageResponseData
1303
+ */
1304
+ usage?: number | null;
1305
+ /**
1306
+ *
1307
+ * @type {boolean}
1308
+ * @memberof CompanyFeatureUsageResponseData
1309
+ */
1310
+ valueBool?: boolean | null;
1311
+ /**
1312
+ *
1313
+ * @type {number}
1314
+ * @memberof CompanyFeatureUsageResponseData
687
1315
  */
688
- amountOff?: number | null;
1316
+ valueNumeric?: number | null;
689
1317
  /**
690
1318
  *
691
- * @type {string}
692
- * @memberof CompanyDiscountResponseData
1319
+ * @type {EntitlementValueType}
1320
+ * @memberof CompanyFeatureUsageResponseData
693
1321
  */
694
- couponName: string;
1322
+ valueType: EntitlementValueType_2;
695
1323
  /**
696
- *
697
- * @type {string}
698
- * @memberof CompanyDiscountResponseData
1324
+ * The default warning-tier value, when configured.
1325
+ * @type {number}
1326
+ * @memberof CompanyFeatureUsageResponseData
699
1327
  */
700
- currency?: string | null;
1328
+ warningThreshold?: number | null;
1329
+ }
1330
+
1331
+ /**
1332
+ *
1333
+ * @export
1334
+ * @interface CompanyFeatureUserUsageResponseData
1335
+ */
1336
+ declare interface CompanyFeatureUserUsageResponseData {
701
1337
  /**
702
- *
703
- * @type {string}
704
- * @memberof CompanyDiscountResponseData
1338
+ * How many of the company's users the breakdown lists across every page, including those without usage in the period; unattributed usage is not a user and is not counted.
1339
+ * @type {number}
1340
+ * @memberof CompanyFeatureUserUsageResponseData
705
1341
  */
706
- customerFacingCode?: string | null;
1342
+ count: number;
707
1343
  /**
708
- * Provider vocabulary: once, repeating, or forever.
709
- * @type {string}
710
- * @memberof CompanyDiscountResponseData
1344
+ * End of the feature's current metric period (exclusive).
1345
+ * @type {Date}
1346
+ * @memberof CompanyFeatureUserUsageResponseData
711
1347
  */
712
- duration: string;
1348
+ endTime: Date;
713
1349
  /**
714
- *
1350
+ * Start of the feature's current metric period.
1351
+ * @type {Date}
1352
+ * @memberof CompanyFeatureUserUsageResponseData
1353
+ */
1354
+ startTime: Date;
1355
+ /**
1356
+ * Usage across every user in the period, not just this page.
715
1357
  * @type {number}
716
- * @memberof CompanyDiscountResponseData
1358
+ * @memberof CompanyFeatureUserUsageResponseData
717
1359
  */
718
- durationInMonths?: number | null;
1360
+ total: number;
719
1361
  /**
720
- *
1362
+ * Usage from events sent without a user; null when the period has none.
721
1363
  * @type {number}
722
- * @memberof CompanyDiscountResponseData
1364
+ * @memberof CompanyFeatureUserUsageResponseData
723
1365
  */
724
- percentOff?: number | null;
1366
+ unattributed?: number | null;
1367
+ /**
1368
+ * This page of users, highest usage first.
1369
+ * @type {Array<CompanyUserUsageResponseData>}
1370
+ * @memberof CompanyFeatureUserUsageResponseData
1371
+ */
1372
+ users: Array<CompanyUserUsageResponseData>;
725
1373
  }
726
1374
 
727
1375
  /**
@@ -927,6 +1575,85 @@ declare interface CompanyUpcomingInvoiceResponseData {
927
1575
  subtotal: number;
928
1576
  }
929
1577
 
1578
+ /**
1579
+ * Schematic API
1580
+ * Schematic API
1581
+ *
1582
+ * The version of the OpenAPI document: 0.1
1583
+ *
1584
+ *
1585
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1586
+ * https://openapi-generator.tech
1587
+ * Do not edit the class manually.
1588
+ */
1589
+ /**
1590
+ *
1591
+ * @export
1592
+ * @interface CompanyUserUsageResponseData
1593
+ */
1594
+ declare interface CompanyUserUsageResponseData {
1595
+ /**
1596
+ * When the user last used the feature in the period.
1597
+ * @type {Date}
1598
+ * @memberof CompanyUserUsageResponseData
1599
+ */
1600
+ lastSeen: Date;
1601
+ /**
1602
+ *
1603
+ * @type {string}
1604
+ * @memberof CompanyUserUsageResponseData
1605
+ */
1606
+ name?: string | null;
1607
+ /**
1608
+ * This user's fraction (0-1) of all usage in the period, unattributed usage included.
1609
+ * @type {number}
1610
+ * @memberof CompanyUserUsageResponseData
1611
+ */
1612
+ share: number;
1613
+ /**
1614
+ *
1615
+ * @type {number}
1616
+ * @memberof CompanyUserUsageResponseData
1617
+ */
1618
+ usage: number;
1619
+ /**
1620
+ *
1621
+ * @type {string}
1622
+ * @memberof CompanyUserUsageResponseData
1623
+ */
1624
+ userId: string;
1625
+ }
1626
+
1627
+ /**
1628
+ * Function supplied by the integrating application that returns an HMAC context
1629
+ * signature (`iat.exp.sig`) for the given context.
1630
+ *
1631
+ * Because a publishable key is public, the signature must be produced by the
1632
+ * customer's backend, which holds the matching secret API key. A typical
1633
+ * implementation forwards the context to that backend and returns the
1634
+ * `X-Schematic-Context-Sig` value it computes:
1635
+ *
1636
+ * ```ts
1637
+ * const schematic = new Schematic(pubKey, {
1638
+ * getContextSignature: async (context) => {
1639
+ * const res = await fetch("/api/schematic/sign", {
1640
+ * method: "POST",
1641
+ * credentials: "include",
1642
+ * headers: { "Content-Type": "application/json" },
1643
+ * body: JSON.stringify(context),
1644
+ * });
1645
+ * const { signature } = await res.json();
1646
+ * return signature; // "iat.exp.sig"
1647
+ * },
1648
+ * });
1649
+ * ```
1650
+ *
1651
+ * The SDK derives the expiry from the returned string (its middle segment) and
1652
+ * caches it per context, so the function is only invoked when no fresh
1653
+ * signature is available.
1654
+ */
1655
+ declare type ContextSignatureProvider = (context: SchematicContext) => string | Promise<string>;
1656
+
930
1657
  /** A company's lease-aware balance for a single credit type */
931
1658
  export declare type CreditBalance = {
932
1659
  /** Spendable balance including any open lease hold (remaining + reserved); the number to display to end users */
@@ -946,6 +1673,153 @@ declare const CreditBalancesFromJSON: (json: any) => CreditBalances;
946
1673
 
947
1674
  declare type CreditBalancesListenerFn = (value: CreditBalances) => void;
948
1675
 
1676
+ /** Every spend policy binding the current context, company-scope first */
1677
+ export declare type CreditSpendPolicies = CreditSpendPolicy[];
1678
+
1679
+ /** Compare two policy sets by value, so an unchanged restream skips the notify. */
1680
+ declare const creditSpendPoliciesEqual: (a: CreditSpendPolicies, b: CreditSpendPolicies) => boolean;
1681
+
1682
+ declare const CreditSpendPoliciesFromJSON: (json: any) => CreditSpendPolicies;
1683
+
1684
+ declare type CreditSpendPoliciesListenerFn = (value: CreditSpendPolicies) => void;
1685
+
1686
+ /** One limit on spending a credit */
1687
+ export declare type CreditSpendPolicy = {
1688
+ id: string;
1689
+ creditId: string;
1690
+ kind: CreditSpendPolicyKind;
1691
+ scope: CreditSpendPolicyScope;
1692
+ label?: string;
1693
+ /** The ceiling, in credits */
1694
+ limit: number;
1695
+ /** How much of the limit is already spent in the current period; 0 for per_draw */
1696
+ consumed: number;
1697
+ /** For windowed kinds, when the current period ends and consumed no longer applies */
1698
+ resetsAt?: Date;
1699
+ /** Set for windowed kinds only */
1700
+ window?: CreditSpendWindow;
1701
+ };
1702
+
1703
+ /**
1704
+ *
1705
+ * @export
1706
+ * @interface CreditSpendPolicy
1707
+ */
1708
+ declare interface CreditSpendPolicy_2 {
1709
+ /**
1710
+ * How much of the limit is already spent in the current period
1711
+ * @type {number}
1712
+ * @memberof CreditSpendPolicy
1713
+ */
1714
+ consumed?: number;
1715
+ /**
1716
+ * The credit the policy limits
1717
+ * @type {string}
1718
+ * @memberof CreditSpendPolicy
1719
+ */
1720
+ creditId: string;
1721
+ /**
1722
+ * The ID of the policy
1723
+ * @type {string}
1724
+ * @memberof CreditSpendPolicy
1725
+ */
1726
+ id: string;
1727
+ /**
1728
+ * How the limit is applied
1729
+ * @type {string}
1730
+ * @memberof CreditSpendPolicy
1731
+ */
1732
+ kind: string;
1733
+ /**
1734
+ * The name the account gave the policy
1735
+ * @type {string}
1736
+ * @memberof CreditSpendPolicy
1737
+ */
1738
+ label?: string | null;
1739
+ /**
1740
+ * The ceiling, in credits
1741
+ * @type {number}
1742
+ * @memberof CreditSpendPolicy
1743
+ */
1744
+ limit: number;
1745
+ /**
1746
+ * For a windowed limit, when the current period ends and consumed no longer applies
1747
+ * @type {Date}
1748
+ * @memberof CreditSpendPolicy
1749
+ */
1750
+ resetsAt?: Date | null;
1751
+ /**
1752
+ * Whether the policy limits the company or one user
1753
+ * @type {CreditSpendPolicyScope}
1754
+ * @memberof CreditSpendPolicy
1755
+ */
1756
+ scope: CreditSpendPolicyScope_2;
1757
+ /**
1758
+ * For a windowed limit, the period it accumulates over
1759
+ * @type {CreditSpendWindow}
1760
+ * @memberof CreditSpendPolicy
1761
+ */
1762
+ window?: CreditSpendWindow_2;
1763
+ }
1764
+
1765
+ /** How a spend policy applies its limit. Unknown kinds are carried, not dropped:
1766
+ * the server may ship a kind this SDK version predates. */
1767
+ export declare type CreditSpendPolicyKind = "per_draw" | "window" | (string & {});
1768
+
1769
+ declare type CreditSpendPolicyListenerFn = CreditSpendPoliciesListenerFn | EmptyListenerFn;
1770
+
1771
+ /** Whether a spend policy limits the company or one user */
1772
+ export declare type CreditSpendPolicyScope = "company" | "user" | (string & {});
1773
+
1774
+ /**
1775
+ *
1776
+ * @export
1777
+ */
1778
+ declare const CreditSpendPolicyScope_2: {
1779
+ readonly Company: "company";
1780
+ readonly User: "user";
1781
+ readonly Group: "group";
1782
+ };
1783
+
1784
+ declare type CreditSpendPolicyScope_2 = (typeof CreditSpendPolicyScope_2)[keyof typeof CreditSpendPolicyScope_2];
1785
+
1786
+ /** The period a windowed spend policy accumulates over */
1787
+ export declare type CreditSpendWindow = {
1788
+ unit: string;
1789
+ count: number;
1790
+ };
1791
+
1792
+ /**
1793
+ * Schematic API
1794
+ * Schematic API
1795
+ *
1796
+ * The version of the OpenAPI document: 0.1
1797
+ *
1798
+ *
1799
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1800
+ * https://openapi-generator.tech
1801
+ * Do not edit the class manually.
1802
+ */
1803
+ /**
1804
+ *
1805
+ * @export
1806
+ * @interface CreditSpendWindow
1807
+ */
1808
+ declare interface CreditSpendWindow_2 {
1809
+ /**
1810
+ * How many units make up one period
1811
+ * @type {number}
1812
+ * @memberof CreditSpendWindow
1813
+ */
1814
+ count: number;
1815
+ /**
1816
+ * The period the limit accumulates over
1817
+ * @type {string}
1818
+ * @memberof CreditSpendWindow
1819
+ */
1820
+ unit: string;
1821
+ }
1822
+
949
1823
  /**
950
1824
  *
951
1825
  * @export
@@ -986,6 +1860,32 @@ export declare type Discount = CompanyDiscountResponseData;
986
1860
 
987
1861
  declare type EmptyListenerFn = () => void;
988
1862
 
1863
+ /**
1864
+ *
1865
+ * @export
1866
+ */
1867
+ declare const EntitlementPriceBehavior: {
1868
+ readonly CreditBurndown: "credit_burndown";
1869
+ readonly Overage: "overage";
1870
+ readonly PayAsYouGo: "pay_as_you_go";
1871
+ readonly PayInAdvance: "pay_in_advance";
1872
+ readonly Tier: "tier";
1873
+ };
1874
+
1875
+ declare type EntitlementPriceBehavior = (typeof EntitlementPriceBehavior)[keyof typeof EntitlementPriceBehavior];
1876
+
1877
+ /**
1878
+ *
1879
+ * @export
1880
+ */
1881
+ declare const EntitlementType: {
1882
+ readonly CompanyOverride: "company_override";
1883
+ readonly PlanEntitlement: "plan_entitlement";
1884
+ readonly Unknown: "unknown";
1885
+ };
1886
+
1887
+ declare type EntitlementType = (typeof EntitlementType)[keyof typeof EntitlementType];
1888
+
989
1889
  /**
990
1890
  *
991
1891
  * @export
@@ -1001,6 +1901,21 @@ declare const EntitlementValueType: {
1001
1901
 
1002
1902
  declare type EntitlementValueType = (typeof EntitlementValueType)[keyof typeof EntitlementValueType];
1003
1903
 
1904
+ /**
1905
+ *
1906
+ * @export
1907
+ */
1908
+ declare const EntitlementValueType_2: {
1909
+ readonly Boolean: "boolean";
1910
+ readonly Credit: "credit";
1911
+ readonly Numeric: "numeric";
1912
+ readonly Trait: "trait";
1913
+ readonly Unknown: "unknown";
1914
+ readonly Unlimited: "unlimited";
1915
+ };
1916
+
1917
+ declare type EntitlementValueType_2 = (typeof EntitlementValueType_2)[keyof typeof EntitlementValueType_2];
1918
+
1004
1919
  declare type Event_2 = {
1005
1920
  api_key: string;
1006
1921
  body: EventBody;
@@ -1125,6 +2040,12 @@ export declare type EventBodyTrack = SchematicContext & {
1125
2040
 
1126
2041
  export declare type EventType = "identify" | "track" | "flag_check";
1127
2042
 
2043
+ /**
2044
+ * Users fetched for one feature's breakdown. The breakdown is read once, not
2045
+ * paged: it lists the heaviest users and says how many more there are.
2046
+ */
2047
+ export declare const FEATURE_USER_USAGE_LIMIT = 20;
2048
+
1128
2049
  /**
1129
2050
  *
1130
2051
  * @export
@@ -1247,6 +2168,48 @@ declare interface FeatureEntitlement {
1247
2168
  warningTiers?: Array<WarningTier>;
1248
2169
  }
1249
2170
 
2171
+ /**
2172
+ *
2173
+ * @export
2174
+ */
2175
+ declare const FeatureType: {
2176
+ readonly Boolean: "boolean";
2177
+ readonly Event: "event";
2178
+ readonly License: "license";
2179
+ readonly Trait: "trait";
2180
+ };
2181
+
2182
+ declare type FeatureType = (typeof FeatureType)[keyof typeof FeatureType];
2183
+
2184
+ /**
2185
+ * One feature the company is entitled to, and its usage. What the server has
2186
+ * already decided, so a consumer never re-derives it:
2187
+ *
2188
+ * * `price` — the one metered price the company is billed at: its billing
2189
+ * period's slot, in the subscription's currency when the feature is priced
2190
+ * in it. Absent when the period has none; another cadence's price is never
2191
+ * substituted.
2192
+ * * `currentCost` — what the feature costs at `price`, in its minor units.
2193
+ * * `perLicenseCreditGrants` — the plan's credit grants that scale with the
2194
+ * license this feature counts.
2195
+ */
2196
+ export declare type FeatureUsage = CompanyFeatureUsageResponseData;
2197
+
2198
+ /**
2199
+ * One event-based feature's usage by user over its current metric period:
2200
+ * a page of `users`, highest usage first; `count` users in all; the period's
2201
+ * `total`; and `unattributed` usage from events sent without a user, which is
2202
+ * not a user and never on the page.
2203
+ */
2204
+ export declare type FeatureUserUsage = CompanyFeatureUserUsageResponseData;
2205
+
2206
+ declare interface FeatureUserUsageRequest {
2207
+ featureId: string;
2208
+ /** Users per page; the server's default when omitted. */
2209
+ limit?: number;
2210
+ offset?: number;
2211
+ }
2212
+
1250
2213
  /**
1251
2214
  * Server prefetch for a provider's `initialData`. A resource that fails is
1252
2215
  * left out rather than thrown, so one of them cannot block a page.
@@ -1315,6 +2278,9 @@ export declare type InvoiceStatus = (typeof InvoiceStatus)[keyof typeof InvoiceS
1315
2278
  /** A record of unique key-value pairs used for identifying a company or user */
1316
2279
  export declare type Keys = Record<string, string>;
1317
2280
 
2281
+ /** A metered price, tiers included. */
2282
+ export declare type MeteredPrice = CatalogPriceResponseData;
2283
+
1318
2284
  /**
1319
2285
  *
1320
2286
  * @export
@@ -1328,6 +2294,19 @@ declare const MetricPeriod: {
1328
2294
 
1329
2295
  declare type MetricPeriod = (typeof MetricPeriod)[keyof typeof MetricPeriod];
1330
2296
 
2297
+ /**
2298
+ *
2299
+ * @export
2300
+ */
2301
+ declare const MetricPeriod_2: {
2302
+ readonly AllTime: "all_time";
2303
+ readonly CurrentDay: "current_day";
2304
+ readonly CurrentMonth: "current_month";
2305
+ readonly CurrentWeek: "current_week";
2306
+ };
2307
+
2308
+ declare type MetricPeriod_2 = (typeof MetricPeriod_2)[keyof typeof MetricPeriod_2];
2309
+
1331
2310
  /**
1332
2311
  *
1333
2312
  * @export
@@ -1339,6 +2318,17 @@ declare const MetricPeriodMonthReset: {
1339
2318
 
1340
2319
  declare type MetricPeriodMonthReset = (typeof MetricPeriodMonthReset)[keyof typeof MetricPeriodMonthReset];
1341
2320
 
2321
+ /**
2322
+ *
2323
+ * @export
2324
+ */
2325
+ declare const MetricPeriodMonthReset_2: {
2326
+ readonly BillingCycle: "billing_cycle";
2327
+ readonly FirstOfMonth: "first_of_month";
2328
+ };
2329
+
2330
+ declare type MetricPeriodMonthReset_2 = (typeof MetricPeriodMonthReset_2)[keyof typeof MetricPeriodMonthReset_2];
2331
+
1342
2332
  /**
1343
2333
  * Keeps only the fields the request reads. The store keys a row set by the
1344
2334
  * query's shape, so a field the API never sees would key a row set of its
@@ -1385,6 +2375,20 @@ export declare interface PaymentMethodsHandle extends ResourceHandle<PaymentMeth
1385
2375
 
1386
2376
  declare type PendingListenerFn = BooleanListenerFn | EmptyListenerFn;
1387
2377
 
2378
+ /** A plan credit grant that scales per license. */
2379
+ export declare type PerLicenseCreditGrant = CatalogCreditGrantResponseData;
2380
+
2381
+ /**
2382
+ *
2383
+ * @export
2384
+ */
2385
+ declare const PlanCreditGrantScaling: {
2386
+ readonly Fixed: "fixed";
2387
+ readonly PerLicense: "per_license";
2388
+ };
2389
+
2390
+ declare type PlanCreditGrantScaling = (typeof PlanCreditGrantScaling)[keyof typeof PlanCreditGrantScaling];
2391
+
1388
2392
  declare type PlanListenerFn = CheckPlanReturnListenerFn | EmptyListenerFn;
1389
2393
 
1390
2394
  declare interface RequestOptions {
@@ -1449,6 +2453,7 @@ declare type RuleType_2 = (typeof RuleType_2)[keyof typeof RuleType_2];
1449
2453
  export declare class Schematic {
1450
2454
  private _additionalHeaders;
1451
2455
  private apiKey;
2456
+ private contextSignatureManager?;
1452
2457
  private _apiUrl;
1453
2458
  private conn;
1454
2459
  private context;
@@ -1463,6 +2468,7 @@ export declare class Schematic {
1463
2468
  private isPendingListeners;
1464
2469
  private planListeners;
1465
2470
  private creditBalanceListeners;
2471
+ private creditSpendPolicyListeners;
1466
2472
  private storage;
1467
2473
  private persistFlagState;
1468
2474
  private flagStateCacheKey;
@@ -1473,6 +2479,7 @@ export declare class Schematic {
1473
2479
  private featureUsageEventMap;
1474
2480
  private planChecks;
1475
2481
  private creditBalances;
2482
+ private creditSpendPolicies;
1476
2483
  private webSocketUrl;
1477
2484
  private webSocketConnectionTimeout;
1478
2485
  private webSocketReconnect;
@@ -1525,6 +2532,22 @@ export declare class Schematic {
1525
2532
  * Only logs if debug mode is enabled
1526
2533
  */
1527
2534
  debug(message: string, ...args: unknown[]): void;
2535
+ /**
2536
+ * Resolve the HMAC context-signature value for a context, if a signature
2537
+ * provider is configured. Returns undefined when no provider is set, when
2538
+ * offline, or when the signature could not be obtained.
2539
+ */
2540
+ private contextSignature;
2541
+ /**
2542
+ * Build the `X-Schematic-Context-Sig` header for a context, or an empty
2543
+ * object when no signature is available. Spread into request headers.
2544
+ *
2545
+ * Returns synchronously (not a Promise) when no signature provider is
2546
+ * configured, so callers that dispatch on the same tick (e.g. fire-and-forget
2547
+ * event sends) keep their existing timing; only a configured provider, which
2548
+ * must fetch a signature, yields a Promise.
2549
+ */
2550
+ private contextSignatureHeaders;
1528
2551
  /**
1529
2552
  * Create a persistent message handler for websocket flag updates
1530
2553
  */
@@ -1691,6 +2714,10 @@ export declare class Schematic {
1691
2714
  getCreditBalances: () => CreditBalances;
1692
2715
  /** Get the company's lease-aware balance for a single credit type in the current context */
1693
2716
  getCreditBalance: (creditId: string) => CreditBalance | undefined;
2717
+ /** Get every credit spend policy binding the current context, company-scope first */
2718
+ getCreditSpendPolicies: () => CreditSpendPolicies;
2719
+ /** Get the spend policies binding a single credit type in the current context */
2720
+ getCreditSpendPoliciesForCredit: (creditId: string) => CreditSpendPolicies;
1694
2721
  getFlagCheck: (flagKey: string) => CheckFlagReturn | undefined;
1695
2722
  getFlagValue: (flagKey: string) => boolean | undefined;
1696
2723
  /** Register an event listener that will be notified with the boolean value for a given flag when this value changes */
@@ -1700,11 +2727,14 @@ export declare class Schematic {
1700
2727
  addPlanListener: (listener: PlanListenerFn) => () => void;
1701
2728
  /** Register an event listener that will be notified with the company's credit balances (keyed by credit ID) whenever they change */
1702
2729
  addCreditBalanceListener: (listener: CreditBalanceListenerFn) => () => void;
2730
+ /** Register an event listener that will be notified with the context's credit spend policies whenever the set changes */
2731
+ addCreditSpendPolicyListener: (listener: CreditSpendPolicyListenerFn) => () => void;
1703
2732
  private notifyFlagCheckListeners;
1704
2733
  /** Add or update a CheckFlagReturn in the featureUsageEventMap */
1705
2734
  private updateFeatureUsageEventMap;
1706
2735
  private notifyFlagValueListeners;
1707
2736
  private notifyPlanListeners;
2737
+ private notifyCreditSpendPolicyListeners;
1708
2738
  private notifyCreditBalanceListeners;
1709
2739
  }
1710
2740
 
@@ -1732,6 +2762,8 @@ declare class SchematicBillingClient implements BillingClient {
1732
2762
  createSetupIntent(): Promise<SetupIntent>;
1733
2763
  updatePaymentMethod(externalId: string): Promise<void>;
1734
2764
  deletePaymentMethod(id: string): Promise<void>;
2765
+ fetchFeatureUsage(): Promise<FeatureUsage[]>;
2766
+ fetchFeatureUserUsage(params: FeatureUserUsageRequest): Promise<FeatureUserUsage>;
1735
2767
  }
1736
2768
 
1737
2769
  /** Context for checking flags and sending events */
@@ -1752,6 +2784,14 @@ export declare type SchematicCreditBalance = {
1752
2784
  isLoading: boolean;
1753
2785
  };
1754
2786
 
2787
+ /** The credit spend policies binding the current context, plus a loading flag */
2788
+ export declare type SchematicCreditSpendPolicies = {
2789
+ /** Company-scope policies first, then the actor's own; empty when none bind */
2790
+ policies: SchematicJS.CreditSpendPolicies;
2791
+ /** True while the policies are still loading and nothing has arrived yet */
2792
+ isLoading: boolean;
2793
+ };
2794
+
1755
2795
  export declare interface SchematicHookOpts {
1756
2796
  client?: SchematicJS.Schematic;
1757
2797
  }
@@ -1804,6 +2844,9 @@ declare namespace SchematicJS {
1804
2844
  BillingResourceParams_2 as BillingResourceParams,
1805
2845
  BillingResources_2 as BillingResources,
1806
2846
  BooleanListenerFn,
2847
+ CatalogCreditGrantResponseData,
2848
+ CatalogPriceResponseData,
2849
+ CatalogPriceTierResponseData,
1807
2850
  CheckFlagResponseData,
1808
2851
  CheckFlagReturn,
1809
2852
  CheckFlagReturnFromJSON,
@@ -1814,14 +2857,27 @@ declare namespace SchematicJS {
1814
2857
  CheckPlanReturnListenerFn,
1815
2858
  CompanyCreditBalance,
1816
2859
  CompanyDiscountResponseData,
2860
+ CompanyFeatureUsageResponseData,
2861
+ CompanyFeatureUserUsageResponseData,
1817
2862
  CompanyInvoiceResponseData,
1818
2863
  CompanyPaymentMethodResponseData,
1819
2864
  CompanyUpcomingInvoiceResponseData,
2865
+ CompanyUserUsageResponseData,
2866
+ ContextSignatureProvider,
1820
2867
  CreditBalance,
1821
2868
  CreditBalanceListenerFn,
1822
2869
  CreditBalances,
1823
2870
  CreditBalancesFromJSON,
1824
2871
  CreditBalancesListenerFn,
2872
+ CreditSpendPolicies,
2873
+ creditSpendPoliciesEqual,
2874
+ CreditSpendPoliciesFromJSON,
2875
+ CreditSpendPoliciesListenerFn,
2876
+ CreditSpendPolicy,
2877
+ CreditSpendPolicyKind,
2878
+ CreditSpendPolicyListenerFn,
2879
+ CreditSpendPolicyScope,
2880
+ CreditSpendWindow,
1825
2881
  DEFAULT_INVOICE_QUERY,
1826
2882
  Discount,
1827
2883
  EmptyListenerFn,
@@ -1831,6 +2887,8 @@ declare namespace SchematicJS {
1831
2887
  EventBodyIdentify,
1832
2888
  EventBodyTrack,
1833
2889
  EventType,
2890
+ FeatureUsage,
2891
+ FeatureUserUsage,
1834
2892
  FlagCheckListenerFn,
1835
2893
  FlagValueListenerFn,
1836
2894
  Invoice,
@@ -1842,8 +2900,10 @@ declare namespace SchematicJS {
1842
2900
  InvoicesResult,
1843
2901
  InvoiceStatus,
1844
2902
  Keys,
2903
+ MeteredPrice,
1845
2904
  PaymentMethod,
1846
2905
  PendingListenerFn,
2906
+ PerLicenseCreditGrant,
1847
2907
  PlanListenerFn,
1848
2908
  RequestOptions,
1849
2909
  ResourceState,
@@ -1868,6 +2928,7 @@ declare namespace SchematicJS {
1868
2928
  TrialStatus,
1869
2929
  UpcomingInvoice,
1870
2930
  UsagePeriod,
2931
+ UserUsage,
1871
2932
  WarningTier
1872
2933
  }
1873
2934
  }
@@ -1882,6 +2943,16 @@ export declare type SchematicOptions = {
1882
2943
  debug?: boolean;
1883
2944
  /** Optionally provide a custom event URL */
1884
2945
  eventUrl?: string;
2946
+ /** Optionally provide a function that returns an HMAC context signature
2947
+ * (`iat.exp.sig`) for a given context. Required only when the Schematic
2948
+ * environment has context-signature verification enabled. Because a
2949
+ * publishable key is public, the signature must be produced by your backend
2950
+ * (which holds the matching secret API key); this function typically forwards
2951
+ * the context to that backend and returns the value it computes. The SDK
2952
+ * caches the signature per context, derives its expiry from the returned
2953
+ * string, and attaches it as the `X-Schematic-Context-Sig` header on flag
2954
+ * checks, the WebSocket bootstrap, and events. */
2955
+ getContextSignature?: ContextSignatureProvider;
1885
2956
  /** Enable offline mode to prevent all network requests.
1886
2957
  * When enabled, events are only logged not sent, and flag checks return fallback values.
1887
2958
  * Can also be enabled at runtime via URL query parameter "schematic_offline=true" */
@@ -2163,6 +3234,19 @@ export declare enum UsagePeriod {
2163
3234
 
2164
3235
  export declare function useBillingDataSource(): BillingDataSource;
2165
3236
 
3237
+ /**
3238
+ * Every feature the company is entitled to, with its usage. `data` is empty
3239
+ * when it is entitled to nothing; `undefined` is what means not loaded yet.
3240
+ */
3241
+ export declare function useFeatureUsage(): ResourceHandle<FeatureUsage[]>;
3242
+
3243
+ /**
3244
+ * One event-based feature's usage by user over its metric period: the
3245
+ * heaviest users, how many there are in all, and usage sent without a user.
3246
+ * A feature the company has no event-based entitlement to fails with a 404.
3247
+ */
3248
+ export declare function useFeatureUserUsage(featureId: string): ResourceHandle<FeatureUserUsage>;
3249
+
2166
3250
  /** Reloads every loaded billing resource (after a plan change, for instance). */
2167
3251
  export declare function useInvalidateBillingData(): () => void;
2168
3252
 
@@ -2185,6 +3269,8 @@ export declare function useInvoices(query?: InvoiceQuery): InvoicesHandle;
2185
3269
  */
2186
3270
  export declare function usePaymentMethods(): PaymentMethodsHandle;
2187
3271
 
3272
+ export declare type UserUsage = CompanyUserUsageResponseData;
3273
+
2188
3274
  export declare const useSchematic: () => SchematicContextProps;
2189
3275
 
2190
3276
  export declare const useSchematicContext: (opts?: SchematicHookOpts) => {
@@ -2206,6 +3292,11 @@ export declare const useSchematicContext: (opts?: SchematicHookOpts) => {
2206
3292
  */
2207
3293
  export declare const useSchematicCreditBalance: (creditId: string | undefined, opts?: SchematicHookOpts) => SchematicCreditBalance;
2208
3294
 
3295
+ /** Every credit spend policy binding the current context, company-scope first.
3296
+ * Streams over the websocket, so an edit in the dashboard lands here without a
3297
+ * refetch. */
3298
+ export declare const useSchematicCreditSpendPolicies: (opts?: SchematicHookOpts) => SchematicCreditSpendPolicies;
3299
+
2209
3300
  export declare const useSchematicEntitlement: (key: string, opts?: UseSchematicFlagOpts) => SchematicJS.CheckFlagReturn;
2210
3301
 
2211
3302
  export declare const useSchematicEvents: (opts?: SchematicHookOpts) => {