RESTOperationsTransport
Class: RESTOperationsTransport<T>
Defined in: packages/core/src/rest/restoperationstransport.service.ts:126
REST transport that exposes model operations as RESTful HTTP routes.
Instead of iterating operations flat, it walks the model tree
(parent/child relationships) to build nested URL prefixes like
/companies/{pid.0}/users/{uuid}.
Webda Modda
Extends
Type Parameters
T
T extends RESTOperationsTransportParameters = RESTOperationsTransportParameters
Constructors
Constructor
new RESTOperationsTransport<
T>(name,params):RESTOperationsTransport<T>
Defined in: packages/core/src/services/service.ts:192
Service
Parameters
name
string
The name of the service
params
T
The parameters block define in the configuration file
Returns
RESTOperationsTransport<T>
Inherited from
OperationsTransport.constructor
Properties
_compiledCapabilities
protected_compiledCapabilities:Record<string,any> ={}
Defined in: packages/core/src/services/iservice.ts:58
Capabilities detected at compile-time from @WebdaCapability-tagged interfaces.
Populated during Service.resolve by reading the service's entry in
webda.module.json. Each key is a capability name (e.g., "request-filter"),
and the value is an empty object {} by default. Override getCapabilities
to provide capability-specific configuration or to conditionally disable capabilities.
See
getCapabilities
Inherited from
OperationsTransport._compiledCapabilities
[WEBDA_EVENTS]
[WEBDA_EVENTS]:
object
Defined in: packages/core/src/services/service.ts:166
Set the Webda events here
Inherited from
OperationsTransport.[WEBDA_EVENTS]
logger
protectedlogger:Logger
Defined in: packages/core/src/services/service.ts:179
Logger with class context
Inherited from
metrics?
protectedoptionalmetrics?:object
Defined in: packages/core/src/services/service.ts:183
Get metrics
Inherited from
name
readonlyname:string
Defined in: packages/core/src/services/iservice.ts:35
Inherited from
openapiContent
openapiContent:
string
Defined in: packages/core/src/rest/restoperationstransport.service.ts:132
OpenAPI cache
parameters
readonlyparameters:T
Defined in: packages/core/src/services/iservice.ts:36
Inherited from
OperationsTransport.parameters
createConfiguration?
staticoptionalcreateConfiguration?: (params) =>any
Defined in: packages/core/src/services/iservice.ts:41
Create configuration set by the application on load
Parameters
params
any
Returns
any
Inherited from
OperationsTransport.createConfiguration
filterConfiguration?
staticoptionalfilterConfiguration?: (params) =>any
Defined in: packages/core/src/services/iservice.ts:46
Create configuration set by the application on load
Parameters
params
any
Returns
any
Inherited from
OperationsTransport.filterConfiguration
Parameters
staticParameters: typeofServiceParameters=ServiceParameters
Defined in: packages/core/src/services/service.ts:162
Service parameters
Inherited from
OperationsTransport.Parameters
Methods
__clean()
abstract__clean():Promise<void>
Defined in: packages/core/src/services/service.ts:492
Clean the service data, can only be used in test mode
Returns
Promise<void>
Inherited from
addListener()
addListener<
Key>(eventName,listener):this
Defined in: packages/core/src/events/asynceventemitter.ts:83
Type Parameters
Key
Key extends never
Parameters
eventName
Key
the event name
listener
(event) => void | Promise<void>
the event listener
Returns
this
this for chaining
See
EventEmitter.addListener
Inherited from
OperationsTransport.addListener
addRoute()
protectedaddRoute(url,methods,executer,openapi?,override?):void
Defined in: packages/core/src/services/service.ts:384
Add a route dynamicaly
Parameters
url
string
of the route can contains dynamic part like {uuid}
methods
the HTTP methods
executer
Function
Method to execute for this route
openapi?
the OpenAPI specification
override?
boolean = false
whether to override existing
Returns
void
Inherited from
authorizeClientEvent()
authorizeClientEvent(
_event,_context):boolean
Defined in: packages/core/src/services/service.ts:337
Authorize a public event subscription
Parameters
_event
string
the event name
_context
the execution context
Returns
boolean
true if the condition is met
Inherited from
OperationsTransport.authorizeClientEvent
computeParameters()
computeParameters():
void
Defined in: packages/core/src/services/service.ts:201
Used to compute or derivate input parameter to attribute
Returns
void
Deprecated
Inherited from
OperationsTransport.computeParameters
emit()
emit<
Key>(event,data):Promise<void>
Defined in: packages/core/src/services/service.ts:473
Emit the event with data and wait for Promise to finish if listener returned a Promise
Type Parameters
Key
Key extends never
Parameters
event
Key
the event name
data
object[Key]
the data to process
Returns
Promise<void>
Inherited from
exposeActionRoute()
protectedexposeActionRoute(prefix,shortId,identifier,actionName,action,depth,injectAttribute):void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:721
Register action route for a model
Parameters
prefix
string
the URL prefix for this model
shortId
string
the short model identifier
identifier
string
the full model identifier
actionName
string
the name of the action
action
the action definition
depth
number
nesting depth for parent id parameters
injectAttribute
string
parent attribute to inject
Returns
void
exposeBehaviorRoutes()
protectedexposeBehaviorRoutes(prefix,shortId,identifier,name,behavior):void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:815
Register routes for every @Action on every Behavior attribute of a
model. The default URL pattern is {prefix}/{uuid}/{attribute}.{action}
(PUT) — the dot disambiguates Behavior calls from nested-resource routing.
Authors can override the route via @Action({ rest: { route, method } }).
addBehaviorOperations resolves that hint and writes the final
rest.method/rest.path on the registered operation; this method just
mirrors what's there, falling back to the dot-notation default if no
hint was set.
Each route dispatches the registered behavior operation
({ShortId}.{AttributeCap}.{ActionCap}). The dispatcher itself
(modelBehaviorAction) handles model load, canAct gating, and method
invocation — this method only wires the HTTP surface.
Schema decoration on the OpenAPI doc is best-effort — we lean on
hasSchema() (the AJV registry) to decide whether to emit
requestBody / responses $refs.
Parameters
prefix
string
the URL prefix for this model (e.g. /api/users)
shortId
string
the short model identifier (e.g. User)
identifier
string
the full model identifier (e.g. MyApp/User) — accepted
for symmetry with walkModel's caller signature even though we don't currently use it
name
string
the model display name used in OpenAPI tags
behavior
ModelGraphBehaviorDefinition
the Behavior attribute relation to expose
Returns
void
exposeCreateRoute()
protectedexposeCreateRoute(prefix,shortId,identifier,depth,injectAttribute,operations):void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:430
Register create route for a model
Parameters
prefix
string
the URL prefix for this model
shortId
string
the short model identifier
identifier
string
the full model identifier
depth
number
nesting depth for parent id parameters
injectAttribute
string
parent attribute to inject on create
operations
Record<string, OperationDefinition>
the filtered operations map
Returns
void
exposeDeleteRoute()
protectedexposeDeleteRoute(prefix,shortId,identifier,operations):void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:521
Register delete route for a model
Parameters
prefix
string
the URL prefix for this model
shortId
string
the short model identifier
identifier
string
the full model identifier
operations
Record<string, OperationDefinition>
the filtered operations map
Returns
void
exposeGetRoute()
protectedexposeGetRoute(prefix,shortId,identifier,operations):void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:661
Register get route for a model
Parameters
prefix
string
the URL prefix for this model
shortId
string
the short model identifier
identifier
string
the full model identifier
operations
Record<string, OperationDefinition>
the filtered operations map
Returns
void
exposeOperation()
exposeOperation(
_operationId,_definition):void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:896
No-op: route exposure is handled entirely by initTransport's tree walk
Parameters
_operationId
string
the operation identifier (unused)
_definition
the operation definition (unused)
Returns
void
Overrides
OperationsTransport.exposeOperation
exposeQueryRoute()
protectedexposeQueryRoute(prefix,plural,shortId,identifier,depth,injectAttribute,operations):void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:310
Register query route for a model
Parameters
prefix
string
the URL prefix for this model
plural
string
the pluralized model name
shortId
string
the short model identifier
identifier
string
the full model identifier
depth
number
nesting depth for parent id parameters
injectAttribute
string
parent attribute to inject in queries
operations
Record<string, OperationDefinition>
the filtered operations map
Returns
void
exposeServiceOperations()
protectedexposeServiceOperations(operations):void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:200
Expose service/bean operations that have rest hints but aren't tied to model CRUD. These are operations registered by Service.initOperations() from
Parameters
operations
Record<string, OperationDefinition>
the filtered operations map
Returns
void
Operation
decorators.
exposeUpdateRoute()
protectedexposeUpdateRoute(prefix,shortId,identifier,operations):void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:578
Register update (PUT) and patch (PATCH) routes for a model
Parameters
prefix
string
the URL prefix for this model
shortId
string
the short model identifier
identifier
string
the full model identifier
operations
Record<string, OperationDefinition>
the filtered operations map
Returns
void
getCapabilities()
getCapabilities():
Record<string,any>
Defined in: packages/core/src/services/iservice.ts:86
Return the capabilities of this service.
By default returns capabilities detected at compile-time from
Returns
Record<string, any>
the result
Webda Capability-tagged
interfaces in webda.module.json.
Override to disable capabilities based on configuration:
getCapabilities() {
const caps = super.getCapabilities();
if (!this.parameters.enabled) delete caps["request-filter"];
return caps;
}
Inherited from
OperationsTransport.getCapabilities
getClientEvents()
getClientEvents():
string[]
Defined in: packages/core/src/services/service.ts:325
Return the events that an external system can subscribe to
Returns
string[]
the list of results
Inherited from
OperationsTransport.getClientEvents
getMaxListeners()
getMaxListeners():
number
Defined in: packages/core/src/events/asynceventemitter.ts:90
Returns
number
Inherited from
OperationsTransport.getMaxListeners
getMetric()
getMetric<
T>(type,configuration):T
Defined in: packages/core/src/services/service.ts:310
Add service name label
Type Parameters
T
T = Gauge<string> | Counter<string> | Histogram<string>
Parameters
type
CustomConstructor<T, [MetricConfiguration<T>]>
the type to look up
configuration
the configuration
Returns
T
the result
Inherited from
getName()
getName():
string
Defined in: packages/core/src/services/service.ts:483
Get service name
Returns
string
the result string
Inherited from
getOpenApiReplacements()
getOpenApiReplacements():
any
Defined in: packages/core/src/services/service.ts:413
Return variables for replacement in openapi
Returns
any
the result
Inherited from
OperationsTransport.getOpenApiReplacements
getOperationId()
getOperationId(
id):string
Defined in: packages/core/src/services/service.ts:371
If undefined is returned it cancel the operation registration
Parameters
id
string
the identifier
Returns
string
the result
Inherited from
OperationsTransport.getOperationId
getOperations()
getOperations():
Record<string,OperationDefinition>
Defined in: packages/core/src/services/operationstransport.ts:82
Get all registered operations, filtered by this transport's include/exclude config
Returns
Record<string, OperationDefinition>
filtered map of operation id to definition
Inherited from
OperationsTransport.getOperations
getParameters()
getParameters():
T
Defined in: packages/core/src/services/service.ts:209
Get the service parameters
Returns
T
the result
Inherited from
OperationsTransport.getParameters
getService()
getService<
T>(name):ServicesMap[T]
Defined in: packages/core/src/services/service.ts:300
Get a service by name
Type Parameters
T
T extends keyof ServicesMap
Parameters
name
T
the name to use
Returns
ServicesMap[T]
the result map
Deprecated
Use useService, might reconsider
Inherited from
OperationsTransport.getService
getState()
getState():
ServiceStates
Defined in: packages/core/src/services/service.ts:172
Get the current state
Returns
the result
Inherited from
getUrl()
getUrl(
url,_methods):string
Defined in: packages/core/src/services/service.ts:348
Return the full path url based on parameters
Parameters
url
string
relative url to service
_methods
in case we need filtering (like Store)
Returns
string
absolute url or undefined if need to skip the Route
Inherited from
init()
init():
Promise<RESTOperationsTransport<T>>
Defined in: packages/core/src/services/operationstransport.ts:97
Initialize the transport by exposing all non-hidden operations
Returns
Promise<RESTOperationsTransport<T>>
this for chaining
Inherited from
initMetrics()
initMetrics():
void
Defined in: packages/core/src/services/service.ts:290
Init the metrics
Returns
void
Inherited from
OperationsTransport.initMetrics
initOperations()
initOperations():
void
Defined in: packages/core/src/services/service.ts:420
Init the operations from
Returns
void
Operation
decorators on this service
Inherited from
OperationsTransport.initOperations
initTransport()
protectedinitTransport():void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:160
Override initTransport to walk the model tree instead of flat iteration. For each model, we look up its operations and register REST routes.
Returns
void
Overrides
OperationsTransport.initTransport
listeners()
listeners(
eventName):Function[]
Defined in: packages/core/src/events/asynceventemitter.ts:183
Get all listeners for an event
Parameters
eventName
never
the event name
Returns
Function[]
the list of results
Inherited from
loadCapabilities()
protectedloadCapabilities():void
Defined in: packages/core/src/services/service.ts:270
Load capabilities from webda.module.json metadata into _compiledCapabilities.
Called during resolve after dependency injection. Reads the service's
type name from parameters, looks it up in the application's module metadata
(moddas or beans section), and populates _compiledCapabilities with an
empty object for each declared capability name.
Fails silently if the application is not available (e.g., in unit tests where services are instantiated without a full application context).
Returns
void
Example
// If webda.module.json contains:
// { "moddas": { "MyApp/HawkService": { "capabilities": ["request-filter", "cors-filter"] } } }
// Then after resolve(), this.getCapabilities() returns:
// { "request-filter": {}, "cors-filter": {} }
See
getCapabilities
Inherited from
OperationsTransport.loadCapabilities
log()
log(
level, ...args):void
Defined in: packages/core/src/services/service.ts:513
Parameters
level
WorkerLogLevel
to log
args
...any[]
additional arguments
Returns
void
Inherited from
off()
off<
Key>(eventName,listener):this
Defined in: packages/core/src/events/asynceventemitter.ts:141
Type Parameters
Key
Key extends never
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.off
Inherited from
on()
on<
Key>(eventName,listener):this
Defined in: packages/core/src/events/asynceventemitter.ts:119
Type Parameters
Key
Key extends never
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.once
Inherited from
once()
once<
Key>(eventName,listener):this
Defined in: packages/core/src/events/asynceventemitter.ts:108
Type Parameters
Key
Key extends never
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.once
Inherited from
openapi()
openapi(
ctx):Promise<void>
Defined in: packages/core/src/rest/restoperationstransport.service.ts:904
Serve the openapi with the swagger-ui
Parameters
ctx
the web context
Returns
Promise<void>
removeAllListeners()
removeAllListeners<
Key>(eventName?):this
Defined in: packages/core/src/events/asynceventemitter.ts:150
Type Parameters
Key
Key extends never
Parameters
eventName?
Key
the event name
Returns
this
this for chaining
See
EventEmitter.removeAllListeners
Inherited from
OperationsTransport.removeAllListeners
removeListener()
removeListener<
Key>(eventName,listener):this
Defined in: packages/core/src/events/asynceventemitter.ts:130
Type Parameters
Key
Key extends never
Parameters
eventName
Key
the event name
listener
(event) => void
the event listener
Returns
this
this for chaining
See
EventEmitter.removeListener
Inherited from
OperationsTransport.removeListener
resolve()
resolve():
RESTOperationsTransport<T>
Defined in: packages/core/src/rest/restoperationstransport.service.ts:147
Resolve the service - set up OpenAPI route if configured
Returns
RESTOperationsTransport<T>
this for chaining
Overrides
setMaxListeners()
setMaxListeners(
n):this
Defined in: packages/core/src/events/asynceventemitter.ts:97
Parameters
n
number
Returns
this
Inherited from
OperationsTransport.setMaxListeners
stop()
stop():
Promise<void>
Defined in: packages/core/src/services/service.ts:217
Shutdown the current service if action need to be taken
Returns
Promise<void>
Inherited from
toJSON()
toJSON():
string
Defined in: packages/core/src/services/service.ts:452
Prevent service to be serialized
Returns
string
the result
Inherited from
toString()
toString():
string
Defined in: packages/core/src/services/service.ts:225
Return service representation
Returns
string
the result
Inherited from
transformName()
transformName(
name):string
Defined in: packages/core/src/rest/restoperationstransport.service.ts:139
Transform name using configured casing
Parameters
name
string
the name to transform
Returns
string
the transformed name
walkModel()
protectedwalkModel(model,metadata,operations,basePrefix,depth):void
Defined in: packages/core/src/rest/restoperationstransport.service.ts:245
Recursively walk a model and its children, registering routes at each level
Parameters
model
the model class
metadata
ModelMetadata
model metadata
operations
Record<string, OperationDefinition>
filtered operations map
basePrefix
string
URL prefix from parent context
depth
number
nesting depth for parent id parameters
Returns
void