@unidoc-health/user 2.3.2 → 3.0.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/lib/index.d.ts +10 -1
- package/lib/index.js +54 -114
- package/package.json +13 -10
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Role, RoleDictionary } from '@
|
|
1
|
+
import { Role, RoleDictionary } from '@unidoc-health/role';
|
|
2
2
|
|
|
3
3
|
declare module '@unidoc-health/user' {
|
|
4
4
|
export interface IUserAdapter {
|
|
@@ -37,6 +37,11 @@ declare module '@unidoc-health/user' {
|
|
|
37
37
|
role?: string;
|
|
38
38
|
npi?: string;
|
|
39
39
|
force_change_password?: boolean;
|
|
40
|
+
|
|
41
|
+
emr_username?: string;
|
|
42
|
+
userType?: string;
|
|
43
|
+
migratedToIKC ? : string;
|
|
44
|
+
|
|
40
45
|
[key: string]: any;
|
|
41
46
|
}
|
|
42
47
|
|
|
@@ -54,6 +59,10 @@ declare module '@unidoc-health/user' {
|
|
|
54
59
|
public force_change_password: boolean;
|
|
55
60
|
public meta: { [key: string]: any };
|
|
56
61
|
|
|
62
|
+
public emr_username?: string;
|
|
63
|
+
public userType?: string;
|
|
64
|
+
public migratedToIKC? : string;
|
|
65
|
+
|
|
57
66
|
constructor(owner: UserProvider, base: Partial<User>);
|
|
58
67
|
hasPermission(permission: string): Promise<boolean>;
|
|
59
68
|
save(update?: boolean): Promise<void>;
|
package/lib/index.js
CHANGED
|
@@ -1,129 +1,69 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _debug = _interopRequireDefault(require("debug"));
|
|
13
|
-
|
|
14
|
-
const _excluded = ["org", "sub", "password", "username", "firstname", "lastname", "role", "npi", "force_change_password"];
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
|
-
|
|
20
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
|
-
|
|
22
|
-
function _classPrivateFieldInitSpec(obj, privateMap, value) { _checkPrivateRedeclaration(obj, privateMap); privateMap.set(obj, value); }
|
|
23
|
-
|
|
24
|
-
function _checkPrivateRedeclaration(obj, privateCollection) { if (privateCollection.has(obj)) { throw new TypeError("Cannot initialize the same private elements twice on an object"); } }
|
|
25
|
-
|
|
26
|
-
function _classPrivateFieldGet(receiver, privateMap) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "get"); return _classApplyDescriptorGet(receiver, descriptor); }
|
|
27
|
-
|
|
28
|
-
function _classApplyDescriptorGet(receiver, descriptor) { if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }
|
|
29
|
-
|
|
30
|
-
function _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = _classExtractFieldDescriptor(receiver, privateMap, "set"); _classApplyDescriptorSet(receiver, descriptor, value); return value; }
|
|
31
|
-
|
|
32
|
-
function _classExtractFieldDescriptor(receiver, privateMap, action) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to " + action + " private field on non-instance"); } return privateMap.get(receiver); }
|
|
33
|
-
|
|
34
|
-
function _classApplyDescriptorSet(receiver, descriptor, value) { if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError("attempted to set read only private field"); } descriptor.value = value; } }
|
|
35
|
-
|
|
36
|
-
const log = (0, _debug.default)('heimdall:user');
|
|
37
|
-
const defaultRole = new _role.RoleDictionary(_role.adapters.Null);
|
|
38
|
-
|
|
39
|
-
var _adapter = /*#__PURE__*/new WeakMap();
|
|
40
|
-
|
|
41
|
-
var _roles = /*#__PURE__*/new WeakMap();
|
|
42
|
-
|
|
43
|
-
class UserProvider {
|
|
1
|
+
const _excluded = ["org", "sub", "password", "username", "firstname", "lastname", "role", "npi", "force_change_password", "emr_username", "userType", "migratedToIKC"];
|
|
2
|
+
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
3
|
+
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
4
|
+
import { adapters, Role, RoleDictionary } from '@unidoc-health/role';
|
|
5
|
+
import bcrypt from 'bcrypt';
|
|
6
|
+
import debug from 'debug';
|
|
7
|
+
const log = debug('heimdall:user');
|
|
8
|
+
const defaultRole = new RoleDictionary(adapters.Null);
|
|
9
|
+
export class UserProvider {
|
|
10
|
+
#adapter;
|
|
11
|
+
#roles;
|
|
44
12
|
constructor(adapter, roles = defaultRole) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
value: void 0
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
_classPrivateFieldInitSpec(this, _roles, {
|
|
51
|
-
writable: true,
|
|
52
|
-
value: void 0
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
_classPrivateFieldSet(this, _adapter, adapter);
|
|
56
|
-
|
|
57
|
-
_classPrivateFieldSet(this, _roles, roles);
|
|
13
|
+
this.#adapter = adapter;
|
|
14
|
+
this.#roles = roles;
|
|
58
15
|
}
|
|
59
|
-
|
|
60
16
|
get adapter() {
|
|
61
|
-
return
|
|
17
|
+
return this.#adapter;
|
|
62
18
|
}
|
|
63
|
-
|
|
64
19
|
get destroy() {
|
|
65
|
-
return
|
|
20
|
+
return this.#adapter.destroy;
|
|
66
21
|
}
|
|
67
|
-
|
|
68
22
|
async all() {
|
|
69
23
|
const {
|
|
70
24
|
entries,
|
|
71
25
|
nextPage
|
|
72
|
-
} = await
|
|
26
|
+
} = await this.#adapter.all();
|
|
73
27
|
const result = [];
|
|
74
|
-
|
|
75
28
|
for (let user of entries) {
|
|
76
29
|
result.push(new User(this, user));
|
|
77
30
|
}
|
|
78
|
-
|
|
79
31
|
return {
|
|
80
32
|
entries: result,
|
|
81
33
|
nextPage
|
|
82
34
|
};
|
|
83
35
|
}
|
|
84
|
-
|
|
85
36
|
async seek(searchParams) {
|
|
86
37
|
const {
|
|
87
38
|
entries,
|
|
88
39
|
nextPage
|
|
89
|
-
} = await
|
|
40
|
+
} = await this.#adapter.seek(searchParams);
|
|
90
41
|
const result = [];
|
|
91
|
-
|
|
92
42
|
for (let user of entries) {
|
|
93
43
|
result.push(new User(this, user));
|
|
94
44
|
}
|
|
95
|
-
|
|
96
45
|
return {
|
|
97
46
|
entries: result,
|
|
98
47
|
nextPage
|
|
99
48
|
};
|
|
100
49
|
}
|
|
101
|
-
|
|
102
50
|
async findById(id) {
|
|
103
|
-
const user = await
|
|
51
|
+
const user = await this.#adapter.findById(id);
|
|
104
52
|
if (user) return new User(this, user);
|
|
105
53
|
}
|
|
106
|
-
|
|
107
54
|
async findByUsername(username) {
|
|
108
|
-
const user = await
|
|
55
|
+
const user = await this.#adapter.findByUsername(username);
|
|
109
56
|
if (user) return new User(this, user);
|
|
110
57
|
}
|
|
111
|
-
|
|
112
58
|
async save(user) {
|
|
113
59
|
return this.adapter.save(user);
|
|
114
60
|
}
|
|
115
|
-
|
|
116
61
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
var _owner = /*#__PURE__*/new WeakMap();
|
|
121
|
-
|
|
122
|
-
class User {
|
|
62
|
+
export class User {
|
|
63
|
+
#owner;
|
|
123
64
|
get accountId() {
|
|
124
65
|
return this.id;
|
|
125
66
|
}
|
|
126
|
-
|
|
127
67
|
constructor(owner, _ref = {
|
|
128
68
|
org: null,
|
|
129
69
|
sub: null,
|
|
@@ -133,28 +73,27 @@ class User {
|
|
|
133
73
|
lastname: null,
|
|
134
74
|
role: null,
|
|
135
75
|
npi: null,
|
|
136
|
-
force_change_password: null
|
|
76
|
+
force_change_password: null,
|
|
77
|
+
emr_username: null,
|
|
78
|
+
userType: null,
|
|
79
|
+
migratedToIKC: null
|
|
137
80
|
}) {
|
|
138
81
|
let {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
_classPrivateFieldSet(this, _owner, owner);
|
|
157
|
-
|
|
82
|
+
org,
|
|
83
|
+
sub,
|
|
84
|
+
password,
|
|
85
|
+
username,
|
|
86
|
+
firstname,
|
|
87
|
+
lastname,
|
|
88
|
+
role,
|
|
89
|
+
npi,
|
|
90
|
+
force_change_password,
|
|
91
|
+
emr_username,
|
|
92
|
+
userType,
|
|
93
|
+
migratedToIKC
|
|
94
|
+
} = _ref,
|
|
95
|
+
base = _objectWithoutProperties(_ref, _excluded);
|
|
96
|
+
this.#owner = owner;
|
|
158
97
|
this.org = org;
|
|
159
98
|
this.sub = sub;
|
|
160
99
|
this.password = password;
|
|
@@ -165,27 +104,25 @@ class User {
|
|
|
165
104
|
this.npi = npi;
|
|
166
105
|
this.force_change_password = force_change_password;
|
|
167
106
|
this.meta = {};
|
|
107
|
+
this.emr_username = emr_username;
|
|
108
|
+
this.userType = userType;
|
|
109
|
+
this.migratedToIKC = migratedToIKC;
|
|
168
110
|
Object.assign(this.meta, base);
|
|
169
111
|
}
|
|
170
|
-
|
|
171
112
|
get id() {
|
|
172
113
|
return this.sub;
|
|
173
114
|
}
|
|
174
|
-
|
|
175
115
|
async hasPermission(permission) {
|
|
176
116
|
const role = this.role;
|
|
177
117
|
return role.can(permission);
|
|
178
118
|
}
|
|
179
|
-
|
|
180
119
|
async save(update = true) {
|
|
181
|
-
return await
|
|
120
|
+
return await this.#owner.save(this, update);
|
|
182
121
|
}
|
|
183
|
-
|
|
184
122
|
async verifyPassword(password) {
|
|
185
123
|
log('verify-password : %o', this);
|
|
186
|
-
return
|
|
124
|
+
return bcrypt.compare(password, this.password);
|
|
187
125
|
}
|
|
188
|
-
|
|
189
126
|
toJSON() {
|
|
190
127
|
const {
|
|
191
128
|
org,
|
|
@@ -195,7 +132,10 @@ class User {
|
|
|
195
132
|
lastname,
|
|
196
133
|
role,
|
|
197
134
|
npi,
|
|
198
|
-
force_change_password
|
|
135
|
+
force_change_password,
|
|
136
|
+
emr_username,
|
|
137
|
+
userType,
|
|
138
|
+
migratedToIKC
|
|
199
139
|
} = this;
|
|
200
140
|
return {
|
|
201
141
|
org,
|
|
@@ -205,10 +145,10 @@ class User {
|
|
|
205
145
|
lastname,
|
|
206
146
|
role,
|
|
207
147
|
npi,
|
|
208
|
-
force_change_password
|
|
148
|
+
force_change_password,
|
|
149
|
+
emr_username,
|
|
150
|
+
userType,
|
|
151
|
+
migratedToIKC
|
|
209
152
|
};
|
|
210
153
|
}
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
exports.User = User;
|
|
154
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unidoc-health/user",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,16 +15,19 @@
|
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "ISC",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@
|
|
19
|
-
"bcrypt": "^
|
|
20
|
-
"debug": "^4.
|
|
21
|
-
"flat": "^5.0.
|
|
22
|
-
"lodash": "^4.
|
|
18
|
+
"@unidoc-health/role": "^2.0.2",
|
|
19
|
+
"bcrypt": "^6.0.0",
|
|
20
|
+
"debug": "^4.3.1",
|
|
21
|
+
"flat": "^5.0.2",
|
|
22
|
+
"lodash": "^4.18.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@babel/cli": "
|
|
26
|
-
"@babel/core": "
|
|
27
|
-
"@babel/plugin-
|
|
28
|
-
"@babel/preset-env": "
|
|
25
|
+
"@babel/cli": "8.0.4",
|
|
26
|
+
"@babel/core": "8.0.1",
|
|
27
|
+
"@babel/plugin-transform-object-rest-spread": "8.0.1",
|
|
28
|
+
"@babel/preset-env": "8.0.2"
|
|
29
|
+
},
|
|
30
|
+
"allowScripts": {
|
|
31
|
+
"bcrypt@6.0.0": true
|
|
29
32
|
}
|
|
30
33
|
}
|