@live-change/user-service
Advanced tools
Comparing version 0.2.32 to 0.2.33
@@ -110,2 +110,14 @@ const definition = require("./definition.js") | ||
} | ||
await service.trigger({ | ||
type: 'contactOrUserOwned' + modelName + 'Moved', | ||
from: { | ||
contactOrUserType: contactType, | ||
contactOrUser: contact | ||
}, | ||
to: { | ||
contactOrUserType: 'user_User', | ||
contactOrUser: user | ||
}, | ||
...extendedIdentifiers | ||
}) | ||
emit({ | ||
@@ -124,3 +136,3 @@ type: transferEventName, | ||
}) | ||
} | ||
} // else ignore | ||
} | ||
@@ -127,0 +139,0 @@ } |
{ | ||
"name": "@live-change/user-service", | ||
"version": "0.2.32", | ||
"version": "0.2.33", | ||
"description": "", | ||
@@ -24,7 +24,7 @@ "main": "index.js", | ||
"dependencies": { | ||
"@live-change/framework": "0.6.4", | ||
"@live-change/relations-plugin": "0.6.3", | ||
"@live-change/framework": "0.6.5", | ||
"@live-change/relations-plugin": "0.6.5", | ||
"pluralize": "8.0.0" | ||
}, | ||
"gitHead": "91f89af637893c2dbc0e1f55b2886345d408a9ea" | ||
"gitHead": "8918e5113c031c3d9766df32283de7fb6421e0be" | ||
} |
@@ -13,3 +13,3 @@ const definition = require("./definition.js") | ||
if(model.sessionOrUserItem) { | ||
if (model.properties.owner) throw new Error('user property already exists!!!') | ||
if (model.properties.sessionOrUser) throw new Error('user property already exists!!!') | ||
const originalModelProperties = { ...model.properties } | ||
@@ -30,4 +30,9 @@ const modelProperties = Object.keys(model.properties) | ||
if(model.itemOfAny) throw new Error("model " + modelName + " already have owner") | ||
const extendedWith = config.extendedWith | ||
? (Array.isArray(config.extendedWith) ? config.extendedWith : [config.extendedWith]) | ||
: [] | ||
model.itemOfAny = { | ||
...config | ||
...config, | ||
to: ['sessionOrUser', ...extendedWith] | ||
} | ||
@@ -48,3 +53,3 @@ | ||
const owner = client.user ? ['user_User', client.user] : ['session_Session', client.session] | ||
const path = modelRuntime().indexRangePath('byOwner', owner, range ) | ||
const path = modelRuntime().indexRangePath('bySessionOrUser', owner, range ) | ||
return path | ||
@@ -64,3 +69,3 @@ } | ||
const owner = client.user ? ['user_User', client.user] : ['session_Session', client.session] | ||
return modelRuntime().sortedIndexRangePath('byOwner' + sortFieldUc, owner, App.extractRange(range)) | ||
return modelRuntime().sortedIndexRangePath('bySsessionOrUser' + sortFieldUc, owner, App.extractRange(range)) | ||
} | ||
@@ -72,3 +77,3 @@ }) | ||
if(config.ownerCreateAccess || config.ownerWriteAccess) { | ||
const eventName = 'ownerOwned' + modelName + 'Created' | ||
const eventName = 'sessionOrUserOwned' + modelName + 'Created' | ||
const actionName = 'createMy' + modelName | ||
@@ -92,7 +97,7 @@ service.actions[actionName] = new ActionDefinition({ | ||
const identifiers = client.user ? { | ||
ownerType: 'user_User', | ||
owner: client.user, | ||
sessionOrUserType: 'user_User', | ||
sessionOrUser: client.user, | ||
} : { | ||
ownerType: 'session_Session', | ||
owner: client.session, | ||
sessionOrUserType: 'session_Session', | ||
sessionOrUser: client.session, | ||
} | ||
@@ -110,3 +115,3 @@ emit({ | ||
if(config.ownerUpdateAccess || config.ownerWriteAccess) { | ||
const eventName = 'ownerOwned' + modelName + 'Updated' | ||
const eventName = 'sessionOrUserOwned' + modelName + 'Updated' | ||
const actionName = 'updateMy' + modelName | ||
@@ -129,7 +134,7 @@ service.actions[actionName] = new ActionDefinition({ | ||
if(!entity) throw 'not_found' | ||
if(entity.ownerType == 'user_User') { | ||
if(entity.owner != client.user) throw 'not_authorized' | ||
if(entity.sessionOrUserType == 'user_User') { | ||
if(entity.sessionOrUser != client.user) throw 'not_authorized' | ||
} | ||
if(entity.ownerType == 'session_Session') { | ||
if(entity.owner != client.session) throw 'not_authorized' | ||
if(entity.sessionOrUserType == 'session_Session') { | ||
if(entity.sessionOrUser != client.session) throw 'not_authorized' | ||
} | ||
@@ -145,7 +150,7 @@ let updateObject = {} | ||
const identifiers = client.user ? { | ||
ownerType: 'user_User', | ||
owner: client.user, | ||
sessionOrUserType: 'user_User', | ||
sessionOrUser: client.user, | ||
} : { | ||
ownerType: 'session_Session', | ||
owner: client.session, | ||
sessionOrUserType: 'session_Session', | ||
sessionOrUser: client.session, | ||
} | ||
@@ -180,14 +185,14 @@ emit({ | ||
if(!entity) throw 'not_found' | ||
if(entity.ownerType == 'user_User') { | ||
if(entity.owner != client.user) throw 'not_authorized' | ||
if(entity.sessionOrUserType == 'user_User') { | ||
if(entity.sessionOrUser != client.user) throw 'not_authorized' | ||
} | ||
if(entity.ownerType == 'session_Session') { | ||
if(entity.owner != client.session) throw 'not_authorized' | ||
if(entity.sessionOrUserType == 'session_Session') { | ||
if(entity.sessionOrUser != client.session) throw 'not_authorized' | ||
} | ||
const identifiers = client.user ? { | ||
ownerType: 'user_User', | ||
owner: client.user, | ||
sessionOrUserType: 'user_User', | ||
sessionOrUser: client.user, | ||
} : { | ||
ownerType: 'session_Session', | ||
owner: client.session, | ||
sessionOrUserType: 'session_Session', | ||
sessionOrUser: client.session, | ||
} | ||
@@ -194,0 +199,0 @@ emit({ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62819
1552
+ Added@live-change/framework@0.6.5(transitive)
+ Added@live-change/relations-plugin@0.6.5(transitive)
- Removed@live-change/framework@0.6.4(transitive)
- Removed@live-change/relations-plugin@0.6.3(transitive)
Updated@live-change/framework@0.6.5