UNPKG

@sane-shopify/sync-utils

Version:

Syncing utility for Node & the browser

60 lines (59 loc) 3.23 kB
import { SanityClient } from '@sanity/client'; import { Paginated } from '@good-idea/unwind-edges'; import { Collection, Product } from '@sane-shopify/types'; declare type Maybe<T> = T | null | undefined | void; export declare function definitely<T>(items?: Maybe<T>[] | null): T[]; export declare const slugify: (text: string) => string; export declare const getItemType: (item: Product | Collection) => "shopifyProduct" | "shopifyCollection"; export declare const getLastCursor: <NodeType>(connection: Paginated<NodeType, import("@good-idea/unwind-edges").Edge<NodeType>>) => import("@good-idea/unwind-edges").Maybe<import("@good-idea/unwind-edges").Cursor>; export declare const mergePaginatedResults: <NodeType>(p1: Paginated<NodeType, import("@good-idea/unwind-edges").Edge<NodeType>>, p2: Paginated<NodeType, import("@good-idea/unwind-edges").Edge<NodeType>>) => Paginated<NodeType, import("@good-idea/unwind-edges").Edge<NodeType>>; interface ProductRef { _type: string; _ref: string; _key: string; } export declare const buildProductReferences: (sanityClient: SanityClient, products: Paginated<Product>) => Promise<ProductRef[]>; export declare const prepareSourceData: <T extends Product | Collection>(item: T) => (T & { options: { _key: string; name: string; values: string[]; }[]; media: { edges: { cursor: string | number | void | null | undefined; node: import("../../types/src").ShopifyMediaImage | import("../../types/src").ShopifyVideo; _key: string | number | void | null | undefined; }[]; pageInfo?: import("@good-idea/unwind-edges").PageInfo | null | undefined; }; images: { edges: { cursor: string | number | void | null | undefined; node: import("../../types/src").ShopifyImage; _key: string | number | void | null | undefined; }[]; pageInfo?: import("@good-idea/unwind-edges").PageInfo | null | undefined; }; __typename: "Product"; handle: string; title: string; description: string; descriptionHtml: string; tags: string[]; productType?: string | undefined; compareAtPriceRange?: import("../../types/src").ProductPriceRange | undefined; priceRange?: import("../../types/src").ProductPriceRange | undefined; availableForSale?: boolean | undefined; collections?: Paginated<Collection, import("@good-idea/unwind-edges").Edge<Collection>> | undefined; variants: Paginated<import("../../types/src").Variant, import("@good-idea/unwind-edges").Edge<import("../../types/src").Variant>>; id: string; updatedAt: string; shopName: string; metafields?: Paginated<import("../../types/src").Metafield, import("@good-idea/unwind-edges").Edge<import("../../types/src").Metafield>> | undefined; }) | (Pick<T & Collection, "id" | "__typename" | "handle" | "title" | "description" | "image" | "updatedAt" | "shopName" | "metafields" | Exclude<keyof T, "products">> & { image: {}; }); export declare const toStorefrontId: (id: string) => string; export declare const toAdminApiId: (id: string) => string; export {};