mcp-quickbase 2.1.0 → 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/.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/dist/tools/apps/list_tables.d.ts +5 -5
- package/dist/tools/apps/list_tables.js +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.js +4 -1
- package/dist/tools/index.js.map +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/package.json +1 -1
|
@@ -42,15 +42,15 @@ export interface TableInfo {
|
|
|
42
42
|
*/
|
|
43
43
|
export interface ListTablesParams {
|
|
44
44
|
/**
|
|
45
|
-
* The
|
|
45
|
+
* The application ID to list tables for
|
|
46
46
|
*/
|
|
47
47
|
app_id?: string;
|
|
48
48
|
/**
|
|
49
|
-
* Whether to include hidden tables
|
|
49
|
+
* Whether to include hidden tables
|
|
50
50
|
*/
|
|
51
51
|
include_hidden?: boolean;
|
|
52
52
|
/**
|
|
53
|
-
* Filter tables by
|
|
53
|
+
* Filter tables by name (case-insensitive substring match)
|
|
54
54
|
*/
|
|
55
55
|
filter?: string;
|
|
56
56
|
}
|
|
@@ -59,7 +59,7 @@ export interface ListTablesParams {
|
|
|
59
59
|
*/
|
|
60
60
|
export interface ListTablesResult {
|
|
61
61
|
/**
|
|
62
|
-
* Array of
|
|
62
|
+
* Array of tables in the application
|
|
63
63
|
*/
|
|
64
64
|
tables: TableInfo[];
|
|
65
65
|
/**
|
|
@@ -68,7 +68,7 @@ export interface ListTablesResult {
|
|
|
68
68
|
appId: string;
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
* Tool for listing tables in a Quickbase application
|
|
71
|
+
* Tool for listing all tables in a Quickbase application
|
|
72
72
|
*/
|
|
73
73
|
export declare class ListTablesTool extends BaseTool<ListTablesParams, ListTablesResult> {
|
|
74
74
|
name: string;
|
|
@@ -5,7 +5,7 @@ const base_1 = require("../base");
|
|
|
5
5
|
const logger_1 = require("../../utils/logger");
|
|
6
6
|
const logger = (0, logger_1.createLogger)("ListTablesTool");
|
|
7
7
|
/**
|
|
8
|
-
* Tool for listing tables in a Quickbase application
|
|
8
|
+
* Tool for listing all tables in a Quickbase application
|
|
9
9
|
*/
|
|
10
10
|
class ListTablesTool extends base_1.BaseTool {
|
|
11
11
|
/**
|
package/dist/tools/index.d.ts
CHANGED
package/dist/tools/index.js
CHANGED
|
@@ -24,6 +24,7 @@ const fields_1 = require("./fields");
|
|
|
24
24
|
const records_1 = require("./records");
|
|
25
25
|
const files_1 = require("./files");
|
|
26
26
|
const reports_1 = require("./reports");
|
|
27
|
+
const relationships_1 = require("./relationships");
|
|
27
28
|
const logger_1 = require("../utils/logger");
|
|
28
29
|
const logger = (0, logger_1.createLogger)("ToolsInit");
|
|
29
30
|
/**
|
|
@@ -48,7 +49,8 @@ function initializeTools(client, cacheService) {
|
|
|
48
49
|
(0, files_1.registerFileTools)(client);
|
|
49
50
|
// Register report operation tools
|
|
50
51
|
(0, reports_1.registerReportTools)(client);
|
|
51
|
-
//
|
|
52
|
+
// Register relationship management tools
|
|
53
|
+
(0, relationships_1.registerRelationshipTools)(client);
|
|
52
54
|
logger.info(`Registered ${registry_1.toolRegistry.getToolCount()} tools`);
|
|
53
55
|
}
|
|
54
56
|
// Export all tools and related types
|
|
@@ -62,4 +64,5 @@ __exportStar(require("./fields"), exports);
|
|
|
62
64
|
__exportStar(require("./records"), exports);
|
|
63
65
|
__exportStar(require("./files"), exports);
|
|
64
66
|
__exportStar(require("./reports"), exports);
|
|
67
|
+
__exportStar(require("./relationships"), exports);
|
|
65
68
|
//# sourceMappingURL=index.js.map
|
package/dist/tools/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{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;AACzB,2CAAyB;AACzB,4CAA0B;AAC1B,0CAAwB;AACxB,4CAA0B;AAC1B,kDAAgC"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { BaseTool } from "../base";
|
|
2
|
+
import { QuickbaseClient } from "../../client/quickbase";
|
|
3
|
+
import { RelationshipFieldInfo } from "./get_relationships";
|
|
4
|
+
/**
|
|
5
|
+
* Valid accumulation types for summary fields
|
|
6
|
+
*/
|
|
7
|
+
export type SummaryAccumulationType = "SUM" | "COUNT" | "AVG" | "MAX" | "MIN";
|
|
8
|
+
/**
|
|
9
|
+
* Parameters for create_relationship tool
|
|
10
|
+
*/
|
|
11
|
+
export interface CreateRelationshipParams {
|
|
12
|
+
/**
|
|
13
|
+
* The ID of the child table (DBID) where the relationship reference field will be created
|
|
14
|
+
*/
|
|
15
|
+
table_id: string;
|
|
16
|
+
/**
|
|
17
|
+
* The ID of the parent table (DBID) to link to
|
|
18
|
+
*/
|
|
19
|
+
parent_table_id: string;
|
|
20
|
+
/**
|
|
21
|
+
* Optional label for the foreign key reference field created in the child table
|
|
22
|
+
*/
|
|
23
|
+
foreign_key_label?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional array of parent field IDs to create as lookup fields in the child table
|
|
26
|
+
*/
|
|
27
|
+
lookup_field_ids?: number[];
|
|
28
|
+
/**
|
|
29
|
+
* Optional child field ID to summarize in the parent table
|
|
30
|
+
*/
|
|
31
|
+
summary_field_id?: number;
|
|
32
|
+
/**
|
|
33
|
+
* Optional label for the summary field created in the parent table
|
|
34
|
+
*/
|
|
35
|
+
summary_label?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Accumulation type for the summary field (required if summary_field_id is provided)
|
|
38
|
+
*/
|
|
39
|
+
summary_accumulation_type?: SummaryAccumulationType;
|
|
40
|
+
/**
|
|
41
|
+
* Optional Quickbase query filter for the summary field
|
|
42
|
+
*/
|
|
43
|
+
summary_where?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Result from creating a relationship
|
|
47
|
+
*/
|
|
48
|
+
export interface CreateRelationshipResult {
|
|
49
|
+
/**
|
|
50
|
+
* The ID of the relationship (same as the foreign key field ID)
|
|
51
|
+
*/
|
|
52
|
+
id: number;
|
|
53
|
+
/**
|
|
54
|
+
* The ID of the parent table
|
|
55
|
+
*/
|
|
56
|
+
parentTableId: string;
|
|
57
|
+
/**
|
|
58
|
+
* The ID of the child table
|
|
59
|
+
*/
|
|
60
|
+
childTableId: string;
|
|
61
|
+
/**
|
|
62
|
+
* The foreign key field created in the child table
|
|
63
|
+
*/
|
|
64
|
+
foreignKeyField: RelationshipFieldInfo;
|
|
65
|
+
/**
|
|
66
|
+
* Lookup fields created in the child table
|
|
67
|
+
*/
|
|
68
|
+
lookupFields: RelationshipFieldInfo[];
|
|
69
|
+
/**
|
|
70
|
+
* Summary fields created in the parent table
|
|
71
|
+
*/
|
|
72
|
+
summaryFields: RelationshipFieldInfo[];
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Tool for creating a new table-to-table relationship in Quickbase.
|
|
76
|
+
*
|
|
77
|
+
* Creates a reference field in the child table linking to the parent table.
|
|
78
|
+
* Optionally creates lookup fields and/or summary fields.
|
|
79
|
+
*/
|
|
80
|
+
export declare class CreateRelationshipTool extends BaseTool<CreateRelationshipParams, CreateRelationshipResult> {
|
|
81
|
+
name: string;
|
|
82
|
+
description: string;
|
|
83
|
+
/**
|
|
84
|
+
* Parameter schema for create_relationship with conditional validation
|
|
85
|
+
*/
|
|
86
|
+
paramSchema: {
|
|
87
|
+
type: string;
|
|
88
|
+
properties: {
|
|
89
|
+
table_id: {
|
|
90
|
+
type: string;
|
|
91
|
+
description: string;
|
|
92
|
+
};
|
|
93
|
+
parent_table_id: {
|
|
94
|
+
type: string;
|
|
95
|
+
description: string;
|
|
96
|
+
};
|
|
97
|
+
foreign_key_label: {
|
|
98
|
+
type: string;
|
|
99
|
+
description: string;
|
|
100
|
+
};
|
|
101
|
+
lookup_field_ids: {
|
|
102
|
+
type: string;
|
|
103
|
+
items: {
|
|
104
|
+
type: string;
|
|
105
|
+
};
|
|
106
|
+
description: string;
|
|
107
|
+
};
|
|
108
|
+
summary_field_id: {
|
|
109
|
+
type: string;
|
|
110
|
+
description: string;
|
|
111
|
+
};
|
|
112
|
+
summary_label: {
|
|
113
|
+
type: string;
|
|
114
|
+
description: string;
|
|
115
|
+
};
|
|
116
|
+
summary_accumulation_type: {
|
|
117
|
+
type: string;
|
|
118
|
+
enum: string[];
|
|
119
|
+
description: string;
|
|
120
|
+
};
|
|
121
|
+
summary_where: {
|
|
122
|
+
type: string;
|
|
123
|
+
description: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
required: string[];
|
|
127
|
+
if: {
|
|
128
|
+
properties: {
|
|
129
|
+
summary_field_id: {
|
|
130
|
+
type: string;
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
required: string[];
|
|
134
|
+
};
|
|
135
|
+
then: {
|
|
136
|
+
required: string[];
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Constructor
|
|
141
|
+
* @param client Quickbase client
|
|
142
|
+
*/
|
|
143
|
+
constructor(client: QuickbaseClient);
|
|
144
|
+
/**
|
|
145
|
+
* Run the create_relationship tool
|
|
146
|
+
* @param params Tool parameters
|
|
147
|
+
* @returns Created relationship details
|
|
148
|
+
*/
|
|
149
|
+
protected run(params: CreateRelationshipParams): Promise<CreateRelationshipResult>;
|
|
150
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateRelationshipTool = void 0;
|
|
4
|
+
const base_1 = require("../base");
|
|
5
|
+
const logger_1 = require("../../utils/logger");
|
|
6
|
+
const logger = (0, logger_1.createLogger)("CreateRelationshipTool");
|
|
7
|
+
/**
|
|
8
|
+
* Tool for creating a new table-to-table relationship in Quickbase.
|
|
9
|
+
*
|
|
10
|
+
* Creates a reference field in the child table linking to the parent table.
|
|
11
|
+
* Optionally creates lookup fields and/or summary fields.
|
|
12
|
+
*/
|
|
13
|
+
class CreateRelationshipTool extends base_1.BaseTool {
|
|
14
|
+
/**
|
|
15
|
+
* Constructor
|
|
16
|
+
* @param client Quickbase client
|
|
17
|
+
*/
|
|
18
|
+
constructor(client) {
|
|
19
|
+
super(client);
|
|
20
|
+
this.name = "create_relationship";
|
|
21
|
+
this.description = "Creates a new table-to-table relationship linking a child table to a parent table. " +
|
|
22
|
+
"This creates a reference field in the child table. Optionally creates lookup fields " +
|
|
23
|
+
"(to display parent data in child records) and/or a summary field (to aggregate child " +
|
|
24
|
+
"data in parent records). Relationships can only be created between tables in the same " +
|
|
25
|
+
"application. This operation is SAFE and does not modify existing data.";
|
|
26
|
+
/**
|
|
27
|
+
* Parameter schema for create_relationship with conditional validation
|
|
28
|
+
*/
|
|
29
|
+
this.paramSchema = {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
table_id: {
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "The ID of the child Quickbase table (DBID) where the relationship reference field will be created",
|
|
35
|
+
},
|
|
36
|
+
parent_table_id: {
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "The ID of the parent Quickbase table (DBID) to link to",
|
|
39
|
+
},
|
|
40
|
+
foreign_key_label: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Optional label for the foreign key reference field created in the child table",
|
|
43
|
+
},
|
|
44
|
+
lookup_field_ids: {
|
|
45
|
+
type: "array",
|
|
46
|
+
items: {
|
|
47
|
+
type: "number",
|
|
48
|
+
},
|
|
49
|
+
description: "Optional array of parent field IDs to create as lookup fields in the child table",
|
|
50
|
+
},
|
|
51
|
+
summary_field_id: {
|
|
52
|
+
type: "number",
|
|
53
|
+
description: "Optional child field ID to summarize in the parent table",
|
|
54
|
+
},
|
|
55
|
+
summary_label: {
|
|
56
|
+
type: "string",
|
|
57
|
+
description: "Optional label for the summary field created in the parent table",
|
|
58
|
+
},
|
|
59
|
+
summary_accumulation_type: {
|
|
60
|
+
type: "string",
|
|
61
|
+
enum: ["SUM", "COUNT", "AVG", "MAX", "MIN"],
|
|
62
|
+
description: "Accumulation type for the summary field. Required when summary_field_id is provided. " +
|
|
63
|
+
"Valid values: SUM, COUNT, AVG, MAX, MIN",
|
|
64
|
+
},
|
|
65
|
+
summary_where: {
|
|
66
|
+
type: "string",
|
|
67
|
+
description: "Optional Quickbase query filter for the summary field (e.g., \"{6.EX.'Active'}\")",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
required: ["table_id", "parent_table_id"],
|
|
71
|
+
// Conditional validation: summary_accumulation_type is required when summary_field_id is provided
|
|
72
|
+
if: {
|
|
73
|
+
properties: { summary_field_id: { type: "number" } },
|
|
74
|
+
required: ["summary_field_id"],
|
|
75
|
+
},
|
|
76
|
+
then: {
|
|
77
|
+
required: ["summary_accumulation_type"],
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Run the create_relationship tool
|
|
83
|
+
* @param params Tool parameters
|
|
84
|
+
* @returns Created relationship details
|
|
85
|
+
*/
|
|
86
|
+
async run(params) {
|
|
87
|
+
const { table_id, parent_table_id, foreign_key_label, lookup_field_ids, summary_field_id, summary_label, summary_accumulation_type, summary_where, } = params;
|
|
88
|
+
logger.info("Creating relationship between tables", {
|
|
89
|
+
childTableId: table_id,
|
|
90
|
+
parentTableId: parent_table_id,
|
|
91
|
+
hasLookupFields: !!lookup_field_ids?.length,
|
|
92
|
+
hasSummaryField: !!summary_field_id,
|
|
93
|
+
});
|
|
94
|
+
// Validate conditional requirement: summary_accumulation_type required when summary_field_id is provided
|
|
95
|
+
if (summary_field_id !== undefined && !summary_accumulation_type) {
|
|
96
|
+
const errorMessage = "summary_accumulation_type is required when summary_field_id is provided. " +
|
|
97
|
+
"Valid values: SUM, COUNT, AVG, MAX, MIN";
|
|
98
|
+
logger.error("Validation failed", { error: errorMessage });
|
|
99
|
+
throw new Error(errorMessage);
|
|
100
|
+
}
|
|
101
|
+
// Build the request body according to Quickbase API format
|
|
102
|
+
const body = {
|
|
103
|
+
parentTableId: parent_table_id,
|
|
104
|
+
};
|
|
105
|
+
// Add optional foreign key label
|
|
106
|
+
if (foreign_key_label) {
|
|
107
|
+
body.foreignKeyField = {
|
|
108
|
+
label: foreign_key_label,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Add lookup fields if provided
|
|
112
|
+
if (lookup_field_ids && lookup_field_ids.length > 0) {
|
|
113
|
+
body.lookupFieldIds = lookup_field_ids;
|
|
114
|
+
}
|
|
115
|
+
// Add summary field configuration if provided
|
|
116
|
+
if (summary_field_id !== undefined && summary_accumulation_type) {
|
|
117
|
+
const summaryField = {
|
|
118
|
+
summaryFid: summary_field_id,
|
|
119
|
+
accumulationType: summary_accumulation_type,
|
|
120
|
+
};
|
|
121
|
+
if (summary_label) {
|
|
122
|
+
summaryField.label = summary_label;
|
|
123
|
+
}
|
|
124
|
+
if (summary_where) {
|
|
125
|
+
summaryField.where = summary_where;
|
|
126
|
+
}
|
|
127
|
+
body.summaryFields = [summaryField];
|
|
128
|
+
}
|
|
129
|
+
// Create the relationship
|
|
130
|
+
const response = await this.client.request({
|
|
131
|
+
method: "POST",
|
|
132
|
+
path: `/tables/${table_id}/relationship`,
|
|
133
|
+
body,
|
|
134
|
+
});
|
|
135
|
+
if (!response.success || !response.data) {
|
|
136
|
+
logger.error("Failed to create relationship", {
|
|
137
|
+
error: response.error,
|
|
138
|
+
childTableId: table_id,
|
|
139
|
+
parentTableId: parent_table_id,
|
|
140
|
+
});
|
|
141
|
+
throw new Error(response.error?.message || "Failed to create relationship");
|
|
142
|
+
}
|
|
143
|
+
// Parse and transform the API response
|
|
144
|
+
const data = response.data;
|
|
145
|
+
const foreignKeyField = data.foreignKeyField;
|
|
146
|
+
const lookupFields = data.lookupFields;
|
|
147
|
+
const summaryFields = data.summaryFields;
|
|
148
|
+
const result = {
|
|
149
|
+
id: data.id,
|
|
150
|
+
parentTableId: data.parentTableId,
|
|
151
|
+
childTableId: data.childTableId,
|
|
152
|
+
foreignKeyField: foreignKeyField
|
|
153
|
+
? {
|
|
154
|
+
id: foreignKeyField.id,
|
|
155
|
+
label: foreignKeyField.label,
|
|
156
|
+
type: foreignKeyField.type,
|
|
157
|
+
}
|
|
158
|
+
: { id: 0, label: "", type: "" },
|
|
159
|
+
lookupFields: (lookupFields || []).map((field) => ({
|
|
160
|
+
id: field.id,
|
|
161
|
+
label: field.label,
|
|
162
|
+
type: field.type,
|
|
163
|
+
})),
|
|
164
|
+
summaryFields: (summaryFields || []).map((field) => ({
|
|
165
|
+
id: field.id,
|
|
166
|
+
label: field.label,
|
|
167
|
+
type: field.type,
|
|
168
|
+
})),
|
|
169
|
+
};
|
|
170
|
+
logger.info("Successfully created relationship", {
|
|
171
|
+
relationshipId: result.id,
|
|
172
|
+
childTableId: result.childTableId,
|
|
173
|
+
parentTableId: result.parentTableId,
|
|
174
|
+
lookupFieldsCreated: result.lookupFields.length,
|
|
175
|
+
summaryFieldsCreated: result.summaryFields.length,
|
|
176
|
+
});
|
|
177
|
+
return result;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
exports.CreateRelationshipTool = CreateRelationshipTool;
|
|
181
|
+
//# sourceMappingURL=create_relationship.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_relationship.js","sourceRoot":"","sources":["../../../src/tools/relationships/create_relationship.ts"],"names":[],"mappings":";;;AAAA,kCAAmC;AAEnC,+CAAkD;AAGlD,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC,wBAAwB,CAAC,CAAC;AAuFtD;;;;;GAKG;AACH,MAAa,sBAAuB,SAAQ,eAG3C;IAsEC;;;OAGG;IACH,YAAY,MAAuB;QACjC,KAAK,CAAC,MAAM,CAAC,CAAC;QA1ET,SAAI,GAAG,qBAAqB,CAAC;QAC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AC,EAAE,EAAE,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE;YAClC,YAAY,EAAE,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,GAAG,CACpC,CAAC,KAA8B,EAAE,EAAE,CAAC,CAAC;gBACnC,EAAE,EAAE,KAAK,CAAC,EAAY;gBACtB,KAAK,EAAE,KAAK,CAAC,KAAe;gBAC5B,IAAI,EAAE,KAAK,CAAC,IAAc;aAC3B,CAAC,CACH;YACD,aAAa,EAAE,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,GAAG,CACtC,CAAC,KAA8B,EAAE,EAAE,CAAC,CAAC;gBACnC,EAAE,EAAE,KAAK,CAAC,EAAY;gBACtB,KAAK,EAAE,KAAK,CAAC,KAAe;gBAC5B,IAAI,EAAE,KAAK,CAAC,IAAc;aAC3B,CAAC,CACH;SACF,CAAC;QAEF,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE;YAC/C,cAAc,EAAE,MAAM,CAAC,EAAE;YACzB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,mBAAmB,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM;YAC/C,oBAAoB,EAAE,MAAM,CAAC,aAAa,CAAC,MAAM;SAClD,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA3ND,wDA2NC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { BaseTool } from "../base";
|
|
2
|
+
import { QuickbaseClient } from "../../client/quickbase";
|
|
3
|
+
/**
|
|
4
|
+
* Parameters for delete_relationship tool
|
|
5
|
+
*/
|
|
6
|
+
export interface DeleteRelationshipParams {
|
|
7
|
+
/**
|
|
8
|
+
* The ID of the child table (DBID) containing the relationship
|
|
9
|
+
*/
|
|
10
|
+
table_id: string;
|
|
11
|
+
/**
|
|
12
|
+
* The ID of the relationship to delete
|
|
13
|
+
*/
|
|
14
|
+
relationship_id: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result from deleting a relationship
|
|
18
|
+
*/
|
|
19
|
+
export interface DeleteRelationshipResult {
|
|
20
|
+
/**
|
|
21
|
+
* The ID of the deleted relationship
|
|
22
|
+
*/
|
|
23
|
+
relationshipId: number;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the deletion was successful
|
|
26
|
+
*/
|
|
27
|
+
deleted: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Tool for deleting a table-to-table relationship in Quickbase.
|
|
31
|
+
*
|
|
32
|
+
* WARNING: This is a DESTRUCTIVE operation that permanently deletes
|
|
33
|
+
* the relationship and all associated lookup and summary fields.
|
|
34
|
+
*/
|
|
35
|
+
export declare class DeleteRelationshipTool extends BaseTool<DeleteRelationshipParams, DeleteRelationshipResult> {
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
/**
|
|
39
|
+
* Parameter schema for delete_relationship
|
|
40
|
+
*/
|
|
41
|
+
paramSchema: {
|
|
42
|
+
type: string;
|
|
43
|
+
properties: {
|
|
44
|
+
table_id: {
|
|
45
|
+
type: string;
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
relationship_id: {
|
|
49
|
+
type: string;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
required: string[];
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Constructor
|
|
57
|
+
* @param client Quickbase client
|
|
58
|
+
*/
|
|
59
|
+
constructor(client: QuickbaseClient);
|
|
60
|
+
/**
|
|
61
|
+
* Run the delete_relationship tool
|
|
62
|
+
* @param params Tool parameters
|
|
63
|
+
* @returns Deletion confirmation
|
|
64
|
+
*/
|
|
65
|
+
protected run(params: DeleteRelationshipParams): Promise<DeleteRelationshipResult>;
|
|
66
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DeleteRelationshipTool = void 0;
|
|
4
|
+
const base_1 = require("../base");
|
|
5
|
+
const logger_1 = require("../../utils/logger");
|
|
6
|
+
const logger = (0, logger_1.createLogger)("DeleteRelationshipTool");
|
|
7
|
+
/**
|
|
8
|
+
* Tool for deleting a table-to-table relationship in Quickbase.
|
|
9
|
+
*
|
|
10
|
+
* WARNING: This is a DESTRUCTIVE operation that permanently deletes
|
|
11
|
+
* the relationship and all associated lookup and summary fields.
|
|
12
|
+
*/
|
|
13
|
+
class DeleteRelationshipTool extends base_1.BaseTool {
|
|
14
|
+
/**
|
|
15
|
+
* Constructor
|
|
16
|
+
* @param client Quickbase client
|
|
17
|
+
*/
|
|
18
|
+
constructor(client) {
|
|
19
|
+
super(client);
|
|
20
|
+
this.name = "delete_relationship";
|
|
21
|
+
this.description = "WARNING: DESTRUCTIVE OPERATION - Permanently deletes an entire table-to-table " +
|
|
22
|
+
"relationship INCLUDING ALL LOOKUP AND SUMMARY FIELDS associated with it. All data " +
|
|
23
|
+
"in those fields will be permanently lost and CANNOT be recovered. The reference " +
|
|
24
|
+
"field in the child table will NOT be deleted (it will remain and may need to be " +
|
|
25
|
+
"manually deleted using field deletion tools if no longer needed). Before using " +
|
|
26
|
+
"this tool:\n" +
|
|
27
|
+
"1. Use get_relationships to see what fields will be deleted\n" +
|
|
28
|
+
"2. Confirm with the user that they want to proceed\n" +
|
|
29
|
+
"3. Consider if you only need to delete specific fields instead\n\n" +
|
|
30
|
+
"Only use this tool when you are certain the entire relationship should be removed.";
|
|
31
|
+
/**
|
|
32
|
+
* Parameter schema for delete_relationship
|
|
33
|
+
*/
|
|
34
|
+
this.paramSchema = {
|
|
35
|
+
type: "object",
|
|
36
|
+
properties: {
|
|
37
|
+
table_id: {
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "The ID of the child Quickbase table (DBID) containing the relationship",
|
|
40
|
+
},
|
|
41
|
+
relationship_id: {
|
|
42
|
+
type: "number",
|
|
43
|
+
description: "The ID of the relationship to delete",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
required: ["table_id", "relationship_id"],
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Run the delete_relationship tool
|
|
51
|
+
* @param params Tool parameters
|
|
52
|
+
* @returns Deletion confirmation
|
|
53
|
+
*/
|
|
54
|
+
async run(params) {
|
|
55
|
+
const { table_id, relationship_id } = params;
|
|
56
|
+
// Use logger.warn for destructive operations
|
|
57
|
+
logger.warn("Deleting relationship", {
|
|
58
|
+
tableId: table_id,
|
|
59
|
+
relationshipId: relationship_id,
|
|
60
|
+
});
|
|
61
|
+
// Delete the relationship
|
|
62
|
+
const response = await this.client.request({
|
|
63
|
+
method: "DELETE",
|
|
64
|
+
path: `/tables/${table_id}/relationship/${relationship_id}`,
|
|
65
|
+
});
|
|
66
|
+
if (!response.success) {
|
|
67
|
+
logger.error("Failed to delete relationship", {
|
|
68
|
+
error: response.error,
|
|
69
|
+
tableId: table_id,
|
|
70
|
+
relationshipId: relationship_id,
|
|
71
|
+
});
|
|
72
|
+
throw new Error(response.error?.message || "Failed to delete relationship");
|
|
73
|
+
}
|
|
74
|
+
logger.warn("Successfully deleted relationship", {
|
|
75
|
+
tableId: table_id,
|
|
76
|
+
relationshipId: relationship_id,
|
|
77
|
+
});
|
|
78
|
+
return {
|
|
79
|
+
relationshipId: relationship_id,
|
|
80
|
+
deleted: true,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
exports.DeleteRelationshipTool = DeleteRelationshipTool;
|
|
85
|
+
//# sourceMappingURL=delete_relationship.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete_relationship.js","sourceRoot":"","sources":["../../../src/tools/relationships/delete_relationship.ts"],"names":[],"mappings":";;;AAAA,kCAAmC;AAEnC,+CAAkD;AAElD,MAAM,MAAM,GAAG,IAAA,qBAAY,EAAC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