mcp-quickbase 2.0.1
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/CHANGELOG.md +82 -0
- package/LICENSE +21 -0
- package/README.md +301 -0
- package/dist/client/quickbase.d.ts +28 -0
- package/dist/client/quickbase.js +235 -0
- package/dist/client/quickbase.js.map +1 -0
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.js +21 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.d.ts +19 -0
- package/dist/mcp/server.js +102 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/mcp-stdio-server.d.ts +2 -0
- package/dist/mcp-stdio-server.js +168 -0
- package/dist/mcp-stdio-server.js.map +1 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +318 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/apps/create_app.d.ts +87 -0
- package/dist/tools/apps/create_app.js +87 -0
- package/dist/tools/apps/create_app.js.map +1 -0
- package/dist/tools/apps/index.d.ts +9 -0
- package/dist/tools/apps/index.js +40 -0
- package/dist/tools/apps/index.js.map +1 -0
- package/dist/tools/apps/list_tables.d.ts +108 -0
- package/dist/tools/apps/list_tables.js +100 -0
- package/dist/tools/apps/list_tables.js.map +1 -0
- package/dist/tools/apps/update_app.d.ts +91 -0
- package/dist/tools/apps/update_app.js +99 -0
- package/dist/tools/apps/update_app.js.map +1 -0
- package/dist/tools/base.d.ts +47 -0
- package/dist/tools/base.js +63 -0
- package/dist/tools/base.js.map +1 -0
- package/dist/tools/configure_cache.d.ts +81 -0
- package/dist/tools/configure_cache.js +77 -0
- package/dist/tools/configure_cache.js.map +1 -0
- package/dist/tools/fields/create_field.d.ts +121 -0
- package/dist/tools/fields/create_field.js +102 -0
- package/dist/tools/fields/create_field.js.map +1 -0
- package/dist/tools/fields/index.d.ts +8 -0
- package/dist/tools/fields/index.js +37 -0
- package/dist/tools/fields/index.js.map +1 -0
- package/dist/tools/fields/update_field.d.ts +112 -0
- package/dist/tools/fields/update_field.js +114 -0
- package/dist/tools/fields/update_field.js.map +1 -0
- package/dist/tools/files/download_file.d.ts +111 -0
- package/dist/tools/files/download_file.js +173 -0
- package/dist/tools/files/download_file.js.map +1 -0
- package/dist/tools/files/index.d.ts +8 -0
- package/dist/tools/files/index.js +37 -0
- package/dist/tools/files/index.js.map +1 -0
- package/dist/tools/files/upload_file.d.ts +107 -0
- package/dist/tools/files/upload_file.js +211 -0
- package/dist/tools/files/upload_file.js.map +1 -0
- package/dist/tools/index.d.ts +18 -0
- package/dist/tools/index.js +65 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/records/bulk_create_records.d.ts +75 -0
- package/dist/tools/records/bulk_create_records.js +104 -0
- package/dist/tools/records/bulk_create_records.js.map +1 -0
- package/dist/tools/records/bulk_update_records.d.ts +77 -0
- package/dist/tools/records/bulk_update_records.js +102 -0
- package/dist/tools/records/bulk_update_records.js.map +1 -0
- package/dist/tools/records/create_record.d.ts +68 -0
- package/dist/tools/records/create_record.js +123 -0
- package/dist/tools/records/create_record.js.map +1 -0
- package/dist/tools/records/index.d.ts +11 -0
- package/dist/tools/records/index.js +46 -0
- package/dist/tools/records/index.js.map +1 -0
- package/dist/tools/records/query_records.d.ts +164 -0
- package/dist/tools/records/query_records.js +261 -0
- package/dist/tools/records/query_records.js.map +1 -0
- package/dist/tools/records/update_record.d.ts +81 -0
- package/dist/tools/records/update_record.js +99 -0
- package/dist/tools/records/update_record.js.map +1 -0
- package/dist/tools/registry.d.ts +41 -0
- package/dist/tools/registry.js +66 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/reports/index.d.ts +6 -0
- package/dist/tools/reports/index.js +31 -0
- package/dist/tools/reports/index.js.map +1 -0
- package/dist/tools/reports/run_report.d.ts +70 -0
- package/dist/tools/reports/run_report.js +72 -0
- package/dist/tools/reports/run_report.js.map +1 -0
- package/dist/tools/tables/create_table.d.ts +142 -0
- package/dist/tools/tables/create_table.js +119 -0
- package/dist/tools/tables/create_table.js.map +1 -0
- package/dist/tools/tables/get_table_fields.d.ts +108 -0
- package/dist/tools/tables/get_table_fields.js +96 -0
- package/dist/tools/tables/get_table_fields.js.map +1 -0
- package/dist/tools/tables/index.d.ts +9 -0
- package/dist/tools/tables/index.js +40 -0
- package/dist/tools/tables/index.js.map +1 -0
- package/dist/tools/tables/update_table.d.ts +91 -0
- package/dist/tools/tables/update_table.js +99 -0
- package/dist/tools/tables/update_table.js.map +1 -0
- package/dist/tools/test_connection.d.ts +51 -0
- package/dist/tools/test_connection.js +101 -0
- package/dist/tools/test_connection.js.map +1 -0
- package/dist/types/api.d.ts +70 -0
- package/dist/types/api.js +6 -0
- package/dist/types/api.js.map +1 -0
- package/dist/types/config.d.ts +49 -0
- package/dist/types/config.js +3 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/mcp.d.ts +55 -0
- package/dist/types/mcp.js +3 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/utils/cache.d.ts +87 -0
- package/dist/utils/cache.js +211 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/file.d.ts +40 -0
- package/dist/utils/file.js +167 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/logger.d.ts +37 -0
- package/dist/utils/logger.js +144 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/retry.d.ts +39 -0
- package/dist/utils/retry.js +88 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/validation.d.ts +32 -0
- package/dist/utils/validation.js +227 -0
- package/dist/utils/validation.js.map +1 -0
- package/docs/README.md +41 -0
- package/docs/architecture.md +94 -0
- package/docs/claude-prompts.md +218 -0
- package/docs/deployment.md +244 -0
- package/docs/developer-guide.md +537 -0
- package/docs/final-qa-report.md +243 -0
- package/docs/performance-benchmarks.md +306 -0
- package/docs/quick-reference.md +109 -0
- package/docs/quickstart.md +183 -0
- package/docs/security-review.md +263 -0
- package/docs/tools.md +269 -0
- package/package.json +68 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UpdateFieldTool = void 0;
|
|
4
|
+
const base_1 = require("../base");
|
|
5
|
+
const logger_1 = require("../../utils/logger");
|
|
6
|
+
const logger = (0, logger_1.createLogger)('UpdateFieldTool');
|
|
7
|
+
/**
|
|
8
|
+
* Tool for updating an existing field in a Quickbase table
|
|
9
|
+
*/
|
|
10
|
+
class UpdateFieldTool extends base_1.BaseTool {
|
|
11
|
+
/**
|
|
12
|
+
* Constructor
|
|
13
|
+
* @param client Quickbase client
|
|
14
|
+
*/
|
|
15
|
+
constructor(client) {
|
|
16
|
+
super(client);
|
|
17
|
+
this.name = 'update_field';
|
|
18
|
+
this.description = 'Updates an existing field in a Quickbase table';
|
|
19
|
+
/**
|
|
20
|
+
* Parameter schema for update_field
|
|
21
|
+
*/
|
|
22
|
+
this.paramSchema = {
|
|
23
|
+
type: 'object',
|
|
24
|
+
properties: {
|
|
25
|
+
table_id: {
|
|
26
|
+
type: 'string',
|
|
27
|
+
description: 'The ID of the table'
|
|
28
|
+
},
|
|
29
|
+
field_id: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
description: 'The ID of the field'
|
|
32
|
+
},
|
|
33
|
+
name: {
|
|
34
|
+
type: 'string',
|
|
35
|
+
description: 'New name for the field'
|
|
36
|
+
},
|
|
37
|
+
field_type: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
description: 'New type for the field'
|
|
40
|
+
},
|
|
41
|
+
description: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'New description for the field'
|
|
44
|
+
},
|
|
45
|
+
options: {
|
|
46
|
+
type: 'object',
|
|
47
|
+
description: 'Additional field options'
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
required: ['table_id', 'field_id']
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Run the update_field tool
|
|
55
|
+
* @param params Tool parameters
|
|
56
|
+
* @returns Updated field details
|
|
57
|
+
*/
|
|
58
|
+
async run(params) {
|
|
59
|
+
const { table_id, field_id, name, field_type, description, options } = params;
|
|
60
|
+
logger.info('Updating field in Quickbase table', {
|
|
61
|
+
tableId: table_id,
|
|
62
|
+
fieldId: field_id
|
|
63
|
+
});
|
|
64
|
+
// At least one update field is required
|
|
65
|
+
if (!name && !description && !field_type && (!options || Object.keys(options).length === 0)) {
|
|
66
|
+
throw new Error('At least one update field (name, description, field_type, or options) is required');
|
|
67
|
+
}
|
|
68
|
+
// Prepare request body with only the fields that are provided
|
|
69
|
+
const body = {};
|
|
70
|
+
if (name !== undefined) {
|
|
71
|
+
body.label = name;
|
|
72
|
+
}
|
|
73
|
+
if (field_type !== undefined) {
|
|
74
|
+
body.fieldType = field_type;
|
|
75
|
+
}
|
|
76
|
+
if (description !== undefined) {
|
|
77
|
+
body.description = description;
|
|
78
|
+
}
|
|
79
|
+
// Add properties if provided
|
|
80
|
+
if (options && Object.keys(options).length > 0) {
|
|
81
|
+
body.properties = { ...options };
|
|
82
|
+
}
|
|
83
|
+
// Update the field
|
|
84
|
+
const response = await this.client.request({
|
|
85
|
+
method: 'POST',
|
|
86
|
+
path: `/fields/${field_id}?tableId=${table_id}`,
|
|
87
|
+
body
|
|
88
|
+
});
|
|
89
|
+
if (!response.success || !response.data) {
|
|
90
|
+
logger.error('Failed to update field', {
|
|
91
|
+
error: response.error,
|
|
92
|
+
tableId: table_id,
|
|
93
|
+
fieldId: field_id
|
|
94
|
+
});
|
|
95
|
+
throw new Error(response.error?.message || 'Failed to update field');
|
|
96
|
+
}
|
|
97
|
+
const field = response.data;
|
|
98
|
+
logger.info('Successfully updated field', {
|
|
99
|
+
fieldId: field.id,
|
|
100
|
+
tableId: table_id,
|
|
101
|
+
updates: Object.keys(body).join(', ')
|
|
102
|
+
});
|
|
103
|
+
return {
|
|
104
|
+
fieldId: field.id,
|
|
105
|
+
label: field.label,
|
|
106
|
+
fieldType: field.fieldType,
|
|
107
|
+
description: field.description,
|
|
108
|
+
tableId: table_id,
|
|
109
|
+
...field
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
exports.UpdateFieldTool = UpdateFieldTool;
|
|
114
|
+
//# sourceMappingURL=update_field.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update_field.js","sourceRoot":"","sources":["../../../src/tools/fields/update_field.ts"],"names":[],"mappings":";;;AAAA,kCAAmC;AAEnC,+CAAkD;AAGlD,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,iBAAiB,CAAC,CAAC;AAwE/C;;GAEG;AACH,MAAa,eAAgB,SAAQ,eAA8C;IAsCjF;;;OAGG;IACH,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAC;QA1CT,SAAI,GAAG,cAAc,CAAC;QACtB,gBAAW,GAAG,gDAAgD,CAAC;QAEtE;;WAEG;QACI,gBAAW,GAAG;YACnB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qBAAqB;iBACnC;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qBAAqB;iBACnC;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,wBAAwB;iBACtC;gBACD,UAAU,EAAE;oBACV,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,wBAAwB;iBACtC;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,+BAA+B;iBAC7C;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,0BAA0B;iBACxC;aACF;YACD,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC;SACnC,CAAC;IAQF,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,GAAG,CAAC,MAAyB;QAC3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Q,CAAC,IAAI,EAAE,CAAC;YACxC,MAAM,CAAC,KAAK,CAAC,wBAAwB,EAAE;gBACrC,KAAK,EAAE,QAAQ,CAAC,KAAK;gBACrB,OAAO,EAAE,QAAQ;gBACjB,OAAO,EAAE,QAAQ;aAClB,CAAC,CAAC;YACH,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,IAAI,wBAAwB,CAAC,CAAC;QACvE,CAAC;QAED,MAAM,KAAK,GAAG,QAAQ,CAAC,IAA2B,CAAC;QAEnD,MAAM,CAAC,IAAI,CAAC,4BAA4B,EAAE;YACxC,OAAO,EAAE,KAAK,CAAC,EAAE;YACjB,OAAO,EAAE,QAAQ;YACjB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;SACtC,CAAC,CAAC;QAEH,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,EAAE;YACjB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,OAAO,EAAE,QAAQ;YACjB,GAAG,KAAK;SACT,CAAC;IACJ,CAAC;CACF;AArHD,0CAqHC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { BaseTool } from '../base';
|
|
2
|
+
import { QuickbaseClient } from '../../client/quickbase';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for download_file tool
|
|
5
|
+
*/
|
|
6
|
+
export interface DownloadFileParams {
|
|
7
|
+
/**
|
|
8
|
+
* The ID of the table containing the record
|
|
9
|
+
*/
|
|
10
|
+
table_id: string;
|
|
11
|
+
/**
|
|
12
|
+
* The ID of the record containing the file
|
|
13
|
+
*/
|
|
14
|
+
record_id: string;
|
|
15
|
+
/**
|
|
16
|
+
* The ID of the file attachment field
|
|
17
|
+
*/
|
|
18
|
+
field_id: string;
|
|
19
|
+
/**
|
|
20
|
+
* Path where the file should be saved
|
|
21
|
+
*/
|
|
22
|
+
output_path: string;
|
|
23
|
+
/**
|
|
24
|
+
* The version of the file to download (default 0 for latest)
|
|
25
|
+
*/
|
|
26
|
+
version?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Response from downloading a file
|
|
30
|
+
*/
|
|
31
|
+
export interface DownloadFileResult {
|
|
32
|
+
/**
|
|
33
|
+
* The ID of the record the file was downloaded from
|
|
34
|
+
*/
|
|
35
|
+
recordId: string;
|
|
36
|
+
/**
|
|
37
|
+
* The ID of the field the file was downloaded from
|
|
38
|
+
*/
|
|
39
|
+
fieldId: string;
|
|
40
|
+
/**
|
|
41
|
+
* The ID of the table containing the record
|
|
42
|
+
*/
|
|
43
|
+
tableId: string;
|
|
44
|
+
/**
|
|
45
|
+
* The name of the downloaded file
|
|
46
|
+
*/
|
|
47
|
+
fileName: string;
|
|
48
|
+
/**
|
|
49
|
+
* The size of the downloaded file in bytes
|
|
50
|
+
*/
|
|
51
|
+
fileSize: number;
|
|
52
|
+
/**
|
|
53
|
+
* The version of the file
|
|
54
|
+
*/
|
|
55
|
+
version: string;
|
|
56
|
+
/**
|
|
57
|
+
* The path where the file was saved
|
|
58
|
+
*/
|
|
59
|
+
outputPath: string;
|
|
60
|
+
/**
|
|
61
|
+
* Download timestamp
|
|
62
|
+
*/
|
|
63
|
+
downloadTime: string;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Tool for downloading a file from a field in a Quickbase record
|
|
67
|
+
*/
|
|
68
|
+
export declare class DownloadFileTool extends BaseTool<DownloadFileParams, DownloadFileResult> {
|
|
69
|
+
name: string;
|
|
70
|
+
description: string;
|
|
71
|
+
/**
|
|
72
|
+
* Parameter schema for download_file
|
|
73
|
+
*/
|
|
74
|
+
paramSchema: {
|
|
75
|
+
type: string;
|
|
76
|
+
properties: {
|
|
77
|
+
table_id: {
|
|
78
|
+
type: string;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
record_id: {
|
|
82
|
+
type: string;
|
|
83
|
+
description: string;
|
|
84
|
+
};
|
|
85
|
+
field_id: {
|
|
86
|
+
type: string;
|
|
87
|
+
description: string;
|
|
88
|
+
};
|
|
89
|
+
output_path: {
|
|
90
|
+
type: string;
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
version: {
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
required: string[];
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Constructor
|
|
102
|
+
* @param client Quickbase client
|
|
103
|
+
*/
|
|
104
|
+
constructor(client: QuickbaseClient);
|
|
105
|
+
/**
|
|
106
|
+
* Run the download_file tool
|
|
107
|
+
* @param params Tool parameters
|
|
108
|
+
* @returns Download result
|
|
109
|
+
*/
|
|
110
|
+
protected run(params: DownloadFileParams): Promise<DownloadFileResult>;
|
|
111
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DownloadFileTool = void 0;
|
|
37
|
+
const base_1 = require("../base");
|
|
38
|
+
const logger_1 = require("../../utils/logger");
|
|
39
|
+
const file_1 = require("../../utils/file");
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const logger = (0, logger_1.createLogger)('DownloadFileTool');
|
|
42
|
+
/**
|
|
43
|
+
* Tool for downloading a file from a field in a Quickbase record
|
|
44
|
+
*/
|
|
45
|
+
class DownloadFileTool extends base_1.BaseTool {
|
|
46
|
+
/**
|
|
47
|
+
* Constructor
|
|
48
|
+
* @param client Quickbase client
|
|
49
|
+
*/
|
|
50
|
+
constructor(client) {
|
|
51
|
+
super(client);
|
|
52
|
+
this.name = 'download_file';
|
|
53
|
+
this.description = 'Downloads a file from a field in a Quickbase record';
|
|
54
|
+
/**
|
|
55
|
+
* Parameter schema for download_file
|
|
56
|
+
*/
|
|
57
|
+
this.paramSchema = {
|
|
58
|
+
type: 'object',
|
|
59
|
+
properties: {
|
|
60
|
+
table_id: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'The ID of the Quickbase table'
|
|
63
|
+
},
|
|
64
|
+
record_id: {
|
|
65
|
+
type: 'string',
|
|
66
|
+
description: 'The ID of the record'
|
|
67
|
+
},
|
|
68
|
+
field_id: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
description: 'The ID of the field (must be a file attachment field)'
|
|
71
|
+
},
|
|
72
|
+
output_path: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
description: 'Path where the file should be saved'
|
|
75
|
+
},
|
|
76
|
+
version: {
|
|
77
|
+
type: 'string',
|
|
78
|
+
description: 'The version of the file to download (default 0 for latest)'
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
required: ['table_id', 'record_id', 'field_id', 'output_path']
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Run the download_file tool
|
|
86
|
+
* @param params Tool parameters
|
|
87
|
+
* @returns Download result
|
|
88
|
+
*/
|
|
89
|
+
async run(params) {
|
|
90
|
+
const { table_id, record_id, field_id, output_path, version = '0' } = params;
|
|
91
|
+
logger.info('Downloading file from Quickbase record', {
|
|
92
|
+
tableId: table_id,
|
|
93
|
+
recordId: record_id,
|
|
94
|
+
fieldId: field_id,
|
|
95
|
+
version
|
|
96
|
+
});
|
|
97
|
+
// Check if the output directory exists
|
|
98
|
+
const outputDir = path.dirname(output_path);
|
|
99
|
+
if (!(0, file_1.ensureDirectoryExists)(outputDir)) {
|
|
100
|
+
throw new Error(`Unable to create output directory: ${outputDir}`);
|
|
101
|
+
}
|
|
102
|
+
// Build the URL for downloading the file
|
|
103
|
+
const queryParams = {
|
|
104
|
+
tableId: table_id,
|
|
105
|
+
recordId: record_id,
|
|
106
|
+
fieldId: field_id,
|
|
107
|
+
version
|
|
108
|
+
};
|
|
109
|
+
// Construct the query string
|
|
110
|
+
const queryString = Object.entries(queryParams)
|
|
111
|
+
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
|
|
112
|
+
.join('&');
|
|
113
|
+
// Download the file
|
|
114
|
+
const response = await this.client.request({
|
|
115
|
+
method: 'GET',
|
|
116
|
+
path: `/files?${queryString}`
|
|
117
|
+
});
|
|
118
|
+
if (!response.success || !response.data) {
|
|
119
|
+
logger.error('Failed to download file', {
|
|
120
|
+
error: response.error,
|
|
121
|
+
tableId: table_id,
|
|
122
|
+
recordId: record_id,
|
|
123
|
+
fieldId: field_id
|
|
124
|
+
});
|
|
125
|
+
throw new Error(response.error?.message || 'Failed to download file');
|
|
126
|
+
}
|
|
127
|
+
const fileData = response.data;
|
|
128
|
+
// Extract file information
|
|
129
|
+
const fileName = fileData.fileName || 'downloaded_file';
|
|
130
|
+
const fileContent = fileData.fileData;
|
|
131
|
+
if (!fileContent) {
|
|
132
|
+
throw new Error('Downloaded file does not contain any data');
|
|
133
|
+
}
|
|
134
|
+
// Determine if the file content is base64 encoded
|
|
135
|
+
const isBase64 = typeof fileContent === 'string' &&
|
|
136
|
+
/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/.test(fileContent);
|
|
137
|
+
// Decode and write the file
|
|
138
|
+
let fileBuffer;
|
|
139
|
+
if (isBase64) {
|
|
140
|
+
fileBuffer = Buffer.from(fileContent, 'base64');
|
|
141
|
+
}
|
|
142
|
+
else if (typeof fileContent === 'string') {
|
|
143
|
+
fileBuffer = Buffer.from(fileContent);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
throw new Error('Unsupported file data format');
|
|
147
|
+
}
|
|
148
|
+
// Write the file to the output path
|
|
149
|
+
const writeSuccess = (0, file_1.writeFile)(output_path, fileBuffer);
|
|
150
|
+
if (!writeSuccess) {
|
|
151
|
+
throw new Error(`Failed to write file to ${output_path}`);
|
|
152
|
+
}
|
|
153
|
+
logger.info('Successfully downloaded file', {
|
|
154
|
+
tableId: table_id,
|
|
155
|
+
recordId: record_id,
|
|
156
|
+
fieldId: field_id,
|
|
157
|
+
fileName,
|
|
158
|
+
outputPath: output_path
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
recordId: record_id,
|
|
162
|
+
fieldId: field_id,
|
|
163
|
+
tableId: table_id,
|
|
164
|
+
fileName,
|
|
165
|
+
fileSize: fileBuffer.length,
|
|
166
|
+
version,
|
|
167
|
+
outputPath: output_path,
|
|
168
|
+
downloadTime: new Date().toISOString()
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
exports.DownloadFileTool = DownloadFileTool;
|
|
173
|
+
//# sourceMappingURL=download_file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download_file.js","sourceRoot":"","sources":["../../../src/tools/files/download_file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kCAAmC;AAEnC,+CAAkD;AAClD,2CAAoE;AACpE,2CAA6B;AAE7B,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,kBAAkB,CAAC,CAAC;AA6EhD;;GAEG;AACH,MAAa,gBAAiB,SAAQ,eAAgD;IAkCpF;;;OAGG;IACH,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAC;QAtCT,SAAI,GAAG,eAAe,CAAC;QACvB,gBAAW,GAAG,qDAAqD,CAAC;QAE3E;;WAEG;QACI,gBAAW,GAAG;YACnB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,+BAA+B;iBAC7C;gBACD,SAAS,EAAE;oBACT,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,sBAAsB;iBACpC;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,uDAAuD;iBACrE;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,qCAAqC;iBACnD;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,4DAA4D;iBAC1E;aACF;YACD,QAAQ,EAAE,CAAC,UAAU,EAAE,WAAW,EAAE,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AA8B,EAAE;YAC1C,OAAO,EAAE,QAAQ;YACjB,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,QAAQ;YACjB,QAAQ;YACR,UAAU,EAAE,WAAW;SACxB,CAAC,CAAC;QAEH,OAAO;YACL,QAAQ,EAAE,SAAS;YACnB,OAAO,EAAE,QAAQ;YACjB,OAAO,EAAE,QAAQ;YACjB,QAAQ;YACR,QAAQ,EAAE,UAAU,CAAC,MAAM;YAC3B,OAAO;YACP,UAAU,EAAE,WAAW;YACvB,YAAY,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;SACvC,CAAC;IACJ,CAAC;CACF;AA/ID,4CA+IC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { QuickbaseClient } from '../../client/quickbase';
|
|
2
|
+
/**
|
|
3
|
+
* Register all file operation tools with the registry
|
|
4
|
+
* @param client Quickbase client
|
|
5
|
+
*/
|
|
6
|
+
export declare function registerFileTools(client: QuickbaseClient): void;
|
|
7
|
+
export * from './upload_file';
|
|
8
|
+
export * from './download_file';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.registerFileTools = registerFileTools;
|
|
18
|
+
const registry_1 = require("../registry");
|
|
19
|
+
const upload_file_1 = require("./upload_file");
|
|
20
|
+
const download_file_1 = require("./download_file");
|
|
21
|
+
const logger_1 = require("../../utils/logger");
|
|
22
|
+
const logger = (0, logger_1.createLogger)('FileTools');
|
|
23
|
+
/**
|
|
24
|
+
* Register all file operation tools with the registry
|
|
25
|
+
* @param client Quickbase client
|
|
26
|
+
*/
|
|
27
|
+
function registerFileTools(client) {
|
|
28
|
+
logger.info('Registering file operation tools');
|
|
29
|
+
// Register individual tools
|
|
30
|
+
registry_1.toolRegistry.registerTool(new upload_file_1.UploadFileTool(client));
|
|
31
|
+
registry_1.toolRegistry.registerTool(new download_file_1.DownloadFileTool(client));
|
|
32
|
+
logger.info('File operation tools registered');
|
|
33
|
+
}
|
|
34
|
+
// Export all tools
|
|
35
|
+
__exportStar(require("./upload_file"), exports);
|
|
36
|
+
__exportStar(require("./download_file"), exports);
|
|
37
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/files/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAYA,8CAQC;AAnBD,0CAA2C;AAC3C,+CAA+C;AAC/C,mDAAmD;AACnD,+CAAkD;AAElD,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,WAAW,CAAC,CAAC;AAEzC;;;GAGG;AACH,SAAgB,iBAAiB,CAAC,MAAuB;IACvD,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAEhD,4BAA4B;IAC5B,uBAAY,CAAC,YAAY,CAAC,IAAI,4BAAc,CAAC,MAAM,CAAC,CAAC,CAAC;IACtD,uBAAY,CAAC,YAAY,CAAC,IAAI,gCAAgB,CAAC,MAAM,CAAC,CAAC,CAAC;IAExD,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AACjD,CAAC;AAED,mBAAmB;AACnB,gDAA8B;AAC9B,kDAAgC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { BaseTool } from '../base';
|
|
2
|
+
import { QuickbaseClient } from '../../client/quickbase';
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for upload_file tool
|
|
5
|
+
*/
|
|
6
|
+
export interface UploadFileParams {
|
|
7
|
+
/**
|
|
8
|
+
* The ID of the table containing the record
|
|
9
|
+
*/
|
|
10
|
+
table_id: string;
|
|
11
|
+
/**
|
|
12
|
+
* The ID of the record to attach the file to
|
|
13
|
+
*/
|
|
14
|
+
record_id: string;
|
|
15
|
+
/**
|
|
16
|
+
* The ID of the file attachment field
|
|
17
|
+
*/
|
|
18
|
+
field_id: string;
|
|
19
|
+
/**
|
|
20
|
+
* Path to the file to upload
|
|
21
|
+
*/
|
|
22
|
+
file_path: string;
|
|
23
|
+
/**
|
|
24
|
+
* Custom file name (optional, defaults to the original filename)
|
|
25
|
+
*/
|
|
26
|
+
file_name?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Response from uploading a file
|
|
30
|
+
*/
|
|
31
|
+
export interface UploadFileResult {
|
|
32
|
+
/**
|
|
33
|
+
* The ID of the record the file was attached to
|
|
34
|
+
*/
|
|
35
|
+
recordId: string;
|
|
36
|
+
/**
|
|
37
|
+
* The ID of the field the file was attached to
|
|
38
|
+
*/
|
|
39
|
+
fieldId: string;
|
|
40
|
+
/**
|
|
41
|
+
* The ID of the table containing the record
|
|
42
|
+
*/
|
|
43
|
+
tableId: string;
|
|
44
|
+
/**
|
|
45
|
+
* The name of the uploaded file
|
|
46
|
+
*/
|
|
47
|
+
fileName: string;
|
|
48
|
+
/**
|
|
49
|
+
* The size of the uploaded file in bytes
|
|
50
|
+
*/
|
|
51
|
+
fileSize: number;
|
|
52
|
+
/**
|
|
53
|
+
* The version of the file (incremented for each upload to the same field)
|
|
54
|
+
*/
|
|
55
|
+
version?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Upload timestamp
|
|
58
|
+
*/
|
|
59
|
+
uploadTime?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Tool for uploading a file to a field in a Quickbase record
|
|
63
|
+
*/
|
|
64
|
+
export declare class UploadFileTool extends BaseTool<UploadFileParams, UploadFileResult> {
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
/**
|
|
68
|
+
* Parameter schema for upload_file
|
|
69
|
+
*/
|
|
70
|
+
paramSchema: {
|
|
71
|
+
type: string;
|
|
72
|
+
properties: {
|
|
73
|
+
table_id: {
|
|
74
|
+
type: string;
|
|
75
|
+
description: string;
|
|
76
|
+
};
|
|
77
|
+
record_id: {
|
|
78
|
+
type: string;
|
|
79
|
+
description: string;
|
|
80
|
+
};
|
|
81
|
+
field_id: {
|
|
82
|
+
type: string;
|
|
83
|
+
description: string;
|
|
84
|
+
};
|
|
85
|
+
file_path: {
|
|
86
|
+
type: string;
|
|
87
|
+
description: string;
|
|
88
|
+
};
|
|
89
|
+
file_name: {
|
|
90
|
+
type: string;
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
required: string[];
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Constructor
|
|
98
|
+
* @param client Quickbase client
|
|
99
|
+
*/
|
|
100
|
+
constructor(client: QuickbaseClient);
|
|
101
|
+
/**
|
|
102
|
+
* Run the upload_file tool
|
|
103
|
+
* @param params Tool parameters
|
|
104
|
+
* @returns Upload result
|
|
105
|
+
*/
|
|
106
|
+
protected run(params: UploadFileParams): Promise<UploadFileResult>;
|
|
107
|
+
}
|