mcp-quickbase 2.0.5 → 2.2.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/.crewchief/runs/state.json +3 -0
- package/.mcp.json +6 -32
- package/.sdd/tickets/RELS_relationship-management/README.md +98 -0
- package/.sdd/tickets/RELS_relationship-management/planning/analysis.md +190 -0
- package/.sdd/tickets/RELS_relationship-management/planning/architecture.md +413 -0
- package/.sdd/tickets/RELS_relationship-management/planning/plan.md +177 -0
- package/.sdd/tickets/RELS_relationship-management/planning/quality-strategy.md +335 -0
- package/.sdd/tickets/RELS_relationship-management/planning/review-updates.md +95 -0
- package/.sdd/tickets/RELS_relationship-management/planning/security-review.md +213 -0
- package/.sdd/tickets/RELS_relationship-management/planning/ticket-review.md +885 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.1001_domain-setup.md +96 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.1002_get-relationships-tool.md +142 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.1003_register-phase1-tools.md +105 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.2001_create-relationship-tool.md +151 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.2002_update-relationship-tool.md +145 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.3001_delete-relationship-tool.md +154 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.4001_integration-testing.md +159 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS.4002_final-verification.md +182 -0
- package/.sdd/tickets/RELS_relationship-management/tasks/RELS_TASK_INDEX.md +179 -0
- package/crewchief.config.js +31 -0
- package/dist/client/quickbase.d.ts +7 -2
- package/dist/client/quickbase.js +64 -51
- package/dist/client/quickbase.js.map +1 -1
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/server.d.ts +3 -3
- package/dist/mcp/server.js +21 -17
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp-stdio-server.js +64 -49
- package/dist/mcp-stdio-server.js.map +1 -1
- package/dist/server.js +84 -83
- package/dist/server.js.map +1 -1
- package/dist/tools/apps/create_app.d.ts +2 -2
- package/dist/tools/apps/create_app.js +23 -23
- package/dist/tools/apps/create_app.js.map +1 -1
- package/dist/tools/apps/index.d.ts +4 -4
- package/dist/tools/apps/index.js +3 -3
- package/dist/tools/apps/list_tables.d.ts +7 -7
- package/dist/tools/apps/list_tables.js +28 -27
- package/dist/tools/apps/list_tables.js.map +1 -1
- package/dist/tools/apps/update_app.d.ts +2 -2
- package/dist/tools/apps/update_app.js +28 -26
- package/dist/tools/apps/update_app.js.map +1 -1
- package/dist/tools/base.d.ts +3 -3
- package/dist/tools/base.js +7 -7
- package/dist/tools/base.js.map +1 -1
- package/dist/tools/configure_cache.d.ts +3 -3
- package/dist/tools/configure_cache.js +16 -16
- package/dist/tools/configure_cache.js.map +1 -1
- package/dist/tools/fields/create_field.d.ts +8 -7
- package/dist/tools/fields/create_field.js +39 -29
- package/dist/tools/fields/create_field.js.map +1 -1
- package/dist/tools/fields/delete_field.d.ts +79 -0
- package/dist/tools/fields/delete_field.js +105 -0
- package/dist/tools/fields/delete_field.js.map +1 -0
- package/dist/tools/fields/get_field.d.ts +91 -0
- package/dist/tools/fields/get_field.js +82 -0
- package/dist/tools/fields/get_field.js.map +1 -0
- package/dist/tools/fields/index.d.ts +5 -3
- package/dist/tools/fields/index.js +11 -5
- package/dist/tools/fields/index.js.map +1 -1
- package/dist/tools/fields/update_field.d.ts +7 -15
- package/dist/tools/fields/update_field.js +39 -38
- package/dist/tools/fields/update_field.js.map +1 -1
- package/dist/tools/files/download_file.d.ts +2 -2
- package/dist/tools/files/download_file.js +35 -35
- package/dist/tools/files/download_file.js.map +1 -1
- package/dist/tools/files/index.d.ts +3 -3
- package/dist/tools/files/index.js +3 -3
- package/dist/tools/files/upload_file.d.ts +2 -2
- package/dist/tools/files/upload_file.js +52 -44
- package/dist/tools/files/upload_file.js.map +1 -1
- package/dist/tools/index.d.ts +13 -12
- package/dist/tools/index.js +6 -3
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/records/bulk_create_records.d.ts +2 -2
- package/dist/tools/records/bulk_create_records.js +28 -28
- package/dist/tools/records/bulk_create_records.js.map +1 -1
- package/dist/tools/records/bulk_update_records.d.ts +2 -2
- package/dist/tools/records/bulk_update_records.js +27 -27
- package/dist/tools/records/bulk_update_records.js.map +1 -1
- package/dist/tools/records/create_record.d.ts +2 -2
- package/dist/tools/records/create_record.js +40 -40
- package/dist/tools/records/create_record.js.map +1 -1
- package/dist/tools/records/index.d.ts +6 -6
- package/dist/tools/records/index.js +3 -3
- package/dist/tools/records/query_records.d.ts +3 -3
- package/dist/tools/records/query_records.js +82 -78
- package/dist/tools/records/query_records.js.map +1 -1
- package/dist/tools/records/update_record.d.ts +2 -2
- package/dist/tools/records/update_record.js +31 -29
- package/dist/tools/records/update_record.js.map +1 -1
- package/dist/tools/registry.d.ts +1 -1
- package/dist/tools/registry.js +1 -1
- package/dist/tools/relationships/create_relationship.d.ts +150 -0
- package/dist/tools/relationships/create_relationship.js +181 -0
- package/dist/tools/relationships/create_relationship.js.map +1 -0
- package/dist/tools/relationships/delete_relationship.d.ts +66 -0
- package/dist/tools/relationships/delete_relationship.js +85 -0
- package/dist/tools/relationships/delete_relationship.js.map +1 -0
- package/dist/tools/relationships/get_relationships.d.ts +126 -0
- package/dist/tools/relationships/get_relationships.js +126 -0
- package/dist/tools/relationships/get_relationships.js.map +1 -0
- package/dist/tools/relationships/index.d.ts +14 -0
- package/dist/tools/relationships/index.js +37 -0
- package/dist/tools/relationships/index.js.map +1 -0
- package/dist/tools/relationships/update_relationship.d.ts +139 -0
- package/dist/tools/relationships/update_relationship.js +168 -0
- package/dist/tools/relationships/update_relationship.js.map +1 -0
- package/dist/tools/reports/index.d.ts +2 -2
- package/dist/tools/reports/index.js +3 -3
- package/dist/tools/reports/run_report.d.ts +3 -3
- package/dist/tools/reports/run_report.js +29 -29
- package/dist/tools/reports/run_report.js.map +1 -1
- package/dist/tools/tables/create_table.d.ts +2 -49
- package/dist/tools/tables/create_table.js +26 -49
- package/dist/tools/tables/create_table.js.map +1 -1
- package/dist/tools/tables/get_table_fields.d.ts +2 -2
- package/dist/tools/tables/get_table_fields.js +25 -25
- package/dist/tools/tables/get_table_fields.js.map +1 -1
- package/dist/tools/tables/index.d.ts +4 -4
- package/dist/tools/tables/index.js +3 -3
- package/dist/tools/tables/update_table.d.ts +2 -2
- package/dist/tools/tables/update_table.js +28 -26
- package/dist/tools/tables/update_table.js.map +1 -1
- package/dist/tools/test_connection.d.ts +2 -2
- package/dist/tools/test_connection.js +28 -28
- package/dist/tools/test_connection.js.map +1 -1
- package/dist/types/api.d.ts +1 -1
- package/dist/types/mcp.d.ts +1 -1
- package/dist/utils/cache.js +16 -16
- package/dist/utils/cache.js.map +1 -1
- package/dist/utils/file.js +44 -40
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/logger.js +30 -28
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/retry.js +10 -10
- package/dist/utils/retry.js.map +1 -1
- package/dist/utils/validation.d.ts +1 -1
- package/dist/utils/validation.js +39 -36
- package/dist/utils/validation.js.map +1 -1
- package/docs/README.md +6 -0
- package/docs/future-improvements.md +33 -0
- package/docs/migration-guide.md +160 -0
- package/docs/release-notes.md +89 -0
- package/package.json +5 -4
- /package/{HARDENING_SUMMARY.md → docs/hardening-summary.md} +0 -0
|
@@ -17,21 +17,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.registerFieldTools = registerFieldTools;
|
|
18
18
|
const registry_1 = require("../registry");
|
|
19
19
|
const create_field_1 = require("./create_field");
|
|
20
|
+
const get_field_1 = require("./get_field");
|
|
20
21
|
const update_field_1 = require("./update_field");
|
|
22
|
+
const delete_field_1 = require("./delete_field");
|
|
21
23
|
const logger_1 = require("../../utils/logger");
|
|
22
|
-
const logger = (0, logger_1.createLogger)(
|
|
24
|
+
const logger = (0, logger_1.createLogger)("FieldTools");
|
|
23
25
|
/**
|
|
24
26
|
* Register all field management tools with the registry
|
|
25
27
|
* @param client Quickbase client
|
|
26
28
|
*/
|
|
27
29
|
function registerFieldTools(client) {
|
|
28
|
-
logger.info(
|
|
29
|
-
// Register individual tools
|
|
30
|
+
logger.info("Registering field management tools");
|
|
31
|
+
// Register individual tools (Create, Get, Update, Delete order)
|
|
30
32
|
registry_1.toolRegistry.registerTool(new create_field_1.CreateFieldTool(client));
|
|
33
|
+
registry_1.toolRegistry.registerTool(new get_field_1.GetFieldTool(client));
|
|
31
34
|
registry_1.toolRegistry.registerTool(new update_field_1.UpdateFieldTool(client));
|
|
32
|
-
|
|
35
|
+
registry_1.toolRegistry.registerTool(new delete_field_1.DeleteFieldTool(client));
|
|
36
|
+
logger.info("Field management tools registered");
|
|
33
37
|
}
|
|
34
|
-
// Export all tools
|
|
38
|
+
// Export all tools (Create, Get, Update, Delete order)
|
|
35
39
|
__exportStar(require("./create_field"), exports);
|
|
40
|
+
__exportStar(require("./get_field"), exports);
|
|
36
41
|
__exportStar(require("./update_field"), exports);
|
|
42
|
+
__exportStar(require("./delete_field"), exports);
|
|
37
43
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/fields/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/fields/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAcA,gDAUC;AAvBD,0CAA2C;AAC3C,iDAAiD;AACjD,2CAA2C;AAC3C,iDAAiD;AACjD,iDAAiD;AACjD,+CAAkD;AAElD,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,YAAY,CAAC,CAAC;AAE1C;;;GAGG;AACH,SAAgB,kBAAkB,CAAC,MAAuB;IACxD,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IAElD,gEAAgE;IAChE,uBAAY,CAAC,YAAY,CAAC,IAAI,8BAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,uBAAY,CAAC,YAAY,CAAC,IAAI,wBAAY,CAAC,MAAM,CAAC,CAAC,CAAC;IACpD,uBAAY,CAAC,YAAY,CAAC,IAAI,8BAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IACvD,uBAAY,CAAC,YAAY,CAAC,IAAI,8BAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAEvD,MAAM,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;AACnD,CAAC;AAED,uDAAuD;AACvD,iDAA+B;AAC/B,8CAA4B;AAC5B,iDAA+B;AAC/B,iDAA+B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { BaseTool } from
|
|
2
|
-
import { QuickbaseClient } from
|
|
3
|
-
import { FieldProperties } from
|
|
1
|
+
import { BaseTool } from "../base";
|
|
2
|
+
import { QuickbaseClient } from "../../client/quickbase";
|
|
3
|
+
import { FieldProperties } from "./create_field";
|
|
4
4
|
/**
|
|
5
5
|
* Parameters for update_field tool
|
|
6
6
|
*/
|
|
@@ -14,17 +14,13 @@ export interface UpdateFieldParams {
|
|
|
14
14
|
*/
|
|
15
15
|
field_id: string;
|
|
16
16
|
/**
|
|
17
|
-
* New
|
|
17
|
+
* New display label for the field
|
|
18
18
|
*/
|
|
19
19
|
name?: string;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Help text shown to users when editing the field (stored as fieldHelp)
|
|
22
22
|
*/
|
|
23
23
|
description?: string;
|
|
24
|
-
/**
|
|
25
|
-
* New field type (only allowed for certain field type conversions)
|
|
26
|
-
*/
|
|
27
|
-
field_type?: string;
|
|
28
24
|
/**
|
|
29
25
|
* Additional options and properties to update
|
|
30
26
|
*/
|
|
@@ -47,9 +43,9 @@ export interface UpdateFieldResult {
|
|
|
47
43
|
*/
|
|
48
44
|
fieldType?: string;
|
|
49
45
|
/**
|
|
50
|
-
*
|
|
46
|
+
* Help text for the field (shown to users when editing)
|
|
51
47
|
*/
|
|
52
|
-
|
|
48
|
+
fieldHelp?: string;
|
|
53
49
|
/**
|
|
54
50
|
* The ID of the table containing the field
|
|
55
51
|
*/
|
|
@@ -83,10 +79,6 @@ export declare class UpdateFieldTool extends BaseTool<UpdateFieldParams, UpdateF
|
|
|
83
79
|
type: string;
|
|
84
80
|
description: string;
|
|
85
81
|
};
|
|
86
|
-
field_type: {
|
|
87
|
-
type: string;
|
|
88
|
-
description: string;
|
|
89
|
-
};
|
|
90
82
|
description: {
|
|
91
83
|
type: string;
|
|
92
84
|
description: string;
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UpdateFieldTool = void 0;
|
|
4
4
|
const base_1 = require("../base");
|
|
5
5
|
const logger_1 = require("../../utils/logger");
|
|
6
|
-
const logger = (0, logger_1.createLogger)(
|
|
6
|
+
const logger = (0, logger_1.createLogger)("UpdateFieldTool");
|
|
7
7
|
/**
|
|
8
8
|
* Tool for updating an existing field in a Quickbase table
|
|
9
9
|
*/
|
|
@@ -14,40 +14,39 @@ class UpdateFieldTool extends base_1.BaseTool {
|
|
|
14
14
|
*/
|
|
15
15
|
constructor(client) {
|
|
16
16
|
super(client);
|
|
17
|
-
this.name =
|
|
18
|
-
this.description =
|
|
17
|
+
this.name = "update_field";
|
|
18
|
+
this.description = "Updates an existing field in a Quickbase table. " +
|
|
19
|
+
"Can modify the field label, help text, and properties. " +
|
|
20
|
+
"Note: Field type cannot be changed - delete and recreate the field instead.";
|
|
19
21
|
/**
|
|
20
22
|
* Parameter schema for update_field
|
|
21
23
|
*/
|
|
22
24
|
this.paramSchema = {
|
|
23
|
-
type:
|
|
25
|
+
type: "object",
|
|
24
26
|
properties: {
|
|
25
27
|
table_id: {
|
|
26
|
-
type:
|
|
27
|
-
description:
|
|
28
|
+
type: "string",
|
|
29
|
+
description: "The ID of the table (e.g., 'bqx7xkw3r')",
|
|
28
30
|
},
|
|
29
31
|
field_id: {
|
|
30
|
-
type:
|
|
31
|
-
description:
|
|
32
|
+
type: "string",
|
|
33
|
+
description: "The ID of the field to update (e.g., '6')",
|
|
32
34
|
},
|
|
33
35
|
name: {
|
|
34
|
-
type:
|
|
35
|
-
description:
|
|
36
|
-
},
|
|
37
|
-
field_type: {
|
|
38
|
-
type: 'string',
|
|
39
|
-
description: 'New type for the field'
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "New display label for the field",
|
|
40
38
|
},
|
|
41
39
|
description: {
|
|
42
|
-
type:
|
|
43
|
-
description:
|
|
40
|
+
type: "string",
|
|
41
|
+
description: "Help text shown to users when editing the field (stored as fieldHelp)",
|
|
44
42
|
},
|
|
45
43
|
options: {
|
|
46
|
-
type:
|
|
47
|
-
description:
|
|
48
|
-
|
|
44
|
+
type: "object",
|
|
45
|
+
description: "Field properties to update: required, unique, appearsByDefault, " +
|
|
46
|
+
"findEnabled, maxLength, numLines, defaultValue, etc.",
|
|
47
|
+
},
|
|
49
48
|
},
|
|
50
|
-
required: [
|
|
49
|
+
required: ["table_id", "field_id"],
|
|
51
50
|
};
|
|
52
51
|
}
|
|
53
52
|
/**
|
|
@@ -56,25 +55,27 @@ class UpdateFieldTool extends base_1.BaseTool {
|
|
|
56
55
|
* @returns Updated field details
|
|
57
56
|
*/
|
|
58
57
|
async run(params) {
|
|
59
|
-
const { table_id, field_id, name,
|
|
60
|
-
logger.info(
|
|
58
|
+
const { table_id, field_id, name, description, options } = params;
|
|
59
|
+
logger.info("Updating field in Quickbase table", {
|
|
61
60
|
tableId: table_id,
|
|
62
|
-
fieldId: field_id
|
|
61
|
+
fieldId: field_id,
|
|
63
62
|
});
|
|
64
63
|
// At least one update field is required
|
|
65
|
-
if (!name &&
|
|
66
|
-
|
|
64
|
+
if (!name &&
|
|
65
|
+
!description &&
|
|
66
|
+
(!options || Object.keys(options).length === 0)) {
|
|
67
|
+
throw new Error("At least one update field (name, description, or options) is required");
|
|
67
68
|
}
|
|
68
69
|
// Prepare request body with only the fields that are provided
|
|
70
|
+
// Note: Quickbase API uses 'fieldHelp' at root level for help text (not 'description')
|
|
71
|
+
// Note: Field type cannot be changed via API - must delete and recreate
|
|
69
72
|
const body = {};
|
|
70
73
|
if (name !== undefined) {
|
|
71
74
|
body.label = name;
|
|
72
75
|
}
|
|
73
|
-
if (
|
|
74
|
-
body.fieldType = field_type;
|
|
75
|
-
}
|
|
76
|
+
// Add fieldHelp if description provided (maps to root-level fieldHelp)
|
|
76
77
|
if (description !== undefined) {
|
|
77
|
-
body.
|
|
78
|
+
body.fieldHelp = description;
|
|
78
79
|
}
|
|
79
80
|
// Add properties if provided
|
|
80
81
|
if (options && Object.keys(options).length > 0) {
|
|
@@ -82,31 +83,31 @@ class UpdateFieldTool extends base_1.BaseTool {
|
|
|
82
83
|
}
|
|
83
84
|
// Update the field
|
|
84
85
|
const response = await this.client.request({
|
|
85
|
-
method:
|
|
86
|
+
method: "POST",
|
|
86
87
|
path: `/fields/${field_id}?tableId=${table_id}`,
|
|
87
|
-
body
|
|
88
|
+
body,
|
|
88
89
|
});
|
|
89
90
|
if (!response.success || !response.data) {
|
|
90
|
-
logger.error(
|
|
91
|
+
logger.error("Failed to update field", {
|
|
91
92
|
error: response.error,
|
|
92
93
|
tableId: table_id,
|
|
93
|
-
fieldId: field_id
|
|
94
|
+
fieldId: field_id,
|
|
94
95
|
});
|
|
95
|
-
throw new Error(response.error?.message ||
|
|
96
|
+
throw new Error(response.error?.message || "Failed to update field");
|
|
96
97
|
}
|
|
97
98
|
const field = response.data;
|
|
98
|
-
logger.info(
|
|
99
|
+
logger.info("Successfully updated field", {
|
|
99
100
|
fieldId: field.id,
|
|
100
101
|
tableId: table_id,
|
|
101
|
-
updates: Object.keys(body).join(
|
|
102
|
+
updates: Object.keys(body).join(", "),
|
|
102
103
|
});
|
|
103
104
|
return {
|
|
104
105
|
fieldId: field.id,
|
|
105
106
|
label: field.label,
|
|
106
107
|
fieldType: field.fieldType,
|
|
107
|
-
|
|
108
|
+
fieldHelp: field.fieldHelp,
|
|
108
109
|
tableId: table_id,
|
|
109
|
-
...field
|
|
110
|
+
...field,
|
|
110
111
|
};
|
|
111
112
|
}
|
|
112
113
|
}
|
|
@@ -1 +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;
|
|
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;AAmE/C;;GAEG;AACH,MAAa,eAAgB,SAAQ,eAGpC;IAwCC;;;OAGG;IACH,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAC;QA5CT,SAAI,GAAG,cAAc,CAAC;QACtB,gBAAW,GAChB,kDAAkD;YAClD,yDAAyD;YACzD,6EAA6E,CAAC;QAEhF;;WAEG;QACI,gBAAW,GAAG;YACnB,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,yCAAyC;iBACvD;gBACD,QAAQ,EAAE;oBACR,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,2CAA2C;iBACzD;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,QAAQ;oBACd,WAAW,EAAE,iCAAiC;iBAC/C;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,uEAAuE;iBAC1E;gBACD,OAAO,EAAE;oBACP,IAAI,EAAE,QAAQ;oBACd,WAAW,EACT,kEAAkE;wBAClE,sDAAsD;iBACzD;aAC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CAAC,QAAQ,CAAC,OAAO,IAAI,CAAC,QAAQ,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,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,OAAO,EAAE,QAAQ;YACjB,GAAG,KAAK;SACT,CAAC;IACJ,CAAC;CACF;AA/HD,0CA+HC"}
|
|
@@ -38,7 +38,7 @@ const base_1 = require("../base");
|
|
|
38
38
|
const logger_1 = require("../../utils/logger");
|
|
39
39
|
const file_1 = require("../../utils/file");
|
|
40
40
|
const path = __importStar(require("path"));
|
|
41
|
-
const logger = (0, logger_1.createLogger)(
|
|
41
|
+
const logger = (0, logger_1.createLogger)("DownloadFileTool");
|
|
42
42
|
/**
|
|
43
43
|
* Tool for downloading a file from a field in a Quickbase record
|
|
44
44
|
*/
|
|
@@ -49,36 +49,36 @@ class DownloadFileTool extends base_1.BaseTool {
|
|
|
49
49
|
*/
|
|
50
50
|
constructor(client) {
|
|
51
51
|
super(client);
|
|
52
|
-
this.name =
|
|
53
|
-
this.description =
|
|
52
|
+
this.name = "download_file";
|
|
53
|
+
this.description = "Downloads a file from a field in a Quickbase record";
|
|
54
54
|
/**
|
|
55
55
|
* Parameter schema for download_file
|
|
56
56
|
*/
|
|
57
57
|
this.paramSchema = {
|
|
58
|
-
type:
|
|
58
|
+
type: "object",
|
|
59
59
|
properties: {
|
|
60
60
|
table_id: {
|
|
61
|
-
type:
|
|
62
|
-
description:
|
|
61
|
+
type: "string",
|
|
62
|
+
description: "The ID of the Quickbase table",
|
|
63
63
|
},
|
|
64
64
|
record_id: {
|
|
65
|
-
type:
|
|
66
|
-
description:
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "The ID of the record",
|
|
67
67
|
},
|
|
68
68
|
field_id: {
|
|
69
|
-
type:
|
|
70
|
-
description:
|
|
69
|
+
type: "string",
|
|
70
|
+
description: "The ID of the field (must be a file attachment field)",
|
|
71
71
|
},
|
|
72
72
|
output_path: {
|
|
73
|
-
type:
|
|
74
|
-
description:
|
|
73
|
+
type: "string",
|
|
74
|
+
description: "Path where the file should be saved",
|
|
75
75
|
},
|
|
76
76
|
version: {
|
|
77
|
-
type:
|
|
78
|
-
description:
|
|
79
|
-
}
|
|
77
|
+
type: "string",
|
|
78
|
+
description: "The version of the file to download (default 0 for latest)",
|
|
79
|
+
},
|
|
80
80
|
},
|
|
81
|
-
required: [
|
|
81
|
+
required: ["table_id", "record_id", "field_id", "output_path"],
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
/**
|
|
@@ -87,12 +87,12 @@ class DownloadFileTool extends base_1.BaseTool {
|
|
|
87
87
|
* @returns Download result
|
|
88
88
|
*/
|
|
89
89
|
async run(params) {
|
|
90
|
-
const { table_id, record_id, field_id, output_path, version =
|
|
91
|
-
logger.info(
|
|
90
|
+
const { table_id, record_id, field_id, output_path, version = "0", } = params;
|
|
91
|
+
logger.info("Downloading file from Quickbase record", {
|
|
92
92
|
tableId: table_id,
|
|
93
93
|
recordId: record_id,
|
|
94
94
|
fieldId: field_id,
|
|
95
|
-
version
|
|
95
|
+
version,
|
|
96
96
|
});
|
|
97
97
|
// Check if the output directory exists
|
|
98
98
|
const outputDir = path.dirname(output_path);
|
|
@@ -104,58 +104,58 @@ class DownloadFileTool extends base_1.BaseTool {
|
|
|
104
104
|
tableId: table_id,
|
|
105
105
|
recordId: record_id,
|
|
106
106
|
fieldId: field_id,
|
|
107
|
-
version
|
|
107
|
+
version,
|
|
108
108
|
};
|
|
109
109
|
// Construct the query string
|
|
110
110
|
const queryString = Object.entries(queryParams)
|
|
111
111
|
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
|
|
112
|
-
.join(
|
|
112
|
+
.join("&");
|
|
113
113
|
// Download the file
|
|
114
114
|
const response = await this.client.request({
|
|
115
|
-
method:
|
|
116
|
-
path: `/files?${queryString}
|
|
115
|
+
method: "GET",
|
|
116
|
+
path: `/files?${queryString}`,
|
|
117
117
|
});
|
|
118
118
|
if (!response.success || !response.data) {
|
|
119
|
-
logger.error(
|
|
119
|
+
logger.error("Failed to download file", {
|
|
120
120
|
error: response.error,
|
|
121
121
|
tableId: table_id,
|
|
122
122
|
recordId: record_id,
|
|
123
|
-
fieldId: field_id
|
|
123
|
+
fieldId: field_id,
|
|
124
124
|
});
|
|
125
|
-
throw new Error(response.error?.message ||
|
|
125
|
+
throw new Error(response.error?.message || "Failed to download file");
|
|
126
126
|
}
|
|
127
127
|
const fileData = response.data;
|
|
128
128
|
// Extract file information
|
|
129
|
-
const fileName = fileData.fileName ||
|
|
129
|
+
const fileName = fileData.fileName || "downloaded_file";
|
|
130
130
|
const fileContent = fileData.fileData;
|
|
131
131
|
if (!fileContent) {
|
|
132
|
-
throw new Error(
|
|
132
|
+
throw new Error("Downloaded file does not contain any data");
|
|
133
133
|
}
|
|
134
134
|
// Determine if the file content is base64 encoded
|
|
135
|
-
const isBase64 = typeof fileContent ===
|
|
135
|
+
const isBase64 = typeof fileContent === "string" &&
|
|
136
136
|
/^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/.test(fileContent);
|
|
137
137
|
// Decode and write the file
|
|
138
138
|
let fileBuffer;
|
|
139
139
|
if (isBase64) {
|
|
140
|
-
fileBuffer = Buffer.from(fileContent,
|
|
140
|
+
fileBuffer = Buffer.from(fileContent, "base64");
|
|
141
141
|
}
|
|
142
|
-
else if (typeof fileContent ===
|
|
142
|
+
else if (typeof fileContent === "string") {
|
|
143
143
|
fileBuffer = Buffer.from(fileContent);
|
|
144
144
|
}
|
|
145
145
|
else {
|
|
146
|
-
throw new Error(
|
|
146
|
+
throw new Error("Unsupported file data format");
|
|
147
147
|
}
|
|
148
148
|
// Write the file to the output path
|
|
149
149
|
const writeSuccess = (0, file_1.writeFile)(output_path, fileBuffer);
|
|
150
150
|
if (!writeSuccess) {
|
|
151
151
|
throw new Error(`Failed to write file to ${output_path}`);
|
|
152
152
|
}
|
|
153
|
-
logger.info(
|
|
153
|
+
logger.info("Successfully downloaded file", {
|
|
154
154
|
tableId: table_id,
|
|
155
155
|
recordId: record_id,
|
|
156
156
|
fieldId: field_id,
|
|
157
157
|
fileName,
|
|
158
|
-
outputPath: output_path
|
|
158
|
+
outputPath: output_path,
|
|
159
159
|
});
|
|
160
160
|
return {
|
|
161
161
|
recordId: record_id,
|
|
@@ -165,7 +165,7 @@ class DownloadFileTool extends base_1.BaseTool {
|
|
|
165
165
|
fileSize: fileBuffer.length,
|
|
166
166
|
version,
|
|
167
167
|
outputPath: output_path,
|
|
168
|
-
downloadTime: new Date().toISOString()
|
|
168
|
+
downloadTime: new Date().toISOString(),
|
|
169
169
|
};
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"download_file.js","sourceRoot":"","sources":["../../../src/tools/files/download_file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kCAAmC;AAEnC,+CAAkD;AAClD,2CAA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Q,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;AA5JD,4CA4JC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { QuickbaseClient } from
|
|
1
|
+
import { QuickbaseClient } from "../../client/quickbase";
|
|
2
2
|
/**
|
|
3
3
|
* Register all file operation tools with the registry
|
|
4
4
|
* @param client Quickbase client
|
|
5
5
|
*/
|
|
6
6
|
export declare function registerFileTools(client: QuickbaseClient): void;
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
7
|
+
export * from "./upload_file";
|
|
8
|
+
export * from "./download_file";
|
|
@@ -19,17 +19,17 @@ const registry_1 = require("../registry");
|
|
|
19
19
|
const upload_file_1 = require("./upload_file");
|
|
20
20
|
const download_file_1 = require("./download_file");
|
|
21
21
|
const logger_1 = require("../../utils/logger");
|
|
22
|
-
const logger = (0, logger_1.createLogger)(
|
|
22
|
+
const logger = (0, logger_1.createLogger)("FileTools");
|
|
23
23
|
/**
|
|
24
24
|
* Register all file operation tools with the registry
|
|
25
25
|
* @param client Quickbase client
|
|
26
26
|
*/
|
|
27
27
|
function registerFileTools(client) {
|
|
28
|
-
logger.info(
|
|
28
|
+
logger.info("Registering file operation tools");
|
|
29
29
|
// Register individual tools
|
|
30
30
|
registry_1.toolRegistry.registerTool(new upload_file_1.UploadFileTool(client));
|
|
31
31
|
registry_1.toolRegistry.registerTool(new download_file_1.DownloadFileTool(client));
|
|
32
|
-
logger.info(
|
|
32
|
+
logger.info("File operation tools registered");
|
|
33
33
|
}
|
|
34
34
|
// Export all tools
|
|
35
35
|
__exportStar(require("./upload_file"), exports);
|