@anker-in/shopify-sdk 0.1.1-beta.2 → 0.1.1-beta.20

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.
@@ -1,5 +1,24 @@
1
1
  'use strict';
2
2
 
3
+ // src/utils.ts
4
+ function addInContextDirective(query, country, language) {
5
+ if (!country || !language) {
6
+ return query;
7
+ }
8
+ const operationRegex = /((?:query|mutation)\s+\w+)(\s*\([^)]*\))?\s*(\{)/;
9
+ const match = query.match(operationRegex);
10
+ if (!match) {
11
+ const braceIndex = query.indexOf("{");
12
+ if (braceIndex === -1) return query;
13
+ const beforeBrace = query.substring(0, braceIndex).trim();
14
+ const afterBrace = query.substring(braceIndex);
15
+ return `${beforeBrace} @inContext(country: ${country}, language: ${language}) ${afterBrace}`;
16
+ }
17
+ const beforeDirective = match[1] + (match[2] || "");
18
+ const afterDirective = query.substring(match.index + match[0].length - 1);
19
+ return `${beforeDirective} @inContext(country: ${country}, language: ${language}) ${afterDirective}`;
20
+ }
21
+
3
22
  // src/client/client.ts
4
23
  var ShopifyClient = class _ShopifyClient {
5
24
  config;
@@ -12,8 +31,11 @@ var ShopifyClient = class _ShopifyClient {
12
31
  * Execute a GraphQL request
13
32
  */
14
33
  async request(request, options = {}) {
15
- const { query, variables, operationName } = request;
34
+ let { query, variables, operationName } = request;
16
35
  const { tags = [], ...fetchOptions } = options;
36
+ const country = this.config.getCountryCode(this.locale);
37
+ const language = this.config.getLanguageCode(this.locale);
38
+ query = addInContextDirective(query, country, language);
17
39
  const apiUrl = this.config.getApiUrl(this.locale);
18
40
  const token = this.config.getStorefrontToken(this.locale);
19
41
  const headers = {
@@ -35,9 +57,7 @@ var ShopifyClient = class _ShopifyClient {
35
57
  ...tags.length > 0 && { next: { tags } }
36
58
  });
37
59
  if (!response.ok) {
38
- throw new Error(
39
- `HTTP ${response.status}: ${response.statusText}`
40
- );
60
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
41
61
  }
42
62
  const json = await response.json();
43
63
  if (json.errors && json.errors.length > 0) {
@@ -53,10 +73,7 @@ var ShopifyClient = class _ShopifyClient {
53
73
  * Convenience method for simple queries
54
74
  */
55
75
  async query(query, variables, options) {
56
- const response = await this.request(
57
- { query, variables },
58
- options
59
- );
76
+ const response = await this.request({ query, variables }, options);
60
77
  return response.data;
61
78
  }
62
79
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/client.ts"],"names":[],"mappings":";;;AAOO,IAAM,aAAA,GAAN,MAAM,cAAA,CAAc;AAAA,EACjB,MAAA;AAAA,EACA,MAAA;AAAA,EAER,WAAA,CAAY,QAAuB,MAAA,EAAgB;AACjD,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAA,CACJ,OAAA,EACA,OAAA,GAAwB,EAAC,EACI;AAC7B,IAAA,MAAM,EAAE,KAAA,EAAO,SAAA,EAAW,aAAA,EAAc,GAAI,OAAA;AAC5C,IAAA,MAAM,EAAE,IAAA,GAAO,EAAC,EAAG,GAAG,cAAa,GAAI,OAAA;AAEvC,IAAA,MAAM,MAAA,GAAS,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,KAAK,MAAM,CAAA;AAChD,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,MAAA,CAAO,kBAAA,CAAmB,KAAK,MAAM,CAAA;AAExD,IAAA,MAAM,OAAA,GAAuB;AAAA,MAC3B,cAAA,EAAgB,kBAAA;AAAA,MAChB,mCAAA,EAAqC,KAAA;AAAA,MACrC,GAAI,YAAA,CAAa,OAAA,IAAW;AAAC,KAC/B;AAEA,IAAA,MAAM,IAAA,GAAO,KAAK,SAAA,CAAU;AAAA,MAC1B,KAAA;AAAA,MACA,SAAA;AAAA,MACA;AAAA,KACD,CAAA;AAED,IAAA,IAAI;AACF,MAAA,MAAM,QAAA,GAAW,MAAM,KAAA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AAoB;AAClB,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,IAAA,CAAK,MAAM,CAAA;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW,MAAA,EAA+B;AACxC,IAAA,OAAO,IAAI,cAAA,CAAc,IAAA,CAAK,MAAA,EAAQ,MAAM,CAAA;AAAA,EAC9C;AACF;AAKO,SAAS,mBAAA,CACd,QACA,MAAA,EACe;AACf,EAAA,OAAO,IAAI,aAAA,CAAc,MAAA,EAAQ,MAAM,CAAA;AACzC","file":"index.js","sourcesContent":["import type { ShopifyConfig } from '@anker-in/shopify-core'\nimport type { GraphQLResponse, GraphQLRequest, FetchOptions } from './types'\n\n/**\n * Shopify GraphQL Client\n * Handles all GraphQL communication with Shopify Storefront API\n */\nexport class ShopifyClient {\n private config: ShopifyConfig\n private locale: string\n\n constructor(config: ShopifyConfig, locale: string) {\n this.config = config\n this.locale = locale\n }\n\n /**\n * Execute a GraphQL request\n */\n async request<T = any>(\n request: GraphQLRequest,\n options: FetchOptions = {}\n ): Promise<GraphQLResponse<T>> {\n const { query, variables, operationName } = request\n const { tags = [], ...fetchOptions } = options\n\n const apiUrl = this.config.getApiUrl(this.locale)\n const token = this.config.getStorefrontToken(this.locale)\n\n const headers: HeadersInit = {\n 'Content-Type': 'application/json',\n 'X-Shopify-Storefront-Access-Token': token,\n ...(fetchOptions.headers || {}),\n }\n\n const body = JSON.stringify({\n query,\n variables,\n operationName,\n })\n\n try {\n const response = await fetch(apiUrl, {\n method: 'POST',\n headers,\n body,\n ...fetchOptions,\n ...(tags.length > 0 && { next: { tags } }),\n })\n\n if (!response.ok) {\n throw new Error(\n `HTTP ${response.status}: ${response.statusText}`\n )\n }\n\n const json: GraphQLResponse<T> = await response.json()\n\n if (json.errors && json.errors.length > 0) {\n console.error('GraphQL Errors:', json.errors)\n }\n\n return json\n } catch (error) {\n console.error('Shopify API Request Failed:', error)\n throw error\n }\n }\n\n /**\n * Convenience method for simple queries\n */\n async query<T = any>(\n query: string,\n variables?: Record<string, any>,\n options?: FetchOptions\n ): Promise<T | undefined> {\n const response = await this.request<T>(\n { query, variables },\n options\n )\n return response.data\n }\n\n /**\n * Get current locale\n */\n getLocale(): string {\n return this.locale\n }\n\n /**\n * Get config\n */\n getConfig(): ShopifyConfig {\n return this.config\n }\n\n /**\n * Get API URL\n */\n getApiUrl(): string {\n return this.config.getApiUrl(this.locale)\n }\n\n /**\n * Create a new client with different locale\n */\n withLocale(locale: string): ShopifyClient {\n return new ShopifyClient(this.config, locale)\n }\n}\n\n/**\n * Factory function to create a Shopify client\n */\nexport function createShopifyClient(\n config: ShopifyConfig,\n locale: string\n): ShopifyClient {\n return new ShopifyClient(config, locale)\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils.ts","../../src/client/client.ts"],"names":[],"mappings":";;;AA0GO,SAAS,qBAAA,CACd,KAAA,EACA,OAAA,EACA,QAAA,EACQ;AAER,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,QAAA,EAAU;AACzB,IAAA,OAAO,KAAA;AAAA,EACT;AAIA,EAAA,MAAM,cAAA,GAAiB,kDAAA;AACvB,EAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,KAAA,CAAM,cAAc,CAAA;AAExC,EAAA,IAAI,CAAC,KAAA,EAAO;AAEV,IAAA,MAAM,UAAA,GAAa,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA;AACpC,IAAA,IAAI,UAAA,KAAe,IAAI,OAAO,KAAA;AAE9B,IAAA,MAAM,cAAc,KAAA,CAAM,SAAA,CAAU,CAAA,EAAG,UAAU,EAAE,IAAA,EAAK;AACxD,IAAA,MAAM,UAAA,GAAa,KAAA,CAAM,SAAA,CAAU,UAAU,CAAA;AAC7C,IAAA,OAAO,GAAG,WAAW,CAAA,qBAAA,EAAwB,OAAO,CAAA,YAAA,EAAe,QAAQ,KAAK,UAAU,CAAA,CAAA;AAAA,EAC5F;AAGA,EAAA,MAAM,kBAAkB,KAAA,CAA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AAS,IAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA,GAAoB;AAClB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA,GAA2B;AACzB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA,GAAoB;AAClB,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,IAAA,CAAK,MAAM,CAAA;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW,MAAA,EAA+B;AACxC,IAAA,OAAO,IAAI,cAAA,CAAc,IAAA,CAAK,MAAA,EAAQ,MAAM,CAAA;AAAA,EAC9C;AACF;AAKO,SAAS,mBAAA,CAAoB,QAAuB,MAAA,EAA+B;AACxF,EAAA,OAAO,IAAI,aAAA,CAAc,MAAA,EAAQ,MAAM,CAAA;AACzC","file":"index.js","sourcesContent":["import { HasMetafieldsIdentifier, Maybe, Metafield } from './shopify-types'\n\nexport type PartialRecord<K extends string | number | symbol, T> = Partial<Record<K, T>>\n\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type Replace<T, K extends keyof T, V> = Omit<T, K> & { [P in K]: V }\n\nexport enum HasMetafieldQueryRoot {\n Product = 'product',\n Variant = 'variant',\n Page = 'page',\n Article = 'article',\n Blog = 'blog',\n Collection = 'collection',\n Shop = 'shop',\n Cart = 'cart',\n Customer = 'customer',\n Location = 'location',\n Market = 'market',\n Order = 'order',\n}\n\n/**\n * 生成 metafieldIdentifiers 查询参数\n */\nexport function constructMetafieldIdentifiersQueryParams<T extends HasMetafieldQueryRoot>(\n metafieldIdentifiers: PartialRecord<T, HasMetafieldsIdentifier[]> = {},\n metafieldNamespacePrefix: string\n): PartialRecord<`${T}MetafieldIdentifiers`, HasMetafieldsIdentifier[]> {\n const identifiers = Object.entries(metafieldIdentifiers).reduce(\n (queryInput, [key, value]) => {\n const metafieldIdentifiers = value as HasMetafieldsIdentifier[]\n queryInput[`${key}MetafieldIdentifiers` as `${T}MetafieldIdentifiers`] =\n metafieldIdentifiers.map((item) => ({\n namespace: item.namespace,\n key: item.key,\n })) as HasMetafieldsIdentifier[]\n return queryInput\n },\n {} as PartialRecord<`${T}MetafieldIdentifiers`, HasMetafieldsIdentifier[]>\n )\n return identifiers\n}\n\nexport const parseMetafield = (item: Metafield, previewData?: any, resource_type?: string) => {\n const type = item?.type && item?.type.toLowerCase()\n if (\n item &&\n previewData &&\n previewData?.__preview_type === resource_type &&\n previewData[`${item?.namespace}${item?.key}`] !== undefined &&\n previewData[`${item?.namespace}${item?.key}`] !== null\n ) {\n return previewData[`${item.namespace}${item.key}`]\n }\n switch (type) {\n case 'json':\n case 'json_string':\n case 'rating':\n case 'volume':\n case 'weight':\n case 'dimension':\n return JSON.parse(item.value)\n default:\n return item?.value || item\n }\n}\n\nexport const normalizeMetafields = (metafields: Array<Maybe<Metafield>>): Record<string, any> => {\n return metafields?.reduce(\n (prev, cur) => {\n if (cur) {\n const namespace = cur.key\n prev[namespace] = prev[namespace] || {}\n const parsedMetafields: {\n [key: string]: Metafield\n } = parseMetafield(cur)\n if (parsedMetafields) {\n Object.entries(parsedMetafields).forEach(([key, innerMetafields]) => {\n prev[namespace][key] =\n prev[namespace][key] ?? (innerMetafields ? parseMetafield(innerMetafields) : null)\n })\n }\n }\n return prev\n },\n {} as Record<string, any>\n )\n}\n\n/**\n * Add @inContext directive to GraphQL query for single shop multi-language/currency support\n *\n * @param query - GraphQL query string\n * @param country - Country code (e.g., 'PL', 'CA', 'US')\n * @param language - Language code (e.g., 'PL', 'FR', 'EN')\n * @returns Modified query with @inContext directive, or original query if country/language not provided\n *\n * @example\n * ```typescript\n * const query = `query getCart($cartId: ID!) { cart(id: $cartId) { id } }`\n * const modifiedQuery = addInContextDirective(query, 'PL', 'PL')\n * // Result: query getCart($cartId: ID!) @inContext(country: PL, language: PL) { cart(id: $cartId) { id } }\n * ```\n */\nexport function addInContextDirective(\n query: string,\n country?: string,\n language?: string\n): string {\n // If no country or language, return original query\n if (!country || !language) {\n return query\n }\n\n // Match query/mutation declaration with optional parameters\n // e.g., \"query getCart(...)\" or \"mutation createCart\"\n const operationRegex = /((?:query|mutation)\\s+\\w+)(\\s*\\([^)]*\\))?\\s*(\\{)/\n const match = query.match(operationRegex)\n\n if (!match) {\n // Fallback: try to find first { if no operation found\n const braceIndex = query.indexOf('{')\n if (braceIndex === -1) return query\n\n const beforeBrace = query.substring(0, braceIndex).trim()\n const afterBrace = query.substring(braceIndex)\n return `${beforeBrace} @inContext(country: ${country}, language: ${language}) ${afterBrace}`\n }\n\n // Insert @inContext after operation declaration (and parameters if exist), before {\n const beforeDirective = match[1] + (match[2] || '') // e.g., \"query getCart($id: ID!)\"\n const afterDirective = query.substring(match.index! + match[0].length - 1) // Everything starting from {\n\n return `${beforeDirective} @inContext(country: ${country}, language: ${language}) ${afterDirective}`\n}\n","import type { ShopifyConfig } from '@anker-in/shopify-core'\nimport type { GraphQLResponse, GraphQLRequest, FetchOptions } from './types'\nimport { addInContextDirective } from '../utils'\n\n/**\n * Shopify GraphQL Client\n * Handles all GraphQL communication with Shopify Storefront API\n */\nexport class ShopifyClient {\n private config: ShopifyConfig\n private locale: string\n\n constructor(config: ShopifyConfig, locale: string) {\n this.config = config\n this.locale = locale\n }\n\n /**\n * Execute a GraphQL request\n */\n async request<T = any>(\n request: GraphQLRequest,\n options: FetchOptions = {}\n ): Promise<GraphQLResponse<T>> {\n let { query, variables, operationName } = request\n const { tags = [], ...fetchOptions } = options\n\n // Add @inContext directive if needed for single shop multi-language/currency\n const country = this.config.getCountryCode(this.locale)\n const language = this.config.getLanguageCode(this.locale)\n query = addInContextDirective(query, country, language)\n\n const apiUrl = this.config.getApiUrl(this.locale)\n const token = this.config.getStorefrontToken(this.locale)\n\n const headers: HeadersInit = {\n 'Content-Type': 'application/json',\n 'X-Shopify-Storefront-Access-Token': token,\n ...(fetchOptions.headers || {}),\n }\n\n const body = JSON.stringify({\n query,\n variables,\n operationName,\n })\n\n try {\n const response = await fetch(apiUrl, {\n method: 'POST',\n headers,\n body,\n ...fetchOptions,\n ...(tags.length > 0 && { next: { tags } }),\n })\n\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n }\n\n const json: GraphQLResponse<T> = await response.json()\n\n if (json.errors && json.errors.length > 0) {\n console.error('GraphQL Errors:', json.errors)\n }\n\n return json\n } catch (error) {\n console.error('Shopify API Request Failed:', error)\n throw error\n }\n }\n\n /**\n * Convenience method for simple queries\n */\n async query<T = any>(\n query: string,\n variables?: Record<string, any>,\n options?: FetchOptions\n ): Promise<T | undefined> {\n const response = await this.request<T>({ query, variables }, options)\n return response.data\n }\n\n /**\n * Get current locale\n */\n getLocale(): string {\n return this.locale\n }\n\n /**\n * Get config\n */\n getConfig(): ShopifyConfig {\n return this.config\n }\n\n /**\n * Get API URL\n */\n getApiUrl(): string {\n return this.config.getApiUrl(this.locale)\n }\n\n /**\n * Create a new client with different locale\n */\n withLocale(locale: string): ShopifyClient {\n return new ShopifyClient(this.config, locale)\n }\n}\n\n/**\n * Factory function to create a Shopify client\n */\nexport function createShopifyClient(config: ShopifyConfig, locale: string): ShopifyClient {\n return new ShopifyClient(config, locale)\n}\n"]}
@@ -1,3 +1,22 @@
1
+ // src/utils.ts
2
+ function addInContextDirective(query, country, language) {
3
+ if (!country || !language) {
4
+ return query;
5
+ }
6
+ const operationRegex = /((?:query|mutation)\s+\w+)(\s*\([^)]*\))?\s*(\{)/;
7
+ const match = query.match(operationRegex);
8
+ if (!match) {
9
+ const braceIndex = query.indexOf("{");
10
+ if (braceIndex === -1) return query;
11
+ const beforeBrace = query.substring(0, braceIndex).trim();
12
+ const afterBrace = query.substring(braceIndex);
13
+ return `${beforeBrace} @inContext(country: ${country}, language: ${language}) ${afterBrace}`;
14
+ }
15
+ const beforeDirective = match[1] + (match[2] || "");
16
+ const afterDirective = query.substring(match.index + match[0].length - 1);
17
+ return `${beforeDirective} @inContext(country: ${country}, language: ${language}) ${afterDirective}`;
18
+ }
19
+
1
20
  // src/client/client.ts
2
21
  var ShopifyClient = class _ShopifyClient {
3
22
  config;
@@ -10,8 +29,11 @@ var ShopifyClient = class _ShopifyClient {
10
29
  * Execute a GraphQL request
11
30
  */
12
31
  async request(request, options = {}) {
13
- const { query, variables, operationName } = request;
32
+ let { query, variables, operationName } = request;
14
33
  const { tags = [], ...fetchOptions } = options;
34
+ const country = this.config.getCountryCode(this.locale);
35
+ const language = this.config.getLanguageCode(this.locale);
36
+ query = addInContextDirective(query, country, language);
15
37
  const apiUrl = this.config.getApiUrl(this.locale);
16
38
  const token = this.config.getStorefrontToken(this.locale);
17
39
  const headers = {
@@ -33,9 +55,7 @@ var ShopifyClient = class _ShopifyClient {
33
55
  ...tags.length > 0 && { next: { tags } }
34
56
  });
35
57
  if (!response.ok) {
36
- throw new Error(
37
- `HTTP ${response.status}: ${response.statusText}`
38
- );
58
+ throw new Error(`HTTP ${response.status}: ${response.statusText}`);
39
59
  }
40
60
  const json = await response.json();
41
61
  if (json.errors && json.errors.length > 0) {
@@ -51,10 +71,7 @@ var ShopifyClient = class _ShopifyClient {
51
71
  * Convenience method for simple queries
52
72
  */
53
73
  async query(query, variables, options) {
54
- const response = await this.request(
55
- { query, variables },
56
- options
57
- );
74
+ const response = await this.request({ query, variables }, options);
58
75
  return response.data;
59
76
  }
60
77
  /**
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/client.ts"],"names":[],"mappings":";AAOO,IAAM,aAAA,GAAN,MAAM,cAAA,CAAc;AAAA,EACjB,MAAA;AAAA,EACA,MAAA;AAAA,EAER,WAAA,CAAY,QAAuB,MAAA,EAAgB;AACjD,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,OAAA,CACJ,OAAA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AM,iBAAA,EAAmB,IAAA,CAAK,MAAM,CAAA;AAAA,MAC9C;AAEA,MAAA,OAAO,IAAA;AAAA,IACT,SAAS,KAAA,EAAO;AACd,MAAA,OAAA,CAAQ,KAAA,CAAM,+BAA+B,KAAK,CAAA;AAClD,MAAA,MAAM,KAAA;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,KAAA,CACJ,KAAA,EACA,SAAA,EACA,OAAA,EACwB;AACxB,IAAA,MAAM,QAAA,GAAW,MAAM,IAAA,CAAK,OAAA;AAAA,MAC1B,EAAE,OAAO,SAAA,EAAU;AAAA,MACnB;AAAA,KACF;AACA,IAAA,OAAO,QAAA,CAAS,IAAA;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA,GAAoB;AAClB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA,GAA2B;AACzB,IAAA,OAAO,IAAA,CAAK,MAAA;AAAA,EACd;AAAA;AAAA;AAAA;AAAA,EAKA,SAAA,GAAoB;AAClB,IAAA,OAAO,IAAA,CAAK,MAAA,CAAO,SAAA,CAAU,IAAA,CAAK,MAAM,CAAA;AAAA,EAC1C;AAAA;AAAA;AAAA;AAAA,EAKA,WAAW,MAAA,EAA+B;AACxC,IAAA,OAAO,IAAI,cAAA,CAAc,IAAA,CAAK,MAAA,EAAQ,MAAM,CAAA;AAAA,EAC9C;AACF;AAKO,SAAS,mBAAA,CACd,QACA,MAAA,EACe;AACf,EAAA,OAAO,IAAI,aAAA,CAAc,MAAA,EAAQ,MAAM,CAAA;AACzC","file":"index.mjs","sourcesContent":["import type { ShopifyConfig } from '@anker-in/shopify-core'\nimport type { GraphQLResponse, GraphQLRequest, FetchOptions } from './types'\n\n/**\n * Shopify GraphQL Client\n * Handles all GraphQL communication with Shopify Storefront API\n */\nexport class ShopifyClient {\n private config: ShopifyConfig\n private locale: string\n\n constructor(config: ShopifyConfig, locale: string) {\n this.config = config\n this.locale = locale\n }\n\n /**\n * Execute a GraphQL request\n */\n async request<T = any>(\n request: GraphQLRequest,\n options: FetchOptions = {}\n ): Promise<GraphQLResponse<T>> {\n const { query, variables, operationName } = request\n const { tags = [], ...fetchOptions } = options\n\n const apiUrl = this.config.getApiUrl(this.locale)\n const token = this.config.getStorefrontToken(this.locale)\n\n const headers: HeadersInit = {\n 'Content-Type': 'application/json',\n 'X-Shopify-Storefront-Access-Token': token,\n ...(fetchOptions.headers || {}),\n }\n\n const body = JSON.stringify({\n query,\n variables,\n operationName,\n })\n\n try {\n const response = await fetch(apiUrl, {\n method: 'POST',\n headers,\n body,\n ...fetchOptions,\n ...(tags.length > 0 && { next: { tags } }),\n })\n\n if (!response.ok) {\n throw new Error(\n `HTTP ${response.status}: ${response.statusText}`\n )\n }\n\n const json: GraphQLResponse<T> = await response.json()\n\n if (json.errors && json.errors.length > 0) {\n console.error('GraphQL Errors:', json.errors)\n }\n\n return json\n } catch (error) {\n console.error('Shopify API Request Failed:', error)\n throw error\n }\n }\n\n /**\n * Convenience method for simple queries\n */\n async query<T = any>(\n query: string,\n variables?: Record<string, any>,\n options?: FetchOptions\n ): Promise<T | undefined> {\n const response = await this.request<T>(\n { query, variables },\n options\n )\n return response.data\n }\n\n /**\n * Get current locale\n */\n getLocale(): string {\n return this.locale\n }\n\n /**\n * Get config\n */\n getConfig(): ShopifyConfig {\n return this.config\n }\n\n /**\n * Get API URL\n */\n getApiUrl(): string {\n return this.config.getApiUrl(this.locale)\n }\n\n /**\n * Create a new client with different locale\n */\n withLocale(locale: string): ShopifyClient {\n return new ShopifyClient(this.config, locale)\n }\n}\n\n/**\n * Factory function to create a Shopify client\n */\nexport function createShopifyClient(\n config: ShopifyConfig,\n locale: string\n): ShopifyClient {\n return new ShopifyClient(config, locale)\n}\n"]}
1
+ {"version":3,"sources":["../../src/utils.ts","../../src/client/client.ts"],"names":[],"mappings":";AA0GO,SAAS,qBAAA,CACd,KAAA,EACA,OAAA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,MAAA,EAAQ,MAAM,CAAA;AACzC","file":"index.mjs","sourcesContent":["import { HasMetafieldsIdentifier, Maybe, Metafield } from './shopify-types'\n\nexport type PartialRecord<K extends string | number | symbol, T> = Partial<Record<K, T>>\n\nexport type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>\n\nexport type Replace<T, K extends keyof T, V> = Omit<T, K> & { [P in K]: V }\n\nexport enum HasMetafieldQueryRoot {\n Product = 'product',\n Variant = 'variant',\n Page = 'page',\n Article = 'article',\n Blog = 'blog',\n Collection = 'collection',\n Shop = 'shop',\n Cart = 'cart',\n Customer = 'customer',\n Location = 'location',\n Market = 'market',\n Order = 'order',\n}\n\n/**\n * 生成 metafieldIdentifiers 查询参数\n */\nexport function constructMetafieldIdentifiersQueryParams<T extends HasMetafieldQueryRoot>(\n metafieldIdentifiers: PartialRecord<T, HasMetafieldsIdentifier[]> = {},\n metafieldNamespacePrefix: string\n): PartialRecord<`${T}MetafieldIdentifiers`, HasMetafieldsIdentifier[]> {\n const identifiers = Object.entries(metafieldIdentifiers).reduce(\n (queryInput, [key, value]) => {\n const metafieldIdentifiers = value as HasMetafieldsIdentifier[]\n queryInput[`${key}MetafieldIdentifiers` as `${T}MetafieldIdentifiers`] =\n metafieldIdentifiers.map((item) => ({\n namespace: item.namespace,\n key: item.key,\n })) as HasMetafieldsIdentifier[]\n return queryInput\n },\n {} as PartialRecord<`${T}MetafieldIdentifiers`, HasMetafieldsIdentifier[]>\n )\n return identifiers\n}\n\nexport const parseMetafield = (item: Metafield, previewData?: any, resource_type?: string) => {\n const type = item?.type && item?.type.toLowerCase()\n if (\n item &&\n previewData &&\n previewData?.__preview_type === resource_type &&\n previewData[`${item?.namespace}${item?.key}`] !== undefined &&\n previewData[`${item?.namespace}${item?.key}`] !== null\n ) {\n return previewData[`${item.namespace}${item.key}`]\n }\n switch (type) {\n case 'json':\n case 'json_string':\n case 'rating':\n case 'volume':\n case 'weight':\n case 'dimension':\n return JSON.parse(item.value)\n default:\n return item?.value || item\n }\n}\n\nexport const normalizeMetafields = (metafields: Array<Maybe<Metafield>>): Record<string, any> => {\n return metafields?.reduce(\n (prev, cur) => {\n if (cur) {\n const namespace = cur.key\n prev[namespace] = prev[namespace] || {}\n const parsedMetafields: {\n [key: string]: Metafield\n } = parseMetafield(cur)\n if (parsedMetafields) {\n Object.entries(parsedMetafields).forEach(([key, innerMetafields]) => {\n prev[namespace][key] =\n prev[namespace][key] ?? (innerMetafields ? parseMetafield(innerMetafields) : null)\n })\n }\n }\n return prev\n },\n {} as Record<string, any>\n )\n}\n\n/**\n * Add @inContext directive to GraphQL query for single shop multi-language/currency support\n *\n * @param query - GraphQL query string\n * @param country - Country code (e.g., 'PL', 'CA', 'US')\n * @param language - Language code (e.g., 'PL', 'FR', 'EN')\n * @returns Modified query with @inContext directive, or original query if country/language not provided\n *\n * @example\n * ```typescript\n * const query = `query getCart($cartId: ID!) { cart(id: $cartId) { id } }`\n * const modifiedQuery = addInContextDirective(query, 'PL', 'PL')\n * // Result: query getCart($cartId: ID!) @inContext(country: PL, language: PL) { cart(id: $cartId) { id } }\n * ```\n */\nexport function addInContextDirective(\n query: string,\n country?: string,\n language?: string\n): string {\n // If no country or language, return original query\n if (!country || !language) {\n return query\n }\n\n // Match query/mutation declaration with optional parameters\n // e.g., \"query getCart(...)\" or \"mutation createCart\"\n const operationRegex = /((?:query|mutation)\\s+\\w+)(\\s*\\([^)]*\\))?\\s*(\\{)/\n const match = query.match(operationRegex)\n\n if (!match) {\n // Fallback: try to find first { if no operation found\n const braceIndex = query.indexOf('{')\n if (braceIndex === -1) return query\n\n const beforeBrace = query.substring(0, braceIndex).trim()\n const afterBrace = query.substring(braceIndex)\n return `${beforeBrace} @inContext(country: ${country}, language: ${language}) ${afterBrace}`\n }\n\n // Insert @inContext after operation declaration (and parameters if exist), before {\n const beforeDirective = match[1] + (match[2] || '') // e.g., \"query getCart($id: ID!)\"\n const afterDirective = query.substring(match.index! + match[0].length - 1) // Everything starting from {\n\n return `${beforeDirective} @inContext(country: ${country}, language: ${language}) ${afterDirective}`\n}\n","import type { ShopifyConfig } from '@anker-in/shopify-core'\nimport type { GraphQLResponse, GraphQLRequest, FetchOptions } from './types'\nimport { addInContextDirective } from '../utils'\n\n/**\n * Shopify GraphQL Client\n * Handles all GraphQL communication with Shopify Storefront API\n */\nexport class ShopifyClient {\n private config: ShopifyConfig\n private locale: string\n\n constructor(config: ShopifyConfig, locale: string) {\n this.config = config\n this.locale = locale\n }\n\n /**\n * Execute a GraphQL request\n */\n async request<T = any>(\n request: GraphQLRequest,\n options: FetchOptions = {}\n ): Promise<GraphQLResponse<T>> {\n let { query, variables, operationName } = request\n const { tags = [], ...fetchOptions } = options\n\n // Add @inContext directive if needed for single shop multi-language/currency\n const country = this.config.getCountryCode(this.locale)\n const language = this.config.getLanguageCode(this.locale)\n query = addInContextDirective(query, country, language)\n\n const apiUrl = this.config.getApiUrl(this.locale)\n const token = this.config.getStorefrontToken(this.locale)\n\n const headers: HeadersInit = {\n 'Content-Type': 'application/json',\n 'X-Shopify-Storefront-Access-Token': token,\n ...(fetchOptions.headers || {}),\n }\n\n const body = JSON.stringify({\n query,\n variables,\n operationName,\n })\n\n try {\n const response = await fetch(apiUrl, {\n method: 'POST',\n headers,\n body,\n ...fetchOptions,\n ...(tags.length > 0 && { next: { tags } }),\n })\n\n if (!response.ok) {\n throw new Error(`HTTP ${response.status}: ${response.statusText}`)\n }\n\n const json: GraphQLResponse<T> = await response.json()\n\n if (json.errors && json.errors.length > 0) {\n console.error('GraphQL Errors:', json.errors)\n }\n\n return json\n } catch (error) {\n console.error('Shopify API Request Failed:', error)\n throw error\n }\n }\n\n /**\n * Convenience method for simple queries\n */\n async query<T = any>(\n query: string,\n variables?: Record<string, any>,\n options?: FetchOptions\n ): Promise<T | undefined> {\n const response = await this.request<T>({ query, variables }, options)\n return response.data\n }\n\n /**\n * Get current locale\n */\n getLocale(): string {\n return this.locale\n }\n\n /**\n * Get config\n */\n getConfig(): ShopifyConfig {\n return this.config\n }\n\n /**\n * Get API URL\n */\n getApiUrl(): string {\n return this.config.getApiUrl(this.locale)\n }\n\n /**\n * Create a new client with different locale\n */\n withLocale(locale: string): ShopifyClient {\n return new ShopifyClient(this.config, locale)\n }\n}\n\n/**\n * Factory function to create a Shopify client\n */\nexport function createShopifyClient(config: ShopifyConfig, locale: string): ShopifyClient {\n return new ShopifyClient(config, locale)\n}\n"]}
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ export { FetchOptions, GraphQLError, GraphQLRequest, GraphQLResponse, createShop
3
3
  export { articleFragment, articleWithMetafieldsFragment, blogFragment, blogWithMetafieldsFragment, cartFragment, collectionFragment, imageFragment, metafieldFragment, metafieldFragmentStr, pageInfoFragment, productFragment, seoFragment, variantFragment } from './fragments/index.mjs';
4
4
  export { getAllProductsPathsQuery, getCartQuery, getProductQuery, getProductsByHandlesQuery, getProductsQuery } from './queries/index.mjs';
5
5
  export { addCartItemsMutation, createCartMutation, removeCartItemsMutation, updateCartAttributesMutation, updateCartDeliveryOptionsMutation, updateCartDiscountCodeMutation, updateCartItemsMutation } from './mutations/index.mjs';
6
- export { ShopifyConfig, clearLocalStorage, getLocalStorage, removeLocalStorage, setLocalStorage } from '@anker-in/shopify-core';
6
+ export * from '@anker-in/shopify-core';
7
7
 
8
8
  type Maybe<T> = T | null;
9
9
  type InputMaybe<T> = Maybe<T>;
@@ -10217,6 +10217,10 @@ declare module '@shopify/storefront-api-client' {
10217
10217
  interface StorefrontMutations extends GeneratedMutationTypes {}
10218
10218
  }
10219
10219
 
10220
+ interface NormalizedAttribute {
10221
+ key: string;
10222
+ value: string;
10223
+ }
10220
10224
  interface NormalizedLineItem {
10221
10225
  id: string;
10222
10226
  name: string;
@@ -10226,13 +10230,11 @@ interface NormalizedLineItem {
10226
10230
  totalAmount: number;
10227
10231
  subtotalAmount: number;
10228
10232
  discountAllocations: Array<{
10233
+ title: string;
10229
10234
  code: string;
10230
10235
  amount: number;
10231
10236
  }>;
10232
- customAttributes?: Array<{
10233
- key: string;
10234
- value: string;
10235
- }>;
10237
+ customAttributes: NormalizedAttribute[];
10236
10238
  variant: {
10237
10239
  id: string;
10238
10240
  price: number;
@@ -10279,13 +10281,14 @@ interface NormalizedCart {
10279
10281
  code: string;
10280
10282
  }>;
10281
10283
  discountAllocations?: Array<{
10284
+ title: string;
10282
10285
  code: string;
10283
10286
  amount: number;
10284
10287
  }>;
10285
10288
  url: string;
10286
10289
  ready: boolean;
10287
- orderStatusUrl?: any;
10288
- customAttributes?: any;
10290
+ orderStatusUrl?: string;
10291
+ customAttributes: NormalizedAttribute[];
10289
10292
  maxNum?: number;
10290
10293
  /** Delivery amount */
10291
10294
  deliveryAmount?: {
@@ -10399,6 +10402,8 @@ interface CreateCartOptions {
10399
10402
  variant: HasMetafieldsIdentifier[];
10400
10403
  product: HasMetafieldsIdentifier[];
10401
10404
  };
10405
+ /** Whether to update the cookie * 默认不更新cookie/ 仅在需要更新cookie时设置为true */
10406
+ updateCookie?: boolean;
10402
10407
  }
10403
10408
  /**
10404
10409
  * Create a new cart
@@ -10436,25 +10441,12 @@ declare function createCart(client: ShopifyClient, options?: CreateCartOptions):
10436
10441
  */
10437
10442
 
10438
10443
  interface AddCartLinesOptions {
10439
- /** Cart ID (optional, will create new cart if not provided) */
10440
- cartId?: string;
10444
+ /** Cart ID (required) */
10445
+ cartId: string;
10441
10446
  /** Lines to add */
10442
10447
  lines: CartLineInput[];
10443
10448
  /** Cookie adapter for managing cart ID */
10444
10449
  cookieAdapter?: CartCookieAdapter;
10445
- /** Current locale */
10446
- /** Buyer identity for cart creation */
10447
- buyerIdentity?: {
10448
- email?: string;
10449
- countryCode?: string;
10450
- };
10451
- /** Discount codes (only used when creating new cart) */
10452
- discountCodes?: string[];
10453
- /** Custom attributes (only used when creating new cart) */
10454
- customAttributes?: Array<{
10455
- key: string;
10456
- value: string;
10457
- }>;
10458
10450
  /** Metafield identifiers */
10459
10451
  metafieldIdentifiers?: {
10460
10452
  variant: HasMetafieldsIdentifier[];
@@ -10462,7 +10454,7 @@ interface AddCartLinesOptions {
10462
10454
  };
10463
10455
  }
10464
10456
  /**
10465
- * Add lines to cart (creates new cart if needed)
10457
+ * Add lines to an existing cart
10466
10458
  *
10467
10459
  * @param client - Shopify GraphQL client
10468
10460
  * @param options - Add cart lines options
@@ -10471,7 +10463,7 @@ interface AddCartLinesOptions {
10471
10463
  * @example
10472
10464
  * ```ts
10473
10465
  * const cart = await addCartLines(client, {
10474
- * locale: 'us',
10466
+ * cartId: 'gid://shopify/Cart/xxx',
10475
10467
  * lines: [{
10476
10468
  * merchandiseId: 'gid://shopify/ProductVariant/123',
10477
10469
  * quantity: 1
@@ -11068,4 +11060,4 @@ declare function getArticles(client: ShopifyClient, options: GetArticlesOptions)
11068
11060
 
11069
11061
  declare function getArticlesInBlog(client: ShopifyClient, options: GetArticlesInBlogOptions): Promise<NormalizedArticle[]>;
11070
11062
 
11071
- export { type AddCartLinesOptions, type AddToCartMutation, type AddToCartMutationVariables, type ApiVersion, type ApplePayWalletContentInput, type ApplePayWalletHeaderInput, type AppliedGiftCard, type Article, type ArticleAuthor, type ArticleCommentsArgs, type ArticleConnection, type ArticleContentArgs, type ArticleEdge, type ArticleExcerptArgs, type ArticleFragment, type ArticleMetafieldArgs, type ArticleMetafieldsArgs, ArticleSortKeys, type ArticleWithMetafieldsFragment, type Attribute, type AttributeInput, type AutomaticDiscountApplication, type BaseCartLine, type BaseCartLineAttributeArgs, type BaseCartLineConnection, type BaseCartLineEdge, type Blog, type BlogArticleByHandleArgs, type BlogArticlesArgs, type BlogConnection, type BlogEdge, type BlogFragment, type BlogMetafieldArgs, type BlogMetafieldsArgs, BlogSortKeys, type BlogWithMetafieldsFragment, type Brand, type BrandColorGroup, type BrandColors, type BuyerInput, CardBrand, type Cart, type CartAPIOptions, type CartAddress, type CartAddressInput, type CartAttributeArgs, type CartAttributesUpdateMutation, type CartAttributesUpdateMutationVariables, type CartAttributesUpdatePayload, type CartAutomaticDiscountAllocation, type CartBillingAddressUpdatePayload, type CartBuyerIdentity, type CartBuyerIdentityInput, type CartBuyerIdentityUpdatePayload, CartCardSource, type CartCodeDiscountAllocation, type CartCompletionAction, type CartCompletionActionRequired, type CartCompletionAttemptResult, type CartCompletionFailed, type CartCompletionProcessing, type CartCompletionSuccess, type CartCookieAdapter, type CartCost, type CartCreatePayload, type CartCustomDiscountAllocation, type CartDelivery, type CartDeliveryAddress, type CartDeliveryAddressFormattedArgs, type CartDeliveryAddressInput, type CartDeliveryAddressesAddPayload, type CartDeliveryAddressesArgs, type CartDeliveryAddressesRemovePayload, type CartDeliveryAddressesUpdatePayload, type CartDeliveryCoordinatesPreference, type CartDeliveryCoordinatesPreferenceInput, type CartDeliveryGroup, type CartDeliveryGroupCartLinesArgs, type CartDeliveryGroupConnection, type CartDeliveryGroupEdge, CartDeliveryGroupType, type CartDeliveryGroupsArgs, type CartDeliveryInput, type CartDeliveryOption, type CartDeliveryPreference, type CartDeliveryPreferenceInput, type CartDirectPaymentMethodInput, type CartDiscountAllocation, type CartDiscountApplication, type CartDiscountCode, type CartDiscountCodesUpdateMutation, type CartDiscountCodesUpdateMutationVariables, type CartDiscountCodesUpdatePayload, CartErrorCode, type CartEstimatedCost, type CartFragment, type CartFreePaymentMethodInput, type CartGiftCardCodesRemovePayload, type CartGiftCardCodesUpdatePayload, type CartInput, type CartInputMetafieldInput, type CartLine, type CartLineAttributeArgs, type CartLineCost, type CartLineEstimatedCost, type CartLineInput, type CartLineUpdateInput, type CartLinesAddPayload, type CartLinesArgs, type CartLinesRemovePayload, type CartLinesUpdatePayload, type CartMetafieldArgs, type CartMetafieldDeleteInput, type CartMetafieldDeletePayload, type CartMetafieldsArgs, type CartMetafieldsSetInput, type CartMetafieldsSetPayload, type CartNoteUpdatePayload, type CartOperationError, type CartOperationResult, type CartPaymentInput, type CartPaymentUpdatePayload, type CartPreferences, type CartPreferencesInput, type CartPrepareForCompletionPayload, type CartPrepareForCompletionResult, type CartSelectableAddress, type CartSelectableAddressInput, type CartSelectableAddressUpdateInput, type CartSelectedDeliveryOptionInput, type CartSelectedDeliveryOptionsUpdatePayload, type CartStatusNotReady, type CartStatusReady, type CartSubmitForCompletionPayload, type CartSubmitForCompletionResult, type CartThrottled, type CartUserError, type CartWalletPaymentMethodInput, type CartWarning, CartWarningCode, type CategoryFilter, type Collection, type CollectionConnection, type CollectionDescriptionArgs, type CollectionEdge, type CollectionFragment, type CollectionMetafieldArgs, type CollectionMetafieldsArgs, type CollectionProductsArgs, CollectionSortKeys, type CollectionsConnection, type Comment, type CommentAuthor, type CommentConnection, type CommentContentArgs, type CommentEdge, type Company, type CompanyContact, type CompanyLocation, type CompanyLocationMetafieldArgs, type CompanyLocationMetafieldsArgs, type CompanyMetafieldArgs, type CompanyMetafieldsArgs, type CompletePaymentChallenge, type CompletionError, CompletionErrorCode, type ComponentizableCartLine, type ComponentizableCartLineAttributeArgs, type Count, CountPrecision, type Country, CountryCode, type CreateCartMutation, type CreateCartMutationVariables, type CreateCartOptions, CropRegion, type Currency, CurrencyCode, type Customer, type CustomerAccessToken, type CustomerAccessTokenCreateInput, type CustomerAccessTokenCreatePayload, type CustomerAccessTokenCreateWithMultipassPayload, type CustomerAccessTokenDeletePayload, type CustomerAccessTokenRenewPayload, type CustomerActivateByUrlPayload, type CustomerActivateInput, type CustomerActivatePayload, type CustomerAddressCreatePayload, type CustomerAddressDeletePayload, type CustomerAddressUpdatePayload, type CustomerAddressesArgs, type CustomerCreateInput, type CustomerCreatePayload, type CustomerDefaultAddressUpdatePayload, CustomerErrorCode, type CustomerMetafieldArgs, type CustomerMetafieldsArgs, type CustomerOrdersArgs, type CustomerRecoverPayload, type CustomerResetByUrlPayload, type CustomerResetInput, type CustomerResetPayload, type CustomerUpdateInput, type CustomerUpdatePayload, type CustomerUserError, type DeliveryAddress, type DeliveryAddressInput, DeliveryAddressValidationStrategy, DeliveryMethodType, DigitalWallet, type DiscountAllocation, type DiscountApplication, DiscountApplicationAllocationMethod, type DiscountApplicationConnection, type DiscountApplicationEdge, DiscountApplicationTargetSelection, DiscountApplicationTargetType, type DiscountCodeApplication, type DisplayableError, type Domain, type EditCartItemsMutation, type EditCartItemsMutationVariables, type Exact, type ExternalVideo, type Filter, FilterPresentation, FilterType, type FilterValue, type Fulfillment, type FulfillmentFulfillmentLineItemsArgs, type FulfillmentLineItem, type FulfillmentLineItemConnection, type FulfillmentLineItemEdge, type FulfillmentTrackingInfo, type FulfillmentTrackingInfoArgs, type GenericFile, type GeoCoordinateInput, type GetAllBlogsOptions, type GetAllProductPathsQuery, type GetAllProductPathsQueryVariables, type GetAllProductsOptions, type GetArticleOptions, type GetArticlesInBlogOptions, type GetArticlesOptions, type GetBlogOptions, type GetCartOptions, type GetCartQuery, type GetCartQueryVariables, type GetCollectionOptions, type GetCollectionsOptions, type GetProductByHandleQuery, type GetProductByHandleQueryVariables, type GetProductOptions, type GetProductsByHandlesOptions, type GetProductsQuery, type GetProductsQueryVariables, type HasMetafields, type HasMetafieldsIdentifier, type HasMetafieldsMetafieldArgs, type HasMetafieldsMetafieldsArgs, type Image, type ImageConnection, ImageContentType, type ImageEdge, type ImageFragment, type ImageTransformInput, type ImageTransformedSrcArgs, type ImageUrlArgs, type InContextAnnotation, type InContextAnnotationType, type Incremental, type InputMaybe, type Language, LanguageCode, type Localization, type Location, type LocationAddress, type LocationConnection, type LocationEdge, type LocationMetafieldArgs, type LocationMetafieldsArgs, LocationSortKeys, type MailingAddress, type MailingAddressConnection, type MailingAddressEdge, type MailingAddressFormattedArgs, type MailingAddressInput, type MakeEmpty, type MakeMaybe, type MakeOptional, type ManualDiscountApplication, type Market, type MarketMetafieldArgs, type MarketMetafieldsArgs, type Maybe, type Media, type MediaConnection, MediaContentType, type MediaEdge, MediaHost, type MediaImage, type MediaPresentation, type MediaPresentationAsJsonArgs, MediaPresentationFormat, type Menu, type MenuItem, type MenuItemResource, MenuItemType, type Merchandise, type Metafield, MetafieldDeleteErrorCode, type MetafieldDeleteUserError, type MetafieldFilter, type MetafieldFragment, type MetafieldParentResource, type MetafieldReference, type MetafieldReferenceConnection, type MetafieldReferenceEdge, type MetafieldReferencesArgs, type MetafieldsSetUserError, MetafieldsSetUserErrorCode, type Metaobject, type MetaobjectConnection, type MetaobjectEdge, type MetaobjectField, type MetaobjectFieldArgs, type MetaobjectFieldReferencesArgs, type MetaobjectHandleInput, type MetaobjectSeo, type Model3d, type Model3dSource, type MoneyInput, type MoneyV2, type Mutation, type MutationCartAttributesUpdateArgs, type MutationCartBillingAddressUpdateArgs, type MutationCartBuyerIdentityUpdateArgs, type MutationCartCreateArgs, type MutationCartDeliveryAddressesAddArgs, type MutationCartDeliveryAddressesRemoveArgs, type MutationCartDeliveryAddressesUpdateArgs, type MutationCartDiscountCodesUpdateArgs, type MutationCartGiftCardCodesRemoveArgs, type MutationCartGiftCardCodesUpdateArgs, type MutationCartLinesAddArgs, type MutationCartLinesRemoveArgs, type MutationCartLinesUpdateArgs, type MutationCartMetafieldDeleteArgs, type MutationCartMetafieldsSetArgs, type MutationCartNoteUpdateArgs, type MutationCartPaymentUpdateArgs, type MutationCartPrepareForCompletionArgs, type MutationCartSelectedDeliveryOptionsUpdateArgs, type MutationCartSubmitForCompletionArgs, type MutationCustomerAccessTokenCreateArgs, type MutationCustomerAccessTokenCreateWithMultipassArgs, type MutationCustomerAccessTokenDeleteArgs, type MutationCustomerAccessTokenRenewArgs, type MutationCustomerActivateArgs, type MutationCustomerActivateByUrlArgs, type MutationCustomerAddressCreateArgs, type MutationCustomerAddressDeleteArgs, type MutationCustomerAddressUpdateArgs, type MutationCustomerCreateArgs, type MutationCustomerDefaultAddressUpdateArgs, type MutationCustomerRecoverArgs, type MutationCustomerResetArgs, type MutationCustomerResetByUrlArgs, type MutationCustomerUpdateArgs, type MutationShopPayPaymentRequestSessionCreateArgs, type MutationShopPayPaymentRequestSessionSubmitArgs, type Node, type NormalizedArticle, type NormalizedBlog, type NormalizedCart, type NormalizedCollection, type NormalizedLineItem, type NormalizedProduct, type NormalizedProductVariant, type NormalizedProductsConnection, type NormalizedSellingPlanGroup, type OnlineStorePublishable, type Order, OrderCancelReason, type OrderConnection, type OrderDiscountApplicationsArgs, type OrderEdge, OrderFinancialStatus, OrderFulfillmentStatus, type OrderLineItem, type OrderLineItemConnection, type OrderLineItemEdge, type OrderLineItemsArgs, type OrderMetafieldArgs, type OrderMetafieldsArgs, OrderSortKeys, type OrderSuccessfulFulfillmentsArgs, type Page, type PageConnection, type PageEdge, type PageInfo, type PageInfoFragment, type PageMetafieldArgs, type PageMetafieldsArgs, PageSortKeys, type PaginatedSitemapResources, type PaymentSettings, PredictiveSearchLimitScope, type PredictiveSearchResult, PredictiveSearchType, PreferenceDeliveryMethodType, type PriceRangeFilter, type PricingPercentageValue, type PricingValue, type Product, type ProductAdjacentVariantsArgs, ProductCollectionSortKeys, type ProductCollectionsArgs, type ProductConnection, type ProductDescriptionArgs, type ProductEdge, type ProductFilter, type ProductFragment, ProductImageSortKeys, type ProductImagesArgs, type ProductMediaArgs, ProductMediaSortKeys, type ProductMetafieldArgs, type ProductMetafieldsArgs, type ProductOption, type ProductOptionValue, type ProductOptionValueSwatch, type ProductOptionsArgs, type ProductPriceRange, ProductRecommendationIntent, type ProductSelectedOrFirstAvailableVariantArgs, type ProductSellingPlanGroupsArgs, ProductSortKeys, type ProductVariant, type ProductVariantBySelectedOptionsArgs, type ProductVariantComponent, type ProductVariantComponentConnection, type ProductVariantComponentEdge, type ProductVariantComponentsArgs, type ProductVariantConnection, type ProductVariantEdge, type ProductVariantGroupedByArgs, type ProductVariantMetafieldArgs, type ProductVariantMetafieldsArgs, type ProductVariantQuantityPriceBreaksArgs, type ProductVariantSellingPlanAllocationsArgs, ProductVariantSortKeys, type ProductVariantStoreAvailabilityArgs, type ProductVariantsArgs, type PurchasingCompany, type QuantityPriceBreak, type QuantityPriceBreakConnection, type QuantityPriceBreakEdge, type QuantityRule, type QueryRoot, type QueryRootArticleArgs, type QueryRootArticlesArgs, type QueryRootBlogArgs, type QueryRootBlogByHandleArgs, type QueryRootBlogsArgs, type QueryRootCartArgs, type QueryRootCartCompletionAttemptArgs, type QueryRootCollectionArgs, type QueryRootCollectionByHandleArgs, type QueryRootCollectionsArgs, type QueryRootCustomerArgs, type QueryRootLocationsArgs, type QueryRootMenuArgs, type QueryRootMetaobjectArgs, type QueryRootMetaobjectsArgs, type QueryRootNodeArgs, type QueryRootNodesArgs, type QueryRootPageArgs, type QueryRootPageByHandleArgs, type QueryRootPagesArgs, type QueryRootPredictiveSearchArgs, type QueryRootProductArgs, type QueryRootProductByHandleArgs, type QueryRootProductRecommendationsArgs, type QueryRootProductTagsArgs, type QueryRootProductTypesArgs, type QueryRootProductsArgs, type QueryRootSearchArgs, type QueryRootSitemapArgs, type QueryRootUrlRedirectsArgs, type RemoveCartLinesOptions, type RemoveFromCartMutation, type RemoveFromCartMutationVariables, type Scalars, type ScriptDiscountApplication, SearchPrefixQueryType, type SearchQuerySuggestion, type SearchResultItem, type SearchResultItemConnection, type SearchResultItemEdge, SearchSortKeys, SearchType, SearchUnavailableProductsType, SearchableField, type SelectedOption, type SelectedOptionInput, type SellingPlan, type SellingPlanAllocation, type SellingPlanAllocationConnection, type SellingPlanAllocationEdge, type SellingPlanAllocationPriceAdjustment, type SellingPlanBillingPolicy, type SellingPlanCheckoutCharge, type SellingPlanCheckoutChargePercentageValue, SellingPlanCheckoutChargeType, type SellingPlanCheckoutChargeValue, type SellingPlanConnection, type SellingPlanDeliveryPolicy, type SellingPlanEdge, type SellingPlanFixedAmountPriceAdjustment, type SellingPlanFixedPriceAdjustment, type SellingPlanGroup, type SellingPlanGroupConnection, type SellingPlanGroupEdge, type SellingPlanGroupOption, type SellingPlanGroupSellingPlansArgs, SellingPlanInterval, type SellingPlanMetafieldArgs, type SellingPlanMetafieldsArgs, type SellingPlanOption, type SellingPlanPercentagePriceAdjustment, type SellingPlanPriceAdjustment, type SellingPlanPriceAdjustmentValue, type SellingPlanRecurringBillingPolicy, type SellingPlanRecurringDeliveryPolicy, type Seo, type SeoFragment, type Shop, type ShopMetafieldArgs, type ShopMetafieldsArgs, type ShopPayInstallmentsFinancingPlan, ShopPayInstallmentsFinancingPlanFrequency, type ShopPayInstallmentsFinancingPlanTerm, ShopPayInstallmentsLoan, type ShopPayInstallmentsPricing, type ShopPayInstallmentsProductVariantPricing, type ShopPayPaymentRequest, type ShopPayPaymentRequestContactField, type ShopPayPaymentRequestDeliveryMethod, type ShopPayPaymentRequestDeliveryMethodInput, ShopPayPaymentRequestDeliveryMethodType, type ShopPayPaymentRequestDiscount, type ShopPayPaymentRequestDiscountInput, type ShopPayPaymentRequestImage, type ShopPayPaymentRequestImageInput, type ShopPayPaymentRequestInput, type ShopPayPaymentRequestLineItem, type ShopPayPaymentRequestLineItemInput, type ShopPayPaymentRequestReceipt, type ShopPayPaymentRequestSession, type ShopPayPaymentRequestSessionCreatePayload, type ShopPayPaymentRequestSessionSubmitPayload, type ShopPayPaymentRequestShippingLine, type ShopPayPaymentRequestShippingLineInput, type ShopPayPaymentRequestTotalShippingPrice, type ShopPayPaymentRequestTotalShippingPriceInput, type ShopPayWalletContentInput, type ShopPolicy, type ShopPolicyWithDefault, ShopifyClient, type Sitemap, type SitemapImage, type SitemapResource, type SitemapResourceInterface, type SitemapResourceMetaobject, type SitemapResourcesArgs, SitemapType, type StoreAvailability, type StoreAvailabilityConnection, type StoreAvailabilityEdge, type StringConnection, type StringEdge, type SubmissionError, SubmissionErrorCode, type SubmitAlreadyAccepted, type SubmitFailed, type SubmitSuccess, type SubmitThrottled, type Swatch, type TaxonomyCategory, type TaxonomyMetafieldFilter, type Trackable, type UnitPriceMeasurement, UnitPriceMeasurementMeasuredType, UnitPriceMeasurementMeasuredUnit, UnitSystem, type UpdateCartAttributesOptions, type UpdateCartCodesOptions, type UpdateCartDeliveryOptions, type UpdateCartDeliveryOptionsMutation, type UpdateCartDeliveryOptionsMutationVariables, type UpdateCartLinesOptions, type UrlRedirect, type UrlRedirectConnection, type UrlRedirectEdge, type UserError, type UserErrorsShopPayPaymentRequestSessionUserErrors, UserErrorsShopPayPaymentRequestSessionUserErrorsCode, type VariantFragment, type VariantOptionFilter, type Video, type VideoSource, WeightUnit, addCartLines, createCart, getAllBlogs, getAllCollections, getAllProducts, getArticle, getArticles, getArticlesInBlog, getBlog, getCart, getCollection, getCollections, getProduct, getProducts, getProductsByHandles, normalizeArticle, normalizeBlog, normalizeCart, normalizeCollection, normalizeLineItem, normalizeProduct, removeCartLines, updateCartAttributes, updateCartCodes, updateCartDeliveryOptions, updateCartLines };
11063
+ export { type AddCartLinesOptions, type AddToCartMutation, type AddToCartMutationVariables, type ApiVersion, type ApplePayWalletContentInput, type ApplePayWalletHeaderInput, type AppliedGiftCard, type Article, type ArticleAuthor, type ArticleCommentsArgs, type ArticleConnection, type ArticleContentArgs, type ArticleEdge, type ArticleExcerptArgs, type ArticleFragment, type ArticleMetafieldArgs, type ArticleMetafieldsArgs, ArticleSortKeys, type ArticleWithMetafieldsFragment, type Attribute, type AttributeInput, type AutomaticDiscountApplication, type BaseCartLine, type BaseCartLineAttributeArgs, type BaseCartLineConnection, type BaseCartLineEdge, type Blog, type BlogArticleByHandleArgs, type BlogArticlesArgs, type BlogConnection, type BlogEdge, type BlogFragment, type BlogMetafieldArgs, type BlogMetafieldsArgs, BlogSortKeys, type BlogWithMetafieldsFragment, type Brand, type BrandColorGroup, type BrandColors, type BuyerInput, CardBrand, type Cart, type CartAPIOptions, type CartAddress, type CartAddressInput, type CartAttributeArgs, type CartAttributesUpdateMutation, type CartAttributesUpdateMutationVariables, type CartAttributesUpdatePayload, type CartAutomaticDiscountAllocation, type CartBillingAddressUpdatePayload, type CartBuyerIdentity, type CartBuyerIdentityInput, type CartBuyerIdentityUpdatePayload, CartCardSource, type CartCodeDiscountAllocation, type CartCompletionAction, type CartCompletionActionRequired, type CartCompletionAttemptResult, type CartCompletionFailed, type CartCompletionProcessing, type CartCompletionSuccess, type CartCookieAdapter, type CartCost, type CartCreatePayload, type CartCustomDiscountAllocation, type CartDelivery, type CartDeliveryAddress, type CartDeliveryAddressFormattedArgs, type CartDeliveryAddressInput, type CartDeliveryAddressesAddPayload, type CartDeliveryAddressesArgs, type CartDeliveryAddressesRemovePayload, type CartDeliveryAddressesUpdatePayload, type CartDeliveryCoordinatesPreference, type CartDeliveryCoordinatesPreferenceInput, type CartDeliveryGroup, type CartDeliveryGroupCartLinesArgs, type CartDeliveryGroupConnection, type CartDeliveryGroupEdge, CartDeliveryGroupType, type CartDeliveryGroupsArgs, type CartDeliveryInput, type CartDeliveryOption, type CartDeliveryPreference, type CartDeliveryPreferenceInput, type CartDirectPaymentMethodInput, type CartDiscountAllocation, type CartDiscountApplication, type CartDiscountCode, type CartDiscountCodesUpdateMutation, type CartDiscountCodesUpdateMutationVariables, type CartDiscountCodesUpdatePayload, CartErrorCode, type CartEstimatedCost, type CartFragment, type CartFreePaymentMethodInput, type CartGiftCardCodesRemovePayload, type CartGiftCardCodesUpdatePayload, type CartInput, type CartInputMetafieldInput, type CartLine, type CartLineAttributeArgs, type CartLineCost, type CartLineEstimatedCost, type CartLineInput, type CartLineUpdateInput, type CartLinesAddPayload, type CartLinesArgs, type CartLinesRemovePayload, type CartLinesUpdatePayload, type CartMetafieldArgs, type CartMetafieldDeleteInput, type CartMetafieldDeletePayload, type CartMetafieldsArgs, type CartMetafieldsSetInput, type CartMetafieldsSetPayload, type CartNoteUpdatePayload, type CartOperationError, type CartOperationResult, type CartPaymentInput, type CartPaymentUpdatePayload, type CartPreferences, type CartPreferencesInput, type CartPrepareForCompletionPayload, type CartPrepareForCompletionResult, type CartSelectableAddress, type CartSelectableAddressInput, type CartSelectableAddressUpdateInput, type CartSelectedDeliveryOptionInput, type CartSelectedDeliveryOptionsUpdatePayload, type CartStatusNotReady, type CartStatusReady, type CartSubmitForCompletionPayload, type CartSubmitForCompletionResult, type CartThrottled, type CartUserError, type CartWalletPaymentMethodInput, type CartWarning, CartWarningCode, type CategoryFilter, type Collection, type CollectionConnection, type CollectionDescriptionArgs, type CollectionEdge, type CollectionFragment, type CollectionMetafieldArgs, type CollectionMetafieldsArgs, type CollectionProductsArgs, CollectionSortKeys, type CollectionsConnection, type Comment, type CommentAuthor, type CommentConnection, type CommentContentArgs, type CommentEdge, type Company, type CompanyContact, type CompanyLocation, type CompanyLocationMetafieldArgs, type CompanyLocationMetafieldsArgs, type CompanyMetafieldArgs, type CompanyMetafieldsArgs, type CompletePaymentChallenge, type CompletionError, CompletionErrorCode, type ComponentizableCartLine, type ComponentizableCartLineAttributeArgs, type Count, CountPrecision, type Country, CountryCode, type CreateCartMutation, type CreateCartMutationVariables, type CreateCartOptions, CropRegion, type Currency, CurrencyCode, type Customer, type CustomerAccessToken, type CustomerAccessTokenCreateInput, type CustomerAccessTokenCreatePayload, type CustomerAccessTokenCreateWithMultipassPayload, type CustomerAccessTokenDeletePayload, type CustomerAccessTokenRenewPayload, type CustomerActivateByUrlPayload, type CustomerActivateInput, type CustomerActivatePayload, type CustomerAddressCreatePayload, type CustomerAddressDeletePayload, type CustomerAddressUpdatePayload, type CustomerAddressesArgs, type CustomerCreateInput, type CustomerCreatePayload, type CustomerDefaultAddressUpdatePayload, CustomerErrorCode, type CustomerMetafieldArgs, type CustomerMetafieldsArgs, type CustomerOrdersArgs, type CustomerRecoverPayload, type CustomerResetByUrlPayload, type CustomerResetInput, type CustomerResetPayload, type CustomerUpdateInput, type CustomerUpdatePayload, type CustomerUserError, type DeliveryAddress, type DeliveryAddressInput, DeliveryAddressValidationStrategy, DeliveryMethodType, DigitalWallet, type DiscountAllocation, type DiscountApplication, DiscountApplicationAllocationMethod, type DiscountApplicationConnection, type DiscountApplicationEdge, DiscountApplicationTargetSelection, DiscountApplicationTargetType, type DiscountCodeApplication, type DisplayableError, type Domain, type EditCartItemsMutation, type EditCartItemsMutationVariables, type Exact, type ExternalVideo, type Filter, FilterPresentation, FilterType, type FilterValue, type Fulfillment, type FulfillmentFulfillmentLineItemsArgs, type FulfillmentLineItem, type FulfillmentLineItemConnection, type FulfillmentLineItemEdge, type FulfillmentTrackingInfo, type FulfillmentTrackingInfoArgs, type GenericFile, type GeoCoordinateInput, type GetAllBlogsOptions, type GetAllProductPathsQuery, type GetAllProductPathsQueryVariables, type GetAllProductsOptions, type GetArticleOptions, type GetArticlesInBlogOptions, type GetArticlesOptions, type GetBlogOptions, type GetCartOptions, type GetCartQuery, type GetCartQueryVariables, type GetCollectionOptions, type GetCollectionsOptions, type GetProductByHandleQuery, type GetProductByHandleQueryVariables, type GetProductOptions, type GetProductsByHandlesOptions, type GetProductsQuery, type GetProductsQueryVariables, type HasMetafields, type HasMetafieldsIdentifier, type HasMetafieldsMetafieldArgs, type HasMetafieldsMetafieldsArgs, type Image, type ImageConnection, ImageContentType, type ImageEdge, type ImageFragment, type ImageTransformInput, type ImageTransformedSrcArgs, type ImageUrlArgs, type InContextAnnotation, type InContextAnnotationType, type Incremental, type InputMaybe, type Language, LanguageCode, type Localization, type Location, type LocationAddress, type LocationConnection, type LocationEdge, type LocationMetafieldArgs, type LocationMetafieldsArgs, LocationSortKeys, type MailingAddress, type MailingAddressConnection, type MailingAddressEdge, type MailingAddressFormattedArgs, type MailingAddressInput, type MakeEmpty, type MakeMaybe, type MakeOptional, type ManualDiscountApplication, type Market, type MarketMetafieldArgs, type MarketMetafieldsArgs, type Maybe, type Media, type MediaConnection, MediaContentType, type MediaEdge, MediaHost, type MediaImage, type MediaPresentation, type MediaPresentationAsJsonArgs, MediaPresentationFormat, type Menu, type MenuItem, type MenuItemResource, MenuItemType, type Merchandise, type Metafield, MetafieldDeleteErrorCode, type MetafieldDeleteUserError, type MetafieldFilter, type MetafieldFragment, type MetafieldParentResource, type MetafieldReference, type MetafieldReferenceConnection, type MetafieldReferenceEdge, type MetafieldReferencesArgs, type MetafieldsSetUserError, MetafieldsSetUserErrorCode, type Metaobject, type MetaobjectConnection, type MetaobjectEdge, type MetaobjectField, type MetaobjectFieldArgs, type MetaobjectFieldReferencesArgs, type MetaobjectHandleInput, type MetaobjectSeo, type Model3d, type Model3dSource, type MoneyInput, type MoneyV2, type Mutation, type MutationCartAttributesUpdateArgs, type MutationCartBillingAddressUpdateArgs, type MutationCartBuyerIdentityUpdateArgs, type MutationCartCreateArgs, type MutationCartDeliveryAddressesAddArgs, type MutationCartDeliveryAddressesRemoveArgs, type MutationCartDeliveryAddressesUpdateArgs, type MutationCartDiscountCodesUpdateArgs, type MutationCartGiftCardCodesRemoveArgs, type MutationCartGiftCardCodesUpdateArgs, type MutationCartLinesAddArgs, type MutationCartLinesRemoveArgs, type MutationCartLinesUpdateArgs, type MutationCartMetafieldDeleteArgs, type MutationCartMetafieldsSetArgs, type MutationCartNoteUpdateArgs, type MutationCartPaymentUpdateArgs, type MutationCartPrepareForCompletionArgs, type MutationCartSelectedDeliveryOptionsUpdateArgs, type MutationCartSubmitForCompletionArgs, type MutationCustomerAccessTokenCreateArgs, type MutationCustomerAccessTokenCreateWithMultipassArgs, type MutationCustomerAccessTokenDeleteArgs, type MutationCustomerAccessTokenRenewArgs, type MutationCustomerActivateArgs, type MutationCustomerActivateByUrlArgs, type MutationCustomerAddressCreateArgs, type MutationCustomerAddressDeleteArgs, type MutationCustomerAddressUpdateArgs, type MutationCustomerCreateArgs, type MutationCustomerDefaultAddressUpdateArgs, type MutationCustomerRecoverArgs, type MutationCustomerResetArgs, type MutationCustomerResetByUrlArgs, type MutationCustomerUpdateArgs, type MutationShopPayPaymentRequestSessionCreateArgs, type MutationShopPayPaymentRequestSessionSubmitArgs, type Node, type NormalizedArticle, type NormalizedAttribute, type NormalizedBlog, type NormalizedCart, type NormalizedCollection, type NormalizedLineItem, type NormalizedProduct, type NormalizedProductVariant, type NormalizedProductsConnection, type NormalizedSellingPlanGroup, type OnlineStorePublishable, type Order, OrderCancelReason, type OrderConnection, type OrderDiscountApplicationsArgs, type OrderEdge, OrderFinancialStatus, OrderFulfillmentStatus, type OrderLineItem, type OrderLineItemConnection, type OrderLineItemEdge, type OrderLineItemsArgs, type OrderMetafieldArgs, type OrderMetafieldsArgs, OrderSortKeys, type OrderSuccessfulFulfillmentsArgs, type Page, type PageConnection, type PageEdge, type PageInfo, type PageInfoFragment, type PageMetafieldArgs, type PageMetafieldsArgs, PageSortKeys, type PaginatedSitemapResources, type PaymentSettings, PredictiveSearchLimitScope, type PredictiveSearchResult, PredictiveSearchType, PreferenceDeliveryMethodType, type PriceRangeFilter, type PricingPercentageValue, type PricingValue, type Product, type ProductAdjacentVariantsArgs, ProductCollectionSortKeys, type ProductCollectionsArgs, type ProductConnection, type ProductDescriptionArgs, type ProductEdge, type ProductFilter, type ProductFragment, ProductImageSortKeys, type ProductImagesArgs, type ProductMediaArgs, ProductMediaSortKeys, type ProductMetafieldArgs, type ProductMetafieldsArgs, type ProductOption, type ProductOptionValue, type ProductOptionValueSwatch, type ProductOptionsArgs, type ProductPriceRange, ProductRecommendationIntent, type ProductSelectedOrFirstAvailableVariantArgs, type ProductSellingPlanGroupsArgs, ProductSortKeys, type ProductVariant, type ProductVariantBySelectedOptionsArgs, type ProductVariantComponent, type ProductVariantComponentConnection, type ProductVariantComponentEdge, type ProductVariantComponentsArgs, type ProductVariantConnection, type ProductVariantEdge, type ProductVariantGroupedByArgs, type ProductVariantMetafieldArgs, type ProductVariantMetafieldsArgs, type ProductVariantQuantityPriceBreaksArgs, type ProductVariantSellingPlanAllocationsArgs, ProductVariantSortKeys, type ProductVariantStoreAvailabilityArgs, type ProductVariantsArgs, type PurchasingCompany, type QuantityPriceBreak, type QuantityPriceBreakConnection, type QuantityPriceBreakEdge, type QuantityRule, type QueryRoot, type QueryRootArticleArgs, type QueryRootArticlesArgs, type QueryRootBlogArgs, type QueryRootBlogByHandleArgs, type QueryRootBlogsArgs, type QueryRootCartArgs, type QueryRootCartCompletionAttemptArgs, type QueryRootCollectionArgs, type QueryRootCollectionByHandleArgs, type QueryRootCollectionsArgs, type QueryRootCustomerArgs, type QueryRootLocationsArgs, type QueryRootMenuArgs, type QueryRootMetaobjectArgs, type QueryRootMetaobjectsArgs, type QueryRootNodeArgs, type QueryRootNodesArgs, type QueryRootPageArgs, type QueryRootPageByHandleArgs, type QueryRootPagesArgs, type QueryRootPredictiveSearchArgs, type QueryRootProductArgs, type QueryRootProductByHandleArgs, type QueryRootProductRecommendationsArgs, type QueryRootProductTagsArgs, type QueryRootProductTypesArgs, type QueryRootProductsArgs, type QueryRootSearchArgs, type QueryRootSitemapArgs, type QueryRootUrlRedirectsArgs, type RemoveCartLinesOptions, type RemoveFromCartMutation, type RemoveFromCartMutationVariables, type Scalars, type ScriptDiscountApplication, SearchPrefixQueryType, type SearchQuerySuggestion, type SearchResultItem, type SearchResultItemConnection, type SearchResultItemEdge, SearchSortKeys, SearchType, SearchUnavailableProductsType, SearchableField, type SelectedOption, type SelectedOptionInput, type SellingPlan, type SellingPlanAllocation, type SellingPlanAllocationConnection, type SellingPlanAllocationEdge, type SellingPlanAllocationPriceAdjustment, type SellingPlanBillingPolicy, type SellingPlanCheckoutCharge, type SellingPlanCheckoutChargePercentageValue, SellingPlanCheckoutChargeType, type SellingPlanCheckoutChargeValue, type SellingPlanConnection, type SellingPlanDeliveryPolicy, type SellingPlanEdge, type SellingPlanFixedAmountPriceAdjustment, type SellingPlanFixedPriceAdjustment, type SellingPlanGroup, type SellingPlanGroupConnection, type SellingPlanGroupEdge, type SellingPlanGroupOption, type SellingPlanGroupSellingPlansArgs, SellingPlanInterval, type SellingPlanMetafieldArgs, type SellingPlanMetafieldsArgs, type SellingPlanOption, type SellingPlanPercentagePriceAdjustment, type SellingPlanPriceAdjustment, type SellingPlanPriceAdjustmentValue, type SellingPlanRecurringBillingPolicy, type SellingPlanRecurringDeliveryPolicy, type Seo, type SeoFragment, type Shop, type ShopMetafieldArgs, type ShopMetafieldsArgs, type ShopPayInstallmentsFinancingPlan, ShopPayInstallmentsFinancingPlanFrequency, type ShopPayInstallmentsFinancingPlanTerm, ShopPayInstallmentsLoan, type ShopPayInstallmentsPricing, type ShopPayInstallmentsProductVariantPricing, type ShopPayPaymentRequest, type ShopPayPaymentRequestContactField, type ShopPayPaymentRequestDeliveryMethod, type ShopPayPaymentRequestDeliveryMethodInput, ShopPayPaymentRequestDeliveryMethodType, type ShopPayPaymentRequestDiscount, type ShopPayPaymentRequestDiscountInput, type ShopPayPaymentRequestImage, type ShopPayPaymentRequestImageInput, type ShopPayPaymentRequestInput, type ShopPayPaymentRequestLineItem, type ShopPayPaymentRequestLineItemInput, type ShopPayPaymentRequestReceipt, type ShopPayPaymentRequestSession, type ShopPayPaymentRequestSessionCreatePayload, type ShopPayPaymentRequestSessionSubmitPayload, type ShopPayPaymentRequestShippingLine, type ShopPayPaymentRequestShippingLineInput, type ShopPayPaymentRequestTotalShippingPrice, type ShopPayPaymentRequestTotalShippingPriceInput, type ShopPayWalletContentInput, type ShopPolicy, type ShopPolicyWithDefault, ShopifyClient, type Sitemap, type SitemapImage, type SitemapResource, type SitemapResourceInterface, type SitemapResourceMetaobject, type SitemapResourcesArgs, SitemapType, type StoreAvailability, type StoreAvailabilityConnection, type StoreAvailabilityEdge, type StringConnection, type StringEdge, type SubmissionError, SubmissionErrorCode, type SubmitAlreadyAccepted, type SubmitFailed, type SubmitSuccess, type SubmitThrottled, type Swatch, type TaxonomyCategory, type TaxonomyMetafieldFilter, type Trackable, type UnitPriceMeasurement, UnitPriceMeasurementMeasuredType, UnitPriceMeasurementMeasuredUnit, UnitSystem, type UpdateCartAttributesOptions, type UpdateCartCodesOptions, type UpdateCartDeliveryOptions, type UpdateCartDeliveryOptionsMutation, type UpdateCartDeliveryOptionsMutationVariables, type UpdateCartLinesOptions, type UrlRedirect, type UrlRedirectConnection, type UrlRedirectEdge, type UserError, type UserErrorsShopPayPaymentRequestSessionUserErrors, UserErrorsShopPayPaymentRequestSessionUserErrorsCode, type VariantFragment, type VariantOptionFilter, type Video, type VideoSource, WeightUnit, addCartLines, createCart, getAllBlogs, getAllCollections, getAllProducts, getArticle, getArticles, getArticlesInBlog, getBlog, getCart, getCollection, getCollections, getProduct, getProducts, getProductsByHandles, normalizeArticle, normalizeBlog, normalizeCart, normalizeCollection, normalizeLineItem, normalizeProduct, removeCartLines, updateCartAttributes, updateCartCodes, updateCartDeliveryOptions, updateCartLines };
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { FetchOptions, GraphQLError, GraphQLRequest, GraphQLResponse, createShop
3
3
  export { articleFragment, articleWithMetafieldsFragment, blogFragment, blogWithMetafieldsFragment, cartFragment, collectionFragment, imageFragment, metafieldFragment, metafieldFragmentStr, pageInfoFragment, productFragment, seoFragment, variantFragment } from './fragments/index.js';
4
4
  export { getAllProductsPathsQuery, getCartQuery, getProductQuery, getProductsByHandlesQuery, getProductsQuery } from './queries/index.js';
5
5
  export { addCartItemsMutation, createCartMutation, removeCartItemsMutation, updateCartAttributesMutation, updateCartDeliveryOptionsMutation, updateCartDiscountCodeMutation, updateCartItemsMutation } from './mutations/index.js';
6
- export { ShopifyConfig, clearLocalStorage, getLocalStorage, removeLocalStorage, setLocalStorage } from '@anker-in/shopify-core';
6
+ export * from '@anker-in/shopify-core';
7
7
 
8
8
  type Maybe<T> = T | null;
9
9
  type InputMaybe<T> = Maybe<T>;
@@ -10217,6 +10217,10 @@ declare module '@shopify/storefront-api-client' {
10217
10217
  interface StorefrontMutations extends GeneratedMutationTypes {}
10218
10218
  }
10219
10219
 
10220
+ interface NormalizedAttribute {
10221
+ key: string;
10222
+ value: string;
10223
+ }
10220
10224
  interface NormalizedLineItem {
10221
10225
  id: string;
10222
10226
  name: string;
@@ -10226,13 +10230,11 @@ interface NormalizedLineItem {
10226
10230
  totalAmount: number;
10227
10231
  subtotalAmount: number;
10228
10232
  discountAllocations: Array<{
10233
+ title: string;
10229
10234
  code: string;
10230
10235
  amount: number;
10231
10236
  }>;
10232
- customAttributes?: Array<{
10233
- key: string;
10234
- value: string;
10235
- }>;
10237
+ customAttributes: NormalizedAttribute[];
10236
10238
  variant: {
10237
10239
  id: string;
10238
10240
  price: number;
@@ -10279,13 +10281,14 @@ interface NormalizedCart {
10279
10281
  code: string;
10280
10282
  }>;
10281
10283
  discountAllocations?: Array<{
10284
+ title: string;
10282
10285
  code: string;
10283
10286
  amount: number;
10284
10287
  }>;
10285
10288
  url: string;
10286
10289
  ready: boolean;
10287
- orderStatusUrl?: any;
10288
- customAttributes?: any;
10290
+ orderStatusUrl?: string;
10291
+ customAttributes: NormalizedAttribute[];
10289
10292
  maxNum?: number;
10290
10293
  /** Delivery amount */
10291
10294
  deliveryAmount?: {
@@ -10399,6 +10402,8 @@ interface CreateCartOptions {
10399
10402
  variant: HasMetafieldsIdentifier[];
10400
10403
  product: HasMetafieldsIdentifier[];
10401
10404
  };
10405
+ /** Whether to update the cookie * 默认不更新cookie/ 仅在需要更新cookie时设置为true */
10406
+ updateCookie?: boolean;
10402
10407
  }
10403
10408
  /**
10404
10409
  * Create a new cart
@@ -10436,25 +10441,12 @@ declare function createCart(client: ShopifyClient, options?: CreateCartOptions):
10436
10441
  */
10437
10442
 
10438
10443
  interface AddCartLinesOptions {
10439
- /** Cart ID (optional, will create new cart if not provided) */
10440
- cartId?: string;
10444
+ /** Cart ID (required) */
10445
+ cartId: string;
10441
10446
  /** Lines to add */
10442
10447
  lines: CartLineInput[];
10443
10448
  /** Cookie adapter for managing cart ID */
10444
10449
  cookieAdapter?: CartCookieAdapter;
10445
- /** Current locale */
10446
- /** Buyer identity for cart creation */
10447
- buyerIdentity?: {
10448
- email?: string;
10449
- countryCode?: string;
10450
- };
10451
- /** Discount codes (only used when creating new cart) */
10452
- discountCodes?: string[];
10453
- /** Custom attributes (only used when creating new cart) */
10454
- customAttributes?: Array<{
10455
- key: string;
10456
- value: string;
10457
- }>;
10458
10450
  /** Metafield identifiers */
10459
10451
  metafieldIdentifiers?: {
10460
10452
  variant: HasMetafieldsIdentifier[];
@@ -10462,7 +10454,7 @@ interface AddCartLinesOptions {
10462
10454
  };
10463
10455
  }
10464
10456
  /**
10465
- * Add lines to cart (creates new cart if needed)
10457
+ * Add lines to an existing cart
10466
10458
  *
10467
10459
  * @param client - Shopify GraphQL client
10468
10460
  * @param options - Add cart lines options
@@ -10471,7 +10463,7 @@ interface AddCartLinesOptions {
10471
10463
  * @example
10472
10464
  * ```ts
10473
10465
  * const cart = await addCartLines(client, {
10474
- * locale: 'us',
10466
+ * cartId: 'gid://shopify/Cart/xxx',
10475
10467
  * lines: [{
10476
10468
  * merchandiseId: 'gid://shopify/ProductVariant/123',
10477
10469
  * quantity: 1
@@ -11068,4 +11060,4 @@ declare function getArticles(client: ShopifyClient, options: GetArticlesOptions)
11068
11060
 
11069
11061
  declare function getArticlesInBlog(client: ShopifyClient, options: GetArticlesInBlogOptions): Promise<NormalizedArticle[]>;
11070
11062
 
11071
- export { type AddCartLinesOptions, type AddToCartMutation, type AddToCartMutationVariables, type ApiVersion, type ApplePayWalletContentInput, type ApplePayWalletHeaderInput, type AppliedGiftCard, type Article, type ArticleAuthor, type ArticleCommentsArgs, type ArticleConnection, type ArticleContentArgs, type ArticleEdge, type ArticleExcerptArgs, type ArticleFragment, type ArticleMetafieldArgs, type ArticleMetafieldsArgs, ArticleSortKeys, type ArticleWithMetafieldsFragment, type Attribute, type AttributeInput, type AutomaticDiscountApplication, type BaseCartLine, type BaseCartLineAttributeArgs, type BaseCartLineConnection, type BaseCartLineEdge, type Blog, type BlogArticleByHandleArgs, type BlogArticlesArgs, type BlogConnection, type BlogEdge, type BlogFragment, type BlogMetafieldArgs, type BlogMetafieldsArgs, BlogSortKeys, type BlogWithMetafieldsFragment, type Brand, type BrandColorGroup, type BrandColors, type BuyerInput, CardBrand, type Cart, type CartAPIOptions, type CartAddress, type CartAddressInput, type CartAttributeArgs, type CartAttributesUpdateMutation, type CartAttributesUpdateMutationVariables, type CartAttributesUpdatePayload, type CartAutomaticDiscountAllocation, type CartBillingAddressUpdatePayload, type CartBuyerIdentity, type CartBuyerIdentityInput, type CartBuyerIdentityUpdatePayload, CartCardSource, type CartCodeDiscountAllocation, type CartCompletionAction, type CartCompletionActionRequired, type CartCompletionAttemptResult, type CartCompletionFailed, type CartCompletionProcessing, type CartCompletionSuccess, type CartCookieAdapter, type CartCost, type CartCreatePayload, type CartCustomDiscountAllocation, type CartDelivery, type CartDeliveryAddress, type CartDeliveryAddressFormattedArgs, type CartDeliveryAddressInput, type CartDeliveryAddressesAddPayload, type CartDeliveryAddressesArgs, type CartDeliveryAddressesRemovePayload, type CartDeliveryAddressesUpdatePayload, type CartDeliveryCoordinatesPreference, type CartDeliveryCoordinatesPreferenceInput, type CartDeliveryGroup, type CartDeliveryGroupCartLinesArgs, type CartDeliveryGroupConnection, type CartDeliveryGroupEdge, CartDeliveryGroupType, type CartDeliveryGroupsArgs, type CartDeliveryInput, type CartDeliveryOption, type CartDeliveryPreference, type CartDeliveryPreferenceInput, type CartDirectPaymentMethodInput, type CartDiscountAllocation, type CartDiscountApplication, type CartDiscountCode, type CartDiscountCodesUpdateMutation, type CartDiscountCodesUpdateMutationVariables, type CartDiscountCodesUpdatePayload, CartErrorCode, type CartEstimatedCost, type CartFragment, type CartFreePaymentMethodInput, type CartGiftCardCodesRemovePayload, type CartGiftCardCodesUpdatePayload, type CartInput, type CartInputMetafieldInput, type CartLine, type CartLineAttributeArgs, type CartLineCost, type CartLineEstimatedCost, type CartLineInput, type CartLineUpdateInput, type CartLinesAddPayload, type CartLinesArgs, type CartLinesRemovePayload, type CartLinesUpdatePayload, type CartMetafieldArgs, type CartMetafieldDeleteInput, type CartMetafieldDeletePayload, type CartMetafieldsArgs, type CartMetafieldsSetInput, type CartMetafieldsSetPayload, type CartNoteUpdatePayload, type CartOperationError, type CartOperationResult, type CartPaymentInput, type CartPaymentUpdatePayload, type CartPreferences, type CartPreferencesInput, type CartPrepareForCompletionPayload, type CartPrepareForCompletionResult, type CartSelectableAddress, type CartSelectableAddressInput, type CartSelectableAddressUpdateInput, type CartSelectedDeliveryOptionInput, type CartSelectedDeliveryOptionsUpdatePayload, type CartStatusNotReady, type CartStatusReady, type CartSubmitForCompletionPayload, type CartSubmitForCompletionResult, type CartThrottled, type CartUserError, type CartWalletPaymentMethodInput, type CartWarning, CartWarningCode, type CategoryFilter, type Collection, type CollectionConnection, type CollectionDescriptionArgs, type CollectionEdge, type CollectionFragment, type CollectionMetafieldArgs, type CollectionMetafieldsArgs, type CollectionProductsArgs, CollectionSortKeys, type CollectionsConnection, type Comment, type CommentAuthor, type CommentConnection, type CommentContentArgs, type CommentEdge, type Company, type CompanyContact, type CompanyLocation, type CompanyLocationMetafieldArgs, type CompanyLocationMetafieldsArgs, type CompanyMetafieldArgs, type CompanyMetafieldsArgs, type CompletePaymentChallenge, type CompletionError, CompletionErrorCode, type ComponentizableCartLine, type ComponentizableCartLineAttributeArgs, type Count, CountPrecision, type Country, CountryCode, type CreateCartMutation, type CreateCartMutationVariables, type CreateCartOptions, CropRegion, type Currency, CurrencyCode, type Customer, type CustomerAccessToken, type CustomerAccessTokenCreateInput, type CustomerAccessTokenCreatePayload, type CustomerAccessTokenCreateWithMultipassPayload, type CustomerAccessTokenDeletePayload, type CustomerAccessTokenRenewPayload, type CustomerActivateByUrlPayload, type CustomerActivateInput, type CustomerActivatePayload, type CustomerAddressCreatePayload, type CustomerAddressDeletePayload, type CustomerAddressUpdatePayload, type CustomerAddressesArgs, type CustomerCreateInput, type CustomerCreatePayload, type CustomerDefaultAddressUpdatePayload, CustomerErrorCode, type CustomerMetafieldArgs, type CustomerMetafieldsArgs, type CustomerOrdersArgs, type CustomerRecoverPayload, type CustomerResetByUrlPayload, type CustomerResetInput, type CustomerResetPayload, type CustomerUpdateInput, type CustomerUpdatePayload, type CustomerUserError, type DeliveryAddress, type DeliveryAddressInput, DeliveryAddressValidationStrategy, DeliveryMethodType, DigitalWallet, type DiscountAllocation, type DiscountApplication, DiscountApplicationAllocationMethod, type DiscountApplicationConnection, type DiscountApplicationEdge, DiscountApplicationTargetSelection, DiscountApplicationTargetType, type DiscountCodeApplication, type DisplayableError, type Domain, type EditCartItemsMutation, type EditCartItemsMutationVariables, type Exact, type ExternalVideo, type Filter, FilterPresentation, FilterType, type FilterValue, type Fulfillment, type FulfillmentFulfillmentLineItemsArgs, type FulfillmentLineItem, type FulfillmentLineItemConnection, type FulfillmentLineItemEdge, type FulfillmentTrackingInfo, type FulfillmentTrackingInfoArgs, type GenericFile, type GeoCoordinateInput, type GetAllBlogsOptions, type GetAllProductPathsQuery, type GetAllProductPathsQueryVariables, type GetAllProductsOptions, type GetArticleOptions, type GetArticlesInBlogOptions, type GetArticlesOptions, type GetBlogOptions, type GetCartOptions, type GetCartQuery, type GetCartQueryVariables, type GetCollectionOptions, type GetCollectionsOptions, type GetProductByHandleQuery, type GetProductByHandleQueryVariables, type GetProductOptions, type GetProductsByHandlesOptions, type GetProductsQuery, type GetProductsQueryVariables, type HasMetafields, type HasMetafieldsIdentifier, type HasMetafieldsMetafieldArgs, type HasMetafieldsMetafieldsArgs, type Image, type ImageConnection, ImageContentType, type ImageEdge, type ImageFragment, type ImageTransformInput, type ImageTransformedSrcArgs, type ImageUrlArgs, type InContextAnnotation, type InContextAnnotationType, type Incremental, type InputMaybe, type Language, LanguageCode, type Localization, type Location, type LocationAddress, type LocationConnection, type LocationEdge, type LocationMetafieldArgs, type LocationMetafieldsArgs, LocationSortKeys, type MailingAddress, type MailingAddressConnection, type MailingAddressEdge, type MailingAddressFormattedArgs, type MailingAddressInput, type MakeEmpty, type MakeMaybe, type MakeOptional, type ManualDiscountApplication, type Market, type MarketMetafieldArgs, type MarketMetafieldsArgs, type Maybe, type Media, type MediaConnection, MediaContentType, type MediaEdge, MediaHost, type MediaImage, type MediaPresentation, type MediaPresentationAsJsonArgs, MediaPresentationFormat, type Menu, type MenuItem, type MenuItemResource, MenuItemType, type Merchandise, type Metafield, MetafieldDeleteErrorCode, type MetafieldDeleteUserError, type MetafieldFilter, type MetafieldFragment, type MetafieldParentResource, type MetafieldReference, type MetafieldReferenceConnection, type MetafieldReferenceEdge, type MetafieldReferencesArgs, type MetafieldsSetUserError, MetafieldsSetUserErrorCode, type Metaobject, type MetaobjectConnection, type MetaobjectEdge, type MetaobjectField, type MetaobjectFieldArgs, type MetaobjectFieldReferencesArgs, type MetaobjectHandleInput, type MetaobjectSeo, type Model3d, type Model3dSource, type MoneyInput, type MoneyV2, type Mutation, type MutationCartAttributesUpdateArgs, type MutationCartBillingAddressUpdateArgs, type MutationCartBuyerIdentityUpdateArgs, type MutationCartCreateArgs, type MutationCartDeliveryAddressesAddArgs, type MutationCartDeliveryAddressesRemoveArgs, type MutationCartDeliveryAddressesUpdateArgs, type MutationCartDiscountCodesUpdateArgs, type MutationCartGiftCardCodesRemoveArgs, type MutationCartGiftCardCodesUpdateArgs, type MutationCartLinesAddArgs, type MutationCartLinesRemoveArgs, type MutationCartLinesUpdateArgs, type MutationCartMetafieldDeleteArgs, type MutationCartMetafieldsSetArgs, type MutationCartNoteUpdateArgs, type MutationCartPaymentUpdateArgs, type MutationCartPrepareForCompletionArgs, type MutationCartSelectedDeliveryOptionsUpdateArgs, type MutationCartSubmitForCompletionArgs, type MutationCustomerAccessTokenCreateArgs, type MutationCustomerAccessTokenCreateWithMultipassArgs, type MutationCustomerAccessTokenDeleteArgs, type MutationCustomerAccessTokenRenewArgs, type MutationCustomerActivateArgs, type MutationCustomerActivateByUrlArgs, type MutationCustomerAddressCreateArgs, type MutationCustomerAddressDeleteArgs, type MutationCustomerAddressUpdateArgs, type MutationCustomerCreateArgs, type MutationCustomerDefaultAddressUpdateArgs, type MutationCustomerRecoverArgs, type MutationCustomerResetArgs, type MutationCustomerResetByUrlArgs, type MutationCustomerUpdateArgs, type MutationShopPayPaymentRequestSessionCreateArgs, type MutationShopPayPaymentRequestSessionSubmitArgs, type Node, type NormalizedArticle, type NormalizedBlog, type NormalizedCart, type NormalizedCollection, type NormalizedLineItem, type NormalizedProduct, type NormalizedProductVariant, type NormalizedProductsConnection, type NormalizedSellingPlanGroup, type OnlineStorePublishable, type Order, OrderCancelReason, type OrderConnection, type OrderDiscountApplicationsArgs, type OrderEdge, OrderFinancialStatus, OrderFulfillmentStatus, type OrderLineItem, type OrderLineItemConnection, type OrderLineItemEdge, type OrderLineItemsArgs, type OrderMetafieldArgs, type OrderMetafieldsArgs, OrderSortKeys, type OrderSuccessfulFulfillmentsArgs, type Page, type PageConnection, type PageEdge, type PageInfo, type PageInfoFragment, type PageMetafieldArgs, type PageMetafieldsArgs, PageSortKeys, type PaginatedSitemapResources, type PaymentSettings, PredictiveSearchLimitScope, type PredictiveSearchResult, PredictiveSearchType, PreferenceDeliveryMethodType, type PriceRangeFilter, type PricingPercentageValue, type PricingValue, type Product, type ProductAdjacentVariantsArgs, ProductCollectionSortKeys, type ProductCollectionsArgs, type ProductConnection, type ProductDescriptionArgs, type ProductEdge, type ProductFilter, type ProductFragment, ProductImageSortKeys, type ProductImagesArgs, type ProductMediaArgs, ProductMediaSortKeys, type ProductMetafieldArgs, type ProductMetafieldsArgs, type ProductOption, type ProductOptionValue, type ProductOptionValueSwatch, type ProductOptionsArgs, type ProductPriceRange, ProductRecommendationIntent, type ProductSelectedOrFirstAvailableVariantArgs, type ProductSellingPlanGroupsArgs, ProductSortKeys, type ProductVariant, type ProductVariantBySelectedOptionsArgs, type ProductVariantComponent, type ProductVariantComponentConnection, type ProductVariantComponentEdge, type ProductVariantComponentsArgs, type ProductVariantConnection, type ProductVariantEdge, type ProductVariantGroupedByArgs, type ProductVariantMetafieldArgs, type ProductVariantMetafieldsArgs, type ProductVariantQuantityPriceBreaksArgs, type ProductVariantSellingPlanAllocationsArgs, ProductVariantSortKeys, type ProductVariantStoreAvailabilityArgs, type ProductVariantsArgs, type PurchasingCompany, type QuantityPriceBreak, type QuantityPriceBreakConnection, type QuantityPriceBreakEdge, type QuantityRule, type QueryRoot, type QueryRootArticleArgs, type QueryRootArticlesArgs, type QueryRootBlogArgs, type QueryRootBlogByHandleArgs, type QueryRootBlogsArgs, type QueryRootCartArgs, type QueryRootCartCompletionAttemptArgs, type QueryRootCollectionArgs, type QueryRootCollectionByHandleArgs, type QueryRootCollectionsArgs, type QueryRootCustomerArgs, type QueryRootLocationsArgs, type QueryRootMenuArgs, type QueryRootMetaobjectArgs, type QueryRootMetaobjectsArgs, type QueryRootNodeArgs, type QueryRootNodesArgs, type QueryRootPageArgs, type QueryRootPageByHandleArgs, type QueryRootPagesArgs, type QueryRootPredictiveSearchArgs, type QueryRootProductArgs, type QueryRootProductByHandleArgs, type QueryRootProductRecommendationsArgs, type QueryRootProductTagsArgs, type QueryRootProductTypesArgs, type QueryRootProductsArgs, type QueryRootSearchArgs, type QueryRootSitemapArgs, type QueryRootUrlRedirectsArgs, type RemoveCartLinesOptions, type RemoveFromCartMutation, type RemoveFromCartMutationVariables, type Scalars, type ScriptDiscountApplication, SearchPrefixQueryType, type SearchQuerySuggestion, type SearchResultItem, type SearchResultItemConnection, type SearchResultItemEdge, SearchSortKeys, SearchType, SearchUnavailableProductsType, SearchableField, type SelectedOption, type SelectedOptionInput, type SellingPlan, type SellingPlanAllocation, type SellingPlanAllocationConnection, type SellingPlanAllocationEdge, type SellingPlanAllocationPriceAdjustment, type SellingPlanBillingPolicy, type SellingPlanCheckoutCharge, type SellingPlanCheckoutChargePercentageValue, SellingPlanCheckoutChargeType, type SellingPlanCheckoutChargeValue, type SellingPlanConnection, type SellingPlanDeliveryPolicy, type SellingPlanEdge, type SellingPlanFixedAmountPriceAdjustment, type SellingPlanFixedPriceAdjustment, type SellingPlanGroup, type SellingPlanGroupConnection, type SellingPlanGroupEdge, type SellingPlanGroupOption, type SellingPlanGroupSellingPlansArgs, SellingPlanInterval, type SellingPlanMetafieldArgs, type SellingPlanMetafieldsArgs, type SellingPlanOption, type SellingPlanPercentagePriceAdjustment, type SellingPlanPriceAdjustment, type SellingPlanPriceAdjustmentValue, type SellingPlanRecurringBillingPolicy, type SellingPlanRecurringDeliveryPolicy, type Seo, type SeoFragment, type Shop, type ShopMetafieldArgs, type ShopMetafieldsArgs, type ShopPayInstallmentsFinancingPlan, ShopPayInstallmentsFinancingPlanFrequency, type ShopPayInstallmentsFinancingPlanTerm, ShopPayInstallmentsLoan, type ShopPayInstallmentsPricing, type ShopPayInstallmentsProductVariantPricing, type ShopPayPaymentRequest, type ShopPayPaymentRequestContactField, type ShopPayPaymentRequestDeliveryMethod, type ShopPayPaymentRequestDeliveryMethodInput, ShopPayPaymentRequestDeliveryMethodType, type ShopPayPaymentRequestDiscount, type ShopPayPaymentRequestDiscountInput, type ShopPayPaymentRequestImage, type ShopPayPaymentRequestImageInput, type ShopPayPaymentRequestInput, type ShopPayPaymentRequestLineItem, type ShopPayPaymentRequestLineItemInput, type ShopPayPaymentRequestReceipt, type ShopPayPaymentRequestSession, type ShopPayPaymentRequestSessionCreatePayload, type ShopPayPaymentRequestSessionSubmitPayload, type ShopPayPaymentRequestShippingLine, type ShopPayPaymentRequestShippingLineInput, type ShopPayPaymentRequestTotalShippingPrice, type ShopPayPaymentRequestTotalShippingPriceInput, type ShopPayWalletContentInput, type ShopPolicy, type ShopPolicyWithDefault, ShopifyClient, type Sitemap, type SitemapImage, type SitemapResource, type SitemapResourceInterface, type SitemapResourceMetaobject, type SitemapResourcesArgs, SitemapType, type StoreAvailability, type StoreAvailabilityConnection, type StoreAvailabilityEdge, type StringConnection, type StringEdge, type SubmissionError, SubmissionErrorCode, type SubmitAlreadyAccepted, type SubmitFailed, type SubmitSuccess, type SubmitThrottled, type Swatch, type TaxonomyCategory, type TaxonomyMetafieldFilter, type Trackable, type UnitPriceMeasurement, UnitPriceMeasurementMeasuredType, UnitPriceMeasurementMeasuredUnit, UnitSystem, type UpdateCartAttributesOptions, type UpdateCartCodesOptions, type UpdateCartDeliveryOptions, type UpdateCartDeliveryOptionsMutation, type UpdateCartDeliveryOptionsMutationVariables, type UpdateCartLinesOptions, type UrlRedirect, type UrlRedirectConnection, type UrlRedirectEdge, type UserError, type UserErrorsShopPayPaymentRequestSessionUserErrors, UserErrorsShopPayPaymentRequestSessionUserErrorsCode, type VariantFragment, type VariantOptionFilter, type Video, type VideoSource, WeightUnit, addCartLines, createCart, getAllBlogs, getAllCollections, getAllProducts, getArticle, getArticles, getArticlesInBlog, getBlog, getCart, getCollection, getCollections, getProduct, getProducts, getProductsByHandles, normalizeArticle, normalizeBlog, normalizeCart, normalizeCollection, normalizeLineItem, normalizeProduct, removeCartLines, updateCartAttributes, updateCartCodes, updateCartDeliveryOptions, updateCartLines };
11063
+ export { type AddCartLinesOptions, type AddToCartMutation, type AddToCartMutationVariables, type ApiVersion, type ApplePayWalletContentInput, type ApplePayWalletHeaderInput, type AppliedGiftCard, type Article, type ArticleAuthor, type ArticleCommentsArgs, type ArticleConnection, type ArticleContentArgs, type ArticleEdge, type ArticleExcerptArgs, type ArticleFragment, type ArticleMetafieldArgs, type ArticleMetafieldsArgs, ArticleSortKeys, type ArticleWithMetafieldsFragment, type Attribute, type AttributeInput, type AutomaticDiscountApplication, type BaseCartLine, type BaseCartLineAttributeArgs, type BaseCartLineConnection, type BaseCartLineEdge, type Blog, type BlogArticleByHandleArgs, type BlogArticlesArgs, type BlogConnection, type BlogEdge, type BlogFragment, type BlogMetafieldArgs, type BlogMetafieldsArgs, BlogSortKeys, type BlogWithMetafieldsFragment, type Brand, type BrandColorGroup, type BrandColors, type BuyerInput, CardBrand, type Cart, type CartAPIOptions, type CartAddress, type CartAddressInput, type CartAttributeArgs, type CartAttributesUpdateMutation, type CartAttributesUpdateMutationVariables, type CartAttributesUpdatePayload, type CartAutomaticDiscountAllocation, type CartBillingAddressUpdatePayload, type CartBuyerIdentity, type CartBuyerIdentityInput, type CartBuyerIdentityUpdatePayload, CartCardSource, type CartCodeDiscountAllocation, type CartCompletionAction, type CartCompletionActionRequired, type CartCompletionAttemptResult, type CartCompletionFailed, type CartCompletionProcessing, type CartCompletionSuccess, type CartCookieAdapter, type CartCost, type CartCreatePayload, type CartCustomDiscountAllocation, type CartDelivery, type CartDeliveryAddress, type CartDeliveryAddressFormattedArgs, type CartDeliveryAddressInput, type CartDeliveryAddressesAddPayload, type CartDeliveryAddressesArgs, type CartDeliveryAddressesRemovePayload, type CartDeliveryAddressesUpdatePayload, type CartDeliveryCoordinatesPreference, type CartDeliveryCoordinatesPreferenceInput, type CartDeliveryGroup, type CartDeliveryGroupCartLinesArgs, type CartDeliveryGroupConnection, type CartDeliveryGroupEdge, CartDeliveryGroupType, type CartDeliveryGroupsArgs, type CartDeliveryInput, type CartDeliveryOption, type CartDeliveryPreference, type CartDeliveryPreferenceInput, type CartDirectPaymentMethodInput, type CartDiscountAllocation, type CartDiscountApplication, type CartDiscountCode, type CartDiscountCodesUpdateMutation, type CartDiscountCodesUpdateMutationVariables, type CartDiscountCodesUpdatePayload, CartErrorCode, type CartEstimatedCost, type CartFragment, type CartFreePaymentMethodInput, type CartGiftCardCodesRemovePayload, type CartGiftCardCodesUpdatePayload, type CartInput, type CartInputMetafieldInput, type CartLine, type CartLineAttributeArgs, type CartLineCost, type CartLineEstimatedCost, type CartLineInput, type CartLineUpdateInput, type CartLinesAddPayload, type CartLinesArgs, type CartLinesRemovePayload, type CartLinesUpdatePayload, type CartMetafieldArgs, type CartMetafieldDeleteInput, type CartMetafieldDeletePayload, type CartMetafieldsArgs, type CartMetafieldsSetInput, type CartMetafieldsSetPayload, type CartNoteUpdatePayload, type CartOperationError, type CartOperationResult, type CartPaymentInput, type CartPaymentUpdatePayload, type CartPreferences, type CartPreferencesInput, type CartPrepareForCompletionPayload, type CartPrepareForCompletionResult, type CartSelectableAddress, type CartSelectableAddressInput, type CartSelectableAddressUpdateInput, type CartSelectedDeliveryOptionInput, type CartSelectedDeliveryOptionsUpdatePayload, type CartStatusNotReady, type CartStatusReady, type CartSubmitForCompletionPayload, type CartSubmitForCompletionResult, type CartThrottled, type CartUserError, type CartWalletPaymentMethodInput, type CartWarning, CartWarningCode, type CategoryFilter, type Collection, type CollectionConnection, type CollectionDescriptionArgs, type CollectionEdge, type CollectionFragment, type CollectionMetafieldArgs, type CollectionMetafieldsArgs, type CollectionProductsArgs, CollectionSortKeys, type CollectionsConnection, type Comment, type CommentAuthor, type CommentConnection, type CommentContentArgs, type CommentEdge, type Company, type CompanyContact, type CompanyLocation, type CompanyLocationMetafieldArgs, type CompanyLocationMetafieldsArgs, type CompanyMetafieldArgs, type CompanyMetafieldsArgs, type CompletePaymentChallenge, type CompletionError, CompletionErrorCode, type ComponentizableCartLine, type ComponentizableCartLineAttributeArgs, type Count, CountPrecision, type Country, CountryCode, type CreateCartMutation, type CreateCartMutationVariables, type CreateCartOptions, CropRegion, type Currency, CurrencyCode, type Customer, type CustomerAccessToken, type CustomerAccessTokenCreateInput, type CustomerAccessTokenCreatePayload, type CustomerAccessTokenCreateWithMultipassPayload, type CustomerAccessTokenDeletePayload, type CustomerAccessTokenRenewPayload, type CustomerActivateByUrlPayload, type CustomerActivateInput, type CustomerActivatePayload, type CustomerAddressCreatePayload, type CustomerAddressDeletePayload, type CustomerAddressUpdatePayload, type CustomerAddressesArgs, type CustomerCreateInput, type CustomerCreatePayload, type CustomerDefaultAddressUpdatePayload, CustomerErrorCode, type CustomerMetafieldArgs, type CustomerMetafieldsArgs, type CustomerOrdersArgs, type CustomerRecoverPayload, type CustomerResetByUrlPayload, type CustomerResetInput, type CustomerResetPayload, type CustomerUpdateInput, type CustomerUpdatePayload, type CustomerUserError, type DeliveryAddress, type DeliveryAddressInput, DeliveryAddressValidationStrategy, DeliveryMethodType, DigitalWallet, type DiscountAllocation, type DiscountApplication, DiscountApplicationAllocationMethod, type DiscountApplicationConnection, type DiscountApplicationEdge, DiscountApplicationTargetSelection, DiscountApplicationTargetType, type DiscountCodeApplication, type DisplayableError, type Domain, type EditCartItemsMutation, type EditCartItemsMutationVariables, type Exact, type ExternalVideo, type Filter, FilterPresentation, FilterType, type FilterValue, type Fulfillment, type FulfillmentFulfillmentLineItemsArgs, type FulfillmentLineItem, type FulfillmentLineItemConnection, type FulfillmentLineItemEdge, type FulfillmentTrackingInfo, type FulfillmentTrackingInfoArgs, type GenericFile, type GeoCoordinateInput, type GetAllBlogsOptions, type GetAllProductPathsQuery, type GetAllProductPathsQueryVariables, type GetAllProductsOptions, type GetArticleOptions, type GetArticlesInBlogOptions, type GetArticlesOptions, type GetBlogOptions, type GetCartOptions, type GetCartQuery, type GetCartQueryVariables, type GetCollectionOptions, type GetCollectionsOptions, type GetProductByHandleQuery, type GetProductByHandleQueryVariables, type GetProductOptions, type GetProductsByHandlesOptions, type GetProductsQuery, type GetProductsQueryVariables, type HasMetafields, type HasMetafieldsIdentifier, type HasMetafieldsMetafieldArgs, type HasMetafieldsMetafieldsArgs, type Image, type ImageConnection, ImageContentType, type ImageEdge, type ImageFragment, type ImageTransformInput, type ImageTransformedSrcArgs, type ImageUrlArgs, type InContextAnnotation, type InContextAnnotationType, type Incremental, type InputMaybe, type Language, LanguageCode, type Localization, type Location, type LocationAddress, type LocationConnection, type LocationEdge, type LocationMetafieldArgs, type LocationMetafieldsArgs, LocationSortKeys, type MailingAddress, type MailingAddressConnection, type MailingAddressEdge, type MailingAddressFormattedArgs, type MailingAddressInput, type MakeEmpty, type MakeMaybe, type MakeOptional, type ManualDiscountApplication, type Market, type MarketMetafieldArgs, type MarketMetafieldsArgs, type Maybe, type Media, type MediaConnection, MediaContentType, type MediaEdge, MediaHost, type MediaImage, type MediaPresentation, type MediaPresentationAsJsonArgs, MediaPresentationFormat, type Menu, type MenuItem, type MenuItemResource, MenuItemType, type Merchandise, type Metafield, MetafieldDeleteErrorCode, type MetafieldDeleteUserError, type MetafieldFilter, type MetafieldFragment, type MetafieldParentResource, type MetafieldReference, type MetafieldReferenceConnection, type MetafieldReferenceEdge, type MetafieldReferencesArgs, type MetafieldsSetUserError, MetafieldsSetUserErrorCode, type Metaobject, type MetaobjectConnection, type MetaobjectEdge, type MetaobjectField, type MetaobjectFieldArgs, type MetaobjectFieldReferencesArgs, type MetaobjectHandleInput, type MetaobjectSeo, type Model3d, type Model3dSource, type MoneyInput, type MoneyV2, type Mutation, type MutationCartAttributesUpdateArgs, type MutationCartBillingAddressUpdateArgs, type MutationCartBuyerIdentityUpdateArgs, type MutationCartCreateArgs, type MutationCartDeliveryAddressesAddArgs, type MutationCartDeliveryAddressesRemoveArgs, type MutationCartDeliveryAddressesUpdateArgs, type MutationCartDiscountCodesUpdateArgs, type MutationCartGiftCardCodesRemoveArgs, type MutationCartGiftCardCodesUpdateArgs, type MutationCartLinesAddArgs, type MutationCartLinesRemoveArgs, type MutationCartLinesUpdateArgs, type MutationCartMetafieldDeleteArgs, type MutationCartMetafieldsSetArgs, type MutationCartNoteUpdateArgs, type MutationCartPaymentUpdateArgs, type MutationCartPrepareForCompletionArgs, type MutationCartSelectedDeliveryOptionsUpdateArgs, type MutationCartSubmitForCompletionArgs, type MutationCustomerAccessTokenCreateArgs, type MutationCustomerAccessTokenCreateWithMultipassArgs, type MutationCustomerAccessTokenDeleteArgs, type MutationCustomerAccessTokenRenewArgs, type MutationCustomerActivateArgs, type MutationCustomerActivateByUrlArgs, type MutationCustomerAddressCreateArgs, type MutationCustomerAddressDeleteArgs, type MutationCustomerAddressUpdateArgs, type MutationCustomerCreateArgs, type MutationCustomerDefaultAddressUpdateArgs, type MutationCustomerRecoverArgs, type MutationCustomerResetArgs, type MutationCustomerResetByUrlArgs, type MutationCustomerUpdateArgs, type MutationShopPayPaymentRequestSessionCreateArgs, type MutationShopPayPaymentRequestSessionSubmitArgs, type Node, type NormalizedArticle, type NormalizedAttribute, type NormalizedBlog, type NormalizedCart, type NormalizedCollection, type NormalizedLineItem, type NormalizedProduct, type NormalizedProductVariant, type NormalizedProductsConnection, type NormalizedSellingPlanGroup, type OnlineStorePublishable, type Order, OrderCancelReason, type OrderConnection, type OrderDiscountApplicationsArgs, type OrderEdge, OrderFinancialStatus, OrderFulfillmentStatus, type OrderLineItem, type OrderLineItemConnection, type OrderLineItemEdge, type OrderLineItemsArgs, type OrderMetafieldArgs, type OrderMetafieldsArgs, OrderSortKeys, type OrderSuccessfulFulfillmentsArgs, type Page, type PageConnection, type PageEdge, type PageInfo, type PageInfoFragment, type PageMetafieldArgs, type PageMetafieldsArgs, PageSortKeys, type PaginatedSitemapResources, type PaymentSettings, PredictiveSearchLimitScope, type PredictiveSearchResult, PredictiveSearchType, PreferenceDeliveryMethodType, type PriceRangeFilter, type PricingPercentageValue, type PricingValue, type Product, type ProductAdjacentVariantsArgs, ProductCollectionSortKeys, type ProductCollectionsArgs, type ProductConnection, type ProductDescriptionArgs, type ProductEdge, type ProductFilter, type ProductFragment, ProductImageSortKeys, type ProductImagesArgs, type ProductMediaArgs, ProductMediaSortKeys, type ProductMetafieldArgs, type ProductMetafieldsArgs, type ProductOption, type ProductOptionValue, type ProductOptionValueSwatch, type ProductOptionsArgs, type ProductPriceRange, ProductRecommendationIntent, type ProductSelectedOrFirstAvailableVariantArgs, type ProductSellingPlanGroupsArgs, ProductSortKeys, type ProductVariant, type ProductVariantBySelectedOptionsArgs, type ProductVariantComponent, type ProductVariantComponentConnection, type ProductVariantComponentEdge, type ProductVariantComponentsArgs, type ProductVariantConnection, type ProductVariantEdge, type ProductVariantGroupedByArgs, type ProductVariantMetafieldArgs, type ProductVariantMetafieldsArgs, type ProductVariantQuantityPriceBreaksArgs, type ProductVariantSellingPlanAllocationsArgs, ProductVariantSortKeys, type ProductVariantStoreAvailabilityArgs, type ProductVariantsArgs, type PurchasingCompany, type QuantityPriceBreak, type QuantityPriceBreakConnection, type QuantityPriceBreakEdge, type QuantityRule, type QueryRoot, type QueryRootArticleArgs, type QueryRootArticlesArgs, type QueryRootBlogArgs, type QueryRootBlogByHandleArgs, type QueryRootBlogsArgs, type QueryRootCartArgs, type QueryRootCartCompletionAttemptArgs, type QueryRootCollectionArgs, type QueryRootCollectionByHandleArgs, type QueryRootCollectionsArgs, type QueryRootCustomerArgs, type QueryRootLocationsArgs, type QueryRootMenuArgs, type QueryRootMetaobjectArgs, type QueryRootMetaobjectsArgs, type QueryRootNodeArgs, type QueryRootNodesArgs, type QueryRootPageArgs, type QueryRootPageByHandleArgs, type QueryRootPagesArgs, type QueryRootPredictiveSearchArgs, type QueryRootProductArgs, type QueryRootProductByHandleArgs, type QueryRootProductRecommendationsArgs, type QueryRootProductTagsArgs, type QueryRootProductTypesArgs, type QueryRootProductsArgs, type QueryRootSearchArgs, type QueryRootSitemapArgs, type QueryRootUrlRedirectsArgs, type RemoveCartLinesOptions, type RemoveFromCartMutation, type RemoveFromCartMutationVariables, type Scalars, type ScriptDiscountApplication, SearchPrefixQueryType, type SearchQuerySuggestion, type SearchResultItem, type SearchResultItemConnection, type SearchResultItemEdge, SearchSortKeys, SearchType, SearchUnavailableProductsType, SearchableField, type SelectedOption, type SelectedOptionInput, type SellingPlan, type SellingPlanAllocation, type SellingPlanAllocationConnection, type SellingPlanAllocationEdge, type SellingPlanAllocationPriceAdjustment, type SellingPlanBillingPolicy, type SellingPlanCheckoutCharge, type SellingPlanCheckoutChargePercentageValue, SellingPlanCheckoutChargeType, type SellingPlanCheckoutChargeValue, type SellingPlanConnection, type SellingPlanDeliveryPolicy, type SellingPlanEdge, type SellingPlanFixedAmountPriceAdjustment, type SellingPlanFixedPriceAdjustment, type SellingPlanGroup, type SellingPlanGroupConnection, type SellingPlanGroupEdge, type SellingPlanGroupOption, type SellingPlanGroupSellingPlansArgs, SellingPlanInterval, type SellingPlanMetafieldArgs, type SellingPlanMetafieldsArgs, type SellingPlanOption, type SellingPlanPercentagePriceAdjustment, type SellingPlanPriceAdjustment, type SellingPlanPriceAdjustmentValue, type SellingPlanRecurringBillingPolicy, type SellingPlanRecurringDeliveryPolicy, type Seo, type SeoFragment, type Shop, type ShopMetafieldArgs, type ShopMetafieldsArgs, type ShopPayInstallmentsFinancingPlan, ShopPayInstallmentsFinancingPlanFrequency, type ShopPayInstallmentsFinancingPlanTerm, ShopPayInstallmentsLoan, type ShopPayInstallmentsPricing, type ShopPayInstallmentsProductVariantPricing, type ShopPayPaymentRequest, type ShopPayPaymentRequestContactField, type ShopPayPaymentRequestDeliveryMethod, type ShopPayPaymentRequestDeliveryMethodInput, ShopPayPaymentRequestDeliveryMethodType, type ShopPayPaymentRequestDiscount, type ShopPayPaymentRequestDiscountInput, type ShopPayPaymentRequestImage, type ShopPayPaymentRequestImageInput, type ShopPayPaymentRequestInput, type ShopPayPaymentRequestLineItem, type ShopPayPaymentRequestLineItemInput, type ShopPayPaymentRequestReceipt, type ShopPayPaymentRequestSession, type ShopPayPaymentRequestSessionCreatePayload, type ShopPayPaymentRequestSessionSubmitPayload, type ShopPayPaymentRequestShippingLine, type ShopPayPaymentRequestShippingLineInput, type ShopPayPaymentRequestTotalShippingPrice, type ShopPayPaymentRequestTotalShippingPriceInput, type ShopPayWalletContentInput, type ShopPolicy, type ShopPolicyWithDefault, ShopifyClient, type Sitemap, type SitemapImage, type SitemapResource, type SitemapResourceInterface, type SitemapResourceMetaobject, type SitemapResourcesArgs, SitemapType, type StoreAvailability, type StoreAvailabilityConnection, type StoreAvailabilityEdge, type StringConnection, type StringEdge, type SubmissionError, SubmissionErrorCode, type SubmitAlreadyAccepted, type SubmitFailed, type SubmitSuccess, type SubmitThrottled, type Swatch, type TaxonomyCategory, type TaxonomyMetafieldFilter, type Trackable, type UnitPriceMeasurement, UnitPriceMeasurementMeasuredType, UnitPriceMeasurementMeasuredUnit, UnitSystem, type UpdateCartAttributesOptions, type UpdateCartCodesOptions, type UpdateCartDeliveryOptions, type UpdateCartDeliveryOptionsMutation, type UpdateCartDeliveryOptionsMutationVariables, type UpdateCartLinesOptions, type UrlRedirect, type UrlRedirectConnection, type UrlRedirectEdge, type UserError, type UserErrorsShopPayPaymentRequestSessionUserErrors, UserErrorsShopPayPaymentRequestSessionUserErrorsCode, type VariantFragment, type VariantOptionFilter, type Video, type VideoSource, WeightUnit, addCartLines, createCart, getAllBlogs, getAllCollections, getAllProducts, getArticle, getArticles, getArticlesInBlog, getBlog, getCart, getCollection, getCollections, getProduct, getProducts, getProductsByHandles, normalizeArticle, normalizeBlog, normalizeCart, normalizeCollection, normalizeLineItem, normalizeProduct, removeCartLines, updateCartAttributes, updateCartCodes, updateCartDeliveryOptions, updateCartLines };