AsyncAction
Class: AsyncAction
Define here a model that can be used along with Store service
Webda Model
Extends
CoreModel
Constructors
new AsyncAction()
new AsyncAction():
AsyncAction
Set type
Returns
Overrides
CoreModel.constructor
Source
Properties
__class
__class:
CoreModelDefinition<AsyncAction>
Class reference to the object
Inherited from
CoreModel.__class
Source
core/lib/models/coremodel.d.ts:402
__ctx
__ctx:
OperationContext<any,any>
Object context
@TJS-ignore
Inherited from
CoreModel.__ctx
Source
core/lib/models/coremodel.d.ts:416
__dirty
__dirty:
Set<string|symbol>
Inherited from
CoreModel.__dirty
Source
core/lib/models/coremodel.d.ts:423
__secretKey
__secretKey:
string
Secret key to post feedback
Source
__store
__store:
Store<AsyncAction,StoreParameters,StoreEvents>
If object is attached to its store
@TJS-ignore
Inherited from
CoreModel.__store
Source
core/lib/models/coremodel.d.ts:422
__type
__type:
string
Type name
Inherited from
CoreModel.__type
Source
core/lib/models/coremodel.d.ts:406
__types
__types:
string[]
Types name
Inherited from
CoreModel.__types
Source
core/lib/models/coremodel.d.ts:410
_creationDate
_creationDate:
Date
Creation date
Inherited from
CoreModel._creationDate
Source
core/lib/models/coremodel.d.ts:427
_lastJobUpdate
_lastJobUpdate:
number
Last time the job was updated
Source
_lastUpdate
_lastUpdate:
Date
Last update date
Inherited from
CoreModel._lastUpdate
Source
core/lib/models/coremodel.d.ts:431
action?
action?:
string
Expected action for the job
It should be a verb
Source
arguments?
arguments?:
any[]
Source
errorMessage?
errorMessage?:
string
If an error occured it should contain the message
Source
job
job:
Job
Job information
Source
logs
logs:
string[]
Current logs
Source
results
results:
any
Results from the job
Source
scheduled?
scheduled?:
number
Timestamp when the action was scheduled
Source
status
status:
"RUNNING"|"SUCCESS"|"ERROR"|"QUEUED"|"STARTING"|"TIMEOUT"|"SCHEDULED"|"CANCELLED"
Current status
Source
statusDetails
statusDetails:
any
Job current status
Source
type
type:
string
Source
uuid
uuid:
string
Action uuid
Source
Methods
_onDelete()
_onDelete():
Promise<void>
Called when object is about to be deleted
Returns
Promise<void>
Inherited from
CoreModel._onDelete
Source
core/lib/models/coremodel.d.ts:813
_onDeleted()
_onDeleted():
Promise<void>
Called when object has been deleted
Returns
Promise<void>
Inherited from
CoreModel._onDeleted
Source
core/lib/models/coremodel.d.ts:817
_onGet()
_onGet():
Promise<void>
Called when object is retrieved
Returns
Promise<void>
Inherited from
CoreModel._onGet
Source
core/lib/models/coremodel.d.ts:821
_onSave()
_onSave():
Promise<void>
Called when object is about to be saved
Returns
Promise<void>
Inherited from
CoreModel._onSave
Source
core/lib/models/coremodel.d.ts:825
_onSaved()
_onSaved():
Promise<void>
Called when object is saved
Returns
Promise<void>
Inherited from
CoreModel._onSaved
Source
core/lib/models/coremodel.d.ts:829
_onUpdate()
_onUpdate(
_updates):Promise<void>
Called when object is about to be updates
Parameters
• _updates: any
Returns
Promise<void>
Inherited from
CoreModel._onUpdate
Source
core/lib/models/coremodel.d.ts:835
_onUpdated()
_onUpdated():
Promise<void>
Called when object is updated
Returns
Promise<void>
Inherited from
CoreModel._onUpdated
Source
core/lib/models/coremodel.d.ts:839
_toJSON()
_toJSON(
secure):any
Remove the specific attributes if not secure
Parameters
• secure: any
serialize server fields also
Returns
any
filtered object to be serialized
Inherited from
CoreModel._toJSON
Source
core/lib/models/coremodel.d.ts:803
attributePermission()
attributePermission(
key,value,mode,context?):any
Allow to define custom permission per attribute
This method allows you to do permission based attribute But also a mask destructive attribute
Parameters
• key: string
• value: any
• mode: "READ" | "WRITE"
• context?: OperationContext<any, any>
Returns
any
updated value
Inherited from
CoreModel.attributePermission
Source
core/lib/models/coremodel.d.ts:710
canAct()
canAct(
_context,_action):Promise<string|boolean>
By default nothing is permitted on a CoreModel
Parameters
• _context: OperationContext<any, any>
• _action: string
Returns
Promise<string | boolean>
Inherited from
CoreModel.canAct
Source
core/lib/models/coremodel.d.ts:667
checkAct()
checkAct(
context,action):Promise<void>
Ensure action hook is ok
Parameters
• context: OperationContext<any, any>
• action: string
Returns
Promise<void>
Overrides
CoreModel.checkAct
Source
delete()
delete():
Promise<void>
Delete this object
Returns
Promise<void>
Inherited from
CoreModel.delete
Throws
Error if the object is not coming from a store
Source
core/lib/models/coremodel.d.ts:753
generateUid()
generateUid(
_object?):string
Generate uuid for the object
Parameters
• _object?: any
Returns
string
Inherited from
CoreModel.generateUid
Source
core/lib/models/coremodel.d.ts:780
get()
get():
Promise<AsyncAction>
Get the object
Returns
Promise<AsyncAction>
Inherited from
CoreModel.get
Source
core/lib/models/coremodel.d.ts:741
getContext()
getContext<
T>():T
Get object context
Global object does not belong to a request
Type parameters
• T extends OperationContext<any, any>
Returns
T
Inherited from
CoreModel.getContext
Source
core/lib/models/coremodel.d.ts:732
getFullUuid()
getFullUuid():
string
Return a unique reference within the application to the object
It contains the Store containing it
Returns
string
Inherited from
CoreModel.getFullUuid
Source
core/lib/models/coremodel.d.ts:689
getHmac()
getHmac(
jobTime):string
Get the hmac for the job
Parameters
• jobTime: string
Returns
string
Source
getHookUrl()
getHookUrl():
string
Return the hook url if empty fallback to the service url
Returns
string
Source
getLogsLimit()
getLogsLimit():
number
Returns
number
Source
getProxy()
getProxy():
this
Return a proxy to the object to detect if dirty
Returns
this
Inherited from
CoreModel.getProxy
Source
core/lib/models/coremodel.d.ts:629
getRef()
getRef<
T>():ModelRef<T>
Return a model ref
Type parameters
• T extends AsyncAction
Returns
ModelRef<T>
Inherited from
CoreModel.getRef
Source
core/lib/models/coremodel.d.ts:861
getService()
getService<
T>(service):T
Get a pre typed service
Type parameters
• T extends Service<ServiceParameters, Events>
Parameters
• service: any
to retrieve WARNING: Only object attached to a store can retrieve service
Returns
T
Inherited from
CoreModel.getService
Source
core/lib/models/coremodel.d.ts:794
getStore()
getStore():
Store<AsyncAction,StoreParameters,StoreEvents>
Return the object registered store
Returns
Store<AsyncAction, StoreParameters, StoreEvents>
Inherited from
CoreModel.getStore
Source
core/lib/models/coremodel.d.ts:736
getUuid()
getUuid():
string
Returns
string
the uuid of the object
Inherited from
CoreModel.getUuid
Source
core/lib/models/coremodel.d.ts:639
handleRelations()
protectedhandleRelations():void
Patch every attribute that is based on a relation to add all the helpers
Returns
void
Inherited from
CoreModel.handleRelations
Source
core/lib/models/coremodel.d.ts:722
incrementAttribute()
incrementAttribute(
property,value):Promise<void>
Increment an attribute both in store and object
Parameters
• property: FilterAttributes<AsyncAction, number>
• value: number
Returns
Promise<void>
Inherited from
CoreModel.incrementAttribute
Source
core/lib/models/coremodel.d.ts:856
incrementAttributes()
incrementAttributes(
info):Promise<void>
Increment a attributes both in store and object
Parameters
• info: Object[]
Returns
Promise<void>
Inherited from
CoreModel.incrementAttributes
Source
core/lib/models/coremodel.d.ts:866
isDirty()
isDirty():
boolean
Return true if needs a save
Returns
boolean
Inherited from
CoreModel.isDirty
Source
core/lib/models/coremodel.d.ts:634
isInternal()
isInternal():
boolean
By default AsyncAction are not considered internal
Internal: That execute a method or operation of Webda application framework
Returns
boolean
Source
load()
load(
raw,secure?,relations?):this
Load an object from RAW
Parameters
• raw: RawModel<AsyncAction>
data
• secure?: boolean
if false will ignore any _ variable
• relations?: boolean
Returns
this
Inherited from
CoreModel.load
Source
core/lib/models/coremodel.d.ts:717
patch()
patch(
obj,conditionField?,conditionValue?):Promise<void>
Patch current object with this update
Parameters
• obj: Partial<AsyncAction>
• conditionField?: keyof AsyncAction
if null no condition used otherwise fallback to lastUpdate
• conditionValue?: any
Returns
Promise<void>
Inherited from
CoreModel.patch
Source
core/lib/models/coremodel.d.ts:760
refresh()
refresh():
Promise<AsyncAction>
Get the object again
Returns
Promise<AsyncAction>
Inherited from
CoreModel.refresh
Throws
Error if the object is not coming from a store
Source
core/lib/models/coremodel.d.ts:747
removeAttribute()
removeAttribute(
property):Promise<void>
Remove attribute from both the object and db
Parameters
• property: keyof AsyncAction
Returns
Promise<void>
Inherited from
CoreModel.removeAttribute
Source
core/lib/models/coremodel.d.ts:850
save()
save(
full?, ...args?):Promise<AsyncAction>
Save this object
Parameters
• full?: boolean | keyof AsyncAction
• ...args?: keyof AsyncAction[]
Returns
Promise<AsyncAction>
Inherited from
CoreModel.save
Throws
Error if the object is not coming from a store
Source
core/lib/models/coremodel.d.ts:766
setAttribute()
setAttribute(
property,value):Promise<void>
Set attribute on the object and database
Parameters
• property: keyof AsyncAction
• value: any
Returns
Promise<void>
Inherited from
CoreModel.setAttribute
Source
core/lib/models/coremodel.d.ts:845
setContext()
setContext(
ctx):this
Context of the request
Parameters
• ctx: OperationContext<any, any>
Returns
this
Inherited from
CoreModel.setContext
Source
core/lib/models/coremodel.d.ts:726
setUuid()
setUuid(
uuid,target?):this
Parameters
• uuid: string
• target?: this
Returns
this
Inherited from
CoreModel.setUuid
Source
core/lib/models/coremodel.d.ts:645
statusAction()
statusAction(
context):Promise<void>
Allow to report status for a job
Parameters
• context: WebContext<any, any>
Returns
Promise<void>
Source
toJSON()
toJSON():
any
Return the object without sensitive attributes
Returns
any
Object to serialize
Inherited from
CoreModel.toJSON
Source
core/lib/models/coremodel.d.ts:809
toStoredJSON()
toStoredJSON(
stringify?):any
Return the object to be serialized without the __store
Parameters
• stringify?: boolean
Returns
any
Inherited from
CoreModel.toStoredJSON
Source
core/lib/models/coremodel.d.ts:787
unflat()
unflat<
T>(split?):T
Create subobject for a model
Useful for counters
Type parameters
• T
Parameters
• split?: string
Returns
T
Inherited from
CoreModel.unflat
Source
core/lib/models/coremodel.d.ts:566
update()
update(
body,time):Promise<AsyncAction>
Parameters
• body: any
• time: string= undefined
Returns
Promise<AsyncAction>
Source
validate()
validate(
ctx,updates,ignoreRequired?):Promise<boolean>
Validate objet modification
Parameters
• ctx: OperationContext<any, any>
• updates: any
• ignoreRequired?: boolean
Returns
Promise<boolean>
Inherited from
CoreModel.validate
Source
core/lib/models/coremodel.d.ts:773
verifyJobRequest()
protectedverifyJobRequest<K>(context):Promise<void>
Type parameters
• K extends AsyncAction = AsyncAction
Parameters
• context: WebContext<any, any>
Returns
Promise<void>
Source
addListener()
staticaddListener<Key>(event,listener):any
Type parameters
• Key extends keyof StoreEvents
Parameters
• event: Key
• listener: (...args) => void
Returns
any
Inherited from
CoreModel.addListener
Source
core/lib/models/coremodel.d.ts:472
authorizeClientEvent()
staticauthorizeClientEvent(_event,_context,_model?):boolean
Does not allow any event by default
Parameters
• _event: string
• _context: OperationContext<any, any>
• _model?: CoreModel
Returns
boolean
Inherited from
CoreModel.authorizeClientEvent
Source
core/lib/models/coremodel.d.ts:502
completeQuery()
staticprotectedcompleteQuery(query,includeSubclass?):string
Complete the query with __type/__types
Parameters
• query: string
• includeSubclass?: boolean
Returns
string
Inherited from
CoreModel.completeQuery
Source
core/lib/models/coremodel.d.ts:596
completeUid()
staticcompleteUid(uid):string
Complete the uid with prefix if any
Useful when object are stored with a prefix for full uuid
Parameters
• uid: string
Returns
string
Inherited from
CoreModel.completeUid
Source
core/lib/models/coremodel.d.ts:516
create()
staticcreate<T>(this,data):Promise<T>
Get a reference to a model
Type parameters
• T extends CoreModel
Parameters
• this: Constructor<T, []>
• data: RawModel<T>
Returns
Promise<T>
Inherited from
CoreModel.create
Source
core/lib/models/coremodel.d.ts:535
emit()
staticemit<T,Key>(this,event,evt):void
Emit an event for this class
Type parameters
• T extends CoreModel
• Key extends keyof StoreEvents
Parameters
• this: Constructor<T, []>
• event: Key
• evt: StoreEvents[Key]
Returns
void
Inherited from
CoreModel.emit
Source
core/lib/models/coremodel.d.ts:452
emitSync()
staticemitSync<T,Key>(this,event,evt):Promise<void>
Emit an event for this class and wait for all listeners to finish
Type parameters
• T extends CoreModel
• Key extends keyof StoreEvents
Parameters
• this: Constructor<T, []>
• event: Key
• evt: StoreEvents[Key]
Returns
Promise<void>
Inherited from
CoreModel.emitSync
Source
core/lib/models/coremodel.d.ts:459
emitter()
staticemitter(method, ...args):any
Parameters
• method: any
• ...args: any[]
Returns
any
Inherited from
CoreModel.emitter
Source
core/lib/models/coremodel.d.ts:473
eventNames()
staticeventNames(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
CoreModel.eventNames
Source
core/lib/models/coremodel.d.ts:485
factory()
staticfactory<T>(this,object,context?):T
Create an object
Type parameters
• T extends CoreModel
Parameters
• this: Constructor<T, []>
• object: Partial<T>
• context?: OperationContext<any, any>
Returns
T
Inherited from
CoreModel.factory
Source
core/lib/models/coremodel.d.ts:676
flat()
staticflat(target,data,split?,prefix?):any
Flat an object into another
{ a: { b: 1 }, c: 1 }
become
{ "a#b": 1 "c": 1 }
Parameters
• target: any
• data: any
• split?: string
• prefix?: string
Returns
any
Inherited from
CoreModel.flat
Source
core/lib/models/coremodel.d.ts:589
fromFullUuid()
staticfromFullUuid<T>(fullUuid,core?,partials?):Promise<T>
Get an object from the full uuid
Type parameters
• T extends CoreModel = CoreModel
Parameters
• fullUuid: string
• core?: Core<CoreEvents>
• partials?: any
Returns
Promise<T>
Inherited from
CoreModel.fromFullUuid
Source
core/lib/models/coremodel.d.ts:697
getActions()
staticgetActions<T>(this):ModelActions
Get actions callable on an object
This will expose them by the Store with /storeUrl/{uuid}/{action}
Type parameters
• T
Parameters
• this: Constructor<T, []>
Returns
ModelActions
Inherited from
CoreModel.getActions
Source
core/lib/models/coremodel.d.ts:651
getClientEvents()
staticgetClientEvents():any[]
Do not declare any public events by default
Returns
any[]
Inherited from
CoreModel.getClientEvents
Source
core/lib/models/coremodel.d.ts:495
getHierarchy()
staticgetHierarchy():Object
Get the model hierarchy
Ancestors will contain every model it inherits from Children will contain every model that inherits from this model in a tree structure
Returns
Object
ancestors
ancestors:
string[]children
children:
ModelsTree
Inherited from
CoreModel.getHierarchy
Source
core/lib/models/coremodel.d.ts:547
getIdentifier()
staticgetIdentifier(short?):string
Get identifier for this model
Parameters
• short?: boolean
Returns
string
Inherited from
CoreModel.getIdentifier
Source
core/lib/models/coremodel.d.ts:540
getMaxListeners()
staticgetMaxListeners(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
CoreModel.getMaxListeners
Source
core/lib/models/coremodel.d.ts:479
getPermissionQuery()
staticgetPermissionQuery(_ctx):Object
Return the expressable query for permission
Parameters
• _ctx: OperationContext<any, any>
Returns
Object
partial
partial:
booleanquery
query:
string
Inherited from
CoreModel.getPermissionQuery
Source
core/lib/models/coremodel.d.ts:658
getRelations()
staticgetRelations():ModelGraph
Returns
ModelGraph
Inherited from
CoreModel.getRelations
Source
core/lib/models/coremodel.d.ts:490
getSchema()
staticgetSchema():JSONSchema7
Return the known schema
Returns
JSONSchema7
Inherited from
CoreModel.getSchema
Source
core/lib/models/coremodel.d.ts:521
getUuidField()
staticgetUuidField():string
Get the UUID property
Returns
string
Inherited from
CoreModel.getUuidField
Source
core/lib/models/coremodel.d.ts:671
instanceOf()
staticinstanceOf(object):boolean
Detect what looks like a CoreModel but can be from different version
Parameters
• object: any
Returns
boolean
Inherited from
CoreModel.instanceOf
Source
core/lib/models/coremodel.d.ts:682
iterate()
staticiterate<T>(this,query?,includeSubclass?,context?):AsyncGenerator<T,any,any>
Iterate through the model
How to use a iterator is:
for await (const model of CoreModel.iterate()) {
// Do something with my model
}
Type parameters
• T extends CoreModel
Parameters
• this: Constructor<T, []>
• query?: string
• includeSubclass?: boolean
• context?: OperationContext<any, any>
Returns
AsyncGenerator<T, any, any>
Inherited from
CoreModel.iterate
Source
core/lib/models/coremodel.d.ts:614
listenerCount()
staticlistenerCount(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
CoreModel.listenerCount
Source
core/lib/models/coremodel.d.ts:482
listeners()
staticlisteners(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
CoreModel.listeners
Source
core/lib/models/coremodel.d.ts:480
off()
staticoff(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
CoreModel.off
Source
core/lib/models/coremodel.d.ts:475
on()
staticon<T,Key>(this,event,listener,async?):any
Listen to events on the model
Type parameters
• T extends CoreModel
• Key extends keyof StoreEvents
Parameters
• this: Constructor<T, []>
• event: Key
• listener: (evt) => any
• async?: boolean
Returns
any
Inherited from
CoreModel.on
Source
core/lib/models/coremodel.d.ts:445
onAsync()
staticonAsync<Key>(event,listener,queue?):any
Listen to events on the model asynchronously
Type parameters
• Key extends keyof StoreEvents
Parameters
• event: Key
• listener: (evt) => any
• queue?: string
Returns
any
Inherited from
CoreModel.onAsync
Source
core/lib/models/coremodel.d.ts:465
once()
staticonce(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
CoreModel.once
Source
core/lib/models/coremodel.d.ts:476
prependListener()
staticprependListener(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
CoreModel.prependListener
Source
core/lib/models/coremodel.d.ts:483
prependOnceListener()
staticprependOnceListener(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
CoreModel.prependOnceListener
Source
core/lib/models/coremodel.d.ts:484
query()
staticquery<T>(this,query?,includeSubclass?,context?):Promise<Object>
Query for models