Skip to main content

UnpackedApplication

@webda/core


Class: UnpackedApplication

Defined in: packages/core/src/application/unpackedapplication.ts:37

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​

Constructor​

new UnpackedApplication(file, logger?): UnpackedApplication

Defined in: packages/core/src/application/unpackedapplication.ts:42

Create a new UnpackedApplication

Parameters​

file​

string | Partial<UnpackedConfiguration>

file path or partial configuration

logger?​

WorkerOutput

the logger instance

Returns​

UnpackedApplication

Overrides​

Application.constructor

Properties​

applicationPath​

readonly applicationPath: string

Defined in: packages/core/src/application/application.ts:112

Get Application root path

Inherited from​

Application.applicationPath


appModule​

protected appModule: WebdaModule

Defined in: packages/core/src/application/application.ts:131

Contains definitions of current application

Inherited from​

Application.appModule


baseConfiguration​

protected baseConfiguration: Configuration

Defined in: packages/core/src/application/application.ts:116

Base configuration loaded from webda.config.json

Inherited from​

Application.baseConfiguration


beans​

protected beans: object = {}

Defined in: packages/core/src/application/application.ts:155

Beans registry

Index Signature​

[key: string]: Modda

Inherited from​

Application.beans


behaviors​

protected behaviors: object = {}

Defined in: packages/core/src/application/application.ts:170

Behaviors registry

Populated by loadModule from the top-level behaviors map of every loaded webda.module.json. Each entry holds the metadata blob emitted by the compiler so downstream consumers (DomainService, REST transport, etc.) can introspect the Behavior's declared actions and shape.

The Behavior class itself is NOT loaded at runtime: the per-model __hydrateBehaviors method emitted at compile time by @webda/content-mapper holds a static import to the class, so the runtime never needs to look it up by identifier.

Index Signature​

[key: string]: object

Inherited from​

Application.behaviors


configurationFile​

readonly configurationFile: string

Defined in: packages/core/src/application/application.ts:185

Configuration file

Inherited from​

Application.configurationFile


currentDeployment​

protected currentDeployment: string

Defined in: packages/core/src/application/application.ts:122

Current deployment

Defaults to the WEBDA_DEPLOYMENT environment variable

Inherited from​

Application.currentDeployment


deployers​

protected deployers: object = {}

Defined in: packages/core/src/application/application.ts:140

Deployers type registry

Index Signature​

[key: string]: any

Inherited from​

Application.deployers


deployment​

protected deployment: Deployment

Defined in: packages/core/src/application/application.ts:126

Definition of the current deployment, once loaded

Inherited from​

Application.deployment


deploymentFile​

deploymentFile: string

Defined in: packages/core/src/application/application.ts:189

Current deployment file

Inherited from​

Application.deploymentFile


logger​

protected logger: WorkerOutput

Defined in: packages/core/src/application/application.ts:175

Class Logger

Inherited from​

Application.logger


moddas​

protected moddas: object = {}

Defined in: packages/core/src/application/application.ts:145

Moddas registry

Index Signature​

[key: string]: Modda

Inherited from​

Application.moddas


models​

protected models: object = {}

Defined in: packages/core/src/application/application.ts:150

Models type registry

Index Signature​

[key: string]: ModelDefinition

Inherited from​

Application.models


workspacesPath​

protected workspacesPath: string = ""

Defined in: packages/core/src/application/application.ts:180

Detect if running as workspace

Inherited from​

Application.workspacesPath


_runner​

static _runner: (app) => Promise<void>

Defined in: packages/core/src/application/application.ts:232

Internal

Pluggable runner — set by runner.ts to avoid circular dependency with Core.

Parameters​

app​

Application

Returns​

Promise<void>

Inherited from​

Application._runner

Methods​

addModda()​

addModda(name, service): this

Defined in: packages/core/src/application/application.ts:423

Add a new service

Parameters​

name​

string

the name to use

service​

Modda

the service instance

Returns​

this

this for chaining

Inherited from​

Application.addModda


addModel()​

addModel(name, model, metadata?): this

Defined in: packages/core/src/application/application.ts:604

Add a new model

Parameters​

name​

string

the name to use

model​

any

the model to use

metadata?​

ModelMetadata = ...

the model metadata

Returns​

this

this for chaining

Inherited from​

Application.addModel


applyCurrentDeployment()​

protected applyCurrentDeployment(): void

Defined in: packages/core/src/application/application.ts:277

Apply the current deployment parameters and services on the configuration

A packaged application already contains its deployment: the file is only required when the deployment differs from the packaged one

Returns​

void

Inherited from​

Application.applyCurrentDeployment


completeConfiguration()​

completeConfiguration(configuration): Configuration

Defined in: packages/core/src/application/unpackedapplication.ts:180

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

Parameters​

configuration​

Configuration

the configuration

Returns​

Configuration

the result


completeNamespace()​

completeNamespace(name?): string

Defined in: packages/core/src/application/application.ts:894

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 = ""

the name to use

Returns​

string

the result string

Inherited from​

Application.completeNamespace


ensureDefaultConfiguration()​

ensureDefaultConfiguration(configuration): void

Defined in: packages/core/src/application/unpackedapplication.ts:82

Ensure default parameters are set on our application Creating the default services if they do not exist

Might want to have only this in unpackaged application as Application should have a perfectly valid configuration

Parameters​

configuration​

Configuration

the configuration

Returns​

void


filterModule()​

filterModule(_filename): boolean

Defined in: packages/core/src/application/unpackedapplication.ts:403

Only allow local and core module and sample-app

Parameters​

_filename​

string

the filename

Returns​

boolean

true if the condition is met


findModules()​

findModules(module): Promise<string[]>

Defined in: packages/core/src/application/unpackedapplication.ts:368

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

the module to load

Returns​

Promise<string[]>

the list of results


getBehaviorMetadata()​

getBehaviorMetadata(identifier): BehaviorMetadata

Defined in: packages/core/src/application/application.ts:539

Return the metadata blob (Identifier, Actions, etc.) for a Behavior loaded from webda.module.json.

Parameters​

identifier​

string

fully qualified Behavior id (e.g. Webda/MFA)

Returns​

BehaviorMetadata

the metadata, or undefined if no Behavior with that id is registered

Inherited from​

Application.getBehaviorMetadata


getBehaviors()​

getBehaviors(): object

Defined in: packages/core/src/application/application.ts:549

Return all loaded Behaviors keyed by identifier.

Each entry exposes the original metadata blob emitted by the compiler.

Returns​

object

the result

Inherited from​

Application.getBehaviors


getConfiguration()​

getConfiguration(_deployment?): Configuration

Defined in: packages/core/src/application/application.ts:717

Get application configuration

Parameters​

_deployment?​

string = undefined

the deployment name

Returns​

Configuration

the result

Inherited from​

Application.getConfiguration


getCurrentConfiguration()​

getCurrentConfiguration(): Configuration

Defined in: packages/core/src/application/application.ts:731

Return current Configuration of the Application

Same as calling

getConfiguration(this.currentDeployment);

Returns​

Configuration

the result

Inherited from​

Application.getCurrentConfiguration


getCurrentDeployment()​

getCurrentDeployment(): string

Defined in: packages/core/src/application/application.ts:698

Get current deployment name

Returns​

string

the result string

Inherited from​

Application.getCurrentDeployment


getDeployers()​

getDeployers(): object

Defined in: packages/core/src/application/application.ts:591

Return all deployers

Returns​

object

the result

Inherited from​

Application.getDeployers


getDeployment()​

getDeployment(): Deployment

Defined in: packages/core/src/application/application.ts:267

Get the definition of the current deployment

It includes the units and resources that are not part of the application configuration

Returns​

Deployment

the deployment or undefined if no deployment is selected

Inherited from​

Application.getDeployment


getGitInformation()​

getGitInformation(_name?, _version?): GitInformation

Defined in: packages/core/src/application/unpackedapplication.ts:206

Parameters​

_name?​

string

the name to use

_version?​

string

the version string

Returns​

GitInformation

empty git information

Overrides​

Application.getGitInformation


getImplementations()​

getImplementations<T>(object): object

Defined in: packages/core/src/application/application.ts:784

Get implementations of a class

Type Parameters​

T​

T extends Service<ServiceParameters, { }>

Parameters​

object​

T

the target object

Returns​

object

the result

Inherited from​

Application.getImplementations


getModda()​

getModda(name): Modda

Defined in: packages/core/src/application/application.ts:500

Get a service based on name

Parameters​

name​

string

the name to use

Returns​

Modda

the result

Inherited from​

Application.getModda


getModdas()​

getModdas(): object

Defined in: packages/core/src/application/application.ts:508

Return all services of the application

Returns​

object

the result

Inherited from​

Application.getModdas


getModel()​

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

Defined in: packages/core/src/application/application.ts:518

Retrieve the model implementation

Type Parameters​

T​

T extends Model = Model

Parameters​

name​

string

model to retrieve

Returns​

ModelDefinition<T>

the result

Inherited from​

Application.getModel


getModelFromConstructor()​

getModelFromConstructor(model): string

Defined in: packages/core/src/application/application.ts:568

Return the model name for a object

Parameters​

model​

ModelClass

the model to use

Returns​

string

the result

Inherited from​

Application.getModelFromConstructor


getModelFromInstance()​

getModelFromInstance(object): string

Defined in: packages/core/src/application/application.ts:558

Return the model name for a object

Parameters​

object​

Storable

the target object

Returns​

string

the result

Inherited from​

Application.getModelFromInstance


getModelId()​

getModelId(model): string

Defined in: packages/core/src/application/application.ts:580

Get the model name from a model or a constructor

Parameters​

model​

Storable<any, any> | ModelClass<Storable<any, any>>

the model to use

Returns​

string

longId for a model

Paramn​

full if true always include the namespace, default is false e.g Webda/

Inherited from​

Application.getModelId


getModels()​

getModels(): object

Defined in: packages/core/src/application/application.ts:526

Get all models definitions

Returns​

object

the result

Inherited from​

Application.getModels


getModules()​

getModules(): CachedModule

Defined in: packages/core/src/application/application.ts:708

Return all application modules merged as one

Used when deployed

Returns​

CachedModule

the result

Inherited from​

Application.getModules


getNamespace()​

getNamespace(): string

Defined in: packages/core/src/application/application.ts:906

Return current namespace

Returns​

string

the result string

Inherited from​

Application.getNamespace


getPackageDescription()​

getPackageDescription(): PackageDescriptor

Defined in: packages/core/src/application/application.ts:378

Retrieve content of package.json

Returns​

PackageDescriptor

the result

Inherited from​

Application.getPackageDescription


getPackageWebda()​

getPackageWebda(): WebdaPackageDescriptor

Defined in: packages/core/src/application/application.ts:367

Retrieve specific webda conf from package.json

In case of workspaces the object is combined

Returns​

WebdaPackageDescriptor

the result

Inherited from​

Application.getPackageWebda


getPath()​

getPath(subpath?): string

Defined in: packages/core/src/application/application.ts:406

Return the current app path

Parameters​

subpath?​

string = undefined

to append to

Returns​

string

the result string

Inherited from​

Application.getPath


getProjectInfo()​

getProjectInfo(): ProjectInformation

Defined in: packages/core/src/application/application.ts:690

Retrieve the project information

Returns​

ProjectInformation

the result

Inherited from​

Application.getProjectInfo


getSchema()​

getSchema(type): JSONSchema7

Defined in: packages/core/src/application/application.ts:326

Get a schema from a type

Schema should be precomputed in the default app

Parameters​

type​

string

the type to look up

Returns​

JSONSchema7

the result

Inherited from​

Application.getSchema


getSchemas()​

getSchemas(): object

Defined in: packages/core/src/application/application.ts:345

Get schemas

Returns​

object

the result

Inherited from​

Application.getSchemas


getWebdaObject()​

getWebdaObject(section, name): any

Defined in: packages/core/src/application/application.ts:476

Parameters​

section​

Section

the section name

name​

string

the name to use

Returns​

any

the result

Inherited from​

Application.getWebdaObject


getWebdaVersion()​

getWebdaVersion(): string

Defined in: packages/core/src/application/application.ts:669

Return webda current version

Returns​

string

package version

Since​

0.4.0

Inherited from​

Application.getWebdaVersion


getWorkerOutput()​

getWorkerOutput(): WorkerOutput

Defined in: packages/core/src/application/application.ts:396

Get current logger

Returns​

WorkerOutput

the result

Inherited from​

Application.getWorkerOutput


hasWebdaObject()​

hasWebdaObject(section, name): boolean

Defined in: packages/core/src/application/application.ts:436

Parameters​

section​

Section

the section name

name​

string

the name to use

Returns​

boolean

true if the condition is met

Inherited from​

Application.hasWebdaObject


importFile()​

protected importFile(info, withExport?): Promise<any>

Defined in: packages/core/src/application/application.ts:744

Import a file

If the default is set take this or use old format

Parameters​

info​

string

the information object

withExport?​

boolean = true

whether to include exports

Returns​

Promise<any>

the result

Inherited from​

Application.importFile


isCached()​

isCached(): boolean

Defined in: packages/core/src/application/application.ts:357

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

true if the condition is met

Inherited from​

Application.isCached


isFinalModel()​

isFinalModel(model): boolean

Defined in: packages/core/src/application/application.ts:458

Return true if model is the one that wins when consumers look up the short name in the current namespace. Used by transports (REST, GraphQL, gRPC) so only one model gets exposed at a given URL / type when the app overrides a framework-provided class — e.g. WebdaSample/User shadowing Webda/User at /users.

A model is "final" when either:

  • it is the one resolved by completeNamespace(shortName), or
  • no other model exists with the same short name in the current namespace.

Parameters​

model​

string

the fully-qualified model identifier (e.g. "Webda/User")

Returns​

boolean

true when model should be treated as the canonical version

Inherited from​

Application.isFinalModel


load()​

load(): Promise<UnpackedApplication>

Defined in: packages/core/src/application/unpackedapplication.ts:64

Ensure default configuration after load

Returns​

Promise<UnpackedApplication>

the result

Overrides​

Application.load


loadConfiguration()​

loadConfiguration(file): Promise<void>

Defined in: packages/core/src/application/unpackedapplication.ts:150

Load full configuration

webda.config.json and complete the cachedModule

Parameters​

file​

string

the file path

Returns​

Promise<void>

the result

Overrides​

Application.loadConfiguration


loadLocalModule()​

loadLocalModule(): Promise<void>

Defined in: packages/core/src/application/application.ts:772

Load local module

Returns​

Promise<void>

Inherited from​

Application.loadLocalModule


loadProjectInformation()​

loadProjectInformation(): ProjectInformation

Defined in: packages/core/src/application/unpackedapplication.ts:244

Check package.json

Returns​

ProjectInformation

the result


loadWebdaModule()​

loadWebdaModule(moduleFile): CachedModule

Defined in: packages/core/src/application/unpackedapplication.ts:414

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

Parameters​

moduleFile​

string

to load

Returns​

CachedModule

the result


log()​

log(level, ...args): void

Defined in: packages/core/src/application/application.ts:388

Log information

Parameters​

level​

WorkerLogLevel

to log for

args​

...any[]

anything to display same as console.log

Returns​

void

Inherited from​

Application.log


mergeModules()​

mergeModules(configuration): Promise<CachedModule>

Defined in: packages/core/src/application/unpackedapplication.ts:453

Merge all modules into one cached module

Parameters​

configuration​

Configuration

the configuration

Returns​

Promise<CachedModule>

the result


run()​

run(): Promise<void>

Defined in: packages/core/src/application/application.ts:224

Run the application

Returns​

Promise<void>

the result

Inherited from​

Application.run


setCurrentDeployment()​

setCurrentDeployment(name): this

Defined in: packages/core/src/application/application.ts:255

Select the deployment to apply on the configuration

Must be called before load

Parameters​

name​

string

deployment name, a deployments/<name> file of the application

Returns​

this

this

Inherited from​

Application.setCurrentDeployment


setModelMetadata()​

protected setModelMetadata(info): void

Defined in: packages/core/src/application/application.ts:864

Set object Metadata Need to be done after all models are loaded to resolve Ancestors and Subclasses

Parameters​

info​

the information object

Returns​

void

Inherited from​

Application.setModelMetadata


toJSON()​

toJSON(): object

Defined in: packages/core/src/application/application.ts:655

Serialize the application state to a plain object

Returns​

object

the result

appModule​

appModule: WebdaModule

baseConfiguration​

baseConfiguration: Configuration

currentDeployment​

currentDeployment: string

Inherited from​

Application.toJSON


upgradeConfigToV4()​

upgradeConfigToV4(): void

Defined in: packages/core/src/application/unpackedapplication.ts:218

Upgrade a v3 configuration to v4 format

Returns​

void


deserialize()​

static deserialize<T>(this, json): T

Defined in: packages/core/src/application/application.ts:643

Type Parameters​

T​

T extends Application

Parameters​

this​

(...args) => T

the constructor

json​

any

the JSON data

Returns​

T

the result

Inherited from​

Application.deserialize


findModulesFiles()​

static findModulesFiles<T>(this, path): Promise<string[]>

Defined in: packages/core/src/application/unpackedapplication.ts:298

Search the node_modules structure for webda.module.json files

Type Parameters​

T​

T

Parameters​

this​

T

path​

string

the path

Returns​

Promise<string[]>

the result