@live-change/relations-plugin 0.5.24 → 0.5.25

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/relations-plugin",
3
- "version": "0.5.24",
3
+ "version": "0.5.25",
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.24",
24
+ "@live-change/framework": "^0.5.25",
25
25
  "pluralize": "8.0.0"
26
26
  },
27
- "gitHead": "2fb6050c59e88d0dd285d640e454819d30130b0b"
27
+ "gitHead": "014a45f0a666820dc25eb728be2fe92834cb89ee"
28
28
  }
@@ -65,7 +65,8 @@ function defineCreateAction(config, context) {
65
65
  if(entity) throw 'exists'
66
66
  const identifiers = extractIdentifiersWithTypes(otherPropertyNames, properties)
67
67
  const data = extractObjectData(writeableProperties, properties, defaults)
68
- await App.validation.validate(data, validators, { source: action, action, service, app, client })
68
+ await App.validation.validate({ ...identifiers, ...data }, validators,
69
+ { source: action, action, service, app, client })
69
70
  emit({
70
71
  type: eventName,
71
72
  [modelPropertyName]: id,
@@ -104,7 +105,8 @@ function defineUpdateAction(config, context) {
104
105
  }
105
106
  const identifiers = extractIdentifiersWithTypes(otherPropertyNames, properties)
106
107
  const data = extractObjectData(writeableProperties, properties, entity)
107
- await App.validation.validate(data, validators, { source: action, action, service, app, client })
108
+ await App.validation.validate({ ...identifiers, ...data }, validators,
109
+ { source: action, action, service, app, client })
108
110
  emit({
109
111
  type: eventName,
110
112
  [modelPropertyName]: id,
@@ -60,7 +60,8 @@ function defineCreateAction(config, context) {
60
60
  if(entity) throw 'exists'
61
61
  const identifiers = extractIdentifiers(otherPropertyNames, properties)
62
62
  const data = extractObjectData(writeableProperties, properties, defaults)
63
- await App.validation.validate(data, validators, { source: action, action, service, app, client })
63
+ await App.validation.validate({ ...identifiers, ...data }, validators,
64
+ { source: action, action, service, app, client })
64
65
  emit({
65
66
  type: eventName,
66
67
  [modelPropertyName]: id,
@@ -99,7 +100,8 @@ function defineUpdateAction(config, context) {
99
100
  }
100
101
  const identifiers = extractIdentifiers(otherPropertyNames, properties)
101
102
  const data = extractObjectData(writeableProperties, properties, entity)
102
- await App.validation.validate(data, validators, { source: action, action, service, app, client })
103
+ await App.validation.validate({ ...identifiers, ...data }, validators,
104
+ { source: action, action, service, app, client })
103
105
  emit({
104
106
  type: eventName,
105
107
  [modelPropertyName]: id,
@@ -55,10 +55,11 @@ function defineSetAction(config, context) {
55
55
  skipValidation: true,
56
56
  queuedBy: otherPropertyNames,
57
57
  waitForEvents: true,
58
- async execute(properties, {client, service}, emit) {
58
+ async execute(properties, { client, service }, emit) {
59
59
  const identifiers = extractIdentifiersWithTypes(otherPropertyNames, properties)
60
60
  const data = extractObjectData(writeableProperties, properties, defaults)
61
- await App.validation.validate(data, validators, { source: action, action, service, app, client })
61
+ await App.validation.validate({ ...identifiers, ...data }, validators,
62
+ { source: action, action, service, app, client })
62
63
  emit({
63
64
  type: eventName,
64
65
  identifiers, data
@@ -91,7 +92,8 @@ function defineUpdateAction(config, context) {
91
92
  const entity = await modelRuntime().get(id)
92
93
  if (!entity) throw new Error('not_found')
93
94
  const data = extractObjectData(writeableProperties, properties, entity)
94
- await App.validation.validate(data, validators, { source: action, action, service, app, client })
95
+ await App.validation.validate({ ...identifiers, ...data }, validators,
96
+ { source: action, action, service, app, client })
95
97
  emit({
96
98
  type: eventName,
97
99
  identifiers, data
@@ -48,10 +48,11 @@ function defineSetAction(config, context) {
48
48
  skipValidation: true,
49
49
  queuedBy: otherPropertyNames,
50
50
  waitForEvents: true,
51
- async execute(properties, {client, service}, emit) {
51
+ async execute(properties, { client, service }, emit) {
52
52
  const identifiers = extractIdentifiers(otherPropertyNames, properties)
53
53
  const data = extractObjectData(writeableProperties, properties, defaults)
54
- await App.validation.validate(data, validators, { source: action, action, service, app, client })
54
+ await App.validation.validate({ ...identifiers, ...data }, validators,
55
+ { source: action, action, service, app, client })
55
56
  emit({
56
57
  type: eventName,
57
58
  identifiers, data
@@ -78,13 +79,14 @@ function defineUpdateAction(config, context) {
78
79
  skipValidation: true,
79
80
  queuedBy: otherPropertyNames,
80
81
  waitForEvents: true,
81
- async execute(properties, {client, service}, emit) {
82
+ async execute(properties, { client, service }, emit) {
82
83
  const identifiers = extractIdentifiers(otherPropertyNames, properties)
83
84
  const id = generateId(otherPropertyNames, properties)
84
85
  const entity = await modelRuntime().get(id)
85
86
  if (!entity) throw new Error('not_found')
86
87
  const data = extractObjectData(writeableProperties, properties, entity)
87
- await App.validation.validate(data, validators, { source: action, action, service, app, client })
88
+ await App.validation.validate({ ...identifiers, ...data }, validators,
89
+ { source: action, action, service, app, client })
88
90
  emit({
89
91
  type: eventName,
90
92
  identifiers, data
@@ -113,7 +115,7 @@ function defineResetAction(config, context) {
113
115
  access: config.resetAccess || config.writeAccess,
114
116
  queuedBy: otherPropertyNames,
115
117
  waitForEvents: true,
116
- async execute(properties, {client, service}, emit) {
118
+ async execute(properties, { client, service }, emit) {
117
119
  const identifiers = extractIdentifiers(otherPropertyNames, properties)
118
120
  const id = generateId(otherPropertyNames, properties)
119
121
  const entity = await modelRuntime().get(id)
package/utils.js CHANGED
@@ -35,13 +35,13 @@ function generateId(otherPropertyNames, properties) {
35
35
  }
36
36
 
37
37
  function extractObjectData(writeableProperties, properties, defaults) {
38
- let updateObject = {}
38
+ let objectData = {}
39
39
  for (const propertyName of writeableProperties) {
40
40
  if (properties.hasOwnProperty(propertyName)) {
41
- newObject[propertyName] = properties[propertyName]
41
+ objectData[propertyName] = properties[propertyName]
42
42
  }
43
43
  }
44
- return App.utils.mergeDeep({}, defaults, updateObject)
44
+ return App.utils.mergeDeep({}, defaults, objectData)
45
45
  }
46
46
 
47
47
  function defineProperties(model, types, names) {