@oasis-path/gamma-sdk 1.0.9 → 1.0.11

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
@@ -58,4 +58,22 @@ export declare class GammaFilesClient {
58
58
  downloadFolder(folderId: string, token: string): Promise<ArrayBuffer>;
59
59
  viewFile(fileId: string, token: string, compressionValue?: number): Promise<ViewFileResult>;
60
60
  listFolderFiles(folderId: string): Promise<ListFolderFilesResponse>;
61
+ deleteFile(fileId: string): Promise<{
62
+ success: true;
63
+ message: string;
64
+ }>;
65
+ getFileMetadata(fileId: string): Promise<{
66
+ success: true;
67
+ file: FileMetadata;
68
+ }>;
69
+ generatePresignedUrl(options: {
70
+ fileId: string;
71
+ expiresIn?: number;
72
+ maxUsageCount?: number;
73
+ }): Promise<{
74
+ success: true;
75
+ token: string;
76
+ url: string;
77
+ expiresAt: string;
78
+ }>;
61
79
  }
package/dist/index.js CHANGED
@@ -6,6 +6,9 @@ const downloadPresigned_1 = require("./methods/downloadPresigned");
6
6
  const downloadFolder_1 = require("./methods/downloadFolder");
7
7
  const viewFile_1 = require("./methods/viewFile");
8
8
  const listFolderFiles_1 = require("./methods/listFolderFiles");
9
+ const deleteFile_1 = require("./methods/deleteFile");
10
+ const getFileMetadata_1 = require("./methods/getFileMetadata");
11
+ const generatePresignedUrl_1 = require("./methods/generatePresignedUrl");
9
12
  // Client
10
13
  class GammaFilesClient {
11
14
  constructor(config) {
@@ -30,5 +33,23 @@ class GammaFilesClient {
30
33
  }
31
34
  return (0, listFolderFiles_1.listFolderFiles)(folderId, this.apiKey, this.baseUrl);
32
35
  }
36
+ async deleteFile(fileId) {
37
+ if (!this.apiKey) {
38
+ throw new Error('API key is required for deleteFile method. Please provide apiKey in the constructor config.');
39
+ }
40
+ return (0, deleteFile_1.deleteFile)(fileId, this.apiKey, this.baseUrl);
41
+ }
42
+ async getFileMetadata(fileId) {
43
+ if (!this.apiKey) {
44
+ throw new Error('API key is required for getFileMetadata method. Please provide apiKey in the constructor config.');
45
+ }
46
+ return (0, getFileMetadata_1.getFileMetadata)(fileId, this.apiKey, this.baseUrl);
47
+ }
48
+ async generatePresignedUrl(options) {
49
+ if (!this.apiKey) {
50
+ throw new Error('API key is required for generatePresignedUrl method. Please provide apiKey in the constructor config.');
51
+ }
52
+ return (0, generatePresignedUrl_1.generatePresignedUrl)(options, this.apiKey, this.baseUrl);
53
+ }
33
54
  }
34
55
  exports.GammaFilesClient = GammaFilesClient;
@@ -1,2 +1,5 @@
1
- import { DeleteFileResponse } from '../types';
2
- export declare function deleteFile(fileId: string, request: <T>(method: string, path: string, options?: any) => Promise<T>): Promise<DeleteFileResponse>;
1
+ export interface DeleteFileResponse {
2
+ success: true;
3
+ message: string;
4
+ }
5
+ export declare function deleteFile(fileId: string, apiKey: string, baseUrl: string): Promise<DeleteFileResponse>;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deleteFile = deleteFile;
4
- async function deleteFile(fileId, request) {
5
- const url = `/api/files/${fileId}`;
6
- return request('DELETE', url);
4
+ const request_1 = require("./request");
5
+ async function deleteFile(fileId, apiKey, baseUrl) {
6
+ return (0, request_1.makeRequest)('POST', `/trpc/deleteFile`, baseUrl, apiKey, {
7
+ body: {
8
+ fileId,
9
+ },
10
+ });
7
11
  }
@@ -1,2 +1,12 @@
1
- import { PresignedUrlOptions, PresignedUrlResponse } from '../types';
2
- export declare function generatePresignedUrl(options: PresignedUrlOptions, request: <T>(method: string, path: string, options?: any) => Promise<T>): Promise<PresignedUrlResponse>;
1
+ export interface GeneratePresignedUrlOptions {
2
+ fileId: string;
3
+ expiresIn?: number;
4
+ maxUsageCount?: number;
5
+ }
6
+ export interface GeneratePresignedUrlResponse {
7
+ success: true;
8
+ token: string;
9
+ url: string;
10
+ expiresAt: string;
11
+ }
12
+ export declare function generatePresignedUrl(options: GeneratePresignedUrlOptions, apiKey: string, baseUrl: string): Promise<GeneratePresignedUrlResponse>;
@@ -1,16 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.generatePresignedUrl = generatePresignedUrl;
4
- async function generatePresignedUrl(options, request) {
5
- const url = '/api/files/presigned-url';
6
- const payload = {
7
- ...options,
8
- maxUsageCount: options.maxUsageCount ?? 1
9
- };
10
- return request('POST', url, {
11
- body: JSON.stringify(payload),
12
- headers: {
13
- 'Content-Type': 'application/json',
4
+ const request_1 = require("./request");
5
+ async function generatePresignedUrl(options, apiKey, baseUrl) {
6
+ return (0, request_1.makeRequest)('POST', `/trpc/generatePresignedUrl`, baseUrl, apiKey, {
7
+ body: {
8
+ fileId: options.fileId,
9
+ expiresIn: options.expiresIn,
10
+ maxUsageCount: options.maxUsageCount,
14
11
  },
15
12
  });
16
13
  }
@@ -1,2 +1,16 @@
1
- import { FileMetadataResponse } from '../types';
2
- export declare function getFileMetadata(fileId: string, request: <T>(method: string, path: string, options?: any) => Promise<T>): Promise<FileMetadataResponse>;
1
+ export interface FileMetadata {
2
+ id: string;
3
+ name: string;
4
+ originalName: string;
5
+ mimeType: string;
6
+ size: number;
7
+ folderId: string;
8
+ uploadedBy: string;
9
+ createdAt: string;
10
+ updatedAt: string | null;
11
+ }
12
+ export interface GetFileMetadataResponse {
13
+ success: true;
14
+ file: FileMetadata;
15
+ }
16
+ export declare function getFileMetadata(fileId: string, apiKey: string, baseUrl: string): Promise<GetFileMetadataResponse>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFileMetadata = getFileMetadata;
4
- async function getFileMetadata(fileId, request) {
5
- const url = `/api/files/${fileId}/metadata`;
6
- return request('GET', url);
4
+ const request_1 = require("./request");
5
+ async function getFileMetadata(fileId, apiKey, baseUrl) {
6
+ return (0, request_1.makeRequest)('GET', `/trpc/getFileMetadata?input=${encodeURIComponent(JSON.stringify({ fileId }))}`, baseUrl, apiKey);
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oasis-path/gamma-sdk",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "description": "TypeScript SDK for Gamma Files API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  "build": "tsc",
10
10
  "watch": "tsc --watch",
11
11
  "prepublishOnly": "pnpm run build",
12
- "publish": "pnpm run build && git add . && git commit -m 'chore: publish new version' && git push && pnpm publish --no-git-checks"
12
+ "publish2": "pnpm run build && git add . && git commit -m 'chore: publish new version' && git push && pnpm publish --no-git-checks"
13
13
  },
14
14
  "keywords": [
15
15
  "gamma",