Application
Class: Application
Defined in: packages/core/src/application/application.ts:108
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:196
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:112
Get Application root path
appModule
protectedappModule:WebdaModule
Defined in: packages/core/src/application/application.ts:131
Contains definitions of current application
baseConfiguration
protectedbaseConfiguration:Configuration
Defined in: packages/core/src/application/application.ts:116
Base configuration loaded from webda.config.json
beans
protectedbeans:object={}
Defined in: packages/core/src/application/application.ts:155
Beans registry
Index Signature
[key: string]: Modda
behaviors
protectedbehaviors: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
configurationFile
readonlyconfigurationFile:string
Defined in: packages/core/src/application/application.ts:185
Configuration file
currentDeployment
protectedcurrentDeployment:string
Defined in: packages/core/src/application/application.ts:122
Current deployment
Defaults to the WEBDA_DEPLOYMENT environment variable
deployers
protecteddeployers:object={}
Defined in: packages/core/src/application/application.ts:140
Deployers type registry
Index Signature
[key: string]: any
deployment
protecteddeployment:Deployment
Defined in: packages/core/src/application/application.ts:126
Definition of the current deployment, once loaded
deploymentFile
deploymentFile:
string
Defined in: packages/core/src/application/application.ts:189
Current deployment file
logger
protectedlogger:WorkerOutput
Defined in: packages/core/src/application/application.ts:175
Class Logger
moddas
protectedmoddas:object={}
Defined in: packages/core/src/application/application.ts:145
Moddas registry
Index Signature
[key: string]: Modda
models
protectedmodels:object={}
Defined in: packages/core/src/application/application.ts:150
Models type registry
Index Signature
[key: string]: ModelDefinition
workspacesPath
protectedworkspacesPath:string=""
Defined in: packages/core/src/application/application.ts:180
Detect if running as workspace
_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>
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
the service instance
Returns
this
this for chaining
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
applyCurrentDeployment()
protectedapplyCurrentDeployment():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
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
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
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
getConfiguration()
getConfiguration(
_deployment?):Configuration
Defined in: packages/core/src/application/application.ts:717
Get application configuration
Parameters
_deployment?
string = undefined
the deployment name
Returns
the result
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
the result
getCurrentDeployment()
getCurrentDeployment():
string
Defined in: packages/core/src/application/application.ts:698
Get current deployment name
Returns
string
the result string
getDeployers()
getDeployers():
object
Defined in: packages/core/src/application/application.ts:591
Return all deployers
Returns
object
the result
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
the deployment or undefined if no deployment is selected
getGitInformation()
getGitInformation(
_packageName?,_version?):GitInformation
Defined in: packages/core/src/application/application.ts:682
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:784
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:500
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:508
Return all services of the application
Returns
object
the result
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
the result
getModelFromConstructor()
getModelFromConstructor(
model):string
Defined in: packages/core/src/application/application.ts:568
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:558
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: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/
getModels()
getModels():
object
Defined in: packages/core/src/application/application.ts:526
Get all models definitions
Returns
object
the result
getModules()
getModules():
CachedModule
Defined in: packages/core/src/application/application.ts:708
Return all application modules merged as one
Used when deployed
Returns
the result
getNamespace()
getNamespace():
string
Defined in: packages/core/src/application/application.ts:906
Return current namespace
Returns
string
the result string
getPackageDescription()
getPackageDescription():
PackageDescriptor
Defined in: packages/core/src/application/application.ts:378
Retrieve content of package.json
Returns
the result
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
the result
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
getProjectInfo()
getProjectInfo():
ProjectInformation
Defined in: packages/core/src/application/application.ts:690
Retrieve the project information
Returns
the result
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
getSchemas()
getSchemas():
object
Defined in: packages/core/src/application/application.ts:345
Get schemas
Returns
object
the result
getWebdaObject()
getWebdaObject(
section,name):any
Defined in: packages/core/src/application/application.ts:476
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:669
Return webda current version
Returns
string
package version
Since
0.4.0
getWorkerOutput()
getWorkerOutput():
WorkerOutput
Defined in: packages/core/src/application/application.ts:396
Get current logger
Returns
WorkerOutput
the result
hasWebdaObject()
hasWebdaObject(
section,name):boolean
Defined in: packages/core/src/application/application.ts:436
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: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
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
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
load()
load():
Promise<Application>
Defined in: packages/core/src/application/application.ts:240
Import all required modules
Returns
Promise<Application>
the result
loadConfiguration()
loadConfiguration(
file):Promise<void>
Defined in: packages/core/src/application/application.ts:301
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:772
Load local module
Returns
Promise<void>
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
run()
run():
Promise<void>
Defined in: packages/core/src/application/application.ts:224
Run the application
Returns
Promise<void>
the result
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
setModelMetadata()
protectedsetModelMetadata(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
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
deserialize()
staticdeserialize<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