@live-change/relations-plugin 0.5.27 → 0.6.0

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/itemOf.js CHANGED
@@ -17,7 +17,7 @@ module.exports = function(service, app) {
17
17
  context.relationWord = 'Item'
18
18
  context.reverseRelationWord = 'Owned'
19
19
 
20
- defineProperties(context.model, context.others, context.otherPropertyNames)
20
+ context.identifiers = defineProperties(context.model, context.others, context.otherPropertyNames)
21
21
  defineIndex(context.model, context.joinedOthersClassName, context.otherPropertyNames)
22
22
 
23
23
  if(config.sortBy) {
@@ -44,7 +44,7 @@ module.exports = function(service, app) {
44
44
  defineUpdateAction(config, context)
45
45
  }
46
46
 
47
- if(config.resetAccess || config.writeAccess) {
47
+ if(config.deleteAccess || config.writeAccess) {
48
48
  defineDeleteAction(config, context)
49
49
  }
50
50
  })
package/itemOfAny.js CHANGED
@@ -17,7 +17,7 @@ module.exports = function(service, app) {
17
17
  context.relationWord = 'Item'
18
18
  context.reverseRelationWord = 'Owned'
19
19
 
20
- defineAnyProperties(context.model, context.otherPropertyNames)
20
+ context.identifiers = defineAnyProperties(context.model, context.otherPropertyNames)
21
21
  defineAnyIndex(context.model, context.joinedOthersClassName, context.otherPropertyNames)
22
22
 
23
23
  if(config.sortBy) {
@@ -44,7 +44,7 @@ module.exports = function(service, app) {
44
44
  defineUpdateAction(config, context)
45
45
  }
46
46
 
47
- if(config.resetAccess || config.writeAccess) {
47
+ if(config.deleteAccess || config.writeAccess) {
48
48
  defineDeleteAction(config, context)
49
49
  }
50
50
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/relations-plugin",
3
- "version": "0.5.27",
3
+ "version": "0.6.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -21,8 +21,8 @@
21
21
  "url": "https://www.viamage.com/"
22
22
  },
23
23
  "dependencies": {
24
- "@live-change/framework": "^0.5.27",
24
+ "@live-change/framework": "^0.6.0",
25
25
  "pluralize": "8.0.0"
26
26
  },
27
- "gitHead": "8cdab8d362794c923e765193d2e786fb29587877"
27
+ "gitHead": "5e4250b3a6fcf11e46f36e6b9713c2a9f4a4dc92"
28
28
  }
@@ -88,6 +88,10 @@ function defineUpdateAction(config, context) {
88
88
  service.actions[actionName] = new ActionDefinition({
89
89
  name: actionName,
90
90
  properties: {
91
+ [modelPropertyName]: {
92
+ type: model,
93
+ validation: ['nonEmpty']
94
+ },
91
95
  ...(model.properties)
92
96
  },
93
97
  access: config.updateAccess || config.writeAccess,
@@ -122,7 +126,7 @@ function defineUpdateAction(config, context) {
122
126
 
123
127
  function defineDeleteAction(config, context) {
124
128
  const {
125
- service, app, model, modelRuntime, modelPropertyName,
129
+ service, app, model, modelRuntime, modelPropertyName, identifiers,
126
130
  otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName
127
131
  } = context
128
132
  const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Deleted'
@@ -130,7 +134,11 @@ function defineDeleteAction(config, context) {
130
134
  service.actions[actionName] = new ActionDefinition({
131
135
  name: actionName,
132
136
  properties: {
133
- ...(model.properties)
137
+ [modelPropertyName]: {
138
+ type: model,
139
+ validation: ['nonEmpty']
140
+ },
141
+ ...identifiers
134
142
  },
135
143
  access: config.deleteAccess || config.writeAccess,
136
144
  skipValidation: true,
package/propertyOf.js CHANGED
@@ -15,7 +15,7 @@ module.exports = function(service, app) {
15
15
  context.relationWord = 'Property'
16
16
  context.reverseRelationWord = 'Owned'
17
17
 
18
- defineProperties(context.model, context.others, context.otherPropertyNames)
18
+ context.identifiers = defineProperties(context.model, context.others, context.otherPropertyNames)
19
19
  defineIndex(context.model, context.joinedOthersClassName, context.otherPropertyNames)
20
20
 
21
21
  if(config.readAccess) {
package/propertyOfAny.js CHANGED
@@ -17,7 +17,7 @@ module.exports = function(service, app) {
17
17
  context.relationWord = 'Property'
18
18
  context.reverseRelationWord = 'Owned'
19
19
 
20
- defineAnyProperties(context.model, context.otherPropertyNames)
20
+ context.identifiers = defineAnyProperties(context.model, context.otherPropertyNames)
21
21
  defineAnyIndex(context.model, context.joinedOthersClassName, context.otherPropertyNames)
22
22
 
23
23
  if(config.readAccess) {
package/relatedTo.js CHANGED
@@ -17,7 +17,7 @@ module.exports = function(service, app) {
17
17
  context.relationWord = 'Friend'
18
18
  context.reverseRelationWord = 'Related'
19
19
 
20
- defineProperties(context.model, context.others, context.otherPropertyNames)
20
+ context.identifiers = defineProperties(context.model, context.others, context.otherPropertyNames)
21
21
  defineIndex(context.model, context.joinedOthersClassName, context.otherPropertyNames)
22
22
 
23
23
  if(config.sortBy) {
@@ -44,7 +44,7 @@ module.exports = function(service, app) {
44
44
  defineUpdateAction(config, context)
45
45
  }
46
46
 
47
- if(config.resetAccess || config.writeAccess) {
47
+ if(config.deleteAccess || config.writeAccess) {
48
48
  defineDeleteAction(config, context)
49
49
  }
50
50
  })
package/relatedToAny.js CHANGED
@@ -17,7 +17,7 @@ module.exports = function(service, app) {
17
17
  context.relationWord = 'Friend'
18
18
  context.reverseRelationWord = 'Related'
19
19
 
20
- defineAnyProperties(context.model, context.otherPropertyNames)
20
+ context.identifiers = defineAnyProperties(context.model, context.otherPropertyNames)
21
21
  defineAnyIndex(context.model, context.joinedOthersClassName, context.otherPropertyNames)
22
22
 
23
23
  if(config.sortBy) {
@@ -44,7 +44,7 @@ module.exports = function(service, app) {
44
44
  defineUpdateAction(config, context)
45
45
  }
46
46
 
47
- if(config.resetAccess || config.writeAccess) {
47
+ if(config.deleteAccess || config.writeAccess) {
48
48
  defineDeleteAction(config, context)
49
49
  }
50
50
  })
package/utils.js CHANGED
@@ -45,12 +45,17 @@ function extractObjectData(writeableProperties, properties, defaults) {
45
45
  }
46
46
 
47
47
  function defineProperties(model, types, names) {
48
+ const identifiers = {}
48
49
  for (let i = 0; i < types.length; i++) {
49
- model.properties[names[i]] = new PropertyDefinition({
50
+ identifiers[names[i]] = new PropertyDefinition({
50
51
  type: types[i],
51
52
  validation: ['nonEmpty']
52
53
  })
53
54
  }
55
+ for(const key in identifiers) {
56
+ model.properties[key] = identifiers[key]
57
+ }
58
+ return identifiers
54
59
  }
55
60
 
56
61
  function defineIndex(model, what, props) {
package/utilsAny.js CHANGED
@@ -27,16 +27,21 @@ function generateAnyId(otherPropertyNames, properties) {
27
27
  }
28
28
 
29
29
  function defineAnyProperties(model, names) {
30
+ const identifiers = {}
30
31
  for (let i = 0; i < names.length; i++) {
31
- model.properties[names[i]] = new PropertyDefinition({
32
+ identifiers[names[i]] = new PropertyDefinition({
32
33
  type: String,
33
34
  validation: ['nonEmpty']
34
35
  })
35
- model.properties[names[i]+'Type'] = new PropertyDefinition({
36
+ identifiers[names[i]+'Type'] = new PropertyDefinition({
36
37
  type: String,
37
38
  validation: ['nonEmpty']
38
39
  })
39
40
  }
41
+ for(const key in identifiers) {
42
+ model.properties[key] = identifiers[key]
43
+ }
44
+ return identifiers
40
45
  }
41
46
 
42
47
  function defineAnyIndex(model, what, props) {