@mcp-z/mcp-sheets 2.4.2 → 2.5.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/README.md +45 -29
- package/dist/cjs/constants.d.cts +2 -0
- package/dist/cjs/constants.d.ts +2 -0
- package/dist/cjs/constants.js +27 -3
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/mcp/tools/cells-copy.d.cts +165 -0
- package/dist/cjs/mcp/tools/cells-copy.d.ts +165 -0
- package/dist/cjs/mcp/tools/cells-copy.js +388 -0
- package/dist/cjs/mcp/tools/cells-copy.js.map +1 -0
- package/dist/cjs/mcp/tools/index.d.cts +1 -0
- package/dist/cjs/mcp/tools/index.d.ts +1 -0
- package/dist/cjs/mcp/tools/index.js +4 -0
- package/dist/cjs/mcp/tools/index.js.map +1 -1
- package/dist/cjs/schemas/index.d.cts +1 -0
- package/dist/cjs/schemas/index.d.ts +1 -0
- package/dist/cjs/schemas/index.js +16 -0
- package/dist/cjs/schemas/index.js.map +1 -1
- package/dist/cjs/setup/config.js +26 -14
- package/dist/cjs/setup/config.js.map +1 -1
- package/dist/cjs/setup/version-help.js +1 -1
- package/dist/cjs/setup/version-help.js.map +1 -1
- package/dist/cjs/spreadsheet/data-operations.js +59 -164
- package/dist/cjs/spreadsheet/data-operations.js.map +1 -1
- package/dist/cjs/spreadsheet/range-operations.d.cts +26 -0
- package/dist/cjs/spreadsheet/range-operations.d.ts +26 -0
- package/dist/cjs/spreadsheet/range-operations.js +48 -0
- package/dist/cjs/spreadsheet/range-operations.js.map +1 -1
- package/dist/cjs/spreadsheet/sheet-operations.d.cts +6 -0
- package/dist/cjs/spreadsheet/sheet-operations.d.ts +6 -0
- package/dist/cjs/spreadsheet/sheet-operations.js +92 -52
- package/dist/cjs/spreadsheet/sheet-operations.js.map +1 -1
- package/dist/esm/constants.d.ts +2 -0
- package/dist/esm/constants.js +14 -0
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/mcp/tools/cells-copy.d.ts +165 -0
- package/dist/esm/mcp/tools/cells-copy.js +190 -0
- package/dist/esm/mcp/tools/cells-copy.js.map +1 -0
- package/dist/esm/mcp/tools/index.d.ts +1 -0
- package/dist/esm/mcp/tools/index.js +1 -0
- package/dist/esm/mcp/tools/index.js.map +1 -1
- package/dist/esm/schemas/index.d.ts +1 -0
- package/dist/esm/schemas/index.js +9 -0
- package/dist/esm/schemas/index.js.map +1 -1
- package/dist/esm/setup/config.js +26 -14
- package/dist/esm/setup/config.js.map +1 -1
- package/dist/esm/setup/version-help.js +7 -0
- package/dist/esm/setup/version-help.js.map +1 -1
- package/dist/esm/spreadsheet/data-operations.js +40 -84
- package/dist/esm/spreadsheet/data-operations.js.map +1 -1
- package/dist/esm/spreadsheet/range-operations.d.ts +26 -0
- package/dist/esm/spreadsheet/range-operations.js +50 -0
- package/dist/esm/spreadsheet/range-operations.js.map +1 -1
- package/dist/esm/spreadsheet/sheet-operations.d.ts +6 -0
- package/dist/esm/spreadsheet/sheet-operations.js +69 -43
- package/dist/esm/spreadsheet/sheet-operations.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/mcp-z/mcp-sheets/src/setup/config.ts"],"sourcesContent":["import { fileURLToPath, pathToFileURL } from 'node:url';\nimport type * as OAuthGoogle from '@mcp-z/oauth-google';\nimport type * as McpServer from '@mcp-z/server';\nimport { Module } from 'module';\nimport { homedir } from 'os';\nimport * as path from 'path';\nimport { parseArgs } from 'util';\nimport { GOOGLE_SCOPE } from '../constants.ts';\nimport type { ServerConfig } from '../types.ts';\nimport { readPkg } from './version-help.ts';\n\nconst pkg = readPkg();\n\n// @mcp-z/oauth-google and @mcp-z/server are requireable at the >=20 floor; deferred so\n// --version/--help (handled via version-help.ts, never this file) load neither package.\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n/**\n * Parse Sheets server configuration from CLI arguments and environment.\n *\n * CLI Arguments (all optional):\n * - --auth=<mode> Authentication mode (default: loopback-oauth)\n * Modes: loopback-oauth, service-account, dcr\n * - --headless Disable browser auto-open, return auth URL instead\n * - --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n * - --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n * - --dcr-verify-url=<url> External verification endpoint (required for external mode)\n * - --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n * - --port=<port> Enable HTTP transport on specified port\n * - --stdio Enable stdio transport (default if no port)\n * - --log-level=<level> Logging level (default: info)\n * - --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-sheets/files)\n * - --base-url=<url> Base URL for HTTP file serving (optional)\n *\n * Environment Variables:\n * - GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n * - GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n * - AUTH_MODE Default authentication mode (optional)\n * - HEADLESS Disable browser auto-open (optional)\n * - DCR_MODE DCR mode (optional, same format as --dcr-mode)\n * - DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n * - DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n * - TOKEN_STORE_URI Token storage URI (optional)\n * - PORT Default HTTP port (optional)\n * - LOG_LEVEL Default logging level (optional)\n * - RESOURCE_STORE_URI Resource store URI (optional, file://)\n * - BASE_URL Base URL for HTTP file serving (optional)\n *\n * OAuth Scopes (from constants.ts):\n * openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive\n */\nexport function parseConfig(args: string[], env: Record<string, string | undefined>): ServerConfig {\n const oauthGoogle = _require('@mcp-z/oauth-google') as typeof OAuthGoogle;\n const mcpServer = _require('@mcp-z/server') as typeof McpServer;\n\n const transportConfig = mcpServer.parseConfig(args, env);\n const oauthConfig = oauthGoogle.parseConfig(args, env);\n\n // Parse DCR configuration if DCR mode is enabled\n const dcrConfig = oauthConfig.auth === 'dcr' ? oauthGoogle.parseDcrConfig(args, env, GOOGLE_SCOPE) : undefined;\n\n // Parse application-level config (LOG_LEVEL, RESOURCE_STORE_URI, BASE_URL)\n const { values } = parseArgs({\n args,\n options: {\n 'log-level': { type: 'string' },\n 'base-url': { type: 'string' },\n 'resource-store-uri': { type: 'string' },\n },\n strict: false, // Allow other arguments\n allowPositionals: true,\n });\n\n const name = pkg.name.replace(/^@[^/]+\\//, '');\n // Parse repository URL from package.json, stripping git+ prefix and .git suffix\n const rawRepoUrl = typeof pkg.repository === 'object' ? pkg.repository.url : pkg.repository;\n const repositoryUrl = rawRepoUrl?.replace(/^git\\+/, '').replace(/\\.git$/, '') ?? `https://github.com/mcp-z/${name}`;\n let rootDir = homedir();\n try {\n const configPath = mcpServer.findConfigPath({ config: '.mcp.json', cwd: process.cwd(), stopDir: homedir() });\n rootDir = path.dirname(configPath);\n } catch {\n rootDir = homedir();\n }\n const baseDir = path.join(rootDir, '.mcp-z');\n const cliLogLevel = typeof values['log-level'] === 'string' ? values['log-level'] : undefined;\n const envLogLevel = env.LOG_LEVEL;\n const logLevel = cliLogLevel ?? envLogLevel ?? 'info';\n\n // Parse storage configuration\n const cliResourceStoreUri = typeof values['resource-store-uri'] === 'string' ? values['resource-store-uri'] : undefined;\n const envResourceStoreUri = env.RESOURCE_STORE_URI;\n const defaultResourceStorePath = path.join(baseDir, name, 'files');\n const resourceStoreUri = normalizeResourceStoreUri(cliResourceStoreUri ?? envResourceStoreUri ?? defaultResourceStorePath);\n\n const cliBaseUrl = typeof values['base-url'] === 'string' ? values['base-url'] : undefined;\n const envBaseUrl = env.BASE_URL;\n const baseUrl = cliBaseUrl ?? envBaseUrl;\n\n // Combine configs\n return {\n ...oauthConfig, // Includes clientId, auth, headless, redirectUri\n transport: transportConfig.transport,\n logLevel,\n baseDir,\n name,\n version: pkg.version,\n repositoryUrl,\n resourceStoreUri,\n ...(baseUrl && { baseUrl }),\n ...(dcrConfig && { dcrConfig }),\n };\n}\n\nfunction normalizeResourceStoreUri(resourceStoreUri: string): string {\n const filePrefix = 'file://';\n if (resourceStoreUri.startsWith(filePrefix)) {\n const rawPath = resourceStoreUri.slice(filePrefix.length);\n const filePath = rawPath.startsWith('~') ? rawPath.replace(/^~/, homedir()) : rawPath.startsWith('/') ? fileURLToPath(resourceStoreUri) : rawPath;\n return pathToFileURL(path.resolve(filePath)).href;\n }\n\n if (resourceStoreUri.includes('://')) return resourceStoreUri;\n\n const expandedPath = resourceStoreUri.startsWith('~') ? resourceStoreUri.replace(/^~/, homedir()) : resourceStoreUri;\n return pathToFileURL(path.resolve(expandedPath)).href;\n}\n\n/**\n * Build production configuration from process globals.\n * Entry point for production server.\n */\nexport function createConfig(): ServerConfig {\n return parseConfig(process.argv, process.env);\n}\n"],"names":["createConfig","parseConfig","pkg","readPkg","_require","require","Module","createRequire","args","env","cliLogLevel","cliResourceStoreUri","oauthGoogle","mcpServer","transportConfig","oauthConfig","dcrConfig","auth","parseDcrConfig","GOOGLE_SCOPE","undefined","values","parseArgs","options","type","strict","allowPositionals","name","replace","rawRepoUrl","repository","url","repositoryUrl","rootDir","homedir","configPath","findConfigPath","config","cwd","process","stopDir","path","dirname","baseDir","join","envLogLevel","LOG_LEVEL","logLevel","envResourceStoreUri","RESOURCE_STORE_URI","defaultResourceStorePath","resourceStoreUri","normalizeResourceStoreUri","cliBaseUrl","envBaseUrl","BASE_URL","baseUrl","transport","version","filePrefix","startsWith","rawPath","slice","length","filePath","fileURLToPath","pathToFileURL","resolve","href","includes","expandedPath","argv"],"mappings":";;;;;;;;;;;QAoIgBA;eAAAA;;QAjFAC;eAAAA;;;uBAnD6B;sBAGtB;kBACC;4DACF;oBACI;2BACG;6BAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExB,IAAMC,MAAMC,IAAAA,sBAAO;AAEnB,uFAAuF;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;QAC1I,OAAOK,IAAAA,sBAAa,EAACzB,MAAK0B,OAAO,CAACH,WAAWI,IAAI;IACnD;IAEA,IAAIjB,iBAAiBkB,QAAQ,CAAC,QAAQ,OAAOlB;IAE7C,IAAMmB,eAAenB,iBAAiBS,UAAU,CAAC,OAAOT,iBAAiBvB,OAAO,CAAC,MAAMM,IAAAA,WAAO,OAAMiB;IACpG,OAAOe,IAAAA,sBAAa,EAACzB,MAAK0B,OAAO,CAACG,eAAeF,IAAI;AACvD;AAMO,SAASpE;IACd,OAAOC,YAAYsC,QAAQgC,IAAI,EAAEhC,QAAQ9B,GAAG;AAC9C"}
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/mcp-z/mcp-sheets/src/setup/config.ts"],"sourcesContent":["import { fileURLToPath, pathToFileURL } from 'node:url';\nimport type * as OAuthGoogle from '@mcp-z/oauth-google';\nimport type * as McpServer from '@mcp-z/server';\nimport { Module } from 'module';\nimport { homedir } from 'os';\nimport * as path from 'path';\nimport { parseArgs } from 'util';\nimport { GOOGLE_SCOPE } from '../constants.ts';\nimport type { ServerConfig } from '../types.ts';\nimport { readPkg } from './version-help.ts';\n\nconst pkg = readPkg();\nconst SERVER_NAME = pkg.name.replace(/^@[^/]+\\//, '');\n\n// @mcp-z/oauth-google and @mcp-z/server are requireable at the >=20 floor; deferred so\n// --version/--help (handled via version-help.ts, never this file) load neither package.\nconst _require = typeof require === 'undefined' ? Module.createRequire(import.meta.url) : require;\n\n/**\n * Parse Sheets server configuration from CLI arguments and environment.\n *\n * CLI Arguments (all optional):\n * - --auth=<mode> Authentication mode (default: loopback-oauth)\n * Modes: loopback-oauth, service-account, dcr\n * - --headless Disable browser auto-open, return auth URL instead\n * - --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n * - --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n * - --dcr-verify-url=<url> External verification endpoint (required for external mode)\n * - --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n * - --port=<port> Enable HTTP transport on specified port\n * - --stdio Enable stdio transport (default if no port)\n * - --log-level=<level> Logging level (default: info)\n * - --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-sheets/files)\n * - --base-url=<url> Base URL for HTTP file serving (optional)\n *\n * Environment Variables:\n * - GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n * - GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n * - AUTH_MODE Default authentication mode (optional)\n * - HEADLESS Disable browser auto-open (optional)\n * - DCR_MODE DCR mode (optional, same format as --dcr-mode)\n * - DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n * - DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n * - TOKEN_STORE_URI Token storage URI (optional)\n * - PORT Default HTTP port (optional)\n * - LOG_LEVEL Default logging level (optional)\n * - RESOURCE_STORE_URI Resource store URI (optional, file://)\n * - BASE_URL Base URL for HTTP file serving (optional)\n *\n * OAuth Scopes (from constants.ts):\n * openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive\n */\nexport function parseConfig(args: string[], env: Record<string, string | undefined>): ServerConfig {\n const oauthGoogle = _require('@mcp-z/oauth-google') as typeof OAuthGoogle;\n const mcpServer = _require('@mcp-z/server') as typeof McpServer;\n\n const transportConfig = mcpServer.parseConfig(args, env);\n const oauthConfig = oauthGoogle.parseConfig(args, env);\n\n // Parse DCR configuration if DCR mode is enabled\n const dcrConfig = oauthConfig.auth === 'dcr' ? oauthGoogle.parseDcrConfig(args, env, GOOGLE_SCOPE) : undefined;\n\n // Parse application-level config (LOG_LEVEL, RESOURCE_STORE_URI, BASE_URL)\n const { values } = parseArgs({\n args,\n options: {\n 'log-level': { type: 'string' },\n 'base-url': { type: 'string' },\n 'resource-store-uri': { type: 'string' },\n },\n strict: false, // Allow other arguments\n allowPositionals: true,\n });\n\n const name = SERVER_NAME;\n // Parse repository URL from package.json, stripping git+ prefix and .git suffix\n const rawRepoUrl = typeof pkg.repository === 'object' ? pkg.repository.url : pkg.repository;\n const repositoryUrl = rawRepoUrl?.replace(/^git\\+/, '').replace(/\\.git$/, '') ?? `https://github.com/mcp-z/${name}`;\n const baseDir = resolveBaseDir();\n const cliLogLevel = typeof values['log-level'] === 'string' ? values['log-level'] : undefined;\n const envLogLevel = env.LOG_LEVEL;\n const logLevel = cliLogLevel ?? envLogLevel ?? 'info';\n\n // Parse storage configuration\n const cliResourceStoreUri = typeof values['resource-store-uri'] === 'string' ? values['resource-store-uri'] : undefined;\n const envResourceStoreUri = env.RESOURCE_STORE_URI;\n const defaultResourceStorePath = path.join(baseDir, name, 'files');\n const resourceStoreUri = normalizeResourceStoreUri(cliResourceStoreUri ?? envResourceStoreUri ?? defaultResourceStorePath);\n\n const cliBaseUrl = typeof values['base-url'] === 'string' ? values['base-url'] : undefined;\n const envBaseUrl = env.BASE_URL;\n const baseUrl = cliBaseUrl ?? envBaseUrl;\n\n // Combine configs\n return {\n ...oauthConfig, // Includes clientId, auth, headless, redirectUri\n transport: transportConfig.transport,\n logLevel,\n baseDir,\n name,\n version: pkg.version,\n repositoryUrl,\n resourceStoreUri,\n ...(baseUrl && { baseUrl }),\n ...(dcrConfig && { dcrConfig }),\n };\n}\n\nfunction normalizeResourceStoreUri(resourceStoreUri: string): string {\n const filePrefix = 'file://';\n if (resourceStoreUri.startsWith(filePrefix)) {\n const rawPath = resourceStoreUri.slice(filePrefix.length);\n const filePath = rawPath.startsWith('~') ? rawPath.replace(/^~/, homedir()) : rawPath.startsWith('/') ? fileURLToPath(resourceStoreUri) : rawPath;\n return pathToFileURL(path.resolve(filePath)).href;\n }\n\n if (resourceStoreUri.includes('://')) return resourceStoreUri;\n\n const expandedPath = resourceStoreUri.startsWith('~') ? resourceStoreUri.replace(/^~/, homedir()) : resourceStoreUri;\n return pathToFileURL(path.resolve(expandedPath)).href;\n}\n\n/** The server's data directory: `.mcp-z` beside the nearest .mcp.json (searched from cwd up to home), else in the home directory. */\nfunction resolveBaseDir(): string {\n const mcpServer = _require('@mcp-z/server') as typeof McpServer;\n try {\n const configPath = mcpServer.findConfigPath({ config: '.mcp.json', cwd: process.cwd(), stopDir: homedir() });\n return path.join(path.dirname(configPath), '.mcp-z');\n } catch {\n return path.join(homedir(), '.mcp-z');\n }\n}\n\n/**\n * Build production configuration from process globals.\n * Entry point for production server.\n */\nexport function createConfig(): ServerConfig {\n const mcpServer = _require('@mcp-z/server') as typeof McpServer;\n const envResult = mcpServer.loadServerEnv({ name: SERVER_NAME, baseDir: resolveBaseDir() });\n try {\n return parseConfig(process.argv, process.env);\n } catch (error) {\n throw new Error(`${(error as Error).message}\\n${mcpServer.formatServerEnvSearch(envResult)}`);\n }\n}\n"],"names":["createConfig","parseConfig","pkg","readPkg","SERVER_NAME","name","replace","_require","require","Module","createRequire","args","env","cliLogLevel","cliResourceStoreUri","oauthGoogle","mcpServer","transportConfig","oauthConfig","dcrConfig","auth","parseDcrConfig","GOOGLE_SCOPE","undefined","values","parseArgs","options","type","strict","allowPositionals","rawRepoUrl","repository","url","repositoryUrl","baseDir","resolveBaseDir","envLogLevel","LOG_LEVEL","logLevel","envResourceStoreUri","RESOURCE_STORE_URI","defaultResourceStorePath","path","join","resourceStoreUri","normalizeResourceStoreUri","cliBaseUrl","envBaseUrl","BASE_URL","baseUrl","transport","version","filePrefix","startsWith","rawPath","slice","length","filePath","homedir","fileURLToPath","pathToFileURL","resolve","href","includes","expandedPath","configPath","findConfigPath","config","cwd","process","stopDir","dirname","envResult","loadServerEnv","argv","error","Error","message","formatServerEnvSearch"],"mappings":";;;;;;;;;;;QAyIgBA;eAAAA;;QArFAC;eAAAA;;;uBApD6B;sBAGtB;kBACC;4DACF;oBACI;2BACG;6BAEL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExB,IAA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MoD,IAAAA,WAAO,OAAMd;IACpG,OAAOgB,IAAAA,sBAAa,EAAClB,MAAKmB,OAAO,CAACG,eAAeF,IAAI;AACvD;AAEA,mIAAmI,GACnI,SAAS3B;IACP,IAAMnB,YAAYT,SAAS;IAC3B,IAAI;QACF,IAAM0D,aAAajD,UAAUkD,cAAc,CAAC;YAAEC,QAAQ;YAAaC,KAAKC,QAAQD,GAAG;YAAIE,SAASZ,IAAAA,WAAO;QAAG;QAC1G,OAAOhB,MAAKC,IAAI,CAACD,MAAK6B,OAAO,CAACN,aAAa;IAC7C,EAAE,eAAM;QACN,OAAOvB,MAAKC,IAAI,CAACe,IAAAA,WAAO,KAAI;IAC9B;AACF;AAMO,SAAS1D;IACd,IAAMgB,YAAYT,SAAS;IAC3B,IAAMiE,YAAYxD,UAAUyD,aAAa,CAAC;QAAEpE,MAAMD;QAAa8B,SAASC;IAAiB;IACzF,IAAI;QACF,OAAOlC,YAAYoE,QAAQK,IAAI,EAAEL,QAAQzD,GAAG;IAC9C,EAAE,OAAO+D,OAAO;QACd,MAAM,IAAIC,MAAM,AAAC,GAA+B5D,OAA7B,AAAC2D,MAAgBE,OAAO,EAAC,MAA+C,OAA3C7D,UAAU8D,qBAAqB,CAACN;IAClF;AACF"}
|
|
@@ -60,7 +60,7 @@ function _interop_require_wildcard(obj, nodeInterop) {
|
|
|
60
60
|
// resolve nothing beyond Node startup: config.ts's parseConfig pulls in @mcp-z/oauth-google and
|
|
61
61
|
// @mcp-z/server, which this path must not touch.
|
|
62
62
|
var pkg = JSON.parse(_fs.readFileSync(_path.join((0, _modulerootsync.default)(_url.fileURLToPath(require("url").pathToFileURL(__filename).toString())), 'package.json'), 'utf-8'));
|
|
63
|
-
var HELP_TEXT =
|
|
63
|
+
var HELP_TEXT = '\nUsage: mcp-sheets [options]\n\nMCP server for Google Sheets spreadsheet management with OAuth authentication.\n\nOptions:\n --version, -v Show version number\n --help, -h Show this help message\n --auth=<mode> Authentication mode (default: loopback-oauth)\n Modes: loopback-oauth, service-account, dcr\n --headless Disable browser auto-open, return auth URL instead\n --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n --dcr-verify-url=<url> External verification endpoint (required for external mode)\n --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n --port=<port> Enable HTTP transport on specified port\n --stdio Enable stdio transport (default if no port)\n --log-level=<level> Logging level (default: info)\n --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-sheets/files)\n --base-url=<url> Base URL for HTTP file serving (optional)\n\nEnvironment Variables:\n GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n AUTH_MODE Default authentication mode (optional)\n HEADLESS Disable browser auto-open (optional)\n DCR_MODE DCR mode (optional, same format as --dcr-mode)\n DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n TOKEN_STORE_URI Token storage URI (optional)\n PORT Default HTTP port (optional)\n LOG_LEVEL Default logging level (optional)\n RESOURCE_STORE_URI Resource store URI (optional, file://)\n BASE_URL Base URL for HTTP file serving (optional)\n\nConfiguration Files:\n Variables may also be set in the first of these files that exists:\n 1. .mcp-z/mcp-sheets/.env beside the nearest .mcp.json (else ~/.mcp-z/mcp-sheets/.env)\n 2. ~/.config/mcp-z/mcp-sheets/.env (~ is your home directory, on every OS)\n Values already in the environment, including .mcp.json "env", take precedence.\n On macOS and Linux the file must be private (chmod 600), or the server will not start.\n\nStorage Backends:\n TOKEN_STORE_URI and DCR_STORE_URI accept any keyv-registry protocol.\n file:// (the default) and memory:// work out of the box. Any other backend\n needs its adapter installed alongside this server:\n npm install -g @keyv/redis\n TOKEN_STORE_URI=redis://localhost:6379 mcp-sheets\n\nOAuth Scopes:\n openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive\n\nExamples:\n mcp-sheets # Use default settings\n mcp-sheets --auth=service-account # Use service account auth\n mcp-sheets --port=3000 # HTTP transport on port 3000\n mcp-sheets --resource-store-uri=file:///tmp/sheets # Custom resource store URI\n GOOGLE_CLIENT_ID=xxx mcp-sheets # Set client ID via env var\n'.trim();
|
|
64
64
|
function readPkg() {
|
|
65
65
|
return pkg;
|
|
66
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/mcp-z/mcp-sheets/src/setup/version-help.ts"],"sourcesContent":["import * as fs from 'fs';\nimport moduleRoot from 'module-root-sync';\nimport * as path from 'path';\nimport * as url from 'url';\nimport { parseArgs } from 'util';\n\n// Kept dependency-free (fs/path/url/module-root-sync only) so `--version`/`--help`\n// resolve nothing beyond Node startup: config.ts's parseConfig pulls in @mcp-z/oauth-google and\n// @mcp-z/server, which this path must not touch.\nconst pkg = JSON.parse(fs.readFileSync(path.join(moduleRoot(url.fileURLToPath(import.meta.url)), 'package.json'), 'utf-8'));\n\nconst HELP_TEXT = `\nUsage: mcp-sheets [options]\n\nMCP server for Google Sheets spreadsheet management with OAuth authentication.\n\nOptions:\n --version, -v Show version number\n --help, -h Show this help message\n --auth=<mode> Authentication mode (default: loopback-oauth)\n Modes: loopback-oauth, service-account, dcr\n --headless Disable browser auto-open, return auth URL instead\n --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n --dcr-verify-url=<url> External verification endpoint (required for external mode)\n --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n --port=<port> Enable HTTP transport on specified port\n --stdio Enable stdio transport (default if no port)\n --log-level=<level> Logging level (default: info)\n --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-sheets/files)\n --base-url=<url> Base URL for HTTP file serving (optional)\n\nEnvironment Variables:\n GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n AUTH_MODE Default authentication mode (optional)\n HEADLESS Disable browser auto-open (optional)\n DCR_MODE DCR mode (optional, same format as --dcr-mode)\n DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n TOKEN_STORE_URI Token storage URI (optional)\n PORT Default HTTP port (optional)\n LOG_LEVEL Default logging level (optional)\n RESOURCE_STORE_URI Resource store URI (optional, file://)\n BASE_URL Base URL for HTTP file serving (optional)\n\nStorage Backends:\n TOKEN_STORE_URI and DCR_STORE_URI accept any keyv-registry protocol.\n file:// (the default) and memory:// work out of the box. Any other backend\n needs its adapter installed alongside this server:\n npm install -g @keyv/redis\n TOKEN_STORE_URI=redis://localhost:6379 mcp-sheets\n\nOAuth Scopes:\n openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive\n\nExamples:\n mcp-sheets # Use default settings\n mcp-sheets --auth=service-account # Use service account auth\n mcp-sheets --port=3000 # HTTP transport on port 3000\n mcp-sheets --resource-store-uri=file:///tmp/sheets # Custom resource store URI\n GOOGLE_CLIENT_ID=xxx mcp-sheets # Set client ID via env var\n`.trim();\n\n/** Package metadata read from package.json, resolved relative to this file. */\nexport function readPkg(): { name: string; version: string; repository?: string | { url?: string } } {\n return pkg;\n}\n\n/**\n * Handle --version/--help flags before config parsing.\n * These must work without requiring any configuration or heavy dependency.\n */\nexport function handleVersionHelp(args: string[]): { handled: boolean; output?: string } {\n const { values } = parseArgs({\n args,\n options: {\n version: { type: 'boolean', short: 'v' },\n help: { type: 'boolean', short: 'h' },\n },\n strict: false,\n allowPositionals: true,\n });\n\n if (values.version) return { handled: true, output: pkg.version };\n if (values.help) return { handled: true, output: HELP_TEXT };\n return { handled: false };\n}\n"],"names":["handleVersionHelp","readPkg","pkg","JSON","parse","fs","readFileSync","path","join","moduleRoot","url","fileURLToPath","HELP_TEXT","trim","args","values","parseArgs","options","version","type","short","help","strict","allowPositionals","handled","output"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/open-source/ai/mcp-z/mcp-sheets/src/setup/version-help.ts"],"sourcesContent":["import * as fs from 'fs';\nimport moduleRoot from 'module-root-sync';\nimport * as path from 'path';\nimport * as url from 'url';\nimport { parseArgs } from 'util';\n\n// Kept dependency-free (fs/path/url/module-root-sync only) so `--version`/`--help`\n// resolve nothing beyond Node startup: config.ts's parseConfig pulls in @mcp-z/oauth-google and\n// @mcp-z/server, which this path must not touch.\nconst pkg = JSON.parse(fs.readFileSync(path.join(moduleRoot(url.fileURLToPath(import.meta.url)), 'package.json'), 'utf-8'));\n\nconst HELP_TEXT = `\nUsage: mcp-sheets [options]\n\nMCP server for Google Sheets spreadsheet management with OAuth authentication.\n\nOptions:\n --version, -v Show version number\n --help, -h Show this help message\n --auth=<mode> Authentication mode (default: loopback-oauth)\n Modes: loopback-oauth, service-account, dcr\n --headless Disable browser auto-open, return auth URL instead\n --redirect-uri=<uri> OAuth redirect URI (default: ephemeral loopback)\n --dcr-mode=<mode> DCR mode (self-hosted or external, default: self-hosted)\n --dcr-verify-url=<url> External verification endpoint (required for external mode)\n --dcr-store-uri=<uri> DCR client storage URI (required for self-hosted mode)\n --port=<port> Enable HTTP transport on specified port\n --stdio Enable stdio transport (default if no port)\n --log-level=<level> Logging level (default: info)\n --resource-store-uri=<uri> Resource store URI for CSV file storage (default: file://~/.mcp-z/mcp-sheets/files)\n --base-url=<url> Base URL for HTTP file serving (optional)\n\nEnvironment Variables:\n GOOGLE_CLIENT_ID OAuth client ID (REQUIRED)\n GOOGLE_CLIENT_SECRET OAuth client secret (optional)\n AUTH_MODE Default authentication mode (optional)\n HEADLESS Disable browser auto-open (optional)\n DCR_MODE DCR mode (optional, same format as --dcr-mode)\n DCR_VERIFY_URL External verification URL (optional, same as --dcr-verify-url)\n DCR_STORE_URI DCR storage URI (optional, same as --dcr-store-uri)\n TOKEN_STORE_URI Token storage URI (optional)\n PORT Default HTTP port (optional)\n LOG_LEVEL Default logging level (optional)\n RESOURCE_STORE_URI Resource store URI (optional, file://)\n BASE_URL Base URL for HTTP file serving (optional)\n\nConfiguration Files:\n Variables may also be set in the first of these files that exists:\n 1. .mcp-z/mcp-sheets/.env beside the nearest .mcp.json (else ~/.mcp-z/mcp-sheets/.env)\n 2. ~/.config/mcp-z/mcp-sheets/.env (~ is your home directory, on every OS)\n Values already in the environment, including .mcp.json \"env\", take precedence.\n On macOS and Linux the file must be private (chmod 600), or the server will not start.\n\nStorage Backends:\n TOKEN_STORE_URI and DCR_STORE_URI accept any keyv-registry protocol.\n file:// (the default) and memory:// work out of the box. Any other backend\n needs its adapter installed alongside this server:\n npm install -g @keyv/redis\n TOKEN_STORE_URI=redis://localhost:6379 mcp-sheets\n\nOAuth Scopes:\n openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/spreadsheets https://www.googleapis.com/auth/drive\n\nExamples:\n mcp-sheets # Use default settings\n mcp-sheets --auth=service-account # Use service account auth\n mcp-sheets --port=3000 # HTTP transport on port 3000\n mcp-sheets --resource-store-uri=file:///tmp/sheets # Custom resource store URI\n GOOGLE_CLIENT_ID=xxx mcp-sheets # Set client ID via env var\n`.trim();\n\n/** Package metadata read from package.json, resolved relative to this file. */\nexport function readPkg(): { name: string; version: string; repository?: string | { url?: string } } {\n return pkg;\n}\n\n/**\n * Handle --version/--help flags before config parsing.\n * These must work without requiring any configuration or heavy dependency.\n */\nexport function handleVersionHelp(args: string[]): { handled: boolean; output?: string } {\n const { values } = parseArgs({\n args,\n options: {\n version: { type: 'boolean', short: 'v' },\n help: { type: 'boolean', short: 'h' },\n },\n strict: false,\n allowPositionals: true,\n });\n\n if (values.version) return { handled: true, output: pkg.version };\n if (values.help) return { handled: true, output: HELP_TEXT };\n return { handled: false };\n}\n"],"names":["handleVersionHelp","readPkg","pkg","JSON","parse","fs","readFileSync","path","join","moduleRoot","url","fileURLToPath","HELP_TEXT","trim","args","values","parseArgs","options","version","type","short","help","strict","allowPositionals","handled","output"],"mappings":";;;;;;;;;;;QAgFgBA;eAAAA;;QARAC;eAAAA;;;0DAxEI;qEACG;4DACD;2DACD;oBACK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE1B,mFAAmF;AACnF,gGAAgG;AAChG,iDAAiD;AACjD,IAAMC,MAAMC,KAAKC,KAAK,CAACC,IAAGC,YAAY,CAACC,MAAKC,IAAI,CAACC,IAAAA,uBAAU,EAACC,KAAIC,aAAa,CAAC,uDAAmB,iBAAiB;AAElH,IAAMC,YAAY,itGA0DhBC,IAAI;AAGC,SAASZ;IACd,OAAOC;AACT;AAMO,SAASF,kBAAkBc,IAAc;IAC9C,IAAM,AAAEC,SAAWC,IAAAA,eAAS,EAAC;QAC3BF,MAAAA;QACAG,SAAS;YACPC,SAAS;gBAAEC,MAAM;gBAAWC,OAAO;YAAI;YACvCC,MAAM;gBAAEF,MAAM;gBAAWC,OAAO;YAAI;QACtC;QACAE,QAAQ;QACRC,kBAAkB;IACpB,GARQR;IAUR,IAAIA,OAAOG,OAAO,EAAE,OAAO;QAAEM,SAAS;QAAMC,QAAQvB,IAAIgB,OAAO;IAAC;IAChE,IAAIH,OAAOM,IAAI,EAAE,OAAO;QAAEG,SAAS;QAAMC,QAAQb;IAAU;IAC3D,OAAO;QAAEY,SAAS;IAAM;AAC1B"}
|
|
@@ -743,9 +743,41 @@ function mapRowsToHeader(param) {
|
|
|
743
743
|
return mappedRow;
|
|
744
744
|
});
|
|
745
745
|
}
|
|
746
|
+
/** Calls onKey with each non-empty generated key of the data rows and its 1-indexed row number; see scanKeyColumnRows for the bounded, error-reporting scan. */ function scanKeyRows(sheets, spreadsheetId, sheetTitle, header, keyIndices, strategy, onKey) {
|
|
747
|
+
return _async_to_generator(function() {
|
|
748
|
+
var _Math, _Math1, minIndex, maxIndex;
|
|
749
|
+
return _ts_generator(this, function(_state) {
|
|
750
|
+
switch(_state.label){
|
|
751
|
+
case 0:
|
|
752
|
+
minIndex = (_Math = Math).min.apply(_Math, _to_consumable_array(keyIndices));
|
|
753
|
+
maxIndex = (_Math1 = Math).max.apply(_Math1, _to_consumable_array(keyIndices));
|
|
754
|
+
return [
|
|
755
|
+
4,
|
|
756
|
+
(0, _sheetoperationsts.scanKeyColumnRows)(sheets, spreadsheetId, sheetTitle, (0, _columnutilitiests.a1Col)(minIndex + 1), (0, _columnutilitiests.a1Col)(maxIndex + 1), function(rawRow, rowNumber) {
|
|
757
|
+
// Reconstruct full row for key generation
|
|
758
|
+
var fullRow = new Array(header.length).fill('');
|
|
759
|
+
keyIndices.forEach(function(globalIndex) {
|
|
760
|
+
var localRowArrayIndex = globalIndex - minIndex;
|
|
761
|
+
if (localRowArrayIndex >= 0 && localRowArrayIndex < rawRow.length) {
|
|
762
|
+
fullRow[globalIndex] = rawRow[localRowArrayIndex];
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
var key = generateRowKey(fullRow, header, strategy);
|
|
766
|
+
if (key.replace(/\\+/g, '') !== '') onKey(key, rowNumber);
|
|
767
|
+
})
|
|
768
|
+
];
|
|
769
|
+
case 1:
|
|
770
|
+
_state.sent();
|
|
771
|
+
return [
|
|
772
|
+
2
|
|
773
|
+
];
|
|
774
|
+
}
|
|
775
|
+
});
|
|
776
|
+
})();
|
|
777
|
+
}
|
|
746
778
|
function snapshotHeaderAndKeys(_0, _1, _2, _3) {
|
|
747
779
|
return _async_to_generator(function(sheets, spreadsheetId, sheetTitle) {
|
|
748
|
-
var keyColumns, keyStrategy,
|
|
780
|
+
var keyColumns, keyStrategy, _ref, _ref1, header, keySet, strategy, keyIndices;
|
|
749
781
|
var _arguments = arguments;
|
|
750
782
|
return _ts_generator(this, function(_state) {
|
|
751
783
|
switch(_state.label){
|
|
@@ -799,97 +831,14 @@ function snapshotHeaderAndKeys(_0, _1, _2, _3) {
|
|
|
799
831
|
}
|
|
800
832
|
];
|
|
801
833
|
}
|
|
802
|
-
// Read key columns data in chunks
|
|
803
|
-
chunkSize = 1000;
|
|
804
|
-
startRow = 2;
|
|
805
|
-
minIndex = (_Math = Math).min.apply(_Math, _to_consumable_array(keyIndices));
|
|
806
|
-
maxIndex = (_Math1 = Math).max.apply(_Math1, _to_consumable_array(keyIndices));
|
|
807
|
-
startCol = (0, _columnutilitiests.a1Col)(minIndex + 1);
|
|
808
|
-
endCol = (0, _columnutilitiests.a1Col)(maxIndex + 1);
|
|
809
|
-
_state.label = 2;
|
|
810
|
-
case 2:
|
|
811
|
-
if (!true) return [
|
|
812
|
-
3,
|
|
813
|
-
7
|
|
814
|
-
];
|
|
815
|
-
endRow = startRow + chunkSize - 1;
|
|
816
|
-
range = "".concat(sheetTitle, "!").concat(startCol).concat(startRow, ":").concat(endCol).concat(endRow);
|
|
817
|
-
_state.label = 3;
|
|
818
|
-
case 3:
|
|
819
|
-
_state.trys.push([
|
|
820
|
-
3,
|
|
821
|
-
5,
|
|
822
|
-
,
|
|
823
|
-
6
|
|
824
|
-
]);
|
|
825
834
|
return [
|
|
826
835
|
4,
|
|
827
|
-
sheets
|
|
828
|
-
|
|
829
|
-
range: range,
|
|
830
|
-
majorDimension: 'ROWS'
|
|
836
|
+
scanKeyRows(sheets, spreadsheetId, sheetTitle, header, keyIndices, strategy, function(key) {
|
|
837
|
+
keySet.add(key);
|
|
831
838
|
})
|
|
832
839
|
];
|
|
833
|
-
case
|
|
834
|
-
|
|
835
|
-
rows = ((_response_data = response.data) === null || _response_data === void 0 ? void 0 : _response_data.values) || [];
|
|
836
|
-
if (rows.length === 0) return [
|
|
837
|
-
3,
|
|
838
|
-
7
|
|
839
|
-
];
|
|
840
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
841
|
-
try {
|
|
842
|
-
_loop = function() {
|
|
843
|
-
var rawRow = _step.value;
|
|
844
|
-
// Reconstruct full row for key generation
|
|
845
|
-
var fullRow = new Array(header.length).fill('');
|
|
846
|
-
keyIndices.forEach(function(globalIndex, _localIndex) {
|
|
847
|
-
var localRowIndex = globalIndex - minIndex;
|
|
848
|
-
if (localRowIndex >= 0 && localRowIndex < rawRow.length) {
|
|
849
|
-
fullRow[globalIndex] = rawRow[localRowIndex];
|
|
850
|
-
}
|
|
851
|
-
});
|
|
852
|
-
var key = generateRowKey(fullRow, header, strategy);
|
|
853
|
-
if (key.replace(/\\+/g, '') !== '') {
|
|
854
|
-
keySet.add(key);
|
|
855
|
-
}
|
|
856
|
-
};
|
|
857
|
-
for(_iterator = rows[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
|
|
858
|
-
} catch (err) {
|
|
859
|
-
_didIteratorError = true;
|
|
860
|
-
_iteratorError = err;
|
|
861
|
-
} finally{
|
|
862
|
-
try {
|
|
863
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
864
|
-
_iterator.return();
|
|
865
|
-
}
|
|
866
|
-
} finally{
|
|
867
|
-
if (_didIteratorError) {
|
|
868
|
-
throw _iteratorError;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
startRow += rows.length;
|
|
873
|
-
if (rows.length < chunkSize) return [
|
|
874
|
-
3,
|
|
875
|
-
7
|
|
876
|
-
]; // Last chunk
|
|
877
|
-
return [
|
|
878
|
-
3,
|
|
879
|
-
6
|
|
880
|
-
];
|
|
881
|
-
case 5:
|
|
882
|
-
unused = _state.sent();
|
|
883
|
-
return [
|
|
884
|
-
3,
|
|
885
|
-
7
|
|
886
|
-
]; // End of data or error
|
|
887
|
-
case 6:
|
|
888
|
-
return [
|
|
889
|
-
3,
|
|
890
|
-
2
|
|
891
|
-
];
|
|
892
|
-
case 7:
|
|
840
|
+
case 2:
|
|
841
|
+
_state.sent();
|
|
893
842
|
return [
|
|
894
843
|
2,
|
|
895
844
|
{
|
|
@@ -902,9 +851,17 @@ function snapshotHeaderAndKeys(_0, _1, _2, _3) {
|
|
|
902
851
|
});
|
|
903
852
|
}).apply(this, arguments);
|
|
904
853
|
}
|
|
854
|
+
/** Message naming every duplicate key and its 1-indexed row numbers */ function formatDuplicateSheetKeys(keyToRows) {
|
|
855
|
+
var parts = [];
|
|
856
|
+
keyToRows.forEach(function(rows, key) {
|
|
857
|
+
if (rows.length > 1) parts.push('"'.concat(key, '" (rows ').concat(rows.join(', '), ")"));
|
|
858
|
+
});
|
|
859
|
+
if (parts.length === 0) return undefined;
|
|
860
|
+
return "duplicate keys found on the sheet: ".concat(parts.join('; '), ". Nothing was written; make each key unique and retry.");
|
|
861
|
+
}
|
|
905
862
|
function snapshotHeaderKeysAndPositions(_0, _1, _2, _3) {
|
|
906
863
|
return _async_to_generator(function(sheets, spreadsheetId, sheetTitle) {
|
|
907
|
-
var keyColumns, keyStrategy,
|
|
864
|
+
var keyColumns, keyStrategy, _ref, _ref1, header, keySet, keyToRowMap, keyToRows, strategy, keyIndices, duplicateMessage;
|
|
908
865
|
var _arguments = arguments;
|
|
909
866
|
return _ts_generator(this, function(_state) {
|
|
910
867
|
switch(_state.label){
|
|
@@ -920,6 +877,7 @@ function snapshotHeaderKeysAndPositions(_0, _1, _2, _3) {
|
|
|
920
877
|
header = _state.sent();
|
|
921
878
|
keySet = new Set();
|
|
922
879
|
keyToRowMap = new Map();
|
|
880
|
+
keyToRows = new Map();
|
|
923
881
|
if (header.length === 0) {
|
|
924
882
|
return [
|
|
925
883
|
2,
|
|
@@ -961,85 +919,22 @@ function snapshotHeaderKeysAndPositions(_0, _1, _2, _3) {
|
|
|
961
919
|
}
|
|
962
920
|
];
|
|
963
921
|
}
|
|
964
|
-
// Read key columns data in chunks and track row positions
|
|
965
|
-
chunkSize = 1000;
|
|
966
|
-
startRow = 2; // Start from row 2 (after header)
|
|
967
|
-
minIndex = (_Math = Math).min.apply(_Math, _to_consumable_array(keyIndices));
|
|
968
|
-
maxIndex = (_Math1 = Math).max.apply(_Math1, _to_consumable_array(keyIndices));
|
|
969
|
-
startCol = (0, _columnutilitiests.a1Col)(minIndex + 1);
|
|
970
|
-
endCol = (0, _columnutilitiests.a1Col)(maxIndex + 1);
|
|
971
|
-
_state.label = 2;
|
|
972
|
-
case 2:
|
|
973
|
-
if (!true) return [
|
|
974
|
-
3,
|
|
975
|
-
7
|
|
976
|
-
];
|
|
977
|
-
endRow = startRow + chunkSize - 1;
|
|
978
|
-
range = "".concat(sheetTitle, "!").concat(startCol).concat(startRow, ":").concat(endCol).concat(endRow);
|
|
979
|
-
_state.label = 3;
|
|
980
|
-
case 3:
|
|
981
|
-
_state.trys.push([
|
|
982
|
-
3,
|
|
983
|
-
5,
|
|
984
|
-
,
|
|
985
|
-
6
|
|
986
|
-
]);
|
|
987
|
-
_loop = function(localRowIndex) {
|
|
988
|
-
var rawRow = rows[localRowIndex];
|
|
989
|
-
var globalRowNumber = startRow + localRowIndex;
|
|
990
|
-
// Reconstruct full row for key generation
|
|
991
|
-
var fullRow = new Array(header.length).fill('');
|
|
992
|
-
if (rawRow) {
|
|
993
|
-
keyIndices.forEach(function(globalIndex, _localIndex) {
|
|
994
|
-
var localRowArrayIndex = globalIndex - minIndex;
|
|
995
|
-
if (localRowArrayIndex >= 0 && localRowArrayIndex < rawRow.length) {
|
|
996
|
-
fullRow[globalIndex] = rawRow[localRowArrayIndex];
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
}
|
|
1000
|
-
var key = generateRowKey(fullRow, header, strategy);
|
|
1001
|
-
if (key.replace(/\\+/g, '') !== '') {
|
|
1002
|
-
keySet.add(key);
|
|
1003
|
-
keyToRowMap.set(key, globalRowNumber); // Store 1-indexed row number
|
|
1004
|
-
}
|
|
1005
|
-
};
|
|
1006
922
|
return [
|
|
1007
923
|
4,
|
|
1008
|
-
sheets
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
924
|
+
scanKeyRows(sheets, spreadsheetId, sheetTitle, header, keyIndices, strategy, function(key, rowNumber) {
|
|
925
|
+
keySet.add(key);
|
|
926
|
+
keyToRowMap.set(key, rowNumber); // Store 1-indexed row number
|
|
927
|
+
var seenRows = keyToRows.get(key);
|
|
928
|
+
if (seenRows) seenRows.push(rowNumber);
|
|
929
|
+
else keyToRows.set(key, [
|
|
930
|
+
rowNumber
|
|
931
|
+
]);
|
|
1012
932
|
})
|
|
1013
933
|
];
|
|
1014
|
-
case
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
if (
|
|
1018
|
-
3,
|
|
1019
|
-
7
|
|
1020
|
-
];
|
|
1021
|
-
for(localRowIndex = 0; localRowIndex < rows.length; localRowIndex++)_loop(localRowIndex);
|
|
1022
|
-
startRow += rows.length;
|
|
1023
|
-
if (rows.length < chunkSize) return [
|
|
1024
|
-
3,
|
|
1025
|
-
7
|
|
1026
|
-
]; // Last chunk
|
|
1027
|
-
return [
|
|
1028
|
-
3,
|
|
1029
|
-
6
|
|
1030
|
-
];
|
|
1031
|
-
case 5:
|
|
1032
|
-
unused = _state.sent();
|
|
1033
|
-
return [
|
|
1034
|
-
3,
|
|
1035
|
-
7
|
|
1036
|
-
]; // End of data or error
|
|
1037
|
-
case 6:
|
|
1038
|
-
return [
|
|
1039
|
-
3,
|
|
1040
|
-
2
|
|
1041
|
-
];
|
|
1042
|
-
case 7:
|
|
934
|
+
case 2:
|
|
935
|
+
_state.sent();
|
|
936
|
+
duplicateMessage = formatDuplicateSheetKeys(keyToRows);
|
|
937
|
+
if (duplicateMessage) throw new Error(duplicateMessage);
|
|
1043
938
|
return [
|
|
1044
939
|
2,
|
|
1045
940
|
{
|