UNPKG

@graphql-hive/cli

Version:

A CLI util to manage and control your GraphQL Hive

639 lines • 35.5 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.InvalidCompositionResultError = exports.RemoteCompositionError = exports.LocalCompositionError = exports.ServiceAndUrlLengthMismatch = exports.InvalidSchemaError = exports.SchemaNotFoundError = exports.PersistedOperationsMalformedError = exports.SchemaPublishMissingUrlError = exports.SchemaPublishMissingServiceError = exports.InvalidSDLError = exports.SchemaPublishFailedError = exports.SchemaCheckApprovalFailedError = exports.SchemaCheckFailedError = exports.SchemaFileEmptyError = exports.SchemaFileNotFoundError = exports.UnexpectedError = exports.InvalidHeaderError = exports.InvalidInputError = exports.RequestTimeoutError = exports.UnsupportedServerError = exports.AccessDeniedError = exports.ConflictingOptionsError = exports.InvalidVersionIdError = exports.InvalidFederationSubgraphError = exports.InvalidTargetError = exports.InvalidFileContentsError = exports.FileMissingError = exports.UnsupportedFileExtensionError = exports.IntrospectionError = exports.APIError = exports.NetworkError = exports.HTTPError = exports.AuthorRequiredError = exports.GithubRepositoryRequiredError = exports.CommitRequiredError = exports.MissingEnvironmentError = exports.MissingCdnEndpointError = exports.InvalidCdnKeyError = exports.InvalidRegistryTokenError = exports.MissingEndpointError = exports.MissingCdnKeyError = exports.MissingRegistryTokenError = exports.MissingArgumentsError = exports.InvalidCommandError = exports.InvalidConfigError = exports.errorCategories = exports.HiveCLIError = exports.ERRORS_DOCS_URL = exports.exitCodeDescriptions = exports.ExitCode = void 0; exports.errorCatalog = exports.InvalidDocumentsError = void 0; exports.errorDocsAnchor = errorDocsAnchor; exports.isAggregateError = isAggregateError; exports.isTimeoutError = isTimeoutError; const node_path_1 = require("node:path"); const node_process_1 = require("node:process"); const errors_1 = require("@oclif/core/lib/errors"); const index_1 = require("../gql/index"); const schema_1 = require("./schema"); const texture_1 = require("./texture/texture"); var ExitCode; (function (ExitCode) { // The command execution succeeded. ExitCode[ExitCode["SUCCESS"] = 0] = "SUCCESS"; // The command ran, but the operation it performed failed. ExitCode[ExitCode["ERROR"] = 1] = "ERROR"; // The request took too long and timed out. The operation may still have completed on the server. ExitCode[ExitCode["TIMED_OUT"] = 2] = "TIMED_OUT"; // The command could not start because of invalid input or setup. E.g. malformed arguments, flags, files or configuration. ExitCode[ExitCode["BAD_INIT"] = 3] = "BAD_INIT"; })(ExitCode || (exports.ExitCode = ExitCode = {})); exports.exitCodeDescriptions = { [ExitCode.SUCCESS]: 'The command succeeded.', [ExitCode.ERROR]: 'The command ran, but the operation failed.', [ExitCode.TIMED_OUT]: 'A request timed out. The operation may still have completed on the server.', [ExitCode.BAD_INIT]: 'The command could not start because of invalid input or setup, such as arguments, flags, files or configuration.', }; exports.ERRORS_DOCS_URL = 'https://the-guild.dev/graphql/hive/docs/api-reference/cli'; function errorDocsAnchor(code) { return `errors-${code}`; } class HiveCLIError extends errors_1.CLIError { constructor(message) { const meta = new.target; const tip = `> See ${exports.ERRORS_DOCS_URL}#${errorDocsAnchor(meta.code)} for a complete list of error codes and recommended fixes. To disable this message set HIVE_NO_ERROR_TIP=1`; super(`${message} [${meta.code}]${node_process_1.env.HIVE_NO_ERROR_TIP === '1' ? '' : `\n${tip}`}`, { exit: meta.exitCode, }); this.exitCode = meta.exitCode; this.errorCode = meta.code; this.plainMessage = message; } } exports.HiveCLIError = HiveCLIError; /** Categorized by the command that introduced the error. Errors shared by many commands are GENERIC. */ var ErrorCategory; (function (ErrorCategory) { ErrorCategory[ErrorCategory["GENERIC"] = 100] = "GENERIC"; ErrorCategory[ErrorCategory["SCHEMA_CHECK"] = 200] = "SCHEMA_CHECK"; ErrorCategory[ErrorCategory["SCHEMA_PUBLISH"] = 300] = "SCHEMA_PUBLISH"; ErrorCategory[ErrorCategory["APP_CREATE"] = 400] = "APP_CREATE"; ErrorCategory[ErrorCategory["ARTIFACT_FETCH"] = 500] = "ARTIFACT_FETCH"; ErrorCategory[ErrorCategory["DEV"] = 600] = "DEV"; ErrorCategory[ErrorCategory["OPERATIONS_CHECK"] = 700] = "OPERATIONS_CHECK"; })(ErrorCategory || (ErrorCategory = {})); exports.errorCategories = [ { name: 'Generic', start: ErrorCategory.GENERIC }, { name: 'Schema check', start: ErrorCategory.SCHEMA_CHECK }, { name: 'Schema publish', start: ErrorCategory.SCHEMA_PUBLISH }, { name: 'App create', start: ErrorCategory.APP_CREATE }, { name: 'Artifact fetch', start: ErrorCategory.ARTIFACT_FETCH }, { name: 'Dev', start: ErrorCategory.DEV }, { name: 'Operations check', start: ErrorCategory.OPERATIONS_CHECK }, ]; const errorCode = (category, id) => { return category + id; }; class InvalidConfigError extends HiveCLIError { constructor(configPath, reason) { super(`The configuration file "${configPath}" is invalid: ${reason}`); } } exports.InvalidConfigError = InvalidConfigError; InvalidConfigError.code = errorCode(ErrorCategory.GENERIC, 0); InvalidConfigError.exitCode = ExitCode.BAD_INIT; InvalidConfigError.title = 'Invalid configuration file'; InvalidConfigError.fix = 'Fix the reported problem in `hive.json` (or the file set with `HIVE_CONFIG`). Supported keys are `registry.endpoint`, `registry.accessToken`, `registry.headers`, `cdn.endpoint` and `cdn.accessToken`. When `HIVE_SPACE` is set, the file must contain a top-level key with that name.'; class InvalidCommandError extends HiveCLIError { constructor(command) { super(`The command, "${command}", does not exist.`); } } exports.InvalidCommandError = InvalidCommandError; InvalidCommandError.code = errorCode(ErrorCategory.GENERIC, 1); InvalidCommandError.exitCode = ExitCode.BAD_INIT; InvalidCommandError.title = 'Unknown command'; InvalidCommandError.fix = 'Run `hive help` to list the available commands and check the spelling.'; class MissingArgumentsError extends HiveCLIError { constructor(...requiredArgs) { const argsStr = requiredArgs.map(a => `${a[0].toUpperCase()} \t${a[1]}`).join('\n'); super(`Missing ${requiredArgs.length} required argument${requiredArgs.length > 1 ? 's' : ''}:\n${argsStr}`); } } exports.MissingArgumentsError = MissingArgumentsError; MissingArgumentsError.code = errorCode(ErrorCategory.GENERIC, 2); MissingArgumentsError.exitCode = ExitCode.BAD_INIT; MissingArgumentsError.title = 'Missing required argument'; MissingArgumentsError.fix = 'Provide the listed arguments or flags. Organization access tokens always require the `--target` flag.'; class MissingRegistryTokenError extends HiveCLIError { constructor() { super(`A registry token is required to perform the action. For help generating an access token, see https://the-guild.dev/graphql/hive/docs/management/targets#registry-access-tokens`); } } exports.MissingRegistryTokenError = MissingRegistryTokenError; MissingRegistryTokenError.code = errorCode(ErrorCategory.GENERIC, 3); MissingRegistryTokenError.exitCode = ExitCode.BAD_INIT; MissingRegistryTokenError.title = 'Missing registry access token'; MissingRegistryTokenError.fix = 'Pass `--registry.accessToken`, set `HIVE_TOKEN`, or set `registry.accessToken` in `hive.json`.'; class MissingCdnKeyError extends HiveCLIError { constructor() { super(`A CDN key is required to perform the action. For help generating a CDN key, see https://the-guild.dev/graphql/hive/docs/management/targets#cdn-access-tokens`); } } exports.MissingCdnKeyError = MissingCdnKeyError; MissingCdnKeyError.code = errorCode(ErrorCategory.GENERIC, 4); MissingCdnKeyError.exitCode = ExitCode.BAD_INIT; MissingCdnKeyError.title = 'Missing CDN access token'; MissingCdnKeyError.fix = 'Pass `--cdn.accessToken`, set `HIVE_CDN_ACCESS_TOKEN`, or set `cdn.accessToken` in `hive.json`.'; class MissingEndpointError extends HiveCLIError { constructor() { super(`A registry endpoint is required to perform the action.`); } } exports.MissingEndpointError = MissingEndpointError; MissingEndpointError.code = errorCode(ErrorCategory.GENERIC, 5); MissingEndpointError.exitCode = ExitCode.BAD_INIT; MissingEndpointError.title = 'Missing registry endpoint'; MissingEndpointError.fix = 'Pass `--registry.endpoint`, set `HIVE_REGISTRY`, or set `registry.endpoint` in `hive.json`. Make sure `HIVE_REGISTRY` is not set to an empty string.'; class InvalidRegistryTokenError extends HiveCLIError { constructor() { super(`The registry access token was rejected. It does not exist, has expired, or has been revoked.`); } } exports.InvalidRegistryTokenError = InvalidRegistryTokenError; InvalidRegistryTokenError.code = errorCode(ErrorCategory.GENERIC, 6); InvalidRegistryTokenError.exitCode = ExitCode.ERROR; InvalidRegistryTokenError.title = 'Invalid registry access token'; InvalidRegistryTokenError.fix = 'Create a new access token, and check that the access token and the registry endpoint belong to the same Hive instance.'; class InvalidCdnKeyError extends HiveCLIError { constructor() { super(`A valid CDN key is required to perform the action. The CDN key used does not exist, has expired, or has been revoked.`); } } exports.InvalidCdnKeyError = InvalidCdnKeyError; InvalidCdnKeyError.code = errorCode(ErrorCategory.GENERIC, 7); InvalidCdnKeyError.exitCode = ExitCode.ERROR; InvalidCdnKeyError.title = 'Invalid CDN access token'; InvalidCdnKeyError.fix = 'Create a new CDN access token for the target, and check that it belongs to the same target as the CDN endpoint.'; class MissingCdnEndpointError extends HiveCLIError { constructor() { super(`A CDN endpoint is required to perform the action.`); } } exports.MissingCdnEndpointError = MissingCdnEndpointError; MissingCdnEndpointError.code = errorCode(ErrorCategory.GENERIC, 8); MissingCdnEndpointError.exitCode = ExitCode.BAD_INIT; MissingCdnEndpointError.title = 'Missing CDN endpoint'; MissingCdnEndpointError.fix = 'Pass `--cdn.endpoint`, set `HIVE_CDN_ENDPOINT`, or set `cdn.endpoint` in `hive.json`.'; class MissingEnvironmentError extends HiveCLIError { constructor(...requiredVars) { const varsStr = requiredVars.map(a => `\t${a[0]} \t${a[1]}`).join('\n'); super(`Missing required environment variable${requiredVars.length > 1 ? 's' : ''}:\n${varsStr}`); } } exports.MissingEnvironmentError = MissingEnvironmentError; MissingEnvironmentError.code = errorCode(ErrorCategory.GENERIC, 9); MissingEnvironmentError.exitCode = ExitCode.BAD_INIT; MissingEnvironmentError.title = 'Missing environment variable'; MissingEnvironmentError.fix = 'Set the listed environment variables. With `--github`, run the command in GitHub Actions or set `GITHUB_REPOSITORY`.'; class CommitRequiredError extends HiveCLIError { constructor() { super(`Couldn't resolve required commit sha. Provide a non-empty commit via the '--commit' parameter or execute the command within a git repository.`); } } exports.CommitRequiredError = CommitRequiredError; CommitRequiredError.code = errorCode(ErrorCategory.GENERIC, 10); CommitRequiredError.exitCode = ExitCode.BAD_INIT; CommitRequiredError.title = 'Missing commit'; CommitRequiredError.fix = 'Pass `--commit` (or set `HIVE_COMMIT` for `schema:publish`), or run the command inside a git repository.'; class GithubRepositoryRequiredError extends HiveCLIError { constructor() { super(`Couldn't resolve git repository required for GitHub Application.`); } } exports.GithubRepositoryRequiredError = GithubRepositoryRequiredError; GithubRepositoryRequiredError.code = errorCode(ErrorCategory.GENERIC, 11); GithubRepositoryRequiredError.exitCode = ExitCode.BAD_INIT; GithubRepositoryRequiredError.title = 'Missing GitHub repository'; GithubRepositoryRequiredError.fix = 'Run the command in GitHub Actions, where `GITHUB_REPOSITORY` is set, or in a CI environment that exposes the repository.'; class AuthorRequiredError extends HiveCLIError { constructor() { super(`Couldn't resolve required commit author. Provide a non-empty author via the '--author' parameter or execute the command within a git repository.`); } } exports.AuthorRequiredError = AuthorRequiredError; AuthorRequiredError.code = errorCode(ErrorCategory.GENERIC, 12); AuthorRequiredError.exitCode = ExitCode.BAD_INIT; AuthorRequiredError.title = 'Missing author'; AuthorRequiredError.fix = 'Pass `--author` (or set `HIVE_AUTHOR` for `schema:publish`), or run the command inside a git repository with a configured user.'; class HTTPError extends HiveCLIError { constructor(endpoint, status, message) { const is400 = status >= 400 && status < 500; super(`A ${is400 ? 'client' : 'server'} error occurred while performing the action. A call to "${endpoint}" failed with Status: ${status}, Text: ${message}`); } } exports.HTTPError = HTTPError; HTTPError.code = errorCode(ErrorCategory.GENERIC, 13); HTTPError.exitCode = ExitCode.ERROR; HTTPError.title = 'HTTP error response'; HTTPError.fix = 'A 4xx status usually means a wrong endpoint or a rejected request: check the endpoint URL and credentials. A 5xx status means the server failed: retry later.'; class NetworkError extends HiveCLIError { constructor(cause, message) { super(message !== null && message !== void 0 ? message : `A network error occurred while performing the action: "${cause instanceof Error ? `${cause.name}: ${cause.message}` : cause}"`); } } exports.NetworkError = NetworkError; NetworkError.code = errorCode(ErrorCategory.GENERIC, 14); NetworkError.exitCode = ExitCode.ERROR; NetworkError.title = 'Network error'; NetworkError.fix = 'The request did not complete. Check the network connection, DNS, proxy and TLS settings, and the endpoint URL, then retry.'; /** GraphQL Errors returned from an operation. Note that some GraphQL Errors that require specific steps to correct are handled through other error types. */ class APIError extends HiveCLIError { constructor(cause, requestId, graphQLErrors) { super((cause instanceof Error ? `${cause.name}: ${cause.message}` : cause) + (requestId ? ` (Request ID: "${requestId}")` : '')); this.graphQLErrors = graphQLErrors; this.ref = requestId; } } exports.APIError = APIError; APIError.code = errorCode(ErrorCategory.GENERIC, 15); APIError.exitCode = ExitCode.ERROR; APIError.title = 'API error'; APIError.fix = 'Read the message returned by the Hive API. Include the request ID when contacting support.'; class IntrospectionError extends HiveCLIError { /** @param service The name or URL of the service. */ constructor(service) { super(`Could not get introspection result from the service${service ? ` '${service}'` : ''}. Make sure introspection is enabled by the server.`); } } exports.IntrospectionError = IntrospectionError; IntrospectionError.code = errorCode(ErrorCategory.GENERIC, 16); IntrospectionError.exitCode = ExitCode.ERROR; IntrospectionError.title = 'Introspection failed'; IntrospectionError.fix = 'Make sure the service is running, reachable and allows introspection, or pass the schema file instead of the URL.'; class UnsupportedFileExtensionError extends HiveCLIError { constructor(filename, supported) { super(`Got unsupported file extension: "${(0, node_path_1.extname)(filename)}".${supported ? ` Try using one of the supported extensions: ${supported.join(',')}` : ''}`); } } exports.UnsupportedFileExtensionError = UnsupportedFileExtensionError; UnsupportedFileExtensionError.code = errorCode(ErrorCategory.GENERIC, 17); UnsupportedFileExtensionError.exitCode = ExitCode.BAD_INIT; UnsupportedFileExtensionError.title = 'Unsupported file extension'; UnsupportedFileExtensionError.fix = 'Use one of the supported file extensions listed in the message.'; class FileMissingError extends HiveCLIError { constructor(fileName, additionalContext) { super(`Failed to load file "${fileName}"${additionalContext ? `: ${additionalContext}` : '.'}`); } } exports.FileMissingError = FileMissingError; FileMissingError.code = errorCode(ErrorCategory.GENERIC, 18); FileMissingError.exitCode = ExitCode.BAD_INIT; FileMissingError.title = 'File not found'; FileMissingError.fix = 'Check that the path or glob matches at least one readable file.'; class InvalidFileContentsError extends HiveCLIError { constructor(fileName, expectedFormat) { super(`File "${fileName}" could not be parsed. Please make sure the file is readable and contains a valid ${expectedFormat}.`); } } exports.InvalidFileContentsError = InvalidFileContentsError; InvalidFileContentsError.code = errorCode(ErrorCategory.GENERIC, 19); InvalidFileContentsError.exitCode = ExitCode.BAD_INIT; InvalidFileContentsError.title = 'Invalid file contents'; InvalidFileContentsError.fix = 'Make sure the file is readable and contains valid content in the expected format.'; class InvalidTargetError extends HiveCLIError { constructor(flagName = '--target') { super(`Invalid slug or ID provided for option "${flagName}". Must match target slug "$organization_slug/$project_slug/$target_slug" (e.g. "the-guild/graphql-hive/staging") or UUID (e.g. c8164307-0b42-473e-a8c5-2860bb4beff6).`); } } exports.InvalidTargetError = InvalidTargetError; InvalidTargetError.code = errorCode(ErrorCategory.GENERIC, 20); InvalidTargetError.exitCode = ExitCode.BAD_INIT; InvalidTargetError.title = 'Invalid target'; InvalidTargetError.fix = 'Pass the target as a slug in the form `organization/project/target`, or as a target UUID.'; class InvalidFederationSubgraphError extends HiveCLIError { constructor(reason) { super(`The provided service URL does not point to a valid Federation subgraph.${reason ? `\n${reason}\n` : ''}`); } } exports.InvalidFederationSubgraphError = InvalidFederationSubgraphError; InvalidFederationSubgraphError.code = errorCode(ErrorCategory.GENERIC, 21); InvalidFederationSubgraphError.exitCode = ExitCode.BAD_INIT; InvalidFederationSubgraphError.title = 'Not a Federation subgraph'; InvalidFederationSubgraphError.fix = 'Point the URL at a Federation subgraph that exposes `Query._service.sdl`, or pass the schema file instead.'; class InvalidVersionIdError extends HiveCLIError { constructor(flagName = '--version', reason) { super(`Invalid version id provided for "${flagName}".${reason ? `\n${reason}\n` : ''}`); } } exports.InvalidVersionIdError = InvalidVersionIdError; InvalidVersionIdError.code = errorCode(ErrorCategory.GENERIC, 22); InvalidVersionIdError.exitCode = ExitCode.BAD_INIT; InvalidVersionIdError.title = 'Invalid schema version ID'; InvalidVersionIdError.fix = 'Pass the ID of a schema version from the same project as the target.'; class ConflictingOptionsError extends HiveCLIError { constructor(flagNames, reason) { super(`The options ${flagNames.map(name => `"${name}"`).join(', ')} conflict. Please only provide one.${reason ? `\n${reason}\n` : ''}`); } } exports.ConflictingOptionsError = ConflictingOptionsError; ConflictingOptionsError.code = errorCode(ErrorCategory.GENERIC, 23); ConflictingOptionsError.exitCode = ExitCode.BAD_INIT; ConflictingOptionsError.title = 'Conflicting options'; ConflictingOptionsError.fix = 'Provide only one of the listed options.'; /** The API rejected the action for an authenticated token (GraphQL error code UNAUTHORISED). */ class AccessDeniedError extends HiveCLIError { constructor(reason, permission, requestId) { super((permission ? `Access denied: the access token is missing the "${permission}" permission, or the target does not exist or is not accessible to this token.` : `Access denied: ${reason}`) + (requestId ? ` (Request ID: "${requestId}")` : '')); this.permission = permission; this.ref = requestId; } } exports.AccessDeniedError = AccessDeniedError; AccessDeniedError.code = errorCode(ErrorCategory.GENERIC, 24); AccessDeniedError.exitCode = ExitCode.ERROR; AccessDeniedError.title = 'Access denied'; AccessDeniedError.fix = 'Grant the named permission to the access token, check that `--target` points at an existing target the token can access, or use an organization access token.'; /** The API rejected the request during GraphQL validation, because the server does not know a field, argument or type the CLI sends. */ class UnsupportedServerError extends HiveCLIError { constructor(endpoint, graphQLErrors) { super(`The Hive server at "${endpoint}" does not support this version of the CLI. The request was rejected before it ran:\n` + graphQLErrors.map(error => `- ${error.message}`).join('\n')); this.graphQLErrors = graphQLErrors; } } exports.UnsupportedServerError = UnsupportedServerError; UnsupportedServerError.code = errorCode(ErrorCategory.GENERIC, 25); UnsupportedServerError.exitCode = ExitCode.ERROR; UnsupportedServerError.title = 'Unsupported Hive server version'; UnsupportedServerError.fix = 'Upgrade the Hive server to a version that supports this CLI version, or use an older CLI version that matches the server. Nothing was executed on the server.'; class RequestTimeoutError extends NetworkError { constructor(endpoint, cause) { super(cause, `The request to "${endpoint}" timed out. The operation may still have completed on the server. Check its result before retrying.`); } } exports.RequestTimeoutError = RequestTimeoutError; RequestTimeoutError.code = errorCode(ErrorCategory.GENERIC, 26); RequestTimeoutError.exitCode = ExitCode.TIMED_OUT; RequestTimeoutError.title = 'Request timed out'; RequestTimeoutError.fix = 'The operation may have completed on the server. Check its result, for example in Hive Console or with `hive schema:fetch`, before retrying.'; class InvalidInputError extends HiveCLIError { constructor(cause) { var _a; super(cause.message); this.showHelp = (_a = cause.showHelp) !== null && _a !== void 0 ? _a : false; this.parse = cause.parse; } } exports.InvalidInputError = InvalidInputError; InvalidInputError.code = errorCode(ErrorCategory.GENERIC, 27); InvalidInputError.exitCode = ExitCode.BAD_INIT; InvalidInputError.title = 'Invalid command input'; InvalidInputError.fix = 'Check the arguments and flags with `hive help <command>`.'; class InvalidHeaderError extends HiveCLIError { constructor(header, format) { super(`Invalid header "${header}". Expected ${format}.`); } } exports.InvalidHeaderError = InvalidHeaderError; InvalidHeaderError.code = errorCode(ErrorCategory.GENERIC, 28); InvalidHeaderError.exitCode = ExitCode.BAD_INIT; InvalidHeaderError.title = 'Invalid header'; InvalidHeaderError.fix = 'Use the `Name=Value` format for `--registry.header` and the `Name:Value` format for `--header`.'; class UnexpectedError extends HiveCLIError { constructor(cause) { const message = cause instanceof Error ? cause.message : typeof cause === 'string' ? cause : JSON.stringify(cause); super(`An unexpected error occurred: ${message}\n> Enable DEBUG=* for more details.`); } } exports.UnexpectedError = UnexpectedError; UnexpectedError.code = errorCode(ErrorCategory.GENERIC, 99); UnexpectedError.exitCode = ExitCode.ERROR; UnexpectedError.title = 'Unexpected error'; UnexpectedError.fix = 'Re-run the command with `DEBUG=*` for more details, and report the output if the problem persists.'; class SchemaFileNotFoundError extends HiveCLIError { constructor(fileName, reason) { const message = reason instanceof Error ? reason.message : reason; super(`Error reading the schema file "${fileName}"${message ? `: ${message}` : '.'}`); } } exports.SchemaFileNotFoundError = SchemaFileNotFoundError; SchemaFileNotFoundError.code = errorCode(ErrorCategory.SCHEMA_CHECK, 0); SchemaFileNotFoundError.exitCode = ExitCode.BAD_INIT; SchemaFileNotFoundError.title = 'Schema not found'; SchemaFileNotFoundError.fix = 'Check the file path, glob or URL. For a URL, make sure the service is reachable.'; class SchemaFileEmptyError extends HiveCLIError { constructor(fileName) { super(`No GraphQL type definitions were found in "${fileName}".`); } } exports.SchemaFileEmptyError = SchemaFileEmptyError; SchemaFileEmptyError.code = errorCode(ErrorCategory.SCHEMA_CHECK, 1); SchemaFileEmptyError.exitCode = ExitCode.BAD_INIT; SchemaFileEmptyError.title = 'No type definitions found'; SchemaFileEmptyError.fix = 'Make sure the schema contains GraphQL type definitions. In code files, the definitions must be in a template literal tagged with `gql` or `graphql`, or marked with a `/* GraphQL */` comment.'; class SchemaCheckFailedError extends HiveCLIError { constructor() { super('Schema check failed.'); } } exports.SchemaCheckFailedError = SchemaCheckFailedError; SchemaCheckFailedError.code = errorCode(ErrorCategory.SCHEMA_CHECK, 2); SchemaCheckFailedError.exitCode = ExitCode.ERROR; SchemaCheckFailedError.title = 'Schema check failed'; SchemaCheckFailedError.fix = 'Review the errors and breaking changes in the output or the linked report. Fix them, approve expected breaking changes in Hive Console, or use `--forceSafe`.'; class SchemaCheckApprovalFailedError extends HiveCLIError { constructor(reason) { super(`Failed to auto-approve the schema check: ${reason}`); } } exports.SchemaCheckApprovalFailedError = SchemaCheckApprovalFailedError; SchemaCheckApprovalFailedError.code = errorCode(ErrorCategory.SCHEMA_CHECK, 3); SchemaCheckApprovalFailedError.exitCode = ExitCode.ERROR; SchemaCheckApprovalFailedError.title = 'Schema check approval failed'; SchemaCheckApprovalFailedError.fix = 'Make sure the access token has the `schemaCheck:approve` permission and that the failed schema check was stored by the registry.'; class SchemaPublishFailedError extends HiveCLIError { constructor(details) { super(`Schema publish failed.${details ? ` ${details}` : ''}`); } } exports.SchemaPublishFailedError = SchemaPublishFailedError; SchemaPublishFailedError.code = errorCode(ErrorCategory.SCHEMA_PUBLISH, 0); SchemaPublishFailedError.exitCode = ExitCode.ERROR; SchemaPublishFailedError.title = 'Schema publish failed'; SchemaPublishFailedError.fix = 'The schema was rejected and nothing was stored. Fix the reported errors and publish again.'; class InvalidSDLError extends HiveCLIError { constructor(err) { var _a; const location = (_a = err.locations) === null || _a === void 0 ? void 0 : _a[0]; const locationString = location ? ` at line ${location.line}, column ${location.column}` : ''; super(`The SDL is not valid${locationString}:\n ${err.message}`); } } exports.InvalidSDLError = InvalidSDLError; InvalidSDLError.code = errorCode(ErrorCategory.SCHEMA_PUBLISH, 1); InvalidSDLError.exitCode = ExitCode.BAD_INIT; InvalidSDLError.title = 'Invalid SDL'; InvalidSDLError.fix = 'Fix the GraphQL syntax error at the reported location.'; class SchemaPublishMissingServiceError extends HiveCLIError { constructor(message) { super(`${message} Please use the "--service <name>" parameter.`); } } exports.SchemaPublishMissingServiceError = SchemaPublishMissingServiceError; SchemaPublishMissingServiceError.code = errorCode(ErrorCategory.SCHEMA_PUBLISH, 2); SchemaPublishMissingServiceError.exitCode = ExitCode.BAD_INIT; SchemaPublishMissingServiceError.title = 'Missing service name'; SchemaPublishMissingServiceError.fix = 'Pass `--service <name>`. Federation and schema stitching projects require a service name.'; class SchemaPublishMissingUrlError extends HiveCLIError { constructor(message) { super(`${message} Please use the "--url <url>" parameter.`); } } exports.SchemaPublishMissingUrlError = SchemaPublishMissingUrlError; SchemaPublishMissingUrlError.code = errorCode(ErrorCategory.SCHEMA_PUBLISH, 3); SchemaPublishMissingUrlError.exitCode = ExitCode.BAD_INIT; SchemaPublishMissingUrlError.title = 'Missing service URL'; SchemaPublishMissingUrlError.fix = 'Pass `--url <url>`. A service needs a URL the first time it is published, and the URL must be valid.'; class PersistedOperationsMalformedError extends HiveCLIError { constructor(file, reason) { super(`Persisted Operations file "${file}" is malformed.` + (reason ? ` ${reason}` : ' Please make sure it follows either the GraphQL Code Generator, Relay or Apollo Persisted Query Manifest Format.')); } } exports.PersistedOperationsMalformedError = PersistedOperationsMalformedError; PersistedOperationsMalformedError.code = errorCode(ErrorCategory.APP_CREATE, 0); PersistedOperationsMalformedError.exitCode = ExitCode.BAD_INIT; PersistedOperationsMalformedError.title = 'Malformed persisted documents'; PersistedOperationsMalformedError.fix = 'Use a GraphQL Code Generator, Relay or Apollo persisted query manifest, a directory of `.graphql` files, or a glob that matches `.graphql` files containing operations.'; class SchemaNotFoundError extends HiveCLIError { constructor(commit) { super(`No schema found${commit ? ` for commit ${commit}.` : '.'}`); } } exports.SchemaNotFoundError = SchemaNotFoundError; SchemaNotFoundError.code = errorCode(ErrorCategory.ARTIFACT_FETCH, 0); SchemaNotFoundError.exitCode = ExitCode.ERROR; SchemaNotFoundError.title = 'Schema not found in the registry'; SchemaNotFoundError.fix = 'Publish a schema to the target first, or check the target, the commit and the `--type` value.'; class InvalidSchemaError extends HiveCLIError { constructor(commit) { super(`Schema is invalid${commit ? ` for commit ${commit}.` : '.'}`); } } exports.InvalidSchemaError = InvalidSchemaError; InvalidSchemaError.code = errorCode(ErrorCategory.ARTIFACT_FETCH, 1); InvalidSchemaError.exitCode = ExitCode.ERROR; InvalidSchemaError.title = 'Schema version is not valid'; InvalidSchemaError.fix = 'The requested schema version is not valid. Use a different commit, or fix and publish the schema again.'; class ServiceAndUrlLengthMismatch extends HiveCLIError { constructor(services, urls) { super(`Not every services has a matching url. Got ${services.length} services and ${urls.length} urls.`); } } exports.ServiceAndUrlLengthMismatch = ServiceAndUrlLengthMismatch; ServiceAndUrlLengthMismatch.code = errorCode(ErrorCategory.DEV, 0); ServiceAndUrlLengthMismatch.exitCode = ExitCode.BAD_INIT; ServiceAndUrlLengthMismatch.title = 'Service and URL count mismatch'; ServiceAndUrlLengthMismatch.fix = 'Pass exactly one `--url` for every `--service`.'; class LocalCompositionError extends HiveCLIError { constructor(compositionResult) { const message = (0, schema_1.renderErrors)((0, index_1.makeFragmentData)({ edges: compositionResult.errors.map(error => ({ node: { message: error.message, }, })), }, schema_1.RenderErrors_SchemaErrorConnectionFragment)); super(`Local composition failed:\n${message}`); } } exports.LocalCompositionError = LocalCompositionError; LocalCompositionError.code = errorCode(ErrorCategory.DEV, 1); LocalCompositionError.exitCode = ExitCode.ERROR; LocalCompositionError.title = 'Local composition failed'; LocalCompositionError.fix = 'Fix the composition errors in the listed subgraphs.'; class RemoteCompositionError extends HiveCLIError { constructor(errors) { super(`Remote composition failed:\n${(0, schema_1.renderErrors)(errors)}`); } } exports.RemoteCompositionError = RemoteCompositionError; RemoteCompositionError.code = errorCode(ErrorCategory.DEV, 2); RemoteCompositionError.exitCode = ExitCode.ERROR; RemoteCompositionError.title = 'Remote composition failed'; RemoteCompositionError.fix = 'Fix the composition errors in the listed subgraphs.'; class InvalidCompositionResultError extends HiveCLIError { /** Compose API spits out the error message */ constructor(supergraph) { super(`Composition resulted in an invalid supergraph: ${supergraph}`); } } exports.InvalidCompositionResultError = InvalidCompositionResultError; InvalidCompositionResultError.code = errorCode(ErrorCategory.DEV, 3); InvalidCompositionResultError.exitCode = ExitCode.ERROR; InvalidCompositionResultError.title = 'Invalid composition result'; InvalidCompositionResultError.fix = 'The composed supergraph is invalid. Report the output as a bug.'; class InvalidDocumentsError extends HiveCLIError { constructor(invalidDocuments) { const message = invalidDocuments .map(doc => { return `${texture_1.Texture.failure(doc.source)}\n${doc.errors.map(e => ` - ${texture_1.Texture.boldQuotedWords(e.message)}`).join('\n')}`; }) .join('\n'); super(`Invalid operation syntax:\n${message}`); } } exports.InvalidDocumentsError = InvalidDocumentsError; InvalidDocumentsError.code = errorCode(ErrorCategory.OPERATIONS_CHECK, 0); InvalidDocumentsError.exitCode = ExitCode.ERROR; InvalidDocumentsError.title = 'Invalid operations'; InvalidDocumentsError.fix = 'Fix the listed operations so that they are valid against the schema.'; /** Every error the CLI can report. Documentation is generated from this list. */ exports.errorCatalog = [ InvalidConfigError, InvalidCommandError, MissingArgumentsError, MissingRegistryTokenError, MissingCdnKeyError, MissingEndpointError, InvalidRegistryTokenError, InvalidCdnKeyError, MissingCdnEndpointError, MissingEnvironmentError, CommitRequiredError, GithubRepositoryRequiredError, AuthorRequiredError, HTTPError, NetworkError, APIError, IntrospectionError, UnsupportedFileExtensionError, FileMissingError, InvalidFileContentsError, InvalidTargetError, InvalidFederationSubgraphError, InvalidVersionIdError, ConflictingOptionsError, AccessDeniedError, UnsupportedServerError, RequestTimeoutError, InvalidInputError, InvalidHeaderError, UnexpectedError, SchemaFileNotFoundError, SchemaFileEmptyError, SchemaCheckFailedError, SchemaCheckApprovalFailedError, SchemaPublishFailedError, InvalidSDLError, SchemaPublishMissingServiceError, SchemaPublishMissingUrlError, PersistedOperationsMalformedError, SchemaNotFoundError, InvalidSchemaError, ServiceAndUrlLengthMismatch, LocalCompositionError, RemoteCompositionError, InvalidCompositionResultError, InvalidDocumentsError, ]; function isAggregateError(error) { return !!error && typeof error === 'object' && 'errors' in error && Array.isArray(error.errors); } /** Whether the error, or one of its causes, is a request timeout (`AbortSignal.timeout`). */ function isTimeoutError(error) { let current = error; for (let depth = 0; depth < 4 && current; depth++) { if (current.name === 'TimeoutError') { return true; } current = current.cause; } return false; } //# sourceMappingURL=errors.js.map