@amedia/user 0.14.108 → 0.14.110
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/README.md +31 -3
- package/dist/user.d.ts +1 -1
- package/package.json +17 -18
package/README.md
CHANGED
|
@@ -65,7 +65,7 @@ NOTE2: If you need to know if the current user is an employee, you are encourage
|
|
|
65
65
|
|
|
66
66
|
#### Storage
|
|
67
67
|
|
|
68
|
-
Storage
|
|
68
|
+
Storage contains namespaces stored in Europa. A namespace is a named set of key value pairs stored for a specific user. An example could be favourite_teams, which could contain team_id as key and timestamp it was stored as favourite as value.
|
|
69
69
|
|
|
70
70
|
Storage is requested by calling `.withStorage(namespaces: Array<string>)` on a `UserDataRequest`. If a namespace does not exist it will be "created" in that you'll get an empty object back. Saving data to it will perform the actual creation.
|
|
71
71
|
|
|
@@ -161,11 +161,13 @@ The callback you supplied to subscribe is called whenever there are any changes
|
|
|
161
161
|
|
|
162
162
|
Also, your requested properties might not arrive all at once. This callback will be called whenever we get data in from the various services.
|
|
163
163
|
|
|
164
|
+
You should check the state object for potential emergency modes and act accordingly.
|
|
165
|
+
|
|
164
166
|
Should you wish to end your subscription, just call the returned function from subscribe.
|
|
165
167
|
|
|
166
168
|
#### Fetching all the data once (no re-renders)
|
|
167
169
|
|
|
168
|
-
In many use
|
|
170
|
+
In many use-cases, it's more convenient to just wait until everything is ready, so you don't have to handle multiple callbacks. In these cases, it's easier to call `.fetch()`. This method will return a `Promise` that resolves the same object you would get in the `subscribe` callback.
|
|
169
171
|
|
|
170
172
|
Full usage example:
|
|
171
173
|
|
|
@@ -217,11 +219,37 @@ new UserDataRequest()
|
|
|
217
219
|
|
|
218
220
|
This may also be lowered below the default, but network request do take some time, even on fast networks, so don't shoot your app in the foot by lowering it too much.
|
|
219
221
|
|
|
222
|
+
##### Emergency mode when using fetch
|
|
223
|
+
|
|
224
|
+
To avoid hanging on timeout, fetch rejects with `EmergencyModeError`, when a relevant emergency mode is active.
|
|
225
|
+
If you receive this error, there will be no user data available.
|
|
226
|
+
Your app should act accordingly, eg:
|
|
227
|
+
|
|
228
|
+
- Render non-personalized
|
|
229
|
+
- Show placeholder with an error message
|
|
230
|
+
- Not rendering at all
|
|
231
|
+
|
|
232
|
+
```ts
|
|
233
|
+
new UserDataRequest()
|
|
234
|
+
.withAttributes(['name'])
|
|
235
|
+
.withStorage(['my_namespace'])
|
|
236
|
+
.fetch()
|
|
237
|
+
.catch((e) => {
|
|
238
|
+
if (e instanceof FetchTimeoutError) {
|
|
239
|
+
console.log(e.partialData);
|
|
240
|
+
// Maybe you're able to render your app in a reduced state (using partialData).
|
|
241
|
+
} else if (e instanceOf EmergencyModeError) {
|
|
242
|
+
console.log(e.activeEmergencyModes);
|
|
243
|
+
// Maybe you're able to render your app in a non-personalized way?
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
```
|
|
247
|
+
|
|
220
248
|
## Actions
|
|
221
249
|
|
|
222
250
|
### `getLoginUrl({requestedUrl: string context: string}): string`
|
|
223
251
|
|
|
224
|
-
Builds and
|
|
252
|
+
Builds and return the aID login URL. See `goToLoginPage` for details
|
|
225
253
|
|
|
226
254
|
### `goToLoginPage({requestedUrl: string context: string}): void`
|
|
227
255
|
|
package/dist/user.d.ts
CHANGED
|
@@ -160,4 +160,4 @@ declare const aidUrls: {
|
|
|
160
160
|
sites: URL;
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
-
export { EmergencyModeError, FetchTimeoutError, PaywallError, PaywallUnlockRequest, PaywallUnlockResponse, PrivacyPreferences, SiteAccessRequest, SiteAccessResponse, State, UserAttributes, UserDataRequest, aidUrls, getLoginUrl, goToLoginPage, logout, requestDataRefresh, saveStorage, updateStorage };
|
|
163
|
+
export { EmergencyModeError, FetchTimeoutError, PaywallError, PaywallUnlockRequest, type PaywallUnlockResponse, type PrivacyPreferences, SiteAccessRequest, type SiteAccessResponse, type State, type UserAttributes, UserDataRequest, aidUrls, getLoginUrl, goToLoginPage, logout, requestDataRefresh, saveStorage, updateStorage };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amedia/user",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.110",
|
|
4
4
|
"description": "Client lib for working with aID user and associated data",
|
|
5
5
|
"repository": "https://github.com/amedia/amedia-user-js",
|
|
6
6
|
"author": "Amedia Utvikling (ID og data)",
|
|
@@ -46,30 +46,29 @@
|
|
|
46
46
|
"@amedia/browserid": "^1.0.17",
|
|
47
47
|
"@amedia/frontend-rpc": "^0.0.12",
|
|
48
48
|
"runtypes": "^6.7.0",
|
|
49
|
-
"ts-deepmerge": "^6.0
|
|
49
|
+
"ts-deepmerge": "^6.2.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@amedia/kragl": "^2.0.
|
|
52
|
+
"@amedia/kragl": "^2.0.1",
|
|
53
53
|
"@changesets/changelog-github": "^0.4.8",
|
|
54
|
-
"@changesets/cli": "^2.26.
|
|
55
|
-
"@eik/esbuild-plugin": "^1.1.
|
|
56
|
-
"@types/jest": "^29.5.
|
|
57
|
-
"@types/node": "^20.
|
|
58
|
-
"concurrently": "^8.2.
|
|
54
|
+
"@changesets/cli": "^2.26.2",
|
|
55
|
+
"@eik/esbuild-plugin": "^1.1.39",
|
|
56
|
+
"@types/jest": "^29.5.7",
|
|
57
|
+
"@types/node": "^20.8.7",
|
|
58
|
+
"concurrently": "^8.2.2",
|
|
59
59
|
"cors": "^2.8.5",
|
|
60
|
-
"esbuild": "0.
|
|
60
|
+
"esbuild": "0.19.5",
|
|
61
61
|
"express": "^4.18.2",
|
|
62
|
-
"jest": "^29.
|
|
63
|
-
"jest-environment-jsdom": "^29.
|
|
64
|
-
"jest-extended": "^4.0.
|
|
62
|
+
"jest": "^29.7.0",
|
|
63
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
64
|
+
"jest-extended": "^4.0.2",
|
|
65
65
|
"jest-fetch-mock": "^3.0.3",
|
|
66
66
|
"mockdate": "^3.0.5",
|
|
67
67
|
"npm-run-all": "^4.1.5",
|
|
68
|
-
"
|
|
69
|
-
"rollup": "
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"typescript": "^5.0.4"
|
|
68
|
+
"rollup": "3.29.4",
|
|
69
|
+
"rollup-plugin-dts": "6.1.0",
|
|
70
|
+
"ts-jest": "^29.1.1",
|
|
71
|
+
"tslib": "^2.6.2",
|
|
72
|
+
"typescript": "^5.2.2"
|
|
74
73
|
}
|
|
75
74
|
}
|