@esushealth/sdk 0.0.0-stage → 1.0.0
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/README.md +149 -2
- package/dist/app-session.d.ts +225 -0
- package/dist/app-session.js +286 -0
- package/dist/clinical-workflows.d.ts +279 -0
- package/dist/clinical-workflows.js +43 -0
- package/dist/diagnostics.d.ts +24 -0
- package/dist/diagnostics.js +57 -0
- package/dist/fhir-contract.d.ts +12540 -0
- package/dist/fhir-contract.js +95 -0
- package/dist/fhir.d.ts +94 -0
- package/dist/fhir.js +174 -0
- package/dist/files.d.ts +13 -0
- package/dist/files.js +40 -0
- package/dist/integration-contract.d.ts +2327 -0
- package/dist/integration-contract.js +124 -0
- package/dist/integration-request.d.ts +11 -0
- package/dist/integration-request.js +19 -0
- package/dist/organization.d.ts +324 -0
- package/dist/organization.js +43 -0
- package/dist/patient-contract.d.ts +2 -0
- package/dist/patient-contract.js +1 -0
- package/dist/public.d.ts +125 -0
- package/dist/public.js +34 -0
- package/dist/server.d.ts +1310 -0
- package/dist/server.js +85 -0
- package/dist/smart.d.ts +42 -0
- package/dist/smart.js +98 -0
- package/dist/tenant-apps.d.ts +355 -0
- package/dist/tenant-apps.js +50 -0
- package/dist/transport.d.ts +38 -0
- package/dist/transport.js +120 -0
- package/dist/webhook-management.d.ts +53 -0
- package/dist/webhook-management.js +83 -0
- package/dist/webhooks.d.ts +24 -0
- package/dist/webhooks.js +41 -0
- package/package.json +17 -4
package/dist/public.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { queryPath } from "./fhir.js";
|
|
2
|
+
import { createTransport, EsusError, record } from "./transport.js";
|
|
3
|
+
export function createPublicClient(options) {
|
|
4
|
+
const request = createTransport({ url: options.url, fetch: options.fetch, timeoutMs: options.timeoutMs }, {});
|
|
5
|
+
async function get(path, { signal }, query) {
|
|
6
|
+
const { body, response } = await request(query ? queryPath(path, query) : path, {
|
|
7
|
+
signal, credentials: "omit", acceptStatus: path === "/health/ready" ? 503 : undefined,
|
|
8
|
+
});
|
|
9
|
+
const status = response.status;
|
|
10
|
+
if ((status !== 200 && status !== 503) || !record(body)) {
|
|
11
|
+
throw new EsusError("Esus returned an invalid public response", status, response.headers.get("x-request-id"));
|
|
12
|
+
}
|
|
13
|
+
return { status, body: body };
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
async planCatalog(options = {}) {
|
|
17
|
+
return (await get("/billing/catalog", options)).body;
|
|
18
|
+
},
|
|
19
|
+
health: {
|
|
20
|
+
async summary(options = {}) { return (await get("/health", options)).body; },
|
|
21
|
+
async live(options = {}) { return (await get("/health/live", options)).body; },
|
|
22
|
+
async ready(options = {}) {
|
|
23
|
+
const result = await get("/health/ready", options);
|
|
24
|
+
if (!record(result.body.checks) || typeof result.body.timestamp !== "string") {
|
|
25
|
+
throw new EsusError("Esus returned an invalid readiness response", result.status);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
},
|
|
29
|
+
async history(query, options = {}) {
|
|
30
|
+
return (await get("/health/history", options, query)).body;
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
}
|