diff --git a/ts/core/index.ts b/ts/core/index.ts index 9878a50..4d9ef17 100644 --- a/ts/core/index.ts +++ b/ts/core/index.ts @@ -1,4 +1,4 @@ // Core exports export * from './types.js'; export * from './response.js'; -export { SmartRequest, isUnixSocket, parseUnixSocketUrl } from './request.js'; \ No newline at end of file +export { CoreRequest, isUnixSocket, parseUnixSocketUrl } from './request.js'; \ No newline at end of file diff --git a/ts/core/request.ts b/ts/core/request.ts index 7adceef..158e40a 100644 --- a/ts/core/request.ts +++ b/ts/core/request.ts @@ -1,6 +1,6 @@ import * as plugins from './plugins.js'; import * as types from './types.js'; -import { SmartResponse } from './response.js'; +import { CoreResponse } from './response.js'; // Keep-alive agents for connection pooling const httpAgent = new plugins.agentkeepalive.HttpAgent({ @@ -26,9 +26,9 @@ const httpsAgentKeepAliveFalse = new plugins.agentkeepalive.HttpsAgent({ }); /** - * Modern Request class that handles all HTTP/HTTPS requests + * Core Request class that handles all HTTP/HTTPS requests */ -export class SmartRequest { +export class CoreRequest { /** * Tests if a URL is a unix socket */ @@ -63,17 +63,17 @@ export class SmartRequest { } /** - * Execute the request and return a SmartResponse + * Fire the request and return a CoreResponse */ - async execute(): Promise { - const incomingMessage = await this.executeCore(); - return new SmartResponse(incomingMessage, this.url); + async fire(): Promise { + const incomingMessage = await this.fireCore(); + return new CoreResponse(incomingMessage, this.url); } /** - * Execute the request and return the raw IncomingMessage + * Fire the request and return the raw IncomingMessage */ - async executeCore(): Promise { + async fireCore(): Promise { const done = plugins.smartpromise.defer(); // Parse URL @@ -88,8 +88,8 @@ export class SmartRequest { this.options.path = parsedUrl.path; // Handle unix socket URLs - if (SmartRequest.isUnixSocket(this.url)) { - const { socketPath, path } = SmartRequest.parseUnixSocketUrl(this.options.path); + if (CoreRequest.isUnixSocket(this.url)) { + const { socketPath, path } = CoreRequest.parseUnixSocketUrl(this.options.path); this.options.socketPath = socketPath; this.options.path = path; } @@ -166,19 +166,19 @@ export class SmartRequest { } /** - * Static factory method to create and execute a request + * Static factory method to create and fire a request */ static async create( url: string, options: types.ICoreRequestOptions = {} - ): Promise { - const request = new SmartRequest(url, options); - return request.execute(); + ): Promise { + const request = new CoreRequest(url, options); + return request.fire(); } } /** * Convenience exports for backward compatibility */ -export const isUnixSocket = SmartRequest.isUnixSocket; -export const parseUnixSocketUrl = SmartRequest.parseUnixSocketUrl; \ No newline at end of file +export const isUnixSocket = CoreRequest.isUnixSocket; +export const parseUnixSocketUrl = CoreRequest.parseUnixSocketUrl; \ No newline at end of file diff --git a/ts/core/response.ts b/ts/core/response.ts index 032d3c8..cae4ce4 100644 --- a/ts/core/response.ts +++ b/ts/core/response.ts @@ -2,9 +2,9 @@ import * as plugins from './plugins.js'; import * as types from './types.js'; /** - * Modern Response class that provides a fetch-like API + * Core Response class that provides a fetch-like API */ -export class SmartResponse implements types.ICoreResponse { +export class CoreResponse implements types.ICoreResponse { private incomingMessage: plugins.http.IncomingMessage; private bodyBufferPromise: Promise | null = null; private consumed = false; diff --git a/ts/legacy/adapter.ts b/ts/legacy/adapter.ts index fbc1491..699bdbb 100644 --- a/ts/legacy/adapter.ts +++ b/ts/legacy/adapter.ts @@ -72,8 +72,8 @@ export async function request( responseStreamArg = false, requestDataFunc?: (req: plugins.http.ClientRequest) => void ): Promise { - const smartRequest = new core.SmartRequest(urlArg, optionsArg, requestDataFunc); - const stream = await smartRequest.executeCore(); + const coreRequest = new core.CoreRequest(urlArg, optionsArg, requestDataFunc); + const stream = await coreRequest.fireCore(); if (responseStreamArg) { // For stream responses, just cast and return diff --git a/ts/modern/features/pagination.ts b/ts/modern/features/pagination.ts index 15ead9d..4bb85cf 100644 --- a/ts/modern/features/pagination.ts +++ b/ts/modern/features/pagination.ts @@ -1,11 +1,11 @@ -import { type SmartResponse } from '../../core/index.js'; +import { type CoreResponse } from '../../core/index.js'; import { type TPaginationConfig, PaginationStrategy, type TPaginatedResponse } from '../types/pagination.js'; /** * Creates a paginated response from a regular response */ export async function createPaginatedResponse( - response: SmartResponse, + response: CoreResponse, paginationConfig: TPaginationConfig, queryParams: Record, fetchNextPage: (params: Record) => Promise> diff --git a/ts/modern/index.ts b/ts/modern/index.ts index af6a0f4..b823d3a 100644 --- a/ts/modern/index.ts +++ b/ts/modern/index.ts @@ -2,7 +2,7 @@ export { SmartRequestClient } from './smartrequestclient.js'; // Export response type from core -export { SmartResponse } from '../core/index.js'; +export { CoreResponse } from '../core/index.js'; // Export types export type { HttpMethod, ResponseType, FormField, RetryConfig, TimeoutConfig } from './types/common.js'; diff --git a/ts/modern/smartrequestclient.ts b/ts/modern/smartrequestclient.ts index dec04a0..8289784 100644 --- a/ts/modern/smartrequestclient.ts +++ b/ts/modern/smartrequestclient.ts @@ -1,4 +1,4 @@ -import { SmartRequest, SmartResponse, type ICoreRequestOptions } from '../core/index.js'; +import { CoreRequest, CoreResponse, type ICoreRequestOptions } from '../core/index.js'; import * as plugins from '../core/plugins.js'; import type { HttpMethod, ResponseType, FormField } from './types/common.js'; @@ -223,35 +223,35 @@ export class SmartRequestClient { /** * Make a GET request */ - async get(): Promise> { + async get(): Promise> { return this.execute('GET'); } /** * Make a POST request */ - async post(): Promise> { + async post(): Promise> { return this.execute('POST'); } /** * Make a PUT request */ - async put(): Promise> { + async put(): Promise> { return this.execute('PUT'); } /** * Make a DELETE request */ - async delete(): Promise> { + async delete(): Promise> { return this.execute('DELETE'); } /** * Make a PATCH request */ - async patch(): Promise> { + async patch(): Promise> { return this.execute('PATCH'); } @@ -296,7 +296,7 @@ export class SmartRequestClient { /** * Execute the HTTP request */ - private async execute(method?: HttpMethod): Promise> { + private async execute(method?: HttpMethod): Promise> { if (method) { this._options.method = method; } @@ -308,8 +308,8 @@ export class SmartRequestClient { for (let attempt = 0; attempt <= this._retries; attempt++) { try { - const response = await SmartRequest.create(this._url, this._options); - return response as SmartResponse; + const response = await CoreRequest.create(this._url, this._options); + return response as CoreResponse; } catch (error) { lastError = error as Error;