@ehrenkind/shopify-lib 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1470,6 +1470,8 @@ type CashRoundingAdjustment = {
1470
1470
  /**
1471
1471
  * A list of products with publishing and pricing information.
1472
1472
  * A catalog can be associated with a specific context, such as a [`Market`](https://shopify.dev/api/admin-graphql/current/objects/market), [`CompanyLocation`](https://shopify.dev/api/admin-graphql/current/objects/companylocation), or [`App`](https://shopify.dev/api/admin-graphql/current/objects/app).
1473
+ *
1474
+ * Catalogs can optionally include a publication to control product visibility and a price list to customize pricing. When a publication isn't associated with a catalog, product availability is determined by the sales channel.
1473
1475
  */
1474
1476
  type Catalog = {
1475
1477
  /** A globally-unique ID. */
@@ -10262,7 +10264,7 @@ type Market = HasMetafieldDefinitions & HasMetafields & Node & {
10262
10264
  webPresences: MarketWebPresenceConnection;
10263
10265
  };
10264
10266
  /**
10265
- * A catalog for managing product availability and pricing for specific [`Market`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Market) contexts. Each catalog links to one or more markets and defines what [`Product`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) objects customers see through its [`Publication`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Publication) settings. The catalog can include a [`PriceList`](https://shopify.dev/docs/api/admin-graphql/latest/objects/PriceList) for market-specific pricing adjustments.
10267
+ * A catalog for managing product availability and pricing for specific [`Market`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Market) contexts. Each catalog links to one or more markets. The catalog can optionally include a [`Publication`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Publication) to control which [`Product`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) objects customers see, and a [`PriceList`](https://shopify.dev/docs/api/admin-graphql/latest/objects/PriceList) for market-specific pricing adjustments. When a publication isn't associated with the catalog, product availability is determined by the sales channel.
10266
10268
  *
10267
10269
  * Use catalogs to create distinct shopping experiences for different geographic regions or customer segments.
10268
10270
  *
@@ -20169,7 +20171,7 @@ type LeanProductVariantsQuery = {
20169
20171
  productVariants: {
20170
20172
  edges: Array<{
20171
20173
  node: (Pick<ProductVariant$1, 'id' | 'title' | 'sku'> & {
20172
- product: Pick<Product, 'id' | 'title'>;
20174
+ product: Pick<Product, 'id' | 'title' | 'status'>;
20173
20175
  });
20174
20176
  }>;
20175
20177
  pageInfo: Pick<PageInfo, 'hasNextPage' | 'endCursor'>;
@@ -20261,7 +20263,7 @@ interface GeneratedQueryTypes {
20261
20263
  return: AllProductVariantsQuery;
20262
20264
  variables: AllProductVariantsQueryVariables;
20263
20265
  };
20264
- "#graphql\n query leanProductVariants($first: Int!, $after: String, $queryFilter: String) {\n productVariants(first: $first, after: $after, query: $queryFilter) {\n edges {\n node { \n id\n title\n sku\n product {\n id\n title\n }\n }\n }\n pageInfo { \n hasNextPage\n endCursor\n }\n }\n }\n ": {
20266
+ "#graphql\n query leanProductVariants($first: Int!, $after: String, $queryFilter: String) {\n productVariants(first: $first, after: $after, query: $queryFilter) {\n edges {\n node {\n id\n title\n sku\n product {\n id\n title\n status\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n ": {
20265
20267
  return: LeanProductVariantsQuery;
20266
20268
  variables: LeanProductVariantsQueryVariables;
20267
20269
  };
@@ -20594,30 +20596,39 @@ declare const GetLeanProductVariantsReturn: z.ZodArray<z.ZodObject<{
20594
20596
  variantId: z.ZodString;
20595
20597
  variantTitle: z.ZodString;
20596
20598
  sku: z.ZodString;
20599
+ status: z.ZodEnum<["ACTIVE", "ARCHIVED", "DRAFT"]>;
20597
20600
  }, "strip", z.ZodTypeAny, {
20601
+ status: "ACTIVE" | "ARCHIVED" | "DRAFT";
20598
20602
  productId: string;
20599
20603
  sku: string;
20600
20604
  variantId: string;
20601
20605
  productTitle: string;
20602
20606
  variantTitle: string;
20603
20607
  }, {
20608
+ status: "ACTIVE" | "ARCHIVED" | "DRAFT";
20604
20609
  productId: string;
20605
20610
  sku: string;
20606
20611
  variantId: string;
20607
20612
  productTitle: string;
20608
20613
  variantTitle: string;
20609
20614
  }>, "many">;
20610
- type GetLeanProductVariantsReturnType = z.infer<typeof GetLeanProductVariantsReturn>;
20615
+ type LeanProductVariant = z.infer<typeof GetLeanProductVariantsReturn>[number];
20616
+ type LeanProductVariantsOptions = {
20617
+ /** Filter to only active/draft products (excludes ARCHIVED). Defaults to false. */
20618
+ activeOnly?: boolean;
20619
+ };
20611
20620
  /**
20612
20621
  * Retrieves a lean list of product variants from Shopify, optionally filtered by SKUs.
20613
20622
  * Product variants are mapped to a simpler output structure.
20614
20623
  * Variants missing essential properties (e.g., SKU) will be filtered out and logged.
20615
20624
  *
20616
20625
  * @param {string[]} [skus] - An optional array of SKUs to filter by. If provided, only variants matching these SKUs will be fetched.
20617
- * @returns {Promise<GetLeanProductVariantsReturnType>} A promise that resolves to an array of lean product variant data.
20626
+ * @param {LeanProductVariantsOptions} [options] - Optional settings.
20627
+ * @param {boolean} [options.activeOnly=false] - If true, excludes ARCHIVED products at query level.
20628
+ * @returns {Promise<LeanProductVariant[]>} A promise that resolves to an array of lean product variant data.
20618
20629
  * @throws {Error} If the GraphQL query fails, returns no data, or if the `productVariants` field is missing in the response.
20619
20630
  */
20620
- declare function getLeanProductVariants(skus?: string[]): Promise<GetLeanProductVariantsReturnType>;
20631
+ declare function getLeanProductVariants(skus?: string[], options?: LeanProductVariantsOptions): Promise<LeanProductVariant[]>;
20621
20632
 
20622
20633
  declare const GetProductVariantsBySkusReturn: z.ZodArray<z.ZodObject<{
20623
20634
  productId: z.ZodString;
@@ -20818,4 +20829,4 @@ type Metaobject = NonNullable<MetaobjectByHandleQuery['metaobjectByHandle']>;
20818
20829
  */
20819
20830
  declare function getMetaobjectByHandle(handle: MetaobjectHandleInput): Promise<Metaobject | undefined>;
20820
20831
 
20821
- export { type BulkUpdateProductVariantsResult, type CalculateRefundLineItem, type CalculateRefundOptions, type CreateFulfillmentResult, type CreateMetaobjectDefinitionInput, type CreateMetaobjectDefinitionResult, type CreateRefundLineItem, type CreateRefundOptions, type CreateRefundResult, type CreateRefundTransaction, type Customer, type CustomerSegmentMember, type CustomerSegmentMembersResult, type Fulfillment, type FulfillmentLineItem$1 as FulfillmentLineItem, type FulfillmentOrder, type FulfillmentTrackingIds, type FullOrder, type FullOrderByName, type LeanOrder, type LeanOrderByName, type Metaobject, type MetaobjectFieldDefinition$1 as MetaobjectFieldDefinition, type MetaobjectHandleInput, type OrderCancellationInfo, type OrderPaymentDetails, type OrderPreview, type ProductVariant, type ProductVariantBySku, type ProductVariantsBySkusOptions, type RefundMoney, type SegmentAttributeStatistics, ShopifyUserError, type ShopifyUserErrorDetail, type SuggestedRefund, type UpdateFulfillmentTrackingResult, type UpsertMetaobjectInput, type UpsertMetaobjectResult, type VariantUpdateInput, bulkUpdateProductVariants, calculateRefund, cancelOrderById, createFile, createFulfillment, createMetaobjectDefinition, createRefund, deleteCustomerById, deleteFilesByIds, getAllProductVariants, getCustomerSegmentMembers, getCustomersByEmail, getFulfillmentById, getFulfillmentOrdersByOrderId, getFulfillmentTrackingIds, getLeanProductVariants, getMetaobjectByHandle, getOrderById, getOrderByName, getOrderCancellationInfoByName, getOrderPaymentDetailsById, getOrdersByCustomerId, getProductVariantsBySkus, parseGid, updateFulfillmentTracking, upsertMetaobject };
20832
+ export { type BulkUpdateProductVariantsResult, type CalculateRefundLineItem, type CalculateRefundOptions, type CreateFulfillmentResult, type CreateMetaobjectDefinitionInput, type CreateMetaobjectDefinitionResult, type CreateRefundLineItem, type CreateRefundOptions, type CreateRefundResult, type CreateRefundTransaction, type Customer, type CustomerSegmentMember, type CustomerSegmentMembersResult, type Fulfillment, type FulfillmentLineItem$1 as FulfillmentLineItem, type FulfillmentOrder, type FulfillmentTrackingIds, type FullOrder, type FullOrderByName, type LeanOrder, type LeanOrderByName, type LeanProductVariant, type LeanProductVariantsOptions, type Metaobject, type MetaobjectFieldDefinition$1 as MetaobjectFieldDefinition, type MetaobjectHandleInput, type OrderCancellationInfo, type OrderPaymentDetails, type OrderPreview, type ProductVariant, type ProductVariantBySku, type ProductVariantsBySkusOptions, type RefundMoney, type SegmentAttributeStatistics, ShopifyUserError, type ShopifyUserErrorDetail, type SuggestedRefund, type UpdateFulfillmentTrackingResult, type UpsertMetaobjectInput, type UpsertMetaobjectResult, type VariantUpdateInput, bulkUpdateProductVariants, calculateRefund, cancelOrderById, createFile, createFulfillment, createMetaobjectDefinition, createRefund, deleteCustomerById, deleteFilesByIds, getAllProductVariants, getCustomerSegmentMembers, getCustomersByEmail, getFulfillmentById, getFulfillmentOrdersByOrderId, getFulfillmentTrackingIds, getLeanProductVariants, getMetaobjectByHandle, getOrderById, getOrderByName, getOrderCancellationInfoByName, getOrderPaymentDetailsById, getOrdersByCustomerId, getProductVariantsBySkus, parseGid, updateFulfillmentTracking, upsertMetaobject };
package/dist/index.d.ts CHANGED
@@ -1470,6 +1470,8 @@ type CashRoundingAdjustment = {
1470
1470
  /**
1471
1471
  * A list of products with publishing and pricing information.
1472
1472
  * A catalog can be associated with a specific context, such as a [`Market`](https://shopify.dev/api/admin-graphql/current/objects/market), [`CompanyLocation`](https://shopify.dev/api/admin-graphql/current/objects/companylocation), or [`App`](https://shopify.dev/api/admin-graphql/current/objects/app).
1473
+ *
1474
+ * Catalogs can optionally include a publication to control product visibility and a price list to customize pricing. When a publication isn't associated with a catalog, product availability is determined by the sales channel.
1473
1475
  */
1474
1476
  type Catalog = {
1475
1477
  /** A globally-unique ID. */
@@ -10262,7 +10264,7 @@ type Market = HasMetafieldDefinitions & HasMetafields & Node & {
10262
10264
  webPresences: MarketWebPresenceConnection;
10263
10265
  };
10264
10266
  /**
10265
- * A catalog for managing product availability and pricing for specific [`Market`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Market) contexts. Each catalog links to one or more markets and defines what [`Product`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) objects customers see through its [`Publication`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Publication) settings. The catalog can include a [`PriceList`](https://shopify.dev/docs/api/admin-graphql/latest/objects/PriceList) for market-specific pricing adjustments.
10267
+ * A catalog for managing product availability and pricing for specific [`Market`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Market) contexts. Each catalog links to one or more markets. The catalog can optionally include a [`Publication`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Publication) to control which [`Product`](https://shopify.dev/docs/api/admin-graphql/latest/objects/Product) objects customers see, and a [`PriceList`](https://shopify.dev/docs/api/admin-graphql/latest/objects/PriceList) for market-specific pricing adjustments. When a publication isn't associated with the catalog, product availability is determined by the sales channel.
10266
10268
  *
10267
10269
  * Use catalogs to create distinct shopping experiences for different geographic regions or customer segments.
10268
10270
  *
@@ -20169,7 +20171,7 @@ type LeanProductVariantsQuery = {
20169
20171
  productVariants: {
20170
20172
  edges: Array<{
20171
20173
  node: (Pick<ProductVariant$1, 'id' | 'title' | 'sku'> & {
20172
- product: Pick<Product, 'id' | 'title'>;
20174
+ product: Pick<Product, 'id' | 'title' | 'status'>;
20173
20175
  });
20174
20176
  }>;
20175
20177
  pageInfo: Pick<PageInfo, 'hasNextPage' | 'endCursor'>;
@@ -20261,7 +20263,7 @@ interface GeneratedQueryTypes {
20261
20263
  return: AllProductVariantsQuery;
20262
20264
  variables: AllProductVariantsQueryVariables;
20263
20265
  };
20264
- "#graphql\n query leanProductVariants($first: Int!, $after: String, $queryFilter: String) {\n productVariants(first: $first, after: $after, query: $queryFilter) {\n edges {\n node { \n id\n title\n sku\n product {\n id\n title\n }\n }\n }\n pageInfo { \n hasNextPage\n endCursor\n }\n }\n }\n ": {
20266
+ "#graphql\n query leanProductVariants($first: Int!, $after: String, $queryFilter: String) {\n productVariants(first: $first, after: $after, query: $queryFilter) {\n edges {\n node {\n id\n title\n sku\n product {\n id\n title\n status\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n ": {
20265
20267
  return: LeanProductVariantsQuery;
20266
20268
  variables: LeanProductVariantsQueryVariables;
20267
20269
  };
@@ -20594,30 +20596,39 @@ declare const GetLeanProductVariantsReturn: z.ZodArray<z.ZodObject<{
20594
20596
  variantId: z.ZodString;
20595
20597
  variantTitle: z.ZodString;
20596
20598
  sku: z.ZodString;
20599
+ status: z.ZodEnum<["ACTIVE", "ARCHIVED", "DRAFT"]>;
20597
20600
  }, "strip", z.ZodTypeAny, {
20601
+ status: "ACTIVE" | "ARCHIVED" | "DRAFT";
20598
20602
  productId: string;
20599
20603
  sku: string;
20600
20604
  variantId: string;
20601
20605
  productTitle: string;
20602
20606
  variantTitle: string;
20603
20607
  }, {
20608
+ status: "ACTIVE" | "ARCHIVED" | "DRAFT";
20604
20609
  productId: string;
20605
20610
  sku: string;
20606
20611
  variantId: string;
20607
20612
  productTitle: string;
20608
20613
  variantTitle: string;
20609
20614
  }>, "many">;
20610
- type GetLeanProductVariantsReturnType = z.infer<typeof GetLeanProductVariantsReturn>;
20615
+ type LeanProductVariant = z.infer<typeof GetLeanProductVariantsReturn>[number];
20616
+ type LeanProductVariantsOptions = {
20617
+ /** Filter to only active/draft products (excludes ARCHIVED). Defaults to false. */
20618
+ activeOnly?: boolean;
20619
+ };
20611
20620
  /**
20612
20621
  * Retrieves a lean list of product variants from Shopify, optionally filtered by SKUs.
20613
20622
  * Product variants are mapped to a simpler output structure.
20614
20623
  * Variants missing essential properties (e.g., SKU) will be filtered out and logged.
20615
20624
  *
20616
20625
  * @param {string[]} [skus] - An optional array of SKUs to filter by. If provided, only variants matching these SKUs will be fetched.
20617
- * @returns {Promise<GetLeanProductVariantsReturnType>} A promise that resolves to an array of lean product variant data.
20626
+ * @param {LeanProductVariantsOptions} [options] - Optional settings.
20627
+ * @param {boolean} [options.activeOnly=false] - If true, excludes ARCHIVED products at query level.
20628
+ * @returns {Promise<LeanProductVariant[]>} A promise that resolves to an array of lean product variant data.
20618
20629
  * @throws {Error} If the GraphQL query fails, returns no data, or if the `productVariants` field is missing in the response.
20619
20630
  */
20620
- declare function getLeanProductVariants(skus?: string[]): Promise<GetLeanProductVariantsReturnType>;
20631
+ declare function getLeanProductVariants(skus?: string[], options?: LeanProductVariantsOptions): Promise<LeanProductVariant[]>;
20621
20632
 
20622
20633
  declare const GetProductVariantsBySkusReturn: z.ZodArray<z.ZodObject<{
20623
20634
  productId: z.ZodString;
@@ -20818,4 +20829,4 @@ type Metaobject = NonNullable<MetaobjectByHandleQuery['metaobjectByHandle']>;
20818
20829
  */
20819
20830
  declare function getMetaobjectByHandle(handle: MetaobjectHandleInput): Promise<Metaobject | undefined>;
20820
20831
 
20821
- export { type BulkUpdateProductVariantsResult, type CalculateRefundLineItem, type CalculateRefundOptions, type CreateFulfillmentResult, type CreateMetaobjectDefinitionInput, type CreateMetaobjectDefinitionResult, type CreateRefundLineItem, type CreateRefundOptions, type CreateRefundResult, type CreateRefundTransaction, type Customer, type CustomerSegmentMember, type CustomerSegmentMembersResult, type Fulfillment, type FulfillmentLineItem$1 as FulfillmentLineItem, type FulfillmentOrder, type FulfillmentTrackingIds, type FullOrder, type FullOrderByName, type LeanOrder, type LeanOrderByName, type Metaobject, type MetaobjectFieldDefinition$1 as MetaobjectFieldDefinition, type MetaobjectHandleInput, type OrderCancellationInfo, type OrderPaymentDetails, type OrderPreview, type ProductVariant, type ProductVariantBySku, type ProductVariantsBySkusOptions, type RefundMoney, type SegmentAttributeStatistics, ShopifyUserError, type ShopifyUserErrorDetail, type SuggestedRefund, type UpdateFulfillmentTrackingResult, type UpsertMetaobjectInput, type UpsertMetaobjectResult, type VariantUpdateInput, bulkUpdateProductVariants, calculateRefund, cancelOrderById, createFile, createFulfillment, createMetaobjectDefinition, createRefund, deleteCustomerById, deleteFilesByIds, getAllProductVariants, getCustomerSegmentMembers, getCustomersByEmail, getFulfillmentById, getFulfillmentOrdersByOrderId, getFulfillmentTrackingIds, getLeanProductVariants, getMetaobjectByHandle, getOrderById, getOrderByName, getOrderCancellationInfoByName, getOrderPaymentDetailsById, getOrdersByCustomerId, getProductVariantsBySkus, parseGid, updateFulfillmentTracking, upsertMetaobject };
20832
+ export { type BulkUpdateProductVariantsResult, type CalculateRefundLineItem, type CalculateRefundOptions, type CreateFulfillmentResult, type CreateMetaobjectDefinitionInput, type CreateMetaobjectDefinitionResult, type CreateRefundLineItem, type CreateRefundOptions, type CreateRefundResult, type CreateRefundTransaction, type Customer, type CustomerSegmentMember, type CustomerSegmentMembersResult, type Fulfillment, type FulfillmentLineItem$1 as FulfillmentLineItem, type FulfillmentOrder, type FulfillmentTrackingIds, type FullOrder, type FullOrderByName, type LeanOrder, type LeanOrderByName, type LeanProductVariant, type LeanProductVariantsOptions, type Metaobject, type MetaobjectFieldDefinition$1 as MetaobjectFieldDefinition, type MetaobjectHandleInput, type OrderCancellationInfo, type OrderPaymentDetails, type OrderPreview, type ProductVariant, type ProductVariantBySku, type ProductVariantsBySkusOptions, type RefundMoney, type SegmentAttributeStatistics, ShopifyUserError, type ShopifyUserErrorDetail, type SuggestedRefund, type UpdateFulfillmentTrackingResult, type UpsertMetaobjectInput, type UpsertMetaobjectResult, type VariantUpdateInput, bulkUpdateProductVariants, calculateRefund, cancelOrderById, createFile, createFulfillment, createMetaobjectDefinition, createRefund, deleteCustomerById, deleteFilesByIds, getAllProductVariants, getCustomerSegmentMembers, getCustomersByEmail, getFulfillmentById, getFulfillmentOrdersByOrderId, getFulfillmentTrackingIds, getLeanProductVariants, getMetaobjectByHandle, getOrderById, getOrderByName, getOrderCancellationInfoByName, getOrderPaymentDetailsById, getOrdersByCustomerId, getProductVariantsBySkus, parseGid, updateFulfillmentTracking, upsertMetaobject };
package/dist/index.mjs CHANGED
@@ -1815,35 +1815,46 @@ var GetLeanProductVariantsReturn = z5.array(
1815
1815
  productTitle: z5.string(),
1816
1816
  variantId: z5.string(),
1817
1817
  variantTitle: z5.string(),
1818
- sku: z5.string()
1818
+ sku: z5.string(),
1819
+ status: z5.enum(["ACTIVE", "ARCHIVED", "DRAFT"])
1819
1820
  })
1820
1821
  );
1821
- async function getLeanProductVariants(skus) {
1822
+ async function getLeanProductVariants(skus, options) {
1822
1823
  const queryGql = gql`#graphql
1823
1824
  query leanProductVariants($first: Int!, $after: String, $queryFilter: String) {
1824
1825
  productVariants(first: $first, after: $after, query: $queryFilter) {
1825
1826
  edges {
1826
- node {
1827
+ node {
1827
1828
  id
1828
1829
  title
1829
1830
  sku
1830
1831
  product {
1831
1832
  id
1832
1833
  title
1834
+ status
1833
1835
  }
1834
1836
  }
1835
1837
  }
1836
- pageInfo {
1838
+ pageInfo {
1837
1839
  hasNextPage
1838
1840
  endCursor
1839
1841
  }
1840
1842
  }
1841
1843
  }
1842
1844
  `;
1843
- const initialVariables = { first: 250 };
1845
+ const queryParts = [];
1844
1846
  if (skus && skus.length > 0) {
1845
- initialVariables.queryFilter = skus.map((sku) => `sku:${sku}`).join(" OR ");
1847
+ queryParts.push(skus.map((sku) => `sku:${sku}`).join(" OR "));
1848
+ }
1849
+ if (options?.activeOnly) {
1850
+ queryParts.push("product_status:active,draft");
1846
1851
  }
1852
+ const initialVariables = {
1853
+ first: 250,
1854
+ ...queryParts.length > 0 && {
1855
+ queryFilter: queryParts.filter(Boolean).join(" AND ")
1856
+ }
1857
+ };
1847
1858
  const extractedNodes = await fetchShopifyGraphql({
1848
1859
  query: queryGql,
1849
1860
  variables: initialVariables,
@@ -1871,7 +1882,8 @@ async function getLeanProductVariants(skus) {
1871
1882
  productTitle: v.product.title,
1872
1883
  variantId: v.id,
1873
1884
  variantTitle: v.title,
1874
- sku: v.sku
1885
+ sku: v.sku,
1886
+ status: v.product.status
1875
1887
  }
1876
1888
  ];
1877
1889
  }