@cto.ai/ops
Version:
π» CTO.ai Ops - The CLI built for Teams π
424 lines (423 loc) β’ 20.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const sdk_1 = require("@cto.ai/sdk");
const errorSource_1 = require("../constants/errorSource");
const env_1 = require("../constants/env");
const ErrorTemplate_1 = require("./ErrorTemplate");
const utils_1 = require("../utils");
const debug_1 = tslib_1.__importDefault(require("debug"));
const debug = debug_1.default('ops:CustomErrors');
const expectedSource = {
source: errorSource_1.errorSource.EXPECTED,
};
const { actionBlue, white, dim } = sdk_1.ux.colors;
const problemContinues = `If the problem continues please contact us at: ${actionBlue(env_1.INTERCOM_EMAIL)}`;
const tryAgainOrContact = `Please try again or contact ${actionBlue(env_1.INTERCOM_EMAIL)} and we'll do our best to help.`;
class FileNotFoundError extends ErrorTemplate_1.ErrorTemplate {
constructor(err, path, file) {
super(white(`π€ Looks like the file ${actionBlue(file)} wasn't found in path:\n ${actionBlue(path)}\n Please verify it exists and try again.`), err, expectedSource);
}
}
exports.FileNotFoundError = FileNotFoundError;
class DockerBuildImageError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white('π€ Looks like there was an error when building your image.\n Please check your Dockerfile and try again.'), err, expectedSource);
}
}
exports.DockerBuildImageError = DockerBuildImageError;
class ConfigError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`βοΈUh-oh, we experienced a problem.\n Please try signing out and back in again.\n ${problemContinues}`), err, expectedSource);
}
}
exports.ConfigError = ConfigError;
class CopyTemplateFilesError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`βWe couldn't copy the required files.\n Please check your directory permissions.\n ${tryAgainOrContact}`), err, expectedSource);
}
}
exports.CopyTemplateFilesError = CopyTemplateFilesError;
class MandatoryParameter extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`βοΈUh-oh, your request failed due to undefined parameters.\n ${tryAgainOrContact}`), err, expectedSource);
}
}
exports.MandatoryParameter = MandatoryParameter;
class UndefinedParameter extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super('Missing parameter', err);
}
}
exports.UndefinedParameter = UndefinedParameter;
class UserUnauthorized extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white("π€ You don't have permissions for that action. Please try again."), err, expectedSource);
}
}
exports.UserUnauthorized = UserUnauthorized;
class CouldNotCreateOp extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white('π
Uh-oh, this op already exists, please remove it try again.'), err, expectedSource);
}
}
exports.CouldNotCreateOp = CouldNotCreateOp;
class CouldNotCreateWorkflow extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white('π
Uh-oh, this workflow already exists, please remove it and try again.'), err, expectedSource);
}
}
exports.CouldNotCreateWorkflow = CouldNotCreateWorkflow;
class InvalidWorkflowStep extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white('π
Uh-oh, one of the steps in your workflow is referencing an invalid op.\n Please make sure all steps are referencing ops you have access to.'), err, expectedSource);
}
}
exports.InvalidWorkflowStep = InvalidWorkflowStep;
class CouldNotInitializeOp extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`βοΈLooks like a problem occurred initializing your Op / Workflow.\n ${tryAgainOrContact}`), err, expectedSource);
}
}
exports.CouldNotInitializeOp = CouldNotInitializeOp;
class CouldNotGetRegistryToken extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white('π
Call to registry/token failed, most likely due to invalid access token.'), err, expectedSource);
}
}
exports.CouldNotGetRegistryToken = CouldNotGetRegistryToken;
class CouldNotMakeDir extends ErrorTemplate_1.ErrorTemplate {
constructor(err, path = '') {
super(white(`π
Looks like we weren't able to create a config directory at:\n ${actionBlue(path)}\n Please check your permissions and try again.`), err, expectedSource);
}
}
exports.CouldNotMakeDir = CouldNotMakeDir;
class InvalidTeamNameFormat extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`β Sorry, that's an invalid team name. \n β Team names may contain only letters (case-sensitive), numbers, dashes (-), and underscores (_).`), err, {
source: errorSource_1.errorSource.EXPECTED,
exit: false,
});
}
}
exports.InvalidTeamNameFormat = InvalidTeamNameFormat;
class CouldNotGetLatestVersion extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super('Call to check version failed, most likely due to internet connection.', err, {
source: errorSource_1.errorSource.EXPECTED,
exit: false,
});
}
}
exports.CouldNotGetLatestVersion = CouldNotGetLatestVersion;
class APIError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`βοΈ Looks like an API error occurred.\n ${tryAgainOrContact}`), err, expectedSource);
}
}
exports.APIError = APIError;
class AnalyticsError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super('Analytics error occurred', err, { exit: false });
}
}
exports.AnalyticsError = AnalyticsError;
class PermissionsError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`π€ Uh-oh! You don't have permission to perform this action.\n Please review your system user permissions and try again.`), err, expectedSource);
}
}
exports.PermissionsError = PermissionsError;
class InviteSendingInvite extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white('π
Uh-oh, the invite failed to send. Please try again.'), err, expectedSource);
}
}
exports.InviteSendingInvite = InviteSendingInvite;
class InviteCodeInvalid extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white("π
Uh-oh, the invite code doesn't seem to be valid. Please check the code and try again."), err, expectedSource);
}
}
exports.InviteCodeInvalid = InviteCodeInvalid;
class InvalidInputCharacter extends ErrorTemplate_1.ErrorTemplate {
constructor(fieldName) {
super(white(`β The ${fieldName} can only contain numbers, letters, -, or _'.`), undefined, expectedSource);
}
}
exports.InvalidInputCharacter = InvalidInputCharacter;
class InvalidOpVersionFormat extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white('β Sorry, version is required and can only contain letters, digits, underscores, \n periods and dashes and must start and end with a letter or a digit'), undefined, expectedSource);
}
}
exports.InvalidOpVersionFormat = InvalidOpVersionFormat;
class MissingRequiredArgument extends ErrorTemplate_1.ErrorTemplate {
constructor(command) {
super(white(`β This command requires an argument. Run ${utils_1.terminalText(`${command} --help`)} to learn more.`), undefined, expectedSource);
}
}
exports.MissingRequiredArgument = MissingRequiredArgument;
class NoResultsFoundForDeletion extends ErrorTemplate_1.ErrorTemplate {
constructor(opOrWorkflow) {
super(white(`π€ We couldn't find any matches for ${actionBlue(opOrWorkflow)}.\n Please check the name and try again.`), undefined, expectedSource);
}
}
exports.NoResultsFoundForDeletion = NoResultsFoundForDeletion;
class DockerPublishNoImageFound extends ErrorTemplate_1.ErrorTemplate {
constructor(opName, teamName) {
super(white(`β We couldn't find an image for ${actionBlue(opName)}.\n βοΈ Please build this op for ${actionBlue(`${teamName}`)}: ${utils_1.terminalText(`ops build ${opName}`)}`), undefined, expectedSource);
}
}
exports.DockerPublishNoImageFound = DockerPublishNoImageFound;
class NoLocalOpsOrWorkflowsFound extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`π© We couldn't find any ops or workflows in the ops.yml!`), undefined, expectedSource);
}
}
exports.NoLocalOpsOrWorkflowsFound = NoLocalOpsOrWorkflowsFound;
class NoLocalOpsFound extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`π© We couldn't find any ops in the ops.yml!`), undefined, expectedSource);
}
}
exports.NoLocalOpsFound = NoLocalOpsFound;
class NoOpsFound extends ErrorTemplate_1.ErrorTemplate {
constructor(opName, teamName) {
let message = `π© We couldn't find any ops with the name ${sdk_1.ux.colors.blueBright(opName)}`;
if (teamName) {
message += ` in the team ${sdk_1.ux.colors.cyan(teamName)}.`;
}
super(white(message), undefined, expectedSource);
}
}
exports.NoOpsFound = NoOpsFound;
class NoStepsFound extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`π© We couldn't find any workflow steps in the ops.yml!`), undefined, expectedSource);
}
}
exports.NoStepsFound = NoStepsFound;
class InvalidStepsFound extends ErrorTemplate_1.ErrorTemplate {
constructor(step) {
super(white(`π© Workflow step: ${step} is invalid!`), undefined, expectedSource);
}
}
exports.InvalidStepsFound = InvalidStepsFound;
class InvalidGlueCode extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`βοΈ Looks like a problem occured with on of the workflows steps.\n ${tryAgainOrContact}`), undefined, expectedSource);
}
}
exports.InvalidGlueCode = InvalidGlueCode;
class ImageNotFoundError extends ErrorTemplate_1.ErrorTemplate {
constructor(imageName) {
super(white(`π€ We couldn't find an image with the name ${actionBlue(imageName)}.\n Please select a different one and try again.`), undefined, expectedSource);
}
}
exports.ImageNotFoundError = ImageNotFoundError;
class SignInError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`π€ Sorry, we couldnβt find an account with that email or password.\n Forgot your password? Run ${utils_1.terminalText('ops account:reset')}`), err, expectedSource);
}
}
exports.SignInError = SignInError;
class NoEmailForReset extends ErrorTemplate_1.ErrorTemplate {
constructor(err, email) {
super(white(`π Uh-oh, we couldn't find any user associated with ${actionBlue(email)}\n Please Check your email and try again.`), err, expectedSource);
}
}
exports.NoEmailForReset = NoEmailForReset;
class ResetTokenError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`π
Looks like there's an issue with that token.\n Please request a new token by running ${utils_1.terminalText('ops account:reset')}`), err, expectedSource);
}
}
exports.ResetTokenError = ResetTokenError;
class SignUpError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`π
We couldn't sign you up at this point in time.\n ${tryAgainOrContact}`), err, expectedSource);
}
}
exports.SignUpError = SignUpError;
class ImageTagError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`βοΈ Oops, seems like there was a problem tagging the image.\n ${tryAgainOrContact}`), err, expectedSource);
}
}
exports.ImageTagError = ImageTagError;
class ImagePushError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`β Oops, seems like there was a problem pushing that image to the registry!\n ${tryAgainOrContact}`), err, expectedSource);
}
}
exports.ImagePushError = ImagePushError;
class ImagePullError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`β Oops, seems like there was a problem pulling that image from the registry!\n ${tryAgainOrContact}`), err, expectedSource);
}
}
exports.ImagePullError = ImagePullError;
class AlreadySignedOut extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`π€·ββοΈ Looks like you are already signed out.\n Run ${utils_1.terminalText('ops account:signin')} to sign back into your account.`), undefined, expectedSource);
}
}
exports.AlreadySignedOut = AlreadySignedOut;
class SignOutError extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`π
Uh-oh, we weren't able to sign out up at this point in time.\n ${tryAgainOrContact}`), err, expectedSource);
}
}
exports.SignOutError = SignOutError;
class YamlPortError extends ErrorTemplate_1.ErrorTemplate {
constructor(badPort) {
super(white(`π€ We're having trouble parsing the port: ${badPort}.\n ${dim('Please enter with the format')} ${actionBlue('{HostPort}:{InternalPort}')}${dim('. For example:')} ${actionBlue('3000:3000')}`), undefined, expectedSource);
}
}
exports.YamlPortError = YamlPortError;
class SSOError extends ErrorTemplate_1.ErrorTemplate {
constructor(message) {
message && debug(message);
super(white(`π€ We're having trouble signing you in. Please try running ${actionBlue('$ ops account:signin')} again!`), undefined, expectedSource);
}
}
exports.SSOError = SSOError;
class TokenExpiredError extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`\nβ οΈ Sorry your session has expired. \n\n π¨βπ» You can sign in with ${sdk_1.ux.colors.green('$')} ${sdk_1.ux.colors.callOutCyan('ops account:signin')}`), undefined, expectedSource);
}
}
exports.TokenExpiredError = TokenExpiredError;
class CannotDeleteOp extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`β Sorry, we cannot delete the op. \n\n Please verify that it is not being used in some other op.\n`), err, expectedSource);
}
}
exports.CannotDeleteOp = CannotDeleteOp;
class InvalidOpName extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`β Sorry, we cannot find that op. Please enter an op with one of the following format:\n- ops run ${sdk_1.ux.colors.bold('@teamName')}/${sdk_1.ux.colors.cyan('opName')}:${sdk_1.ux.colors.reset('version')}\n- ops run ${sdk_1.ux.colors.bold('@teamName')}/${sdk_1.ux.colors.cyan('opName')} ${sdk_1.ux.colors.dim('(for the latest version of the op)')}\n- ops run ${sdk_1.ux.colors.cyan('opName')} ${sdk_1.ux.colors.dim('(for ops you have in your team, or a folder in your current working directory)')}`), undefined, expectedSource);
}
}
exports.InvalidOpName = InvalidOpName;
class UnauthorizedtoAccessOp extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`β Oops, seems like you do not have access to run this op!`), err, expectedSource);
}
}
exports.UnauthorizedtoAccessOp = UnauthorizedtoAccessOp;
class IncompleteOpsYml extends ErrorTemplate_1.ErrorTemplate {
constructor(message) {
super(white(`β Sorry, we have difficulty parsing your ops.yml. ${message}`), undefined, expectedSource);
}
}
exports.IncompleteOpsYml = IncompleteOpsYml;
class InvalidRemoveOpFormat extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`β Sorry, please provide op you want to remove in a valid format. E.g. \n ${utils_1.terminalText('ops remove my-command:0.1.0')} - for your own ops \n `), undefined, expectedSource);
}
}
exports.InvalidRemoveOpFormat = InvalidRemoveOpFormat;
class OpAlreadyBelongsToTeam extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`β That's odd. It seems like you are trying to add an op that belongs to your team.`), undefined, expectedSource);
}
}
exports.OpAlreadyBelongsToTeam = OpAlreadyBelongsToTeam;
class OpNotFoundOpsAdd extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`β That's odd. It seems like you are trying to add an op that does not exist.`), undefined, expectedSource);
}
}
exports.OpNotFoundOpsAdd = OpNotFoundOpsAdd;
class OpAlreadyAdded extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`β That's odd. It seems like you are trying to add an op that's already added to your team.`), undefined, expectedSource);
}
}
exports.OpAlreadyAdded = OpAlreadyAdded;
class VersionIsTaken extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`π€ It seems like the version of the op that you are trying to publish is already taken. Please try again with a different version name.`), undefined, expectedSource);
}
}
exports.VersionIsTaken = VersionIsTaken;
class NoTeamFound extends ErrorTemplate_1.ErrorTemplate {
constructor(teamName) {
super(white(`π€ Sorry, we couldn't find a team with name ${sdk_1.ux.colors.cyan(teamName)}.`), undefined, expectedSource);
}
}
exports.NoTeamFound = NoTeamFound;
class TeamUnauthorized extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white('π€ Your team lacks the permission for that action. Please try again.'), err, expectedSource);
}
}
exports.TeamUnauthorized = TeamUnauthorized;
class RegisterSecretsProvider extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white('π
Oops! We were not able to register the secrets provider'), err, expectedSource);
}
}
exports.RegisterSecretsProvider = RegisterSecretsProvider;
class InvalidSecretToken extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`π
It looks like this token is not valid with the specified vault`), err, expectedSource);
}
}
exports.InvalidSecretToken = InvalidSecretToken;
class InvalidSecretVault extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`π€ It appears the vault URL that was specified is invalid`), err, expectedSource);
}
}
exports.InvalidSecretVault = InvalidSecretVault;
class SecretNotFound extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`π€ It appears the secret you are trying to delete cannot be found`), err, expectedSource);
}
}
exports.SecretNotFound = SecretNotFound;
class SecretsProviderFound extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`π
It looks like you already got a ${sdk_1.ux.colors.bold('secrets provider')} for this team. You can unregister a secrets provider using ${utils_1.terminalText('ops secrets:unregister')}.`), undefined, expectedSource);
}
}
exports.SecretsProviderFound = SecretsProviderFound;
class NoSecretsProviderFound extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`π
Oops! We are not able to find a secrets provider for this team. You can register a secrets provider using ${utils_1.terminalText('ops secrets:register')}.`), err, expectedSource);
}
}
exports.NoSecretsProviderFound = NoSecretsProviderFound;
class NoSecretsOnTeam extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white(`π€ There does not appear to be any secrets stored for your current team`), err, expectedSource);
}
}
exports.NoSecretsOnTeam = NoSecretsOnTeam;
class SetSecretsProvider extends ErrorTemplate_1.ErrorTemplate {
constructor(err) {
super(white('π
Oops! we were not able to successfully set the secret'), err, expectedSource);
}
}
exports.SetSecretsProvider = SetSecretsProvider;
class SecretsValuesNotEqual extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white('π€ Sorry, the values you have entered do not match!'), undefined, expectedSource);
}
}
exports.SecretsValuesNotEqual = SecretsValuesNotEqual;
class SecretsFlagsRequired extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white('π
Oops! it appears that either flag -k or -v is missing'), undefined, expectedSource);
}
}
exports.SecretsFlagsRequired = SecretsFlagsRequired;
class NoSecretFound extends ErrorTemplate_1.ErrorTemplate {
constructor() {
super(white(`π Sorry, we weren't able to select the secret key. ${tryAgainOrContact}`), undefined, expectedSource);
}
}
exports.NoSecretFound = NoSecretFound;