@oystehr/sdk 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/cjs/client/client.d.ts +2 -1
  2. package/dist/cjs/index.cjs +70 -2
  3. package/dist/cjs/index.cjs.map +1 -1
  4. package/dist/cjs/index.min.cjs +1 -1
  5. package/dist/cjs/index.min.cjs.map +1 -1
  6. package/dist/cjs/resources/classes/erx.d.ts +5 -1
  7. package/dist/cjs/resources/classes/z3-ext.d.ts +22 -0
  8. package/dist/cjs/resources/classes/z3.d.ts +15 -0
  9. package/dist/cjs/resources/types/ErxMedicationSearchV2Params.d.ts +4 -0
  10. package/dist/cjs/resources/types/ErxMedicationSearchV2Response.d.ts +38 -0
  11. package/dist/cjs/resources/types/Z3ListObjectsParams.d.ts +1 -0
  12. package/dist/cjs/resources/types/index.d.ts +2 -0
  13. package/dist/cjs/tests/setup/constants.d.ts +1 -1
  14. package/dist/esm/client/client.d.ts +2 -1
  15. package/dist/esm/client/client.js +1 -1
  16. package/dist/esm/client/client.js.map +1 -1
  17. package/dist/esm/index.min.js +1 -1
  18. package/dist/esm/index.min.js.map +1 -1
  19. package/dist/esm/node_modules/tslib/tslib.es6.js +1 -1
  20. package/dist/esm/node_modules/tslib/tslib.es6.js.map +1 -1
  21. package/dist/esm/resources/classes/erx.d.ts +5 -1
  22. package/dist/esm/resources/classes/erx.js +4 -0
  23. package/dist/esm/resources/classes/erx.js.map +1 -1
  24. package/dist/esm/resources/classes/fhir-ext.js +4 -1
  25. package/dist/esm/resources/classes/fhir-ext.js.map +1 -1
  26. package/dist/esm/resources/classes/z3-ext.d.ts +22 -0
  27. package/dist/esm/resources/classes/z3-ext.js +49 -1
  28. package/dist/esm/resources/classes/z3-ext.js.map +1 -1
  29. package/dist/esm/resources/classes/z3.d.ts +15 -0
  30. package/dist/esm/resources/classes/z3.js +16 -1
  31. package/dist/esm/resources/classes/z3.js.map +1 -1
  32. package/dist/esm/resources/types/ErxMedicationSearchV2Params.d.ts +4 -0
  33. package/dist/esm/resources/types/ErxMedicationSearchV2Response.d.ts +38 -0
  34. package/dist/esm/resources/types/Z3ListObjectsParams.d.ts +1 -0
  35. package/dist/esm/resources/types/index.d.ts +2 -0
  36. package/dist/esm/tests/setup/constants.d.ts +1 -1
  37. package/package.json +1 -1
  38. package/src/client/client.ts +2 -2
  39. package/src/resources/classes/erx.ts +9 -0
  40. package/src/resources/classes/fhir-ext.ts +5 -2
  41. package/src/resources/classes/z3-ext.ts +48 -1
  42. package/src/resources/classes/z3.ts +15 -0
  43. package/src/resources/types/ErxMedicationSearchV2Params.ts +6 -0
  44. package/src/resources/types/ErxMedicationSearchV2Response.ts +40 -0
  45. package/src/resources/types/Z3ListObjectsParams.ts +1 -0
  46. package/src/resources/types/index.ts +2 -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
- private readonly config;
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>>;
@@ -52,7 +52,7 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
52
52
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
53
53
  PERFORMANCE OF THIS SOFTWARE.
54
54
  ***************************************************************************** */
55
- /* global Reflect, Promise, SuppressedError, Symbol */
55
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
56
56
 
57
57
 
58
58
  function __awaiter(thisArg, _arguments, P, generator) {
@@ -566,6 +566,10 @@ class Erx extends SDKResource {
566
566
  * Search for medications. Provide at least one of code or name filters
567
567
  */
568
568
  this.medicationSearch = (params, request) => this.request('/erx/medication/search', 'get')(params, request);
569
+ /**
570
+ * Search for medications. Provide at least one of code or name filters
571
+ */
572
+ this.medicationSearchV2 = (params, request) => this.request('/erx/v2/medication/search', 'get')(params, request);
569
573
  }
570
574
  }
571
575
 
@@ -647,7 +651,10 @@ function batchInputRequestToBundleEntryItem(request) {
647
651
  return { name, value };
648
652
  })
649
653
  .reduce((acc, { name, value }) => {
650
- acc[name] = value;
654
+ if (!acc[name]) {
655
+ acc[name] = [];
656
+ }
657
+ acc[name].push(value);
651
658
  return acc;
652
659
  }, {});
653
660
  const search = new URLSearchParams();
@@ -1161,6 +1168,11 @@ class Version extends SDKResource {
1161
1168
  }
1162
1169
  }
1163
1170
 
1171
+ /**
1172
+ * Uploads a file to the bucket and key. Files should be Blobs.
1173
+ *
1174
+ * @param params upload file params
1175
+ */
1164
1176
  function uploadFile$1({ bucketName, 'objectPath+': key, file, }) {
1165
1177
  return __awaiter(this, void 0, void 0, function* () {
1166
1178
  const uploadUrl = yield this.request('/z3/{bucketName}/{objectPath+}', 'post')({
@@ -1174,6 +1186,11 @@ function uploadFile$1({ bucketName, 'objectPath+': key, file, }) {
1174
1186
  });
1175
1187
  });
1176
1188
  }
1189
+ /**
1190
+ * Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
1191
+ *
1192
+ * @param params download file params
1193
+ */
1177
1194
  function downloadFile({ bucketName, 'objectPath+': key, }) {
1178
1195
  return __awaiter(this, void 0, void 0, function* () {
1179
1196
  const uploadUrl = yield this.request('/z3/{bucketName}/{objectPath+}', 'post')({
@@ -1190,13 +1207,64 @@ function downloadFile({ bucketName, 'objectPath+': key, }) {
1190
1207
  return resp.arrayBuffer();
1191
1208
  });
1192
1209
  }
1210
+ /**
1211
+ * This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
1212
+ * `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` or `z3://<bucket>/<key>`
1213
+ * instead of the standard SDK `Z3GetPresignedUrlParams`.
1214
+ *
1215
+ * @param params url and action
1216
+ */
1217
+ function getPresignedUrlForZ3Url(params) {
1218
+ var _a;
1219
+ return __awaiter(this, void 0, void 0, function* () {
1220
+ let bucket;
1221
+ let key;
1222
+ const url = new URL(params.url);
1223
+ if (url.protocol === 'z3:') {
1224
+ // remove leading forward slash
1225
+ const z3PathParts = url.pathname.split('/').slice(1);
1226
+ bucket = url.hostname;
1227
+ key = z3PathParts.join('/');
1228
+ }
1229
+ else if (url.href.startsWith((_a = this.config.projectApiUrl) !== null && _a !== void 0 ? _a : defaultProjectApiUrl)) {
1230
+ // remove leading `/v1/z3`
1231
+ const httpsPathParts = url.pathname.split('/').slice(3);
1232
+ bucket = httpsPathParts[0];
1233
+ key = httpsPathParts.slice(1).join('/');
1234
+ }
1235
+ else {
1236
+ throw new OystehrSdkError({ message: 'Invalid Z3 URL', code: 400 });
1237
+ }
1238
+ const requestParams = {
1239
+ action: 'upload',
1240
+ bucketName: bucket,
1241
+ 'objectPath+': key,
1242
+ };
1243
+ return this.request('/z3/{bucketName}/{objectPath+}', 'post')(requestParams);
1244
+ });
1245
+ }
1193
1246
 
1194
1247
  // AUTOGENERATED -- DO NOT EDIT
1195
1248
  class Z3 extends SDKResource {
1196
1249
  constructor(config) {
1197
1250
  super(config);
1251
+ /**
1252
+ * Uploads a file to the bucket and key. Files should be Blobs.
1253
+ * @param params upload file params
1254
+ */
1198
1255
  this.uploadFile = uploadFile$1;
1256
+ /**
1257
+ * Downloads an object matching the bucket and key. File content is returned as an ArrayBuffer.
1258
+ * @param params download file params
1259
+ */
1199
1260
  this.downloadFile = downloadFile;
1261
+ /**
1262
+ * This helper performs a `getPresignedUrl` request for Z3 URLs of the forms
1263
+ * `https://projects-api.oystehr.com/v1/z3/<bucket>/<key>` * or `z3://<bucket>/<key>`
1264
+ * instead of the standard SDK `Z3GetPresignedUrlParams`.
1265
+ * @param params url and action
1266
+ */
1267
+ this.getPresignedUrlForZ3Url = getPresignedUrlForZ3Url;
1200
1268
  /**
1201
1269
  * List all Z3 Buckets. [Z3](https://docs.oystehr.com/services/z3/) is Oystehr's built-in and fully integrated solution for file storage.
1202
1270
  *