/** * The plain parts of the Shopify host (`ShopifyCartSyncHost`, in `./shopifyHost`): everything it * needs from `@tiledev/sdk-shopify` and from the app's state, as functions a test can call without * React or React Native. The host component only connects these to the hooks. * * - `cartSyncReady`: when a sync may decide anything. * - The cart adapters: read and write any cart by id (not only the phone's current one). * - `signedInShopifyCustomer`: the Customer Account API of the shopper the host sees, for * `configureCartSync`, which is set up once at module level, before anyone signs in. * - `requestCartSync`: "sync now", for a screen (the Cart, each time it shows). * - `syncWhenAppComesBack`: a sync each time the app returns to the foreground. */ import { type CustomerState } from "@tiledev/sdk-shopify"; import type { CarriedLine, CarriedLineInput, CartAttribute, CustomerAccountRequest } from "./types"; /** What `cartSyncReady` looks at. */ export interface CartSyncReadiness { /** The phone's stored cart has loaded (`useShopify().ready`). */ cartLoaded: boolean; /** The session is still being read back at app open (`useCustomer().restoring`). */ restoring: boolean; /** The signed-in shopper's profile has loaded (`useCustomer().customer` is set). */ profileLoaded: boolean; } /** * Whether a sync may decide anything yet. All three, or it decides from half the picture: * - **the stored cart has loaded**: before that the phone's cart id is null, so the sync concludes * this phone has no cart and adopts the account's cart outright, dropping this one's lines (found * on an iPhone 2026-10-05: a guest's item vanished at sign-in); * - **the session isn't still being read back** at app open; * - **the profile has loaded**: the sync keys the shopper by customer id, which a sign-in only has * once the profile arrives; a sync before that quietly did nothing, so the sign-in never merged. */ export declare function cartSyncReady(state: CartSyncReadiness): boolean; /** * Only a Shopify sign-in has a shared cart: its pointer lives on the Customer Account API, which an * email-and-password session can't read. */ export declare function signedInWithShopify(customer: Pick): boolean; /** * A cart's lines by id, for the sync to compare or copy (any cart, not only the phone's). Null when * the cart no longer exists; a network error throws, which keeps the phone's cart. */ export declare function readCartLines(cartId: string): Promise; /** Adds lines to a cart by id: the sync's copy when the merge service fails. */ export declare function addCartLines(cartId: string, lines: CarriedLineInput[]): Promise; /** A cart's attributes by id, so a copy carries its live-show sales counts along. */ export declare function readCartAttributes(cartId: string): Promise; /** Writes a cart's attributes by id. Shopify replaces the whole set. */ export declare function writeCartAttributes(cartId: string, attributes: CartAttribute[]): Promise; /** What the host keeps of the shopper signed in with Shopify. */ type ShopifyCustomerAccess = Pick; /** * Set by `ShopifyCartSyncHost` each time it renders: the shopper signed in with Shopify, or null. * Exported for the host and for tests; an app never calls it. */ export declare function rememberShopperSignedInWithShopify(customer: ShopifyCustomerAccess | null): void; /** * The Customer Account API of the shopper `ShopifyCartSyncHost` sees, to pass to `configureCartSync` * (which runs once at module level, before anyone signs in): * * ```ts * configureCartSync({ ..., customerAccountRequest: signedInShopifyCustomer.request, * getAccessToken: signedInShopifyCustomer.getAccessToken }); * ``` * * `request` rejects with "Not signed in" and `getAccessToken` resolves null while no one is signed * in with Shopify, or while the host isn't mounted. */ export declare const signedInShopifyCustomer: { request: CustomerAccountRequest; getAccessToken: () => Promise; }; /** * Syncs now, if `ShopifyCartSyncHost` is mounted; otherwise does nothing. For a screen where a stale * cart shows: the Cart calls it each time it shows, as Apptile's production app did. */ export declare function requestCartSync(): void; /** * Makes `sync` the one `requestCartSync` runs. Returns how to undo that, which only undoes it while * `sync` is still the one (a newer host's isn't touched). Exported for the host and for tests. */ export declare function rememberSyncNow(sync: () => void): () => void; /** The part of React Native's `AppState` the host uses. */ export interface AppStateEvents { addEventListener(type: "change", listener: (state: string) => void): { remove(): void; }; } /** * Runs `sync` each time the app returns to the foreground (`active`), when another device's changes * are most likely. Returns how to stop. */ export declare function syncWhenAppComesBack(appState: AppStateEvents, sync: () => void): () => void; export {}; //# sourceMappingURL=shopify.d.ts.map