google-drive-mcp-lib 1.0.0
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/README.md +357 -0
- package/dist/cli.d.ts +6 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -0
- package/dist/client.d.ts +28 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +44 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/handlers.d.ts +14 -0
- package/dist/mcp/handlers.d.ts.map +1 -0
- package/dist/mcp/handlers.js +146 -0
- package/dist/mcp/handlers.js.map +1 -0
- package/dist/mcp/server.d.ts +13 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +87 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp/tools.d.ts +231 -0
- package/dist/mcp/tools.d.ts.map +1 -0
- package/dist/mcp/tools.js +100 -0
- package/dist/mcp/tools.js.map +1 -0
- package/dist/operations/create-folder.d.ts +14 -0
- package/dist/operations/create-folder.d.ts.map +1 -0
- package/dist/operations/create-folder.js +31 -0
- package/dist/operations/create-folder.js.map +1 -0
- package/dist/operations/delete-file.d.ts +14 -0
- package/dist/operations/delete-file.d.ts.map +1 -0
- package/dist/operations/delete-file.js +13 -0
- package/dist/operations/delete-file.js.map +1 -0
- package/dist/operations/download-file.d.ts +14 -0
- package/dist/operations/download-file.d.ts.map +1 -0
- package/dist/operations/download-file.js +36 -0
- package/dist/operations/download-file.js.map +1 -0
- package/dist/operations/get-file.d.ts +14 -0
- package/dist/operations/get-file.d.ts.map +1 -0
- package/dist/operations/get-file.js +50 -0
- package/dist/operations/get-file.js.map +1 -0
- package/dist/operations/index.d.ts +11 -0
- package/dist/operations/index.d.ts.map +1 -0
- package/dist/operations/index.js +11 -0
- package/dist/operations/index.js.map +1 -0
- package/dist/operations/list-files.d.ts +14 -0
- package/dist/operations/list-files.d.ts.map +1 -0
- package/dist/operations/list-files.js +48 -0
- package/dist/operations/list-files.js.map +1 -0
- package/dist/operations/search-files.d.ts +14 -0
- package/dist/operations/search-files.d.ts.map +1 -0
- package/dist/operations/search-files.js +47 -0
- package/dist/operations/search-files.js.map +1 -0
- package/dist/operations/upload-file.d.ts +14 -0
- package/dist/operations/upload-file.d.ts.map +1 -0
- package/dist/operations/upload-file.js +36 -0
- package/dist/operations/upload-file.js.map +1 -0
- package/dist/tokens.d.ts +31 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +77 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +178 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get file operation
|
|
3
|
+
*/
|
|
4
|
+
import { createDriveClient } from '../client.js';
|
|
5
|
+
/**
|
|
6
|
+
* Default fields to retrieve for a file
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_FIELDS = [
|
|
9
|
+
'id',
|
|
10
|
+
'name',
|
|
11
|
+
'mimeType',
|
|
12
|
+
'size',
|
|
13
|
+
'createdTime',
|
|
14
|
+
'modifiedTime',
|
|
15
|
+
'parents',
|
|
16
|
+
'webViewLink',
|
|
17
|
+
'thumbnailLink',
|
|
18
|
+
'description',
|
|
19
|
+
'owners',
|
|
20
|
+
];
|
|
21
|
+
export async function getFile(options, tokens) {
|
|
22
|
+
// Handle both calling conventions
|
|
23
|
+
const resolvedTokens = tokens ?? options.tokens;
|
|
24
|
+
const drive = createDriveClient({ tokens: resolvedTokens });
|
|
25
|
+
const { fileId, fields = DEFAULT_FIELDS } = options;
|
|
26
|
+
const response = await drive.files.get({
|
|
27
|
+
fileId,
|
|
28
|
+
fields: fields.join(','),
|
|
29
|
+
});
|
|
30
|
+
const file = response.data;
|
|
31
|
+
return {
|
|
32
|
+
id: file.id ?? undefined,
|
|
33
|
+
name: file.name ?? undefined,
|
|
34
|
+
mimeType: file.mimeType ?? undefined,
|
|
35
|
+
parents: Array.isArray(file.parents) ? file.parents : undefined,
|
|
36
|
+
size: file.size != null ? parseInt(String(file.size), 10) : undefined,
|
|
37
|
+
createdTime: typeof file.createdTime === 'string' ? file.createdTime : undefined,
|
|
38
|
+
modifiedTime: typeof file.modifiedTime === 'string' ? file.modifiedTime : undefined,
|
|
39
|
+
webViewLink: typeof file.webViewLink === 'string' ? file.webViewLink : undefined,
|
|
40
|
+
thumbnailLink: typeof file.thumbnailLink === 'string' ? file.thumbnailLink : undefined,
|
|
41
|
+
description: typeof file.description === 'string' ? file.description : undefined,
|
|
42
|
+
owners: Array.isArray(file.owners)
|
|
43
|
+
? file.owners.map((owner) => ({
|
|
44
|
+
displayName: typeof owner.displayName === 'string' ? owner.displayName : undefined,
|
|
45
|
+
emailAddress: typeof owner.emailAddress === 'string' ? owner.emailAddress : undefined,
|
|
46
|
+
}))
|
|
47
|
+
: undefined,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=get-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-file.js","sourceRoot":"","sources":["../../src/operations/get-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD;;GAEG;AACH,MAAM,cAAc,GAAG;IACrB,IAAI;IACJ,MAAM;IACN,UAAU;IACV,MAAM;IACN,aAAa;IACb,cAAc;IACd,SAAS;IACT,aAAa;IACb,eAAe;IACf,aAAa;IACb,QAAQ;CACT,CAAC;AAgBF,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,OAAgC,EAChC,MAAe;IAEf,kCAAkC;IAClC,MAAM,cAAc,GAAG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAChD,MA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AAC,CAAC,CAAC,SAAS;QACtF,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;QAChF,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;YAChC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBAC1B,WAAW,EAAE,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;gBAClF,YAAY,EAAE,OAAO,KAAK,CAAC,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;aACtF,CAAC,CAAC;YACL,CAAC,CAAC,SAAS;KACd,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operations index - re-export all operations
|
|
3
|
+
*/
|
|
4
|
+
export { listFiles } from './list-files.js';
|
|
5
|
+
export { uploadFile } from './upload-file.js';
|
|
6
|
+
export { getFile } from './get-file.js';
|
|
7
|
+
export { downloadFile } from './download-file.js';
|
|
8
|
+
export { createFolder } from './create-folder.js';
|
|
9
|
+
export { searchFiles } from './search-files.js';
|
|
10
|
+
export { deleteFile } from './delete-file.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Operations index - re-export all operations
|
|
3
|
+
*/
|
|
4
|
+
export { listFiles } from './list-files.js';
|
|
5
|
+
export { uploadFile } from './upload-file.js';
|
|
6
|
+
export { getFile } from './get-file.js';
|
|
7
|
+
export { downloadFile } from './download-file.js';
|
|
8
|
+
export { createFolder } from './create-folder.js';
|
|
9
|
+
export { searchFiles } from './search-files.js';
|
|
10
|
+
export { deleteFile } from './delete-file.js';
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/operations/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List files operation
|
|
3
|
+
*/
|
|
4
|
+
import type { ListFilesOperationOptions, ListFilesResult, Tokens } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* List files in Google Drive
|
|
7
|
+
*
|
|
8
|
+
* @param options - List options including pagination and sorting
|
|
9
|
+
* @param tokensOrOptions - Tokens or combined options object
|
|
10
|
+
* @returns List of files and optional next page token
|
|
11
|
+
*/
|
|
12
|
+
export declare function listFiles(options?: ListFilesOperationOptions): Promise<ListFilesResult>;
|
|
13
|
+
export declare function listFiles(options?: Omit<ListFilesOperationOptions, 'tokens'>, tokens?: Tokens): Promise<ListFilesResult>;
|
|
14
|
+
//# sourceMappingURL=list-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-files.d.ts","sourceRoot":"","sources":["../../src/operations/list-files.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgBtF;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,eAAe,CAAC,CAAC;AAC5B,wBAAsB,SAAS,CAC7B,OAAO,CAAC,EAAE,IAAI,CAAC,yBAAyB,EAAE,QAAQ,CAAC,EACnD,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List files operation
|
|
3
|
+
*/
|
|
4
|
+
import { createDriveClient } from '../client.js';
|
|
5
|
+
/**
|
|
6
|
+
* Default fields to retrieve for files
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_FIELDS = [
|
|
9
|
+
'id',
|
|
10
|
+
'name',
|
|
11
|
+
'mimeType',
|
|
12
|
+
'size',
|
|
13
|
+
'createdTime',
|
|
14
|
+
'modifiedTime',
|
|
15
|
+
'parents',
|
|
16
|
+
'webViewLink',
|
|
17
|
+
];
|
|
18
|
+
export async function listFiles(options = {}, tokens) {
|
|
19
|
+
// Handle both calling conventions
|
|
20
|
+
const resolvedTokens = tokens ?? options.tokens;
|
|
21
|
+
const drive = createDriveClient({ tokens: resolvedTokens });
|
|
22
|
+
const pageSize = options.pageSize ?? 10;
|
|
23
|
+
const fields = options.fields ?? DEFAULT_FIELDS;
|
|
24
|
+
const response = await drive.files.list({
|
|
25
|
+
pageSize,
|
|
26
|
+
pageToken: options.pageToken,
|
|
27
|
+
orderBy: options.orderBy,
|
|
28
|
+
q: options.query,
|
|
29
|
+
fields: `nextPageToken, files(${fields.join(',')})`,
|
|
30
|
+
});
|
|
31
|
+
const files = (response.data.files ?? [])
|
|
32
|
+
.filter((file) => file.id != null && file.name != null && file.mimeType != null)
|
|
33
|
+
.map((file) => ({
|
|
34
|
+
id: file.id,
|
|
35
|
+
name: file.name,
|
|
36
|
+
mimeType: file.mimeType,
|
|
37
|
+
size: file.size != null ? parseInt(String(file.size), 10) : undefined,
|
|
38
|
+
createdTime: typeof file.createdTime === 'string' ? file.createdTime : undefined,
|
|
39
|
+
modifiedTime: typeof file.modifiedTime === 'string' ? file.modifiedTime : undefined,
|
|
40
|
+
parents: Array.isArray(file.parents) ? file.parents : undefined,
|
|
41
|
+
webViewLink: typeof file.webViewLink === 'string' ? file.webViewLink : undefined,
|
|
42
|
+
}));
|
|
43
|
+
return {
|
|
44
|
+
files,
|
|
45
|
+
nextPageToken: response.data.nextPageToken ?? undefined,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=list-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-files.js","sourceRoot":"","sources":["../../src/operations/list-files.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD;;GAEG;AACH,MAAM,cAAc,GAAG;IACrB,IAAI;IACJ,MAAM;IACN,UAAU;IACV,MAAM;IACN,aAAa;IACb,cAAc;IACd,SAAS;IACT,aAAa;CACd,CAAC;AAgBF,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,UAAqC,EAAE,EACvC,MAAe;IAEf,kCAAkC;IAClC,MAAM,cAAc,GAAG,MAAM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K,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QACnF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAmB,CAAC,CAAC,CAAC,SAAS;QAC3E,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;KACjF,CAAC,CAAC,CAAC;IAEN,OAAO;QACL,KAAK;QACL,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,IAAI,SAAS;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search files operation
|
|
3
|
+
*/
|
|
4
|
+
import type { SearchFilesOperationOptions, ListFilesResult, Tokens } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Search for files in Google Drive
|
|
7
|
+
*
|
|
8
|
+
* @param options - Search options including query string
|
|
9
|
+
* @param tokensOrOptions - Tokens or combined options object
|
|
10
|
+
* @returns List of matching files and optional next page token
|
|
11
|
+
*/
|
|
12
|
+
export declare function searchFiles(options: SearchFilesOperationOptions): Promise<ListFilesResult>;
|
|
13
|
+
export declare function searchFiles(options: Omit<SearchFilesOperationOptions, 'tokens'>, tokens?: Tokens): Promise<ListFilesResult>;
|
|
14
|
+
//# sourceMappingURL=search-files.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-files.d.ts","sourceRoot":"","sources":["../../src/operations/search-files.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,2BAA2B,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAgBxF;;;;;;GAMG;AACH,wBAAsB,WAAW,CAC/B,OAAO,EAAE,2BAA2B,GACnC,OAAO,CAAC,eAAe,CAAC,CAAC;AAC5B,wBAAsB,WAAW,CAC/B,OAAO,EAAE,IAAI,CAAC,2BAA2B,EAAE,QAAQ,CAAC,EACpD,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search files operation
|
|
3
|
+
*/
|
|
4
|
+
import { createDriveClient } from '../client.js';
|
|
5
|
+
/**
|
|
6
|
+
* Default fields to retrieve for files
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_FIELDS = [
|
|
9
|
+
'id',
|
|
10
|
+
'name',
|
|
11
|
+
'mimeType',
|
|
12
|
+
'size',
|
|
13
|
+
'createdTime',
|
|
14
|
+
'modifiedTime',
|
|
15
|
+
'parents',
|
|
16
|
+
'webViewLink',
|
|
17
|
+
];
|
|
18
|
+
export async function searchFiles(options, tokens) {
|
|
19
|
+
// Handle both calling conventions
|
|
20
|
+
const resolvedTokens = tokens ?? options.tokens;
|
|
21
|
+
const drive = createDriveClient({ tokens: resolvedTokens });
|
|
22
|
+
const { query, pageSize = 10, pageToken, orderBy, fields = DEFAULT_FIELDS } = options;
|
|
23
|
+
const response = await drive.files.list({
|
|
24
|
+
q: query,
|
|
25
|
+
pageSize,
|
|
26
|
+
pageToken,
|
|
27
|
+
orderBy,
|
|
28
|
+
fields: `nextPageToken, files(${fields.join(',')})`,
|
|
29
|
+
});
|
|
30
|
+
const files = (response.data.files ?? [])
|
|
31
|
+
.filter((file) => file.id != null && file.name != null && file.mimeType != null)
|
|
32
|
+
.map((file) => ({
|
|
33
|
+
id: file.id,
|
|
34
|
+
name: file.name,
|
|
35
|
+
mimeType: file.mimeType,
|
|
36
|
+
size: file.size != null ? parseInt(String(file.size), 10) : undefined,
|
|
37
|
+
createdTime: typeof file.createdTime === 'string' ? file.createdTime : undefined,
|
|
38
|
+
modifiedTime: typeof file.modifiedTime === 'string' ? file.modifiedTime : undefined,
|
|
39
|
+
parents: Array.isArray(file.parents) ? file.parents : undefined,
|
|
40
|
+
webViewLink: typeof file.webViewLink === 'string' ? file.webViewLink : undefined,
|
|
41
|
+
}));
|
|
42
|
+
return {
|
|
43
|
+
files,
|
|
44
|
+
nextPageToken: response.data.nextPageToken ?? undefined,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=search-files.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-files.js","sourceRoot":"","sources":["../../src/operations/search-files.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjD;;GAEG;AACH,MAAM,cAAc,GAAG;IACrB,IAAI;IACJ,MAAM;IACN,UAAU;IACV,MAAM;IACN,aAAa;IACb,cAAc;IACd,SAAS;IACT,aAAa;CACd,CAAC;AAgBF,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,OAAoC,EACpC,MAAe;IAEf,kCAAkC;IAClC,MAAM,cAAc,GAAG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAChD,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IAE5D,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;IAEtF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC;QACtC,CAAC,EAAE,KAAK;QACR,QAAQ;QACR,SAAS;QACT,OAAO;QACP,MAAM,EAAE,wBAAwB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG;KACpD,CAAC,CAAC;IAEH,MAAM,KAAK,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;SACtC,MAAM,CAAC,CAAC,IAAI,EAAoF,EAAE,CACjG,IAAI,CAAC,EAAE,IAAI,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;SAC/D,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACd,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;QACrE,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;QAChF,YAAY,EAAE,OAAO,IAAI,CAAC,YAAY,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS;QACnF,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAmB,CAAC,CAAC,CAAC,SAAS;QAC3E,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;KACjF,CAAC,CAAC,CAAC;IAEN,OAAO;QACL,KAAK;QACL,aAAa,EAAE,QAAQ,CAAC,IAAI,CAAC,aAAa,IAAI,SAAS;KACxD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload file operation
|
|
3
|
+
*/
|
|
4
|
+
import type { UploadFileOperationOptions, UploadFileResult, Tokens } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Upload a file to Google Drive
|
|
7
|
+
*
|
|
8
|
+
* @param options - Upload options including file name, content, and parent folder
|
|
9
|
+
* @param tokensOrOptions - Tokens or combined options object
|
|
10
|
+
* @returns Uploaded file metadata
|
|
11
|
+
*/
|
|
12
|
+
export declare function uploadFile(options: UploadFileOperationOptions): Promise<UploadFileResult>;
|
|
13
|
+
export declare function uploadFile(options: Omit<UploadFileOperationOptions, 'tokens'>, tokens?: Tokens): Promise<UploadFileResult>;
|
|
14
|
+
//# sourceMappingURL=upload-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-file.d.ts","sourceRoot":"","sources":["../../src/operations/upload-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAExF;;;;;;GAMG;AACH,wBAAsB,UAAU,CAC9B,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAC7B,wBAAsB,UAAU,CAC9B,OAAO,EAAE,IAAI,CAAC,0BAA0B,EAAE,QAAQ,CAAC,EACnD,MAAM,CAAC,EAAE,MAAM,GACd,OAAO,CAAC,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Upload file operation
|
|
3
|
+
*/
|
|
4
|
+
import { createDriveClient } from '../client.js';
|
|
5
|
+
export async function uploadFile(options, tokens) {
|
|
6
|
+
// Handle both calling conventions
|
|
7
|
+
const resolvedTokens = tokens ?? options.tokens;
|
|
8
|
+
const drive = createDriveClient({ tokens: resolvedTokens });
|
|
9
|
+
const { name, mimeType, parents, body, description } = options;
|
|
10
|
+
const response = await drive.files.create({
|
|
11
|
+
requestBody: {
|
|
12
|
+
name,
|
|
13
|
+
mimeType,
|
|
14
|
+
parents,
|
|
15
|
+
description,
|
|
16
|
+
},
|
|
17
|
+
media: {
|
|
18
|
+
mimeType: mimeType || 'application/octet-stream',
|
|
19
|
+
body,
|
|
20
|
+
},
|
|
21
|
+
fields: 'id,name,mimeType,size,webViewLink,createdTime',
|
|
22
|
+
});
|
|
23
|
+
const data = response.data;
|
|
24
|
+
if (!data.id || !data.name || !data.mimeType) {
|
|
25
|
+
throw new Error('Upload failed: incomplete response from Google Drive API');
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
id: data.id,
|
|
29
|
+
name: data.name,
|
|
30
|
+
mimeType: data.mimeType,
|
|
31
|
+
size: data.size != null ? parseInt(String(data.size), 10) : undefined,
|
|
32
|
+
webViewLink: typeof data.webViewLink === 'string' ? data.webViewLink : undefined,
|
|
33
|
+
createdTime: typeof data.createdTime === 'string' ? data.createdTime : undefined,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=upload-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"upload-file.js","sourceRoot":"","sources":["../../src/operations/upload-file.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAiBjD,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,OAAmC,EACnC,MAAe;IAEf,kCAAkC;IAClC,MAAM,cAAc,GAAG,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;IAChD,MAAM,KAAK,GAAG,iBAAiB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;IAE5D,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC;IAE/D,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;QACxC,WAAW,EAAE;YACX,IAAI;YACJ,QAAQ;YACR,OAAO;YACP,WAAW;SACZ;QACD,KAAK,EAAE;YACL,QAAQ,EAAE,QAAQ,IAAI,0BAA0B;YAChD,IAAI;SACL;QACD,MAAM,EAAE,+CAA+C;KACxD,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC;IAC3B,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI,CAAC,EAAE;QACX,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS;QACrE,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;QAChF,WAAW,EAAE,OAAO,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS;KACjF,CAAC;AACJ,CAAC"}
|
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token resolution logic for google-drive-mcp
|
|
3
|
+
*
|
|
4
|
+
* Priority order (lowest to highest):
|
|
5
|
+
* 1. JSON file at GOOGLE_DRIVE_TOKEN_FILE or ./token.json
|
|
6
|
+
* 2. Environment variable GOOGLE_DRIVE_TOKEN (JSON string)
|
|
7
|
+
* 3. Direct tokens parameter passed to functions
|
|
8
|
+
*/
|
|
9
|
+
import type { Tokens } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Error thrown when no valid tokens are found
|
|
12
|
+
*/
|
|
13
|
+
export declare class TokenNotFoundError extends Error {
|
|
14
|
+
constructor(message?: string);
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Resolve tokens from multiple sources with priority
|
|
18
|
+
*
|
|
19
|
+
* @param provided - Tokens passed directly to the function (highest priority)
|
|
20
|
+
* @returns Resolved tokens or null if none found
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveTokens(provided?: Tokens): Tokens | null;
|
|
23
|
+
/**
|
|
24
|
+
* Resolve tokens or throw error if none found
|
|
25
|
+
*
|
|
26
|
+
* @param provided - Tokens passed directly to the function
|
|
27
|
+
* @returns Resolved tokens
|
|
28
|
+
* @throws TokenNotFoundError if no valid tokens found
|
|
29
|
+
*/
|
|
30
|
+
export declare function requireTokens(provided?: Tokens): Tokens;
|
|
31
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,OAAO,GAAE,MAAiF;CAIvG;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsC9D;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAMvD"}
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Token resolution logic for google-drive-mcp
|
|
3
|
+
*
|
|
4
|
+
* Priority order (lowest to highest):
|
|
5
|
+
* 1. JSON file at GOOGLE_DRIVE_TOKEN_FILE or ./token.json
|
|
6
|
+
* 2. Environment variable GOOGLE_DRIVE_TOKEN (JSON string)
|
|
7
|
+
* 3. Direct tokens parameter passed to functions
|
|
8
|
+
*/
|
|
9
|
+
import { readFileSync, existsSync } from 'node:fs';
|
|
10
|
+
import { resolve } from 'node:path';
|
|
11
|
+
/**
|
|
12
|
+
* Error thrown when no valid tokens are found
|
|
13
|
+
*/
|
|
14
|
+
export class TokenNotFoundError extends Error {
|
|
15
|
+
constructor(message = 'No valid tokens found. Provide tokens via parameter, env var, or file.') {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = 'TokenNotFoundError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Resolve tokens from multiple sources with priority
|
|
22
|
+
*
|
|
23
|
+
* @param provided - Tokens passed directly to the function (highest priority)
|
|
24
|
+
* @returns Resolved tokens or null if none found
|
|
25
|
+
*/
|
|
26
|
+
export function resolveTokens(provided) {
|
|
27
|
+
// 1. Check direct param (highest priority)
|
|
28
|
+
if (provided?.access_token) {
|
|
29
|
+
return provided;
|
|
30
|
+
}
|
|
31
|
+
// 2. Check env var GOOGLE_DRIVE_TOKEN
|
|
32
|
+
const envToken = process.env.GOOGLE_DRIVE_TOKEN;
|
|
33
|
+
if (envToken) {
|
|
34
|
+
try {
|
|
35
|
+
const parsed = JSON.parse(envToken);
|
|
36
|
+
if (parsed.access_token) {
|
|
37
|
+
return parsed;
|
|
38
|
+
}
|
|
39
|
+
console.error('GOOGLE_DRIVE_TOKEN env var does not contain valid access_token');
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error('Failed to parse GOOGLE_DRIVE_TOKEN env var:', error);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// 3. Check token file
|
|
46
|
+
const tokenFilePath = process.env.GOOGLE_DRIVE_TOKEN_FILE || './token.json';
|
|
47
|
+
const absolutePath = resolve(tokenFilePath);
|
|
48
|
+
if (existsSync(absolutePath)) {
|
|
49
|
+
try {
|
|
50
|
+
const fileContent = readFileSync(absolutePath, 'utf-8');
|
|
51
|
+
const parsed = JSON.parse(fileContent);
|
|
52
|
+
if (parsed.access_token) {
|
|
53
|
+
return parsed;
|
|
54
|
+
}
|
|
55
|
+
console.error(`Token file at ${absolutePath} does not contain valid access_token`);
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
console.error(`Failed to read/parse token file at ${absolutePath}:`, error);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Resolve tokens or throw error if none found
|
|
65
|
+
*
|
|
66
|
+
* @param provided - Tokens passed directly to the function
|
|
67
|
+
* @returns Resolved tokens
|
|
68
|
+
* @throws TokenNotFoundError if no valid tokens found
|
|
69
|
+
*/
|
|
70
|
+
export function requireTokens(provided) {
|
|
71
|
+
const tokens = resolveTokens(provided);
|
|
72
|
+
if (!tokens) {
|
|
73
|
+
throw new TokenNotFoundError();
|
|
74
|
+
}
|
|
75
|
+
return tokens;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGpC;;GAEG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,UAAkB,wEAAwE;QACpG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,QAAiB;IAC7C,2CAA2C;IAC3C,IAAI,QAAQ,EAAE,YAAY,EAAE,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,sCAAsC;IACtC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC;IAChD,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,C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types.d.ts
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core types and interfaces for google-drive-mcp
|
|
3
|
+
*/
|
|
4
|
+
import type { Readable } from 'node:stream';
|
|
5
|
+
/**
|
|
6
|
+
* Token structure for Google Drive OAuth2
|
|
7
|
+
*/
|
|
8
|
+
export interface Tokens {
|
|
9
|
+
access_token: string;
|
|
10
|
+
refresh_token?: string;
|
|
11
|
+
scope?: string;
|
|
12
|
+
token_type?: string;
|
|
13
|
+
expiry_date?: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Options for creating Drive client
|
|
17
|
+
*/
|
|
18
|
+
export interface DriveClientOptions {
|
|
19
|
+
tokens?: Tokens;
|
|
20
|
+
clientId?: string;
|
|
21
|
+
clientSecret?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* File metadata interface
|
|
25
|
+
*/
|
|
26
|
+
export interface FileMetadata {
|
|
27
|
+
id?: string;
|
|
28
|
+
name?: string;
|
|
29
|
+
mimeType?: string;
|
|
30
|
+
parents?: string[];
|
|
31
|
+
size?: number;
|
|
32
|
+
createdTime?: string;
|
|
33
|
+
modifiedTime?: string;
|
|
34
|
+
webViewLink?: string;
|
|
35
|
+
thumbnailLink?: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
owners?: Array<{
|
|
38
|
+
displayName?: string;
|
|
39
|
+
emailAddress?: string;
|
|
40
|
+
}>;
|
|
41
|
+
[key: string]: unknown;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Options for listing files
|
|
45
|
+
*/
|
|
46
|
+
export interface ListFilesOptions {
|
|
47
|
+
pageSize?: number;
|
|
48
|
+
pageToken?: string;
|
|
49
|
+
orderBy?: string;
|
|
50
|
+
fields?: string[];
|
|
51
|
+
query?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Result of listing files
|
|
55
|
+
*/
|
|
56
|
+
export interface ListFilesResult {
|
|
57
|
+
files: Array<{
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
mimeType: string;
|
|
61
|
+
size?: number;
|
|
62
|
+
createdTime?: string;
|
|
63
|
+
modifiedTime?: string;
|
|
64
|
+
parents?: string[];
|
|
65
|
+
webViewLink?: string;
|
|
66
|
+
}>;
|
|
67
|
+
nextPageToken?: string;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Options for uploading a file
|
|
71
|
+
*/
|
|
72
|
+
export interface UploadFileOptions {
|
|
73
|
+
name: string;
|
|
74
|
+
mimeType?: string;
|
|
75
|
+
parents?: string[];
|
|
76
|
+
body: Readable | Buffer | string;
|
|
77
|
+
description?: string;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Result of uploading a file
|
|
81
|
+
*/
|
|
82
|
+
export interface UploadFileResult {
|
|
83
|
+
id: string;
|
|
84
|
+
name: string;
|
|
85
|
+
mimeType: string;
|
|
86
|
+
size?: number;
|
|
87
|
+
webViewLink?: string;
|
|
88
|
+
createdTime?: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Options for searching files
|
|
92
|
+
*/
|
|
93
|
+
export interface SearchFilesOptions {
|
|
94
|
+
query: string;
|
|
95
|
+
pageSize?: number;
|
|
96
|
+
pageToken?: string;
|
|
97
|
+
orderBy?: string;
|
|
98
|
+
fields?: string[];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Options for creating a folder
|
|
102
|
+
*/
|
|
103
|
+
export interface CreateFolderOptions {
|
|
104
|
+
name: string;
|
|
105
|
+
parents?: string[];
|
|
106
|
+
description?: string;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Result of creating a folder
|
|
110
|
+
*/
|
|
111
|
+
export interface CreateFolderResult {
|
|
112
|
+
id: string;
|
|
113
|
+
name: string;
|
|
114
|
+
mimeType: string;
|
|
115
|
+
parents?: string[];
|
|
116
|
+
webViewLink?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Result of downloading a file
|
|
120
|
+
*/
|
|
121
|
+
export interface DownloadFileResult {
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
mimeType: string;
|
|
125
|
+
content: Buffer;
|
|
126
|
+
size: number;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Options for getting a file
|
|
130
|
+
*/
|
|
131
|
+
export interface GetFileOptions {
|
|
132
|
+
fileId: string;
|
|
133
|
+
fields?: string[];
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Base options for operations that accept tokens
|
|
137
|
+
*/
|
|
138
|
+
export interface OperationOptions {
|
|
139
|
+
tokens?: Tokens;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Combined options for list files operation
|
|
143
|
+
*/
|
|
144
|
+
export interface ListFilesOperationOptions extends ListFilesOptions, OperationOptions {
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Combined options for upload file operation
|
|
148
|
+
*/
|
|
149
|
+
export interface UploadFileOperationOptions extends UploadFileOptions, OperationOptions {
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Combined options for search files operation
|
|
153
|
+
*/
|
|
154
|
+
export interface SearchFilesOperationOptions extends SearchFilesOptions, OperationOptions {
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Combined options for create folder operation
|
|
158
|
+
*/
|
|
159
|
+
export interface CreateFolderOperationOptions extends CreateFolderOptions, OperationOptions {
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Combined options for get file operation
|
|
163
|
+
*/
|
|
164
|
+
export interface GetFileOperationOptions extends GetFileOptions, OperationOptions {
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Combined options for download file operation
|
|
168
|
+
*/
|
|
169
|
+
export interface DownloadFileOperationOptions extends OperationOptions {
|
|
170
|
+
fileId: string;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Combined options for delete file operation
|
|
174
|
+
*/
|
|
175
|
+
export interface DeleteFileOperationOptions extends OperationOptions {
|
|
176
|
+
fileId: string;
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,KAAK,CAAC;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC,CAAC;IACH,CAAC,GAAG,EAAE,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