@openmrs/esm-framework 10.0.1-pre.5141 → 10.0.1-pre.5147
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/.turbo/turbo-build.log +1 -1
- package/docs/functions/clearCurrentUser.md +1 -1
- package/docs/functions/getLocale.md +1 -1
- package/docs/functions/getLocaleDisplayName.md +37 -0
- package/docs/functions/getLoggedInUser.md +1 -1
- package/docs/functions/getSessionLocation.md +1 -1
- package/docs/functions/matchLocale.md +1 -1
- package/docs/functions/refetchCurrentUser.md +1 -1
- package/docs/functions/setSessionLocation.md +1 -1
- package/docs/functions/setUserProperties.md +1 -1
- package/docs/functions/toLanguageTag.md +44 -0
- package/docs/functions/userHasAccess.md +1 -1
- package/mock-jest.tsx +2 -0
- package/mock.tsx +2 -0
- package/package.json +20 -20
package/.turbo/turbo-build.log
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **clearCurrentUser**(): `void`
|
|
6
6
|
|
|
7
|
-
Defined in: [packages/framework/esm-api/src/current-user.ts:
|
|
7
|
+
Defined in: [packages/framework/esm-api/src/current-user.ts:234](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L234)
|
|
8
8
|
|
|
9
9
|
Clears the current user session from the session store, setting the session
|
|
10
10
|
to an unauthenticated state. This is typically called during logout to reset
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **getLocale**(): `string`
|
|
6
6
|
|
|
7
|
-
Defined in: [packages/framework/esm-utils/src/get-locale.ts:
|
|
7
|
+
Defined in: [packages/framework/esm-utils/src/get-locale.ts:7](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/get-locale.ts#L7)
|
|
8
8
|
|
|
9
9
|
Returns the current locale of the application.
|
|
10
10
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[O3 Framework](../API.md) / getLocaleDisplayName
|
|
2
|
+
|
|
3
|
+
# Function: getLocaleDisplayName()
|
|
4
|
+
|
|
5
|
+
> **getLocaleDisplayName**(`locale`): `string`
|
|
6
|
+
|
|
7
|
+
Defined in: [packages/framework/esm-utils/src/language-tag.ts:54](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/language-tag.ts#L54)
|
|
8
|
+
|
|
9
|
+
Returns the name of a locale as written in that locale, so `fr` becomes "français" and `sw_KE`
|
|
10
|
+
becomes "Kiswahili (Kenya)". Falls back to the identifier itself for anything `Intl` cannot
|
|
11
|
+
resolve, so the result is always safe to render.
|
|
12
|
+
|
|
13
|
+
The name is CLDR's middle-of-sentence form. When presenting it as a standalone label, capitalize
|
|
14
|
+
only the first character: lowercasing the remainder corrupts names carrying internal capitals,
|
|
15
|
+
turning "American English" into "American english".
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
### locale
|
|
20
|
+
|
|
21
|
+
An OpenMRS locale identifier, e.g. `sw_KE`.
|
|
22
|
+
|
|
23
|
+
`undefined` | `null` | `string`
|
|
24
|
+
|
|
25
|
+
## Returns
|
|
26
|
+
|
|
27
|
+
`string`
|
|
28
|
+
|
|
29
|
+
The locale's name in its own language, `locale` itself if it cannot be resolved, or an
|
|
30
|
+
empty string if no locale was given.
|
|
31
|
+
|
|
32
|
+
## Example
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
getLocaleDisplayName('fr'); // => 'français'
|
|
36
|
+
getLocaleDisplayName('sw_KE'); // => 'Kiswahili (Kenya)'
|
|
37
|
+
```
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **getLoggedInUser**(): `Promise`\<[`LoggedInUser`](../interfaces/LoggedInUser.md)\>
|
|
6
6
|
|
|
7
|
-
Defined in: [packages/framework/esm-api/src/current-user.ts:
|
|
7
|
+
Defined in: [packages/framework/esm-api/src/current-user.ts:291](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L291)
|
|
8
8
|
|
|
9
9
|
Returns a Promise that resolves with the currently logged-in user object.
|
|
10
10
|
If the user is already loaded in the session store, the Promise resolves immediately.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **getSessionLocation**(): `Promise`\<`undefined` \| [`SessionLocation`](../interfaces/SessionLocation.md)\>
|
|
6
6
|
|
|
7
|
-
Defined in: [packages/framework/esm-api/src/current-user.ts:
|
|
7
|
+
Defined in: [packages/framework/esm-api/src/current-user.ts:329](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L329)
|
|
8
8
|
|
|
9
9
|
Returns a Promise that resolves with the current session location, if one is set.
|
|
10
10
|
The session location represents the physical location where the user is currently
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **matchLocale**(`requested`, `available`, `fallback?`): `undefined` \| `string`
|
|
6
6
|
|
|
7
|
-
Defined in: [packages/framework/esm-utils/src/match-locale.ts:
|
|
7
|
+
Defined in: [packages/framework/esm-utils/src/match-locale.ts:35](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/match-locale.ts#L35)
|
|
8
8
|
|
|
9
9
|
Resolves a requested locale against a list of available locales using the
|
|
10
10
|
BCP 47 lookup algorithm (RFC 4647, §3.4).
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **refetchCurrentUser**(`username?`, `password?`): `Promise`\<[`SessionStore`](../type-aliases/SessionStore.md)\>
|
|
6
6
|
|
|
7
|
-
Defined in: [packages/framework/esm-api/src/current-user.ts:
|
|
7
|
+
Defined in: [packages/framework/esm-api/src/current-user.ts:208](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L208)
|
|
8
8
|
|
|
9
9
|
The `refetchCurrentUser` function causes a network request to redownload
|
|
10
10
|
the user. All subscribers to the current user will be notified of the
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **setSessionLocation**(`locationUuid`, `abortController`): `Promise`\<`any`\>
|
|
6
6
|
|
|
7
|
-
Defined in: [packages/framework/esm-api/src/current-user.ts:
|
|
7
|
+
Defined in: [packages/framework/esm-api/src/current-user.ts:355](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L355)
|
|
8
8
|
|
|
9
9
|
Sets the session location for the current user. The session location represents
|
|
10
10
|
the physical location where the user is working (e.g., a clinic or ward).
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **setUserProperties**(`userUuid`, `userProperties`, `abortController?`): `Promise`\<[`SessionStore`](../type-aliases/SessionStore.md)\>
|
|
6
6
|
|
|
7
|
-
Defined in: [packages/framework/esm-api/src/current-user.ts:
|
|
7
|
+
Defined in: [packages/framework/esm-api/src/current-user.ts:391](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L391)
|
|
8
8
|
|
|
9
9
|
Updates the user properties for a specific user. User properties are key-value
|
|
10
10
|
pairs that store user-specific settings and preferences. After updating the
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[O3 Framework](../API.md) / toLanguageTag
|
|
2
|
+
|
|
3
|
+
# Function: toLanguageTag()
|
|
4
|
+
|
|
5
|
+
> **toLanguageTag**(`locale`): `undefined` \| `string`
|
|
6
|
+
|
|
7
|
+
Defined in: [packages/framework/esm-utils/src/language-tag.ts:25](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-utils/src/language-tag.ts#L25)
|
|
8
|
+
|
|
9
|
+
Converts an OpenMRS locale identifier into a canonical BCP 47 language tag.
|
|
10
|
+
|
|
11
|
+
OpenMRS locale identifiers are not always language tags. User properties such as
|
|
12
|
+
`defaultLocale` store Java's `Locale#toString()` form (`en_US`, `sw_KE`) verbatim, some backends
|
|
13
|
+
serialize session locales the same way, and some installs configure POSIX-style variants
|
|
14
|
+
(`uz@Latn`). The `Intl` constructors throw `RangeError` rather than degrading when handed any of
|
|
15
|
+
them, so convert before passing an OpenMRS locale to `Intl`.
|
|
16
|
+
|
|
17
|
+
Both `_` and `@` are treated as subtag separators, which covers the `@Latn` script modifier.
|
|
18
|
+
Other POSIX modifiers have no BCP 47 equivalent and parse as whatever their length implies
|
|
19
|
+
(`de@euro` becomes the script subtag `de-Euro`), so they are converted rather than rejected.
|
|
20
|
+
|
|
21
|
+
## Parameters
|
|
22
|
+
|
|
23
|
+
### locale
|
|
24
|
+
|
|
25
|
+
An OpenMRS locale identifier, e.g. `sw_KE`. Locale data reaching this function
|
|
26
|
+
comes from the REST session and from configuration, so anything that is not a string is
|
|
27
|
+
treated as an unresolvable locale rather than an error.
|
|
28
|
+
|
|
29
|
+
`undefined` | `null` | `string`
|
|
30
|
+
|
|
31
|
+
## Returns
|
|
32
|
+
|
|
33
|
+
`undefined` \| `string`
|
|
34
|
+
|
|
35
|
+
The canonical language tag, or `undefined` if `locale` is not a structurally valid tag.
|
|
36
|
+
|
|
37
|
+
## Example
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
toLanguageTag('sw_KE'); // => 'sw-KE'
|
|
41
|
+
toLanguageTag('uz@Latn'); // => 'uz-Latn'
|
|
42
|
+
toLanguageTag('en_us'); // => 'en-US'
|
|
43
|
+
toLanguageTag('not a locale'); // => undefined
|
|
44
|
+
```
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **userHasAccess**(`requiredPrivilege`, `user`): `boolean`
|
|
6
6
|
|
|
7
|
-
Defined in: [packages/framework/esm-api/src/current-user.ts:
|
|
7
|
+
Defined in: [packages/framework/esm-api/src/current-user.ts:259](https://github.com/openmrs/openmrs-esm-core/blob/main/packages/framework/esm-api/src/current-user.ts#L259)
|
|
8
8
|
|
|
9
9
|
Checks whether the given user has access based on the required privilege(s).
|
|
10
10
|
A user has access if they have the required privilege(s) or if they are a
|
package/mock-jest.tsx
CHANGED
package/mock.tsx
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-framework",
|
|
3
|
-
"version": "10.0.1-pre.
|
|
3
|
+
"version": "10.0.1-pre.5147",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -59,24 +59,24 @@
|
|
|
59
59
|
"access": "public"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@openmrs/esm-api": "10.0.1-pre.
|
|
63
|
-
"@openmrs/esm-config": "10.0.1-pre.
|
|
64
|
-
"@openmrs/esm-context": "10.0.1-pre.
|
|
65
|
-
"@openmrs/esm-dynamic-loading": "10.0.1-pre.
|
|
66
|
-
"@openmrs/esm-emr-api": "10.0.1-pre.
|
|
67
|
-
"@openmrs/esm-error-handling": "10.0.1-pre.
|
|
68
|
-
"@openmrs/esm-expression-evaluator": "10.0.1-pre.
|
|
69
|
-
"@openmrs/esm-extensions": "10.0.1-pre.
|
|
70
|
-
"@openmrs/esm-feature-flags": "10.0.1-pre.
|
|
71
|
-
"@openmrs/esm-globals": "10.0.1-pre.
|
|
72
|
-
"@openmrs/esm-navigation": "10.0.1-pre.
|
|
73
|
-
"@openmrs/esm-offline": "10.0.1-pre.
|
|
74
|
-
"@openmrs/esm-react-utils": "10.0.1-pre.
|
|
75
|
-
"@openmrs/esm-routes": "10.0.1-pre.
|
|
76
|
-
"@openmrs/esm-state": "10.0.1-pre.
|
|
77
|
-
"@openmrs/esm-styleguide": "10.0.1-pre.
|
|
78
|
-
"@openmrs/esm-translations": "10.0.1-pre.
|
|
79
|
-
"@openmrs/esm-utils": "10.0.1-pre.
|
|
62
|
+
"@openmrs/esm-api": "10.0.1-pre.5147",
|
|
63
|
+
"@openmrs/esm-config": "10.0.1-pre.5147",
|
|
64
|
+
"@openmrs/esm-context": "10.0.1-pre.5147",
|
|
65
|
+
"@openmrs/esm-dynamic-loading": "10.0.1-pre.5147",
|
|
66
|
+
"@openmrs/esm-emr-api": "10.0.1-pre.5147",
|
|
67
|
+
"@openmrs/esm-error-handling": "10.0.1-pre.5147",
|
|
68
|
+
"@openmrs/esm-expression-evaluator": "10.0.1-pre.5147",
|
|
69
|
+
"@openmrs/esm-extensions": "10.0.1-pre.5147",
|
|
70
|
+
"@openmrs/esm-feature-flags": "10.0.1-pre.5147",
|
|
71
|
+
"@openmrs/esm-globals": "10.0.1-pre.5147",
|
|
72
|
+
"@openmrs/esm-navigation": "10.0.1-pre.5147",
|
|
73
|
+
"@openmrs/esm-offline": "10.0.1-pre.5147",
|
|
74
|
+
"@openmrs/esm-react-utils": "10.0.1-pre.5147",
|
|
75
|
+
"@openmrs/esm-routes": "10.0.1-pre.5147",
|
|
76
|
+
"@openmrs/esm-state": "10.0.1-pre.5147",
|
|
77
|
+
"@openmrs/esm-styleguide": "10.0.1-pre.5147",
|
|
78
|
+
"@openmrs/esm-translations": "10.0.1-pre.5147",
|
|
79
|
+
"@openmrs/esm-utils": "10.0.1-pre.5147"
|
|
80
80
|
},
|
|
81
81
|
"peerDependencies": {
|
|
82
82
|
"dayjs": "1.x",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"swr": "2.x"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
|
-
"@openmrs/typedoc-plugin-file-categories": "10.0.1-pre.
|
|
92
|
+
"@openmrs/typedoc-plugin-file-categories": "10.0.1-pre.5147",
|
|
93
93
|
"@swc/cli": "0.8.1",
|
|
94
94
|
"@swc/core": "1.15.21",
|
|
95
95
|
"@vitest/coverage-v8": "^4.1.2",
|