@mcp-z/mcp-sheets 1.2.4 → 1.3.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/dist/cjs/index.js.map +1 -1
- package/dist/cjs/lib/google-auth.d.cts +9 -0
- package/dist/cjs/lib/google-auth.d.ts +9 -0
- package/dist/cjs/lib/google-auth.js +16 -0
- package/dist/cjs/lib/google-auth.js.map +1 -0
- package/dist/cjs/mcp/prompts/a1-notation.d.cts +2 -3
- package/dist/cjs/mcp/prompts/a1-notation.d.ts +2 -3
- package/dist/cjs/mcp/prompts/a1-notation.js.map +1 -1
- package/dist/cjs/mcp/resources/spreadsheet.js +6 -5
- package/dist/cjs/mcp/resources/spreadsheet.js.map +1 -1
- package/dist/cjs/mcp/tools/cells-format.d.cts +1 -1
- package/dist/cjs/mcp/tools/cells-format.d.ts +1 -1
- package/dist/cjs/mcp/tools/cells-format.js +7 -6
- package/dist/cjs/mcp/tools/cells-format.js.map +1 -1
- package/dist/cjs/mcp/tools/chart-create.d.cts +1 -1
- package/dist/cjs/mcp/tools/chart-create.d.ts +1 -1
- package/dist/cjs/mcp/tools/chart-create.js +11 -10
- package/dist/cjs/mcp/tools/chart-create.js.map +1 -1
- package/dist/cjs/mcp/tools/columns-get.d.cts +1 -1
- package/dist/cjs/mcp/tools/columns-get.d.ts +1 -1
- package/dist/cjs/mcp/tools/columns-get.js +7 -6
- package/dist/cjs/mcp/tools/columns-get.js.map +1 -1
- package/dist/cjs/mcp/tools/columns-update.d.cts +1 -1
- package/dist/cjs/mcp/tools/columns-update.d.ts +1 -1
- package/dist/cjs/mcp/tools/columns-update.js +8 -7
- package/dist/cjs/mcp/tools/columns-update.js.map +1 -1
- package/dist/cjs/mcp/tools/csv-get-columns.d.cts +1 -1
- package/dist/cjs/mcp/tools/csv-get-columns.d.ts +1 -1
- package/dist/cjs/mcp/tools/csv-get-columns.js +2 -2
- package/dist/cjs/mcp/tools/csv-get-columns.js.map +1 -1
- package/dist/cjs/mcp/tools/dimensions-batch-update.d.cts +1 -1
- package/dist/cjs/mcp/tools/dimensions-batch-update.d.ts +1 -1
- package/dist/cjs/mcp/tools/dimensions-batch-update.js +12 -11
- package/dist/cjs/mcp/tools/dimensions-batch-update.js.map +1 -1
- package/dist/cjs/mcp/tools/dimensions-move.d.cts +1 -1
- package/dist/cjs/mcp/tools/dimensions-move.d.ts +1 -1
- package/dist/cjs/mcp/tools/dimensions-move.js +10 -9
- package/dist/cjs/mcp/tools/dimensions-move.js.map +1 -1
- package/dist/cjs/mcp/tools/rows-append.d.cts +1 -1
- package/dist/cjs/mcp/tools/rows-append.d.ts +1 -1
- package/dist/cjs/mcp/tools/rows-append.js +7 -6
- package/dist/cjs/mcp/tools/rows-append.js.map +1 -1
- package/dist/cjs/mcp/tools/rows-csv-append.d.cts +1 -1
- package/dist/cjs/mcp/tools/rows-csv-append.d.ts +1 -1
- package/dist/cjs/mcp/tools/rows-csv-append.js +11 -10
- package/dist/cjs/mcp/tools/rows-csv-append.js.map +1 -1
- package/dist/cjs/mcp/tools/rows-get.d.cts +1 -1
- package/dist/cjs/mcp/tools/rows-get.d.ts +1 -1
- package/dist/cjs/mcp/tools/rows-get.js +8 -7
- package/dist/cjs/mcp/tools/rows-get.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-copy-to.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-copy-to.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-copy-to.js +8 -7
- package/dist/cjs/mcp/tools/sheet-copy-to.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-copy.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-copy.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-copy.js +8 -7
- package/dist/cjs/mcp/tools/sheet-copy.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-create.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-create.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-create.js +7 -6
- package/dist/cjs/mcp/tools/sheet-create.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-delete.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-delete.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-delete.js +6 -5
- package/dist/cjs/mcp/tools/sheet-delete.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-find.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-find.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-find.js +7 -6
- package/dist/cjs/mcp/tools/sheet-find.js.map +1 -1
- package/dist/cjs/mcp/tools/sheet-rename.d.cts +1 -1
- package/dist/cjs/mcp/tools/sheet-rename.d.ts +1 -1
- package/dist/cjs/mcp/tools/sheet-rename.js +8 -7
- package/dist/cjs/mcp/tools/sheet-rename.js.map +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-copy.d.cts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-copy.d.ts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-copy.js +9 -7
- package/dist/cjs/mcp/tools/spreadsheet-copy.js.map +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-create.d.cts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-create.d.ts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-create.js +7 -6
- package/dist/cjs/mcp/tools/spreadsheet-create.js.map +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-find.d.cts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-find.d.ts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-find.js +9 -7
- package/dist/cjs/mcp/tools/spreadsheet-find.js.map +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-rename.d.cts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-rename.d.ts +1 -1
- package/dist/cjs/mcp/tools/spreadsheet-rename.js +6 -5
- package/dist/cjs/mcp/tools/spreadsheet-rename.js.map +1 -1
- package/dist/cjs/mcp/tools/validation-set.d.cts +1 -1
- package/dist/cjs/mcp/tools/validation-set.d.ts +1 -1
- package/dist/cjs/mcp/tools/validation-set.js +8 -7
- package/dist/cjs/mcp/tools/validation-set.js.map +1 -1
- package/dist/cjs/mcp/tools/values-batch-update.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-batch-update.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-batch-update.js +9 -8
- package/dist/cjs/mcp/tools/values-batch-update.js.map +1 -1
- package/dist/cjs/mcp/tools/values-clear.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-clear.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-clear.js +7 -6
- package/dist/cjs/mcp/tools/values-clear.js.map +1 -1
- package/dist/cjs/mcp/tools/values-csv-update.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-csv-update.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-csv-update.js +8 -7
- package/dist/cjs/mcp/tools/values-csv-update.js.map +1 -1
- package/dist/cjs/mcp/tools/values-markdown-update.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-markdown-update.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-markdown-update.js +9 -8
- package/dist/cjs/mcp/tools/values-markdown-update.js.map +1 -1
- package/dist/cjs/mcp/tools/values-replace.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-replace.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-replace.js +9 -8
- package/dist/cjs/mcp/tools/values-replace.js.map +1 -1
- package/dist/cjs/mcp/tools/values-search.d.cts +1 -1
- package/dist/cjs/mcp/tools/values-search.d.ts +1 -1
- package/dist/cjs/mcp/tools/values-search.js +7 -6
- package/dist/cjs/mcp/tools/values-search.js.map +1 -1
- package/dist/cjs/setup/http.d.cts +0 -2
- package/dist/cjs/setup/http.d.ts +0 -2
- package/dist/cjs/setup/http.js +18 -11
- package/dist/cjs/setup/http.js.map +1 -1
- package/dist/cjs/setup/stdio.d.cts +0 -2
- package/dist/cjs/setup/stdio.d.ts +0 -2
- package/dist/cjs/setup/stdio.js +18 -11
- package/dist/cjs/setup/stdio.js.map +1 -1
- package/dist/cjs/spreadsheet/data-operations.d.cts +1 -1
- package/dist/cjs/spreadsheet/data-operations.d.ts +1 -1
- package/dist/cjs/spreadsheet/data-operations.js.map +1 -1
- package/dist/cjs/spreadsheet/markdown-runs.d.cts +1 -31
- package/dist/cjs/spreadsheet/markdown-runs.d.ts +1 -31
- package/dist/cjs/spreadsheet/markdown-runs.js +31 -31
- package/dist/cjs/spreadsheet/markdown-runs.js.map +1 -1
- package/dist/cjs/spreadsheet/sheet-operations.d.cts +1 -1
- package/dist/cjs/spreadsheet/sheet-operations.d.ts +1 -1
- package/dist/cjs/spreadsheet/sheet-operations.js.map +1 -1
- package/dist/cjs/spreadsheet/spreadsheet-management.d.cts +2 -1
- package/dist/cjs/spreadsheet/spreadsheet-management.d.ts +2 -1
- package/dist/cjs/spreadsheet/spreadsheet-management.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/google-auth.d.ts +9 -0
- package/dist/esm/lib/google-auth.js +11 -0
- package/dist/esm/lib/google-auth.js.map +1 -0
- package/dist/esm/mcp/prompts/a1-notation.d.ts +2 -3
- package/dist/esm/mcp/prompts/a1-notation.js.map +1 -1
- package/dist/esm/mcp/resources/spreadsheet.js +5 -4
- package/dist/esm/mcp/resources/spreadsheet.js.map +1 -1
- package/dist/esm/mcp/tools/cells-format.d.ts +1 -1
- package/dist/esm/mcp/tools/cells-format.js +7 -6
- package/dist/esm/mcp/tools/cells-format.js.map +1 -1
- package/dist/esm/mcp/tools/chart-create.d.ts +1 -1
- package/dist/esm/mcp/tools/chart-create.js +11 -10
- package/dist/esm/mcp/tools/chart-create.js.map +1 -1
- package/dist/esm/mcp/tools/columns-get.d.ts +1 -1
- package/dist/esm/mcp/tools/columns-get.js +8 -7
- package/dist/esm/mcp/tools/columns-get.js.map +1 -1
- package/dist/esm/mcp/tools/columns-update.d.ts +1 -1
- package/dist/esm/mcp/tools/columns-update.js +8 -7
- package/dist/esm/mcp/tools/columns-update.js.map +1 -1
- package/dist/esm/mcp/tools/csv-get-columns.d.ts +1 -1
- package/dist/esm/mcp/tools/csv-get-columns.js +2 -2
- package/dist/esm/mcp/tools/csv-get-columns.js.map +1 -1
- package/dist/esm/mcp/tools/dimensions-batch-update.d.ts +1 -1
- package/dist/esm/mcp/tools/dimensions-batch-update.js +12 -11
- package/dist/esm/mcp/tools/dimensions-batch-update.js.map +1 -1
- package/dist/esm/mcp/tools/dimensions-move.d.ts +1 -1
- package/dist/esm/mcp/tools/dimensions-move.js +10 -9
- package/dist/esm/mcp/tools/dimensions-move.js.map +1 -1
- package/dist/esm/mcp/tools/rows-append.d.ts +1 -1
- package/dist/esm/mcp/tools/rows-append.js +7 -6
- package/dist/esm/mcp/tools/rows-append.js.map +1 -1
- package/dist/esm/mcp/tools/rows-csv-append.d.ts +1 -1
- package/dist/esm/mcp/tools/rows-csv-append.js +12 -11
- package/dist/esm/mcp/tools/rows-csv-append.js.map +1 -1
- package/dist/esm/mcp/tools/rows-get.d.ts +1 -1
- package/dist/esm/mcp/tools/rows-get.js +8 -7
- package/dist/esm/mcp/tools/rows-get.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-copy-to.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-copy-to.js +8 -7
- package/dist/esm/mcp/tools/sheet-copy-to.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-copy.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-copy.js +8 -7
- package/dist/esm/mcp/tools/sheet-copy.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-create.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-create.js +7 -6
- package/dist/esm/mcp/tools/sheet-create.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-delete.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-delete.js +6 -5
- package/dist/esm/mcp/tools/sheet-delete.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-find.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-find.js +7 -6
- package/dist/esm/mcp/tools/sheet-find.js.map +1 -1
- package/dist/esm/mcp/tools/sheet-rename.d.ts +1 -1
- package/dist/esm/mcp/tools/sheet-rename.js +8 -7
- package/dist/esm/mcp/tools/sheet-rename.js.map +1 -1
- package/dist/esm/mcp/tools/spreadsheet-copy.d.ts +1 -1
- package/dist/esm/mcp/tools/spreadsheet-copy.js +9 -7
- package/dist/esm/mcp/tools/spreadsheet-copy.js.map +1 -1
- package/dist/esm/mcp/tools/spreadsheet-create.d.ts +1 -1
- package/dist/esm/mcp/tools/spreadsheet-create.js +7 -6
- package/dist/esm/mcp/tools/spreadsheet-create.js.map +1 -1
- package/dist/esm/mcp/tools/spreadsheet-find.d.ts +1 -1
- package/dist/esm/mcp/tools/spreadsheet-find.js +9 -7
- package/dist/esm/mcp/tools/spreadsheet-find.js.map +1 -1
- package/dist/esm/mcp/tools/spreadsheet-rename.d.ts +1 -1
- package/dist/esm/mcp/tools/spreadsheet-rename.js +6 -5
- package/dist/esm/mcp/tools/spreadsheet-rename.js.map +1 -1
- package/dist/esm/mcp/tools/validation-set.d.ts +1 -1
- package/dist/esm/mcp/tools/validation-set.js +8 -7
- package/dist/esm/mcp/tools/validation-set.js.map +1 -1
- package/dist/esm/mcp/tools/values-batch-update.d.ts +1 -1
- package/dist/esm/mcp/tools/values-batch-update.js +9 -8
- package/dist/esm/mcp/tools/values-batch-update.js.map +1 -1
- package/dist/esm/mcp/tools/values-clear.d.ts +1 -1
- package/dist/esm/mcp/tools/values-clear.js +7 -6
- package/dist/esm/mcp/tools/values-clear.js.map +1 -1
- package/dist/esm/mcp/tools/values-csv-update.d.ts +1 -1
- package/dist/esm/mcp/tools/values-csv-update.js +9 -8
- package/dist/esm/mcp/tools/values-csv-update.js.map +1 -1
- package/dist/esm/mcp/tools/values-markdown-update.d.ts +1 -1
- package/dist/esm/mcp/tools/values-markdown-update.js +9 -8
- package/dist/esm/mcp/tools/values-markdown-update.js.map +1 -1
- package/dist/esm/mcp/tools/values-replace.d.ts +1 -1
- package/dist/esm/mcp/tools/values-replace.js +9 -8
- package/dist/esm/mcp/tools/values-replace.js.map +1 -1
- package/dist/esm/mcp/tools/values-search.d.ts +1 -1
- package/dist/esm/mcp/tools/values-search.js +7 -6
- package/dist/esm/mcp/tools/values-search.js.map +1 -1
- package/dist/esm/setup/http.d.ts +0 -2
- package/dist/esm/setup/http.js +18 -11
- package/dist/esm/setup/http.js.map +1 -1
- package/dist/esm/setup/stdio.d.ts +0 -2
- package/dist/esm/setup/stdio.js +18 -11
- package/dist/esm/setup/stdio.js.map +1 -1
- package/dist/esm/spreadsheet/data-operations.d.ts +1 -1
- package/dist/esm/spreadsheet/data-operations.js.map +1 -1
- package/dist/esm/spreadsheet/markdown-runs.d.ts +1 -31
- package/dist/esm/spreadsheet/markdown-runs.js.map +1 -1
- package/dist/esm/spreadsheet/sheet-operations.d.ts +1 -1
- package/dist/esm/spreadsheet/sheet-operations.js.map +1 -1
- package/dist/esm/spreadsheet/spreadsheet-management.d.ts +2 -1
- package/dist/esm/spreadsheet/spreadsheet-management.js.map +1 -1
- package/package.json +9 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/validation-set.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { google, type sheets_v4 } from 'googleapis';\nimport { z } from 'zod';\nimport { SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { parseA1Notation, rangeReferenceToGridRange } from '../../spreadsheet/range-operations.ts';\n\n// Discriminated union for validation rule types\nconst ValidationRuleSchema = z.discriminatedUnion('conditionType', [\n // Dropdown with hardcoded list\n z.object({\n conditionType: z.literal('ONE_OF_LIST'),\n values: z.array(z.string()).min(1).describe('Hardcoded dropdown options'),\n showDropdown: z.boolean().default(true).describe('Show dropdown UI in cells'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Dropdown from range\n z.object({\n conditionType: z.literal('ONE_OF_RANGE'),\n sourceRange: z.string().min(1).describe('A1 notation range containing dropdown options (e.g., \"Options!A1:A10\")'),\n showDropdown: z.boolean().default(true).describe('Show dropdown UI in cells'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Numeric constraints\n z.object({\n conditionType: z.enum(['NUMBER_GREATER', 'NUMBER_LESS', 'NUMBER_BETWEEN']),\n values: z.array(z.number()).min(1).max(2).describe('1 value for GREATER/LESS, 2 values for BETWEEN'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Text constraints\n z.object({\n conditionType: z.enum(['TEXT_CONTAINS', 'TEXT_IS_EMAIL', 'TEXT_IS_URL']),\n values: z.array(z.string()).optional().describe('Text to match (for TEXT_CONTAINS only)'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Date constraints\n z.object({\n conditionType: z.enum(['DATE_AFTER', 'DATE_BEFORE', 'DATE_BETWEEN']),\n values: z.array(z.string()).min(1).max(2).describe('ISO date strings (YYYY-MM-DD)'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Custom formula\n z.object({\n conditionType: z.literal('CUSTOM_FORMULA'),\n formula: z.string().min(1).describe('Custom validation formula (e.g., \"=A1>0\")'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n]);\n\n// Input schema for validation requests\nconst ValidationRequestSchema = z.object({\n range: z.string().min(1).describe('A1 notation range for validation (e.g., \"B2:B100\")'),\n rule: ValidationRuleSchema,\n inputMessage: z.string().optional().describe('Help text shown when cell is selected'),\n});\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n requests: z.array(ValidationRequestSchema).min(1).max(50).describe('Array of validation rules. Batch multiple ranges for efficiency.'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n sheetTitle: z.string().describe('Title of the sheet with validation'),\n sheetUrl: z.string().describe('URL of the sheet with validation'),\n successCount: z.number().int().nonnegative().describe('Number of validation rules successfully applied'),\n failedRanges: z\n .array(\n z.object({\n range: z.string().describe('A1 notation of range that failed validation setup'),\n error: z.string().describe('Why validation failed for this range'),\n })\n )\n .optional()\n .describe('Only populated if some validation rules failed'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Add data validation rules including dropdowns, numeric constraints, text patterns, date ranges, custom formulas. Supports batch operations for efficiency. Use discriminated conditionType to specify rule type. Best for enforcing data integrity and providing user-friendly input controls.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\n// Map condition types to Google Sheets API format\nfunction buildCondition(rule: z.infer<typeof ValidationRuleSchema>) {\n switch (rule.conditionType) {\n case 'ONE_OF_LIST':\n return {\n type: 'ONE_OF_LIST',\n values: rule.values.map((value) => ({ userEnteredValue: value })),\n };\n case 'ONE_OF_RANGE':\n return {\n type: 'ONE_OF_RANGE',\n values: [{ userEnteredValue: `=${rule.sourceRange}` }],\n };\n case 'NUMBER_GREATER':\n return {\n type: 'NUMBER_GREATER',\n values: [{ userEnteredValue: String(rule.values[0]) }],\n };\n case 'NUMBER_LESS':\n return {\n type: 'NUMBER_LESS',\n values: [{ userEnteredValue: String(rule.values[0]) }],\n };\n case 'NUMBER_BETWEEN':\n return {\n type: 'NUMBER_BETWEEN',\n values: [{ userEnteredValue: String(rule.values[0]) }, { userEnteredValue: String(rule.values[1]) }],\n };\n case 'TEXT_CONTAINS':\n return {\n type: 'TEXT_CONTAINS',\n values: rule.values ? [{ userEnteredValue: rule.values[0] }] : [],\n };\n case 'TEXT_IS_EMAIL':\n return {\n type: 'TEXT_IS_EMAIL',\n values: [],\n };\n case 'TEXT_IS_URL':\n return {\n type: 'TEXT_IS_URL',\n values: [],\n };\n case 'DATE_AFTER':\n return {\n type: 'DATE_AFTER',\n values: [{ userEnteredValue: rule.values[0] }],\n };\n case 'DATE_BEFORE':\n return {\n type: 'DATE_BEFORE',\n values: [{ userEnteredValue: rule.values[0] }],\n };\n case 'DATE_BETWEEN':\n return {\n type: 'DATE_BETWEEN',\n values: [{ userEnteredValue: rule.values[0] }, { userEnteredValue: rule.values[1] }],\n };\n case 'CUSTOM_FORMULA':\n return {\n type: 'CUSTOM_FORMULA',\n values: [{ userEnteredValue: rule.formula.startsWith('=') ? rule.formula : `=${rule.formula}` }],\n };\n default:\n // Exhaustive check - all valid conditionType values should be handled above\n throw new Error(`Unknown condition type: ${(rule as { conditionType: string }).conditionType}`);\n }\n}\n\nasync function handler({ id, gid, requests }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.validation.set called', {\n id,\n gid,\n requestCount: requests.length,\n });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // Get spreadsheet and sheet info in single API call\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'sheets.properties.sheetId,sheets.properties.title',\n });\n\n // Find sheet by gid\n const sheet = spreadsheetResponse.data.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n logger.info('Sheet not found for validation set', { id, gid, requestCount: requests.length });\n throw new McpError(ErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n const sheetTitle = sheet.properties.title ?? gid;\n const sheetId = sheet.properties.sheetId;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetId}`;\n\n // Validate sheetId exists\n if (sheetId === undefined || sheetId === null) {\n logger.error('Sheet ID not available for validation set', { id, gid, sheetTitle });\n throw new McpError(ErrorCode.InternalError, `Sheet ID not available for ${gid}. Cannot perform validation operations without valid sheet ID.`);\n }\n\n // Build batch update requests\n const batchRequests: sheets_v4.Schema$Request[] = [];\n const failedRanges: Array<{ range: string; error: string }> = [];\n\n for (const request of requests) {\n try {\n // Parse A1 notation to range reference\n const rangeRef = parseA1Notation(request.range);\n\n // Build grid range from range reference using helper function\n const gridRange = rangeReferenceToGridRange(rangeRef, sheetId);\n\n // Build validation rule\n const condition = buildCondition(request.rule);\n\n // Build data validation rule - structure matches Schema$DataValidationRule\n const dataValidationRule = {\n condition,\n strict: request.rule.strict,\n showCustomUi: 'showDropdown' in request.rule ? request.rule.showDropdown : undefined,\n inputMessage: request.inputMessage,\n } as sheets_v4.Schema$DataValidationRule;\n\n // Add setDataValidation request\n batchRequests.push({\n setDataValidation: {\n range: gridRange,\n rule: dataValidationRule,\n },\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.info('Failed to build validation rule', {\n range: request.range,\n error: message,\n });\n failedRanges.push({\n range: request.range,\n error: `Failed to build validation rule: ${message}`,\n });\n }\n }\n\n // Early return if all ranges failed\n if (batchRequests.length === 0) {\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetId),\n sheetTitle,\n sheetUrl,\n successCount: 0,\n failedRanges: failedRanges.length > 0 ? failedRanges : undefined,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n }\n\n logger.info('sheets.validation.set executing batch request', {\n spreadsheetId: id,\n sheetTitle,\n batchRequestsCount: batchRequests.length,\n });\n\n // Execute the batch update\n await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: batchRequests,\n },\n });\n\n logger.info('sheets.validation.set completed successfully', {\n successCount: requests.length - failedRanges.length,\n failedCount: failedRanges.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetId),\n sheetTitle,\n sheetUrl,\n successCount: requests.length - failedRanges.length,\n failedRanges: failedRanges.length > 0 ? failedRanges : undefined,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('Validation set operation failed', {\n id,\n gid,\n requestCount: requests.length,\n error: message,\n });\n\n throw new McpError(ErrorCode.InternalError, `Error setting validation: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'validation-set',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","ValidationRuleSchema","z","discriminatedUnion","object","conditionType","literal","values","array","string","min","describe","showDropdown","boolean","default","strict","sourceRange","enum","number","max","optional","formula","ValidationRequestSchema","range","rule","inputMessage","inputSchema","id","SpreadsheetIdSchema","gid","SheetGidSchema","requests","successBranchSchema","type","SpreadsheetIdOutput","SheetGidOutput","sheetTitle","sheetUrl","successCount","int","nonnegative","failedRanges","error","outputSchema","config","description","result","buildCondition","map","value","userEnteredValue","String","startsWith","Error","handler","extra","logger","sheet","spreadsheetResponse","sheets","sheetId","batchRequests","request","rangeRef","gridRange","condition","dataValidationRule","message","info","requestCount","length","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","find","s","properties","McpError","ErrorCode","InvalidParams","title","undefined","InternalError","parseA1Notation","rangeReferenceToGridRange","showCustomUi","push","setDataValidation","content","text","JSON","stringify","structuredContent","batchRequestsCount","batchUpdate","requestBody","failedCount","stack","name"],"mappings":";;;;+BAuTA;;;eAAwBA;;;2BAtTA;qBAMY;0BACG;mBACrB;uBACuE;iCAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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pD,QAAAA;4BAAO;wBAC9B;;;oBACOJ;oBACDyB,WAAUzB,AAAK,YAALA,OAAiBW,SAAQX,MAAMyB,OAAO,GAAGhB,OAAOT;oBAChEc,OAAOd,KAAK,CAAC,mCAAmC;wBAC9Cf,IAAAA;wBACAE,KAAAA;wBACAwC,cAActC,SAASuC,MAAM;wBAC7B5B,OAAOyB;oBACT;oBAEA,MAAM,IAAIgB,eAAQ,CAACC,gBAAS,CAACI,aAAa,EAAE,AAAC,6BAAoC,OAARrB,WAAW;wBAClFoC,OAAO7D,AAAK,YAALA,OAAiBW,SAAQX,MAAM6D,KAAK,GAAGhB;oBAChD;;;;;;;IAEJ;;AAEe,SAASzF;IACtB,OAAO;QACL0G,MAAM;QACN5D,QAAAA;QACAU,SAAAA;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/validation-set.ts"],"sourcesContent":["import { type sheets_v4, sheets as sheetsApi } from '@googleapis/sheets';\nimport type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { CallToolResult, ToolModule } from '@mcp-z/server';\nimport { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { z } from 'zod';\nimport { googleAuth } from '../../lib/google-auth.ts';\nimport { SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { parseA1Notation, rangeReferenceToGridRange } from '../../spreadsheet/range-operations.ts';\n\n// Discriminated union for validation rule types\nconst ValidationRuleSchema = z.discriminatedUnion('conditionType', [\n // Dropdown with hardcoded list\n z.object({\n conditionType: z.literal('ONE_OF_LIST'),\n values: z.array(z.string()).min(1).describe('Hardcoded dropdown options'),\n showDropdown: z.boolean().default(true).describe('Show dropdown UI in cells'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Dropdown from range\n z.object({\n conditionType: z.literal('ONE_OF_RANGE'),\n sourceRange: z.string().min(1).describe('A1 notation range containing dropdown options (e.g., \"Options!A1:A10\")'),\n showDropdown: z.boolean().default(true).describe('Show dropdown UI in cells'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Numeric constraints\n z.object({\n conditionType: z.enum(['NUMBER_GREATER', 'NUMBER_LESS', 'NUMBER_BETWEEN']),\n values: z.array(z.number()).min(1).max(2).describe('1 value for GREATER/LESS, 2 values for BETWEEN'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Text constraints\n z.object({\n conditionType: z.enum(['TEXT_CONTAINS', 'TEXT_IS_EMAIL', 'TEXT_IS_URL']),\n values: z.array(z.string()).optional().describe('Text to match (for TEXT_CONTAINS only)'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Date constraints\n z.object({\n conditionType: z.enum(['DATE_AFTER', 'DATE_BEFORE', 'DATE_BETWEEN']),\n values: z.array(z.string()).min(1).max(2).describe('ISO date strings (YYYY-MM-DD)'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n // Custom formula\n z.object({\n conditionType: z.literal('CUSTOM_FORMULA'),\n formula: z.string().min(1).describe('Custom validation formula (e.g., \"=A1>0\")'),\n strict: z.boolean().default(true).describe('Reject invalid entries'),\n }),\n]);\n\n// Input schema for validation requests\nconst ValidationRequestSchema = z.object({\n range: z.string().min(1).describe('A1 notation range for validation (e.g., \"B2:B100\")'),\n rule: ValidationRuleSchema,\n inputMessage: z.string().optional().describe('Help text shown when cell is selected'),\n});\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n requests: z.array(ValidationRequestSchema).min(1).max(50).describe('Array of validation rules. Batch multiple ranges for efficiency.'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n sheetTitle: z.string().describe('Title of the sheet with validation'),\n sheetUrl: z.string().describe('URL of the sheet with validation'),\n successCount: z.number().int().nonnegative().describe('Number of validation rules successfully applied'),\n failedRanges: z\n .array(\n z.object({\n range: z.string().describe('A1 notation of range that failed validation setup'),\n error: z.string().describe('Why validation failed for this range'),\n })\n )\n .optional()\n .describe('Only populated if some validation rules failed'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Add data validation rules including dropdowns, numeric constraints, text patterns, date ranges, custom formulas. Supports batch operations for efficiency. Use discriminated conditionType to specify rule type. Best for enforcing data integrity and providing user-friendly input controls.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\n// Map condition types to Google Sheets API format\nfunction buildCondition(rule: z.infer<typeof ValidationRuleSchema>) {\n switch (rule.conditionType) {\n case 'ONE_OF_LIST':\n return {\n type: 'ONE_OF_LIST',\n values: rule.values.map((value) => ({ userEnteredValue: value })),\n };\n case 'ONE_OF_RANGE':\n return {\n type: 'ONE_OF_RANGE',\n values: [{ userEnteredValue: `=${rule.sourceRange}` }],\n };\n case 'NUMBER_GREATER':\n return {\n type: 'NUMBER_GREATER',\n values: [{ userEnteredValue: String(rule.values[0]) }],\n };\n case 'NUMBER_LESS':\n return {\n type: 'NUMBER_LESS',\n values: [{ userEnteredValue: String(rule.values[0]) }],\n };\n case 'NUMBER_BETWEEN':\n return {\n type: 'NUMBER_BETWEEN',\n values: [{ userEnteredValue: String(rule.values[0]) }, { userEnteredValue: String(rule.values[1]) }],\n };\n case 'TEXT_CONTAINS':\n return {\n type: 'TEXT_CONTAINS',\n values: rule.values ? [{ userEnteredValue: rule.values[0] }] : [],\n };\n case 'TEXT_IS_EMAIL':\n return {\n type: 'TEXT_IS_EMAIL',\n values: [],\n };\n case 'TEXT_IS_URL':\n return {\n type: 'TEXT_IS_URL',\n values: [],\n };\n case 'DATE_AFTER':\n return {\n type: 'DATE_AFTER',\n values: [{ userEnteredValue: rule.values[0] }],\n };\n case 'DATE_BEFORE':\n return {\n type: 'DATE_BEFORE',\n values: [{ userEnteredValue: rule.values[0] }],\n };\n case 'DATE_BETWEEN':\n return {\n type: 'DATE_BETWEEN',\n values: [{ userEnteredValue: rule.values[0] }, { userEnteredValue: rule.values[1] }],\n };\n case 'CUSTOM_FORMULA':\n return {\n type: 'CUSTOM_FORMULA',\n values: [{ userEnteredValue: rule.formula.startsWith('=') ? rule.formula : `=${rule.formula}` }],\n };\n default:\n // Exhaustive check - all valid conditionType values should be handled above\n throw new Error(`Unknown condition type: ${(rule as { conditionType: string }).conditionType}`);\n }\n}\n\nasync function handler({ id, gid, requests }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.validation.set called', {\n id,\n gid,\n requestCount: requests.length,\n });\n\n try {\n const sheets = sheetsApi({ version: 'v4', auth: googleAuth(extra.authContext.auth) });\n\n // Get spreadsheet and sheet info in single API call\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'sheets.properties.sheetId,sheets.properties.title',\n });\n\n // Find sheet by gid\n const sheet = spreadsheetResponse.data.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n logger.info('Sheet not found for validation set', { id, gid, requestCount: requests.length });\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n const sheetTitle = sheet.properties.title ?? gid;\n const sheetId = sheet.properties.sheetId;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetId}`;\n\n // Validate sheetId exists\n if (sheetId === undefined || sheetId === null) {\n logger.error('Sheet ID not available for validation set', { id, gid, sheetTitle });\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Sheet ID not available for ${gid}. Cannot perform validation operations without valid sheet ID.`);\n }\n\n // Build batch update requests\n const batchRequests: sheets_v4.Schema$Request[] = [];\n const failedRanges: Array<{ range: string; error: string }> = [];\n\n for (const request of requests) {\n try {\n // Parse A1 notation to range reference\n const rangeRef = parseA1Notation(request.range);\n\n // Build grid range from range reference using helper function\n const gridRange = rangeReferenceToGridRange(rangeRef, sheetId);\n\n // Build validation rule\n const condition = buildCondition(request.rule);\n\n // Build data validation rule - structure matches Schema$DataValidationRule\n const dataValidationRule = {\n condition,\n strict: request.rule.strict,\n showCustomUi: 'showDropdown' in request.rule ? request.rule.showDropdown : undefined,\n inputMessage: request.inputMessage,\n } as sheets_v4.Schema$DataValidationRule;\n\n // Add setDataValidation request\n batchRequests.push({\n setDataValidation: {\n range: gridRange,\n rule: dataValidationRule,\n },\n });\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.info('Failed to build validation rule', {\n range: request.range,\n error: message,\n });\n failedRanges.push({\n range: request.range,\n error: `Failed to build validation rule: ${message}`,\n });\n }\n }\n\n // Early return if all ranges failed\n if (batchRequests.length === 0) {\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetId),\n sheetTitle,\n sheetUrl,\n successCount: 0,\n failedRanges: failedRanges.length > 0 ? failedRanges : undefined,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n }\n\n logger.info('sheets.validation.set executing batch request', {\n spreadsheetId: id,\n sheetTitle,\n batchRequestsCount: batchRequests.length,\n });\n\n // Execute the batch update\n await sheets.spreadsheets.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n requests: batchRequests,\n },\n });\n\n logger.info('sheets.validation.set completed successfully', {\n successCount: requests.length - failedRanges.length,\n failedCount: failedRanges.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetId),\n sheetTitle,\n sheetUrl,\n successCount: requests.length - failedRanges.length,\n failedRanges: failedRanges.length > 0 ? failedRanges : undefined,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('Validation set operation failed', {\n id,\n gid,\n requestCount: requests.length,\n error: message,\n });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error setting validation: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'validation-set',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","ValidationRuleSchema","z","discriminatedUnion","object","conditionType","literal","values","array","string","min","describe","showDropdown","boolean","default","strict","sourceRange","enum","number","max","optional","formula","ValidationRequestSchema","range","rule","inputMessage","inputSchema","id","SpreadsheetIdSchema","gid","SheetGidSchema","requests","successBranchSchema","type","SpreadsheetIdOutput","SheetGidOutput","sheetTitle","sheetUrl","successCount","int","nonnegative","failedRanges","error","outputSchema","config","description","result","buildCondition","map","value","userEnteredValue","String","startsWith","Error","handler","extra","logger","sheet","spreadsheetResponse","sheets","sheetId","batchRequests","request","rangeRef","gridRange","condition","dataValidationRule","message","info","requestCount","length","sheetsApi","version","auth","googleAuth","authContext","spreadsheets","get","spreadsheetId","fields","data","find","s","properties","ProtocolError","ProtocolErrorCode","InvalidParams","title","undefined","InternalError","parseA1Notation","rangeReferenceToGridRange","showCustomUi","push","setDataValidation","content","text","JSON","stringify","structuredContent","batchRequestsCount","batchUpdate","requestBody","failedCount","stack","name"],"mappings":";;;;+BAuTA;;;eAAwBA;;;sBAvT4B;2BAE5B;sBAKyB;mBAC/B;4BACS;uBAC8D;iCAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAP3D,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AASR,gDAAgD;AAChD,IAAME,uBAAuBC,MAAC,CAACC,kBAAkB,CAAC,iBAAiB;IACjE,+BAA+B;IAC/BD,MAAC,CAACE,MAAM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ACAE,KAAAA;wBACAwC,cAActC,SAASuC,MAAM;wBAC7B5B,OAAOyB;oBACT;oBAEA,MAAM,IAAIiB,qBAAa,CAACC,yBAAiB,CAACI,aAAa,EAAE,AAAC,6BAAoC,OAARtB,WAAW;wBAC/FqC,OAAO9D,AAAK,YAALA,OAAiBW,SAAQX,MAAM8D,KAAK,GAAGhB;oBAChD;;;;;;;IAEJ;;AAEe,SAAS1F;IACtB,OAAO;QACL2G,MAAM;QACN7D,QAAAA;QACAU,SAAAA;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
-
import type { CallToolResult } from '@
|
|
2
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
-
import type { CallToolResult } from '@
|
|
2
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodString;
|
|
@@ -8,10 +8,11 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return createTool;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
var _sheets = require("@googleapis/sheets");
|
|
11
12
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
13
|
-
var _googleapis = require("googleapis");
|
|
13
|
+
var _server = require("@mcp-z/server");
|
|
14
14
|
var _zod = require("zod");
|
|
15
|
+
var _googleauthts = require("../../lib/google-auth.js");
|
|
15
16
|
var _indexts = require("../../schemas/index.js");
|
|
16
17
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
18
|
try {
|
|
@@ -219,9 +220,9 @@ function handler(_0, _1) {
|
|
|
219
220
|
,
|
|
220
221
|
5
|
|
221
222
|
]);
|
|
222
|
-
sheets =
|
|
223
|
+
sheets = (0, _sheets.sheets)({
|
|
223
224
|
version: 'v4',
|
|
224
|
-
auth: extra.authContext.auth
|
|
225
|
+
auth: (0, _googleauthts.googleAuth)(extra.authContext.auth)
|
|
225
226
|
});
|
|
226
227
|
return [
|
|
227
228
|
4,
|
|
@@ -246,7 +247,7 @@ function handler(_0, _1) {
|
|
|
246
247
|
gid: gid,
|
|
247
248
|
requestCount: requests.length
|
|
248
249
|
});
|
|
249
|
-
throw new
|
|
250
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, "Sheet not found: ".concat(gid));
|
|
250
251
|
}
|
|
251
252
|
sheetTitle = (_sheet_properties_title = sheet.properties.title) !== null && _sheet_properties_title !== void 0 ? _sheet_properties_title : gid;
|
|
252
253
|
sheetGid = (_sheet_properties_sheetId = sheet.properties.sheetId) !== null && _sheet_properties_sheetId !== void 0 ? _sheet_properties_sheetId : 0;
|
|
@@ -291,7 +292,7 @@ function handler(_0, _1) {
|
|
|
291
292
|
spreadsheetId: id,
|
|
292
293
|
sheetTitle: sheetTitle
|
|
293
294
|
});
|
|
294
|
-
throw new
|
|
295
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Batch operation partially failed: ".concat(actualCount, "/").concat(expectedCount, " operations completed"));
|
|
295
296
|
}
|
|
296
297
|
// Check for any failed operations (empty or null responses)
|
|
297
298
|
failedOperations = responses.filter(function(response, index) {
|
|
@@ -308,7 +309,7 @@ function handler(_0, _1) {
|
|
|
308
309
|
return false;
|
|
309
310
|
});
|
|
310
311
|
if (failedOperations.length > 0) {
|
|
311
|
-
throw new
|
|
312
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "".concat(failedOperations.length, " operations failed to update ranges"));
|
|
312
313
|
}
|
|
313
314
|
// Extract updated ranges and calculate totals
|
|
314
315
|
updatedRanges = responses.map(function(response) {
|
|
@@ -384,7 +385,7 @@ function handler(_0, _1) {
|
|
|
384
385
|
valueInputOption: valueInputOption,
|
|
385
386
|
error: message
|
|
386
387
|
});
|
|
387
|
-
throw new
|
|
388
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error batch updating values: ".concat(message), {
|
|
388
389
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
389
390
|
});
|
|
390
391
|
case 5:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-batch-update.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\nimport { A1NotationSchema, SheetCellSchema, SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\n// Types for updated data response\ninterface UpdatedDataItem {\n range: string;\n majorDimension: 'ROWS' | 'COLUMNS';\n values?: (string | number | boolean | null)[][];\n}\n\n// Input schema for values batch update requests\nconst ValuesBatchUpdateRequestSchema = z.object({\n range: A1NotationSchema.describe('A1 notation range defining the bounded target area. Data dimensions must match range dimensions. Example: D1:D100 requires exactly 100 rows of data. Use open-ended ranges like D1:D to write any number of rows.'),\n values: z.array(z.array(SheetCellSchema)).min(1).describe('2D array of values. Row count must match range height, column count must match range width. Use null to skip a cell (preserve existing value), empty string \"\" to clear it.'),\n majorDimension: z.enum(['ROWS', 'COLUMNS']).describe('Whether values represent rows or columns'),\n});\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n requests: z.array(ValuesBatchUpdateRequestSchema).min(1).describe('Array of value update requests'),\n valueInputOption: z.enum(['RAW', 'USER_ENTERED']).describe('How input data should be interpreted (RAW = exact values, USER_ENTERED = parsed like user input)'),\n includeData: z.boolean().describe('Whether to include updated cell values in the response'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n spreadsheetTitle: z.string().describe('Title of the updated spreadsheet'),\n spreadsheetUrl: z.string().describe('URL of the updated spreadsheet'),\n sheetTitle: z.string().describe('Title of the updated sheet'),\n sheetUrl: z.string().describe('URL of the updated sheet'),\n totalUpdatedRows: z.number().int().nonnegative().describe('Total number of rows updated across all requests'),\n totalUpdatedColumns: z.number().int().nonnegative().describe('Total number of columns updated across all requests'),\n totalUpdatedCells: z.number().int().nonnegative().describe('Total number of cells updated across all requests'),\n updatedRanges: z.array(z.string()).describe('A1 notation ranges that were updated'),\n updatedData: z\n .array(\n z.object({\n range: z.string().describe('A1 notation range that was updated'),\n majorDimension: z.enum(['ROWS', 'COLUMNS']).describe('Dimension of the updated data'),\n values: z.array(z.array(SheetCellSchema)).optional().describe('Updated values (if includeData was true)'),\n })\n )\n .optional()\n .describe('Detailed information about updated data (if includeData was true)'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Batch update multiple cell ranges. RAW=exact values, USER_ENTERED=parsed like user input. Use a1-notation prompt for range syntax. For multiple clickable links or rich text inside a single cell, use values-markdown-update.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, gid, requests, valueInputOption = 'USER_ENTERED', includeData = false }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values.batchUpdate called', {\n id,\n gid,\n requestCount: requests.length,\n valueInputOption,\n includeData,\n });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // Get spreadsheet and sheet info in single API call\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'properties.title,spreadsheetUrl,sheets.properties.sheetId,sheets.properties.title',\n });\n\n const spreadsheetData = spreadsheetResponse.data;\n const spreadsheetTitle = spreadsheetData.properties?.title ?? '';\n const spreadsheetUrl = spreadsheetData.spreadsheetUrl ?? '';\n\n // Find sheet by gid\n const sheet = spreadsheetData.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n logger.info('Sheet not found for batch update', { id, gid, requestCount: requests.length });\n throw new McpError(ErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n const sheetTitle = sheet.properties.title ?? gid;\n const sheetGid = sheet.properties.sheetId ?? 0;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetGid}`;\n\n // Build batch update request with prefixed ranges\n const batchUpdateData = requests.map((req) => ({\n range: `${sheetTitle}!${req.range}`,\n values: req.values,\n majorDimension: req.majorDimension || 'ROWS',\n }));\n\n logger.info('sheets.values.batchUpdate executing batch request', {\n spreadsheetId: id,\n sheetTitle,\n batchUpdateDataCount: batchUpdateData.length,\n });\n\n // Execute the batch update\n const batchUpdateResponse = await sheets.spreadsheets.values.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n valueInputOption,\n data: batchUpdateData,\n includeValuesInResponse: includeData,\n responseDateTimeRenderOption: 'FORMATTED_STRING',\n responseValueRenderOption: 'FORMATTED_VALUE',\n },\n });\n\n const updateResult = batchUpdateResponse.data;\n\n // Validate batch operation results and detect partial failures\n const responses = updateResult.responses || [];\n const expectedCount = requests.length;\n const actualCount = responses.length;\n\n if (actualCount !== expectedCount) {\n logger.error('Partial batch failure detected', {\n expectedOperations: expectedCount,\n completedOperations: actualCount,\n spreadsheetId: id,\n sheetTitle,\n });\n\n throw new McpError(ErrorCode.InternalError, `Batch operation partially failed: ${actualCount}/${expectedCount} operations completed`);\n }\n\n // Check for any failed operations (empty or null responses)\n const failedOperations = responses.filter((response, index) => {\n if (!response || !response.updatedRange) {\n logger.error('Failed operation detected', {\n operationIndex: index,\n requestedRange: requests[index]?.range,\n spreadsheetId: id,\n sheetTitle,\n });\n return true;\n }\n return false;\n });\n\n if (failedOperations.length > 0) {\n throw new McpError(ErrorCode.InternalError, `${failedOperations.length} operations failed to update ranges`);\n }\n\n // Extract updated ranges and calculate totals\n const updatedRanges = responses.map((response) => response.updatedRange || '').filter((range) => range);\n const totalUpdatedRows = updateResult.totalUpdatedRows || 0;\n const totalUpdatedColumns = updateResult.totalUpdatedColumns || 0;\n const totalUpdatedCells = updateResult.totalUpdatedCells || 0;\n\n // Build updated data response if requested\n let updatedData: UpdatedDataItem[] | undefined;\n if (includeData && updateResult.responses) {\n updatedData = updateResult.responses\n .filter((response) => response.updatedData)\n .map((response) => {\n const item: UpdatedDataItem = {\n range: response.updatedRange || '',\n majorDimension: (response.updatedData?.majorDimension as 'ROWS' | 'COLUMNS' | undefined) || 'ROWS',\n };\n const values = response.updatedData?.values as (string | number | boolean | null | undefined)[][] | undefined;\n if (values !== undefined) {\n // Map undefined values to null for JSON Schema compatibility\n item.values = values.map((row) => row.map((cell) => (cell === undefined ? null : cell)));\n }\n return item;\n });\n }\n\n logger.info('sheets.values.batchUpdate completed successfully', {\n totalUpdatedRows,\n totalUpdatedColumns,\n totalUpdatedCells,\n updatedRangesCount: updatedRanges.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetGid),\n spreadsheetTitle: spreadsheetTitle || '',\n spreadsheetUrl: spreadsheetUrl || '',\n sheetTitle,\n sheetUrl,\n totalUpdatedRows,\n totalUpdatedColumns,\n totalUpdatedCells,\n updatedRanges,\n updatedData,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('Batch update operation failed', {\n id,\n gid,\n requestCount: requests.length,\n valueInputOption,\n error: message,\n });\n\n throw new McpError(ErrorCode.InternalError, `Error batch updating values: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-batch-update',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","ValuesBatchUpdateRequestSchema","z","object","range","A1NotationSchema","describe","values","array","SheetCellSchema","min","majorDimension","enum","inputSchema","id","SpreadsheetIdSchema","gid","SheetGidSchema","requests","valueInputOption","includeData","boolean","successBranchSchema","type","literal","SpreadsheetIdOutput","SheetGidOutput","spreadsheetTitle","string","spreadsheetUrl","sheetTitle","sheetUrl","totalUpdatedRows","number","int","nonnegative","totalUpdatedColumns","totalUpdatedCells","updatedRanges","updatedData","optional","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","spreadsheetData","sheet","sheets","spreadsheetResponse","sheetGid","batchUpdateData","batchUpdateResponse","updateResult","responses","expectedCount","actualCount","failedOperations","error","message","info","requestCount","length","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","properties","title","find","s","String","sheetId","McpError","ErrorCode","InvalidParams","map","req","batchUpdateDataCount","batchUpdate","requestBody","includeValuesInResponse","responseDateTimeRenderOption","responseValueRenderOption","expectedOperations","completedOperations","InternalError","filter","response","index","updatedRange","operationIndex","requestedRange","item","undefined","row","cell","updatedRangesCount","content","text","JSON","stringify","structuredContent","Error","stack","name"],"mappings":";;;;+BAyOA;;;eAAwBA;;;2BAxOA;qBAMY;0BACb;mBACL;uBAC0G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAP5H,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAgBR,gDAAgD;AAChD,IAAME,iCAAiCC,MAAC,CAACC,MAAM,CAAC;IAC9C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AAA;wBACAI,qBAAAA;wBACAC,mBAAAA;wBACAC,eAAAA;wBACAC,aAAAA;oBACF;oBAEA;;wBAAO;4BACLmE,OAAO;gCAAG;oCAAEnF,MAAM;oCAAiBoF,MAAMC,KAAKC,SAAS,CAAChE;gCAAQ;;4BAChEiE,mBAAmB;gCAAEjE,QAAAA;4BAAO;wBAC9B;;;oBACOgB;oBACDC,UAAUD,AAAK,YAALA,OAAiBkD,SAAQlD,MAAMC,OAAO,GAAGiB,OAAOlB;oBAChEb,OAAOa,KAAK,CAAC,iCAAiC;wBAC5C/C,IAAAA;wBACAE,KAAAA;wBACAgD,cAAc9C,SAAS+C,MAAM;wBAC7B9C,kBAAAA;wBACA0C,OAAOC;oBACT;oBAEA,MAAM,IAAImB,eAAQ,CAACC,gBAAS,CAACY,aAAa,EAAE,AAAC,gCAAuC,OAARhC,UAAW;wBACrFkD,OAAOnD,AAAK,YAALA,OAAiBkD,SAAQlD,MAAMmD,KAAK,GAAGV;oBAChD;;;;;;;IAEJ;;AAEe,SAASxG;IACtB,OAAO;QACLmH,MAAM;QACNtE,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-batch-update.ts"],"sourcesContent":["import { sheets as sheetsApi } from '@googleapis/sheets';\nimport type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { CallToolResult, ToolModule } from '@mcp-z/server';\nimport { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { z } from 'zod';\nimport { googleAuth } from '../../lib/google-auth.ts';\nimport { A1NotationSchema, SheetCellSchema, SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\n// Types for updated data response\ninterface UpdatedDataItem {\n range: string;\n majorDimension: 'ROWS' | 'COLUMNS';\n values?: (string | number | boolean | null)[][];\n}\n\n// Input schema for values batch update requests\nconst ValuesBatchUpdateRequestSchema = z.object({\n range: A1NotationSchema.describe('A1 notation range defining the bounded target area. Data dimensions must match range dimensions. Example: D1:D100 requires exactly 100 rows of data. Use open-ended ranges like D1:D to write any number of rows.'),\n values: z.array(z.array(SheetCellSchema)).min(1).describe('2D array of values. Row count must match range height, column count must match range width. Use null to skip a cell (preserve existing value), empty string \"\" to clear it.'),\n majorDimension: z.enum(['ROWS', 'COLUMNS']).describe('Whether values represent rows or columns'),\n});\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n requests: z.array(ValuesBatchUpdateRequestSchema).min(1).describe('Array of value update requests'),\n valueInputOption: z.enum(['RAW', 'USER_ENTERED']).describe('How input data should be interpreted (RAW = exact values, USER_ENTERED = parsed like user input)'),\n includeData: z.boolean().describe('Whether to include updated cell values in the response'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n spreadsheetTitle: z.string().describe('Title of the updated spreadsheet'),\n spreadsheetUrl: z.string().describe('URL of the updated spreadsheet'),\n sheetTitle: z.string().describe('Title of the updated sheet'),\n sheetUrl: z.string().describe('URL of the updated sheet'),\n totalUpdatedRows: z.number().int().nonnegative().describe('Total number of rows updated across all requests'),\n totalUpdatedColumns: z.number().int().nonnegative().describe('Total number of columns updated across all requests'),\n totalUpdatedCells: z.number().int().nonnegative().describe('Total number of cells updated across all requests'),\n updatedRanges: z.array(z.string()).describe('A1 notation ranges that were updated'),\n updatedData: z\n .array(\n z.object({\n range: z.string().describe('A1 notation range that was updated'),\n majorDimension: z.enum(['ROWS', 'COLUMNS']).describe('Dimension of the updated data'),\n values: z.array(z.array(SheetCellSchema)).optional().describe('Updated values (if includeData was true)'),\n })\n )\n .optional()\n .describe('Detailed information about updated data (if includeData was true)'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Batch update multiple cell ranges. RAW=exact values, USER_ENTERED=parsed like user input. Use a1-notation prompt for range syntax. For multiple clickable links or rich text inside a single cell, use values-markdown-update.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, gid, requests, valueInputOption = 'USER_ENTERED', includeData = false }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values.batchUpdate called', {\n id,\n gid,\n requestCount: requests.length,\n valueInputOption,\n includeData,\n });\n\n try {\n const sheets = sheetsApi({ version: 'v4', auth: googleAuth(extra.authContext.auth) });\n\n // Get spreadsheet and sheet info in single API call\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'properties.title,spreadsheetUrl,sheets.properties.sheetId,sheets.properties.title',\n });\n\n const spreadsheetData = spreadsheetResponse.data;\n const spreadsheetTitle = spreadsheetData.properties?.title ?? '';\n const spreadsheetUrl = spreadsheetData.spreadsheetUrl ?? '';\n\n // Find sheet by gid\n const sheet = spreadsheetData.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n logger.info('Sheet not found for batch update', { id, gid, requestCount: requests.length });\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n const sheetTitle = sheet.properties.title ?? gid;\n const sheetGid = sheet.properties.sheetId ?? 0;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetGid}`;\n\n // Build batch update request with prefixed ranges\n const batchUpdateData = requests.map((req) => ({\n range: `${sheetTitle}!${req.range}`,\n values: req.values,\n majorDimension: req.majorDimension || 'ROWS',\n }));\n\n logger.info('sheets.values.batchUpdate executing batch request', {\n spreadsheetId: id,\n sheetTitle,\n batchUpdateDataCount: batchUpdateData.length,\n });\n\n // Execute the batch update\n const batchUpdateResponse = await sheets.spreadsheets.values.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n valueInputOption,\n data: batchUpdateData,\n includeValuesInResponse: includeData,\n responseDateTimeRenderOption: 'FORMATTED_STRING',\n responseValueRenderOption: 'FORMATTED_VALUE',\n },\n });\n\n const updateResult = batchUpdateResponse.data;\n\n // Validate batch operation results and detect partial failures\n const responses = updateResult.responses || [];\n const expectedCount = requests.length;\n const actualCount = responses.length;\n\n if (actualCount !== expectedCount) {\n logger.error('Partial batch failure detected', {\n expectedOperations: expectedCount,\n completedOperations: actualCount,\n spreadsheetId: id,\n sheetTitle,\n });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Batch operation partially failed: ${actualCount}/${expectedCount} operations completed`);\n }\n\n // Check for any failed operations (empty or null responses)\n const failedOperations = responses.filter((response, index) => {\n if (!response || !response.updatedRange) {\n logger.error('Failed operation detected', {\n operationIndex: index,\n requestedRange: requests[index]?.range,\n spreadsheetId: id,\n sheetTitle,\n });\n return true;\n }\n return false;\n });\n\n if (failedOperations.length > 0) {\n throw new ProtocolError(ProtocolErrorCode.InternalError, `${failedOperations.length} operations failed to update ranges`);\n }\n\n // Extract updated ranges and calculate totals\n const updatedRanges = responses.map((response) => response.updatedRange || '').filter((range) => range);\n const totalUpdatedRows = updateResult.totalUpdatedRows || 0;\n const totalUpdatedColumns = updateResult.totalUpdatedColumns || 0;\n const totalUpdatedCells = updateResult.totalUpdatedCells || 0;\n\n // Build updated data response if requested\n let updatedData: UpdatedDataItem[] | undefined;\n if (includeData && updateResult.responses) {\n updatedData = updateResult.responses\n .filter((response) => response.updatedData)\n .map((response) => {\n const item: UpdatedDataItem = {\n range: response.updatedRange || '',\n majorDimension: (response.updatedData?.majorDimension as 'ROWS' | 'COLUMNS' | undefined) || 'ROWS',\n };\n const values = response.updatedData?.values as (string | number | boolean | null | undefined)[][] | undefined;\n if (values !== undefined) {\n // Map undefined values to null for JSON Schema compatibility\n item.values = values.map((row) => row.map((cell) => (cell === undefined ? null : cell)));\n }\n return item;\n });\n }\n\n logger.info('sheets.values.batchUpdate completed successfully', {\n totalUpdatedRows,\n totalUpdatedColumns,\n totalUpdatedCells,\n updatedRangesCount: updatedRanges.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetGid),\n spreadsheetTitle: spreadsheetTitle || '',\n spreadsheetUrl: spreadsheetUrl || '',\n sheetTitle,\n sheetUrl,\n totalUpdatedRows,\n totalUpdatedColumns,\n totalUpdatedCells,\n updatedRanges,\n updatedData,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('Batch update operation failed', {\n id,\n gid,\n requestCount: requests.length,\n valueInputOption,\n error: message,\n });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error batch updating values: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-batch-update',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","ValuesBatchUpdateRequestSchema","z","object","range","A1NotationSchema","describe","values","array","SheetCellSchema","min","majorDimension","enum","inputSchema","id","SpreadsheetIdSchema","gid","SheetGidSchema","requests","valueInputOption","includeData","boolean","successBranchSchema","type","literal","SpreadsheetIdOutput","SheetGidOutput","spreadsheetTitle","string","spreadsheetUrl","sheetTitle","sheetUrl","totalUpdatedRows","number","int","nonnegative","totalUpdatedColumns","totalUpdatedCells","updatedRanges","updatedData","optional","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","spreadsheetData","sheet","sheets","spreadsheetResponse","sheetGid","batchUpdateData","batchUpdateResponse","updateResult","responses","expectedCount","actualCount","failedOperations","error","message","info","requestCount","length","sheetsApi","version","auth","googleAuth","authContext","spreadsheets","get","spreadsheetId","fields","data","properties","title","find","s","String","sheetId","ProtocolError","ProtocolErrorCode","InvalidParams","map","req","batchUpdateDataCount","batchUpdate","requestBody","includeValuesInResponse","responseDateTimeRenderOption","responseValueRenderOption","expectedOperations","completedOperations","InternalError","filter","response","index","updatedRange","operationIndex","requestedRange","item","undefined","row","cell","updatedRangesCount","content","text","JSON","stringify","structuredContent","Error","stack","name"],"mappings":";;;;+BAyOA;;;eAAwBA;;;sBAzOY;2BAEZ;sBAKyB;mBAC/B;4BACS;uBACiG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAN5H,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAeR,gDAAgD;AAChD,IAAME,iCAAiCC,MAAC,CAACC,MAAM,CAAC;IAC9CC,OAAOC,yBAAgB,CAACC,QAAQ,CAAC;IACjCC,QAAQL,MAAC,CAACM,KAAK,CAACN,MAAC,CAACM,KAAK,CAACC,wBAAe,GAAGC,GAAG,CAAC,GAAGJ,QAAQ,CAAC;IAC1DK,gBAAgBT,MAAC,CAACU,IAAI,CAAC;QAAC;QAAQ;KAAU,EAAEN,QAAQ,CAAC;AACvD;AAEA,IAAMO,cAAcX,MAAC,CAACC,MAAM,CAAC;IAC3BW,IAAIC,4BAAmB;IACvBC,KAAKC,uBAAc;IACnBC,UAAUhB,MAAC,CAACM,KAAK,CAACP,gCAAgCS,GAAG,CAAC,GAAGJ,QAAQ,CAAC;IAClEa,kBAAkBjB,MAAC,CAACU,IAAI,CAAC;QAAC;QAAO;KAAe,EAAEN,QAAQ,CAAC;IAC3Dc,aAAalB,MAAC,CAACmB,OAAO,GAAGf,QAAQ,CAAC;AACpC;AAEA,IAAMgB,sBAAsBpB,MAAC,CAACC,MAAM,CAAC;IACnCoB,MAAMrB,MAAC,CAACsB,OAAO,CAAC;IAChBV,IAAIW,4BAAmB;IACvBT,KAAKU,uBAAc;IACnBC,kBAAkBzB,MAAC,CAAC0B,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A;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
-
import type { CallToolResult } from '@
|
|
2
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
-
import type { CallToolResult } from '@
|
|
2
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodString;
|
|
@@ -8,10 +8,11 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return createTool;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
var _sheets = require("@googleapis/sheets");
|
|
11
12
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
13
|
-
var _googleapis = require("googleapis");
|
|
13
|
+
var _server = require("@mcp-z/server");
|
|
14
14
|
var _zod = require("zod");
|
|
15
|
+
var _googleauthts = require("../../lib/google-auth.js");
|
|
15
16
|
var _indexts = require("../../schemas/index.js");
|
|
16
17
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
17
18
|
try {
|
|
@@ -192,9 +193,9 @@ function handler(_0, _1) {
|
|
|
192
193
|
,
|
|
193
194
|
5
|
|
194
195
|
]);
|
|
195
|
-
sheets =
|
|
196
|
+
sheets = (0, _sheets.sheets)({
|
|
196
197
|
version: 'v4',
|
|
197
|
-
auth: extra.authContext.auth
|
|
198
|
+
auth: (0, _googleauthts.googleAuth)(extra.authContext.auth)
|
|
198
199
|
});
|
|
199
200
|
return [
|
|
200
201
|
4,
|
|
@@ -219,7 +220,7 @@ function handler(_0, _1) {
|
|
|
219
220
|
gid: gid,
|
|
220
221
|
rangeCount: ranges.length
|
|
221
222
|
});
|
|
222
|
-
throw new
|
|
223
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, "Sheet not found: ".concat(gid));
|
|
223
224
|
}
|
|
224
225
|
sheetTitle = (_sheet_properties_title = sheet.properties.title) !== null && _sheet_properties_title !== void 0 ? _sheet_properties_title : gid;
|
|
225
226
|
sheetGid = (_sheet_properties_sheetId = sheet.properties.sheetId) !== null && _sheet_properties_sheetId !== void 0 ? _sheet_properties_sheetId : 0;
|
|
@@ -283,7 +284,7 @@ function handler(_0, _1) {
|
|
|
283
284
|
rangeCount: ranges.length,
|
|
284
285
|
error: message
|
|
285
286
|
});
|
|
286
|
-
throw new
|
|
287
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error clearing values: ".concat(message), {
|
|
287
288
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
288
289
|
});
|
|
289
290
|
case 5:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-clear.ts"],"sourcesContent":["import type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-clear.ts"],"sourcesContent":["import { sheets as sheetsApi } from '@googleapis/sheets';\nimport type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { CallToolResult, ToolModule } from '@mcp-z/server';\nimport { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { z } from 'zod';\nimport { googleAuth } from '../../lib/google-auth.ts';\nimport { A1NotationSchema, SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n ranges: z.array(A1NotationSchema).min(1).describe('A1 notation ranges to clear (e.g., [\"A1:B5\", \"D3:D10\"]). Clears values only, preserves formatting.'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n spreadsheetTitle: z.string().describe('Title of the spreadsheet'),\n spreadsheetUrl: z.string().describe('URL of the spreadsheet'),\n sheetTitle: z.string().describe('Title of the sheet'),\n sheetUrl: z.string().describe('URL of the sheet'),\n clearedRanges: z.array(z.string()).describe('A1 notation ranges that were cleared'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Clear cell values from one or more ranges. Clears values only - preserves formatting, validation, and other cell properties. Use a1-notation prompt for range syntax.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, gid, ranges }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values.clear called', { id, gid, rangeCount: ranges.length });\n\n try {\n const sheets = sheetsApi({ version: 'v4', auth: googleAuth(extra.authContext.auth) });\n\n // Get spreadsheet and sheet info in single API call\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'properties.title,spreadsheetUrl,sheets.properties.sheetId,sheets.properties.title',\n });\n\n const spreadsheetData = spreadsheetResponse.data;\n const spreadsheetTitle = spreadsheetData.properties?.title ?? '';\n const spreadsheetUrl = spreadsheetData.spreadsheetUrl ?? '';\n\n // Find sheet by gid\n const sheet = spreadsheetData.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n logger.info('Sheet not found for clear', { id, gid, rangeCount: ranges.length });\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n const sheetTitle = sheet.properties.title ?? gid;\n const sheetGid = sheet.properties.sheetId ?? 0;\n const sheetUrl = `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheetGid}`;\n\n // Prefix ranges with sheet title\n const prefixedRanges = ranges.map((range) => `${sheetTitle}!${range}`);\n\n logger.info('sheets.values.clear executing', { spreadsheetId: id, sheetTitle, prefixedRanges });\n\n // Use batchClear for efficiency (works for single or multiple ranges)\n const clearResponse = await sheets.spreadsheets.values.batchClear({\n spreadsheetId: id,\n requestBody: {\n ranges: prefixedRanges,\n },\n });\n\n const clearedRanges = clearResponse.data.clearedRanges || [];\n\n logger.info('sheets.values.clear completed successfully', {\n spreadsheetId: id,\n sheetTitle,\n clearedRangesCount: clearedRanges.length,\n });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheetGid),\n spreadsheetTitle: spreadsheetTitle || '',\n spreadsheetUrl: spreadsheetUrl || '',\n sheetTitle,\n sheetUrl,\n clearedRanges,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('Clear operation failed', { id, gid, rangeCount: ranges.length, error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error clearing values: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-clear',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","inputSchema","z","object","id","SpreadsheetIdSchema","gid","SheetGidSchema","ranges","array","A1NotationSchema","min","describe","successBranchSchema","type","literal","SpreadsheetIdOutput","SheetGidOutput","spreadsheetTitle","string","spreadsheetUrl","sheetTitle","sheetUrl","clearedRanges","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","spreadsheetData","sheet","sheets","spreadsheetResponse","sheetGid","prefixedRanges","clearResponse","error","message","info","rangeCount","length","sheetsApi","version","auth","googleAuth","authContext","spreadsheets","get","spreadsheetId","fields","data","properties","title","find","s","String","sheetId","ProtocolError","ProtocolErrorCode","InvalidParams","map","range","values","batchClear","requestBody","clearedRangesCount","content","text","JSON","stringify","structuredContent","Error","InternalError","stack","undefined","name"],"mappings":";;;;+BAoHA;;;eAAwBA;;;sBApHY;2BAEZ;sBAKyB;mBAC/B;4BACS;uBACgF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAN3G,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAQR,IAAME,cAAcC,MAAC,CAACC,MAAM,CAAC;IAC3BC,IAAIC,4BAAmB;IACvBC,KAAKC,uBAAc;IACnBC,QAAQN,MAAC,CAACO,KAAK,CAACC,yBAAgB,EAAEC,GAAG,CAAC,GAAGC,QAAQ,CAAC;AACpD;AAEA,IAAMC,sBAAsBX,MAAC,CAACC,MAAM,CAAC;IACnCW,MAAMZ,MAAC,CAACa,OAAO,CAAC;IAChBX,IAAIY,4BAAmB;IACvBV,KAAKW,uBAAc;IACnBC,kBAAkBhB,MAAC,CAACiB,MAAM,GAAGP,QAAQ,CAAC;IACtCQ,gBAAgBlB,MAAC,CAACiB,MAAM,GAAGP,QAAQ,CAAC;IACpCS,YAAYnB,MAAC,CAACiB,MAAM,GAAGP,QAAQ,CAAC;IAChCU,UAAUpB,MAAC,CAACiB,MAAM,GAAGP,QAAQ,CAAC;IAC9BW,eAAerB,MAAC,CAACO,KAAK,CAACP,MAAC,CAACiB,MAAM,IAAIP,QAAQ,CAAC;AAC9C;AAEA,IAAMY,eAAetB,MAAC,CAACuB,kBAAkB,CAAC,QAAQ;IAACZ;IAAqBd;CAAyB;AAEjG,IAAM2B,SAAS;IACb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ACDC,UAAUD,AAAK,YAALA,OAAiBmC,SAAQnC,MAAMC,OAAO,GAAGkB,OAAOnB;oBAChER,OAAOQ,KAAK,CAAC,0BAA0B;wBAAEnC,IAAAA;wBAAIE,KAAAA;wBAAKoC,YAAYlC,OAAOmC,MAAM;wBAAEJ,OAAOC;oBAAQ;oBAE5F,MAAM,IAAIoB,qBAAa,CAACC,yBAAiB,CAACc,aAAa,EAAE,AAAC,0BAAiC,OAARnC,UAAW;wBAC5FoC,OAAOrC,AAAK,YAALA,OAAiBmC,SAAQnC,MAAMqC,KAAK,GAAGC;oBAChD;;;;;;;IAEJ;;AAEe,SAAS/E;IACtB,OAAO;QACLgF,MAAM;QACNpD,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Import CSV data to Google Sheets with range-based update (no deduplication) */
|
|
2
2
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
3
|
-
import type { CallToolResult } from '@
|
|
3
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
declare const inputSchema: z.ZodObject<{
|
|
6
6
|
id: z.ZodString;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Import CSV data to Google Sheets with range-based update (no deduplication) */
|
|
2
2
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
3
|
-
import type { CallToolResult } from '@
|
|
3
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
declare const inputSchema: z.ZodObject<{
|
|
6
6
|
id: z.ZodString;
|
|
@@ -8,11 +8,12 @@ Object.defineProperty(exports, "default", {
|
|
|
8
8
|
return createTool;
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
|
+
var _sheets = require("@googleapis/sheets");
|
|
11
12
|
var _oauthgoogle = require("@mcp-z/oauth-google");
|
|
12
|
-
var
|
|
13
|
+
var _server = require("@mcp-z/server");
|
|
13
14
|
var _csvparse = require("csv-parse");
|
|
14
|
-
var _googleapis = require("googleapis");
|
|
15
15
|
var _zod = require("zod");
|
|
16
|
+
var _googleauthts = require("../../lib/google-auth.js");
|
|
16
17
|
var _indexts = require("../../schemas/index.js");
|
|
17
18
|
var _csvstreamingts = require("../../spreadsheet/csv-streaming.js");
|
|
18
19
|
function _async_iterator(iterable) {
|
|
@@ -248,9 +249,9 @@ function handler(_0, _1) {
|
|
|
248
249
|
,
|
|
249
250
|
18
|
|
250
251
|
]);
|
|
251
|
-
sheets =
|
|
252
|
+
sheets = (0, _sheets.sheets)({
|
|
252
253
|
version: 'v4',
|
|
253
|
-
auth: extra.authContext.auth
|
|
254
|
+
auth: (0, _googleauthts.googleAuth)(extra.authContext.auth)
|
|
254
255
|
});
|
|
255
256
|
return [
|
|
256
257
|
4,
|
|
@@ -268,7 +269,7 @@ function handler(_0, _1) {
|
|
|
268
269
|
return String((_s_properties = s.properties) === null || _s_properties === void 0 ? void 0 : _s_properties.sheetId) === gid;
|
|
269
270
|
});
|
|
270
271
|
if (!(sheet === null || sheet === void 0 ? void 0 : sheet.properties)) {
|
|
271
|
-
throw new
|
|
272
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, "Sheet not found: ".concat(gid));
|
|
272
273
|
}
|
|
273
274
|
sheetTitle = (_sheet_properties_title = sheet.properties.title) !== null && _sheet_properties_title !== void 0 ? _sheet_properties_title : '';
|
|
274
275
|
// Streaming CSV processing state
|
|
@@ -396,7 +397,7 @@ function handler(_0, _1) {
|
|
|
396
397
|
];
|
|
397
398
|
case 15:
|
|
398
399
|
if (allRows.length === 0) {
|
|
399
|
-
throw new
|
|
400
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InvalidParams, 'CSV file is empty');
|
|
400
401
|
}
|
|
401
402
|
// Prepare data for update (all rows)
|
|
402
403
|
dataToWrite = allRows;
|
|
@@ -475,7 +476,7 @@ function handler(_0, _1) {
|
|
|
475
476
|
logger.error('sheets.values.csv-update error', {
|
|
476
477
|
error: message
|
|
477
478
|
});
|
|
478
|
-
throw new
|
|
479
|
+
throw new _server.ProtocolError(_server.ProtocolErrorCode.InternalError, "Error updating values from CSV: ".concat(message), {
|
|
479
480
|
stack: _instanceof(error, Error) ? error.stack : undefined
|
|
480
481
|
});
|
|
481
482
|
case 18:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-csv-update.ts"],"sourcesContent":["/** Import CSV data to Google Sheets with range-based update (no deduplication) */\n\nimport type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { ToolModule } from '@mcp-z/server';\nimport type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';\nimport { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js';\nimport { parse } from 'csv-parse';\nimport { google } from 'googleapis';\nimport { z } from 'zod';\nimport { A1NotationSchema, SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { getCsvReadStream } from '../../spreadsheet/csv-streaming.ts';\n\n/** Batch size for Sheets API calls (1000 rows × avg 10 cols = 10K cells, well under 40K limit) */\nconst BATCH_SIZE = 1000;\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n sourceUri: z.string().trim().min(1).describe('CSV file URI (file://, http://, https://)'),\n startRange: A1NotationSchema.default('A1').describe('Top-left cell where CSV data starts (default: A1)'),\n valueInputOption: z.enum(['RAW', 'USER_ENTERED']).default('USER_ENTERED').describe('How to interpret values (RAW = exact, USER_ENTERED = parse formulas/dates)'),\n sourceHasHeaders: z.boolean().default(true).describe('First row is headers (metadata) - exclude from data range. Set to false to include first row as data.'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n spreadsheetTitle: z.string().describe('Spreadsheet title'),\n spreadsheetUrl: z.string().describe('Spreadsheet URL'),\n sheetTitle: z.string().describe('Sheet title'),\n sheetUrl: z.string().describe('Sheet URL'),\n updatedRange: z.string().describe('A1 notation range that was updated'),\n updatedRows: z.number().describe('Number of rows updated'),\n updatedColumns: z.number().describe('Number of columns updated'),\n updatedCells: z.number().describe('Number of cells updated'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Import CSV to sheet range. Overwrites existing data at startRange. Use rows-csv-append for database-style appends with deduplication.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, gid, sourceUri, startRange, valueInputOption = 'USER_ENTERED', sourceHasHeaders }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values.csv-update called', { id, gid, sourceUri, startRange, valueInputOption, sourceHasHeaders });\n\n try {\n const sheets = google.sheets({ version: 'v4', auth: extra.authContext.auth });\n\n // Get spreadsheet and sheet info in single API call\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'properties.title,spreadsheetUrl,sheets.properties.sheetId,sheets.properties.title',\n });\n\n const spreadsheetData = spreadsheetResponse.data;\n\n // Find the sheet by gid\n const sheet = spreadsheetData.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n throw new McpError(ErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n const sheetTitle = sheet.properties.title ?? '';\n\n // Streaming CSV processing state\n let sourceHeaders: string[] = [];\n const allRows: (string | number | boolean | null)[][] = [];\n let totalCols = 0;\n\n // Get readable stream from CSV URI (no temp files!)\n const readStream = await getCsvReadStream(sourceUri);\n\n // Create CSV parser with native streaming\n const parser = readStream.pipe(\n parse({\n columns: !!sourceHasHeaders, // Parse first row as column names if source has headers\n skip_empty_lines: true,\n trim: true,\n cast: true, // Auto-convert numbers/booleans\n relax_column_count: true,\n })\n );\n\n // Stream and collect all rows (with batching for very large files)\n for await (const record of parser) {\n if (sourceHasHeaders) {\n // Extract source headers from first record\n if (sourceHeaders.length === 0) {\n sourceHeaders = Object.keys(record as Record<string, unknown>);\n totalCols = sourceHeaders.length;\n logger.info('sheets.values.csv-update source headers', { sourceHeaders, totalCols });\n }\n\n // Convert record to row array (exclude source headers from data range)\n // CSV values are strings/numbers/booleans/nulls from the parser\n const row = sourceHeaders.map((header) => (record as Record<string, string | number | boolean | null>)[header] ?? null);\n allRows.push(row);\n } else {\n // sourceHasHeaders=false: record is an array, include all rows (including first row)\n const row = record as (string | number | boolean | null)[];\n allRows.push(row);\n\n if (totalCols === 0) {\n totalCols = row.length;\n }\n }\n }\n\n if (allRows.length === 0) {\n throw new McpError(ErrorCode.InvalidParams, 'CSV file is empty');\n }\n\n // Prepare data for update (all rows)\n const dataToWrite: (string | number | boolean | null)[][] = allRows;\n\n // For large datasets, use batchUpdate to write in chunks\n // This respects the 40K cell limit per request\n const batchRequests = [];\n const currentRow = startRange.match(/[A-Z]+(\\d+)/)?.[1] || '1';\n let currentRowNum = Number.parseInt(currentRow, 10);\n\n for (let i = 0; i < dataToWrite.length; i += BATCH_SIZE) {\n const batchData = dataToWrite.slice(i, i + BATCH_SIZE);\n const batchRange = `${sheetTitle}!${startRange.match(/[A-Z]+/)?.[0]}${currentRowNum}`;\n\n batchRequests.push({\n range: batchRange,\n values: batchData,\n });\n\n currentRowNum += batchData.length;\n }\n\n logger.info('sheets.values.csv-update batching', { totalBatches: batchRequests.length, batchSize: BATCH_SIZE });\n\n // Execute batch update\n const batchUpdateResponse = await sheets.spreadsheets.values.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n valueInputOption,\n data: batchRequests,\n },\n });\n\n const totalUpdatedCells = batchUpdateResponse.data.totalUpdatedCells || 0;\n const totalUpdatedRows = batchUpdateResponse.data.totalUpdatedRows || 0;\n const totalUpdatedColumns = batchUpdateResponse.data.totalUpdatedColumns || 0;\n const firstUpdatedRange = batchUpdateResponse.data.responses?.[0]?.updatedRange || `${sheetTitle}!${startRange}`;\n\n logger.info('sheets.values.csv-update completed', { id, gid: sheet.properties.sheetId, updatedRange: firstUpdatedRange, updatedRows: totalUpdatedRows, sourceUri });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheet.properties.sheetId ?? ''),\n spreadsheetTitle: spreadsheetData.properties?.title ?? '',\n spreadsheetUrl: spreadsheetData.spreadsheetUrl ?? `https://docs.google.com/spreadsheets/d/${id}`,\n sheetTitle,\n sheetUrl: `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheet.properties.sheetId}`,\n updatedRange: firstUpdatedRange,\n updatedRows: totalUpdatedRows,\n updatedColumns: totalUpdatedColumns,\n updatedCells: totalUpdatedCells,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('sheets.values.csv-update error', { error: message });\n\n throw new McpError(ErrorCode.InternalError, `Error updating values from CSV: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-csv-update',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","BATCH_SIZE","inputSchema","z","object","id","SpreadsheetIdSchema","gid","SheetGidSchema","sourceUri","string","trim","min","describe","startRange","A1NotationSchema","default","valueInputOption","enum","sourceHasHeaders","boolean","successBranchSchema","type","literal","SpreadsheetIdOutput","SheetGidOutput","spreadsheetTitle","spreadsheetUrl","sheetTitle","sheetUrl","updatedRange","updatedRows","number","updatedColumns","updatedCells","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","sheet","spreadsheetData","batchUpdateResponse","sheets","spreadsheetResponse","sourceHeaders","allRows","totalCols","readStream","parser","dataToWrite","batchRequests","currentRow","currentRowNum","i","batchData","batchRange","totalUpdatedCells","totalUpdatedRows","totalUpdatedColumns","firstUpdatedRange","error","message","info","google","version","auth","authContext","spreadsheets","get","spreadsheetId","fields","data","find","s","String","properties","sheetId","McpError","ErrorCode","InvalidParams","title","getCsvReadStream","pipe","parse","columns","skip_empty_lines","cast","relax_column_count","record","length","Object","keys","row","map","header","push","match","Number","parseInt","slice","range","values","totalBatches","batchSize","batchUpdate","requestBody","responses","content","text","JSON","stringify","structuredContent","Error","InternalError","stack","undefined","name"],"mappings":"AAAA,gFAAgF;;;;+BAiMhF;;;eAAwBA;;;2BA9LA;qBAMY;wBACd;0BACC;mBACL;uBACyF;8BAC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AATjC,IAAM,AAAEC,2BAA6BC,oBAAO,CAApCD;AAWR,gGAAgG,GAChG,IAAME,aAAa;AAEnB,IAAMC,cAAcC,MAAC,CAACC,MAAM,CAAC;IAC3BC,IAAIC,4BAAmB;IACvBC,KAAKC,uBAAc;IACnBC,WAAWN,MAAC,CAACO,MAAM,GAAGC,IAAI,GAAGC,GAAG,CAAC,GAAGC,QAAQ,CAAC;IAC7CC,YAAYC,yBAAgB,CAACC,OAAO,CAAC,MAAMH,QAAQ,CAAC;IACpDI,kBAAkBd,MAAC,CAACe,IAAI,CAAC;QAAC;QAAO;KAAe,EAAEF,OAAO,CAAC,gBAAgBH,QAAQ,CAAC;IACnFM,kBAAkBhB,MAAC,CAACiB,OAAO,GAAGJ,OAAO,CAAC,MAAMH,QAAQ,CAAC;AACvD;AAEA,IAAMQ,sBAAsBlB,MAAC,CAACC,MAAM,CAAC;IACnCkB,MAAMnB,MAAC,CAACoB,OAA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,0CAAwDc,OAAftC,IAAG,cAAqC,OAAzBsC,MAAMoC,UAAU,CAACC,OAAO;wBAC3FlD,cAAciC;wBACdhC,aAAa8B;wBACb5B,gBAAgB6B;wBAChB5B,cAAc0B;oBAChB;oBAEA;;wBAAO;4BACLmD,OAAO;gCAAG;oCAAEzF,MAAM;oCAAiB0F,MAAMC,KAAKC,SAAS,CAAC3E;gCAAQ;;4BAChE4E,mBAAmB;gCAAE5E,QAAAA;4BAAO;wBAC9B;;;oBACOyB;oBACDC,UAAUD,AAAK,YAALA,OAAiBoD,SAAQpD,MAAMC,OAAO,GAAGa,OAAOd;oBAChEtB,OAAOsB,KAAK,CAAC,kCAAkC;wBAAEA,OAAOC;oBAAQ;oBAEhE,MAAM,IAAIgB,eAAQ,CAACC,gBAAS,CAACmC,aAAa,EAAE,AAAC,mCAA0C,OAARpD,UAAW;wBACxFqD,OAAOtD,AAAK,YAALA,OAAiBoD,SAAQpD,MAAMsD,KAAK,GAAGC;oBAChD;;;;;;;IAEJ;;AAEe,SAASzH;IACtB,OAAO;QACL0H,MAAM;QACNnF,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/OpenSource/ai/mcp-z/mcp-sheets/src/mcp/tools/values-csv-update.ts"],"sourcesContent":["/** Import CSV data to Google Sheets with range-based update (no deduplication) */\n\nimport { sheets as sheetsApi } from '@googleapis/sheets';\nimport type { EnrichedExtra } from '@mcp-z/oauth-google';\nimport { schemas } from '@mcp-z/oauth-google';\n\nconst { AuthRequiredBranchSchema } = schemas;\n\nimport type { CallToolResult, ToolModule } from '@mcp-z/server';\nimport { ProtocolError, ProtocolErrorCode } from '@mcp-z/server';\nimport { parse } from 'csv-parse';\nimport { z } from 'zod';\nimport { googleAuth } from '../../lib/google-auth.ts';\nimport { A1NotationSchema, SheetGidOutput, SheetGidSchema, SpreadsheetIdOutput, SpreadsheetIdSchema } from '../../schemas/index.ts';\nimport { getCsvReadStream } from '../../spreadsheet/csv-streaming.ts';\n\n/** Batch size for Sheets API calls (1000 rows × avg 10 cols = 10K cells, well under 40K limit) */\nconst BATCH_SIZE = 1000;\n\nconst inputSchema = z.object({\n id: SpreadsheetIdSchema,\n gid: SheetGidSchema,\n sourceUri: z.string().trim().min(1).describe('CSV file URI (file://, http://, https://)'),\n startRange: A1NotationSchema.default('A1').describe('Top-left cell where CSV data starts (default: A1)'),\n valueInputOption: z.enum(['RAW', 'USER_ENTERED']).default('USER_ENTERED').describe('How to interpret values (RAW = exact, USER_ENTERED = parse formulas/dates)'),\n sourceHasHeaders: z.boolean().default(true).describe('First row is headers (metadata) - exclude from data range. Set to false to include first row as data.'),\n});\n\nconst successBranchSchema = z.object({\n type: z.literal('success'),\n id: SpreadsheetIdOutput,\n gid: SheetGidOutput,\n spreadsheetTitle: z.string().describe('Spreadsheet title'),\n spreadsheetUrl: z.string().describe('Spreadsheet URL'),\n sheetTitle: z.string().describe('Sheet title'),\n sheetUrl: z.string().describe('Sheet URL'),\n updatedRange: z.string().describe('A1 notation range that was updated'),\n updatedRows: z.number().describe('Number of rows updated'),\n updatedColumns: z.number().describe('Number of columns updated'),\n updatedCells: z.number().describe('Number of cells updated'),\n});\n\nconst outputSchema = z.discriminatedUnion('type', [successBranchSchema, AuthRequiredBranchSchema]);\n\nconst config = {\n description: 'Import CSV to sheet range. Overwrites existing data at startRange. Use rows-csv-append for database-style appends with deduplication.',\n inputSchema,\n outputSchema: z.object({\n result: outputSchema,\n }),\n} as const;\n\nexport type Input = z.infer<typeof inputSchema>;\nexport type Output = z.infer<typeof outputSchema>;\n\nasync function handler({ id, gid, sourceUri, startRange, valueInputOption = 'USER_ENTERED', sourceHasHeaders }: Input, extra: EnrichedExtra): Promise<CallToolResult> {\n const logger = extra.logger;\n logger.info('sheets.values.csv-update called', { id, gid, sourceUri, startRange, valueInputOption, sourceHasHeaders });\n\n try {\n const sheets = sheetsApi({ version: 'v4', auth: googleAuth(extra.authContext.auth) });\n\n // Get spreadsheet and sheet info in single API call\n const spreadsheetResponse = await sheets.spreadsheets.get({\n spreadsheetId: id,\n fields: 'properties.title,spreadsheetUrl,sheets.properties.sheetId,sheets.properties.title',\n });\n\n const spreadsheetData = spreadsheetResponse.data;\n\n // Find the sheet by gid\n const sheet = spreadsheetData.sheets?.find((s) => String(s.properties?.sheetId) === gid);\n if (!sheet?.properties) {\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, `Sheet not found: ${gid}`);\n }\n\n const sheetTitle = sheet.properties.title ?? '';\n\n // Streaming CSV processing state\n let sourceHeaders: string[] = [];\n const allRows: (string | number | boolean | null)[][] = [];\n let totalCols = 0;\n\n // Get readable stream from CSV URI (no temp files!)\n const readStream = await getCsvReadStream(sourceUri);\n\n // Create CSV parser with native streaming\n const parser = readStream.pipe(\n parse({\n columns: !!sourceHasHeaders, // Parse first row as column names if source has headers\n skip_empty_lines: true,\n trim: true,\n cast: true, // Auto-convert numbers/booleans\n relax_column_count: true,\n })\n );\n\n // Stream and collect all rows (with batching for very large files)\n for await (const record of parser) {\n if (sourceHasHeaders) {\n // Extract source headers from first record\n if (sourceHeaders.length === 0) {\n sourceHeaders = Object.keys(record as Record<string, unknown>);\n totalCols = sourceHeaders.length;\n logger.info('sheets.values.csv-update source headers', { sourceHeaders, totalCols });\n }\n\n // Convert record to row array (exclude source headers from data range)\n // CSV values are strings/numbers/booleans/nulls from the parser\n const row = sourceHeaders.map((header) => (record as Record<string, string | number | boolean | null>)[header] ?? null);\n allRows.push(row);\n } else {\n // sourceHasHeaders=false: record is an array, include all rows (including first row)\n const row = record as (string | number | boolean | null)[];\n allRows.push(row);\n\n if (totalCols === 0) {\n totalCols = row.length;\n }\n }\n }\n\n if (allRows.length === 0) {\n throw new ProtocolError(ProtocolErrorCode.InvalidParams, 'CSV file is empty');\n }\n\n // Prepare data for update (all rows)\n const dataToWrite: (string | number | boolean | null)[][] = allRows;\n\n // For large datasets, use batchUpdate to write in chunks\n // This respects the 40K cell limit per request\n const batchRequests = [];\n const currentRow = startRange.match(/[A-Z]+(\\d+)/)?.[1] || '1';\n let currentRowNum = Number.parseInt(currentRow, 10);\n\n for (let i = 0; i < dataToWrite.length; i += BATCH_SIZE) {\n const batchData = dataToWrite.slice(i, i + BATCH_SIZE);\n const batchRange = `${sheetTitle}!${startRange.match(/[A-Z]+/)?.[0]}${currentRowNum}`;\n\n batchRequests.push({\n range: batchRange,\n values: batchData,\n });\n\n currentRowNum += batchData.length;\n }\n\n logger.info('sheets.values.csv-update batching', { totalBatches: batchRequests.length, batchSize: BATCH_SIZE });\n\n // Execute batch update\n const batchUpdateResponse = await sheets.spreadsheets.values.batchUpdate({\n spreadsheetId: id,\n requestBody: {\n valueInputOption,\n data: batchRequests,\n },\n });\n\n const totalUpdatedCells = batchUpdateResponse.data.totalUpdatedCells || 0;\n const totalUpdatedRows = batchUpdateResponse.data.totalUpdatedRows || 0;\n const totalUpdatedColumns = batchUpdateResponse.data.totalUpdatedColumns || 0;\n const firstUpdatedRange = batchUpdateResponse.data.responses?.[0]?.updatedRange || `${sheetTitle}!${startRange}`;\n\n logger.info('sheets.values.csv-update completed', { id, gid: sheet.properties.sheetId, updatedRange: firstUpdatedRange, updatedRows: totalUpdatedRows, sourceUri });\n\n const result: Output = {\n type: 'success' as const,\n id,\n gid: String(sheet.properties.sheetId ?? ''),\n spreadsheetTitle: spreadsheetData.properties?.title ?? '',\n spreadsheetUrl: spreadsheetData.spreadsheetUrl ?? `https://docs.google.com/spreadsheets/d/${id}`,\n sheetTitle,\n sheetUrl: `https://docs.google.com/spreadsheets/d/${id}/edit#gid=${sheet.properties.sheetId}`,\n updatedRange: firstUpdatedRange,\n updatedRows: totalUpdatedRows,\n updatedColumns: totalUpdatedColumns,\n updatedCells: totalUpdatedCells,\n };\n\n return {\n content: [{ type: 'text' as const, text: JSON.stringify(result) }],\n structuredContent: { result },\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n logger.error('sheets.values.csv-update error', { error: message });\n\n throw new ProtocolError(ProtocolErrorCode.InternalError, `Error updating values from CSV: ${message}`, {\n stack: error instanceof Error ? error.stack : undefined,\n });\n }\n}\n\nexport default function createTool() {\n return {\n name: 'values-csv-update',\n config,\n handler,\n } satisfies ToolModule;\n}\n"],"names":["createTool","AuthRequiredBranchSchema","schemas","BATCH_SIZE","inputSchema","z","object","id","SpreadsheetIdSchema","gid","SheetGidSchema","sourceUri","string","trim","min","describe","startRange","A1NotationSchema","default","valueInputOption","enum","sourceHasHeaders","boolean","successBranchSchema","type","literal","SpreadsheetIdOutput","SheetGidOutput","spreadsheetTitle","spreadsheetUrl","sheetTitle","sheetUrl","updatedRange","updatedRows","number","updatedColumns","updatedCells","outputSchema","discriminatedUnion","config","description","result","handler","extra","logger","sheet","spreadsheetData","batchUpdateResponse","sheets","spreadsheetResponse","sourceHeaders","allRows","totalCols","readStream","parser","dataToWrite","batchRequests","currentRow","currentRowNum","i","batchData","batchRange","totalUpdatedCells","totalUpdatedRows","totalUpdatedColumns","firstUpdatedRange","error","message","info","sheetsApi","version","auth","googleAuth","authContext","spreadsheets","get","spreadsheetId","fields","data","find","s","String","properties","sheetId","ProtocolError","ProtocolErrorCode","InvalidParams","title","getCsvReadStream","pipe","parse","columns","skip_empty_lines","cast","relax_column_count","record","length","Object","keys","row","map","header","push","match","Number","parseInt","slice","range","values","totalBatches","batchSize","batchUpdate","requestBody","responses","content","text","JSON","stringify","structuredContent","Error","InternalError","stack","undefined","name"],"mappings":"AAAA,gFAAgF;;;;+BAiMhF;;;eAAwBA;;;sBA/LY;2BAEZ;sBAKyB;wBAC3B;mBACJ;4BACS;uBACgF;8BAC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AARjC,IAAM,AAAEC,2BA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L2H,MAAM;QACNpF,QAAAA;QACAG,SAAAA;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
-
import type { CallToolResult } from '@
|
|
2
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodString;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EnrichedExtra } from '@mcp-z/oauth-google';
|
|
2
|
-
import type { CallToolResult } from '@
|
|
2
|
+
import type { CallToolResult } from '@mcp-z/server';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
declare const inputSchema: z.ZodObject<{
|
|
5
5
|
id: z.ZodString;
|