Skip to main content

@webda/coreReadme | API


Class: UnpackedApplication

An unpacked application load dynamically all webda.module.json And load also all the package description

The normal Application is designed to load all this information from the cachedModule to avoid any unecessary action within a production environment

Extends

Constructors

new UnpackedApplication(file, logger)

new UnpackedApplication(file, logger?): UnpackedApplication

Parameters

file: string

logger?: WorkerOutput

Returns

UnpackedApplication

Overrides

Application.constructor

Source

packages/core/src/unpackedapplication.ts:35

Properties

_loaded

protected _loaded: string[] = []

Contains already loaded modules

Inherited from

Application._loaded

Source

packages/core/src/application.ts:473


appModule

protected appModule: Module

Contains definitions of current application

Inherited from

Application.appModule

Source

packages/core/src/application.ts:457


appPath

readonly appPath: string

Get Application root path

Inherited from

Application.appPath

Source

packages/core/src/application.ts:444


baseConfiguration

protected baseConfiguration: Configuration

Base configuration loaded from webda.config.json

Inherited from

Application.baseConfiguration

Source

packages/core/src/application.ts:448


configurationFile

readonly configurationFile: string

Configuration file

Inherited from

Application.configurationFile

Source

packages/core/src/application.ts:523


currentDeployment

protected currentDeployment: string

Current deployment

Inherited from

Application.currentDeployment

Source

packages/core/src/application.ts:452


deployers

protected deployers: Object = {}

Deployers type registry

Index signature

[key: string]: any

Inherited from

Application.deployers

Source

packages/core/src/application.ts:478


deploymentFile

deploymentFile: string

Current deployment file

Inherited from

Application.deploymentFile

Source

packages/core/src/application.ts:527


flatHierarchy

protected flatHierarchy: Object = {}

Direct parent of a model

Index signature

[key: string]: string

Inherited from

Application.flatHierarchy

Source

packages/core/src/application.ts:518


graph

protected graph: ModelsGraph = {}

Models graph

Inherited from

Application.graph

Source

packages/core/src/application.ts:493


initTime

protected initTime: number

When the application got initiated

Inherited from

Application.initTime

Source

packages/core/src/application.ts:513


logger

protected logger: WorkerOutput

Class Logger

Inherited from

Application.logger

Source

packages/core/src/application.ts:503


moddas

protected moddas: Object = {}

Moddas registry

Index signature

[key: string]: Modda

Inherited from

Application.moddas

Source

packages/core/src/application.ts:483


models

protected models: Object = {}

Models type registry

Index signature

[key: string]: CoreModelDefinition

Inherited from

Application.models

Source

packages/core/src/application.ts:488


plurals

protected plurals: Object = {}

Models specific plurals

Index signature

[key: string]: string

Inherited from

Application.plurals

Source

packages/core/src/application.ts:498


workspacesPath

protected workspacesPath: string = ""

Detect if running as workspace

Inherited from

Application.workspacesPath

Source

packages/core/src/application.ts:508


active

static protected active: Application

Current application

Inherited from

Application.active

Source

packages/core/src/application.ts:532

Methods

addDeployer()

addDeployer(name, model): this

Add a new deployer

Parameters

name: string

model: any

Returns

this

Inherited from

Application.addDeployer

Source

packages/core/src/application.ts:990


addModel()

addModel(name, model, dynamic): this

Add a new model

Parameters

name: string

model: any

dynamic: boolean= true

Returns

this

Inherited from

Application.addModel

Source

packages/core/src/application.ts:969


addService()

addService(name, service): this

Add a new service

Parameters

name: string

service: Modda

Returns

this

Inherited from

Application.addService

Source

packages/core/src/application.ts:737


completeConfiguration()

completeConfiguration(configuration): Configuration

Add Moddas, Models and Deployers definitions It also add the project metadata

Parameters

configuration: Configuration

Returns

Configuration

Source

packages/core/src/unpackedapplication.ts:90


completeNamespace()

completeNamespace(name): string

Return the full name including namespace

In Webda the ServiceType include namespace Webda/Store or Webda/Test This method will make sure the namespace is present, adding it if no '/' is found in the name

Parameters

name: string= ""

Returns

string

Inherited from

Application.completeNamespace

Source

packages/core/src/application.ts:1234


filterModule()

filterModule(_filename): boolean

Only allow local and core module and sample-app

Parameters

_filename: string

Returns

boolean

Source

packages/core/src/unpackedapplication.ts:257


findModules()

findModules(module): string[]

Load all imported modules and current module It will compile module Generate the current module file Load any imported webda.module.json

Parameters

module: CachedModule

Returns

string[]

Source

packages/core/src/unpackedapplication.ts:211


getAppPath()

getAppPath(subpath): string

Return the current app path

Parameters

subpath: string= undefined

to append to

Returns

string

Inherited from

Application.getAppPath

Source

packages/core/src/application.ts:721


getBeans()

getBeans(): Object

Return all beans of the application

Returns

Object

Inherited from

Application.getBeans

Source

packages/core/src/application.ts:836


getConfiguration()

getConfiguration(_deployment): Configuration

Get application configuration

Parameters

_deployment: string= undefined

Returns

Configuration

Inherited from

Application.getConfiguration

Source

packages/core/src/application.ts:1128


getCurrentConfiguration()

getCurrentConfiguration(): Configuration

Return current Configuration of the Application

Same as calling

getConfiguration(this.currentDeployment);

Returns

Configuration

Inherited from

Application.getCurrentConfiguration

Source

packages/core/src/application.ts:1141


getCurrentDeployment()

getCurrentDeployment(): string

Get current deployment name

Returns

string

Inherited from

Application.getCurrentDeployment

Source

packages/core/src/application.ts:1110


getDeployers()

getDeployers(): Object

Return all deployers

Returns

Object

Inherited from

Application.getDeployers

Source

packages/core/src/application.ts:959


getFullNameFromPrototype()

getFullNameFromPrototype(proto): string

Parameters

proto: any

Prototype to send

Returns

string

Inherited from

Application.getFullNameFromPrototype

Source

packages/core/src/application.ts:605


getGitInformation()

getGitInformation(_name?, _version?): GitInformation

Parameters

_name?: string

_version?: string

Returns

GitInformation

empty git information

Overrides

Application.getGitInformation

Source

packages/core/src/unpackedapplication.ts:132


getGraph()

getGraph(): ModelsGraph

Get the all graph

Returns

ModelsGraph

Inherited from

Application.getGraph

Source

packages/core/src/application.ts:663


getModda()

getModda(name): Modda

Get a service based on name

Parameters

name: any

Returns

Modda

Inherited from

Application.getModda

Source

packages/core/src/application.ts:822


getModdas()

getModdas(): Object

Return all services of the application

Returns

Object

Inherited from

Application.getModdas

Source

packages/core/src/application.ts:829


getModel()

getModel<T>(name): CoreModelDefinition<T>

Retrieve the model implementation

Type parameters

T extends CoreModel = CoreModel

Parameters

name: string

model to retrieve

Returns

CoreModelDefinition<T>

Inherited from

Application.getModel

Source

packages/core/src/application.ts:845


getModelFromConstructor()

getModelFromConstructor(model): string

Return the model name for a object

Parameters

model: Constructor<CoreModel>

Returns

string

Inherited from

Application.getModelFromConstructor

Source

packages/core/src/application.ts:893


getModelFromInstance()

getModelFromInstance(object): string

Return the model name for a object

Parameters

object: CoreModel

Returns

string

Inherited from

Application.getModelFromInstance

Source

packages/core/src/application.ts:885


getModelHierarchy()

getModelHierarchy(model): Object

Get the model hierarchy

Parameters

model: string | CoreModel | Constructor<CoreModel>

Returns

Object

ancestors

ancestors: string[]

children

children: ModelsTree

Inherited from

Application.getModelHierarchy

Source

packages/core/src/application.ts:918


getModelName()

getModelName(model): string

Get the model name from a model or a constructor

Parameters

model: CoreModel | Constructor<CoreModel>

Returns

string

longId for a model

Inherited from

Application.getModelName

Source

packages/core/src/application.ts:903


getModelPlural()

getModelPlural(name): string

Get plural of an Id

Parameters

name: string

Returns

string

Inherited from

Application.getModelPlural

Source

packages/core/src/application.ts:760


getModelTypes()

getModelTypes(model): string[]

Get all model types with the hierarchy

Parameters

model: CoreModel

Returns

string[]

Inherited from

Application.getModelTypes

Source

packages/core/src/application.ts:948


getModels()

getModels(): Object

Get all models definitions

Returns

Object

Inherited from

Application.getModels

Source

packages/core/src/application.ts:852


getModules()

getModules(): CachedModule

Return all application modules merged as one

Used when deployed

Returns

CachedModule

Inherited from

Application.getModules

Source

packages/core/src/application.ts:1120


getModulesCache()

getModulesCache(): any

Store the current module

Returns

any

Source

packages/core/src/unpackedapplication.ts:197


getNamespace()

getNamespace(): string

Return current namespace

Returns

string

Inherited from

Application.getNamespace

Source

packages/core/src/application.ts:1250


getPackageDescription()

getPackageDescription(): PackageDescriptor

Retrieve content of package.json

Returns

PackageDescriptor

Inherited from

Application.getPackageDescription

Source

packages/core/src/application.ts:693


getPackageWebda()

getPackageWebda(): WebdaPackageDescriptor

Retrieve specific webda conf from package.json

In case of workspaces the object is combined

Returns

WebdaPackageDescriptor

Inherited from

Application.getPackageWebda

Source

packages/core/src/application.ts:683


getRelations()

getRelations(model): ModelGraph

Get model graph

Parameters

model: string | CoreModel | Constructor<CoreModel>

Returns

ModelGraph

Inherited from

Application.getRelations

Source

packages/core/src/application.ts:652


getRootExposedModels()

getRootExposedModels(): string[]

Return models that do not have parents and are exposed Or specifically set as root via the Expose.root parameter

Returns

string[]

Inherited from

Application.getRootExposedModels

Source

packages/core/src/application.ts:871


getRootModels()

getRootModels(): string[]

Return models that do not have parents

Returns

string[]

Inherited from

Application.getRootModels

Source

packages/core/src/application.ts:862


getSchema()

getSchema(type): JSONSchema7

Get a schema from a type

Schema should be precomputed in the default app

Parameters

type: string

Returns

JSONSchema7

Inherited from

Application.getSchema

Source

packages/core/src/application.ts:628


getSchemas()

getSchemas(): Object

Get schemas

Returns

Object

Inherited from

Application.getSchemas

Source

packages/core/src/application.ts:636


getShortId()

getShortId(name): string

Get short id for a name

Parameters

name: string

if name is shortId return longId else return shortId

Returns

string

Inherited from

Application.getShortId

Source

packages/core/src/application.ts:1259


getWebdaObject()

getWebdaObject(section, name, caseSensitive): any

Parameters

section: Section

name: string

caseSensitive: boolean= false

Returns

any

Inherited from

Application.getWebdaObject

Source

packages/core/src/application.ts:794


getWebdaVersion()

getWebdaVersion(): string

Return webda current version

Returns

string

package version

Inherited from

Application.getWebdaVersion

Since

0.4.0

Source

packages/core/src/application.ts:1002


getWorkerOutput()

getWorkerOutput(): WorkerOutput

Get current logger

Returns

WorkerOutput

Inherited from

Application.getWorkerOutput

Source

packages/core/src/application.ts:712


hasSchema()

hasSchema(type): boolean

Check if a schema exists

Parameters

type: string

Returns

boolean

schema name if it exists

Inherited from

Application.hasSchema

Source

packages/core/src/application.ts:645


hasWebdaObject()

hasWebdaObject(section, name, caseSensitive): boolean

Parameters

section: Section

name: string

caseSensitive: boolean= false

Returns

boolean

Inherited from

Application.hasWebdaObject

Source

packages/core/src/application.ts:771


importFile()

importFile(info, withExport): Promise<any>

Import a file

If the default is set take this or use old format

Parameters

info: string

withExport: boolean= true

Returns

Promise<any>

Inherited from

Application.importFile

Source

packages/core/src/application.ts:1152


isCached()

isCached(): boolean

Check if application has cached modules

When deployed the application contains cachedModules in the webda.config.json It allows to avoid the search for webda.module.json inside node_modules and take the schema from the cached modules also

Returns

boolean

Inherited from

Application.isCached

Source

packages/core/src/application.ts:674


load()

load(): Promise<UnpackedApplication>

Compute short ids

Returns

Promise<UnpackedApplication>

Overrides

Application.load

Source

packages/core/src/unpackedapplication.ts:59


loadConfiguration()

loadConfiguration(file): void

Load full configuration

webda.config.json and complete the cachedModule

Parameters

file: string

Returns

void

Overrides

Application.loadConfiguration

Source

packages/core/src/unpackedapplication.ts:47


loadLocalModule()

loadLocalModule(): Promise<void>

Load local module

Returns

Promise<void>

Inherited from

Application.loadLocalModule

Source

packages/core/src/application.ts:1179


loadProjectInformation()

loadProjectInformation(): ProjectInformation

Check package.json

Returns

ProjectInformation

Source

packages/core/src/unpackedapplication.ts:146


loadWebdaModule()

loadWebdaModule(moduleFile): CachedModule

Load a webda.module.json file Resolve the linked file to current application

Parameters

moduleFile: string

to load

Returns

CachedModule

Source

packages/core/src/unpackedapplication.ts:268


log()

log(level, ...args): void

Log information

Parameters

level: WorkerLogLevel

to log for

• ...args: any[]

anything to display same as console.log

Returns

void

Inherited from

Application.log

Source

packages/core/src/application.ts:703


mergeModules()

mergeModules(configuration): void

Merge all modules into one cached module

Parameters

configuration: Configuration

Returns

void

Source

packages/core/src/unpackedapplication.ts:300


registerSchema()

registerSchema(name, schema): void

Register a new schema in the application

Parameters

name: string

schema: JSONSchema7

Returns

void

Inherited from

Application.registerSchema

Source

packages/core/src/application.ts:748


replaceVariables()

replaceVariables(object, replacements): any

Allow variable inside object strings

Example

replaceVariables({
myobj: "${test.replace}"
}, {
test: {
replace: 'plop'
}
})

will return

{
myobj: 'plop'
}

By default the replacements map contains

{
git: GitInformation,
package: 'package.json content',
deployment: string,
now: number,
...replacements
}

See: GitInformation

Parameters

object: any

a duplicated object with replacement done

replacements: any= {}

additional replacements to run

Returns

any

Inherited from

Application.replaceVariables

Source

packages/core/src/application.ts:1092


stringParameter()

protected stringParameter(templateString, replacements): any

Allow variable inside of string

Parameters

templateString: string

to copy

replacements: any= {}

additional replacements to run

Returns

any

Inherited from

Application.stringParameter

Source

packages/core/src/application.ts:1022