@schematichq/schematic-components 0.4.5 → 0.4.6

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.
@@ -10655,6 +10655,8 @@ function BillingSubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
10655
10655
  return json;
10656
10656
  }
10657
10657
  return {
10658
+ cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
10659
+ cancelAtPeriodEnd: json["cancel_at_period_end"],
10658
10660
  companyId: json["company_id"] == null ? void 0 : json["company_id"],
10659
10661
  createdAt: new Date(json["created_at"]),
10660
10662
  currency: json["currency"],
@@ -10741,6 +10743,8 @@ function BillingSubscriptionViewFromJSONTyped(json, ignoreDiscriminator) {
10741
10743
  return json;
10742
10744
  }
10743
10745
  return {
10746
+ cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
10747
+ cancelAtPeriodEnd: json["cancel_at_period_end"],
10744
10748
  companyId: json["company_id"] == null ? void 0 : json["company_id"],
10745
10749
  createdAt: new Date(json["created_at"]),
10746
10750
  currency: json["currency"],
@@ -10823,6 +10827,33 @@ function CheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
10823
10827
  };
10824
10828
  }
10825
10829
 
10830
+ // src/api/models/DeleteResponse.ts
10831
+ function DeleteResponseFromJSON(json) {
10832
+ return DeleteResponseFromJSONTyped(json, false);
10833
+ }
10834
+ function DeleteResponseFromJSONTyped(json, ignoreDiscriminator) {
10835
+ if (json == null) {
10836
+ return json;
10837
+ }
10838
+ return {
10839
+ deleted: json["deleted"] == null ? void 0 : json["deleted"]
10840
+ };
10841
+ }
10842
+
10843
+ // src/api/models/CheckoutUnsubscribeResponse.ts
10844
+ function CheckoutUnsubscribeResponseFromJSON(json) {
10845
+ return CheckoutUnsubscribeResponseFromJSONTyped(json, false);
10846
+ }
10847
+ function CheckoutUnsubscribeResponseFromJSONTyped(json, ignoreDiscriminator) {
10848
+ if (json == null) {
10849
+ return json;
10850
+ }
10851
+ return {
10852
+ data: DeleteResponseFromJSON(json["data"]),
10853
+ params: json["params"]
10854
+ };
10855
+ }
10856
+
10826
10857
  // src/api/models/CompanyEventPeriodMetricsResponseData.ts
10827
10858
  function CompanyEventPeriodMetricsResponseDataFromJSON(json) {
10828
10859
  return CompanyEventPeriodMetricsResponseDataFromJSONTyped(json, false);
@@ -11322,6 +11353,8 @@ function CompanySubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
11322
11353
  return json;
11323
11354
  }
11324
11355
  return {
11356
+ cancelAt: json["cancel_at"] == null ? void 0 : new Date(json["cancel_at"]),
11357
+ cancelAtPeriodEnd: json["cancel_at_period_end"],
11325
11358
  currency: json["currency"],
11326
11359
  customerExternalId: json["customer_external_id"],
11327
11360
  discounts: json["discounts"].map(
@@ -11682,6 +11715,38 @@ var CheckoutexternalApi = class extends BaseAPI {
11682
11715
  const response = await this.checkoutRaw(requestParameters, initOverrides);
11683
11716
  return await response.value();
11684
11717
  }
11718
+ /**
11719
+ * Checkout unsubscribe
11720
+ */
11721
+ async checkoutUnsubscribeRaw(initOverrides) {
11722
+ const queryParameters = {};
11723
+ const headerParameters = {};
11724
+ if (this.configuration && this.configuration.apiKey) {
11725
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
11726
+ "X-Schematic-Api-Key"
11727
+ );
11728
+ }
11729
+ const response = await this.request(
11730
+ {
11731
+ path: `/checkout/unsubscribe`,
11732
+ method: "DELETE",
11733
+ headers: headerParameters,
11734
+ query: queryParameters
11735
+ },
11736
+ initOverrides
11737
+ );
11738
+ return new JSONApiResponse(
11739
+ response,
11740
+ (jsonValue) => CheckoutUnsubscribeResponseFromJSON(jsonValue)
11741
+ );
11742
+ }
11743
+ /**
11744
+ * Checkout unsubscribe
11745
+ */
11746
+ async checkoutUnsubscribe(initOverrides) {
11747
+ const response = await this.checkoutUnsubscribeRaw(initOverrides);
11748
+ return await response.value();
11749
+ }
11685
11750
  /**
11686
11751
  * Get setup intent
11687
11752
  */
@@ -12735,7 +12800,7 @@ var EmbedProvider = ({
12735
12800
  (0, import_react11.useEffect)(() => {
12736
12801
  if (accessToken) {
12737
12802
  const { headers = {} } = apiConfig ?? {};
12738
- headers["X-Schematic-Components-Version"] = "0.4.5";
12803
+ headers["X-Schematic-Components-Version"] = "0.4.6";
12739
12804
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
12740
12805
  const config = new Configuration({
12741
12806
  ...apiConfig,
@@ -12910,13 +12975,15 @@ function shortenPeriod(period) {
12910
12975
  }
12911
12976
 
12912
12977
  // src/utils/string.ts
12978
+ var DEFAULT_CURRENCY = "USD";
12913
12979
  function camelToHyphen(str) {
12914
12980
  return str.replace(/([a-z][A-Z])/g, (g2) => `${g2[0]}-${g2[1].toLowerCase()}`);
12915
12981
  }
12916
12982
  function formatNumber(num) {
12917
12983
  return new Intl.NumberFormat("en-US").format(num);
12918
12984
  }
12919
- function formatCurrency(amount, currency = "USD") {
12985
+ function formatCurrency(amount, currency = DEFAULT_CURRENCY) {
12986
+ const nonEmptyCurrency = currency ? currency.toUpperCase() : DEFAULT_CURRENCY;
12920
12987
  try {
12921
12988
  const dollars = amount / 100;
12922
12989
  const formatValue = (value, symbol) => {
@@ -12924,8 +12991,8 @@ function formatCurrency(amount, currency = "USD") {
12924
12991
  if (formatted.endsWith(".0")) {
12925
12992
  formatted = formatted.slice(0, -2);
12926
12993
  }
12927
- if (currency.toUpperCase() !== "USD") {
12928
- return `${currency.toUpperCase()}${formatted}${symbol}`;
12994
+ if (nonEmptyCurrency !== DEFAULT_CURRENCY) {
12995
+ return `${nonEmptyCurrency}${formatted}${symbol}`;
12929
12996
  }
12930
12997
  return `$${formatted}${symbol}`;
12931
12998
  };
@@ -12936,14 +13003,14 @@ function formatCurrency(amount, currency = "USD") {
12936
13003
  } else {
12937
13004
  return new Intl.NumberFormat("en-US", {
12938
13005
  style: "currency",
12939
- currency: currency.toUpperCase()
13006
+ currency: nonEmptyCurrency
12940
13007
  }).format(dollars);
12941
13008
  }
12942
13009
  } catch (error) {
12943
13010
  console.error("Error formatting currency", error);
12944
13011
  return new Intl.NumberFormat("en-US", {
12945
13012
  style: "currency",
12946
- currency: currency.toUpperCase()
13013
+ currency: nonEmptyCurrency
12947
13014
  }).format(amount / 100);
12948
13015
  }
12949
13016
  }
@@ -18705,7 +18772,7 @@ var PlanManager = (0, import_react36.forwardRef)(({ children, className, portal,
18705
18772
  []
18706
18773
  );
18707
18774
  const billingSubscription = data.company?.billingSubscription;
18708
- const subscriptionCurrency = billingSubscription?.currency ?? "USD";
18775
+ const subscriptionCurrency = billingSubscription?.currency;
18709
18776
  const showTrialBox = billingSubscription && billingSubscription.status == "trialing";
18710
18777
  const trialEndDate = billingSubscription?.trialEnd ? new Date(billingSubscription.trialEnd * 1e3) : /* @__PURE__ */ new Date();
18711
18778
  const todayDate = /* @__PURE__ */ new Date();
@@ -516,6 +516,18 @@ declare interface BillingSubscriptionDiscountView {
516
516
  * @interface BillingSubscriptionResponseData
517
517
  */
518
518
  declare interface BillingSubscriptionResponseData {
519
+ /**
520
+ *
521
+ * @type {number}
522
+ * @memberof BillingSubscriptionResponseData
523
+ */
524
+ cancelAt?: number | null;
525
+ /**
526
+ *
527
+ * @type {boolean}
528
+ * @memberof BillingSubscriptionResponseData
529
+ */
530
+ cancelAtPeriodEnd: boolean;
519
531
  /**
520
532
  *
521
533
  * @type {string}
@@ -614,6 +626,18 @@ declare interface BillingSubscriptionResponseData {
614
626
  * @interface BillingSubscriptionView
615
627
  */
616
628
  declare interface BillingSubscriptionView {
629
+ /**
630
+ *
631
+ * @type {number}
632
+ * @memberof BillingSubscriptionView
633
+ */
634
+ cancelAt?: number | null;
635
+ /**
636
+ *
637
+ * @type {boolean}
638
+ * @memberof BillingSubscriptionView
639
+ */
640
+ cancelAtPeriodEnd: boolean;
617
641
  /**
618
642
  *
619
643
  * @type {string}
@@ -837,6 +861,14 @@ declare class CheckoutexternalApi extends runtime.BaseAPI {
837
861
  * Checkout
838
862
  */
839
863
  checkout(requestParameters: CheckoutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<CheckoutResponse>;
864
+ /**
865
+ * Checkout unsubscribe
866
+ */
867
+ checkoutUnsubscribeRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<CheckoutUnsubscribeResponse>>;
868
+ /**
869
+ * Checkout unsubscribe
870
+ */
871
+ checkoutUnsubscribe(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<CheckoutUnsubscribeResponse>;
840
872
  /**
841
873
  * Get setup intent
842
874
  */
@@ -903,6 +935,26 @@ declare interface CheckoutResponse {
903
935
  params: object;
904
936
  }
905
937
 
938
+ /**
939
+ *
940
+ * @export
941
+ * @interface CheckoutUnsubscribeResponse
942
+ */
943
+ declare interface CheckoutUnsubscribeResponse {
944
+ /**
945
+ *
946
+ * @type {DeleteResponse}
947
+ * @memberof CheckoutUnsubscribeResponse
948
+ */
949
+ data: DeleteResponse;
950
+ /**
951
+ * Input parameters
952
+ * @type {object}
953
+ * @memberof CheckoutUnsubscribeResponse
954
+ */
955
+ params: object;
956
+ }
957
+
906
958
  declare const COLLECTION_FORMATS: {
907
959
  csv: string;
908
960
  ssv: string;
@@ -1330,6 +1382,18 @@ declare interface CompanyPlanWithBillingSubView {
1330
1382
  * @interface CompanySubscriptionResponseData
1331
1383
  */
1332
1384
  declare interface CompanySubscriptionResponseData {
1385
+ /**
1386
+ *
1387
+ * @type {Date}
1388
+ * @memberof CompanySubscriptionResponseData
1389
+ */
1390
+ cancelAt?: Date | null;
1391
+ /**
1392
+ *
1393
+ * @type {boolean}
1394
+ * @memberof CompanySubscriptionResponseData
1395
+ */
1396
+ cancelAtPeriodEnd: boolean;
1333
1397
  /**
1334
1398
  *
1335
1399
  * @type {string}
@@ -1779,6 +1843,31 @@ export declare const defaultSettings: EmbedSettings;
1779
1843
 
1780
1844
  export declare const defaultTheme: EmbedThemeSettings;
1781
1845
 
1846
+ /**
1847
+ * Schematic API
1848
+ * Schematic API
1849
+ *
1850
+ * The version of the OpenAPI document: 0.1
1851
+ *
1852
+ *
1853
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
1854
+ * https://openapi-generator.tech
1855
+ * Do not edit the class manually.
1856
+ */
1857
+ /**
1858
+ *
1859
+ * @export
1860
+ * @interface DeleteResponse
1861
+ */
1862
+ declare interface DeleteResponse {
1863
+ /**
1864
+ * Whether the delete was successful
1865
+ * @type {boolean}
1866
+ * @memberof DeleteResponse
1867
+ */
1868
+ deleted?: boolean;
1869
+ }
1870
+
1782
1871
  export declare interface DesignProps {
1783
1872
  header: {
1784
1873
  isVisible: boolean;
@@ -10608,6 +10608,8 @@ function BillingSubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
10608
10608
  return json;
10609
10609
  }
10610
10610
  return {
10611
+ cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
10612
+ cancelAtPeriodEnd: json["cancel_at_period_end"],
10611
10613
  companyId: json["company_id"] == null ? void 0 : json["company_id"],
10612
10614
  createdAt: new Date(json["created_at"]),
10613
10615
  currency: json["currency"],
@@ -10694,6 +10696,8 @@ function BillingSubscriptionViewFromJSONTyped(json, ignoreDiscriminator) {
10694
10696
  return json;
10695
10697
  }
10696
10698
  return {
10699
+ cancelAt: json["cancel_at"] == null ? void 0 : json["cancel_at"],
10700
+ cancelAtPeriodEnd: json["cancel_at_period_end"],
10697
10701
  companyId: json["company_id"] == null ? void 0 : json["company_id"],
10698
10702
  createdAt: new Date(json["created_at"]),
10699
10703
  currency: json["currency"],
@@ -10776,6 +10780,33 @@ function CheckoutResponseFromJSONTyped(json, ignoreDiscriminator) {
10776
10780
  };
10777
10781
  }
10778
10782
 
10783
+ // src/api/models/DeleteResponse.ts
10784
+ function DeleteResponseFromJSON(json) {
10785
+ return DeleteResponseFromJSONTyped(json, false);
10786
+ }
10787
+ function DeleteResponseFromJSONTyped(json, ignoreDiscriminator) {
10788
+ if (json == null) {
10789
+ return json;
10790
+ }
10791
+ return {
10792
+ deleted: json["deleted"] == null ? void 0 : json["deleted"]
10793
+ };
10794
+ }
10795
+
10796
+ // src/api/models/CheckoutUnsubscribeResponse.ts
10797
+ function CheckoutUnsubscribeResponseFromJSON(json) {
10798
+ return CheckoutUnsubscribeResponseFromJSONTyped(json, false);
10799
+ }
10800
+ function CheckoutUnsubscribeResponseFromJSONTyped(json, ignoreDiscriminator) {
10801
+ if (json == null) {
10802
+ return json;
10803
+ }
10804
+ return {
10805
+ data: DeleteResponseFromJSON(json["data"]),
10806
+ params: json["params"]
10807
+ };
10808
+ }
10809
+
10779
10810
  // src/api/models/CompanyEventPeriodMetricsResponseData.ts
10780
10811
  function CompanyEventPeriodMetricsResponseDataFromJSON(json) {
10781
10812
  return CompanyEventPeriodMetricsResponseDataFromJSONTyped(json, false);
@@ -11275,6 +11306,8 @@ function CompanySubscriptionResponseDataFromJSONTyped(json, ignoreDiscriminator)
11275
11306
  return json;
11276
11307
  }
11277
11308
  return {
11309
+ cancelAt: json["cancel_at"] == null ? void 0 : new Date(json["cancel_at"]),
11310
+ cancelAtPeriodEnd: json["cancel_at_period_end"],
11278
11311
  currency: json["currency"],
11279
11312
  customerExternalId: json["customer_external_id"],
11280
11313
  discounts: json["discounts"].map(
@@ -11635,6 +11668,38 @@ var CheckoutexternalApi = class extends BaseAPI {
11635
11668
  const response = await this.checkoutRaw(requestParameters, initOverrides);
11636
11669
  return await response.value();
11637
11670
  }
11671
+ /**
11672
+ * Checkout unsubscribe
11673
+ */
11674
+ async checkoutUnsubscribeRaw(initOverrides) {
11675
+ const queryParameters = {};
11676
+ const headerParameters = {};
11677
+ if (this.configuration && this.configuration.apiKey) {
11678
+ headerParameters["X-Schematic-Api-Key"] = await this.configuration.apiKey(
11679
+ "X-Schematic-Api-Key"
11680
+ );
11681
+ }
11682
+ const response = await this.request(
11683
+ {
11684
+ path: `/checkout/unsubscribe`,
11685
+ method: "DELETE",
11686
+ headers: headerParameters,
11687
+ query: queryParameters
11688
+ },
11689
+ initOverrides
11690
+ );
11691
+ return new JSONApiResponse(
11692
+ response,
11693
+ (jsonValue) => CheckoutUnsubscribeResponseFromJSON(jsonValue)
11694
+ );
11695
+ }
11696
+ /**
11697
+ * Checkout unsubscribe
11698
+ */
11699
+ async checkoutUnsubscribe(initOverrides) {
11700
+ const response = await this.checkoutUnsubscribeRaw(initOverrides);
11701
+ return await response.value();
11702
+ }
11638
11703
  /**
11639
11704
  * Get setup intent
11640
11705
  */
@@ -12688,7 +12753,7 @@ var EmbedProvider = ({
12688
12753
  useEffect2(() => {
12689
12754
  if (accessToken) {
12690
12755
  const { headers = {} } = apiConfig ?? {};
12691
- headers["X-Schematic-Components-Version"] = "0.4.5";
12756
+ headers["X-Schematic-Components-Version"] = "0.4.6";
12692
12757
  headers["X-Schematic-Session-ID"] = sessionIdRef.current;
12693
12758
  const config = new Configuration({
12694
12759
  ...apiConfig,
@@ -12863,13 +12928,15 @@ function shortenPeriod(period) {
12863
12928
  }
12864
12929
 
12865
12930
  // src/utils/string.ts
12931
+ var DEFAULT_CURRENCY = "USD";
12866
12932
  function camelToHyphen(str) {
12867
12933
  return str.replace(/([a-z][A-Z])/g, (g2) => `${g2[0]}-${g2[1].toLowerCase()}`);
12868
12934
  }
12869
12935
  function formatNumber(num) {
12870
12936
  return new Intl.NumberFormat("en-US").format(num);
12871
12937
  }
12872
- function formatCurrency(amount, currency = "USD") {
12938
+ function formatCurrency(amount, currency = DEFAULT_CURRENCY) {
12939
+ const nonEmptyCurrency = currency ? currency.toUpperCase() : DEFAULT_CURRENCY;
12873
12940
  try {
12874
12941
  const dollars = amount / 100;
12875
12942
  const formatValue = (value, symbol) => {
@@ -12877,8 +12944,8 @@ function formatCurrency(amount, currency = "USD") {
12877
12944
  if (formatted.endsWith(".0")) {
12878
12945
  formatted = formatted.slice(0, -2);
12879
12946
  }
12880
- if (currency.toUpperCase() !== "USD") {
12881
- return `${currency.toUpperCase()}${formatted}${symbol}`;
12947
+ if (nonEmptyCurrency !== DEFAULT_CURRENCY) {
12948
+ return `${nonEmptyCurrency}${formatted}${symbol}`;
12882
12949
  }
12883
12950
  return `$${formatted}${symbol}`;
12884
12951
  };
@@ -12889,14 +12956,14 @@ function formatCurrency(amount, currency = "USD") {
12889
12956
  } else {
12890
12957
  return new Intl.NumberFormat("en-US", {
12891
12958
  style: "currency",
12892
- currency: currency.toUpperCase()
12959
+ currency: nonEmptyCurrency
12893
12960
  }).format(dollars);
12894
12961
  }
12895
12962
  } catch (error) {
12896
12963
  console.error("Error formatting currency", error);
12897
12964
  return new Intl.NumberFormat("en-US", {
12898
12965
  style: "currency",
12899
- currency: currency.toUpperCase()
12966
+ currency: nonEmptyCurrency
12900
12967
  }).format(amount / 100);
12901
12968
  }
12902
12969
  }
@@ -18676,7 +18743,7 @@ var PlanManager = forwardRef11(({ children, className, portal, ...rest }, ref) =
18676
18743
  []
18677
18744
  );
18678
18745
  const billingSubscription = data.company?.billingSubscription;
18679
- const subscriptionCurrency = billingSubscription?.currency ?? "USD";
18746
+ const subscriptionCurrency = billingSubscription?.currency;
18680
18747
  const showTrialBox = billingSubscription && billingSubscription.status == "trialing";
18681
18748
  const trialEndDate = billingSubscription?.trialEnd ? new Date(billingSubscription.trialEnd * 1e3) : /* @__PURE__ */ new Date();
18682
18749
  const todayDate = /* @__PURE__ */ new Date();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@schematichq/schematic-components",
3
- "version": "0.4.5",
3
+ "version": "0.4.6",
4
4
  "main": "dist/schematic-components.cjs.js",
5
5
  "module": "dist/schematic-components.esm.js",
6
6
  "types": "dist/schematic-components.d.ts",