@oystehr/sdk 4.3.7 → 4.3.8
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/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/zambda-ext.cjs +23 -3
- package/dist/cjs/resources/classes/zambda-ext.cjs.map +1 -1
- package/dist/cjs/resources/classes/zambda-ext.d.ts +3 -0
- package/dist/cjs/resources/classes/zambda.cjs +13 -0
- package/dist/cjs/resources/classes/zambda.cjs.map +1 -1
- package/dist/cjs/resources/classes/zambda.d.ts +12 -1
- package/dist/cjs/resources/types/ZambdaGetPresignedUrlParams.d.ts +11 -0
- package/dist/cjs/resources/types/ZambdaGetPresignedUrlResponse.d.ts +9 -0
- package/dist/cjs/resources/types/index.d.ts +2 -0
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/zambda-ext.d.ts +3 -0
- package/dist/esm/resources/classes/zambda-ext.js +23 -4
- package/dist/esm/resources/classes/zambda-ext.js.map +1 -1
- package/dist/esm/resources/classes/zambda.d.ts +12 -1
- package/dist/esm/resources/classes/zambda.js +14 -1
- package/dist/esm/resources/classes/zambda.js.map +1 -1
- package/dist/esm/resources/types/ZambdaGetPresignedUrlParams.d.ts +11 -0
- package/dist/esm/resources/types/ZambdaGetPresignedUrlResponse.d.ts +9 -0
- package/dist/esm/resources/types/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/resources/classes/zambda-ext.ts +30 -3
- package/src/resources/classes/zambda.ts +18 -0
- package/src/resources/types/ZambdaGetPresignedUrlParams.ts +13 -0
- package/src/resources/types/ZambdaGetPresignedUrlResponse.ts +11 -0
- package/src/resources/types/index.ts +2 -0
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var index = require('../../errors/index.cjs');
|
|
4
|
+
|
|
3
5
|
function baseUrlThunk() {
|
|
4
|
-
return this.config.services?.['
|
|
6
|
+
return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';
|
|
5
7
|
}
|
|
6
8
|
async function uploadFile({ id, file, filename, }) {
|
|
7
|
-
const uploadUrl = await this.request('/zambda/{id}/
|
|
8
|
-
await fetch(uploadUrl.signedUrl, {
|
|
9
|
+
const uploadUrl = await this.request('/zambda/{id}/presigned-url', 'post', baseUrlThunk.bind(this))({ id, action: 'upload', filename });
|
|
10
|
+
const response = await fetch(uploadUrl.signedUrl, {
|
|
9
11
|
method: 'PUT',
|
|
10
12
|
body: file,
|
|
11
13
|
});
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
throw new index.OystehrSdkError({ message: 'Failed to upload file', code: response.status, cause: response.statusText });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
async function downloadFile({ id }) {
|
|
19
|
+
const downloadUrl = await this.request('/zambda/{id}/presigned-url', 'post', baseUrlThunk.bind(this))({ id, action: 'download' });
|
|
20
|
+
const response = await fetch(downloadUrl.signedUrl, {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
throw new index.OystehrSdkError({
|
|
25
|
+
message: 'Failed to download file',
|
|
26
|
+
code: response.status,
|
|
27
|
+
cause: response.statusText,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
return response.arrayBuffer();
|
|
12
31
|
}
|
|
13
32
|
|
|
33
|
+
exports.downloadFile = downloadFile;
|
|
14
34
|
exports.uploadFile = uploadFile;
|
|
15
35
|
//# sourceMappingURL=zambda-ext.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zambda-ext.cjs","sources":["../../../../src/resources/classes/zambda-ext.ts"],"sourcesContent":["import { SDKResource } from '../../client/client';\n\nfunction baseUrlThunk(this: SDKResource): string {\n return this.config.services?.['
|
|
1
|
+
{"version":3,"file":"zambda-ext.cjs","sources":["../../../../src/resources/classes/zambda-ext.ts"],"sourcesContent":["import { SDKResource } from '../../client/client';\nimport { OystehrSdkError } from '../../errors';\n\nfunction baseUrlThunk(this: SDKResource): string {\n return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';\n}\n\nexport async function uploadFile(\n this: SDKResource,\n {\n id,\n file,\n filename,\n }: {\n id: string;\n file: Blob;\n filename?: string | undefined;\n }\n): Promise<void> {\n const uploadUrl = await this.request(\n '/zambda/{id}/presigned-url',\n 'post',\n baseUrlThunk.bind(this)\n )({ id, action: 'upload', filename });\n const response = await fetch(uploadUrl.signedUrl, {\n method: 'PUT',\n body: file,\n });\n if (!response.ok) {\n throw new OystehrSdkError({ message: 'Failed to upload file', code: response.status, cause: response.statusText });\n }\n}\n\nexport async function downloadFile(this: SDKResource, { id }: { id: string }): Promise<ArrayBuffer> {\n const downloadUrl = await this.request(\n '/zambda/{id}/presigned-url',\n 'post',\n baseUrlThunk.bind(this)\n )({ id, action: 'download' });\n const response = await fetch(downloadUrl.signedUrl, {\n method: 'GET',\n });\n if (!response.ok) {\n throw new OystehrSdkError({\n message: 'Failed to download file',\n code: response.status,\n cause: response.statusText,\n });\n }\n return response.arrayBuffer();\n}\n"],"names":["OystehrSdkError"],"mappings":";;;;AAGA,SAAS,YAAY,GAAA;IACnB,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,cAAc,CAAC,IAAI,kCAAkC;AACrF;AAEO,eAAe,UAAU,CAE9B,EACE,EAAE,EACF,IAAI,EACJ,QAAQ,GAKT,EAAA;AAED,IAAA,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,OAAO,CAClC,4BAA4B,EAC5B,MAAM,EACN,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CACxB,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE;AAChD,QAAA,MAAM,EAAE,KAAK;AACb,QAAA,IAAI,EAAE,IAAI;AACX,KAAA,CAAC;AACF,IAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;QAChB,MAAM,IAAIA,qBAAe,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,UAAU,EAAE,CAAC;IACpH;AACF;AAEO,eAAe,YAAY,CAAoB,EAAE,EAAE,EAAkB,EAAA;IAC1E,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,OAAO,CACpC,4BAA4B,EAC5B,MAAM,EACN,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CACxB,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC;IAC7B,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE;AAClD,QAAA,MAAM,EAAE,KAAK;AACd,KAAA,CAAC;AACF,IAAA,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE;QAChB,MAAM,IAAIA,qBAAe,CAAC;AACxB,YAAA,OAAO,EAAE,yBAAyB;YAClC,IAAI,EAAE,QAAQ,CAAC,MAAM;YACrB,KAAK,EAAE,QAAQ,CAAC,UAAU;AAC3B,SAAA,CAAC;IACJ;AACA,IAAA,OAAO,QAAQ,CAAC,WAAW,EAAE;AAC/B;;;;;"}
|
|
@@ -12,6 +12,7 @@ class Zambda extends client.SDKResource {
|
|
|
12
12
|
return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';
|
|
13
13
|
}
|
|
14
14
|
uploadFile = zambdaExt.uploadFile;
|
|
15
|
+
downloadFile = zambdaExt.downloadFile;
|
|
15
16
|
/**
|
|
16
17
|
* Get a list of all Zambda Functions in the Project. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.
|
|
17
18
|
*
|
|
@@ -75,6 +76,8 @@ class Zambda extends client.SDKResource {
|
|
|
75
76
|
return this.request('/zambda/{id}/execute-public', 'post', this.#baseUrlThunk.bind(this))(params, request);
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
79
|
+
* **Deprecated.** Use `POST /zambda/{id}/presigned-url` with `action: "upload"` instead. This endpoint will be removed in future releases.
|
|
80
|
+
*
|
|
78
81
|
* Returns a URL that is used to deploy code to the Zambda Function with the provided ID. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.
|
|
79
82
|
*
|
|
80
83
|
* Access Policy Action: `Zambda:UpdateFunction`
|
|
@@ -83,6 +86,16 @@ class Zambda extends client.SDKResource {
|
|
|
83
86
|
s3Upload(params, request) {
|
|
84
87
|
return this.request('/zambda/{id}/s3-upload', 'post', this.#baseUrlThunk.bind(this))(params, request);
|
|
85
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* Returns a presigned URL to upload or download code for the Zambda Function with the provided ID. Pass `action: "upload"` to get a URL for deploying a new code zip, or `action: "download"` to get a URL for retrieving the currently deployed zip. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.
|
|
91
|
+
*
|
|
92
|
+
* Upload: Access Policy Action: `Zambda:UpdateFunction`
|
|
93
|
+
* Download: Access Policy Action: `Zambda:GetFunctionSource`
|
|
94
|
+
* Access Policy Resource: `Zambda:Function`
|
|
95
|
+
*/
|
|
96
|
+
getPresignedUrl(params, request) {
|
|
97
|
+
return this.request('/zambda/{id}/presigned-url', 'post', this.#baseUrlThunk.bind(this))(params, request);
|
|
98
|
+
}
|
|
86
99
|
}
|
|
87
100
|
|
|
88
101
|
exports.Zambda = Zambda;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zambda.cjs","sources":["../../../../src/resources/classes/zambda.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport {\n OystehrClientRequest,\n ZambdaCreateParams,\n ZambdaCreateResponse,\n ZambdaDeleteParams,\n ZambdaExecuteParams,\n ZambdaExecutePublicParams,\n ZambdaExecutePublicResponse,\n ZambdaExecuteResponse,\n ZambdaGetParams,\n ZambdaGetResponse,\n ZambdaListResponse,\n ZambdaS3UploadParams,\n ZambdaS3UploadResponse,\n ZambdaUpdateParams,\n ZambdaUpdateResponse,\n} from '../..';\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport * as ext from './zambda-ext';\n\nexport class Zambda extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n #baseUrlThunk(): string {\n return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';\n }\n uploadFile = ext.uploadFile;\n /**\n * Get a list of all Zambda Functions in the Project. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:ListAllFunctions`\n * Access Policy Resource: `Zambda:Function`\n */\n list(request?: OystehrClientRequest): Promise<ZambdaListResponse> {\n return this.request('/zambda', 'get', this.#baseUrlThunk.bind(this))(request);\n }\n /**\n * Create a new Zambda Function. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:CreateFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n create(params: ZambdaCreateParams, request?: OystehrClientRequest): Promise<ZambdaCreateResponse> {\n return this.request('/zambda', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Get the Zambda Function with the provided ID or name. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:GetFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n get(params: ZambdaGetParams, request?: OystehrClientRequest): Promise<ZambdaGetResponse> {\n return this.request('/zambda/{id}', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Update the Zambda Function with the provided ID or name. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:UpdateFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n update(params: ZambdaUpdateParams, request?: OystehrClientRequest): Promise<ZambdaUpdateResponse> {\n return this.request('/zambda/{id}', 'patch', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Delete the Zambda Function with the provided ID or name. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:DeleteFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n delete(params: ZambdaDeleteParams, request?: OystehrClientRequest): Promise<void> {\n return this.request('/zambda/{id}', 'delete', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Execute the [Authenticated Zambda Function](https://docs.oystehr.com/oystehr/services/zambda/types/authenticated/) with the provided ID. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:InvokeFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n execute(params: ZambdaExecuteParams, request?: OystehrClientRequest): Promise<ZambdaExecuteResponse> {\n return this.request('/zambda/{id}/execute', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Execute the [Public Zambda Function](https://docs.oystehr.com/oystehr/services/zambda/types/public/) with the provided ID. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Execute a zambda that has method http_open. This endpoint is public so there are no access policy requirements.\n */\n executePublic(\n params: ZambdaExecutePublicParams,\n request?: OystehrClientRequest\n ): Promise<ZambdaExecutePublicResponse> {\n return this.request('/zambda/{id}/execute-public', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Returns a URL that is used to deploy code to the Zambda Function with the provided ID. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:UpdateFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n s3Upload(params: ZambdaS3UploadParams, request?: OystehrClientRequest): Promise<ZambdaS3UploadResponse> {\n return this.request('/zambda/{id}/s3-upload', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n}\n"],"names":["SDKResource","ext.uploadFile"],"mappings":";;;;;AAAA;
|
|
1
|
+
{"version":3,"file":"zambda.cjs","sources":["../../../../src/resources/classes/zambda.ts"],"sourcesContent":["// AUTOGENERATED -- DO NOT EDIT\n\nimport {\n OystehrClientRequest,\n ZambdaCreateParams,\n ZambdaCreateResponse,\n ZambdaDeleteParams,\n ZambdaExecuteParams,\n ZambdaExecutePublicParams,\n ZambdaExecutePublicResponse,\n ZambdaExecuteResponse,\n ZambdaGetParams,\n ZambdaGetPresignedUrlParams,\n ZambdaGetPresignedUrlResponse,\n ZambdaGetResponse,\n ZambdaListResponse,\n ZambdaS3UploadParams,\n ZambdaS3UploadResponse,\n ZambdaUpdateParams,\n ZambdaUpdateResponse,\n} from '../..';\nimport { SDKResource } from '../../client/client';\nimport { OystehrConfig } from '../../config';\nimport * as ext from './zambda-ext';\n\nexport class Zambda extends SDKResource {\n constructor(config: OystehrConfig) {\n super(config);\n }\n #baseUrlThunk(): string {\n return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';\n }\n uploadFile = ext.uploadFile;\n downloadFile = ext.downloadFile;\n /**\n * Get a list of all Zambda Functions in the Project. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:ListAllFunctions`\n * Access Policy Resource: `Zambda:Function`\n */\n list(request?: OystehrClientRequest): Promise<ZambdaListResponse> {\n return this.request('/zambda', 'get', this.#baseUrlThunk.bind(this))(request);\n }\n /**\n * Create a new Zambda Function. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:CreateFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n create(params: ZambdaCreateParams, request?: OystehrClientRequest): Promise<ZambdaCreateResponse> {\n return this.request('/zambda', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Get the Zambda Function with the provided ID or name. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:GetFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n get(params: ZambdaGetParams, request?: OystehrClientRequest): Promise<ZambdaGetResponse> {\n return this.request('/zambda/{id}', 'get', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Update the Zambda Function with the provided ID or name. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:UpdateFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n update(params: ZambdaUpdateParams, request?: OystehrClientRequest): Promise<ZambdaUpdateResponse> {\n return this.request('/zambda/{id}', 'patch', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Delete the Zambda Function with the provided ID or name. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:DeleteFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n delete(params: ZambdaDeleteParams, request?: OystehrClientRequest): Promise<void> {\n return this.request('/zambda/{id}', 'delete', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Execute the [Authenticated Zambda Function](https://docs.oystehr.com/oystehr/services/zambda/types/authenticated/) with the provided ID. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:InvokeFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n execute(params: ZambdaExecuteParams, request?: OystehrClientRequest): Promise<ZambdaExecuteResponse> {\n return this.request('/zambda/{id}/execute', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Execute the [Public Zambda Function](https://docs.oystehr.com/oystehr/services/zambda/types/public/) with the provided ID. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Execute a zambda that has method http_open. This endpoint is public so there are no access policy requirements.\n */\n executePublic(\n params: ZambdaExecutePublicParams,\n request?: OystehrClientRequest\n ): Promise<ZambdaExecutePublicResponse> {\n return this.request('/zambda/{id}/execute-public', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * **Deprecated.** Use `POST /zambda/{id}/presigned-url` with `action: \"upload\"` instead. This endpoint will be removed in future releases.\n *\n * Returns a URL that is used to deploy code to the Zambda Function with the provided ID. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Access Policy Action: `Zambda:UpdateFunction`\n * Access Policy Resource: `Zambda:Function`\n */\n s3Upload(params: ZambdaS3UploadParams, request?: OystehrClientRequest): Promise<ZambdaS3UploadResponse> {\n return this.request('/zambda/{id}/s3-upload', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n /**\n * Returns a presigned URL to upload or download code for the Zambda Function with the provided ID. Pass `action: \"upload\"` to get a URL for deploying a new code zip, or `action: \"download\"` to get a URL for retrieving the currently deployed zip. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.\n *\n * Upload: Access Policy Action: `Zambda:UpdateFunction`\n * Download: Access Policy Action: `Zambda:GetFunctionSource`\n * Access Policy Resource: `Zambda:Function`\n */\n getPresignedUrl(\n params: ZambdaGetPresignedUrlParams,\n request?: OystehrClientRequest\n ): Promise<ZambdaGetPresignedUrlResponse> {\n return this.request('/zambda/{id}/presigned-url', 'post', this.#baseUrlThunk.bind(this))(params, request);\n }\n}\n"],"names":["SDKResource","ext.uploadFile","ext.downloadFile"],"mappings":";;;;;AAAA;AAyBM,MAAO,MAAO,SAAQA,kBAAW,CAAA;AACrC,IAAA,WAAA,CAAY,MAAqB,EAAA;QAC/B,KAAK,CAAC,MAAM,CAAC;IACf;IACA,aAAa,GAAA;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,GAAG,cAAc,CAAC,IAAI,kCAAkC;IACrF;AACA,IAAA,UAAU,GAAGC,oBAAc;AAC3B,IAAA,YAAY,GAAGC,sBAAgB;AAC/B;;;;;AAKG;AACH,IAAA,IAAI,CAAC,OAA8B,EAAA;QACjC,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;IAC/E;AACA;;;;;AAKG;IACH,MAAM,CAAC,MAA0B,EAAE,OAA8B,EAAA;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACxF;AACA;;;;;AAKG;IACH,GAAG,CAAC,MAAuB,EAAE,OAA8B,EAAA;QACzD,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5F;AACA;;;;;AAKG;IACH,MAAM,CAAC,MAA0B,EAAE,OAA8B,EAAA;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9F;AACA;;;;;AAKG;IACH,MAAM,CAAC,MAA0B,EAAE,OAA8B,EAAA;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IAC/F;AACA;;;;;AAKG;IACH,OAAO,CAAC,MAA2B,EAAE,OAA8B,EAAA;QACjE,OAAO,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACrG;AACA;;;;AAIG;IACH,aAAa,CACX,MAAiC,EACjC,OAA8B,EAAA;QAE9B,OAAO,IAAI,CAAC,OAAO,CAAC,6BAA6B,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5G;AACA;;;;;;;AAOG;IACH,QAAQ,CAAC,MAA4B,EAAE,OAA8B,EAAA;QACnE,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IACvG;AACA;;;;;;AAMG;IACH,eAAe,CACb,MAAmC,EACnC,OAA8B,EAAA;QAE9B,OAAO,IAAI,CAAC,OAAO,CAAC,4BAA4B,EAAE,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3G;AACD;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { OystehrClientRequest, ZambdaCreateParams, ZambdaCreateResponse, ZambdaDeleteParams, ZambdaExecuteParams, ZambdaExecutePublicParams, ZambdaExecutePublicResponse, ZambdaExecuteResponse, ZambdaGetParams, ZambdaGetResponse, ZambdaListResponse, ZambdaS3UploadParams, ZambdaS3UploadResponse, ZambdaUpdateParams, ZambdaUpdateResponse } from '../..';
|
|
1
|
+
import { OystehrClientRequest, ZambdaCreateParams, ZambdaCreateResponse, ZambdaDeleteParams, ZambdaExecuteParams, ZambdaExecutePublicParams, ZambdaExecutePublicResponse, ZambdaExecuteResponse, ZambdaGetParams, ZambdaGetPresignedUrlParams, ZambdaGetPresignedUrlResponse, ZambdaGetResponse, ZambdaListResponse, ZambdaS3UploadParams, ZambdaS3UploadResponse, ZambdaUpdateParams, ZambdaUpdateResponse } from '../..';
|
|
2
2
|
import { SDKResource } from '../../client/client';
|
|
3
3
|
import { OystehrConfig } from '../../config';
|
|
4
4
|
import * as ext from './zambda-ext';
|
|
@@ -6,6 +6,7 @@ export declare class Zambda extends SDKResource {
|
|
|
6
6
|
#private;
|
|
7
7
|
constructor(config: OystehrConfig);
|
|
8
8
|
uploadFile: typeof ext.uploadFile;
|
|
9
|
+
downloadFile: typeof ext.downloadFile;
|
|
9
10
|
/**
|
|
10
11
|
* Get a list of all Zambda Functions in the Project. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.
|
|
11
12
|
*
|
|
@@ -55,10 +56,20 @@ export declare class Zambda extends SDKResource {
|
|
|
55
56
|
*/
|
|
56
57
|
executePublic(params: ZambdaExecutePublicParams, request?: OystehrClientRequest): Promise<ZambdaExecutePublicResponse>;
|
|
57
58
|
/**
|
|
59
|
+
* **Deprecated.** Use `POST /zambda/{id}/presigned-url` with `action: "upload"` instead. This endpoint will be removed in future releases.
|
|
60
|
+
*
|
|
58
61
|
* Returns a URL that is used to deploy code to the Zambda Function with the provided ID. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.
|
|
59
62
|
*
|
|
60
63
|
* Access Policy Action: `Zambda:UpdateFunction`
|
|
61
64
|
* Access Policy Resource: `Zambda:Function`
|
|
62
65
|
*/
|
|
63
66
|
s3Upload(params: ZambdaS3UploadParams, request?: OystehrClientRequest): Promise<ZambdaS3UploadResponse>;
|
|
67
|
+
/**
|
|
68
|
+
* Returns a presigned URL to upload or download code for the Zambda Function with the provided ID. Pass `action: "upload"` to get a URL for deploying a new code zip, or `action: "download"` to get a URL for retrieving the currently deployed zip. [Zambdas](https://docs.oystehr.com/oystehr/services/zambda/) are functions that can be used to execute your code. They can be used to process data received from Oystehr's APIs or to perform operations on third-party services.
|
|
69
|
+
*
|
|
70
|
+
* Upload: Access Policy Action: `Zambda:UpdateFunction`
|
|
71
|
+
* Download: Access Policy Action: `Zambda:GetFunctionSource`
|
|
72
|
+
* Access Policy Resource: `Zambda:Function`
|
|
73
|
+
*/
|
|
74
|
+
getPresignedUrl(params: ZambdaGetPresignedUrlParams, request?: OystehrClientRequest): Promise<ZambdaGetPresignedUrlResponse>;
|
|
64
75
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ZambdaGetPresignedUrlParams {
|
|
2
|
+
/**
|
|
3
|
+
* Whether to get a presigned URL for uploading or downloading the Zambda Function code zip.
|
|
4
|
+
*/
|
|
5
|
+
action: 'upload' | 'download';
|
|
6
|
+
/**
|
|
7
|
+
* Optional filename for the Zambda Function code zip (upload only). If not provided, the filename will be randomized.
|
|
8
|
+
*/
|
|
9
|
+
filename?: string;
|
|
10
|
+
id: string;
|
|
11
|
+
}
|
|
@@ -192,6 +192,8 @@ export * from './ZambdaLogStreamListParams';
|
|
|
192
192
|
export * from './ZambdaLogStreamListResponse';
|
|
193
193
|
export * from './ZambdaS3UploadParams';
|
|
194
194
|
export * from './ZambdaS3UploadResponse';
|
|
195
|
+
export * from './ZambdaGetPresignedUrlParams';
|
|
196
|
+
export * from './ZambdaGetPresignedUrlResponse';
|
|
195
197
|
export * from './ZambdaLogStreamSearchParams';
|
|
196
198
|
export * from './ZambdaLogStreamSearchResponse';
|
|
197
199
|
export * from './ZambdaLogStreamGetParams';
|
package/dist/esm/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{v4 as e,validate as t}from"uuid";class s extends Error{code;constructor({message:e,code:t,cause:r}){super(e,{cause:r}),Object.setPrototypeOf(this,s.prototype),this.code=t,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function r(e){const t=[];for(const s of e.issue??[])s.details&&s.details.text&&t.push(s.details.text);return t.length||t.push("Unknown FHIR error"),t.join(",")}class i extends s{cause;constructor({error:e,code:t}){super({message:r(e),code:t}),Object.setPrototypeOf(this,i.prototype),this.cause=e,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}class n{_level;constructor({level:e}){this._level=e}error(e,t={}){this._level&&["error","info","debug"].includes(this._level)&&console.error(JSON.stringify({message:e,...t}))}info(e,t={}){this._level&&["info","debug"].includes(this._level)&&console.info(JSON.stringify({message:e,...t}))}debug(e,t={}){this._level&&["debug"].includes(this._level)&&console.debug(JSON.stringify({message:e,...t}))}time(e,t={}){this._level&&["debug"].includes(this._level)&&console.time(JSON.stringify({message:e,...t}))}timeEnd(e,t={}){this._level&&["debug"].includes(this._level)&&console.timeEnd(JSON.stringify({message:e,...t}))}}const o=[408,429,500,502,503,504],a=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class u{config;logger;constructor(e){this.config=e,this.logger=new n({level:this.config.logLevel})}request(e,t,r){return async(i,n)=>{const o=()=>this.config,a=()=>this.logger;try{return await c(r,o,a,e,t)(i,n)}catch(e){const t=e;throw this.logger.error(t.message,{code:t.code,cause:t.cause}),new s({message:t.message,code:t.code,cause:t.cause})}}}fhirRequest(e,t){return async(r,n)=>{try{const s=()=>this.config.services?.fhirApiUrl??"https://fhir-api.zapehr.com",i=()=>this.config,o=()=>this.logger;return await c(s,i,o,e,t)(r,n)}catch(e){const t=e;if("string"==typeof t.message)throw new s({message:t.message,code:t.code,cause:t.cause});throw new i({error:t.message,code:t.code})}}}}function h(e){return"accessToken"in e||"projectId"in e&&t(e.projectId)||"contentType"in e&&2===e.contentType?.split("/").length||"requestId"in e||"ifMatch"in e&&e.ifMatch.startsWith('W/"')}function c(t,r,i,n,u){return async(c,d)=>{let[p,b]=function(e,t){const s=e&&!t&&!Array.isArray(e)&&h(e)?{}:e??{},r=e&&!t&&!Array.isArray(e)&&h(e)?e:t;return[s,r]}(c,d);b??={},b.requestId??=e();const g=r(),m=i(),f=u.toLowerCase();m.debug("Beginning fetch",{method:f,path:n,requestId:b?.requestId});const T=g.fetch??fetch,U=b?.accessToken??g.accessToken,k=b?.projectId??g.projectId;let y=n,q=p;if(!Array.isArray(p)){const[e,t]=function(e,t){const r={...t},i=e.replace(/\{([^}]+)\}/g,((e,i)=>{if(delete r[i],i.match(/^.*\+$/))return t[i]+"";if(!t[i]||""===t[i])throw new s({message:`Required path parameter is an empty string: ${i}`,code:400});return t[i]?encodeURIComponent(t[i]+""):""})),n=Object.keys(r),o=n.length?n.reduce(((e,t)=>({...e,[t]:r[t]})),{}):{};return[i,o]}(n,p);y=e,q=t}m.debug("Substituted parameters in path",{method:f,path:n,requestId:b?.requestId}),y=y.replace(/^\//,"");const v=t(),w=v.endsWith("/")?v:v+"/",j=new URL(y,w);let I;if(Array.isArray(q))I=JSON.stringify(q);else if(Object.keys(q).length)if("get"===f)l(q,j.searchParams);else if("application/x-www-form-urlencoded"===b?.contentType){const e=new URLSearchParams;l(q,e),I=e.toString()}else I=JSON.stringify(q);else"application/x-www-form-urlencoded"!==b?.contentType&&"post"===f&&(I="{}");m.debug("Prepared request body",{method:f,path:n,requestId:b?.requestId});const z=Object.assign(k?{"x-zapehr-project-id":k,"x-oystehr-project-id":k}:{},{"content-type":b?.contentType??"application/json"},U?{Authorization:`Bearer ${U}`}:{},b?.ifMatch?{"If-Match":b.ifMatch}:{},{"x-oystehr-request-id":b?.requestId}),x={retries:g.retry?.retries??3,jitter:g.retry?.jitter??20,delay:g.retry?.delay??100,onRetry:g.retry?.onRetry,retryOn:[...g.retry?.retryOn??[],...o]};return x.retryOn.push(...o),async function(e,t){let s;for(const r of Array.from({length:(t.retries??0)+1},((e,t)=>t)))try{return await e(r)}catch(e){let i=!1;if("response"in e){const r=e;i=t.retryOn.includes(r.code),s={message:e.message,code:e.code}}else if(s=e,"code"in e&&"string"==typeof e.code){const t=e;i=a.includes(t.code)}if(!i)break;const n=Math.floor(Math.random()*(t.jitter+1));await new Promise((e=>setTimeout(e,t.delay+n))),t.onRetry&&r!==(t.retries??0)&&t.onRetry(r+1)}throw s}((async()=>{m.info("Request start",{method:f,url:j,requestId:b?.requestId});const e=Date.now(),t=await T(new Request(j,{method:f.toUpperCase(),body:I,headers:z}));m.info("Request end",{method:f,url:j,duration:Date.now()-e,requestId:b?.requestId});const s=t.body?await t.text():null;let r;const i=t.headers.get("content-type");try{s&&(i?.includes("application/json")||i?.includes("application/fhir+json"))?(m.time("Deserialized JSON response",{method:f,url:j,requestId:b?.requestId}),r=JSON.parse(s),m.timeEnd("Deserialized JSON response",{method:f,url:j,requestId:b?.requestId})):s&&(i?.includes("application/xml")||i?.includes("text/xml"))?(m.time("Deserialized XML response",{method:f,url:j,requestId:b?.requestId}),r=function(e){try{const t=e.match(/<status>(\d+)<\/status>/),s=t?parseInt(t[1],10):null,r=e.match(/<output>([\s\S]*?)<\/output>/),i=r?r[1]:null;return null===s||null===i?null:{status:s,output:i}}catch(e){return null}}(s),m.timeEnd("Deserialized XML response",{method:f,url:j,requestId:b?.requestId})):r=null}catch(e){r=null}m.debug("Deserialized response",{method:f,url:j,requestId:b?.requestId});if(!t.ok||t.status>=400){throw{message:("string"==typeof r?.output?r.output:r?.output?.message)??r?.message??r??s??t.statusText,code:r?.output?.code??r?.code??t.status,response:t}}return r}),x)}}function l(e,t){for(const[s,r]of Object.entries(e))Array.isArray(r)?r.forEach((e=>null!=e&&t.append(s,e))):null!=r&&t.append(s,r)}class d extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/application","get",this.#e.bind(this))(e)}create(e,t){return this.request("/application","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/application/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/application/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/application/{id}","delete",this.#e.bind(this))(e,t)}rotateSecret(e,t){return this.request("/application/{id}/rotate-secret","post",this.#e.bind(this))(e,t)}revokeRefreshToken(e,t){return this.request("/application/{id}/revoke-refresh-token","post",this.#e.bind(this))(e,t)}revokeAccessToken(e,t){return this.request("/application/{id}/revoke-access-token","post",this.#e.bind(this))(e,t)}}class p extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}issue(e,t){return this.request("/payment/charge/issue","post",this.#e.bind(this))(e,t)}status(e,t){return this.request("/payment/charge/status","post",this.#e.bind(this))(e,t)}}const b="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",g="addressString";function m(e){if(function(e){return Object.hasOwn(e,"virtualService")}(e)){const t=e.virtualService?.find((e=>"https://fhir.zapehr.com/virtual-service-type"===e.channelType?.system));return t?.addressString}if(!e.extension)return;const t=e.extension.find((e=>e.url===b));if(!t?.extension)return;const s=t.extension?.find((e=>e.url===g))?.valueString;return s}class f extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}ENCOUNTER_VS_EXTENSION_URL=b;ENCOUNTER_VS_EXTENSION_RELATIVE_URL=g;getConversationIdFromEncounter=m;create(e,t){return this.request("/messaging/conversation","post",this.#e.bind(this))(e,t)}getToken(e){return this.request("/messaging/conversation/token","get",this.#e.bind(this))(e)}addParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","post",this.#e.bind(this))(e,t)}removeParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","delete",this.#e.bind(this))(e,t)}message(e,t){return this.request("/messaging/conversation/{conversationId}/message","post",this.#e.bind(this))(e,t)}}class T extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e,t){return this.request("/developer/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/developer/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/developer/{id}","delete",this.#e.bind(this))(e,t)}invite(e,t){return this.request("/developer/invite","post",this.#e.bind(this))(e,t)}list(e){return this.request("/developer","get",this.#e.bind(this))(e)}listV2(e,t){return this.request("/developer/v2/list","get",this.#e.bind(this))(e,t)}}class U extends u{constructor(e){super(e)}#e(){return this.config.services?.erxApiUrl??"https://erx-api.zapehr.com/v3"}searchAllergens(e,t){return this.request("/allergen","get",this.#e.bind(this))(e,t)}searchMedications(e,t){return this.request("/medication","get",this.#e.bind(this))(e,t)}getMedication(e,t){return this.request("/medication/details","get",this.#e.bind(this))(e,t)}getConfiguration(e){return this.request("/config","get",this.#e.bind(this))(e)}checkAllergyInteractions(e,t){return this.request("/patient/{patientId}/interactions/allergy","get",this.#e.bind(this))(e,t)}checkMedicationInteractions(e,t){return this.request("/patient/{patientId}/interactions/medication","get",this.#e.bind(this))(e,t)}checkPrecheckInteractions(e,t){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",this.#e.bind(this))(e,t)}getMedicationHistory(e,t){return this.request("/patient/{patientId}/medication-history","get",this.#e.bind(this))(e,t)}addPatientPharmacy(e,t){return this.request("/patient/{patientId}/pharmacies","post",this.#e.bind(this))(e,t)}cancelPrescription(e,t){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",this.#e.bind(this))(e,t)}syncPatient(e,t){return this.request("/patient/{patientId}/sync","post",this.#e.bind(this))(e,t)}searchPharmacies(e,t){return this.request("/pharmacy","get",this.#e.bind(this))(e,t)}connectPractitioner(e,t){return this.request("/practitioner/connect","get",this.#e.bind(this))(e,t)}checkPractitionerEnrollment(e,t){return this.request("/practitioner/{practitionerId}","get",this.#e.bind(this))(e,t)}enrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","post",this.#e.bind(this))(e,t)}unenrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","delete",this.#e.bind(this))(e,t)}}class k extends u{constructor(e){super(e)}#e(){return this.config.services?.faxApiUrl??"https://fax-api.zapehr.com/v1"}offboard(e){return this.request("/offboard","post",this.#e.bind(this))(e)}onboard(e){return this.request("/onboard","post",this.#e.bind(this))(e)}getConfiguration(e){return this.request("/config","get",this.#e.bind(this))(e)}send(e,t){return this.request("/send","post",this.#e.bind(this))(e,t)}}const y=65535;function q(e){const t=(new globalThis.TextEncoder).encode(e);let s="";for(let e=0;e<t.length;e+=y){const r=t.subarray(e,e+y);s+=globalThis.btoa(String.fromCodePoint.apply(void 0,r))}return s}function v(e){return e.system?`${e.system}|${e.code??""}`:e.code??""}function w(e,t){return(e.system??"")===(t.system??"")&&(e.code??"")===(t.code??"")}function j(e,t){const r=t;if(e.ignoreTags?.length){const i=r.meta?.tag??[];for(const t of e.ignoreTags)if(i.some((e=>w(e,t))))throw new s({message:`Resource has an ignored tag (system: "${t.system??""}", code: "${t.code??""}") and cannot be mutated in ignoreTags mode`,code:400});return t}if(e.workspaceTag){const s=e.workspaceTag,i=r.meta?.tag??[];if(!i.some((e=>w(e,s))))return{...t,meta:{...r.meta,tag:[...i,s]}}}return t}function I(e,t){if(e.ignoreTags?.length){for(const r of t)if("add"===r.op||"replace"===r.op||"test"===r.op){const t=r.value;if(null!=t&&"object"==typeof t){const r=t;if(void 0!==r.code)for(const t of e.ignoreTags)if(w(r,t))throw new s({message:`Patch operation contains an ignored tag (system: "${t.system??""}", code: "${t.code??""}") and cannot be applied in ignoreTags mode`,code:400})}}return t}if(e.workspaceTag){const s=e.workspaceTag;return t.reduce(((e,t)=>{if("remove"===t.op&&"/meta/tag"===t.path)return e.push(t),e.push({op:"add",path:"/meta/tag",value:[s]}),e;if("remove"===t.op&&"/meta"===t.path)return e.push(t),e.push({op:"add",path:"/meta",value:{tag:[s]}}),e;if(("add"===t.op||"replace"===t.op)&&"/meta/tag"===t.path){const r=Array.isArray(t.value)?t.value:[];return r.some((e=>w(e,s)))?e.push(t):e.push({...t,value:[...r,s]}),e}if(("add"===t.op||"replace"===t.op)&&"/meta"===t.path){const r=null!=t.value&&"object"==typeof t.value?t.value:{},i=r.tag??[];return i.some((e=>w(e,s)))?e.push(t):e.push({...t,value:{...r,tag:[...i,s]}}),e}return e.push(t),e}),[])}return t}function z(e,t){const s=t,r=s.meta?.tag??[];if(e.workspaceTag){const t=e.workspaceTag;if(!r.some((e=>w(e,t))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}else if(e.ignoreTags?.length)for(const t of e.ignoreTags)if(r.some((e=>w(e,t))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}async function x(e,t){const{resourceType:s}=e,r=function(e,t){const s=t?[...t]:[];if(e.workspaceTag)s.push({name:"_tag",value:v(e.workspaceTag)});else if(e.ignoreTags?.length)for(const t of e.ignoreTags)s.push({name:"_tag:not",value:v(t)});return s}(this.config,e.params);let i;r.length&&(i=r.reduce(((e,t)=>(e[t.name]||(e[t.name]=[]),e[t.name].push(t.value),e)),{}));const n=await this.fhirRequest(`/${s}/_search`,"POST")(i,{...t,contentType:"application/x-www-form-urlencoded"});return{...n,entry:n.entry,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]}}}async function E(e,t){const s=j(this.config,e),{resourceType:r}=s;return this.fhirRequest(`/${r}`,"POST")(s,t)}async function S({resourceType:e,id:t},s){const r=await this.fhirRequest(`/${e}/${t}`,"GET")({},s);return z(this.config,r),r}async function A(e,t){const s=j(this.config,e),{id:r,resourceType:i}=s;return this.fhirRequest(`/${i}/${r}`,"PUT")(s,{...t,ifMatch:t?.optimisticLockingVersionId?`W/"${t.optimisticLockingVersionId}"`:void 0})}async function O({resourceType:e,id:t,operations:s},r){const i=I(this.config,s);return this.fhirRequest(`/${e}/${t}`,"PATCH")(i,{...r,contentType:"application/json-patch+json",ifMatch:r?.optimisticLockingVersionId?`W/"${r.optimisticLockingVersionId}"`:void 0})}async function P({resourceType:e,id:t},s){return this.fhirRequest(`/${e}/${t}`,"DELETE")({},s)}async function R({resourceType:e,id:t,versionId:s,count:r,offset:i},n){return s?this.fhirRequest(`/${e}/${t}/_history/${s}`,"GET")({},n):r?this.fhirRequest(`/${e}/${t}/_history?_total=accurate&_count=${r}\n ${i?`&_offset=${i}`:""}`,"GET")({},n):this.fhirRequest(`/${e}/${t}/_history?_total=accurate`,"GET")({},n)}function N(e){const t=e.split("?")[0].split("/").filter(Boolean);return t.length<=1||t[1].startsWith("_")}function _(e){return e.split("?")[0].endsWith("/_search")}function $(e,t){const{method:s}=e;let r=e.url;if((("GET"===s||"HEAD"===s)&&N(r)||"POST"===s&&_(r))&&(t.workspaceTag&&(r+=(r.includes("?")?"&":"?")+`_tag=${v(t.workspaceTag)}`),t.ignoreTags?.length))for(const e of t.ignoreTags)r+=(r.includes("?")?"&":"?")+`_tag:not=${v(e)}`;const i={request:{method:s,url:r}};if(r.split("?").length>1){const[e,t]=r.split("?"),s=t.split("&").map((e=>{const[t,s]=e.split("=");return{name:t,value:s}})).reduce(((e,{name:t,value:s})=>t?(e[t]||(e[t]=[]),e[t].push(s),e):e),{}),n=new URLSearchParams;l(s,n),i.request.url=`${e}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(s))return i;if("PUT"===s){const s=j(t,e.resource);return{request:{...i.request,ifMatch:e.ifMatch},resource:s}}if("PATCH"===s){if("resource"in e){let s=e.resource;const r=s.data;if(r){const e=I(t,JSON.parse(function(e){const t=globalThis.atob(e),s=new Uint8Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);return(new globalThis.TextDecoder).decode(s)}(r)));s={...s,data:q(JSON.stringify(e))}}return{request:{...i.request,ifMatch:e.ifMatch},resource:s}}const s=I(t,e.operations),r=q(JSON.stringify(s));return{...i,resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:r}}}if("POST"===s&&_(r))return i;if("POST"===s&&"resource"in e){const s=j(t,e.resource),{fullUrl:r}=e;return{...i,resource:s,fullUrl:r}}throw new Error("Unrecognized method")}async function M(e,t){const s=await this.fhirRequest("/","POST")({resourceType:"Bundle",type:"batch",entry:e.requests.map((e=>$(e,this.config)))},t),r=s.entry,n=this.config.workspaceTag||this.config.ignoreTags?.length?r?.map(((t,s)=>{const r=e.requests[s];if(!r||!t?.resource)return t;if(("GET"===r.method||"HEAD"===r.method)&&!N(r.url))try{z(this.config,t.resource)}catch(e){if(!(e instanceof i))throw e;return{request:t.request,response:{status:"404",outcome:e.cause}}}return t})):r;return{...s,entry:n,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]},errors:function(){return this.entry?.filter((e=>e.response?.status?.startsWith("4")||e.response?.status?.startsWith("5"))).map((e=>e.response?.outcome)).filter((e=>void 0!==e))}}}async function C(e,t){const s=await this.fhirRequest("/","POST")({resourceType:"Bundle",type:"transaction",entry:e.requests.map((e=>$(e,this.config)))},t);(this.config.workspaceTag||this.config.ignoreTags?.length)&&s.entry?.forEach(((t,s)=>{const r=e.requests[s];r&&t?.resource&&("GET"!==r.method&&"HEAD"!==r.method||N(r.url)||z(this.config,t.resource))}));return{...s,entry:s.entry,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]}}}async function L({id:e},t){return this.fhirRequest(`/Patient/${e}/$generate-friendly-patient-id`,"POST")({},t)}function D(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&&(t?.all||t?.use)&&s.push("["+e.use+"]"),s.join(t?.lineSeparator||", ").trim()}function J(e,t){const s=[];return e.prefix&&!1!==t?.prefix&&s.push(...e.prefix),e.given&&s.push(...e.given),e.family&&s.push(e.family),e.suffix&&!1!==t?.suffix&&s.push(...e.suffix),e.use&&(t?.all||t?.use)&&s.push("["+e.use+"]"),s.join(" ").trim()}class G extends u{constructor(e){super(e)}#e(){return this.config.services?.fhirApiUrl??"https://fhir-api.zapehr.com"}search=x;create=E;get=S;update=A;patch=O;delete=P;history=R;batch=M;transaction=C;generateFriendlyPatientId=L;formatAddress=D;formatHumanName=J}class H extends u{constructor(e){super(e)}#e(){return this.config.services?.labApiUrl??"https://labs-api.zapehr.com/v1"}routeList(e){return this.request("/route","get",this.#e.bind(this))(e)}routeCreate(e,t){return this.request("/route","post",this.#e.bind(this))(e,t)}routeGet(e,t){return this.request("/route/{routeGuid}","get",this.#e.bind(this))(e,t)}routeDelete(e,t){return this.request("/route/{routeGuid}","delete",this.#e.bind(this))(e,t)}orderableItemList(e,t){return this.request("/orderableItem","get",this.#e.bind(this))(e,t)}orderableItemQuestionnaireGet(e,t){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",this.#e.bind(this))(e,t)}orderSubmit(e,t){return this.request("/submit","post",this.#e.bind(this))(e,t)}}class B extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/m2m","get",this.#e.bind(this))(e)}create(e,t){return this.request("/m2m","post",this.#e.bind(this))(e,t)}me(e){return this.request("/m2m/me","get",this.#e.bind(this))(e)}get(e,t){return this.request("/m2m/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/m2m/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/m2m/{id}","delete",this.#e.bind(this))(e,t)}rotateSecret(e,t){return this.request("/m2m/{id}/rotate-secret","post",this.#e.bind(this))(e,t)}listV2(e,t){return this.request("/m2m/v2/list","get",this.#e.bind(this))(e,t)}}class F extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}getMessagingConfig(e){return this.request("/messaging/config","get",this.#e.bind(this))(e)}}class V extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}setUp(e,t){return this.request("/payment/payment-method/setup","post",this.#e.bind(this))(e,t)}setDefault(e,t){return this.request("/payment/payment-method/set-default","post",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/payment/payment-method","delete",this.#e.bind(this))(e,t)}list(e,t){return this.request("/payment/payment-method/list","post",this.#e.bind(this))(e,t)}}class W extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e){return this.request("/project","get",this.#e.bind(this))(e)}update(e,t){return this.request("/project","patch",this.#e.bind(this))(e,t)}}function X(){return this.config.services?.rcmApiUrl??"https://rcm-api.zapehr.com/v1"}function Z({id:e}){return`${X.call(this)}/payer/${e}`}async function K({url:e},t){if(!e.startsWith(Z.call(this,{id:""})))throw new s({code:400,message:"Invalid payer URL."});const r=new URL(e).pathname.split("/").filter(Boolean),i=r[r.length-1];return this.request("/payer/{id}","get",X.bind(this))({id:i},t)}class Q extends u{constructor(e){super(e)}#e(){return this.config.services?.rcmApiUrl??"https://rcm-api.zapehr.com/v1"}constructPayerUrl=Z;getPayerByUrl=K;eligibilityCheck(e,t){return this.request("/eligibility-check","post",this.#e.bind(this))(e,t)}submitClaim(e,t){return this.request("/claim/{claimId}/submit","post",this.#e.bind(this))(e,t)}setClaimStatus(e,t){return this.request("/claim/{claimId}/status","post",this.#e.bind(this))(e,t)}listPayers(e,t){return this.request("/payer","get",this.#e.bind(this))(e,t)}getPayer(e,t){return this.request("/payer/{id}","get",this.#e.bind(this))(e,t)}}class Y extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/iam/role","get",this.#e.bind(this))(e)}create(e,t){return this.request("/iam/role","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/iam/role/{roleId}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/iam/role/{roleId}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/iam/role/{roleId}","delete",this.#e.bind(this))(e,t)}}class ee extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/secret","get",this.#e.bind(this))(e)}set(e,t){return this.request("/secret","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/secret/{name}","get",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/secret/{name}","delete",this.#e.bind(this))(e,t)}}class te extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}createMeeting(e,t){return this.request("/telemed/v2/meeting","post",this.#e.bind(this))(e,t)}joinMeeting(e,t){return this.request("/telemed/v2/meeting/{encounterId}/join","get",this.#e.bind(this))(e,t)}}class se extends u{constructor(e){super(e)}#e(){return this.config.services?.terminologyApiUrl??"https://terminology-api.zapehr.com/v1"}searchCpt(e,t){return this.request("/cpt/search","get",this.#e.bind(this))(e,t)}searchHcpcs(e,t){return this.request("/hcpcs/search","get",this.#e.bind(this))(e,t)}}class re extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}send(e,t){return this.request("/messaging/transactional-sms/send","post",this.#e.bind(this))(e,t)}}class ie extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}me(e){return this.request("/user/me","get",this.#e.bind(this))(e)}get(e,t){return this.request("/user/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/user/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/user/{id}","delete",this.#e.bind(this))(e,t)}resetMfa(e,t){return this.request("/user/{id}/reset-mfa","post",this.#e.bind(this))(e,t)}resetPasswordLink(e,t){return this.request("/user/{id}/reset-password-link","post",this.#e.bind(this))(e,t)}changePassword(e,t){return this.request("/user/{id}/change-password","post",this.#e.bind(this))(e,t)}invite(e,t){return this.request("/user/invite","post",this.#e.bind(this))(e,t)}list(e){return this.request("/user","get",this.#e.bind(this))(e)}listV2(e,t){return this.request("/user/v2/list","get",this.#e.bind(this))(e,t)}}class ne extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e){return this.request("/version","get",this.#e.bind(this))(e)}}function oe(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}async function ae({bucketName:e,"objectPath+":t,file:s}){const r=await this.request("/z3/{bucketName}/{objectPath+}","post",oe.bind(this))({action:"upload",bucketName:e,"objectPath+":t});await fetch(r.signedUrl,{method:"PUT",body:s})}async function ue({bucketName:e,"objectPath+":t}){const s=await this.request("/z3/{bucketName}/{objectPath+}","post",oe.bind(this))({action:"download",bucketName:e,"objectPath+":t}),r=await fetch(s.signedUrl,{method:"GET"});if(!r.ok)throw new Error("Failed to download file");return r.arrayBuffer()}async function he(e){let t,r;const i=new URL(e.url);if("z3:"===i.protocol){const e=i.pathname.split("/").slice(1);t=i.hostname,r=e.join("/")}else{if(!i.href.startsWith(this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"))throw new s({message:"Invalid Z3 URL",code:400});{const e=i.pathname.split("/").slice(3);t=e[0],r=e.slice(1).join("/")}}const n={action:"upload",bucketName:t,"objectPath+":r};return this.request("/z3/{bucketName}/{objectPath+}","post",oe.bind(this))(n)}class ce extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}uploadFile=ae;downloadFile=ue;getPresignedUrlForZ3Url=he;listBuckets(e){return this.request("/z3","get",this.#e.bind(this))(e)}createBucket(e,t){return this.request("/z3/{bucketName}","put",this.#e.bind(this))(e,t)}deleteBucket(e,t){return this.request("/z3/{bucketName}","delete",this.#e.bind(this))(e,t)}listObjects(e,t){return this.request("/z3/{bucketName}/{objectPath+}","get",this.#e.bind(this))(e,t)}getPresignedUrl(e,t){return this.request("/z3/{bucketName}/{objectPath+}","post",this.#e.bind(this))(e,t)}deleteObject(e,t){return this.request("/z3/{bucketName}/{objectPath+}","delete",this.#e.bind(this))(e,t)}}function le(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}async function de({id:e,file:t,filename:s}){const r=await this.request("/zambda/{id}/s3-upload","post",le.bind(this))({id:e,filename:s});await fetch(r.signedUrl,{method:"PUT",body:t})}class pe extends u{constructor(e){super(e)}#e(){return this.config.services?.zambdaApiUrl??"https://zambda-api.zapehr.com/v1"}uploadFile=de;list(e){return this.request("/zambda","get",this.#e.bind(this))(e)}create(e,t){return this.request("/zambda","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/zambda/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/zambda/{id}","delete",this.#e.bind(this))(e,t)}execute(e,t){return this.request("/zambda/{id}/execute","post",this.#e.bind(this))(e,t)}executePublic(e,t){return this.request("/zambda/{id}/execute-public","post",this.#e.bind(this))(e,t)}s3Upload(e,t){return this.request("/zambda/{id}/s3-upload","post",this.#e.bind(this))(e,t)}}class be extends u{constructor(e){super(e)}#e(){return this.config.services?.zambdaApiUrl??"https://zambda-api.zapehr.com/v1"}list(e,t){return this.request("/zambda/{id}/logStream","post",this.#e.bind(this))(e,t)}search(e,t){return this.request("/zambda/{id}/logStream/search","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}/logStream/{logStreamName}","post",this.#e.bind(this))(e,t)}}let ge=class{config;application;developer;m2m;messaging;conversation;transactionalSMS;paymentMethod;charge;project;role;secret;telemed;user;version;z3;fax;lab;erx;terminology;zambda;zambdaLogStream;rcm;fhir;constructor(e){if(e.workspaceTag&&e.ignoreTags)throw new s({message:"workspaceTag and ignoreTags are mutually exclusive and cannot both be set in config",code:400});this.config=e,this.config.services??={},this.config.services.projectApiUrl??=e.projectApiUrl,this.config.services.fhirApiUrl??=e.fhirApiUrl,this.application=new d(e),this.developer=new T(e),this.m2m=new B(e),this.messaging=new F(e),this.conversation=new f(e),this.transactionalSMS=new re(e),this.paymentMethod=new V(e),this.charge=new p(e),this.project=new W(e),this.role=new Y(e),this.secret=new ee(e),this.telemed=new te(e),this.user=new ie(e),this.version=new ne(e),this.z3=new ce(e),this.fax=new k(e),this.lab=new H(e),this.erx=new U(e),this.terminology=new se(e),this.zambda=new pe(e),this.zambdaLogStream=new be(e),this.rcm=new Q(e),this.fhir=new G(e)}};class me extends ge{static OystehrFHIRError=i;static OystehrSdkError=s}export{me as default};
|
|
1
|
+
import{v4 as e,validate as t}from"uuid";class s extends Error{code;constructor({message:e,code:t,cause:r}){super(e,{cause:r}),Object.setPrototypeOf(this,s.prototype),this.code=t,this.name="OystehrSdkError"}toString(){return`${this.name}: ${this.message} (code: ${this.code})`}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}function r(e){const t=[];for(const s of e.issue??[])s.details&&s.details.text&&t.push(s.details.text);return t.length||t.push("Unknown FHIR error"),t.join(",")}class i extends s{cause;constructor({error:e,code:t}){super({message:r(e),code:t}),Object.setPrototypeOf(this,i.prototype),this.cause=e,this.name="OystehrFHIRError"}toJSON(){return{name:this.name,message:this.message,code:this.code,cause:this.cause}}}class n{_level;constructor({level:e}){this._level=e}error(e,t={}){this._level&&["error","info","debug"].includes(this._level)&&console.error(JSON.stringify({message:e,...t}))}info(e,t={}){this._level&&["info","debug"].includes(this._level)&&console.info(JSON.stringify({message:e,...t}))}debug(e,t={}){this._level&&["debug"].includes(this._level)&&console.debug(JSON.stringify({message:e,...t}))}time(e,t={}){this._level&&["debug"].includes(this._level)&&console.time(JSON.stringify({message:e,...t}))}timeEnd(e,t={}){this._level&&["debug"].includes(this._level)&&console.timeEnd(JSON.stringify({message:e,...t}))}}const o=[408,429,500,502,503,504],a=["ECONNRESET","ECONNREFUSED","EPIPE","ETIMEDOUT","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_SOCKET"];class u{config;logger;constructor(e){this.config=e,this.logger=new n({level:this.config.logLevel})}request(e,t,r){return async(i,n)=>{const o=()=>this.config,a=()=>this.logger;try{return await c(r,o,a,e,t)(i,n)}catch(e){const t=e;throw this.logger.error(t.message,{code:t.code,cause:t.cause}),new s({message:t.message,code:t.code,cause:t.cause})}}}fhirRequest(e,t){return async(r,n)=>{try{const s=()=>this.config.services?.fhirApiUrl??"https://fhir-api.zapehr.com",i=()=>this.config,o=()=>this.logger;return await c(s,i,o,e,t)(r,n)}catch(e){const t=e;if("string"==typeof t.message)throw new s({message:t.message,code:t.code,cause:t.cause});throw new i({error:t.message,code:t.code})}}}}function h(e){return"accessToken"in e||"projectId"in e&&t(e.projectId)||"contentType"in e&&2===e.contentType?.split("/").length||"requestId"in e||"ifMatch"in e&&e.ifMatch.startsWith('W/"')}function c(t,r,i,n,u){return async(c,d)=>{let[p,b]=function(e,t){const s=e&&!t&&!Array.isArray(e)&&h(e)?{}:e??{},r=e&&!t&&!Array.isArray(e)&&h(e)?e:t;return[s,r]}(c,d);b??={},b.requestId??=e();const g=r(),m=i(),f=u.toLowerCase();m.debug("Beginning fetch",{method:f,path:n,requestId:b?.requestId});const T=g.fetch??fetch,U=b?.accessToken??g.accessToken,k=b?.projectId??g.projectId;let y=n,q=p;if(!Array.isArray(p)){const[e,t]=function(e,t){const r={...t},i=e.replace(/\{([^}]+)\}/g,((e,i)=>{if(delete r[i],i.match(/^.*\+$/))return t[i]+"";if(!t[i]||""===t[i])throw new s({message:`Required path parameter is an empty string: ${i}`,code:400});return t[i]?encodeURIComponent(t[i]+""):""})),n=Object.keys(r),o=n.length?n.reduce(((e,t)=>({...e,[t]:r[t]})),{}):{};return[i,o]}(n,p);y=e,q=t}m.debug("Substituted parameters in path",{method:f,path:n,requestId:b?.requestId}),y=y.replace(/^\//,"");const v=t(),w=v.endsWith("/")?v:v+"/",j=new URL(y,w);let I;if(Array.isArray(q))I=JSON.stringify(q);else if(Object.keys(q).length)if("get"===f)l(q,j.searchParams);else if("application/x-www-form-urlencoded"===b?.contentType){const e=new URLSearchParams;l(q,e),I=e.toString()}else I=JSON.stringify(q);else"application/x-www-form-urlencoded"!==b?.contentType&&"post"===f&&(I="{}");m.debug("Prepared request body",{method:f,path:n,requestId:b?.requestId});const z=Object.assign(k?{"x-zapehr-project-id":k,"x-oystehr-project-id":k}:{},{"content-type":b?.contentType??"application/json"},U?{Authorization:`Bearer ${U}`}:{},b?.ifMatch?{"If-Match":b.ifMatch}:{},{"x-oystehr-request-id":b?.requestId}),x={retries:g.retry?.retries??3,jitter:g.retry?.jitter??20,delay:g.retry?.delay??100,onRetry:g.retry?.onRetry,retryOn:[...g.retry?.retryOn??[],...o]};return x.retryOn.push(...o),async function(e,t){let s;for(const r of Array.from({length:(t.retries??0)+1},((e,t)=>t)))try{return await e(r)}catch(e){let i=!1;if("response"in e){const r=e;i=t.retryOn.includes(r.code),s={message:e.message,code:e.code}}else if(s=e,"code"in e&&"string"==typeof e.code){const t=e;i=a.includes(t.code)}if(!i)break;const n=Math.floor(Math.random()*(t.jitter+1));await new Promise((e=>setTimeout(e,t.delay+n))),t.onRetry&&r!==(t.retries??0)&&t.onRetry(r+1)}throw s}((async()=>{m.info("Request start",{method:f,url:j,requestId:b?.requestId});const e=Date.now(),t=await T(new Request(j,{method:f.toUpperCase(),body:I,headers:z}));m.info("Request end",{method:f,url:j,duration:Date.now()-e,requestId:b?.requestId});const s=t.body?await t.text():null;let r;const i=t.headers.get("content-type");try{s&&(i?.includes("application/json")||i?.includes("application/fhir+json"))?(m.time("Deserialized JSON response",{method:f,url:j,requestId:b?.requestId}),r=JSON.parse(s),m.timeEnd("Deserialized JSON response",{method:f,url:j,requestId:b?.requestId})):s&&(i?.includes("application/xml")||i?.includes("text/xml"))?(m.time("Deserialized XML response",{method:f,url:j,requestId:b?.requestId}),r=function(e){try{const t=e.match(/<status>(\d+)<\/status>/),s=t?parseInt(t[1],10):null,r=e.match(/<output>([\s\S]*?)<\/output>/),i=r?r[1]:null;return null===s||null===i?null:{status:s,output:i}}catch(e){return null}}(s),m.timeEnd("Deserialized XML response",{method:f,url:j,requestId:b?.requestId})):r=null}catch(e){r=null}m.debug("Deserialized response",{method:f,url:j,requestId:b?.requestId});if(!t.ok||t.status>=400){throw{message:("string"==typeof r?.output?r.output:r?.output?.message)??r?.message??r??s??t.statusText,code:r?.output?.code??r?.code??t.status,response:t}}return r}),x)}}function l(e,t){for(const[s,r]of Object.entries(e))Array.isArray(r)?r.forEach((e=>null!=e&&t.append(s,e))):null!=r&&t.append(s,r)}class d extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/application","get",this.#e.bind(this))(e)}create(e,t){return this.request("/application","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/application/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/application/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/application/{id}","delete",this.#e.bind(this))(e,t)}rotateSecret(e,t){return this.request("/application/{id}/rotate-secret","post",this.#e.bind(this))(e,t)}revokeRefreshToken(e,t){return this.request("/application/{id}/revoke-refresh-token","post",this.#e.bind(this))(e,t)}revokeAccessToken(e,t){return this.request("/application/{id}/revoke-access-token","post",this.#e.bind(this))(e,t)}}class p extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}issue(e,t){return this.request("/payment/charge/issue","post",this.#e.bind(this))(e,t)}status(e,t){return this.request("/payment/charge/status","post",this.#e.bind(this))(e,t)}}const b="https://extensions.fhir.zapehr.com/encounter-virtual-service-pre-release",g="addressString";function m(e){if(function(e){return Object.hasOwn(e,"virtualService")}(e)){const t=e.virtualService?.find((e=>"https://fhir.zapehr.com/virtual-service-type"===e.channelType?.system));return t?.addressString}if(!e.extension)return;const t=e.extension.find((e=>e.url===b));if(!t?.extension)return;const s=t.extension?.find((e=>e.url===g))?.valueString;return s}class f extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}ENCOUNTER_VS_EXTENSION_URL=b;ENCOUNTER_VS_EXTENSION_RELATIVE_URL=g;getConversationIdFromEncounter=m;create(e,t){return this.request("/messaging/conversation","post",this.#e.bind(this))(e,t)}getToken(e){return this.request("/messaging/conversation/token","get",this.#e.bind(this))(e)}addParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","post",this.#e.bind(this))(e,t)}removeParticipant(e,t){return this.request("/messaging/conversation/{conversationId}/participant","delete",this.#e.bind(this))(e,t)}message(e,t){return this.request("/messaging/conversation/{conversationId}/message","post",this.#e.bind(this))(e,t)}}class T extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e,t){return this.request("/developer/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/developer/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/developer/{id}","delete",this.#e.bind(this))(e,t)}invite(e,t){return this.request("/developer/invite","post",this.#e.bind(this))(e,t)}list(e){return this.request("/developer","get",this.#e.bind(this))(e)}listV2(e,t){return this.request("/developer/v2/list","get",this.#e.bind(this))(e,t)}}class U extends u{constructor(e){super(e)}#e(){return this.config.services?.erxApiUrl??"https://erx-api.zapehr.com/v3"}searchAllergens(e,t){return this.request("/allergen","get",this.#e.bind(this))(e,t)}searchMedications(e,t){return this.request("/medication","get",this.#e.bind(this))(e,t)}getMedication(e,t){return this.request("/medication/details","get",this.#e.bind(this))(e,t)}getConfiguration(e){return this.request("/config","get",this.#e.bind(this))(e)}checkAllergyInteractions(e,t){return this.request("/patient/{patientId}/interactions/allergy","get",this.#e.bind(this))(e,t)}checkMedicationInteractions(e,t){return this.request("/patient/{patientId}/interactions/medication","get",this.#e.bind(this))(e,t)}checkPrecheckInteractions(e,t){return this.request("/patient/{patientId}/interactions/precheck/{drugId}","get",this.#e.bind(this))(e,t)}getMedicationHistory(e,t){return this.request("/patient/{patientId}/medication-history","get",this.#e.bind(this))(e,t)}addPatientPharmacy(e,t){return this.request("/patient/{patientId}/pharmacies","post",this.#e.bind(this))(e,t)}cancelPrescription(e,t){return this.request("/patient/{patientId}/prescriptions/{medicationRequestId}","delete",this.#e.bind(this))(e,t)}syncPatient(e,t){return this.request("/patient/{patientId}/sync","post",this.#e.bind(this))(e,t)}searchPharmacies(e,t){return this.request("/pharmacy","get",this.#e.bind(this))(e,t)}connectPractitioner(e,t){return this.request("/practitioner/connect","get",this.#e.bind(this))(e,t)}checkPractitionerEnrollment(e,t){return this.request("/practitioner/{practitionerId}","get",this.#e.bind(this))(e,t)}enrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","post",this.#e.bind(this))(e,t)}unenrollPractitioner(e,t){return this.request("/practitioner/{practitionerId}","delete",this.#e.bind(this))(e,t)}}class k extends u{constructor(e){super(e)}#e(){return this.config.services?.faxApiUrl??"https://fax-api.zapehr.com/v1"}offboard(e){return this.request("/offboard","post",this.#e.bind(this))(e)}onboard(e){return this.request("/onboard","post",this.#e.bind(this))(e)}getConfiguration(e){return this.request("/config","get",this.#e.bind(this))(e)}send(e,t){return this.request("/send","post",this.#e.bind(this))(e,t)}}const y=65535;function q(e){const t=(new globalThis.TextEncoder).encode(e);let s="";for(let e=0;e<t.length;e+=y){const r=t.subarray(e,e+y);s+=globalThis.btoa(String.fromCodePoint.apply(void 0,r))}return s}function v(e){return e.system?`${e.system}|${e.code??""}`:e.code??""}function w(e,t){return(e.system??"")===(t.system??"")&&(e.code??"")===(t.code??"")}function j(e,t){const r=t;if(e.ignoreTags?.length){const i=r.meta?.tag??[];for(const t of e.ignoreTags)if(i.some((e=>w(e,t))))throw new s({message:`Resource has an ignored tag (system: "${t.system??""}", code: "${t.code??""}") and cannot be mutated in ignoreTags mode`,code:400});return t}if(e.workspaceTag){const s=e.workspaceTag,i=r.meta?.tag??[];if(!i.some((e=>w(e,s))))return{...t,meta:{...r.meta,tag:[...i,s]}}}return t}function I(e,t){if(e.ignoreTags?.length){for(const r of t)if("add"===r.op||"replace"===r.op||"test"===r.op){const t=r.value;if(null!=t&&"object"==typeof t){const r=t;if(void 0!==r.code)for(const t of e.ignoreTags)if(w(r,t))throw new s({message:`Patch operation contains an ignored tag (system: "${t.system??""}", code: "${t.code??""}") and cannot be applied in ignoreTags mode`,code:400})}}return t}if(e.workspaceTag){const s=e.workspaceTag;return t.reduce(((e,t)=>{if("remove"===t.op&&"/meta/tag"===t.path)return e.push(t),e.push({op:"add",path:"/meta/tag",value:[s]}),e;if("remove"===t.op&&"/meta"===t.path)return e.push(t),e.push({op:"add",path:"/meta",value:{tag:[s]}}),e;if(("add"===t.op||"replace"===t.op)&&"/meta/tag"===t.path){const r=Array.isArray(t.value)?t.value:[];return r.some((e=>w(e,s)))?e.push(t):e.push({...t,value:[...r,s]}),e}if(("add"===t.op||"replace"===t.op)&&"/meta"===t.path){const r=null!=t.value&&"object"==typeof t.value?t.value:{},i=r.tag??[];return i.some((e=>w(e,s)))?e.push(t):e.push({...t,value:{...r,tag:[...i,s]}}),e}return e.push(t),e}),[])}return t}function z(e,t){const s=t,r=s.meta?.tag??[];if(e.workspaceTag){const t=e.workspaceTag;if(!r.some((e=>w(e,t))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}else if(e.ignoreTags?.length)for(const t of e.ignoreTags)if(r.some((e=>w(e,t))))throw new i({error:{resourceType:"OperationOutcome",id:"not-found",issue:[{severity:"error",code:"not-found",details:{text:"Not found"}}]},code:404})}async function x(e,t){const{resourceType:s}=e,r=function(e,t){const s=t?[...t]:[];if(e.workspaceTag)s.push({name:"_tag",value:v(e.workspaceTag)});else if(e.ignoreTags?.length)for(const t of e.ignoreTags)s.push({name:"_tag:not",value:v(t)});return s}(this.config,e.params);let i;r.length&&(i=r.reduce(((e,t)=>(e[t.name]||(e[t.name]=[]),e[t.name].push(t.value),e)),{}));const n=await this.fhirRequest(`/${s}/_search`,"POST")(i,{...t,contentType:"application/x-www-form-urlencoded"});return{...n,entry:n.entry,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]}}}async function E(e,t){const s=j(this.config,e),{resourceType:r}=s;return this.fhirRequest(`/${r}`,"POST")(s,t)}async function S({resourceType:e,id:t},s){const r=await this.fhirRequest(`/${e}/${t}`,"GET")({},s);return z(this.config,r),r}async function A(e,t){const s=j(this.config,e),{id:r,resourceType:i}=s;return this.fhirRequest(`/${i}/${r}`,"PUT")(s,{...t,ifMatch:t?.optimisticLockingVersionId?`W/"${t.optimisticLockingVersionId}"`:void 0})}async function P({resourceType:e,id:t,operations:s},r){const i=I(this.config,s);return this.fhirRequest(`/${e}/${t}`,"PATCH")(i,{...r,contentType:"application/json-patch+json",ifMatch:r?.optimisticLockingVersionId?`W/"${r.optimisticLockingVersionId}"`:void 0})}async function O({resourceType:e,id:t},s){return this.fhirRequest(`/${e}/${t}`,"DELETE")({},s)}async function R({resourceType:e,id:t,versionId:s,count:r,offset:i},n){return s?this.fhirRequest(`/${e}/${t}/_history/${s}`,"GET")({},n):r?this.fhirRequest(`/${e}/${t}/_history?_total=accurate&_count=${r}\n ${i?`&_offset=${i}`:""}`,"GET")({},n):this.fhirRequest(`/${e}/${t}/_history?_total=accurate`,"GET")({},n)}function N(e){const t=e.split("?")[0].split("/").filter(Boolean);return t.length<=1||t[1].startsWith("_")}function _(e){return e.split("?")[0].endsWith("/_search")}function $(e,t){const{method:s}=e;let r=e.url;if((("GET"===s||"HEAD"===s)&&N(r)||"POST"===s&&_(r))&&(t.workspaceTag&&(r+=(r.includes("?")?"&":"?")+`_tag=${v(t.workspaceTag)}`),t.ignoreTags?.length))for(const e of t.ignoreTags)r+=(r.includes("?")?"&":"?")+`_tag:not=${v(e)}`;const i={request:{method:s,url:r}};if(r.split("?").length>1){const[e,t]=r.split("?"),s=t.split("&").map((e=>{const[t,s]=e.split("=");return{name:t,value:s}})).reduce(((e,{name:t,value:s})=>t?(e[t]||(e[t]=[]),e[t].push(s),e):e),{}),n=new URLSearchParams;l(s,n),i.request.url=`${e}?${n.toString()}`}if(["GET","DELETE","HEAD"].includes(s))return i;if("PUT"===s){const s=j(t,e.resource);return{request:{...i.request,ifMatch:e.ifMatch},resource:s}}if("PATCH"===s){if("resource"in e){let s=e.resource;const r=s.data;if(r){const e=I(t,JSON.parse(function(e){const t=globalThis.atob(e),s=new Uint8Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);return(new globalThis.TextDecoder).decode(s)}(r)));s={...s,data:q(JSON.stringify(e))}}return{request:{...i.request,ifMatch:e.ifMatch},resource:s}}const s=I(t,e.operations),r=q(JSON.stringify(s));return{...i,resource:{resourceType:"Binary",contentType:"application/json-patch+json",data:r}}}if("POST"===s&&_(r))return i;if("POST"===s&&"resource"in e){const s=j(t,e.resource),{fullUrl:r}=e;return{...i,resource:s,fullUrl:r}}throw new Error("Unrecognized method")}async function M(e,t){const s=await this.fhirRequest("/","POST")({resourceType:"Bundle",type:"batch",entry:e.requests.map((e=>$(e,this.config)))},t),r=s.entry,n=this.config.workspaceTag||this.config.ignoreTags?.length?r?.map(((t,s)=>{const r=e.requests[s];if(!r||!t?.resource)return t;if(("GET"===r.method||"HEAD"===r.method)&&!N(r.url))try{z(this.config,t.resource)}catch(e){if(!(e instanceof i))throw e;return{request:t.request,response:{status:"404",outcome:e.cause}}}return t})):r;return{...s,entry:n,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]},errors:function(){return this.entry?.filter((e=>e.response?.status?.startsWith("4")||e.response?.status?.startsWith("5"))).map((e=>e.response?.outcome)).filter((e=>void 0!==e))}}}async function C(e,t){const s=await this.fhirRequest("/","POST")({resourceType:"Bundle",type:"transaction",entry:e.requests.map((e=>$(e,this.config)))},t);(this.config.workspaceTag||this.config.ignoreTags?.length)&&s.entry?.forEach(((t,s)=>{const r=e.requests[s];r&&t?.resource&&("GET"!==r.method&&"HEAD"!==r.method||N(r.url)||z(this.config,t.resource))}));return{...s,entry:s.entry,unbundle:function(){return this.entry?.map((e=>e.resource)).filter((e=>void 0!==e))??[]}}}async function L({id:e},t){return this.fhirRequest(`/Patient/${e}/$generate-friendly-patient-id`,"POST")({},t)}function D(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&&(t?.all||t?.use)&&s.push("["+e.use+"]"),s.join(t?.lineSeparator||", ").trim()}function G(e,t){const s=[];return e.prefix&&!1!==t?.prefix&&s.push(...e.prefix),e.given&&s.push(...e.given),e.family&&s.push(e.family),e.suffix&&!1!==t?.suffix&&s.push(...e.suffix),e.use&&(t?.all||t?.use)&&s.push("["+e.use+"]"),s.join(" ").trim()}class J extends u{constructor(e){super(e)}#e(){return this.config.services?.fhirApiUrl??"https://fhir-api.zapehr.com"}search=x;create=E;get=S;update=A;patch=P;delete=O;history=R;batch=M;transaction=C;generateFriendlyPatientId=L;formatAddress=D;formatHumanName=G}class F extends u{constructor(e){super(e)}#e(){return this.config.services?.labApiUrl??"https://labs-api.zapehr.com/v1"}routeList(e){return this.request("/route","get",this.#e.bind(this))(e)}routeCreate(e,t){return this.request("/route","post",this.#e.bind(this))(e,t)}routeGet(e,t){return this.request("/route/{routeGuid}","get",this.#e.bind(this))(e,t)}routeDelete(e,t){return this.request("/route/{routeGuid}","delete",this.#e.bind(this))(e,t)}orderableItemList(e,t){return this.request("/orderableItem","get",this.#e.bind(this))(e,t)}orderableItemQuestionnaireGet(e,t){return this.request("/canonical-questionnaire/lab/{labGuid}/compendium/{compendiumVersion}/item/{itemCode}/questionnaire","get",this.#e.bind(this))(e,t)}orderSubmit(e,t){return this.request("/submit","post",this.#e.bind(this))(e,t)}}class H extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/m2m","get",this.#e.bind(this))(e)}create(e,t){return this.request("/m2m","post",this.#e.bind(this))(e,t)}me(e){return this.request("/m2m/me","get",this.#e.bind(this))(e)}get(e,t){return this.request("/m2m/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/m2m/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/m2m/{id}","delete",this.#e.bind(this))(e,t)}rotateSecret(e,t){return this.request("/m2m/{id}/rotate-secret","post",this.#e.bind(this))(e,t)}listV2(e,t){return this.request("/m2m/v2/list","get",this.#e.bind(this))(e,t)}}class B extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}getMessagingConfig(e){return this.request("/messaging/config","get",this.#e.bind(this))(e)}}class V extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}setUp(e,t){return this.request("/payment/payment-method/setup","post",this.#e.bind(this))(e,t)}setDefault(e,t){return this.request("/payment/payment-method/set-default","post",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/payment/payment-method","delete",this.#e.bind(this))(e,t)}list(e,t){return this.request("/payment/payment-method/list","post",this.#e.bind(this))(e,t)}}class W extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e){return this.request("/project","get",this.#e.bind(this))(e)}update(e,t){return this.request("/project","patch",this.#e.bind(this))(e,t)}}function X(){return this.config.services?.rcmApiUrl??"https://rcm-api.zapehr.com/v1"}function Z({id:e}){return`${X.call(this)}/payer/${e}`}async function K({url:e},t){if(!e.startsWith(Z.call(this,{id:""})))throw new s({code:400,message:"Invalid payer URL."});const r=new URL(e).pathname.split("/").filter(Boolean),i=r[r.length-1];return this.request("/payer/{id}","get",X.bind(this))({id:i},t)}class Q extends u{constructor(e){super(e)}#e(){return this.config.services?.rcmApiUrl??"https://rcm-api.zapehr.com/v1"}constructPayerUrl=Z;getPayerByUrl=K;eligibilityCheck(e,t){return this.request("/eligibility-check","post",this.#e.bind(this))(e,t)}submitClaim(e,t){return this.request("/claim/{claimId}/submit","post",this.#e.bind(this))(e,t)}setClaimStatus(e,t){return this.request("/claim/{claimId}/status","post",this.#e.bind(this))(e,t)}listPayers(e,t){return this.request("/payer","get",this.#e.bind(this))(e,t)}getPayer(e,t){return this.request("/payer/{id}","get",this.#e.bind(this))(e,t)}}class Y extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/iam/role","get",this.#e.bind(this))(e)}create(e,t){return this.request("/iam/role","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/iam/role/{roleId}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/iam/role/{roleId}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/iam/role/{roleId}","delete",this.#e.bind(this))(e,t)}}class ee extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}list(e){return this.request("/secret","get",this.#e.bind(this))(e)}set(e,t){return this.request("/secret","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/secret/{name}","get",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/secret/{name}","delete",this.#e.bind(this))(e,t)}}class te extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}createMeeting(e,t){return this.request("/telemed/v2/meeting","post",this.#e.bind(this))(e,t)}joinMeeting(e,t){return this.request("/telemed/v2/meeting/{encounterId}/join","get",this.#e.bind(this))(e,t)}}class se extends u{constructor(e){super(e)}#e(){return this.config.services?.terminologyApiUrl??"https://terminology-api.zapehr.com/v1"}searchCpt(e,t){return this.request("/cpt/search","get",this.#e.bind(this))(e,t)}searchHcpcs(e,t){return this.request("/hcpcs/search","get",this.#e.bind(this))(e,t)}}class re extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}send(e,t){return this.request("/messaging/transactional-sms/send","post",this.#e.bind(this))(e,t)}}class ie extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}me(e){return this.request("/user/me","get",this.#e.bind(this))(e)}get(e,t){return this.request("/user/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/user/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/user/{id}","delete",this.#e.bind(this))(e,t)}resetMfa(e,t){return this.request("/user/{id}/reset-mfa","post",this.#e.bind(this))(e,t)}resetPasswordLink(e,t){return this.request("/user/{id}/reset-password-link","post",this.#e.bind(this))(e,t)}changePassword(e,t){return this.request("/user/{id}/change-password","post",this.#e.bind(this))(e,t)}invite(e,t){return this.request("/user/invite","post",this.#e.bind(this))(e,t)}list(e){return this.request("/user","get",this.#e.bind(this))(e)}listV2(e,t){return this.request("/user/v2/list","get",this.#e.bind(this))(e,t)}}class ne extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}get(e){return this.request("/version","get",this.#e.bind(this))(e)}}function oe(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}async function ae({bucketName:e,"objectPath+":t,file:s}){const r=await this.request("/z3/{bucketName}/{objectPath+}","post",oe.bind(this))({action:"upload",bucketName:e,"objectPath+":t});await fetch(r.signedUrl,{method:"PUT",body:s})}async function ue({bucketName:e,"objectPath+":t}){const s=await this.request("/z3/{bucketName}/{objectPath+}","post",oe.bind(this))({action:"download",bucketName:e,"objectPath+":t}),r=await fetch(s.signedUrl,{method:"GET"});if(!r.ok)throw new Error("Failed to download file");return r.arrayBuffer()}async function he(e){let t,r;const i=new URL(e.url);if("z3:"===i.protocol){const e=i.pathname.split("/").slice(1);t=i.hostname,r=e.join("/")}else{if(!i.href.startsWith(this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"))throw new s({message:"Invalid Z3 URL",code:400});{const e=i.pathname.split("/").slice(3);t=e[0],r=e.slice(1).join("/")}}const n={action:"upload",bucketName:t,"objectPath+":r};return this.request("/z3/{bucketName}/{objectPath+}","post",oe.bind(this))(n)}class ce extends u{constructor(e){super(e)}#e(){return this.config.services?.projectApiUrl??"https://project-api.zapehr.com/v1"}uploadFile=ae;downloadFile=ue;getPresignedUrlForZ3Url=he;listBuckets(e){return this.request("/z3","get",this.#e.bind(this))(e)}createBucket(e,t){return this.request("/z3/{bucketName}","put",this.#e.bind(this))(e,t)}deleteBucket(e,t){return this.request("/z3/{bucketName}","delete",this.#e.bind(this))(e,t)}listObjects(e,t){return this.request("/z3/{bucketName}/{objectPath+}","get",this.#e.bind(this))(e,t)}getPresignedUrl(e,t){return this.request("/z3/{bucketName}/{objectPath+}","post",this.#e.bind(this))(e,t)}deleteObject(e,t){return this.request("/z3/{bucketName}/{objectPath+}","delete",this.#e.bind(this))(e,t)}}function le(){return this.config.services?.zambdaApiUrl??"https://zambda-api.zapehr.com/v1"}async function de({id:e,file:t,filename:r}){const i=await this.request("/zambda/{id}/presigned-url","post",le.bind(this))({id:e,action:"upload",filename:r}),n=await fetch(i.signedUrl,{method:"PUT",body:t});if(!n.ok)throw new s({message:"Failed to upload file",code:n.status,cause:n.statusText})}async function pe({id:e}){const t=await this.request("/zambda/{id}/presigned-url","post",le.bind(this))({id:e,action:"download"}),r=await fetch(t.signedUrl,{method:"GET"});if(!r.ok)throw new s({message:"Failed to download file",code:r.status,cause:r.statusText});return r.arrayBuffer()}class be extends u{constructor(e){super(e)}#e(){return this.config.services?.zambdaApiUrl??"https://zambda-api.zapehr.com/v1"}uploadFile=de;downloadFile=pe;list(e){return this.request("/zambda","get",this.#e.bind(this))(e)}create(e,t){return this.request("/zambda","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}","get",this.#e.bind(this))(e,t)}update(e,t){return this.request("/zambda/{id}","patch",this.#e.bind(this))(e,t)}delete(e,t){return this.request("/zambda/{id}","delete",this.#e.bind(this))(e,t)}execute(e,t){return this.request("/zambda/{id}/execute","post",this.#e.bind(this))(e,t)}executePublic(e,t){return this.request("/zambda/{id}/execute-public","post",this.#e.bind(this))(e,t)}s3Upload(e,t){return this.request("/zambda/{id}/s3-upload","post",this.#e.bind(this))(e,t)}getPresignedUrl(e,t){return this.request("/zambda/{id}/presigned-url","post",this.#e.bind(this))(e,t)}}class ge extends u{constructor(e){super(e)}#e(){return this.config.services?.zambdaApiUrl??"https://zambda-api.zapehr.com/v1"}list(e,t){return this.request("/zambda/{id}/logStream","post",this.#e.bind(this))(e,t)}search(e,t){return this.request("/zambda/{id}/logStream/search","post",this.#e.bind(this))(e,t)}get(e,t){return this.request("/zambda/{id}/logStream/{logStreamName}","post",this.#e.bind(this))(e,t)}}let me=class{config;application;developer;m2m;messaging;conversation;transactionalSMS;paymentMethod;charge;project;role;secret;telemed;user;version;z3;fax;lab;erx;terminology;zambda;zambdaLogStream;rcm;fhir;constructor(e){if(e.workspaceTag&&e.ignoreTags)throw new s({message:"workspaceTag and ignoreTags are mutually exclusive and cannot both be set in config",code:400});this.config=e,this.config.services??={},this.config.services.projectApiUrl??=e.projectApiUrl,this.config.services.fhirApiUrl??=e.fhirApiUrl,this.application=new d(e),this.developer=new T(e),this.m2m=new H(e),this.messaging=new B(e),this.conversation=new f(e),this.transactionalSMS=new re(e),this.paymentMethod=new V(e),this.charge=new p(e),this.project=new W(e),this.role=new Y(e),this.secret=new ee(e),this.telemed=new te(e),this.user=new ie(e),this.version=new ne(e),this.z3=new ce(e),this.fax=new k(e),this.lab=new F(e),this.erx=new U(e),this.terminology=new se(e),this.zambda=new be(e),this.zambdaLogStream=new ge(e),this.rcm=new Q(e),this.fhir=new J(e)}};class fe extends me{static OystehrFHIRError=i;static OystehrSdkError=s}export{fe as default};
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|