@oasis-path/gamma-sdk 1.0.13 → 1.0.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.
@@ -1,5 +1,5 @@
1
1
  export declare function makeRequest<T>(method: string, path: string, baseUrl: string, apiKey: string, options?: {
2
- body?: any;
2
+ body?: unknown;
3
3
  headers?: Record<string, string>;
4
4
  query?: Record<string, string>;
5
5
  }): Promise<T>;
@@ -1,6 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.makeRequest = makeRequest;
4
+ function isTRPCResponse(obj) {
5
+ return (typeof obj === 'object' &&
6
+ obj !== null &&
7
+ 'result' in obj &&
8
+ typeof obj.result === 'object' &&
9
+ obj.result !== null &&
10
+ 'data' in obj.result);
11
+ }
4
12
  async function makeRequest(method, path, baseUrl, apiKey, options) {
5
13
  const url = new URL(path, baseUrl);
6
14
  if (options?.query) {
@@ -40,7 +48,12 @@ async function makeRequest(method, path, baseUrl, apiKey, options) {
40
48
  }
41
49
  const contentType = response.headers.get('content-type');
42
50
  if (contentType?.includes('application/json')) {
43
- return await response.json();
51
+ const json = await response.json();
52
+ // tRPC wraps responses in { result: { data: ... } }
53
+ if (isTRPCResponse(json)) {
54
+ return json.result.data;
55
+ }
56
+ throw new Error('Invalid response format: expected tRPC response structure');
44
57
  }
45
- return response;
58
+ throw new Error('Invalid response: expected JSON content-type');
46
59
  }
package/package.json CHANGED
@@ -1,11 +1,15 @@
1
1
  {
2
2
  "name": "@oasis-path/gamma-sdk",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "TypeScript SDK for Gamma Files API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
- "publishConfig": {
8
- "access": "public"
7
+ "publishConfig": { "access": "public" },
8
+ "scripts": {
9
+ "build": "tsc",
10
+ "watch": "tsc --watch",
11
+ "prepublishOnly": "pnpm run build",
12
+ "publish2": "pnpm run build && git add . && git commit -m 'chore: publish new version' && git push && pnpm publish --no-git-checks"
9
13
  },
10
14
  "keywords": [
11
15
  "gamma",
@@ -26,10 +30,5 @@
26
30
  },
27
31
  "files": [
28
32
  "dist"
29
- ],
30
- "scripts": {
31
- "build": "tsc",
32
- "watch": "tsc --watch",
33
- "publish2": "pnpm run build && git add . && git commit -m 'chore: publish new version' && git push && pnpm publish --no-git-checks"
34
- }
35
- }
33
+ ]
34
+ }