@live-change/relations-plugin 0.9.7 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/entity.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import {
2
2
  defineProperties, defineIndex,
3
- processModelsAnnotation, extractIdParts, extractIdentifiers, extractObjectData
3
+ processModelsAnnotation, extractIdParts, extractIdentifiers, extractObjectData, prepareAccessControl
4
4
  } from './utils.js'
5
5
  import { fireChangeTriggers } from "./changeTriggers.js"
6
6
  import App from '@live-change/framework'
7
7
  import {
8
8
  PropertyDefinition, ViewDefinition, IndexDefinition, ActionDefinition, EventDefinition, TriggerDefinition
9
9
  } from "@live-change/framework"
10
+ import pluralize from 'pluralize'
10
11
 
11
12
  const annotation = 'entity'
12
13
 
@@ -44,6 +45,32 @@ function defineView(config, context, external) {
44
45
  })
45
46
  }
46
47
 
48
+ function defineRangeView(config, context, external = true) {
49
+ const { service, modelRuntime, modelPropertyName, modelName, model } = context
50
+ const viewName = (config.prefix || '' ) + pluralize(config.prefix ? modelName : modelPropertyName) + (config.suffix || '')
51
+ if(external) model.crud.range = viewName
52
+ service.views[viewName] = new ViewDefinition({
53
+ name: viewName,
54
+ properties: {
55
+ ...App.utils.rangeProperties
56
+ },
57
+ returns: {
58
+ type: Array,
59
+ of: {
60
+ type: model
61
+ }
62
+ },
63
+ internal: !external,
64
+ global: config.globalView,
65
+ access: external && config.readAllAccess,
66
+ daoPath(properties, { client, context }) {
67
+ const range = App.extractRange(properties)
68
+ const path = modelRuntime().rangePath(range)
69
+ return path
70
+ }
71
+ })
72
+ }
73
+
47
74
  function defineCreatedEvent(config, context) {
48
75
  const {
49
76
  service, modelRuntime, modelName, modelPropertyName
@@ -338,7 +365,7 @@ export default function(service, app) {
338
365
  const modelProperties = Object.keys(model.properties)
339
366
  const modelPropertyName = modelName.slice(0, 1).toLowerCase() + modelName.slice(1)
340
367
 
341
- model.identifiers = [{ [modelPropertyName]: 'id' }]
368
+ model.identifiers = [{ name: modelPropertyName, field: 'id' }]
342
369
  model.crud = {}
343
370
 
344
371
  function modelRuntime() {
@@ -359,6 +386,7 @@ export default function(service, app) {
359
386
  }
360
387
 
361
388
  defineView(config, context, config.readAccess || config.readAccessControl || config.writeAccessControl)
389
+ defineRangeView(config, context, config.readAllAccess)
362
390
  /// TODO: multiple views with limited fields
363
391
 
364
392
  defineCreatedEvent(config, context)
package/itemOf.js CHANGED
@@ -24,7 +24,7 @@ export default function(service, app) {
24
24
  context.reverseRelationWord = 'Owned'
25
25
 
26
26
  context.identifiers = defineProperties(context.model, context.others, context.otherPropertyNames)
27
- context.model.identifiers = [...Object.keys(context.identifiers), { [context.modelPropertyName]: 'id' }]
27
+ context.model.identifiers = [...Object.keys(context.identifiers), { name: context.modelPropertyName, field: 'id' }]
28
28
 
29
29
  addAccessControlParents(context)
30
30
  defineIndexes(context.model, context.otherPropertyNames.map(p => p[0].toLowerCase() + p.slice(1)), context.others)
package/itemOfAny.js CHANGED
@@ -22,7 +22,7 @@ export default function(service, app) {
22
22
  context.reverseRelationWord = 'Owned'
23
23
 
24
24
  context.identifiers = defineAnyProperties(context.model, context.otherPropertyNames)
25
- context.model.identifiers = [...Object.keys(context.identifiers), { [context.modelPropertyName]: 'id' }]
25
+ context.model.identifiers = [...Object.keys(context.identifiers), { name: context.modelPropertyName, field: 'id' }]
26
26
 
27
27
  addAccessControlAnyParents(context)
28
28
  defineAnyIndexes(context.model, context.otherPropertyNames)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/relations-plugin",
3
- "version": "0.9.7",
3
+ "version": "0.9.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,8 +22,8 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/framework": "^0.9.7",
25
+ "@live-change/framework": "^0.9.8",
26
26
  "pluralize": "^8.0.0"
27
27
  },
28
- "gitHead": "f936468bf39ea3c5b07ce14666f4b3a4a4a9287d"
28
+ "gitHead": "bb09550504f28df5f4fdd73273de45dc91a857b5"
29
29
  }