@autofleet/network 1.9.17 → 1.11.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/lib/index.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["axiosCacheAdapter","axiosRetry","qsStringify: typeof stringify | undefined","qsStringifyOptions: NonNullable<Parameters<typeof stringify>[1]>","defaultSettings: NetworkSettings","env","#logger","HttpAgent","HttpsAgent","#createBaseUrl","#addRetry","#buildClassHttpMethods","#addLogs","currentResult: T[]","resultsInFirstPage: number | null","lastResultsSize: number | null"],"sources":["../src/index.ts"],"sourcesContent":["import { env } from 'node:process';\nimport { createRequire } from 'node:module';\nimport axios, { type CreateAxiosDefaults, type AxiosRequestConfig, type AxiosInstance, type AxiosResponse, type AxiosRequestHeaders } from 'axios';\nimport axiosRetry, { type IAxiosRetryConfigExtended, type IAxiosRetryConfig, type IAxiosRetryReturn } from 'axios-retry';\nimport Logger, { type LoggerInstanceManager } from '@autofleet/logger';\nimport merge from 'deepmerge';\nimport axiosCacheAdapter from '@autofleet/axios-cache-adapter';\nimport { HttpAgent, HttpsAgent } from 'agentkeepalive';\nimport type { stringify } from 'qs';\nimport type { IAxiosCacheAdapterOptions } from '@autofleet/axios-cache-adapter';\n\ndeclare module 'axios' {\n interface AxiosRequestConfig {\n /** configure how the cached requests will be handled, where they will be stored, etc. */\n cache?: IAxiosCacheAdapterOptions;\n /** force cache invalidation */\n clearCacheEntry?: boolean;\n 'axios-retry'?: IAxiosRetryConfigExtended;\n }\n}\n\n// Due to issue with multiple `axios` versions in monorepo, we need to explicitly override the types to use v0\nconst { setup } = axiosCacheAdapter as { setup: (options: AxiosRequestConfig) => AxiosInstance; };\nconst correctlyTypedAxiosRetry = axiosRetry as unknown as (axiosInstance: AxiosInstance, axiosRetryConfig?: IAxiosRetryConfig) => IAxiosRetryReturn;\n\nconst safeRequire = createRequire(import.meta.url);\n\nlet qsStringify: typeof stringify | undefined;\nconst lazilyLoadQsStringify = (...args: Parameters<typeof stringify>) => {\n qsStringify ??= safeRequire('qs').stringify;\n return qsStringify!(...args);\n};\n\nconst HTTPMethods = [\n 'get',\n 'post',\n 'delete',\n 'head',\n 'put',\n 'patch',\n 'options',\n] as const;\n\nconst qsStringifyOptions: NonNullable<Parameters<typeof stringify>[1]> = { arrayFormat: 'brackets' };\n\n/**\n * Network client configuration settings\n */\ninterface NetworkSettings extends CreateAxiosDefaults, IAxiosRetryConfig {\n /** Service name for Kubernetes DNS resolution (e.g., 'EXAMPLE_MS' resolves to EXAMPLE_MS_SERVICE_HOST) */\n serviceName?: string;\n /** Direct service URL (alternative to serviceName) */\n serviceUrl?: string;\n /**\n * Enable HTTP keep-alive connections (default: true)\n * @since 1.9.0 - To disable keep-alive, set to false AND set env var NETWORK_ALLOW_KEEPALIVE_FALSE=true\n */\n keepAlive?: boolean;\n /** Logger instance for request/response logging */\n logger?: LoggerInstanceManager;\n /** Request timeout in milliseconds (default: 10000) */\n timeout?: number;\n}\n\nconst defaultSettings: NetworkSettings = {\n timeout: 10_000,\n headers: {\n 'X-AF-AUTH': 'ANYONE',\n 'X-IAF-ORIGIN-SERVICE': env.AF_SERVICE_NAME || null as unknown as string,\n },\n paramsSerializer: params => lazilyLoadQsStringify(params, qsStringifyOptions),\n 'axios-retry': {\n shouldResetTimeout: true,\n },\n keepAlive: true,\n};\n\nconst createRequestString = (request: AxiosRequestConfig): string => `[${(request.method || '').toUpperCase()}] ${request.baseURL ?? 'unknown-base-url'}${request.url ?? '/unknown-url'}`;\n\n/*\n The default free socket keepalive timeout, in milliseconds.\n Setting to 5000 (5 seconds) as default because out grace period is 10 seconds\n and we want to make sure we don't have any socket issues.\n See https://www.npmjs.com/package/agentkeepalive\n\n There is also autoscaling reason for that, if we don't timeout at some point,\n new pods that were auto scaled will not be used.\n*/\nconst FREE_SOCKET_TIMEOUT = Number.parseInt(env.FREE_SOCKET_TIMEOUT || '', 10) || 5_000;\n\n/**\n * HTTP client wrapper built on Axios with keep-alive connection pooling, caching, retry logic, and logging.\n *\n * @example\n * ```typescript\n * const client = new Network({\n * serviceName: 'EXAMPLE_MS',\n * timeout: 10000,\n * retries: 3\n * });\n *\n * const response = await client.get('/endpoint');\n * await client.post('/data', { payload });\n * ```\n */\nexport default class Network {\n readonly #logger: LoggerInstanceManager;\n private readonly settings: NetworkSettings;\n private readonly axios: AxiosInstance;\n\n public get!: AxiosInstance['get'];\n public post!: AxiosInstance['post'];\n public delete!: AxiosInstance['delete'];\n public head!: AxiosInstance['head'];\n public put!: AxiosInstance['put'];\n public patch!: AxiosInstance['patch'];\n public options!: AxiosInstance['options'];\n\n constructor(settings: NetworkSettings = {}) {\n this.#logger = settings.logger ?? Logger();\n this.settings = merge(defaultSettings, settings);\n\n // Configure keep-alive behavior\n if (this.settings.keepAlive) {\n // Enable keep-alive with custom free socket timeout\n this.settings.httpAgent = new HttpAgent({ freeSocketTimeout: FREE_SOCKET_TIMEOUT });\n this.settings.httpsAgent = new HttpsAgent({ freeSocketTimeout: FREE_SOCKET_TIMEOUT });\n delete this.settings.keepAlive;\n } else if (this.settings.keepAlive === false && process.env.NETWORK_ALLOW_KEEPALIVE_FALSE === 'true') {\n // [v1.9.0] Explicitly disable keep-alive\n // Node.js 20+ has keep-alive enabled by default, so we need to explicitly set keepAlive: false\n // This env var is required to prevent silent performance degradation in services that unknowingly relied on keep-alive\n this.settings.httpAgent = new HttpAgent({ keepAlive: false });\n this.settings.httpsAgent = new HttpsAgent({ keepAlive: false });\n delete this.settings.keepAlive;\n }\n\n this.#createBaseUrl();\n\n if (settings.cache) {\n this.settings.cache = {\n maxAge: 15 * 60 * 1000,\n // Store responses from requests with query parameters in cache\n exclude: { query: false },\n ...settings.cache,\n };\n }\n\n this.axios = settings.cache ? setup(this.settings as NetworkSettings & { headers: AxiosRequestHeaders; }) : axios.create(this.settings);\n this.#addRetry(settings);\n this.#buildClassHttpMethods();\n this.#addLogs();\n }\n\n #addRetry(settings: NetworkSettings): void {\n correctlyTypedAxiosRetry(this.axios, {\n retries: 0,\n retryDelay: axiosRetry.exponentialDelay,\n ...settings,\n });\n }\n\n #addLogs(): void {\n this.axios.interceptors.request.use((request) => {\n this.#logger.info(`Start Request: ${createRequestString(request)}`);\n return request;\n });\n\n this.axios.interceptors.response.use((response) => {\n this.#logger.info(`Finish Request: ${createRequestString(response.config)}`);\n return response;\n }, (error) => {\n if (error.request?._currentRequest?.reusedSocket && ['ECONNRESET', 'EPIPE'].includes(error.code)) {\n // See https://www.npmjs.com/package/agentkeepalive\n // Support req.reusedSocket\n // https://code-examples.net/en/q/28a8069\n this.#logger.warn(`${error.code} issue, will retry`, {\n req: error.request._currentRequest._currentUrl,\n // method: error.request._currentRequest._options.method,\n });\n return this.axios.request(error.config);\n }\n const request = error.config?.baseURL ? error.config : error.request;\n this.#logger.error(`Finish Request with error ${request ? createRequestString(request) : ''}`, {\n status: error.status,\n data: error.response?.data,\n });\n throw error;\n });\n }\n\n #createBaseUrl(): void {\n if (!this.settings.serviceUrl && !this.settings.serviceName) {\n throw new Error('At least one of the settings Missing serviceUrl or serviceName');\n }\n\n const { settings } = this;\n if (settings.serviceUrl) {\n settings.baseURL = settings.serviceUrl;\n } else if (settings.serviceName) {\n const envServiceHostName = `${settings.serviceName}_SERVICE_HOST`;\n settings.baseURL = `http://${env[envServiceHostName]}`;\n }\n }\n\n /**\n * Build class methods that wrap axios methods\n */\n #buildClassHttpMethods(): void {\n HTTPMethods.forEach((method) => {\n this[method] = <T = any, R = AxiosResponse<T>>(\n ...args: Parameters<AxiosInstance[typeof method]>\n ): Promise<R> => this.axios[method](...args as [url: string, leaveUsAlone?: AxiosRequestConfig<unknown>]);\n });\n }\n\n /**\n * Fetches all pages from a paginated API endpoint using page-based pagination.\n * Continues fetching until the response size differs from the first page or returns empty.\n *\n * @param url The endpoint URL to send the request to.\n * @param options Additional Axios request options to include (e.g., headers, params).\n * @returns A promise that resolves to an array of all results from all pages.\n *\n * @example\n * ```typescript\n * const allUsers = await client.getAllPages<User>('/users', {\n * params: { status: 'active' }\n * });\n * ```\n */\n public async getAllPages<T>(url: string, options: object = {}): Promise<T[]> {\n const currentResult: T[] = [];\n let resultsInFirstPage: number | null = null;\n let lastResultsSize: number | null = null;\n const { params: { page = 1, ...restParams } = {}, ...rest } = options as any;\n // Ensure `page` is always the first property in params and initialized to 1, even if `options` already had `params`.\n const localOptions = { params: { page: page || 1, ...restParams }, ...rest };\n while ((localOptions.params.page === 1 || lastResultsSize === resultsInFirstPage) && lastResultsSize !== 0) {\n const { data } = await this.get<T[]>(url, localOptions);\n lastResultsSize = data.length;\n if (localOptions.params.page === 1) {\n resultsInFirstPage = data.length;\n }\n\n localOptions.params.page += 1;\n Array.prototype.push.apply(currentResult, data);\n }\n\n return currentResult;\n }\n\n /**\n * Fetches all pages from a paginated API endpoint that uses POST requests with `{ rows, count }` response format.\n * Continues fetching until all results are retrieved or the optional page limit is reached.\n *\n * @param url The endpoint URL to send POST requests to.\n * @param options Additional options to include in the request payload (merged with page number).\n * @param pageLimit The maximum number of pages to fetch (default: 100). Set to -1 for no limit.\n * @returns A promise that resolves to an array of all results from all pages.\n *\n * @example\n * ```typescript\n * const allOrders = await client.getAllPagesFromQueryEndpoint<Order>('/orders/query', {\n * filters: { status: 'pending' }\n * }, 50);\n * ```\n */\n public async getAllPagesFromQueryEndpoint<T>(url: string, options: object = {}, pageLimit = 100): Promise<T[]> {\n const currentResult: T[] = [];\n\n let moreResultsToLoad = true;\n let page = 1;\n while (moreResultsToLoad && (pageLimit === -1 || page < pageLimit)) {\n const { data } = await this.post<{ rows: T[]; count: number; }>(url, {\n ...options,\n page,\n });\n const { rows, count } = data;\n page += 1;\n Array.prototype.push.apply(currentResult, rows);\n moreResultsToLoad = currentResult.length < count;\n }\n\n return currentResult;\n }\n};\n"],"mappings":"svBAsBA,KAAM,CAAE,SAAUA,EAAAA,QACZ,EAA2BC,EAAAA,QAE3B,GAAA,EAAA,EAAA,eAAA,QAAA,MAAA,C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K,MAAM,GAAQ,GAAG,EAAkE,EACzG,CAkBJ,MAAa,YAAe,EAAa,EAAkB,EAAE,CAAgB,CAC3E,IAAMQ,EAAqB,EAAE,CACzBC,EAAoC,KACpCC,EAAiC,KAC/B,CAAE,OAAQ,CAAE,OAAO,EAAG,GAAG,GAAe,EAAE,CAAE,GAAG,GAAS,EAExD,EAAe,CAAE,OAAQ,CAAE,KAAM,GAAQ,EAAG,GAAG,EAAY,CAAE,GAAG,EAAM,CAC5E,MAAQ,EAAa,OAAO,OAAS,GAAK,IAAoB,IAAuB,IAAoB,GAAG,CAC1G,GAAM,CAAE,QAAS,MAAM,KAAK,IAAS,EAAK,EAAa,CACvD,EAAkB,EAAK,OACnB,EAAa,OAAO,OAAS,IAC/B,EAAqB,EAAK,QAG5B,EAAa,OAAO,MAAQ,EAC5B,MAAM,UAAU,KAAK,MAAM,EAAe,EAAK,CAGjD,OAAO,EAmBT,MAAa,6BAAgC,EAAa,EAAkB,EAAE,CAAE,EAAY,IAAmB,CAC7G,IAAMF,EAAqB,EAAE,CAEzB,EAAoB,GACpB,EAAO,EACX,KAAO,IAAsB,IAAc,IAAM,EAAO,IAAY,CAClE,GAAM,CAAE,QAAS,MAAM,KAAK,KAAoC,EAAK,CACnE,GAAG,EACH,OACD,CAAC,CACI,CAAE,OAAM,SAAU,EACxB,GAAQ,EACR,MAAM,UAAU,KAAK,MAAM,EAAe,EAAK,CAC/C,EAAoB,EAAc,OAAS,EAG7C,OAAO"}
1
+ {"version":3,"file":"index.cjs","names":["axiosCacheAdapter","axiosRetry","qsStringify: typeof stringify | undefined","qsStringifyOptions: NonNullable<Parameters<typeof stringify>[1]>","defaultSettings: NetworkSettings","env","#logger","HttpAgent","HttpsAgent","#createBaseUrl","#addRetry","#buildClassHttpMethods","#addLogs","currentResult: T[]","resultsInFirstPage: number | null","lastResultsSize: number | null"],"sources":["../src/index.ts"],"sourcesContent":["import { env } from 'node:process';\nimport { createRequire } from 'node:module';\nimport axios, { type CreateAxiosDefaults, type AxiosRequestConfig, type AxiosInstance, type AxiosResponse, type AxiosRequestHeaders } from 'axios';\nimport axiosRetry, { type IAxiosRetryConfigExtended, type IAxiosRetryConfig, type IAxiosRetryReturn } from 'axios-retry';\nimport Logger, { type LoggerInstanceManager } from '@autofleet/logger';\nimport merge from 'deepmerge';\nimport axiosCacheAdapter from '@autofleet/axios-cache-adapter';\nimport { HttpAgent, HttpsAgent } from 'agentkeepalive';\nimport type { stringify } from 'qs';\nimport type { IAxiosCacheAdapterOptions } from '@autofleet/axios-cache-adapter';\n\ndeclare module 'axios' {\n interface AxiosRequestConfig {\n /** configure how the cached requests will be handled, where they will be stored, etc. */\n cache?: IAxiosCacheAdapterOptions;\n /** force cache invalidation */\n clearCacheEntry?: boolean;\n 'axios-retry'?: IAxiosRetryConfigExtended;\n }\n}\n\nconst { setup } = axiosCacheAdapter as { setup: (options: AxiosRequestConfig) => AxiosInstance; };\nconst correctlyTypedAxiosRetry = axiosRetry as unknown as (axiosInstance: AxiosInstance, axiosRetryConfig?: IAxiosRetryConfig) => IAxiosRetryReturn;\n\nconst safeRequire = createRequire(import.meta.url);\n\nlet qsStringify: typeof stringify | undefined;\nconst lazilyLoadQsStringify = (...args: Parameters<typeof stringify>) => {\n qsStringify ??= safeRequire('qs').stringify;\n return qsStringify!(...args);\n};\n\nconst HTTPMethods = [\n 'get',\n 'post',\n 'delete',\n 'head',\n 'put',\n 'patch',\n 'options',\n] as const;\n\nconst qsStringifyOptions: NonNullable<Parameters<typeof stringify>[1]> = { arrayFormat: 'brackets' };\n\n/**\n * Network client configuration settings\n */\ninterface NetworkSettings extends CreateAxiosDefaults, IAxiosRetryConfig {\n /** Service name for Kubernetes DNS resolution (e.g., 'EXAMPLE_MS' resolves to EXAMPLE_MS_SERVICE_HOST) */\n serviceName?: string;\n /** Direct service URL (alternative to serviceName) */\n serviceUrl?: string;\n /**\n * Enable HTTP keep-alive connections (default: true)\n * @since 1.9.0 - To disable keep-alive, set to false AND set env var NETWORK_ALLOW_KEEPALIVE_FALSE=true\n */\n keepAlive?: boolean;\n /** Logger instance for request/response logging */\n logger?: LoggerInstanceManager;\n /** Request timeout in milliseconds (default: 10000) */\n timeout?: number;\n}\n\nconst defaultSettings: NetworkSettings = {\n timeout: 10_000,\n headers: {\n 'X-AF-AUTH': 'ANYONE',\n 'X-IAF-ORIGIN-SERVICE': env.AF_SERVICE_NAME || null as unknown as string,\n },\n paramsSerializer: params => lazilyLoadQsStringify(params, qsStringifyOptions),\n 'axios-retry': {\n shouldResetTimeout: true,\n },\n keepAlive: true,\n};\n\nconst createRequestString = (request: AxiosRequestConfig): string => `[${(request.method || '').toUpperCase()}] ${request.baseURL ?? 'unknown-base-url'}${request.url ?? '/unknown-url'}`;\n\n/*\n The default free socket keepalive timeout, in milliseconds.\n Setting to 5000 (5 seconds) as default because out grace period is 10 seconds\n and we want to make sure we don't have any socket issues.\n See https://www.npmjs.com/package/agentkeepalive\n\n There is also autoscaling reason for that, if we don't timeout at some point,\n new pods that were auto scaled will not be used.\n*/\nconst FREE_SOCKET_TIMEOUT = Number.parseInt(env.FREE_SOCKET_TIMEOUT || '', 10) || 5_000;\n\n/**\n * HTTP client wrapper built on Axios with keep-alive connection pooling, caching, retry logic, and logging.\n *\n * @example\n * ```typescript\n * const client = new Network({\n * serviceName: 'EXAMPLE_MS',\n * timeout: 10000,\n * retries: 3\n * });\n *\n * const response = await client.get('/endpoint');\n * await client.post('/data', { payload });\n * ```\n */\nexport default class Network {\n readonly #logger: LoggerInstanceManager;\n private readonly settings: NetworkSettings;\n private readonly axios: AxiosInstance;\n\n public get!: AxiosInstance['get'];\n public post!: AxiosInstance['post'];\n public delete!: AxiosInstance['delete'];\n public head!: AxiosInstance['head'];\n public put!: AxiosInstance['put'];\n public patch!: AxiosInstance['patch'];\n public options!: AxiosInstance['options'];\n\n constructor(settings: NetworkSettings = {}) {\n this.#logger = settings.logger ?? Logger();\n this.settings = merge(defaultSettings, settings);\n\n // Configure keep-alive behavior\n if (this.settings.keepAlive) {\n // Enable keep-alive with custom free socket timeout\n this.settings.httpAgent = new HttpAgent({ freeSocketTimeout: FREE_SOCKET_TIMEOUT });\n this.settings.httpsAgent = new HttpsAgent({ freeSocketTimeout: FREE_SOCKET_TIMEOUT });\n delete this.settings.keepAlive;\n } else if (this.settings.keepAlive === false && process.env.NETWORK_ALLOW_KEEPALIVE_FALSE === 'true') {\n // [v1.9.0] Explicitly disable keep-alive\n // Node.js 20+ has keep-alive enabled by default, so we need to explicitly set keepAlive: false\n // This env var is required to prevent silent performance degradation in services that unknowingly relied on keep-alive\n this.settings.httpAgent = new HttpAgent({ keepAlive: false });\n this.settings.httpsAgent = new HttpsAgent({ keepAlive: false });\n delete this.settings.keepAlive;\n }\n\n this.#createBaseUrl();\n\n if (settings.cache) {\n this.settings.cache = {\n maxAge: 15 * 60 * 1000,\n // Store responses from requests with query parameters in cache\n exclude: { query: false },\n ...settings.cache,\n };\n }\n\n this.axios = settings.cache ? setup(this.settings as NetworkSettings & { headers: AxiosRequestHeaders; }) : axios.create(this.settings);\n this.#addRetry(settings);\n this.#buildClassHttpMethods();\n this.#addLogs();\n }\n\n #addRetry(settings: NetworkSettings): void {\n correctlyTypedAxiosRetry(this.axios, {\n retries: 0,\n retryDelay: axiosRetry.exponentialDelay,\n ...settings,\n });\n }\n\n #addLogs(): void {\n this.axios.interceptors.request.use((request) => {\n this.#logger.info(`Start Request: ${createRequestString(request)}`);\n return request;\n });\n\n this.axios.interceptors.response.use((response) => {\n this.#logger.info(`Finish Request: ${createRequestString(response.config)}`);\n return response;\n }, (error) => {\n if (error.request?._currentRequest?.reusedSocket && ['ECONNRESET', 'EPIPE'].includes(error.code)) {\n // See https://www.npmjs.com/package/agentkeepalive\n // Support req.reusedSocket\n // https://code-examples.net/en/q/28a8069\n this.#logger.warn(`${error.code} issue, will retry`, {\n req: error.request._currentRequest._currentUrl,\n // method: error.request._currentRequest._options.method,\n });\n return this.axios.request(error.config);\n }\n const request = error.config?.baseURL ? error.config : error.request;\n this.#logger.error(`Finish Request with error ${request ? createRequestString(request) : ''}`, {\n status: error.status,\n data: error.response?.data,\n });\n throw error;\n });\n }\n\n #createBaseUrl(): void {\n if (!this.settings.serviceUrl && !this.settings.serviceName) {\n throw new Error('At least one of the settings Missing serviceUrl or serviceName');\n }\n\n const { settings } = this;\n if (settings.serviceUrl) {\n settings.baseURL = settings.serviceUrl;\n } else if (settings.serviceName) {\n const envServiceHostName = `${settings.serviceName}_SERVICE_HOST`;\n settings.baseURL = `http://${env[envServiceHostName]}`;\n }\n }\n\n /**\n * Build class methods that wrap axios methods\n */\n #buildClassHttpMethods(): void {\n HTTPMethods.forEach((method) => {\n this[method] = <T = any, R = AxiosResponse<T>>(\n ...args: Parameters<AxiosInstance[typeof method]>\n ): Promise<R> => this.axios[method](...args as [url: string, leaveUsAlone?: AxiosRequestConfig<unknown>]);\n });\n }\n\n /**\n * Fetches all pages from a paginated API endpoint using page-based pagination.\n * Continues fetching until the response size differs from the first page or returns empty.\n *\n * @param url The endpoint URL to send the request to.\n * @param options Additional Axios request options to include (e.g., headers, params).\n * @returns A promise that resolves to an array of all results from all pages.\n *\n * @example\n * ```typescript\n * const allUsers = await client.getAllPages<User>('/users', {\n * params: { status: 'active' }\n * });\n * ```\n */\n public async getAllPages<T>(url: string, options: object = {}): Promise<T[]> {\n const currentResult: T[] = [];\n let resultsInFirstPage: number | null = null;\n let lastResultsSize: number | null = null;\n const { params: { page = 1, ...restParams } = {}, ...rest } = options as any;\n // Ensure `page` is always the first property in params and initialized to 1, even if `options` already had `params`.\n const localOptions = { params: { page: page || 1, ...restParams }, ...rest };\n while ((localOptions.params.page === 1 || lastResultsSize === resultsInFirstPage) && lastResultsSize !== 0) {\n const { data } = await this.get<T[]>(url, localOptions);\n lastResultsSize = data.length;\n if (localOptions.params.page === 1) {\n resultsInFirstPage = data.length;\n }\n\n localOptions.params.page += 1;\n Array.prototype.push.apply(currentResult, data);\n }\n\n return currentResult;\n }\n\n /**\n * Fetches all pages from a paginated API endpoint that uses POST requests with `{ rows, count }` response format.\n * Continues fetching until all results are retrieved or the optional page limit is reached.\n *\n * @param url The endpoint URL to send POST requests to.\n * @param options Additional options to include in the request payload (merged with page number).\n * @param pageLimit The maximum number of pages to fetch (default: 100). Set to -1 for no limit.\n * @returns A promise that resolves to an array of all results from all pages.\n *\n * @example\n * ```typescript\n * const allOrders = await client.getAllPagesFromQueryEndpoint<Order>('/orders/query', {\n * filters: { status: 'pending' }\n * }, 50);\n * ```\n */\n public async getAllPagesFromQueryEndpoint<T>(url: string, options: object = {}, pageLimit = 100): Promise<T[]> {\n const currentResult: T[] = [];\n\n let moreResultsToLoad = true;\n let page = 1;\n while (moreResultsToLoad && (pageLimit === -1 || page < pageLimit)) {\n const { data } = await this.post<{ rows: T[]; count: number; }>(url, {\n ...options,\n page,\n });\n const { rows, count } = data;\n page += 1;\n Array.prototype.push.apply(currentResult, rows);\n moreResultsToLoad = currentResult.length < count;\n }\n\n return currentResult;\n }\n};\n"],"mappings":"svBAqBA,KAAM,CAAE,SAAUA,EAAAA,QACZ,EAA2BC,EAAAA,QAE3B,GAAA,EAAA,EAAA,eAAA,QAAA,MAAA,CAAA,cAAA,WAAA,CAAA,KAA4C,CAElD,IAAIC,EACJ,MAAM,GAAyB,GAAG,KAChC,IAAgB,EAAY,KAAK,CAAC,UAC3B,EAAa,GAAG,EAAK,EAGxB,EAAc,CAClB,MACA,OACA,SACA,OACA,MACA,QACA,UACD,CAEKC,EAAmE,CAAE,YAAa,WAAY,CAqB9FC,EAAmC,CACvC,QAAS,IACT,QAAS,CACP,YAAa,SACb,uBAAwBC,EAAAA,IAAI,iBAAmB,KAChD,CACD,iBAAkB,GAAU,EAAsB,EAAQ,EAAmB,CAC7E,cAAe,CACb,mBAAoB,GACrB,CACD,UAAW,GACZ,CAEK,EAAuB,GAAwC,KAAK,EAAQ,QAAU,IAAI,aAAa,CAAC,IAAI,EAAQ,SAAW,qBAAqB,EAAQ,KAAO,iBAWnK,EAAsB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EAC5B,MAAM,UAAU,KAAK,MAAM,EAAe,EAAK,CAGjD,OAAO,EAmBT,MAAa,6BAAgC,EAAa,EAAkB,EAAE,CAAE,EAAY,IAAmB,CAC7G,IAAMF,EAAqB,EAAE,CAEzB,EAAoB,GACpB,EAAO,EACX,KAAO,IAAsB,IAAc,IAAM,EAAO,IAAY,CAClE,GAAM,CAAE,QAAS,MAAM,KAAK,KAAoC,EAAK,CACnE,GAAG,EACH,OACD,CAAC,CACI,CAAE,OAAM,SAAU,EACxB,GAAQ,EACR,MAAM,UAAU,KAAK,MAAM,EAAe,EAAK,CAC/C,EAAoB,EAAc,OAAS,EAG7C,OAAO"}
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["qsStringify: typeof stringify | undefined","qsStringifyOptions: NonNullable<Parameters<typeof stringify>[1]>","defaultSettings: NetworkSettings","#logger","#createBaseUrl","#addRetry","#buildClassHttpMethods","#addLogs","currentResult: T[]","resultsInFirstPage: number | null","lastResultsSize: number | null"],"sources":["../src/index.ts"],"sourcesContent":["import { env } from 'node:process';\nimport { createRequire } from 'node:module';\nimport axios, { type CreateAxiosDefaults, type AxiosRequestConfig, type AxiosInstance, type AxiosResponse, type AxiosRequestHeaders } from 'axios';\nimport axiosRetry, { type IAxiosRetryConfigExtended, type IAxiosRetryConfig, type IAxiosRetryReturn } from 'axios-retry';\nimport Logger, { type LoggerInstanceManager } from '@autofleet/logger';\nimport merge from 'deepmerge';\nimport axiosCacheAdapter from '@autofleet/axios-cache-adapter';\nimport { HttpAgent, HttpsAgent } from 'agentkeepalive';\nimport type { stringify } from 'qs';\nimport type { IAxiosCacheAdapterOptions } from '@autofleet/axios-cache-adapter';\n\ndeclare module 'axios' {\n interface AxiosRequestConfig {\n /** configure how the cached requests will be handled, where they will be stored, etc. */\n cache?: IAxiosCacheAdapterOptions;\n /** force cache invalidation */\n clearCacheEntry?: boolean;\n 'axios-retry'?: IAxiosRetryConfigExtended;\n }\n}\n\n// Due to issue with multiple `axios` versions in monorepo, we need to explicitly override the types to use v0\nconst { setup } = axiosCacheAdapter as { setup: (options: AxiosRequestConfig) => AxiosInstance; };\nconst correctlyTypedAxiosRetry = axiosRetry as unknown as (axiosInstance: AxiosInstance, axiosRetryConfig?: IAxiosRetryConfig) => IAxiosRetryReturn;\n\nconst safeRequire = createRequire(import.meta.url);\n\nlet qsStringify: typeof stringify | undefined;\nconst lazilyLoadQsStringify = (...args: Parameters<typeof stringify>) => {\n qsStringify ??= safeRequire('qs').stringify;\n return qsStringify!(...args);\n};\n\nconst HTTPMethods = [\n 'get',\n 'post',\n 'delete',\n 'head',\n 'put',\n 'patch',\n 'options',\n] as const;\n\nconst qsStringifyOptions: NonNullable<Parameters<typeof stringify>[1]> = { arrayFormat: 'brackets' };\n\n/**\n * Network client configuration settings\n */\ninterface NetworkSettings extends CreateAxiosDefaults, IAxiosRetryConfig {\n /** Service name for Kubernetes DNS resolution (e.g., 'EXAMPLE_MS' resolves to EXAMPLE_MS_SERVICE_HOST) */\n serviceName?: string;\n /** Direct service URL (alternative to serviceName) */\n serviceUrl?: string;\n /**\n * Enable HTTP keep-alive connections (default: true)\n * @since 1.9.0 - To disable keep-alive, set to false AND set env var NETWORK_ALLOW_KEEPALIVE_FALSE=true\n */\n keepAlive?: boolean;\n /** Logger instance for request/response logging */\n logger?: LoggerInstanceManager;\n /** Request timeout in milliseconds (default: 10000) */\n timeout?: number;\n}\n\nconst defaultSettings: NetworkSettings = {\n timeout: 10_000,\n headers: {\n 'X-AF-AUTH': 'ANYONE',\n 'X-IAF-ORIGIN-SERVICE': env.AF_SERVICE_NAME || null as unknown as string,\n },\n paramsSerializer: params => lazilyLoadQsStringify(params, qsStringifyOptions),\n 'axios-retry': {\n shouldResetTimeout: true,\n },\n keepAlive: true,\n};\n\nconst createRequestString = (request: AxiosRequestConfig): string => `[${(request.method || '').toUpperCase()}] ${request.baseURL ?? 'unknown-base-url'}${request.url ?? '/unknown-url'}`;\n\n/*\n The default free socket keepalive timeout, in milliseconds.\n Setting to 5000 (5 seconds) as default because out grace period is 10 seconds\n and we want to make sure we don't have any socket issues.\n See https://www.npmjs.com/package/agentkeepalive\n\n There is also autoscaling reason for that, if we don't timeout at some point,\n new pods that were auto scaled will not be used.\n*/\nconst FREE_SOCKET_TIMEOUT = Number.parseInt(env.FREE_SOCKET_TIMEOUT || '', 10) || 5_000;\n\n/**\n * HTTP client wrapper built on Axios with keep-alive connection pooling, caching, retry logic, and logging.\n *\n * @example\n * ```typescript\n * const client = new Network({\n * serviceName: 'EXAMPLE_MS',\n * timeout: 10000,\n * retries: 3\n * });\n *\n * const response = await client.get('/endpoint');\n * await client.post('/data', { payload });\n * ```\n */\nexport default class Network {\n readonly #logger: LoggerInstanceManager;\n private readonly settings: NetworkSettings;\n private readonly axios: AxiosInstance;\n\n public get!: AxiosInstance['get'];\n public post!: AxiosInstance['post'];\n public delete!: AxiosInstance['delete'];\n public head!: AxiosInstance['head'];\n public put!: AxiosInstance['put'];\n public patch!: AxiosInstance['patch'];\n public options!: AxiosInstance['options'];\n\n constructor(settings: NetworkSettings = {}) {\n this.#logger = settings.logger ?? Logger();\n this.settings = merge(defaultSettings, settings);\n\n // Configure keep-alive behavior\n if (this.settings.keepAlive) {\n // Enable keep-alive with custom free socket timeout\n this.settings.httpAgent = new HttpAgent({ freeSocketTimeout: FREE_SOCKET_TIMEOUT });\n this.settings.httpsAgent = new HttpsAgent({ freeSocketTimeout: FREE_SOCKET_TIMEOUT });\n delete this.settings.keepAlive;\n } else if (this.settings.keepAlive === false && process.env.NETWORK_ALLOW_KEEPALIVE_FALSE === 'true') {\n // [v1.9.0] Explicitly disable keep-alive\n // Node.js 20+ has keep-alive enabled by default, so we need to explicitly set keepAlive: false\n // This env var is required to prevent silent performance degradation in services that unknowingly relied on keep-alive\n this.settings.httpAgent = new HttpAgent({ keepAlive: false });\n this.settings.httpsAgent = new HttpsAgent({ keepAlive: false });\n delete this.settings.keepAlive;\n }\n\n this.#createBaseUrl();\n\n if (settings.cache) {\n this.settings.cache = {\n maxAge: 15 * 60 * 1000,\n // Store responses from requests with query parameters in cache\n exclude: { query: false },\n ...settings.cache,\n };\n }\n\n this.axios = settings.cache ? setup(this.settings as NetworkSettings & { headers: AxiosRequestHeaders; }) : axios.create(this.settings);\n this.#addRetry(settings);\n this.#buildClassHttpMethods();\n this.#addLogs();\n }\n\n #addRetry(settings: NetworkSettings): void {\n correctlyTypedAxiosRetry(this.axios, {\n retries: 0,\n retryDelay: axiosRetry.exponentialDelay,\n ...settings,\n });\n }\n\n #addLogs(): void {\n this.axios.interceptors.request.use((request) => {\n this.#logger.info(`Start Request: ${createRequestString(request)}`);\n return request;\n });\n\n this.axios.interceptors.response.use((response) => {\n this.#logger.info(`Finish Request: ${createRequestString(response.config)}`);\n return response;\n }, (error) => {\n if (error.request?._currentRequest?.reusedSocket && ['ECONNRESET', 'EPIPE'].includes(error.code)) {\n // See https://www.npmjs.com/package/agentkeepalive\n // Support req.reusedSocket\n // https://code-examples.net/en/q/28a8069\n this.#logger.warn(`${error.code} issue, will retry`, {\n req: error.request._currentRequest._currentUrl,\n // method: error.request._currentRequest._options.method,\n });\n return this.axios.request(error.config);\n }\n const request = error.config?.baseURL ? error.config : error.request;\n this.#logger.error(`Finish Request with error ${request ? createRequestString(request) : ''}`, {\n status: error.status,\n data: error.response?.data,\n });\n throw error;\n });\n }\n\n #createBaseUrl(): void {\n if (!this.settings.serviceUrl && !this.settings.serviceName) {\n throw new Error('At least one of the settings Missing serviceUrl or serviceName');\n }\n\n const { settings } = this;\n if (settings.serviceUrl) {\n settings.baseURL = settings.serviceUrl;\n } else if (settings.serviceName) {\n const envServiceHostName = `${settings.serviceName}_SERVICE_HOST`;\n settings.baseURL = `http://${env[envServiceHostName]}`;\n }\n }\n\n /**\n * Build class methods that wrap axios methods\n */\n #buildClassHttpMethods(): void {\n HTTPMethods.forEach((method) => {\n this[method] = <T = any, R = AxiosResponse<T>>(\n ...args: Parameters<AxiosInstance[typeof method]>\n ): Promise<R> => this.axios[method](...args as [url: string, leaveUsAlone?: AxiosRequestConfig<unknown>]);\n });\n }\n\n /**\n * Fetches all pages from a paginated API endpoint using page-based pagination.\n * Continues fetching until the response size differs from the first page or returns empty.\n *\n * @param url The endpoint URL to send the request to.\n * @param options Additional Axios request options to include (e.g., headers, params).\n * @returns A promise that resolves to an array of all results from all pages.\n *\n * @example\n * ```typescript\n * const allUsers = await client.getAllPages<User>('/users', {\n * params: { status: 'active' }\n * });\n * ```\n */\n public async getAllPages<T>(url: string, options: object = {}): Promise<T[]> {\n const currentResult: T[] = [];\n let resultsInFirstPage: number | null = null;\n let lastResultsSize: number | null = null;\n const { params: { page = 1, ...restParams } = {}, ...rest } = options as any;\n // Ensure `page` is always the first property in params and initialized to 1, even if `options` already had `params`.\n const localOptions = { params: { page: page || 1, ...restParams }, ...rest };\n while ((localOptions.params.page === 1 || lastResultsSize === resultsInFirstPage) && lastResultsSize !== 0) {\n const { data } = await this.get<T[]>(url, localOptions);\n lastResultsSize = data.length;\n if (localOptions.params.page === 1) {\n resultsInFirstPage = data.length;\n }\n\n localOptions.params.page += 1;\n Array.prototype.push.apply(currentResult, data);\n }\n\n return currentResult;\n }\n\n /**\n * Fetches all pages from a paginated API endpoint that uses POST requests with `{ rows, count }` response format.\n * Continues fetching until all results are retrieved or the optional page limit is reached.\n *\n * @param url The endpoint URL to send POST requests to.\n * @param options Additional options to include in the request payload (merged with page number).\n * @param pageLimit The maximum number of pages to fetch (default: 100). Set to -1 for no limit.\n * @returns A promise that resolves to an array of all results from all pages.\n *\n * @example\n * ```typescript\n * const allOrders = await client.getAllPagesFromQueryEndpoint<Order>('/orders/query', {\n * filters: { status: 'pending' }\n * }, 50);\n * ```\n */\n public async getAllPagesFromQueryEndpoint<T>(url: string, options: object = {}, pageLimit = 100): Promise<T[]> {\n const currentResult: T[] = [];\n\n let moreResultsToLoad = true;\n let page = 1;\n while (moreResultsToLoad && (pageLimit === -1 || page < pageLimit)) {\n const { data } = await this.post<{ rows: T[]; count: number; }>(url, {\n ...options,\n page,\n });\n const { rows, count } = data;\n page += 1;\n Array.prototype.push.apply(currentResult, rows);\n moreResultsToLoad = currentResult.length < count;\n }\n\n return currentResult;\n }\n};\n"],"mappings":"kSAsBA,KAAM,CAAE,SAAU,EACZ,EAA2B,EAE3B,EAAc,EAAc,OAAO,KAAK,IAAI,CAElD,IAAIA,EACJ,MAAM,GAAyB,GAAG,KAChC,IAAgB,EAAY,KAAK,CAAC,UAC3B,EAAa,GAAG,EAAK,EAGxB,EAAc,CAClB,MACA,OACA,SACA,OACA,MACA,QACA,UACD,CAEKC,EAAmE,CAAE,YAAa,WAAY,CAqB9FC,EAAmC,CACvC,QAAS,IACT,QAAS,CACP,YAAa,SACb,uBAAwB,EAAI,iBAAmB,KAChD,CACD,iBAAkB,GAAU,EAAsB,EAAQ,EAAmB,CAC7E,cAAe,CACb,mBAAoB,GACrB,CACD,UAAW,GACZ,CAEK,EAAuB,GAAwC,KAAK,EAAQ,QAAU,IAAI,aAAa,CAAC,IAAI,EAAQ,SAAW,qBAAqB,EAAQ,KAAO,iBAWnK,EAAsB,OAAO,SAAS,EAAI,qBAAuB,GAAI,GAAG,EAAI,IAiBlF,IAAqB,EAArB,KAA6B,CAC3B,GAYA,YAAY,EAA4B,EAAE,CAAE,CAC1C,MAAA,EAAe,EAAS,QAAU,GAAQ,CAC1C,KAAK,SAAW,EAAM,EAAiB,EAAS,CAG5C,KAAK,SAAS,WAEhB,KAAK,SAAS,UAAY,IAAI,EAAU,CAAE,kBAAmB,EAAqB,CAAC,CACnF,KAAK,SAAS,WAAa,IAAI,EAAW,CAAE,kBAAmB,EAAqB,CAAC,CACrF,OAAO,KAAK,SAAS,WACZ,KAAK,SAAS,YAAc,IAAS,QAAQ,IAAI,gCAAkC,SAI5F,KAAK,SAAS,UAAY,IAAI,EAAU,CAAE,UAAW,GAAO,CAAC,CAC7D,KAAK,SAAS,WAAa,IAAI,EAAW,CAAE,UAAW,GAAO,CAAC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UAAU,EADF,GAAG,EAAS,YAAY,mBAQvD,IAA+B,CAC7B,EAAY,QAAS,GAAW,CAC9B,KAAK,IACH,GAAG,IACY,KAAK,MAAM,GAAQ,GAAG,EAAkE,EACzG,CAkBJ,MAAa,YAAe,EAAa,EAAkB,EAAE,CAAgB,CAC3E,IAAMM,EAAqB,EAAE,CACzBC,EAAoC,KACpCC,EAAiC,KAC/B,CAAE,OAAQ,CAAE,OAAO,EAAG,GAAG,GAAe,EAAE,CAAE,GAAG,GAAS,EAExD,EAAe,CAAE,OAAQ,CAAE,KAAM,GAAQ,EAAG,GAAG,EAAY,CAAE,GAAG,EAAM,CAC5E,MAAQ,EAAa,OAAO,OAAS,GAAK,IAAoB,IAAuB,IAAoB,GAAG,CAC1G,GAAM,CAAE,QAAS,MAAM,KAAK,IAAS,EAAK,EAAa,CACvD,EAAkB,EAAK,OACnB,EAAa,OAAO,OAAS,IAC/B,EAAqB,EAAK,QAG5B,EAAa,OAAO,MAAQ,EAC5B,MAAM,UAAU,KAAK,MAAM,EAAe,EAAK,CAGjD,OAAO,EAmBT,MAAa,6BAAgC,EAAa,EAAkB,EAAE,CAAE,EAAY,IAAmB,CAC7G,IAAMF,EAAqB,EAAE,CAEzB,EAAoB,GACpB,EAAO,EACX,KAAO,IAAsB,IAAc,IAAM,EAAO,IAAY,CAClE,GAAM,CAAE,QAAS,MAAM,KAAK,KAAoC,EAAK,CACnE,GAAG,EACH,OACD,CAAC,CACI,CAAE,OAAM,SAAU,EACxB,GAAQ,EACR,MAAM,UAAU,KAAK,MAAM,EAAe,EAAK,CAC/C,EAAoB,EAAc,OAAS,EAG7C,OAAO"}
1
+ {"version":3,"file":"index.js","names":["qsStringify: typeof stringify | undefined","qsStringifyOptions: NonNullable<Parameters<typeof stringify>[1]>","defaultSettings: NetworkSettings","#logger","#createBaseUrl","#addRetry","#buildClassHttpMethods","#addLogs","currentResult: T[]","resultsInFirstPage: number | null","lastResultsSize: number | null"],"sources":["../src/index.ts"],"sourcesContent":["import { env } from 'node:process';\nimport { createRequire } from 'node:module';\nimport axios, { type CreateAxiosDefaults, type AxiosRequestConfig, type AxiosInstance, type AxiosResponse, type AxiosRequestHeaders } from 'axios';\nimport axiosRetry, { type IAxiosRetryConfigExtended, type IAxiosRetryConfig, type IAxiosRetryReturn } from 'axios-retry';\nimport Logger, { type LoggerInstanceManager } from '@autofleet/logger';\nimport merge from 'deepmerge';\nimport axiosCacheAdapter from '@autofleet/axios-cache-adapter';\nimport { HttpAgent, HttpsAgent } from 'agentkeepalive';\nimport type { stringify } from 'qs';\nimport type { IAxiosCacheAdapterOptions } from '@autofleet/axios-cache-adapter';\n\ndeclare module 'axios' {\n interface AxiosRequestConfig {\n /** configure how the cached requests will be handled, where they will be stored, etc. */\n cache?: IAxiosCacheAdapterOptions;\n /** force cache invalidation */\n clearCacheEntry?: boolean;\n 'axios-retry'?: IAxiosRetryConfigExtended;\n }\n}\n\nconst { setup } = axiosCacheAdapter as { setup: (options: AxiosRequestConfig) => AxiosInstance; };\nconst correctlyTypedAxiosRetry = axiosRetry as unknown as (axiosInstance: AxiosInstance, axiosRetryConfig?: IAxiosRetryConfig) => IAxiosRetryReturn;\n\nconst safeRequire = createRequire(import.meta.url);\n\nlet qsStringify: typeof stringify | undefined;\nconst lazilyLoadQsStringify = (...args: Parameters<typeof stringify>) => {\n qsStringify ??= safeRequire('qs').stringify;\n return qsStringify!(...args);\n};\n\nconst HTTPMethods = [\n 'get',\n 'post',\n 'delete',\n 'head',\n 'put',\n 'patch',\n 'options',\n] as const;\n\nconst qsStringifyOptions: NonNullable<Parameters<typeof stringify>[1]> = { arrayFormat: 'brackets' };\n\n/**\n * Network client configuration settings\n */\ninterface NetworkSettings extends CreateAxiosDefaults, IAxiosRetryConfig {\n /** Service name for Kubernetes DNS resolution (e.g., 'EXAMPLE_MS' resolves to EXAMPLE_MS_SERVICE_HOST) */\n serviceName?: string;\n /** Direct service URL (alternative to serviceName) */\n serviceUrl?: string;\n /**\n * Enable HTTP keep-alive connections (default: true)\n * @since 1.9.0 - To disable keep-alive, set to false AND set env var NETWORK_ALLOW_KEEPALIVE_FALSE=true\n */\n keepAlive?: boolean;\n /** Logger instance for request/response logging */\n logger?: LoggerInstanceManager;\n /** Request timeout in milliseconds (default: 10000) */\n timeout?: number;\n}\n\nconst defaultSettings: NetworkSettings = {\n timeout: 10_000,\n headers: {\n 'X-AF-AUTH': 'ANYONE',\n 'X-IAF-ORIGIN-SERVICE': env.AF_SERVICE_NAME || null as unknown as string,\n },\n paramsSerializer: params => lazilyLoadQsStringify(params, qsStringifyOptions),\n 'axios-retry': {\n shouldResetTimeout: true,\n },\n keepAlive: true,\n};\n\nconst createRequestString = (request: AxiosRequestConfig): string => `[${(request.method || '').toUpperCase()}] ${request.baseURL ?? 'unknown-base-url'}${request.url ?? '/unknown-url'}`;\n\n/*\n The default free socket keepalive timeout, in milliseconds.\n Setting to 5000 (5 seconds) as default because out grace period is 10 seconds\n and we want to make sure we don't have any socket issues.\n See https://www.npmjs.com/package/agentkeepalive\n\n There is also autoscaling reason for that, if we don't timeout at some point,\n new pods that were auto scaled will not be used.\n*/\nconst FREE_SOCKET_TIMEOUT = Number.parseInt(env.FREE_SOCKET_TIMEOUT || '', 10) || 5_000;\n\n/**\n * HTTP client wrapper built on Axios with keep-alive connection pooling, caching, retry logic, and logging.\n *\n * @example\n * ```typescript\n * const client = new Network({\n * serviceName: 'EXAMPLE_MS',\n * timeout: 10000,\n * retries: 3\n * });\n *\n * const response = await client.get('/endpoint');\n * await client.post('/data', { payload });\n * ```\n */\nexport default class Network {\n readonly #logger: LoggerInstanceManager;\n private readonly settings: NetworkSettings;\n private readonly axios: AxiosInstance;\n\n public get!: AxiosInstance['get'];\n public post!: AxiosInstance['post'];\n public delete!: AxiosInstance['delete'];\n public head!: AxiosInstance['head'];\n public put!: AxiosInstance['put'];\n public patch!: AxiosInstance['patch'];\n public options!: AxiosInstance['options'];\n\n constructor(settings: NetworkSettings = {}) {\n this.#logger = settings.logger ?? Logger();\n this.settings = merge(defaultSettings, settings);\n\n // Configure keep-alive behavior\n if (this.settings.keepAlive) {\n // Enable keep-alive with custom free socket timeout\n this.settings.httpAgent = new HttpAgent({ freeSocketTimeout: FREE_SOCKET_TIMEOUT });\n this.settings.httpsAgent = new HttpsAgent({ freeSocketTimeout: FREE_SOCKET_TIMEOUT });\n delete this.settings.keepAlive;\n } else if (this.settings.keepAlive === false && process.env.NETWORK_ALLOW_KEEPALIVE_FALSE === 'true') {\n // [v1.9.0] Explicitly disable keep-alive\n // Node.js 20+ has keep-alive enabled by default, so we need to explicitly set keepAlive: false\n // This env var is required to prevent silent performance degradation in services that unknowingly relied on keep-alive\n this.settings.httpAgent = new HttpAgent({ keepAlive: false });\n this.settings.httpsAgent = new HttpsAgent({ keepAlive: false });\n delete this.settings.keepAlive;\n }\n\n this.#createBaseUrl();\n\n if (settings.cache) {\n this.settings.cache = {\n maxAge: 15 * 60 * 1000,\n // Store responses from requests with query parameters in cache\n exclude: { query: false },\n ...settings.cache,\n };\n }\n\n this.axios = settings.cache ? setup(this.settings as NetworkSettings & { headers: AxiosRequestHeaders; }) : axios.create(this.settings);\n this.#addRetry(settings);\n this.#buildClassHttpMethods();\n this.#addLogs();\n }\n\n #addRetry(settings: NetworkSettings): void {\n correctlyTypedAxiosRetry(this.axios, {\n retries: 0,\n retryDelay: axiosRetry.exponentialDelay,\n ...settings,\n });\n }\n\n #addLogs(): void {\n this.axios.interceptors.request.use((request) => {\n this.#logger.info(`Start Request: ${createRequestString(request)}`);\n return request;\n });\n\n this.axios.interceptors.response.use((response) => {\n this.#logger.info(`Finish Request: ${createRequestString(response.config)}`);\n return response;\n }, (error) => {\n if (error.request?._currentRequest?.reusedSocket && ['ECONNRESET', 'EPIPE'].includes(error.code)) {\n // See https://www.npmjs.com/package/agentkeepalive\n // Support req.reusedSocket\n // https://code-examples.net/en/q/28a8069\n this.#logger.warn(`${error.code} issue, will retry`, {\n req: error.request._currentRequest._currentUrl,\n // method: error.request._currentRequest._options.method,\n });\n return this.axios.request(error.config);\n }\n const request = error.config?.baseURL ? error.config : error.request;\n this.#logger.error(`Finish Request with error ${request ? createRequestString(request) : ''}`, {\n status: error.status,\n data: error.response?.data,\n });\n throw error;\n });\n }\n\n #createBaseUrl(): void {\n if (!this.settings.serviceUrl && !this.settings.serviceName) {\n throw new Error('At least one of the settings Missing serviceUrl or serviceName');\n }\n\n const { settings } = this;\n if (settings.serviceUrl) {\n settings.baseURL = settings.serviceUrl;\n } else if (settings.serviceName) {\n const envServiceHostName = `${settings.serviceName}_SERVICE_HOST`;\n settings.baseURL = `http://${env[envServiceHostName]}`;\n }\n }\n\n /**\n * Build class methods that wrap axios methods\n */\n #buildClassHttpMethods(): void {\n HTTPMethods.forEach((method) => {\n this[method] = <T = any, R = AxiosResponse<T>>(\n ...args: Parameters<AxiosInstance[typeof method]>\n ): Promise<R> => this.axios[method](...args as [url: string, leaveUsAlone?: AxiosRequestConfig<unknown>]);\n });\n }\n\n /**\n * Fetches all pages from a paginated API endpoint using page-based pagination.\n * Continues fetching until the response size differs from the first page or returns empty.\n *\n * @param url The endpoint URL to send the request to.\n * @param options Additional Axios request options to include (e.g., headers, params).\n * @returns A promise that resolves to an array of all results from all pages.\n *\n * @example\n * ```typescript\n * const allUsers = await client.getAllPages<User>('/users', {\n * params: { status: 'active' }\n * });\n * ```\n */\n public async getAllPages<T>(url: string, options: object = {}): Promise<T[]> {\n const currentResult: T[] = [];\n let resultsInFirstPage: number | null = null;\n let lastResultsSize: number | null = null;\n const { params: { page = 1, ...restParams } = {}, ...rest } = options as any;\n // Ensure `page` is always the first property in params and initialized to 1, even if `options` already had `params`.\n const localOptions = { params: { page: page || 1, ...restParams }, ...rest };\n while ((localOptions.params.page === 1 || lastResultsSize === resultsInFirstPage) && lastResultsSize !== 0) {\n const { data } = await this.get<T[]>(url, localOptions);\n lastResultsSize = data.length;\n if (localOptions.params.page === 1) {\n resultsInFirstPage = data.length;\n }\n\n localOptions.params.page += 1;\n Array.prototype.push.apply(currentResult, data);\n }\n\n return currentResult;\n }\n\n /**\n * Fetches all pages from a paginated API endpoint that uses POST requests with `{ rows, count }` response format.\n * Continues fetching until all results are retrieved or the optional page limit is reached.\n *\n * @param url The endpoint URL to send POST requests to.\n * @param options Additional options to include in the request payload (merged with page number).\n * @param pageLimit The maximum number of pages to fetch (default: 100). Set to -1 for no limit.\n * @returns A promise that resolves to an array of all results from all pages.\n *\n * @example\n * ```typescript\n * const allOrders = await client.getAllPagesFromQueryEndpoint<Order>('/orders/query', {\n * filters: { status: 'pending' }\n * }, 50);\n * ```\n */\n public async getAllPagesFromQueryEndpoint<T>(url: string, options: object = {}, pageLimit = 100): Promise<T[]> {\n const currentResult: T[] = [];\n\n let moreResultsToLoad = true;\n let page = 1;\n while (moreResultsToLoad && (pageLimit === -1 || page < pageLimit)) {\n const { data } = await this.post<{ rows: T[]; count: number; }>(url, {\n ...options,\n page,\n });\n const { rows, count } = data;\n page += 1;\n Array.prototype.push.apply(currentResult, rows);\n moreResultsToLoad = currentResult.length < count;\n }\n\n return currentResult;\n }\n};\n"],"mappings":"kSAqBA,KAAM,CAAE,SAAU,EACZ,EAA2B,EAE3B,EAAc,EAAc,OAAO,KAAK,IAAI,CAElD,IAAIA,EACJ,MAAM,GAAyB,GAAG,KAChC,IAAgB,EAAY,KAAK,CAAC,UAC3B,EAAa,GAAG,EAAK,EAGxB,EAAc,CAClB,MACA,OACA,SACA,OACA,MACA,QACA,UACD,CAEKC,EAAmE,CAAE,YAAa,WAAY,CAqB9FC,EAAmC,CACvC,QAAS,IACT,QAAS,CACP,YAAa,SACb,uBAAwB,EAAI,iBAAmB,KAChD,CACD,iBAAkB,GAAU,EAAsB,EAAQ,EAAmB,CAC7E,cAAe,CACb,mBAAoB,GACrB,CACD,UAAW,GACZ,CAEK,EAAuB,GAAwC,KAAK,EAAQ,QAAU,IAAI,aAAa,CAAC,IAAI,EAAQ,SAAW,qBAAqB,EAAQ,KAAO,iBAWnK,EAAsB,OAAO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E,CAAE,EAAY,IAAmB,CAC7G,IAAMF,EAAqB,EAAE,CAEzB,EAAoB,GACpB,EAAO,EACX,KAAO,IAAsB,IAAc,IAAM,EAAO,IAAY,CAClE,GAAM,CAAE,QAAS,MAAM,KAAK,KAAoC,EAAK,CACnE,GAAG,EACH,OACD,CAAC,CACI,CAAE,OAAM,SAAU,EACxB,GAAQ,EACR,MAAM,UAAU,KAAK,MAAM,EAAe,EAAK,CAC/C,EAAoB,EAAc,OAAS,EAG7C,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/network",
3
- "version": "1.9.17",
3
+ "version": "1.11.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "./lib/index.cjs",
@@ -27,9 +27,9 @@
27
27
  "author": "Dor Shay",
28
28
  "license": "Proprietary",
29
29
  "dependencies": {
30
- "@autofleet/axios-cache-adapter": "^2.7.3-hotfix-1",
30
+ "@autofleet/axios-cache-adapter": "^2.8.0",
31
31
  "agentkeepalive": "^4.6.0",
32
- "axios": "^0.30.3",
32
+ "axios": "^1.15.0",
33
33
  "axios-retry": "^4.5.0",
34
34
  "deepmerge": "^4.3.1",
35
35
  "qs": "^6.14.0"