@oasis-path/gamma-sdk 1.0.22 → 1.0.24

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.
@@ -4,6 +4,8 @@ exports.generatePresignedFileDownloadUrl = generatePresignedFileDownloadUrl;
4
4
  const makeTrpcRequest_1 = require("../utils/makeTrpcRequest");
5
5
  async function generatePresignedFileDownloadUrl(options, apiKey, baseUrl) {
6
6
  console.log(`sending to ${baseUrl}/trpc/generatePresignedFileDownloadUrl`);
7
+ console.log("******************");
8
+ console.log(options);
7
9
  return (0, makeTrpcRequest_1.makeTrpcRequest)('POST', '/trpc/generatePresignedFileDownloadUrl', baseUrl, apiKey, {
8
10
  body: options
9
11
  });
@@ -4,10 +4,6 @@ exports.makeTrpcRequest = makeTrpcRequest;
4
4
  async function makeTrpcRequest(method, path, baseUrl, apiKey, options) {
5
5
  console.log(`${baseUrl}/${path}`);
6
6
  const url = new URL(path, baseUrl);
7
- // For tRPC, the input needs to be sent as a query parameter
8
- if (options?.body && typeof options.body === 'object' && !(options.body instanceof FormData)) {
9
- url.searchParams.append('input', JSON.stringify(options.body));
10
- }
11
7
  if (options?.query) {
12
8
  Object.entries(options.query).forEach(([key, value]) => {
13
9
  if (value !== undefined && value !== null) {
@@ -17,14 +13,20 @@ async function makeTrpcRequest(method, path, baseUrl, apiKey, options) {
17
13
  }
18
14
  const headers = {
19
15
  'X-API-Key': apiKey,
20
- 'Content-Type': 'application/json',
21
16
  ...options?.headers,
22
17
  };
18
+ if (options?.body && typeof options.body === 'object' && !(options.body instanceof FormData)) {
19
+ headers['Content-Type'] = 'application/json';
20
+ }
23
21
  const fetchOptions = {
24
22
  method,
25
23
  headers,
26
- body: method === 'POST' ? '{}' : undefined,
27
24
  };
25
+ if (options?.body) {
26
+ fetchOptions.body = options.body instanceof FormData || typeof options.body === 'string'
27
+ ? options.body
28
+ : JSON.stringify(options.body);
29
+ }
28
30
  const response = await fetch(url.toString(), fetchOptions);
29
31
  if (!response.ok) {
30
32
  const errorText = await response.text();
@@ -39,7 +41,12 @@ async function makeTrpcRequest(method, path, baseUrl, apiKey, options) {
39
41
  }
40
42
  const contentType = response.headers.get('content-type');
41
43
  if (contentType?.includes('application/json')) {
42
- return await response.json();
44
+ const jsonResponse = await response.json();
45
+ // Unwrap nested result.data structure if present
46
+ if (jsonResponse?.result?.data) {
47
+ return jsonResponse.result.data;
48
+ }
49
+ return jsonResponse;
43
50
  }
44
51
  return response;
45
52
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oasis-path/gamma-sdk",
3
- "version": "1.0.22",
3
+ "version": "1.0.24",
4
4
  "description": "TypeScript SDK for Gamma Files API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",