@xsai/shared 0.0.22 → 0.0.23

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
@@ -1,10 +1,7 @@
1
1
  interface CommonRequestOptions {
2
2
  abortSignal?: AbortSignal;
3
3
  apiKey?: string;
4
- /**
5
- * @example `https://openai.com/v1/`
6
- * @remarks make sure the baseURL ends with a slash.
7
- */
4
+ /** @example `https://openai.com/v1/` */
8
5
  baseURL: string | URL;
9
6
  fetch?: typeof globalThis.fetch;
10
7
  /** @default `undefined` */
@@ -24,4 +21,6 @@ declare const requestBody: (body: Record<string, unknown>) => string;
24
21
 
25
22
  declare const requestHeaders: (headers?: CommonRequestOptions["headers"], apiKey?: CommonRequestOptions["apiKey"]) => Record<"Authorization", never>;
26
23
 
27
- export { type CommonRequestOptions, clean, objCamelToSnake, requestBody, requestHeaders, strCamelToSnake };
24
+ declare const requestURL: (path: string, baseURL: string | URL) => URL;
25
+
26
+ export { type CommonRequestOptions, clean, objCamelToSnake, requestBody, requestHeaders, requestURL, strCamelToSnake };
package/dist/index.js CHANGED
@@ -17,4 +17,9 @@ const requestHeaders = (headers, apiKey) => clean({
17
17
  ...headers
18
18
  });
19
19
 
20
- export { clean, objCamelToSnake, requestBody, requestHeaders, strCamelToSnake };
20
+ const requestURL = (path, baseURL) => {
21
+ const base = baseURL.toString();
22
+ return new URL(path, base.endsWith("/") ? base : `${base}/`);
23
+ };
24
+
25
+ export { clean, objCamelToSnake, requestBody, requestHeaders, requestURL, strCamelToSnake };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsai/shared",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "type": "module",
5
5
  "author": "Moeru AI",
6
6
  "license": "MIT",