@AppKu/StashKu

@AppKu/StashKu

v1.0.46

Class

ModelGenerator

A utility class for working with StashKu-compatible model objects.

Constructor

new ModelGenerator()

Source

Methods

static

formatModelName(dirtyResourceName, suffixopt) → {String}

Attempts to format a generic resource name into a model class name in PascalCase format. The resource name is always suffixed with the word "Model".

This function leverages the STASHKU_MODEL_NAME_REMOVE environmental setting, which allows you to configure one or more regular expressions that are removed from a generated model's class name (derived from a resource name). By default the configured expressions will strip "dbo.", "etl.", and "rpt." prefixes from resource names.

Parameters

  • dirtyResourceName String

    The resource name value to be formatted.

  • suffix String <optional>
    "Model"

    A suffix attached to the model name. Defaults to "Model".

Returns

  • String

Source

static

formatPropName(dirtyPropName) → {String}

Attempts to format a generically formatted property name to a JavaScript camelCase property name format.

Parameters

  • dirtyPropName String

    The property name value to be formatted.

Returns

  • String

Source

static

generateModelType(resource, properties, configurationopt, classNameopt) → {Modeling.AnyModelType}

Generates a model type class dynamically utilizing the given properties and configuration.

Parameters

  • resource String

    The name of the target resource.

  • properties Map.<String, Modeling.PropertyDefinition>

    The map of all properties definable for the model.

  • configuration Modeling.Configuration <optional>

    The $stashku model configuration.

  • className String <optional>

    Optional argument to utilize a specific class name instead of generating one from the resource name.

Returns

Throws

  1. 500 RESTError if the "typeName" argument is missing.

  2. 500 RESTError if the "properties" argument is missing.

  3. 500 RESTError if the "properties" argument is not a Map instance.

Source