BREAKING CHANGE(core): major architectural refactoring with cross-platform support and SmartRequest rename
Some checks failed
Default (tags) / security (push) Failing after 24s
Default (tags) / test (push) Failing after 12s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped

This commit is contained in:
2025-07-28 23:20:52 +00:00
parent 8e75047d1f
commit 2dc82bd730
10 changed files with 2019 additions and 2545 deletions

View File

@@ -1,5 +1,5 @@
// Export the main client
export { SmartRequestClient } from './smartrequestclient.js';
export { SmartRequest } from './smartrequest.js';
// Export response type from core
export { CoreResponse } from '../core/index.js';
@@ -17,32 +17,32 @@ export {
} from './types/pagination.js';
// Convenience factory functions
import { SmartRequestClient } from './smartrequestclient.js';
import { SmartRequest } from './smartrequest.js';
/**
* Create a client pre-configured for JSON requests
*/
export function createJsonClient<T = any>() {
return SmartRequestClient.create<T>();
return SmartRequest.create<T>();
}
/**
* Create a client pre-configured for form data requests
*/
export function createFormClient<T = any>() {
return SmartRequestClient.create<T>();
return SmartRequest.create<T>();
}
/**
* Create a client pre-configured for binary data
*/
export function createBinaryClient<T = any>() {
return SmartRequestClient.create<T>().accept('binary');
return SmartRequest.create<T>().accept('binary');
}
/**
* Create a client pre-configured for streaming
*/
export function createStreamClient() {
return SmartRequestClient.create().accept('stream');
return SmartRequest.create().accept('stream');
}

View File

@@ -17,7 +17,7 @@ import { createPaginatedResponse } from './features/pagination.js';
/**
* Modern fluent client for making HTTP requests
*/
export class SmartRequestClient<T = any> {
export class SmartRequest<T = any> {
private _url: string;
private _options: ICoreRequestOptions = {};
private _retries: number = 0;
@@ -25,10 +25,10 @@ export class SmartRequestClient<T = any> {
private _paginationConfig?: TPaginationConfig;
/**
* Create a new SmartRequestClient instance
* Create a new SmartRequest instance
*/
static create<T = any>(): SmartRequestClient<T> {
return new SmartRequestClient<T>();
static create<T = any>(): SmartRequest<T> {
return new SmartRequest<T>();
}
/**
@@ -278,7 +278,7 @@ export class SmartRequestClient<T = any> {
this._queryParams,
(nextPageParams) => {
// Create a new client with the same configuration but updated query params
const nextClient = new SmartRequestClient<ItemType>();
const nextClient = new SmartRequest<ItemType>();
Object.assign(nextClient, this);
nextClient._queryParams = nextPageParams;