@live-change/relations-plugin 0.5.22 → 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/itemOfAny.js +1 -1
- package/package.json +3 -3
- package/pluralRelationAnyUtils.js +5 -3
- package/pluralRelationUtils.js +4 -2
- package/propertyOfAny.js +6 -2
- package/singularRelationAnyUtils.js +5 -3
- package/singularRelationUtils.js +7 -5
- package/utils.js +3 -3
- package/utilsAny.js +0 -2
package/itemOfAny.js
CHANGED
|
@@ -9,7 +9,7 @@ const {
|
|
|
9
9
|
|
|
10
10
|
const {
|
|
11
11
|
defineView, defineCreateAction, defineUpdateAction, defineDeleteAction, defineSortIndex
|
|
12
|
-
} = require('./
|
|
12
|
+
} = require('./pluralRelationAnyUtils.js')
|
|
13
13
|
|
|
14
14
|
module.exports = function(service, app) {
|
|
15
15
|
processModelsAnyAnnotation(service, app, 'itemOfAny',false, (config, context) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/relations-plugin",
|
|
3
|
-
"version": "0.5.
|
|
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
|
+
"@live-change/framework": "^0.5.25",
|
|
25
25
|
"pluralize": "8.0.0"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "014a45f0a666820dc25eb728be2fe92834cb89ee"
|
|
28
28
|
}
|
|
@@ -49,7 +49,7 @@ function defineCreateAction(config, context) {
|
|
|
49
49
|
otherPropertyNames, joinedOthersPropertyName, modelName, writeableProperties, joinedOthersClassName
|
|
50
50
|
} = context
|
|
51
51
|
const eventName = joinedOthersPropertyName + context.reverseRelationWord + modelName + 'Created'
|
|
52
|
-
const actionName = '
|
|
52
|
+
const actionName = 'create' + joinedOthersClassName + context.reverseRelationWord + modelName
|
|
53
53
|
service.actions[actionName] = new ActionDefinition({
|
|
54
54
|
name: actionName,
|
|
55
55
|
properties: {
|
|
@@ -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(
|
|
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(
|
|
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,
|
package/pluralRelationUtils.js
CHANGED
|
@@ -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(
|
|
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(
|
|
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,
|
package/propertyOfAny.js
CHANGED
|
@@ -3,9 +3,13 @@ const {
|
|
|
3
3
|
processModelsAnyAnnotation, generateAnyId
|
|
4
4
|
} = require('./utilsAny.js')
|
|
5
5
|
|
|
6
|
-
const {
|
|
6
|
+
const {
|
|
7
|
+
defineSetEvent, defineUpdatedEvent, defineTransferredEvent, defineResetEvent
|
|
8
|
+
} = require('./propertyEvents.js')
|
|
7
9
|
|
|
8
|
-
const
|
|
10
|
+
const {
|
|
11
|
+
defineView, defineSetAction, defineUpdateAction, defineResetAction
|
|
12
|
+
} = require('./singularRelationAnyUtils.js')
|
|
9
13
|
|
|
10
14
|
module.exports = function(service, app) {
|
|
11
15
|
processModelsAnyAnnotation(service, app, 'propertyOfAny', false, (config, context) => {
|
|
@@ -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(
|
|
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(
|
|
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
|
package/singularRelationUtils.js
CHANGED
|
@@ -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(
|
|
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(
|
|
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
|
|
38
|
+
let objectData = {}
|
|
39
39
|
for (const propertyName of writeableProperties) {
|
|
40
40
|
if (properties.hasOwnProperty(propertyName)) {
|
|
41
|
-
|
|
41
|
+
objectData[propertyName] = properties[propertyName]
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
return App.utils.mergeDeep({}, defaults,
|
|
44
|
+
return App.utils.mergeDeep({}, defaults, objectData)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
function defineProperties(model, types, names) {
|