@live-change/relations-plugin
Advanced tools
Comparing version 0.9.7 to 0.9.8
import { | ||
defineProperties, defineIndex, | ||
processModelsAnnotation, extractIdParts, extractIdentifiers, extractObjectData | ||
processModelsAnnotation, extractIdParts, extractIdentifiers, extractObjectData, prepareAccessControl | ||
} from './utils.js' | ||
@@ -10,2 +10,3 @@ import { fireChangeTriggers } from "./changeTriggers.js" | ||
} from "@live-change/framework" | ||
import pluralize from 'pluralize' | ||
@@ -48,2 +49,28 @@ const annotation = 'entity' | ||
function defineRangeView(config, context, external = true) { | ||
const { service, modelRuntime, modelPropertyName, modelName, model } = context | ||
const viewName = (config.prefix || '' ) + pluralize(config.prefix ? modelName : modelPropertyName) + (config.suffix || '') | ||
if(external) model.crud.range = viewName | ||
service.views[viewName] = new ViewDefinition({ | ||
name: viewName, | ||
properties: { | ||
...App.utils.rangeProperties | ||
}, | ||
returns: { | ||
type: Array, | ||
of: { | ||
type: model | ||
} | ||
}, | ||
internal: !external, | ||
global: config.globalView, | ||
access: external && config.readAllAccess, | ||
daoPath(properties, { client, context }) { | ||
const range = App.extractRange(properties) | ||
const path = modelRuntime().rangePath(range) | ||
return path | ||
} | ||
}) | ||
} | ||
function defineCreatedEvent(config, context) { | ||
@@ -343,3 +370,3 @@ const { | ||
model.identifiers = [{ [modelPropertyName]: 'id' }] | ||
model.identifiers = [{ name: modelPropertyName, field: 'id' }] | ||
model.crud = {} | ||
@@ -365,2 +392,3 @@ | ||
defineView(config, context, config.readAccess || config.readAccessControl || config.writeAccessControl) | ||
defineRangeView(config, context, config.readAllAccess) | ||
/// TODO: multiple views with limited fields | ||
@@ -367,0 +395,0 @@ |
@@ -27,3 +27,3 @@ import { | ||
context.identifiers = defineProperties(context.model, context.others, context.otherPropertyNames) | ||
context.model.identifiers = [...Object.keys(context.identifiers), { [context.modelPropertyName]: 'id' }] | ||
context.model.identifiers = [...Object.keys(context.identifiers), { name: context.modelPropertyName, field: 'id' }] | ||
@@ -30,0 +30,0 @@ addAccessControlParents(context) |
@@ -25,3 +25,3 @@ import { | ||
context.identifiers = defineAnyProperties(context.model, context.otherPropertyNames) | ||
context.model.identifiers = [...Object.keys(context.identifiers), { [context.modelPropertyName]: 'id' }] | ||
context.model.identifiers = [...Object.keys(context.identifiers), { name: context.modelPropertyName, field: 'id' }] | ||
@@ -28,0 +28,0 @@ addAccessControlAnyParents(context) |
{ | ||
"name": "@live-change/relations-plugin", | ||
"version": "0.9.7", | ||
"version": "0.9.8", | ||
"description": "", | ||
@@ -25,6 +25,6 @@ "main": "index.js", | ||
"dependencies": { | ||
"@live-change/framework": "^0.9.7", | ||
"@live-change/framework": "^0.9.8", | ||
"pluralize": "^8.0.0" | ||
}, | ||
"gitHead": "f936468bf39ea3c5b07ce14666f4b3a4a4a9287d" | ||
"gitHead": "bb09550504f28df5f4fdd73273de45dc91a857b5" | ||
} |
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
132029
3323