BREAKING CHANGE(core): major architectural refactoring with cross-platform support and SmartRequest rename
This commit is contained in:
@@ -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');
|
||||
}
|
@@ -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;
|
||||
|
@@ -6,5 +6,5 @@ export { CoreResponse } from './core/index.js';
|
||||
export type { ICoreRequestOptions, ICoreResponse } from './core_base/types.js';
|
||||
|
||||
// Default export for easier importing
|
||||
import { SmartRequestClient } from './client/smartrequestclient.js';
|
||||
export default SmartRequestClient;
|
||||
import { SmartRequest } from './client/smartrequest.js';
|
||||
export default SmartRequest;
|
Reference in New Issue
Block a user