@schematichq/schematic-react 1.15.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- // node_modules/.pnpm/@schematichq+schematic-js@1.15.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
1
+ // node_modules/.pnpm/@schematichq+schematic-js@1.16.0/node_modules/@schematichq/schematic-js/dist/schematic.esm.js
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1329,7 +1329,7 @@ var ContextSignatureManager = class {
1329
1329
  }
1330
1330
  }
1331
1331
  };
1332
- var version = "1.15.0";
1332
+ var version = "1.16.0";
1333
1333
  var DEFAULT_CATALOG_QUERY = {};
1334
1334
  function normalizeCatalogQuery(query) {
1335
1335
  return query.catalogId === void 0 ? {} : { catalogId: query.catalogId };
@@ -1448,6 +1448,10 @@ __export(models_exports, {
1448
1448
  CatalogPlanRefResponseDataFromJSONTyped: () => CatalogPlanRefResponseDataFromJSONTyped,
1449
1449
  CatalogPlanRefResponseDataToJSON: () => CatalogPlanRefResponseDataToJSON,
1450
1450
  CatalogPlanRefResponseDataToJSONTyped: () => CatalogPlanRefResponseDataToJSONTyped,
1451
+ CatalogPlanResponseDataFromJSON: () => CatalogPlanResponseDataFromJSON2,
1452
+ CatalogPlanResponseDataFromJSONTyped: () => CatalogPlanResponseDataFromJSONTyped2,
1453
+ CatalogPlanResponseDataToJSON: () => CatalogPlanResponseDataToJSON2,
1454
+ CatalogPlanResponseDataToJSONTyped: () => CatalogPlanResponseDataToJSONTyped2,
1451
1455
  CatalogPriceResponseDataFromJSON: () => CatalogPriceResponseDataFromJSON2,
1452
1456
  CatalogPriceResponseDataFromJSONTyped: () => CatalogPriceResponseDataFromJSONTyped7,
1453
1457
  CatalogPriceResponseDataToJSON: () => CatalogPriceResponseDataToJSON2,
@@ -1754,6 +1758,14 @@ __export(models_exports, {
1754
1758
  GetCompanyUpcomingInvoiceResponseFromJSONTyped: () => GetCompanyUpcomingInvoiceResponseFromJSONTyped,
1755
1759
  GetCompanyUpcomingInvoiceResponseToJSON: () => GetCompanyUpcomingInvoiceResponseToJSON,
1756
1760
  GetCompanyUpcomingInvoiceResponseToJSONTyped: () => GetCompanyUpcomingInvoiceResponseToJSONTyped,
1761
+ GetPublicCatalogByIDResponseFromJSON: () => GetPublicCatalogByIDResponseFromJSON,
1762
+ GetPublicCatalogByIDResponseFromJSONTyped: () => GetPublicCatalogByIDResponseFromJSONTyped,
1763
+ GetPublicCatalogByIDResponseToJSON: () => GetPublicCatalogByIDResponseToJSON,
1764
+ GetPublicCatalogByIDResponseToJSONTyped: () => GetPublicCatalogByIDResponseToJSONTyped,
1765
+ GetPublicCatalogResponseFromJSON: () => GetPublicCatalogResponseFromJSON,
1766
+ GetPublicCatalogResponseFromJSONTyped: () => GetPublicCatalogResponseFromJSONTyped,
1767
+ GetPublicCatalogResponseToJSON: () => GetPublicCatalogResponseToJSON,
1768
+ GetPublicCatalogResponseToJSONTyped: () => GetPublicCatalogResponseToJSONTyped,
1757
1769
  InvoiceStatus: () => InvoiceStatus,
1758
1770
  InvoiceStatusFromJSON: () => InvoiceStatusFromJSON,
1759
1771
  InvoiceStatusFromJSONTyped: () => InvoiceStatusFromJSONTyped,
@@ -1801,6 +1813,10 @@ __export(models_exports, {
1801
1813
  ProrationLineKindFromJSONTyped: () => ProrationLineKindFromJSONTyped,
1802
1814
  ProrationLineKindToJSON: () => ProrationLineKindToJSON,
1803
1815
  ProrationLineKindToJSONTyped: () => ProrationLineKindToJSONTyped,
1816
+ PublicCatalogResponseDataFromJSON: () => PublicCatalogResponseDataFromJSON2,
1817
+ PublicCatalogResponseDataFromJSONTyped: () => PublicCatalogResponseDataFromJSONTyped3,
1818
+ PublicCatalogResponseDataToJSON: () => PublicCatalogResponseDataToJSON2,
1819
+ PublicCatalogResponseDataToJSONTyped: () => PublicCatalogResponseDataToJSONTyped3,
1804
1820
  ScheduledDowngradeConfigBehavior: () => ScheduledDowngradeConfigBehavior,
1805
1821
  ScheduledDowngradeConfigBehaviorFromJSON: () => ScheduledDowngradeConfigBehaviorFromJSON,
1806
1822
  ScheduledDowngradeConfigBehaviorFromJSONTyped: () => ScheduledDowngradeConfigBehaviorFromJSONTyped,
@@ -1888,6 +1904,7 @@ __export(models_exports, {
1888
1904
  instanceOfCatalogCustomPlanCTAResponseData: () => instanceOfCatalogCustomPlanCTAResponseData,
1889
1905
  instanceOfCatalogPlanEntitlementResponseData: () => instanceOfCatalogPlanEntitlementResponseData,
1890
1906
  instanceOfCatalogPlanRefResponseData: () => instanceOfCatalogPlanRefResponseData,
1907
+ instanceOfCatalogPlanResponseData: () => instanceOfCatalogPlanResponseData,
1891
1908
  instanceOfCatalogPriceResponseData: () => instanceOfCatalogPriceResponseData,
1892
1909
  instanceOfCatalogPriceTierResponseData: () => instanceOfCatalogPriceTierResponseData,
1893
1910
  instanceOfCatalogUsageViolationResponseData: () => instanceOfCatalogUsageViolationResponseData,
@@ -1961,6 +1978,8 @@ __export(models_exports, {
1961
1978
  instanceOfGetCompanyPaymentMethodsResponse: () => instanceOfGetCompanyPaymentMethodsResponse,
1962
1979
  instanceOfGetCompanyResponse: () => instanceOfGetCompanyResponse,
1963
1980
  instanceOfGetCompanyUpcomingInvoiceResponse: () => instanceOfGetCompanyUpcomingInvoiceResponse,
1981
+ instanceOfGetPublicCatalogByIDResponse: () => instanceOfGetPublicCatalogByIDResponse,
1982
+ instanceOfGetPublicCatalogResponse: () => instanceOfGetPublicCatalogResponse,
1964
1983
  instanceOfInvoiceStatus: () => instanceOfInvoiceStatus,
1965
1984
  instanceOfListCheckoutsParams: () => instanceOfListCheckoutsParams,
1966
1985
  instanceOfListCheckoutsResponse: () => instanceOfListCheckoutsResponse,
@@ -1971,6 +1990,7 @@ __export(models_exports, {
1971
1990
  instanceOfPlanPriceCadence: () => instanceOfPlanPriceCadence,
1972
1991
  instanceOfProrationBehavior: () => instanceOfProrationBehavior,
1973
1992
  instanceOfProrationLineKind: () => instanceOfProrationLineKind,
1993
+ instanceOfPublicCatalogResponseData: () => instanceOfPublicCatalogResponseData,
1974
1994
  instanceOfScheduledDowngradeConfigBehavior: () => instanceOfScheduledDowngradeConfigBehavior,
1975
1995
  instanceOfSetupIntentResponseData: () => instanceOfSetupIntentResponseData,
1976
1996
  instanceOfTaxIDInput: () => instanceOfTaxIDInput,
@@ -3281,6 +3301,7 @@ function instanceOfCatalogCreditGrantResponseData(value) {
3281
3301
  return false;
3282
3302
  if (!("id" in value) || value["id"] === void 0) return false;
3283
3303
  if (!("scaling" in value) || value["scaling"] === void 0) return false;
3304
+ if (!("visible" in value) || value["visible"] === void 0) return false;
3284
3305
  return true;
3285
3306
  }
3286
3307
  function CatalogCreditGrantResponseDataFromJSON2(json) {
@@ -3301,7 +3322,8 @@ function CatalogCreditGrantResponseDataFromJSONTyped2(json, ignoreDiscriminator)
3301
3322
  id: json["id"],
3302
3323
  licenseId: json["license_id"] == null ? void 0 : json["license_id"],
3303
3324
  resetCadence: json["reset_cadence"] == null ? void 0 : BillingPlanCreditGrantResetCadenceFromJSON2(json["reset_cadence"]),
3304
- scaling: PlanCreditGrantScalingFromJSON2(json["scaling"])
3325
+ scaling: PlanCreditGrantScalingFromJSON2(json["scaling"]),
3326
+ visible: json["visible"]
3305
3327
  };
3306
3328
  }
3307
3329
  function CatalogCreditGrantResponseDataToJSON2(json) {
@@ -3324,7 +3346,8 @@ function CatalogCreditGrantResponseDataToJSONTyped2(value, ignoreDiscriminator =
3324
3346
  reset_cadence: BillingPlanCreditGrantResetCadenceToJSON2(
3325
3347
  value["resetCadence"]
3326
3348
  ),
3327
- scaling: PlanCreditGrantScalingToJSON2(value["scaling"])
3349
+ scaling: PlanCreditGrantScalingToJSON2(value["scaling"]),
3350
+ visible: value["visible"]
3328
3351
  };
3329
3352
  }
3330
3353
  var PlanPriceCadence = {
@@ -3604,6 +3627,98 @@ function CatalogPlanRefResponseDataToJSONTyped(value, ignoreDiscriminator = fals
3604
3627
  name: value["name"]
3605
3628
  };
3606
3629
  }
3630
+ function instanceOfCatalogPlanResponseData(value) {
3631
+ if (!("availablePeriods" in value) || value["availablePeriods"] === void 0)
3632
+ return false;
3633
+ if (!("billingStrategy" in value) || value["billingStrategy"] === void 0)
3634
+ return false;
3635
+ if (!("chargeType" in value) || value["chargeType"] === void 0)
3636
+ return false;
3637
+ if (!("currencyPrices" in value) || value["currencyPrices"] === void 0)
3638
+ return false;
3639
+ if (!("description" in value) || value["description"] === void 0)
3640
+ return false;
3641
+ if (!("entitlements" in value) || value["entitlements"] === void 0)
3642
+ return false;
3643
+ if (!("icon" in value) || value["icon"] === void 0) return false;
3644
+ if (!("id" in value) || value["id"] === void 0) return false;
3645
+ if (!("includedCreditGrants" in value) || value["includedCreditGrants"] === void 0)
3646
+ return false;
3647
+ if (!("isTrialable" in value) || value["isTrialable"] === void 0)
3648
+ return false;
3649
+ if (!("name" in value) || value["name"] === void 0) return false;
3650
+ return true;
3651
+ }
3652
+ function CatalogPlanResponseDataFromJSON2(json) {
3653
+ return CatalogPlanResponseDataFromJSONTyped2(json, false);
3654
+ }
3655
+ function CatalogPlanResponseDataFromJSONTyped2(json, ignoreDiscriminator) {
3656
+ if (json == null) {
3657
+ return json;
3658
+ }
3659
+ return {
3660
+ availablePeriods: json["available_periods"].map(
3661
+ PlanPriceCadenceFromJSON2
3662
+ ),
3663
+ billingStrategy: BillingStrategyFromJSON2(json["billing_strategy"]),
3664
+ chargeType: ChargeTypeFromJSON2(json["charge_type"]),
3665
+ compatiblePlanIds: json["compatible_plan_ids"] == null ? void 0 : json["compatible_plan_ids"],
3666
+ currencyPrices: json["currency_prices"].map(
3667
+ CatalogCurrencyPricesResponseDataFromJSON2
3668
+ ),
3669
+ description: json["description"],
3670
+ entitlements: json["entitlements"].map(
3671
+ CatalogPlanEntitlementResponseDataFromJSON2
3672
+ ),
3673
+ icon: json["icon"],
3674
+ id: json["id"],
3675
+ includedCreditGrants: json["included_credit_grants"].map(
3676
+ CatalogCreditGrantResponseDataFromJSON2
3677
+ ),
3678
+ isTrialable: json["is_trialable"],
3679
+ monthlyPrice: json["monthly_price"] == null ? void 0 : CatalogPriceResponseDataFromJSON2(json["monthly_price"]),
3680
+ name: json["name"],
3681
+ oneTimePrice: json["one_time_price"] == null ? void 0 : CatalogPriceResponseDataFromJSON2(json["one_time_price"]),
3682
+ quarterlyPrice: json["quarterly_price"] == null ? void 0 : CatalogPriceResponseDataFromJSON2(json["quarterly_price"]),
3683
+ trialDays: json["trial_days"] == null ? void 0 : json["trial_days"],
3684
+ yearlyPrice: json["yearly_price"] == null ? void 0 : CatalogPriceResponseDataFromJSON2(json["yearly_price"])
3685
+ };
3686
+ }
3687
+ function CatalogPlanResponseDataToJSON2(json) {
3688
+ return CatalogPlanResponseDataToJSONTyped2(json, false);
3689
+ }
3690
+ function CatalogPlanResponseDataToJSONTyped2(value, ignoreDiscriminator = false) {
3691
+ if (value == null) {
3692
+ return value;
3693
+ }
3694
+ return {
3695
+ available_periods: value["availablePeriods"].map(
3696
+ PlanPriceCadenceToJSON2
3697
+ ),
3698
+ billing_strategy: BillingStrategyToJSON2(value["billingStrategy"]),
3699
+ charge_type: ChargeTypeToJSON2(value["chargeType"]),
3700
+ compatible_plan_ids: value["compatiblePlanIds"],
3701
+ currency_prices: value["currencyPrices"].map(
3702
+ CatalogCurrencyPricesResponseDataToJSON2
3703
+ ),
3704
+ description: value["description"],
3705
+ entitlements: value["entitlements"].map(
3706
+ CatalogPlanEntitlementResponseDataToJSON2
3707
+ ),
3708
+ icon: value["icon"],
3709
+ id: value["id"],
3710
+ included_credit_grants: value["includedCreditGrants"].map(
3711
+ CatalogCreditGrantResponseDataToJSON2
3712
+ ),
3713
+ is_trialable: value["isTrialable"],
3714
+ monthly_price: CatalogPriceResponseDataToJSON2(value["monthlyPrice"]),
3715
+ name: value["name"],
3716
+ one_time_price: CatalogPriceResponseDataToJSON2(value["oneTimePrice"]),
3717
+ quarterly_price: CatalogPriceResponseDataToJSON2(value["quarterlyPrice"]),
3718
+ trial_days: value["trialDays"],
3719
+ yearly_price: CatalogPriceResponseDataToJSON2(value["yearlyPrice"])
3720
+ };
3721
+ }
3607
3722
  var CheckoutChargeTiming = {
3608
3723
  AtRenewal: "at_renewal",
3609
3724
  None: "none",
@@ -6518,6 +6633,127 @@ function GetCompanyUpcomingInvoiceResponseToJSONTyped(value, ignoreDiscriminator
6518
6633
  params: value["params"]
6519
6634
  };
6520
6635
  }
6636
+ function instanceOfPublicCatalogResponseData(value) {
6637
+ if (!("addOns" in value) || value["addOns"] === void 0) return false;
6638
+ if (!("capabilities" in value) || value["capabilities"] === void 0)
6639
+ return false;
6640
+ if (!("creditBundles" in value) || value["creditBundles"] === void 0)
6641
+ return false;
6642
+ if (!("defaultCurrency" in value) || value["defaultCurrency"] === void 0)
6643
+ return false;
6644
+ if (!("id" in value) || value["id"] === void 0) return false;
6645
+ if (!("name" in value) || value["name"] === void 0) return false;
6646
+ if (!("plans" in value) || value["plans"] === void 0) return false;
6647
+ return true;
6648
+ }
6649
+ function PublicCatalogResponseDataFromJSON2(json) {
6650
+ return PublicCatalogResponseDataFromJSONTyped3(json, false);
6651
+ }
6652
+ function PublicCatalogResponseDataFromJSONTyped3(json, ignoreDiscriminator) {
6653
+ if (json == null) {
6654
+ return json;
6655
+ }
6656
+ return {
6657
+ addOns: json["add_ons"].map(
6658
+ CatalogPlanResponseDataFromJSON2
6659
+ ),
6660
+ capabilities: CatalogCapabilitiesResponseDataFromJSON2(json["capabilities"]),
6661
+ creditBundles: json["credit_bundles"].map(
6662
+ CatalogCreditBundleResponseDataFromJSON2
6663
+ ),
6664
+ customPlanCta: json["custom_plan_cta"] == null ? void 0 : CatalogCustomPlanCTAResponseDataFromJSON2(json["custom_plan_cta"]),
6665
+ defaultCurrency: CurrencyFromJSON2(json["default_currency"]),
6666
+ description: json["description"] == null ? void 0 : json["description"],
6667
+ id: json["id"],
6668
+ name: json["name"],
6669
+ plans: json["plans"].map(CatalogPlanResponseDataFromJSON2),
6670
+ pricingModel: json["pricing_model"] == null ? void 0 : json["pricing_model"],
6671
+ pricingUrl: json["pricing_url"] == null ? void 0 : json["pricing_url"]
6672
+ };
6673
+ }
6674
+ function PublicCatalogResponseDataToJSON2(json) {
6675
+ return PublicCatalogResponseDataToJSONTyped3(json, false);
6676
+ }
6677
+ function PublicCatalogResponseDataToJSONTyped3(value, ignoreDiscriminator = false) {
6678
+ if (value == null) {
6679
+ return value;
6680
+ }
6681
+ return {
6682
+ add_ons: value["addOns"].map(CatalogPlanResponseDataToJSON2),
6683
+ capabilities: CatalogCapabilitiesResponseDataToJSON2(value["capabilities"]),
6684
+ credit_bundles: value["creditBundles"].map(
6685
+ CatalogCreditBundleResponseDataToJSON2
6686
+ ),
6687
+ custom_plan_cta: CatalogCustomPlanCTAResponseDataToJSON2(
6688
+ value["customPlanCta"]
6689
+ ),
6690
+ default_currency: CurrencyToJSON2(value["defaultCurrency"]),
6691
+ description: value["description"],
6692
+ id: value["id"],
6693
+ name: value["name"],
6694
+ plans: value["plans"].map(CatalogPlanResponseDataToJSON2),
6695
+ pricing_model: value["pricingModel"],
6696
+ pricing_url: value["pricingUrl"]
6697
+ };
6698
+ }
6699
+ function instanceOfGetPublicCatalogByIDResponse(value) {
6700
+ if (!("data" in value) || value["data"] === void 0) return false;
6701
+ if (!("params" in value) || value["params"] === void 0) return false;
6702
+ return true;
6703
+ }
6704
+ function GetPublicCatalogByIDResponseFromJSON(json) {
6705
+ return GetPublicCatalogByIDResponseFromJSONTyped(json, false);
6706
+ }
6707
+ function GetPublicCatalogByIDResponseFromJSONTyped(json, ignoreDiscriminator) {
6708
+ if (json == null) {
6709
+ return json;
6710
+ }
6711
+ return {
6712
+ data: PublicCatalogResponseDataFromJSON2(json["data"]),
6713
+ params: json["params"]
6714
+ };
6715
+ }
6716
+ function GetPublicCatalogByIDResponseToJSON(json) {
6717
+ return GetPublicCatalogByIDResponseToJSONTyped(json, false);
6718
+ }
6719
+ function GetPublicCatalogByIDResponseToJSONTyped(value, ignoreDiscriminator = false) {
6720
+ if (value == null) {
6721
+ return value;
6722
+ }
6723
+ return {
6724
+ data: PublicCatalogResponseDataToJSON2(value["data"]),
6725
+ params: value["params"]
6726
+ };
6727
+ }
6728
+ function instanceOfGetPublicCatalogResponse(value) {
6729
+ if (!("data" in value) || value["data"] === void 0) return false;
6730
+ if (!("params" in value) || value["params"] === void 0) return false;
6731
+ return true;
6732
+ }
6733
+ function GetPublicCatalogResponseFromJSON(json) {
6734
+ return GetPublicCatalogResponseFromJSONTyped(json, false);
6735
+ }
6736
+ function GetPublicCatalogResponseFromJSONTyped(json, ignoreDiscriminator) {
6737
+ if (json == null) {
6738
+ return json;
6739
+ }
6740
+ return {
6741
+ data: PublicCatalogResponseDataFromJSON2(json["data"]),
6742
+ params: json["params"]
6743
+ };
6744
+ }
6745
+ function GetPublicCatalogResponseToJSON(json) {
6746
+ return GetPublicCatalogResponseToJSONTyped(json, false);
6747
+ }
6748
+ function GetPublicCatalogResponseToJSONTyped(value, ignoreDiscriminator = false) {
6749
+ if (value == null) {
6750
+ return value;
6751
+ }
6752
+ return {
6753
+ data: PublicCatalogResponseDataToJSON2(value["data"]),
6754
+ params: value["params"]
6755
+ };
6756
+ }
6521
6757
  function instanceOfListCheckoutsParams(value) {
6522
6758
  return true;
6523
6759
  }
@@ -6993,6 +7229,7 @@ var SchematicSession = class {
6993
7229
  _apiUrl;
6994
7230
  _headers;
6995
7231
  _fetch;
7232
+ _publishableKey;
6996
7233
  _session;
6997
7234
  _tokens = /* @__PURE__ */ new Map();
6998
7235
  _resolving = /* @__PURE__ */ new Map();
@@ -7005,6 +7242,7 @@ var SchematicSession = class {
7005
7242
  _listeners = /* @__PURE__ */ new Set();
7006
7243
  constructor(options = {}) {
7007
7244
  this._session = options.session;
7245
+ this._publishableKey = options.publishableKey;
7008
7246
  this._apiUrl = (options.apiUrl ?? DEFAULT_API_URL).replace(/\/$/, "");
7009
7247
  this._headers = options.additionalHeaders ?? {};
7010
7248
  this._fetch = options.fetch ?? ((input, init) => globalThis.fetch(input, init));
@@ -7012,6 +7250,9 @@ var SchematicSession = class {
7012
7250
  get key() {
7013
7251
  return this._session === null || this._session === void 0 ? void 0 : sessionKey(this._session);
7014
7252
  }
7253
+ get hasPublishableKey() {
7254
+ return this._publishableKey !== void 0;
7255
+ }
7015
7256
  get status() {
7016
7257
  if (this._session === void 0) {
7017
7258
  return "pending";
@@ -7130,6 +7371,30 @@ var SchematicSession = class {
7130
7371
  async request(path, options = {}) {
7131
7372
  return (await this.requestWithResponse(path, options)).body;
7132
7373
  }
7374
+ /**
7375
+ * A read under the publishable key, whatever the session. Nothing is
7376
+ * refreshed or retried, since the key does not expire, and a session
7377
+ * changing mid-flight does not void the answer: it is the same for
7378
+ * everyone.
7379
+ */
7380
+ async requestPublic(path) {
7381
+ if (this._publishableKey === void 0) {
7382
+ throw new Error("A publishable key is required to read public data.");
7383
+ }
7384
+ const response = await this._fetch(`${this._apiUrl}${path}`, {
7385
+ method: "GET",
7386
+ headers: {
7387
+ "Accept": "application/json",
7388
+ ...this._headers,
7389
+ "X-Schematic-Api-Key": this._publishableKey
7390
+ }
7391
+ });
7392
+ const parsed = await readBody(response);
7393
+ if (!response.ok) {
7394
+ throw new SchematicApiError(response.status, path, parsed);
7395
+ }
7396
+ return parsed;
7397
+ }
7133
7398
  /**
7134
7399
  * `request`, with the headers the answer came back with — for a resource
7135
7400
  * whose protocol rides beside the body, as a checkout's session does.
@@ -7563,6 +7828,9 @@ var SchematicBillingClient = class {
7563
7828
  get sessionStatus() {
7564
7829
  return this.session.status;
7565
7830
  }
7831
+ get hasPublishableKey() {
7832
+ return this.session.hasPublishableKey;
7833
+ }
7566
7834
  setSession(session) {
7567
7835
  this.session.set(session);
7568
7836
  }
@@ -7573,6 +7841,10 @@ var SchematicBillingClient = class {
7573
7841
  const path = query.catalogId === void 0 ? "/catalog/view" : `/catalogs/${encodeURIComponent(query.catalogId)}/view`;
7574
7842
  return this.session.request(path).then((body) => CompanyCatalogResponseDataFromJSON(dataOf(body, path)));
7575
7843
  }
7844
+ fetchPublicCatalog(query = {}) {
7845
+ const path = query.catalogId === void 0 ? "/public/catalog" : `/public/catalogs/${encodeURIComponent(query.catalogId)}`;
7846
+ return this.session.requestPublic(path).then((body) => PublicCatalogResponseDataFromJSON2(dataOf(body, path)));
7847
+ }
7576
7848
  createCheckout(selections) {
7577
7849
  return this.checkoutWrite("/checkouts", {
7578
7850
  method: "POST",
@@ -7974,6 +8246,10 @@ var Schematic = class {
7974
8246
  get additionalHeaders() {
7975
8247
  return { ...this._additionalHeaders };
7976
8248
  }
8249
+ /** The key flags are read with, for a billing client reading beside it. */
8250
+ get publishableKey() {
8251
+ return this.apiKey;
8252
+ }
7977
8253
  /**
7978
8254
  * Resolve fallback value according to priority order:
7979
8255
  * 1. Callsite fallback value (if provided)
@@ -10012,6 +10288,27 @@ var BillingStore = class {
10012
10288
  (query) => this._client.fetchCatalog(query),
10013
10289
  { readiness }
10014
10290
  );
10291
+ this.publicCatalog = new KeyedResource(
10292
+ (query) => this._client.fetchPublicCatalog?.(query) ?? Promise.reject(
10293
+ new Error("The billing client cannot read public data.")
10294
+ ),
10295
+ {
10296
+ readiness: () => {
10297
+ if (!this._connected) {
10298
+ return "waiting";
10299
+ }
10300
+ return this._client.hasPublishableKey === true && this._client.fetchPublicCatalog !== void 0 ? "ready" : "never";
10301
+ }
10302
+ }
10303
+ );
10304
+ if (initialData.publicCatalog !== void 0) {
10305
+ this.publicCatalog.seed(
10306
+ normalizeCatalogQuery2(
10307
+ initialData.params?.publicCatalog ?? DEFAULT_CATALOG_QUERY
10308
+ ),
10309
+ initialData.publicCatalog
10310
+ );
10311
+ }
10015
10312
  this.invoices = new KeyedResource(
10016
10313
  (query, current) => this._reloadWindow(
10017
10314
  query,
@@ -10099,6 +10396,7 @@ var BillingStore = class {
10099
10396
  }
10100
10397
  _client;
10101
10398
  catalog;
10399
+ publicCatalog;
10102
10400
  invoices;
10103
10401
  upcomingInvoice;
10104
10402
  paymentMethods;
@@ -10146,6 +10444,7 @@ var BillingStore = class {
10146
10444
  this._connected = true;
10147
10445
  this._settleSeed(claimOf(this._client));
10148
10446
  this.resumeAll();
10447
+ this.publicCatalog.resumeAll();
10149
10448
  }
10150
10449
  return () => {
10151
10450
  unsubscribe?.();
@@ -10205,6 +10504,15 @@ var BillingStore = class {
10205
10504
  this._seeded = true;
10206
10505
  }
10207
10506
  }
10507
+ /**
10508
+ * The company's view once someone is signed in; the public catalog until
10509
+ * then, where the client has a key to read it with. A session still
10510
+ * pending reads the public one too: a page that never states a session
10511
+ * would otherwise wait on one for good.
10512
+ */
10513
+ catalogSource() {
10514
+ return this._client.sessionStatus !== "active" && this._client.hasPublishableKey === true ? "public" : "company";
10515
+ }
10208
10516
  resource(name) {
10209
10517
  return this[name];
10210
10518
  }
@@ -10445,6 +10753,9 @@ function useSchematicStrings() {
10445
10753
 
10446
10754
  // src/billing/context.tsx
10447
10755
  import { jsx as jsx2 } from "react/jsx-runtime";
10756
+ function catalogSourceOf(data) {
10757
+ return data.catalog === void 0 && data.publicCatalog !== void 0 ? "public" : "company";
10758
+ }
10448
10759
  var BillingDataContext = createContext2(
10449
10760
  void 0
10450
10761
  );
@@ -10584,7 +10895,8 @@ function BillingDataProvider({
10584
10895
  return Promise.resolve();
10585
10896
  },
10586
10897
  invalidateAll: () => {
10587
- }
10898
+ },
10899
+ catalogSource: () => catalogSourceOf(data)
10588
10900
  };
10589
10901
  }, [
10590
10902
  actions,
@@ -10637,10 +10949,30 @@ function useBillingResource(name, params) {
10637
10949
  return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
10638
10950
  }
10639
10951
  function useCatalog(query = DEFAULT_CATALOG_QUERY) {
10640
- return useBillingResource(
10641
- "catalog",
10642
- useStableParams(normalizeCatalogQuery2(query))
10952
+ const source = useBillingDataSource();
10953
+ const params = useStableParams(normalizeCatalogQuery2(query));
10954
+ const subscribeSource = useCallback(
10955
+ (listener) => source.onSessionChange?.(() => listener()) ?? (() => {
10956
+ }),
10957
+ [source]
10958
+ );
10959
+ const readSource = useCallback(
10960
+ () => source.catalogSource?.() ?? "company",
10961
+ [source]
10962
+ );
10963
+ const which = useSyncExternalStore(subscribeSource, readSource, readSource);
10964
+ const handle = useBillingResource(
10965
+ which === "public" ? "publicCatalog" : "catalog",
10966
+ params
10643
10967
  );
10968
+ return useMemo3(() => {
10969
+ const { data } = handle;
10970
+ let view;
10971
+ if (data !== void 0) {
10972
+ view = which === "public" ? { source: "public", catalog: data } : { source: "company", catalog: data };
10973
+ }
10974
+ return { ...handle, data: view };
10975
+ }, [handle, which]);
10644
10976
  }
10645
10977
  function useInvoices(query = DEFAULT_INVOICE_QUERY) {
10646
10978
  const source = useBillingDataSource();
@@ -10924,7 +11256,8 @@ function BillingProvider({
10924
11256
  updateCheckout: (id, version3, selections) => store.updateCheckout(id, version3, selections),
10925
11257
  finalizeCheckout: (id, version3, options) => store.finalizeCheckout(id, version3, options)
10926
11258
  },
10927
- onSessionChange: (listener) => store.onSessionChange(listener)
11259
+ onSessionChange: (listener) => store.onSessionChange(listener),
11260
+ catalogSource: () => store.catalogSource()
10928
11261
  };
10929
11262
  }, [store]);
10930
11263
  const localized = /* @__PURE__ */ jsx3(
@@ -10985,12 +11318,13 @@ function staticSource(data) {
10985
11318
  },
10986
11319
  loadMoreInvoices: () => Promise.resolve(),
10987
11320
  invalidateAll: () => {
10988
- }
11321
+ },
11322
+ catalogSource: () => catalogSourceOf(data)
10989
11323
  };
10990
11324
  }
10991
11325
 
10992
11326
  // src/version.ts
10993
- var version2 = "1.15.0";
11327
+ var version2 = "1.16.0";
10994
11328
 
10995
11329
  // src/context/schematic.tsx
10996
11330
  import { jsx as jsx4 } from "react/jsx-runtime";
@@ -11043,9 +11377,11 @@ var SchematicProvider = ({
11043
11377
  );
11044
11378
  const { apiUrl, additionalHeaders } = initialOptsRef.current;
11045
11379
  const providedApiUrl = providedClient?.apiUrl;
11380
+ const resolvedPublishableKey = initialOptsRef.current.publishableKey ?? providedClient?.publishableKey;
11046
11381
  const resolvedBillingClient = useMemo5(
11047
11382
  () => billingClient ?? new SchematicBillingClient({
11048
11383
  session,
11384
+ publishableKey: resolvedPublishableKey,
11049
11385
  apiUrl: apiUrl ?? providedApiUrl,
11050
11386
  // Read as they stand when a client is built: headers do not change
11051
11387
  // where the token goes, so they are no reason to build one.
@@ -11057,7 +11393,13 @@ var SchematicProvider = ({
11057
11393
  // `session` is deliberately absent: `BillingProvider` forwards it through
11058
11394
  // `setSession`, so a token change resets the billing resources without
11059
11395
  // rebuilding the client.
11060
- [additionalHeaders, apiUrl, billingClient, providedApiUrl]
11396
+ [
11397
+ additionalHeaders,
11398
+ apiUrl,
11399
+ billingClient,
11400
+ providedApiUrl,
11401
+ resolvedPublishableKey
11402
+ ]
11061
11403
  );
11062
11404
  return /* @__PURE__ */ jsx4(SchematicContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsx4(
11063
11405
  BillingProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-react",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "main": "dist/schematic-react.cjs.js",
5
5
  "module": "dist/schematic-react.esm.js",
6
6
  "types": "dist/schematic-react.d.ts",
@@ -34,7 +34,7 @@
34
34
  "devDependencies": {
35
35
  "@eslint/js": "^10.0.1",
36
36
  "@microsoft/api-extractor": "^7.59.4",
37
- "@schematichq/schematic-js": "^1.15.0",
37
+ "@schematichq/schematic-js": "^1.16.0",
38
38
  "@testing-library/dom": "^10.4.2",
39
39
  "@testing-library/jest-dom": "^7.0.1",
40
40
  "@testing-library/react": "^16.3.3",