@anker-in/shopify-sdk 1.2.0-beta.10 → 1.2.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -766,6 +766,110 @@ var blogWithMetafieldsFragment = (
766
766
  `
767
767
  );
768
768
 
769
+ // src/fragments/page.ts
770
+ var pageFragment = (
771
+ /* GraphQL */
772
+ `
773
+ fragment page on Page {
774
+ id
775
+ handle
776
+ title
777
+ body
778
+ bodySummary
779
+ createdAt
780
+ updatedAt
781
+ seo {
782
+ ...seo
783
+ }
784
+ }
785
+ ${seoFragment}
786
+ `
787
+ );
788
+ var pageWithMetafieldsFragment = (
789
+ /* GraphQL */
790
+ `
791
+ fragment pageWithMetafields on Page {
792
+ id
793
+ handle
794
+ title
795
+ body
796
+ bodySummary
797
+ createdAt
798
+ updatedAt
799
+ seo {
800
+ ...seo
801
+ }
802
+ metafields(identifiers: $pageMetafieldIdentifiers) {
803
+ ...metafield
804
+ }
805
+ }
806
+ ${seoFragment}
807
+ ${metafieldFragment}
808
+ `
809
+ );
810
+
811
+ // src/fragments/shop.ts
812
+ var shopFragment = (
813
+ /* GraphQL */
814
+ `
815
+ fragment shop on Shop {
816
+ name
817
+ description
818
+ primaryDomain {
819
+ url
820
+ host
821
+ }
822
+ brand {
823
+ logo {
824
+ image {
825
+ url
826
+ }
827
+ }
828
+ colors {
829
+ primary {
830
+ background
831
+ }
832
+ secondary {
833
+ background
834
+ }
835
+ }
836
+ }
837
+ }
838
+ `
839
+ );
840
+ var shopWithMetafieldsFragment = (
841
+ /* GraphQL */
842
+ `
843
+ fragment shopWithMetafields on Shop {
844
+ name
845
+ description
846
+ primaryDomain {
847
+ url
848
+ host
849
+ }
850
+ brand {
851
+ logo {
852
+ image {
853
+ url
854
+ }
855
+ }
856
+ colors {
857
+ primary {
858
+ background
859
+ }
860
+ secondary {
861
+ background
862
+ }
863
+ }
864
+ }
865
+ metafields(identifiers: $shopMetafieldIdentifiers) {
866
+ ...metafield
867
+ }
868
+ }
869
+ ${metafieldFragment}
870
+ `
871
+ );
872
+
769
873
  // src/queries/product/get-product.ts
770
874
  var getProductQuery = (
771
875
  /* GraphQL */
@@ -2068,10 +2172,7 @@ async function getCollections(client, options) {
2068
2172
  }
2069
2173
 
2070
2174
  // src/api/collection/get-collections-by-handles.ts
2071
- var getCollectionsByHandles = async ({
2072
- client,
2073
- options
2074
- }) => {
2175
+ async function getCollectionsByHandles(client, options) {
2075
2176
  const { handles, graphqlQuery, metafieldIdentifiers } = options;
2076
2177
  if (handles.length === 0) {
2077
2178
  return [];
@@ -2095,7 +2196,7 @@ var getCollectionsByHandles = async ({
2095
2196
  return normalizeCollection(item);
2096
2197
  });
2097
2198
  return collections;
2098
- };
2199
+ }
2099
2200
 
2100
2201
  // src/api/blog/normalize.ts
2101
2202
  function normalizeBlog(blog) {
@@ -2416,6 +2517,95 @@ async function getArticlesInBlog(client, options) {
2416
2517
  return fetchAllPages5(client, options);
2417
2518
  }
2418
2519
 
2419
- export { ShopifyClient, addCartItemsMutation, addCartLines, articleFragment, articleWithMetafieldsFragment, blogFragment, blogWithMetafieldsFragment, cartFragment, collectionFragment, createCart, createCartMutation, createShopifyClient, getAllBlogs, getAllCollections, getAllProducts, getAllProductsPathsQuery, getArticle, getArticles, getArticlesInBlog, getBlog, getCart, getCartQuery, getCollection, getCollections, getCollectionsByHandles, getCollectionsByHandlesQuery, getProduct, getProductQuery, getProducts, getProductsByHandles, getProductsByHandlesQuery, getProductsQuery, imageFragment, metafieldFragment, metafieldFragmentStr, normalizeArticle, normalizeBlog, normalizeCart, normalizeCollection, normalizeLineItem, normalizeProduct, pageInfoFragment, productFragment, removeCartItemsMutation, removeCartLines, seoFragment, updateBuyerIdentity, updateBuyerIdentityMutation, updateCartAttributes, updateCartAttributesMutation, updateCartCodes, updateCartDeliveryOptions, updateCartDeliveryOptionsMutation, updateCartDiscountCodeMutation, updateCartItemsMutation, updateCartLines, variantFragment };
2520
+ // src/api/page/normalize.ts
2521
+ function normalizePage(page) {
2522
+ return {
2523
+ id: page.id,
2524
+ handle: page.handle,
2525
+ title: page.title,
2526
+ body: page.body,
2527
+ bodySummary: page.bodySummary,
2528
+ createdAt: page.createdAt,
2529
+ updatedAt: page.updatedAt,
2530
+ seo: page.seo ? {
2531
+ ...page.seo
2532
+ } : void 0,
2533
+ metafields: normalizeMetafields(page.metafields)
2534
+ };
2535
+ }
2536
+
2537
+ // src/api/page/get-page.ts
2538
+ async function getPage(client, options) {
2539
+ const { handle, graphqlQuery, metafieldIdentifiers } = options;
2540
+ const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
2541
+ const fragment = hasMetafields ? pageWithMetafieldsFragment : pageFragment;
2542
+ const defaultQuery = (
2543
+ /* GraphQL */
2544
+ `
2545
+ query getPage(
2546
+ $handle: String!
2547
+ ${hasMetafields ? "$pageMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
2548
+ ) {
2549
+ page(handle: $handle) {
2550
+ ...${hasMetafields ? "pageWithMetafields" : "page"}
2551
+ }
2552
+ }
2553
+ ${fragment}
2554
+ `
2555
+ );
2556
+ const query = graphqlQuery || defaultQuery;
2557
+ const variables = { handle };
2558
+ if (hasMetafields) {
2559
+ variables.pageMetafieldIdentifiers = metafieldIdentifiers;
2560
+ }
2561
+ const data = await client.query(query, variables);
2562
+ if (!data || !data.page) {
2563
+ return void 0;
2564
+ }
2565
+ return normalizePage(data.page);
2566
+ }
2567
+
2568
+ // src/api/shop/normalize.ts
2569
+ function normalizeShop(shop) {
2570
+ return {
2571
+ name: shop.name,
2572
+ description: shop.description || "",
2573
+ primaryDomain: shop.primaryDomain,
2574
+ brand: shop.brand || void 0,
2575
+ metafields: normalizeMetafields(shop.metafields)
2576
+ };
2577
+ }
2578
+
2579
+ // src/api/shop/get-shop.ts
2580
+ async function getShop(client, options) {
2581
+ const { graphqlQuery, metafieldIdentifiers } = options;
2582
+ const hasMetafields = metafieldIdentifiers && metafieldIdentifiers.length > 0;
2583
+ const fragment = hasMetafields ? shopWithMetafieldsFragment : shopFragment;
2584
+ const defaultQuery = (
2585
+ /* GraphQL */
2586
+ `
2587
+ query getShop(
2588
+ ${hasMetafields ? "$shopMetafieldIdentifiers: [HasMetafieldsIdentifier!]!" : ""}
2589
+ ) {
2590
+ shop {
2591
+ ...${hasMetafields ? "shopWithMetafields" : "shop"}
2592
+ }
2593
+ }
2594
+ ${fragment}
2595
+ `
2596
+ );
2597
+ const query = graphqlQuery || defaultQuery;
2598
+ const variables = {};
2599
+ if (hasMetafields) {
2600
+ variables.shopMetafieldIdentifiers = metafieldIdentifiers;
2601
+ }
2602
+ const data = await client.query(query, variables);
2603
+ if (!data || !data.shop) {
2604
+ return void 0;
2605
+ }
2606
+ return normalizeShop(data.shop);
2607
+ }
2608
+
2609
+ export { ShopifyClient, addCartItemsMutation, addCartLines, articleFragment, articleWithMetafieldsFragment, blogFragment, blogWithMetafieldsFragment, cartFragment, collectionFragment, createCart, createCartMutation, createShopifyClient, getAllBlogs, getAllCollections, getAllProducts, getAllProductsPathsQuery, getArticle, getArticles, getArticlesInBlog, getBlog, getCart, getCartQuery, getCollection, getCollections, getCollectionsByHandles, getCollectionsByHandlesQuery, getPage, getProduct, getProductQuery, getProducts, getProductsByHandles, getProductsByHandlesQuery, getProductsQuery, getShop, imageFragment, metafieldFragment, metafieldFragmentStr, normalizeArticle, normalizeBlog, normalizeCart, normalizeCollection, normalizeLineItem, normalizePage, normalizeProduct, normalizeShop, pageFragment, pageInfoFragment, pageWithMetafieldsFragment, productFragment, removeCartItemsMutation, removeCartLines, seoFragment, shopFragment, shopWithMetafieldsFragment, updateBuyerIdentity, updateBuyerIdentityMutation, updateCartAttributes, updateCartAttributesMutation, updateCartCodes, updateCartDeliveryOptions, updateCartDeliveryOptionsMutation, updateCartDiscountCodeMutation, updateCartItemsMutation, updateCartLines, variantFragment };
2420
2610
  //# sourceMappingURL=index.mjs.map
2421
2611
  //# sourceMappingURL=index.mjs.map