@misiki/gocommerce-connector 0.4.0 → 0.4.2

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.
@@ -988,9 +988,20 @@ var StoreFacts = class extends BaseService {
988
988
  return false;
989
989
  }
990
990
  }
991
- /** The store's settlement currency and default language. */
991
+ /**
992
+ * The store's settlement currency and default language, from routes bound
993
+ * to the store: `/health/ready` answers for the install, so on a shared
994
+ * engine every store read as the install's currency.
995
+ */
992
996
  ready() {
993
- return remember(this.key("ready"), () => this.data("/health/ready"));
997
+ return remember(this.key("ready"), async () => {
998
+ const [{ currency }, { language }] = await Promise.all([this.checkoutOptions(), this.profile()]);
999
+ return { currency, language };
1000
+ });
1001
+ }
1002
+ /** The store's own name and how a buyer reaches it, as set in its panel. */
1003
+ profile() {
1004
+ return remember(this.key("profile"), () => this.data("/api/store"));
994
1005
  }
995
1006
  checkoutOptions() {
996
1007
  return remember(this.key("checkout"), () => this.data("/api/checkout"));
@@ -2497,17 +2508,22 @@ var StoreService = class extends BaseService {
2497
2508
  return super.post(path, data);
2498
2509
  }
2499
2510
  async live() {
2500
- const [ready, plugins, menus, base] = await Promise.all([
2511
+ const [ready, plugins, menus, base, profile] = await Promise.all([
2501
2512
  this.facts.ready(),
2502
2513
  this.facts.plugins().catch(() => /* @__PURE__ */ new Map()),
2503
2514
  new MenuService(this._fetch).engineMenus(),
2504
- readStaticStore()
2515
+ readStaticStore(),
2516
+ this.facts.profile().catch(() => null)
2505
2517
  ]);
2506
2518
  const code = ready.currency;
2507
2519
  const sameCurrency = (base.currency?.code ?? base.currencyCode) === code;
2508
2520
  const flag = (on) => ({ ...on ? { active: true } : { active: false } });
2509
2521
  const basePlugins = base.plugins ?? {};
2510
2522
  return {
2523
+ // Only what the owner filled in: an empty name keeps the static one.
2524
+ ...profile?.name ? { name: profile.name } : {},
2525
+ ...profile?.email ? { businessEmail: profile.email } : {},
2526
+ ...profile?.phone ? { businessPhone: profile.phone } : {},
2511
2527
  currencyCode: code,
2512
2528
  currencySymbol: sameCurrency ? base.currencySymbol ?? symbolFor(code) : symbolFor(code),
2513
2529
  currency: {