@ehrenkind/shopify-lib 0.2.0 → 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/generated-api-types/2025-04/admin.generated.d.ts +2 -2
- 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 +12 -11
- package/dist/generated-api-types/2025-04/admin.types.d.ts.map +1 -1
- package/dist/generated-api-types/2025-04/admin.types.js +3 -3
- package/dist/generated-api-types/2025-04/admin.types.js.map +1 -1
- package/dist/index.cjs +16 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -8
- package/dist/index.mjs.map +1 -1
- package/dist/queries/orders/getOrderById.d.ts +4 -4
- package/dist/queries/orders/getOrderById.d.ts.map +1 -1
- package/dist/queries/orders/getOrderById.js +4 -3
- package/dist/queries/orders/getOrderById.js.map +1 -1
- package/dist/queries/orders/getOrderById.mock.d.ts +1 -1
- package/dist/queries/orders/getOrderById.mock.d.ts.map +1 -1
- package/dist/queries/orders/getOrderById.mock.js +1 -0
- package/dist/queries/orders/getOrderById.mock.js.map +1 -1
- package/dist/queries/orders/getOrderById.queries.d.ts.map +1 -1
- package/dist/queries/orders/getOrderById.queries.js +1 -0
- package/dist/queries/orders/getOrderById.queries.js.map +1 -1
- package/dist/utils/parseGid.d.ts +9 -0
- package/dist/utils/parseGid.d.ts.map +1 -0
- package/dist/utils/parseGid.js +12 -0
- package/dist/utils/parseGid.js.map +1 -0
- package/dist/utils/parseGid.test.d.ts +2 -0
- package/dist/utils/parseGid.test.d.ts.map +1 -0
- package/dist/utils/parseGid.test.js +26 -0
- package/dist/utils/parseGid.test.js.map +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -34,7 +34,8 @@ __export(index_exports, {
|
|
|
34
34
|
getLeanProductVariants: () => getLeanProductVariants,
|
|
35
35
|
getOrderById: () => getOrderById,
|
|
36
36
|
getOrderByName: () => getOrderByName,
|
|
37
|
-
getOrderPaymentDetailsById: () => getOrderPaymentDetailsById
|
|
37
|
+
getOrderPaymentDetailsById: () => getOrderPaymentDetailsById,
|
|
38
|
+
parseGid: () => parseGid
|
|
38
39
|
});
|
|
39
40
|
module.exports = __toCommonJS(index_exports);
|
|
40
41
|
|
|
@@ -341,12 +342,9 @@ var queryOrderByIdFull = gql`#graphql
|
|
|
341
342
|
}
|
|
342
343
|
customer {
|
|
343
344
|
id
|
|
344
|
-
lastName
|
|
345
|
-
defaultEmailAddress {
|
|
346
|
-
emailAddress
|
|
347
|
-
}
|
|
348
|
-
displayName
|
|
349
345
|
firstName
|
|
346
|
+
lastName
|
|
347
|
+
email
|
|
350
348
|
phone
|
|
351
349
|
}
|
|
352
350
|
displayFinancialStatus
|
|
@@ -419,6 +417,7 @@ var queryOrderByIdFull = gql`#graphql
|
|
|
419
417
|
quantity
|
|
420
418
|
lineItem {
|
|
421
419
|
id
|
|
420
|
+
sku
|
|
422
421
|
}
|
|
423
422
|
}
|
|
424
423
|
}
|
|
@@ -493,10 +492,11 @@ var GetLeanOrderByIdReturn = import_zod5.default.object({
|
|
|
493
492
|
shippingAddress: AddressSchema
|
|
494
493
|
}).nullable();
|
|
495
494
|
async function getOrderById(id, detailLevel = "lean") {
|
|
495
|
+
const bigIntId = typeof id === "number" ? BigInt(id) : id;
|
|
496
496
|
if (detailLevel === "lean") {
|
|
497
|
-
return getLeanOrderById(
|
|
497
|
+
return getLeanOrderById(bigIntId);
|
|
498
498
|
}
|
|
499
|
-
return getFullOrderById(
|
|
499
|
+
return getFullOrderById(bigIntId);
|
|
500
500
|
}
|
|
501
501
|
async function getLeanOrderById(id) {
|
|
502
502
|
const variables = {
|
|
@@ -1137,12 +1137,19 @@ async function getOrderPaymentDetailsById(id) {
|
|
|
1137
1137
|
}
|
|
1138
1138
|
return await returnOutputParsed(response, GetOrderPaymentDetailsByIdReturn);
|
|
1139
1139
|
}
|
|
1140
|
+
|
|
1141
|
+
// src/utils/parseGid.ts
|
|
1142
|
+
function parseGid(gid) {
|
|
1143
|
+
const match = gid.match(/\d+$/);
|
|
1144
|
+
return match ? Number.parseInt(match[0], 10) : 0;
|
|
1145
|
+
}
|
|
1140
1146
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1141
1147
|
0 && (module.exports = {
|
|
1142
1148
|
deleteCustomerById,
|
|
1143
1149
|
getLeanProductVariants,
|
|
1144
1150
|
getOrderById,
|
|
1145
1151
|
getOrderByName,
|
|
1146
|
-
getOrderPaymentDetailsById
|
|
1152
|
+
getOrderPaymentDetailsById,
|
|
1153
|
+
parseGid
|
|
1147
1154
|
});
|
|
1148
1155
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -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"],"sourcesContent":["export { deleteCustomerById } from './mutations/customers/deleteCustomerById.js'\nexport {\n getOrderById,\n type FullOrder,\n type LeanOrder,\n} from './queries/orders/getOrderById.js'\nexport { getOrderByName } from './queries/orders/getOrderByName.js'\nexport { getLeanProductVariants } from './queries/productVariants/getLeanProductVariants.js'\nexport { getOrderPaymentDetailsById } from './queries/orders/getOrderPaymentDetails.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: 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;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,OAAO,IAAI,SAAoB;AAC7B,QAAI,UAAU,SAAS,qBAAqB;AAE1C,cAAQ,MAAM,GAAG,IAA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,cAAc,aAAAA,QAAE;AAAA,MACd,aAAAA,QAAE,OAAO;AAAA,QACP,WAAW,aAAAA,QAAE,OAAO;AAAA,UAClB,WAAW,aAAAA,QAAE,OAAO;AAAA,YAClB,QAAQ,aAAAA,QAAE,OAAO;AAAA,YACjB,cAAc,aAAAA,QAAE,OAAO;AAAA,UACzB,CAAC;AAAA,QACH,CAAC;AAAA,QACD,WAAW,aAAAA,QAAE,OAAO;AAAA,QACpB,SAAS,aAAAA,QAAE,OAAO;AAAA,QAClB,kBAAkB,aAAAA,QAAE,OAAO;AAAA,QAC3B,MAAM,aAAAA,QAAE,OAAO;AAAA,QACf,WAAW,aAAAA,QAAE,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":["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;AACzE,IAAM,s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B,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
|
-
/**
|
|
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
|
-
/**
|
|
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
|
|
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",
|
|
@@ -18539,9 +18539,7 @@ type OrderByIdFullQuery = {
|
|
|
18539
18539
|
totalPriceSet: {
|
|
18540
18540
|
shopMoney: Pick<MoneyV2, 'amount' | 'currencyCode'>;
|
|
18541
18541
|
};
|
|
18542
|
-
customer?: Maybe<
|
|
18543
|
-
defaultEmailAddress?: Maybe<Pick<CustomerEmailAddress, 'emailAddress'>>;
|
|
18544
|
-
})>;
|
|
18542
|
+
customer?: Maybe<Pick<Customer, 'id' | 'firstName' | 'lastName' | 'email' | 'phone'>>;
|
|
18545
18543
|
shippingAddress?: Maybe<Pick<MailingAddress, 'firstName' | 'lastName' | 'address1' | 'address2' | 'city' | 'province' | 'country' | 'zip'>>;
|
|
18546
18544
|
billingAddress?: Maybe<Pick<MailingAddress, 'firstName' | 'lastName' | 'address1' | 'address2' | 'city' | 'province' | 'country' | 'zip'>>;
|
|
18547
18545
|
lineItems: {
|
|
@@ -18560,7 +18558,7 @@ type OrderByIdFullQuery = {
|
|
|
18560
18558
|
fulfillmentLineItems: {
|
|
18561
18559
|
edges: Array<{
|
|
18562
18560
|
node: (Pick<FulfillmentLineItem, 'id' | 'quantity'> & {
|
|
18563
|
-
lineItem: Pick<LineItem, 'id'>;
|
|
18561
|
+
lineItem: Pick<LineItem, 'id' | 'sku'>;
|
|
18564
18562
|
});
|
|
18565
18563
|
}>;
|
|
18566
18564
|
};
|
|
@@ -18737,7 +18735,7 @@ interface GeneratedQueryTypes {
|
|
|
18737
18735
|
return: OrderByIdQuery;
|
|
18738
18736
|
variables: OrderByIdQueryVariables;
|
|
18739
18737
|
};
|
|
18740
|
-
"#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
|
|
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": {
|
|
18741
18739
|
return: OrderByIdFullQuery;
|
|
18742
18740
|
variables: OrderByIdFullQueryVariables;
|
|
18743
18741
|
};
|
|
@@ -18908,10 +18906,10 @@ declare const GetLeanOrderByIdReturn: z.ZodNullable<z.ZodObject<{
|
|
|
18908
18906
|
financialStatus: string | null;
|
|
18909
18907
|
}>>;
|
|
18910
18908
|
type LeanOrder = z.infer<typeof GetLeanOrderByIdReturn>;
|
|
18911
|
-
type FullOrder = NonNullable<OrderByIdFullQuery['order']
|
|
18912
|
-
declare function getOrderById(id: bigint): Promise<LeanOrder>;
|
|
18913
|
-
declare function getOrderById(id: bigint, detailLevel: 'lean'): Promise<LeanOrder>;
|
|
18914
|
-
declare function getOrderById(id: bigint, detailLevel: 'full'): Promise<FullOrder>;
|
|
18909
|
+
type FullOrder = NonNullable<OrderByIdFullQuery['order']>;
|
|
18910
|
+
declare function getOrderById(id: number | bigint): Promise<LeanOrder>;
|
|
18911
|
+
declare function getOrderById(id: number | bigint, detailLevel: 'lean'): Promise<LeanOrder>;
|
|
18912
|
+
declare function getOrderById(id: number | bigint, detailLevel: 'full'): Promise<FullOrder | null>;
|
|
18915
18913
|
|
|
18916
18914
|
declare const GetLeanOrderByNameReturn: z.ZodNullable<z.ZodObject<{
|
|
18917
18915
|
id: z.ZodString;
|
|
@@ -18976,11 +18974,11 @@ declare const GetLeanOrderByNameReturn: z.ZodNullable<z.ZodObject<{
|
|
|
18976
18974
|
fulfillmentStatus: string | null;
|
|
18977
18975
|
financialStatus: string | null;
|
|
18978
18976
|
}>>;
|
|
18979
|
-
type
|
|
18980
|
-
type
|
|
18981
|
-
declare function getOrderByName(orderName: string, detailLevel: 'lean'): Promise<
|
|
18982
|
-
declare function getOrderByName(orderName: string, detailLevel: 'full'): Promise<
|
|
18983
|
-
declare function getOrderByName(orderName: string): Promise<
|
|
18977
|
+
type LeanOrderByName = z.infer<typeof GetLeanOrderByNameReturn>;
|
|
18978
|
+
type FullOrderByName = NonNullable<NonNullable<OrdersByNameFullQuery['orders']>['edges'][number]['node']> | null;
|
|
18979
|
+
declare function getOrderByName(orderName: string, detailLevel: 'lean'): Promise<LeanOrderByName>;
|
|
18980
|
+
declare function getOrderByName(orderName: string, detailLevel: 'full'): Promise<FullOrderByName>;
|
|
18981
|
+
declare function getOrderByName(orderName: string): Promise<LeanOrderByName>;
|
|
18984
18982
|
|
|
18985
18983
|
declare const GetLeanProductVariantsReturn: z.ZodArray<z.ZodObject<{
|
|
18986
18984
|
productId: z.ZodString;
|
|
@@ -19141,4 +19139,13 @@ type GetOrderPaymentDetailsByIdReturnType = z.infer<typeof GetOrderPaymentDetail
|
|
|
19141
19139
|
*/
|
|
19142
19140
|
declare function getOrderPaymentDetailsById(id: bigint): Promise<GetOrderPaymentDetailsByIdReturnType | null>;
|
|
19143
19141
|
|
|
19144
|
-
|
|
19142
|
+
/**
|
|
19143
|
+
* Extract numeric ID from a Shopify GID string.
|
|
19144
|
+
*
|
|
19145
|
+
* @example
|
|
19146
|
+
* parseGid('gid://shopify/Order/12345678901234') // → 12345678901234
|
|
19147
|
+
* parseGid('gid://shopify/LineItem/999') // → 999
|
|
19148
|
+
*/
|
|
19149
|
+
declare function parseGid(gid: string): number;
|
|
19150
|
+
|
|
19151
|
+
export { type FullOrder, type FullOrderByName, type LeanOrder, type LeanOrderByName, deleteCustomerById, getLeanProductVariants, getOrderById, getOrderByName, getOrderPaymentDetailsById, parseGid };
|
package/dist/index.d.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { getOrderById, type FullOrder, type LeanOrder, } from './queries/orders/
|
|
|
3
3
|
export { getOrderByName, type FullOrderByName, type LeanOrderByName, } from './queries/orders/getOrderByName.js';
|
|
4
4
|
export { getLeanProductVariants } from './queries/productVariants/getLeanProductVariants.js';
|
|
5
5
|
export { getOrderPaymentDetailsById } from './queries/orders/getOrderPaymentDetails.js';
|
|
6
|
+
export { parseGid } from './utils/parseGid.js';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAChF,OAAO,EACL,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,SAAS,GACf,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAA;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAChF,OAAO,EACL,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,SAAS,GACf,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,GACrB,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAA;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAA;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { getOrderById, } from './queries/orders/getOrderById.js';
|
|
|
3
3
|
export { getOrderByName, } from './queries/orders/getOrderByName.js';
|
|
4
4
|
export { getLeanProductVariants } from './queries/productVariants/getLeanProductVariants.js';
|
|
5
5
|
export { getOrderPaymentDetailsById } from './queries/orders/getOrderPaymentDetails.js';
|
|
6
|
+
export { parseGid } from './utils/parseGid.js';
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAChF,OAAO,EACL,YAAY,GAGb,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,cAAc,GAGf,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAA;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAA;AAChF,OAAO,EACL,YAAY,GAGb,MAAM,kCAAkC,CAAA;AACzC,OAAO,EACL,cAAc,GAGf,MAAM,oCAAoC,CAAA;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,qDAAqD,CAAA;AAC5F,OAAO,EAAE,0BAA0B,EAAE,MAAM,4CAA4C,CAAA;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -306,12 +306,9 @@ var queryOrderByIdFull = gql`#graphql
|
|
|
306
306
|
}
|
|
307
307
|
customer {
|
|
308
308
|
id
|
|
309
|
-
lastName
|
|
310
|
-
defaultEmailAddress {
|
|
311
|
-
emailAddress
|
|
312
|
-
}
|
|
313
|
-
displayName
|
|
314
309
|
firstName
|
|
310
|
+
lastName
|
|
311
|
+
email
|
|
315
312
|
phone
|
|
316
313
|
}
|
|
317
314
|
displayFinancialStatus
|
|
@@ -384,6 +381,7 @@ var queryOrderByIdFull = gql`#graphql
|
|
|
384
381
|
quantity
|
|
385
382
|
lineItem {
|
|
386
383
|
id
|
|
384
|
+
sku
|
|
387
385
|
}
|
|
388
386
|
}
|
|
389
387
|
}
|
|
@@ -458,10 +456,11 @@ var GetLeanOrderByIdReturn = z4.object({
|
|
|
458
456
|
shippingAddress: AddressSchema
|
|
459
457
|
}).nullable();
|
|
460
458
|
async function getOrderById(id, detailLevel = "lean") {
|
|
459
|
+
const bigIntId = typeof id === "number" ? BigInt(id) : id;
|
|
461
460
|
if (detailLevel === "lean") {
|
|
462
|
-
return getLeanOrderById(
|
|
461
|
+
return getLeanOrderById(bigIntId);
|
|
463
462
|
}
|
|
464
|
-
return getFullOrderById(
|
|
463
|
+
return getFullOrderById(bigIntId);
|
|
465
464
|
}
|
|
466
465
|
async function getLeanOrderById(id) {
|
|
467
466
|
const variables = {
|
|
@@ -1102,11 +1101,18 @@ async function getOrderPaymentDetailsById(id) {
|
|
|
1102
1101
|
}
|
|
1103
1102
|
return await returnOutputParsed(response, GetOrderPaymentDetailsByIdReturn);
|
|
1104
1103
|
}
|
|
1104
|
+
|
|
1105
|
+
// src/utils/parseGid.ts
|
|
1106
|
+
function parseGid(gid) {
|
|
1107
|
+
const match = gid.match(/\d+$/);
|
|
1108
|
+
return match ? Number.parseInt(match[0], 10) : 0;
|
|
1109
|
+
}
|
|
1105
1110
|
export {
|
|
1106
1111
|
deleteCustomerById,
|
|
1107
1112
|
getLeanProductVariants,
|
|
1108
1113
|
getOrderById,
|
|
1109
1114
|
getOrderByName,
|
|
1110
|
-
getOrderPaymentDetailsById
|
|
1115
|
+
getOrderPaymentDetailsById,
|
|
1116
|
+
parseGid
|
|
1111
1117
|
};
|
|
1112
1118
|
//# sourceMappingURL=index.mjs.map
|