Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AbstractProfileManager<T>

The abstract profile manager contains most (if not all in some cases) methods to manage Imperative profiles. Profiles are user configuration documents intended to be used on commands, as a convenience, to supply a slew of additional input and configuration (normally more than would be feasible as command arguments). See the "IProfile" interface for a detailed description of profiles, their use case, and examples.

The abstract manager is implemented by (at least as part of Imperative) the BasicProfileManager. The BasicProfileManager implements the save, load, update, etc. methods in, as the name implies, a "basic" way. In general, the abstract manager contains all parameter and profile validation code, methods to write/read/etc and the Basic Manager uses most of the internal methods to perform the "work". The basic manager does in some cases change the default abstract behavior (such as for loadAll profile and loadDependencies).

Imperative, however, uses the the "Cli Profile Manager", which extends the "Basic Profile Manager". The CLI Manager includes additional capabilities, such as creating or updating a profile from command line arguments.

In general, Imperative CLI's will use the "Cli Profile Manager", where the "Basic Profile Manager" is normally sufficient for usage outside of Imperative (for usage in building extensions to editors, Electron apps, programmatic usage of APIs built by implementations of Imperative, etc.), although either can be used.

It is not an absolute requirement, but in the case of an Imperative CLI, the "Basic Profile Manager initialize()" API is invoked to create the required directories and sub-directories. This is NOT a requirement, but avoiding "initialize()" means you must supply all configuration information to the manager when creating an instance. See the "initialize()" API method in the "BasicProfileManager" for full details.

export
abstract

Type parameters

Hierarchy

Index

Constructors

constructor

Properties

Private mConstructorParms

mConstructorParms: IProfileManager<T>

Parameters passed on the constructor (normally used to create additional instances of profile manager objects)

memberof

AbstractProfileManager

Private mLoadCounter

mLoadCounter: Map<string, number> = new Map<string, number>()

Load counter for this instance of the imperative profile manager. The load counter ensures that we are not attempting to load circular dependencies by checking if a load (with dependencies) is attempting a load of the same profile twice. The counts are reset when the loads complete, so state should be preserved correctly.

static
memberof

AbstractProfileManager

Private mLogger

mLogger: Logger = Logger.getImperativeLogger()

Logger instance - must be log4js compatible. Can be the Imperative logger (normally), but is required for profile manager operation.

memberof

AbstractProfileManager

Private mProductDisplayName

mProductDisplayName: string

Product display name of the CLI.

memberof

AbstractProfileManager

Private mProfileRootDirectory

mProfileRootDirectory: string

The profile root directory is normally supplied on an Imperative configuration document, but it is the location where all profile type directories are stored.

memberof

AbstractProfileManager

Private mProfileType

mProfileType: string

The profile "type" for this manager - indicating the profile/schema that this manager is working directly with.

memberof

AbstractProfileManager

Private mProfileTypeConfiguration

mProfileTypeConfiguration: T

The profile configuration document for the "type" defined to this manager. Contains the schema and dependency specifications for the profile type.

memberof

AbstractProfileManager

Private mProfileTypeConfigurations

mProfileTypeConfigurations: T[]

The full set of profile type configurations. The manager needs to ensure that A) the profile type configuration is among the set (because it contains schema and dependency specifications) and B) That other type configurations are available to verify/load dependencies, etc.

memberof

AbstractProfileManager

Private mProfileTypeMetaFileName

mProfileTypeMetaFileName: string

The meta file name for this profile type. Of the form "_meta".

memberof

AbstractProfileManager

Private mProfileTypeRootDirectory

mProfileTypeRootDirectory: string

The root directory for the type (contained within the profile root directory).

memberof

AbstractProfileManager

Private mProfileTypeSchema

mProfileTypeSchema: IProfileSchema

The profile schema for the "type". The JSON schema is used to validate any profiles loaded or saved by this profile manager for the type.

memberof

AbstractProfileManager

Static Readonly META_FILE_SUFFIX

META_FILE_SUFFIX: string = "_meta"

The meta file suffix - always appended to the meta file to distinguish from other profiles. Users then cannot supply a profile name that would conflict with the meta file.

static
memberof

AbstractProfileManager

Static Readonly PROFILE_EXTENSION

PROFILE_EXTENSION: string = ".yaml"

The default profile file extension (YAML format) - all profiles are stored in YAML format including the meta profile file.

static
memberof

ProfileManager

Accessors

configurations

Protected loadCounter

  • get loadCounter(): Map<string, number>

Protected log

Protected managerParameters

Protected productDisplayName

  • get productDisplayName(): string

Protected profileRootDirectory

  • get profileRootDirectory(): string

Protected profileType

  • get profileType(): string

Protected profileTypeConfiguration

  • get profileTypeConfiguration(): T

Protected profileTypeConfigurations

  • get profileTypeConfigurations(): T[]

Protected profileTypeMetaFileName

  • get profileTypeMetaFileName(): string

Protected profileTypeRootDirectory

  • get profileTypeRootDirectory(): string

Protected profileTypeSchema

Methods

clearDefault

  • clearDefault(): string

Private collectAllConfigurations

  • collectAllConfigurations(): T[]

Protected constructFullProfilePath

  • constructFullProfilePath(name: string, type?: string): string

Private constructMetaName

  • constructMetaName(type?: string): string

Private createProfileTypeDirectory

  • createProfileTypeDirectory(): string

delete

  • Deletes a profile from disk. Ensures that the parameters are correct and removes the profile. If the profile is listed as a dependency of other profiles it will NOT delete the profile unless "rejectIfDependency" is set to false.

    memberof

    AbstractProfileManager

    Type parameters

    Parameters

    • parms: D

      See the interface for details

    Returns Promise<IProfileDeleted>

    • The promise that is fulfilled with the response object (see interface for details) or rejected with an Imperative Error.

Protected Abstract deleteProfile

Protected deleteProfileFromDisk

  • deleteProfileFromDisk(name: string): string

Private failNotFoundDefaultResponse

getAllProfileNames

  • getAllProfileNames(): string[]

getDefaultProfileName

  • getDefaultProfileName(): string

Private isDependencyOf

Protected isProfileEmpty

  • isProfileEmpty(profile: IProfile): boolean
  • Checks if the profile object passed is "empty" - meaning it has no contents other than that type or name. A profile can only specify "dependencies", in the event that it is just acting as a "pointer" to another profile.

    memberof

    AbstractProfileManager

    Parameters

    • profile: IProfile

      The profile to check for "emptiness".

    Returns boolean

    True if the profile object is empty.

load

  • Load a profile from disk. Ensures that the parameters are valid and loads the profile specified by name OR the default profile if requested. If load default is requested, any name supplied is ignored.

    memberof

    AbstractProfileManager

    Type parameters

    Parameters

    • parms: L

      See the interface for details.

    Returns Promise<IProfileLoaded>

    • The promise that is fulfilled with the response object (see interface for details) or rejected with an Imperative Error.

Abstract loadAll

Protected Abstract loadDependencies

Protected loadFailed

  • loadFailed(name: string): void

Protected Abstract loadProfile

Protected loadSpecificProfile

  • loadSpecificProfile(name: string, failNotFound?: boolean, loadDependencies?: boolean): Promise<IProfileLoaded>

Protected locateExistingProfile

  • locateExistingProfile(name: string): string

mergeProfiles

Private protectAgainstOverwrite

  • protectAgainstOverwrite(name: string, overwrite: boolean): void

Private readMeta

save

  • Save a profile to disk. Ensures that the profile specified is valid (basic and schema validation) and invokes the implementations "saveProfile" method to perform the save and formulate the response.

    memberof

    AbstractProfileManager

    Type parameters

    Parameters

    • parms: S

      See interface for details

    Returns Promise<IProfileSaved>

    • The promise that is fulfilled with the response object (see interface for details) or rejected with an Imperative Error.

Protected Abstract saveProfile

setDefault

  • setDefault(name: string): string

Private setDefaultInMetaObject

  • setDefaultInMetaObject(meta: IMetaProfile<T>, defaultProfileName: string): void

update

Protected Abstract updateProfile

validate

Private validateConfigurationDocument

  • validateConfigurationDocument(typeConfiguration: T): void

Private validateMetaProfile

  • validateMetaProfile(meta: IMetaProfile<T>, type?: string): void

Protected Abstract validateProfile

Protected validateProfileAgainstSchema

  • validateProfileAgainstSchema(name: string, profile: IProfile, strict?: boolean): void

Protected validateProfileObject

  • validateProfileObject(name: string, type: string, profile: IProfile): void

Private validateRequiredDependenciesAreSpecified

  • validateRequiredDependenciesAreSpecified(profile: IProfile): void
  • Validates a profiles contents against the required dependencies specified on the profile configuration type document. If the document indicates that a dependency is required and that dependency is missing from the input profile, an error is thrown.

    memberof

    AbstractProfileManager

    Parameters

    • profile: IProfile

      The profile to validate dependency specs

    Returns void

Private validateSchema

  • Validate that the schema document passed is well formed for the profile manager usage. Ensures that the schema is not overloading reserved properties.

    memberof

    AbstractProfileManager

    Parameters

    • schema: IProfileSchema

      The schema document to validate.

    • Default value type: string = this.profileType

      the type of profile for the schema - defaults to the current type for this manager

    Returns void

Generated using TypeDoc