@openrails/billing-ui 0.245.0 → 0.246.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.
@@ -282,14 +282,14 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
282
282
  psp_id: e.string().nullish(),
283
283
  transactions: e.array(e.string()).nullish(),
284
284
  payload: e.record(e.string(), e.string()).nullish()
285
- }), L = e.object({
285
+ }), se = e.object({
286
286
  attempts: e.number(),
287
287
  retries_left: e.number().nullish(),
288
288
  next_retry_at: O.nullish(),
289
289
  final_retry_at: O.nullish(),
290
290
  waiting_for_new_card: e.boolean(),
291
291
  last_failure_reason: e.string().nullish()
292
- }), R = e.object({
292
+ }), L = e.object({
293
293
  id: e.string(),
294
294
  status: j,
295
295
  rail: e.string().nullish(),
@@ -313,7 +313,7 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
313
313
  starts_at: O,
314
314
  ends_at: O.nullish()
315
315
  }).nullish(),
316
- dunning: L.nullish(),
316
+ dunning: se.nullish(),
317
317
  price: N.nullish(),
318
318
  product: P.nullish(),
319
319
  scheduled_change: e.object({
@@ -329,7 +329,7 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
329
329
  next_action: I.nullish(),
330
330
  created_at: O.nullish(),
331
331
  updated_at: O.nullish()
332
- }), z = e.object({
332
+ }), R = e.object({
333
333
  name: e.string().nullish(),
334
334
  email: e.string().nullish(),
335
335
  phone: e.string().nullish(),
@@ -341,7 +341,7 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
341
341
  postal_code: e.string().nullish(),
342
342
  country: e.string().nullish()
343
343
  }).nullish()
344
- }), B = e.object({
344
+ }), z = e.object({
345
345
  id: e.string(),
346
346
  status: e.string().nullish(),
347
347
  next_action: e.object({
@@ -352,7 +352,7 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
352
352
  rail: e.string().nullish(),
353
353
  psp_id: e.string().nullish(),
354
354
  card: F.nullish(),
355
- billing_details: z.nullish(),
355
+ billing_details: R.nullish(),
356
356
  reusable: e.boolean().nullish(),
357
357
  health: e.object({
358
358
  expiry_status: e.string().nullish(),
@@ -366,11 +366,11 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
366
366
  })).nullish(),
367
367
  default_currencies: e.array(e.string()).nullish(),
368
368
  created_at: O.nullish()
369
- }), V = e.object({
369
+ }), B = e.object({
370
370
  reason: e.string(),
371
371
  message: e.string(),
372
372
  field: e.string().nullish()
373
- }), H = e.object({
373
+ }), V = e.object({
374
374
  id: e.string(),
375
375
  price_id: e.string().nullish(),
376
376
  product_id: e.string().nullish(),
@@ -383,7 +383,7 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
383
383
  access_duration_hours: e.number().nullish(),
384
384
  subscription_id: e.string().nullish(),
385
385
  product_access_id: e.string().nullish()
386
- }), U = e.object({
386
+ }), H = e.object({
387
387
  id: e.string(),
388
388
  customer_id: e.string(),
389
389
  origin: e.string(),
@@ -391,11 +391,11 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
391
391
  number: e.string().nullish(),
392
392
  currency: e.string(),
393
393
  total: D,
394
- lines: e.array(H),
394
+ lines: e.array(V),
395
395
  payment: e.object({
396
396
  status: e.string(),
397
397
  next_action: I.nullish(),
398
- last_payment_error: V.nullish(),
398
+ last_payment_error: B.nullish(),
399
399
  payment_method_id: e.string().nullish(),
400
400
  payment_id: e.string().nullish()
401
401
  }),
@@ -437,12 +437,12 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
437
437
  voided_at: O.nullish(),
438
438
  uncollectible_at: O.nullish(),
439
439
  created_at: O
440
- }), W = e.object({
440
+ }), U = e.object({
441
441
  code: e.string(),
442
442
  message: e.string(),
443
443
  owned_by: e.string().nullish(),
444
444
  hint: e.string().nullish()
445
- }), G = e.object({
445
+ }), W = e.object({
446
446
  price_id: e.string(),
447
447
  product_id: e.string(),
448
448
  description: e.string(),
@@ -452,15 +452,15 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
452
452
  ownership: e.string(),
453
453
  billing_interval_hours: e.number().nullish(),
454
454
  access_duration_hours: e.number().nullish(),
455
- refusal: W.nullish()
456
- }), K = e.object({
455
+ refusal: U.nullish()
456
+ }), G = e.object({
457
457
  currency: e.string(),
458
458
  total: D,
459
- lines: e.array(G),
460
- payment_options: U.shape.payment_options,
459
+ lines: e.array(W),
460
+ payment_options: H.shape.payment_options,
461
461
  last_changed_at: O.nullish(),
462
462
  expires_at: O.nullish()
463
- }), q = e.object({
463
+ }), K = e.object({
464
464
  id: e.string(),
465
465
  key: e.string(),
466
466
  revision: e.number().int().nonnegative().optional(),
@@ -479,7 +479,7 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
479
479
  prices: e.array(N).nullish().transform((e) => e ?? []),
480
480
  created_at: O,
481
481
  updated_at: O
482
- }), se = e.object({
482
+ }), ce = e.object({
483
483
  id: e.string(),
484
484
  kind: e.string(),
485
485
  status: e.string(),
@@ -499,7 +499,7 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
499
499
  message: e.string(),
500
500
  field: e.string().nullish()
501
501
  }).nullish()
502
- }), ce = e.object({
502
+ }), le = e.object({
503
503
  currency: e.string(),
504
504
  billing_mode: e.string(),
505
505
  balance_amount: D,
@@ -510,33 +510,43 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
510
510
  accrual_rate_per_hour: D,
511
511
  as_of: e.string(),
512
512
  depletes_at: e.string().nullable()
513
- }), le = e.object({
513
+ }), q = e.object({
514
+ currency: e.string(),
515
+ amount: D,
516
+ runway_hours: e.number().int(),
517
+ source: e.enum([
518
+ "customer",
519
+ "merchant",
520
+ "default"
521
+ ])
522
+ }), ue = e.object({
514
523
  id: e.string(),
515
- balances: e.array(ce),
524
+ balances: e.array(le),
516
525
  default_payment_methods: e.array(e.object({
517
526
  currency: e.string(),
518
527
  payment_method_id: e.string()
519
- }))
520
- }), ue = e.object({
528
+ })),
529
+ low_balance_lines: e.array(q)
530
+ }), de = e.object({
521
531
  key: e.string(),
522
532
  cell: e.string().nullish(),
523
533
  event_count: e.number(),
524
534
  amount: D,
525
535
  quantity: e.number().nullish(),
526
536
  dimensions: e.record(e.string(), e.number()).nullish()
527
- }), de = e.object({
537
+ }), fe = e.object({
528
538
  customer_id: e.string(),
529
539
  currency: e.string(),
530
540
  from: O,
531
541
  to: O,
532
542
  group_by: e.string(),
533
- rows: e.array(ue),
543
+ rows: e.array(de),
534
544
  next_cursor: e.string().nullish().transform((e) => e ?? null)
535
- }), fe = e.object({
545
+ }), pe = e.object({
536
546
  code: e.string(),
537
547
  decimals: e.number(),
538
548
  minor_decimals: e.number().nullish()
539
- }), pe = e.object({
549
+ }), me = e.object({
540
550
  price_id: e.string(),
541
551
  quantity: e.number().nullish(),
542
552
  rail: e.string().nullish(),
@@ -560,7 +570,7 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
560
570
  next_charge_amount: D.nullish(),
561
571
  next_charge_date: O.nullish(),
562
572
  message: e.string().nullish()
563
- }), me = e.object({
573
+ }), he = e.object({
564
574
  psps: e.array(u).nullish().transform((e) => e ?? []),
565
575
  solana: e.object({
566
576
  network: e.string(),
@@ -575,36 +585,36 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
575
585
  recurring_eligible: e.boolean().nullish()
576
586
  })).nullish().transform((e) => e ?? [])
577
587
  }).nullish()
578
- }), he = e.object({
588
+ }), ge = e.object({
579
589
  provider: e.string(),
580
590
  site_key: e.string(),
581
591
  script_url: e.string(),
582
592
  action: e.string(),
583
593
  token_header: e.string()
584
- }), ge = e.object({
594
+ }), _e = e.object({
585
595
  display_name: e.string(),
586
596
  logo_url: e.string().nullish(),
587
597
  support_url: e.string().nullish(),
588
598
  embed_origins: e.array(e.string()).nullish().transform((e) => e ?? [])
589
- }), _e = e.object({
599
+ }), ve = e.object({
590
600
  capabilities: e.object({
591
601
  route_groups: e.record(e.string(), e.boolean()),
592
602
  features: e.record(e.string(), e.boolean())
593
603
  }),
594
- currencies: e.array(fe).nullish().transform((e) => e ?? []),
595
- captcha: he.nullish(),
604
+ currencies: e.array(pe).nullish().transform((e) => e ?? []),
605
+ captcha: ge.nullish(),
596
606
  network: e.object({
597
607
  issuer: e.string(),
598
608
  client_id: e.string()
599
609
  }).nullish()
600
- }), ve = e.object({
601
- payment: me,
602
- merchant: ge
603
610
  }), ye = e.object({
611
+ payment: he,
612
+ merchant: _e
613
+ }), be = e.object({
604
614
  id: e.string(),
605
615
  nonce: e.string(),
606
616
  expires_at: O
607
- }), be = e.object({
617
+ }), xe = e.object({
608
618
  id: e.string(),
609
619
  merchant_id: e.string(),
610
620
  customer_id: e.string(),
@@ -618,8 +628,8 @@ var D = e.string().refine(S, "amount must be an int64 string"), O = e.string(),
618
628
  constructor(e = "The wallet request was declined.") {
619
629
  super(e), this.name = "WalletRejectedError";
620
630
  }
621
- }, xe = 4, Se = 500, Ce = (e) => e?.type === "solana_sign_transactions" && !!e.transactions?.length;
622
- async function X(e, t) {
631
+ }, Se = 4, Ce = 500, X = (e) => e?.type === "solana_sign_transactions" && !!e.transactions?.length;
632
+ async function we(e, t) {
623
633
  let n = "";
624
634
  for (let r of e.transactions ?? []) {
625
635
  try {
@@ -632,9 +642,9 @@ async function X(e, t) {
632
642
  if (!n) throw i("wallet_no_signature", "The wallet returned no signature.");
633
643
  return n;
634
644
  }
635
- var we = 2e3, Z = 300;
636
- function Te(e) {
637
- let t = Ee(e.headers.get("Retry-After"));
645
+ var Te = 2e3, Z = 300;
646
+ function Ee(e) {
647
+ let t = De(e.headers.get("Retry-After"));
638
648
  switch (e.status) {
639
649
  case 429: return t;
640
650
  case 503: return t ?? Z;
@@ -643,7 +653,7 @@ function Te(e) {
643
653
  default: return null;
644
654
  }
645
655
  }
646
- function Ee(e) {
656
+ function De(e) {
647
657
  if (!e) return null;
648
658
  if (/^\d+$/.test(e.trim())) return Number(e.trim()) * 1e3;
649
659
  let t = Date.parse(e);
@@ -660,8 +670,8 @@ function Q(e, t) {
660
670
  t?.addEventListener("abort", a, { once: !0 });
661
671
  });
662
672
  }
663
- function De(e = {}) {
664
- let t = (e.baseUrl ?? "/billing/v1").replace(/\/+$/, ""), r = e.fetch ?? ((e, t) => fetch(e, t)), o = Oe({
673
+ function Oe(e = {}) {
674
+ let t = (e.baseUrl ?? "/billing/v1").replace(/\/+$/, ""), r = e.fetch ?? ((e, t) => fetch(e, t)), o = ke({
665
675
  ...s,
666
676
  ...e.currencies
667
677
  });
@@ -705,7 +715,7 @@ function De(e = {}) {
705
715
  e.getToken.invalidate(o), o = await e.getToken(), i.set("Authorization", `Bearer ${o}`), p = !0, s--;
706
716
  continue;
707
717
  }
708
- let m = Te(l);
718
+ let m = Ee(l);
709
719
  if (s >= d || m === null || f + m > 2e3) throw await a(l);
710
720
  await l.body?.cancel().catch(() => void 0), f += await Q(m, n.signal);
711
721
  }
@@ -721,16 +731,16 @@ function De(e = {}) {
721
731
  if (!o.success) throw i("invalid_response", `${t}: ${o.error.issues[0]?.path.join(".")} ${o.error.issues[0]?.message}`);
722
732
  return o.data;
723
733
  }
724
- let d = (e) => encodeURIComponent(e), f = A(R), p = A(B), m = A(se), h = A(U), g = (e, t) => ({
734
+ let d = (e) => encodeURIComponent(e), f = A(L), p = A(z), m = A(ce), h = A(H), g = (e, t) => ({
725
735
  limit: e.limit ?? t,
726
736
  cursor: e.cursor ?? void 0
727
- }), _ = k(q);
737
+ }), _ = k(K);
728
738
  async function v(e, t) {
729
739
  try {
730
- return { order: await u(U, e, t) };
740
+ return { order: await u(H, e, t) };
731
741
  } catch (e) {
732
742
  if (n(e) && e.status === 402 && e.order) {
733
- let t = U.safeParse(e.order);
743
+ let t = H.safeParse(e.order);
734
744
  if (t.success) return {
735
745
  order: t.data,
736
746
  error: e
@@ -751,10 +761,10 @@ function De(e = {}) {
751
761
  });
752
762
  },
753
763
  getSubscription(e, t) {
754
- return u(R, `/me/subscriptions/${d(e)}`, { signal: t });
764
+ return u(L, `/me/subscriptions/${d(e)}`, { signal: t });
755
765
  },
756
766
  cancelSubscription(e, t) {
757
- return u(R, `/me/subscriptions/${d(e)}/cancel`, {
767
+ return u(L, `/me/subscriptions/${d(e)}/cancel`, {
758
768
  method: "POST",
759
769
  body: {
760
770
  reason: t.reason.trim(),
@@ -763,19 +773,19 @@ function De(e = {}) {
763
773
  });
764
774
  },
765
775
  resumeSubscription(e) {
766
- return u(R, `/me/subscriptions/${d(e)}/resume`, {
776
+ return u(L, `/me/subscriptions/${d(e)}/resume`, {
767
777
  method: "POST",
768
778
  body: {}
769
779
  });
770
780
  },
771
781
  setSubscriptionPaymentMethod(e, t) {
772
- return u(R, `/me/subscriptions/${d(e)}/payment-method`, {
782
+ return u(L, `/me/subscriptions/${d(e)}/payment-method`, {
773
783
  method: "PUT",
774
784
  body: { payment_method_id: t }
775
785
  });
776
786
  },
777
787
  previewSubscriptionChange(e, t, n) {
778
- return u(pe, `/me/subscriptions/${d(e)}/change/preview`, {
788
+ return u(me, `/me/subscriptions/${d(e)}/change/preview`, {
779
789
  method: "POST",
780
790
  body: {
781
791
  price_id: t.priceId,
@@ -808,17 +818,17 @@ function De(e = {}) {
808
818
  });
809
819
  },
810
820
  addPaymentMethod(e, t) {
811
- return u(B, "/me/payment-methods", {
821
+ return u(z, "/me/payment-methods", {
812
822
  method: "POST",
813
823
  body: e,
814
824
  headers: t ? { "Idempotency-Key": t } : void 0
815
825
  });
816
826
  },
817
827
  getCart(e) {
818
- return u(K, "/me/cart", { signal: e });
828
+ return u(G, "/me/cart", { signal: e });
819
829
  },
820
830
  setCartLine(e, t = {}) {
821
- return u(K, `/me/cart/lines/${d(e)}`, {
831
+ return u(G, `/me/cart/lines/${d(e)}`, {
822
832
  method: "PUT",
823
833
  body: t
824
834
  });
@@ -851,7 +861,7 @@ function De(e = {}) {
851
861
  });
852
862
  },
853
863
  getOrder(e, t) {
854
- return u(U, `/me/orders/${d(e)}`, { signal: t });
864
+ return u(H, `/me/orders/${d(e)}`, { signal: t });
855
865
  },
856
866
  payOrder(e, t) {
857
867
  return v(`/me/orders/${d(e)}/pay`, {
@@ -871,7 +881,7 @@ function De(e = {}) {
871
881
  });
872
882
  },
873
883
  confirmPaymentMethod(e, t) {
874
- return u(B, `/me/payment-methods/${d(e)}/confirm`, {
884
+ return u(z, `/me/payment-methods/${d(e)}/confirm`, {
875
885
  method: "POST",
876
886
  body: t ? { capture: t } : {}
877
887
  });
@@ -895,10 +905,19 @@ function De(e = {}) {
895
905
  });
896
906
  },
897
907
  getAccount(e) {
898
- return u(le, "/me", { signal: e });
908
+ return u(ue, "/me", { signal: e });
909
+ },
910
+ setLowBalanceLine(e) {
911
+ return u(q, `/me/low-balance-lines/${d(e.currency.toUpperCase())}`, {
912
+ method: "PUT",
913
+ body: {
914
+ amount: e.amount,
915
+ runway_hours: e.runwayHours
916
+ }
917
+ });
899
918
  },
900
919
  getUsage(e) {
901
- return u(de, "/me/usage", {
920
+ return u(fe, "/me/usage", {
902
921
  query: {
903
922
  currency: e.currency,
904
923
  group_by: e.groupBy,
@@ -924,13 +943,13 @@ function De(e = {}) {
924
943
  });
925
944
  },
926
945
  createNetworkLinkChallenge() {
927
- return u(ye, "/me/network-link/challenges", {
946
+ return u(be, "/me/network-link/challenges", {
928
947
  method: "POST",
929
948
  body: {}
930
949
  });
931
950
  },
932
951
  createNetworkLink(e) {
933
- return u(be, "/me/network-link", {
952
+ return u(xe, "/me/network-link", {
934
953
  method: "POST",
935
954
  body: {
936
955
  challenge_id: e.challengeId,
@@ -939,22 +958,22 @@ function De(e = {}) {
939
958
  });
940
959
  },
941
960
  getConfig(e) {
942
- return u(_e, "/config", {
961
+ return u(ve, "/config", {
943
962
  signal: e,
944
963
  public: !0
945
964
  });
946
965
  },
947
966
  getCustomerConfig(e) {
948
- return u(ve, "/me/config", { signal: e });
967
+ return u(ye, "/me/config", { signal: e });
949
968
  },
950
969
  currencies: o
951
970
  };
952
971
  }
953
- function Oe(e) {
972
+ function ke(e) {
954
973
  return Object.fromEntries(Object.entries(e).map(([e, t]) => [e.toUpperCase(), t]));
955
974
  }
956
975
  var $ = (e) => e instanceof Y || e instanceof Error && e.name === "WalletRejectedError" || e instanceof t && e.code === "wallet_rejected";
957
976
  //#endregion
958
- export { t as C, a as D, i as E, o as O, c as S, r as T, p as _, De as a, u as b, X as c, E as d, ie as f, _ as g, v as h, Y as i, te as l, S as m, xe as n, Ce as o, ae as p, we as r, $ as s, Se as t, re as u, g as v, n as w, l as x, d as y };
977
+ export { t as C, a as D, i as E, o as O, c as S, r as T, p as _, Oe as a, u as b, we as c, E as d, ie as f, _ as g, v as h, Y as i, te as l, S as m, Se as n, X as o, ae as p, Te as r, $ as s, Ce as t, re as u, g as v, n as w, l as x, d as y };
959
978
 
960
- //# sourceMappingURL=client-D5Af726I.js.map
979
+ //# sourceMappingURL=client-CfiKK7wX.js.map