@live-change/user-identification-service 0.8.14 → 0.8.16

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.
Files changed (2) hide show
  1. package/identification.js +41 -0
  2. package/package.json +4 -4
package/identification.js CHANGED
@@ -53,4 +53,45 @@ definition.view({
53
53
  }
54
54
  })
55
55
 
56
+ definition.trigger({
57
+ name: 'setIdentification',
58
+ properties: {
59
+ sessionOrUserType: {
60
+ type: String,
61
+ validation: ['nonEmpty']
62
+ },
63
+ sessionOrUser: {
64
+ validation: ['nonEmpty']
65
+ },
66
+ overwrite: {
67
+ type: Boolean
68
+ },
69
+ ...identificationFields
70
+ },
71
+ async execute({ sessionOrUserType, sessionOrUser, overwrite, ...identificationData }, { service }, emit) {
72
+ const identification = {}
73
+ for(const field in identificationFields) {
74
+ identification[field] = identificationData[field]
75
+ }
76
+ const id = [sessionOrUserType, sessionOrUser].map(p => JSON.stringify(p)).join(':')
77
+ const currentIdentification = (await Identification.get(id))
78
+ const newIdentification = overwrite
79
+ ? { ...currentIdentification, ...identification }
80
+ : { ...identification, ...currentIdentification }
81
+ if(currentIdentification) {
82
+ emit({
83
+ type: 'sessionOrUserOwnedIdentificationUpdated',
84
+ identifiers: { sessionOrUserType, sessionOrUser },
85
+ data: newIdentification
86
+ })
87
+ } else {
88
+ emit({
89
+ type: 'sessionOrUserOwnedIdentificationSet',
90
+ identifiers: { sessionOrUserType, sessionOrUser },
91
+ data: newIdentification
92
+ })
93
+ }
94
+ }
95
+ })
96
+
56
97
  export { Identification }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@live-change/user-identification-service",
3
- "version": "0.8.14",
3
+ "version": "0.8.16",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -22,9 +22,9 @@
22
22
  },
23
23
  "type": "module",
24
24
  "dependencies": {
25
- "@live-change/framework": "^0.8.14",
26
- "@live-change/relations-plugin": "^0.8.14",
25
+ "@live-change/framework": "^0.8.16",
26
+ "@live-change/relations-plugin": "^0.8.16",
27
27
  "pluralize": "^8.0.0"
28
28
  },
29
- "gitHead": "d81b573fb8891746ae1c67f4f68558123c9f85f7"
29
+ "gitHead": "b8ac84cbe1a8c435c7b5003dfc64ddc41a4e15a6"
30
30
  }