@occluze/tether 0.6.8 → 0.7.1
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 +28 -28
- package/dist/esm/astro.js +2 -2
- package/dist/esm/chunks/account-CXMA5RPZ.js +1 -0
- package/dist/esm/chunks/account-pages-IZO7FEOZ.js +1 -0
- package/dist/esm/chunks/analytics-PG5FPRDN.js +1 -0
- package/dist/esm/chunks/chunk-4HD4J5JC.js +1 -0
- package/dist/esm/chunks/chunk-6TFMLT4A.js +4 -0
- package/dist/esm/chunks/chunk-BBVUVPMO.js +1 -0
- package/dist/esm/chunks/chunk-E5YO6274.js +1 -0
- package/dist/esm/chunks/chunk-EW5SYO6L.js +1 -0
- package/dist/esm/chunks/chunk-HJY2JSNB.js +1 -0
- package/dist/esm/chunks/chunk-MQYB6BH4.js +1 -0
- package/dist/esm/chunks/chunk-N3V45JPS.js +1 -0
- package/dist/esm/chunks/chunk-RPMBCAGS.js +1 -0
- package/dist/esm/chunks/chunk-VFNHIGCS.js +1 -0
- package/dist/esm/chunks/chunk-WT7RGGJU.js +1 -0
- package/dist/esm/chunks/chunk-YN6LEBEN.js +1 -0
- package/dist/esm/chunks/chunk-Z6HS3H7K.js +1 -0
- package/dist/esm/chunks/diagnose-XCEBQKBO.js +14 -0
- package/dist/esm/chunks/extras-4HU3VSBQ.js +1 -0
- package/dist/esm/chunks/markets-ui-M4IQ62CT.js +1 -0
- package/dist/esm/chunks/search-A5DS2IOS.js +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/server.js +2 -2
- package/dist/presets/barba.esm.js +19 -23
- package/dist/tether.account-pages.js +332 -367
- package/dist/tether.account-pages.min.js +1 -1
- package/dist/tether.account.js +253 -492
- package/dist/tether.account.min.js +1 -1
- package/dist/tether.analytics.js +82 -89
- package/dist/tether.analytics.min.js +1 -1
- package/dist/tether.diagnose.js +52 -34
- package/dist/tether.diagnose.min.js +2 -2
- package/dist/tether.extras.js +42 -37
- package/dist/tether.extras.min.js +1 -1
- package/dist/tether.js +1361 -935
- package/dist/tether.markets.js +89 -91
- package/dist/tether.markets.min.js +1 -1
- package/dist/tether.min.js +0 -0
- package/dist/tether.min.js.map +4 -4
- package/dist/tether.search.js +60 -69
- package/dist/tether.search.min.js +1 -1
- package/dist/types/server/src/shared/account-orders.d.ts +44 -0
- package/dist/types/server/src/shared/account-routes.d.ts +153 -0
- package/dist/types/server/src/shared/api-versions.d.ts +13 -0
- package/dist/types/server/src/shared/cart-id.d.ts +2 -0
- package/dist/types/server/src/shared/error-message.d.ts +2 -0
- package/dist/types/server/src/shared/json.d.ts +25 -0
- package/dist/types/server/src/shared/market-codes.d.ts +16 -0
- package/dist/types/src/account/addresses-view.d.ts +5 -0
- package/dist/types/src/account/answers.d.ts +40 -0
- package/dist/types/src/account/markup.d.ts +19 -0
- package/dist/types/src/account/operations.d.ts +41 -0
- package/dist/types/src/account/order-lines.d.ts +13 -0
- package/dist/types/src/account/order-list.d.ts +12 -0
- package/dist/types/src/account/order-page.d.ts +6 -0
- package/dist/types/src/account/page-answers.d.ts +182 -0
- package/dist/types/src/account/page-events.d.ts +2 -0
- package/dist/types/src/account/server-client.d.ts +60 -0
- package/dist/types/src/account/subscriptions-view.d.ts +2 -0
- package/dist/types/src/account-api.d.ts +18 -0
- package/dist/types/src/account-marks.d.ts +15 -0
- package/dist/types/src/account-pages.d.ts +8 -0
- package/dist/types/src/account.d.ts +64 -0
- package/dist/types/src/amounts.d.ts +12 -0
- package/dist/types/src/analytics-shopify.d.ts +41 -0
- package/dist/types/src/analytics.d.ts +2 -0
- package/dist/types/src/api-version.d.ts +28 -0
- package/dist/types/src/astro.d.ts +42 -0
- package/dist/types/src/cart/cart-shape.d.ts +43 -0
- package/dist/types/src/cart/checkout.d.ts +16 -0
- package/dist/types/src/cart/drawer.d.ts +18 -0
- package/dist/types/src/cart/mutations.d.ts +85 -0
- package/dist/types/src/cart/render.d.ts +17 -0
- package/dist/types/src/cart/store.d.ts +185 -0
- package/dist/types/src/cart.d.ts +106 -0
- package/dist/types/src/client.d.ts +134 -0
- package/dist/types/src/collection.d.ts +25 -0
- package/dist/types/src/config-sections.d.ts +40 -0
- package/dist/types/src/config.d.ts +190 -0
- package/dist/types/src/controls/cart-controls.d.ts +2 -0
- package/dist/types/src/controls/discount.d.ts +2 -0
- package/dist/types/src/controls/extras.d.ts +5 -0
- package/dist/types/src/controls/navigation.d.ts +12 -0
- package/dist/types/src/diagnose-markup.d.ts +19 -0
- package/dist/types/src/diagnose.d.ts +60 -0
- package/dist/types/src/dom.d.ts +75 -0
- package/dist/types/src/extras.d.ts +21 -0
- package/dist/types/src/fragments.d.ts +158 -0
- package/dist/types/src/globals.d.ts +15 -0
- package/dist/types/src/images.d.ts +20 -0
- package/dist/types/src/index.d.ts +167 -0
- package/dist/types/src/initial.d.ts +56 -0
- package/dist/types/src/lazy.d.ts +28 -0
- package/dist/types/src/loader.d.ts +84 -0
- package/dist/types/src/market-codes.d.ts +6 -0
- package/dist/types/src/markets-ui.d.ts +32 -0
- package/dist/types/src/markets.d.ts +72 -0
- package/dist/types/src/markup.d.ts +131 -0
- package/dist/types/src/mounting.d.ts +46 -0
- package/dist/types/src/page-market.d.ts +27 -0
- package/dist/types/src/presets/barba.d.ts +56 -0
- package/dist/types/src/product-events.d.ts +2 -0
- package/dist/types/src/product-render.d.ts +17 -0
- package/dist/types/src/product-shape.d.ts +90 -0
- package/dist/types/src/product-state.d.ts +110 -0
- package/dist/types/src/product.d.ts +66 -0
- package/dist/types/src/repeaters.d.ts +16 -0
- package/dist/types/src/search.d.ts +33 -0
- package/dist/types/src/selling-plans.d.ts +64 -0
- package/dist/types/src/server.d.ts +88 -0
- package/dist/types/src/shopify-values.d.ts +46 -0
- package/dist/types/src/status.d.ts +33 -0
- package/dist/types/src/storage.d.ts +12 -0
- package/dist/types/src/store-html.d.ts +39 -0
- package/dist/types/src/storefront/catalog.d.ts +38 -0
- package/dist/types/src/storefront/json-ld.d.ts +20 -0
- package/dist/types/src/variant-render.d.ts +14 -0
- package/package.json +24 -24
- package/dist/esm/chunks/account-C3NP6HFB.js +0 -1
- package/dist/esm/chunks/account-pages-WLK374FO.js +0 -1
- package/dist/esm/chunks/analytics-G3SAWMNL.js +0 -1
- package/dist/esm/chunks/chunk-27PJJZGC.js +0 -1
- package/dist/esm/chunks/chunk-2FSXS55U.js +0 -1
- package/dist/esm/chunks/chunk-FCSWQDVV.js +0 -1
- package/dist/esm/chunks/chunk-FOMSMIAM.js +0 -1
- package/dist/esm/chunks/chunk-GZJTCLLW.js +0 -1
- package/dist/esm/chunks/chunk-HEQILZVR.js +0 -1
- package/dist/esm/chunks/chunk-JOOEXYF3.js +0 -4
- package/dist/esm/chunks/chunk-MPTQYLSM.js +0 -1
- package/dist/esm/chunks/chunk-NEHZ37TU.js +0 -3
- package/dist/esm/chunks/chunk-V74KGEJF.js +0 -1
- package/dist/esm/chunks/chunk-VT4CDUJJ.js +0 -1
- package/dist/esm/chunks/chunk-YJLWX2HK.js +0 -1
- package/dist/esm/chunks/diagnose-6VVGZNTY.js +0 -14
- package/dist/esm/chunks/extras-GJVRDFM3.js +0 -1
- package/dist/esm/chunks/markets-ui-UNB4PTA7.js +0 -1
- package/dist/esm/chunks/search-OU75RNQL.js +0 -1
- package/src/account/addresses-view.js +0 -92
- package/src/account/browser-session.js +0 -359
- package/src/account/markup.js +0 -48
- package/src/account/operations.js +0 -180
- package/src/account/order-lines.js +0 -96
- package/src/account/order-list.js +0 -91
- package/src/account/order-page.js +0 -192
- package/src/account/page-events.js +0 -288
- package/src/account/server-client.js +0 -172
- package/src/account/shared.js +0 -111
- package/src/account/shopify-auth.js +0 -150
- package/src/account/subscriptions-view.js +0 -158
- package/src/account-api.js +0 -118
- package/src/account-links.js +0 -35
- package/src/account-pages.js +0 -89
- package/src/account.js +0 -342
- package/src/amounts.js +0 -36
- package/src/analytics-shopify.js +0 -241
- package/src/analytics.js +0 -352
- package/src/api-version.js +0 -85
- package/src/astro.js +0 -266
- package/src/cart/checkout.js +0 -97
- package/src/cart/drawer.js +0 -138
- package/src/cart/mutations.js +0 -234
- package/src/cart/render.js +0 -294
- package/src/cart/store.js +0 -326
- package/src/cart.js +0 -391
- package/src/client.js +0 -267
- package/src/collection.js +0 -183
- package/src/config.js +0 -349
- package/src/controls/cart-controls.js +0 -155
- package/src/controls/discount.js +0 -96
- package/src/controls/extras.js +0 -63
- package/src/controls/navigation.js +0 -83
- package/src/diagnose-markup.js +0 -333
- package/src/diagnose.js +0 -295
- package/src/dom.js +0 -287
- package/src/extras.js +0 -145
- package/src/fragments.js +0 -237
- package/src/images.js +0 -104
- package/src/index.js +0 -353
- package/src/initial.js +0 -87
- package/src/lazy-iife.js +0 -116
- package/src/lazy.js +0 -39
- package/src/loader.js +0 -337
- package/src/market-codes.js +0 -35
- package/src/markets-ui.js +0 -204
- package/src/markets.js +0 -334
- package/src/markup.js +0 -64
- package/src/mounting.js +0 -277
- package/src/page-market.js +0 -116
- package/src/parts/account-pages.js +0 -6
- package/src/parts/account.js +0 -6
- package/src/parts/analytics.js +0 -6
- package/src/parts/diagnose.js +0 -6
- package/src/parts/extras.js +0 -6
- package/src/parts/markets.js +0 -6
- package/src/parts/search.js +0 -6
- package/src/presets/barba.js +0 -190
- package/src/product-events.js +0 -130
- package/src/product-render.js +0 -257
- package/src/product-state.js +0 -318
- package/src/product.js +0 -344
- package/src/repeaters.js +0 -173
- package/src/search.js +0 -323
- package/src/selling-plans.js +0 -154
- package/src/server.js +0 -215
- package/src/shopify-values.js +0 -89
- package/src/status.js +0 -126
- package/src/store-html.js +0 -0
- package/src/storefront/catalog.js +0 -199
- package/src/storefront/json-ld.js +0 -167
- package/src/variant-render.js +0 -165
- package/types/astro.d.ts +0 -28
- package/types/barba.d.ts +0 -16
- package/types/index.d.ts +0 -577
- package/types/server.d.ts +0 -182
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { AttributeValue } from '../dom.js';
|
|
2
|
+
import type { ShopifyCart, Attribute } from './store.js';
|
|
3
|
+
export type Attributes = Record<string, AttributeValue> | {
|
|
4
|
+
key: string | number;
|
|
5
|
+
value?: AttributeValue;
|
|
6
|
+
}[];
|
|
7
|
+
/** A line to add, in any of the shapes `Cart.add` takes. */
|
|
8
|
+
export interface LineSpec {
|
|
9
|
+
variantId?: string | number;
|
|
10
|
+
merchandiseId?: string | number;
|
|
11
|
+
id?: string | number;
|
|
12
|
+
quantity?: number | string;
|
|
13
|
+
sellingPlanId?: string | number | null;
|
|
14
|
+
sellingPlan?: string | number | null;
|
|
15
|
+
attributes?: Attributes | null;
|
|
16
|
+
}
|
|
17
|
+
/** Shopify's `CartLineInput`. */
|
|
18
|
+
export interface CartLineInput {
|
|
19
|
+
merchandiseId: string;
|
|
20
|
+
quantity: number;
|
|
21
|
+
sellingPlanId?: string;
|
|
22
|
+
attributes?: Attribute[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* @returns True when `error` says Shopify doesn't have the cart, false for any other failure (the network, the token,
|
|
26
|
+
* a line it refused), after which the saved cart is still good.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isCartGone(error: unknown): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* @returns True when a change failed without saying whether Shopify applied it: no answer or no whole body came (the
|
|
31
|
+
* network), a 2xx whose body isn't valid, or a server error (5xx), which can come after the change was committed.
|
|
32
|
+
* Shopify's user errors and a 4xx are clear.
|
|
33
|
+
*/
|
|
34
|
+
export declare function isUnclearFailure(error: unknown): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* @param input A variant id, or a line.
|
|
37
|
+
* @param quantity For a variant id.
|
|
38
|
+
* @param options For a variant id.
|
|
39
|
+
* @throws {TetherError} `ERROR` without a variant id.
|
|
40
|
+
*/
|
|
41
|
+
export declare function toLineInput(input: string | number | LineSpec | null | undefined, quantity?: number, options?: Omit<LineSpec, 'variantId' | 'quantity'>): CartLineInput;
|
|
42
|
+
/** A mutation on the saved cart. */
|
|
43
|
+
interface CartMutation {
|
|
44
|
+
/** The mutation, e.g. `cartLinesAdd`. */
|
|
45
|
+
name: string;
|
|
46
|
+
/** Its variable definitions besides `$cartId`. */
|
|
47
|
+
args: string;
|
|
48
|
+
/** Its arguments besides `cartId`. */
|
|
49
|
+
inner: string;
|
|
50
|
+
variables: Record<string, unknown>;
|
|
51
|
+
/**
|
|
52
|
+
* The `CartInput` of a new cart that does what the mutation asks, when there is no cart (or Shopify no longer has
|
|
53
|
+
* it); `null` leaves the visitor without a cart instead.
|
|
54
|
+
*/
|
|
55
|
+
createInput: Record<string, unknown> | null;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Runs a mutation on the saved cart, or creates a cart from `createInput` when there is none to change.
|
|
59
|
+
*
|
|
60
|
+
* @returns The changed cart; `null` without a cart and without a `createInput`.
|
|
61
|
+
* @throws {TetherError} For a failed request or Shopify's user errors; also when the cart is gone and there is no
|
|
62
|
+
* `createInput` (the saved cart is forgotten first).
|
|
63
|
+
*/
|
|
64
|
+
export declare function mutateCart({ name, args, inner, variables, createInput, }: CartMutation): Promise<ShopifyCart | null>;
|
|
65
|
+
/** @returns The cart, `null` when Shopify doesn't have it (expired or checked out). */
|
|
66
|
+
export declare function fetchCart(id: string): Promise<ShopifyCart | null>;
|
|
67
|
+
/** @returns The cart's current checkout URL, `null` when Shopify doesn't have the cart. */
|
|
68
|
+
export declare function fetchCheckoutUrl(id: string): Promise<string | null>;
|
|
69
|
+
/** A change to one line, for `updateLine`. */
|
|
70
|
+
export interface LinePatch {
|
|
71
|
+
/** 0 or less removes the line. */
|
|
72
|
+
quantity?: number;
|
|
73
|
+
/** `null` switches the line back to one-time purchase. */
|
|
74
|
+
sellingPlanId?: string | number | null;
|
|
75
|
+
attributes?: Attributes;
|
|
76
|
+
merchandiseId?: string | number;
|
|
77
|
+
variantId?: string | number;
|
|
78
|
+
}
|
|
79
|
+
/** @returns Shopify's `CartLineUpdateInput`. */
|
|
80
|
+
export declare function toLineUpdate(lineId: string, patch: number | LinePatch): Record<string, unknown>;
|
|
81
|
+
export declare const updateLines: (lines: Record<string, unknown>[]) => Promise<ShopifyCart | null>;
|
|
82
|
+
export declare const removeLines: (lineIds: string[]) => Promise<ShopifyCart | null>;
|
|
83
|
+
/** @returns The cart once `lineId` has `target` (0 removes it). */
|
|
84
|
+
export declare const setLineQuantity: (lineId: string, target: number) => Promise<ShopifyCart | null>;
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { CartWarning } from '../config.js';
|
|
2
|
+
import type { ShopifyCart, ShopifyCartLine, PendingQuantity } from './store.js';
|
|
3
|
+
/** What a render shows. */
|
|
4
|
+
interface CartView {
|
|
5
|
+
cart: ShopifyCart | null;
|
|
6
|
+
warnings: readonly CartWarning[];
|
|
7
|
+
/** Line id → the quantity quick clicks asked for. */
|
|
8
|
+
pending: ReadonlyMap<string, PendingQuantity>;
|
|
9
|
+
/** The last load or change failed (`tether-show="cart-error"`). */
|
|
10
|
+
failed: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** @returns The quantity to show: the one asked for while an update is on its way. */
|
|
13
|
+
export declare const quantityOf: (line: ShopifyCartLine, pending: ReadonlyMap<string, PendingQuantity>) => number;
|
|
14
|
+
export declare function renderCart(view: CartView): void;
|
|
15
|
+
/** Shows the count a saved cart had on the last page in the cart counts the page left at 0, until it has loaded. */
|
|
16
|
+
export declare function showSavedCount(count: number): void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import type { CartWarning } from '../config.js';
|
|
2
|
+
import type { Image } from '../fragments.js';
|
|
3
|
+
import type { Money } from '../shopify-values.js';
|
|
4
|
+
export interface Attribute {
|
|
5
|
+
key: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
/** A line's `merchandise`: Shopify's `Merchandise` union has only `ProductVariant`. */
|
|
9
|
+
export interface CartVariant {
|
|
10
|
+
id: string;
|
|
11
|
+
title: string;
|
|
12
|
+
sku: string | null;
|
|
13
|
+
availableForSale: boolean;
|
|
14
|
+
requiresShipping: boolean;
|
|
15
|
+
/** Absent when the store's token can't read inventory. */
|
|
16
|
+
quantityAvailable?: number | null;
|
|
17
|
+
image: Image | null;
|
|
18
|
+
price: Money;
|
|
19
|
+
compareAtPrice: Money | null;
|
|
20
|
+
selectedOptions: {
|
|
21
|
+
name: string;
|
|
22
|
+
value: string;
|
|
23
|
+
}[];
|
|
24
|
+
product: {
|
|
25
|
+
id: string;
|
|
26
|
+
title: string;
|
|
27
|
+
handle: string;
|
|
28
|
+
vendor: string;
|
|
29
|
+
featuredImage: Image | null;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
interface LinePlanAllocation {
|
|
33
|
+
sellingPlan: {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
description: string | null;
|
|
37
|
+
recurringDeliveries: boolean;
|
|
38
|
+
options: {
|
|
39
|
+
name: string;
|
|
40
|
+
value: string;
|
|
41
|
+
}[];
|
|
42
|
+
};
|
|
43
|
+
checkoutChargeAmount: Money;
|
|
44
|
+
priceAdjustments: {
|
|
45
|
+
price: Money;
|
|
46
|
+
compareAtPrice: Money;
|
|
47
|
+
perDeliveryPrice: Money;
|
|
48
|
+
}[];
|
|
49
|
+
}
|
|
50
|
+
export interface ShopifyCartLine {
|
|
51
|
+
id: string;
|
|
52
|
+
quantity: number;
|
|
53
|
+
attributes: Attribute[];
|
|
54
|
+
cost: {
|
|
55
|
+
totalAmount: Money;
|
|
56
|
+
subtotalAmount: Money;
|
|
57
|
+
amountPerQuantity: Money;
|
|
58
|
+
compareAtAmountPerQuantity: Money | null;
|
|
59
|
+
};
|
|
60
|
+
discountAllocations: {
|
|
61
|
+
discountedAmount: Money;
|
|
62
|
+
}[];
|
|
63
|
+
sellingPlanAllocation: LinePlanAllocation | null;
|
|
64
|
+
merchandise: CartVariant;
|
|
65
|
+
/** Only on a bundle (`ComponentizableCartLine`). */
|
|
66
|
+
lineComponents?: {
|
|
67
|
+
id: string;
|
|
68
|
+
quantity: number;
|
|
69
|
+
merchandise: {
|
|
70
|
+
id: string;
|
|
71
|
+
title: string;
|
|
72
|
+
product: {
|
|
73
|
+
title: string;
|
|
74
|
+
handle: string;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
}[];
|
|
78
|
+
}
|
|
79
|
+
/** The fields of `fragment TetherCart`. */
|
|
80
|
+
export interface ShopifyCart {
|
|
81
|
+
id: string;
|
|
82
|
+
checkoutUrl: string;
|
|
83
|
+
totalQuantity: number;
|
|
84
|
+
note: string | null;
|
|
85
|
+
createdAt: string;
|
|
86
|
+
updatedAt: string;
|
|
87
|
+
attributes: Attribute[];
|
|
88
|
+
buyerIdentity: {
|
|
89
|
+
countryCode: string | null;
|
|
90
|
+
email: string | null;
|
|
91
|
+
};
|
|
92
|
+
discountCodes: {
|
|
93
|
+
code: string;
|
|
94
|
+
applicable: boolean;
|
|
95
|
+
}[];
|
|
96
|
+
cost: {
|
|
97
|
+
subtotalAmount: Money;
|
|
98
|
+
totalAmount: Money;
|
|
99
|
+
checkoutChargeAmount: Money;
|
|
100
|
+
};
|
|
101
|
+
lines: {
|
|
102
|
+
nodes: ShopifyCartLine[];
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* `unknown` until the saved cart has loaded (the page's own markup shows); `empty` without a cart (none saved, or
|
|
107
|
+
* Shopify no longer has it); `error` after a failed load or change, with the cart as Shopify last sent it.
|
|
108
|
+
*/
|
|
109
|
+
export type CartStatus = {
|
|
110
|
+
kind: 'unknown';
|
|
111
|
+
} | {
|
|
112
|
+
kind: 'empty';
|
|
113
|
+
} | {
|
|
114
|
+
kind: 'ready';
|
|
115
|
+
cart: ShopifyCart;
|
|
116
|
+
} | {
|
|
117
|
+
kind: 'error';
|
|
118
|
+
error: unknown;
|
|
119
|
+
cart: ShopifyCart | null;
|
|
120
|
+
};
|
|
121
|
+
/** What one quick +/- click asked for; a newer click replaces it. */
|
|
122
|
+
export interface PendingQuantity {
|
|
123
|
+
quantity: number;
|
|
124
|
+
}
|
|
125
|
+
/** The second argument of a `subscribe` listener. */
|
|
126
|
+
interface CartMeta {
|
|
127
|
+
open: boolean;
|
|
128
|
+
count: number;
|
|
129
|
+
loaded: boolean;
|
|
130
|
+
/** A copy of Shopify's notes on the last change. */
|
|
131
|
+
warnings: CartWarning[];
|
|
132
|
+
}
|
|
133
|
+
/** Line id → what quick +/- clicks asked for, until Shopify has answered. */
|
|
134
|
+
export declare const pendingQuantities: Map<string, PendingQuantity>;
|
|
135
|
+
export declare const cartStatus: () => CartStatus;
|
|
136
|
+
/** The cart as Shopify last sent it. */
|
|
137
|
+
export declare function currentCart(): ShopifyCart | null;
|
|
138
|
+
export declare const currentWarnings: () => readonly CartWarning[];
|
|
139
|
+
/**
|
|
140
|
+
* The id of the visitor's cart, kept across pages. A stored value that isn't a cart id (written by another script,
|
|
141
|
+
* or edited by hand) is forgotten, so it is never sent to Shopify or the Worker and the next change starts a new cart.
|
|
142
|
+
*/
|
|
143
|
+
export declare function savedCartId(): string | null;
|
|
144
|
+
/** Forgets the saved cart, which Shopify no longer has. */
|
|
145
|
+
export declare function forgetSavedCart(): void;
|
|
146
|
+
/** Keeps a cart Shopify sent without showing it, for an answer a newer change will replace. */
|
|
147
|
+
export declare function keepQuietly(cart: ShopifyCart | null): void;
|
|
148
|
+
/** Renders the document with the store's cart. */
|
|
149
|
+
export declare function render(): void;
|
|
150
|
+
/** @param reason The `reason` of `tether:cart-updated`. */
|
|
151
|
+
export declare function announce(reason: string): void;
|
|
152
|
+
/**
|
|
153
|
+
* Keeps a cart Shopify sent after a change, shows it, and tells this page and the visitor's other tabs.
|
|
154
|
+
*
|
|
155
|
+
* @returns `cart`.
|
|
156
|
+
*/
|
|
157
|
+
export declare function commit(cart: ShopifyCart | null, reason: string): ShopifyCart | null;
|
|
158
|
+
/** The outcome of loading the saved cart: the cart, `null` when there is none, or the failure. */
|
|
159
|
+
export declare function settleLoad(outcome: {
|
|
160
|
+
kind: 'loaded';
|
|
161
|
+
cart: ShopifyCart | null;
|
|
162
|
+
} | {
|
|
163
|
+
kind: 'failed';
|
|
164
|
+
error: unknown;
|
|
165
|
+
}): void;
|
|
166
|
+
/** Until the saved cart has loaded, the counts show the count it had on the last page instead of the page's 0. */
|
|
167
|
+
export declare function showLastKnownCount(): void;
|
|
168
|
+
/** Sets Shopify's notes on the last change: each message once, in the site's words (`warningText`). */
|
|
169
|
+
export declare function setWarnings(notes: readonly CartWarning[]): void;
|
|
170
|
+
/** @returns A runner that starts each task once the one before has settled, whether it succeeded or failed. */
|
|
171
|
+
export declare function serial(): <T>(task: () => Promise<T>) => Promise<T>;
|
|
172
|
+
/**
|
|
173
|
+
* Runs a cart change after the ones before it, so quick clicks never race. A failure sets the `error` status (shown by
|
|
174
|
+
* `tether-show="cart-error"` until the next change succeeds), emits `tether:cart-error` and rejects.
|
|
175
|
+
*/
|
|
176
|
+
export declare function enqueue<T>(task: () => Promise<T>): Promise<T>;
|
|
177
|
+
/** @returns The quantity to show for `line`. */
|
|
178
|
+
export declare const pendingQuantityOf: (line: ShopifyCartLine) => number;
|
|
179
|
+
/**
|
|
180
|
+
* Calls `listener` now and after every change of the cart or the drawer.
|
|
181
|
+
*
|
|
182
|
+
* @returns Stops listening.
|
|
183
|
+
*/
|
|
184
|
+
export declare function subscribe(listener: (cart: ShopifyCart | null, meta: CartMeta) => void): () => void;
|
|
185
|
+
export {};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { checkout, setCheckoutResolver } from './cart/checkout.js';
|
|
2
|
+
import { isOpen, openCart, closeCart, toggleCart, trapFocus } from './cart/drawer.js';
|
|
3
|
+
import { render, savedCartId, subscribe } from './cart/store.js';
|
|
4
|
+
import type { CartWarning } from './config.js';
|
|
5
|
+
import type { Attributes, LineSpec, LinePatch } from './cart/mutations.js';
|
|
6
|
+
import type { ShopifyCart, ShopifyCartLine, CartStatus } from './cart/store.js';
|
|
7
|
+
export { trapFocus };
|
|
8
|
+
type DiscountCodes = string[] | string | ((current: string[]) => string[]);
|
|
9
|
+
/**
|
|
10
|
+
* +1 / -1 for a line. Quick clicks add up: each builds on the quantity the click before asked for, which shows at once
|
|
11
|
+
* (`tether-line="quantity"`, `quantityOf`) until Shopify has answered. Only the latest target is sent; the ones it
|
|
12
|
+
* replaced are skipped.
|
|
13
|
+
*/
|
|
14
|
+
declare function changeQuantity(lineId: string, delta: number): Promise<ShopifyCart | null>;
|
|
15
|
+
/**
|
|
16
|
+
* Loads the saved cart. A cart Shopify no longer has is forgotten; one it can't be asked about (the network, the
|
|
17
|
+
* token) is kept, because it is probably fine.
|
|
18
|
+
*/
|
|
19
|
+
declare function init(): Promise<ShopifyCart | null>;
|
|
20
|
+
export declare const Cart: {
|
|
21
|
+
init: typeof init;
|
|
22
|
+
/** The saved cart's id. */
|
|
23
|
+
id: typeof savedCartId;
|
|
24
|
+
readonly status: CartStatus;
|
|
25
|
+
readonly state: ShopifyCart | null;
|
|
26
|
+
/** The cart's lines, a copy: changing it changes nothing in the cart. */
|
|
27
|
+
readonly lines: ShopifyCartLine[];
|
|
28
|
+
readonly count: number;
|
|
29
|
+
/** True once the saved cart, or that there is none, is known. */
|
|
30
|
+
readonly loaded: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* The failure of the last load or change, until a change succeeds. Requests fail with an `Error`; anything else
|
|
33
|
+
* thrown is wrapped, so the public type holds.
|
|
34
|
+
*/
|
|
35
|
+
readonly lastError: Error | null;
|
|
36
|
+
/** Shopify's notes on the last change, a copy. */
|
|
37
|
+
readonly warnings: CartWarning[];
|
|
38
|
+
/** Line id → the quantity quick clicks asked for. */
|
|
39
|
+
readonly pendingQty: ReadonlyMap<string, {
|
|
40
|
+
quantity: number;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Sets where a logged-in customer checks out, or clears it with `null`: the account part's resolver answers the
|
|
44
|
+
* customer's checkout URL for the cart (`null` uses the cart's own).
|
|
45
|
+
*/
|
|
46
|
+
setCheckoutResolver: typeof setCheckoutResolver;
|
|
47
|
+
/**
|
|
48
|
+
* Forgets the saved cart on this device, as if there were none: the page shows an empty cart and
|
|
49
|
+
* `tether:cart-updated` fires with reason `load`. The next add starts a new cart.
|
|
50
|
+
*/
|
|
51
|
+
forgetSaved(): void;
|
|
52
|
+
render: typeof render;
|
|
53
|
+
subscribe: typeof subscribe;
|
|
54
|
+
/**
|
|
55
|
+
* `add(variantId, 2)`, `add({ variantId, quantity, sellingPlanId, attributes })`, or `add([line, line])` for
|
|
56
|
+
* bundles in one request. Creates the cart when there is none.
|
|
57
|
+
*
|
|
58
|
+
* @throws {TetherError} (rejected) When the add fails, or Shopify answers it without a cart.
|
|
59
|
+
*/
|
|
60
|
+
add(input: string | number | LineSpec | (string | number | LineSpec)[], quantity?: number, options?: Omit<LineSpec, "variantId" | "quantity">): Promise<ShopifyCart>;
|
|
61
|
+
/**
|
|
62
|
+
* `updateLine(lineId, 3)` or `updateLine(lineId, { quantity, sellingPlanId, attributes })`.
|
|
63
|
+
*
|
|
64
|
+
* @param patch A quantity of 0 or less removes the line.
|
|
65
|
+
*/
|
|
66
|
+
updateLine(lineId: string, patch: number | LinePatch): Promise<ShopifyCart | null>;
|
|
67
|
+
changeQuantity: typeof changeQuantity;
|
|
68
|
+
/** The quantity to show: the one asked for while an update is on its way. */
|
|
69
|
+
quantityOf: (line: ShopifyCartLine) => number;
|
|
70
|
+
removeLine(lineIds: string | string[]): Promise<ShopifyCart | null>;
|
|
71
|
+
clear(): Promise<ShopifyCart | null>;
|
|
72
|
+
setNote(note: string | null | undefined): Promise<ShopifyCart | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Cart attributes, merged with the cart's (as it is when the change runs, so quick calls don't drop each other).
|
|
75
|
+
*
|
|
76
|
+
* @param attributes The value `''` removes a key.
|
|
77
|
+
*/
|
|
78
|
+
setAttributes(attributes: Attributes): Promise<ShopifyCart | null>;
|
|
79
|
+
/** Replaces the discount codes; `[]` removes them all. */
|
|
80
|
+
setDiscountCodes(codes: DiscountCodes): Promise<ShopifyCart | null>;
|
|
81
|
+
/**
|
|
82
|
+
* Adds a code. A code Shopify doesn't accept is removed again, so it doesn't warn on every later change.
|
|
83
|
+
*
|
|
84
|
+
* @throws {TetherError} `INVALID_DISCOUNT` (rejected) when Shopify doesn't accept the code.
|
|
85
|
+
*/
|
|
86
|
+
applyDiscount(code: string): Promise<ShopifyCart | null>;
|
|
87
|
+
removeDiscount(code: string): Promise<ShopifyCart | null>;
|
|
88
|
+
/**
|
|
89
|
+
* Sets who is buying; a country changes the cart's currency and prices to that market's.
|
|
90
|
+
*
|
|
91
|
+
* @param options `create: false` forgets an expired cart instead of creating an empty one.
|
|
92
|
+
*/
|
|
93
|
+
setBuyerIdentity(buyerIdentity: {
|
|
94
|
+
countryCode?: string;
|
|
95
|
+
email?: string;
|
|
96
|
+
phone?: string;
|
|
97
|
+
}, { create }?: {
|
|
98
|
+
create?: boolean;
|
|
99
|
+
}): Promise<ShopifyCart | null>;
|
|
100
|
+
checkout: typeof checkout;
|
|
101
|
+
drawers: () => HTMLElement[];
|
|
102
|
+
isOpen: typeof isOpen;
|
|
103
|
+
open: typeof openCart;
|
|
104
|
+
close: typeof closeCart;
|
|
105
|
+
toggle: typeof toggleCart;
|
|
106
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import type { TetherConfig } from './config.js';
|
|
2
|
+
export type TetherErrorCode = 'NOT_FOUND' | 'NETWORK' | 'NOT_CONFIGURED' | 'NOT_LOGGED_IN' | 'INVALID' | 'INVALID_COUNTRY' | 'INVALID_DISCOUNT' | 'INVALID_RESPONSE' | 'ERROR' | `HTTP_${number}`;
|
|
3
|
+
export interface GraphQLError {
|
|
4
|
+
message: string;
|
|
5
|
+
extensions?: {
|
|
6
|
+
code?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface UserError {
|
|
10
|
+
message: string;
|
|
11
|
+
field?: string[] | null;
|
|
12
|
+
code?: string | null;
|
|
13
|
+
}
|
|
14
|
+
interface TetherErrorDetails {
|
|
15
|
+
/** Default `HTTP_<status>` with a status, else `ERROR`. */
|
|
16
|
+
code?: TetherErrorCode;
|
|
17
|
+
/** The HTTP status of the response that failed. */
|
|
18
|
+
status?: number;
|
|
19
|
+
/** The GraphQL errors of that response. */
|
|
20
|
+
errors?: readonly GraphQLError[];
|
|
21
|
+
/** A mutation's user errors. */
|
|
22
|
+
userErrors?: readonly UserError[];
|
|
23
|
+
}
|
|
24
|
+
export declare class TetherError extends Error {
|
|
25
|
+
readonly name: "TetherError";
|
|
26
|
+
readonly code: TetherErrorCode;
|
|
27
|
+
readonly status: number | undefined;
|
|
28
|
+
readonly errors: readonly GraphQLError[] | undefined;
|
|
29
|
+
readonly userErrors: readonly UserError[] | undefined;
|
|
30
|
+
constructor(message: string, { status, errors, userErrors, code }?: TetherErrorDetails);
|
|
31
|
+
}
|
|
32
|
+
/** What a request needs from a config: the browser's `cfg`, or a config the server helpers build. */
|
|
33
|
+
export type StorefrontConfig = Pick<TetherConfig, 'domain' | 'token' | 'apiVersion' | 'country' | 'language' | 'maxAge' | 'retries'> & {
|
|
34
|
+
fetch?: typeof fetch;
|
|
35
|
+
};
|
|
36
|
+
/** Checks a query's `data` before its caller reads it as a `T`. */
|
|
37
|
+
export type DataCheck<T> = (data: unknown) => data is T;
|
|
38
|
+
/**
|
|
39
|
+
* The structure of JSON a check accepts: a `typeof` name, `'object'` for a plain object, `[item]` for a list of
|
|
40
|
+
* items, an object's fields, or a check of its own. Fields it doesn't name aren't checked, so a shape names only what
|
|
41
|
+
* its reader walks without a fallback. A field's `undefined` is the type of one `ShapeOf` leaves out, and checks
|
|
42
|
+
* nothing.
|
|
43
|
+
*/
|
|
44
|
+
export type Shape = 'string' | 'number' | 'boolean' | 'object' | ((value: unknown) => boolean) | readonly [Shape] | {
|
|
45
|
+
readonly [key: string]: Shape | undefined;
|
|
46
|
+
};
|
|
47
|
+
/** @returns True when `value` has the structure `shape` describes. */
|
|
48
|
+
export declare function matches(value: unknown, shape: Shape): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The shapes that describe a `T`: every structure such a shape names is one `T` declares at that place, and a check
|
|
51
|
+
* in it is a type guard for a type `T` accepts there. A shape for `T` therefore can't name a field `T` lacks or claim
|
|
52
|
+
* a type `T` contradicts, so a change to `T` that its shape no longer agrees with fails to compile. Fields of `T` the
|
|
53
|
+
* shape doesn't name stay unchecked (`Shape`).
|
|
54
|
+
*/
|
|
55
|
+
export type ShapeOf<T> = unknown extends T ? Shape : KnownShapeOf<T>;
|
|
56
|
+
type KnownShapeOf<T> = DataCheck<T> | (string extends T ? 'string' : never) | (number extends T ? 'number' : never) | (boolean extends T ? 'boolean' : never) | ListShapeOf<T> | FieldsShapeOf<T>;
|
|
57
|
+
type ListShapeOf<T> = T extends readonly (infer Item)[] ? readonly [ShapeOf<Item>] : never;
|
|
58
|
+
type FieldsShapeOf<T> = T extends readonly unknown[] ? never : T extends object ? 'object' | {
|
|
59
|
+
readonly [Key in keyof T]?: ShapeOf<T[Key]>;
|
|
60
|
+
} : never;
|
|
61
|
+
/** @returns A check that `value` is `null` or has the structure `shape` describes. */
|
|
62
|
+
export declare const orNull: <T>(shape: ShapeOf<T>) => DataCheck<T | null>;
|
|
63
|
+
/**
|
|
64
|
+
* @returns A check that `data` has the structure `shape` describes. `ShapeOf` ties `shape` to `T`; fields `shape`
|
|
65
|
+
* doesn't name are `T`'s claim.
|
|
66
|
+
*/
|
|
67
|
+
export declare const shaped: <T>(shape: ShapeOf<T>) => DataCheck<T>;
|
|
68
|
+
/**
|
|
69
|
+
* What an operation does to the store, which decides what is safe to retry. A query only reads, so a failure that may
|
|
70
|
+
* pass is retried: the network (no answer, or a body that stopped arriving), a 429, a 5xx and `THROTTLED`. Shopify may
|
|
71
|
+
* have applied a mutation before a 5xx or a dropped connection, so a mutation is retried only when Shopify answers
|
|
72
|
+
* that it didn't run it (429 or `THROTTLED`): sending it again could add a line twice. Other failures (a 4xx, a 430,
|
|
73
|
+
* an answer that isn't valid, other GraphQL errors) are never retried.
|
|
74
|
+
*/
|
|
75
|
+
export type Operation = 'query' | 'mutation';
|
|
76
|
+
interface RequestOptions {
|
|
77
|
+
/** `false` sends the query without `@inContext`. */
|
|
78
|
+
context?: boolean;
|
|
79
|
+
/** Default `'query'`. */
|
|
80
|
+
operation?: Operation;
|
|
81
|
+
}
|
|
82
|
+
/** What the store's token may read beyond the defaults. */
|
|
83
|
+
export interface StoreAccess {
|
|
84
|
+
inventory: boolean;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A query's text, or a function that writes it for what the token may read: Tether's own queries, built from
|
|
88
|
+
* `fragments.ts`, leave out inventory for a token that can't read it.
|
|
89
|
+
*/
|
|
90
|
+
export type QueryText = string | ((access: StoreAccess) => string);
|
|
91
|
+
/** @returns The Storefront GraphQL endpoint of `conf`'s store. */
|
|
92
|
+
export declare function endpoint(conf?: Pick<TetherConfig, 'domain' | 'apiVersion'>): string;
|
|
93
|
+
/**
|
|
94
|
+
* The operation of a document Tether didn't write (`Tether.query()`, the server's `query()`). Outside strings and
|
|
95
|
+
* comments, any `mutation` keyword makes it a mutation: a document that starts with a fragment still has its
|
|
96
|
+
* operation found, and a misread errs on the side that is never sent twice.
|
|
97
|
+
*/
|
|
98
|
+
export declare function operationOf(document: string): Operation;
|
|
99
|
+
/**
|
|
100
|
+
* `inContext` for any country and language, as the public `Tether.withContext` takes them: one that isn't a valid
|
|
101
|
+
* code is left out, so page input never becomes query text.
|
|
102
|
+
*/
|
|
103
|
+
export declare function withContext(query: string, ctx?: {
|
|
104
|
+
country?: string | undefined;
|
|
105
|
+
language?: string | undefined;
|
|
106
|
+
}): string;
|
|
107
|
+
/**
|
|
108
|
+
* One Storefront API request, for any config: the browser's shared one (`gql`) or one the server helpers build.
|
|
109
|
+
* Queries carry a time bucket so Shopify's cache of an identical query text is at most `maxAge` seconds old. A query
|
|
110
|
+
* written for the store's access leaves out inventory once the token turns out not to read it (`INVENTORY_FIELD`);
|
|
111
|
+
* a fixed query text is the caller's own, and that refusal is its error. How often a failure is retried is
|
|
112
|
+
* `conf.retries`; which failures are retried is the operation's (`Operation`).
|
|
113
|
+
*
|
|
114
|
+
* @param isData Checks that `data` has what the caller then reads, so a malformed answer fails here.
|
|
115
|
+
* @throws {TetherError} `NOT_CONFIGURED` without a domain or token, `NETWORK` when the store can't be reached or
|
|
116
|
+
* the answer's body stops arriving, `INVALID_RESPONSE` for a 2xx whose body isn't valid (not JSON, not in the
|
|
117
|
+
* GraphQL shape, or `data` that `isData` refuses), `HTTP_<status>` for any other HTTP or GraphQL failure.
|
|
118
|
+
*/
|
|
119
|
+
export declare function request<T>(conf: StorefrontConfig, query: QueryText, variables: Record<string, unknown>, isData: DataCheck<T>, { context, operation }?: RequestOptions): Promise<T>;
|
|
120
|
+
/** `request` with the browser's shared config. */
|
|
121
|
+
export declare function gql<T>(query: QueryText, variables: Record<string, unknown>, isData: DataCheck<T>, options?: RequestOptions): Promise<T>;
|
|
122
|
+
/** The check of `Tether.query()` and the server's `query()`, whose callers read `data` themselves. */
|
|
123
|
+
export declare const hasData: (data: unknown) => data is object;
|
|
124
|
+
/** `Tether.query()`: the caller's own query text decides the shape of `data`, and the caller's `T` states it. */
|
|
125
|
+
export declare function query<T>(text: QueryText, variables?: Record<string, unknown>, options?: Omit<RequestOptions, 'operation'>): Promise<T>;
|
|
126
|
+
/**
|
|
127
|
+
* @param payload A mutation's payload.
|
|
128
|
+
* @param name The mutation, for the error message.
|
|
129
|
+
* @throws {TetherError} `ERROR` on an empty payload or on user errors (in `userErrors`).
|
|
130
|
+
*/
|
|
131
|
+
export declare function unwrap<Payload extends {
|
|
132
|
+
userErrors?: readonly UserError[] | null;
|
|
133
|
+
}>(payload: Payload | null | undefined, name: string): Payload;
|
|
134
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Product } from './fragments.js';
|
|
2
|
+
import type { Collection, PageInfo, ProductQuery } from './loader.js';
|
|
3
|
+
export declare const listSelector: () => string;
|
|
4
|
+
export declare class ListScope {
|
|
5
|
+
readonly root: HTMLElement;
|
|
6
|
+
products: Product[];
|
|
7
|
+
pageInfo: PageInfo | null;
|
|
8
|
+
collection: Collection | null;
|
|
9
|
+
/** Counts loads, so only the latest one renders. */
|
|
10
|
+
loadToken: number;
|
|
11
|
+
constructor(root: HTMLElement);
|
|
12
|
+
$(selector: string): HTMLElement[];
|
|
13
|
+
/** The collection or search query of the list's attributes. */
|
|
14
|
+
options(): ProductQuery;
|
|
15
|
+
/**
|
|
16
|
+
* The product of a recommendations list: a handle, `url:…` (one dynamic product page), or empty inside a product
|
|
17
|
+
* scope for that product.
|
|
18
|
+
*
|
|
19
|
+
* @throws {TetherError} `NOT_FOUND` when there is no product to recommend for.
|
|
20
|
+
*/
|
|
21
|
+
loadRecommendations(): Promise<Product[]>;
|
|
22
|
+
/** @param more Appends the next page instead of replacing the products. */
|
|
23
|
+
load(more?: boolean): Promise<void>;
|
|
24
|
+
render(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AccountConfig, AnalyticsConfig, MarketsConfig, MetafieldIdentifier, MetafieldRef } from './config.js';
|
|
2
|
+
/** Warns that an option was dropped. */
|
|
3
|
+
type Invalid = (name: string, value: unknown) => void;
|
|
4
|
+
/** A host name, without protocol or path: what `domainOption` keeps of the `domain` option. */
|
|
5
|
+
export type ShopDomain = string & {
|
|
6
|
+
readonly __brand: 'ShopDomain';
|
|
7
|
+
};
|
|
8
|
+
/** Every source `markets.detect` reads. */
|
|
9
|
+
export declare const MARKET_SOURCES: readonly ('saved' | 'server' | 'webflow')[];
|
|
10
|
+
/**
|
|
11
|
+
* @returns The store's domain without protocol or path (`https://shop.example/x` → `shop.example`), `''` for anything
|
|
12
|
+
* that isn't a host name.
|
|
13
|
+
*/
|
|
14
|
+
export declare function domainOption(value: unknown, invalid: Invalid): ShopDomain | '';
|
|
15
|
+
/**
|
|
16
|
+
* The folder of the optional parts. It must be https or on this site, which keeps parts off plain http (mixed content,
|
|
17
|
+
* rewritable on the way); it doesn't vouch for the host, which the site chose.
|
|
18
|
+
*
|
|
19
|
+
* @returns The folder as written, `null` for none or one elsewhere (the parts then load beside the core).
|
|
20
|
+
*/
|
|
21
|
+
export declare function partsUrlOption(value: unknown, invalid: Invalid): string | null;
|
|
22
|
+
/**
|
|
23
|
+
* The origins a site lets description iframes load from. Each one is trusted to show only what the site expects in a
|
|
24
|
+
* description, so only a bare https origin is taken: a path would suggest a narrower trust than is given.
|
|
25
|
+
*
|
|
26
|
+
* @returns The valid origins; each other entry is skipped with a warning.
|
|
27
|
+
*/
|
|
28
|
+
export declare function embedOriginsOption(value: unknown, invalid: Invalid): string[];
|
|
29
|
+
/** @returns The identifier of `'namespace.key'` or `{ namespace, key }`, when both parts are valid identifiers. */
|
|
30
|
+
export declare function toMetafieldIdentifier(ref: unknown): MetafieldIdentifier | null;
|
|
31
|
+
/** @returns The refs that name a valid identifier, as written; each other one is skipped with a warning. */
|
|
32
|
+
export declare function metafieldsOption(value: unknown, invalid: Invalid): MetafieldRef[];
|
|
33
|
+
/**
|
|
34
|
+
* @param warn Says why an `account` without a usable `server` is off.
|
|
35
|
+
* @returns `null` without a usable `account.server`: nothing of the account part loads.
|
|
36
|
+
*/
|
|
37
|
+
export declare function accountOption(value: unknown, invalid: Invalid, warn: (message: string) => void): AccountConfig | null;
|
|
38
|
+
export declare const marketsOption: (value: unknown, invalid: Invalid) => MarketsConfig | null;
|
|
39
|
+
export declare const analyticsOption: (value: unknown, invalid: Invalid) => AnalyticsConfig | null;
|
|
40
|
+
export {};
|