@hapaul/api 0.1.12 → 0.1.14

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/dist/index.d.ts CHANGED
@@ -1421,6 +1421,7 @@ type ResponseData<T extends PathsWithMethod<paths, M>, M extends Methods> = Pars
1421
1421
  type ResponseError<T extends PathsWithMethod<paths, M>, M extends Methods> = ErrorResponse<ResponseObjectMap<paths[T][M]>, `${string}/${string}`>;
1422
1422
  type ClientConfig = {
1423
1423
  baseUrl?: string;
1424
+ fetch?: typeof fetch;
1424
1425
  };
1425
1426
  type RequestConfig<T extends PathsWithMethod<paths, M>, M extends Methods, C = {}> = ClientConfig & {
1426
1427
  method: M;
@@ -1446,6 +1447,7 @@ interface Middleware<C> {
1446
1447
  declare class Client<C> {
1447
1448
  private middlewares;
1448
1449
  private baseUrl;
1450
+ private fetch;
1449
1451
  constructor(config?: ClientConfig);
1450
1452
  use(middleware: Middleware<C>): void;
1451
1453
  request<T extends PathsWithMethod<paths, M>, M extends Methods>(method: M, path: T, ...params: RequestParams<T, M, C>): RequestResponse<T, M>;
package/dist/index.js CHANGED
@@ -2,9 +2,11 @@
2
2
  var Client = class {
3
3
  middlewares;
4
4
  baseUrl;
5
+ fetch;
5
6
  constructor(config) {
6
7
  this.middlewares = [];
7
8
  this.baseUrl = config?.baseUrl ?? "";
9
+ this.fetch = config?.fetch ?? fetch;
8
10
  }
9
11
  use(middleware) {
10
12
  this.middlewares.push(middleware);
@@ -28,7 +30,7 @@ var Client = class {
28
30
  if (!contentType) headers.set("Content-Type", "application/json");
29
31
  try {
30
32
  const serializedBody = defaultBodySerializer(body, headers);
31
- let response = await fetch(url, {
33
+ let response = await this.fetch(url, {
32
34
  ...requestConfig,
33
35
  body: serializedBody,
34
36
  method: method.toUpperCase(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hapaul/api",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "files": [
@@ -23,10 +23,12 @@
23
23
  "author": "",
24
24
  "license": "ISC",
25
25
  "packageManager": "pnpm@10.23.0+sha512.21c4e5698002ade97e4efe8b8b4a89a8de3c85a37919f957e7a0f30f38fbc5bbdd05980ffe29179b2fb6e6e691242e098d945d1601772cad0fef5fb6411e2a4b",
26
+ "dependencies": {
27
+ "openapi-typescript-helpers": "^0.0.15"
28
+ },
26
29
  "devDependencies": {
27
30
  "@hapaul/dev": "^0.0.3",
28
31
  "openapi-typescript": "^7.10.1",
29
- "openapi-typescript-helpers": "^0.0.15",
30
32
  "rolldown": "1.0.0-beta.30",
31
33
  "rolldown-plugin-dts": "^0.14.3",
32
34
  "typescript": "^5.9.3"