oro-sdk-apis 1.8.2 → 1.8.5
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/LICENSE +21 -0
- package/dist/models/practice.d.ts +2 -0
- package/dist/oro-sdk-apis.cjs.development.js +40 -10
- package/dist/oro-sdk-apis.cjs.development.js.map +1 -1
- package/dist/oro-sdk-apis.cjs.production.min.js +1 -1
- package/dist/oro-sdk-apis.cjs.production.min.js.map +1 -1
- package/dist/oro-sdk-apis.esm.js +40 -10
- package/dist/oro-sdk-apis.esm.js.map +1 -1
- package/dist/services/guard.d.ts +3 -1
- package/package.json +58 -58
- package/src/models/practice.ts +2 -1
- package/src/services/guard.ts +16 -3
package/dist/services/guard.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export interface GuardRequestConfig extends AxiosAuthRefreshRequestConfig {
|
|
|
7
7
|
export declare class GuardService {
|
|
8
8
|
private api;
|
|
9
9
|
private baseURL;
|
|
10
|
+
private identityCache;
|
|
10
11
|
private whoAmICache;
|
|
11
12
|
constructor(api: APIService, baseURL: string);
|
|
12
13
|
/**
|
|
@@ -61,9 +62,10 @@ export declare class GuardService {
|
|
|
61
62
|
* without authentication
|
|
62
63
|
*
|
|
63
64
|
* @param identityID Unique id of the identity to retrieve
|
|
65
|
+
* @param skipCache (default: false) will skip identity cache (not even update it)
|
|
64
66
|
* @returns IdentityResponse
|
|
65
67
|
*/
|
|
66
|
-
identityGet(identityID: Uuid): Promise<IdentityResponse>;
|
|
68
|
+
identityGet(identityID: Uuid, skipCache?: boolean): Promise<IdentityResponse>;
|
|
67
69
|
/**
|
|
68
70
|
* Get information about the current authenticated user
|
|
69
71
|
*
|
package/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
2
|
+
"version": "1.8.5",
|
|
3
|
+
"main": "dist/index.js",
|
|
4
|
+
"typings": "dist/index.d.ts",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist",
|
|
7
|
+
"src"
|
|
8
|
+
],
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=10",
|
|
11
|
+
"npm": ">=6.14.13"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"link:watch": "npm link && tsdx watch",
|
|
15
|
+
"start": "tsdx watch",
|
|
16
|
+
"build": "tsdx build",
|
|
17
|
+
"test": "tsdx test",
|
|
18
|
+
"lint": "tsdx lint",
|
|
19
|
+
"prepare": "tsdx build",
|
|
20
|
+
"size": "size-limit",
|
|
21
|
+
"analyze": "size-limit --why",
|
|
22
|
+
"package": "tsdx build && npm publish"
|
|
23
|
+
},
|
|
24
|
+
"husky": {
|
|
25
|
+
"hooks": {
|
|
26
|
+
"pre-commit": "tsdx lint"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"name": "oro-sdk-apis",
|
|
30
|
+
"author": "Antoine Jaouën <antoine@orohealth.me>",
|
|
31
|
+
"module": "dist/oro-sdk-apis.esm.js",
|
|
32
|
+
"description": "This package is intended to be run in browser or Node.js environment. It contains all models and apis services.",
|
|
33
|
+
"size-limit": [
|
|
34
|
+
{
|
|
35
|
+
"path": "dist/oro-sdk-apis.cjs.production.min.js",
|
|
36
|
+
"limit": "10 KB"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "dist/oro-sdk-apis.esm.js",
|
|
40
|
+
"limit": "10 KB"
|
|
41
|
+
}
|
|
42
|
+
],
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@size-limit/preset-small-lib": "^4.10.2",
|
|
45
|
+
"@types/jest": "^27.4.1",
|
|
46
|
+
"@types/sha.js": "^2.4.0",
|
|
47
|
+
"@types/uuid": "^8.3.0",
|
|
48
|
+
"husky": "^6.0.0",
|
|
49
|
+
"prettier": "^2.5.1",
|
|
50
|
+
"prettier-plugin-svelte": "^2.3.0",
|
|
51
|
+
"size-limit": "^4.10.2",
|
|
52
|
+
"tsdx": "^0.14.1",
|
|
53
|
+
"tslib": "^2.2.0",
|
|
54
|
+
"typescript": "^4.2.4"
|
|
37
55
|
},
|
|
38
|
-
{
|
|
39
|
-
|
|
40
|
-
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"axios": "^0.21.4",
|
|
58
|
+
"axios-auth-refresh": "^3.2.1",
|
|
59
|
+
"buffer": "^6.0.3",
|
|
60
|
+
"hash.js": "^1.1.7"
|
|
41
61
|
}
|
|
42
|
-
],
|
|
43
|
-
"devDependencies": {
|
|
44
|
-
"@size-limit/preset-small-lib": "^4.10.2",
|
|
45
|
-
"@types/jest": "^27.4.1",
|
|
46
|
-
"@types/sha.js": "^2.4.0",
|
|
47
|
-
"@types/uuid": "^8.3.0",
|
|
48
|
-
"husky": "^6.0.0",
|
|
49
|
-
"prettier": "^2.5.1",
|
|
50
|
-
"prettier-plugin-svelte": "^2.3.0",
|
|
51
|
-
"size-limit": "^4.10.2",
|
|
52
|
-
"tsdx": "^0.14.1",
|
|
53
|
-
"tslib": "^2.2.0",
|
|
54
|
-
"typescript": "^4.2.4"
|
|
55
|
-
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"axios": "^0.21.4",
|
|
58
|
-
"axios-auth-refresh": "^3.2.1",
|
|
59
|
-
"buffer": "^6.0.3",
|
|
60
|
-
"hash.js": "^1.1.7"
|
|
61
|
-
}
|
|
62
62
|
}
|
package/src/models/practice.ts
CHANGED
|
@@ -158,7 +158,7 @@ export type PracticeConfigPracticeOnlinePharmacy = PracticeConfig<
|
|
|
158
158
|
onlinePharmacy?: {
|
|
159
159
|
name: string,
|
|
160
160
|
id: string,
|
|
161
|
-
phones: { countryCode: string, number: string, extension: string | null, type: string, isTollFree: boolean }[]
|
|
161
|
+
phones: { countryCode: string, number: string, extension: string | null, type: string, isTollFree: boolean, province?: string }[]
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
>
|
|
@@ -365,6 +365,7 @@ export interface HydratedPracticeConfigs {
|
|
|
365
365
|
[PracticeConfigKind.PracticeTheme]?: PracticeConfigPracticeTheme
|
|
366
366
|
[PracticeConfigKind.PracticeLocaleSwitcher]?: PracticeConfigPracticeLocaleSwitcher
|
|
367
367
|
[PracticeConfigKind.PracticeCookieBanner]?: PracticeConfigPracticeCookieBanner
|
|
368
|
+
[PracticeConfigKind.PracticePharmacyPicker]?: PracticeConfigPracticeOnlinePharmacy
|
|
368
369
|
}
|
|
369
370
|
|
|
370
371
|
export interface Practice {
|
package/src/services/guard.ts
CHANGED
|
@@ -28,10 +28,12 @@ export interface GuardRequestConfig extends AxiosAuthRefreshRequestConfig {
|
|
|
28
28
|
useRefreshToken: boolean
|
|
29
29
|
}
|
|
30
30
|
export class GuardService {
|
|
31
|
+
private identityCache: Record<string, IdentityResponse>
|
|
31
32
|
private whoAmICache: Record<string, WhoAmIResponse>
|
|
32
33
|
|
|
33
34
|
constructor(private api: APIService, private baseURL: string) {
|
|
34
35
|
this.api.setAuthRefreshFn(this.authRefresh.bind(this))
|
|
36
|
+
this.identityCache = {}
|
|
35
37
|
this.whoAmICache = {}
|
|
36
38
|
}
|
|
37
39
|
|
|
@@ -155,16 +157,27 @@ export class GuardService {
|
|
|
155
157
|
}
|
|
156
158
|
return resp
|
|
157
159
|
}
|
|
158
|
-
|
|
160
|
+
|
|
159
161
|
/**
|
|
160
162
|
* Retrieve an identity. Will return public fields only when requested
|
|
161
163
|
* without authentication
|
|
162
164
|
*
|
|
163
165
|
* @param identityID Unique id of the identity to retrieve
|
|
166
|
+
* @param skipCache (default: false) will skip identity cache (not even update it)
|
|
164
167
|
* @returns IdentityResponse
|
|
165
168
|
*/
|
|
166
|
-
public async identityGet(identityID: Uuid): Promise<IdentityResponse> {
|
|
167
|
-
|
|
169
|
+
public async identityGet(identityID: Uuid, skipCache = false): Promise<IdentityResponse> {
|
|
170
|
+
const tokens = this.api.getTokens()
|
|
171
|
+
const cacheKey = (tokens.accessToken ?? '') + (tokens.refreshToken ?? '') + identityID
|
|
172
|
+
|
|
173
|
+
if (skipCache || !tokens.accessToken || !this.identityCache[cacheKey]) {
|
|
174
|
+
const identity = await this.api.get<IdentityResponse>(`${this.baseURL}/v1/identities/${identityID}`)
|
|
175
|
+
|
|
176
|
+
if (skipCache) return identity
|
|
177
|
+
|
|
178
|
+
this.identityCache[cacheKey] = identity
|
|
179
|
+
}
|
|
180
|
+
return this.identityCache[cacheKey]
|
|
168
181
|
}
|
|
169
182
|
|
|
170
183
|
/**
|