@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.
- package/README.md +4 -2
- package/dist/{index-iPG0fxzc.d.cts → index-CIjHKuHK.d.cts} +25 -8
- package/dist/{index-iPG0fxzc.d.ts → index-CIjHKuHK.d.ts} +25 -8
- package/dist/index.cjs +20 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +20 -4
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +20 -4
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +20 -4
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -98,8 +98,10 @@ import { setRequestHost } from '@misiki/gocommerce-connector'
|
|
|
98
98
|
setRequestHost(() => getRequestEvent().url.hostname)
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
Each store renders with the name, email and phone its owner set in the panel
|
|
102
|
+
(`GET /api/store`); the static record's values stand only where the owner left
|
|
103
|
+
one empty. Store-level facts (name, plugins, currency, menus) are cached per
|
|
104
|
+
store, so two stores on one process never see each other's. A host under the base domain that names
|
|
103
105
|
a store the engine does not have makes `getStoreByIdOrDomain` throw a
|
|
104
106
|
`GoCommerceError` with status 404 and "store not found" in its message, which
|
|
105
107
|
Svelte Commerce renders as its own "Store not found" page. An engine that is
|
|
@@ -346,6 +346,14 @@ type Plugin = {
|
|
|
346
346
|
title: string;
|
|
347
347
|
settings: Record<string, unknown>;
|
|
348
348
|
};
|
|
349
|
+
/** `GET /api/store`: what anyone may read about the shop. */
|
|
350
|
+
type StoreProfile = {
|
|
351
|
+
name: string;
|
|
352
|
+
email: string;
|
|
353
|
+
phone: string;
|
|
354
|
+
support_url: string;
|
|
355
|
+
language: string;
|
|
356
|
+
};
|
|
349
357
|
type Vendor = {
|
|
350
358
|
id: number;
|
|
351
359
|
slug: string;
|
|
@@ -1258,12 +1266,17 @@ declare class StoreFacts extends BaseService {
|
|
|
1258
1266
|
/** Enabled plugins by key. A module that is not installed has no key here. */
|
|
1259
1267
|
plugins(): Promise<Map<string, Plugin>>;
|
|
1260
1268
|
pluginOn(key: string): Promise<boolean>;
|
|
1261
|
-
/**
|
|
1269
|
+
/**
|
|
1270
|
+
* The store's settlement currency and default language, from routes bound
|
|
1271
|
+
* to the store: `/health/ready` answers for the install, so on a shared
|
|
1272
|
+
* engine every store read as the install's currency.
|
|
1273
|
+
*/
|
|
1262
1274
|
ready(): Promise<{
|
|
1263
1275
|
currency: string;
|
|
1264
1276
|
language: string;
|
|
1265
|
-
version: string;
|
|
1266
1277
|
}>;
|
|
1278
|
+
/** The store's own name and how a buyer reaches it, as set in its panel. */
|
|
1279
|
+
profile(): Promise<StoreProfile>;
|
|
1267
1280
|
checkoutOptions(): Promise<CheckoutOptions>;
|
|
1268
1281
|
/**
|
|
1269
1282
|
* The whole tree, flat and depth-first. Past 500 categories the engine
|
|
@@ -5232,12 +5245,16 @@ declare const menuService: MenuService;
|
|
|
5232
5245
|
/**
|
|
5233
5246
|
* The store record every page renders from.
|
|
5234
5247
|
*
|
|
5235
|
-
*
|
|
5248
|
+
* Logo, theme and the rest are the storefront's own (its static store,
|
|
5236
5249
|
* registered through `setStaticStore`); the engine has no opinion on them.
|
|
5237
|
-
* Where the engine does have one, it wins:
|
|
5238
|
-
*
|
|
5239
|
-
*
|
|
5240
|
-
*
|
|
5250
|
+
* Where the engine does have one, it wins:
|
|
5251
|
+
* - the store's name and contact, as its owner set them in the panel. One
|
|
5252
|
+
* storefront serves every store under `baseDomain`, so a name in the static
|
|
5253
|
+
* record would be every store's name;
|
|
5254
|
+
* - the settlement currency. Every price on the site is formatted with it, and
|
|
5255
|
+
* a store record saying USD over an engine charging INR would print the
|
|
5256
|
+
* wrong symbol on every price;
|
|
5257
|
+
* - the modules that back a storefront feature, and the menus.
|
|
5241
5258
|
*
|
|
5242
5259
|
* This runs on every request and a throw here takes every page down, so the
|
|
5243
5260
|
* engine's half is best-effort: unreachable, the storefront still renders
|
|
@@ -6489,4 +6506,4 @@ declare class B2bService extends BaseService {
|
|
|
6489
6506
|
}
|
|
6490
6507
|
declare const b2bService: B2bService;
|
|
6491
6508
|
|
|
6492
|
-
export { type Menu as $, type Address as A, type B2bPlaced as B, type Cart as C, CountryService as D, CouponService as E, type Credentials as F, type Credit as G, CurrencyService as H, type Customer as I, DealService as J, DemoRequestService as K, type EngineRequest as L, EnquiryService as M, type Envelope as N, type Faq as O, FaqService as P, FeedbackService as Q, type Fulfillment as R, GalleryService as S, HomeService as T, type IdentityAddress as U, InitService as V, type Invitation as W, type Lead as X, type ListMeta as Y, MeilisearchService as Z, type Member as _, AddressService as a,
|
|
6509
|
+
export { type Menu as $, type Address as A, type B2bPlaced as B, type Cart as C, CountryService as D, CouponService as E, type Credentials as F, type Credit as G, CurrencyService as H, type Customer as I, DealService as J, DemoRequestService as K, type EngineRequest as L, EnquiryService as M, type Envelope as N, type Faq as O, FaqService as P, FeedbackService as Q, type Fulfillment as R, GalleryService as S, HomeService as T, type IdentityAddress as U, InitService as V, type Invitation as W, type Lead as X, type ListMeta as Y, MeilisearchService as Z, type Member as _, AddressService as a, collectionService as a$, type MenuItem as a0, MenuService as a1, type MenuSummary as a2, type Money as a3, NewsletterService as a4, type Offer as a5, type Order as a6, type OrderLine as a7, OrderService as a8, PageService as a9, type StorefrontCategory as aA, type StorefrontMenu as aB, type StorefrontOrder as aC, type StorefrontProduct as aD, UploadService as aE, UserService as aF, type Variant as aG, type VariantImage as aH, VariantService as aI, VarniCustomDesignService as aJ, VarniCustomProductService as aK, type Vendor as aL, VendorService as aM, WarrantyService as aN, type Wishlist as aO, type WishlistItem as aP, WishlistService as aQ, addressService as aR, authService as aS, autocompleteService as aT, b2bService as aU, bannerService as aV, blogService as aW, cartService as aX, categoryService as aY, chatService as aZ, checkoutService as a_, type PaymentIntent as aa, PaymentMethodService as ab, type Plugin as ac, PluginService as ad, PopularSearchService as ae, PopularityService as af, type Product as ag, type ProductOption as ah, ProductService as ai, ProfileService as aj, type Quote as ak, REDIRECT_GATEWAYS as al, ReelsService as am, RegionService as an, type RejectedLine as ao, type Review as ap, type ReviewPage as aq, ReviewService as ar, type SearchDoc as as, type SearchResult as at, SearchService as au, SettingService as av, type ShippingRate as aw, StateService as ax, type StoreProfile as ay, StoreService as az, type AppliedDiscount as b, userService as b$, contactService as b0, countryService as b1, couponService as b2, currencyExponent as b3, currencyService as b4, dealService as b5, demoRequestService as b6, emptyCart as b7, emptyPage as b8, enquiryService as b9, regionService as bA, reviewService as bB, searchService as bC, setRequestHost as bD, settingService as bE, settingsService as bF, stateService as bG, staticStore as bH, storeForHost as bI, storeService as bJ, toCart as bK, toCartLine as bL, toCategory as bM, toCmsPage as bN, toCollection as bO, toEngineAddress as bP, toIdentityAddress as bQ, toMajor as bR, toMinor as bS, toOrder as bT, toPage as bU, toProduct as bV, toRating as bW, toUser as bX, toVariant as bY, toVendor as bZ, uploadService as b_, faqService as ba, feedbackService as bb, fromEngineAddress as bc, fromIdentityAddress as bd, fromSearchDoc as be, galleryService as bf, homeService as bg, initService as bh, mediaUrl as bi, meilisearchService as bj, menuService as bk, minorToMajor as bl, newsletterService as bm, orderService as bn, pageService as bo, paymentMethodService as bp, pluginService as bq, pluginsService as br, popularSearchService as bs, popularityService as bt, priceOf as bu, productImages as bv, productService as bw, profileService as bx, qs as by, reelsService as bz, type Approval as c, variantService as c0, varniCustomDesignService as c1, varniCustomProductService as c2, vendorService as c3, warrantyService as c4, wishlistService as c5, type AuthResponse as d, AuthService as e, AutocompleteService as f, type B2bRole as g, B2bService as h, BannerService as i, BaseService as j, BlogService as k, type CartLine as l, CartService as m, CatalogService as n, type Category as o, CategoryService as p, ChatService as q, type CheckoutOptions as r, type CheckoutResult as s, CheckoutService as t, type CmsPage as u, type Collection as v, CollectionService as w, type Company as x, type CompanyOrder as y, ContactService as z };
|
|
@@ -346,6 +346,14 @@ type Plugin = {
|
|
|
346
346
|
title: string;
|
|
347
347
|
settings: Record<string, unknown>;
|
|
348
348
|
};
|
|
349
|
+
/** `GET /api/store`: what anyone may read about the shop. */
|
|
350
|
+
type StoreProfile = {
|
|
351
|
+
name: string;
|
|
352
|
+
email: string;
|
|
353
|
+
phone: string;
|
|
354
|
+
support_url: string;
|
|
355
|
+
language: string;
|
|
356
|
+
};
|
|
349
357
|
type Vendor = {
|
|
350
358
|
id: number;
|
|
351
359
|
slug: string;
|
|
@@ -1258,12 +1266,17 @@ declare class StoreFacts extends BaseService {
|
|
|
1258
1266
|
/** Enabled plugins by key. A module that is not installed has no key here. */
|
|
1259
1267
|
plugins(): Promise<Map<string, Plugin>>;
|
|
1260
1268
|
pluginOn(key: string): Promise<boolean>;
|
|
1261
|
-
/**
|
|
1269
|
+
/**
|
|
1270
|
+
* The store's settlement currency and default language, from routes bound
|
|
1271
|
+
* to the store: `/health/ready` answers for the install, so on a shared
|
|
1272
|
+
* engine every store read as the install's currency.
|
|
1273
|
+
*/
|
|
1262
1274
|
ready(): Promise<{
|
|
1263
1275
|
currency: string;
|
|
1264
1276
|
language: string;
|
|
1265
|
-
version: string;
|
|
1266
1277
|
}>;
|
|
1278
|
+
/** The store's own name and how a buyer reaches it, as set in its panel. */
|
|
1279
|
+
profile(): Promise<StoreProfile>;
|
|
1267
1280
|
checkoutOptions(): Promise<CheckoutOptions>;
|
|
1268
1281
|
/**
|
|
1269
1282
|
* The whole tree, flat and depth-first. Past 500 categories the engine
|
|
@@ -5232,12 +5245,16 @@ declare const menuService: MenuService;
|
|
|
5232
5245
|
/**
|
|
5233
5246
|
* The store record every page renders from.
|
|
5234
5247
|
*
|
|
5235
|
-
*
|
|
5248
|
+
* Logo, theme and the rest are the storefront's own (its static store,
|
|
5236
5249
|
* registered through `setStaticStore`); the engine has no opinion on them.
|
|
5237
|
-
* Where the engine does have one, it wins:
|
|
5238
|
-
*
|
|
5239
|
-
*
|
|
5240
|
-
*
|
|
5250
|
+
* Where the engine does have one, it wins:
|
|
5251
|
+
* - the store's name and contact, as its owner set them in the panel. One
|
|
5252
|
+
* storefront serves every store under `baseDomain`, so a name in the static
|
|
5253
|
+
* record would be every store's name;
|
|
5254
|
+
* - the settlement currency. Every price on the site is formatted with it, and
|
|
5255
|
+
* a store record saying USD over an engine charging INR would print the
|
|
5256
|
+
* wrong symbol on every price;
|
|
5257
|
+
* - the modules that back a storefront feature, and the menus.
|
|
5241
5258
|
*
|
|
5242
5259
|
* This runs on every request and a throw here takes every page down, so the
|
|
5243
5260
|
* engine's half is best-effort: unreachable, the storefront still renders
|
|
@@ -6489,4 +6506,4 @@ declare class B2bService extends BaseService {
|
|
|
6489
6506
|
}
|
|
6490
6507
|
declare const b2bService: B2bService;
|
|
6491
6508
|
|
|
6492
|
-
export { type Menu as $, type Address as A, type B2bPlaced as B, type Cart as C, CountryService as D, CouponService as E, type Credentials as F, type Credit as G, CurrencyService as H, type Customer as I, DealService as J, DemoRequestService as K, type EngineRequest as L, EnquiryService as M, type Envelope as N, type Faq as O, FaqService as P, FeedbackService as Q, type Fulfillment as R, GalleryService as S, HomeService as T, type IdentityAddress as U, InitService as V, type Invitation as W, type Lead as X, type ListMeta as Y, MeilisearchService as Z, type Member as _, AddressService as a,
|
|
6509
|
+
export { type Menu as $, type Address as A, type B2bPlaced as B, type Cart as C, CountryService as D, CouponService as E, type Credentials as F, type Credit as G, CurrencyService as H, type Customer as I, DealService as J, DemoRequestService as K, type EngineRequest as L, EnquiryService as M, type Envelope as N, type Faq as O, FaqService as P, FeedbackService as Q, type Fulfillment as R, GalleryService as S, HomeService as T, type IdentityAddress as U, InitService as V, type Invitation as W, type Lead as X, type ListMeta as Y, MeilisearchService as Z, type Member as _, AddressService as a, collectionService as a$, type MenuItem as a0, MenuService as a1, type MenuSummary as a2, type Money as a3, NewsletterService as a4, type Offer as a5, type Order as a6, type OrderLine as a7, OrderService as a8, PageService as a9, type StorefrontCategory as aA, type StorefrontMenu as aB, type StorefrontOrder as aC, type StorefrontProduct as aD, UploadService as aE, UserService as aF, type Variant as aG, type VariantImage as aH, VariantService as aI, VarniCustomDesignService as aJ, VarniCustomProductService as aK, type Vendor as aL, VendorService as aM, WarrantyService as aN, type Wishlist as aO, type WishlistItem as aP, WishlistService as aQ, addressService as aR, authService as aS, autocompleteService as aT, b2bService as aU, bannerService as aV, blogService as aW, cartService as aX, categoryService as aY, chatService as aZ, checkoutService as a_, type PaymentIntent as aa, PaymentMethodService as ab, type Plugin as ac, PluginService as ad, PopularSearchService as ae, PopularityService as af, type Product as ag, type ProductOption as ah, ProductService as ai, ProfileService as aj, type Quote as ak, REDIRECT_GATEWAYS as al, ReelsService as am, RegionService as an, type RejectedLine as ao, type Review as ap, type ReviewPage as aq, ReviewService as ar, type SearchDoc as as, type SearchResult as at, SearchService as au, SettingService as av, type ShippingRate as aw, StateService as ax, type StoreProfile as ay, StoreService as az, type AppliedDiscount as b, userService as b$, contactService as b0, countryService as b1, couponService as b2, currencyExponent as b3, currencyService as b4, dealService as b5, demoRequestService as b6, emptyCart as b7, emptyPage as b8, enquiryService as b9, regionService as bA, reviewService as bB, searchService as bC, setRequestHost as bD, settingService as bE, settingsService as bF, stateService as bG, staticStore as bH, storeForHost as bI, storeService as bJ, toCart as bK, toCartLine as bL, toCategory as bM, toCmsPage as bN, toCollection as bO, toEngineAddress as bP, toIdentityAddress as bQ, toMajor as bR, toMinor as bS, toOrder as bT, toPage as bU, toProduct as bV, toRating as bW, toUser as bX, toVariant as bY, toVendor as bZ, uploadService as b_, faqService as ba, feedbackService as bb, fromEngineAddress as bc, fromIdentityAddress as bd, fromSearchDoc as be, galleryService as bf, homeService as bg, initService as bh, mediaUrl as bi, meilisearchService as bj, menuService as bk, minorToMajor as bl, newsletterService as bm, orderService as bn, pageService as bo, paymentMethodService as bp, pluginService as bq, pluginsService as br, popularSearchService as bs, popularityService as bt, priceOf as bu, productImages as bv, productService as bw, profileService as bx, qs as by, reelsService as bz, type Approval as c, variantService as c0, varniCustomDesignService as c1, varniCustomProductService as c2, vendorService as c3, warrantyService as c4, wishlistService as c5, type AuthResponse as d, AuthService as e, AutocompleteService as f, type B2bRole as g, B2bService as h, BannerService as i, BaseService as j, BlogService as k, type CartLine as l, CartService as m, CatalogService as n, type Category as o, CategoryService as p, ChatService as q, type CheckoutOptions as r, type CheckoutResult as s, CheckoutService as t, type CmsPage as u, type Collection as v, CollectionService as w, type Company as x, type CompanyOrder as y, ContactService as z };
|
package/dist/index.cjs
CHANGED
|
@@ -1007,9 +1007,20 @@ var StoreFacts = class extends BaseService {
|
|
|
1007
1007
|
return false;
|
|
1008
1008
|
}
|
|
1009
1009
|
}
|
|
1010
|
-
/**
|
|
1010
|
+
/**
|
|
1011
|
+
* The store's settlement currency and default language, from routes bound
|
|
1012
|
+
* to the store: `/health/ready` answers for the install, so on a shared
|
|
1013
|
+
* engine every store read as the install's currency.
|
|
1014
|
+
*/
|
|
1011
1015
|
ready() {
|
|
1012
|
-
return remember(this.key("ready"), () =>
|
|
1016
|
+
return remember(this.key("ready"), async () => {
|
|
1017
|
+
const [{ currency }, { language }] = await Promise.all([this.checkoutOptions(), this.profile()]);
|
|
1018
|
+
return { currency, language };
|
|
1019
|
+
});
|
|
1020
|
+
}
|
|
1021
|
+
/** The store's own name and how a buyer reaches it, as set in its panel. */
|
|
1022
|
+
profile() {
|
|
1023
|
+
return remember(this.key("profile"), () => this.data("/api/store"));
|
|
1013
1024
|
}
|
|
1014
1025
|
checkoutOptions() {
|
|
1015
1026
|
return remember(this.key("checkout"), () => this.data("/api/checkout"));
|
|
@@ -2513,17 +2524,22 @@ var StoreService = class extends BaseService {
|
|
|
2513
2524
|
return super.post(path, data);
|
|
2514
2525
|
}
|
|
2515
2526
|
async live() {
|
|
2516
|
-
const [ready, plugins, menus, base] = await Promise.all([
|
|
2527
|
+
const [ready, plugins, menus, base, profile] = await Promise.all([
|
|
2517
2528
|
this.facts.ready(),
|
|
2518
2529
|
this.facts.plugins().catch(() => /* @__PURE__ */ new Map()),
|
|
2519
2530
|
new MenuService(this._fetch).engineMenus(),
|
|
2520
|
-
readStaticStore()
|
|
2531
|
+
readStaticStore(),
|
|
2532
|
+
this.facts.profile().catch(() => null)
|
|
2521
2533
|
]);
|
|
2522
2534
|
const code = ready.currency;
|
|
2523
2535
|
const sameCurrency = (base.currency?.code ?? base.currencyCode) === code;
|
|
2524
2536
|
const flag = (on) => ({ ...on ? { active: true } : { active: false } });
|
|
2525
2537
|
const basePlugins = base.plugins ?? {};
|
|
2526
2538
|
return {
|
|
2539
|
+
// Only what the owner filled in: an empty name keeps the static one.
|
|
2540
|
+
...profile?.name ? { name: profile.name } : {},
|
|
2541
|
+
...profile?.email ? { businessEmail: profile.email } : {},
|
|
2542
|
+
...profile?.phone ? { businessPhone: profile.phone } : {},
|
|
2527
2543
|
currencyCode: code,
|
|
2528
2544
|
currencySymbol: sameCurrency ? base.currencySymbol ?? symbolFor(code) : symbolFor(code),
|
|
2529
2545
|
currency: {
|