@oystehr/sdk 3.0.2 → 3.0.4
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/dist/cjs/client/client.d.ts +2 -1
- package/dist/cjs/index.cjs +70 -2
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/erx.d.ts +5 -1
- package/dist/cjs/resources/classes/z3-ext.d.ts +22 -0
- package/dist/cjs/resources/classes/z3.d.ts +15 -0
- package/dist/cjs/resources/types/ErxMedicationSearchV2Params.d.ts +4 -0
- package/dist/cjs/resources/types/ErxMedicationSearchV2Response.d.ts +38 -0
- package/dist/cjs/resources/types/Z3ListObjectsParams.d.ts +1 -0
- package/dist/cjs/resources/types/index.d.ts +2 -0
- package/dist/cjs/tests/setup/constants.d.ts +1 -1
- package/dist/esm/client/client.d.ts +2 -1
- package/dist/esm/client/client.js +1 -1
- package/dist/esm/client/client.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js +1 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/esm/resources/classes/erx.d.ts +5 -1
- package/dist/esm/resources/classes/erx.js +4 -0
- package/dist/esm/resources/classes/erx.js.map +1 -1
- package/dist/esm/resources/classes/fhir-ext.js +4 -1
- package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
- package/dist/esm/resources/classes/z3-ext.d.ts +22 -0
- package/dist/esm/resources/classes/z3-ext.js +49 -1
- package/dist/esm/resources/classes/z3-ext.js.map +1 -1
- package/dist/esm/resources/classes/z3.d.ts +15 -0
- package/dist/esm/resources/classes/z3.js +16 -1
- package/dist/esm/resources/classes/z3.js.map +1 -1
- package/dist/esm/resources/types/ErxMedicationSearchV2Params.d.ts +4 -0
- package/dist/esm/resources/types/ErxMedicationSearchV2Response.d.ts +38 -0
- package/dist/esm/resources/types/Z3ListObjectsParams.d.ts +1 -0
- package/dist/esm/resources/types/index.d.ts +2 -0
- package/dist/esm/tests/setup/constants.d.ts +1 -1
- package/package.json +1 -1
- package/src/client/client.ts +2 -2
- package/src/resources/classes/erx.ts +9 -0
- package/src/resources/classes/fhir-ext.ts +5 -2
- package/src/resources/classes/z3-ext.ts +48 -1
- package/src/resources/classes/z3.ts +15 -0
- package/src/resources/types/ErxMedicationSearchV2Params.ts +6 -0
- package/src/resources/types/ErxMedicationSearchV2Response.ts +40 -0
- package/src/resources/types/Z3ListObjectsParams.ts +1 -0
- package/src/resources/types/index.ts +2 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErxAllergySearchParams, ErxAllergySearchResponse, ErxMedicationSearchParams, ErxMedicationSearchResponse, ErxSyncPatientParams, ErxSyncPatientResponse, OystehrClientRequest } from '../..';
|
|
1
|
+
import { ErxAllergySearchParams, ErxAllergySearchResponse, ErxMedicationSearchParams, ErxMedicationSearchResponse, ErxMedicationSearchV2Params, ErxMedicationSearchV2Response, ErxSyncPatientParams, ErxSyncPatientResponse, OystehrClientRequest } from '../..';
|
|
2
2
|
import { SDKResource } from '../../client/client';
|
|
3
3
|
import { OystehrConfig } from '../../config';
|
|
4
4
|
export declare class Erx extends SDKResource {
|
|
@@ -15,4 +15,8 @@ export declare class Erx extends SDKResource {
|
|
|
15
15
|
* Search for medications. Provide at least one of code or name filters
|
|
16
16
|
*/
|
|
17
17
|
medicationSearch: (params: ErxMedicationSearchParams, request?: OystehrClientRequest) => Promise<ErxMedicationSearchResponse>;
|
|
18
|
+
/**
|
|
19
|
+
* Search for medications. Provide at least one of code or name filters
|
|
20
|
+
*/
|
|
21
|
+
medicationSearchV2: (params: ErxMedicationSearchV2Params, request?: OystehrClientRequest) => Promise<ErxMedicationSearchV2Response>;
|
|
18
22
|
}
|
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
import { SDKResource } from '../../client/client';
|
|
2
|
+
import { Z3GetPresignedUrlParams, Z3GetPresignedUrlResponse } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Uploads a file to the bucket and key. Files should be Blobs.
|
|
5
|
+
*
|
|
6
|
+
* @param params upload file params
|
|
7
|
+
*/
|
|
2
8
|
export declare function uploadFile(this: SDKResource, { bucketName, 'objectPath+': key, file, }: {
|
|
3
9
|
bucketName: string;
|
|
4
10
|
'objectPath+': string;
|
|
5
11
|
file: Blob;
|
|
6
12
|
}): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
|
|
15
|
+
*
|
|
16
|
+
* @param params download file params
|
|
17
|
+
*/
|
|
7
18
|
export declare function downloadFile(this: SDKResource, { bucketName, 'objectPath+': key, }: {
|
|
8
19
|
bucketName: string;
|
|
9
20
|
'objectPath+': string;
|
|
10
21
|
}): Promise<ArrayBuffer>;
|
|
22
|
+
/**
|
|
23
|
+
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
|
|
24
|
+
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` or `z3://<bucket>/<key>`
|
|
25
|
+
* instead of the standard SDK `Z3GetPresignedUrlParams`.
|
|
26
|
+
*
|
|
27
|
+
* @param params url and action
|
|
28
|
+
*/
|
|
29
|
+
export declare function getPresignedUrlForZ3Url(this: SDKResource, params: {
|
|
30
|
+
url: string;
|
|
31
|
+
action: Z3GetPresignedUrlParams['action'];
|
|
32
|
+
}): Promise<Z3GetPresignedUrlResponse>;
|
|
@@ -4,8 +4,23 @@ import { OystehrConfig } from '../../config';
|
|
|
4
4
|
import * as ext from './z3-ext';
|
|
5
5
|
export declare class Z3 extends SDKResource {
|
|
6
6
|
constructor(config: OystehrConfig);
|
|
7
|
+
/**
|
|
8
|
+
* Uploads a file to the bucket and key. Files should be Blobs.
|
|
9
|
+
* @param params upload file params
|
|
10
|
+
*/
|
|
7
11
|
uploadFile: typeof ext.uploadFile;
|
|
12
|
+
/**
|
|
13
|
+
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
|
|
14
|
+
* @param params download file params
|
|
15
|
+
*/
|
|
8
16
|
downloadFile: typeof ext.downloadFile;
|
|
17
|
+
/**
|
|
18
|
+
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
|
|
19
|
+
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` * or `z3://<bucket>/<key>`
|
|
20
|
+
* instead of the standard SDK `Z3GetPresignedUrlParams`.
|
|
21
|
+
* @param params url and action
|
|
22
|
+
*/
|
|
23
|
+
getPresignedUrlForZ3Url: typeof ext.getPresignedUrlForZ3Url;
|
|
9
24
|
/**
|
|
10
25
|
* List all Z3 Buckets. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
|
|
11
26
|
*
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Medications
|
|
3
|
+
*/
|
|
4
|
+
export interface ErxMedicationSearchV2Response {
|
|
5
|
+
medications?: {
|
|
6
|
+
/**
|
|
7
|
+
* Internal identifier for the medication.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Human readible name of medication.
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
codes: {
|
|
15
|
+
/**
|
|
16
|
+
* RxNorm Concept Unique (RxCUI) identifier of medication.
|
|
17
|
+
*/
|
|
18
|
+
rxcui?: string | null;
|
|
19
|
+
productNDC?: string | null;
|
|
20
|
+
packageNDC?: string | null;
|
|
21
|
+
SKU?: string | null;
|
|
22
|
+
HCPCS?: string | null;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Null implies a medication can not be prescribed
|
|
26
|
+
*/
|
|
27
|
+
type?: ('RX' | 'OTC') | null;
|
|
28
|
+
concept?: ('DRUG' | 'PRODUCT' | 'PACKAGE') | null;
|
|
29
|
+
schedule?: ('I' | 'II' | 'III' | 'IV' | 'V') | null;
|
|
30
|
+
controlled?: boolean | null;
|
|
31
|
+
brandName?: string | null;
|
|
32
|
+
genericName?: string | null;
|
|
33
|
+
strength?: string | null;
|
|
34
|
+
form?: string | null;
|
|
35
|
+
manufacturer?: string | null;
|
|
36
|
+
description?: string | null;
|
|
37
|
+
}[];
|
|
38
|
+
}
|
|
@@ -97,6 +97,8 @@ export * from './ErxAllergySearchParams';
|
|
|
97
97
|
export * from './ErxAllergySearchResponse';
|
|
98
98
|
export * from './ErxMedicationSearchParams';
|
|
99
99
|
export * from './ErxMedicationSearchResponse';
|
|
100
|
+
export * from './ErxMedicationSearchV2Params';
|
|
101
|
+
export * from './ErxMedicationSearchV2Response';
|
|
100
102
|
export * from './RoleListResponse';
|
|
101
103
|
export * from './RoleCreateParams';
|
|
102
104
|
export * from './RoleCreateResponse';
|
|
@@ -3,7 +3,7 @@ export declare const projectId = "eb1306aa-fba5-416a-a2a4-6b69eca58d87";
|
|
|
3
3
|
export declare const FHIR_API_URL = "http://localhost:3030/dev";
|
|
4
4
|
export declare const PLATFORM_API_URL = "http://localhost:3031/dev";
|
|
5
5
|
export declare const PROJECT_API_URL = "http://localhost:3032/dev";
|
|
6
|
-
export declare const FHIR_VERSION:
|
|
6
|
+
export declare const FHIR_VERSION: any;
|
|
7
7
|
export declare const config: {
|
|
8
8
|
accessToken: string;
|
|
9
9
|
projectId: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OystehrConfig } from '../config';
|
|
2
2
|
import { FhirBundle, FhirResource } from '../resources/types';
|
|
3
|
+
export declare const defaultProjectApiUrl = "https://project-api.zapehr.com/v1";
|
|
3
4
|
/**
|
|
4
5
|
* Optional parameter that can be passed to the client methods. It allows
|
|
5
6
|
* overriding the access token or project ID, and setting various headers,
|
|
@@ -29,7 +30,7 @@ interface InternalClientRequest extends OystehrClientRequest {
|
|
|
29
30
|
type FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>;
|
|
30
31
|
export type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;
|
|
31
32
|
export declare class SDKResource {
|
|
32
|
-
|
|
33
|
+
protected readonly config: OystehrConfig;
|
|
33
34
|
constructor(config: OystehrConfig);
|
|
34
35
|
protected request(path: string, method: string): FetcherFunction;
|
|
35
36
|
protected fhirRequest<T extends FhirResource = any>(path: string, method: string): (params: any, request?: InternalClientRequest) => Promise<FhirFetcherResponse<T>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sources":["../../../src/client/client.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport { OystehrConfig } from '../config';\nimport { OystehrFHIRError, OystehrSdkError } from '../errors';\nimport { FhirBundle, FhirResource, OperationOutcome } from '../resources/types';\n\ntype HttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';\nconst defaultProjectApiUrl = 'https://project-api.zapehr.com/v1';\nconst defaultFhirApiUrl = 'https://fhir-api.zapehr.com';\nconst STATUS_CODES_TO_RETRY = [408, 429, 500, 502, 503, 504];\nconst ERROR_CODES_TO_RETRY = [\n 'ECONNRESET',\n 'ECONNREFUSED',\n 'EPIPE',\n 'ETIMEDOUT',\n 'UND_ERR_CONNECT_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_SOCKET',\n];\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'.\n */\nexport interface OystehrClientRequest {\n /**\n * The access token to use for the request. If not provided, the access token from `oystehr.init()` will be used.\n */\n accessToken?: string;\n /**\n * The project ID to use for the request. If not provided, the project ID from `oystehr.init()` will be used.\n */\n projectId?: string;\n /**\n * The value of the 'Content-Type' header to use for the request.\n */\n contentType?: string;\n /**\n * Unique identifier for this request.\n */\n requestId?: string;\n}\n\ninterface InternalClientRequest extends OystehrClientRequest {\n ifMatch?: string;\n}\n\ntype FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>;\nexport type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;\n\nexport class SDKResource {\n private readonly config: OystehrConfig;\n constructor(config: OystehrConfig) {\n this.config = config;\n }\n\n protected request(path: string, method: string): FetcherFunction {\n return async (params: any, request?: InternalClientRequest): Promise<FetcherResponse> => {\n const baseUrlThunk = (): string => this.config.projectApiUrl ?? defaultProjectApiUrl;\n const configThunk = (): OystehrConfig => this.config;\n try {\n return await fetcher(baseUrlThunk, configThunk, path, method)(params, request);\n } catch (err: any) {\n const error = err as { message: string; code: number };\n throw new OystehrSdkError({ message: error.message, code: error.code });\n }\n };\n }\n\n protected fhirRequest<T extends FhirResource = any>(path: string, method: string) {\n return async (params: any, request?: InternalClientRequest): Promise<FhirFetcherResponse<T>> => {\n try {\n const baseUrlThunk = (): string => this.config.fhirApiUrl ?? defaultFhirApiUrl;\n const configThunk = (): OystehrConfig => this.config;\n // must await here to catch\n return await fetcher(baseUrlThunk, configThunk, path, method)(params, request);\n } catch (err: unknown) {\n // FHIR API error messages are JSON strings\n const fullError = err as { message: string | Record<string, any>; code: number };\n if (typeof fullError.message === 'string') {\n throw new OystehrSdkError({\n message: fullError.message,\n code: fullError.code,\n });\n }\n throw new OystehrFHIRError({\n error: fullError.message as OperationOutcome,\n code: fullError.code,\n });\n }\n };\n }\n}\n\nexport type FetcherError = { message: string; code: number };\nexport type FetcherResponse = any;\nexport type FetcherFunction = (\n params?: Record<string, any> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n) => Promise<FetcherResponse>;\n\nfunction isInternalClientRequest(request: Record<string, any>): request is InternalClientRequest {\n return 'accessToken' in request;\n}\n\nfunction fetcher(\n baseUrlThunk: () => string,\n configThunk: () => OystehrConfig,\n path: string,\n methodParam: string\n): FetcherFunction {\n return async (\n params?: Record<string, unknown> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n ): Promise<FetcherResponse> => {\n // this function supports multiple signatures. fetcher(baseUrl, path, method)(params, request) or fetcher(baseUrl, path, method)(request)\n // or fetcher(baseUrl, path, method)(params) or fetcher(baseUrl, path, method)(). the types for this are handled by Client<Path, Methods>\n // and this is the backend implementation behind it. the heuristic we're using is that if the first param is an object with an accessToken\n // and there is no second param, assume the first one is the request object instead\n const providedParams: Record<string, unknown> | [any] =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? {}\n : (params as Record<string, unknown>) ?? {};\n const requestCtx =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? (params as InternalClientRequest)\n : request;\n const method = methodParam.toLowerCase() as HttpMethod;\n const config = configThunk();\n const fetchImpl = config.fetch ?? fetch;\n const accessToken = requestCtx?.accessToken ?? config.accessToken;\n const projectId = requestCtx?.projectId ?? configThunk().projectId;\n let finalPath = path;\n let finalParams = providedParams;\n if (!Array.isArray(providedParams)) {\n const [subbedPath, addlParams] = subParamsInPath(path, providedParams);\n finalPath = subbedPath;\n finalParams = addlParams;\n }\n finalPath = finalPath.replace(/^\\//, ''); // remove leading slash\n const baseUrlEvaluated = baseUrlThunk();\n const fullBaseUrl = baseUrlEvaluated.endsWith('/') ? baseUrlEvaluated : baseUrlEvaluated + '/';\n const url = new URL(finalPath, fullBaseUrl);\n let body: any;\n\n if (Array.isArray(finalParams)) {\n body = JSON.stringify(finalParams);\n } else if (Object.keys(finalParams).length) {\n if (method === 'get') {\n addParamsToSearch(finalParams, url.searchParams);\n } else if (requestCtx?.contentType === 'application/x-www-form-urlencoded') {\n const search = new URLSearchParams();\n addParamsToSearch(finalParams, search);\n body = search.toString();\n } else {\n body = JSON.stringify(finalParams);\n }\n } else {\n // override for rpc call\n if (requestCtx?.contentType !== 'application/x-www-form-urlencoded' && method === 'post') {\n body = '{}';\n }\n }\n\n const headers: Record<string, string> = Object.assign(\n projectId\n ? {\n 'x-zapehr-project-id': projectId,\n 'x-oystehr-project-id': projectId,\n }\n : {},\n {\n 'content-type': requestCtx?.contentType ?? 'application/json',\n },\n accessToken ? { Authorization: `Bearer ${accessToken}` } : {},\n requestCtx?.ifMatch ? { 'If-Match': requestCtx.ifMatch } : {},\n { 'x-oystehr-request-id': requestCtx?.requestId ?? uuidv4() }\n );\n const retryConfig: ConstructedRetryConfig = {\n retries: config.retry?.retries ?? 3,\n onRetry: config.retry?.onRetry,\n // Using array instead of set because the length is too short for uniqueness to be important\n retryOn: [...(config.retry?.retryOn ?? []), ...STATUS_CODES_TO_RETRY],\n };\n retryConfig.retryOn.push(...STATUS_CODES_TO_RETRY);\n return retry(async (attempt) => {\n const response = await fetchImpl(\n new Request(url, {\n method: method.toUpperCase(),\n body,\n headers,\n })\n );\n const responseBody = response.body ? await response.text() : null;\n let responseJson: Record<string, unknown> | null;\n try {\n responseJson =\n responseBody &&\n (response.headers.get('content-type')?.includes('application/json') ||\n response.headers.get('content-type')?.includes('application/fhir+json'))\n ? JSON.parse(responseBody)\n : null;\n } catch (err) {\n // ignore JSON.parse errors\n responseJson = null;\n }\n const isError = !response.ok || response.status >= 400;\n if (isError) {\n headers['x-oystehr-fetch-attempts'] = `${attempt}`;\n const errObj = {\n message: responseJson?.message ?? responseJson ?? responseBody ?? response.statusText,\n code: responseJson?.code ?? response.status,\n response,\n };\n throw errObj;\n }\n return responseJson;\n }, retryConfig);\n };\n}\n\ntype ConstructedRetryConfig = Omit<NonNullable<OystehrConfig['retry']>, 'retryOn'> & {\n retryOn: NonNullable<NonNullable<OystehrConfig['retry']>['retryOn']>;\n};\nasync function retry<T>(work: (attempt: number) => Promise<T>, config: ConstructedRetryConfig): Promise<T> {\n let lastErr;\n for (const attempt of Array.from({ length: (config.retries ?? 0) + 1 }, (_, index) => index)) {\n try {\n return await work(attempt);\n } catch (e: any) {\n let isRetryable = false;\n if ('response' in e) {\n // error from API\n const err = e as FetcherError;\n isRetryable = config.retryOn.includes(err.code);\n // Removes response\n lastErr = { message: e.message, code: e.code };\n } else {\n lastErr = e;\n // error from fetch\n if ('code' in e && typeof e.code === 'string') {\n const err = e as { code: string };\n isRetryable = ERROR_CODES_TO_RETRY.includes(err.code);\n }\n }\n if (!isRetryable) {\n break;\n }\n if (config.onRetry && attempt !== (config.retries ?? 0)) {\n config.onRetry(attempt + 1);\n }\n }\n }\n throw lastErr;\n}\n\n/**\n * Substitutes params in a path and returns the path with params substituted and any unused params.\n *\n * Uses the property names in the params object to determine the param to substitute in the path.\n *\n * @param path JSON API resource URI\n * @param params all params provided to the client method\n * @returns resource URI with params substituted and any unused params\n */\nfunction subParamsInPath(path: string, params: Record<string, unknown>): [string, Record<string, string>] {\n const unusedParams = { ...params };\n // capture everything of the form `{paramName}` and replace with the value of `params[paramName]`\n const subbedPath = path.replace(/\\{([^}]+)\\}/g, (_, paramName) => {\n delete unusedParams[paramName];\n // override for path params that are paths, indicated by a `+` at the end\n if (paramName.match(/^.*\\+$/)) {\n return params[paramName] + '';\n }\n // error if param value is empty\n if (!params[paramName] || params[paramName] === '') {\n throw new OystehrSdkError({ message: `Required path parameter is an empty string: ${paramName}`, code: 400 });\n }\n // encode search params\n if (params[paramName]) {\n return encodeURIComponent(params[paramName] + ''); // coerce to string\n }\n return '';\n });\n\n const unusedKeys = Object.keys(unusedParams);\n const addlParams = unusedKeys.length\n ? unusedKeys.reduce((acc, key) => ({ ...acc, [key]: unusedParams[key] }), {})\n : {};\n return [subbedPath, addlParams];\n}\n\n/**\n * Adds params to a URLSearchParams object in such a way as to preserve array values.\n * @param params params\n * @param search URLSearchParams object\n */\nexport function addParamsToSearch(params: Record<string, unknown>, search: URLSearchParams): void {\n for (const [key, value] of Object.entries(params)) {\n if (Array.isArray(value)) {\n value.forEach((v) => search.append(key, v as string));\n continue;\n }\n search.append(key, value as string);\n }\n}\n"],"names":["uuidv4"],"mappings":";;;;AAMA,MAAM,oBAAoB,GAAG,mCAAmC,CAAC;AACjE,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AACxD,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;A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AAA,CAAG,EAAE,EAAE,CAAC;UAC3E,EAAE,CAAC;AACP,IAAA,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAClC,CAAC;AAED;;;;AAIG;AACa,SAAA,iBAAiB,CAAC,MAA+B,EAAE,MAAuB,EAAA;AACxF,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACjD,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,YAAA,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAW,CAAC,CAAC,CAAC;YACtD,SAAS;AACV,SAAA;AACD,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAe,CAAC,CAAC;AACrC,KAAA;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"client.js","sources":["../../../src/client/client.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport { OystehrConfig } from '../config';\nimport { OystehrFHIRError, OystehrSdkError } from '../errors';\nimport { FhirBundle, FhirResource, OperationOutcome } from '../resources/types';\n\ntype HttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';\nexport const defaultProjectApiUrl = 'https://project-api.zapehr.com/v1';\nconst defaultFhirApiUrl = 'https://fhir-api.zapehr.com';\nconst STATUS_CODES_TO_RETRY = [408, 429, 500, 502, 503, 504];\nconst ERROR_CODES_TO_RETRY = [\n 'ECONNRESET',\n 'ECONNREFUSED',\n 'EPIPE',\n 'ETIMEDOUT',\n 'UND_ERR_CONNECT_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_SOCKET',\n];\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'.\n */\nexport interface OystehrClientRequest {\n /**\n * The access token to use for the request. If not provided, the access token from `oystehr.init()` will be used.\n */\n accessToken?: string;\n /**\n * The project ID to use for the request. If not provided, the project ID from `oystehr.init()` will be used.\n */\n projectId?: string;\n /**\n * The value of the 'Content-Type' header to use for the request.\n */\n contentType?: string;\n /**\n * Unique identifier for this request.\n */\n requestId?: string;\n}\n\ninterface InternalClientRequest extends OystehrClientRequest {\n ifMatch?: string;\n}\n\ntype FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>;\nexport type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;\n\nexport class SDKResource {\n protected readonly config: OystehrConfig;\n constructor(config: OystehrConfig) {\n this.config = config;\n }\n\n protected request(path: string, method: string): FetcherFunction {\n return async (params: any, request?: InternalClientRequest): Promise<FetcherResponse> => {\n const baseUrlThunk = (): string => this.config.projectApiUrl ?? defaultProjectApiUrl;\n const configThunk = (): OystehrConfig => this.config;\n try {\n return await fetcher(baseUrlThunk, configThunk, path, method)(params, request);\n } catch (err: any) {\n const error = err as { message: string; code: number };\n throw new OystehrSdkError({ message: error.message, code: error.code });\n }\n };\n }\n\n protected fhirRequest<T extends FhirResource = any>(path: string, method: string) {\n return async (params: any, request?: InternalClientRequest): Promise<FhirFetcherResponse<T>> => {\n try {\n const baseUrlThunk = (): string => this.config.fhirApiUrl ?? defaultFhirApiUrl;\n const configThunk = (): OystehrConfig => this.config;\n // must await here to catch\n return await fetcher(baseUrlThunk, configThunk, path, method)(params, request);\n } catch (err: unknown) {\n // FHIR API error messages are JSON strings\n const fullError = err as { message: string | Record<string, any>; code: number };\n if (typeof fullError.message === 'string') {\n throw new OystehrSdkError({\n message: fullError.message,\n code: fullError.code,\n });\n }\n throw new OystehrFHIRError({\n error: fullError.message as OperationOutcome,\n code: fullError.code,\n });\n }\n };\n }\n}\n\nexport type FetcherError = { message: string; code: number };\nexport type FetcherResponse = any;\nexport type FetcherFunction = (\n params?: Record<string, any> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n) => Promise<FetcherResponse>;\n\nfunction isInternalClientRequest(request: Record<string, any>): request is InternalClientRequest {\n return 'accessToken' in request;\n}\n\nfunction fetcher(\n baseUrlThunk: () => string,\n configThunk: () => OystehrConfig,\n path: string,\n methodParam: string\n): FetcherFunction {\n return async (\n params?: Record<string, unknown> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n ): Promise<FetcherResponse> => {\n // this function supports multiple signatures. fetcher(baseUrl, path, method)(params, request) or fetcher(baseUrl, path, method)(request)\n // or fetcher(baseUrl, path, method)(params) or fetcher(baseUrl, path, method)(). the types for this are handled by Client<Path, Methods>\n // and this is the backend implementation behind it. the heuristic we're using is that if the first param is an object with an accessToken\n // and there is no second param, assume the first one is the request object instead\n const providedParams: Record<string, unknown> | [any] =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? {}\n : (params as Record<string, unknown>) ?? {};\n const requestCtx =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? (params as InternalClientRequest)\n : request;\n const method = methodParam.toLowerCase() as HttpMethod;\n const config = configThunk();\n const fetchImpl = config.fetch ?? fetch;\n const accessToken = requestCtx?.accessToken ?? config.accessToken;\n const projectId = requestCtx?.projectId ?? configThunk().projectId;\n let finalPath = path;\n let finalParams = providedParams;\n if (!Array.isArray(providedParams)) {\n const [subbedPath, addlParams] = subParamsInPath(path, providedParams);\n finalPath = subbedPath;\n finalParams = addlParams;\n }\n finalPath = finalPath.replace(/^\\//, ''); // remove leading slash\n const baseUrlEvaluated = baseUrlThunk();\n const fullBaseUrl = baseUrlEvaluated.endsWith('/') ? baseUrlEvaluated : baseUrlEvaluated + '/';\n const url = new URL(finalPath, fullBaseUrl);\n let body: any;\n\n if (Array.isArray(finalParams)) {\n body = JSON.stringify(finalParams);\n } else if (Object.keys(finalParams).length) {\n if (method === 'get') {\n addParamsToSearch(finalParams, url.searchParams);\n } else if (requestCtx?.contentType === 'application/x-www-form-urlencoded') {\n const search = new URLSearchParams();\n addParamsToSearch(finalParams, search);\n body = search.toString();\n } else {\n body = JSON.stringify(finalParams);\n }\n } else {\n // override for rpc call\n if (requestCtx?.contentType !== 'application/x-www-form-urlencoded' && method === 'post') {\n body = '{}';\n }\n }\n\n const headers: Record<string, string> = Object.assign(\n projectId\n ? {\n 'x-zapehr-project-id': projectId,\n 'x-oystehr-project-id': projectId,\n }\n : {},\n {\n 'content-type': requestCtx?.contentType ?? 'application/json',\n },\n accessToken ? { Authorization: `Bearer ${accessToken}` } : {},\n requestCtx?.ifMatch ? { 'If-Match': requestCtx.ifMatch } : {},\n { 'x-oystehr-request-id': requestCtx?.requestId ?? uuidv4() }\n );\n const retryConfig: ConstructedRetryConfig = {\n retries: config.retry?.retries ?? 3,\n onRetry: config.retry?.onRetry,\n // Using array instead of set because the length is too short for uniqueness to be important\n retryOn: [...(config.retry?.retryOn ?? []), ...STATUS_CODES_TO_RETRY],\n };\n retryConfig.retryOn.push(...STATUS_CODES_TO_RETRY);\n return retry(async (attempt) => {\n const response = await fetchImpl(\n new Request(url, {\n method: method.toUpperCase(),\n body,\n headers,\n })\n );\n const responseBody = response.body ? await response.text() : null;\n let responseJson: Record<string, unknown> | null;\n try {\n responseJson =\n responseBody &&\n (response.headers.get('content-type')?.includes('application/json') ||\n response.headers.get('content-type')?.includes('application/fhir+json'))\n ? JSON.parse(responseBody)\n : null;\n } catch (err) {\n // ignore JSON.parse errors\n responseJson = null;\n }\n const isError = !response.ok || response.status >= 400;\n if (isError) {\n headers['x-oystehr-fetch-attempts'] = `${attempt}`;\n const errObj = {\n message: responseJson?.message ?? responseJson ?? responseBody ?? response.statusText,\n code: responseJson?.code ?? response.status,\n response,\n };\n throw errObj;\n }\n return responseJson;\n }, retryConfig);\n };\n}\n\ntype ConstructedRetryConfig = Omit<NonNullable<OystehrConfig['retry']>, 'retryOn'> & {\n retryOn: NonNullable<NonNullable<OystehrConfig['retry']>['retryOn']>;\n};\nasync function retry<T>(work: (attempt: number) => Promise<T>, config: ConstructedRetryConfig): Promise<T> {\n let lastErr;\n for (const attempt of Array.from({ length: (config.retries ?? 0) + 1 }, (_, index) => index)) {\n try {\n return await work(attempt);\n } catch (e: any) {\n let isRetryable = false;\n if ('response' in e) {\n // error from API\n const err = e as FetcherError;\n isRetryable = config.retryOn.includes(err.code);\n // Removes response\n lastErr = { message: e.message, code: e.code };\n } else {\n lastErr = e;\n // error from fetch\n if ('code' in e && typeof e.code === 'string') {\n const err = e as { code: string };\n isRetryable = ERROR_CODES_TO_RETRY.includes(err.code);\n }\n }\n if (!isRetryable) {\n break;\n }\n if (config.onRetry && attempt !== (config.retries ?? 0)) {\n config.onRetry(attempt + 1);\n }\n }\n }\n throw lastErr;\n}\n\n/**\n * Substitutes params in a path and returns the path with params substituted and any unused params.\n *\n * Uses the property names in the params object to determine the param to substitute in the path.\n *\n * @param path JSON API resource URI\n * @param params all params provided to the client method\n * @returns resource URI with params substituted and any unused params\n */\nfunction subParamsInPath(path: string, params: Record<string, unknown>): [string, Record<string, string>] {\n const unusedParams = { ...params };\n // capture everything of the form `{paramName}` and replace with the value of `params[paramName]`\n const subbedPath = path.replace(/\\{([^}]+)\\}/g, (_, paramName) => {\n delete unusedParams[paramName];\n // override for path params that are paths, indicated by a `+` at the end\n if (paramName.match(/^.*\\+$/)) {\n return params[paramName] + '';\n }\n // error if param value is empty\n if (!params[paramName] || params[paramName] === '') {\n throw new OystehrSdkError({ message: `Required path parameter is an empty string: ${paramName}`, code: 400 });\n }\n // encode search params\n if (params[paramName]) {\n return encodeURIComponent(params[paramName] + ''); // coerce to string\n }\n return '';\n });\n\n const unusedKeys = Object.keys(unusedParams);\n const addlParams = unusedKeys.length\n ? unusedKeys.reduce((acc, key) => ({ ...acc, [key]: unusedParams[key] }), {})\n : {};\n return [subbedPath, addlParams];\n}\n\n/**\n * Adds params to a URLSearchParams object in such a way as to preserve array values.\n * @param params params\n * @param search URLSearchParams object\n */\nexport function addParamsToSearch(params: Record<string, unknown>, search: URLSearchParams): void {\n for (const [key, value] of Object.entries(params)) {\n if (Array.isArray(value)) {\n value.forEach((v) => search.append(key, v as string));\n continue;\n }\n search.append(key, value as string);\n }\n}\n"],"names":["uuidv4"],"mappings":";;;;AAMO,MAAM,oBAAoB,GAAG,oCAAoC;AACxE,MAAM,iBAAiB,GAAG,6BAA6B,CAAC;AACxD,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;AAC7D,MAAM,oBAAoB,GAAG;IAC3B,YAAY;IACZ,cAAc;IACd,OAAO;IACP,WAAW;IACX,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,gBAAgB;CACjB,CAAC;MAiCW,WAAW,CAAA;AAEtB,IAAA,WAAA,CAAY,MAAqB,EAAA;AAC/B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;KACtB;IAES,OAAO,CAAC,IAAY,EAAE,MAAc,EAAA;AAC5C,QAAA,OAAO,CAAO,MAAW,EAAE,OAA+B,KAA8B,SAAA,CAAA,IAAA,EAAA,KAAA,CAAA,EAAA,KAAA,CAAA,EAAA,aAAA;AACtF,YAAA,MAAM,YAAY,GAAG,MAAa,EAAA,IAAA,EAAA,CAAA,CAAC,OAAA,CAAA,EAAA,GAAA,IAAI,CAAC,MAAM,CAAC,aAAa,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,oBAAoB,CAAA,EAAA,CAAC;YACrF,MAAM,WAAW,GAAG,MAAqB,IAAI,CAAC,MAAM,CAAC;YACrD,IAAI;AACF,gBAAA,OAAO,MAAM,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAChF,aAAA;AAAC,YAAA,OAAO,GAAQ,EAAE;gBACjB,MAAM,KAAK,GAAG,GAAwC,CAAC;AACvD,gBAAA,MAAM,IAAI,eAAe,CAAC,EA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AAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;AAC7C,IAAA,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM;UAChC,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,MAAK,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAM,GAAG,CAAE,EAAA,EAAA,CAAC,GAAG,GAAG,YAAY,CAAC,GAAG,CAAC,EAAA,CAAA,CAAG,EAAE,EAAE,CAAC;UAC3E,EAAE,CAAC;AACP,IAAA,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;AAClC,CAAC;AAED;;;;AAIG;AACa,SAAA,iBAAiB,CAAC,MAA+B,EAAE,MAAuB,EAAA;AACxF,IAAA,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACjD,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,YAAA,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAW,CAAC,CAAC,CAAC;YACtD,SAAS;AACV,SAAA;AACD,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAe,CAAC,CAAC;AACrC,KAAA;AACH;;;;"}
|
package/dist/esm/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{v4 as e}from"uuid";class t extends Error{constructor({message:e,code:s}){super(e),Object.setPrototypeOf(this,t.prototype),this.code=s,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}}function s(e){var t;const s=[];for(const i of null!==(t=e.issue)&&void 0!==t?t:[])i.details&&i.details.text&&s.push(i.details.text);return s.length||s.push("Unknown FHIR error"),s.join(",")}class i extends t{constructor({error:e,code:t}){super({message:s(e),code:t}),Object.setPrototypeOf(this,i.prototype),this.cause=e,this.name="OystehrFHIRError"}}function r(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{u(i.next(e))}catch(e){n(e)}}function c(e){try{u(i.throw(e))}catch(e){n(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,c)}u((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const n=[408,429,500,502,503,504],o=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class c{constructor(e){this.config=e}request(e,s){return(i,n)=>r(this,void 0,void 0,(function*(){const r=()=>{var e;return null!==(e=this.config.projectApiUrl)&&void 0!==e?e:"https://project-api.zapehr.com/v1"},o=()=>this.config;try{return yield a(r,o,e,s)(i,n)}catch(e){const s=e;throw new t({message:s.message,code:s.code})}}))}fhirRequest(e,s){return(n,o)=>r(this,void 0,void 0,(function*(){try{const t=()=>{var e;return null!==(e=this.config.fhirApiUrl)&&void 0!==e?e:"https://fhir-api.zapehr.com"},i=()=>this.config;return yield a(t,i,e,s)(n,o)}catch(e){const s=e;if("string"==typeof s.message)throw new t({message:s.message,code:s.code});throw new i({error:s.message,code:s.code})}}))}}function u(e){return"accessToken"in e}function a(s,i,c,a){return(d,l)=>r(this,void 0,void 0,(function*(){var p,m,f,v,g,y,q,b,j,O,w;const x=d&&!l&&!Array.isArray(d)&&u(d)?{}:null!==(p=d)&&void 0!==p?p:{},E=d&&!l&&!Array.isArray(d)&&u(d)?d:l,T=a.toLowerCase(),S=i(),k=null!==(m=S.fetch)&&void 0!==m?m:fetch,R=null!==(f=null==E?void 0:E.accessToken)&&void 0!==f?f:S.accessToken,N=null!==(v=null==E?void 0:E.projectId)&&void 0!==v?v:i().projectId;let P=c,U=x;if(!Array.isArray(x)){const[e,s]=function(e,s){const i=Object.assign({},s),r=e.replace(/\{([^}]+)\}/g,((e,r)=>{if(delete i[r],r.match(/^.*\+$/))return s[r]+"";if(!s[r]||""===s[r])throw new t({message:`Required path parameter is an empty string: ${r}`,code:400});return s[r]?encodeURIComponent(s[r]+""):""})),n=Object.keys(i),o=n.length?n.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:i[t]})),{}):{};return[r,o]}(c,x);P=e,U=s}P=P.replace(/^\//,"");const z=s(),I=z.endsWith("/")?z:z+"/",$=new URL(P,I);let A;if(Array.isArray(U))A=JSON.stringify(U);else if(Object.keys(U).length)if("get"===T)h(U,$.searchParams);else if("application/x-www-form-urlencoded"===(null==E?void 0:E.contentType)){const e=new URLSearchParams;h(U,e),A=e.toString()}else A=JSON.stringify(U);else"application/x-www-form-urlencoded"!==(null==E?void 0:E.contentType)&&"post"===T&&(A="{}");const C=Object.assign(N?{"x-zapehr-project-id":N,"x-oystehr-project-id":N}:{},{"content-type":null!==(g=null==E?void 0:E.contentType)&&void 0!==g?g:"application/json"},R?{Authorization:`Bearer ${R}`}:{},(null==E?void 0:E.ifMatch)?{"If-Match":E.ifMatch}:{},{"x-oystehr-request-id":null!==(y=null==E?void 0:E.requestId)&&void 0!==y?y:e()}),_={retries:null!==(b=null===(q=S.retry)||void 0===q?void 0:q.retries)&&void 0!==b?b:3,onRetry:null===(j=S.retry)||void 0===j?void 0:j.onRetry,retryOn:[...null!==(w=null===(O=S.retry)||void 0===O?void 0:O.retryOn)&&void 0!==w?w:[],...n]};return _.retryOn.push(...n),function(e,t){var s,i;return r(this,void 0,void 0,(function*(){let r;for(const n of Array.from({length:(null!==(s=t.retries)&&void 0!==s?s:0)+1},((e,t)=>t)))try{return yield e(n)}catch(e){let s=!1;if("response"in e){const i=e;s=t.retryOn.includes(i.code),r={message:e.message,code:e.code}}else if(r=e,"code"in e&&"string"==typeof e.code){const t=e;s=o.includes(t.code)}if(!s)break;t.onRetry&&n!==(null!==(i=t.retries)&&void 0!==i?i:0)&&t.onRetry(n+1)}throw r}))}((e=>r(this,void 0,void 0,(function*(){var t,s,i,r,n,o;const c=yield k(new Request($,{method:T.toUpperCase(),body:A,headers:C})),u=c.body?yield c.text():null;let a;try{a=u&&((null===(t=c.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))||(null===(s=c.headers.get("content-type"))||void 0===s?void 0:s.includes("application/fhir+json")))?JSON.parse(u):null}catch(e){a=null}if(!c.ok||c.status>=400){C["x-oystehr-fetch-attempts"]=`${e}`;throw{message:null!==(n=null!==(r=null!==(i=null==a?void 0:a.message)&&void 0!==i?i:a)&&void 0!==r?r:u)&&void 0!==n?n:c.statusText,code:null!==(o=null==a?void 0:a.code)&&void 0!==o?o:c.status,response:c}}return a}))),_)}))}function h(e,t){for(const[s,i]of Object.entries(e))Array.isArray(i)?i.forEach((e=>t.append(s,e))):t.append(s,i)}class d extends c{constructor(e){super(e),this.list=e=>this.request("/application","get")(e),this.create=(e,t)=>this.request("/application","post")(e,t),this.get=(e,t)=>this.request("/application/{id}","get")(e,t),this.update=(e,t)=>this.request("/application/{id}","patch")(e,t),this.delete=(e,t)=>this.request("/application/{id}","delete")(e,t),this.rotateSecret=(e,t)=>this.request("/application/{id}/rotate-secret","post")(e,t),this.revokeRefreshToken=(e,t)=>this.request("/application/{id}/revoke-refresh-token","post")(e,t),this.revokeAccessToken=(e,t)=>this.request("/application/{id}/revoke-access-token","post")(e,t)}}class l extends c{constructor(e){super(e),this.issue=(e,t)=>this.request("/payment/charge/issue","post")(e,t),this.status=(e,t)=>this.request("/payment/charge/status","post")(e,t)}}const p="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",m="addressString";function f(e){var t,s,i;if(function(e){return Object.hasOwn(e,"virtualService")}(e)){const s=null===(t=e.virtualService)||void 0===t?void 0:t.find((e=>{var t;return"https://fhir.zapehr.com/virtual-service-type"===(null===(t=e.channelType)||void 0===t?void 0:t.system)}));return null==s?void 0:s.addressString}if(!e.extension)return;const r=e.extension.find((e=>e.url===p));if(!(null==r?void 0:r.extension))return;return null===(i=null===(s=r.extension)||void 0===s?void 0:s.find((e=>e.url===m)))||void 0===i?void 0:i.valueString}class v extends c{constructor(e){super(e),this.ENCOUNTER_VS_EXTENSION_URL=p,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=m,this.getConversationIdFromEncounter=f,this.create=(e,t)=>this.request("/messaging/conversation","post")(e,t),this.getToken=e=>this.request("/messaging/conversation/token","get")(e),this.addParticipant=(e,t)=>this.request("/messaging/conversation/{conversationId}/participant","post")(e,t),this.removeParticipant=(e,t)=>this.request("/messaging/conversation/{conversationId}/participant","delete")(e,t),this.message=(e,t)=>this.request("/messaging/conversation/{conversationId}/message","post")(e,t)}}class g extends c{constructor(e){super(e),this.get=(e,t)=>this.request("/developer/{id}","get")(e,t),this.update=(e,t)=>this.request("/developer/{id}","patch")(e,t),this.delete=(e,t)=>this.request("/developer/{id}","delete")(e,t),this.invite=(e,t)=>this.request("/developer/invite","post")(e,t),this.list=e=>this.request("/developer","get")(e),this.listV2=(e,t)=>this.request("/developer/v2/list","get")(e,t)}}class y extends c{constructor(e){super(e),this.syncPatient=(e,t)=>this.request("/erx/sync-patient/{patientId}","post")(e,t),this.allergySearch=(e,t)=>this.request("/erx/allergy/search","get")(e,t),this.medicationSearch=(e,t)=>this.request("/erx/medication/search","get")(e,t)}}function q(e,t){return r(this,void 0,void 0,(function*(){const{resourceType:s,params:i}=e;let r;i&&(r=Object.entries(i).reduce(((e,[t,s])=>(e[s.name]||(e[s.name]=[]),e[s.name].push(s.value),e)),{}));const n=yield this.fhirRequest(`/${s}/_search`,"POST")(r,Object.assign(Object.assign({},t),{contentType:"application/x-www-form-urlencoded"}));return Object.assign(Object.assign({},n),{entry:n.entry,unbundle:function(){var e,t;return null!==(t=null===(e=this.entry)||void 0===e?void 0:e.map((e=>e.resource)).filter((e=>void 0!==e)))&&void 0!==t?t:[]}})}))}function b(e,t){return r(this,void 0,void 0,(function*(){const{resourceType:s}=e;return this.fhirRequest(`/${s}`,"POST")(e,t)}))}function j({resourceType:e,id:t},s){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${e}/${t}`,"GET")({},s)}))}function O(e,t){return r(this,void 0,void 0,(function*(){const{id:s,resourceType:i}=e;return this.fhirRequest(`/${i}/${s}`,"PUT")(e,Object.assign(Object.assign({},t),{ifMatch:(null==t?void 0:t.optimisticLockingVersionId)?`W/"${t.optimisticLockingVersionId}"`:void 0}))}))}function w({resourceType:e,id:t,operations:s},i){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${e}/${t}`,"PATCH")(s,Object.assign(Object.assign({},i),{contentType:"application/json-patch+json",ifMatch:(null==i?void 0:i.optimisticLockingVersionId)?`W/"${i.optimisticLockingVersionId}"`:void 0}))}))}function x({resourceType:e,id:t},s){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${e}/${t}`,"DELETE")({},s)}))}function E({resourceType:e,id:t,versionId:s},i){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${e}/${t}/_history${s?`/${s}`:""}`,"GET")({},i)}))}function T(e){const{method:t,url:s}=e,i={request:{method:t,url:s}};if(s.split("?").length>1){const[e,t]=s.split("?"),r=t.split("&").map((e=>{const[t,s]=e.split("=");return{name:t,value:s}})).reduce(((e,{name:t,value:s})=>(e[t]=s,e)),{}),n=new URLSearchParams;h(r,n),i.request.url=`${e}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(t))return i;if("PUT"===t){const{resource:t}=e;return Object.assign(Object.assign({},i),{resource:t})}if("PATCH"===t)return"resource"in e?Object.assign(Object.assign({},i),{resource:e.resource}):Object.assign(Object.assign({},i),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:Buffer.from(JSON.stringify(e.operations),"utf8").toString("base64")}});if("POST"===t){const{resource:t,fullUrl:s}=e;return Object.assign(Object.assign({},i),{resource:t,fullUrl:s})}throw new Error("Unrecognized method")}function S(e){return function(t,s){return r(this,void 0,void 0,(function*(){return this.fhirRequest("/","POST")({resourceType:"Bundle",type:e,entry:t.requests.map(T)},s)}))}}const k=S("batch"),R=S("transaction");function N(e,t){const s=[];if(e.line&&s.push(...e.line),e.city||e.state||e.postalCode){const t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),s.push(t.join(", "))}return e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&s.push("["+e.use+"]"),s.join((null==t?void 0:t.lineSeparator)||", ").trim()}function P(e,t){const s=[];return e.prefix&&!1!==(null==t?void 0:t.prefix)&&s.push(...e.prefix),e.given&&s.push(...e.given),e.family&&s.push(e.family),e.suffix&&!1!==(null==t?void 0:t.suffix)&&s.push(...e.suffix),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&s.push("["+e.use+"]"),s.join(" ").trim()}class U extends c{constructor(e){super(e),this.search=q,this.create=b,this.get=j,this.update=O,this.patch=w,this.delete=x,this.history=E,this.batch=k,this.transaction=R,this.formatAddress=N,this.formatHumanName=P}}class z extends c{constructor(e){super(e),this.list=e=>this.request("/m2m","get")(e),this.create=(e,t)=>this.request("/m2m","post")(e,t),this.get=(e,t)=>this.request("/m2m/{id}","get")(e,t),this.update=(e,t)=>this.request("/m2m/{id}","patch")(e,t),this.delete=(e,t)=>this.request("/m2m/{id}","delete")(e,t),this.rotateSecret=(e,t)=>this.request("/m2m/{id}/rotate-secret","post")(e,t),this.listV2=(e,t)=>this.request("/m2m/v2/list","get")(e,t)}}class I extends c{constructor(e){super(e),this.getMessagingConfig=e=>this.request("/messaging/config","get")(e)}}class $ extends c{constructor(e){super(e),this.setUp=(e,t)=>this.request("/payment/payment-method/setup","post")(e,t),this.setDefault=(e,t)=>this.request("/payment/payment-method/set-default","post")(e,t),this.delete=(e,t)=>this.request("/payment/payment-method","delete")(e,t),this.list=(e,t)=>this.request("/payment/payment-method/list","post")(e,t)}}class A extends c{constructor(e){super(e),this.get=e=>this.request("/project","get")(e),this.update=(e,t)=>this.request("/project","patch")(e,t)}}class C extends c{constructor(e){super(e),this.eligibilityCheck=(e,t)=>this.request("/rcm/eligibility-check","post")(e,t),this.validateProfessionalClaim=(e,t)=>this.request("/rcm/professional-claim/validate","post")(e,t),this.submitProfessionalClaim=(e,t)=>this.request("/rcm/professional-claim/submit","post")(e,t)}}class _ extends c{constructor(e){super(e),this.list=e=>this.request("/iam/role","get")(e),this.create=(e,t)=>this.request("/iam/role","post")(e,t),this.get=(e,t)=>this.request("/iam/role/{roleId}","get")(e,t),this.update=(e,t)=>this.request("/iam/role/{roleId}","patch")(e,t),this.delete=(e,t)=>this.request("/iam/role/{roleId}","delete")(e,t)}}class L extends c{constructor(e){super(e),this.list=e=>this.request("/secret","get")(e),this.set=(e,t)=>this.request("/secret","post")(e,t),this.get=(e,t)=>this.request("/secret/{name}","get")(e,t),this.delete=(e,t)=>this.request("/secret/{name}","delete")(e,t)}}class M extends c{constructor(e){super(e),this.createMeeting=(e,t)=>this.request("/telemed/v2/meeting","post")(e,t),this.joinMeeting=(e,t)=>this.request("/telemed/v2/meeting/{encounterId}/join","get")(e,t)}}class D extends c{constructor(e){super(e),this.send=(e,t)=>this.request("/messaging/transactional-sms/send","post")(e,t)}}class V extends c{constructor(e){super(e),this.me=e=>this.request("/user/me","get")(e),this.get=(e,t)=>this.request("/user/{id}","get")(e,t),this.update=(e,t)=>this.request("/user/{id}","patch")(e,t),this.delete=(e,t)=>this.request("/user/{id}","delete")(e,t),this.invite=(e,t)=>this.request("/user/invite","post")(e,t),this.list=e=>this.request("/user","get")(e),this.listV2=(e,t)=>this.request("/user/v2/list","get")(e,t)}}class F extends c{constructor(e){super(e),this.get=e=>this.request("/version","get")(e)}}function H({bucketName:e,"objectPath+":t,file:s}){return r(this,void 0,void 0,(function*(){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post")({action:"upload",bucketName:e,"objectPath+":t});yield fetch(i.signedUrl,{method:"PUT",body:s})}))}function B({bucketName:e,"objectPath+":t}){return r(this,void 0,void 0,(function*(){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post")({action:"download",bucketName:e,"objectPath+":t}),i=yield fetch(s.signedUrl,{method:"GET"});if(!i.ok)throw new Error("Failed to download file");return i.arrayBuffer()}))}class G extends c{constructor(e){super(e),this.uploadFile=H,this.downloadFile=B,this.listBuckets=e=>this.request("/z3","get")(e),this.createBucket=(e,t)=>this.request("/z3/{bucketName}","put")(e,t),this.deleteBucket=(e,t)=>this.request("/z3/{bucketName}","delete")(e,t),this.listObjects=(e,t)=>this.request("/z3/{bucketName}/{objectPath+}","get")(e,t),this.getPresignedUrl=(e,t)=>this.request("/z3/{bucketName}/{objectPath+}","post")(e,t),this.deleteObject=(e,t)=>this.request("/z3/{bucketName}/{objectPath+}","delete")(e,t)}}function J({id:e,file:t,filename:s}){return r(this,void 0,void 0,(function*(){const i=yield this.request("/zambda/{id}/s3-upload","post")({id:e,filename:s});yield fetch(i.signedUrl,{method:"PUT",body:t})}))}class W extends c{constructor(e){super(e),this.uploadFile=J,this.list=e=>this.request("/zambda","get")(e),this.create=(e,t)=>this.request("/zambda","post")(e,t),this.get=(e,t)=>this.request("/zambda/{id}","get")(e,t),this.update=(e,t)=>this.request("/zambda/{id}","patch")(e,t),this.delete=(e,t)=>this.request("/zambda/{id}","delete")(e,t),this.execute=(e,t)=>this.request("/zambda/{id}/execute","post")(e,t),this.executePublic=(e,t)=>this.request("/zambda/{id}/execute-public","post")(e,t),this.s3Upload=(e,t)=>this.request("/zambda/{id}/s3-upload","post")(e,t)}}class X extends c{constructor(e){super(e),this.list=(e,t)=>this.request("/zambda/{id}/logStream","post")(e,t),this.search=(e,t)=>this.request("/zambda/{id}/logStream/search","post")(e,t),this.get=(e,t)=>this.request("/zambda/{id}/logStream/{logStreamName}","post")(e,t)}}let K=class{constructor(e){this.config=e,this.application=new d(e),this.developer=new g(e),this.m2m=new z(e),this.messaging=new I(e),this.conversation=new v(e),this.transactionalSMS=new D(e),this.paymentMethod=new $(e),this.charge=new l(e),this.project=new A(e),this.rcm=new C(e),this.erx=new y(e),this.role=new _(e),this.secret=new L(e),this.telemed=new M(e),this.user=new V(e),this.version=new F(e),this.z3=new G(e),this.zambda=new W(e),this.zambdaLogStream=new X(e),this.fhir=new U(e)}};class Q extends K{}Q.OystehrFHIRError=i,Q.OystehrSdkError=t;export{Q as default};
|
|
1
|
+
import{v4 as e}from"uuid";class t extends Error{constructor({message:e,code:s}){super(e),Object.setPrototypeOf(this,t.prototype),this.code=s,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}}function s(e){var t;const s=[];for(const i of null!==(t=e.issue)&&void 0!==t?t:[])i.details&&i.details.text&&s.push(i.details.text);return s.length||s.push("Unknown FHIR error"),s.join(",")}class i extends t{constructor({error:e,code:t}){super({message:s(e),code:t}),Object.setPrototypeOf(this,i.prototype),this.cause=e,this.name="OystehrFHIRError"}}function r(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{u(i.next(e))}catch(e){n(e)}}function c(e){try{u(i.throw(e))}catch(e){n(e)}}function u(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,c)}u((i=i.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;const n="https://project-api.zapehr.com/v1",o=[408,429,500,502,503,504],c=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class u{constructor(e){this.config=e}request(e,s){return(i,o)=>r(this,void 0,void 0,(function*(){const r=()=>{var e;return null!==(e=this.config.projectApiUrl)&&void 0!==e?e:n},c=()=>this.config;try{return yield h(r,c,e,s)(i,o)}catch(e){const s=e;throw new t({message:s.message,code:s.code})}}))}fhirRequest(e,s){return(n,o)=>r(this,void 0,void 0,(function*(){try{const t=()=>{var e;return null!==(e=this.config.fhirApiUrl)&&void 0!==e?e:"https://fhir-api.zapehr.com"},i=()=>this.config;return yield h(t,i,e,s)(n,o)}catch(e){const s=e;if("string"==typeof s.message)throw new t({message:s.message,code:s.code});throw new i({error:s.message,code:s.code})}}))}}function a(e){return"accessToken"in e}function h(s,i,n,u){return(h,d)=>r(this,void 0,void 0,(function*(){var p,m,f,v,g,y,q,b,j,O,w;const x=h&&!d&&!Array.isArray(h)&&a(h)?{}:null!==(p=h)&&void 0!==p?p:{},E=h&&!d&&!Array.isArray(h)&&a(h)?h:d,T=u.toLowerCase(),S=i(),k=null!==(m=S.fetch)&&void 0!==m?m:fetch,R=null!==(f=null==E?void 0:E.accessToken)&&void 0!==f?f:S.accessToken,U=null!==(v=null==E?void 0:E.projectId)&&void 0!==v?v:i().projectId;let N=n,P=x;if(!Array.isArray(x)){const[e,s]=function(e,s){const i=Object.assign({},s),r=e.replace(/\{([^}]+)\}/g,((e,r)=>{if(delete i[r],r.match(/^.*\+$/))return s[r]+"";if(!s[r]||""===s[r])throw new t({message:`Required path parameter is an empty string: ${r}`,code:400});return s[r]?encodeURIComponent(s[r]+""):""})),n=Object.keys(i),o=n.length?n.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:i[t]})),{}):{};return[r,o]}(n,x);N=e,P=s}N=N.replace(/^\//,"");const z=s(),I=z.endsWith("/")?z:z+"/",$=new URL(N,I);let A;if(Array.isArray(P))A=JSON.stringify(P);else if(Object.keys(P).length)if("get"===T)l(P,$.searchParams);else if("application/x-www-form-urlencoded"===(null==E?void 0:E.contentType)){const e=new URLSearchParams;l(P,e),A=e.toString()}else A=JSON.stringify(P);else"application/x-www-form-urlencoded"!==(null==E?void 0:E.contentType)&&"post"===T&&(A="{}");const C=Object.assign(U?{"x-zapehr-project-id":U,"x-oystehr-project-id":U}:{},{"content-type":null!==(g=null==E?void 0:E.contentType)&&void 0!==g?g:"application/json"},R?{Authorization:`Bearer ${R}`}:{},(null==E?void 0:E.ifMatch)?{"If-Match":E.ifMatch}:{},{"x-oystehr-request-id":null!==(y=null==E?void 0:E.requestId)&&void 0!==y?y:e()}),_={retries:null!==(b=null===(q=S.retry)||void 0===q?void 0:q.retries)&&void 0!==b?b:3,onRetry:null===(j=S.retry)||void 0===j?void 0:j.onRetry,retryOn:[...null!==(w=null===(O=S.retry)||void 0===O?void 0:O.retryOn)&&void 0!==w?w:[],...o]};return _.retryOn.push(...o),function(e,t){var s,i;return r(this,void 0,void 0,(function*(){let r;for(const n of Array.from({length:(null!==(s=t.retries)&&void 0!==s?s:0)+1},((e,t)=>t)))try{return yield e(n)}catch(e){let s=!1;if("response"in e){const i=e;s=t.retryOn.includes(i.code),r={message:e.message,code:e.code}}else if(r=e,"code"in e&&"string"==typeof e.code){const t=e;s=c.includes(t.code)}if(!s)break;t.onRetry&&n!==(null!==(i=t.retries)&&void 0!==i?i:0)&&t.onRetry(n+1)}throw r}))}((e=>r(this,void 0,void 0,(function*(){var t,s,i,r,n,o;const c=yield k(new Request($,{method:T.toUpperCase(),body:A,headers:C})),u=c.body?yield c.text():null;let a;try{a=u&&((null===(t=c.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))||(null===(s=c.headers.get("content-type"))||void 0===s?void 0:s.includes("application/fhir+json")))?JSON.parse(u):null}catch(e){a=null}if(!c.ok||c.status>=400){C["x-oystehr-fetch-attempts"]=`${e}`;throw{message:null!==(n=null!==(r=null!==(i=null==a?void 0:a.message)&&void 0!==i?i:a)&&void 0!==r?r:u)&&void 0!==n?n:c.statusText,code:null!==(o=null==a?void 0:a.code)&&void 0!==o?o:c.status,response:c}}return a}))),_)}))}function l(e,t){for(const[s,i]of Object.entries(e))Array.isArray(i)?i.forEach((e=>t.append(s,e))):t.append(s,i)}class d extends u{constructor(e){super(e),this.list=e=>this.request("/application","get")(e),this.create=(e,t)=>this.request("/application","post")(e,t),this.get=(e,t)=>this.request("/application/{id}","get")(e,t),this.update=(e,t)=>this.request("/application/{id}","patch")(e,t),this.delete=(e,t)=>this.request("/application/{id}","delete")(e,t),this.rotateSecret=(e,t)=>this.request("/application/{id}/rotate-secret","post")(e,t),this.revokeRefreshToken=(e,t)=>this.request("/application/{id}/revoke-refresh-token","post")(e,t),this.revokeAccessToken=(e,t)=>this.request("/application/{id}/revoke-access-token","post")(e,t)}}class p extends u{constructor(e){super(e),this.issue=(e,t)=>this.request("/payment/charge/issue","post")(e,t),this.status=(e,t)=>this.request("/payment/charge/status","post")(e,t)}}const m="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",f="addressString";function v(e){var t,s,i;if(function(e){return Object.hasOwn(e,"virtualService")}(e)){const s=null===(t=e.virtualService)||void 0===t?void 0:t.find((e=>{var t;return"https://fhir.zapehr.com/virtual-service-type"===(null===(t=e.channelType)||void 0===t?void 0:t.system)}));return null==s?void 0:s.addressString}if(!e.extension)return;const r=e.extension.find((e=>e.url===m));if(!(null==r?void 0:r.extension))return;return null===(i=null===(s=r.extension)||void 0===s?void 0:s.find((e=>e.url===f)))||void 0===i?void 0:i.valueString}class g extends u{constructor(e){super(e),this.ENCOUNTER_VS_EXTENSION_URL=m,this.ENCOUNTER_VS_EXTENSION_RELATIVE_URL=f,this.getConversationIdFromEncounter=v,this.create=(e,t)=>this.request("/messaging/conversation","post")(e,t),this.getToken=e=>this.request("/messaging/conversation/token","get")(e),this.addParticipant=(e,t)=>this.request("/messaging/conversation/{conversationId}/participant","post")(e,t),this.removeParticipant=(e,t)=>this.request("/messaging/conversation/{conversationId}/participant","delete")(e,t),this.message=(e,t)=>this.request("/messaging/conversation/{conversationId}/message","post")(e,t)}}class y extends u{constructor(e){super(e),this.get=(e,t)=>this.request("/developer/{id}","get")(e,t),this.update=(e,t)=>this.request("/developer/{id}","patch")(e,t),this.delete=(e,t)=>this.request("/developer/{id}","delete")(e,t),this.invite=(e,t)=>this.request("/developer/invite","post")(e,t),this.list=e=>this.request("/developer","get")(e),this.listV2=(e,t)=>this.request("/developer/v2/list","get")(e,t)}}class q extends u{constructor(e){super(e),this.syncPatient=(e,t)=>this.request("/erx/sync-patient/{patientId}","post")(e,t),this.allergySearch=(e,t)=>this.request("/erx/allergy/search","get")(e,t),this.medicationSearch=(e,t)=>this.request("/erx/medication/search","get")(e,t),this.medicationSearchV2=(e,t)=>this.request("/erx/v2/medication/search","get")(e,t)}}function b(e,t){return r(this,void 0,void 0,(function*(){const{resourceType:s,params:i}=e;let r;i&&(r=Object.entries(i).reduce(((e,[t,s])=>(e[s.name]||(e[s.name]=[]),e[s.name].push(s.value),e)),{}));const n=yield this.fhirRequest(`/${s}/_search`,"POST")(r,Object.assign(Object.assign({},t),{contentType:"application/x-www-form-urlencoded"}));return Object.assign(Object.assign({},n),{entry:n.entry,unbundle:function(){var e,t;return null!==(t=null===(e=this.entry)||void 0===e?void 0:e.map((e=>e.resource)).filter((e=>void 0!==e)))&&void 0!==t?t:[]}})}))}function j(e,t){return r(this,void 0,void 0,(function*(){const{resourceType:s}=e;return this.fhirRequest(`/${s}`,"POST")(e,t)}))}function O({resourceType:e,id:t},s){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${e}/${t}`,"GET")({},s)}))}function w(e,t){return r(this,void 0,void 0,(function*(){const{id:s,resourceType:i}=e;return this.fhirRequest(`/${i}/${s}`,"PUT")(e,Object.assign(Object.assign({},t),{ifMatch:(null==t?void 0:t.optimisticLockingVersionId)?`W/"${t.optimisticLockingVersionId}"`:void 0}))}))}function x({resourceType:e,id:t,operations:s},i){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${e}/${t}`,"PATCH")(s,Object.assign(Object.assign({},i),{contentType:"application/json-patch+json",ifMatch:(null==i?void 0:i.optimisticLockingVersionId)?`W/"${i.optimisticLockingVersionId}"`:void 0}))}))}function E({resourceType:e,id:t},s){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${e}/${t}`,"DELETE")({},s)}))}function T({resourceType:e,id:t,versionId:s},i){return r(this,void 0,void 0,(function*(){return this.fhirRequest(`/${e}/${t}/_history${s?`/${s}`:""}`,"GET")({},i)}))}function S(e){const{method:t,url:s}=e,i={request:{method:t,url:s}};if(s.split("?").length>1){const[e,t]=s.split("?"),r=t.split("&").map((e=>{const[t,s]=e.split("=");return{name:t,value:s}})).reduce(((e,{name:t,value:s})=>(e[t]||(e[t]=[]),e[t].push(s),e)),{}),n=new URLSearchParams;l(r,n),i.request.url=`${e}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(t))return i;if("PUT"===t){const{resource:t}=e;return Object.assign(Object.assign({},i),{resource:t})}if("PATCH"===t)return"resource"in e?Object.assign(Object.assign({},i),{resource:e.resource}):Object.assign(Object.assign({},i),{resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:Buffer.from(JSON.stringify(e.operations),"utf8").toString("base64")}});if("POST"===t){const{resource:t,fullUrl:s}=e;return Object.assign(Object.assign({},i),{resource:t,fullUrl:s})}throw new Error("Unrecognized method")}function k(e){return function(t,s){return r(this,void 0,void 0,(function*(){return this.fhirRequest("/","POST")({resourceType:"Bundle",type:e,entry:t.requests.map(S)},s)}))}}const R=k("batch"),U=k("transaction");function N(e,t){const s=[];if(e.line&&s.push(...e.line),e.city||e.state||e.postalCode){const t=[];e.city&&t.push(e.city),e.state&&t.push(e.state),e.postalCode&&t.push(e.postalCode),s.push(t.join(", "))}return e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&s.push("["+e.use+"]"),s.join((null==t?void 0:t.lineSeparator)||", ").trim()}function P(e,t){const s=[];return e.prefix&&!1!==(null==t?void 0:t.prefix)&&s.push(...e.prefix),e.given&&s.push(...e.given),e.family&&s.push(e.family),e.suffix&&!1!==(null==t?void 0:t.suffix)&&s.push(...e.suffix),e.use&&((null==t?void 0:t.all)||(null==t?void 0:t.use))&&s.push("["+e.use+"]"),s.join(" ").trim()}class z extends u{constructor(e){super(e),this.search=b,this.create=j,this.get=O,this.update=w,this.patch=x,this.delete=E,this.history=T,this.batch=R,this.transaction=U,this.formatAddress=N,this.formatHumanName=P}}class I extends u{constructor(e){super(e),this.list=e=>this.request("/m2m","get")(e),this.create=(e,t)=>this.request("/m2m","post")(e,t),this.get=(e,t)=>this.request("/m2m/{id}","get")(e,t),this.update=(e,t)=>this.request("/m2m/{id}","patch")(e,t),this.delete=(e,t)=>this.request("/m2m/{id}","delete")(e,t),this.rotateSecret=(e,t)=>this.request("/m2m/{id}/rotate-secret","post")(e,t),this.listV2=(e,t)=>this.request("/m2m/v2/list","get")(e,t)}}class $ extends u{constructor(e){super(e),this.getMessagingConfig=e=>this.request("/messaging/config","get")(e)}}class A extends u{constructor(e){super(e),this.setUp=(e,t)=>this.request("/payment/payment-method/setup","post")(e,t),this.setDefault=(e,t)=>this.request("/payment/payment-method/set-default","post")(e,t),this.delete=(e,t)=>this.request("/payment/payment-method","delete")(e,t),this.list=(e,t)=>this.request("/payment/payment-method/list","post")(e,t)}}class C extends u{constructor(e){super(e),this.get=e=>this.request("/project","get")(e),this.update=(e,t)=>this.request("/project","patch")(e,t)}}class _ extends u{constructor(e){super(e),this.eligibilityCheck=(e,t)=>this.request("/rcm/eligibility-check","post")(e,t),this.validateProfessionalClaim=(e,t)=>this.request("/rcm/professional-claim/validate","post")(e,t),this.submitProfessionalClaim=(e,t)=>this.request("/rcm/professional-claim/submit","post")(e,t)}}class L extends u{constructor(e){super(e),this.list=e=>this.request("/iam/role","get")(e),this.create=(e,t)=>this.request("/iam/role","post")(e,t),this.get=(e,t)=>this.request("/iam/role/{roleId}","get")(e,t),this.update=(e,t)=>this.request("/iam/role/{roleId}","patch")(e,t),this.delete=(e,t)=>this.request("/iam/role/{roleId}","delete")(e,t)}}class M extends u{constructor(e){super(e),this.list=e=>this.request("/secret","get")(e),this.set=(e,t)=>this.request("/secret","post")(e,t),this.get=(e,t)=>this.request("/secret/{name}","get")(e,t),this.delete=(e,t)=>this.request("/secret/{name}","delete")(e,t)}}class D extends u{constructor(e){super(e),this.createMeeting=(e,t)=>this.request("/telemed/v2/meeting","post")(e,t),this.joinMeeting=(e,t)=>this.request("/telemed/v2/meeting/{encounterId}/join","get")(e,t)}}class V extends u{constructor(e){super(e),this.send=(e,t)=>this.request("/messaging/transactional-sms/send","post")(e,t)}}class F extends u{constructor(e){super(e),this.me=e=>this.request("/user/me","get")(e),this.get=(e,t)=>this.request("/user/{id}","get")(e,t),this.update=(e,t)=>this.request("/user/{id}","patch")(e,t),this.delete=(e,t)=>this.request("/user/{id}","delete")(e,t),this.invite=(e,t)=>this.request("/user/invite","post")(e,t),this.list=e=>this.request("/user","get")(e),this.listV2=(e,t)=>this.request("/user/v2/list","get")(e,t)}}class H extends u{constructor(e){super(e),this.get=e=>this.request("/version","get")(e)}}function B({bucketName:e,"objectPath+":t,file:s}){return r(this,void 0,void 0,(function*(){const i=yield this.request("/z3/{bucketName}/{objectPath+}","post")({action:"upload",bucketName:e,"objectPath+":t});yield fetch(i.signedUrl,{method:"PUT",body:s})}))}function G({bucketName:e,"objectPath+":t}){return r(this,void 0,void 0,(function*(){const s=yield this.request("/z3/{bucketName}/{objectPath+}","post")({action:"download",bucketName:e,"objectPath+":t}),i=yield fetch(s.signedUrl,{method:"GET"});if(!i.ok)throw new Error("Failed to download file");return i.arrayBuffer()}))}function J(e){var s;return r(this,void 0,void 0,(function*(){let i,r;const o=new URL(e.url);if("z3:"===o.protocol){const e=o.pathname.split("/").slice(1);i=o.hostname,r=e.join("/")}else{if(!o.href.startsWith(null!==(s=this.config.projectApiUrl)&&void 0!==s?s:n))throw new t({message:"Invalid Z3 URL",code:400});{const e=o.pathname.split("/").slice(3);i=e[0],r=e.slice(1).join("/")}}const c={action:"upload",bucketName:i,"objectPath+":r};return this.request("/z3/{bucketName}/{objectPath+}","post")(c)}))}class W extends u{constructor(e){super(e),this.uploadFile=B,this.downloadFile=G,this.getPresignedUrlForZ3Url=J,this.listBuckets=e=>this.request("/z3","get")(e),this.createBucket=(e,t)=>this.request("/z3/{bucketName}","put")(e,t),this.deleteBucket=(e,t)=>this.request("/z3/{bucketName}","delete")(e,t),this.listObjects=(e,t)=>this.request("/z3/{bucketName}/{objectPath+}","get")(e,t),this.getPresignedUrl=(e,t)=>this.request("/z3/{bucketName}/{objectPath+}","post")(e,t),this.deleteObject=(e,t)=>this.request("/z3/{bucketName}/{objectPath+}","delete")(e,t)}}function X({id:e,file:t,filename:s}){return r(this,void 0,void 0,(function*(){const i=yield this.request("/zambda/{id}/s3-upload","post")({id:e,filename:s});yield fetch(i.signedUrl,{method:"PUT",body:t})}))}class Z extends u{constructor(e){super(e),this.uploadFile=X,this.list=e=>this.request("/zambda","get")(e),this.create=(e,t)=>this.request("/zambda","post")(e,t),this.get=(e,t)=>this.request("/zambda/{id}","get")(e,t),this.update=(e,t)=>this.request("/zambda/{id}","patch")(e,t),this.delete=(e,t)=>this.request("/zambda/{id}","delete")(e,t),this.execute=(e,t)=>this.request("/zambda/{id}/execute","post")(e,t),this.executePublic=(e,t)=>this.request("/zambda/{id}/execute-public","post")(e,t),this.s3Upload=(e,t)=>this.request("/zambda/{id}/s3-upload","post")(e,t)}}class K extends u{constructor(e){super(e),this.list=(e,t)=>this.request("/zambda/{id}/logStream","post")(e,t),this.search=(e,t)=>this.request("/zambda/{id}/logStream/search","post")(e,t),this.get=(e,t)=>this.request("/zambda/{id}/logStream/{logStreamName}","post")(e,t)}}let Q=class{constructor(e){this.config=e,this.application=new d(e),this.developer=new y(e),this.m2m=new I(e),this.messaging=new $(e),this.conversation=new g(e),this.transactionalSMS=new V(e),this.paymentMethod=new A(e),this.charge=new p(e),this.project=new C(e),this.rcm=new _(e),this.erx=new q(e),this.role=new L(e),this.secret=new M(e),this.telemed=new D(e),this.user=new F(e),this.version=new H(e),this.z3=new W(e),this.zambda=new Z(e),this.zambdaLogStream=new K(e),this.fhir=new z(e)}};class Y extends Q{}Y.OystehrFHIRError=i,Y.OystehrSdkError=t;export{Y as default};
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|