import { CustomFieldType } from '@atlassian/forge-graphql-types'; import { arrayToSentence, truncate, } from '../../../../../helpers/arrayToSentence'; export const missingKeyErrorMessage = (missingKeys: Array): string => `${arrayToSentence(missingKeys)} must be included in the configuration file`; export const missingNestedKeyErrorMessage = ( missingKeys: Array, topLevelProperty: string, ): string => `the "${topLevelProperty}" property in the configuration file must include ${arrayToSentence( missingKeys, )}`; export function invalidKeyErrorMessage( propertyName: string, validProperties?: string[], ): string { const truncatedPropertyName = truncate(propertyName); return validProperties && validProperties.length > 0 ? `"${truncatedPropertyName}" must be one of the following keys: ${validProperties.join( ', ', )}` : `"${truncatedPropertyName}" is not a valid property`; } export const invalidCharactersErrorMessage = (key: string): string => `"${key}" contains invalid characters. Remove those characters and try again.`; export const maxValueLengthErrorMessage = ( key: string, length: number, ): string => `"${key}" field is too long. Try again with a value no longer than ${length} characters.`; export const invalidValueTypeErrorMessage = ( key: string, expectedType: string, ): string => `"${key}" must be of type "${expectedType}"`; export const invalidFieldTypeErrorMessage = ( propertyName: string, validTypes: string[], ): string => `"${propertyName}" must have a value of: ${validTypes.join(', ')}`; export const invalidFieldValueErrorMessage = ( key: string, validValue: string | number, ): string => `"${key}" is invalid. "${key}" must be ${validValue}`; export const invalidOptionIdTypeErrorMessage = ( id: string, expectedType: string, ): string => `option id: "${id}" must be of type "${expectedType}"`; export const invalidDisplayValueErrorMessage = ( value: string, expectedType: string, ): string => `option display value: "${value}" must be of type "${expectedType}"`; export const invalidLinkTypeErrorMessage = ( type: string, validTypes: string[], ): string => `"${truncate( type, )}" is not a valid link type. The accepted values are: ${validTypes.join( ', ', )}`; export const invalidCustomFieldTypeErrorMessage = ( type: string, validTypes: string[], ): string => `"${ typeof type === 'string' ? truncate(type) : type }" is not a valid customField type. The accepted values are: ${validTypes.join( ', ', )}`; export const multipleSameCustomFieldsError = (customFieldName: string) => `"${customFieldName}" has duplication in config file. Custom fields must be with unique name.`; export const invalidCustomFieldValueType = ( value: any, requiredValueType: string, customFieldType: CustomFieldType, ): string => `"${truncate( value, )}" has a not valid type for ${customFieldType}. Value must be ${requiredValueType}.`; export const missingSpecificCustomFieldInComponent = ( customFieldName: string, ) => `Component doesn't have custom field with name "${customFieldName}"`; export const invalidCustomFieldTypeForExistingComponent = ( customFieldName: string, requiredCustomFieldType: string, ) => `"${customFieldName}" field has a difference in the type. Type must be "${requiredCustomFieldType}"`; export const DETACH_ERROR_MESSAGE = 'Unexpected internal server error. You may need to relink the component and try deleting it again'; export const INVALID_RELATIONSHIP_ERROR_MESSAGE = 'The Atlassian resource identifier (ARI) of the component at the start node of this relationship is invalid. Try again with a valid ARI'; export const DEFAULT_SERVER_ERROR_MESSAGE = 'Unexpected internal server error. Try again'; export const INVALID_YAML_ERROR = 'Invalid YAML format. Try again with a valid YAML file'; export const UNKNOWN_EXTERNAL_ALIAS_ERROR_MESSAGE = 'We couldn’t find the external alias. Check for typos and try again'; export const MISSING_CUSTOM_FIELDS_IN_COMPONENT = 'Custom fields defined in yaml need to already exist on the component'; export const labelHasWhitespaceErrorMessage = (label: string): string => `The component label name [${label}] contains whitespace characters. Remove all whitespace characters and try again.`; export const labelHasUppercaseErrorMessage = (label: string): string => `The component label name [${label}] must be in lowercase. Remove all uppercase characters and try again.`; export const componentNotFound = (id: string | null): string => `Component with id ${id} not found`;