@ehrenkind/shopify-lib 0.2.1 → 0.2.2

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.cjs CHANGED
@@ -35,8 +35,7 @@ __export(index_exports, {
35
35
  getOrderById: () => getOrderById,
36
36
  getOrderByName: () => getOrderByName,
37
37
  getOrderPaymentDetailsById: () => getOrderPaymentDetailsById,
38
- parseGid: () => parseGid,
39
- toRestFormat: () => toRestFormat
38
+ parseGid: () => parseGid
40
39
  });
41
40
  module.exports = __toCommonJS(index_exports);
42
41
 
@@ -418,6 +417,7 @@ var queryOrderByIdFull = gql`#graphql
418
417
  quantity
419
418
  lineItem {
420
419
  id
420
+ sku
421
421
  }
422
422
  }
423
423
  }
@@ -1138,46 +1138,10 @@ async function getOrderPaymentDetailsById(id) {
1138
1138
  return await returnOutputParsed(response, GetOrderPaymentDetailsByIdReturn);
1139
1139
  }
1140
1140
 
1141
- // src/utils/toRestFormat.ts
1142
- function camelToSnake(str) {
1143
- return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
1144
- }
1145
- function extractNumericId(gid) {
1146
- const match = gid.match(/\d+$/);
1147
- return match ? parseInt(match[0], 10) : 0;
1148
- }
1149
- function toRestFormat(obj) {
1150
- if (obj === null || obj === void 0) {
1151
- return obj;
1152
- }
1153
- if (Array.isArray(obj)) {
1154
- return obj.map(toRestFormat);
1155
- }
1156
- if (typeof obj === "object") {
1157
- const record = obj;
1158
- const result = {};
1159
- for (const [key, value] of Object.entries(record)) {
1160
- if (key === "edges" && Array.isArray(value) && value.every(
1161
- (item) => typeof item === "object" && item !== null && "node" in item
1162
- )) {
1163
- return value.map((edge) => toRestFormat(edge.node));
1164
- }
1165
- if (key === "id" && typeof value === "string" && value.startsWith("gid://")) {
1166
- result[key] = extractNumericId(value);
1167
- continue;
1168
- }
1169
- const snakeKey = camelToSnake(key);
1170
- result[snakeKey] = toRestFormat(value);
1171
- }
1172
- return result;
1173
- }
1174
- return obj;
1175
- }
1176
-
1177
1141
  // src/utils/parseGid.ts
1178
1142
  function parseGid(gid) {
1179
1143
  const match = gid.match(/\d+$/);
1180
- return match ? parseInt(match[0], 10) : 0;
1144
+ return match ? Number.parseInt(match[0], 10) : 0;
1181
1145
  }
1182
1146
  // Annotate the CommonJS export names for ESM import in node:
1183
1147
  0 && (module.exports = {
@@ -1186,7 +1150,6 @@ function parseGid(gid) {
1186
1150
  getOrderById,
1187
1151
  getOrderByName,
1188
1152
  getOrderPaymentDetailsById,
1189
- parseGid,
1190
- toRestFormat
1153
+ parseGid
1191
1154
  });
1192
1155
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/mutations/customers/deleteCustomerById.ts","../src/utils/logger.ts","../src/utils/shopifyClient.ts","../src/utils/shopifyFetch.ts","../src/utils/zod.ts","../src/queries/orders/getOrderById.ts","../src/queries/orders/getOrderById.queries.ts","../src/queries/orders/getOrderByName.ts","../src/queries/orders/getOrderByName.queries.ts","../src/queries/productVariants/getLeanProductVariants.ts","../src/queries/orders/getOrderPaymentDetails.ts","../src/queries/orders/getOrderPaymentDetails.queries.ts","../src/utils/toRestFormat.ts","../src/utils/parseGid.ts"],"sourcesContent":["export { deleteCustomerById } from './mutations/customers/deleteCustomerById.js'\nexport {\n getOrderById,\n type FullOrder,\n type LeanOrder,\n} from './queries/orders/getOrderById.js'\nexport {\n getOrderByName,\n type FullOrderByName,\n type LeanOrderByName,\n} from './queries/orders/getOrderByName.js'\nexport { getLeanProductVariants } from './queries/productVariants/getLeanProductVariants.js'\nexport { getOrderPaymentDetailsById } from './queries/orders/getOrderPaymentDetails.js'\nexport { toRestFormat } from './utils/toRestFormat.js'\nexport { parseGid } from './utils/parseGid.js'\n","import z from 'zod'\nimport type {\n CustomerDeleteMutation,\n CustomerDeleteMutationVariables,\n} from '../../generated-api-types/2025-04/admin.generated'\nimport { gql } from '../../utils/logger'\nimport { fetchShopifyGraphql } from '../../utils/shopifyFetch'\nimport { returnOutputParsed } from '../../utils/zod'\n\nexport const DeleteCustomerByIdReturn = z.string().nullable()\n\ntype SingleNode = { deletedCustomerId: string | null }\n\nexport async function deleteCustomerById(\n customerId: string,\n): Promise<z.infer<typeof DeleteCustomerByIdReturn>> {\n const mutation = gql`#graphql\n mutation customerDelete($input: CustomerDeleteInput!) {\n customerDelete(input: $input) {\n deletedCustomerId\n userErrors {\n field\n message\n }\n }\n }\n `\n\n const variables: CustomerDeleteMutationVariables = {\n input: { id: customerId },\n }\n\n const response = await fetchShopifyGraphql<\n SingleNode,\n CustomerDeleteMutation\n >({\n query: mutation,\n variables,\n dataExtractor: (data: CustomerDeleteMutation) => {\n if (!data.customerDelete) {\n throw new Error(\"GraphQL response missing 'customerDelete' field\")\n }\n return {\n nodes: [\n { deletedCustomerId: data.customerDelete.deletedCustomerId ?? null },\n ],\n userErrors: data.customerDelete.userErrors,\n }\n },\n })\n\n return returnOutputParsed(\n response[0]?.deletedCustomerId ?? null,\n DeleteCustomerByIdReturn,\n )\n}\n","const { env } = process\n\nexport const gql = String.raw\n\nconst logLevels = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n} as const\n\ntype LogLevelName = keyof typeof logLevels\n\nfunction getLogLevel(\n nodeEnv: string | undefined,\n logLevelEnv: string | undefined,\n): LogLevelName {\n if (logLevelEnv && logLevelEnv in logLevels) {\n return logLevelEnv as LogLevelName\n }\n\n if (nodeEnv === 'test') {\n return 'silent'\n }\n\n if (nodeEnv === 'production') {\n return 'info'\n }\n return 'debug'\n}\n\nexport const activeLogLevelName = getLogLevel(env.NODE_ENV, env.LOG_LEVEL)\nconst activeLogLevelValue = logLevels[activeLogLevelName]\n\nexport const logger = {\n debug: (...args: unknown[]) => {\n if (logLevels.debug <= activeLogLevelValue) {\n // biome-ignore lint/suspicious/noConsole: <explanation>\n console.debug(...args)\n }\n },\n info: (...args: unknown[]) => {\n if (logLevels.info <= activeLogLevelValue) {\n // biome-ignore lint/suspicious/noConsole: <explanation>\n console.info(...args)\n }\n },\n warn: (...args: unknown[]) => {\n if (logLevels.warn <= activeLogLevelValue) {\n // biome-ignore lint/suspicious/noConsole: <explanation>\n console.warn(...args)\n }\n },\n error: (...args: unknown[]) => {\n if (logLevels.error <= activeLogLevelValue) {\n // biome-ignore lint/suspicious/noConsole: <explanation>\n console.error(...args)\n }\n },\n}\n","import {\n ApiVersion,\n type GraphqlClient,\n LogSeverity,\n Session,\n shopifyApi,\n} from '@shopify/shopify-api'\nimport '@shopify/shopify-api/adapters/node'\nimport dotenv from 'dotenv'\nimport { z } from 'zod'\nimport { activeLogLevelName, logger } from './logger.js'\n\n// https://shopify.dev/docs/api/admin-graphql/2025-04/\nexport const SHOPIFY_API_VERSION = ApiVersion.April25\n\ndotenv.config()\n\nconst envSchema = z.object({\n SHOPIFY_API_KEY: z.string({\n required_error: 'SHOPIFY_API_KEY is required',\n }),\n SHOPIFY_API_SECRET: z.string({\n required_error: 'SHOPIFY_API_SECRET is required',\n }),\n SHOPIFY_API_HOSTNAME: z.string({\n required_error: 'SHOPIFY_API_HOSTNAME is required',\n }),\n SHOPIFY_ACCESS_TOKEN: z.string({\n required_error: 'SHOPIFY_ACCESS_TOKEN is required',\n }),\n NODE_ENV: z\n .enum(['development', 'production', 'test'])\n .default('development'),\n})\n\nconst mapLogLevelToShopifySeverity = (level: string): LogSeverity => {\n switch (level) {\n case 'silent':\n return LogSeverity.Error\n case 'debug':\n return LogSeverity.Debug\n case 'info':\n return LogSeverity.Info\n case 'warn':\n return LogSeverity.Warning\n case 'error':\n return LogSeverity.Error\n default:\n return LogSeverity.Info\n }\n}\n\nlet shopifyGraphqlClient: GraphqlClient\n\ntry {\n // biome-ignore lint/nursery/noProcessEnv: <explanation>\n const env = envSchema.parse(process.env)\n\n const shopify = shopifyApi({\n apiKey: env.SHOPIFY_API_KEY,\n apiSecretKey: env.SHOPIFY_API_SECRET,\n hostName: env.SHOPIFY_API_HOSTNAME,\n apiVersion: SHOPIFY_API_VERSION,\n isEmbeddedApp: false,\n logger: { level: mapLogLevelToShopifySeverity(activeLogLevelName) },\n future: {\n customerAddressDefaultFix: true,\n lineItemBilling: true,\n unstable_managedPricingSupport: false,\n },\n })\n\n const shopifySession = new Session({\n id: `custom-session-${env.SHOPIFY_API_HOSTNAME}`,\n shop: env.SHOPIFY_API_HOSTNAME,\n state: 'authenticated',\n isOnline: true,\n accessToken: env.SHOPIFY_ACCESS_TOKEN,\n })\n\n shopifyGraphqlClient = new shopify.clients.Graphql({\n session: shopifySession,\n })\n\n logger.info('Shopify API client initialized successfully.')\n} catch (error) {\n if (error instanceof z.ZodError) {\n const msg = JSON.stringify(error.format(), null, 2)\n logger.error(msg)\n } else {\n logger.error('Failed to initialize Shopify API client:', error)\n }\n throw error\n}\n\nexport { shopifyGraphqlClient as shopifyClient }\n","import { logger } from './logger.js'\nimport { shopifyClient } from './shopifyClient.js'\n\nexport function convertIdIntoGid(\n id: bigint,\n type: 'Order' | 'Customer',\n): string {\n return `gid://shopify/${type}/${id}`\n}\n\ninterface PageInfo {\n hasNextPage: boolean\n endCursor?: string | null | undefined\n}\n\ninterface ShopifyErrorWithMessage {\n message?: string\n [key: string]: unknown\n}\n\ntype TExtractorFunctionType<TResultNode, TPageData> = (pageData: TPageData) => {\n nodes: TResultNode[]\n pageInfo?: PageInfo\n userErrors?: { message?: string }[]\n}\n\nexport async function fetchShopifyGraphql<TResultNode, TPageData>(params: {\n query: string\n variables: Record<string, unknown>\n dataExtractor?: TExtractorFunctionType<TResultNode, TPageData>\n fetchAllPages?: boolean\n}): Promise<TResultNode[]>\nexport async function fetchShopifyGraphql<TReturnType>(params: {\n query: string\n variables: Record<string, unknown>\n}): Promise<TReturnType>\nexport async function fetchShopifyGraphql<\n TResultNode,\n TPageData,\n TReturnType,\n>(params: {\n query: string\n variables: Record<string, unknown>\n dataExtractor?: TExtractorFunctionType<TResultNode, TPageData>\n fetchAllPages?: boolean\n}): Promise<TResultNode[] | TReturnType> {\n const {\n query,\n variables: initialVariables,\n dataExtractor,\n fetchAllPages = false,\n } = params\n\n let currentVariables = { ...initialVariables }\n\n if (!dataExtractor) {\n return makeRequest<NonNullable<TReturnType>>(query, currentVariables)\n }\n\n const allNodes: TResultNode[] = []\n let hasNextLoop = true\n\n do {\n const response = await makeRequest<TPageData>(query, currentVariables)\n const { nodes, pageInfo, userErrors } = dataExtractor(response)\n\n // Handle Shopify mutation userErrors pattern\n if (Array.isArray(userErrors) && userErrors.length > 0) {\n const errorMessages = userErrors\n .map((e) => e.message || JSON.stringify(e))\n .join('\\n')\n logger.error('Shopify mutation userErrors:', errorMessages)\n throw new Error(`Shopify mutation userErrors: ${errorMessages}`)\n }\n\n allNodes.push(...nodes)\n\n hasNextLoop = fetchAllPages ? !!pageInfo?.hasNextPage : false\n if (hasNextLoop && pageInfo?.endCursor) {\n currentVariables = {\n ...currentVariables,\n after: pageInfo.endCursor,\n }\n }\n } while (hasNextLoop)\n\n return allNodes\n}\n\nasync function makeRequest<TReturnDataType>(\n query: string,\n variables: Record<string, unknown>,\n): Promise<NonNullable<TReturnDataType>> {\n type ShopifyRequestErrorType = {\n errors?: ShopifyErrorWithMessage | ShopifyErrorWithMessage[]\n }\n\n const response = (await shopifyClient.request<TReturnDataType>(query, {\n variables,\n })) as { data?: TReturnDataType } & ShopifyRequestErrorType\n\n if (response.errors) {\n let errorMessages = 'GraphQL query failed.'\n const errors = response.errors\n if (Array.isArray(errors)) {\n errorMessages = errors\n .map((e: ShopifyErrorWithMessage) => e.message || JSON.stringify(e))\n .join('\\n')\n } else if (\n typeof errors === 'object' &&\n errors !== null &&\n 'message' in errors\n ) {\n errorMessages = errors.message || JSON.stringify(errors)\n } else if (typeof errors === 'string') {\n errorMessages = errors\n } else {\n errorMessages = JSON.stringify(errors)\n }\n logger.error('GraphQL query failed:', errorMessages)\n throw new Error(`GraphQL errors: ${errorMessages}`)\n }\n\n if (!response.data) {\n throw new Error('No data in Shopify API response')\n }\n\n return response.data\n}\n","import z from 'zod'\nimport { logger } from './logger.js'\n\nexport async function returnOutputParsed<T>(\n data: unknown,\n Model: z.ZodType<T>,\n) {\n const parsed = await Model.safeParseAsync(data)\n if (!parsed.success) {\n if (parsed.error instanceof z.ZodError) {\n const msg = JSON.stringify(parsed.error.format(), null, 2)\n logger.error(msg)\n } else {\n logger.error('Failed to parse:', parsed.error)\n }\n // throw parsedVariants.error\n throw new Error('Failed to parse product variants')\n }\n logger.info('Parsed data successfully')\n return parsed.data\n}\n","import z from 'zod'\nimport type {\n OrderByIdFullQuery,\n OrderByIdQuery,\n OrderByIdQueryVariables,\n} from '../../generated-api-types/2025-04/admin.generated.js'\nimport { logger } from '../../utils/logger.js'\nimport {\n convertIdIntoGid,\n fetchShopifyGraphql,\n} from '../../utils/shopifyFetch.js'\nimport { returnOutputParsed } from '../../utils/zod.js'\nimport { queryOrderById, queryOrderByIdFull } from './getOrderById.queries.js'\n\n// Address schema (shared between lean and full)\nconst AddressSchema = z\n .object({\n firstName: z.string().nullable(),\n lastName: z.string().nullable(),\n address1: z.string().nullable(),\n address2: z.string().nullable(),\n city: z.string().nullable(),\n province: z.string().nullable(),\n country: z.string().nullable(),\n zip: z.string().nullable(),\n })\n .nullable()\n\n// Lean order schema\nconst GetLeanOrderByIdReturn = z\n .object({\n id: z.string(),\n name: z.string(),\n createdAt: z.string(),\n updatedAt: z.string(),\n cancelledAt: z.string().nullable(),\n cancelReason: z.string().nullable(),\n totalPrice: z.object({\n amount: z.string(),\n currencyCode: z.string(),\n }),\n customer: z\n .object({\n id: z.string(),\n displayName: z.string(),\n firstName: z.string().nullable(),\n lastName: z.string().nullable(),\n emailAddress: z.string().nullable(),\n })\n .nullable(),\n financialStatus: z.string().nullable(),\n fulfillmentStatus: z.string().nullable(),\n shippingAddress: AddressSchema,\n })\n .nullable()\n\nexport type LeanOrder = z.infer<typeof GetLeanOrderByIdReturn>\n\n// Full order type - derived from the generated GraphQL types\nexport type FullOrder = NonNullable<OrderByIdFullQuery['order']> | null\n\ntype OrderDetailLevel = 'lean' | 'full'\n\n// Function overloads\nexport function getOrderById(id: number | bigint): Promise<LeanOrder>\nexport function getOrderById(\n id: number | bigint,\n detailLevel: 'lean',\n): Promise<LeanOrder>\nexport function getOrderById(\n id: number | bigint,\n detailLevel: 'full',\n): Promise<FullOrder>\n\n/**\n * Retrieves a single order from Shopify by its numeric ID.\n * Returns null if no order is found with the specified ID.\n *\n * @param {number | bigint} id - The numerical Shopify order ID (e.g., 12345678 or 12345678n).\n * @param {OrderDetailLevel} detailLevel - The level of detail to return ('lean' or 'full'). Defaults to 'lean'.\n * @returns {Promise<LeanOrder | FullOrder>} A promise that resolves to the order data or null if not found.\n * @throws {Error} If the GraphQL query fails or if the response structure is invalid.\n */\nexport async function getOrderById(\n id: number | bigint,\n detailLevel: OrderDetailLevel = 'lean',\n): Promise<LeanOrder | FullOrder> {\n const bigIntId = typeof id === 'number' ? BigInt(id) : id\n if (detailLevel === 'lean') {\n return getLeanOrderById(bigIntId)\n }\n return getFullOrderById(bigIntId)\n}\n\nasync function getLeanOrderById(id: bigint): Promise<LeanOrder> {\n const variables: OrderByIdQueryVariables = {\n id: convertIdIntoGid(id, 'Order'),\n }\n\n const response = await fetchShopifyGraphql<OrderByIdQuery>({\n query: queryOrderById,\n variables,\n })\n\n if (!response.order) {\n logger.debug(`No order found with ID: ${id}`)\n return null\n }\n\n const order = response.order\n\n const leanOrder = {\n id: order.id,\n name: order.name,\n createdAt: order.createdAt,\n updatedAt: order.updatedAt,\n cancelledAt: order.cancelledAt ?? null,\n cancelReason: order.cancelReason ?? null,\n totalPrice: {\n amount: order.totalPriceSet?.shopMoney?.amount ?? '',\n currencyCode: order.totalPriceSet?.shopMoney?.currencyCode ?? '',\n },\n customer: order.customer\n ? {\n id: order.customer.id,\n displayName: order.customer.displayName,\n firstName: order.customer.firstName ?? null,\n lastName: order.customer.lastName ?? null,\n emailAddress:\n order.customer.defaultEmailAddress?.emailAddress ?? null,\n }\n : null,\n financialStatus: order.displayFinancialStatus ?? null,\n fulfillmentStatus: order.displayFulfillmentStatus ?? null,\n shippingAddress: order.shippingAddress\n ? {\n firstName: order.shippingAddress.firstName ?? null,\n lastName: order.shippingAddress.lastName ?? null,\n address1: order.shippingAddress.address1 ?? null,\n address2: order.shippingAddress.address2 ?? null,\n city: order.shippingAddress.city ?? null,\n province: order.shippingAddress.province ?? null,\n country: order.shippingAddress.country ?? null,\n zip: order.shippingAddress.zip ?? null,\n }\n : null,\n }\n\n return await returnOutputParsed(leanOrder, GetLeanOrderByIdReturn)\n}\n\nasync function getFullOrderById(id: bigint): Promise<FullOrder> {\n const variables: OrderByIdQueryVariables = {\n id: convertIdIntoGid(id, 'Order'),\n }\n\n const response = await fetchShopifyGraphql<OrderByIdFullQuery>({\n query: queryOrderByIdFull,\n variables,\n })\n\n if (!response.order) {\n logger.debug(`No order found with ID: ${id}`)\n return null\n }\n\n return response.order\n}\n","import { gql } from '../../utils/logger'\n\nexport const queryOrderById = gql`#graphql\n query orderById($id: ID!) {\n order(id: $id) {\n id\n name\n createdAt\n updatedAt\n cancelledAt\n cancelReason\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n customer {\n id\n lastName\n defaultEmailAddress {\n emailAddress\n }\n displayName\n firstName\n }\n displayFinancialStatus\n displayFulfillmentStatus\n shippingAddress {\n firstName\n lastName\n address1\n address2\n city\n province\n country\n zip\n }\n }\n }\n`\n\nexport const queryOrderByIdFull = gql`#graphql\n query orderByIdFull($id: ID!) {\n order(id: $id) {\n id\n name\n createdAt\n updatedAt\n processedAt\n closedAt\n cancelledAt\n cancelReason\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n customer {\n id\n firstName\n lastName\n email\n phone\n }\n displayFinancialStatus\n displayFulfillmentStatus\n shippingAddress {\n firstName\n lastName\n address1\n address2\n city\n province\n country\n zip\n }\n billingAddress {\n firstName\n lastName\n address1\n address2\n city\n province\n country\n zip\n }\n lineItems(first: 100) {\n edges {\n node {\n id\n sku\n title\n variantTitle\n quantity\n customAttributes {\n key\n value\n }\n originalUnitPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n vendor\n image {\n url\n width\n height\n altText\n }\n }\n }\n }\n fulfillments {\n id\n name\n totalQuantity\n status\n createdAt\n estimatedDeliveryAt\n deliveredAt\n trackingInfo {\n company\n number\n url\n }\n fulfillmentLineItems(first: 100) {\n edges {\n node {\n id\n quantity\n lineItem {\n id\n }\n }\n }\n }\n }\n shippingLine {\n originalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n taxLines {\n priceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n totalDiscountsSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n discountCodes\n refunds {\n totalRefundedSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n }\n }\n`\n","import z from 'zod'\nimport type {\n OrdersByNameFullQuery,\n OrdersByNameQuery,\n OrdersByNameQueryVariables,\n} from '../../generated-api-types/2025-04/admin.generated.js'\nimport { logger } from '../../utils/logger.js'\nimport { fetchShopifyGraphql } from '../../utils/shopifyFetch.js'\nimport { returnOutputParsed } from '../../utils/zod.js'\nimport {\n queryOrdersByName,\n queryOrdersByNameFull,\n} from './getOrderByName.queries.js'\n\nconst GetLeanOrderByNameReturn = z\n .object({\n id: z.string(),\n name: z.string(),\n createdAt: z.string(),\n updatedAt: z.string(),\n totalPrice: z.object({\n amount: z.string(),\n currencyCode: z.string(),\n }),\n customer: z\n .object({\n id: z.string(),\n displayName: z.string(),\n emailAddress: z.string().nullable(),\n })\n .nullable(),\n financialStatus: z.string().nullable(),\n fulfillmentStatus: z.string().nullable(),\n })\n .nullable()\n\nexport type LeanOrderByName = z.infer<typeof GetLeanOrderByNameReturn>\n\nexport type FullOrderByName = NonNullable<\n NonNullable<OrdersByNameFullQuery['orders']>['edges'][number]['node']\n> | null\n\ntype OrderDetailLevel = 'lean' | 'full'\n\n// Function overloads\nexport function getOrderByName(\n orderName: string,\n detailLevel: 'lean',\n): Promise<LeanOrderByName>\nexport function getOrderByName(\n orderName: string,\n detailLevel: 'full',\n): Promise<FullOrderByName>\nexport function getOrderByName(orderName: string): Promise<LeanOrderByName>\n\n/**\n * Retrieves a single order from Shopify by its order name (e.g., \"B12345\").\n * Returns null if no order is found with the specified name.\n *\n * @param {string} orderName - The order name to search for (e.g., \"B12345\").\n * @param {OrderDetailLevel} detailLevel - The level of detail to return ('lean' or 'full'). Defaults to 'lean'.\n * @returns {Promise<LeanOrderByName | FullOrderByName>} A promise that resolves to the order data or null if not found.\n * @throws {Error} If the GraphQL query fails or if the response structure is invalid.\n */\nexport async function getOrderByName(\n orderName: string,\n detailLevel: OrderDetailLevel = 'lean',\n): Promise<LeanOrderByName | FullOrderByName> {\n if (detailLevel === 'lean') {\n return getLeanOrderByName(orderName)\n }\n return getFullOrderByName(orderName)\n}\n\nasync function getLeanOrderByName(orderName: string): Promise<LeanOrderByName> {\n const variables: OrdersByNameQueryVariables = {\n first: 1,\n queryFilter: `name:${orderName}`,\n }\n\n type SingleNode = NonNullable<\n NonNullable<OrdersByNameQuery['orders']>['edges'][number]['node']\n >\n\n const extractedNodes = await fetchShopifyGraphql<\n SingleNode,\n OrdersByNameQuery\n >({\n query: queryOrdersByName,\n variables,\n dataExtractor: (pageData: OrdersByNameQuery) => {\n if (!pageData.orders) {\n throw new Error(\n \"GraphQL response for orders is missing the 'orders' field.\",\n )\n }\n const nodes: SingleNode[] = pageData.orders.edges.map(\n (edge: { node: SingleNode }) => edge.node,\n )\n return {\n nodes,\n }\n },\n fetchAllPages: false,\n })\n\n const order = extractedNodes[0]\n if (!order) {\n logger.debug(`No order found with name: ${orderName}`)\n return null\n }\n\n const leanOrder = {\n id: order.id,\n name: order.name,\n createdAt: order.createdAt,\n updatedAt: order.updatedAt,\n totalPrice: {\n amount: order.totalPriceSet?.shopMoney?.amount ?? '',\n currencyCode: order.totalPriceSet?.shopMoney?.currencyCode ?? '',\n },\n customer: order.customer\n ? {\n id: order.customer.id,\n displayName: order.customer.displayName,\n emailAddress:\n order.customer.defaultEmailAddress?.emailAddress ?? null,\n }\n : null,\n financialStatus: order.displayFinancialStatus ?? null,\n fulfillmentStatus: order.displayFulfillmentStatus ?? null,\n }\n\n return await returnOutputParsed(leanOrder, GetLeanOrderByNameReturn)\n}\n\nasync function getFullOrderByName(orderName: string): Promise<FullOrderByName> {\n const variables: OrdersByNameQueryVariables = {\n first: 1,\n queryFilter: `name:${orderName}`,\n }\n\n type SingleNode = NonNullable<\n NonNullable<OrdersByNameFullQuery['orders']>['edges'][number]['node']\n >\n\n const extractedNodes = await fetchShopifyGraphql<\n SingleNode,\n OrdersByNameFullQuery\n >({\n query: queryOrdersByNameFull,\n variables,\n dataExtractor: (pageData: OrdersByNameFullQuery) => {\n if (!pageData.orders) {\n throw new Error(\n \"GraphQL response for orders is missing the 'orders' field.\",\n )\n }\n const nodes: SingleNode[] = pageData.orders.edges.map(\n (edge: { node: SingleNode }) => edge.node,\n )\n return {\n nodes,\n }\n },\n fetchAllPages: false,\n })\n\n if (extractedNodes.length === 0) {\n logger.debug(`No order found with name: ${orderName}`)\n return null\n }\n\n const order = extractedNodes[0]\n if (!order) {\n logger.debug(`No order found with name: ${orderName}`)\n return null\n }\n\n return order\n}\n","import { gql } from '../../utils/logger'\n\nexport const queryOrdersByName = gql`#graphql\n query ordersByName($first: Int!, $queryFilter: String!) {\n orders(first: $first, query: $queryFilter) {\n edges {\n node {\n id\n name\n createdAt\n updatedAt\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n customer {\n id\n lastName\n defaultEmailAddress {\n emailAddress\n }\n displayName\n firstName\n }\n displayFinancialStatus\n displayFulfillmentStatus\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`\n\nexport const queryOrdersByNameFull = gql`#graphql\n query ordersByNameFull($first: Int!, $queryFilter: String!) {\n orders(first: $first, query: $queryFilter) {\n edges {\n node {\n billingAddress {\n address1\n address2\n city\n company\n country\n countryCodeV2\n firstName\n formattedArea\n id\n lastName\n name\n phone\n province\n provinceCode\n timeZone\n zip\n }\n billingAddressMatchesShippingAddress\n cancelReason\n cancellation {\n staffNote\n }\n cancelledAt\n capturable\n clientIp\n closed\n closedAt\n confirmed\n createdAt\n currencyCode\n currentCartDiscountAmountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentShippingPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentSubtotalLineItemsQuantity\n currentSubtotalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTaxLines {\n channelLiable\n rate\n ratePercentage\n source\n title\n priceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n currentTotalAdditionalFeesSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTotalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTotalDutiesSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTotalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTotalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTotalWeight\n customer {\n id\n lastName\n defaultEmailAddress {\n emailAddress\n }\n displayName\n firstName\n }\n customerAcceptsMarketing\n discountCodes\n discountCode\n displayAddress {\n address1\n address2\n city\n company\n country\n countryCodeV2\n firstName\n formattedArea\n id\n lastName\n name\n phone\n province\n provinceCode\n timeZone\n zip\n }\n displayFinancialStatus\n displayFulfillmentStatus\n dutiesIncluded\n edited\n email\n estimatedTaxes\n fulfillable\n fulfillments(first: 20) {\n createdAt\n deliveredAt\n displayStatus\n estimatedDeliveryAt\n updatedAt\n trackingInfo(first: 10) {\n company\n url\n }\n totalQuantity\n status\n name\n id\n }\n fullyPaid\n id\n lineItems(first: 50) {\n edges {\n node {\n id\n name\n originalUnitPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n quantity\n requiresShipping\n sku\n title\n variantTitle\n }\n }\n }\n name\n note\n processedAt\n shippingAddress {\n address1\n address2\n city\n company\n country\n countryCodeV2\n firstName\n formattedArea\n id\n lastName\n name\n phone\n province\n provinceCode\n timeZone\n zip\n }\n statusPageUrl\n tags\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalReceivedSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalRefundedSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalShippingPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalWeight\n unpaid\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`\n","import z from 'zod'\nimport type {\n LeanProductVariantsQuery,\n LeanProductVariantsQueryVariables,\n} from '../../generated-api-types/2025-04/admin.generated.js'\nimport { gql, logger } from '../../utils/logger.js'\nimport { fetchShopifyGraphql } from '../../utils/shopifyFetch.js'\nimport { returnOutputParsed } from '../../utils/zod.js'\n\nconst GetLeanProductVariantsReturn = z.array(\n z.object({\n productId: z.string(),\n productTitle: z.string(),\n variantId: z.string(),\n variantTitle: z.string(),\n sku: z.string(),\n }),\n)\n\ntype GetLeanProductVariantsReturnType = z.infer<\n typeof GetLeanProductVariantsReturn\n>\n\n/**\n * Retrieves a lean list of product variants from Shopify, optionally filtered by SKUs.\n * Product variants are mapped to a simpler output structure.\n * Variants missing essential properties (e.g., SKU) will be filtered out and logged.\n *\n * @param {string[]} [skus] - An optional array of SKUs to filter by. If provided, only variants matching these SKUs will be fetched.\n * @returns {Promise<GetLeanProductVariantsReturnType>} A promise that resolves to an array of lean product variant data.\n * @throws {Error} If the GraphQL query fails, returns no data, or if the `productVariants` field is missing in the response.\n */\nexport async function getLeanProductVariants(\n skus?: string[],\n): Promise<GetLeanProductVariantsReturnType> {\n const queryGql = gql`#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 `\n\n const initialVariables: LeanProductVariantsQueryVariables = { first: 250 }\n if (skus && skus.length > 0) {\n initialVariables.queryFilter = skus\n .map((sku: string) => `sku:${sku}`)\n .join(' OR ')\n }\n\n // Type for a single node from the productVariants query\n type SingleNode = NonNullable<\n NonNullable<\n LeanProductVariantsQuery['productVariants']\n >['edges'][number]['node']\n >\n\n const extractedNodes = await fetchShopifyGraphql<\n SingleNode,\n LeanProductVariantsQuery\n >({\n query: queryGql,\n variables: initialVariables,\n dataExtractor: (pageData: LeanProductVariantsQuery) => {\n if (!pageData.productVariants) {\n throw new Error(\n \"GraphQL response for product variants is missing the 'productVariants' field.\",\n )\n }\n const nodes: SingleNode[] = pageData.productVariants.edges.map(\n (edge: { node: SingleNode }) => edge.node,\n )\n return {\n nodes,\n pageInfo: pageData.productVariants.pageInfo,\n }\n },\n fetchAllPages: true,\n })\n\n const allVariants = extractedNodes.flatMap<\n GetLeanProductVariantsReturnType[number]\n >((v) => {\n if (v.sku) {\n return [\n {\n productId: v.product.id,\n productTitle: v.product.title,\n variantId: v.id,\n variantTitle: v.title,\n sku: v.sku,\n },\n ]\n }\n logger.debug(\n `Product ${v.product.title} (ID: ${v.product.id}) has a variant (ID: ${v.id}) with no SKU. Filtering out.`,\n )\n return []\n })\n\n return await returnOutputParsed(allVariants, GetLeanProductVariantsReturn)\n}\n","import z from 'zod'\nimport type {\n OrderPaymentDetailsByIdQuery,\n OrderPaymentDetailsByIdQueryVariables,\n} from '../../generated-api-types/2025-04/admin.generated.js'\nimport { logger } from '../../utils/logger.js'\nimport {\n convertIdIntoGid,\n fetchShopifyGraphql,\n} from '../../utils/shopifyFetch.js'\nimport { returnOutputParsed } from '../../utils/zod.js'\nimport { queryOrderPaymentDetails } from './getOrderPaymentDetails.queries.js'\n\nconst GetOrderPaymentDetailsByIdReturn = z.object({\n order: z.object({\n transactions: z.array(\n z.object({\n amountSet: z.object({\n shopMoney: z.object({\n amount: z.string(),\n currencyCode: z.string(),\n }),\n }),\n createdAt: z.string(),\n gateway: z.string(),\n formattedGateway: z.string(),\n kind: z.string(),\n paymentId: z.string(),\n }),\n ),\n }),\n})\n\ntype GetOrderPaymentDetailsByIdReturnType = z.infer<\n typeof GetOrderPaymentDetailsByIdReturn\n>\n\n/**\n * Retrieves payment details for a single order from Shopify by its ID.\n * Returns null if no order is found with the specified ID.\n *\n * @param {bigint} id - The numerical Shopify order ID (e.g., 12345678n).\n * @returns {Promise<GetOrderPaymentDetailsByIdReturnType | null>} A promise that resolves to the order payment data or null if not found.\n * @throws {Error} If the GraphQL query fails or if the response structure is invalid.\n */\nexport async function getOrderPaymentDetailsById(\n id: bigint,\n): Promise<GetOrderPaymentDetailsByIdReturnType | null> {\n const variables: OrderPaymentDetailsByIdQueryVariables = {\n id: convertIdIntoGid(id, 'Order'),\n }\n\n const response = await fetchShopifyGraphql<OrderPaymentDetailsByIdQuery>({\n query: queryOrderPaymentDetails,\n variables,\n })\n\n if (!response.order) {\n logger.debug(`No order found with ID: ${id}`)\n return null\n }\n\n return await returnOutputParsed(response, GetOrderPaymentDetailsByIdReturn)\n}\n","import { gql } from '../../utils/logger.js'\n\nexport const queryOrderPaymentDetails = gql`#graphql\n query orderPaymentDetailsById($id: ID!) {\n order(id: $id) {\n transactions {\n amountSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n createdAt\n gateway\n formattedGateway\n kind\n paymentId\n }\n }\n }\n`\n","/**\n * Transforms GraphQL responses to REST-like format.\n *\n * This utility recursively:\n * 1. Flattens `{ edges: [{ node: ... }] }` → `[...]`\n * 2. Converts camelCase to snake_case (`lineItems` → `line_items`)\n * 3. Extracts numeric IDs from GIDs (`gid://shopify/Order/123` → `123`)\n */\n\n/**\n * Convert a camelCase string to snake_case\n */\nfunction camelToSnake(str: string): string {\n return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)\n}\n\n/**\n * Extract numeric ID from a Shopify GID string\n */\nfunction extractNumericId(gid: string): number {\n const match = gid.match(/\\d+$/)\n return match ? parseInt(match[0], 10) : 0\n}\n\n/**\n * Transform a GraphQL response object to REST-like format.\n *\n * @example\n * ```typescript\n * const graphqlOrder = {\n * id: 'gid://shopify/Order/123',\n * lineItems: {\n * edges: [{ node: { id: 'gid://shopify/LineItem/456', sku: 'ABC' } }]\n * }\n * };\n *\n * const restOrder = toRestFormat(graphqlOrder);\n * // Result:\n * // {\n * // id: 123,\n * // line_items: [{ id: 456, sku: 'ABC' }]\n * // }\n * ```\n */\nexport function toRestFormat<T>(obj: T): unknown {\n if (obj === null || obj === undefined) {\n return obj\n }\n\n if (Array.isArray(obj)) {\n return obj.map(toRestFormat)\n }\n\n if (typeof obj === 'object') {\n const record = obj as Record<string, unknown>\n const result: Record<string, unknown> = {}\n\n for (const [key, value] of Object.entries(record)) {\n // Flatten edges/node pattern: { edges: [{ node: ... }] } → [...]\n if (\n key === 'edges' &&\n Array.isArray(value) &&\n value.every(\n (item) =>\n typeof item === 'object' && item !== null && 'node' in item,\n )\n ) {\n return value.map((edge: { node: unknown }) => toRestFormat(edge.node))\n }\n\n // Convert GID to numeric ID\n if (\n key === 'id' &&\n typeof value === 'string' &&\n value.startsWith('gid://')\n ) {\n result[key] = extractNumericId(value)\n continue\n }\n\n // Convert camelCase to snake_case and recurse\n const snakeKey = camelToSnake(key)\n result[snakeKey] = toRestFormat(value)\n }\n\n return result\n }\n\n return obj\n}\n","/**\n * Extract numeric ID from a Shopify GID string.\n *\n * @example\n * parseGid('gid://shopify/Order/12345678901234') // → 12345678901234\n * parseGid('gid://shopify/LineItem/999') // → 999\n */\nexport function parseGid(gid: string): number {\n const match = gid.match(/\\d+$/)\n return match ? parseInt(match[0], 10) : 0\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,cAAc;;;ACAd,IAAM,EAAE,IAAI,IAAI;AAET,IAAM,MAAM,OAAO;AAE1B,IAAM,YAAY;AAAA,EAChB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAIA,SAAS,YACP,SACA,aACc;AACd,MAAI,eAAe,eAAe,WAAW;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,YAAY,QAAQ;AACtB,WAAO;AAAA,EACT;AAEA,MAAI,YAAY,cAAc;AAC5B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,IAAM,qBAAqB,YAAY,IAAI,UAAU,IAAI,SAAS;AACzE,IAAM,sBAAsB,UAAU,kBAAkB;AAEjD,IAAM,SAAS;AAAA,EACpB,OAAO,IAAI,SAAoB;AAC7B,QAAI,UAAU,SAAS,qBAAqB;AAE1C,cAAQ,MAAM,GAAG,IAAI;AAAA,IACvB;AAAA,EACF;AAAA,EACA,MAAM,IAAI,SAAoB;AAC5B,QAAI,UAAU,QAAQ,qBAAqB;AAEzC,cAAQ,KAAK,GAAG,IAAI;AAAA,IACtB;AAAA,EACF;AAAA,EACA,MAAM,IAAI,SAAoB;AAC5B,QAAI,UAAU,QAAQ,qBAAqB;AAEzC,cAAQ,KAAK,GAAG,IAAI;AAAA,IACtB;AAAA,EACF;AAAA,EACA,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C,WAAO;AAAA,EACT;AAEA,MAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,WAAO,IAAI,IAAI,YAAY;AAAA,EAC7B;AAEA,MAAI,OAAO,QAAQ,UAAU;AAC3B,UAAM,SAAS;AACf,UAAM,SAAkC,CAAC;AAEzC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,MAAM,GAAG;AAEjD,UACE,QAAQ,WACR,MAAM,QAAQ,KAAK,KACnB,MAAM;AAAA,QACJ,CAAC,SACC,OAAO,SAAS,YAAY,SAAS,QAAQ,UAAU;AAAA,MAC3D,GACA;AACA,eAAO,MAAM,IAAI,CAAC,SAA4B,aAAa,KAAK,IAAI,CAAC;AAAA,MACvE;AAGA,UACE,QAAQ,QACR,OAAO,UAAU,YACjB,MAAM,WAAW,QAAQ,GACzB;AACA,eAAO,GAAG,IAAI,iBAAiB,KAAK;AACpC;AAAA,MACF;AAGA,YAAM,WAAW,aAAa,GAAG;AACjC,aAAO,QAAQ,IAAI,aAAa,KAAK;AAAA,IACvC;AAEA,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;AClFO,SAAS,SAAS,KAAqB;AAC5C,QAAM,QAAQ,IAAI,MAAM,MAAM;AAC9B,SAAO,QAAQ,SAAS,MAAM,CAAC,GAAG,EAAE,IAAI;AAC1C;","names":["import_zod","dotenv","env","import_zod","z","z","import_zod","z","import_zod","z","import_zod","z","import_zod","z"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/mutations/customers/deleteCustomerById.ts","../src/utils/logger.ts","../src/utils/shopifyClient.ts","../src/utils/shopifyFetch.ts","../src/utils/zod.ts","../src/queries/orders/getOrderById.ts","../src/queries/orders/getOrderById.queries.ts","../src/queries/orders/getOrderByName.ts","../src/queries/orders/getOrderByName.queries.ts","../src/queries/productVariants/getLeanProductVariants.ts","../src/queries/orders/getOrderPaymentDetails.ts","../src/queries/orders/getOrderPaymentDetails.queries.ts","../src/utils/parseGid.ts"],"sourcesContent":["export { deleteCustomerById } from './mutations/customers/deleteCustomerById.js'\nexport {\n getOrderById,\n type FullOrder,\n type LeanOrder,\n} from './queries/orders/getOrderById.js'\nexport {\n getOrderByName,\n type FullOrderByName,\n type LeanOrderByName,\n} from './queries/orders/getOrderByName.js'\nexport { getLeanProductVariants } from './queries/productVariants/getLeanProductVariants.js'\nexport { getOrderPaymentDetailsById } from './queries/orders/getOrderPaymentDetails.js'\nexport { parseGid } from './utils/parseGid.js'\n","import z from 'zod'\nimport type {\n CustomerDeleteMutation,\n CustomerDeleteMutationVariables,\n} from '../../generated-api-types/2025-04/admin.generated'\nimport { gql } from '../../utils/logger'\nimport { fetchShopifyGraphql } from '../../utils/shopifyFetch'\nimport { returnOutputParsed } from '../../utils/zod'\n\nexport const DeleteCustomerByIdReturn = z.string().nullable()\n\ntype SingleNode = { deletedCustomerId: string | null }\n\nexport async function deleteCustomerById(\n customerId: string,\n): Promise<z.infer<typeof DeleteCustomerByIdReturn>> {\n const mutation = gql`#graphql\n mutation customerDelete($input: CustomerDeleteInput!) {\n customerDelete(input: $input) {\n deletedCustomerId\n userErrors {\n field\n message\n }\n }\n }\n `\n\n const variables: CustomerDeleteMutationVariables = {\n input: { id: customerId },\n }\n\n const response = await fetchShopifyGraphql<\n SingleNode,\n CustomerDeleteMutation\n >({\n query: mutation,\n variables,\n dataExtractor: (data: CustomerDeleteMutation) => {\n if (!data.customerDelete) {\n throw new Error(\"GraphQL response missing 'customerDelete' field\")\n }\n return {\n nodes: [\n { deletedCustomerId: data.customerDelete.deletedCustomerId ?? null },\n ],\n userErrors: data.customerDelete.userErrors,\n }\n },\n })\n\n return returnOutputParsed(\n response[0]?.deletedCustomerId ?? null,\n DeleteCustomerByIdReturn,\n )\n}\n","const { env } = process\n\nexport const gql = String.raw\n\nconst logLevels = {\n silent: 0,\n error: 1,\n warn: 2,\n info: 3,\n debug: 4,\n} as const\n\ntype LogLevelName = keyof typeof logLevels\n\nfunction getLogLevel(\n nodeEnv: string | undefined,\n logLevelEnv: string | undefined,\n): LogLevelName {\n if (logLevelEnv && logLevelEnv in logLevels) {\n return logLevelEnv as LogLevelName\n }\n\n if (nodeEnv === 'test') {\n return 'silent'\n }\n\n if (nodeEnv === 'production') {\n return 'info'\n }\n return 'debug'\n}\n\nexport const activeLogLevelName = getLogLevel(env.NODE_ENV, env.LOG_LEVEL)\nconst activeLogLevelValue = logLevels[activeLogLevelName]\n\nexport const logger = {\n debug: (...args: unknown[]) => {\n if (logLevels.debug <= activeLogLevelValue) {\n // biome-ignore lint/suspicious/noConsole: <explanation>\n console.debug(...args)\n }\n },\n info: (...args: unknown[]) => {\n if (logLevels.info <= activeLogLevelValue) {\n // biome-ignore lint/suspicious/noConsole: <explanation>\n console.info(...args)\n }\n },\n warn: (...args: unknown[]) => {\n if (logLevels.warn <= activeLogLevelValue) {\n // biome-ignore lint/suspicious/noConsole: <explanation>\n console.warn(...args)\n }\n },\n error: (...args: unknown[]) => {\n if (logLevels.error <= activeLogLevelValue) {\n // biome-ignore lint/suspicious/noConsole: <explanation>\n console.error(...args)\n }\n },\n}\n","import {\n ApiVersion,\n type GraphqlClient,\n LogSeverity,\n Session,\n shopifyApi,\n} from '@shopify/shopify-api'\nimport '@shopify/shopify-api/adapters/node'\nimport dotenv from 'dotenv'\nimport { z } from 'zod'\nimport { activeLogLevelName, logger } from './logger.js'\n\n// https://shopify.dev/docs/api/admin-graphql/2025-04/\nexport const SHOPIFY_API_VERSION = ApiVersion.April25\n\ndotenv.config()\n\nconst envSchema = z.object({\n SHOPIFY_API_KEY: z.string({\n required_error: 'SHOPIFY_API_KEY is required',\n }),\n SHOPIFY_API_SECRET: z.string({\n required_error: 'SHOPIFY_API_SECRET is required',\n }),\n SHOPIFY_API_HOSTNAME: z.string({\n required_error: 'SHOPIFY_API_HOSTNAME is required',\n }),\n SHOPIFY_ACCESS_TOKEN: z.string({\n required_error: 'SHOPIFY_ACCESS_TOKEN is required',\n }),\n NODE_ENV: z\n .enum(['development', 'production', 'test'])\n .default('development'),\n})\n\nconst mapLogLevelToShopifySeverity = (level: string): LogSeverity => {\n switch (level) {\n case 'silent':\n return LogSeverity.Error\n case 'debug':\n return LogSeverity.Debug\n case 'info':\n return LogSeverity.Info\n case 'warn':\n return LogSeverity.Warning\n case 'error':\n return LogSeverity.Error\n default:\n return LogSeverity.Info\n }\n}\n\nlet shopifyGraphqlClient: GraphqlClient\n\ntry {\n // biome-ignore lint/nursery/noProcessEnv: <explanation>\n const env = envSchema.parse(process.env)\n\n const shopify = shopifyApi({\n apiKey: env.SHOPIFY_API_KEY,\n apiSecretKey: env.SHOPIFY_API_SECRET,\n hostName: env.SHOPIFY_API_HOSTNAME,\n apiVersion: SHOPIFY_API_VERSION,\n isEmbeddedApp: false,\n logger: { level: mapLogLevelToShopifySeverity(activeLogLevelName) },\n future: {\n customerAddressDefaultFix: true,\n lineItemBilling: true,\n unstable_managedPricingSupport: false,\n },\n })\n\n const shopifySession = new Session({\n id: `custom-session-${env.SHOPIFY_API_HOSTNAME}`,\n shop: env.SHOPIFY_API_HOSTNAME,\n state: 'authenticated',\n isOnline: true,\n accessToken: env.SHOPIFY_ACCESS_TOKEN,\n })\n\n shopifyGraphqlClient = new shopify.clients.Graphql({\n session: shopifySession,\n })\n\n logger.info('Shopify API client initialized successfully.')\n} catch (error) {\n if (error instanceof z.ZodError) {\n const msg = JSON.stringify(error.format(), null, 2)\n logger.error(msg)\n } else {\n logger.error('Failed to initialize Shopify API client:', error)\n }\n throw error\n}\n\nexport { shopifyGraphqlClient as shopifyClient }\n","import { logger } from './logger.js'\nimport { shopifyClient } from './shopifyClient.js'\n\nexport function convertIdIntoGid(\n id: bigint,\n type: 'Order' | 'Customer',\n): string {\n return `gid://shopify/${type}/${id}`\n}\n\ninterface PageInfo {\n hasNextPage: boolean\n endCursor?: string | null | undefined\n}\n\ninterface ShopifyErrorWithMessage {\n message?: string\n [key: string]: unknown\n}\n\ntype TExtractorFunctionType<TResultNode, TPageData> = (pageData: TPageData) => {\n nodes: TResultNode[]\n pageInfo?: PageInfo\n userErrors?: { message?: string }[]\n}\n\nexport async function fetchShopifyGraphql<TResultNode, TPageData>(params: {\n query: string\n variables: Record<string, unknown>\n dataExtractor?: TExtractorFunctionType<TResultNode, TPageData>\n fetchAllPages?: boolean\n}): Promise<TResultNode[]>\nexport async function fetchShopifyGraphql<TReturnType>(params: {\n query: string\n variables: Record<string, unknown>\n}): Promise<TReturnType>\nexport async function fetchShopifyGraphql<\n TResultNode,\n TPageData,\n TReturnType,\n>(params: {\n query: string\n variables: Record<string, unknown>\n dataExtractor?: TExtractorFunctionType<TResultNode, TPageData>\n fetchAllPages?: boolean\n}): Promise<TResultNode[] | TReturnType> {\n const {\n query,\n variables: initialVariables,\n dataExtractor,\n fetchAllPages = false,\n } = params\n\n let currentVariables = { ...initialVariables }\n\n if (!dataExtractor) {\n return makeRequest<NonNullable<TReturnType>>(query, currentVariables)\n }\n\n const allNodes: TResultNode[] = []\n let hasNextLoop = true\n\n do {\n const response = await makeRequest<TPageData>(query, currentVariables)\n const { nodes, pageInfo, userErrors } = dataExtractor(response)\n\n // Handle Shopify mutation userErrors pattern\n if (Array.isArray(userErrors) && userErrors.length > 0) {\n const errorMessages = userErrors\n .map((e) => e.message || JSON.stringify(e))\n .join('\\n')\n logger.error('Shopify mutation userErrors:', errorMessages)\n throw new Error(`Shopify mutation userErrors: ${errorMessages}`)\n }\n\n allNodes.push(...nodes)\n\n hasNextLoop = fetchAllPages ? !!pageInfo?.hasNextPage : false\n if (hasNextLoop && pageInfo?.endCursor) {\n currentVariables = {\n ...currentVariables,\n after: pageInfo.endCursor,\n }\n }\n } while (hasNextLoop)\n\n return allNodes\n}\n\nasync function makeRequest<TReturnDataType>(\n query: string,\n variables: Record<string, unknown>,\n): Promise<NonNullable<TReturnDataType>> {\n type ShopifyRequestErrorType = {\n errors?: ShopifyErrorWithMessage | ShopifyErrorWithMessage[]\n }\n\n const response = (await shopifyClient.request<TReturnDataType>(query, {\n variables,\n })) as { data?: TReturnDataType } & ShopifyRequestErrorType\n\n if (response.errors) {\n let errorMessages = 'GraphQL query failed.'\n const errors = response.errors\n if (Array.isArray(errors)) {\n errorMessages = errors\n .map((e: ShopifyErrorWithMessage) => e.message || JSON.stringify(e))\n .join('\\n')\n } else if (\n typeof errors === 'object' &&\n errors !== null &&\n 'message' in errors\n ) {\n errorMessages = errors.message || JSON.stringify(errors)\n } else if (typeof errors === 'string') {\n errorMessages = errors\n } else {\n errorMessages = JSON.stringify(errors)\n }\n logger.error('GraphQL query failed:', errorMessages)\n throw new Error(`GraphQL errors: ${errorMessages}`)\n }\n\n if (!response.data) {\n throw new Error('No data in Shopify API response')\n }\n\n return response.data\n}\n","import z from 'zod'\nimport { logger } from './logger.js'\n\nexport async function returnOutputParsed<T>(\n data: unknown,\n Model: z.ZodType<T>,\n) {\n const parsed = await Model.safeParseAsync(data)\n if (!parsed.success) {\n if (parsed.error instanceof z.ZodError) {\n const msg = JSON.stringify(parsed.error.format(), null, 2)\n logger.error(msg)\n } else {\n logger.error('Failed to parse:', parsed.error)\n }\n // throw parsedVariants.error\n throw new Error('Failed to parse product variants')\n }\n logger.info('Parsed data successfully')\n return parsed.data\n}\n","import z from 'zod'\nimport type {\n OrderByIdFullQuery,\n OrderByIdQuery,\n OrderByIdQueryVariables,\n} from '../../generated-api-types/2025-04/admin.generated.js'\nimport { logger } from '../../utils/logger.js'\nimport {\n convertIdIntoGid,\n fetchShopifyGraphql,\n} from '../../utils/shopifyFetch.js'\nimport { returnOutputParsed } from '../../utils/zod.js'\nimport { queryOrderById, queryOrderByIdFull } from './getOrderById.queries.js'\n\n// Address schema (shared between lean and full)\nconst AddressSchema = z\n .object({\n firstName: z.string().nullable(),\n lastName: z.string().nullable(),\n address1: z.string().nullable(),\n address2: z.string().nullable(),\n city: z.string().nullable(),\n province: z.string().nullable(),\n country: z.string().nullable(),\n zip: z.string().nullable(),\n })\n .nullable()\n\n// Lean order schema\nconst GetLeanOrderByIdReturn = z\n .object({\n id: z.string(),\n name: z.string(),\n createdAt: z.string(),\n updatedAt: z.string(),\n cancelledAt: z.string().nullable(),\n cancelReason: z.string().nullable(),\n totalPrice: z.object({\n amount: z.string(),\n currencyCode: z.string(),\n }),\n customer: z\n .object({\n id: z.string(),\n displayName: z.string(),\n firstName: z.string().nullable(),\n lastName: z.string().nullable(),\n emailAddress: z.string().nullable(),\n })\n .nullable(),\n financialStatus: z.string().nullable(),\n fulfillmentStatus: z.string().nullable(),\n shippingAddress: AddressSchema,\n })\n .nullable()\n\nexport type LeanOrder = z.infer<typeof GetLeanOrderByIdReturn>\n\n// Full order type - derived from the generated GraphQL types\nexport type FullOrder = NonNullable<OrderByIdFullQuery['order']>\n\ntype OrderDetailLevel = 'lean' | 'full'\n\n// Function overloads\nexport function getOrderById(id: number | bigint): Promise<LeanOrder>\nexport function getOrderById(\n id: number | bigint,\n detailLevel: 'lean',\n): Promise<LeanOrder>\nexport function getOrderById(\n id: number | bigint,\n detailLevel: 'full',\n): Promise<FullOrder | null>\n\n/**\n * Retrieves a single order from Shopify by its numeric ID.\n * Returns null if no order is found with the specified ID.\n *\n * @param {number | bigint} id - The numerical Shopify order ID (e.g., 12345678 or 12345678n).\n * @param {OrderDetailLevel} detailLevel - The level of detail to return ('lean' or 'full'). Defaults to 'lean'.\n * @returns {Promise<LeanOrder | FullOrder>} A promise that resolves to the order data or null if not found.\n * @throws {Error} If the GraphQL query fails or if the response structure is invalid.\n */\nexport async function getOrderById(\n id: number | bigint,\n detailLevel: OrderDetailLevel = 'lean',\n): Promise<LeanOrder | FullOrder> {\n const bigIntId = typeof id === 'number' ? BigInt(id) : id\n if (detailLevel === 'lean') {\n return getLeanOrderById(bigIntId)\n }\n return getFullOrderById(bigIntId)\n}\n\nasync function getLeanOrderById(id: bigint): Promise<LeanOrder> {\n const variables: OrderByIdQueryVariables = {\n id: convertIdIntoGid(id, 'Order'),\n }\n\n const response = await fetchShopifyGraphql<OrderByIdQuery>({\n query: queryOrderById,\n variables,\n })\n\n if (!response.order) {\n logger.debug(`No order found with ID: ${id}`)\n return null\n }\n\n const order = response.order\n\n const leanOrder = {\n id: order.id,\n name: order.name,\n createdAt: order.createdAt,\n updatedAt: order.updatedAt,\n cancelledAt: order.cancelledAt ?? null,\n cancelReason: order.cancelReason ?? null,\n totalPrice: {\n amount: order.totalPriceSet?.shopMoney?.amount ?? '',\n currencyCode: order.totalPriceSet?.shopMoney?.currencyCode ?? '',\n },\n customer: order.customer\n ? {\n id: order.customer.id,\n displayName: order.customer.displayName,\n firstName: order.customer.firstName ?? null,\n lastName: order.customer.lastName ?? null,\n emailAddress:\n order.customer.defaultEmailAddress?.emailAddress ?? null,\n }\n : null,\n financialStatus: order.displayFinancialStatus ?? null,\n fulfillmentStatus: order.displayFulfillmentStatus ?? null,\n shippingAddress: order.shippingAddress\n ? {\n firstName: order.shippingAddress.firstName ?? null,\n lastName: order.shippingAddress.lastName ?? null,\n address1: order.shippingAddress.address1 ?? null,\n address2: order.shippingAddress.address2 ?? null,\n city: order.shippingAddress.city ?? null,\n province: order.shippingAddress.province ?? null,\n country: order.shippingAddress.country ?? null,\n zip: order.shippingAddress.zip ?? null,\n }\n : null,\n }\n\n return await returnOutputParsed(leanOrder, GetLeanOrderByIdReturn)\n}\n\nasync function getFullOrderById(id: bigint): Promise<FullOrder | null> {\n const variables: OrderByIdQueryVariables = {\n id: convertIdIntoGid(id, 'Order'),\n }\n\n const response = await fetchShopifyGraphql<OrderByIdFullQuery>({\n query: queryOrderByIdFull,\n variables,\n })\n\n if (!response.order) {\n logger.debug(`No order found with ID: ${id}`)\n return null\n }\n\n return response.order\n}\n","import { gql } from '../../utils/logger'\n\nexport const queryOrderById = gql`#graphql\n query orderById($id: ID!) {\n order(id: $id) {\n id\n name\n createdAt\n updatedAt\n cancelledAt\n cancelReason\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n customer {\n id\n lastName\n defaultEmailAddress {\n emailAddress\n }\n displayName\n firstName\n }\n displayFinancialStatus\n displayFulfillmentStatus\n shippingAddress {\n firstName\n lastName\n address1\n address2\n city\n province\n country\n zip\n }\n }\n }\n`\n\nexport const queryOrderByIdFull = gql`#graphql\n query orderByIdFull($id: ID!) {\n order(id: $id) {\n id\n name\n createdAt\n updatedAt\n processedAt\n closedAt\n cancelledAt\n cancelReason\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n customer {\n id\n firstName\n lastName\n email\n phone\n }\n displayFinancialStatus\n displayFulfillmentStatus\n shippingAddress {\n firstName\n lastName\n address1\n address2\n city\n province\n country\n zip\n }\n billingAddress {\n firstName\n lastName\n address1\n address2\n city\n province\n country\n zip\n }\n lineItems(first: 100) {\n edges {\n node {\n id\n sku\n title\n variantTitle\n quantity\n customAttributes {\n key\n value\n }\n originalUnitPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n vendor\n image {\n url\n width\n height\n altText\n }\n }\n }\n }\n fulfillments {\n id\n name\n totalQuantity\n status\n createdAt\n estimatedDeliveryAt\n deliveredAt\n trackingInfo {\n company\n number\n url\n }\n fulfillmentLineItems(first: 100) {\n edges {\n node {\n id\n quantity\n lineItem {\n id\n sku\n }\n }\n }\n }\n }\n shippingLine {\n originalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n taxLines {\n priceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n totalDiscountsSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n discountCodes\n refunds {\n totalRefundedSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n }\n }\n`\n","import z from 'zod'\nimport type {\n OrdersByNameFullQuery,\n OrdersByNameQuery,\n OrdersByNameQueryVariables,\n} from '../../generated-api-types/2025-04/admin.generated.js'\nimport { logger } from '../../utils/logger.js'\nimport { fetchShopifyGraphql } from '../../utils/shopifyFetch.js'\nimport { returnOutputParsed } from '../../utils/zod.js'\nimport {\n queryOrdersByName,\n queryOrdersByNameFull,\n} from './getOrderByName.queries.js'\n\nconst GetLeanOrderByNameReturn = z\n .object({\n id: z.string(),\n name: z.string(),\n createdAt: z.string(),\n updatedAt: z.string(),\n totalPrice: z.object({\n amount: z.string(),\n currencyCode: z.string(),\n }),\n customer: z\n .object({\n id: z.string(),\n displayName: z.string(),\n emailAddress: z.string().nullable(),\n })\n .nullable(),\n financialStatus: z.string().nullable(),\n fulfillmentStatus: z.string().nullable(),\n })\n .nullable()\n\nexport type LeanOrderByName = z.infer<typeof GetLeanOrderByNameReturn>\n\nexport type FullOrderByName = NonNullable<\n NonNullable<OrdersByNameFullQuery['orders']>['edges'][number]['node']\n> | null\n\ntype OrderDetailLevel = 'lean' | 'full'\n\n// Function overloads\nexport function getOrderByName(\n orderName: string,\n detailLevel: 'lean',\n): Promise<LeanOrderByName>\nexport function getOrderByName(\n orderName: string,\n detailLevel: 'full',\n): Promise<FullOrderByName>\nexport function getOrderByName(orderName: string): Promise<LeanOrderByName>\n\n/**\n * Retrieves a single order from Shopify by its order name (e.g., \"B12345\").\n * Returns null if no order is found with the specified name.\n *\n * @param {string} orderName - The order name to search for (e.g., \"B12345\").\n * @param {OrderDetailLevel} detailLevel - The level of detail to return ('lean' or 'full'). Defaults to 'lean'.\n * @returns {Promise<LeanOrderByName | FullOrderByName>} A promise that resolves to the order data or null if not found.\n * @throws {Error} If the GraphQL query fails or if the response structure is invalid.\n */\nexport async function getOrderByName(\n orderName: string,\n detailLevel: OrderDetailLevel = 'lean',\n): Promise<LeanOrderByName | FullOrderByName> {\n if (detailLevel === 'lean') {\n return getLeanOrderByName(orderName)\n }\n return getFullOrderByName(orderName)\n}\n\nasync function getLeanOrderByName(orderName: string): Promise<LeanOrderByName> {\n const variables: OrdersByNameQueryVariables = {\n first: 1,\n queryFilter: `name:${orderName}`,\n }\n\n type SingleNode = NonNullable<\n NonNullable<OrdersByNameQuery['orders']>['edges'][number]['node']\n >\n\n const extractedNodes = await fetchShopifyGraphql<\n SingleNode,\n OrdersByNameQuery\n >({\n query: queryOrdersByName,\n variables,\n dataExtractor: (pageData: OrdersByNameQuery) => {\n if (!pageData.orders) {\n throw new Error(\n \"GraphQL response for orders is missing the 'orders' field.\",\n )\n }\n const nodes: SingleNode[] = pageData.orders.edges.map(\n (edge: { node: SingleNode }) => edge.node,\n )\n return {\n nodes,\n }\n },\n fetchAllPages: false,\n })\n\n const order = extractedNodes[0]\n if (!order) {\n logger.debug(`No order found with name: ${orderName}`)\n return null\n }\n\n const leanOrder = {\n id: order.id,\n name: order.name,\n createdAt: order.createdAt,\n updatedAt: order.updatedAt,\n totalPrice: {\n amount: order.totalPriceSet?.shopMoney?.amount ?? '',\n currencyCode: order.totalPriceSet?.shopMoney?.currencyCode ?? '',\n },\n customer: order.customer\n ? {\n id: order.customer.id,\n displayName: order.customer.displayName,\n emailAddress:\n order.customer.defaultEmailAddress?.emailAddress ?? null,\n }\n : null,\n financialStatus: order.displayFinancialStatus ?? null,\n fulfillmentStatus: order.displayFulfillmentStatus ?? null,\n }\n\n return await returnOutputParsed(leanOrder, GetLeanOrderByNameReturn)\n}\n\nasync function getFullOrderByName(orderName: string): Promise<FullOrderByName> {\n const variables: OrdersByNameQueryVariables = {\n first: 1,\n queryFilter: `name:${orderName}`,\n }\n\n type SingleNode = NonNullable<\n NonNullable<OrdersByNameFullQuery['orders']>['edges'][number]['node']\n >\n\n const extractedNodes = await fetchShopifyGraphql<\n SingleNode,\n OrdersByNameFullQuery\n >({\n query: queryOrdersByNameFull,\n variables,\n dataExtractor: (pageData: OrdersByNameFullQuery) => {\n if (!pageData.orders) {\n throw new Error(\n \"GraphQL response for orders is missing the 'orders' field.\",\n )\n }\n const nodes: SingleNode[] = pageData.orders.edges.map(\n (edge: { node: SingleNode }) => edge.node,\n )\n return {\n nodes,\n }\n },\n fetchAllPages: false,\n })\n\n if (extractedNodes.length === 0) {\n logger.debug(`No order found with name: ${orderName}`)\n return null\n }\n\n const order = extractedNodes[0]\n if (!order) {\n logger.debug(`No order found with name: ${orderName}`)\n return null\n }\n\n return order\n}\n","import { gql } from '../../utils/logger'\n\nexport const queryOrdersByName = gql`#graphql\n query ordersByName($first: Int!, $queryFilter: String!) {\n orders(first: $first, query: $queryFilter) {\n edges {\n node {\n id\n name\n createdAt\n updatedAt\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n customer {\n id\n lastName\n defaultEmailAddress {\n emailAddress\n }\n displayName\n firstName\n }\n displayFinancialStatus\n displayFulfillmentStatus\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`\n\nexport const queryOrdersByNameFull = gql`#graphql\n query ordersByNameFull($first: Int!, $queryFilter: String!) {\n orders(first: $first, query: $queryFilter) {\n edges {\n node {\n billingAddress {\n address1\n address2\n city\n company\n country\n countryCodeV2\n firstName\n formattedArea\n id\n lastName\n name\n phone\n province\n provinceCode\n timeZone\n zip\n }\n billingAddressMatchesShippingAddress\n cancelReason\n cancellation {\n staffNote\n }\n cancelledAt\n capturable\n clientIp\n closed\n closedAt\n confirmed\n createdAt\n currencyCode\n currentCartDiscountAmountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentShippingPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentSubtotalLineItemsQuantity\n currentSubtotalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTaxLines {\n channelLiable\n rate\n ratePercentage\n source\n title\n priceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n currentTotalAdditionalFeesSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTotalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTotalDutiesSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTotalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTotalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n currentTotalWeight\n customer {\n id\n lastName\n defaultEmailAddress {\n emailAddress\n }\n displayName\n firstName\n }\n customerAcceptsMarketing\n discountCodes\n discountCode\n displayAddress {\n address1\n address2\n city\n company\n country\n countryCodeV2\n firstName\n formattedArea\n id\n lastName\n name\n phone\n province\n provinceCode\n timeZone\n zip\n }\n displayFinancialStatus\n displayFulfillmentStatus\n dutiesIncluded\n edited\n email\n estimatedTaxes\n fulfillable\n fulfillments(first: 20) {\n createdAt\n deliveredAt\n displayStatus\n estimatedDeliveryAt\n updatedAt\n trackingInfo(first: 10) {\n company\n url\n }\n totalQuantity\n status\n name\n id\n }\n fullyPaid\n id\n lineItems(first: 50) {\n edges {\n node {\n id\n name\n originalUnitPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n quantity\n requiresShipping\n sku\n title\n variantTitle\n }\n }\n }\n name\n note\n processedAt\n shippingAddress {\n address1\n address2\n city\n company\n country\n countryCodeV2\n firstName\n formattedArea\n id\n lastName\n name\n phone\n province\n provinceCode\n timeZone\n zip\n }\n statusPageUrl\n tags\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalReceivedSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalRefundedSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalShippingPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalWeight\n unpaid\n updatedAt\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n`\n","import z from 'zod'\nimport type {\n LeanProductVariantsQuery,\n LeanProductVariantsQueryVariables,\n} from '../../generated-api-types/2025-04/admin.generated.js'\nimport { gql, logger } from '../../utils/logger.js'\nimport { fetchShopifyGraphql } from '../../utils/shopifyFetch.js'\nimport { returnOutputParsed } from '../../utils/zod.js'\n\nconst GetLeanProductVariantsReturn = z.array(\n z.object({\n productId: z.string(),\n productTitle: z.string(),\n variantId: z.string(),\n variantTitle: z.string(),\n sku: z.string(),\n }),\n)\n\ntype GetLeanProductVariantsReturnType = z.infer<\n typeof GetLeanProductVariantsReturn\n>\n\n/**\n * Retrieves a lean list of product variants from Shopify, optionally filtered by SKUs.\n * Product variants are mapped to a simpler output structure.\n * Variants missing essential properties (e.g., SKU) will be filtered out and logged.\n *\n * @param {string[]} [skus] - An optional array of SKUs to filter by. If provided, only variants matching these SKUs will be fetched.\n * @returns {Promise<GetLeanProductVariantsReturnType>} A promise that resolves to an array of lean product variant data.\n * @throws {Error} If the GraphQL query fails, returns no data, or if the `productVariants` field is missing in the response.\n */\nexport async function getLeanProductVariants(\n skus?: string[],\n): Promise<GetLeanProductVariantsReturnType> {\n const queryGql = gql`#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 `\n\n const initialVariables: LeanProductVariantsQueryVariables = { first: 250 }\n if (skus && skus.length > 0) {\n initialVariables.queryFilter = skus\n .map((sku: string) => `sku:${sku}`)\n .join(' OR ')\n }\n\n // Type for a single node from the productVariants query\n type SingleNode = NonNullable<\n NonNullable<\n LeanProductVariantsQuery['productVariants']\n >['edges'][number]['node']\n >\n\n const extractedNodes = await fetchShopifyGraphql<\n SingleNode,\n LeanProductVariantsQuery\n >({\n query: queryGql,\n variables: initialVariables,\n dataExtractor: (pageData: LeanProductVariantsQuery) => {\n if (!pageData.productVariants) {\n throw new Error(\n \"GraphQL response for product variants is missing the 'productVariants' field.\",\n )\n }\n const nodes: SingleNode[] = pageData.productVariants.edges.map(\n (edge: { node: SingleNode }) => edge.node,\n )\n return {\n nodes,\n pageInfo: pageData.productVariants.pageInfo,\n }\n },\n fetchAllPages: true,\n })\n\n const allVariants = extractedNodes.flatMap<\n GetLeanProductVariantsReturnType[number]\n >((v) => {\n if (v.sku) {\n return [\n {\n productId: v.product.id,\n productTitle: v.product.title,\n variantId: v.id,\n variantTitle: v.title,\n sku: v.sku,\n },\n ]\n }\n logger.debug(\n `Product ${v.product.title} (ID: ${v.product.id}) has a variant (ID: ${v.id}) with no SKU. Filtering out.`,\n )\n return []\n })\n\n return await returnOutputParsed(allVariants, GetLeanProductVariantsReturn)\n}\n","import z from 'zod'\nimport type {\n OrderPaymentDetailsByIdQuery,\n OrderPaymentDetailsByIdQueryVariables,\n} from '../../generated-api-types/2025-04/admin.generated.js'\nimport { logger } from '../../utils/logger.js'\nimport {\n convertIdIntoGid,\n fetchShopifyGraphql,\n} from '../../utils/shopifyFetch.js'\nimport { returnOutputParsed } from '../../utils/zod.js'\nimport { queryOrderPaymentDetails } from './getOrderPaymentDetails.queries.js'\n\nconst GetOrderPaymentDetailsByIdReturn = z.object({\n order: z.object({\n transactions: z.array(\n z.object({\n amountSet: z.object({\n shopMoney: z.object({\n amount: z.string(),\n currencyCode: z.string(),\n }),\n }),\n createdAt: z.string(),\n gateway: z.string(),\n formattedGateway: z.string(),\n kind: z.string(),\n paymentId: z.string(),\n }),\n ),\n }),\n})\n\ntype GetOrderPaymentDetailsByIdReturnType = z.infer<\n typeof GetOrderPaymentDetailsByIdReturn\n>\n\n/**\n * Retrieves payment details for a single order from Shopify by its ID.\n * Returns null if no order is found with the specified ID.\n *\n * @param {bigint} id - The numerical Shopify order ID (e.g., 12345678n).\n * @returns {Promise<GetOrderPaymentDetailsByIdReturnType | null>} A promise that resolves to the order payment data or null if not found.\n * @throws {Error} If the GraphQL query fails or if the response structure is invalid.\n */\nexport async function getOrderPaymentDetailsById(\n id: bigint,\n): Promise<GetOrderPaymentDetailsByIdReturnType | null> {\n const variables: OrderPaymentDetailsByIdQueryVariables = {\n id: convertIdIntoGid(id, 'Order'),\n }\n\n const response = await fetchShopifyGraphql<OrderPaymentDetailsByIdQuery>({\n query: queryOrderPaymentDetails,\n variables,\n })\n\n if (!response.order) {\n logger.debug(`No order found with ID: ${id}`)\n return null\n }\n\n return await returnOutputParsed(response, GetOrderPaymentDetailsByIdReturn)\n}\n","import { gql } from '../../utils/logger.js'\n\nexport const queryOrderPaymentDetails = gql`#graphql\n query orderPaymentDetailsById($id: ID!) {\n order(id: $id) {\n transactions {\n amountSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n createdAt\n gateway\n formattedGateway\n kind\n paymentId\n }\n }\n }\n`\n","/**\n * Extract numeric ID from a Shopify GID string.\n *\n * @example\n * parseGid('gid://shopify/Order/12345678901234') // → 12345678901234\n * parseGid('gid://shopify/LineItem/999') // → 999\n */\nexport function parseGid(gid: string): number {\n const match = gid.match(/\\d+$/)\n return match ? Number.parseInt(match[0], 10) : 0\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,cAAc;;;ACAd,IAAM,EAAE,IAAI,IAAI;AAET,IAAM,MAAM,OAAO;AAE1B,IAAM,YAAY;AAAA,EAChB,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,MAAM;AAAA,EACN,MAAM;AAAA,EACN,OAAO;AACT;AAIA,SAAS,YACP,SACA,aACc;AACd,MAAI,eAAe,eAAe,WAAW;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,YAAY,QAAQ;AACtB,WAAO;AAAA,EACT;AAEA,MAAI,YAAY,cAAc;AAC5B,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAEO,IAAM,qBAAqB,YAAY,IAAI,UAAU,IAAI,SAAS;A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S,OAAO;AACnB,WAAO,MAAM,2BAA2B,EAAE,EAAE;AAC5C,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,mBAAmB,UAAU,gCAAgC;AAC5E;;;AExDO,SAAS,SAAS,KAAqB;AAC5C,QAAM,QAAQ,IAAI,MAAM,MAAM;AAC9B,SAAO,QAAQ,OAAO,SAAS,MAAM,CAAC,GAAG,EAAE,IAAI;AACjD;","names":["import_zod","dotenv","env","import_zod","z","z","import_zod","z","import_zod","z","import_zod","z","import_zod","z"]}
package/dist/index.d.cts CHANGED
@@ -4704,7 +4704,7 @@ type DeliveryProfile = Node & {
4704
4704
  id: Scalars['ID']['output'];
4705
4705
  /**
4706
4706
  * Whether this shop has enabled legacy compatibility mode for delivery profiles.
4707
- * @deprecated Legacy mode profiles are no longer supported.
4707
+ * @deprecated Legacy mode profiles are no longer supported. This will be removed in 2026-04.
4708
4708
  */
4709
4709
  legacyMode: Scalars['Boolean']['output'];
4710
4710
  /** The number of locations without rates defined. */
@@ -9409,7 +9409,7 @@ type Location = HasMetafieldDefinitions & HasMetafields & LegacyInteroperability
9409
9409
  metafields: MetafieldConnection;
9410
9410
  /** The name of the location. */
9411
9411
  name: Scalars['String']['output'];
9412
- /** Whether this location is used for calculating shipping rates. In multi-origin shipping mode, this flag is ignored. */
9412
+ /** Legacy field indicating this location was designated for shipping. All locations with valid addresses can now ship. */
9413
9413
  shipsInventory: Scalars['Boolean']['output'];
9414
9414
  /** List of suggested addresses for this location (empty if none). */
9415
9415
  suggestedAddresses: Array<LocationSuggestedAddress>;
@@ -12265,7 +12265,7 @@ declare enum OrderTransactionErrorCode {
12265
12265
  AmazonPaymentsOrderReferenceCanceled = "AMAZON_PAYMENTS_ORDER_REFERENCE_CANCELED",
12266
12266
  /** The order was not confirmed within three hours. */
12267
12267
  AmazonPaymentsStale = "AMAZON_PAYMENTS_STALE",
12268
- /** Call the card issuer. */
12268
+ /** The issuer declined the transaction, the customer should contact their issuer for more details. */
12269
12269
  CallIssuer = "CALL_ISSUER",
12270
12270
  /** The card was declined. */
12271
12271
  CardDeclined = "CARD_DECLINED",
@@ -12285,7 +12285,7 @@ declare enum OrderTransactionErrorCode {
12285
12285
  IncorrectPin = "INCORRECT_PIN",
12286
12286
  /** The ZIP or postal code doesn't match the one on file. */
12287
12287
  IncorrectZip = "INCORRECT_ZIP",
12288
- /** The amount is either too high or too low for the provider. */
12288
+ /** The amount is invalid. */
12289
12289
  InvalidAmount = "INVALID_AMOUNT",
12290
12290
  /** The payment method is not available in the customer's country. */
12291
12291
  InvalidCountry = "INVALID_COUNTRY",
@@ -18558,7 +18558,7 @@ type OrderByIdFullQuery = {
18558
18558
  fulfillmentLineItems: {
18559
18559
  edges: Array<{
18560
18560
  node: (Pick<FulfillmentLineItem, 'id' | 'quantity'> & {
18561
- lineItem: Pick<LineItem, 'id'>;
18561
+ lineItem: Pick<LineItem, 'id' | 'sku'>;
18562
18562
  });
18563
18563
  }>;
18564
18564
  };
@@ -18735,7 +18735,7 @@ interface GeneratedQueryTypes {
18735
18735
  return: OrderByIdQuery;
18736
18736
  variables: OrderByIdQueryVariables;
18737
18737
  };
18738
- "#graphql\n query orderByIdFull($id: ID!) {\n order(id: $id) {\n id\n name\n createdAt\n updatedAt\n processedAt\n closedAt\n cancelledAt\n cancelReason\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n customer {\n id\n firstName\n lastName\n email\n phone\n }\n displayFinancialStatus\n displayFulfillmentStatus\n shippingAddress {\n firstName\n lastName\n address1\n address2\n city\n province\n country\n zip\n }\n billingAddress {\n firstName\n lastName\n address1\n address2\n city\n province\n country\n zip\n }\n lineItems(first: 100) {\n edges {\n node {\n id\n sku\n title\n variantTitle\n quantity\n customAttributes {\n key\n value\n }\n originalUnitPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n vendor\n image {\n url\n width\n height\n altText\n }\n }\n }\n }\n fulfillments {\n id\n name\n totalQuantity\n status\n createdAt\n estimatedDeliveryAt\n deliveredAt\n trackingInfo {\n company\n number\n url\n }\n fulfillmentLineItems(first: 100) {\n edges {\n node {\n id\n quantity\n lineItem {\n id\n }\n }\n }\n }\n }\n shippingLine {\n originalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n taxLines {\n priceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n totalDiscountsSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n discountCodes\n refunds {\n totalRefundedSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n }\n }\n": {
18738
+ "#graphql\n query orderByIdFull($id: ID!) {\n order(id: $id) {\n id\n name\n createdAt\n updatedAt\n processedAt\n closedAt\n cancelledAt\n cancelReason\n totalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n customer {\n id\n firstName\n lastName\n email\n phone\n }\n displayFinancialStatus\n displayFulfillmentStatus\n shippingAddress {\n firstName\n lastName\n address1\n address2\n city\n province\n country\n zip\n }\n billingAddress {\n firstName\n lastName\n address1\n address2\n city\n province\n country\n zip\n }\n lineItems(first: 100) {\n edges {\n node {\n id\n sku\n title\n variantTitle\n quantity\n customAttributes {\n key\n value\n }\n originalUnitPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n vendor\n image {\n url\n width\n height\n altText\n }\n }\n }\n }\n fulfillments {\n id\n name\n totalQuantity\n status\n createdAt\n estimatedDeliveryAt\n deliveredAt\n trackingInfo {\n company\n number\n url\n }\n fulfillmentLineItems(first: 100) {\n edges {\n node {\n id\n quantity\n lineItem {\n id\n sku\n }\n }\n }\n }\n }\n shippingLine {\n originalPriceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n taxLines {\n priceSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n totalDiscountsSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n discountCodes\n refunds {\n totalRefundedSet {\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n }\n }\n": {
18739
18739
  return: OrderByIdFullQuery;
18740
18740
  variables: OrderByIdFullQueryVariables;
18741
18741
  };
@@ -18906,10 +18906,10 @@ declare const GetLeanOrderByIdReturn: z.ZodNullable<z.ZodObject<{
18906
18906
  financialStatus: string | null;
18907
18907
  }>>;
18908
18908
  type LeanOrder = z.infer<typeof GetLeanOrderByIdReturn>;
18909
- type FullOrder = NonNullable<OrderByIdFullQuery['order']> | null;
18909
+ type FullOrder = NonNullable<OrderByIdFullQuery['order']>;
18910
18910
  declare function getOrderById(id: number | bigint): Promise<LeanOrder>;
18911
18911
  declare function getOrderById(id: number | bigint, detailLevel: 'lean'): Promise<LeanOrder>;
18912
- declare function getOrderById(id: number | bigint, detailLevel: 'full'): Promise<FullOrder>;
18912
+ declare function getOrderById(id: number | bigint, detailLevel: 'full'): Promise<FullOrder | null>;
18913
18913
 
18914
18914
  declare const GetLeanOrderByNameReturn: z.ZodNullable<z.ZodObject<{
18915
18915
  id: z.ZodString;
@@ -19139,36 +19139,6 @@ type GetOrderPaymentDetailsByIdReturnType = z.infer<typeof GetOrderPaymentDetail
19139
19139
  */
19140
19140
  declare function getOrderPaymentDetailsById(id: bigint): Promise<GetOrderPaymentDetailsByIdReturnType | null>;
19141
19141
 
19142
- /**
19143
- * Transforms GraphQL responses to REST-like format.
19144
- *
19145
- * This utility recursively:
19146
- * 1. Flattens `{ edges: [{ node: ... }] }` → `[...]`
19147
- * 2. Converts camelCase to snake_case (`lineItems` → `line_items`)
19148
- * 3. Extracts numeric IDs from GIDs (`gid://shopify/Order/123` → `123`)
19149
- */
19150
- /**
19151
- * Transform a GraphQL response object to REST-like format.
19152
- *
19153
- * @example
19154
- * ```typescript
19155
- * const graphqlOrder = {
19156
- * id: 'gid://shopify/Order/123',
19157
- * lineItems: {
19158
- * edges: [{ node: { id: 'gid://shopify/LineItem/456', sku: 'ABC' } }]
19159
- * }
19160
- * };
19161
- *
19162
- * const restOrder = toRestFormat(graphqlOrder);
19163
- * // Result:
19164
- * // {
19165
- * // id: 123,
19166
- * // line_items: [{ id: 456, sku: 'ABC' }]
19167
- * // }
19168
- * ```
19169
- */
19170
- declare function toRestFormat<T>(obj: T): unknown;
19171
-
19172
19142
  /**
19173
19143
  * Extract numeric ID from a Shopify GID string.
19174
19144
  *
@@ -19178,4 +19148,4 @@ declare function toRestFormat<T>(obj: T): unknown;
19178
19148
  */
19179
19149
  declare function parseGid(gid: string): number;
19180
19150
 
19181
- export { type FullOrder, type FullOrderByName, type LeanOrder, type LeanOrderByName, deleteCustomerById, getLeanProductVariants, getOrderById, getOrderByName, getOrderPaymentDetailsById, parseGid, toRestFormat };
19151
+ export { type FullOrder, type FullOrderByName, type LeanOrder, type LeanOrderByName, deleteCustomerById, getLeanProductVariants, getOrderById, getOrderByName, getOrderPaymentDetailsById, parseGid };
package/dist/index.mjs CHANGED
@@ -381,6 +381,7 @@ var queryOrderByIdFull = gql`#graphql
381
381
  quantity
382
382
  lineItem {
383
383
  id
384
+ sku
384
385
  }
385
386
  }
386
387
  }
@@ -1101,46 +1102,10 @@ async function getOrderPaymentDetailsById(id) {
1101
1102
  return await returnOutputParsed(response, GetOrderPaymentDetailsByIdReturn);
1102
1103
  }
1103
1104
 
1104
- // src/utils/toRestFormat.ts
1105
- function camelToSnake(str) {
1106
- return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
1107
- }
1108
- function extractNumericId(gid) {
1109
- const match = gid.match(/\d+$/);
1110
- return match ? parseInt(match[0], 10) : 0;
1111
- }
1112
- function toRestFormat(obj) {
1113
- if (obj === null || obj === void 0) {
1114
- return obj;
1115
- }
1116
- if (Array.isArray(obj)) {
1117
- return obj.map(toRestFormat);
1118
- }
1119
- if (typeof obj === "object") {
1120
- const record = obj;
1121
- const result = {};
1122
- for (const [key, value] of Object.entries(record)) {
1123
- if (key === "edges" && Array.isArray(value) && value.every(
1124
- (item) => typeof item === "object" && item !== null && "node" in item
1125
- )) {
1126
- return value.map((edge) => toRestFormat(edge.node));
1127
- }
1128
- if (key === "id" && typeof value === "string" && value.startsWith("gid://")) {
1129
- result[key] = extractNumericId(value);
1130
- continue;
1131
- }
1132
- const snakeKey = camelToSnake(key);
1133
- result[snakeKey] = toRestFormat(value);
1134
- }
1135
- return result;
1136
- }
1137
- return obj;
1138
- }
1139
-
1140
1105
  // src/utils/parseGid.ts
1141
1106
  function parseGid(gid) {
1142
1107
  const match = gid.match(/\d+$/);
1143
- return match ? parseInt(match[0], 10) : 0;
1108
+ return match ? Number.parseInt(match[0], 10) : 0;
1144
1109
  }
1145
1110
  export {
1146
1111
  deleteCustomerById,
@@ -1148,7 +1113,6 @@ export {
1148
1113
  getOrderById,
1149
1114
  getOrderByName,
1150
1115
  getOrderPaymentDetailsById,
1151
- parseGid,
1152
- toRestFormat
1116
+ parseGid
1153
1117
  };
1154
1118
  //# sourceMappingURL=index.mjs.map