bktide 1.0.1755559112 → 1.0.1755568192
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/commands/ShowBuild.js +4 -0
- package/dist/commands/ShowBuild.js.map +1 -1
- package/dist/formatters/build-detail/PlainTextFormatter.js +283 -112
- package/dist/formatters/build-detail/PlainTextFormatter.js.map +1 -1
- package/dist/formatters/builds/PlainTextFormatter.js +4 -2
- package/dist/formatters/builds/PlainTextFormatter.js.map +1 -1
- package/dist/formatters/pipelines/PlainTextFormatter.js +3 -6
- package/dist/formatters/pipelines/PlainTextFormatter.js.map +1 -1
- package/dist/graphql/queries.js +4 -0
- package/dist/graphql/queries.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/services/BuildkiteClient.js +32 -31
- package/dist/services/BuildkiteClient.js.map +1 -1
- package/dist/services/BuildkiteRestClient.js +8 -7
- package/dist/services/BuildkiteRestClient.js.map +1 -1
- package/dist/ui/theme.js +193 -8
- package/dist/ui/theme.js.map +1 -1
- package/dist/utils/terminal-links.js +165 -0
- package/dist/utils/terminal-links.js.map +1 -0
- package/package.json +1 -1
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EACL,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,SAAS,EACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,eAAe,E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AAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAClD,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC;AAEhB,4CAA4C;AAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;AAC/B,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,6CAA6C;IAC7C,WAAW,CAAC,OAAO,CAAC,CAAC;IACrB,MAAM,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;AACtD,CAAC;KAAM,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;IAC5B,WAAW,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9B,MAAM,CAAC,KAAK,CAAC,oBAAoB,OAAO,CAAC,QAAQ,yBAAyB,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,CAAC,KAAK,CAAC;IACX,GAAG,EAAE,OAAO,CAAC,GAAG;CACjB,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport {\n BaseCommand,\n ShowViewer,\n ListOrganizations,\n ListBuilds,\n ListPipelines,\n ManageToken,\n ListAnnotations,\n GenerateCompletions,\n ShowBuild\n} from './commands/index.js';\nimport { initializeErrorHandling } from './utils/errorUtils.js';\nimport { displayCLIError, setErrorFormat } from './utils/cli-error-handler.js';\nimport { logger, setLogLevel } from './services/logger.js';\nimport { WidthAwareHelp } from './ui/help.js';\n\n// Set a global error handler for uncaught exceptions\nconst uncaughtExceptionHandler = (err: Error) => {\n // Remove any existing handlers to avoid duplicates\n const handlers = process.listeners('uncaughtException');\n handlers.forEach(listener => {\n if (listener !== uncaughtExceptionHandler) {\n process.removeListener('uncaughtException', listener);\n }\n });\n \n displayCLIError(\n err, \n process.argv.includes('--debug')\n );\n};\nprocess.on('uncaughtException', uncaughtExceptionHandler);\n\n// Set a global error handler for unhandled promise rejections\nconst unhandledRejectionHandler = (reason: unknown) => {\n // Remove any existing handlers to avoid duplicates\n const handlers = process.listeners('unhandledRejection');\n handlers.forEach(listener => {\n if (listener !== unhandledRejectionHandler) {\n process.removeListener('unhandledRejection', listener);\n }\n });\n \n displayCLIError(\n reason, \n process.argv.includes('--debug')\n );\n};\nprocess.on('unhandledRejection', unhandledRejectionHandler);\n\n// Initialize error handling after our handlers are registered\ninitializeErrorHandling();\n\nconst program = new Command();\n\n// Define a generic interface for the command classes that includes the execute method\ninterface CommandWithExecute {\n execute(options: any): Promise<number>;\n}\n\n// Define a type for the constructor that includes static properties\ntype CommandConstructor = {\n new (options?: any): BaseCommand & CommandWithExecute;\n requiresToken: boolean;\n}\n\n// Extend the Command type to include our custom properties\ninterface ExtendedCommand extends Command {\n mergedOptions?: any;\n pipelineOptions?: {\n organization?: string;\n count?: number;\n filter?: string;\n };\n buildOptions?: {\n organization?: string;\n pipeline?: string;\n branch?: string;\n state?: string;\n count: number;\n page: number;\n filter?: string;\n };\n}\n\n// Handler for executing commands with proper option handling\nconst createCommandHandler = (CommandClass: CommandConstructor) => {\n return async function(this: ExtendedCommand) {\n try {\n const options = this.mergedOptions || this.opts();\n const cacheOptions = { enabled: options.cache !== false, ttl: options.cacheTtl, clear: options.clearCache };\n\n if (CommandClass.requiresToken) {\n const token = await BaseCommand.getToken(options);\n options.token = token;\n }\n \n const handler = new CommandClass({\n ...cacheOptions,\n token: options.token,\n debug: options.debug,\n format: options.format,\n quiet: options.quiet,\n tips: options.tips,\n });\n \n // Pass command-specific options if available\n const commandName = this.name();\n if (commandName === 'pipelines' && this.pipelineOptions) {\n logger.debug('Using pipeline options:', this.pipelineOptions);\n }\n else if (commandName === 'builds' && this.buildOptions) {\n logger.debug('Using build options:', this.buildOptions);\n }\n \n const exitCode = await handler.execute(options);\n // Set process.exitCode to propagate the exit code\n process.exitCode = exitCode;\n } catch (error) {\n const debug = this.mergedOptions?.debug || this.opts().debug || false;\n // No need to pass format - will use global format set in preAction hook\n displayCLIError(error, debug);\n process.exitCode = 1; // Set error exit code\n }\n };\n};\n\nfunction resolveAppVersion(): string {\n // Prefer environment-provided version (set in CI before publish)\n if (process.env.BKTIDE_VERSION && process.env.BKTIDE_VERSION.trim().length > 0) {\n return process.env.BKTIDE_VERSION.trim();\n }\n\n try {\n // Attempt to read package.json near compiled dist/index.js\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidatePaths = [\n path.resolve(__dirname, '..', 'package.json'), // when running from dist/\n path.resolve(__dirname, '..', '..', 'package.json'), // fallback\n ];\n for (const pkgPath of candidatePaths) {\n if (fs.existsSync(pkgPath)) {\n const raw = fs.readFileSync(pkgPath, 'utf-8');\n const pkg = JSON.parse(raw) as { version?: string };\n if (pkg.version) return pkg.version;\n }\n }\n } catch {\n // ignore\n }\n\n // Last resort\n return '0.0.0';\n}\n\n// Create custom help instance\nconst customHelp = new WidthAwareHelp();\n\nprogram\n .name('bktide')\n .description('Buildkite CLI tool')\n .version(resolveAppVersion())\n .configureHelp(customHelp)\n .showSuggestionAfterError()\n .option('--log-level <level>', 'Set logging level (trace, debug, info, warn, error, fatal)', 'info')\n .option('-d, --debug', 'Show debug information for errors')\n .option('--no-cache', 'Disable caching of API responses')\n .option('--cache-ttl <milliseconds>', 'Set cache time-to-live in milliseconds', parseInt)\n .option('--clear-cache', 'Clear all cached data before executing command')\n .option('-t, --token <token>', 'Buildkite API token (set BUILDKITE_API_TOKEN or BK_TOKEN env var)', process.env.BUILDKITE_API_TOKEN || process.env.BK_TOKEN)\n .option('--save-token', 'Save the token to system keychain for future use')\n .option('-f, --format <format>', 'Output format for results and errors (plain, json, alfred)', 'plain')\n .option('--color <mode>', 'Color output: auto|always|never', 'auto')\n .option('-q, --quiet', 'Suppress non-error output (plain format only)')\n .option('--tips', 'Show helpful tips and suggestions')\n .option('--no-tips', 'Hide helpful tips and suggestions')\n .option('--ascii', 'Use ASCII symbols instead of Unicode');\n\n// Add hooks for handling options\nprogram\n .hook('preAction', (_thisCommand, actionCommand) => {\n // Cast to our extended command type\n const cmd = actionCommand as unknown as ExtendedCommand;\n \n // Merge global options with command-specific options\n const globalOpts = program.opts();\n const commandOpts = cmd.opts();\n const mergedOptions = { ...globalOpts, ...commandOpts };\n \n // Set the global error format from the command line options\n if (mergedOptions.format) {\n setErrorFormat(mergedOptions.format);\n }\n\n // Apply color mode\n if (mergedOptions.color) {\n const mode = String(mergedOptions.color).toLowerCase();\n // Respect NO_COLOR when mode is never; clear when always\n if (mode === 'never') {\n process.env.NO_COLOR = '1';\n } else if (mode === 'always') {\n // Explicitly enable color by unsetting NO_COLOR; downstream code should still TTY-check\n if (process.env.NO_COLOR) {\n delete process.env.NO_COLOR;\n }\n process.env.BKTIDE_COLOR_MODE = 'always';\n } else {\n // auto\n process.env.BKTIDE_COLOR_MODE = 'auto';\n }\n }\n \n if (mergedOptions.cacheTtl && (isNaN(mergedOptions.cacheTtl) || mergedOptions.cacheTtl <= 0)) {\n logger.error('cache-ttl must be a positive number');\n process.exitCode = 1;\n return;\n }\n \n if (mergedOptions.cache === false && mergedOptions.cacheTtl) {\n logger.warn('--no-cache and --cache-ttl used together. Cache will be disabled regardless of TTL setting.');\n }\n \n // Validate count options\n if (mergedOptions.count && (isNaN(parseInt(mergedOptions.count)) || parseInt(mergedOptions.count) <= 0)) {\n logger.error('count must be a positive number');\n process.exitCode = 1;\n return;\n }\n\n cmd.mergedOptions = mergedOptions;\n\n const commandName = cmd.name();\n\n if (commandName === 'pipelines') {\n // Create pipeline-specific options structure\n cmd.pipelineOptions = {\n organization: mergedOptions.org,\n count: mergedOptions.count ? parseInt(mergedOptions.count) : undefined,\n filter: mergedOptions.filter\n };\n \n if (mergedOptions.debug) {\n logger.debug('Pipeline options:', cmd.pipelineOptions);\n }\n }\n else if (commandName === 'builds') {\n // Create builds-specific options structure\n cmd.buildOptions = {\n organization: mergedOptions.org,\n pipeline: mergedOptions.pipeline,\n branch: mergedOptions.branch,\n state: mergedOptions.state,\n count: mergedOptions.count ? parseInt(mergedOptions.count) : 10,\n page: mergedOptions.page ? parseInt(mergedOptions.page) : 1,\n filter: mergedOptions.filter\n };\n \n if (mergedOptions.debug) {\n logger.debug('Build options:', cmd.buildOptions);\n }\n }\n else if (commandName === 'annotations') {\n // Attach the build argument to options\n cmd.mergedOptions.buildArg = cmd.args?.[0];\n \n if (mergedOptions.debug) {\n logger.debug('Annotations build arg:', cmd.mergedOptions.buildArg);\n logger.debug('Annotations context filter:', mergedOptions.context);\n }\n }\n else if (commandName === 'build') {\n // Attach the build argument to options\n cmd.mergedOptions.buildArg = cmd.args?.[0];\n \n if (mergedOptions.debug) {\n logger.debug('Build arg:', cmd.mergedOptions.buildArg);\n logger.debug('Build options:', mergedOptions);\n }\n }\n \n if (mergedOptions.debug) {\n logger.debug(`Executing command: ${commandName}`);\n logger.debug('Options:', mergedOptions);\n }\n })\n .hook('postAction', (_thisCommand, actionCommand) => {\n // Cast to our extended command type\n const cmd = actionCommand as unknown as ExtendedCommand;\n \n // Accessing the custom property\n const options = cmd.mergedOptions || {};\n if (options.debug) {\n logger.debug(`Command ${cmd.name()} completed`);\n }\n });\n\nprogram\n .command('viewer')\n .description('Show logged in user information')\n .action(createCommandHandler(ShowViewer));\n\nprogram\n .command('orgs')\n .description('List organizations')\n .action(createCommandHandler(ListOrganizations));\n\nprogram\n .command('pipelines')\n .description('List pipelines for an organization')\n .option('-o, --org <org>', 'Organization slug (optional - will search all your orgs if not specified)')\n .option('-n, --count <count>', 'Limit to specified number of pipelines per organization')\n .option('--filter <name>', 'Filter pipelines by name (case insensitive)')\n .action(createCommandHandler(ListPipelines));\n\n// Update the builds command to include REST API filtering options\nprogram\n .command('builds')\n .description('List builds for the current user')\n .option('-o, --org <org>', 'Organization slug (optional - will search all your orgs if not specified)')\n .option('-p, --pipeline <pipeline>', 'Filter by pipeline slug')\n .option('-b, --branch <branch>', 'Filter by branch name')\n .option('-s, --state <state>', 'Filter by build state (running, scheduled, passed, failing, failed, canceled, etc.)')\n .option('-n, --count <count>', 'Number of builds per page', '10')\n .option('--page <page>', 'Page number', '1')\n .option('--filter <filter>', 'Fuzzy filter builds by name or other properties')\n .action(createCommandHandler(ListBuilds));\n\n// Add token management command\nprogram\n .command('token')\n .description('Manage API tokens')\n .option('--check', 'Check if a token is stored in the system keychain')\n .option('--store', 'Store a token in the system keychain')\n .option('--reset', 'Delete the stored token from system keychain')\n .action(createCommandHandler(ManageToken));\n\n// Add annotations command\nprogram\n .command('annotations')\n .description('Show annotations for a build')\n .argument('<build>', 'Build reference (org/pipeline/number or @https://buildkite.com/org/pipeline/builds/number)')\n .option('--context <context>', 'Filter annotations by context (e.g., rspec, build-resources)')\n .action(createCommandHandler(ListAnnotations));\n\n// Add build command\nprogram\n .command('build')\n .description('Show details for a specific build')\n .argument('<build>', 'Build reference (org/pipeline/number or @https://buildkite.com/org/pipeline/builds/number)')\n .option('--jobs', 'Show job summary and details')\n .option('--failed', 'Show only failed job details (implies --jobs)')\n .option('--annotations', 'Show annotation details with context')\n .option('--annotations-full', 'Show complete annotation content')\n .option('--full', 'Show all available information')\n .option('--summary', 'Single-line summary only (for scripts)')\n .action(createCommandHandler(ShowBuild));\n\n// Add completions command\nprogram\n .command('completions [shell]')\n .description('Generate shell completions')\n .action(async (shell) => {\n const handler = new GenerateCompletions();\n const exitCode = await handler.execute({ shell, quiet: program.opts().quiet, debug: program.opts().debug });\n process.exitCode = exitCode;\n });\n\nprogram\n .command('boom')\n .description('Test error handling')\n .option('--type <type>', 'Type of error to throw (basic, api, object)', 'basic')\n .option('--format <format>', 'Output format (plain, json, alfred)', 'plain')\n .action((options) => {\n switch (options.type) {\n case 'api':\n const apiError = new Error('API request failed');\n (apiError as any).response = {\n errors: [\n { message: 'Invalid token', path: ['viewer'] }\n ]\n };\n throw apiError;\n \n case 'object':\n throw {\n message: 'This is not an Error instance',\n code: 'CUSTOM_ERROR'\n };\n \n case 'basic':\n default:\n throw new Error('Boom! This is a test error');\n }\n });\n\nprogram.parse();\n\n// Apply log level from command line options\nconst options = program.opts();\nif (options.debug) {\n // Debug mode takes precedence over log-level\n setLogLevel('debug');\n logger.debug('Debug mode enabled via --debug flag');\n} else if (options.logLevel) {\n setLogLevel(options.logLevel);\n logger.debug(`Log level set to ${options.logLevel} via --log-level option`);\n}\n\nlogger.debug({ \n pid: process.pid, \n}, 'Buildkite CLI started'); "]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,OAAO,EACL,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,WAAW,EACX,eAAe,EACf,mBAAmB,EACnB,SAAS,EACV,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,qDAAqD;AACrD,MAAM,wBAAwB,GAAG,CAAC,GAAU,EAAE,EAAE;IAC9C,mDAAmD;IACnD,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;IACxD,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC1B,IAAI,QAAQ,KAAK,wBAAwB,EAAE,CAAC;YAC1C,OAAO,CAAC,cAAc,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;QACxD,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,eAAe,CACb,GAAG,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CAAC,QAAQ,yBAAyB,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,CAAC,KAAK,CAAC;IACX,GAAG,EAAE,OAAO,CAAC,GAAG;CACjB,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from 'commander';\nimport fs from 'fs';\nimport path from 'path';\nimport { fileURLToPath } from 'url';\n\nimport {\n BaseCommand,\n ShowViewer,\n ListOrganizations,\n ListBuilds,\n ListPipelines,\n ManageToken,\n ListAnnotations,\n GenerateCompletions,\n ShowBuild\n} from './commands/index.js';\nimport { initializeErrorHandling } from './utils/errorUtils.js';\nimport { displayCLIError, setErrorFormat } from './utils/cli-error-handler.js';\nimport { logger, setLogLevel } from './services/logger.js';\nimport { WidthAwareHelp } from './ui/help.js';\n\n// Set a global error handler for uncaught exceptions\nconst uncaughtExceptionHandler = (err: Error) => {\n // Remove any existing handlers to avoid duplicates\n const handlers = process.listeners('uncaughtException');\n handlers.forEach(listener => {\n if (listener !== uncaughtExceptionHandler) {\n process.removeListener('uncaughtException', listener);\n }\n });\n \n displayCLIError(\n err, \n process.argv.includes('--debug')\n );\n};\nprocess.on('uncaughtException', uncaughtExceptionHandler);\n\n// Set a global error handler for unhandled promise rejections\nconst unhandledRejectionHandler = (reason: unknown) => {\n // Remove any existing handlers to avoid duplicates\n const handlers = process.listeners('unhandledRejection');\n handlers.forEach(listener => {\n if (listener !== unhandledRejectionHandler) {\n process.removeListener('unhandledRejection', listener);\n }\n });\n \n displayCLIError(\n reason, \n process.argv.includes('--debug')\n );\n};\nprocess.on('unhandledRejection', unhandledRejectionHandler);\n\n// Initialize error handling after our handlers are registered\ninitializeErrorHandling();\n\nconst program = new Command();\n\n// Define a generic interface for the command classes that includes the execute method\ninterface CommandWithExecute {\n execute(options: any): Promise<number>;\n}\n\n// Define a type for the constructor that includes static properties\ntype CommandConstructor = {\n new (options?: any): BaseCommand & CommandWithExecute;\n requiresToken: boolean;\n}\n\n// Extend the Command type to include our custom properties\ninterface ExtendedCommand extends Command {\n mergedOptions?: any;\n pipelineOptions?: {\n organization?: string;\n count?: number;\n filter?: string;\n };\n buildOptions?: {\n organization?: string;\n pipeline?: string;\n branch?: string;\n state?: string;\n count: number;\n page: number;\n filter?: string;\n };\n}\n\n// Handler for executing commands with proper option handling\nconst createCommandHandler = (CommandClass: CommandConstructor) => {\n return async function(this: ExtendedCommand) {\n try {\n const options = this.mergedOptions || this.opts();\n const cacheOptions = { enabled: options.cache !== false, ttl: options.cacheTtl, clear: options.clearCache };\n\n if (CommandClass.requiresToken) {\n const token = await BaseCommand.getToken(options);\n options.token = token;\n }\n \n const handler = new CommandClass({\n ...cacheOptions,\n token: options.token,\n debug: options.debug,\n format: options.format,\n quiet: options.quiet,\n tips: options.tips,\n });\n \n // Pass command-specific options if available\n const commandName = this.name();\n if (commandName === 'pipelines' && this.pipelineOptions) {\n logger.debug('Using pipeline options:', this.pipelineOptions);\n }\n else if (commandName === 'builds' && this.buildOptions) {\n logger.debug('Using build options:', this.buildOptions);\n }\n \n const exitCode = await handler.execute(options);\n // Set process.exitCode to propagate the exit code\n process.exitCode = exitCode;\n } catch (error) {\n const debug = this.mergedOptions?.debug || this.opts().debug || false;\n // No need to pass format - will use global format set in preAction hook\n displayCLIError(error, debug);\n process.exitCode = 1; // Set error exit code\n }\n };\n};\n\nfunction resolveAppVersion(): string {\n // Prefer environment-provided version (set in CI before publish)\n if (process.env.BKTIDE_VERSION && process.env.BKTIDE_VERSION.trim().length > 0) {\n return process.env.BKTIDE_VERSION.trim();\n }\n\n try {\n // Attempt to read package.json near compiled dist/index.js\n const __filename = fileURLToPath(import.meta.url);\n const __dirname = path.dirname(__filename);\n const candidatePaths = [\n path.resolve(__dirname, '..', 'package.json'), // when running from dist/\n path.resolve(__dirname, '..', '..', 'package.json'), // fallback\n ];\n for (const pkgPath of candidatePaths) {\n if (fs.existsSync(pkgPath)) {\n const raw = fs.readFileSync(pkgPath, 'utf-8');\n const pkg = JSON.parse(raw) as { version?: string };\n if (pkg.version) return pkg.version;\n }\n }\n } catch {\n // ignore\n }\n\n // Last resort\n return '0.0.0';\n}\n\n// Create custom help instance\nconst customHelp = new WidthAwareHelp();\n\nprogram\n .name('bktide')\n .description('Buildkite CLI tool')\n .version(resolveAppVersion())\n .configureHelp(customHelp)\n .showSuggestionAfterError()\n .option('--log-level <level>', 'Set logging level (trace, debug, info, warn, error, fatal)', 'info')\n .option('-d, --debug', 'Show debug information for errors')\n .option('--no-cache', 'Disable caching of API responses')\n .option('--cache-ttl <milliseconds>', 'Set cache time-to-live in milliseconds', parseInt)\n .option('--clear-cache', 'Clear all cached data before executing command')\n .option('-t, --token <token>', 'Buildkite API token (set BUILDKITE_API_TOKEN or BK_TOKEN env var)', process.env.BUILDKITE_API_TOKEN || process.env.BK_TOKEN)\n .option('--save-token', 'Save the token to system keychain for future use')\n .option('-f, --format <format>', 'Output format for results and errors (plain, json, alfred)', 'plain')\n .option('--color <mode>', 'Color output: auto|always|never', 'auto')\n .option('-q, --quiet', 'Suppress non-error output (plain format only)')\n .option('--tips', 'Show helpful tips and suggestions')\n .option('--no-tips', 'Hide helpful tips and suggestions')\n .option('--ascii', 'Use ASCII symbols instead of Unicode');\n\n// Add hooks for handling options\nprogram\n .hook('preAction', (_thisCommand, actionCommand) => {\n // Cast to our extended command type\n const cmd = actionCommand as unknown as ExtendedCommand;\n \n // Merge global options with command-specific options\n const globalOpts = program.opts();\n const commandOpts = cmd.opts();\n const mergedOptions = { ...globalOpts, ...commandOpts };\n \n // Set the global error format from the command line options\n if (mergedOptions.format) {\n setErrorFormat(mergedOptions.format);\n }\n\n // Apply color mode\n if (mergedOptions.color) {\n const mode = String(mergedOptions.color).toLowerCase();\n // Respect NO_COLOR when mode is never; clear when always\n if (mode === 'never') {\n process.env.NO_COLOR = '1';\n } else if (mode === 'always') {\n // Explicitly enable color by unsetting NO_COLOR; downstream code should still TTY-check\n if (process.env.NO_COLOR) {\n delete process.env.NO_COLOR;\n }\n process.env.BKTIDE_COLOR_MODE = 'always';\n } else {\n // auto\n process.env.BKTIDE_COLOR_MODE = 'auto';\n }\n }\n \n if (mergedOptions.cacheTtl && (isNaN(mergedOptions.cacheTtl) || mergedOptions.cacheTtl <= 0)) {\n logger.error('cache-ttl must be a positive number');\n process.exitCode = 1;\n return;\n }\n \n if (mergedOptions.cache === false && mergedOptions.cacheTtl) {\n logger.warn('--no-cache and --cache-ttl used together. Cache will be disabled regardless of TTL setting.');\n }\n \n // Validate count options\n if (mergedOptions.count && (isNaN(parseInt(mergedOptions.count)) || parseInt(mergedOptions.count) <= 0)) {\n logger.error('count must be a positive number');\n process.exitCode = 1;\n return;\n }\n\n cmd.mergedOptions = mergedOptions;\n\n const commandName = cmd.name();\n\n if (commandName === 'pipelines') {\n // Create pipeline-specific options structure\n cmd.pipelineOptions = {\n organization: mergedOptions.org,\n count: mergedOptions.count ? parseInt(mergedOptions.count) : undefined,\n filter: mergedOptions.filter\n };\n \n if (mergedOptions.debug) {\n logger.debug('Pipeline options:', cmd.pipelineOptions);\n }\n }\n else if (commandName === 'builds') {\n // Create builds-specific options structure\n cmd.buildOptions = {\n organization: mergedOptions.org,\n pipeline: mergedOptions.pipeline,\n branch: mergedOptions.branch,\n state: mergedOptions.state,\n count: mergedOptions.count ? parseInt(mergedOptions.count) : 10,\n page: mergedOptions.page ? parseInt(mergedOptions.page) : 1,\n filter: mergedOptions.filter\n };\n \n if (mergedOptions.debug) {\n logger.debug('Build options:', cmd.buildOptions);\n }\n }\n else if (commandName === 'annotations') {\n // Attach the build argument to options\n cmd.mergedOptions.buildArg = cmd.args?.[0];\n \n if (mergedOptions.debug) {\n logger.debug('Annotations build arg:', cmd.mergedOptions.buildArg);\n logger.debug('Annotations context filter:', mergedOptions.context);\n }\n }\n else if (commandName === 'build') {\n // Attach the build argument to options\n cmd.mergedOptions.buildArg = cmd.args?.[0];\n \n if (mergedOptions.debug) {\n logger.debug('Build arg:', cmd.mergedOptions.buildArg);\n logger.debug('Build options:', mergedOptions);\n }\n }\n \n if (mergedOptions.debug) {\n logger.debug(`Executing command: ${commandName}`);\n logger.debug('Options:', mergedOptions);\n }\n })\n .hook('postAction', (_thisCommand, actionCommand) => {\n // Cast to our extended command type\n const cmd = actionCommand as unknown as ExtendedCommand;\n \n // Accessing the custom property\n const options = cmd.mergedOptions || {};\n if (options.debug) {\n logger.debug(`Command ${cmd.name()} completed`);\n }\n });\n\nprogram\n .command('viewer')\n .description('Show logged in user information')\n .action(createCommandHandler(ShowViewer));\n\nprogram\n .command('orgs')\n .description('List organizations')\n .action(createCommandHandler(ListOrganizations));\n\nprogram\n .command('pipelines')\n .description('List pipelines for an organization')\n .option('-o, --org <org>', 'Organization slug (optional - will search all your orgs if not specified)')\n .option('-n, --count <count>', 'Limit to specified number of pipelines per organization')\n .option('--filter <name>', 'Filter pipelines by name (case insensitive)')\n .action(createCommandHandler(ListPipelines));\n\n// Update the builds command to include REST API filtering options\nprogram\n .command('builds')\n .description('List builds for the current user')\n .option('-o, --org <org>', 'Organization slug (optional - will search all your orgs if not specified)')\n .option('-p, --pipeline <pipeline>', 'Filter by pipeline slug')\n .option('-b, --branch <branch>', 'Filter by branch name')\n .option('-s, --state <state>', 'Filter by build state (running, scheduled, passed, failing, failed, canceled, etc.)')\n .option('-n, --count <count>', 'Number of builds per page', '10')\n .option('--page <page>', 'Page number', '1')\n .option('--filter <filter>', 'Fuzzy filter builds by name or other properties')\n .action(createCommandHandler(ListBuilds));\n\n// Add token management command\nprogram\n .command('token')\n .description('Manage API tokens')\n .option('--check', 'Check if a token is stored in the system keychain')\n .option('--store', 'Store a token in the system keychain')\n .option('--reset', 'Delete the stored token from system keychain')\n .action(createCommandHandler(ManageToken));\n\n// Add annotations command\nprogram\n .command('annotations')\n .description('Show annotations for a build')\n .argument('<build>', 'Build reference (org/pipeline/number or @https://buildkite.com/org/pipeline/builds/number)')\n .option('--context <context>', 'Filter annotations by context (e.g., rspec, build-resources)')\n .action(createCommandHandler(ListAnnotations));\n\n// Add build command\nprogram\n .command('build')\n .description('Show details for a specific build')\n .argument('<build>', 'Build reference (org/pipeline/number or @https://buildkite.com/org/pipeline/builds/number)')\n .option('--jobs', 'Show job summary and details')\n .option('--failed', 'Show only failed job details (implies --jobs)')\n .option('--all-jobs', 'Show all jobs without grouping limit')\n .option('--annotations', 'Show annotation details with context')\n .option('--annotations-full', 'Show complete annotation content')\n .option('--full', 'Show all available information')\n .option('--summary', 'Single-line summary only (for scripts)')\n .action(createCommandHandler(ShowBuild));\n\n// Add completions command\nprogram\n .command('completions [shell]')\n .description('Generate shell completions')\n .action(async (shell) => {\n const handler = new GenerateCompletions();\n const exitCode = await handler.execute({ shell, quiet: program.opts().quiet, debug: program.opts().debug });\n process.exitCode = exitCode;\n });\n\nprogram\n .command('boom')\n .description('Test error handling')\n .option('--type <type>', 'Type of error to throw (basic, api, object)', 'basic')\n .option('--format <format>', 'Output format (plain, json, alfred)', 'plain')\n .action((options) => {\n switch (options.type) {\n case 'api':\n const apiError = new Error('API request failed');\n (apiError as any).response = {\n errors: [\n { message: 'Invalid token', path: ['viewer'] }\n ]\n };\n throw apiError;\n \n case 'object':\n throw {\n message: 'This is not an Error instance',\n code: 'CUSTOM_ERROR'\n };\n \n case 'basic':\n default:\n throw new Error('Boom! This is a test error');\n }\n });\n\nprogram.parse();\n\n// Apply log level from command line options\nconst options = program.opts();\nif (options.debug) {\n // Debug mode takes precedence over log-level\n setLogLevel('debug');\n logger.debug('Debug mode enabled via --debug flag');\n} else if (options.logLevel) {\n setLogLevel(options.logLevel);\n logger.debug(`Log level set to ${options.logLevel} via --log-level option`);\n}\n\nlogger.debug({ \n pid: process.pid, \n}, 'Buildkite CLI started'); "]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { GraphQLClient } from 'graphql-request';
|
|
2
2
|
import { CacheManager } from './CacheManager.js';
|
|
3
|
+
import { getProgressIcon } from '../ui/theme.js';
|
|
3
4
|
// Import the queries - we'll use them for both string queries and typed SDK
|
|
4
5
|
import { GET_VIEWER, GET_ORGANIZATIONS, GET_PIPELINES, GET_BUILDS, GET_VIEWER_BUILDS, GET_BUILD_ANNOTATIONS, GET_BUILD_SUMMARY, GET_BUILD_FULL } from '../graphql/queries.js';
|
|
5
6
|
import { logger } from './logger.js';
|
|
@@ -72,7 +73,7 @@ export class BuildkiteClient {
|
|
|
72
73
|
const startTime = process.hrtime.bigint();
|
|
73
74
|
const operationName = query.match(/query\s+(\w+)?/)?.[1] || 'UnnamedQuery';
|
|
74
75
|
if (this.debug) {
|
|
75
|
-
logger.debug(
|
|
76
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: ${operationName}`);
|
|
76
77
|
}
|
|
77
78
|
// Check if result is in cache
|
|
78
79
|
if (this.cacheManager) {
|
|
@@ -82,7 +83,7 @@ export class BuildkiteClient {
|
|
|
82
83
|
const cachedResult = await this.cacheManager.get(query, variables);
|
|
83
84
|
if (cachedResult) {
|
|
84
85
|
if (this.debug) {
|
|
85
|
-
logger.debug(
|
|
86
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: ${operationName}`);
|
|
86
87
|
}
|
|
87
88
|
return cachedResult;
|
|
88
89
|
}
|
|
@@ -95,7 +96,7 @@ export class BuildkiteClient {
|
|
|
95
96
|
const endTime = process.hrtime.bigint();
|
|
96
97
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
97
98
|
if (this.debug) {
|
|
98
|
-
logger.debug(
|
|
99
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: ${operationName} (${duration.toFixed(2)}ms)`);
|
|
99
100
|
}
|
|
100
101
|
return response;
|
|
101
102
|
}
|
|
@@ -165,7 +166,7 @@ export class BuildkiteClient {
|
|
|
165
166
|
const startTime = process.hrtime.bigint();
|
|
166
167
|
const operationName = mutation.match(/mutation\s+(\w+)?/)?.[1] || 'UnnamedMutation';
|
|
167
168
|
if (this.debug) {
|
|
168
|
-
logger.debug(
|
|
169
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL mutation: ${operationName}`);
|
|
169
170
|
}
|
|
170
171
|
const result = await this.client.request(mutation, variables);
|
|
171
172
|
// Invalidate relevant caches after mutations
|
|
@@ -180,7 +181,7 @@ export class BuildkiteClient {
|
|
|
180
181
|
}
|
|
181
182
|
const endTime = process.hrtime.bigint();
|
|
182
183
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
183
|
-
logger.debug(
|
|
184
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL mutation completed: ${operationName} (${duration.toFixed(2)}ms)`);
|
|
184
185
|
return result;
|
|
185
186
|
}
|
|
186
187
|
catch (error) {
|
|
@@ -196,7 +197,7 @@ export class BuildkiteClient {
|
|
|
196
197
|
try {
|
|
197
198
|
const startTime = process.hrtime.bigint();
|
|
198
199
|
if (this.debug) {
|
|
199
|
-
logger.debug(
|
|
200
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: getViewerOrganizationSlugs`);
|
|
200
201
|
}
|
|
201
202
|
// Get the organizations using our query
|
|
202
203
|
if (this.debug) {
|
|
@@ -234,7 +235,7 @@ export class BuildkiteClient {
|
|
|
234
235
|
const endTime = process.hrtime.bigint();
|
|
235
236
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
236
237
|
if (this.debug) {
|
|
237
|
-
logger.debug(
|
|
238
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} Found ${slugs.length} organizations (${duration.toFixed(2)}ms)`);
|
|
238
239
|
}
|
|
239
240
|
return slugs;
|
|
240
241
|
}
|
|
@@ -287,14 +288,14 @@ export class BuildkiteClient {
|
|
|
287
288
|
*/
|
|
288
289
|
async getViewer() {
|
|
289
290
|
if (this.debug) {
|
|
290
|
-
logger.debug(
|
|
291
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetViewer`);
|
|
291
292
|
}
|
|
292
293
|
// Check if result is in cache
|
|
293
294
|
if (this.cacheManager) {
|
|
294
295
|
const cachedResult = await this.cacheManager.get(GET_VIEWER.toString(), {});
|
|
295
296
|
if (cachedResult) {
|
|
296
297
|
if (this.debug) {
|
|
297
|
-
logger.debug(
|
|
298
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetViewer`);
|
|
298
299
|
}
|
|
299
300
|
return cachedResult;
|
|
300
301
|
}
|
|
@@ -308,7 +309,7 @@ export class BuildkiteClient {
|
|
|
308
309
|
const endTime = process.hrtime.bigint();
|
|
309
310
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
310
311
|
if (this.debug) {
|
|
311
|
-
logger.debug(
|
|
312
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetViewer (${duration.toFixed(2)}ms)`);
|
|
312
313
|
}
|
|
313
314
|
return result;
|
|
314
315
|
}
|
|
@@ -318,14 +319,14 @@ export class BuildkiteClient {
|
|
|
318
319
|
*/
|
|
319
320
|
async getOrganizations() {
|
|
320
321
|
if (this.debug) {
|
|
321
|
-
logger.debug(
|
|
322
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetOrganizations`);
|
|
322
323
|
}
|
|
323
324
|
// Check if result is in cache
|
|
324
325
|
if (this.cacheManager) {
|
|
325
326
|
const cachedResult = await this.cacheManager.get(GET_ORGANIZATIONS.toString(), {});
|
|
326
327
|
if (cachedResult) {
|
|
327
328
|
if (this.debug) {
|
|
328
|
-
logger.debug(
|
|
329
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetOrganizations`);
|
|
329
330
|
}
|
|
330
331
|
return this.processOrganizationsResponse(cachedResult);
|
|
331
332
|
}
|
|
@@ -339,7 +340,7 @@ export class BuildkiteClient {
|
|
|
339
340
|
const endTime = process.hrtime.bigint();
|
|
340
341
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
341
342
|
if (this.debug) {
|
|
342
|
-
logger.debug(
|
|
343
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetOrganizations (${duration.toFixed(2)}ms)`);
|
|
343
344
|
}
|
|
344
345
|
return this.processOrganizationsResponse(result);
|
|
345
346
|
}
|
|
@@ -375,14 +376,14 @@ export class BuildkiteClient {
|
|
|
375
376
|
after,
|
|
376
377
|
};
|
|
377
378
|
if (this.debug) {
|
|
378
|
-
logger.debug(
|
|
379
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetPipelines for ${organizationSlug}`);
|
|
379
380
|
}
|
|
380
381
|
// Check if result is in cache
|
|
381
382
|
if (this.cacheManager) {
|
|
382
383
|
const cachedResult = await this.cacheManager.get(GET_PIPELINES.toString(), variables);
|
|
383
384
|
if (cachedResult) {
|
|
384
385
|
if (this.debug) {
|
|
385
|
-
logger.debug(
|
|
386
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetPipelines`);
|
|
386
387
|
}
|
|
387
388
|
return cachedResult;
|
|
388
389
|
}
|
|
@@ -396,7 +397,7 @@ export class BuildkiteClient {
|
|
|
396
397
|
const endTime = process.hrtime.bigint();
|
|
397
398
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
398
399
|
if (this.debug) {
|
|
399
|
-
logger.debug(
|
|
400
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetPipelines (${duration.toFixed(2)}ms)`);
|
|
400
401
|
}
|
|
401
402
|
return result;
|
|
402
403
|
}
|
|
@@ -414,14 +415,14 @@ export class BuildkiteClient {
|
|
|
414
415
|
first,
|
|
415
416
|
};
|
|
416
417
|
if (this.debug) {
|
|
417
|
-
logger.debug(
|
|
418
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetBuilds for ${pipelineSlug} in ${organizationSlug}`);
|
|
418
419
|
}
|
|
419
420
|
// Check if result is in cache
|
|
420
421
|
if (this.cacheManager) {
|
|
421
422
|
const cachedResult = await this.cacheManager.get(GET_BUILDS.toString(), variables);
|
|
422
423
|
if (cachedResult) {
|
|
423
424
|
if (this.debug) {
|
|
424
|
-
logger.debug(
|
|
425
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetBuilds`);
|
|
425
426
|
}
|
|
426
427
|
return cachedResult;
|
|
427
428
|
}
|
|
@@ -435,7 +436,7 @@ export class BuildkiteClient {
|
|
|
435
436
|
const endTime = process.hrtime.bigint();
|
|
436
437
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
437
438
|
if (this.debug) {
|
|
438
|
-
logger.debug(
|
|
439
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetBuilds (${duration.toFixed(2)}ms)`);
|
|
439
440
|
}
|
|
440
441
|
return result;
|
|
441
442
|
}
|
|
@@ -449,14 +450,14 @@ export class BuildkiteClient {
|
|
|
449
450
|
first,
|
|
450
451
|
};
|
|
451
452
|
if (this.debug) {
|
|
452
|
-
logger.debug(
|
|
453
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetViewerBuilds`);
|
|
453
454
|
}
|
|
454
455
|
// Check if result is in cache
|
|
455
456
|
if (this.cacheManager) {
|
|
456
457
|
const cachedResult = await this.cacheManager.get(GET_VIEWER_BUILDS.toString(), variables);
|
|
457
458
|
if (cachedResult) {
|
|
458
459
|
if (this.debug) {
|
|
459
|
-
logger.debug(
|
|
460
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetViewerBuilds`);
|
|
460
461
|
}
|
|
461
462
|
return cachedResult;
|
|
462
463
|
}
|
|
@@ -470,7 +471,7 @@ export class BuildkiteClient {
|
|
|
470
471
|
const endTime = process.hrtime.bigint();
|
|
471
472
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
472
473
|
if (this.debug) {
|
|
473
|
-
logger.debug(
|
|
474
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetViewerBuilds (${duration.toFixed(2)}ms)`);
|
|
474
475
|
}
|
|
475
476
|
return result;
|
|
476
477
|
}
|
|
@@ -491,14 +492,14 @@ export class BuildkiteClient {
|
|
|
491
492
|
buildSlug,
|
|
492
493
|
};
|
|
493
494
|
if (this.debug) {
|
|
494
|
-
logger.debug(
|
|
495
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetBuildAnnotations for ${buildSlug}`);
|
|
495
496
|
}
|
|
496
497
|
// Check if result is in cache
|
|
497
498
|
if (this.cacheManager) {
|
|
498
499
|
const cachedResult = await this.cacheManager.get(GET_BUILD_ANNOTATIONS.toString(), variables);
|
|
499
500
|
if (cachedResult) {
|
|
500
501
|
if (this.debug) {
|
|
501
|
-
logger.debug(
|
|
502
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetBuildAnnotations`);
|
|
502
503
|
}
|
|
503
504
|
return cachedResult;
|
|
504
505
|
}
|
|
@@ -512,7 +513,7 @@ export class BuildkiteClient {
|
|
|
512
513
|
const endTime = process.hrtime.bigint();
|
|
513
514
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
514
515
|
if (this.debug) {
|
|
515
|
-
logger.debug(
|
|
516
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetBuildAnnotations (${duration.toFixed(2)}ms)`);
|
|
516
517
|
}
|
|
517
518
|
return result;
|
|
518
519
|
}
|
|
@@ -521,14 +522,14 @@ export class BuildkiteClient {
|
|
|
521
522
|
slug: buildSlug,
|
|
522
523
|
};
|
|
523
524
|
if (this.debug) {
|
|
524
|
-
logger.debug(
|
|
525
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetBuildSummary for ${buildSlug}`);
|
|
525
526
|
}
|
|
526
527
|
// Check if result is in cache
|
|
527
528
|
if (this.cacheManager) {
|
|
528
529
|
const cachedResult = await this.cacheManager.get('GET_BUILD_SUMMARY', variables);
|
|
529
530
|
if (cachedResult) {
|
|
530
531
|
if (this.debug) {
|
|
531
|
-
logger.debug(
|
|
532
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetBuildSummary`);
|
|
532
533
|
}
|
|
533
534
|
return cachedResult;
|
|
534
535
|
}
|
|
@@ -542,7 +543,7 @@ export class BuildkiteClient {
|
|
|
542
543
|
const endTime = process.hrtime.bigint();
|
|
543
544
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
544
545
|
if (this.debug) {
|
|
545
|
-
logger.debug(
|
|
546
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetBuildSummary (${duration.toFixed(2)}ms)`);
|
|
546
547
|
}
|
|
547
548
|
return result;
|
|
548
549
|
}
|
|
@@ -551,14 +552,14 @@ export class BuildkiteClient {
|
|
|
551
552
|
slug: buildSlug,
|
|
552
553
|
};
|
|
553
554
|
if (this.debug) {
|
|
554
|
-
logger.debug(
|
|
555
|
+
logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetBuildFull for ${buildSlug}`);
|
|
555
556
|
}
|
|
556
557
|
// Check if result is in cache
|
|
557
558
|
if (this.cacheManager) {
|
|
558
559
|
const cachedResult = await this.cacheManager.get('GET_BUILD_FULL', variables);
|
|
559
560
|
if (cachedResult) {
|
|
560
561
|
if (this.debug) {
|
|
561
|
-
logger.debug(
|
|
562
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetBuildFull`);
|
|
562
563
|
}
|
|
563
564
|
return cachedResult;
|
|
564
565
|
}
|
|
@@ -572,7 +573,7 @@ export class BuildkiteClient {
|
|
|
572
573
|
const endTime = process.hrtime.bigint();
|
|
573
574
|
const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds
|
|
574
575
|
if (this.debug) {
|
|
575
|
-
logger.debug(
|
|
576
|
+
logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetBuildFull (${duration.toFixed(2)}ms)`);
|
|
576
577
|
}
|
|
577
578
|
return result;
|
|
578
579
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,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAM,cAAc,CAAC,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC;QAEpF,8CAA8C;QAC9C,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACnE,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,0BAA0B;QAClF,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,4CAA4C,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACrF,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { GraphQLClient } from 'graphql-request';\nimport { CacheManager } from './CacheManager.js';\n// Import the queries - we'll use them for both string queries and typed SDK\nimport { \n GET_VIEWER, \n GET_ORGANIZATIONS, \n GET_PIPELINES, \n GET_BUILDS, \n GET_VIEWER_BUILDS,\n GET_BUILD_ANNOTATIONS,\n GET_BUILD_SUMMARY,\n GET_BUILD_FULL\n} from '../graphql/queries.js';\n// Import generated types\nimport { \n GetViewerQuery, \n GetOrganizationsQuery, \n GetPipelinesQuery, \n GetPipelinesQueryVariables,\n GetBuildsQuery,\n GetBuildsQueryVariables,\n GetViewerBuildsQuery,\n GetViewerBuildsQueryVariables,\n} from '../graphql/generated/sdk.js';\nimport { logger } from './logger.js';\n\n// Note: We're now using the automatically generated types from GraphQL Codegen\n\nexport interface BuildkiteClientOptions {\n debug?: boolean;\n baseUrl?: string;\n caching?: boolean;\n cacheTTLs?: Partial<{\n viewer: number;\n organizations: number;\n pipelines: number;\n builds: number;\n default: number;\n }>;\n}\n\nexport interface RateLimitInfo {\n remaining: number;\n limit: number;\n reset: number;\n}\n\n/**\n * BuildkiteClient provides methods to interact with the Buildkite GraphQL API\n */\nexport class BuildkiteClient {\n private client: GraphQLClient;\n private token: string;\n private baseUrl: string = 'https://graphql.buildkite.com/v1';\n private cacheManager: CacheManager | null = null;\n private debug: boolean = false;\n private rateLimitInfo: RateLimitInfo | null = null;\n /**\n * Create a new BuildkiteClient\n * @param token Your Buildkite API token\n * @param options Configuration options\n */\n constructor(token: string, options?: BuildkiteClientOptions, debug?: boolean) {\n this.token = token;\n this.debug = debug || options?.debug || false;\n \n if (this.debug) {\n logger.debug('Initializing BuildkiteClient with options:', {\n baseUrl: options?.baseUrl || this.baseUrl,\n caching: options?.caching !== false,\n debug: this.debug,\n tokenLength: token ? token.length : 0\n });\n }\n \n if (options?.baseUrl) {\n this.baseUrl = options.baseUrl;\n }\n\n this.client = new GraphQLClient(this.baseUrl, {\n headers: {\n Authorization: `Bearer ${this.token}`,\n },\n });\n\n // Initialize cache if caching is enabled\n if (options?.caching !== false) {\n if (this.debug) {\n logger.debug('BuildkiteClient constructor - creating CacheManager');\n }\n this.cacheManager = new CacheManager(options?.cacheTTLs, this.debug);\n // Initialize cache and set token hash (async, but we don't wait)\n this.initCache();\n } else {\n if (this.debug) {\n logger.debug('BuildkiteClient constructor - caching disabled');\n }\n }\n }\n\n /**\n * Initialize cache asynchronously\n */\n private async initCache(): Promise<void> {\n if (this.cacheManager) {\n await this.cacheManager.init();\n await this.cacheManager.setTokenHash(this.token);\n }\n }\n\n /**\n * Execute a GraphQL query\n * @param query The GraphQL query\n * @param variables Variables for the query\n * @returns The query response\n */\n public async query<T = unknown, V extends Record<string, any> = Record<string, any>>(\n query: string,\n variables?: V\n ): Promise<T> {\n try {\n const startTime = process.hrtime.bigint();\n const operationName = query.match(/query\\s+(\\w+)?/)?.[1] || 'UnnamedQuery';\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL query: ${operationName}`);\n }\n \n // Check if result is in cache\n if (this.cacheManager) {\n if (this.debug) {\n logger.debug('query() - cacheManager exists, checking cache');\n }\n const cachedResult = await this.cacheManager.get<T>(query, variables);\n \n if (cachedResult) {\n if (this.debug) {\n logger.debug(`✅ Served from cache: ${operationName}`);\n }\n return cachedResult;\n }\n }\n \n const response = await this.client.request<T>(query, variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(query, response, variables);\n }\n \n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`✅ GraphQL query completed: ${operationName} (${duration.toFixed(2)}ms)`);\n }\n \n return response;\n } catch (error: unknown) {\n const isAuthError = this.isAuthenticationError(error as any);\n if (isAuthError && this.debug) {\n logger.debug('Authentication error detected, not caching result');\n }\n \n if (this.debug) {\n logger.error(error as any, 'Error in GraphQL query');\n // Log raw error information\n logger.debug('Raw error object:', { \n error, \n type: typeof error, \n constructor: (error as any)?.constructor?.name,\n keys: error && typeof error === 'object' ? Object.keys(error as any) : undefined\n });\n // Log more detailed error information\n if (error instanceof Error && 'response' in (error as any)) {\n const response = (error as any).response;\n logger.debug('GraphQL error details:', {\n status: response?.status,\n statusText: response?.statusText,\n errors: response?.errors,\n data: response?.data,\n headers: response?.headers ? Object.fromEntries(response.headers.entries()) : undefined\n });\n }\n }\n throw error;\n }\n }\n\n /**\n * Check if an error is an authentication error\n */\n private isAuthenticationError(error: any): boolean {\n // Check for common authentication error patterns\n if (error.response?.errors) {\n const errors = error.response.errors;\n return errors.some((err: any) => \n err.message?.includes('unauthorized') || \n err.message?.includes('authentication') || \n err.message?.includes('permission') ||\n err.message?.includes('invalid token')\n );\n }\n \n // Check for HTTP status codes that indicate auth issues\n if (error.response?.status) {\n const status = error.response.status;\n return status === 401 || status === 403;\n }\n \n // Check error message directly\n if (error.message) {\n return error.message.includes('unauthorized') || \n error.message.includes('authentication') || \n error.message.includes('permission') ||\n error.message.includes('invalid token');\n }\n \n return false;\n }\n\n /**\n * Execute a GraphQL mutation\n * @param mutation The GraphQL mutation\n * @param variables Variables for the mutation\n * @returns The mutation response\n */\n public async mutate<T = unknown, V extends Record<string, any> = Record<string, any>>(\n mutation: string,\n variables?: V\n ): Promise<T> {\n try {\n const startTime = process.hrtime.bigint();\n const operationName = mutation.match(/mutation\\s+(\\w+)?/)?.[1] || 'UnnamedMutation';\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL mutation: ${operationName}`);\n }\n \n const result = await this.client.request<T>(mutation, variables);\n \n // Invalidate relevant caches after mutations\n if (this.cacheManager) {\n // Determine what cache types to invalidate based on mutation name/content\n if (mutation.includes('Pipeline')) {\n await this.cacheManager.invalidateType('pipelines');\n } else if (mutation.includes('Build')) {\n await this.cacheManager.invalidateType('builds');\n }\n }\n \n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n logger.debug(`✅ GraphQL mutation completed: ${operationName} (${duration.toFixed(2)}ms)`);\n \n return result;\n } catch (error) {\n logger.error('GraphQL mutation error:', error);\n throw error;\n }\n }\n\n /**\n * Get the organization slugs for the current viewer\n * @returns An array of organization slugs the current user belongs to\n */\n public async getViewerOrganizationSlugs(): Promise<string[]> {\n try {\n const startTime = process.hrtime.bigint();\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL query: getViewerOrganizationSlugs`);\n }\n \n // Get the organizations using our query\n if (this.debug) {\n logger.debug('About to call this.query with GET_ORGANIZATIONS');\n }\n const data = await this.query<GetOrganizationsQuery>(GET_ORGANIZATIONS.toString());\n if (this.debug) {\n logger.debug('Successfully got data from this.query');\n }\n \n if (this.debug) {\n logger.debug('Raw GraphQL response for organizations:', {\n hasData: !!data,\n hasViewer: !!data?.viewer,\n hasOrganizations: !!data?.viewer?.organizations,\n hasEdges: !!data?.viewer?.organizations?.edges,\n edgesLength: data?.viewer?.organizations?.edges?.length || 0\n });\n }\n \n // Use our helper method to process the response\n const organizations = this.processOrganizationsResponse(data);\n \n if (this.debug) {\n logger.debug('Processed organizations:', {\n count: organizations.length,\n organizations: organizations.map(org => ({ id: org.id, name: org.name, slug: org.slug }))\n });\n }\n \n if (organizations.length === 0) {\n if (this.debug) {\n logger.debug('No organizations found in response', { data });\n }\n return []\n }\n \n // Map to just the slugs\n const slugs = organizations.map(org => org.slug);\n \n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`✅ Found ${slugs.length} organizations (${duration.toFixed(2)}ms)`);\n }\n \n return slugs;\n } catch (error) {\n if (this.debug) {\n logger.debug('GraphQL query failed', {\n error: error instanceof Error ? error.message : String(error),\n details: error instanceof Error ? error : undefined\n });\n \n // Log more detailed error information\n if (error instanceof Error && 'response' in error) {\n const response = (error as any).response;\n logger.debug('GraphQL error response:', {\n status: response?.status,\n statusText: response?.statusText,\n errors: response?.errors,\n data: response?.data\n });\n }\n \n // Log detailed error information\n logger.debug('Error in getViewerOrganizationSlugs:', {\n errorMessage: error instanceof Error ? error.message : String(error),\n errorType: error?.constructor?.name,\n hasResponse: error instanceof Error && 'response' in error,\n response: error instanceof Error && 'response' in error ? (error as any).response : undefined\n });\n }\n throw new Error('Failed to determine your organizations', { cause: error });\n }\n }\n\n /**\n * Clear all cache entries\n */\n public async clearCache(): Promise<void> {\n if (this.cacheManager) {\n await this.cacheManager.clear();\n }\n }\n\n /**\n * Invalidate a specific cache type\n */\n public async invalidateCache(type: string): Promise<void> {\n if (this.cacheManager) {\n await this.cacheManager.invalidateType(type);\n }\n }\n\n /**\n * Get the current viewer information with type safety\n * @returns The viewer data\n */\n public async getViewer(): Promise<GetViewerQuery> {\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL query: GetViewer`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<GetViewerQuery>(GET_VIEWER.toString(), {});\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`✅ Served from cache: GetViewer`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<GetViewerQuery>(GET_VIEWER.toString());\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_VIEWER.toString(), result, {});\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`✅ GraphQL query completed: GetViewer (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n /**\n * Get organizations for the current viewer\n * @returns An array of organization objects with id, name, and slug\n */\n public async getOrganizations(): Promise<Array<{ id: string; name: string; slug: string; }>> {\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL query: GetOrganizations`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<GetOrganizationsQuery>(GET_ORGANIZATIONS.toString(), {});\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`✅ Served from cache: GetOrganizations`);\n }\n return this.processOrganizationsResponse(cachedResult);\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<GetOrganizationsQuery>(GET_ORGANIZATIONS.toString());\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_ORGANIZATIONS.toString(), result, {});\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`✅ GraphQL query completed: GetOrganizations (${duration.toFixed(2)}ms)`);\n }\n\n return this.processOrganizationsResponse(result);\n }\n\n /**\n * Process the raw GraphQL organizations response into a clean array\n * @param data The raw GraphQL response\n * @returns A processed array of organization objects\n * @private\n */\n private processOrganizationsResponse(data: GetOrganizationsQuery): Array<{ id: string; name: string; slug: string; }> {\n if (!data?.viewer?.organizations?.edges) {\n return [];\n }\n \n const edges = data.viewer.organizations.edges;\n \n // Filter out null edges and map to non-null nodes\n const organizations = edges\n .filter((edge): edge is NonNullable<typeof edge> => edge !== null)\n .map(edge => edge.node)\n .filter((node): node is NonNullable<typeof node> => node !== null);\n \n return organizations;\n }\n\n /**\n * Get pipelines for an organization with type safety\n * @param organizationSlug The organization slug\n * @param first Number of pipelines to retrieve\n * @param after Cursor for pagination\n * @returns The pipelines data\n */\n public async getPipelines(\n organizationSlug: string, \n first?: number, \n after?: string\n ): Promise<GetPipelinesQuery> {\n const variables: GetPipelinesQueryVariables = {\n organizationSlug,\n first,\n after,\n };\n\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL query: GetPipelines for ${organizationSlug}`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<GetPipelinesQuery>(GET_PIPELINES.toString(), variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`✅ Served from cache: GetPipelines`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<GetPipelinesQuery>(GET_PIPELINES.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_PIPELINES.toString(), result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`✅ GraphQL query completed: GetPipelines (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n /**\n * Get builds for a pipeline with type safety\n * @param pipelineSlug The pipeline slug\n * @param organizationSlug The organization slug\n * @param first Number of builds to retrieve\n * @returns The builds data\n */\n public async getBuilds(\n pipelineSlug: string,\n organizationSlug: string,\n first?: number\n ): Promise<GetBuildsQuery> {\n const variables: GetBuildsQueryVariables = {\n pipelineSlug,\n organizationSlug,\n first,\n };\n\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL query: GetBuilds for ${pipelineSlug} in ${organizationSlug}`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<GetBuildsQuery>(GET_BUILDS.toString(), variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`✅ Served from cache: GetBuilds`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<GetBuildsQuery>(GET_BUILDS.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_BUILDS.toString(), result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`✅ GraphQL query completed: GetBuilds (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n /**\n * Get builds for the current viewer with type safety\n * @param first Number of builds to retrieve\n * @returns The viewer builds data\n */\n public async getViewerBuilds(first: number): Promise<GetViewerBuildsQuery> {\n const variables: GetViewerBuildsQueryVariables = {\n first,\n };\n\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL query: GetViewerBuilds`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<GetViewerBuildsQuery>(GET_VIEWER_BUILDS.toString(), variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`✅ Served from cache: GetViewerBuilds`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<GetViewerBuildsQuery>(GET_VIEWER_BUILDS.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_VIEWER_BUILDS.toString(), result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`✅ GraphQL query completed: GetViewerBuilds (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n /**\n * Get the current rate limit information\n * @returns Current rate limit information or null if not available\n */\n public getRateLimitInfo(): RateLimitInfo | null {\n return this.rateLimitInfo;\n }\n\n /**\n * Get annotations for a build with type safety\n * @param buildSlug The build slug (e.g., \"org/pipeline/number\")\n * @returns The build annotations data\n */\n public async getBuildAnnotations(buildSlug: string): Promise<any> {\n const variables = {\n buildSlug,\n };\n\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL query: GetBuildAnnotations for ${buildSlug}`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<any>(GET_BUILD_ANNOTATIONS.toString(), variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`✅ Served from cache: GetBuildAnnotations`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<any>(GET_BUILD_ANNOTATIONS.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_BUILD_ANNOTATIONS.toString(), result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`✅ GraphQL query completed: GetBuildAnnotations (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n public async getBuildSummary(buildSlug: string): Promise<any> {\n const variables = {\n slug: buildSlug,\n };\n\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL query: GetBuildSummary for ${buildSlug}`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<any>('GET_BUILD_SUMMARY', variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`✅ Served from cache: GetBuildSummary`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<any>(GET_BUILD_SUMMARY.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set('GET_BUILD_SUMMARY', result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`✅ GraphQL query completed: GetBuildSummary (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n public async getBuildFull(buildSlug: string): Promise<any> {\n const variables = {\n slug: buildSlug,\n };\n\n if (this.debug) {\n logger.debug(`🕒 Starting GraphQL query: GetBuildFull for ${buildSlug}`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<any>('GET_BUILD_FULL', variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`✅ Served from cache: GetBuildFull`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<any>(GET_BUILD_FULL.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set('GET_BUILD_FULL', result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`✅ GraphQL query completed: GetBuildFull (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"BuildkiteClient.js","sourceRoot":"/","sources":["services/BuildkiteClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,4EAA4E;AAC5E,OAAO,EACL,UAAU,EACV,iBAAiB,EACjB,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACf,MAAM,uBAAuB,CAAC;AAY/B,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAuBrC;;GAEG;AACH,MAAM,OAAO,eAAe;IAClB,MAAM,CAAgB;IACtB,KAAK,CAAS;IACd,OAAO,GAAW,kCAAkC,CAAC;IACrD,YAAY,GAAwB,IAAI,CAAC;IACzC,KAAK,GAAY,KAAK,CAAC;IACvB,aAAa,GAAyB,IAAI,CAAC;IACnD;;;;OAIG;IACH,YAAY,KAAa,EAAE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jB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACf,MAAM,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,aAAa,CAAC,kCAAkC,CAAC,CAAC;gBACpF,CAAC;gBACD,OAAO,YAAY,CAAC;YACtB,CAAC;QACH,CAAC;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAM,cAAc,CAAC,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC;QAEpF,8CAA8C;QAC9C,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtB,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;QACnE,CAAC;QAED,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,0BAA0B;QAClF,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,GAAG,eAAe,CAAC,aAAa,CAAC,2CAA2C,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACrH,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { GraphQLClient } from 'graphql-request';\nimport { CacheManager } from './CacheManager.js';\nimport { getProgressIcon } from '../ui/theme.js';\n// Import the queries - we'll use them for both string queries and typed SDK\nimport { \n GET_VIEWER, \n GET_ORGANIZATIONS, \n GET_PIPELINES, \n GET_BUILDS, \n GET_VIEWER_BUILDS,\n GET_BUILD_ANNOTATIONS,\n GET_BUILD_SUMMARY,\n GET_BUILD_FULL\n} from '../graphql/queries.js';\n// Import generated types\nimport { \n GetViewerQuery, \n GetOrganizationsQuery, \n GetPipelinesQuery, \n GetPipelinesQueryVariables,\n GetBuildsQuery,\n GetBuildsQueryVariables,\n GetViewerBuildsQuery,\n GetViewerBuildsQueryVariables,\n} from '../graphql/generated/sdk.js';\nimport { logger } from './logger.js';\n\n// Note: We're now using the automatically generated types from GraphQL Codegen\n\nexport interface BuildkiteClientOptions {\n debug?: boolean;\n baseUrl?: string;\n caching?: boolean;\n cacheTTLs?: Partial<{\n viewer: number;\n organizations: number;\n pipelines: number;\n builds: number;\n default: number;\n }>;\n}\n\nexport interface RateLimitInfo {\n remaining: number;\n limit: number;\n reset: number;\n}\n\n/**\n * BuildkiteClient provides methods to interact with the Buildkite GraphQL API\n */\nexport class BuildkiteClient {\n private client: GraphQLClient;\n private token: string;\n private baseUrl: string = 'https://graphql.buildkite.com/v1';\n private cacheManager: CacheManager | null = null;\n private debug: boolean = false;\n private rateLimitInfo: RateLimitInfo | null = null;\n /**\n * Create a new BuildkiteClient\n * @param token Your Buildkite API token\n * @param options Configuration options\n */\n constructor(token: string, options?: BuildkiteClientOptions, debug?: boolean) {\n this.token = token;\n this.debug = debug || options?.debug || false;\n \n if (this.debug) {\n logger.debug('Initializing BuildkiteClient with options:', {\n baseUrl: options?.baseUrl || this.baseUrl,\n caching: options?.caching !== false,\n debug: this.debug,\n tokenLength: token ? token.length : 0\n });\n }\n \n if (options?.baseUrl) {\n this.baseUrl = options.baseUrl;\n }\n\n this.client = new GraphQLClient(this.baseUrl, {\n headers: {\n Authorization: `Bearer ${this.token}`,\n },\n });\n\n // Initialize cache if caching is enabled\n if (options?.caching !== false) {\n if (this.debug) {\n logger.debug('BuildkiteClient constructor - creating CacheManager');\n }\n this.cacheManager = new CacheManager(options?.cacheTTLs, this.debug);\n // Initialize cache and set token hash (async, but we don't wait)\n this.initCache();\n } else {\n if (this.debug) {\n logger.debug('BuildkiteClient constructor - caching disabled');\n }\n }\n }\n\n /**\n * Initialize cache asynchronously\n */\n private async initCache(): Promise<void> {\n if (this.cacheManager) {\n await this.cacheManager.init();\n await this.cacheManager.setTokenHash(this.token);\n }\n }\n\n /**\n * Execute a GraphQL query\n * @param query The GraphQL query\n * @param variables Variables for the query\n * @returns The query response\n */\n public async query<T = unknown, V extends Record<string, any> = Record<string, any>>(\n query: string,\n variables?: V\n ): Promise<T> {\n try {\n const startTime = process.hrtime.bigint();\n const operationName = query.match(/query\\s+(\\w+)?/)?.[1] || 'UnnamedQuery';\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: ${operationName}`);\n }\n \n // Check if result is in cache\n if (this.cacheManager) {\n if (this.debug) {\n logger.debug('query() - cacheManager exists, checking cache');\n }\n const cachedResult = await this.cacheManager.get<T>(query, variables);\n \n if (cachedResult) {\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: ${operationName}`);\n }\n return cachedResult;\n }\n }\n \n const response = await this.client.request<T>(query, variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(query, response, variables);\n }\n \n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: ${operationName} (${duration.toFixed(2)}ms)`);\n }\n \n return response;\n } catch (error: unknown) {\n const isAuthError = this.isAuthenticationError(error as any);\n if (isAuthError && this.debug) {\n logger.debug('Authentication error detected, not caching result');\n }\n \n if (this.debug) {\n logger.error(error as any, 'Error in GraphQL query');\n // Log raw error information\n logger.debug('Raw error object:', { \n error, \n type: typeof error, \n constructor: (error as any)?.constructor?.name,\n keys: error && typeof error === 'object' ? Object.keys(error as any) : undefined\n });\n // Log more detailed error information\n if (error instanceof Error && 'response' in (error as any)) {\n const response = (error as any).response;\n logger.debug('GraphQL error details:', {\n status: response?.status,\n statusText: response?.statusText,\n errors: response?.errors,\n data: response?.data,\n headers: response?.headers ? Object.fromEntries(response.headers.entries()) : undefined\n });\n }\n }\n throw error;\n }\n }\n\n /**\n * Check if an error is an authentication error\n */\n private isAuthenticationError(error: any): boolean {\n // Check for common authentication error patterns\n if (error.response?.errors) {\n const errors = error.response.errors;\n return errors.some((err: any) => \n err.message?.includes('unauthorized') || \n err.message?.includes('authentication') || \n err.message?.includes('permission') ||\n err.message?.includes('invalid token')\n );\n }\n \n // Check for HTTP status codes that indicate auth issues\n if (error.response?.status) {\n const status = error.response.status;\n return status === 401 || status === 403;\n }\n \n // Check error message directly\n if (error.message) {\n return error.message.includes('unauthorized') || \n error.message.includes('authentication') || \n error.message.includes('permission') ||\n error.message.includes('invalid token');\n }\n \n return false;\n }\n\n /**\n * Execute a GraphQL mutation\n * @param mutation The GraphQL mutation\n * @param variables Variables for the mutation\n * @returns The mutation response\n */\n public async mutate<T = unknown, V extends Record<string, any> = Record<string, any>>(\n mutation: string,\n variables?: V\n ): Promise<T> {\n try {\n const startTime = process.hrtime.bigint();\n const operationName = mutation.match(/mutation\\s+(\\w+)?/)?.[1] || 'UnnamedMutation';\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL mutation: ${operationName}`);\n }\n \n const result = await this.client.request<T>(mutation, variables);\n \n // Invalidate relevant caches after mutations\n if (this.cacheManager) {\n // Determine what cache types to invalidate based on mutation name/content\n if (mutation.includes('Pipeline')) {\n await this.cacheManager.invalidateType('pipelines');\n } else if (mutation.includes('Build')) {\n await this.cacheManager.invalidateType('builds');\n }\n }\n \n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL mutation completed: ${operationName} (${duration.toFixed(2)}ms)`);\n \n return result;\n } catch (error) {\n logger.error('GraphQL mutation error:', error);\n throw error;\n }\n }\n\n /**\n * Get the organization slugs for the current viewer\n * @returns An array of organization slugs the current user belongs to\n */\n public async getViewerOrganizationSlugs(): Promise<string[]> {\n try {\n const startTime = process.hrtime.bigint();\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: getViewerOrganizationSlugs`);\n }\n \n // Get the organizations using our query\n if (this.debug) {\n logger.debug('About to call this.query with GET_ORGANIZATIONS');\n }\n const data = await this.query<GetOrganizationsQuery>(GET_ORGANIZATIONS.toString());\n if (this.debug) {\n logger.debug('Successfully got data from this.query');\n }\n \n if (this.debug) {\n logger.debug('Raw GraphQL response for organizations:', {\n hasData: !!data,\n hasViewer: !!data?.viewer,\n hasOrganizations: !!data?.viewer?.organizations,\n hasEdges: !!data?.viewer?.organizations?.edges,\n edgesLength: data?.viewer?.organizations?.edges?.length || 0\n });\n }\n \n // Use our helper method to process the response\n const organizations = this.processOrganizationsResponse(data);\n \n if (this.debug) {\n logger.debug('Processed organizations:', {\n count: organizations.length,\n organizations: organizations.map(org => ({ id: org.id, name: org.name, slug: org.slug }))\n });\n }\n \n if (organizations.length === 0) {\n if (this.debug) {\n logger.debug('No organizations found in response', { data });\n }\n return []\n }\n \n // Map to just the slugs\n const slugs = organizations.map(org => org.slug);\n \n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} Found ${slugs.length} organizations (${duration.toFixed(2)}ms)`);\n }\n \n return slugs;\n } catch (error) {\n if (this.debug) {\n logger.debug('GraphQL query failed', {\n error: error instanceof Error ? error.message : String(error),\n details: error instanceof Error ? error : undefined\n });\n \n // Log more detailed error information\n if (error instanceof Error && 'response' in error) {\n const response = (error as any).response;\n logger.debug('GraphQL error response:', {\n status: response?.status,\n statusText: response?.statusText,\n errors: response?.errors,\n data: response?.data\n });\n }\n \n // Log detailed error information\n logger.debug('Error in getViewerOrganizationSlugs:', {\n errorMessage: error instanceof Error ? error.message : String(error),\n errorType: error?.constructor?.name,\n hasResponse: error instanceof Error && 'response' in error,\n response: error instanceof Error && 'response' in error ? (error as any).response : undefined\n });\n }\n throw new Error('Failed to determine your organizations', { cause: error });\n }\n }\n\n /**\n * Clear all cache entries\n */\n public async clearCache(): Promise<void> {\n if (this.cacheManager) {\n await this.cacheManager.clear();\n }\n }\n\n /**\n * Invalidate a specific cache type\n */\n public async invalidateCache(type: string): Promise<void> {\n if (this.cacheManager) {\n await this.cacheManager.invalidateType(type);\n }\n }\n\n /**\n * Get the current viewer information with type safety\n * @returns The viewer data\n */\n public async getViewer(): Promise<GetViewerQuery> {\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetViewer`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<GetViewerQuery>(GET_VIEWER.toString(), {});\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetViewer`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<GetViewerQuery>(GET_VIEWER.toString());\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_VIEWER.toString(), result, {});\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetViewer (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n /**\n * Get organizations for the current viewer\n * @returns An array of organization objects with id, name, and slug\n */\n public async getOrganizations(): Promise<Array<{ id: string; name: string; slug: string; }>> {\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetOrganizations`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<GetOrganizationsQuery>(GET_ORGANIZATIONS.toString(), {});\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetOrganizations`);\n }\n return this.processOrganizationsResponse(cachedResult);\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<GetOrganizationsQuery>(GET_ORGANIZATIONS.toString());\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_ORGANIZATIONS.toString(), result, {});\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetOrganizations (${duration.toFixed(2)}ms)`);\n }\n\n return this.processOrganizationsResponse(result);\n }\n\n /**\n * Process the raw GraphQL organizations response into a clean array\n * @param data The raw GraphQL response\n * @returns A processed array of organization objects\n * @private\n */\n private processOrganizationsResponse(data: GetOrganizationsQuery): Array<{ id: string; name: string; slug: string; }> {\n if (!data?.viewer?.organizations?.edges) {\n return [];\n }\n \n const edges = data.viewer.organizations.edges;\n \n // Filter out null edges and map to non-null nodes\n const organizations = edges\n .filter((edge): edge is NonNullable<typeof edge> => edge !== null)\n .map(edge => edge.node)\n .filter((node): node is NonNullable<typeof node> => node !== null);\n \n return organizations;\n }\n\n /**\n * Get pipelines for an organization with type safety\n * @param organizationSlug The organization slug\n * @param first Number of pipelines to retrieve\n * @param after Cursor for pagination\n * @returns The pipelines data\n */\n public async getPipelines(\n organizationSlug: string, \n first?: number, \n after?: string\n ): Promise<GetPipelinesQuery> {\n const variables: GetPipelinesQueryVariables = {\n organizationSlug,\n first,\n after,\n };\n\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetPipelines for ${organizationSlug}`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<GetPipelinesQuery>(GET_PIPELINES.toString(), variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetPipelines`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<GetPipelinesQuery>(GET_PIPELINES.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_PIPELINES.toString(), result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetPipelines (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n /**\n * Get builds for a pipeline with type safety\n * @param pipelineSlug The pipeline slug\n * @param organizationSlug The organization slug\n * @param first Number of builds to retrieve\n * @returns The builds data\n */\n public async getBuilds(\n pipelineSlug: string,\n organizationSlug: string,\n first?: number\n ): Promise<GetBuildsQuery> {\n const variables: GetBuildsQueryVariables = {\n pipelineSlug,\n organizationSlug,\n first,\n };\n\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetBuilds for ${pipelineSlug} in ${organizationSlug}`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<GetBuildsQuery>(GET_BUILDS.toString(), variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetBuilds`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<GetBuildsQuery>(GET_BUILDS.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_BUILDS.toString(), result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetBuilds (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n /**\n * Get builds for the current viewer with type safety\n * @param first Number of builds to retrieve\n * @returns The viewer builds data\n */\n public async getViewerBuilds(first: number): Promise<GetViewerBuildsQuery> {\n const variables: GetViewerBuildsQueryVariables = {\n first,\n };\n\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetViewerBuilds`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<GetViewerBuildsQuery>(GET_VIEWER_BUILDS.toString(), variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetViewerBuilds`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<GetViewerBuildsQuery>(GET_VIEWER_BUILDS.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_VIEWER_BUILDS.toString(), result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetViewerBuilds (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n /**\n * Get the current rate limit information\n * @returns Current rate limit information or null if not available\n */\n public getRateLimitInfo(): RateLimitInfo | null {\n return this.rateLimitInfo;\n }\n\n /**\n * Get annotations for a build with type safety\n * @param buildSlug The build slug (e.g., \"org/pipeline/number\")\n * @returns The build annotations data\n */\n public async getBuildAnnotations(buildSlug: string): Promise<any> {\n const variables = {\n buildSlug,\n };\n\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetBuildAnnotations for ${buildSlug}`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<any>(GET_BUILD_ANNOTATIONS.toString(), variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetBuildAnnotations`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<any>(GET_BUILD_ANNOTATIONS.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set(GET_BUILD_ANNOTATIONS.toString(), result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetBuildAnnotations (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n public async getBuildSummary(buildSlug: string): Promise<any> {\n const variables = {\n slug: buildSlug,\n };\n\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetBuildSummary for ${buildSlug}`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<any>('GET_BUILD_SUMMARY', variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetBuildSummary`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<any>(GET_BUILD_SUMMARY.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set('GET_BUILD_SUMMARY', result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetBuildSummary (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n\n public async getBuildFull(buildSlug: string): Promise<any> {\n const variables = {\n slug: buildSlug,\n };\n\n if (this.debug) {\n logger.debug(`${getProgressIcon('STARTING')} Starting GraphQL query: GetBuildFull for ${buildSlug}`);\n }\n\n // Check if result is in cache\n if (this.cacheManager) {\n const cachedResult = await this.cacheManager.get<any>('GET_BUILD_FULL', variables);\n if (cachedResult) {\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} Served from cache: GetBuildFull`);\n }\n return cachedResult;\n }\n }\n\n const startTime = process.hrtime.bigint();\n const result = await this.client.request<any>(GET_BUILD_FULL.toString(), variables);\n\n // Store result in cache if caching is enabled\n if (this.cacheManager) {\n await this.cacheManager.set('GET_BUILD_FULL', result, variables);\n }\n\n const endTime = process.hrtime.bigint();\n const duration = Number(endTime - startTime) / 1000000; // Convert to milliseconds\n if (this.debug) {\n logger.debug(`${getProgressIcon('SUCCESS_LOG')} GraphQL query completed: GetBuildFull (${duration.toFixed(2)}ms)`);\n }\n\n return result;\n }\n}"]}
|