@ehrenkind/shopify-lib 0.1.0 → 0.2.0
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/generated-api-types/2025-04/admin.generated.d.ts +74 -0
- package/dist/generated-api-types/2025-04/admin.generated.d.ts.map +1 -1
- package/dist/generated-api-types/2025-04/admin.types.d.ts +4 -4
- package/dist/generated-api-types/2025-04/admin.types.d.ts.map +1 -1
- package/dist/generated-api-types/2025-04/admin.types.js +4 -4
- package/dist/generated-api-types/2025-04/admin.types.js.map +1 -1
- package/dist/index.cjs +319 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +214 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +318 -37
- package/dist/index.mjs.map +1 -1
- package/dist/queries/orders/getOrderById.d.ts +136 -0
- package/dist/queries/orders/getOrderById.d.ts.map +1 -0
- package/dist/queries/orders/getOrderById.js +125 -0
- package/dist/queries/orders/getOrderById.js.map +1 -0
- package/dist/queries/orders/getOrderById.mock.d.ts +82 -0
- package/dist/queries/orders/getOrderById.mock.d.ts.map +1 -0
- package/dist/queries/orders/getOrderById.mock.js +204 -0
- package/dist/queries/orders/getOrderById.mock.js.map +1 -0
- package/dist/queries/orders/getOrderById.queries.d.ts +3 -0
- package/dist/queries/orders/getOrderById.queries.d.ts.map +1 -0
- package/dist/queries/orders/getOrderById.queries.js +174 -0
- package/dist/queries/orders/getOrderById.queries.js.map +1 -0
- package/dist/queries/orders/getOrderById.test.d.ts +2 -0
- package/dist/queries/orders/getOrderById.test.d.ts.map +1 -0
- package/dist/queries/orders/getOrderById.test.js +46 -0
- package/dist/queries/orders/getOrderById.test.js.map +1 -0
- package/dist/queries/orders/getOrderByName.d.ts +5 -5
- package/dist/queries/orders/getOrderByName.d.ts.map +1 -1
- package/dist/queries/orders/getOrderByName.js +1 -1
- package/dist/queries/orders/getOrderByName.js.map +1 -1
- package/dist/queries/orders/getOrderByName.test.js +6 -4
- package/dist/queries/orders/getOrderByName.test.js.map +1 -1
- package/dist/queries/orders/getOrderPaymentDetails.mock.d.ts +12 -0
- package/dist/queries/orders/getOrderPaymentDetails.mock.d.ts.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.mock.js +24 -0
- package/dist/queries/orders/getOrderPaymentDetails.mock.js.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.test.d.ts +2 -0
- package/dist/queries/orders/getOrderPaymentDetails.test.d.ts.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.test.js +19 -0
- package/dist/queries/orders/getOrderPaymentDetails.test.js.map +1 -0
- package/dist/utils/mswHandlers.d.ts.map +1 -1
- package/dist/utils/mswHandlers.js +5 -0
- package/dist/utils/mswHandlers.js.map +1 -1
- package/package.json +6 -4
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/mutations/customers/deleteCustomerById.ts","../src/utils/logger.ts","../src/utils/shopifyClient.ts","../src/utils/shopifyFetch.ts","../src/utils/zod.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"],"sourcesContent":["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 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\ntype GetLeanOrderByNameReturnType = z.infer<typeof GetLeanOrderByNameReturn>\n\ntype GetFullOrderByNameReturnType = 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<GetLeanOrderByNameReturnType>\nexport function getOrderByName(\n orderName: string,\n detailLevel: 'full',\n): Promise<GetFullOrderByNameReturnType>\nexport function getOrderByName(\n orderName: string,\n): Promise<GetLeanOrderByNameReturnType>\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<GetLeanOrderByNameReturnType | GetFullOrderByNameReturnType>} 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<GetLeanOrderByNameReturnType | GetFullOrderByNameReturnType> {\n if (detailLevel === 'lean') {\n return getLeanOrderByName(orderName)\n }\n return getFullOrderByName(orderName)\n}\n\nasync function getLeanOrderByName(\n orderName: string,\n): Promise<GetLeanOrderByNameReturnType> {\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(\n orderName: string,\n): Promise<GetFullOrderByNameReturnType> {\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"],"mappings":";AAAA,OAAOA,QAAO;;;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,WAA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A;AAAA;AAAA;AAAA;AAAA;AAAA;;;ADWxC,IAAM,mCAAmCC,GAAE,OAAO;AAAA,EAChD,OAAOA,GAAE,OAAO;AAAA,IACd,cAAcA,GAAE;AAAA,MACdA,GAAE,OAAO;AAAA,QACP,WAAWA,GAAE,OAAO;AAAA,UAClB,WAAWA,GAAE,OAAO;AAAA,YAClB,QAAQA,GAAE,OAAO;AAAA,YACjB,cAAcA,GAAE,OAAO;AAAA,UACzB,CAAC;AAAA,QACH,CAAC;AAAA,QACD,WAAWA,GAAE,OAAO;AAAA,QACpB,SAASA,GAAE,OAAO;AAAA,QAClB,kBAAkBA,GAAE,OAAO;AAAA,QAC3B,MAAMA,GAAE,OAAO;AAAA,QACf,WAAWA,GAAE,OAAO;AAAA,MACtB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH,CAAC;AAcD,eAAsB,2BACpB,IACsD;AACtD,QAAM,YAAmD;AAAA,IACvD,IAAI,iBAAiB,IAAI,OAAO;AAAA,EAClC;AAEA,QAAM,WAAW,MAAM,oBAAkD;AAAA,IACvE,OAAO;AAAA,IACP;AAAA,EACF,CAAC;AAED,MAAI,CAAC,SAAS,OAAO;AACnB,WAAO,MAAM,2BAA2B,EAAE,EAAE;AAC5C,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,mBAAmB,UAAU,gCAAgC;AAC5E;","names":["z","env","z","z","z","z","z","z","z","z","z"]}
|
|
1
|
+
{"version":3,"sources":["../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"],"sourcesContent":["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: bigint): Promise<LeanOrder>\nexport function getOrderById(id: bigint, detailLevel: 'lean'): Promise<LeanOrder>\nexport function getOrderById(id: bigint, detailLevel: 'full'): 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 {bigint} id - The numerical Shopify order ID (e.g., 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: bigint,\n detailLevel: OrderDetailLevel = 'lean',\n): Promise<LeanOrder | FullOrder> {\n if (detailLevel === 'lean') {\n return getLeanOrderById(id)\n }\n return getFullOrderById(id)\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 lastName\n defaultEmailAddress {\n emailAddress\n }\n displayName\n firstName\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\ntype GetLeanOrderByNameReturnType = z.infer<typeof GetLeanOrderByNameReturn>\n\ntype GetFullOrderByNameReturnType = 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<GetLeanOrderByNameReturnType>\nexport function getOrderByName(\n orderName: string,\n detailLevel: 'full',\n): Promise<GetFullOrderByNameReturnType>\nexport function getOrderByName(\n orderName: string,\n): Promise<GetLeanOrderByNameReturnType>\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<GetLeanOrderByNameReturnType | GetFullOrderByNameReturnType>} 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<GetLeanOrderByNameReturnType | GetFullOrderByNameReturnType> {\n if (detailLevel === 'lean') {\n return getLeanOrderByName(orderName)\n }\n return getFullOrderByName(orderName)\n}\n\nasync function getLeanOrderByName(\n orderName: string,\n): Promise<GetLeanOrderByNameReturnType> {\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(\n orderName: string,\n): Promise<GetFullOrderByNameReturnType> {\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"],"mappings":";AAAA,OAAOA,QAAO;;;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,OAAO,IAAI,SAAoB;AAC7B,QAAI,UAAU,SAAS,qBAAqB;AAE1C,cAAQ,MAAM,GAAG,IAAI;AAAA,IACvB;AAAA,EACF;AACF;;;AC5DA;AAAA,E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A,QACf,WAAWA,GAAE,OAAO;AAAA,MACtB,CAAC;AAAA,IACH;AAAA,EACF,CAAC;AACH,CAAC;AAcD,eAAsB,2BACpB,IACsD;AACtD,QAAM,YAAmD;AAAA,IACvD,IAAI,iBAAiB,IAAI,OAAO;AAAA,EAClC;AAEA,QAAM,WAAW,MAAM,oBAAkD;AAAA,IACvE,OAAO;AAAA,IACP;AAAA,EACF,CAAC;AAED,MAAI,CAAC,SAAS,OAAO;AACnB,WAAO,MAAM,2BAA2B,EAAE,EAAE;AAC5C,WAAO;AAAA,EACT;AAEA,SAAO,MAAM,mBAAmB,UAAU,gCAAgC;AAC5E;","names":["z","env","z","z","z","z","z","z","z","z","z","z","z"]}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import type { OrderByIdFullQuery } from '../../generated-api-types/2025-04/admin.generated.js';
|
|
3
|
+
declare const GetLeanOrderByIdReturn: z.ZodNullable<z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
createdAt: z.ZodString;
|
|
7
|
+
updatedAt: z.ZodString;
|
|
8
|
+
cancelledAt: z.ZodNullable<z.ZodString>;
|
|
9
|
+
cancelReason: z.ZodNullable<z.ZodString>;
|
|
10
|
+
totalPrice: z.ZodObject<{
|
|
11
|
+
amount: z.ZodString;
|
|
12
|
+
currencyCode: z.ZodString;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
currencyCode: string;
|
|
15
|
+
amount: string;
|
|
16
|
+
}, {
|
|
17
|
+
currencyCode: string;
|
|
18
|
+
amount: string;
|
|
19
|
+
}>;
|
|
20
|
+
customer: z.ZodNullable<z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
displayName: z.ZodString;
|
|
23
|
+
firstName: z.ZodNullable<z.ZodString>;
|
|
24
|
+
lastName: z.ZodNullable<z.ZodString>;
|
|
25
|
+
emailAddress: z.ZodNullable<z.ZodString>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
id: string;
|
|
28
|
+
displayName: string;
|
|
29
|
+
lastName: string | null;
|
|
30
|
+
firstName: string | null;
|
|
31
|
+
emailAddress: string | null;
|
|
32
|
+
}, {
|
|
33
|
+
id: string;
|
|
34
|
+
displayName: string;
|
|
35
|
+
lastName: string | null;
|
|
36
|
+
firstName: string | null;
|
|
37
|
+
emailAddress: string | null;
|
|
38
|
+
}>>;
|
|
39
|
+
financialStatus: z.ZodNullable<z.ZodString>;
|
|
40
|
+
fulfillmentStatus: z.ZodNullable<z.ZodString>;
|
|
41
|
+
shippingAddress: z.ZodNullable<z.ZodObject<{
|
|
42
|
+
firstName: z.ZodNullable<z.ZodString>;
|
|
43
|
+
lastName: z.ZodNullable<z.ZodString>;
|
|
44
|
+
address1: z.ZodNullable<z.ZodString>;
|
|
45
|
+
address2: z.ZodNullable<z.ZodString>;
|
|
46
|
+
city: z.ZodNullable<z.ZodString>;
|
|
47
|
+
province: z.ZodNullable<z.ZodString>;
|
|
48
|
+
country: z.ZodNullable<z.ZodString>;
|
|
49
|
+
zip: z.ZodNullable<z.ZodString>;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
lastName: string | null;
|
|
52
|
+
firstName: string | null;
|
|
53
|
+
address1: string | null;
|
|
54
|
+
address2: string | null;
|
|
55
|
+
city: string | null;
|
|
56
|
+
province: string | null;
|
|
57
|
+
country: string | null;
|
|
58
|
+
zip: string | null;
|
|
59
|
+
}, {
|
|
60
|
+
lastName: string | null;
|
|
61
|
+
firstName: string | null;
|
|
62
|
+
address1: string | null;
|
|
63
|
+
address2: string | null;
|
|
64
|
+
city: string | null;
|
|
65
|
+
province: string | null;
|
|
66
|
+
country: string | null;
|
|
67
|
+
zip: string | null;
|
|
68
|
+
}>>;
|
|
69
|
+
}, "strip", z.ZodTypeAny, {
|
|
70
|
+
id: string;
|
|
71
|
+
createdAt: string;
|
|
72
|
+
updatedAt: string;
|
|
73
|
+
name: string;
|
|
74
|
+
cancelledAt: string | null;
|
|
75
|
+
cancelReason: string | null;
|
|
76
|
+
customer: {
|
|
77
|
+
id: string;
|
|
78
|
+
displayName: string;
|
|
79
|
+
lastName: string | null;
|
|
80
|
+
firstName: string | null;
|
|
81
|
+
emailAddress: string | null;
|
|
82
|
+
} | null;
|
|
83
|
+
shippingAddress: {
|
|
84
|
+
lastName: string | null;
|
|
85
|
+
firstName: string | null;
|
|
86
|
+
address1: string | null;
|
|
87
|
+
address2: string | null;
|
|
88
|
+
city: string | null;
|
|
89
|
+
province: string | null;
|
|
90
|
+
country: string | null;
|
|
91
|
+
zip: string | null;
|
|
92
|
+
} | null;
|
|
93
|
+
totalPrice: {
|
|
94
|
+
currencyCode: string;
|
|
95
|
+
amount: string;
|
|
96
|
+
};
|
|
97
|
+
fulfillmentStatus: string | null;
|
|
98
|
+
financialStatus: string | null;
|
|
99
|
+
}, {
|
|
100
|
+
id: string;
|
|
101
|
+
createdAt: string;
|
|
102
|
+
updatedAt: string;
|
|
103
|
+
name: string;
|
|
104
|
+
cancelledAt: string | null;
|
|
105
|
+
cancelReason: string | null;
|
|
106
|
+
customer: {
|
|
107
|
+
id: string;
|
|
108
|
+
displayName: string;
|
|
109
|
+
lastName: string | null;
|
|
110
|
+
firstName: string | null;
|
|
111
|
+
emailAddress: string | null;
|
|
112
|
+
} | null;
|
|
113
|
+
shippingAddress: {
|
|
114
|
+
lastName: string | null;
|
|
115
|
+
firstName: string | null;
|
|
116
|
+
address1: string | null;
|
|
117
|
+
address2: string | null;
|
|
118
|
+
city: string | null;
|
|
119
|
+
province: string | null;
|
|
120
|
+
country: string | null;
|
|
121
|
+
zip: string | null;
|
|
122
|
+
} | null;
|
|
123
|
+
totalPrice: {
|
|
124
|
+
currencyCode: string;
|
|
125
|
+
amount: string;
|
|
126
|
+
};
|
|
127
|
+
fulfillmentStatus: string | null;
|
|
128
|
+
financialStatus: string | null;
|
|
129
|
+
}>>;
|
|
130
|
+
export type LeanOrder = z.infer<typeof GetLeanOrderByIdReturn>;
|
|
131
|
+
export type FullOrder = NonNullable<OrderByIdFullQuery['order']> | null;
|
|
132
|
+
export declare function getOrderById(id: bigint): Promise<LeanOrder>;
|
|
133
|
+
export declare function getOrderById(id: bigint, detailLevel: 'lean'): Promise<LeanOrder>;
|
|
134
|
+
export declare function getOrderById(id: bigint, detailLevel: 'full'): Promise<FullOrder>;
|
|
135
|
+
export {};
|
|
136
|
+
//# sourceMappingURL=getOrderById.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderById.d.ts","sourceRoot":"","sources":["../../../src/queries/orders/getOrderById.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AACnB,OAAO,KAAK,EACV,kBAAkB,EAGnB,MAAM,sDAAsD,CAAA;AAwB7D,QAAA,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyBf,CAAA;AAEb,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAG9D,MAAM,MAAM,SAAS,GAAG,WAAW,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAA;AAKvE,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAC5D,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,SAAS,CAAC,CAAA;AACrB,wBAAgB,YAAY,CAC1B,EAAE,EAAE,MAAM,EACV,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,SAAS,CAAC,CAAA"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { logger } from '../../utils/logger.js';
|
|
3
|
+
import { convertIdIntoGid, fetchShopifyGraphql, } from '../../utils/shopifyFetch.js';
|
|
4
|
+
import { returnOutputParsed } from '../../utils/zod.js';
|
|
5
|
+
import { queryOrderById, queryOrderByIdFull } from './getOrderById.queries.js';
|
|
6
|
+
// Address schema (shared between lean and full)
|
|
7
|
+
const AddressSchema = z
|
|
8
|
+
.object({
|
|
9
|
+
firstName: z.string().nullable(),
|
|
10
|
+
lastName: z.string().nullable(),
|
|
11
|
+
address1: z.string().nullable(),
|
|
12
|
+
address2: z.string().nullable(),
|
|
13
|
+
city: z.string().nullable(),
|
|
14
|
+
province: z.string().nullable(),
|
|
15
|
+
country: z.string().nullable(),
|
|
16
|
+
zip: z.string().nullable(),
|
|
17
|
+
})
|
|
18
|
+
.nullable();
|
|
19
|
+
// Lean order schema
|
|
20
|
+
const GetLeanOrderByIdReturn = z
|
|
21
|
+
.object({
|
|
22
|
+
id: z.string(),
|
|
23
|
+
name: z.string(),
|
|
24
|
+
createdAt: z.string(),
|
|
25
|
+
updatedAt: z.string(),
|
|
26
|
+
cancelledAt: z.string().nullable(),
|
|
27
|
+
cancelReason: z.string().nullable(),
|
|
28
|
+
totalPrice: z.object({
|
|
29
|
+
amount: z.string(),
|
|
30
|
+
currencyCode: z.string(),
|
|
31
|
+
}),
|
|
32
|
+
customer: z
|
|
33
|
+
.object({
|
|
34
|
+
id: z.string(),
|
|
35
|
+
displayName: z.string(),
|
|
36
|
+
firstName: z.string().nullable(),
|
|
37
|
+
lastName: z.string().nullable(),
|
|
38
|
+
emailAddress: z.string().nullable(),
|
|
39
|
+
})
|
|
40
|
+
.nullable(),
|
|
41
|
+
financialStatus: z.string().nullable(),
|
|
42
|
+
fulfillmentStatus: z.string().nullable(),
|
|
43
|
+
shippingAddress: AddressSchema,
|
|
44
|
+
})
|
|
45
|
+
.nullable();
|
|
46
|
+
/**
|
|
47
|
+
* Retrieves a single order from Shopify by its numeric ID.
|
|
48
|
+
* Returns null if no order is found with the specified ID.
|
|
49
|
+
*
|
|
50
|
+
* @param {bigint} id - The numerical Shopify order ID (e.g., 12345678n).
|
|
51
|
+
* @param {OrderDetailLevel} detailLevel - The level of detail to return ('lean' or 'full'). Defaults to 'lean'.
|
|
52
|
+
* @returns {Promise<LeanOrder | FullOrder>} A promise that resolves to the order data or null if not found.
|
|
53
|
+
* @throws {Error} If the GraphQL query fails or if the response structure is invalid.
|
|
54
|
+
*/
|
|
55
|
+
export async function getOrderById(id, detailLevel = 'lean') {
|
|
56
|
+
if (detailLevel === 'lean') {
|
|
57
|
+
return getLeanOrderById(id);
|
|
58
|
+
}
|
|
59
|
+
return getFullOrderById(id);
|
|
60
|
+
}
|
|
61
|
+
async function getLeanOrderById(id) {
|
|
62
|
+
const variables = {
|
|
63
|
+
id: convertIdIntoGid(id, 'Order'),
|
|
64
|
+
};
|
|
65
|
+
const response = await fetchShopifyGraphql({
|
|
66
|
+
query: queryOrderById,
|
|
67
|
+
variables,
|
|
68
|
+
});
|
|
69
|
+
if (!response.order) {
|
|
70
|
+
logger.debug(`No order found with ID: ${id}`);
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const order = response.order;
|
|
74
|
+
const leanOrder = {
|
|
75
|
+
id: order.id,
|
|
76
|
+
name: order.name,
|
|
77
|
+
createdAt: order.createdAt,
|
|
78
|
+
updatedAt: order.updatedAt,
|
|
79
|
+
cancelledAt: order.cancelledAt ?? null,
|
|
80
|
+
cancelReason: order.cancelReason ?? null,
|
|
81
|
+
totalPrice: {
|
|
82
|
+
amount: order.totalPriceSet?.shopMoney?.amount ?? '',
|
|
83
|
+
currencyCode: order.totalPriceSet?.shopMoney?.currencyCode ?? '',
|
|
84
|
+
},
|
|
85
|
+
customer: order.customer
|
|
86
|
+
? {
|
|
87
|
+
id: order.customer.id,
|
|
88
|
+
displayName: order.customer.displayName,
|
|
89
|
+
firstName: order.customer.firstName ?? null,
|
|
90
|
+
lastName: order.customer.lastName ?? null,
|
|
91
|
+
emailAddress: order.customer.defaultEmailAddress?.emailAddress ?? null,
|
|
92
|
+
}
|
|
93
|
+
: null,
|
|
94
|
+
financialStatus: order.displayFinancialStatus ?? null,
|
|
95
|
+
fulfillmentStatus: order.displayFulfillmentStatus ?? null,
|
|
96
|
+
shippingAddress: order.shippingAddress
|
|
97
|
+
? {
|
|
98
|
+
firstName: order.shippingAddress.firstName ?? null,
|
|
99
|
+
lastName: order.shippingAddress.lastName ?? null,
|
|
100
|
+
address1: order.shippingAddress.address1 ?? null,
|
|
101
|
+
address2: order.shippingAddress.address2 ?? null,
|
|
102
|
+
city: order.shippingAddress.city ?? null,
|
|
103
|
+
province: order.shippingAddress.province ?? null,
|
|
104
|
+
country: order.shippingAddress.country ?? null,
|
|
105
|
+
zip: order.shippingAddress.zip ?? null,
|
|
106
|
+
}
|
|
107
|
+
: null,
|
|
108
|
+
};
|
|
109
|
+
return await returnOutputParsed(leanOrder, GetLeanOrderByIdReturn);
|
|
110
|
+
}
|
|
111
|
+
async function getFullOrderById(id) {
|
|
112
|
+
const variables = {
|
|
113
|
+
id: convertIdIntoGid(id, 'Order'),
|
|
114
|
+
};
|
|
115
|
+
const response = await fetchShopifyGraphql({
|
|
116
|
+
query: queryOrderByIdFull,
|
|
117
|
+
variables,
|
|
118
|
+
});
|
|
119
|
+
if (!response.order) {
|
|
120
|
+
logger.debug(`No order found with ID: ${id}`);
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
return response.order;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=getOrderById.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderById.js","sourceRoot":"","sources":["../../../src/queries/orders/getOrderById.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAMnB,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,GACpB,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AAe,CAAC,IAAI,IAAI,IAAI;gBACxC,QAAQ,EAAE,KAAK,CAAC,eAAe,CAAC,QAAQ,IAAI,IAAI;gBAChD,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,OAAO,IAAI,IAAI;gBAC9C,GAAG,EAAE,KAAK,CAAC,eAAe,CAAC,GAAG,IAAI,IAAI;aACvC;YACH,CAAC,CAAC,IAAI;KACT,CAAA;IAED,OAAO,MAAM,kBAAkB,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAA;AACpE,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,EAAU;IACxC,MAAM,SAAS,GAA4B;QACzC,EAAE,EAAE,gBAAgB,CAAC,EAAE,EAAE,OAAO,CAAC;KAClC,CAAA;IAED,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAqB;QAC7D,KAAK,EAAE,kBAAkB;QACzB,SAAS;KACV,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACpB,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAA;QAC7C,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,QAAQ,CAAC,KAAK,CAAA;AACvB,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { OrderByIdFullQuery, OrderByIdQuery } from '../../generated-api-types/2025-04/admin.generated';
|
|
2
|
+
export declare const orderByIdMock: OrderByIdQuery;
|
|
3
|
+
export declare const expectedLeanOrderById: {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
createdAt: string;
|
|
7
|
+
updatedAt: string;
|
|
8
|
+
cancelledAt: null;
|
|
9
|
+
cancelReason: null;
|
|
10
|
+
totalPrice: {
|
|
11
|
+
amount: string;
|
|
12
|
+
currencyCode: string;
|
|
13
|
+
};
|
|
14
|
+
customer: {
|
|
15
|
+
id: string;
|
|
16
|
+
displayName: string;
|
|
17
|
+
firstName: string;
|
|
18
|
+
lastName: string;
|
|
19
|
+
emailAddress: string;
|
|
20
|
+
};
|
|
21
|
+
financialStatus: string;
|
|
22
|
+
fulfillmentStatus: string;
|
|
23
|
+
shippingAddress: {
|
|
24
|
+
firstName: string;
|
|
25
|
+
lastName: string;
|
|
26
|
+
address1: string;
|
|
27
|
+
address2: string;
|
|
28
|
+
city: string;
|
|
29
|
+
province: string;
|
|
30
|
+
country: string;
|
|
31
|
+
zip: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export declare const orderByIdFullMock: OrderByIdFullQuery;
|
|
35
|
+
export declare const expectedFullOrderById: import("../../generated-api-types/2025-04/admin.types").Maybe<Pick<import("../../generated-api-types/2025-04/admin.types").Order, "id" | "createdAt" | "updatedAt" | "name" | "cancelledAt" | "cancelReason" | "displayFinancialStatus" | "displayFulfillmentStatus" | "closedAt" | "discountCodes" | "processedAt"> & {
|
|
36
|
+
totalPriceSet: {
|
|
37
|
+
shopMoney: Pick<import("../../generated-api-types/2025-04/admin.types").MoneyV2, "amount" | "currencyCode">;
|
|
38
|
+
};
|
|
39
|
+
customer?: import("../../generated-api-types/2025-04/admin.types").Maybe<Pick<import("../../generated-api-types/2025-04/admin.types").Customer, "id" | "firstName" | "lastName" | "email" | "phone">>;
|
|
40
|
+
shippingAddress?: import("../../generated-api-types/2025-04/admin.types").Maybe<Pick<import("../../generated-api-types/2025-04/admin.types").MailingAddress, "firstName" | "lastName" | "address1" | "address2" | "city" | "province" | "country" | "zip">>;
|
|
41
|
+
billingAddress?: import("../../generated-api-types/2025-04/admin.types").Maybe<Pick<import("../../generated-api-types/2025-04/admin.types").MailingAddress, "firstName" | "lastName" | "address1" | "address2" | "city" | "province" | "country" | "zip">>;
|
|
42
|
+
lineItems: {
|
|
43
|
+
edges: Array<{
|
|
44
|
+
node: (Pick<import("../../generated-api-types/2025-04/admin.types").LineItem, "id" | "sku" | "title" | "variantTitle" | "quantity" | "vendor"> & {
|
|
45
|
+
customAttributes: Array<Pick<import("../../generated-api-types/2025-04/admin.types").Attribute, "key" | "value">>;
|
|
46
|
+
originalUnitPriceSet: {
|
|
47
|
+
shopMoney: Pick<import("../../generated-api-types/2025-04/admin.types").MoneyV2, "amount" | "currencyCode">;
|
|
48
|
+
};
|
|
49
|
+
image?: import("../../generated-api-types/2025-04/admin.types").Maybe<Pick<import("../../generated-api-types/2025-04/admin.types").Image, "url" | "width" | "height" | "altText">>;
|
|
50
|
+
});
|
|
51
|
+
}>;
|
|
52
|
+
};
|
|
53
|
+
fulfillments: Array<(Pick<import("../../generated-api-types/2025-04/admin.types").Fulfillment, "id" | "name" | "totalQuantity" | "status" | "createdAt" | "estimatedDeliveryAt" | "deliveredAt"> & {
|
|
54
|
+
trackingInfo: Array<Pick<import("../../generated-api-types/2025-04/admin.types").FulfillmentTrackingInfo, "company" | "number" | "url">>;
|
|
55
|
+
fulfillmentLineItems: {
|
|
56
|
+
edges: Array<{
|
|
57
|
+
node: (Pick<import("../../generated-api-types/2025-04/admin.types").FulfillmentLineItem, "id" | "quantity"> & {
|
|
58
|
+
lineItem: Pick<import("../../generated-api-types/2025-04/admin.types").LineItem, "id">;
|
|
59
|
+
});
|
|
60
|
+
}>;
|
|
61
|
+
};
|
|
62
|
+
})>;
|
|
63
|
+
shippingLine?: import("../../generated-api-types/2025-04/admin.types").Maybe<{
|
|
64
|
+
originalPriceSet: {
|
|
65
|
+
shopMoney: Pick<import("../../generated-api-types/2025-04/admin.types").MoneyV2, "amount" | "currencyCode">;
|
|
66
|
+
};
|
|
67
|
+
}>;
|
|
68
|
+
taxLines: Array<{
|
|
69
|
+
priceSet: {
|
|
70
|
+
shopMoney: Pick<import("../../generated-api-types/2025-04/admin.types").MoneyV2, "amount" | "currencyCode">;
|
|
71
|
+
};
|
|
72
|
+
}>;
|
|
73
|
+
totalDiscountsSet?: import("../../generated-api-types/2025-04/admin.types").Maybe<{
|
|
74
|
+
shopMoney: Pick<import("../../generated-api-types/2025-04/admin.types").MoneyV2, "amount" | "currencyCode">;
|
|
75
|
+
}>;
|
|
76
|
+
refunds: Array<{
|
|
77
|
+
totalRefundedSet: {
|
|
78
|
+
shopMoney: Pick<import("../../generated-api-types/2025-04/admin.types").MoneyV2, "amount" | "currencyCode">;
|
|
79
|
+
};
|
|
80
|
+
}>;
|
|
81
|
+
}> | undefined;
|
|
82
|
+
//# sourceMappingURL=getOrderById.mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderById.mock.d.ts","sourceRoot":"","sources":["../../../src/queries/orders/getOrderById.mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,cAAc,EACf,MAAM,mDAAmD,CAAA;AAS1D,eAAO,MAAM,aAAa,EAAE,cAoC3B,CAAA;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8BjC,CAAA;AAGD,eAAO,MAAM,iBAAiB,EAAE,kBAkI/B,CAAA;AAED,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;qBA9F5B,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA8FsD,CAAA"}
|