@atomic-solutions/woocommerce-api-client 0.1.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/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/client/index.d.mts +9 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +1461 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/index.mjs +1455 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/http/index.d.mts +11 -0
- package/dist/http/index.d.ts +11 -0
- package/dist/http/index.js +638 -0
- package/dist/http/index.js.map +1 -0
- package/dist/http/index.mjs +631 -0
- package/dist/http/index.mjs.map +1 -0
- package/dist/index.d.mts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +2152 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2105 -0
- package/dist/index.mjs.map +1 -0
- package/dist/pagination.schema-CdjWGZJr.d.mts +190 -0
- package/dist/pagination.schema-CdjWGZJr.d.ts +190 -0
- package/dist/products-Cxl54crz.d.mts +3412 -0
- package/dist/products-Cxl54crz.d.ts +3412 -0
- package/dist/schemas/admin-api/index.d.mts +5340 -0
- package/dist/schemas/admin-api/index.d.ts +5340 -0
- package/dist/schemas/admin-api/index.js +584 -0
- package/dist/schemas/admin-api/index.js.map +1 -0
- package/dist/schemas/admin-api/index.mjs +545 -0
- package/dist/schemas/admin-api/index.mjs.map +1 -0
- package/dist/schemas/index.d.mts +4 -0
- package/dist/schemas/index.d.ts +4 -0
- package/dist/schemas/index.js +887 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/schemas/index.mjs +844 -0
- package/dist/schemas/index.mjs.map +1 -0
- package/dist/schemas/store-api/index.d.mts +1076 -0
- package/dist/schemas/store-api/index.d.ts +1076 -0
- package/dist/schemas/store-api/index.js +887 -0
- package/dist/schemas/store-api/index.js.map +1 -0
- package/dist/schemas/store-api/index.mjs +844 -0
- package/dist/schemas/store-api/index.mjs.map +1 -0
- package/dist/types-B-zy1xrP.d.mts +183 -0
- package/dist/types-qKWtrw7A.d.ts +183 -0
- package/dist/utils/index.d.mts +17 -0
- package/dist/utils/index.d.ts +17 -0
- package/dist/utils/index.js +316 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +308 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +117 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/errors/classes/BaseError.ts","../../src/errors/mapping/mapWooCommerceCode.ts","../../src/errors/mapping/constants.ts","../../src/errors/classes/WooCommerceApiError.ts","../../src/errors/classes/WooCommerceDataValidationError.ts","../../src/http/handleApiResponse.ts","../../src/utils/calculatePagination.ts","../../src/utils/getPaginationMeta.ts","../../src/http/handlePaginatedApiResponse.ts","../../src/logging/logger.ts","../../src/http/interceptors/request.ts","../../src/http/interceptors/response.ts","../../src/utils/initializeCartSession.ts","../../src/http/interceptors/error.ts"],"names":["error"],"mappings":";;;AASO,IAAM,SAAA,GAAN,cAGG,KAAA,CAAM;AAAA,EACd,YAA4B,OAAA,EAAmB;AAC7C,IAAA,KAAA,CAAM,QAAQ,OAAO,CAAA;AADK,IAAA,IAAA,CAAA,OAAA,GAAA,OAAA;AAI1B,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,GAAA,CAAA,MAAA,CAAW,SAAS,CAAA;AAGhD,IAAA,IAAA,CAAK,IAAA,GAAO,KAAK,WAAA,CAAY,IAAA;AAG7B,IAAA,IAAI,MAAM,iBAAA,EAAmB;AAC3B,MAAA,KAAA,CAAM,iBAAA,CAAkB,IAAA,EAAM,IAAA,CAAK,WAAW,CAAA;AAAA,IAChD;AAGA,IAAA,IAAI,KAAK,OAAA,CAAQ,KAAA,YAAiB,SAAS,IAAA,CAAK,OAAA,CAAQ,MAAM,KAAA,EAAO;AACnE,MAAA,IAAA,CAAK,KAAA,GAAQ,CAAA,EAAG,IAAA,CAAK,KAAK;AAAA,WAAA,EAAgB,IAAA,CAA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,aAAA,EAAe,OAAO,OAAO,CAAA;AAEpC,MAAA,OAAO,OAAA,CAAQ,OAAO,OAAO,CAAA;AAAA,IAC/B;AAAA,GACF;AACF","file":"index.mjs","sourcesContent":["/**\n * Base error class for all package errors\n *\n * Generic over:\n * - TOptions: The options type for this error class\n * - TReportable: The reportable data structure for error tracking\n */\nimport type { BaseErrorOptions, BaseReportableData } from './types';\n\nexport class BaseError<\n TOptions extends BaseErrorOptions = BaseErrorOptions,\n TReportable extends BaseReportableData = BaseReportableData,\n> extends Error {\n constructor(public readonly options: TOptions) {\n super(options.message);\n\n // Maintain proper prototype chain\n Object.setPrototypeOf(this, new.target.prototype);\n\n // Set error name\n this.name = this.constructor.name;\n\n // Capture stack trace (excluding constructor call)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, this.constructor);\n }\n\n // If there's a cause with a stack, preserve it\n if (this.options.cause instanceof Error && this.options.cause.stack) {\n this.stack = `${this.stack}\\nCaused by: ${this.options.cause.stack}`;\n }\n }\n\n /**\n * Get reportable data for error tracking/logging\n * Subclasses should override this to add their own reportable fields\n */\n getReportableData(): TReportable {\n const { code, operation, userMessage, retryable } = this.options;\n return {\n code,\n operation,\n userMessage,\n retryable,\n } as TReportable;\n }\n\n /**\n * Custom JSON serialization\n * Makes the error properly serializable for logging/reporting\n */\n toJSON(): Record<string, unknown> {\n return {\n ...this.getReportableData(),\n name: this.name,\n message: this.message,\n stack: this.stack,\n } as unknown as Record<string, unknown>;\n }\n}\n","import type { WooCommerceApiErrorCode } from './types';\n\nexport const mapWooCommerceCode = (apiCode?: string): WooCommerceApiErrorCode => {\n if (!apiCode) return 'unknown_error';\n\n // Direct matches\n const directMatches: Record<string, WooCommerceApiErrorCode> = {\n woocommerce_rest_cart_empty: 'cart_empty',\n woocommerce_rest_cart_coupon_error: 'invalid_coupon',\n woocommerce_rest_missing_nonce: 'missing_nonce',\n woocommerce_rest_invalid_nonce: 'invalid_nonce',\n rest_invalid_param: 'invalid_params',\n woocommerce_rest_product_invalid_id: 'product_not_found',\n woocommerce_rest_product_out_of_stock: 'out_of_stock',\n woocommerce_rest_product_not_enough_stock: 'insufficient_stock',\n woocommerce_rest_checkout_invalid_payment_method: 'invalid_payment_method',\n };\n\n if (directMatches[apiCode]) {\n return directMatches[apiCode];\n }\n\n // Pattern matches\n if (apiCode.includes('nonce')) return 'invalid_nonce';\n if (apiCode.includes('coupon')) return 'invalid_coupon';\n if (apiCode.includes('stock')) return 'insufficient_stock';\n if (apiCode.includes('checkout')) return 'checkout_error';\n if (apiCode.includes('payment')) return 'invalid_payment_method';\n\n return 'unknown_error';\n};\n","import type { WooCommerceApiErrorCode, WooCommerceApiErrorMetaData } from './types';\n\nexport const WOOCOMMERCE_ERROR_METADATA: Record<\n WooCommerceApiErrorCode,\n WooCommerceApiErrorMetaData\n> = {\n cart_empty: {\n operation: 'get_cart',\n retryable: false,\n userMessage: 'Your cart is empty',\n },\n invalid_coupon: {\n operation: 'apply_coupon',\n retryable: false,\n userMessage: 'Invalid coupon code',\n },\n missing_nonce: {\n operation: 'cart_request',\n retryable: true, // Auto-retry with new nonce\n },\n invalid_nonce: {\n operation: 'cart_request',\n retryable: true, // Auto-retry with new nonce\n },\n invalid_params: {\n operation: 'api_request',\n retryable: false,\n userMessage: 'Invalid request parameters',\n },\n product_not_found: {\n operation: 'get_product',\n retryable: false,\n userMessage: 'Product not found',\n },\n out_of_stock: {\n operation: 'add_to_cart',\n retryable: false,\n userMessage: 'This product is out of stock',\n },\n insufficient_stock: {\n operation: 'add_to_cart',\n retryable: false,\n userMessage: 'Not enough stock available',\n },\n invalid_payment_method: {\n operation: 'process_checkout',\n retryable: false,\n userMessage: 'Invalid payment method',\n },\n checkout_error: {\n operation: 'process_checkout',\n retryable: false,\n },\n network_error: {\n operation: 'network_request',\n retryable: true,\n },\n unknown_error: {\n operation: 'unknown',\n retryable: false,\n },\n};\n","/**\n * WooCommerce API Error\n */\n\nimport { WOOCOMMERCE_ERROR_METADATA, type WooCommerceApiErrorCode } from '../mapping';\nimport { BaseError } from './BaseError';\nimport type { ApiReportableData, WooCommerceApiErrorOptions } from './types';\n\n/**\n * WooCommerce-specific error class\n *\n * Extends BaseError to provide:\n * - Code transformation (WooCommerce API codes → clean app codes)\n * - WooCommerce-specific error categorization\n * - HTTP context (status, URL, method)\n */\nexport class WooCommerceApiError extends BaseError<WooCommerceApiErrorOptions, ApiReportableData> {\n constructor(options: WooCommerceApiErrorOptions) {\n const metadata = WOOCOMMERCE_ERROR_METADATA[options.code] ?? {\n operation: 'woocommerce_api_request',\n retryable: false,\n };\n\n // Enrich options with metadata defaults\n const enrichedOptions: WooCommerceApiErrorOptions = {\n ...options,\n operation: options.operation || metadata.operation,\n userMessage: options.userMessage || metadata.userMessage,\n retryable: options.retryable ?? metadata.retryable,\n };\n\n super(enrichedOptions);\n }\n\n // Convenient getters for frequently accessed fields (no duplication)\n get wooCode(): WooCommerceApiErrorCode {\n return this.options.code;\n }\n\n get originalCode(): string {\n return this.options.originalCode;\n }\n\n get statusCode(): number {\n return this.options.statusCode;\n }\n\n get url(): string {\n return this.options.url;\n }\n\n get method(): string {\n return this.options.method;\n }\n\n get requestBody(): unknown | undefined {\n return this.options.requestBody;\n }\n\n get responseBody(): unknown | undefined {\n return this.options.responseBody;\n }\n\n get data(): Record<string, unknown> | undefined {\n return this.options.data;\n }\n\n /**\n * Get reportable data for error tracking/logging\n * Includes HTTP context and WooCommerce-specific fields\n */\n override getReportableData(): ApiReportableData {\n return {\n code: this.options.code,\n operation: this.options.operation,\n userMessage: this.options.userMessage,\n retryable: this.options.retryable,\n statusCode: this.options.statusCode,\n url: this.options.url,\n method: this.options.method,\n wooCode: this.options.code,\n originalCode: this.options.originalCode,\n };\n }\n}\n","/**\n * WooCommerce validation error class\n * Thrown when API response validation fails\n */\n\nimport type { ZodError } from 'zod';\n\nimport { BaseError } from './BaseError';\nimport type {\n BaseErrorOptions,\n ValidationReportableData,\n WooCommerceDataValidationErrorOptions,\n} from './types';\n\n/**\n * Internal options type that combines user options with computed fields\n */\ninterface WooCommerceDataValidationErrorInternalOptions extends BaseErrorOptions {\n url?: string;\n zodError?: ZodError;\n value?: unknown;\n fieldErrors?: Record<string, string[]>;\n}\n\n/**\n * WooCommerce validation error\n *\n * Thrown when API response validation fails using Zod schemas\n */\nexport class WooCommerceDataValidationError extends BaseError<\n WooCommerceDataValidationErrorInternalOptions,\n ValidationReportableData\n> {\n constructor(options: WooCommerceDataValidationErrorOptions) {\n // Extract field errors from Zod error if provided\n const fieldErrors = options.zodError\n ? WooCommerceDataValidationError.extractFieldErrorsFromZod(options.zodError)\n : undefined;\n\n super({\n code: 'validation_error',\n message: options.message,\n operation: options.operation,\n userMessage: options.userMessage || 'Received unexpected data from WooCommerce',\n retryable: false,\n cause: options.cause,\n url: options.url,\n zodError: options.zodError,\n value: options.value,\n fieldErrors,\n });\n }\n\n // Convenient getters for validation-specific fields (no duplication)\n get url(): string | undefined {\n return this.options.url;\n }\n\n get zodError(): ZodError | undefined {\n return this.options.zodError;\n }\n\n get invalidValue(): unknown | undefined {\n return this.options.value;\n }\n\n get fieldErrors(): Record<string, string[]> | undefined {\n return this.options.fieldErrors;\n }\n\n /**\n * Get reportable data for error tracking/logging\n * Includes validation-specific fields\n */\n override getReportableData(): ValidationReportableData {\n return {\n code: this.options.code,\n operation: this.options.operation,\n userMessage: this.options.userMessage,\n retryable: false,\n fieldErrors: this.options.fieldErrors,\n url: this.options.url,\n };\n }\n\n /**\n * Extract field errors from Zod error\n */\n private static extractFieldErrorsFromZod(\n zodError: ZodError\n ): Record<string, string[]> | undefined {\n if (!zodError?.errors) {\n return undefined;\n }\n\n const fieldErrors: Record<string, string[]> = {};\n\n for (const issue of zodError.errors) {\n const path = issue.path.join('.');\n if (!fieldErrors[path]) {\n fieldErrors[path] = [];\n }\n fieldErrors[path].push(issue.message);\n }\n\n return fieldErrors;\n }\n\n /**\n * Get all error messages as a flat array\n */\n getMessages(): string[] {\n if (!this.fieldErrors) {\n return [this.message];\n }\n\n const messages: string[] = [];\n for (const fieldMessages of Object.values(this.fieldErrors)) {\n messages.push(...fieldMessages);\n }\n\n return messages;\n }\n\n /**\n * Check if a specific field has errors\n */\n hasFieldError(field: string): boolean {\n return this.fieldErrors ? field in this.fieldErrors : false;\n }\n\n /**\n * Get error messages for a specific field\n */\n getFieldError(field: string): string[] | undefined {\n return this.fieldErrors?.[field];\n }\n}\n","/**\n * Response validation utilities\n */\n\nimport type { AxiosResponse } from 'axios';\nimport type { ZodError, ZodSchema } from 'zod';\n\nimport { WooCommerceDataValidationError } from '@/errors';\n\n/**\n * Validation mode for API responses\n * - 'strict': Throw error on validation failure (default)\n * - 'warn': Log warning and continue on validation failure\n */\nexport type ValidationMode = 'strict' | 'warn';\n\n/**\n * Options for response handling\n */\nexport interface ResponseOptions {\n /** Validation mode */\n validationMode?: ValidationMode;\n\n /** Error reporter for validation errors */\n errorReporter?: (error: Error) => void;\n\n /** Optional validation error handler (called before errorReporter) */\n onValidationError?: (error: Error) => void;\n}\n\n/**\n * Handle and validate API response\n *\n * @param response - Axios response\n * @param schema - Zod schema for validation\n * @param options - Response handling options\n * @returns Validated data\n * @throws ValidationError if validation fails in strict mode\n */\nexport const handleApiResponse = <T>(\n response: AxiosResponse,\n schema: ZodSchema<T>,\n options?: ResponseOptions\n): T => {\n const validationMode = options?.validationMode ?? 'strict';\n\n // Warn mode - use safeParse and continue on validation failure\n if (validationMode === 'warn') {\n const result = schema.safeParse(response.data);\n\n if (!result.success) {\n const validationError = new WooCommerceDataValidationError({\n message: `WooCommerce API response validation failed for ${response.config.url || 'unknown endpoint'}`,\n url: response.config.url,\n zodError: result.error,\n value: response.data,\n userMessage: 'Received unexpected data from WooCommerce',\n });\n\n // Call optional validation error handler\n options?.onValidationError?.(validationError);\n\n // Report to error tracker (if provided)\n options?.errorReporter?.(validationError);\n\n // Log warning to console in warn mode\n console.warn('[woocommerce-utils] Validation warning:', validationError.message);\n\n // Return raw data to allow app to continue\n return response.data as T;\n }\n\n return result.data;\n }\n\n // Strict mode - throw on validation failure\n try {\n return schema.parse(response.data);\n } catch (error) {\n if (error && typeof error === 'object' && 'issues' in error) {\n const validationError = new WooCommerceDataValidationError({\n message: `WooCommerce API response validation failed for ${response.config.url || 'unknown endpoint'}`,\n url: response.config.url,\n zodError: error as ZodError,\n value: response.data,\n userMessage: 'Received unexpected data from WooCommerce',\n });\n\n // Call optional validation error handler\n options?.onValidationError?.(validationError);\n\n // Report to error tracker (if provided)\n options?.errorReporter?.(validationError);\n\n throw validationError;\n }\n throw error;\n }\n};\n\n/**\n * Check if error is a Zod validation error\n */\nexport const isZodError = (error: unknown): error is ZodError => {\n return error instanceof Error && error.name === 'ZodError';\n};\n","/**\n * Calculate pagination navigation\n */\n\nexport interface Pagination {\n page: number;\n perPage: number;\n total: number;\n totalPages: number;\n hasNextPage: boolean;\n hasPrevPage: boolean;\n nextPage: number | null;\n prevPage: number | null;\n}\n\nexport interface CalculatePaginationInput {\n page: number;\n perPage: number;\n total: number;\n totalPages: number;\n}\n\n/**\n * Calculate pagination navigation from WooCommerce pagination metadata\n *\n * @param input - Current pagination state\n * @returns Full pagination object with navigation helpers\n */\nexport const calculatePagination = (input: CalculatePaginationInput): Pagination => {\n const { page, perPage, total, totalPages } = input;\n\n const hasNextPage = page < totalPages;\n const hasPrevPage = page > 1;\n\n return {\n page,\n perPage,\n total,\n totalPages,\n hasNextPage,\n hasPrevPage,\n nextPage: hasNextPage ? page + 1 : null,\n prevPage: hasPrevPage ? page - 1 : null,\n };\n};\n","/**\n * Extract pagination metadata from WooCommerce response headers\n */\n\nimport type { AxiosResponse } from 'axios';\n\nexport interface PaginationMeta {\n total: number;\n totalPages: number;\n}\n\nexport const getPaginationMeta = (headers: AxiosResponse['headers']): PaginationMeta => {\n // Handle undefined/null headers\n if (!headers) {\n return {\n total: 0,\n totalPages: 0,\n };\n }\n\n const wpTotal = headers['x-wp-total'];\n const wpTotalPages = headers['x-wp-totalpages'];\n\n if (!wpTotal || !wpTotalPages) {\n return {\n total: 0,\n totalPages: 0,\n };\n }\n\n const total = parseInt(wpTotal, 10);\n const totalPages = parseInt(wpTotalPages, 10);\n\n return {\n total,\n totalPages,\n };\n};\n","/**\n * Pagination utilities for WooCommerce API responses\n */\n\nimport type { AxiosResponse } from 'axios';\nimport type { ZodError, ZodSchema } from 'zod';\n\nimport { WooCommerceDataValidationError } from '../errors';\nimport { calculatePagination, type Pagination } from '../utils/calculatePagination';\nimport { getPaginationMeta } from '../utils/getPaginationMeta';\nimport type { ResponseOptions } from './handleApiResponse';\n\n/**\n * Paginated response wrapper\n */\nexport interface PaginatedResponse<T> {\n data: T[];\n pagination: Pagination;\n}\n\n/**\n * Handle paginated API response\n *\n * @param response - Axios response\n * @param schema - Zod schema for validating array items\n * @param params - Request parameters (page, per_page)\n * @param options - Response handling options\n * @returns Paginated response with validated data\n * @throws ValidationError if validation fails in strict mode\n */\nexport const handlePaginatedApiResponse = <T>(\n response: AxiosResponse,\n schema: ZodSchema<T[]>,\n params: { page?: number; per_page?: number } = {},\n options?: ResponseOptions\n): PaginatedResponse<T> => {\n const validationMode = options?.validationMode ?? 'strict';\n let data: T[];\n\n // Warn mode - use safeParse and continue on validation failure\n if (validationMode === 'warn') {\n const result = schema.safeParse(response.data);\n\n if (!result.success) {\n const validationError = new WooCommerceDataValidationError({\n message: `WooCommerce API response validation failed for ${response.config.url || 'unknown endpoint'}`,\n url: response.config.url,\n zodError: result.error,\n value: response.data,\n userMessage: 'Received unexpected data from WooCommerce',\n });\n\n // Call optional validation error handler\n options?.onValidationError?.(validationError);\n\n // Report to error tracker (if provided)\n options?.errorReporter?.(validationError);\n\n // Log warning to console in warn mode\n console.warn('[woocommerce-utils] Validation warning:', validationError.message);\n\n // Return raw data as array (best effort)\n data = Array.isArray(response.data) ? response.data : [];\n } else {\n data = result.data;\n }\n } else {\n // Strict mode - throw on validation failure\n try {\n data = schema.parse(response.data);\n } catch (error) {\n if (error && typeof error === 'object' && 'issues' in error) {\n const validationError = new WooCommerceDataValidationError({\n message: `WooCommerce API response validation failed for ${response.config.url || 'unknown endpoint'}`,\n url: response.config.url,\n zodError: error as ZodError,\n value: response.data,\n userMessage: 'Received unexpected data from WooCommerce',\n });\n\n // Call optional validation error handler\n options?.onValidationError?.(validationError);\n\n // Report to error tracker (if provided)\n options?.errorReporter?.(validationError);\n\n throw validationError;\n }\n throw error;\n }\n }\n\n const { total, totalPages } = getPaginationMeta(response.headers);\n const page = params.page || 1;\n const perPage = params.per_page || 10;\n\n const pagination = calculatePagination({\n page,\n perPage,\n total,\n totalPages,\n });\n\n return {\n data,\n pagination,\n };\n};\n","/**\n * Debug logger for WooCommerce utils\n */\n\nconst DEBUG_PREFIX = '[woocommerce-utils]';\n\n/**\n * Check if debug mode is enabled\n */\nexport const isDebugEnabled = (): boolean => {\n if (typeof process !== 'undefined' && process.env) {\n return process.env.DEBUG === 'true' || process.env.DEBUG === '1';\n }\n return false;\n};\n\n/**\n * Log debug message (only if DEBUG is enabled)\n */\nexport const debug = (...args: unknown[]): void => {\n if (isDebugEnabled()) {\n console.log(DEBUG_PREFIX, ...args);\n }\n};\n\n/**\n * Log warning message\n */\nexport const warn = (...args: unknown[]): void => {\n console.warn(DEBUG_PREFIX, ...args);\n};\n\n/**\n * Log error message\n */\nexport const error = (...args: unknown[]): void => {\n console.error(DEBUG_PREFIX, ...args);\n};\n","/**\n * Request interceptor\n *\n * Handles:\n * - JWT authentication for protected endpoints\n * - Nonce/Cart-Token injection for cart/checkout endpoints\n * - Cache-Control headers for cart/checkout to prevent Android caching bugs\n * - Debug logging\n */\n\nimport type { AxiosInstance, InternalAxiosRequestConfig } from 'axios';\n\nimport type { WooCommerceClient, WooCommerceConfig } from '../../client/types';\nimport { debug } from '../../logging/logger';\n\n/**\n * Check if endpoint requires JWT authentication\n */\nconst requiresAuth = (url?: string): boolean => {\n if (!url) return false;\n\n const authEndpoints = ['/jwt-auth/', '/customers/me', '/wp/v2/users/me'];\n\n return authEndpoints.some((endpoint) => url.includes(endpoint));\n};\n\n/**\n * Check if endpoint requires cart authentication (nonce/cart-token)\n *\n * Matches both versioned (/wc/store/v1/cart) and non-versioned (/wc/store/cart) endpoints\n */\nconst requiresCartAuth = (url?: string): boolean => {\n if (!url) return false;\n\n // Match /wc/store/cart or /wc/store/v1/cart (and similar for checkout)\n return /\\/wc\\/store\\/(v\\d+\\/)?cart/.test(url) || /\\/wc\\/store\\/(v\\d+\\/)?checkout/.test(url);\n};\n\n/**\n * Setup request interceptor\n *\n * - Injects JWT Bearer token for authenticated requests\n * - Injects Nonce/Cart-Token headers for cart/checkout requests\n * - Adds Cache-Control headers to prevent Android caching bugs\n * - Calls optional onRequest hook\n * - Passes client instance to callbacks\n */\nexport const setupRequestInterceptor = (\n axiosInstance: AxiosInstance,\n config: WooCommerceConfig,\n client: WooCommerceClient\n): void => {\n axiosInstance.interceptors.request.use(\n async (requestConfig: InternalAxiosRequestConfig) => {\n const url = requestConfig.url;\n\n // Inject JWT token for authenticated endpoints\n if (requiresAuth(url) && config.jwtToken) {\n const token = await config.jwtToken.get();\n if (token) {\n requestConfig.headers.Authorization = `Bearer ${token}`;\n if (config.debug) {\n debug('Injected JWT token for', url);\n }\n }\n }\n\n // Inject nonce/cart-token for cart endpoints\n if (requiresCartAuth(url)) {\n const headers = await config.cartHeaders.get();\n\n if (headers.nonce) {\n requestConfig.headers.Nonce = headers.nonce;\n }\n if (headers.cartToken) {\n requestConfig.headers['Cart-Token'] = headers.cartToken;\n }\n\n // CRITICAL: Disable HTTP caching for cart/checkout endpoints\n // WooCommerce sends aggressive cache headers (max-age=2419200, 28 days) which\n // can cause Android HTTP clients to serve stale cart data from cache.\n // This was causing empty carts to be returned after successful add-item operations\n // because the cached GET /cart response (from before items were added) was being\n // served instead of fetching fresh data from the server.\n // iOS URLSession happened to work because it handles expired cache differently.\n requestConfig.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate';\n requestConfig.headers.Pragma = 'no-cache';\n requestConfig.headers.Expires = '0';\n\n if (config.debug) {\n debug('Injected cart headers for', url, {\n hasNonce: !!headers.nonce,\n hasCartToken: !!headers.cartToken,\n });\n }\n }\n\n // Debug logging\n if (config.debug) {\n debug(\n `${requestConfig.method?.toUpperCase()} ${requestConfig.url}`,\n requestConfig.params || requestConfig.data\n );\n }\n\n // Call optional onRequest hook\n if (config.onRequest) {\n return config.onRequest(requestConfig, client);\n }\n\n return requestConfig;\n },\n (error) => {\n return Promise.reject(error);\n }\n );\n};\n","/**\n * Axios response interceptor for WooCommerce API\n */\n\nimport type { AxiosInstance, AxiosResponse } from 'axios';\n\nimport type { WooCommerceClient, WooCommerceConfig } from '../../client/types';\nimport { debug } from '../../logging/logger';\n\n/**\n * Check if response is from cart/checkout endpoint\n *\n * Matches both versioned (/wc/store/v1/cart) and non-versioned (/wc/store/cart) endpoints\n */\nconst isCartResponse = (url?: string): boolean => {\n if (!url) return false;\n\n // Match /wc/store/cart or /wc/store/v1/cart (and similar for checkout)\n return /\\/wc\\/store\\/(v\\d+\\/)?cart/.test(url) || /\\/wc\\/store\\/(v\\d+\\/)?checkout/.test(url);\n};\n\n/**\n * Setup response interceptor\n *\n * - Extracts and saves cart headers (nonce rotation)\n * - Logs responses in debug mode\n * - Calls optional onResponse hook\n * - Passes client instance to callbacks\n */\nexport const setupResponseInterceptor = (\n axiosInstance: AxiosInstance,\n config: WooCommerceConfig,\n client: WooCommerceClient\n): void => {\n axiosInstance.interceptors.response.use(\n async (response: AxiosResponse) => {\n // Extract and save cart headers (nonce rotation)\n if (isCartResponse(response.config.url)) {\n const nonce = response.headers['nonce'] || response.headers['Nonce'];\n const cartToken = response.headers['cart-token'] || response.headers['Cart-Token'];\n\n if (nonce || cartToken) {\n await config.cartHeaders.save({\n nonce: nonce || undefined,\n cartToken: cartToken || undefined,\n });\n\n if (config.debug) {\n debug(\n 'Saved updated cart headers:',\n response.config.url,\n 'nonce:',\n !!nonce,\n 'cartToken:',\n !!cartToken\n );\n }\n }\n }\n\n if (config.debug) {\n debug('Response:', response.config.url, response.status);\n }\n\n // Call optional onResponse hook\n if (config.onResponse) {\n return config.onResponse(response, client);\n }\n\n return response;\n },\n (error) => {\n return Promise.reject(error);\n }\n );\n};\n","/**\n * Cart session initialization utility\n */\n\nimport type { AxiosInstance } from 'axios';\n\nimport type { CartHeadersAdapter } from '../client/types';\nimport { debug } from '../logging/logger';\n\n/**\n * Initialize cart session by fetching cart and saving headers\n *\n * This is called when nonce errors occur to get a fresh nonce/cart-token\n *\n * @param client - Axios instance\n * @param cartHeaders - Cart headers adapter\n */\nexport const initializeCartSession = async (\n client: AxiosInstance,\n cartHeaders: CartHeadersAdapter\n): Promise<void> => {\n try {\n debug('session', 'Initializing cart session');\n\n // Make GET request to cart endpoint\n const response = await client.get('/wc/store/v1/cart');\n\n // Extract headers\n const nonce = response.headers['nonce'] || response.headers['Nonce'];\n const cartToken = response.headers['cart-token'] || response.headers['Cart-Token'];\n\n // Save headers\n if (nonce || cartToken) {\n await cartHeaders.save({\n nonce: nonce || undefined,\n cartToken: cartToken || undefined,\n });\n\n debug('session', 'Cart session initialized', {\n hasNonce: !!nonce,\n hasCartToken: !!cartToken,\n });\n }\n } catch (error) {\n debug('session', 'Failed to initialize cart session', error);\n throw error;\n }\n};\n","/**\n * Axios error interceptor for WooCommerce API\n */\n\nimport { isAxiosError, type AxiosError, type AxiosInstance } from 'axios';\n\nimport type { WooCommerceClient, WooCommerceConfig } from '../../client/types';\nimport { WooCommerceApiError } from '../../errors/classes/WooCommerceApiError';\nimport { mapWooCommerceCode, WOOCOMMERCE_ERROR_METADATA } from '../../errors/mapping';\nimport { debug, error as logError } from '../../logging/logger';\nimport { initializeCartSession } from '../../utils/initializeCartSession';\n\ninterface WooCommerceErrorData {\n code?: string;\n message?: string;\n data?: {\n status?: number;\n };\n}\n\n/**\n * Setup error interceptor\n *\n * - Transforms WooCommerce errors into WooCommerceApiError instances\n * - Calls optional onError hook\n * - Passes client instance to callbacks\n */\nexport const setupErrorInterceptor = (\n axiosInstance: AxiosInstance,\n config: WooCommerceConfig,\n client: WooCommerceClient\n): void => {\n axiosInstance.interceptors.response.use(\n (response) => response,\n async (axiosError: AxiosError<WooCommerceErrorData>) => {\n const status = axiosError.response?.status || 500;\n const errorData = axiosError.response?.data;\n\n // Extract WooCommerce error details\n const apiCode = errorData?.code || 'unknown_error';\n const wpMessage = errorData?.message || axiosError.message || 'Unknown error';\n\n // Transform WooCommerce API code to application-level code\n // e.g., \"woocommerce_rest_cart_empty\" → \"cart_empty\"\n const errorCode = mapWooCommerceCode(apiCode);\n const errorMetadata = WOOCOMMERCE_ERROR_METADATA[errorCode];\n\n // Create WooCommerceError with full context\n const wcError = new WooCommerceApiError({\n message: wpMessage,\n statusCode: status,\n code: errorCode, // Transformed app-level code\n originalCode: apiCode, // Original WooCommerce API code\n retryable: errorMetadata.retryable,\n userMessage: errorMetadata.userMessage,\n operation: errorMetadata.operation,\n url: axiosError.config?.url || '',\n method: axiosError.config?.method?.toUpperCase() || 'GET',\n requestBody: axiosError.config?.data,\n responseBody: errorData,\n data: errorData?.data as Record<string, unknown> | undefined,\n cause: axiosError,\n });\n\n if (config.debug) {\n debug('WooCommerce error:', apiCode, status, wpMessage);\n logError(wcError);\n }\n\n // Handle authentication errors (401/403)\n if (\n (status === 401 || status === 403) &&\n config.onAuthError &&\n isAxiosError(axiosError) &&\n !axiosError.config?._retry\n ) {\n if (config.debug) {\n debug('Auth error detected, calling onAuthError handler');\n }\n\n try {\n const shouldRetry = await config.onAuthError(wcError, client);\n\n if (shouldRetry) {\n if (config.debug) {\n debug('Retrying request after auth error');\n }\n\n // Mark as retry to prevent infinite loops\n axiosError.config!._retry = true;\n\n // Retry the request\n return axiosInstance.request(axiosError.config!);\n }\n } catch (authErrorHandlerError) {\n // If onAuthError handler throws, fall through to error reporting\n if (config.debug) {\n debug('onAuthError handler threw error', authErrorHandlerError);\n }\n }\n }\n\n // Call optional onError hook first (even for retryable errors)\n if (config.onError) {\n config.onError(wcError, client);\n }\n\n // Auto-retry nonce errors\n const isNonceError = errorCode === 'missing_nonce' || errorCode === 'invalid_nonce';\n if (isNonceError && isAxiosError(axiosError) && !axiosError.config?._retry) {\n if (config.debug) {\n debug('Nonce error detected, retrying with new session');\n }\n\n try {\n // Initialize new cart session\n await initializeCartSession(axiosInstance, config.cartHeaders);\n\n // Mark as retry to prevent infinite loops\n axiosError.config!._retry = true;\n\n // Retry the request\n return axiosInstance.request(axiosError.config!);\n } catch (_retryError) {\n // If retry fails, report and throw original error\n config.errorReporter?.report(wcError);\n return Promise.reject(wcError);\n }\n }\n\n // Report error to configured error reporter (Sentry, etc.)\n config.errorReporter?.report(wcError);\n\n return Promise.reject(wcError);\n }\n );\n};\n\n// Augment AxiosRequestConfig to include _retry flag\ndeclare module 'axios' {\n export interface AxiosRequestConfig {\n _retry?: boolean;\n }\n}\n"]}
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { createClient } from './client/index.mjs';
|
|
2
|
+
import { B as BaseError, a as BaseErrorOptions, V as ValidationReportableData, W as WooCommerceDataValidationErrorOptions } from './types-B-zy1xrP.mjs';
|
|
3
|
+
export { C as CartAPI, b as CartHeadersAdapter, c as CheckoutAPI, G as GetOrderInput, J as JwtTokenAdapter, O as OrdersAPI, P as PaginatedResponse, d as ProductsAPI, e as WooCommerceApiError, f as WooCommerceApiErrorOptions, g as WooCommerceClient, h as WooCommerceConfig } from './types-B-zy1xrP.mjs';
|
|
4
|
+
export { A as Address, B as BillingAddress, P as PaginationMeta, a as PaginationParams, b as addressSchema, c as billingAddressSchema, p as paginationMetaSchema, d as paginationParamsSchema } from './pagination.schema-CdjWGZJr.mjs';
|
|
5
|
+
export { A as AddToCartInput, C as Cart, a as CartItem, b as CartItemImage, c as Checkout, d as CheckoutInput, e as CouponInput, P as Product, f as ProductCategory, g as ProductImage, h as ProductParams, R as RemoveCartItemInput, S as SelectShippingRateInput, i as StoreApiOrder, U as UpdateCartItemInput, j as UpdateCustomerInput, k as addToCartInputSchema, l as cartItemImageSchema, m as cartSchema, n as checkoutInputSchema, o as checkoutSchema, p as couponInputSchema, q as productCategorySchema, r as productImageSchema, s as productSchema, t as removeCartItemInputSchema, u as searchParamsSchema, v as selectShippingRateInputSchema, w as storeApiOrderSchema, x as updateCartItemInputSchema, y as updateCustomerInputSchema } from './products-Cxl54crz.mjs';
|
|
6
|
+
export { CategoryFilterParams as AdminCategoryFilterParams, Product as AdminProduct, ProductCategory as AdminProductCategory, ProductFilterParams as AdminProductFilterParams, Coupon, CouponFilterParams, Customer, CustomerFilterParams, Order, OrderFilterParams, PaymentMethod, PaymentMethodFilterParams, TAppEnumsKeys, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema as adminOrderSchema, productCategorySchema as adminProductCategorySchema, productFilterSchema as adminProductFilterSchema, productSchema as adminProductSchema, createCategorySchema, createCouponSchema, createCustomerSchema, customerFilterSchema, customerSchema, getAppEnumRaw, getAppEnumZod, paymentMethodFilterSchema, paymentMethodSchema, schemas, updateCustomerSchema, wcErrorResponseSchema } from './schemas/admin-api/index.mjs';
|
|
7
|
+
import { ZodError } from 'zod';
|
|
8
|
+
import 'axios';
|
|
9
|
+
|
|
10
|
+
interface WooCommerceDataValidationErrorInternalOptions extends BaseErrorOptions {
|
|
11
|
+
url?: string;
|
|
12
|
+
zodError?: ZodError;
|
|
13
|
+
value?: unknown;
|
|
14
|
+
fieldErrors?: Record<string, string[]>;
|
|
15
|
+
}
|
|
16
|
+
declare class WooCommerceDataValidationError extends BaseError<WooCommerceDataValidationErrorInternalOptions, ValidationReportableData> {
|
|
17
|
+
constructor(options: WooCommerceDataValidationErrorOptions);
|
|
18
|
+
get url(): string | undefined;
|
|
19
|
+
get zodError(): ZodError | undefined;
|
|
20
|
+
get invalidValue(): unknown | undefined;
|
|
21
|
+
get fieldErrors(): Record<string, string[]> | undefined;
|
|
22
|
+
getReportableData(): ValidationReportableData;
|
|
23
|
+
private static extractFieldErrorsFromZod;
|
|
24
|
+
getMessages(): string[];
|
|
25
|
+
hasFieldError(field: string): boolean;
|
|
26
|
+
getFieldError(field: string): string[] | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { WooCommerceDataValidationError, WooCommerceDataValidationErrorOptions };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export { createClient } from './client/index.js';
|
|
2
|
+
import { B as BaseError, a as BaseErrorOptions, V as ValidationReportableData, W as WooCommerceDataValidationErrorOptions } from './types-qKWtrw7A.js';
|
|
3
|
+
export { C as CartAPI, b as CartHeadersAdapter, c as CheckoutAPI, G as GetOrderInput, J as JwtTokenAdapter, O as OrdersAPI, P as PaginatedResponse, d as ProductsAPI, e as WooCommerceApiError, f as WooCommerceApiErrorOptions, g as WooCommerceClient, h as WooCommerceConfig } from './types-qKWtrw7A.js';
|
|
4
|
+
export { A as Address, B as BillingAddress, P as PaginationMeta, a as PaginationParams, b as addressSchema, c as billingAddressSchema, p as paginationMetaSchema, d as paginationParamsSchema } from './pagination.schema-CdjWGZJr.js';
|
|
5
|
+
export { A as AddToCartInput, C as Cart, a as CartItem, b as CartItemImage, c as Checkout, d as CheckoutInput, e as CouponInput, P as Product, f as ProductCategory, g as ProductImage, h as ProductParams, R as RemoveCartItemInput, S as SelectShippingRateInput, i as StoreApiOrder, U as UpdateCartItemInput, j as UpdateCustomerInput, k as addToCartInputSchema, l as cartItemImageSchema, m as cartSchema, n as checkoutInputSchema, o as checkoutSchema, p as couponInputSchema, q as productCategorySchema, r as productImageSchema, s as productSchema, t as removeCartItemInputSchema, u as searchParamsSchema, v as selectShippingRateInputSchema, w as storeApiOrderSchema, x as updateCartItemInputSchema, y as updateCustomerInputSchema } from './products-Cxl54crz.js';
|
|
6
|
+
export { CategoryFilterParams as AdminCategoryFilterParams, Product as AdminProduct, ProductCategory as AdminProductCategory, ProductFilterParams as AdminProductFilterParams, Coupon, CouponFilterParams, Customer, CustomerFilterParams, Order, OrderFilterParams, PaymentMethod, PaymentMethodFilterParams, TAppEnumsKeys, categoryFilterSchema as adminCategoryFilterSchema, couponFilterSchema as adminCouponFilterSchema, couponSchema as adminCouponSchema, orderFilterSchema as adminOrderFilterSchema, orderSchema as adminOrderSchema, productCategorySchema as adminProductCategorySchema, productFilterSchema as adminProductFilterSchema, productSchema as adminProductSchema, createCategorySchema, createCouponSchema, createCustomerSchema, customerFilterSchema, customerSchema, getAppEnumRaw, getAppEnumZod, paymentMethodFilterSchema, paymentMethodSchema, schemas, updateCustomerSchema, wcErrorResponseSchema } from './schemas/admin-api/index.js';
|
|
7
|
+
import { ZodError } from 'zod';
|
|
8
|
+
import 'axios';
|
|
9
|
+
|
|
10
|
+
interface WooCommerceDataValidationErrorInternalOptions extends BaseErrorOptions {
|
|
11
|
+
url?: string;
|
|
12
|
+
zodError?: ZodError;
|
|
13
|
+
value?: unknown;
|
|
14
|
+
fieldErrors?: Record<string, string[]>;
|
|
15
|
+
}
|
|
16
|
+
declare class WooCommerceDataValidationError extends BaseError<WooCommerceDataValidationErrorInternalOptions, ValidationReportableData> {
|
|
17
|
+
constructor(options: WooCommerceDataValidationErrorOptions);
|
|
18
|
+
get url(): string | undefined;
|
|
19
|
+
get zodError(): ZodError | undefined;
|
|
20
|
+
get invalidValue(): unknown | undefined;
|
|
21
|
+
get fieldErrors(): Record<string, string[]> | undefined;
|
|
22
|
+
getReportableData(): ValidationReportableData;
|
|
23
|
+
private static extractFieldErrorsFromZod;
|
|
24
|
+
getMessages(): string[];
|
|
25
|
+
hasFieldError(field: string): boolean;
|
|
26
|
+
getFieldError(field: string): string[] | undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { WooCommerceDataValidationError, WooCommerceDataValidationErrorOptions };
|