@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.
@@ -222,6 +222,12 @@ declare namespace billingApi {
222
222
  CatalogPlanRefResponseDataToJSON,
223
223
  CatalogPlanRefResponseDataToJSONTyped,
224
224
  CatalogPlanRefResponseData,
225
+ instanceOfCatalogPlanResponseData,
226
+ CatalogPlanResponseDataFromJSON,
227
+ CatalogPlanResponseDataFromJSONTyped,
228
+ CatalogPlanResponseDataToJSON,
229
+ CatalogPlanResponseDataToJSONTyped,
230
+ CatalogPlanResponseData,
225
231
  instanceOfCatalogPriceResponseData,
226
232
  CatalogPriceResponseDataFromJSON,
227
233
  CatalogPriceResponseDataFromJSONTyped,
@@ -660,6 +666,18 @@ declare namespace billingApi {
660
666
  GetCompanyUpcomingInvoiceResponseToJSON,
661
667
  GetCompanyUpcomingInvoiceResponseToJSONTyped,
662
668
  GetCompanyUpcomingInvoiceResponse,
669
+ instanceOfGetPublicCatalogByIDResponse,
670
+ GetPublicCatalogByIDResponseFromJSON,
671
+ GetPublicCatalogByIDResponseFromJSONTyped,
672
+ GetPublicCatalogByIDResponseToJSON,
673
+ GetPublicCatalogByIDResponseToJSONTyped,
674
+ GetPublicCatalogByIDResponse,
675
+ instanceOfGetPublicCatalogResponse,
676
+ GetPublicCatalogResponseFromJSON,
677
+ GetPublicCatalogResponseFromJSONTyped,
678
+ GetPublicCatalogResponseToJSON,
679
+ GetPublicCatalogResponseToJSONTyped,
680
+ GetPublicCatalogResponse,
663
681
  instanceOfInvoiceStatus,
664
682
  InvoiceStatusFromJSON,
665
683
  InvoiceStatusFromJSONTyped,
@@ -720,6 +738,12 @@ declare namespace billingApi {
720
738
  ProrationLineKindToJSON,
721
739
  ProrationLineKindToJSONTyped,
722
740
  ProrationLineKind,
741
+ instanceOfPublicCatalogResponseData,
742
+ PublicCatalogResponseDataFromJSON,
743
+ PublicCatalogResponseDataFromJSONTyped,
744
+ PublicCatalogResponseDataToJSON,
745
+ PublicCatalogResponseDataToJSONTyped,
746
+ PublicCatalogResponseData,
723
747
  instanceOfScheduledDowngradeConfigBehavior,
724
748
  ScheduledDowngradeConfigBehaviorFromJSON,
725
749
  ScheduledDowngradeConfigBehaviorFromJSONTyped,
@@ -822,6 +846,13 @@ declare namespace billingApi {
822
846
  declare interface BillingClient {
823
847
  /** The environment's catalog, or the one `catalogId` names. */
824
848
  fetchCatalog(query?: CatalogQuery): Promise<Catalog>;
849
+ /**
850
+ * The same catalog with no company's standing in it, read with the
851
+ * publishable key whether or not a session is active.
852
+ */
853
+ fetchPublicCatalog(query?: CatalogQuery): Promise<PublicCatalog>;
854
+ /** Whether `fetchPublicCatalog` has a key to read with. */
855
+ readonly hasPublishableKey: boolean;
825
856
  /** Opens a checkout, priced when the cart is priceable. */
826
857
  createCheckout(selections: CheckoutSelections): Promise<CheckoutWrite>;
827
858
  getCheckout(id: string): Promise<Checkout>;
@@ -1020,6 +1051,11 @@ export declare interface BillingDataSource {
1020
1051
  * on a source whose session never changes.
1021
1052
  */
1022
1053
  onSessionChange?: (listener: (event: SessionEvent) => void) => () => void;
1054
+ /**
1055
+ * Which catalog a reader sees now; it changes only with the session, so
1056
+ * `onSessionChange` says when to ask again. Absent, the company's view.
1057
+ */
1058
+ catalogSource?: () => CatalogSource;
1023
1059
  }
1024
1060
 
1025
1061
  /** Per-resource status overrides, for fixtures that simulate loading and failure. */
@@ -1055,7 +1091,10 @@ declare interface BillingPrefetchOptions {
1055
1091
  names: BillingResourceName_2[];
1056
1092
  /** The invoice query to prefetch for; the element must ask the same one. */
1057
1093
  invoices?: InvoiceQuery;
1058
- /** The catalog to prefetch; the element must ask the same one. */
1094
+ /**
1095
+ * The catalog to prefetch, as `catalog` or `publicCatalog`; the element
1096
+ * must ask the same one.
1097
+ */
1059
1098
  catalog?: CatalogQuery;
1060
1099
  }
1061
1100
 
@@ -1097,7 +1136,7 @@ export declare function BillingProvider({ billingClient, children, initialData,
1097
1136
  * much. Named apart from schematic-js's `BillingClient`, which is the whole
1098
1137
  * interface; this is the part the hooks here call.
1099
1138
  */
1100
- export declare type BillingProviderClient = Pick<BillingClient, "sessionStatus" | "sessionKey" | "setSession" | "onSessionChange" | "fetchCatalog" | "createCheckout" | "getCheckout" | "updateCheckout" | "finalizeCheckout" | "fetchInvoices" | "fetchUpcomingInvoice" | "fetchPaymentMethods" | "createSetupIntent" | "updatePaymentMethod" | "deletePaymentMethod" | "fetchFeatureUsage" | "fetchFeatureUserUsage" | "fetchCreditBalances" | "fetchCreditUserUsage" | "fetchCompany" | "cancelSubscription" | "fetchTaxIds" | "updateTaxId">;
1139
+ export declare type BillingProviderClient = Pick<BillingClient, "sessionStatus" | "sessionKey" | "setSession" | "onSessionChange" | "fetchCatalog" | "createCheckout" | "getCheckout" | "updateCheckout" | "finalizeCheckout" | "fetchInvoices" | "fetchUpcomingInvoice" | "fetchPaymentMethods" | "createSetupIntent" | "updatePaymentMethod" | "deletePaymentMethod" | "fetchFeatureUsage" | "fetchFeatureUserUsage" | "fetchCreditBalances" | "fetchCreditUserUsage" | "fetchCompany" | "cancelSubscription" | "fetchTaxIds" | "updateTaxId"> & Partial<Pick<BillingClient, "fetchPublicCatalog" | "hasPublishableKey">>;
1101
1140
 
1102
1141
  declare interface BillingProviderDataProps {
1103
1142
  /**
@@ -1150,7 +1189,7 @@ declare const BillingProviderType: {
1150
1189
  declare type BillingProviderType = (typeof BillingProviderType)[keyof typeof BillingProviderType];
1151
1190
 
1152
1191
  /** The resources this package serves; a key of schematic-js's contract. */
1153
- export declare type BillingResourceName = "catalog" | "invoices" | "upcomingInvoice" | "paymentMethods" | "featureUsage" | "creditBalances" | "company" | "taxIds";
1192
+ export declare type BillingResourceName = "catalog" | "publicCatalog" | "invoices" | "upcomingInvoice" | "paymentMethods" | "featureUsage" | "creditBalances" | "company" | "taxIds";
1154
1193
 
1155
1194
  declare type BillingResourceName_2 = keyof BillingResources_2;
1156
1195
 
@@ -1159,6 +1198,7 @@ export declare type BillingResourceParams = Pick<BillingResourceParams_2, Billin
1159
1198
  /** `Record<string, never>` marks a singleton; anything else is keyed. */
1160
1199
  declare interface BillingResourceParams_2 {
1161
1200
  catalog: CatalogQuery;
1201
+ publicCatalog: CatalogQuery;
1162
1202
  invoices: InvoiceQuery;
1163
1203
  upcomingInvoice: Record<string, never>;
1164
1204
  paymentMethods: Record<string, never>;
@@ -1183,6 +1223,12 @@ declare interface BillingResources_2 {
1183
1223
  * `catalogId`: the catalog as the company sees it.
1184
1224
  */
1185
1225
  catalog: Catalog;
1226
+ /**
1227
+ * `GET /public/catalog`, or `GET /public/catalogs/{catalog_id}`: the
1228
+ * catalog read with the publishable key. It belongs to no session, so a
1229
+ * session starting, changing or ending leaves it loaded.
1230
+ */
1231
+ publicCatalog: PublicCatalog;
1186
1232
  /** `GET /company/invoices?limit&offset&include_pending`. */
1187
1233
  invoices: InvoicePage;
1188
1234
  /**
@@ -1829,6 +1875,12 @@ declare interface CatalogCreditGrantResponseData {
1829
1875
  * @memberof CatalogCreditGrantResponseData
1830
1876
  */
1831
1877
  scaling: PlanCreditGrantScaling;
1878
+ /**
1879
+ * Whether the catalog shows this credit on the plan. Display-only: a hidden grant is still granted and priced at checkout.
1880
+ * @type {boolean}
1881
+ * @memberof CatalogCreditGrantResponseData
1882
+ */
1883
+ visible: boolean;
1832
1884
  }
1833
1885
 
1834
1886
  /**
@@ -2117,6 +2169,116 @@ declare interface CatalogPlanRefResponseData {
2117
2169
  name: string;
2118
2170
  }
2119
2171
 
2172
+ /**
2173
+ *
2174
+ * @export
2175
+ * @interface CatalogPlanResponseData
2176
+ */
2177
+ declare interface CatalogPlanResponseData {
2178
+ /**
2179
+ *
2180
+ * @type {Array<PlanPriceCadence>}
2181
+ * @memberof CatalogPlanResponseData
2182
+ */
2183
+ availablePeriods: Array<PlanPriceCadence>;
2184
+ /**
2185
+ *
2186
+ * @type {BillingStrategy}
2187
+ * @memberof CatalogPlanResponseData
2188
+ */
2189
+ billingStrategy: BillingStrategy;
2190
+ /**
2191
+ *
2192
+ * @type {ChargeType}
2193
+ * @memberof CatalogPlanResponseData
2194
+ */
2195
+ chargeType: ChargeType;
2196
+ /**
2197
+ * For add-ons, the plans this add-on may be purchased with. Null means compatible with every plan.
2198
+ * @type {Array<string>}
2199
+ * @memberof CatalogPlanResponseData
2200
+ */
2201
+ compatiblePlanIds?: Array<string> | null;
2202
+ /**
2203
+ *
2204
+ * @type {Array<CatalogCurrencyPricesResponseData>}
2205
+ * @memberof CatalogPlanResponseData
2206
+ */
2207
+ currencyPrices: Array<CatalogCurrencyPricesResponseData>;
2208
+ /**
2209
+ *
2210
+ * @type {string}
2211
+ * @memberof CatalogPlanResponseData
2212
+ */
2213
+ description: string;
2214
+ /**
2215
+ *
2216
+ * @type {Array<CatalogPlanEntitlementResponseData>}
2217
+ * @memberof CatalogPlanResponseData
2218
+ */
2219
+ entitlements: Array<CatalogPlanEntitlementResponseData>;
2220
+ /**
2221
+ *
2222
+ * @type {string}
2223
+ * @memberof CatalogPlanResponseData
2224
+ */
2225
+ icon: string;
2226
+ /**
2227
+ *
2228
+ * @type {string}
2229
+ * @memberof CatalogPlanResponseData
2230
+ */
2231
+ id: string;
2232
+ /**
2233
+ *
2234
+ * @type {Array<CatalogCreditGrantResponseData>}
2235
+ * @memberof CatalogPlanResponseData
2236
+ */
2237
+ includedCreditGrants: Array<CatalogCreditGrantResponseData>;
2238
+ /**
2239
+ *
2240
+ * @type {boolean}
2241
+ * @memberof CatalogPlanResponseData
2242
+ */
2243
+ isTrialable: boolean;
2244
+ /**
2245
+ *
2246
+ * @type {CatalogPriceResponseData}
2247
+ * @memberof CatalogPlanResponseData
2248
+ */
2249
+ monthlyPrice?: CatalogPriceResponseData;
2250
+ /**
2251
+ *
2252
+ * @type {string}
2253
+ * @memberof CatalogPlanResponseData
2254
+ */
2255
+ name: string;
2256
+ /**
2257
+ *
2258
+ * @type {CatalogPriceResponseData}
2259
+ * @memberof CatalogPlanResponseData
2260
+ */
2261
+ oneTimePrice?: CatalogPriceResponseData;
2262
+ /**
2263
+ *
2264
+ * @type {CatalogPriceResponseData}
2265
+ * @memberof CatalogPlanResponseData
2266
+ */
2267
+ quarterlyPrice?: CatalogPriceResponseData;
2268
+ /**
2269
+ *
2270
+ * @type {number}
2271
+ * @memberof CatalogPlanResponseData
2272
+ */
2273
+ trialDays?: number | null;
2274
+ /**
2275
+ *
2276
+ * @type {CatalogPriceResponseData}
2277
+ * @memberof CatalogPlanResponseData
2278
+ */
2279
+ yearlyPrice?: CatalogPriceResponseData;
2280
+ }
2281
+
2120
2282
  /**
2121
2283
  *
2122
2284
  * @export
@@ -2245,6 +2407,9 @@ export declare interface CatalogQuery {
2245
2407
  catalogId?: string;
2246
2408
  }
2247
2409
 
2410
+ /** Which catalog `useCatalog` reads: `catalog` or `publicCatalog`. */
2411
+ export declare type CatalogSource = CatalogView["source"];
2412
+
2248
2413
  /**
2249
2414
  * Schematic API
2250
2415
  * Schematic API
@@ -2288,6 +2453,19 @@ declare interface CatalogUsageViolationResponseData {
2288
2453
  usage: number;
2289
2454
  }
2290
2455
 
2456
+ /**
2457
+ * A catalog as whoever is reading it sees it. Tagged rather than merged: a
2458
+ * public plan is not one the company has no standing against, and filling
2459
+ * `valid` in for it would say something the server did not.
2460
+ */
2461
+ export declare type CatalogView = {
2462
+ source: "company";
2463
+ catalog: Catalog;
2464
+ } | {
2465
+ source: "public";
2466
+ catalog: PublicCatalog;
2467
+ };
2468
+
2291
2469
  /**
2292
2470
  *
2293
2471
  * @export
@@ -6033,6 +6211,89 @@ declare const ProrationLineKind: {
6033
6211
 
6034
6212
  declare type ProrationLineKind = (typeof ProrationLineKind)[keyof typeof ProrationLineKind];
6035
6213
 
6214
+ /**
6215
+ * The catalog with no company to stand against it: no `current`, `valid` or
6216
+ * trial standing on its plans, and no checkout settings, since nobody is
6217
+ * signed in to check out.
6218
+ */
6219
+ export declare type PublicCatalog = PublicCatalogResponseData;
6220
+
6221
+ export declare type PublicCatalogPlan = CatalogPlanResponseData;
6222
+
6223
+ /**
6224
+ *
6225
+ * @export
6226
+ * @interface PublicCatalogResponseData
6227
+ */
6228
+ declare interface PublicCatalogResponseData {
6229
+ /**
6230
+ *
6231
+ * @type {Array<CatalogPlanResponseData>}
6232
+ * @memberof PublicCatalogResponseData
6233
+ */
6234
+ addOns: Array<CatalogPlanResponseData>;
6235
+ /**
6236
+ *
6237
+ * @type {CatalogCapabilitiesResponseData}
6238
+ * @memberof PublicCatalogResponseData
6239
+ */
6240
+ capabilities: CatalogCapabilitiesResponseData;
6241
+ /**
6242
+ *
6243
+ * @type {Array<CatalogCreditBundleResponseData>}
6244
+ * @memberof PublicCatalogResponseData
6245
+ */
6246
+ creditBundles: Array<CatalogCreditBundleResponseData>;
6247
+ /**
6248
+ * Present when the catalog offers a custom plan; absent when custom plans are hidden.
6249
+ * @type {CatalogCustomPlanCTAResponseData}
6250
+ * @memberof PublicCatalogResponseData
6251
+ */
6252
+ customPlanCta?: CatalogCustomPlanCTAResponseData;
6253
+ /**
6254
+ * ISO 4217 currency of every top-level price slot; currency_prices carries the others.
6255
+ * @type {Currency}
6256
+ * @memberof PublicCatalogResponseData
6257
+ */
6258
+ defaultCurrency: Currency;
6259
+ /**
6260
+ *
6261
+ * @type {string}
6262
+ * @memberof PublicCatalogResponseData
6263
+ */
6264
+ description?: string | null;
6265
+ /**
6266
+ *
6267
+ * @type {string}
6268
+ * @memberof PublicCatalogResponseData
6269
+ */
6270
+ id: string;
6271
+ /**
6272
+ *
6273
+ * @type {string}
6274
+ * @memberof PublicCatalogResponseData
6275
+ */
6276
+ name: string;
6277
+ /**
6278
+ *
6279
+ * @type {Array<CatalogPlanResponseData>}
6280
+ * @memberof PublicCatalogResponseData
6281
+ */
6282
+ plans: Array<CatalogPlanResponseData>;
6283
+ /**
6284
+ *
6285
+ * @type {string}
6286
+ * @memberof PublicCatalogResponseData
6287
+ */
6288
+ pricingModel?: string | null;
6289
+ /**
6290
+ *
6291
+ * @type {string}
6292
+ * @memberof PublicCatalogResponseData
6293
+ */
6294
+ pricingUrl?: string | null;
6295
+ }
6296
+
6036
6297
  declare interface RequestOptions {
6037
6298
  method?: string;
6038
6299
  body?: unknown;
@@ -6163,6 +6424,8 @@ export declare class Schematic {
6163
6424
  constructor(apiKey: string, options?: SchematicOptions);
6164
6425
  get apiUrl(): string;
6165
6426
  get additionalHeaders(): Record<string, string>;
6427
+ /** The key flags are read with, for a billing client reading beside it. */
6428
+ get publishableKey(): string;
6166
6429
  /**
6167
6430
  * Resolve fallback value according to priority order:
6168
6431
  * 1. Callsite fallback value (if provided)
@@ -6414,9 +6677,11 @@ declare class SchematicBillingClient implements BillingClient {
6414
6677
  constructor(options?: BillingClientOptions | SchematicSession);
6415
6678
  get sessionKey(): string | undefined;
6416
6679
  get sessionStatus(): SessionStatus;
6680
+ get hasPublishableKey(): boolean;
6417
6681
  setSession(session: SessionInput): void;
6418
6682
  onSessionChange(listener: (event: SessionEvent) => void): () => void;
6419
6683
  fetchCatalog(query?: CatalogQuery): Promise<Catalog>;
6684
+ fetchPublicCatalog(query?: CatalogQuery): Promise<PublicCatalog>;
6420
6685
  createCheckout(selections: CheckoutSelections): Promise<CheckoutWrite>;
6421
6686
  getCheckout(id: string): Promise<Checkout>;
6422
6687
  updateCheckout(id: string, version: number, selections: CheckoutSelections): Promise<CheckoutWrite>;
@@ -6536,9 +6801,11 @@ declare namespace SchematicJS {
6536
6801
  CatalogEntitlement,
6537
6802
  CatalogPlan,
6538
6803
  CatalogPlanEntitlementResponseData,
6804
+ CatalogPlanResponseData,
6539
6805
  CatalogPriceResponseData,
6540
6806
  CatalogPriceTierResponseData,
6541
6807
  CatalogQuery,
6808
+ CatalogView,
6542
6809
  CheckFlagResponseData,
6543
6810
  CheckFlagReturn,
6544
6811
  CheckFlagReturnFromJSON,
@@ -6639,6 +6906,9 @@ declare namespace SchematicJS {
6639
6906
  PendingListenerFn,
6640
6907
  PerLicenseCreditGrant,
6641
6908
  PlanListenerFn,
6909
+ PublicCatalog,
6910
+ PublicCatalogPlan,
6911
+ PublicCatalogResponseData,
6642
6912
  RequestOptions,
6643
6913
  ResourceState,
6644
6914
  RuleType,
@@ -6761,6 +7031,7 @@ declare class SchematicSession {
6761
7031
  private readonly _apiUrl;
6762
7032
  private readonly _headers;
6763
7033
  private readonly _fetch;
7034
+ private readonly _publishableKey;
6764
7035
  private _session;
6765
7036
  private readonly _tokens;
6766
7037
  private readonly _resolving;
@@ -6773,6 +7044,7 @@ declare class SchematicSession {
6773
7044
  private readonly _listeners;
6774
7045
  constructor(options?: SessionOptions);
6775
7046
  get key(): string | undefined;
7047
+ get hasPublishableKey(): boolean;
6776
7048
  get status(): SessionStatus;
6777
7049
  /** Only a statement that changes which pair is read counts as a change. */
6778
7050
  set(session: SessionInput): void;
@@ -6793,6 +7065,13 @@ declare class SchematicSession {
6793
7065
  * otherwise come back as the answer to a question asked for another pair.
6794
7066
  */
6795
7067
  request(path: string, options?: RequestOptions): Promise<unknown>;
7068
+ /**
7069
+ * A read under the publishable key, whatever the session. Nothing is
7070
+ * refreshed or retried, since the key does not expire, and a session
7071
+ * changing mid-flight does not void the answer: it is the same for
7072
+ * everyone.
7073
+ */
7074
+ requestPublic(path: string): Promise<unknown>;
6796
7075
  /**
6797
7076
  * `request`, with the headers the answer came back with — for a resource
6798
7077
  * whose protocol rides beside the body, as a checkout's session does.
@@ -6851,6 +7130,11 @@ declare function sessionKey(session: Session): string;
6851
7130
 
6852
7131
  declare interface SessionOptions {
6853
7132
  session?: SessionInput;
7133
+ /**
7134
+ * For the reads that belong to no session: the public catalog, which a
7135
+ * page renders before anyone has signed in.
7136
+ */
7137
+ publishableKey?: string;
6854
7138
  apiUrl?: string;
6855
7139
  additionalHeaders?: Record<string, string>;
6856
7140
  /** Override for tests and non-browser runtimes. */
@@ -7214,11 +7498,14 @@ export declare enum UsagePeriod {
7214
7498
  export declare function useBillingDataSource(): BillingDataSource;
7215
7499
 
7216
7500
  /**
7217
- * The catalog as the session's company sees it: what it can buy, and how it
7218
- * stands against each plan and add-on. Without a `catalogId`, the catalog the
7219
- * environment sells; an inline object literal is fine, the hook keys by value.
7501
+ * The catalog as whoever is reading sees it. Signed in, the company's view:
7502
+ * what it can buy, and how it stands against each plan and add-on. Signed
7503
+ * out, or before the session resolves, the public catalog, read with the
7504
+ * publishable key; `data.source` says which, and a session starting swaps
7505
+ * one for the other. Without a `catalogId`, the catalog the environment
7506
+ * sells; an inline object literal is fine, the hook keys by value.
7220
7507
  */
7221
- export declare function useCatalog(query?: CatalogQuery): ResourceHandle<Catalog>;
7508
+ export declare function useCatalog(query?: CatalogQuery): ResourceHandle<CatalogView>;
7222
7509
 
7223
7510
  /**
7224
7511
  * A persisted checkout: the first `setSelections` opens it, each later one