Application
Class: Application
Defined in: packages/core/src/application/application.ts:147
Map a Webda Application
It allows to:
- Analyse imported modules
- Scan code for Modda and generate the webda.config.json
- Compile and Watch
- Migrate from old configuration
- List deployments
Extended by
Constructors
Constructor
new Application(
file,logger?):Application
Defined in: packages/core/src/application/application.ts:235
Create a new Application
Parameters
file
string | UnpackedConfiguration
file path or unpacked configuration to load from
logger?
WorkerOutput = undefined
the logger instance
Returns
Application
Properties
applicationPath
readonlyapplicationPath:string
Defined in: packages/core/src/application/application.ts:151
Get Application root path
appModule
protectedappModule:WebdaModule
Defined in: packages/core/src/application/application.ts:170
Contains definitions of current application
baseConfiguration
protectedbaseConfiguration:Configuration
Defined in: packages/core/src/application/application.ts:155
Base configuration loaded from webda.config.json
beans
protectedbeans:object={}
Defined in: packages/core/src/application/application.ts:194
Beans registry
Index Signature
[key: string]: Modda
behaviors
protectedbehaviors:object={}
Defined in: packages/core/src/application/application.ts:209
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
configurationFile
readonlyconfigurationFile:string
Defined in: packages/core/src/application/application.ts:224
Configuration file
currentDeployment
protectedcurrentDeployment:string
Defined in: packages/core/src/application/application.ts:161
Current deployment
Defaults to the WEBDA_DEPLOYMENT environment variable
deployers
protecteddeployers:object={}
Defined in: packages/core/src/application/application.ts:179
Deployers type registry
Index Signature
[key: string]: any
deployment
protecteddeployment:Deployment
Defined in: packages/core/src/application/application.ts:165
Definition of the current deployment, once loaded
deploymentFile
deploymentFile:
string
Defined in: packages/core/src/application/application.ts:228
Current deployment file
logger
protectedlogger:WorkerOutput
Defined in: packages/core/src/application/application.ts:214
Class Logger
moddas
protectedmoddas:object={}
Defined in: packages/core/src/application/application.ts:184
Moddas registry
Index Signature
[key: string]: Modda
models
protectedmodels:object={}
Defined in: packages/core/src/application/application.ts:189
Models type registry
Index Signature
[key: string]: ModelDefinition
workspacesPath
protectedworkspacesPath:string=""
Defined in: packages/core/src/application/application.ts:219
Detect if running as workspace
_runner
static_runner: (app) =>Promise<void>
Defined in: packages/core/src/application/application.ts:272
Internal
Pluggable runner — set by runner.ts to avoid circular dependency with Core.
Parameters
app
Application
Returns
Promise<void>
Methods
addModda()
addModda(
name,service):this
Defined in: packages/core/src/application/application.ts:463
Add a new service
Parameters
name
string
the name to use
service
the service instance
Returns
this
this for chaining
addModel()
addModel(
name,model,metadata?):this
Defined in: packages/core/src/application/application.ts:654
Add a new model The stored type resolver is rebuilt.
Parameters
name
string
the name to use
model
any
the model to use
metadata?
ModelMetadata = ...
the model metadata
Returns
this
this for chaining
applyCurrentDeployment()
protectedapplyCurrentDeployment():void
Defined in: packages/core/src/application/application.ts:317
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
checkRelations()
protectedcheckRelations():void
Defined in: packages/core/src/application/application.ts:951
Validate symmetry of model relations
Returns
void
completeNamespace()
completeNamespace(
name?):string
Defined in: packages/core/src/application/application.ts:972
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
getBehaviorMetadata()
getBehaviorMetadata(
identifier):BehaviorMetadata
Defined in: packages/core/src/application/application.ts:588
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
getBehaviors()
getBehaviors():
object
Defined in: packages/core/src/application/application.ts:598
Return all loaded Behaviors keyed by identifier.
Each entry exposes the original metadata blob emitted by the compiler.
Returns
object
the result
getConfiguration()
getConfiguration(
_deployment?):Configuration
Defined in: packages/core/src/application/application.ts:767
Get application configuration
Parameters
_deployment?
string = undefined
the deployment name
Returns
the result
getCurrentConfiguration()
getCurrentConfiguration():
Configuration
Defined in: packages/core/src/application/application.ts:781
Return current Configuration of the Application
Same as calling
getConfiguration(this.currentDeployment);
Returns
the result
getCurrentDeployment()
getCurrentDeployment():
string
Defined in: packages/core/src/application/application.ts:748
Get current deployment name
Returns
string
the result string
getDeployers()
getDeployers():
object
Defined in: packages/core/src/application/application.ts:640
Return all deployers
Returns
object
the result
getDeployment()
getDeployment():
Deployment
Defined in: packages/core/src/application/application.ts:307
Get the definition of the current deployment
It includes the units and resources that are not part of the application configuration
Returns
the deployment or undefined if no deployment is selected
getGitInformation()
getGitInformation(
_packageName?,_version?):GitInformation
Defined in: packages/core/src/application/application.ts:732
Retrieve Git Repository information
GitInformation for more details on how the information is gathered
Parameters
_packageName?
string
the package name
_version?
string
the version string
Returns
the git information
getImplementations()
getImplementations<
T>(object):object
Defined in: packages/core/src/application/application.ts:834
Get implementations of a class
Type Parameters
T
T extends Service<ServiceParameters, { }>
Parameters
object
T
the target object
Returns
object
the result
getModda()
getModda(
name):Modda
Defined in: packages/core/src/application/application.ts:540
Get a service based on name
Parameters
name
string
the name to use
Returns
the result
getModdas()
getModdas():
object
Defined in: packages/core/src/application/application.ts:557
Return all services of the application
Returns
object
the result
getModel()
getModel<
T>(name):ModelDefinition<T>
Defined in: packages/core/src/application/application.ts:567
Retrieve the model implementation
Type Parameters
T
T extends Model = Model
Parameters
name
string
model to retrieve
Returns
the result
getModelFromConstructor()
getModelFromConstructor(
model):string
Defined in: packages/core/src/application/application.ts:617
Return the model name for a object
Parameters
model
the model to use
Returns
string
the result
getModelFromInstance()
getModelFromInstance(
object):string
Defined in: packages/core/src/application/application.ts:607
Return the model name for a object
Parameters
object
Storable
the target object
Returns
string
the result
getModelId()
getModelId(
model):string
Defined in: packages/core/src/application/application.ts:629
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/
getModels()
getModels():
object
Defined in: packages/core/src/application/application.ts:575
Get all models definitions
Returns
object
the result
getModuleFilePath()
protectedgetModuleFilePath(parent,info):string
Defined in: packages/core/src/application/application.ts:850
Path of a file referenced by a module, see resolveModuleFile
Parameters
parent
string
the module folder
info
string
the path:export descriptor of the module
Returns
string
the descriptor with the path resolved
getModules()
getModules():
CachedModule
Defined in: packages/core/src/application/application.ts:758
Return all application modules merged as one
Used when deployed
Returns
the result
getNamespace()
getNamespace():
string
Defined in: packages/core/src/application/application.ts:984
Return current namespace
Returns
string
the result string
getPackageDescription()
getPackageDescription():
PackageDescriptor
Defined in: packages/core/src/application/application.ts:418
Retrieve content of package.json
Returns
the result
getPackageWebda()
getPackageWebda():
WebdaPackageDescriptor
Defined in: packages/core/src/application/application.ts:407
Retrieve specific webda conf from package.json
In case of workspaces the object is combined
Returns
the result
getPath()
getPath(
subpath?):string
Defined in: packages/core/src/application/application.ts:446
Return the current app path
Parameters
subpath?
string = undefined
to append to
Returns
string
the result string
getProjectInfo()
getProjectInfo():
ProjectInformation
Defined in: packages/core/src/application/application.ts:740
Retrieve the project information
Returns
the result
getSchema()
getSchema(
type):JSONSchema7
Defined in: packages/core/src/application/application.ts:366
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
getSchemas()
getSchemas():
object
Defined in: packages/core/src/application/application.ts:385
Get schemas
Returns
object
the result
getWebdaObject()
getWebdaObject(
section,name):any
Defined in: packages/core/src/application/application.ts:516
Get the Webda object
Parameters
section
the section name
name
string
the name to use
Returns
any
the result
getWebdaVersion()
getWebdaVersion():
string
Defined in: packages/core/src/application/application.ts:719
Return webda current version
Returns
string
package version
Since
0.4.0
getWorkerOutput()
getWorkerOutput():
WorkerOutput
Defined in: packages/core/src/application/application.ts:436
Get current logger
Returns
WorkerOutput
the result
hasWebdaObject()
hasWebdaObject(
section,name):boolean
Defined in: packages/core/src/application/application.ts:476
Check whether it has Webda object
Parameters
section
the section name
name
string
the name to use
Returns
boolean
true if the condition is met
importFile()
protectedimportFile(info,withExport?):Promise<any>
Defined in: packages/core/src/application/application.ts:794
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
isCached()
isCached():
boolean
Defined in: packages/core/src/application/application.ts:397
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
isFinalModel()
isFinalModel(
model):boolean
Defined in: packages/core/src/application/application.ts:498
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
load()
load():
Promise<Application>
Defined in: packages/core/src/application/application.ts:280
Import all required modules
Returns
Promise<Application>
the result
loadConfiguration()
loadConfiguration(
file):Promise<void>
Defined in: packages/core/src/application/application.ts:341
Allow subclass to implement migration
Parameters
file
string
the file path
Returns
Promise<void>
the result
loadLocalModule()
loadLocalModule():
Promise<void>
Defined in: packages/core/src/application/application.ts:822
Load local module
Returns
Promise<void>
log()
log(
level, ...args):void
Defined in: packages/core/src/application/application.ts:428
Log information
Parameters
level
WorkerLogLevel
to log for
args
...any[]
anything to display same as console.log
Returns
void
run()
run():
Promise<void>
Defined in: packages/core/src/application/application.ts:264
Run the application
Returns
Promise<void>
the result
setCurrentDeployment()
setCurrentDeployment(
name):this
Defined in: packages/core/src/application/application.ts:295
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
setModelMetadata()
protectedsetModelMetadata(info):void
Defined in: packages/core/src/application/application.ts:924
Set object Metadata Need to be done after all models are loaded to resolve Ancestors and Subclasses
Parameters
info
{[key: string]: ModelMetadata; }
the information object
Returns
void
toJSON()
toJSON():
object
Defined in: packages/core/src/application/application.ts:705
Serialize the application state to a plain object
Returns
object
the result
appModule
appModule:
WebdaModule
baseConfiguration
baseConfiguration:
Configuration
currentDeployment
currentDeployment:
string
deserialize()
staticdeserialize<T>(this,json):T
Defined in: packages/core/src/application/application.ts:693
Deserialize operation
Type Parameters
T
T extends Application
Parameters
this
new (...args) => T
the constructor
json
any
the JSON data
Returns
T
the result