Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@openmrs/esm-api

Package Overview
Dependencies
Maintainers
7
Versions
1245
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@openmrs/esm-api - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

5

package.json
{
"name": "@openmrs/esm-api",
"version": "1.0.0",
"version": "1.0.1",
"description": "The javascript module for interacting with the OpenMRS API",
"main": "dist/openmrs-esm-api.js",
"types": "dist/openmrs-esm-api.d.ts",
"types": "src/openmrs-esm-api.ts",
"scripts": {

@@ -12,3 +12,2 @@ "test": "jest",

"typescript": "tsc",
"prepublishOnly": "tsc src/openmrs-esm-api.ts --jsx react --outFile dist/openmrs-esm-api.js --module system -d --moduleResolution node",
"prettier": "prettier src/**/* --write",

@@ -15,0 +14,0 @@ "lint": "eslint src --ext ts"

62

src/shared-api-objects/current-user.ts

@@ -1,15 +0,21 @@

import { BehaviorSubject } from "rxjs";
import { BehaviorSubject, Observable } from "rxjs";
import { openmrsObservableFetch, FetchResponse } from "../openmrs-fetch";
import { mergeAll, filter, map } from "rxjs/operators";
const userSubject = new BehaviorSubject(
openmrsObservableFetch("/ws/rest/v1/session")
const userSubject = new BehaviorSubject<Observable<LoggedInUserFetchResponse>>(
openmrsObservableFetch("/ws/rest/v1/session") as Observable<
LoggedInUserFetchResponse
>
);
export function getCurrentUser(opts: CurrentUserOptions = {}) {
export function getCurrentUser(
opts: CurrentUserOptions = {}
): Observable<LoggedInUser | UnauthenticatedUser> {
return userSubject.asObservable().pipe(
mergeAll(),
map((r: FetchResponse) => (opts.includeAuthStatus ? r.data : r.data.user)),
map((r: LoggedInUserFetchResponse) =>
opts.includeAuthStatus ? r.data : r.data.user
),
filter(Boolean)
);
) as Observable<LoggedInUser | UnauthenticatedUser>;
}

@@ -28,1 +34,45 @@

};
interface LoggedInUser {
uuid: string;
display: string;
username: string;
systemId: string;
userProperties: any;
person: Person;
privileges: Privilege[];
roles: Role[];
retired: boolean;
locale: string;
allowedLocales: string[];
[anythingElse: string]: any;
}
type UnauthenticatedUser = {
sessionId: string;
authenticated: boolean;
};
type Person = {
uuid: string;
display: string;
links: any[];
};
type Privilege = {
uuid: string;
display: string;
links: any[];
};
type Role = {
uuid: string;
display: string;
links: any[];
};
interface LoggedInUserFetchResponse extends FetchResponse {
data: UnauthenticatedUser & {
user?: LoggedInUser;
};
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc