AclModel
Class: AclModel
Object that contains ACL to define its own permissions
Webda Model
Extends
Constructors
new AclModel()
new AclModel():
AclModel
Returns
Inherited from
Source
packages/core/src/models/coremodel.ts:690
Properties
__acl
__acl:
Acl={}
Permissions on the object
Source
packages/core/src/models/aclmodel.ts:19
__class
__class:
CoreModelDefinition<AclModel>
Class reference to the object
Inherited from
Source
packages/core/src/models/coremodel.ts:647
__ctx
__ctx:
OperationContext<any,any>
Object context
@TJS-ignore
Inherited from
Source
packages/core/src/models/coremodel.ts:662
__dirty
__dirty:
Set<string|symbol>
Inherited from
Source
packages/core/src/models/coremodel.ts:672
__store
__store:
Store<AclModel,StoreParameters,StoreEvents>
If object is attached to its store
@TJS-ignore
Inherited from
Source
packages/core/src/models/coremodel.ts:669
__type
__type:
string
Type name
Inherited from
Source
packages/core/src/models/coremodel.ts:651
__types
__types:
string[]
Types name
Inherited from
Source
packages/core/src/models/coremodel.ts:655
_creationDate
_creationDate:
Date
Creation date
Inherited from
Source
packages/core/src/models/coremodel.ts:677
_creator
_creator:
string
Object creator
Source
packages/core/src/models/aclmodel.ts:15
_lastUpdate
_lastUpdate:
Date
Last update date
Inherited from
Source
packages/core/src/models/coremodel.ts:682
_permissions?
protected_permissions?:string[]
Contains permissions
Source
packages/core/src/models/aclmodel.ts:23
Methods
_httpGetAcls()
_httpGetAcls(
ctx):Promise<Object>
GET
Parameters
• ctx: OperationContext<any, any>
Returns
Promise<Object>
raw
raw:
Aclresolved
resolved:
Object[]
Source
packages/core/src/models/aclmodel.ts:136
_httpPutAcls()
_httpPutAcls(
ctx):Promise<void>
Parameters
• ctx: OperationContext<any, any>
Returns
Promise<void>
Source
packages/core/src/models/aclmodel.ts:164
_onDelete()
_onDelete():
Promise<void>
Called when object is about to be deleted
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1598
_onDeleted()
_onDeleted():
Promise<void>
Called when object has been deleted
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1605
_onGet()
_onGet():
Promise<void>
Add the permissions for current user
Returns
Promise<void>
Overrides
Source
packages/core/src/models/aclmodel.ts:39
_onSave()
_onSave():
Promise<void>
Ensure creator has all permissions by default
Returns
Promise<void>
Overrides
Source
packages/core/src/models/aclmodel.ts:28
_onSaved()
_onSaved():
Promise<void>
Called when object is saved
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1626
_onUpdate()
_onUpdate(
_updates):Promise<void>
Called when object is about to be updates
Parameters
• _updates: any
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1635
_onUpdated()
_onUpdated():
Promise<void>
Called when object is updated
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1642
_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
Source
packages/core/src/models/coremodel.ts:1567
acl()
acl(
ctx):Promise<void|Object>
Manage the ACL REST api actions
Parameters
• ctx: WebContext<any, any>
Returns
Promise<void | Object>
Source
packages/core/src/models/aclmodel.ts:124
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
Source
packages/core/src/models/coremodel.ts:1311
canAct()
canAct(
ctx,action):Promise<string|boolean>
By default nothing is permitted on a CoreModel
Parameters
• ctx: OperationContext<any, any>
• action: string
Returns
Promise<string | boolean>
Overrides
Source
packages/core/src/models/aclmodel.ts:220
checkAct()
checkAct(
context,action):Promise<void>
Parameters
• context: OperationContext<any, any>
• action: string
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1202
delete()
delete():
Promise<void>
Delete this object
Returns
Promise<void>
Inherited from
Throws
Error if the object is not coming from a store
Source
packages/core/src/models/coremodel.ts:1462
generateUid()
generateUid(
_object):string
Generate uuid for the object
Parameters
• _object: any= undefined
Returns
string
Inherited from
Source
packages/core/src/models/coremodel.ts:1531
get()
get():
Promise<AclModel>
Get the object
Returns
Promise<AclModel>
Inherited from
Source
packages/core/src/models/coremodel.ts:1433
getAcl()
getAcl():
Acl
Return object ACLs
Returns
Source
packages/core/src/models/aclmodel.ts:52
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
Source
packages/core/src/models/coremodel.ts:1418
getFullUuid()
getFullUuid():
string
Return a unique reference within the application to the object
It contains the Store containing it
Returns
string
Inherited from
Source
packages/core/src/models/coremodel.ts:1275
getGroups()
getGroups(
_ctx,user):string[]
Parameters
• _ctx: OperationContext<any, any>
• user: User
Returns
string[]
Source
packages/core/src/models/aclmodel.ts:175
getPermissions()
getPermissions(
ctx,user?):Promise<string[]>
Get Permissions for one object
Parameters
• ctx: OperationContext<any, any>
• user?: User
Returns
Promise<string[]>
Source
packages/core/src/models/aclmodel.ts:194
getProxy()
getProxy():
this
Return a proxy to the object to detect if dirty
Returns
this
Inherited from
Source
packages/core/src/models/coremodel.ts:1098
getRef()
getRef<
T>():ModelRef<T>
Return a model ref
Type parameters
• T extends AclModel
Returns
ModelRef<T>
Inherited from
Source
packages/core/src/models/coremodel.ts:1678
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
Source
packages/core/src/models/coremodel.ts:1555
getStore()
getStore():
Store<AclModel,StoreParameters,StoreEvents>
Return the object registered store
Returns
Store<AclModel, StoreParameters, StoreEvents>
Inherited from
Source
packages/core/src/models/coremodel.ts:1425
getUserPublicEntry()
getUserPublicEntry(
ace):Promise<any>
Get the user public entry
Override if using a custom User without backward compatibility
Parameters
• ace: string
Returns
Promise<any>
Source
packages/core/src/models/aclmodel.ts:157
getUuid()
getUuid():
string
Returns
string
the uuid of the object
Inherited from
Source
packages/core/src/models/coremodel.ts:1157
handleRelations()
protectedhandleRelations():void
Patch every attribute that is based on a relation to add all the helpers
Returns
void
Inherited from
Source
packages/core/src/models/coremodel.ts:1358
hasPermission()
hasPermission(
ctx,user,action):Promise<boolean>
Parameters
• ctx: OperationContext<any, any>
• user: User
• action: string
Returns
Promise<boolean>
Source
packages/core/src/models/aclmodel.ts:208
incrementAttribute()
incrementAttribute(
property,value):Promise<void>
Increment an attribute both in store and object
Parameters
• property: never
• value: number
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1670
incrementAttributes()
incrementAttributes(
info):Promise<void>
Increment a attributes both in store and object
Parameters
• info: Object[]
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1686
isDirty()
isDirty():
boolean
Return true if needs a save
Returns
boolean
Inherited from
Source
packages/core/src/models/coremodel.ts:1149
load()
load(
raw,secure,relations):this
Load an object from RAW
Parameters
data
• secure: boolean= false
if false will ignore any _ variable
• relations: boolean= true
Returns
this
Inherited from
Source
packages/core/src/models/coremodel.ts:1325
patch()
patch(
obj,conditionField?,conditionValue?):Promise<void>
Patch current object with this update
Parameters
• obj: Partial<AclModel>
• conditionField?: keyof AclModel
if null no condition used otherwise fallback to lastUpdate
• conditionValue?: any
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1472
refresh()
refresh():
Promise<AclModel>
Get the object again
Returns
Promise<AclModel>
Inherited from
Throws
Error if the object is not coming from a store
Source
packages/core/src/models/coremodel.ts:1442
removeAttribute()
removeAttribute(
property):Promise<void>
Remove attribute from both the object and db
Parameters
• property: keyof AclModel
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1660
save()
save(
full?, ...args?):Promise<AclModel>
Save this object
Parameters
• full?: boolean | keyof AclModel
• ...args?: keyof AclModel[]
Returns
Promise<AclModel>
Inherited from
Throws
Error if the object is not coming from a store
Source
packages/core/src/models/coremodel.ts:1487
setAcl()
setAcl(
acl):void
Set object ACLs
Parameters
• acl: Acl
Returns
void
Source
packages/core/src/models/aclmodel.ts:60
setAttribute()
setAttribute(
property,value):Promise<void>
Set attribute on the object and database
Parameters
• property: keyof AclModel
• value: any
Returns
Promise<void>
Inherited from
Source
packages/core/src/models/coremodel.ts:1651
setContext()
setContext(
ctx):this
Context of the request
Parameters
• ctx: OperationContext<any, any>
Returns
this
Inherited from
Source
packages/core/src/models/coremodel.ts:1408
setUuid()
setUuid(
uuid,target):this
Parameters
• uuid: string
• target: AclModel= undefined
Returns
this
Inherited from
Source
packages/core/src/models/coremodel.ts:1167
toJSON()
toJSON():
any
Return the object without sensitive attributes
Returns
any
Object to serialize
Inherited from
Source
packages/core/src/models/coremodel.ts:1591
toStoredJSON()
toStoredJSON(
stringify):any
Return the object to be serialized without the __store
Parameters
• stringify: boolean= false
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:1541
unflat()
unflat<
T>(split):T
Create subobject for a model
Useful for counters
Type parameters
• T
Parameters
• split: string= "#"
Returns
T
Inherited from
Source
packages/core/src/models/coremodel.ts:991
validate()
validate(
ctx,updates,ignoreRequired):Promise<boolean>
Validate objet modification
Parameters
• ctx: OperationContext<any, any>
• updates: any
• ignoreRequired: boolean= false
Returns
Promise<boolean>
Inherited from
Source
packages/core/src/models/coremodel.ts:1520
addListener()
staticaddListener<Key>(event,listener):any
Type parameters
• Key extends keyof StoreEvents
Parameters
• event: Key
• listener: (...args) => void
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:795
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
packages/core/src/models/coremodel.ts:876
completeQuery()
staticprotectedcompleteQuery(query,includeSubclass):string
Complete the query with __type/__types
Parameters
• query: string
• includeSubclass: boolean= true
Returns
string
Inherited from
Source
packages/core/src/models/coremodel.ts:1033
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
Source
packages/core/src/models/coremodel.ts:899
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
Source
packages/core/src/models/coremodel.ts:928
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
Source
packages/core/src/models/coremodel.ts:732
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
Source
packages/core/src/models/coremodel.ts:758
emitter()
staticemitter(method, ...args):any
Parameters
• method: any
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:799
eventNames()
staticeventNames(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:851
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
Source
packages/core/src/models/coremodel.ts:1254
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
Source
packages/core/src/models/coremodel.ts:1017
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>= undefined
• partials?: any
Returns
Promise<T>
Inherited from
Source
packages/core/src/models/coremodel.ts:1286
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
Inherited from
Source
packages/core/src/models/coremodel.ts:1177
getClientEvents()
staticgetClientEvents():any[]
Do not declare any public events by default
Returns
any[]
Inherited from
Source
packages/core/src/models/coremodel.ts:866
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
Source
packages/core/src/models/coremodel.ts:951
getIdentifier()
staticgetIdentifier(short):string
Get identifier for this model
Parameters
• short: boolean= true
Returns
string
Inherited from
Source
packages/core/src/models/coremodel.ts:936
getMaxListeners()
staticgetMaxListeners(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:827
getPermissionQuery()
staticgetPermissionQuery(_ctx):Object
Return the expressable query for permission
Parameters
• _ctx: OperationContext<any, any>
Returns
Object
partial
partial:
booleanquery
query:
string
Inherited from
Source
packages/core/src/models/coremodel.ts:1198
getRelations()
staticgetRelations():ModelGraph
Returns
Inherited from
Source
packages/core/src/models/coremodel.ts:858
getSchema()
staticgetSchema():JSONSchema7
Return the known schema
Returns
JSONSchema7
Inherited from
Source
packages/core/src/models/coremodel.ts:907
getUuidField()
staticgetUuidField():string
Get the UUID property
Returns
string
Inherited from
Source
packages/core/src/models/coremodel.ts:1246
instanceOf()
staticinstanceOf(object):boolean
Detect what looks like a CoreModel but can be from different version
Parameters
• object: any
Returns
boolean
Inherited from
Source
packages/core/src/models/coremodel.ts:1263
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= true
• context?: OperationContext<any, any>
Returns
AsyncGenerator<T, any, any>
Inherited from
Source
packages/core/src/models/coremodel.ts:1065
listenerCount()
staticlistenerCount(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:839
listeners()
staticlisteners(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:831
off()
staticoff(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:811
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= false
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:706
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
Source
packages/core/src/models/coremodel.ts:785
once()
staticonce(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:815
prependListener()
staticprependListener(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:843
prependOnceListener()
staticprependOnceListener(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:847
query()
staticquery<T>(this,query,includeSubclass,context?):Promise<Object>
Query for models
Type parameters
• T extends CoreModel
Parameters
• this: Constructor<T, []>
• query: string= ""
• includeSubclass: boolean= true
• context?: OperationContext<any, any>
Returns
Promise<Object>
continuationToken?
continuationToken?:
stringresults
results:
T[]
Inherited from
Source
packages/core/src/models/coremodel.ts:1081
rawListeners()
staticrawListeners(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:835
ref()
staticref<T>(this,uid):ModelRefWithCreate<T>
Get a reference to a model
Type parameters
• T extends CoreModel
Parameters
• this: Constructor<T, []>
• uid: string
Returns
Inherited from
Source
packages/core/src/models/coremodel.ts:918
removeAllListeners()
staticremoveAllListeners(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:819
removeListener()
staticremoveListener(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:807
setMaxListeners()
staticsetMaxListeners(...args):any
Parameters
• ...args: any[]
Returns
any
Inherited from
Source
packages/core/src/models/coremodel.ts:823
store()
staticstore<T>(this):Store<T,StoreParameters,StoreEvents>
Get Store for this model
Type parameters
• T extends CoreModel
Parameters
• this: Constructor<T, []>
Returns
Store<T, StoreParameters, StoreEvents>
Inherited from
Source
packages/core/src/models/coremodel.ts:885
unflat()
staticunflat<T>(data,split):T
Unflat an object
Type parameters
• T = any
Parameters
• data: any
• split: string= "#"
Returns
T