mcp-quickbase
Version:
Work with Quickbase via Model Context Protocol
85 lines • 3.45 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteRelationshipTool = void 0;
const base_1 = require("../base");
const logger_1 = require("../../utils/logger");
const logger = (0, logger_1.createLogger)("DeleteRelationshipTool");
/**
* Tool for deleting a table-to-table relationship in Quickbase.
*
* WARNING: This is a DESTRUCTIVE operation that permanently deletes
* the relationship and all associated lookup and summary fields.
*/
class DeleteRelationshipTool extends base_1.BaseTool {
/**
* Constructor
* @param client Quickbase client
*/
constructor(client) {
super(client);
this.name = "delete_relationship";
this.description = "WARNING: DESTRUCTIVE OPERATION - Permanently deletes an entire table-to-table " +
"relationship INCLUDING ALL LOOKUP AND SUMMARY FIELDS associated with it. All data " +
"in those fields will be permanently lost and CANNOT be recovered. The reference " +
"field in the child table will NOT be deleted (it will remain and may need to be " +
"manually deleted using field deletion tools if no longer needed). Before using " +
"this tool:\n" +
"1. Use get_relationships to see what fields will be deleted\n" +
"2. Confirm with the user that they want to proceed\n" +
"3. Consider if you only need to delete specific fields instead\n\n" +
"Only use this tool when you are certain the entire relationship should be removed.";
/**
* Parameter schema for delete_relationship
*/
this.paramSchema = {
type: "object",
properties: {
table_id: {
type: "string",
description: "The ID of the child Quickbase table (DBID) containing the relationship",
},
relationship_id: {
type: "number",
description: "The ID of the relationship to delete",
},
},
required: ["table_id", "relationship_id"],
};
}
/**
* Run the delete_relationship tool
* @param params Tool parameters
* @returns Deletion confirmation
*/
async run(params) {
const { table_id, relationship_id } = params;
// Use logger.warn for destructive operations
logger.warn("Deleting relationship", {
tableId: table_id,
relationshipId: relationship_id,
});
// Delete the relationship
const response = await this.client.request({
method: "DELETE",
path: `/tables/${table_id}/relationship/${relationship_id}`,
});
if (!response.success) {
logger.error("Failed to delete relationship", {
error: response.error,
tableId: table_id,
relationshipId: relationship_id,
});
throw new Error(response.error?.message || "Failed to delete relationship");
}
logger.warn("Successfully deleted relationship", {
tableId: table_id,
relationshipId: relationship_id,
});
return {
relationshipId: relationship_id,
deleted: true,
};
}
}
exports.DeleteRelationshipTool = DeleteRelationshipTool;
//# sourceMappingURL=delete_relationship.js.map