@schematichq/schematic-react 1.15.0 → 1.16.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.
@@ -82,7 +82,7 @@ __export(index_exports, {
82
82
  });
83
83
  module.exports = __toCommonJS(index_exports);
84
84
 
85
- // node_modules/.pnpm/@schematichq+schematic-js@1.15.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
85
+ // node_modules/.pnpm/@schematichq+schematic-js@1.16.1/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
86
86
  var __create2 = Object.create;
87
87
  var __defProp2 = Object.defineProperty;
88
88
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -1413,7 +1413,7 @@ var ContextSignatureManager = class {
1413
1413
  }
1414
1414
  }
1415
1415
  };
1416
- var version = "1.15.0";
1416
+ var version = "1.16.1";
1417
1417
  var DEFAULT_CATALOG_QUERY = {};
1418
1418
  function normalizeCatalogQuery(query) {
1419
1419
  return query.catalogId === void 0 ? {} : { catalogId: query.catalogId };
@@ -1532,6 +1532,10 @@ __export2(models_exports, {
1532
1532
  CatalogPlanRefResponseDataFromJSONTyped: () => CatalogPlanRefResponseDataFromJSONTyped,
1533
1533
  CatalogPlanRefResponseDataToJSON: () => CatalogPlanRefResponseDataToJSON,
1534
1534
  CatalogPlanRefResponseDataToJSONTyped: () => CatalogPlanRefResponseDataToJSONTyped,
1535
+ CatalogPlanResponseDataFromJSON: () => CatalogPlanResponseDataFromJSON2,
1536
+ CatalogPlanResponseDataFromJSONTyped: () => CatalogPlanResponseDataFromJSONTyped2,
1537
+ CatalogPlanResponseDataToJSON: () => CatalogPlanResponseDataToJSON2,
1538
+ CatalogPlanResponseDataToJSONTyped: () => CatalogPlanResponseDataToJSONTyped2,
1535
1539
  CatalogPriceResponseDataFromJSON: () => CatalogPriceResponseDataFromJSON2,
1536
1540
  CatalogPriceResponseDataFromJSONTyped: () => CatalogPriceResponseDataFromJSONTyped7,
1537
1541
  CatalogPriceResponseDataToJSON: () => CatalogPriceResponseDataToJSON2,
@@ -1838,6 +1842,14 @@ __export2(models_exports, {
1838
1842
  GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
1839
1843
  GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
1840
1844
  GetCompanyUpcomingInvoiceResponseToJSONTyped: () => GetCompanyUpcomingInvoiceResponseToJSONTyped,
1845
+ GetPublicCatalogByIDResponseFromJSON: () => GetPublicCatalogByIDResponseFromJSON,
1846
+ GetPublicCatalogByIDResponseFromJSONTyped: () => GetPublicCatalogByIDResponseFromJSONTyped,
1847
+ GetPublicCatalogByIDResponseToJSON: () => GetPublicCatalogByIDResponseToJSON,
1848
+ GetPublicCatalogByIDResponseToJSONTyped: () => GetPublicCatalogByIDResponseToJSONTyped,
1849
+ GetPublicCatalogResponseFromJSON: () => GetPublicCatalogResponseFromJSON,
1850
+ GetPublicCatalogResponseFromJSONTyped: () => GetPublicCatalogResponseFromJSONTyped,
1851
+ GetPublicCatalogResponseToJSON: () => GetPublicCatalogResponseToJSON,
1852
+ GetPublicCatalogResponseToJSONTyped: () => GetPublicCatalogResponseToJSONTyped,
1841
1853
  InvoiceStatus: () => InvoiceStatus,
1842
1854
  InvoiceStatusFromJSON: () => InvoiceStatusFromJSON,
1843
1855
  InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
@@ -1885,6 +1897,10 @@ __export2(models_exports, {
1885
1897
  ProrationLineKindFromJSONTyped: () => ProrationLineKindFromJSONTyped,
1886
1898
  ProrationLineKindToJSON: () => ProrationLineKindToJSON,
1887
1899
  ProrationLineKindToJSONTyped: () => ProrationLineKindToJSONTyped,
1900
+ PublicCatalogResponseDataFromJSON: () => PublicCatalogResponseDataFromJSON2,
1901
+ PublicCatalogResponseDataFromJSONTyped: () => PublicCatalogResponseDataFromJSONTyped3,
1902
+ PublicCatalogResponseDataToJSON: () => PublicCatalogResponseDataToJSON2,
1903
+ PublicCatalogResponseDataToJSONTyped: () => PublicCatalogResponseDataToJSONTyped3,
1888
1904
  ScheduledDowngradeConfigBehavior: () => ScheduledDowngradeConfigBehavior,
1889
1905
  ScheduledDowngradeConfigBehaviorFromJSON: () => ScheduledDowngradeConfigBehaviorFromJSON,
1890
1906
  ScheduledDowngradeConfigBehaviorFromJSONTyped: () => ScheduledDowngradeConfigBehaviorFromJSONTyped,
@@ -1972,6 +1988,7 @@ __export2(models_exports, {
1972
1988
  instanceOfCatalogCustomPlanCTAResponseData: () => instanceOfCatalogCustomPlanCTAResponseData,
1973
1989
  instanceOfCatalogPlanEntitlementResponseData: () => instanceOfCatalogPlanEntitlementResponseData,
1974
1990
  instanceOfCatalogPlanRefResponseData: () => instanceOfCatalogPlanRefResponseData,
1991
+ instanceOfCatalogPlanResponseData: () => instanceOfCatalogPlanResponseData,
1975
1992
  instanceOfCatalogPriceResponseData: () => instanceOfCatalogPriceResponseData,
1976
1993
  instanceOfCatalogPriceTierResponseData: () => instanceOfCatalogPriceTierResponseData,
1977
1994
  instanceOfCatalogUsageViolationResponseData: () => instanceOfCatalogUsageViolationResponseData,
@@ -2045,6 +2062,8 @@ __export2(models_exports, {
2045
2062
  instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
2046
2063
  instanceOfGetCompanyResponse: () => instanceOfGetCompanyResponse,
2047
2064
  instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
2065
+ instanceOfGetPublicCatalogByIDResponse: () => instanceOfGetPublicCatalogByIDResponse,
2066
+ instanceOfGetPublicCatalogResponse: () => instanceOfGetPublicCatalogResponse,
2048
2067
  instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
2049
2068
  instanceOfListCheckoutsParams: () => instanceOfListCheckoutsParams,
2050
2069
  instanceOfListCheckoutsResponse: () => instanceOfListCheckoutsResponse,
@@ -2055,6 +2074,7 @@ __export2(models_exports, {
2055
2074
  instanceOfPlanPriceCadence: () => instanceOfPlanPriceCadence,
2056
2075
  instanceOfProrationBehavior: () => instanceOfProrationBehavior,
2057
2076
  instanceOfProrationLineKind: () => instanceOfProrationLineKind,
2077
+ instanceOfPublicCatalogResponseData: () => instanceOfPublicCatalogResponseData,
2058
2078
  instanceOfScheduledDowngradeConfigBehavior: () => instanceOfScheduledDowngradeConfigBehavior,
2059
2079
  instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
2060
2080
  instanceOfTaxIDInput: () => instanceOfTaxIDInput,
@@ -3365,6 +3385,7 @@ function instanceOfCatalogCreditGrantResponseData(value) {
3365
3385
  return false;
3366
3386
  if (!("id" in value) || value["id"] === void 0) return false;
3367
3387
  if (!("scaling" in value) || value["scaling"] === void 0) return false;
3388
+ if (!("visible" in value) || value["visible"] === void 0) return false;
3368
3389
  return true;
3369
3390
  }
3370
3391
  function CatalogCreditGrantResponseDataFromJSON2(json) {
@@ -3385,7 +3406,8 @@ function CatalogCreditGrantResponseDataFromJSONTyped2(json, ignoreDiscriminator)
3385
3406
  id: json["id"],
3386
3407
  licenseId: json["license_id"] == null ? void 0 : json["license_id"],
3387
3408
  resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON2(json["reset_cadence"]),
3388
- scaling: PlanCreditGrantScalingFromJSON2(json["scaling"])
3409
+ scaling: PlanCreditGrantScalingFromJSON2(json["scaling"]),
3410
+ visible: json["visible"]
3389
3411
  };
3390
3412
  }
3391
3413
  function CatalogCreditGrantResponseDataToJSON2(json) {
@@ -3408,7 +3430,8 @@ function CatalogCreditGrantResponseDataToJSONTyped2(value, ignoreDiscriminator =
3408
3430
  reset_cadence: BillingPlanCreditGrantResetCadenceToJSON2(
3409
3431
  value["resetCadence"]
3410
3432
  ),
3411
- scaling: PlanCreditGrantScalingToJSON2(value["scaling"])
3433
+ scaling: PlanCreditGrantScalingToJSON2(value["scaling"]),
3434
+ visible: value["visible"]
3412
3435
  };
3413
3436
  }
3414
3437
  var PlanPriceCadence = {
@@ -3688,6 +3711,98 @@ function CatalogPlanRefResponseDataToJSONTyped(value, ignoreDiscriminator = fals
3688
3711
  name: value["name"]
3689
3712
  };
3690
3713
  }
3714
+ function instanceOfCatalogPlanResponseData(value) {
3715
+ if (!("availablePeriods" in value) || value["availablePeriods"] === void 0)
3716
+ return false;
3717
+ if (!("billingStrategy" in value) || value["billingStrategy"] === void 0)
3718
+ return false;
3719
+ if (!("chargeType" in value) || value["chargeType"] === void 0)
3720
+ return false;
3721
+ if (!("currencyPrices" in value) || value["currencyPrices"] === void 0)
3722
+ return false;
3723
+ if (!("description" in value) || value["description"] === void 0)
3724
+ return false;
3725
+ if (!("entitlements" in value) || value["entitlements"] === void 0)
3726
+ return false;
3727
+ if (!("icon" in value) || value["icon"] === void 0) return false;
3728
+ if (!("id" in value) || value["id"] === void 0) return false;
3729
+ if (!("includedCreditGrants" in value) || value["includedCreditGrants"] === void 0)
3730
+ return false;
3731
+ if (!("isTrialable" in value) || value["isTrialable"] === void 0)
3732
+ return false;
3733
+ if (!("name" in value) || value["name"] === void 0) return false;
3734
+ return true;
3735
+ }
3736
+ function CatalogPlanResponseDataFromJSON2(json) {
3737
+ return CatalogPlanResponseDataFromJSONTyped2(json, false);
3738
+ }
3739
+ function CatalogPlanResponseDataFromJSONTyped2(json, ignoreDiscriminator) {
3740
+ if (json == null) {
3741
+ return json;
3742
+ }
3743
+ return {
3744
+ availablePeriods: json["available_periods"].map(
3745
+ PlanPriceCadenceFromJSON2
3746
+ ),
3747
+ billingStrategy: BillingStrategyFromJSON2(json["billing_strategy"]),
3748
+ chargeType: ChargeTypeFromJSON2(json["charge_type"]),
3749
+ compatiblePlanIds: json["compatible_plan_ids"] == null ? void 0 : json["compatible_plan_ids"],
3750
+ currencyPrices: json["currency_prices"].map(
3751
+ CatalogCurrencyPricesResponseDataFromJSON2
3752
+ ),
3753
+ description: json["description"],
3754
+ entitlements: json["entitlements"].map(
3755
+ CatalogPlanEntitlementResponseDataFromJSON2
3756
+ ),
3757
+ icon: json["icon"],
3758
+ id: json["id"],
3759
+ includedCreditGrants: json["included_credit_grants"].map(
3760
+ CatalogCreditGrantResponseDataFromJSON2
3761
+ ),
3762
+ isTrialable: json["is_trialable"],
3763
+ monthlyPrice: json["monthly_price"] == null ? void 0 : CatalogPriceResponseDataFromJSON2(json["monthly_price"]),
3764
+ name: json["name"],
3765
+ oneTimePrice: json["one_time_price"] == null ? void 0 : CatalogPriceResponseDataFromJSON2(json["one_time_price"]),
3766
+ quarterlyPrice: json["quarterly_price"] == null ? void 0 : CatalogPriceResponseDataFromJSON2(json["quarterly_price"]),
3767
+ trialDays: json["trial_days"] == null ? void 0 : json["trial_days"],
3768
+ yearlyPrice: json["yearly_price"] == null ? void 0 : CatalogPriceResponseDataFromJSON2(json["yearly_price"])
3769
+ };
3770
+ }
3771
+ function CatalogPlanResponseDataToJSON2(json) {
3772
+ return CatalogPlanResponseDataToJSONTyped2(json, false);
3773
+ }
3774
+ function CatalogPlanResponseDataToJSONTyped2(value, ignoreDiscriminator = false) {
3775
+ if (value == null) {
3776
+ return value;
3777
+ }
3778
+ return {
3779
+ available_periods: value["availablePeriods"].map(
3780
+ PlanPriceCadenceToJSON2
3781
+ ),
3782
+ billing_strategy: BillingStrategyToJSON2(value["billingStrategy"]),
3783
+ charge_type: ChargeTypeToJSON2(value["chargeType"]),
3784
+ compatible_plan_ids: value["compatiblePlanIds"],
3785
+ currency_prices: value["currencyPrices"].map(
3786
+ CatalogCurrencyPricesResponseDataToJSON2
3787
+ ),
3788
+ description: value["description"],
3789
+ entitlements: value["entitlements"].map(
3790
+ CatalogPlanEntitlementResponseDataToJSON2
3791
+ ),
3792
+ icon: value["icon"],
3793
+ id: value["id"],
3794
+ included_credit_grants: value["includedCreditGrants"].map(
3795
+ CatalogCreditGrantResponseDataToJSON2
3796
+ ),
3797
+ is_trialable: value["isTrialable"],
3798
+ monthly_price: CatalogPriceResponseDataToJSON2(value["monthlyPrice"]),
3799
+ name: value["name"],
3800
+ one_time_price: CatalogPriceResponseDataToJSON2(value["oneTimePrice"]),
3801
+ quarterly_price: CatalogPriceResponseDataToJSON2(value["quarterlyPrice"]),
3802
+ trial_days: value["trialDays"],
3803
+ yearly_price: CatalogPriceResponseDataToJSON2(value["yearlyPrice"])
3804
+ };
3805
+ }
3691
3806
  var CheckoutChargeTiming = {
3692
3807
  AtRenewal: "at_renewal",
3693
3808
  None: "none",
@@ -6602,6 +6717,127 @@ function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator
6602
6717
  params: value["params"]
6603
6718
  };
6604
6719
  }
6720
+ function instanceOfPublicCatalogResponseData(value) {
6721
+ if (!("addOns" in value) || value["addOns"] === void 0) return false;
6722
+ if (!("capabilities" in value) || value["capabilities"] === void 0)
6723
+ return false;
6724
+ if (!("creditBundles" in value) || value["creditBundles"] === void 0)
6725
+ return false;
6726
+ if (!("defaultCurrency" in value) || value["defaultCurrency"] === void 0)
6727
+ return false;
6728
+ if (!("id" in value) || value["id"] === void 0) return false;
6729
+ if (!("name" in value) || value["name"] === void 0) return false;
6730
+ if (!("plans" in value) || value["plans"] === void 0) return false;
6731
+ return true;
6732
+ }
6733
+ function PublicCatalogResponseDataFromJSON2(json) {
6734
+ return PublicCatalogResponseDataFromJSONTyped3(json, false);
6735
+ }
6736
+ function PublicCatalogResponseDataFromJSONTyped3(json, ignoreDiscriminator) {
6737
+ if (json == null) {
6738
+ return json;
6739
+ }
6740
+ return {
6741
+ addOns: json["add_ons"].map(
6742
+ CatalogPlanResponseDataFromJSON2
6743
+ ),
6744
+ capabilities: CatalogCapabilitiesResponseDataFromJSON2(json["capabilities"]),
6745
+ creditBundles: json["credit_bundles"].map(
6746
+ CatalogCreditBundleResponseDataFromJSON2
6747
+ ),
6748
+ customPlanCta: json["custom_plan_cta"] == null ? void 0 : CatalogCustomPlanCTAResponseDataFromJSON2(json["custom_plan_cta"]),
6749
+ defaultCurrency: CurrencyFromJSON2(json["default_currency"]),
6750
+ description: json["description"] == null ? void 0 : json["description"],
6751
+ id: json["id"],
6752
+ name: json["name"],
6753
+ plans: json["plans"].map(CatalogPlanResponseDataFromJSON2),
6754
+ pricingModel: json["pricing_model"] == null ? void 0 : json["pricing_model"],
6755
+ pricingUrl: json["pricing_url"] == null ? void 0 : json["pricing_url"]
6756
+ };
6757
+ }
6758
+ function PublicCatalogResponseDataToJSON2(json) {
6759
+ return PublicCatalogResponseDataToJSONTyped3(json, false);
6760
+ }
6761
+ function PublicCatalogResponseDataToJSONTyped3(value, ignoreDiscriminator = false) {
6762
+ if (value == null) {
6763
+ return value;
6764
+ }
6765
+ return {
6766
+ add_ons: value["addOns"].map(CatalogPlanResponseDataToJSON2),
6767
+ capabilities: CatalogCapabilitiesResponseDataToJSON2(value["capabilities"]),
6768
+ credit_bundles: value["creditBundles"].map(
6769
+ CatalogCreditBundleResponseDataToJSON2
6770
+ ),
6771
+ custom_plan_cta: CatalogCustomPlanCTAResponseDataToJSON2(
6772
+ value["customPlanCta"]
6773
+ ),
6774
+ default_currency: CurrencyToJSON2(value["defaultCurrency"]),
6775
+ description: value["description"],
6776
+ id: value["id"],
6777
+ name: value["name"],
6778
+ plans: value["plans"].map(CatalogPlanResponseDataToJSON2),
6779
+ pricing_model: value["pricingModel"],
6780
+ pricing_url: value["pricingUrl"]
6781
+ };
6782
+ }
6783
+ function instanceOfGetPublicCatalogByIDResponse(value) {
6784
+ if (!("data" in value) || value["data"] === void 0) return false;
6785
+ if (!("params" in value) || value["params"] === void 0) return false;
6786
+ return true;
6787
+ }
6788
+ function GetPublicCatalogByIDResponseFromJSON(json) {
6789
+ return GetPublicCatalogByIDResponseFromJSONTyped(json, false);
6790
+ }
6791
+ function GetPublicCatalogByIDResponseFromJSONTyped(json, ignoreDiscriminator) {
6792
+ if (json == null) {
6793
+ return json;
6794
+ }
6795
+ return {
6796
+ data: PublicCatalogResponseDataFromJSON2(json["data"]),
6797
+ params: json["params"]
6798
+ };
6799
+ }
6800
+ function GetPublicCatalogByIDResponseToJSON(json) {
6801
+ return GetPublicCatalogByIDResponseToJSONTyped(json, false);
6802
+ }
6803
+ function GetPublicCatalogByIDResponseToJSONTyped(value, ignoreDiscriminator = false) {
6804
+ if (value == null) {
6805
+ return value;
6806
+ }
6807
+ return {
6808
+ data: PublicCatalogResponseDataToJSON2(value["data"]),
6809
+ params: value["params"]
6810
+ };
6811
+ }
6812
+ function instanceOfGetPublicCatalogResponse(value) {
6813
+ if (!("data" in value) || value["data"] === void 0) return false;
6814
+ if (!("params" in value) || value["params"] === void 0) return false;
6815
+ return true;
6816
+ }
6817
+ function GetPublicCatalogResponseFromJSON(json) {
6818
+ return GetPublicCatalogResponseFromJSONTyped(json, false);
6819
+ }
6820
+ function GetPublicCatalogResponseFromJSONTyped(json, ignoreDiscriminator) {
6821
+ if (json == null) {
6822
+ return json;
6823
+ }
6824
+ return {
6825
+ data: PublicCatalogResponseDataFromJSON2(json["data"]),
6826
+ params: json["params"]
6827
+ };
6828
+ }
6829
+ function GetPublicCatalogResponseToJSON(json) {
6830
+ return GetPublicCatalogResponseToJSONTyped(json, false);
6831
+ }
6832
+ function GetPublicCatalogResponseToJSONTyped(value, ignoreDiscriminator = false) {
6833
+ if (value == null) {
6834
+ return value;
6835
+ }
6836
+ return {
6837
+ data: PublicCatalogResponseDataToJSON2(value["data"]),
6838
+ params: value["params"]
6839
+ };
6840
+ }
6605
6841
  function instanceOfListCheckoutsParams(value) {
6606
6842
  return true;
6607
6843
  }
@@ -7077,6 +7313,7 @@ var SchematicSession = class {
7077
7313
  _apiUrl;
7078
7314
  _headers;
7079
7315
  _fetch;
7316
+ _publishableKey;
7080
7317
  _session;
7081
7318
  _tokens = /* @__PURE__ */ new Map();
7082
7319
  _resolving = /* @__PURE__ */ new Map();
@@ -7089,6 +7326,7 @@ var SchematicSession = class {
7089
7326
  _listeners = /* @__PURE__ */ new Set();
7090
7327
  constructor(options = {}) {
7091
7328
  this._session = options.session;
7329
+ this._publishableKey = options.publishableKey;
7092
7330
  this._apiUrl = (options.apiUrl ?? DEFAULT_API_URL).replace(/\/$/, "");
7093
7331
  this._headers = options.additionalHeaders ?? {};
7094
7332
  this._fetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
@@ -7096,6 +7334,9 @@ var SchematicSession = class {
7096
7334
  get key() {
7097
7335
  return this._session === null || this._session === void 0 ? void 0 : sessionKey(this._session);
7098
7336
  }
7337
+ get hasPublishableKey() {
7338
+ return this._publishableKey !== void 0;
7339
+ }
7099
7340
  get status() {
7100
7341
  if (this._session === void 0) {
7101
7342
  return "pending";
@@ -7214,6 +7455,30 @@ var SchematicSession = class {
7214
7455
  async request(path, options = {}) {
7215
7456
  return (await this.requestWithResponse(path, options)).body;
7216
7457
  }
7458
+ /**
7459
+ * A read under the publishable key, whatever the session. Nothing is
7460
+ * refreshed or retried, since the key does not expire, and a session
7461
+ * changing mid-flight does not void the answer: it is the same for
7462
+ * everyone.
7463
+ */
7464
+ async requestPublic(path) {
7465
+ if (this._publishableKey === void 0) {
7466
+ throw new Error("A publishable key is required to read public data.");
7467
+ }
7468
+ const response = await this._fetch(`${this._apiUrl}${path}`, {
7469
+ method: "GET",
7470
+ headers: {
7471
+ "Accept": "application/json",
7472
+ ...this._headers,
7473
+ "X-Schematic-Api-Key": this._publishableKey
7474
+ }
7475
+ });
7476
+ const parsed = await readBody(response);
7477
+ if (!response.ok) {
7478
+ throw new SchematicApiError(response.status, path, parsed);
7479
+ }
7480
+ return parsed;
7481
+ }
7217
7482
  /**
7218
7483
  * `request`, with the headers the answer came back with — for a resource
7219
7484
  * whose protocol rides beside the body, as a checkout's session does.
@@ -7394,6 +7659,8 @@ var CheckoutDraft = class {
7394
7659
  /** Bumped by reset, so an answer for a discarded draft lands nowhere. */
7395
7660
  generation = 0;
7396
7661
  inFlight;
7662
+ /** The read of a resumed checkout, while one is out. */
7663
+ loading;
7397
7664
  queued;
7398
7665
  constructor(transport, options = {}) {
7399
7666
  this.transport = transport;
@@ -7419,10 +7686,19 @@ var CheckoutDraft = class {
7419
7686
  }
7420
7687
  /**
7421
7688
  * Reads the checkout this draft was opened on, for a resume. A draft with
7422
- * no checkout yet has nothing to read.
7689
+ * no checkout yet has nothing to read. A call while a read is out shares
7690
+ * its answer.
7423
7691
  */
7424
7692
  load() {
7425
- return this.refresh(this.generation);
7693
+ if (this.loading === void 0) {
7694
+ const generation = this.generation;
7695
+ this.loading = this.refresh(generation).finally(() => {
7696
+ if (generation === this.generation) {
7697
+ this.loading = void 0;
7698
+ }
7699
+ });
7700
+ }
7701
+ return this.loading;
7426
7702
  }
7427
7703
  /**
7428
7704
  * Replaces the cart and re-prices it. Resolves with the checkout the write
@@ -7455,11 +7731,12 @@ var CheckoutDraft = class {
7455
7731
  if (generation !== this.generation) {
7456
7732
  throw new Error("The checkout was reset before it was finalized.");
7457
7733
  }
7458
- if (this.checkoutId === void 0 || this.version === void 0) {
7734
+ if (this.checkoutId === void 0) {
7459
7735
  throw new Error("There is no checkout to finalize yet.");
7460
7736
  }
7461
7737
  this.update({ isFinalizing: true, error: void 0 });
7462
7738
  try {
7739
+ await this.readResumed(generation);
7463
7740
  const result = await this.finalizeOnce(generation, true);
7464
7741
  if (generation === this.generation) {
7465
7742
  this.update({ isFinalizing: false, result });
@@ -7487,6 +7764,7 @@ var CheckoutDraft = class {
7487
7764
  const queued = this.queued;
7488
7765
  this.queued = void 0;
7489
7766
  this.inFlight = void 0;
7767
+ this.loading = void 0;
7490
7768
  queued?.waiters.forEach((w) => w.resolve(void 0));
7491
7769
  this.update({ ...INITIAL_STATE });
7492
7770
  }
@@ -7536,6 +7814,7 @@ var CheckoutDraft = class {
7536
7814
  });
7537
7815
  }
7538
7816
  async write(generation, selections) {
7817
+ await this.readResumed(generation);
7539
7818
  let written;
7540
7819
  if (this.checkoutId === void 0 || this.version === void 0) {
7541
7820
  written = await this.transport.createCheckout(selections);
@@ -7597,6 +7876,20 @@ var CheckoutDraft = class {
7597
7876
  return this.finalizeOnce(generation, false);
7598
7877
  }
7599
7878
  }
7879
+ /**
7880
+ * A resumed checkout is read before it is written or finalized: a write
7881
+ * ahead of the read would open a second checkout beside it, and the read's
7882
+ * answer would then point the draft back at the first.
7883
+ */
7884
+ async readResumed(generation) {
7885
+ if (this.checkoutId === void 0 || this.version !== void 0) {
7886
+ return;
7887
+ }
7888
+ await this.load();
7889
+ if (generation !== this.generation) {
7890
+ throw new Error("The checkout was reset before it was read.");
7891
+ }
7892
+ }
7600
7893
  async refresh(generation) {
7601
7894
  if (this.checkoutId === void 0) {
7602
7895
  return void 0;
@@ -7647,6 +7940,9 @@ var SchematicBillingClient = class {
7647
7940
  get sessionStatus() {
7648
7941
  return this.session.status;
7649
7942
  }
7943
+ get hasPublishableKey() {
7944
+ return this.session.hasPublishableKey;
7945
+ }
7650
7946
  setSession(session) {
7651
7947
  this.session.set(session);
7652
7948
  }
@@ -7657,6 +7953,10 @@ var SchematicBillingClient = class {
7657
7953
  const path = query.catalogId === void 0 ? "/catalog/view" : `/catalogs/${encodeURIComponent(query.catalogId)}/view`;
7658
7954
  return this.session.request(path).then((body) => CompanyCatalogResponseDataFromJSON(dataOf(body, path)));
7659
7955
  }
7956
+ fetchPublicCatalog(query = {}) {
7957
+ const path = query.catalogId === void 0 ? "/public/catalog" : `/public/catalogs/${encodeURIComponent(query.catalogId)}`;
7958
+ return this.session.requestPublic(path).then((body) => PublicCatalogResponseDataFromJSON2(dataOf(body, path)));
7959
+ }
7660
7960
  createCheckout(selections) {
7661
7961
  return this.checkoutWrite("/checkouts", {
7662
7962
  method: "POST",
@@ -8058,6 +8358,10 @@ var Schematic = class {
8058
8358
  get additionalHeaders() {
8059
8359
  return { ...this._additionalHeaders };
8060
8360
  }
8361
+ /** The key flags are read with, for a billing client reading beside it. */
8362
+ get publishableKey() {
8363
+ return this.apiKey;
8364
+ }
8061
8365
  /**
8062
8366
  * Resolve fallback value according to priority order:
8063
8367
  * 1. Callsite fallback value (if provided)
@@ -10096,6 +10400,27 @@ var BillingStore = class {
10096
10400
  (query) => this._client.fetchCatalog(query),
10097
10401
  { readiness }
10098
10402
  );
10403
+ this.publicCatalog = new KeyedResource(
10404
+ (query) => this._client.fetchPublicCatalog?.(query) ?? Promise.reject(
10405
+ new Error("The billing client cannot read public data.")
10406
+ ),
10407
+ {
10408
+ readiness: () => {
10409
+ if (!this._connected) {
10410
+ return "waiting";
10411
+ }
10412
+ return this._client.hasPublishableKey === true && this._client.fetchPublicCatalog !== void 0 ? "ready" : "never";
10413
+ }
10414
+ }
10415
+ );
10416
+ if (initialData.publicCatalog !== void 0) {
10417
+ this.publicCatalog.seed(
10418
+ normalizeCatalogQuery2(
10419
+ initialData.params?.publicCatalog ?? DEFAULT_CATALOG_QUERY
10420
+ ),
10421
+ initialData.publicCatalog
10422
+ );
10423
+ }
10099
10424
  this.invoices = new KeyedResource(
10100
10425
  (query, current) => this._reloadWindow(
10101
10426
  query,
@@ -10183,6 +10508,7 @@ var BillingStore = class {
10183
10508
  }
10184
10509
  _client;
10185
10510
  catalog;
10511
+ publicCatalog;
10186
10512
  invoices;
10187
10513
  upcomingInvoice;
10188
10514
  paymentMethods;
@@ -10230,6 +10556,7 @@ var BillingStore = class {
10230
10556
  this._connected = true;
10231
10557
  this._settleSeed(claimOf(this._client));
10232
10558
  this.resumeAll();
10559
+ this.publicCatalog.resumeAll();
10233
10560
  }
10234
10561
  return () => {
10235
10562
  unsubscribe?.();
@@ -10289,6 +10616,15 @@ var BillingStore = class {
10289
10616
  this._seeded = true;
10290
10617
  }
10291
10618
  }
10619
+ /**
10620
+ * The company's view once someone is signed in; the public catalog until
10621
+ * then, where the client has a key to read it with. A session still
10622
+ * pending reads the public one too: a page that never states a session
10623
+ * would otherwise wait on one for good.
10624
+ */
10625
+ catalogSource() {
10626
+ return this._client.sessionStatus !== "active" && this._client.hasPublishableKey === true ? "public" : "company";
10627
+ }
10292
10628
  resource(name) {
10293
10629
  return this[name];
10294
10630
  }
@@ -10529,6 +10865,9 @@ function useSchematicStrings() {
10529
10865
 
10530
10866
  // src/billing/context.tsx
10531
10867
  var import_jsx_runtime2 = require("react/jsx-runtime");
10868
+ function catalogSourceOf(data) {
10869
+ return data.catalog === void 0 && data.publicCatalog !== void 0 ? "public" : "company";
10870
+ }
10532
10871
  var BillingDataContext = (0, import_react2.createContext)(
10533
10872
  void 0
10534
10873
  );
@@ -10668,7 +11007,8 @@ function BillingDataProvider({
10668
11007
  return Promise.resolve();
10669
11008
  },
10670
11009
  invalidateAll: () => {
10671
- }
11010
+ },
11011
+ catalogSource: () => catalogSourceOf(data)
10672
11012
  };
10673
11013
  }, [
10674
11014
  actions,
@@ -10714,10 +11054,30 @@ function useBillingResource(name, params) {
10714
11054
  return (0, import_react3.useSyncExternalStore)(subscribe, getSnapshot, getSnapshot);
10715
11055
  }
10716
11056
  function useCatalog(query = DEFAULT_CATALOG_QUERY) {
10717
- return useBillingResource(
10718
- "catalog",
10719
- useStableParams(normalizeCatalogQuery2(query))
11057
+ const source = useBillingDataSource();
11058
+ const params = useStableParams(normalizeCatalogQuery2(query));
11059
+ const subscribeSource = (0, import_react3.useCallback)(
11060
+ (listener) => source.onSessionChange?.(() => listener()) ?? (() => {
11061
+ }),
11062
+ [source]
11063
+ );
11064
+ const readSource = (0, import_react3.useCallback)(
11065
+ () => source.catalogSource?.() ?? "company",
11066
+ [source]
10720
11067
  );
11068
+ const which = (0, import_react3.useSyncExternalStore)(subscribeSource, readSource, readSource);
11069
+ const handle = useBillingResource(
11070
+ which === "public" ? "publicCatalog" : "catalog",
11071
+ params
11072
+ );
11073
+ return (0, import_react3.useMemo)(() => {
11074
+ const { data } = handle;
11075
+ let view;
11076
+ if (data !== void 0) {
11077
+ view = which === "public" ? { source: "public", catalog: data } : { source: "company", catalog: data };
11078
+ }
11079
+ return { ...handle, data: view };
11080
+ }, [handle, which]);
10721
11081
  }
10722
11082
  function useInvoices(query = DEFAULT_INVOICE_QUERY) {
10723
11083
  const source = useBillingDataSource();
@@ -11001,7 +11361,8 @@ function BillingProvider({
11001
11361
  updateCheckout: (id, version3, selections) => store.updateCheckout(id, version3, selections),
11002
11362
  finalizeCheckout: (id, version3, options) => store.finalizeCheckout(id, version3, options)
11003
11363
  },
11004
- onSessionChange: (listener) => store.onSessionChange(listener)
11364
+ onSessionChange: (listener) => store.onSessionChange(listener),
11365
+ catalogSource: () => store.catalogSource()
11005
11366
  };
11006
11367
  }, [store]);
11007
11368
  const localized = /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
@@ -11062,12 +11423,13 @@ function staticSource(data) {
11062
11423
  },
11063
11424
  loadMoreInvoices: () => Promise.resolve(),
11064
11425
  invalidateAll: () => {
11065
- }
11426
+ },
11427
+ catalogSource: () => catalogSourceOf(data)
11066
11428
  };
11067
11429
  }
11068
11430
 
11069
11431
  // src/version.ts
11070
- var version2 = "1.15.0";
11432
+ var version2 = "1.16.1";
11071
11433
 
11072
11434
  // src/context/schematic.tsx
11073
11435
  var import_jsx_runtime4 = require("react/jsx-runtime");
@@ -11120,9 +11482,11 @@ var SchematicProvider = ({
11120
11482
  );
11121
11483
  const { apiUrl, additionalHeaders } = initialOptsRef.current;
11122
11484
  const providedApiUrl = providedClient?.apiUrl;
11485
+ const resolvedPublishableKey = initialOptsRef.current.publishableKey ?? providedClient?.publishableKey;
11123
11486
  const resolvedBillingClient = (0, import_react5.useMemo)(
11124
11487
  () => billingClient ?? new SchematicBillingClient({
11125
11488
  session,
11489
+ publishableKey: resolvedPublishableKey,
11126
11490
  apiUrl: apiUrl ?? providedApiUrl,
11127
11491
  // Read as they stand when a client is built: headers do not change
11128
11492
  // where the token goes, so they are no reason to build one.
@@ -11134,7 +11498,13 @@ var SchematicProvider = ({
11134
11498
  // `session` is deliberately absent: `BillingProvider` forwards it through
11135
11499
  // `setSession`, so a token change resets the billing resources without
11136
11500
  // rebuilding the client.
11137
- [additionalHeaders, apiUrl, billingClient, providedApiUrl]
11501
+ [
11502
+ additionalHeaders,
11503
+ apiUrl,
11504
+ billingClient,
11505
+ providedApiUrl,
11506
+ resolvedPublishableKey
11507
+ ]
11138
11508
  );
11139
11509
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SchematicContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
11140
11510
  BillingProvider,