@flow-conductor/adapter-fetch 1.0.0 → 1.0.1
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/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/package.json +1 -1
package/build/index.d.ts
CHANGED
|
@@ -35,4 +35,4 @@ declare class FetchRequestAdapter extends RequestAdapter<Response, FetchRequestC
|
|
|
35
35
|
createRequest(requestConfig: IRequestConfig): Promise<Response>;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export { type FetchRequestConfig
|
|
38
|
+
export { FetchRequestAdapter, type FetchRequestConfig };
|
package/build/index.js
CHANGED
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/fetch-request-adapter.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"sources":["../src/fetch-request-adapter.ts"],"names":[],"mappings":";;;AAyBO,IAAM,mBAAA,GAAN,cAAkC,cAAA,CAGvC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,YAAY,oBAAA,EAA6C;AACvD,IAAA,KAAA,CAAM,oBAAoB,CAAA;AAAA,EAC5B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,cAAc,aAAA,EAAkD;AACrE,IAAA,MAAM,EAAE,IAAA,EAAM,GAAA,EAAK,GAAG,MAAK,GAAI,aAAA;AAC/B,IAAA,MAAM,WAAA,GAA2B,EAAE,GAAG,IAAA,EAAK;AAC3C,IAAA,IAAI,IAAA,EAAM;AACR,MAAA,WAAA,CAAY,OAAO,OAAO,IAAA,KAAS,WAAW,IAAA,GAAO,IAAA,CAAK,UAAU,IAAI,CAAA;AACxE,MAAA,WAAA,CAAY,OAAA,GAAU;AAAA,QACpB,cAAA,EAAgB,kBAAA;AAAA,QAChB,GAAI,WAAA,CAAY;AAAA,OAClB;AAAA,IACF;AACA,IAAA,OAAO,KAAA,CAAM,KAAK,WAAW,CAAA;AAAA,EAC/B;AACF","file":"index.js","sourcesContent":["import { RequestAdapter } from \"@flow-conductor/core\";\nimport type {\n IRequestConfig,\n UrlValidationOptions,\n} from \"@flow-conductor/core\";\n\n/**\n * Request configuration type for Fetch adapter.\n * Extends IRequestConfig with fetch-specific options via the index signature.\n */\nexport type FetchRequestConfig = IRequestConfig;\n\n/**\n * Request adapter implementation using the native Fetch API.\n * Provides a lightweight, dependency-free HTTP client adapter.\n *\n * @example\n * ```typescript\n * const adapter = new FetchRequestAdapter();\n * const chain = begin(\n * { config: { url: 'https://api.example.com/users', method: 'GET' } },\n * adapter\n * );\n * ```\n */\nexport class FetchRequestAdapter extends RequestAdapter<\n Response,\n FetchRequestConfig\n> {\n /**\n * Creates a new FetchRequestAdapter instance.\n *\n * @param urlValidationOptions - Optional URL validation options to prevent SSRF attacks\n */\n constructor(urlValidationOptions?: UrlValidationOptions) {\n super(urlValidationOptions);\n }\n\n /**\n * Creates and executes an HTTP request using the Fetch API.\n * Automatically handles JSON serialization for request bodies.\n *\n * @param requestConfig - The request configuration object\n * @returns A promise that resolves to a Response object\n */\n public createRequest(requestConfig: IRequestConfig): Promise<Response> {\n const { data, url, ...rest } = requestConfig;\n const fetchConfig: RequestInit = { ...rest };\n if (data) {\n fetchConfig.body = typeof data === \"string\" ? data : JSON.stringify(data);\n fetchConfig.headers = {\n \"Content-Type\": \"application/json\",\n ...(fetchConfig.headers as Record<string, string>),\n };\n }\n return fetch(url, fetchConfig);\n }\n}\n"]}
|