@healthcloudai/hc-settings-connector 0.0.1
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 +52 -0
- package/dist/index.cjs +70 -0
- package/dist/index.d.cts +44 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +40 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Healthcheck Settings Connector
|
|
2
|
+
|
|
3
|
+
This library provides a client for accessing user settings and profile-related data from the Healthcheck API.
|
|
4
|
+
It is built on top of the shared Healthcheck HTTP and Login connectors and can be used from TypeScript or JavaScript.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
1. Retrieve authenticated user information
|
|
9
|
+
2. Centralized access to user profile and settings data
|
|
10
|
+
3. Built on shared HttpClient and authentication layer
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
npm install @healthcloudai/hc-settings-connector \
|
|
15
|
+
@healthcloudai/hc-login-connector \
|
|
16
|
+
@healthcloudai/hc-http
|
|
17
|
+
|
|
18
|
+
## Import
|
|
19
|
+
|
|
20
|
+
import { HCSettingsClient } from "@healthcloudai/hc-settings-connector";
|
|
21
|
+
import { HCLoginClient } from "@healthcloudai/hc-login-connector";
|
|
22
|
+
import { HttpClient } from "@healthcloudai/hc-http";
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
### Configuration
|
|
27
|
+
|
|
28
|
+
import { HCSettingsClient } from "@healthcloudai/hc-settings-connector";
|
|
29
|
+
import { HCLoginClient } from "@healthcloudai/hc-login-connector";
|
|
30
|
+
import { HttpClient } from "@healthcloudai/hc-http";
|
|
31
|
+
|
|
32
|
+
const httpClient = new HttpClient();
|
|
33
|
+
const authClient = new HCLoginClient(/* auth configuration */);
|
|
34
|
+
|
|
35
|
+
const settingsClient = new HCSettingsClient(
|
|
36
|
+
httpClient,
|
|
37
|
+
authClient
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
### Get User Info
|
|
41
|
+
|
|
42
|
+
await settingsClient.getUserInfo();
|
|
43
|
+
|
|
44
|
+
## How It Works
|
|
45
|
+
|
|
46
|
+
- HCLoginClient handles authentication, base URL resolution, and authorization headers
|
|
47
|
+
- HttpClient performs all HTTP requests
|
|
48
|
+
- HCSettingsClient exposes user-related settings and profile APIs
|
|
49
|
+
- All requests automatically include authentication headers
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
AuthError: () => AuthError,
|
|
24
|
+
ConfigError: () => ConfigError,
|
|
25
|
+
HCSettingsClient: () => HCSettingsClient,
|
|
26
|
+
HttpError: () => HttpError
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(index_exports);
|
|
29
|
+
|
|
30
|
+
// src/client.ts
|
|
31
|
+
var HCSettingsClient = class {
|
|
32
|
+
constructor(httpClient, authClient) {
|
|
33
|
+
this.http = httpClient;
|
|
34
|
+
this.auth = authClient;
|
|
35
|
+
}
|
|
36
|
+
async getUserInfo() {
|
|
37
|
+
return this.http.get(
|
|
38
|
+
`${this.auth.getBaseUrl()}/user/info`,
|
|
39
|
+
this.auth.getAuthHeader()
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/errors.ts
|
|
45
|
+
var ConfigError = class extends Error {
|
|
46
|
+
constructor(message) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.name = "ConfigError";
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var AuthError = class extends Error {
|
|
52
|
+
constructor(message) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = "AuthError";
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var HttpError = class extends Error {
|
|
58
|
+
constructor(status, message) {
|
|
59
|
+
super(message);
|
|
60
|
+
this.name = "HttpError";
|
|
61
|
+
this.status = status;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
AuthError,
|
|
67
|
+
ConfigError,
|
|
68
|
+
HCSettingsClient,
|
|
69
|
+
HttpError
|
|
70
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { HCLoginClient } from '@healthcloudai/hc-login-connector';
|
|
2
|
+
import { HttpClient } from '@healthcloudai/hc-http';
|
|
3
|
+
|
|
4
|
+
type Environment = "dev" | "uat" | "prod";
|
|
5
|
+
interface HCLoginConfig {
|
|
6
|
+
tenantID: string;
|
|
7
|
+
environment: Environment;
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
}
|
|
10
|
+
interface AuthTokens {
|
|
11
|
+
accessToken: string;
|
|
12
|
+
refreshToken: string;
|
|
13
|
+
idToken: string;
|
|
14
|
+
expiresIn: number;
|
|
15
|
+
}
|
|
16
|
+
interface HCUserInfo {
|
|
17
|
+
ID?: string;
|
|
18
|
+
Email?: string;
|
|
19
|
+
TenantID?: string;
|
|
20
|
+
HasInsurance?: boolean;
|
|
21
|
+
HasIDCard?: boolean;
|
|
22
|
+
HasSelfie?: boolean;
|
|
23
|
+
Attributes?: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare class HCSettingsClient {
|
|
27
|
+
private http;
|
|
28
|
+
private auth;
|
|
29
|
+
constructor(httpClient: HttpClient, authClient: HCLoginClient);
|
|
30
|
+
getUserInfo(): Promise<HCUserInfo>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare class ConfigError extends Error {
|
|
34
|
+
constructor(message: string);
|
|
35
|
+
}
|
|
36
|
+
declare class AuthError extends Error {
|
|
37
|
+
constructor(message: string);
|
|
38
|
+
}
|
|
39
|
+
declare class HttpError extends Error {
|
|
40
|
+
status: number;
|
|
41
|
+
constructor(status: number, message: string);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { AuthError, type AuthTokens, ConfigError, type Environment, type HCLoginConfig, HCSettingsClient, type HCUserInfo, HttpError };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { HCLoginClient } from '@healthcloudai/hc-login-connector';
|
|
2
|
+
import { HttpClient } from '@healthcloudai/hc-http';
|
|
3
|
+
|
|
4
|
+
type Environment = "dev" | "uat" | "prod";
|
|
5
|
+
interface HCLoginConfig {
|
|
6
|
+
tenantID: string;
|
|
7
|
+
environment: Environment;
|
|
8
|
+
baseUrl: string;
|
|
9
|
+
}
|
|
10
|
+
interface AuthTokens {
|
|
11
|
+
accessToken: string;
|
|
12
|
+
refreshToken: string;
|
|
13
|
+
idToken: string;
|
|
14
|
+
expiresIn: number;
|
|
15
|
+
}
|
|
16
|
+
interface HCUserInfo {
|
|
17
|
+
ID?: string;
|
|
18
|
+
Email?: string;
|
|
19
|
+
TenantID?: string;
|
|
20
|
+
HasInsurance?: boolean;
|
|
21
|
+
HasIDCard?: boolean;
|
|
22
|
+
HasSelfie?: boolean;
|
|
23
|
+
Attributes?: Record<string, any>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare class HCSettingsClient {
|
|
27
|
+
private http;
|
|
28
|
+
private auth;
|
|
29
|
+
constructor(httpClient: HttpClient, authClient: HCLoginClient);
|
|
30
|
+
getUserInfo(): Promise<HCUserInfo>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
declare class ConfigError extends Error {
|
|
34
|
+
constructor(message: string);
|
|
35
|
+
}
|
|
36
|
+
declare class AuthError extends Error {
|
|
37
|
+
constructor(message: string);
|
|
38
|
+
}
|
|
39
|
+
declare class HttpError extends Error {
|
|
40
|
+
status: number;
|
|
41
|
+
constructor(status: number, message: string);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { AuthError, type AuthTokens, ConfigError, type Environment, type HCLoginConfig, HCSettingsClient, type HCUserInfo, HttpError };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// src/client.ts
|
|
2
|
+
var HCSettingsClient = class {
|
|
3
|
+
constructor(httpClient, authClient) {
|
|
4
|
+
this.http = httpClient;
|
|
5
|
+
this.auth = authClient;
|
|
6
|
+
}
|
|
7
|
+
async getUserInfo() {
|
|
8
|
+
return this.http.get(
|
|
9
|
+
`${this.auth.getBaseUrl()}/user/info`,
|
|
10
|
+
this.auth.getAuthHeader()
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/errors.ts
|
|
16
|
+
var ConfigError = class extends Error {
|
|
17
|
+
constructor(message) {
|
|
18
|
+
super(message);
|
|
19
|
+
this.name = "ConfigError";
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
var AuthError = class extends Error {
|
|
23
|
+
constructor(message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = "AuthError";
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
var HttpError = class extends Error {
|
|
29
|
+
constructor(status, message) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = "HttpError";
|
|
32
|
+
this.status = status;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
AuthError,
|
|
37
|
+
ConfigError,
|
|
38
|
+
HCSettingsClient,
|
|
39
|
+
HttpError
|
|
40
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@healthcloudai/hc-settings-connector",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Healthcheck Settings SDK with TypeScript",
|
|
5
|
+
"author": "Healthcheck Systems Inc",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"health-cloud",
|
|
9
|
+
"react-native",
|
|
10
|
+
"typescript",
|
|
11
|
+
"sdk",
|
|
12
|
+
"auth",
|
|
13
|
+
"fetch",
|
|
14
|
+
"axios"
|
|
15
|
+
],
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "dist/index.cjs.js",
|
|
18
|
+
"module": "dist/index.esm.js",
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"react-native": "dist/index.esm.js",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"import": "./dist/index.esm.js",
|
|
25
|
+
"require": "./dist/index.cjs.js"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
|
33
|
+
"dev": "tsup src/index.ts --watch",
|
|
34
|
+
"lint": "eslint src --ext .ts",
|
|
35
|
+
"prepublishOnly": "npm run build"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"axios": "^1.13.4",
|
|
39
|
+
"@healthcloudai/hc-login-connector": "^0.0.1",
|
|
40
|
+
"@healthcloudai/hc-http": "^0.0.1"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"react-native": ">=0.70.0"
|
|
44
|
+
},
|
|
45
|
+
"peerDependenciesMeta": {
|
|
46
|
+
"react-native": {
|
|
47
|
+
"optional": true
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/node": "^20.19.30",
|
|
52
|
+
"eslint": "^8.56.0",
|
|
53
|
+
"tsup": "^8.0.0",
|
|
54
|
+
"typescript": "^5.3.0"
|
|
55
|
+
},
|
|
56
|
+
"engines": {
|
|
57
|
+
"node": ">=18"
|
|
58
|
+
}
|
|
59
|
+
}
|