@stryke/http 0.12.1 → 0.12.3

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/fetch.cjs CHANGED
@@ -6,19 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.fetch = void 0;
7
7
  exports.fetchRequest = fetchRequest;
8
8
  var _isSetString = require("@stryke/type-checks/is-set-string");
9
- var _isUrl = require("@stryke/type-checks/is-url");
10
9
  var _helpers = require("@stryke/url/helpers");
11
10
  var _defu = require("defu");
12
11
  var _undici = require("undici");
13
12
  var _proxyAgent = require("./proxy-agent.cjs");
14
- async function fetchRequest(t, e = {}) {
15
- if ((0, _isSetString.isSetString)(t)) {
16
- if (!(0, _helpers.isValidURL)(t)) throw new Error(`Invalid URL format provided: ${t}`);
17
- } else if (!(0, _isUrl.isURL)(t)) throw new Error("Invalid URL provided to fetch");
18
- const r = new AbortController();
19
- return setTimeout(() => r.abort(), e.timeout ?? 5e3), (0, _undici.request)(t, (0, _defu.defu)(e, {
13
+ async function fetchRequest(e, t = {}) {
14
+ if ((0, _isSetString.isSetString)(e) && !(0, _helpers.isValidURL)(e)) throw new Error(`Invalid URL format provided: ${e}`);
15
+ const o = new AbortController();
16
+ return setTimeout(() => o.abort(), t.timeout ?? 5e3), (0, _undici.fetch)(e, (0, _defu.defu)(t, {
20
17
  agent: (0, _proxyAgent.getProxyAgent)(),
21
- signal: r.signal,
18
+ signal: o.signal,
22
19
  headers: {
23
20
  "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"
24
21
  }
package/dist/fetch.d.ts CHANGED
@@ -1,8 +1,5 @@
1
- import type { UrlObject } from "node:url";
2
- import type { Dispatcher } from "undici";
3
- export type FetchRequestOptions<T = null> = {
4
- dispatcher?: Dispatcher;
5
- } & Omit<Dispatcher.RequestOptions<T>, "origin" | "path" | "method"> & Partial<Pick<Dispatcher.RequestOptions, "method">> & {
1
+ import type { RequestInfo } from "undici";
2
+ export type FetchRequestOptions = RequestInit & {
6
3
  /**
7
4
  * Timeout in milliseconds
8
5
  *
@@ -13,8 +10,9 @@ export type FetchRequestOptions<T = null> = {
13
10
  /**
14
11
  * Fetches a resource from a URL.
15
12
  *
16
- * @param url - The URL to fetch.
17
- * @returns A promise that resolves to the response.
13
+ * @param input - The URL to fetch.
14
+ * @param options - Additional fetch options.
15
+ * @returns The fetched response.
18
16
  */
19
- export declare function fetchRequest<T = null>(url: string | URL | UrlObject, options?: FetchRequestOptions<T>): Promise<Dispatcher.ResponseData<T>>;
17
+ export declare function fetchRequest(input: RequestInfo, options?: FetchRequestOptions): Promise<import("undici").Response>;
20
18
  export declare const fetch: typeof fetchRequest;
package/dist/fetch.mjs CHANGED
@@ -1 +1 @@
1
- import{isSetString as o}from"@stryke/type-checks/is-set-string";import{isURL as i}from"@stryke/type-checks/is-url";import{isValidURL as n}from"@stryke/url/helpers";import{defu as s}from"defu";import{request as p}from"undici";import{getProxyAgent as m}from"./proxy-agent";export async function fetchRequest(t,e={}){if(o(t)){if(!n(t))throw new Error(`Invalid URL format provided: ${t}`)}else if(!i(t))throw new Error("Invalid URL provided to fetch");const r=new AbortController;return setTimeout(()=>r.abort(),e.timeout??5e3),p(t,s(e,{agent:m(),signal:r.signal,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"}}))}export const fetch=fetchRequest;
1
+ import{isSetString as r}from"@stryke/type-checks/is-set-string";import{isValidURL as i}from"@stryke/url/helpers";import{defu as n}from"defu";import{fetch as s}from"undici";import{getProxyAgent as m}from"./proxy-agent";export async function fetchRequest(e,t={}){if(r(e)&&!i(e))throw new Error(`Invalid URL format provided: ${e}`);const o=new AbortController;return setTimeout(()=>o.abort(),t.timeout??5e3),s(e,n(t,{agent:m(),signal:o.signal,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"}}))}export const fetch=fetchRequest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/http",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
4
4
  "type": "module",
5
5
  "description": "A package containing HTTP communication utilities used by Storm Software.",
6
6
  "repository": {
@@ -10,8 +10,8 @@
10
10
  },
11
11
  "private": false,
12
12
  "dependencies": {
13
- "@stryke/type-checks": "^0.4.2",
14
- "@stryke/url": "^0.3.2",
13
+ "@stryke/type-checks": "^0.4.4",
14
+ "@stryke/url": "^0.3.4",
15
15
  "defu": "^6.1.4",
16
16
  "undici": "^7.16.0"
17
17
  },
@@ -181,5 +181,5 @@
181
181
  "main": "./dist/index.cjs",
182
182
  "module": "./dist/index.mjs",
183
183
  "types": "./dist/index.d.ts",
184
- "gitHead": "4f9ec36edfefa375090353856bca8d00e4e778e2"
184
+ "gitHead": "eb28313b3230b7ea654c87586ca07773e2e57f52"
185
185
  }