@schematichq/schematic-components 2.14.0 → 2.14.1

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.
@@ -252,7 +252,7 @@ var require_debounce = __commonJS({
252
252
  var FUNC_ERROR_TEXT = "Expected a function";
253
253
  var nativeMax = Math.max;
254
254
  var nativeMin = Math.min;
255
- function debounce4(func, wait, options) {
255
+ function debounce5(func, wait, options) {
256
256
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
257
257
  if (typeof func != "function") {
258
258
  throw new TypeError(FUNC_ERROR_TEXT);
@@ -333,7 +333,7 @@ var require_debounce = __commonJS({
333
333
  debounced.flush = flush;
334
334
  return debounced;
335
335
  }
336
- module2.exports = debounce4;
336
+ module2.exports = debounce5;
337
337
  }
338
338
  });
339
339
 
@@ -1907,6 +1907,10 @@ var LEADING_DEBOUNCE_SETTINGS = {
1907
1907
  leading: true,
1908
1908
  trailing: false
1909
1909
  };
1910
+ var TRAILING_DEBOUNCE_SETTINGS = {
1911
+ leading: false,
1912
+ trailing: true
1913
+ };
1910
1914
  var EVENT_DEBOUNCE_TIMEOUT = 200;
1911
1915
  var FETCH_DEBOUNCE_TIMEOUT = 300;
1912
1916
 
@@ -8085,7 +8089,8 @@ var BillingCreditGrantReason = {
8085
8089
  BillingCreditAutoTopup: "billing_credit_auto_topup",
8086
8090
  Free: "free",
8087
8091
  Plan: "plan",
8088
- Purchased: "purchased"
8092
+ Purchased: "purchased",
8093
+ Rollover: "rollover"
8089
8094
  };
8090
8095
  function BillingCreditGrantReasonFromJSON(json) {
8091
8096
  return BillingCreditGrantReasonFromJSONTyped(json, false);
@@ -8102,6 +8107,14 @@ function BillingCreditGrantZeroedOutReasonFromJSONTyped(json, ignoreDiscriminato
8102
8107
  return json;
8103
8108
  }
8104
8109
 
8110
+ // src/api/checkoutexternal/models/BillingCreditLedgerAuthority.ts
8111
+ function BillingCreditLedgerAuthorityFromJSON(json) {
8112
+ return BillingCreditLedgerAuthorityFromJSONTyped(json, false);
8113
+ }
8114
+ function BillingCreditLedgerAuthorityFromJSONTyped(json, ignoreDiscriminator) {
8115
+ return json;
8116
+ }
8117
+
8105
8118
  // src/api/checkoutexternal/models/BillingPriceResponseData.ts
8106
8119
  function BillingPriceResponseDataFromJSON(json) {
8107
8120
  return BillingPriceResponseDataFromJSONTyped(json, false);
@@ -8246,6 +8259,9 @@ function BillingCreditViewFromJSONTyped(json, ignoreDiscriminator) {
8246
8259
  environmentId: json["environment_id"],
8247
8260
  icon: json["icon"] == null ? void 0 : json["icon"],
8248
8261
  id: json["id"],
8262
+ ledgerAuthority: BillingCreditLedgerAuthorityFromJSON(
8263
+ json["ledger_authority"]
8264
+ ),
8249
8265
  name: json["name"],
8250
8266
  pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
8251
8267
  price: json["price"] == null ? void 0 : BillingPriceViewFromJSON(json["price"]),
@@ -8354,6 +8370,7 @@ function BillingPlanCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminat
8354
8370
  resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON(json["reset_cadence"]),
8355
8371
  resetStart: json["reset_start"] == null ? void 0 : BillingPlanCreditGrantResetStartFromJSON(json["reset_start"]),
8356
8372
  resetType: json["reset_type"] == null ? void 0 : BillingPlanCreditGrantResetTypeFromJSON(json["reset_type"]),
8373
+ rolloverPercentage: json["rollover_percentage"],
8357
8374
  updatedAt: new Date(json["updated_at"])
8358
8375
  };
8359
8376
  }
@@ -8610,6 +8627,20 @@ function UpdateCreditBundleRequestBodyToJSONTyped(value, ignoreDiscriminator = f
8610
8627
  };
8611
8628
  }
8612
8629
 
8630
+ // src/api/checkoutexternal/models/CheckoutFieldValue.ts
8631
+ function CheckoutFieldValueToJSON(json) {
8632
+ return CheckoutFieldValueToJSONTyped(json, false);
8633
+ }
8634
+ function CheckoutFieldValueToJSONTyped(value, ignoreDiscriminator = false) {
8635
+ if (value == null) {
8636
+ return value;
8637
+ }
8638
+ return {
8639
+ id: value["id"],
8640
+ value: value["value"]
8641
+ };
8642
+ }
8643
+
8613
8644
  // src/api/checkoutexternal/models/UpdateAddOnRequestBody.ts
8614
8645
  function UpdateAddOnRequestBodyToJSON(json) {
8615
8646
  return UpdateAddOnRequestBodyToJSONTyped(json, false);
@@ -8659,6 +8690,9 @@ function ChangeSubscriptionRequestBodyToJSONTyped(value, ignoreDiscriminator = f
8659
8690
  credit_bundles: value["creditBundles"].map(
8660
8691
  UpdateCreditBundleRequestBodyToJSON
8661
8692
  ),
8693
+ custom_field_values: value["customFieldValues"].map(
8694
+ CheckoutFieldValueToJSON
8695
+ ),
8662
8696
  new_plan_id: value["newPlanId"],
8663
8697
  new_price_id: value["newPriceId"],
8664
8698
  pay_in_advance: value["payInAdvance"].map(
@@ -8678,6 +8712,25 @@ function ChargeTypeFromJSONTyped(json, ignoreDiscriminator) {
8678
8712
  return json;
8679
8713
  }
8680
8714
 
8715
+ // src/api/checkoutexternal/models/CheckoutFieldWithValue.ts
8716
+ function CheckoutFieldWithValueFromJSON(json) {
8717
+ return CheckoutFieldWithValueFromJSONTyped(json, false);
8718
+ }
8719
+ function CheckoutFieldWithValueFromJSONTyped(json, ignoreDiscriminator) {
8720
+ if (json == null) {
8721
+ return json;
8722
+ }
8723
+ return {
8724
+ definitionId: json["definition_id"],
8725
+ helperText: json["helper_text"] == null ? void 0 : json["helper_text"],
8726
+ id: json["id"],
8727
+ name: json["name"],
8728
+ required: json["required"],
8729
+ stripeMetadataKey: json["stripe_metadata_key"],
8730
+ value: json["value"] == null ? void 0 : json["value"]
8731
+ };
8732
+ }
8733
+
8681
8734
  // src/api/checkoutexternal/models/ScheduledDowngradeConfigBehavior.ts
8682
8735
  function ScheduledDowngradeConfigBehaviorFromJSON(json) {
8683
8736
  return ScheduledDowngradeConfigBehaviorFromJSONTyped(json, false);
@@ -8890,6 +8943,7 @@ function CompanyPlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
8890
8943
  resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON(json["reset_cadence"]),
8891
8944
  resetStart: json["reset_start"] == null ? void 0 : BillingPlanCreditGrantResetStartFromJSON(json["reset_start"]),
8892
8945
  resetType: BillingPlanCreditGrantResetTypeFromJSON(json["reset_type"]),
8946
+ rolloverPercentage: json["rollover_percentage"],
8893
8947
  singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
8894
8948
  updatedAt: new Date(json["updated_at"])
8895
8949
  };
@@ -9752,6 +9806,7 @@ function PlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
9752
9806
  resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON(json["reset_cadence"]),
9753
9807
  resetStart: json["reset_start"] == null ? void 0 : BillingPlanCreditGrantResetStartFromJSON(json["reset_start"]),
9754
9808
  resetType: BillingPlanCreditGrantResetTypeFromJSON(json["reset_type"]),
9809
+ rolloverPercentage: json["rollover_percentage"],
9755
9810
  singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
9756
9811
  updatedAt: new Date(json["updated_at"])
9757
9812
  };
@@ -10189,7 +10244,10 @@ function CreditCompanyGrantViewFromJSONTyped(json, ignoreDiscriminator) {
10189
10244
  quantityUsed: json["quantity_used"],
10190
10245
  renewalEnabled: json["renewal_enabled"],
10191
10246
  renewalPeriod: json["renewal_period"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON(json["renewal_period"]),
10247
+ reserved: json["reserved"] == null ? void 0 : json["reserved"],
10248
+ settled: json["settled"] == null ? void 0 : json["settled"],
10192
10249
  singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
10250
+ sourceGrantId: json["source_grant_id"] == null ? void 0 : json["source_grant_id"],
10193
10251
  sourceLabel: json["source_label"],
10194
10252
  transfers: json["transfers"] == null ? void 0 : json["transfers"].map(CreditTransferViewFromJSON),
10195
10253
  updatedAt: new Date(json["updated_at"]),
@@ -10298,6 +10356,9 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10298
10356
  creditGrants: json["credit_grants"].map(
10299
10357
  CreditCompanyGrantViewFromJSON
10300
10358
  ),
10359
+ customCheckoutFields: json["custom_checkout_fields"].map(
10360
+ CheckoutFieldWithValueFromJSON
10361
+ ),
10301
10362
  defaultPlan: json["default_plan"] == null ? void 0 : PlanDetailResponseDataFromJSON(json["default_plan"]),
10302
10363
  displaySettings: ComponentDisplaySettingsFromJSON(json["display_settings"]),
10303
10364
  featureUsage: json["feature_usage"] == null ? void 0 : FeatureUsageDetailResponseDataFromJSON(json["feature_usage"]),
@@ -10542,6 +10603,46 @@ function PreviewCheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
10542
10603
  };
10543
10604
  }
10544
10605
 
10606
+ // src/api/checkoutexternal/models/UpdateCheckoutFieldValuesRequestBody.ts
10607
+ function UpdateCheckoutFieldValuesRequestBodyToJSON(json) {
10608
+ return UpdateCheckoutFieldValuesRequestBodyToJSONTyped(json, false);
10609
+ }
10610
+ function UpdateCheckoutFieldValuesRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
10611
+ if (value == null) {
10612
+ return value;
10613
+ }
10614
+ return {
10615
+ values: value["values"].map(CheckoutFieldValueToJSON)
10616
+ };
10617
+ }
10618
+
10619
+ // src/api/checkoutexternal/models/UpdateCheckoutFieldValuesResponseData.ts
10620
+ function UpdateCheckoutFieldValuesResponseDataFromJSON(json) {
10621
+ return UpdateCheckoutFieldValuesResponseDataFromJSONTyped(json, false);
10622
+ }
10623
+ function UpdateCheckoutFieldValuesResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10624
+ if (json == null) {
10625
+ return json;
10626
+ }
10627
+ return {
10628
+ company: json["company"] == null ? void 0 : CompanyDetailResponseDataFromJSON(json["company"])
10629
+ };
10630
+ }
10631
+
10632
+ // src/api/checkoutexternal/models/UpdateCheckoutFieldValuesResponse.ts
10633
+ function UpdateCheckoutFieldValuesResponseFromJSON(json) {
10634
+ return UpdateCheckoutFieldValuesResponseFromJSONTyped(json, false);
10635
+ }
10636
+ function UpdateCheckoutFieldValuesResponseFromJSONTyped(json, ignoreDiscriminator) {
10637
+ if (json == null) {
10638
+ return json;
10639
+ }
10640
+ return {
10641
+ data: UpdateCheckoutFieldValuesResponseDataFromJSON(json["data"]),
10642
+ params: json["params"]
10643
+ };
10644
+ }
10645
+
10545
10646
  // src/api/checkoutexternal/models/UpdatePaymentMethodRequestBody.ts
10546
10647
  function UpdatePaymentMethodRequestBodyToJSON(json) {
10547
10648
  return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
@@ -11003,6 +11104,51 @@ var CheckoutexternalApi = class extends BaseAPI {
11003
11104
  );
11004
11105
  return await response.value();
11005
11106
  }
11107
+ /**
11108
+ * Update checkout field values
11109
+ */
11110
+ async updateCheckoutFieldValuesRaw(requestParameters, initOverrides) {
11111
+ if (requestParameters["updateCheckoutFieldValuesRequestBody"] == null) {
11112
+ throw new RequiredError(
11113
+ "updateCheckoutFieldValuesRequestBody",
11114
+ 'Required parameter "updateCheckoutFieldValuesRequestBody" was null or undefined when calling updateCheckoutFieldValues().'
11115
+ );
11116
+ }
11117
+ const queryParameters = {};
11118
+ const headerParameters = {};
11119
+ headerParameters["Content-Type"] = "application/json";
11120
+ if (this.configuration && this.configuration.apiKey) {
11121
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
11122
+ "X-Schematic-Api-Key"
11123
+ );
11124
+ }
11125
+ const response = await this.request(
11126
+ {
11127
+ path: `/checkout/custom-field-values`,
11128
+ method: "POST",
11129
+ headers: headerParameters,
11130
+ query: queryParameters,
11131
+ body: UpdateCheckoutFieldValuesRequestBodyToJSON(
11132
+ requestParameters["updateCheckoutFieldValuesRequestBody"]
11133
+ )
11134
+ },
11135
+ initOverrides
11136
+ );
11137
+ return new JSONApiResponse(
11138
+ response,
11139
+ (jsonValue) => UpdateCheckoutFieldValuesResponseFromJSON(jsonValue)
11140
+ );
11141
+ }
11142
+ /**
11143
+ * Update checkout field values
11144
+ */
11145
+ async updateCheckoutFieldValues(requestParameters, initOverrides) {
11146
+ const response = await this.updateCheckoutFieldValuesRaw(
11147
+ requestParameters,
11148
+ initOverrides
11149
+ );
11150
+ return await response.value();
11151
+ }
11006
11152
  /**
11007
11153
  * Update payment method
11008
11154
  */
@@ -11330,6 +11476,14 @@ function BillingCreditExpiryUnitFromJSONTyped9(json, ignoreDiscriminator) {
11330
11476
  return json;
11331
11477
  }
11332
11478
 
11479
+ // src/api/componentspublic/models/BillingCreditLedgerAuthority.ts
11480
+ function BillingCreditLedgerAuthorityFromJSON2(json) {
11481
+ return BillingCreditLedgerAuthorityFromJSONTyped3(json, false);
11482
+ }
11483
+ function BillingCreditLedgerAuthorityFromJSONTyped3(json, ignoreDiscriminator) {
11484
+ return json;
11485
+ }
11486
+
11333
11487
  // src/api/componentspublic/models/BillingProductPriceInterval.ts
11334
11488
  function BillingProductPriceIntervalFromJSON2(json) {
11335
11489
  return BillingProductPriceIntervalFromJSONTyped5(json, false);
@@ -11568,6 +11722,9 @@ function BillingCreditViewFromJSONTyped4(json, ignoreDiscriminator) {
11568
11722
  environmentId: json["environment_id"],
11569
11723
  icon: json["icon"] == null ? void 0 : json["icon"],
11570
11724
  id: json["id"],
11725
+ ledgerAuthority: BillingCreditLedgerAuthorityFromJSON2(
11726
+ json["ledger_authority"]
11727
+ ),
11571
11728
  name: json["name"],
11572
11729
  pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
11573
11730
  price: json["price"] == null ? void 0 : BillingPriceViewFromJSON2(json["price"]),
@@ -12217,6 +12374,7 @@ function PlanCreditGrantViewFromJSONTyped3(json, ignoreDiscriminator) {
12217
12374
  resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON2(json["reset_cadence"]),
12218
12375
  resetStart: json["reset_start"] == null ? void 0 : BillingPlanCreditGrantResetStartFromJSON2(json["reset_start"]),
12219
12376
  resetType: BillingPlanCreditGrantResetTypeFromJSON2(json["reset_type"]),
12377
+ rolloverPercentage: json["rollover_percentage"],
12220
12378
  singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
12221
12379
  updatedAt: new Date(json["updated_at"])
12222
12380
  };
@@ -13645,6 +13803,7 @@ function normalize(data) {
13645
13803
  },
13646
13804
  creditBundles: [],
13647
13805
  creditGrants: [],
13806
+ customCheckoutFields: [],
13648
13807
  preventSelfServiceDowngrade: false
13649
13808
  });
13650
13809
  }
@@ -13826,7 +13985,7 @@ var reducer = (state, action) => {
13826
13985
  // src/context/EmbedProvider.tsx
13827
13986
  var import_jsx_runtime2 = require("react/jsx-runtime");
13828
13987
  var getCustomHeaders = (sessionId) => ({
13829
- "X-Schematic-Components-Version": "2.14.0",
13988
+ "X-Schematic-Components-Version": "2.14.1",
13830
13989
  "X-Schematic-Session-ID": sessionId
13831
13990
  });
13832
13991
  var normalizeCurrencyFilter = (filter2) => {
@@ -15915,7 +16074,7 @@ var Root = (0, import_react31.forwardRef)(
15915
16074
  Root.displayName = "Root";
15916
16075
 
15917
16076
  // src/components/layout/viewport/Viewport.tsx
15918
- var import_debounce3 = __toESM(require_debounce());
16077
+ var import_debounce4 = __toESM(require_debounce());
15919
16078
  var import_react46 = require("react");
15920
16079
  var import_react_dom3 = require("react-dom");
15921
16080
 
@@ -17365,6 +17524,7 @@ var Checkout = ({
17365
17524
  };
17366
17525
 
17367
17526
  // src/components/shared/checkout-dialog/CheckoutDialog.tsx
17527
+ var import_debounce3 = __toESM(require_debounce());
17368
17528
  var import_react36 = require("react");
17369
17529
 
17370
17530
  // src/components/shared/checkout-dialog/Navigation.tsx
@@ -17876,6 +18036,7 @@ var CheckoutDialog = ({ top }) => {
17876
18036
  }
17877
18037
  return id;
17878
18038
  }, [checkoutStage, checkoutStages, checkoutState, isBypassLoading]);
18039
+ const previewRequestIdRef = (0, import_react36.useRef)(0);
17879
18040
  const handlePreviewCheckout = (0, import_react36.useCallback)(
17880
18041
  async (updates) => {
17881
18042
  const period = updates.period || planPeriod;
@@ -17899,6 +18060,8 @@ var CheckoutDialog = ({ top }) => {
17899
18060
  setSelectedPlanId(null);
17900
18061
  return;
17901
18062
  }
18063
+ const requestId = ++previewRequestIdRef.current;
18064
+ const isStale = () => requestId !== previewRequestIdRef.current;
17902
18065
  setError(void 0);
17903
18066
  setCharges(void 0);
17904
18067
  setIsLoading(true);
@@ -17942,9 +18105,13 @@ var CheckoutDialog = ({ top }) => {
17942
18105
  autoTopupOverrides: isCreditOnly ? [] : autoTopupRequestBody,
17943
18106
  payInAdvance: isCreditOnly ? [] : [...planPayInAdvanceRequestBody, ...addOnPayInAdvanceRequestBody],
17944
18107
  creditBundles: creditBundlesRequestBody,
18108
+ customFieldValues: [],
17945
18109
  skipTrial,
17946
18110
  ...code && { promoCode: code }
17947
18111
  });
18112
+ if (isStale()) {
18113
+ return;
18114
+ }
17948
18115
  if (response) {
17949
18116
  setCharges(response.data.finance);
17950
18117
  setIsPaymentMethodRequired(response.data.paymentMethodRequired);
@@ -17954,6 +18121,9 @@ var CheckoutDialog = ({ top }) => {
17954
18121
  setPromoCode(code);
17955
18122
  }
17956
18123
  } catch (err2) {
18124
+ if (isStale()) {
18125
+ return;
18126
+ }
17957
18127
  if (err2 instanceof ResponseError) {
17958
18128
  if (err2.response.status === 401) {
17959
18129
  setError(t3("Session expired. Please refresh and try again."));
@@ -17988,9 +18158,11 @@ var CheckoutDialog = ({ top }) => {
17988
18158
  const { message: msg } = isError(err2) ? err2 : ERROR_UNKNOWN;
17989
18159
  setError(msg);
17990
18160
  } finally {
17991
- setIsLoading(false);
17992
- if (isBypassLoading) {
17993
- setIsBypassLoading(false);
18161
+ if (!isStale()) {
18162
+ setIsLoading(false);
18163
+ if (isBypassLoading) {
18164
+ setIsBypassLoading(false);
18165
+ }
17994
18166
  }
17995
18167
  }
17996
18168
  },
@@ -18013,6 +18185,29 @@ var CheckoutDialog = ({ top }) => {
18013
18185
  isBypassLoading
18014
18186
  ]
18015
18187
  );
18188
+ const handlePreviewCheckoutRef = (0, import_react36.useRef)(handlePreviewCheckout);
18189
+ (0, import_react36.useEffect)(() => {
18190
+ handlePreviewCheckoutRef.current = handlePreviewCheckout;
18191
+ }, [handlePreviewCheckout]);
18192
+ const debouncedPreviewCheckoutRef = (0, import_react36.useRef)(null);
18193
+ (0, import_react36.useEffect)(() => {
18194
+ const debounced = (0, import_debounce3.default)(
18195
+ (updates) => handlePreviewCheckoutRef.current(updates),
18196
+ FETCH_DEBOUNCE_TIMEOUT,
18197
+ TRAILING_DEBOUNCE_SETTINGS
18198
+ );
18199
+ debouncedPreviewCheckoutRef.current = debounced;
18200
+ return () => {
18201
+ debounced.cancel();
18202
+ debouncedPreviewCheckoutRef.current = null;
18203
+ };
18204
+ }, []);
18205
+ const debouncedPreviewCheckout = (0, import_react36.useCallback)(
18206
+ (updates) => {
18207
+ debouncedPreviewCheckoutRef.current?.(updates);
18208
+ },
18209
+ []
18210
+ );
18016
18211
  const selectPlan = (0, import_react36.useCallback)(
18017
18212
  (updates) => {
18018
18213
  const plan = updates.plan;
@@ -18176,11 +18371,11 @@ var CheckoutDialog = ({ top }) => {
18176
18371
  companyAutoTopupAmount: updates.companyAutoTopupAmount ?? prevConfig?.companyAutoTopupAmount ?? matchedCreditGrant?.billingCreditAutoTopupAmount ?? 0
18177
18372
  };
18178
18373
  nextMap.set(id, updatedConfig);
18179
- handlePreviewCheckout({ autoTopupConfigs: nextMap });
18374
+ debouncedPreviewCheckout({ autoTopupConfigs: nextMap });
18180
18375
  return nextMap;
18181
18376
  });
18182
18377
  },
18183
- [handlePreviewCheckout, planCreditGrants]
18378
+ [debouncedPreviewCheckout, planCreditGrants]
18184
18379
  );
18185
18380
  const updateUsageBasedEntitlementQuantity = (0, import_react36.useCallback)(
18186
18381
  (id, updatedQuantity) => {
@@ -18191,7 +18386,7 @@ var CheckoutDialog = ({ top }) => {
18191
18386
  quantity: updatedQuantity
18192
18387
  } : entitlement
18193
18388
  );
18194
- handlePreviewCheckout({
18389
+ debouncedPreviewCheckout({
18195
18390
  payInAdvanceEntitlements: updated.filter(
18196
18391
  ({ priceBehavior }) => priceBehavior === EntitlementPriceBehavior.PayInAdvance
18197
18392
  )
@@ -18199,7 +18394,7 @@ var CheckoutDialog = ({ top }) => {
18199
18394
  return updated;
18200
18395
  });
18201
18396
  },
18202
- [handlePreviewCheckout]
18397
+ [debouncedPreviewCheckout]
18203
18398
  );
18204
18399
  const updateCreditBundleCount = (0, import_react36.useCallback)(
18205
18400
  (id, updatedCount) => {
@@ -18210,11 +18405,11 @@ var CheckoutDialog = ({ top }) => {
18210
18405
  count: updatedCount
18211
18406
  } : bundle
18212
18407
  );
18213
- handlePreviewCheckout({ creditBundles: updated });
18408
+ debouncedPreviewCheckout({ creditBundles: updated });
18214
18409
  return updated;
18215
18410
  });
18216
18411
  },
18217
- [handlePreviewCheckout]
18412
+ [debouncedPreviewCheckout]
18218
18413
  );
18219
18414
  const updateAddOnEntitlementQuantity = (0, import_react36.useCallback)(
18220
18415
  (id, updatedQuantity) => {
@@ -18228,13 +18423,13 @@ var CheckoutDialog = ({ top }) => {
18228
18423
  const updatedAddOnPayInAdvanceEntitlements = updated.filter(
18229
18424
  (entitlement) => entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance
18230
18425
  );
18231
- handlePreviewCheckout({
18426
+ debouncedPreviewCheckout({
18232
18427
  addOnPayInAdvanceEntitlements: updatedAddOnPayInAdvanceEntitlements
18233
18428
  });
18234
18429
  return updated;
18235
18430
  });
18236
18431
  },
18237
- [handlePreviewCheckout]
18432
+ [debouncedPreviewCheckout]
18238
18433
  );
18239
18434
  const updatePromoCode = (0, import_react36.useCallback)(
18240
18435
  async (code) => {
@@ -20142,6 +20337,7 @@ var SubscriptionSidebar = (0, import_react43.forwardRef)(
20142
20337
  autoTopupOverrides: isCreditOnlyPurchase ? [] : autoTopupRequestBody,
20143
20338
  payInAdvance: isCreditOnlyPurchase ? [] : [...planPayInAdvanceRequestBody, ...addOnPayInAdvanceRequestBody],
20144
20339
  creditBundles: creditBundlesRequestBody,
20340
+ customFieldValues: [],
20145
20341
  skipTrial: !shouldTrial,
20146
20342
  ...paymentMethodId && { paymentMethodId },
20147
20343
  ...promoCode && { promoCode }
@@ -21300,7 +21496,7 @@ var Viewport = (0, import_react46.forwardRef)(
21300
21496
  const [top, setTop] = (0, import_react46.useState)(0);
21301
21497
  (0, import_react46.useLayoutEffect)(() => {
21302
21498
  const element = portalRef.current;
21303
- const setModalY = (0, import_debounce3.default)(() => {
21499
+ const setModalY = (0, import_debounce4.default)(() => {
21304
21500
  const value = Math.abs(
21305
21501
  (element === document.body ? window.scrollY : element.scrollTop) ?? 0
21306
21502
  );
@@ -283,6 +283,7 @@ declare const BillingCreditGrantReason: {
283
283
  readonly Free: "free";
284
284
  readonly Plan: "plan";
285
285
  readonly Purchased: "purchased";
286
+ readonly Rollover: "rollover";
286
287
  };
287
288
 
288
289
  declare type BillingCreditGrantReason = (typeof BillingCreditGrantReason)[keyof typeof BillingCreditGrantReason];
@@ -300,6 +301,30 @@ declare const BillingCreditGrantZeroedOutReason: {
300
301
 
301
302
  declare type BillingCreditGrantZeroedOutReason = (typeof BillingCreditGrantZeroedOutReason)[keyof typeof BillingCreditGrantZeroedOutReason];
302
303
 
304
+ /**
305
+ *
306
+ * @export
307
+ */
308
+ declare const BillingCreditLedgerAuthority: {
309
+ readonly SchematicAuthoritative: "schematic_authoritative";
310
+ readonly ExternalMirror: "external_mirror";
311
+ readonly ExternalRated: "external_rated";
312
+ };
313
+
314
+ declare type BillingCreditLedgerAuthority = (typeof BillingCreditLedgerAuthority)[keyof typeof BillingCreditLedgerAuthority];
315
+
316
+ /**
317
+ *
318
+ * @export
319
+ */
320
+ declare const BillingCreditLedgerAuthority_2: {
321
+ readonly SchematicAuthoritative: "schematic_authoritative";
322
+ readonly ExternalMirror: "external_mirror";
323
+ readonly ExternalRated: "external_rated";
324
+ };
325
+
326
+ declare type BillingCreditLedgerAuthority_2 = (typeof BillingCreditLedgerAuthority_2)[keyof typeof BillingCreditLedgerAuthority_2];
327
+
303
328
  /**
304
329
  *
305
330
  * @export
@@ -610,6 +635,12 @@ declare interface BillingCreditView {
610
635
  * @memberof BillingCreditView
611
636
  */
612
637
  id: string;
638
+ /**
639
+ *
640
+ * @type {BillingCreditLedgerAuthority}
641
+ * @memberof BillingCreditView
642
+ */
643
+ ledgerAuthority: BillingCreditLedgerAuthority;
613
644
  /**
614
645
  *
615
646
  * @type {string}
@@ -738,6 +769,12 @@ declare interface BillingCreditView_2 {
738
769
  * @memberof BillingCreditView
739
770
  */
740
771
  id: string;
772
+ /**
773
+ *
774
+ * @type {BillingCreditLedgerAuthority}
775
+ * @memberof BillingCreditView
776
+ */
777
+ ledgerAuthority: BillingCreditLedgerAuthority_2;
741
778
  /**
742
779
  *
743
780
  * @type {string}
@@ -1082,6 +1119,12 @@ declare interface BillingPlanCreditGrantResponseData {
1082
1119
  * @memberof BillingPlanCreditGrantResponseData
1083
1120
  */
1084
1121
  resetType?: BillingPlanCreditGrantResetType | null;
1122
+ /**
1123
+ * Percentage of unused credits that carry over when this grant resets. Only meaningful when reset_type is plan_period.
1124
+ * @type {number}
1125
+ * @memberof BillingPlanCreditGrantResponseData
1126
+ */
1127
+ rolloverPercentage: number;
1085
1128
  /**
1086
1129
  *
1087
1130
  * @type {Date}
@@ -2325,6 +2368,7 @@ declare interface BillingProductResponseData_2 {
2325
2368
  * @export
2326
2369
  */
2327
2370
  declare const BillingProviderType: {
2371
+ readonly Metronome: "metronome";
2328
2372
  readonly Orb: "orb";
2329
2373
  readonly Schematic: "schematic";
2330
2374
  readonly Stripe: "stripe";
@@ -2337,6 +2381,7 @@ declare type BillingProviderType = (typeof BillingProviderType)[keyof typeof Bil
2337
2381
  * @export
2338
2382
  */
2339
2383
  declare const BillingProviderType_2: {
2384
+ readonly Metronome: "metronome";
2340
2385
  readonly Orb: "orb";
2341
2386
  readonly Schematic: "schematic";
2342
2387
  readonly Stripe: "stripe";
@@ -2878,6 +2923,12 @@ declare interface ChangeSubscriptionRequestBody {
2878
2923
  * @memberof ChangeSubscriptionRequestBody
2879
2924
  */
2880
2925
  creditBundles: Array<UpdateCreditBundleRequestBody>;
2926
+ /**
2927
+ *
2928
+ * @type {Array<CheckoutFieldValue>}
2929
+ * @memberof ChangeSubscriptionRequestBody
2930
+ */
2931
+ customFieldValues: Array<CheckoutFieldValue>;
2881
2932
  /**
2882
2933
  *
2883
2934
  * @type {string}
@@ -2963,6 +3014,98 @@ declare interface CheckoutDialogProps {
2963
3014
  top?: number;
2964
3015
  }
2965
3016
 
3017
+ /**
3018
+ * Schematic API
3019
+ * Schematic API
3020
+ *
3021
+ * The version of the OpenAPI document: 0.1
3022
+ *
3023
+ *
3024
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
3025
+ * https://openapi-generator.tech
3026
+ * Do not edit the class manually.
3027
+ */
3028
+ /**
3029
+ *
3030
+ * @export
3031
+ * @interface CheckoutFieldValue
3032
+ */
3033
+ declare interface CheckoutFieldValue {
3034
+ /**
3035
+ *
3036
+ * @type {string}
3037
+ * @memberof CheckoutFieldValue
3038
+ */
3039
+ id: string;
3040
+ /**
3041
+ *
3042
+ * @type {string}
3043
+ * @memberof CheckoutFieldValue
3044
+ */
3045
+ value: string;
3046
+ }
3047
+
3048
+ /**
3049
+ * Schematic API
3050
+ * Schematic API
3051
+ *
3052
+ * The version of the OpenAPI document: 0.1
3053
+ *
3054
+ *
3055
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
3056
+ * https://openapi-generator.tech
3057
+ * Do not edit the class manually.
3058
+ */
3059
+ /**
3060
+ *
3061
+ * @export
3062
+ * @interface CheckoutFieldWithValue
3063
+ */
3064
+ declare interface CheckoutFieldWithValue {
3065
+ /**
3066
+ *
3067
+ * @type {string}
3068
+ * @memberof CheckoutFieldWithValue
3069
+ */
3070
+ definitionId: string;
3071
+ /**
3072
+ *
3073
+ * @type {string}
3074
+ * @memberof CheckoutFieldWithValue
3075
+ */
3076
+ helperText?: string | null;
3077
+ /**
3078
+ *
3079
+ * @type {string}
3080
+ * @memberof CheckoutFieldWithValue
3081
+ */
3082
+ id: string;
3083
+ /**
3084
+ *
3085
+ * @type {string}
3086
+ * @memberof CheckoutFieldWithValue
3087
+ */
3088
+ name: string;
3089
+ /**
3090
+ *
3091
+ * @type {boolean}
3092
+ * @memberof CheckoutFieldWithValue
3093
+ */
3094
+ required: boolean;
3095
+ /**
3096
+ *
3097
+ * @type {string}
3098
+ * @memberof CheckoutFieldWithValue
3099
+ */
3100
+ stripeMetadataKey: string;
3101
+ /**
3102
+ *
3103
+ * @type {string}
3104
+ * @memberof CheckoutFieldWithValue
3105
+ */
3106
+ value?: string | null;
3107
+ }
3108
+
2966
3109
  /**
2967
3110
  * Configuration for pre-populating the checkout flow with host-provided values.
2968
3111
  *
@@ -3880,6 +4023,12 @@ declare interface CompanyPlanCreditGrantView {
3880
4023
  * @memberof CompanyPlanCreditGrantView
3881
4024
  */
3882
4025
  resetType: BillingPlanCreditGrantResetType;
4026
+ /**
4027
+ *
4028
+ * @type {number}
4029
+ * @memberof CompanyPlanCreditGrantView
4030
+ */
4031
+ rolloverPercentage: number;
3883
4032
  /**
3884
4033
  * Deprecated field, will be removed in the future. Use Credit.SingularName instead.
3885
4034
  * @type {string}
@@ -4729,6 +4878,12 @@ declare interface ComponentHydrateResponseData {
4729
4878
  * @memberof ComponentHydrateResponseData
4730
4879
  */
4731
4880
  creditGrants: Array<CreditCompanyGrantView>;
4881
+ /**
4882
+ *
4883
+ * @type {Array<CheckoutFieldWithValue>}
4884
+ * @memberof ComponentHydrateResponseData
4885
+ */
4886
+ customCheckoutFields: Array<CheckoutFieldWithValue>;
4732
4887
  /**
4733
4888
  *
4734
4889
  * @type {PlanDetailResponseData}
@@ -5261,12 +5416,30 @@ declare interface CreditCompanyGrantView {
5261
5416
  * @memberof CreditCompanyGrantView
5262
5417
  */
5263
5418
  renewalPeriod?: BillingPlanCreditGrantResetCadence | null;
5419
+ /**
5420
+ *
5421
+ * @type {number}
5422
+ * @memberof CreditCompanyGrantView
5423
+ */
5424
+ reserved?: number | null;
5425
+ /**
5426
+ *
5427
+ * @type {number}
5428
+ * @memberof CreditCompanyGrantView
5429
+ */
5430
+ settled?: number | null;
5264
5431
  /**
5265
5432
  *
5266
5433
  * @type {string}
5267
5434
  * @memberof CreditCompanyGrantView
5268
5435
  */
5269
5436
  singularName?: string | null;
5437
+ /**
5438
+ *
5439
+ * @type {string}
5440
+ * @memberof CreditCompanyGrantView
5441
+ */
5442
+ sourceGrantId?: string | null;
5270
5443
  /**
5271
5444
  *
5272
5445
  * @type {string}
@@ -8812,6 +8985,12 @@ declare interface PlanCreditGrantView {
8812
8985
  * @memberof PlanCreditGrantView
8813
8986
  */
8814
8987
  resetType: BillingPlanCreditGrantResetType;
8988
+ /**
8989
+ *
8990
+ * @type {number}
8991
+ * @memberof PlanCreditGrantView
8992
+ */
8993
+ rolloverPercentage: number;
8815
8994
  /**
8816
8995
  * Deprecated field, will be removed in the future. Use Credit.SingularName instead.
8817
8996
  * @type {string}
@@ -8999,6 +9178,12 @@ declare interface PlanCreditGrantView_2 {
8999
9178
  * @memberof PlanCreditGrantView
9000
9179
  */
9001
9180
  resetType: BillingPlanCreditGrantResetType_2;
9181
+ /**
9182
+ *
9183
+ * @type {number}
9184
+ * @memberof PlanCreditGrantView
9185
+ */
9186
+ rolloverPercentage: number;
9002
9187
  /**
9003
9188
  * Deprecated field, will be removed in the future. Use Credit.SingularName instead.
9004
9189
  * @type {string}
@@ -246,7 +246,7 @@ var require_debounce = __commonJS({
246
246
  var FUNC_ERROR_TEXT = "Expected a function";
247
247
  var nativeMax = Math.max;
248
248
  var nativeMin = Math.min;
249
- function debounce4(func, wait, options) {
249
+ function debounce5(func, wait, options) {
250
250
  var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
251
251
  if (typeof func != "function") {
252
252
  throw new TypeError(FUNC_ERROR_TEXT);
@@ -327,7 +327,7 @@ var require_debounce = __commonJS({
327
327
  debounced.flush = flush;
328
328
  return debounced;
329
329
  }
330
- module.exports = debounce4;
330
+ module.exports = debounce5;
331
331
  }
332
332
  });
333
333
 
@@ -1819,6 +1819,10 @@ var LEADING_DEBOUNCE_SETTINGS = {
1819
1819
  leading: true,
1820
1820
  trailing: false
1821
1821
  };
1822
+ var TRAILING_DEBOUNCE_SETTINGS = {
1823
+ leading: false,
1824
+ trailing: true
1825
+ };
1822
1826
  var EVENT_DEBOUNCE_TIMEOUT = 200;
1823
1827
  var FETCH_DEBOUNCE_TIMEOUT = 300;
1824
1828
 
@@ -7997,7 +8001,8 @@ var BillingCreditGrantReason = {
7997
8001
  BillingCreditAutoTopup: "billing_credit_auto_topup",
7998
8002
  Free: "free",
7999
8003
  Plan: "plan",
8000
- Purchased: "purchased"
8004
+ Purchased: "purchased",
8005
+ Rollover: "rollover"
8001
8006
  };
8002
8007
  function BillingCreditGrantReasonFromJSON(json) {
8003
8008
  return BillingCreditGrantReasonFromJSONTyped(json, false);
@@ -8014,6 +8019,14 @@ function BillingCreditGrantZeroedOutReasonFromJSONTyped(json, ignoreDiscriminato
8014
8019
  return json;
8015
8020
  }
8016
8021
 
8022
+ // src/api/checkoutexternal/models/BillingCreditLedgerAuthority.ts
8023
+ function BillingCreditLedgerAuthorityFromJSON(json) {
8024
+ return BillingCreditLedgerAuthorityFromJSONTyped(json, false);
8025
+ }
8026
+ function BillingCreditLedgerAuthorityFromJSONTyped(json, ignoreDiscriminator) {
8027
+ return json;
8028
+ }
8029
+
8017
8030
  // src/api/checkoutexternal/models/BillingPriceResponseData.ts
8018
8031
  function BillingPriceResponseDataFromJSON(json) {
8019
8032
  return BillingPriceResponseDataFromJSONTyped(json, false);
@@ -8158,6 +8171,9 @@ function BillingCreditViewFromJSONTyped(json, ignoreDiscriminator) {
8158
8171
  environmentId: json["environment_id"],
8159
8172
  icon: json["icon"] == null ? void 0 : json["icon"],
8160
8173
  id: json["id"],
8174
+ ledgerAuthority: BillingCreditLedgerAuthorityFromJSON(
8175
+ json["ledger_authority"]
8176
+ ),
8161
8177
  name: json["name"],
8162
8178
  pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
8163
8179
  price: json["price"] == null ? void 0 : BillingPriceViewFromJSON(json["price"]),
@@ -8266,6 +8282,7 @@ function BillingPlanCreditGrantResponseDataFromJSONTyped(json, ignoreDiscriminat
8266
8282
  resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON(json["reset_cadence"]),
8267
8283
  resetStart: json["reset_start"] == null ? void 0 : BillingPlanCreditGrantResetStartFromJSON(json["reset_start"]),
8268
8284
  resetType: json["reset_type"] == null ? void 0 : BillingPlanCreditGrantResetTypeFromJSON(json["reset_type"]),
8285
+ rolloverPercentage: json["rollover_percentage"],
8269
8286
  updatedAt: new Date(json["updated_at"])
8270
8287
  };
8271
8288
  }
@@ -8522,6 +8539,20 @@ function UpdateCreditBundleRequestBodyToJSONTyped(value, ignoreDiscriminator = f
8522
8539
  };
8523
8540
  }
8524
8541
 
8542
+ // src/api/checkoutexternal/models/CheckoutFieldValue.ts
8543
+ function CheckoutFieldValueToJSON(json) {
8544
+ return CheckoutFieldValueToJSONTyped(json, false);
8545
+ }
8546
+ function CheckoutFieldValueToJSONTyped(value, ignoreDiscriminator = false) {
8547
+ if (value == null) {
8548
+ return value;
8549
+ }
8550
+ return {
8551
+ id: value["id"],
8552
+ value: value["value"]
8553
+ };
8554
+ }
8555
+
8525
8556
  // src/api/checkoutexternal/models/UpdateAddOnRequestBody.ts
8526
8557
  function UpdateAddOnRequestBodyToJSON(json) {
8527
8558
  return UpdateAddOnRequestBodyToJSONTyped(json, false);
@@ -8571,6 +8602,9 @@ function ChangeSubscriptionRequestBodyToJSONTyped(value, ignoreDiscriminator = f
8571
8602
  credit_bundles: value["creditBundles"].map(
8572
8603
  UpdateCreditBundleRequestBodyToJSON
8573
8604
  ),
8605
+ custom_field_values: value["customFieldValues"].map(
8606
+ CheckoutFieldValueToJSON
8607
+ ),
8574
8608
  new_plan_id: value["newPlanId"],
8575
8609
  new_price_id: value["newPriceId"],
8576
8610
  pay_in_advance: value["payInAdvance"].map(
@@ -8590,6 +8624,25 @@ function ChargeTypeFromJSONTyped(json, ignoreDiscriminator) {
8590
8624
  return json;
8591
8625
  }
8592
8626
 
8627
+ // src/api/checkoutexternal/models/CheckoutFieldWithValue.ts
8628
+ function CheckoutFieldWithValueFromJSON(json) {
8629
+ return CheckoutFieldWithValueFromJSONTyped(json, false);
8630
+ }
8631
+ function CheckoutFieldWithValueFromJSONTyped(json, ignoreDiscriminator) {
8632
+ if (json == null) {
8633
+ return json;
8634
+ }
8635
+ return {
8636
+ definitionId: json["definition_id"],
8637
+ helperText: json["helper_text"] == null ? void 0 : json["helper_text"],
8638
+ id: json["id"],
8639
+ name: json["name"],
8640
+ required: json["required"],
8641
+ stripeMetadataKey: json["stripe_metadata_key"],
8642
+ value: json["value"] == null ? void 0 : json["value"]
8643
+ };
8644
+ }
8645
+
8593
8646
  // src/api/checkoutexternal/models/ScheduledDowngradeConfigBehavior.ts
8594
8647
  function ScheduledDowngradeConfigBehaviorFromJSON(json) {
8595
8648
  return ScheduledDowngradeConfigBehaviorFromJSONTyped(json, false);
@@ -8802,6 +8855,7 @@ function CompanyPlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
8802
8855
  resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON(json["reset_cadence"]),
8803
8856
  resetStart: json["reset_start"] == null ? void 0 : BillingPlanCreditGrantResetStartFromJSON(json["reset_start"]),
8804
8857
  resetType: BillingPlanCreditGrantResetTypeFromJSON(json["reset_type"]),
8858
+ rolloverPercentage: json["rollover_percentage"],
8805
8859
  singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
8806
8860
  updatedAt: new Date(json["updated_at"])
8807
8861
  };
@@ -9664,6 +9718,7 @@ function PlanCreditGrantViewFromJSONTyped(json, ignoreDiscriminator) {
9664
9718
  resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON(json["reset_cadence"]),
9665
9719
  resetStart: json["reset_start"] == null ? void 0 : BillingPlanCreditGrantResetStartFromJSON(json["reset_start"]),
9666
9720
  resetType: BillingPlanCreditGrantResetTypeFromJSON(json["reset_type"]),
9721
+ rolloverPercentage: json["rollover_percentage"],
9667
9722
  singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
9668
9723
  updatedAt: new Date(json["updated_at"])
9669
9724
  };
@@ -10101,7 +10156,10 @@ function CreditCompanyGrantViewFromJSONTyped(json, ignoreDiscriminator) {
10101
10156
  quantityUsed: json["quantity_used"],
10102
10157
  renewalEnabled: json["renewal_enabled"],
10103
10158
  renewalPeriod: json["renewal_period"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON(json["renewal_period"]),
10159
+ reserved: json["reserved"] == null ? void 0 : json["reserved"],
10160
+ settled: json["settled"] == null ? void 0 : json["settled"],
10104
10161
  singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
10162
+ sourceGrantId: json["source_grant_id"] == null ? void 0 : json["source_grant_id"],
10105
10163
  sourceLabel: json["source_label"],
10106
10164
  transfers: json["transfers"] == null ? void 0 : json["transfers"].map(CreditTransferViewFromJSON),
10107
10165
  updatedAt: new Date(json["updated_at"]),
@@ -10210,6 +10268,9 @@ function ComponentHydrateResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10210
10268
  creditGrants: json["credit_grants"].map(
10211
10269
  CreditCompanyGrantViewFromJSON
10212
10270
  ),
10271
+ customCheckoutFields: json["custom_checkout_fields"].map(
10272
+ CheckoutFieldWithValueFromJSON
10273
+ ),
10213
10274
  defaultPlan: json["default_plan"] == null ? void 0 : PlanDetailResponseDataFromJSON(json["default_plan"]),
10214
10275
  displaySettings: ComponentDisplaySettingsFromJSON(json["display_settings"]),
10215
10276
  featureUsage: json["feature_usage"] == null ? void 0 : FeatureUsageDetailResponseDataFromJSON(json["feature_usage"]),
@@ -10454,6 +10515,46 @@ function PreviewCheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
10454
10515
  };
10455
10516
  }
10456
10517
 
10518
+ // src/api/checkoutexternal/models/UpdateCheckoutFieldValuesRequestBody.ts
10519
+ function UpdateCheckoutFieldValuesRequestBodyToJSON(json) {
10520
+ return UpdateCheckoutFieldValuesRequestBodyToJSONTyped(json, false);
10521
+ }
10522
+ function UpdateCheckoutFieldValuesRequestBodyToJSONTyped(value, ignoreDiscriminator = false) {
10523
+ if (value == null) {
10524
+ return value;
10525
+ }
10526
+ return {
10527
+ values: value["values"].map(CheckoutFieldValueToJSON)
10528
+ };
10529
+ }
10530
+
10531
+ // src/api/checkoutexternal/models/UpdateCheckoutFieldValuesResponseData.ts
10532
+ function UpdateCheckoutFieldValuesResponseDataFromJSON(json) {
10533
+ return UpdateCheckoutFieldValuesResponseDataFromJSONTyped(json, false);
10534
+ }
10535
+ function UpdateCheckoutFieldValuesResponseDataFromJSONTyped(json, ignoreDiscriminator) {
10536
+ if (json == null) {
10537
+ return json;
10538
+ }
10539
+ return {
10540
+ company: json["company"] == null ? void 0 : CompanyDetailResponseDataFromJSON(json["company"])
10541
+ };
10542
+ }
10543
+
10544
+ // src/api/checkoutexternal/models/UpdateCheckoutFieldValuesResponse.ts
10545
+ function UpdateCheckoutFieldValuesResponseFromJSON(json) {
10546
+ return UpdateCheckoutFieldValuesResponseFromJSONTyped(json, false);
10547
+ }
10548
+ function UpdateCheckoutFieldValuesResponseFromJSONTyped(json, ignoreDiscriminator) {
10549
+ if (json == null) {
10550
+ return json;
10551
+ }
10552
+ return {
10553
+ data: UpdateCheckoutFieldValuesResponseDataFromJSON(json["data"]),
10554
+ params: json["params"]
10555
+ };
10556
+ }
10557
+
10457
10558
  // src/api/checkoutexternal/models/UpdatePaymentMethodRequestBody.ts
10458
10559
  function UpdatePaymentMethodRequestBodyToJSON(json) {
10459
10560
  return UpdatePaymentMethodRequestBodyToJSONTyped(json, false);
@@ -10915,6 +11016,51 @@ var CheckoutexternalApi = class extends BaseAPI {
10915
11016
  );
10916
11017
  return await response.value();
10917
11018
  }
11019
+ /**
11020
+ * Update checkout field values
11021
+ */
11022
+ async updateCheckoutFieldValuesRaw(requestParameters, initOverrides) {
11023
+ if (requestParameters["updateCheckoutFieldValuesRequestBody"] == null) {
11024
+ throw new RequiredError(
11025
+ "updateCheckoutFieldValuesRequestBody",
11026
+ 'Required parameter "updateCheckoutFieldValuesRequestBody" was null or undefined when calling updateCheckoutFieldValues().'
11027
+ );
11028
+ }
11029
+ const queryParameters = {};
11030
+ const headerParameters = {};
11031
+ headerParameters["Content-Type"] = "application/json";
11032
+ if (this.configuration && this.configuration.apiKey) {
11033
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
11034
+ "X-Schematic-Api-Key"
11035
+ );
11036
+ }
11037
+ const response = await this.request(
11038
+ {
11039
+ path: `/checkout/custom-field-values`,
11040
+ method: "POST",
11041
+ headers: headerParameters,
11042
+ query: queryParameters,
11043
+ body: UpdateCheckoutFieldValuesRequestBodyToJSON(
11044
+ requestParameters["updateCheckoutFieldValuesRequestBody"]
11045
+ )
11046
+ },
11047
+ initOverrides
11048
+ );
11049
+ return new JSONApiResponse(
11050
+ response,
11051
+ (jsonValue) => UpdateCheckoutFieldValuesResponseFromJSON(jsonValue)
11052
+ );
11053
+ }
11054
+ /**
11055
+ * Update checkout field values
11056
+ */
11057
+ async updateCheckoutFieldValues(requestParameters, initOverrides) {
11058
+ const response = await this.updateCheckoutFieldValuesRaw(
11059
+ requestParameters,
11060
+ initOverrides
11061
+ );
11062
+ return await response.value();
11063
+ }
10918
11064
  /**
10919
11065
  * Update payment method
10920
11066
  */
@@ -11242,6 +11388,14 @@ function BillingCreditExpiryUnitFromJSONTyped9(json, ignoreDiscriminator) {
11242
11388
  return json;
11243
11389
  }
11244
11390
 
11391
+ // src/api/componentspublic/models/BillingCreditLedgerAuthority.ts
11392
+ function BillingCreditLedgerAuthorityFromJSON2(json) {
11393
+ return BillingCreditLedgerAuthorityFromJSONTyped3(json, false);
11394
+ }
11395
+ function BillingCreditLedgerAuthorityFromJSONTyped3(json, ignoreDiscriminator) {
11396
+ return json;
11397
+ }
11398
+
11245
11399
  // src/api/componentspublic/models/BillingProductPriceInterval.ts
11246
11400
  function BillingProductPriceIntervalFromJSON2(json) {
11247
11401
  return BillingProductPriceIntervalFromJSONTyped5(json, false);
@@ -11480,6 +11634,9 @@ function BillingCreditViewFromJSONTyped4(json, ignoreDiscriminator) {
11480
11634
  environmentId: json["environment_id"],
11481
11635
  icon: json["icon"] == null ? void 0 : json["icon"],
11482
11636
  id: json["id"],
11637
+ ledgerAuthority: BillingCreditLedgerAuthorityFromJSON2(
11638
+ json["ledger_authority"]
11639
+ ),
11483
11640
  name: json["name"],
11484
11641
  pluralName: json["plural_name"] == null ? void 0 : json["plural_name"],
11485
11642
  price: json["price"] == null ? void 0 : BillingPriceViewFromJSON2(json["price"]),
@@ -12129,6 +12286,7 @@ function PlanCreditGrantViewFromJSONTyped3(json, ignoreDiscriminator) {
12129
12286
  resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON2(json["reset_cadence"]),
12130
12287
  resetStart: json["reset_start"] == null ? void 0 : BillingPlanCreditGrantResetStartFromJSON2(json["reset_start"]),
12131
12288
  resetType: BillingPlanCreditGrantResetTypeFromJSON2(json["reset_type"]),
12289
+ rolloverPercentage: json["rollover_percentage"],
12132
12290
  singularName: json["singular_name"] == null ? void 0 : json["singular_name"],
12133
12291
  updatedAt: new Date(json["updated_at"])
12134
12292
  };
@@ -13557,6 +13715,7 @@ function normalize(data) {
13557
13715
  },
13558
13716
  creditBundles: [],
13559
13717
  creditGrants: [],
13718
+ customCheckoutFields: [],
13560
13719
  preventSelfServiceDowngrade: false
13561
13720
  });
13562
13721
  }
@@ -13738,7 +13897,7 @@ var reducer = (state, action) => {
13738
13897
  // src/context/EmbedProvider.tsx
13739
13898
  import { jsx, jsxs } from "react/jsx-runtime";
13740
13899
  var getCustomHeaders = (sessionId) => ({
13741
- "X-Schematic-Components-Version": "2.14.0",
13900
+ "X-Schematic-Components-Version": "2.14.1",
13742
13901
  "X-Schematic-Session-ID": sessionId
13743
13902
  });
13744
13903
  var normalizeCurrencyFilter = (filter2) => {
@@ -15839,7 +15998,7 @@ var Root = forwardRef6(
15839
15998
  Root.displayName = "Root";
15840
15999
 
15841
16000
  // src/components/layout/viewport/Viewport.tsx
15842
- var import_debounce3 = __toESM(require_debounce());
16001
+ var import_debounce4 = __toESM(require_debounce());
15843
16002
  import { forwardRef as forwardRef8, useLayoutEffect as useLayoutEffect8, useRef as useRef11, useState as useState14 } from "react";
15844
16003
  import { createPortal as createPortal3 } from "react-dom";
15845
16004
 
@@ -17289,6 +17448,7 @@ var Checkout = ({
17289
17448
  };
17290
17449
 
17291
17450
  // src/components/shared/checkout-dialog/CheckoutDialog.tsx
17451
+ var import_debounce3 = __toESM(require_debounce());
17292
17452
  import {
17293
17453
  useCallback as useCallback7,
17294
17454
  useEffect as useEffect4,
@@ -17807,6 +17967,7 @@ var CheckoutDialog = ({ top }) => {
17807
17967
  }
17808
17968
  return id;
17809
17969
  }, [checkoutStage, checkoutStages, checkoutState, isBypassLoading]);
17970
+ const previewRequestIdRef = useRef6(0);
17810
17971
  const handlePreviewCheckout = useCallback7(
17811
17972
  async (updates) => {
17812
17973
  const period = updates.period || planPeriod;
@@ -17830,6 +17991,8 @@ var CheckoutDialog = ({ top }) => {
17830
17991
  setSelectedPlanId(null);
17831
17992
  return;
17832
17993
  }
17994
+ const requestId = ++previewRequestIdRef.current;
17995
+ const isStale = () => requestId !== previewRequestIdRef.current;
17833
17996
  setError(void 0);
17834
17997
  setCharges(void 0);
17835
17998
  setIsLoading(true);
@@ -17873,9 +18036,13 @@ var CheckoutDialog = ({ top }) => {
17873
18036
  autoTopupOverrides: isCreditOnly ? [] : autoTopupRequestBody,
17874
18037
  payInAdvance: isCreditOnly ? [] : [...planPayInAdvanceRequestBody, ...addOnPayInAdvanceRequestBody],
17875
18038
  creditBundles: creditBundlesRequestBody,
18039
+ customFieldValues: [],
17876
18040
  skipTrial,
17877
18041
  ...code && { promoCode: code }
17878
18042
  });
18043
+ if (isStale()) {
18044
+ return;
18045
+ }
17879
18046
  if (response) {
17880
18047
  setCharges(response.data.finance);
17881
18048
  setIsPaymentMethodRequired(response.data.paymentMethodRequired);
@@ -17885,6 +18052,9 @@ var CheckoutDialog = ({ top }) => {
17885
18052
  setPromoCode(code);
17886
18053
  }
17887
18054
  } catch (err2) {
18055
+ if (isStale()) {
18056
+ return;
18057
+ }
17888
18058
  if (err2 instanceof ResponseError) {
17889
18059
  if (err2.response.status === 401) {
17890
18060
  setError(t3("Session expired. Please refresh and try again."));
@@ -17919,9 +18089,11 @@ var CheckoutDialog = ({ top }) => {
17919
18089
  const { message: msg } = isError(err2) ? err2 : ERROR_UNKNOWN;
17920
18090
  setError(msg);
17921
18091
  } finally {
17922
- setIsLoading(false);
17923
- if (isBypassLoading) {
17924
- setIsBypassLoading(false);
18092
+ if (!isStale()) {
18093
+ setIsLoading(false);
18094
+ if (isBypassLoading) {
18095
+ setIsBypassLoading(false);
18096
+ }
17925
18097
  }
17926
18098
  }
17927
18099
  },
@@ -17944,6 +18116,29 @@ var CheckoutDialog = ({ top }) => {
17944
18116
  isBypassLoading
17945
18117
  ]
17946
18118
  );
18119
+ const handlePreviewCheckoutRef = useRef6(handlePreviewCheckout);
18120
+ useEffect4(() => {
18121
+ handlePreviewCheckoutRef.current = handlePreviewCheckout;
18122
+ }, [handlePreviewCheckout]);
18123
+ const debouncedPreviewCheckoutRef = useRef6(null);
18124
+ useEffect4(() => {
18125
+ const debounced = (0, import_debounce3.default)(
18126
+ (updates) => handlePreviewCheckoutRef.current(updates),
18127
+ FETCH_DEBOUNCE_TIMEOUT,
18128
+ TRAILING_DEBOUNCE_SETTINGS
18129
+ );
18130
+ debouncedPreviewCheckoutRef.current = debounced;
18131
+ return () => {
18132
+ debounced.cancel();
18133
+ debouncedPreviewCheckoutRef.current = null;
18134
+ };
18135
+ }, []);
18136
+ const debouncedPreviewCheckout = useCallback7(
18137
+ (updates) => {
18138
+ debouncedPreviewCheckoutRef.current?.(updates);
18139
+ },
18140
+ []
18141
+ );
17947
18142
  const selectPlan = useCallback7(
17948
18143
  (updates) => {
17949
18144
  const plan = updates.plan;
@@ -18107,11 +18302,11 @@ var CheckoutDialog = ({ top }) => {
18107
18302
  companyAutoTopupAmount: updates.companyAutoTopupAmount ?? prevConfig?.companyAutoTopupAmount ?? matchedCreditGrant?.billingCreditAutoTopupAmount ?? 0
18108
18303
  };
18109
18304
  nextMap.set(id, updatedConfig);
18110
- handlePreviewCheckout({ autoTopupConfigs: nextMap });
18305
+ debouncedPreviewCheckout({ autoTopupConfigs: nextMap });
18111
18306
  return nextMap;
18112
18307
  });
18113
18308
  },
18114
- [handlePreviewCheckout, planCreditGrants]
18309
+ [debouncedPreviewCheckout, planCreditGrants]
18115
18310
  );
18116
18311
  const updateUsageBasedEntitlementQuantity = useCallback7(
18117
18312
  (id, updatedQuantity) => {
@@ -18122,7 +18317,7 @@ var CheckoutDialog = ({ top }) => {
18122
18317
  quantity: updatedQuantity
18123
18318
  } : entitlement
18124
18319
  );
18125
- handlePreviewCheckout({
18320
+ debouncedPreviewCheckout({
18126
18321
  payInAdvanceEntitlements: updated.filter(
18127
18322
  ({ priceBehavior }) => priceBehavior === EntitlementPriceBehavior.PayInAdvance
18128
18323
  )
@@ -18130,7 +18325,7 @@ var CheckoutDialog = ({ top }) => {
18130
18325
  return updated;
18131
18326
  });
18132
18327
  },
18133
- [handlePreviewCheckout]
18328
+ [debouncedPreviewCheckout]
18134
18329
  );
18135
18330
  const updateCreditBundleCount = useCallback7(
18136
18331
  (id, updatedCount) => {
@@ -18141,11 +18336,11 @@ var CheckoutDialog = ({ top }) => {
18141
18336
  count: updatedCount
18142
18337
  } : bundle
18143
18338
  );
18144
- handlePreviewCheckout({ creditBundles: updated });
18339
+ debouncedPreviewCheckout({ creditBundles: updated });
18145
18340
  return updated;
18146
18341
  });
18147
18342
  },
18148
- [handlePreviewCheckout]
18343
+ [debouncedPreviewCheckout]
18149
18344
  );
18150
18345
  const updateAddOnEntitlementQuantity = useCallback7(
18151
18346
  (id, updatedQuantity) => {
@@ -18159,13 +18354,13 @@ var CheckoutDialog = ({ top }) => {
18159
18354
  const updatedAddOnPayInAdvanceEntitlements = updated.filter(
18160
18355
  (entitlement) => entitlement.priceBehavior === EntitlementPriceBehavior.PayInAdvance
18161
18356
  );
18162
- handlePreviewCheckout({
18357
+ debouncedPreviewCheckout({
18163
18358
  addOnPayInAdvanceEntitlements: updatedAddOnPayInAdvanceEntitlements
18164
18359
  });
18165
18360
  return updated;
18166
18361
  });
18167
18362
  },
18168
- [handlePreviewCheckout]
18363
+ [debouncedPreviewCheckout]
18169
18364
  );
18170
18365
  const updatePromoCode = useCallback7(
18171
18366
  async (code) => {
@@ -20085,6 +20280,7 @@ var SubscriptionSidebar = forwardRef7(
20085
20280
  autoTopupOverrides: isCreditOnlyPurchase ? [] : autoTopupRequestBody,
20086
20281
  payInAdvance: isCreditOnlyPurchase ? [] : [...planPayInAdvanceRequestBody, ...addOnPayInAdvanceRequestBody],
20087
20282
  creditBundles: creditBundlesRequestBody,
20283
+ customFieldValues: [],
20088
20284
  skipTrial: !shouldTrial,
20089
20285
  ...paymentMethodId && { paymentMethodId },
20090
20286
  ...promoCode && { promoCode }
@@ -21243,7 +21439,7 @@ var Viewport = forwardRef8(
21243
21439
  const [top, setTop] = useState14(0);
21244
21440
  useLayoutEffect8(() => {
21245
21441
  const element = portalRef.current;
21246
- const setModalY = (0, import_debounce3.default)(() => {
21442
+ const setModalY = (0, import_debounce4.default)(() => {
21247
21443
  const value = Math.abs(
21248
21444
  (element === document.body ? window.scrollY : element.scrollTop) ?? 0
21249
21445
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "2.14.0",
3
+ "version": "2.14.1",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",
@@ -72,7 +72,7 @@
72
72
  "react": "^19.2.6",
73
73
  "react-dom": "^19.2.6",
74
74
  "typescript": "^6.0.3",
75
- "typescript-eslint": "^8.60.0",
75
+ "typescript-eslint": "^8.60.1",
76
76
  "vitest": "^4.1.7"
77
77
  },
78
78
  "peerDependencies": {