@xsai/shared 0.0.28 → 0.0.30

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -8
  2. package/package.json +9 -9
package/dist/index.js CHANGED
@@ -10,19 +10,19 @@ class XSAIError extends Error {
10
10
  const strCamelToSnake = (str) => str.replace(/[A-Z]/g, (s) => `_${s.toLowerCase()}`);
11
11
  const objCamelToSnake = (obj) => Object.fromEntries(Object.entries(obj).map(([k, v]) => [strCamelToSnake(k), v]));
12
12
 
13
- const clean = (record) => Object.fromEntries(Object.entries(record).filter(([, v]) => v !== void 0));
13
+ const clean = (record) => Object.fromEntries(Object.entries(record).filter(([, v]) => v !== undefined));
14
14
 
15
15
  const requestBody = (body) => JSON.stringify(objCamelToSnake(clean({
16
16
  ...body,
17
- abortSignal: void 0,
18
- apiKey: void 0,
19
- baseURL: void 0,
20
- fetch: void 0,
21
- headers: void 0
17
+ abortSignal: undefined,
18
+ apiKey: undefined,
19
+ baseURL: undefined,
20
+ fetch: undefined,
21
+ headers: undefined
22
22
  })));
23
23
 
24
24
  const requestHeaders = (headers, apiKey) => clean({
25
- Authorization: apiKey ? `Bearer ${apiKey}` : void 0,
25
+ Authorization: apiKey !== undefined ? `Bearer ${apiKey}` : undefined,
26
26
  ...headers
27
27
  });
28
28
 
@@ -48,6 +48,6 @@ const responseCatch = async (res) => {
48
48
  return res;
49
49
  };
50
50
 
51
- const responseJSON = async (res) => responseCatch(res).then((res2) => res2.json());
51
+ const responseJSON = async (res) => responseCatch(res).then(async (res2) => res2.json());
52
52
 
53
53
  export { XSAIError, clean, objCamelToSnake, requestBody, requestHeaders, requestURL, responseCatch, responseJSON, strCamelToSnake };
package/package.json CHANGED
@@ -1,31 +1,31 @@
1
1
  {
2
2
  "name": "@xsai/shared",
3
- "version": "0.0.28",
4
3
  "type": "module",
4
+ "version": "0.0.30",
5
+ "description": "extra-small AI SDK for Browser, Node.js, Deno, Bun or Edge Runtime.",
5
6
  "author": "Moeru AI",
6
7
  "license": "MIT",
7
8
  "homepage": "https://xsai.js.org",
8
- "description": "extra-small AI SDK for Browser, Node.js, Deno, Bun or Edge Runtime.",
9
- "keywords": [
10
- "xsai",
11
- "openai",
12
- "ai"
13
- ],
14
9
  "repository": {
15
10
  "type": "git",
16
11
  "url": "git+https://github.com/moeru-ai/xsai.git",
17
12
  "directory": "packages/shared"
18
13
  },
19
14
  "bugs": "https://github.com/moeru-ai/xsai/issues",
15
+ "keywords": [
16
+ "xsai",
17
+ "openai",
18
+ "ai"
19
+ ],
20
20
  "sideEffects": false,
21
- "main": "./dist/index.js",
22
- "types": "./dist/index.d.ts",
23
21
  "exports": {
24
22
  ".": {
25
23
  "types": "./dist/index.d.ts",
26
24
  "default": "./dist/index.js"
27
25
  }
28
26
  },
27
+ "main": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
29
  "files": [
30
30
  "dist"
31
31
  ],