@live-change/user-service 0.2.28 → 0.2.31
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/contactOrUserProperty.js +29 -13
- package/package.json +4 -4
package/contactOrUserProperty.js
CHANGED
|
@@ -39,6 +39,9 @@ definition.processor(function(service, app) {
|
|
|
39
39
|
to: ['contactOrUser', ...extendedWith]
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
const transferEventName = ['contactOrUser', ...(extendedWith.map(e => e[0].toUpperCase() + e.slice(1)))]
|
|
43
|
+
.join('And') + 'Owned' + modelName + 'Transferred'
|
|
44
|
+
|
|
42
45
|
service.trigger({
|
|
43
46
|
name: 'contactConnected',
|
|
44
47
|
properties: {
|
|
@@ -58,8 +61,14 @@ definition.processor(function(service, app) {
|
|
|
58
61
|
async execute({ contactType, contact, user }, { service }, emit) {
|
|
59
62
|
const contactPath = [contactType, contact]
|
|
60
63
|
const contactPropertyId = contactPath.map(p => JSON.stringify(p)).join(':')
|
|
61
|
-
const
|
|
62
|
-
|
|
64
|
+
const range = {
|
|
65
|
+
gte: contactPropertyId + '', // '' because it can be not-extended
|
|
66
|
+
lte: contactPropertyId + ':\xFF'
|
|
67
|
+
}
|
|
68
|
+
const contactProperties = await modelRuntime().rangeGet(range)
|
|
69
|
+
/// TODO: list based merge method
|
|
70
|
+
for(const contactProperty of contactProperties) {
|
|
71
|
+
console.log("CONTACT PROPERTY FOUND!", contactProperty, "MERGE =", config.merge)
|
|
63
72
|
const userPath = ['user_User', user]
|
|
64
73
|
const userPropertyId = userPath.map(p => JSON.stringify(p)).join(':')
|
|
65
74
|
const userProperty = await modelRuntime().get(userPropertyId)
|
|
@@ -69,8 +78,8 @@ definition.processor(function(service, app) {
|
|
|
69
78
|
emit({
|
|
70
79
|
type: 'contactOrUserOwned' + modelName + 'Updated',
|
|
71
80
|
identifiers: {
|
|
72
|
-
|
|
73
|
-
|
|
81
|
+
contactOrUserType: 'user_User',
|
|
82
|
+
contactOrUser: user
|
|
74
83
|
},
|
|
75
84
|
data: mergeResult
|
|
76
85
|
})
|
|
@@ -78,8 +87,8 @@ definition.processor(function(service, app) {
|
|
|
78
87
|
emit({
|
|
79
88
|
type: 'contactOrUserOwned' + modelName + 'Set',
|
|
80
89
|
identifiers: {
|
|
81
|
-
|
|
82
|
-
|
|
90
|
+
contactOrUserType: 'user_User',
|
|
91
|
+
contactOrUser: user
|
|
83
92
|
},
|
|
84
93
|
data: mergeResult
|
|
85
94
|
})
|
|
@@ -87,21 +96,28 @@ definition.processor(function(service, app) {
|
|
|
87
96
|
emit({
|
|
88
97
|
type: 'contactOrUserOwned' + modelName + 'Reset',
|
|
89
98
|
identifiers: {
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
contactOrUserType: contactType,
|
|
100
|
+
contactOrUser: contact
|
|
92
101
|
}
|
|
93
102
|
})
|
|
94
103
|
} else {
|
|
95
104
|
if(!userProperty) {
|
|
105
|
+
const extendedIdentifiers = {}
|
|
106
|
+
for(const key of extendedWith) {
|
|
107
|
+
extendedIdentifiers[key+'Type'] = contactProperty[key+'Type']
|
|
108
|
+
extendedIdentifiers[key] = contactProperty[key]
|
|
109
|
+
}
|
|
96
110
|
emit({
|
|
97
|
-
type:
|
|
111
|
+
type: transferEventName,
|
|
98
112
|
from: {
|
|
99
|
-
|
|
100
|
-
|
|
113
|
+
contactOrUserType: contactType,
|
|
114
|
+
contactOrUser: contact,
|
|
115
|
+
...extendedIdentifiers
|
|
101
116
|
},
|
|
102
117
|
to: {
|
|
103
|
-
|
|
104
|
-
|
|
118
|
+
contactOrUserType: 'user_User',
|
|
119
|
+
contactOrUser: user,
|
|
120
|
+
...extendedIdentifiers
|
|
105
121
|
}
|
|
106
122
|
})
|
|
107
123
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@live-change/user-service",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.31",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -21,9 +21,9 @@
|
|
|
21
21
|
"url": "https://www.viamage.com/"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@live-change/framework": "0.6.
|
|
25
|
-
"@live-change/relations-plugin": "0.6.
|
|
24
|
+
"@live-change/framework": "0.6.4",
|
|
25
|
+
"@live-change/relations-plugin": "0.6.3",
|
|
26
26
|
"pluralize": "8.0.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "be1924699748fe7abcddabf207f9290e734bac6b"
|
|
29
29
|
}
|