@oasis-path/gamma-sdk 1.0.21 → 1.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.
@@ -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) {
@@ -19,10 +15,18 @@ async function makeTrpcRequest(method, path, baseUrl, apiKey, options) {
19
15
  'X-API-Key': apiKey,
20
16
  ...options?.headers,
21
17
  };
18
+ if (options?.body && typeof options.body === 'object' && !(options.body instanceof FormData)) {
19
+ headers['Content-Type'] = 'application/json';
20
+ }
22
21
  const fetchOptions = {
23
22
  method,
24
23
  headers,
25
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
+ }
26
30
  const response = await fetch(url.toString(), fetchOptions);
27
31
  if (!response.ok) {
28
32
  const errorText = await response.text();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oasis-path/gamma-sdk",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "description": "TypeScript SDK for Gamma Files API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",