@oystehr/sdk 4.3.6 → 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/client/client.cjs +4 -2
- package/dist/cjs/client/client.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/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/client/client.js +4 -2
- 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/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/client/client.ts +4 -2
- 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,13 +1,32 @@
|
|
|
1
|
+
import { OystehrSdkError } from '../../errors/index.js';
|
|
2
|
+
|
|
1
3
|
function baseUrlThunk() {
|
|
2
|
-
return this.config.services?.['
|
|
4
|
+
return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';
|
|
3
5
|
}
|
|
4
6
|
async function uploadFile({ id, file, filename, }) {
|
|
5
|
-
const uploadUrl = await this.request('/zambda/{id}/
|
|
6
|
-
await fetch(uploadUrl.signedUrl, {
|
|
7
|
+
const uploadUrl = await this.request('/zambda/{id}/presigned-url', 'post', baseUrlThunk.bind(this))({ id, action: 'upload', filename });
|
|
8
|
+
const response = await fetch(uploadUrl.signedUrl, {
|
|
7
9
|
method: 'PUT',
|
|
8
10
|
body: file,
|
|
9
11
|
});
|
|
12
|
+
if (!response.ok) {
|
|
13
|
+
throw new OystehrSdkError({ message: 'Failed to upload file', code: response.status, cause: response.statusText });
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
async function downloadFile({ id }) {
|
|
17
|
+
const downloadUrl = await this.request('/zambda/{id}/presigned-url', 'post', baseUrlThunk.bind(this))({ id, action: 'download' });
|
|
18
|
+
const response = await fetch(downloadUrl.signedUrl, {
|
|
19
|
+
method: 'GET',
|
|
20
|
+
});
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
throw new OystehrSdkError({
|
|
23
|
+
message: 'Failed to download file',
|
|
24
|
+
code: response.status,
|
|
25
|
+
cause: response.statusText,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return response.arrayBuffer();
|
|
10
29
|
}
|
|
11
30
|
|
|
12
|
-
export { uploadFile };
|
|
31
|
+
export { downloadFile, uploadFile };
|
|
13
32
|
//# sourceMappingURL=zambda-ext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zambda-ext.js","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.js","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":[],"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,IAAI,eAAe,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,IAAI,eAAe,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;;;;"}
|
|
@@ -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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SDKResource } from '../../client/client.js';
|
|
2
|
-
import { uploadFile } from './zambda-ext.js';
|
|
2
|
+
import { uploadFile, downloadFile } from './zambda-ext.js';
|
|
3
3
|
|
|
4
4
|
// AUTOGENERATED -- DO NOT EDIT
|
|
5
5
|
class Zambda extends SDKResource {
|
|
@@ -10,6 +10,7 @@ class Zambda extends SDKResource {
|
|
|
10
10
|
return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';
|
|
11
11
|
}
|
|
12
12
|
uploadFile = uploadFile;
|
|
13
|
+
downloadFile = downloadFile;
|
|
13
14
|
/**
|
|
14
15
|
* 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.
|
|
15
16
|
*
|
|
@@ -73,6 +74,8 @@ class Zambda extends SDKResource {
|
|
|
73
74
|
return this.request('/zambda/{id}/execute-public', 'post', this.#baseUrlThunk.bind(this))(params, request);
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
77
|
+
* **Deprecated.** Use `POST /zambda/{id}/presigned-url` with `action: "upload"` instead. This endpoint will be removed in future releases.
|
|
78
|
+
*
|
|
76
79
|
* 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.
|
|
77
80
|
*
|
|
78
81
|
* Access Policy Action: `Zambda:UpdateFunction`
|
|
@@ -81,6 +84,16 @@ class Zambda extends SDKResource {
|
|
|
81
84
|
s3Upload(params, request) {
|
|
82
85
|
return this.request('/zambda/{id}/s3-upload', 'post', this.#baseUrlThunk.bind(this))(params, request);
|
|
83
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* 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.
|
|
89
|
+
*
|
|
90
|
+
* Upload: Access Policy Action: `Zambda:UpdateFunction`
|
|
91
|
+
* Download: Access Policy Action: `Zambda:GetFunctionSource`
|
|
92
|
+
* Access Policy Resource: `Zambda:Function`
|
|
93
|
+
*/
|
|
94
|
+
getPresignedUrl(params, request) {
|
|
95
|
+
return this.request('/zambda/{id}/presigned-url', 'post', this.#baseUrlThunk.bind(this))(params, request);
|
|
96
|
+
}
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
export { Zambda };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zambda.js","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":["ext.uploadFile"],"mappings":";;;AAAA;
|
|
1
|
+
{"version":3,"file":"zambda.js","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":["ext.uploadFile","ext.downloadFile"],"mappings":";;;AAAA;AAyBM,MAAO,MAAO,SAAQ,WAAW,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,GAAGA,UAAc;AAC3B,IAAA,YAAY,GAAGC,YAAgB;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;;;;"}
|
|
@@ -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/package.json
CHANGED
package/src/client/client.ts
CHANGED
|
@@ -408,10 +408,12 @@ function subParamsInPath(path: string, params: Record<string, unknown>): [string
|
|
|
408
408
|
export function addParamsToSearch(params: Record<string, unknown>, search: URLSearchParams): void {
|
|
409
409
|
for (const [key, value] of Object.entries(params)) {
|
|
410
410
|
if (Array.isArray(value)) {
|
|
411
|
-
value.forEach((v) => search.append(key, v as string));
|
|
411
|
+
value.forEach((v) => v !== null && v !== undefined && search.append(key, v as string));
|
|
412
412
|
continue;
|
|
413
413
|
}
|
|
414
|
-
|
|
414
|
+
if (value !== null && value !== undefined) {
|
|
415
|
+
search.append(key, value as string);
|
|
416
|
+
}
|
|
415
417
|
}
|
|
416
418
|
}
|
|
417
419
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SDKResource } from '../../client/client';
|
|
2
|
+
import { OystehrSdkError } from '../../errors';
|
|
2
3
|
|
|
3
4
|
function baseUrlThunk(this: SDKResource): string {
|
|
4
|
-
return this.config.services?.['
|
|
5
|
+
return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
export async function uploadFile(
|
|
@@ -16,9 +17,35 @@ export async function uploadFile(
|
|
|
16
17
|
filename?: string | undefined;
|
|
17
18
|
}
|
|
18
19
|
): Promise<void> {
|
|
19
|
-
const uploadUrl = await this.request(
|
|
20
|
-
|
|
20
|
+
const uploadUrl = await this.request(
|
|
21
|
+
'/zambda/{id}/presigned-url',
|
|
22
|
+
'post',
|
|
23
|
+
baseUrlThunk.bind(this)
|
|
24
|
+
)({ id, action: 'upload', filename });
|
|
25
|
+
const response = await fetch(uploadUrl.signedUrl, {
|
|
21
26
|
method: 'PUT',
|
|
22
27
|
body: file,
|
|
23
28
|
});
|
|
29
|
+
if (!response.ok) {
|
|
30
|
+
throw new OystehrSdkError({ message: 'Failed to upload file', code: response.status, cause: response.statusText });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function downloadFile(this: SDKResource, { id }: { id: string }): Promise<ArrayBuffer> {
|
|
35
|
+
const downloadUrl = await this.request(
|
|
36
|
+
'/zambda/{id}/presigned-url',
|
|
37
|
+
'post',
|
|
38
|
+
baseUrlThunk.bind(this)
|
|
39
|
+
)({ id, action: 'download' });
|
|
40
|
+
const response = await fetch(downloadUrl.signedUrl, {
|
|
41
|
+
method: 'GET',
|
|
42
|
+
});
|
|
43
|
+
if (!response.ok) {
|
|
44
|
+
throw new OystehrSdkError({
|
|
45
|
+
message: 'Failed to download file',
|
|
46
|
+
code: response.status,
|
|
47
|
+
cause: response.statusText,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return response.arrayBuffer();
|
|
24
51
|
}
|
|
@@ -10,6 +10,8 @@ import {
|
|
|
10
10
|
ZambdaExecutePublicResponse,
|
|
11
11
|
ZambdaExecuteResponse,
|
|
12
12
|
ZambdaGetParams,
|
|
13
|
+
ZambdaGetPresignedUrlParams,
|
|
14
|
+
ZambdaGetPresignedUrlResponse,
|
|
13
15
|
ZambdaGetResponse,
|
|
14
16
|
ZambdaListResponse,
|
|
15
17
|
ZambdaS3UploadParams,
|
|
@@ -29,6 +31,7 @@ export class Zambda extends SDKResource {
|
|
|
29
31
|
return this.config.services?.['zambdaApiUrl'] ?? 'https://zambda-api.zapehr.com/v1';
|
|
30
32
|
}
|
|
31
33
|
uploadFile = ext.uploadFile;
|
|
34
|
+
downloadFile = ext.downloadFile;
|
|
32
35
|
/**
|
|
33
36
|
* 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.
|
|
34
37
|
*
|
|
@@ -95,6 +98,8 @@ export class Zambda extends SDKResource {
|
|
|
95
98
|
return this.request('/zambda/{id}/execute-public', 'post', this.#baseUrlThunk.bind(this))(params, request);
|
|
96
99
|
}
|
|
97
100
|
/**
|
|
101
|
+
* **Deprecated.** Use `POST /zambda/{id}/presigned-url` with `action: "upload"` instead. This endpoint will be removed in future releases.
|
|
102
|
+
*
|
|
98
103
|
* 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.
|
|
99
104
|
*
|
|
100
105
|
* Access Policy Action: `Zambda:UpdateFunction`
|
|
@@ -103,4 +108,17 @@ export class Zambda extends SDKResource {
|
|
|
103
108
|
s3Upload(params: ZambdaS3UploadParams, request?: OystehrClientRequest): Promise<ZambdaS3UploadResponse> {
|
|
104
109
|
return this.request('/zambda/{id}/s3-upload', 'post', this.#baseUrlThunk.bind(this))(params, request);
|
|
105
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* 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.
|
|
113
|
+
*
|
|
114
|
+
* Upload: Access Policy Action: `Zambda:UpdateFunction`
|
|
115
|
+
* Download: Access Policy Action: `Zambda:GetFunctionSource`
|
|
116
|
+
* Access Policy Resource: `Zambda:Function`
|
|
117
|
+
*/
|
|
118
|
+
getPresignedUrl(
|
|
119
|
+
params: ZambdaGetPresignedUrlParams,
|
|
120
|
+
request?: OystehrClientRequest
|
|
121
|
+
): Promise<ZambdaGetPresignedUrlResponse> {
|
|
122
|
+
return this.request('/zambda/{id}/presigned-url', 'post', this.#baseUrlThunk.bind(this))(params, request);
|
|
123
|
+
}
|
|
106
124
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// AUTOGENERATED -- DO NOT EDIT
|
|
2
|
+
|
|
3
|
+
export interface ZambdaGetPresignedUrlParams {
|
|
4
|
+
/**
|
|
5
|
+
* Whether to get a presigned URL for uploading or downloading the Zambda Function code zip.
|
|
6
|
+
*/
|
|
7
|
+
action: 'upload' | 'download';
|
|
8
|
+
/**
|
|
9
|
+
* Optional filename for the Zambda Function code zip (upload only). If not provided, the filename will be randomized.
|
|
10
|
+
*/
|
|
11
|
+
filename?: string;
|
|
12
|
+
id: string;
|
|
13
|
+
}
|
|
@@ -194,6 +194,8 @@ export * from './ZambdaLogStreamListParams';
|
|
|
194
194
|
export * from './ZambdaLogStreamListResponse';
|
|
195
195
|
export * from './ZambdaS3UploadParams';
|
|
196
196
|
export * from './ZambdaS3UploadResponse';
|
|
197
|
+
export * from './ZambdaGetPresignedUrlParams';
|
|
198
|
+
export * from './ZambdaGetPresignedUrlResponse';
|
|
197
199
|
export * from './ZambdaLogStreamSearchParams';
|
|
198
200
|
export * from './ZambdaLogStreamSearchResponse';
|
|
199
201
|
export * from './ZambdaLogStreamGetParams';
|