@live-change/relations-plugin
Advanced tools
Comparing version 0.6.5 to 0.6.6
@@ -0,1 +1,3 @@ | ||
const entity = require('./entity.js') | ||
const propertyOf = require('./propertyOf.js') | ||
@@ -14,2 +16,3 @@ const itemOf = require('./itemOf.js') | ||
const processors = [ | ||
entity, | ||
propertyOf, itemOf, | ||
@@ -27,2 +30,2 @@ propertyOfAny, itemOfAny, | ||
...processors | ||
] | ||
] |
const { | ||
defineProperties, defineIndex, | ||
processModelsAnnotation | ||
processModelsAnnotation, addAccessControlParents | ||
} = require('./utils.js') | ||
@@ -21,2 +21,3 @@ | ||
context.identifiers = defineProperties(context.model, context.others, context.otherPropertyNames) | ||
addAccessControlParents(context) | ||
defineIndex(context.model, context.joinedOthersClassName, context.otherPropertyNames) | ||
@@ -52,2 +53,2 @@ | ||
}) | ||
} | ||
} |
const { | ||
defineAnyProperties, defineAnyIndexes, | ||
processModelsAnyAnnotation | ||
processModelsAnyAnnotation, addAccessControlAnyParents | ||
} = require('./utilsAny.js') | ||
@@ -21,2 +21,3 @@ | ||
context.identifiers = defineAnyProperties(context.model, context.otherPropertyNames) | ||
addAccessControlAnyParents(context) | ||
defineAnyIndexes(context.model, context.otherPropertyNames) | ||
@@ -53,2 +54,2 @@ | ||
}) | ||
} | ||
} |
{ | ||
"name": "@live-change/relations-plugin", | ||
"version": "0.6.5", | ||
"version": "0.6.6", | ||
"description": "", | ||
@@ -24,6 +24,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"@live-change/framework": "^0.6.5", | ||
"@live-change/framework": "^0.6.6", | ||
"pluralize": "8.0.0" | ||
}, | ||
"gitHead": "6ffba5113875638abf4203b56bdab5ed6a2e5e55" | ||
"gitHead": "d6f4e8a34d88ecf90a3bf97bb367d4c8027ce7af" | ||
} |
const { | ||
defineProperties, defineIndex, | ||
processModelsAnnotation, generateId | ||
processModelsAnnotation, generateId, addAccessControlParents | ||
} = require('./utils.js') | ||
@@ -19,2 +19,3 @@ | ||
context.identifiers = defineProperties(context.model, context.others, context.otherPropertyNames) | ||
addAccessControlParents(context) | ||
defineIndex(context.model, context.joinedOthersClassName, context.otherPropertyNames) | ||
@@ -52,2 +53,2 @@ | ||
}) | ||
} | ||
} |
const { | ||
defineAnyProperties, defineAnyIndexes, | ||
processModelsAnyAnnotation, generateAnyId | ||
processModelsAnyAnnotation, generateAnyId, addAccessControlAnyParents | ||
} = require('./utilsAny.js') | ||
@@ -22,2 +22,3 @@ | ||
context.identifiers = defineAnyProperties(context.model, context.otherPropertyNames) | ||
addAccessControlAnyParents(context) | ||
defineAnyIndexes(context.model, context.otherPropertyNames) | ||
@@ -57,2 +58,2 @@ | ||
}) | ||
} | ||
} |
22
utils.js
@@ -118,5 +118,23 @@ const App = require("@live-change/framework") | ||
function addAccessControlParents(context) { | ||
const { modelRuntime } = context | ||
context.model.accessControlParents = async (id) => { | ||
const data = await modelRuntime().get(id) | ||
return context.otherPropertyNames.map(otherPropertyName => { | ||
const objectType = (otherPropertyName.slice(0, 1).toUpperCase() + otherPropertyName.slice(1)) | ||
const object = data[otherPropertyName] | ||
return { objectType, object } | ||
}).filter(parent => parent.object && parent.objectType) | ||
} | ||
context.model.accessControlParentsSource = context.otherPropertyNames.map( | ||
otherPropertyName => ({ | ||
property: otherPropertyName, | ||
type: (otherPropertyName.slice(0, 1).toUpperCase() + otherPropertyName.slice(1)) | ||
}) | ||
) | ||
} | ||
module.exports = { | ||
extractIdParts, extractIdentifiers, extractObjectData, defineProperties, defineIndex, | ||
processModelsAnnotation, generateId | ||
} | ||
processModelsAnnotation, generateId, addAccessControlParents | ||
} |
@@ -120,6 +120,24 @@ const App = require("@live-change/framework") | ||
function addAccessControlAnyParents(context) { | ||
const { modelRuntime } = context | ||
context.model.accessControlParents = async (id) => { | ||
const data = await modelRuntime().get(id) | ||
return context.otherPropertyNames.map(otherPropertyName => { | ||
const objectType = data[otherPropertyName + 'Type'] | ||
const object = data[otherPropertyName] | ||
return { objectType, object } | ||
}).filter(parent => parent.object && parent.objectType) | ||
} | ||
context.model.accessControlParentsSource = context.otherPropertyNames.map( | ||
otherPropertyName => ({ | ||
property: otherPropertyName | ||
}) | ||
) | ||
} | ||
module.exports = { | ||
extractTypeAndIdParts, extractIdentifiersWithTypes, defineAnyProperties, | ||
defineAnyIndex, defineAnyIndexes, | ||
processModelsAnyAnnotation, generateAnyId | ||
} | ||
processModelsAnyAnnotation, generateAnyId, | ||
addAccessControlAnyParents | ||
} |
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
69536
22
1784