@live-change/relations-plugin
Advanced tools
Comparing version 0.6.11 to 0.6.12
{ | ||
"name": "@live-change/relations-plugin", | ||
"version": "0.6.11", | ||
"version": "0.6.12", | ||
"description": "", | ||
@@ -24,6 +24,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"@live-change/framework": "^0.6.11", | ||
"@live-change/framework": "^0.6.12", | ||
"pluralize": "8.0.0" | ||
}, | ||
"gitHead": "99d448214c2df44f42e5d25a08fa50ae79e5bdbe" | ||
"gitHead": "2971bd3c587931c7a33f8f424dd7b22a08e04ab0" | ||
} |
const App = require("@live-change/framework") | ||
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition } = App | ||
const { extractTypeAndIdParts, extractIdentifiersWithTypes } = require("./utilsAny.js") | ||
const { extractTypeAndIdParts, extractIdentifiersWithTypes, prepareAccessControl } = require("./utilsAny.js") | ||
const { extractObjectData } = require("./utils.js") | ||
@@ -25,8 +25,3 @@ const { extractRange } = App | ||
const accessControl = config.readAccessControl || config.writeAccessControl | ||
if(typeof accessControl == 'object') { | ||
accessControl.objects = accessControl.objects ?? ((params) => otherPropertyNames.map(name => ({ | ||
objectType: params[name + 'Type'], | ||
object: params[name] | ||
}))) | ||
} | ||
prepareAccessControl(accessControl, otherPropertyNames) | ||
const viewName = joinedOthersPropertyName + context.reverseRelationWord + pluralize(modelName) | ||
@@ -63,2 +58,4 @@ service.views[viewName] = new ViewDefinition({ | ||
const actionName = 'create' + joinedOthersClassName + context.reverseRelationWord + modelName | ||
const accessControl = config.createAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -70,3 +67,3 @@ name: actionName, | ||
access: config.createAccess || config.writeAccess, | ||
accessControl: config.createAccessControl || config.writeAccessControl, | ||
accessControl, | ||
skipValidation: true, | ||
@@ -101,2 +98,4 @@ //queuedBy: otherPropertyNames, | ||
const actionName = 'update' + joinedOthersClassName + context.reverseRelationWord + modelName | ||
const accessControl = config.updateAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -112,3 +111,3 @@ name: actionName, | ||
access: config.updateAccess || config.writeAccess, | ||
accessControl: config.updateAccessControl || config.writeAccessControl, | ||
accessControl, | ||
skipValidation: true, | ||
@@ -150,2 +149,4 @@ //queuedBy: otherPropertyNames, | ||
const actionName = 'delete' + joinedOthersClassName + context.reverseRelationWord + modelName | ||
const accessControl = config.deleteAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -161,3 +162,3 @@ name: actionName, | ||
access: config.deleteAccess || config.writeAccess, | ||
accessControl: config.deleteAccessControl || config.writeAccessControl, | ||
accessControl, | ||
skipValidation: true, | ||
@@ -164,0 +165,0 @@ //queuedBy: otherPropertyNames, |
const App = require("@live-change/framework") | ||
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition } = App | ||
const { extractIdParts, extractRange, extractIdentifiers, extractObjectData } = require("./utils.js") | ||
const { extractIdParts, extractRange, extractIdentifiers, extractObjectData, prepareAccessControl } = require("./utils.js") | ||
@@ -19,2 +19,4 @@ const pluralize = require('pluralize') | ||
const viewName = joinedOthersPropertyName + context.reverseRelationWord + pluralize(modelName) | ||
const accessControl = config.readAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames, others) | ||
service.views[viewName] = new ViewDefinition({ | ||
@@ -46,6 +48,8 @@ name: viewName, | ||
service, app, model, defaults, modelPropertyName, modelRuntime, | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others | ||
} = context | ||
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Created' | ||
const actionName = 'set' + joinedOthersClassName + context.reverseRelationWord + modelName | ||
const accessControl = config.createAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames, others) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -57,3 +61,3 @@ name: actionName, | ||
access: config.createAccess || config.writeAccess, | ||
accessControl: config.createAccessControl || config.writeAccessControl, | ||
accessControl, | ||
skipValidation: true, | ||
@@ -84,6 +88,8 @@ //queuedBy: otherPropertyNames, | ||
service, app, model, modelRuntime, modelPropertyName, | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others | ||
} = context | ||
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Updated' | ||
const actionName = 'update' + joinedOthersClassName + context.reverseRelationWord + modelName | ||
const accessControl = config.updateAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames, others) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -127,6 +133,8 @@ name: actionName, | ||
service, app, model, modelRuntime, modelPropertyName, | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others | ||
} = context | ||
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Deleted' | ||
const actionName = 'delete' + joinedOthersClassName + context.reverseRelationWord + modelName | ||
const accessControl = config.deleteAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames, others) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -138,3 +146,3 @@ name: actionName, | ||
access: config.deleteAccess || config.writeAccess, | ||
accessControl: config.deleteAccessControl || config.writeAccessControl, | ||
accessControl, | ||
skipValidation: true, | ||
@@ -141,0 +149,0 @@ //queuedBy: otherPropertyNames, |
@@ -22,4 +22,4 @@ const { | ||
if(config.readAccess || config.readAccessControl || config.writeAccessControl) { | ||
defineView({ ...config, access: config.readAccess }, context) | ||
if(config.readAccess || config.writeAccess || config.readAccessControl || config.writeAccessControl) { | ||
defineView({ ...config }, context) | ||
} | ||
@@ -26,0 +26,0 @@ if(config.views) { |
const App = require("@live-change/framework") | ||
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition } = App | ||
const { extractTypeAndIdParts, extractIdentifiersWithTypes, generateAnyId } = require("./utilsAny.js") | ||
const { extractTypeAndIdParts, extractIdentifiersWithTypes, generateAnyId, prepareAccessControl } = require("./utilsAny.js") | ||
const { extractObjectData } = require("./utils.js") | ||
@@ -39,8 +39,3 @@ const { allCombinations } = require("./combinations.js") | ||
const accessControl = config.singleAccessControl || config.readAccessControl || config.writeAccessControl | ||
if(typeof accessControl == 'object') { | ||
accessControl.objects = accessControl.objects ?? ((params) => otherPropertyNames.map(name => ({ | ||
objectType: params[name + 'Type'], | ||
object: params[name] | ||
}))) | ||
} | ||
prepareAccessControl(accessControl, otherPropertyNames) | ||
const viewName = config.name || ((config.prefix ? (config.prefix + joinedOthersClassName) : joinedOthersPropertyName) + | ||
@@ -71,2 +66,4 @@ context.reverseRelationWord + modelName + (config.suffix || '')) | ||
const identifierCombinations = allCombinations(otherPropertyNames).slice(0, -1) | ||
const accessControl = config.listAccessControl || config.readAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames) | ||
for(const combination of identifierCombinations) { | ||
@@ -86,3 +83,3 @@ const propsUpperCase = combination.map(prop => prop[0].toUpperCase() + prop.slice(1)) | ||
access: config.listAccess || config.readAccess, | ||
accessControl: config.listAccessControl || config.readAccessControl || config.writeAccessControl, | ||
accessControl, | ||
daoPath(params, { client, context }) { | ||
@@ -107,2 +104,4 @@ const owner = [] | ||
const actionName = 'set' + joinedOthersClassName + context.reverseRelationWord + modelName | ||
const accessControl = config.setAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -114,3 +113,3 @@ name: actionName, | ||
access: config.setAccess || config.writeAccess, | ||
accessControl: config.setAccessControl || config.writeAccessControl, | ||
accessControl, | ||
skipValidation: true, | ||
@@ -141,2 +140,4 @@ queuedBy: otherPropertyNames, | ||
const actionName = 'update' + joinedOthersClassName + context.reverseRelationWord + modelName | ||
const accessControl = config.updateAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -148,3 +149,3 @@ name: actionName, | ||
access: config.updateAccess || config.writeAccess, | ||
accessControl: config.updateAccessControl || config.writeAccessControl, | ||
accessControl, | ||
skipValidation: true, | ||
@@ -178,2 +179,4 @@ queuedBy: otherPropertyNames, | ||
const actionName = 'setOrUpdate' + joinedOthersClassName + context.reverseRelationWord + modelName | ||
const accessControl = config.setOrUpdateAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -185,3 +188,3 @@ name: actionName, | ||
access: config.updateAccess || config.writeAccess, | ||
accessControl: config.setAccessControl || config.writeAccessControl, | ||
accessControl, | ||
skipValidation: true, | ||
@@ -214,2 +217,4 @@ queuedBy: otherPropertyNames, | ||
const actionName = 'reset' + joinedOthersClassName + context.reverseRelationWord + modelName | ||
const accessControl = config.resetAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -225,3 +230,3 @@ name: actionName, | ||
access: config.resetAccess || config.writeAccess, | ||
accessControl: config.resetAccessControl || config.writeAccessControl, | ||
accessControl, | ||
queuedBy: otherPropertyNames, | ||
@@ -228,0 +233,0 @@ waitForEvents: true, |
const App = require("@live-change/framework") | ||
const { PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition } = App | ||
const { extractIdentifiers, extractObjectData, generateId, extractIdParts} = require("./utils.js") | ||
const { | ||
extractIdentifiers, extractObjectData, generateId, extractIdParts, prepareAccessControl | ||
} = require("./utils.js") | ||
@@ -17,2 +19,4 @@ function defineView(config, context) { | ||
'Owned' + modelName + (config.suffix || '')) | ||
const accessControl = config.readAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames, others) | ||
service.views[viewName] = new ViewDefinition({ | ||
@@ -26,4 +30,4 @@ name: viewName, | ||
}, | ||
access: config.readAccess, | ||
accessControl: config.readAccessControl || config.writeAccessControl, | ||
access: config.readAccess || config.writeAccess, | ||
accessControl, | ||
daoPath(properties, { client, context }) { | ||
@@ -41,6 +45,8 @@ const idParts = extractIdParts(otherPropertyNames, properties) | ||
service, app, model, defaults, | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others | ||
} = context | ||
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Set' | ||
const actionName = 'set' + joinedOthersClassName + 'Owned' + modelName | ||
const accessControl = config.setAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames, others) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -52,3 +58,3 @@ name: actionName, | ||
access: config.setAccess || config.writeAccess, | ||
accessControl: config.setAccessControl || config.writeAccessControl, | ||
accessControl, | ||
skipValidation: true, | ||
@@ -75,6 +81,8 @@ queuedBy: otherPropertyNames, | ||
service, app, model, modelRuntime, | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others | ||
} = context | ||
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Updated' | ||
const actionName = 'update' + joinedOthersClassName + 'Owned' + modelName | ||
const accessControl = config.updateAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames, others) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -86,3 +94,3 @@ name: actionName, | ||
access: config.updateAccess || config.writeAccess, | ||
accessControl: config.updateAccessControl || config.writeAccessControl, | ||
accessControl, | ||
skipValidation: true, | ||
@@ -112,6 +120,8 @@ queuedBy: otherPropertyNames, | ||
service, app, model, defaults, modelRuntime, | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName | ||
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName, others | ||
} = context | ||
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Updated' | ||
const actionName = 'update' + joinedOthersClassName + 'Owned' + modelName | ||
const accessControl = config.updateAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames, others) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -147,6 +157,8 @@ name: actionName, | ||
service, modelRuntime, modelPropertyName, | ||
otherPropertyNames, joinedOthersPropertyName, modelName, joinedOthersClassName, model | ||
otherPropertyNames, joinedOthersPropertyName, modelName, joinedOthersClassName, model, others | ||
} = context | ||
const eventName = joinedOthersPropertyName + 'Owned' + modelName + 'Reset' | ||
const actionName = 'reset' + joinedOthersClassName + 'Owned' + modelName | ||
const accessControl = config.resetAccessControl || config.writeAccessControl | ||
prepareAccessControl(accessControl, otherPropertyNames, others) | ||
service.actions[actionName] = new ActionDefinition({ | ||
@@ -161,3 +173,3 @@ name: actionName, | ||
access: config.resetAccess || config.writeAccess, | ||
accessControl: config.resetAccessControl || config.writeAccessControl, | ||
accessControl, | ||
queuedBy: otherPropertyNames, | ||
@@ -164,0 +176,0 @@ waitForEvents: true, |
11
utils.js
@@ -136,5 +136,14 @@ const App = require("@live-change/framework") | ||
function prepareAccessControl(accessControl, names, types) { | ||
if(typeof accessControl == 'object') { | ||
accessControl.objects = accessControl.objects ?? ((params) => names.map((name, index) => ({ | ||
objectType: types[index], | ||
object: params[name] | ||
}))) | ||
} | ||
} | ||
module.exports = { | ||
extractIdParts, extractIdentifiers, extractObjectData, defineProperties, defineIndex, | ||
processModelsAnnotation, generateId, addAccessControlParents | ||
processModelsAnnotation, generateId, addAccessControlParents, prepareAccessControl | ||
} |
@@ -137,2 +137,11 @@ const App = require("@live-change/framework") | ||
function prepareAccessControl(accessControl, names) { | ||
if(typeof accessControl == 'object') { | ||
accessControl.objects = accessControl.objects ?? ((params) => names.map(name => ({ | ||
objectType: params[name + 'Type'], | ||
object: params[name] | ||
}))) | ||
} | ||
} | ||
module.exports = { | ||
@@ -142,3 +151,4 @@ extractTypeAndIdParts, extractIdentifiersWithTypes, defineAnyProperties, | ||
processModelsAnyAnnotation, generateAnyId, | ||
addAccessControlAnyParents | ||
addAccessControlAnyParents, | ||
prepareAccessControl | ||
} |
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
77800
1877