@oystehr/sdk 3.0.2 → 3.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/client.d.ts +2 -1
- package/dist/cjs/index.cjs +61 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.min.cjs +1 -1
- package/dist/cjs/index.min.cjs.map +1 -1
- package/dist/cjs/resources/classes/z3-ext.d.ts +22 -0
- package/dist/cjs/resources/classes/z3.d.ts +15 -0
- package/dist/esm/client/client.d.ts +2 -1
- package/dist/esm/client/client.js +1 -1
- package/dist/esm/client/client.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/resources/classes/z3-ext.d.ts +22 -0
- package/dist/esm/resources/classes/z3-ext.js +49 -1
- package/dist/esm/resources/classes/z3-ext.js.map +1 -1
- package/dist/esm/resources/classes/z3.d.ts +15 -0
- package/dist/esm/resources/classes/z3.js +16 -1
- package/dist/esm/resources/classes/z3.js.map +1 -1
- package/package.json +1 -1
- package/src/client/client.ts +2 -2
- package/src/resources/classes/z3-ext.ts +48 -1
- package/src/resources/classes/z3.ts +15 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { OystehrConfig } from '../config';
|
|
2
2
|
import { FhirBundle, FhirResource } from '../resources/types';
|
|
3
|
+
export declare const defaultProjectApiUrl = "https://project-api.zapehr.com/v1";
|
|
3
4
|
/**
|
|
4
5
|
* Optional parameter that can be passed to the client methods. It allows
|
|
5
6
|
* overriding the access token or project ID, and setting various headers,
|
|
@@ -29,7 +30,7 @@ interface InternalClientRequest extends OystehrClientRequest {
|
|
|
29
30
|
type FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>;
|
|
30
31
|
export type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;
|
|
31
32
|
export declare class SDKResource {
|
|
32
|
-
|
|
33
|
+
protected readonly config: OystehrConfig;
|
|
33
34
|
constructor(config: OystehrConfig);
|
|
34
35
|
protected request(path: string, method: string): FetcherFunction;
|
|
35
36
|
protected fhirRequest<T extends FhirResource = any>(path: string, method: string): (params: any, request?: InternalClientRequest) => Promise<FhirFetcherResponse<T>>;
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1161,6 +1161,11 @@ class Version extends SDKResource {
|
|
|
1161
1161
|
}
|
|
1162
1162
|
}
|
|
1163
1163
|
|
|
1164
|
+
/**
|
|
1165
|
+
* Uploads a file to the bucket and key. Files should be Blobs.
|
|
1166
|
+
*
|
|
1167
|
+
* @param params upload file params
|
|
1168
|
+
*/
|
|
1164
1169
|
function uploadFile$1({ bucketName, 'objectPath+': key, file, }) {
|
|
1165
1170
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1166
1171
|
const uploadUrl = yield this.request('/z3/{bucketName}/{objectPath+}', 'post')({
|
|
@@ -1174,6 +1179,11 @@ function uploadFile$1({ bucketName, 'objectPath+': key, file, }) {
|
|
|
1174
1179
|
});
|
|
1175
1180
|
});
|
|
1176
1181
|
}
|
|
1182
|
+
/**
|
|
1183
|
+
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
|
|
1184
|
+
*
|
|
1185
|
+
* @param params download file params
|
|
1186
|
+
*/
|
|
1177
1187
|
function downloadFile({ bucketName, 'objectPath+': key, }) {
|
|
1178
1188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1179
1189
|
const uploadUrl = yield this.request('/z3/{bucketName}/{objectPath+}', 'post')({
|
|
@@ -1190,13 +1200,64 @@ function downloadFile({ bucketName, 'objectPath+': key, }) {
|
|
|
1190
1200
|
return resp.arrayBuffer();
|
|
1191
1201
|
});
|
|
1192
1202
|
}
|
|
1203
|
+
/**
|
|
1204
|
+
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
|
|
1205
|
+
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` or `z3://<bucket>/<key>`
|
|
1206
|
+
* instead of the standard SDK `Z3GetPresignedUrlParams`.
|
|
1207
|
+
*
|
|
1208
|
+
* @param params url and action
|
|
1209
|
+
*/
|
|
1210
|
+
function getPresignedUrlForZ3Url(params) {
|
|
1211
|
+
var _a;
|
|
1212
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1213
|
+
let bucket;
|
|
1214
|
+
let key;
|
|
1215
|
+
const url = new URL(params.url);
|
|
1216
|
+
if (url.protocol === 'z3:') {
|
|
1217
|
+
// remove leading forward slash
|
|
1218
|
+
const z3PathParts = url.pathname.split('/').slice(1);
|
|
1219
|
+
bucket = url.hostname;
|
|
1220
|
+
key = z3PathParts.join('/');
|
|
1221
|
+
}
|
|
1222
|
+
else if (url.href.startsWith((_a = this.config.projectApiUrl) !== null && _a !== void 0 ? _a : defaultProjectApiUrl)) {
|
|
1223
|
+
// remove leading `/v1/z3`
|
|
1224
|
+
const httpsPathParts = url.pathname.split('/').slice(3);
|
|
1225
|
+
bucket = httpsPathParts[0];
|
|
1226
|
+
key = httpsPathParts.slice(1).join('/');
|
|
1227
|
+
}
|
|
1228
|
+
else {
|
|
1229
|
+
throw new OystehrSdkError({ message: 'Invalid Z3 URL', code: 400 });
|
|
1230
|
+
}
|
|
1231
|
+
const requestParams = {
|
|
1232
|
+
action: 'upload',
|
|
1233
|
+
bucketName: bucket,
|
|
1234
|
+
'objectPath+': key,
|
|
1235
|
+
};
|
|
1236
|
+
return this.request('/z3/{bucketName}/{objectPath+}', 'post')(requestParams);
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1193
1239
|
|
|
1194
1240
|
// AUTOGENERATED -- DO NOT EDIT
|
|
1195
1241
|
class Z3 extends SDKResource {
|
|
1196
1242
|
constructor(config) {
|
|
1197
1243
|
super(config);
|
|
1244
|
+
/**
|
|
1245
|
+
* Uploads a file to the bucket and key. Files should be Blobs.
|
|
1246
|
+
* @param params upload file params
|
|
1247
|
+
*/
|
|
1198
1248
|
this.uploadFile = uploadFile$1;
|
|
1249
|
+
/**
|
|
1250
|
+
* Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
|
|
1251
|
+
* @param params download file params
|
|
1252
|
+
*/
|
|
1199
1253
|
this.downloadFile = downloadFile;
|
|
1254
|
+
/**
|
|
1255
|
+
* This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
|
|
1256
|
+
* `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` * or `z3://<bucket>/<key>`
|
|
1257
|
+
* instead of the standard SDK `Z3GetPresignedUrlParams`.
|
|
1258
|
+
* @param params url and action
|
|
1259
|
+
*/
|
|
1260
|
+
this.getPresignedUrlForZ3Url = getPresignedUrlForZ3Url;
|
|
1200
1261
|
/**
|
|
1201
1262
|
* List all Z3 Buckets. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
|
|
1202
1263
|
*
|