@oystehr/sdk 4.3.1 → 4.3.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.
Files changed (111) hide show
  1. package/dist/cjs/client/client.cjs +87 -13
  2. package/dist/cjs/client/client.cjs.map +1 -1
  3. package/dist/cjs/client/client.d.ts +3 -0
  4. package/dist/cjs/config.d.ts +6 -0
  5. package/dist/cjs/index.min.cjs +1 -1
  6. package/dist/cjs/index.min.cjs.map +1 -1
  7. package/dist/cjs/logger.cjs +36 -0
  8. package/dist/cjs/logger.cjs.map +1 -0
  9. package/dist/cjs/logger.d.ts +11 -0
  10. package/dist/cjs/resources/classes/erx.cjs +8 -0
  11. package/dist/cjs/resources/classes/erx.cjs.map +1 -1
  12. package/dist/cjs/resources/classes/erx.d.ts +7 -1
  13. package/dist/cjs/resources/classes/index.cjs +6 -6
  14. package/dist/cjs/resources/classes/index.cjs.map +1 -1
  15. package/dist/cjs/resources/classes/index.d.ts +3 -3
  16. package/dist/cjs/resources/classes/rcm.cjs +29 -14
  17. package/dist/cjs/resources/classes/rcm.cjs.map +1 -1
  18. package/dist/cjs/resources/classes/rcm.d.ts +29 -11
  19. package/dist/cjs/resources/classes/user.cjs +9 -0
  20. package/dist/cjs/resources/classes/user.cjs.map +1 -1
  21. package/dist/cjs/resources/classes/user.d.ts +8 -1
  22. package/dist/cjs/resources/classes/zambda.cjs +1 -1
  23. package/dist/cjs/resources/classes/zambda.cjs.map +1 -1
  24. package/dist/cjs/resources/classes/zambdaLogStream.cjs +1 -1
  25. package/dist/cjs/resources/classes/zambdaLogStream.cjs.map +1 -1
  26. package/dist/cjs/resources/types/ErxGetMedicationHistoryParams.d.ts +3 -0
  27. package/dist/cjs/resources/types/ErxGetMedicationHistoryResponse.d.ts +43 -0
  28. package/dist/cjs/resources/types/ErxGetMedicationResponse.d.ts +1 -1
  29. package/dist/cjs/resources/types/RcmGetPayerParams.d.ts +3 -0
  30. package/dist/cjs/resources/types/RcmGetPayerResponse.d.ts +5 -0
  31. package/dist/cjs/resources/types/RcmListPayersParams.d.ts +5 -0
  32. package/dist/cjs/resources/types/RcmListPayersResponse.d.ts +5 -0
  33. package/dist/cjs/resources/types/RcmSetClaimStatusParams.d.ts +7 -0
  34. package/dist/cjs/resources/types/RcmSetClaimStatusResponse.d.ts +5 -0
  35. package/dist/cjs/resources/types/RcmSubmitClaimParams.d.ts +3 -0
  36. package/dist/cjs/resources/types/RcmSubmitClaimResponse.d.ts +5 -0
  37. package/dist/cjs/resources/types/UserChangePasswordParams.d.ts +7 -0
  38. package/dist/cjs/resources/types/index.d.ts +36 -29
  39. package/dist/esm/client/client.d.ts +3 -0
  40. package/dist/esm/client/client.js +88 -15
  41. package/dist/esm/client/client.js.map +1 -1
  42. package/dist/esm/config.d.ts +6 -0
  43. package/dist/esm/index.min.js +1 -1
  44. package/dist/esm/index.min.js.map +1 -1
  45. package/dist/esm/logger.d.ts +11 -0
  46. package/dist/esm/logger.js +34 -0
  47. package/dist/esm/logger.js.map +1 -0
  48. package/dist/esm/resources/classes/erx.d.ts +7 -1
  49. package/dist/esm/resources/classes/erx.js +8 -0
  50. package/dist/esm/resources/classes/erx.js.map +1 -1
  51. package/dist/esm/resources/classes/index.d.ts +3 -3
  52. package/dist/esm/resources/classes/index.js +6 -6
  53. package/dist/esm/resources/classes/index.js.map +1 -1
  54. package/dist/esm/resources/classes/rcm.d.ts +29 -11
  55. package/dist/esm/resources/classes/rcm.js +29 -14
  56. package/dist/esm/resources/classes/rcm.js.map +1 -1
  57. package/dist/esm/resources/classes/user.d.ts +8 -1
  58. package/dist/esm/resources/classes/user.js +9 -0
  59. package/dist/esm/resources/classes/user.js.map +1 -1
  60. package/dist/esm/resources/classes/zambda.js +1 -1
  61. package/dist/esm/resources/classes/zambda.js.map +1 -1
  62. package/dist/esm/resources/classes/zambdaLogStream.js +1 -1
  63. package/dist/esm/resources/classes/zambdaLogStream.js.map +1 -1
  64. package/dist/esm/resources/types/ErxGetMedicationHistoryParams.d.ts +3 -0
  65. package/dist/esm/resources/types/ErxGetMedicationHistoryResponse.d.ts +43 -0
  66. package/dist/esm/resources/types/ErxGetMedicationResponse.d.ts +1 -1
  67. package/dist/esm/resources/types/RcmGetPayerParams.d.ts +3 -0
  68. package/dist/esm/resources/types/RcmGetPayerResponse.d.ts +5 -0
  69. package/dist/esm/resources/types/RcmListPayersParams.d.ts +5 -0
  70. package/dist/esm/resources/types/RcmListPayersResponse.d.ts +5 -0
  71. package/dist/esm/resources/types/RcmSetClaimStatusParams.d.ts +7 -0
  72. package/dist/esm/resources/types/RcmSetClaimStatusResponse.d.ts +5 -0
  73. package/dist/esm/resources/types/RcmSubmitClaimParams.d.ts +3 -0
  74. package/dist/esm/resources/types/RcmSubmitClaimResponse.d.ts +5 -0
  75. package/dist/esm/resources/types/UserChangePasswordParams.d.ts +7 -0
  76. package/dist/esm/resources/types/index.d.ts +36 -29
  77. package/package.json +2 -2
  78. package/src/client/client.ts +95 -15
  79. package/src/config.ts +6 -0
  80. package/src/logger.ts +36 -0
  81. package/src/resources/classes/erx.ts +17 -0
  82. package/src/resources/classes/index.ts +6 -6
  83. package/src/resources/classes/rcm.ts +53 -23
  84. package/src/resources/classes/user.ts +10 -0
  85. package/src/resources/classes/zambda.ts +1 -1
  86. package/src/resources/classes/zambdaLogStream.ts +1 -1
  87. package/src/resources/types/ErxGetMedicationHistoryParams.ts +5 -0
  88. package/src/resources/types/ErxGetMedicationHistoryResponse.ts +45 -0
  89. package/src/resources/types/ErxGetMedicationResponse.ts +1 -1
  90. package/src/resources/types/RcmGetPayerParams.ts +5 -0
  91. package/src/resources/types/RcmGetPayerResponse.ts +7 -0
  92. package/src/resources/types/RcmListPayersParams.ts +7 -0
  93. package/src/resources/types/RcmListPayersResponse.ts +7 -0
  94. package/src/resources/types/RcmSetClaimStatusParams.ts +9 -0
  95. package/src/resources/types/RcmSetClaimStatusResponse.ts +7 -0
  96. package/src/resources/types/RcmSubmitClaimParams.ts +5 -0
  97. package/src/resources/types/RcmSubmitClaimResponse.ts +7 -0
  98. package/src/resources/types/UserChangePasswordParams.ts +9 -0
  99. package/src/resources/types/index.ts +36 -29
  100. package/dist/cjs/resources/types/RcmSubmitProfessionalClaimParams.d.ts +0 -10
  101. package/dist/cjs/resources/types/RcmSubmitProfessionalClaimResponse.d.ts +0 -5
  102. package/dist/cjs/resources/types/RcmValidateProfessionalClaimParams.d.ts +0 -6
  103. package/dist/cjs/resources/types/RcmValidateProfessionalClaimResponse.d.ts +0 -21
  104. package/dist/esm/resources/types/RcmSubmitProfessionalClaimParams.d.ts +0 -10
  105. package/dist/esm/resources/types/RcmSubmitProfessionalClaimResponse.d.ts +0 -5
  106. package/dist/esm/resources/types/RcmValidateProfessionalClaimParams.d.ts +0 -6
  107. package/dist/esm/resources/types/RcmValidateProfessionalClaimResponse.d.ts +0 -21
  108. package/src/resources/types/RcmSubmitProfessionalClaimParams.ts +0 -13
  109. package/src/resources/types/RcmSubmitProfessionalClaimResponse.ts +0 -7
  110. package/src/resources/types/RcmValidateProfessionalClaimParams.ts +0 -9
  111. package/src/resources/types/RcmValidateProfessionalClaimResponse.ts +0 -23
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Success
3
+ */
4
+ export type ErxGetMedicationHistoryResponse = {
5
+ /**
6
+ * Unique identifier for the medication history item.
7
+ */
8
+ id: number;
9
+ /**
10
+ * The Medi-Span identifier for the medication.
11
+ */
12
+ medicationId: number;
13
+ /**
14
+ * National Drug Code (NDC) identifier of medication.
15
+ */
16
+ ndc: string | null;
17
+ /**
18
+ * RxNorm Concept Unique (RxCUI) identifier of medication.
19
+ */
20
+ rxcui: number | null;
21
+ /**
22
+ * Human readable name of medication.
23
+ */
24
+ name: string;
25
+ route: string | null;
26
+ doseForm: string | null;
27
+ strength: string | null;
28
+ dispenseUnit: string | null;
29
+ isBrandName: boolean;
30
+ genericName: string | null;
31
+ isOtc: boolean;
32
+ refills: string;
33
+ daysSupply: number | null;
34
+ quantity: number;
35
+ classification: string | null;
36
+ schedule: number | null;
37
+ directions: string | null;
38
+ substitutionsAllowed: boolean;
39
+ writtenDate: string;
40
+ effectiveDate: string | null;
41
+ lastFillDate: string | null;
42
+ expirationDate: string | null;
43
+ }[];
@@ -7,7 +7,7 @@ export interface ErxGetMedicationResponse {
7
7
  */
8
8
  id: number;
9
9
  /**
10
- * RxNorm Concept Unique (RxCUI) identifier of medication.
10
+ * National Drug Code (NDC) identifier of medication.
11
11
  */
12
12
  ndc?: string | null;
13
13
  /**
@@ -0,0 +1,3 @@
1
+ export interface RcmGetPayerParams {
2
+ id: string;
3
+ }
@@ -0,0 +1,5 @@
1
+ import { Organization } from 'fhir/r4b';
2
+ /**
3
+ * A valid FHIR Organization object corresponding to the payer.
4
+ */
5
+ export type RcmGetPayerResponse = Organization;
@@ -0,0 +1,5 @@
1
+ export interface RcmListPayersParams {
2
+ name?: string;
3
+ identifier?: string;
4
+ includeInactive?: boolean;
5
+ }
@@ -0,0 +1,5 @@
1
+ import { Organization } from 'fhir/r4b';
2
+ /**
3
+ * List of payers matching the search criteria.
4
+ */
5
+ export type RcmListPayersResponse = Organization[];
@@ -0,0 +1,7 @@
1
+ export interface RcmSetClaimStatusParams {
2
+ /**
3
+ * The new status for the claim.
4
+ */
5
+ status: 'accepted' | 'rejected';
6
+ claimId: string;
7
+ }
@@ -0,0 +1,5 @@
1
+ import { ClaimResponse } from 'fhir/r4b';
2
+ /**
3
+ * A valid FHIR ClaimResponse object will be returned with details on the claim result.
4
+ */
5
+ export type RcmSetClaimStatusResponse = ClaimResponse;
@@ -0,0 +1,3 @@
1
+ export interface RcmSubmitClaimParams {
2
+ claimId: string;
3
+ }
@@ -0,0 +1,5 @@
1
+ import { ClaimResponse } from 'fhir/r4b';
2
+ /**
3
+ * A valid FHIR ClaimResponse object will be returned with details on the claim result.
4
+ */
5
+ export type RcmSubmitClaimResponse = ClaimResponse;
@@ -0,0 +1,7 @@
1
+ export interface UserChangePasswordParams {
2
+ /**
3
+ * The new password for the user.
4
+ */
5
+ password: string;
6
+ id: string;
7
+ }
@@ -8,9 +8,6 @@ export * from './Application';
8
8
  export * from './RoleStub';
9
9
  export * from './RoleListItem';
10
10
  export * from './Role';
11
- export * from './ZambdaSchedule';
12
- export * from './ZambdaFunction';
13
- export * from './ZambdaExecuteResult';
14
11
  export * from './Secret';
15
12
  export * from './SecretListItem';
16
13
  export * from './UserListItem';
@@ -87,12 +84,6 @@ export * from './ChargeStatusResponse';
87
84
  export * from './ProjectGetResponse';
88
85
  export * from './ProjectUpdateParams';
89
86
  export * from './ProjectUpdateResponse';
90
- export * from './RcmEligibilityCheckParams';
91
- export * from './RcmEligibilityCheckResponse';
92
- export * from './RcmValidateProfessionalClaimParams';
93
- export * from './RcmValidateProfessionalClaimResponse';
94
- export * from './RcmSubmitProfessionalClaimParams';
95
- export * from './RcmSubmitProfessionalClaimResponse';
96
87
  export * from './RoleListResponse';
97
88
  export * from './RoleCreateParams';
98
89
  export * from './RoleCreateResponse';
@@ -119,6 +110,7 @@ export * from './UserUpdateResponse';
119
110
  export * from './UserDeleteParams';
120
111
  export * from './UserResetMfaParams';
121
112
  export * from './UserResetPasswordLinkParams';
113
+ export * from './UserChangePasswordParams';
122
114
  export * from './UserInviteParams';
123
115
  export * from './UserInviteResponse';
124
116
  export * from './UserListResponse';
@@ -134,26 +126,6 @@ export * from './Z3ListObjectsResponse';
134
126
  export * from './Z3GetPresignedUrlParams';
135
127
  export * from './Z3GetPresignedUrlResponse';
136
128
  export * from './Z3DeleteObjectParams';
137
- export * from './ZambdaListResponse';
138
- export * from './ZambdaCreateParams';
139
- export * from './ZambdaCreateResponse';
140
- export * from './ZambdaGetParams';
141
- export * from './ZambdaGetResponse';
142
- export * from './ZambdaUpdateParams';
143
- export * from './ZambdaUpdateResponse';
144
- export * from './ZambdaDeleteParams';
145
- export * from './ZambdaExecuteParams';
146
- export * from './ZambdaExecuteResponse';
147
- export * from './ZambdaExecutePublicParams';
148
- export * from './ZambdaExecutePublicResponse';
149
- export * from './ZambdaLogStreamListParams';
150
- export * from './ZambdaLogStreamListResponse';
151
- export * from './ZambdaS3UploadParams';
152
- export * from './ZambdaS3UploadResponse';
153
- export * from './ZambdaLogStreamSearchParams';
154
- export * from './ZambdaLogStreamSearchResponse';
155
- export * from './ZambdaLogStreamGetParams';
156
- export * from './ZambdaLogStreamGetResponse';
157
129
  export * from './FaxOnboardResponse';
158
130
  export * from './FaxGetConfigurationResponse';
159
131
  export * from './FaxSendParams';
@@ -184,6 +156,8 @@ export * from './ErxCheckMedicationInteractionsParams';
184
156
  export * from './ErxCheckMedicationInteractionsResponse';
185
157
  export * from './ErxCheckPrecheckInteractionsParams';
186
158
  export * from './ErxCheckPrecheckInteractionsResponse';
159
+ export * from './ErxGetMedicationHistoryParams';
160
+ export * from './ErxGetMedicationHistoryResponse';
187
161
  export * from './ErxAddPatientPharmacyParams';
188
162
  export * from './ErxCancelPrescriptionParams';
189
163
  export * from './ErxSyncPatientParams';
@@ -199,3 +173,36 @@ export * from './TerminologySearchCptParams';
199
173
  export * from './TerminologySearchCptResponse';
200
174
  export * from './TerminologySearchHcpcsParams';
201
175
  export * from './TerminologySearchHcpcsResponse';
176
+ export * from './ZambdaSchedule';
177
+ export * from './ZambdaFunction';
178
+ export * from './ZambdaExecuteResult';
179
+ export * from './ZambdaListResponse';
180
+ export * from './ZambdaCreateParams';
181
+ export * from './ZambdaCreateResponse';
182
+ export * from './ZambdaGetParams';
183
+ export * from './ZambdaGetResponse';
184
+ export * from './ZambdaUpdateParams';
185
+ export * from './ZambdaUpdateResponse';
186
+ export * from './ZambdaDeleteParams';
187
+ export * from './ZambdaExecuteParams';
188
+ export * from './ZambdaExecuteResponse';
189
+ export * from './ZambdaExecutePublicParams';
190
+ export * from './ZambdaExecutePublicResponse';
191
+ export * from './ZambdaLogStreamListParams';
192
+ export * from './ZambdaLogStreamListResponse';
193
+ export * from './ZambdaS3UploadParams';
194
+ export * from './ZambdaS3UploadResponse';
195
+ export * from './ZambdaLogStreamSearchParams';
196
+ export * from './ZambdaLogStreamSearchResponse';
197
+ export * from './ZambdaLogStreamGetParams';
198
+ export * from './ZambdaLogStreamGetResponse';
199
+ export * from './RcmEligibilityCheckParams';
200
+ export * from './RcmEligibilityCheckResponse';
201
+ export * from './RcmSubmitClaimParams';
202
+ export * from './RcmSubmitClaimResponse';
203
+ export * from './RcmSetClaimStatusParams';
204
+ export * from './RcmSetClaimStatusResponse';
205
+ export * from './RcmListPayersParams';
206
+ export * from './RcmListPayersResponse';
207
+ export * from './RcmGetPayerParams';
208
+ export * from './RcmGetPayerResponse';
@@ -1,4 +1,5 @@
1
1
  import { OystehrConfig } from '../config';
2
+ import { Logger } from '../logger';
2
3
  import { FhirBundle, FhirResource } from '../resources/types';
3
4
  export declare const defaultProjectApiUrl = "https://project-api.zapehr.com/v1";
4
5
  /**
@@ -31,6 +32,7 @@ type FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>;
31
32
  export type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;
32
33
  export declare class SDKResource {
33
34
  protected readonly config: OystehrConfig;
35
+ protected readonly logger: Logger;
34
36
  constructor(config: OystehrConfig);
35
37
  protected request(path: string, method: string, baseUrlThunk: () => string): FetcherFunction;
36
38
  protected fhirRequest<T extends FhirResource = any>(path: string, method: string): (params: any, request?: InternalClientRequest) => Promise<FhirFetcherResponse<T>>;
@@ -47,4 +49,5 @@ export type FetcherFunction = (params?: Record<string, any> | [any] | InternalCl
47
49
  * @param search URLSearchParams object
48
50
  */
49
51
  export declare function addParamsToSearch(params: Record<string, unknown>, search: URLSearchParams): void;
52
+ export declare function extractParamsAndRequest(params?: Record<string, unknown> | [any] | InternalClientRequest, request?: InternalClientRequest): [Record<string, unknown>, InternalClientRequest | undefined];
50
53
  export {};
@@ -1,5 +1,6 @@
1
- import { v4 } from 'uuid';
1
+ import { v4, validate } from 'uuid';
2
2
  import { OystehrSdkError, OystehrFHIRError } from '../errors/index.js';
3
+ import { Logger } from '../logger.js';
3
4
 
4
5
  const defaultProjectApiUrl = 'https://project-api.zapehr.com/v1';
5
6
  const defaultFhirApiUrl = 'https://fhir-api.zapehr.com';
@@ -16,17 +17,24 @@ const ERROR_CODES_TO_RETRY = [
16
17
  ];
17
18
  class SDKResource {
18
19
  config;
20
+ logger;
19
21
  constructor(config) {
20
22
  this.config = config;
23
+ this.logger = new Logger({
24
+ level: this.config.logLevel,
25
+ });
21
26
  }
22
27
  request(path, method, baseUrlThunk) {
23
28
  return async (params, request) => {
24
29
  const configThunk = () => this.config;
30
+ const loggerThunk = () => this.logger;
25
31
  try {
26
- return await fetcher(baseUrlThunk, configThunk, path, method)(params, request);
32
+ // must await here to catch
33
+ return await fetcher(baseUrlThunk, configThunk, loggerThunk, path, method)(params, request);
27
34
  }
28
35
  catch (err) {
29
36
  const error = err;
37
+ this.logger.error(error.message, { code: error.code, cause: error.cause });
30
38
  throw new OystehrSdkError({ message: error.message, code: error.code, cause: error.cause });
31
39
  }
32
40
  };
@@ -36,8 +44,9 @@ class SDKResource {
36
44
  try {
37
45
  const baseUrlThunk = () => this.config.services?.fhirApiUrl ?? defaultFhirApiUrl;
38
46
  const configThunk = () => this.config;
47
+ const loggerThunk = () => this.logger;
39
48
  // must await here to catch
40
- return await fetcher(baseUrlThunk, configThunk, path, method)(params, request);
49
+ return await fetcher(baseUrlThunk, configThunk, loggerThunk, path, method)(params, request);
41
50
  }
42
51
  catch (err) {
43
52
  // FHIR API error messages are JSON strings
@@ -58,7 +67,11 @@ class SDKResource {
58
67
  }
59
68
  }
60
69
  function isInternalClientRequest(request) {
61
- return 'accessToken' in request;
70
+ return ('accessToken' in request ||
71
+ ('projectId' in request && validate(request.projectId)) ||
72
+ ('contentType' in request && request.contentType?.split('/').length === 2) ||
73
+ 'requestId' in request ||
74
+ ('ifMatch' in request && request.ifMatch.startsWith('W/"')));
62
75
  }
63
76
  /**
64
77
  * Parse XML response in format <response><status>...</status><output>...</output></response>
@@ -80,23 +93,27 @@ function parseXmlResponse(xmlString) {
80
93
  return null;
81
94
  }
82
95
  }
83
- function fetcher(baseUrlThunk, configThunk, path, methodParam) {
96
+ function fetcher(baseUrlThunk, configThunk, loggerThunk, path, methodParam) {
84
97
  return async (params, request) => {
85
98
  // this function supports multiple signatures. fetcher(baseUrl, path, method)(params, request) or fetcher(baseUrl, path, method)(request)
86
99
  // or fetcher(baseUrl, path, method)(params) or fetcher(baseUrl, path, method)(). the types for this are handled by Client<Path, Methods>
87
100
  // and this is the backend implementation behind it. the heuristic we're using is that if the first param is an object with an accessToken
88
101
  // and there is no second param, assume the first one is the request object instead
89
- const providedParams = !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)
90
- ? {}
91
- : params ?? {};
92
- const requestCtx = !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)
93
- ? params
94
- : request;
95
- const method = methodParam.toLowerCase();
102
+ // eslint-disable-next-line prefer-const
103
+ let [providedParams, requestCtx] = extractParamsAndRequest(params, request);
104
+ requestCtx ??= {};
105
+ requestCtx.requestId ??= v4();
96
106
  const config = configThunk();
107
+ const logger = loggerThunk();
108
+ const method = methodParam.toLowerCase();
109
+ logger.debug('Beginning fetch', {
110
+ method,
111
+ path,
112
+ requestId: requestCtx?.requestId,
113
+ });
97
114
  const fetchImpl = config.fetch ?? fetch;
98
115
  const accessToken = requestCtx?.accessToken ?? config.accessToken;
99
- const projectId = requestCtx?.projectId ?? configThunk().projectId;
116
+ const projectId = requestCtx?.projectId ?? config.projectId;
100
117
  let finalPath = path;
101
118
  let finalParams = providedParams;
102
119
  if (!Array.isArray(providedParams)) {
@@ -104,6 +121,11 @@ function fetcher(baseUrlThunk, configThunk, path, methodParam) {
104
121
  finalPath = subbedPath;
105
122
  finalParams = addlParams;
106
123
  }
124
+ logger.debug('Substituted parameters in path', {
125
+ method,
126
+ path,
127
+ requestId: requestCtx?.requestId,
128
+ });
107
129
  finalPath = finalPath.replace(/^\//, ''); // remove leading slash
108
130
  const baseUrlEvaluated = baseUrlThunk();
109
131
  const fullBaseUrl = baseUrlEvaluated.endsWith('/') ? baseUrlEvaluated : baseUrlEvaluated + '/';
@@ -131,6 +153,11 @@ function fetcher(baseUrlThunk, configThunk, path, methodParam) {
131
153
  body = '{}';
132
154
  }
133
155
  }
156
+ logger.debug('Prepared request body', {
157
+ method,
158
+ path,
159
+ requestId: requestCtx?.requestId,
160
+ });
134
161
  const headers = Object.assign(projectId
135
162
  ? {
136
163
  'x-zapehr-project-id': projectId,
@@ -138,7 +165,7 @@ function fetcher(baseUrlThunk, configThunk, path, methodParam) {
138
165
  }
139
166
  : {}, {
140
167
  'content-type': requestCtx?.contentType ?? 'application/json',
141
- }, accessToken ? { Authorization: `Bearer ${accessToken}` } : {}, requestCtx?.ifMatch ? { 'If-Match': requestCtx.ifMatch } : {}, { 'x-oystehr-request-id': requestCtx?.requestId ?? v4() });
168
+ }, accessToken ? { Authorization: `Bearer ${accessToken}` } : {}, requestCtx?.ifMatch ? { 'If-Match': requestCtx.ifMatch } : {}, { 'x-oystehr-request-id': requestCtx?.requestId });
142
169
  const retryConfig = {
143
170
  retries: config.retry?.retries ?? 3,
144
171
  jitter: config.retry?.jitter ?? 20,
@@ -149,22 +176,54 @@ function fetcher(baseUrlThunk, configThunk, path, methodParam) {
149
176
  };
150
177
  retryConfig.retryOn.push(...STATUS_CODES_TO_RETRY);
151
178
  return retry(async () => {
179
+ logger.info('Request start', {
180
+ method,
181
+ url,
182
+ requestId: requestCtx?.requestId,
183
+ });
184
+ const now = Date.now();
152
185
  const response = await fetchImpl(new Request(url, {
153
186
  method: method.toUpperCase(),
154
187
  body,
155
188
  headers,
156
189
  }));
190
+ logger.info('Request end', {
191
+ method,
192
+ url,
193
+ duration: Date.now() - now,
194
+ requestId: requestCtx?.requestId,
195
+ });
157
196
  const responseBody = response.body ? await response.text() : null;
158
197
  let responseJson;
159
198
  const contentType = response.headers.get('content-type');
160
199
  try {
161
200
  if (responseBody &&
162
201
  (contentType?.includes('application/json') || contentType?.includes('application/fhir+json'))) {
202
+ logger.time('Deserialized JSON response', {
203
+ method,
204
+ url,
205
+ requestId: requestCtx?.requestId,
206
+ });
163
207
  responseJson = JSON.parse(responseBody);
208
+ logger.timeEnd('Deserialized JSON response', {
209
+ method,
210
+ url,
211
+ requestId: requestCtx?.requestId,
212
+ });
164
213
  }
165
214
  else if (responseBody && (contentType?.includes('application/xml') || contentType?.includes('text/xml'))) {
166
215
  // Parse XML response into { status, output } structure
216
+ logger.time('Deserialized XML response', {
217
+ method,
218
+ url,
219
+ requestId: requestCtx?.requestId,
220
+ });
167
221
  responseJson = parseXmlResponse(responseBody);
222
+ logger.timeEnd('Deserialized XML response', {
223
+ method,
224
+ url,
225
+ requestId: requestCtx?.requestId,
226
+ });
168
227
  }
169
228
  else {
170
229
  responseJson = null;
@@ -174,6 +233,11 @@ function fetcher(baseUrlThunk, configThunk, path, methodParam) {
174
233
  // ignore JSON.parse errors
175
234
  responseJson = null;
176
235
  }
236
+ logger.debug('Deserialized response', {
237
+ method,
238
+ url,
239
+ requestId: requestCtx?.requestId,
240
+ });
177
241
  const isError = !response.ok || response.status >= 400;
178
242
  if (isError) {
179
243
  const errObj = {
@@ -278,6 +342,15 @@ function addParamsToSearch(params, search) {
278
342
  search.append(key, value);
279
343
  }
280
344
  }
345
+ function extractParamsAndRequest(params, request) {
346
+ const providedParams = !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)
347
+ ? {}
348
+ : params ?? {};
349
+ const requestCtx = !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)
350
+ ? params
351
+ : request;
352
+ return [providedParams, requestCtx];
353
+ }
281
354
 
282
- export { SDKResource, addParamsToSearch, defaultProjectApiUrl };
355
+ export { SDKResource, addParamsToSearch, defaultProjectApiUrl, extractParamsAndRequest };
283
356
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sources":["../../../src/client/client.ts"],"sourcesContent":["import { v4 as uuidv4 } from 'uuid';\nimport { OystehrConfig } from '../config';\nimport { OystehrFHIRError, OystehrSdkError } from '../errors';\nimport { FhirBundle, FhirResource, OperationOutcome } from '../resources/types';\n\ntype HttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';\nexport const defaultProjectApiUrl = 'https://project-api.zapehr.com/v1';\nconst defaultFhirApiUrl = 'https://fhir-api.zapehr.com';\nconst STATUS_CODES_TO_RETRY = [408, 429, 500, 502, 503, 504];\nconst ERROR_CODES_TO_RETRY = [\n 'ECONNRESET',\n 'ECONNREFUSED',\n 'EPIPE',\n 'ETIMEDOUT',\n 'UND_ERR_CONNECT_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_SOCKET',\n];\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'.\n */\nexport interface OystehrClientRequest {\n /**\n * The access token to use for the request. If not provided, the access token from `oystehr.init()` will be used.\n */\n accessToken?: string;\n /**\n * The project ID to use for the request. If not provided, the project ID from `oystehr.init()` will be used.\n */\n projectId?: string;\n /**\n * The value of the 'Content-Type' header to use for the request.\n */\n contentType?: string;\n /**\n * Unique identifier for this request.\n */\n requestId?: string;\n}\n\ninterface InternalClientRequest extends OystehrClientRequest {\n ifMatch?: string;\n}\n\ntype FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>;\nexport type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;\n\nexport class SDKResource {\n protected readonly config: OystehrConfig;\n constructor(config: OystehrConfig) {\n this.config = config;\n }\n\n protected request(path: string, method: string, baseUrlThunk: () => string): FetcherFunction {\n return async (params: any, request?: InternalClientRequest): Promise<FetcherResponse> => {\n const configThunk = (): OystehrConfig => this.config;\n try {\n return await fetcher(baseUrlThunk, configThunk, path, method)(params, request);\n } catch (err: any) {\n const error = err as { message: string; code: number; cause?: unknown };\n throw new OystehrSdkError({ message: error.message, code: error.code, cause: error.cause });\n }\n };\n }\n\n protected fhirRequest<T extends FhirResource = any>(path: string, method: string) {\n return async (params: any, request?: InternalClientRequest): Promise<FhirFetcherResponse<T>> => {\n try {\n const baseUrlThunk = (): string => this.config.services?.fhirApiUrl ?? defaultFhirApiUrl;\n const configThunk = (): OystehrConfig => this.config;\n // must await here to catch\n return await fetcher(baseUrlThunk, configThunk, path, method)(params, request);\n } catch (err: unknown) {\n // FHIR API error messages are JSON strings\n const fullError = err as { message: string | Record<string, any>; code: number; cause?: unknown };\n if (typeof fullError.message === 'string') {\n throw new OystehrSdkError({\n message: fullError.message,\n code: fullError.code,\n cause: fullError.cause,\n });\n }\n throw new OystehrFHIRError({\n error: fullError.message as OperationOutcome,\n code: fullError.code,\n });\n }\n };\n }\n}\n\nexport type FetcherError = { message: string; code: number };\nexport type FetcherResponse = any;\nexport type FetcherFunction = (\n params?: Record<string, any> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n) => Promise<FetcherResponse>;\n\nfunction isInternalClientRequest(request: Record<string, any>): request is InternalClientRequest {\n return 'accessToken' in request;\n}\n\n/**\n * Parse XML response in format <response><status>...</status><output>...</output></response>\n */\nfunction parseXmlResponse(xmlString: string): Record<string, unknown> | null {\n try {\n // Extract status\n const statusMatch = xmlString.match(/<status>(\\d+)<\\/status>/);\n const status = statusMatch ? parseInt(statusMatch[1], 10) : null;\n\n // Extract output - everything between <output> and </output>\n const outputMatch = xmlString.match(/<output>([\\s\\S]*?)<\\/output>/);\n const output = outputMatch ? outputMatch[1] : null;\n\n if (status === null || output === null) {\n return null;\n }\n\n return { status, output };\n } catch (_err) {\n return null;\n }\n}\n\nfunction fetcher(\n baseUrlThunk: () => string,\n configThunk: () => OystehrConfig,\n path: string,\n methodParam: string\n): FetcherFunction {\n return async (\n params?: Record<string, unknown> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n ): Promise<FetcherResponse> => {\n // this function supports multiple signatures. fetcher(baseUrl, path, method)(params, request) or fetcher(baseUrl, path, method)(request)\n // or fetcher(baseUrl, path, method)(params) or fetcher(baseUrl, path, method)(). the types for this are handled by Client<Path, Methods>\n // and this is the backend implementation behind it. the heuristic we're using is that if the first param is an object with an accessToken\n // and there is no second param, assume the first one is the request object instead\n const providedParams: Record<string, unknown> | [any] =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? {}\n : (params as Record<string, unknown>) ?? {};\n const requestCtx =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? (params as InternalClientRequest)\n : request;\n const method = methodParam.toLowerCase() as HttpMethod;\n const config = configThunk();\n const fetchImpl = config.fetch ?? fetch;\n const accessToken = requestCtx?.accessToken ?? config.accessToken;\n const projectId = requestCtx?.projectId ?? configThunk().projectId;\n let finalPath = path;\n let finalParams = providedParams;\n if (!Array.isArray(providedParams)) {\n const [subbedPath, addlParams] = subParamsInPath(path, providedParams);\n finalPath = subbedPath;\n finalParams = addlParams;\n }\n finalPath = finalPath.replace(/^\\//, ''); // remove leading slash\n const baseUrlEvaluated = baseUrlThunk();\n const fullBaseUrl = baseUrlEvaluated.endsWith('/') ? baseUrlEvaluated : baseUrlEvaluated + '/';\n const url = new URL(finalPath, fullBaseUrl);\n let body: any;\n\n if (Array.isArray(finalParams)) {\n body = JSON.stringify(finalParams);\n } else if (Object.keys(finalParams).length) {\n if (method === 'get') {\n addParamsToSearch(finalParams, url.searchParams);\n } else if (requestCtx?.contentType === 'application/x-www-form-urlencoded') {\n const search = new URLSearchParams();\n addParamsToSearch(finalParams, search);\n body = search.toString();\n } else {\n body = JSON.stringify(finalParams);\n }\n } else {\n // override for rpc call\n if (requestCtx?.contentType !== 'application/x-www-form-urlencoded' && method === 'post') {\n body = '{}';\n }\n }\n\n const headers: Record<string, string> = Object.assign(\n projectId\n ? {\n 'x-zapehr-project-id': projectId,\n 'x-oystehr-project-id': projectId,\n }\n : {},\n {\n 'content-type': requestCtx?.contentType ?? 'application/json',\n },\n accessToken ? { Authorization: `Bearer ${accessToken}` } : {},\n requestCtx?.ifMatch ? { 'If-Match': requestCtx.ifMatch } : {},\n { 'x-oystehr-request-id': requestCtx?.requestId ?? uuidv4() }\n );\n const retryConfig: ConstructedRetryConfig = {\n retries: config.retry?.retries ?? 3,\n jitter: config.retry?.jitter ?? 20,\n delay: config.retry?.delay ?? 100,\n onRetry: config.retry?.onRetry,\n // Using array instead of set because the length is too short for uniqueness to be important\n retryOn: [...(config.retry?.retryOn ?? []), ...STATUS_CODES_TO_RETRY],\n };\n retryConfig.retryOn.push(...STATUS_CODES_TO_RETRY);\n return retry(async () => {\n const response = await fetchImpl(\n new Request(url, {\n method: method.toUpperCase(),\n body,\n headers,\n })\n );\n const responseBody = response.body ? await response.text() : null;\n let responseJson: Record<string, unknown> | null;\n const contentType = response.headers.get('content-type');\n try {\n if (\n responseBody &&\n (contentType?.includes('application/json') || contentType?.includes('application/fhir+json'))\n ) {\n responseJson = JSON.parse(responseBody);\n } else if (responseBody && (contentType?.includes('application/xml') || contentType?.includes('text/xml'))) {\n // Parse XML response into { status, output } structure\n responseJson = parseXmlResponse(responseBody);\n } else {\n responseJson = null;\n }\n } catch (_err) {\n // ignore JSON.parse errors\n responseJson = null;\n }\n const isError = !response.ok || response.status >= 400;\n if (isError) {\n const errObj = {\n message:\n (typeof responseJson?.output === 'string'\n ? responseJson.output // XML error case - output is XML string\n : (responseJson?.output as Record<string, unknown>)?.message) ?? // official zambda output format (JSON)\n responseJson?.message ?? // normal endpoint output format\n responseJson ?? // parsable json\n responseBody ?? // raw response\n response.statusText, // fallback to status text\n code:\n (responseJson?.output as Record<string, unknown>)?.code ?? // official zambda output format\n responseJson?.code ?? // normal endpoint output format\n response.status, // fallback to status code\n response,\n };\n throw errObj;\n }\n return responseJson;\n }, retryConfig);\n };\n}\n\ntype ConstructedRetryConfig = Omit<NonNullable<OystehrConfig['retry']>, 'retryOn'> & {\n jitter: NonNullable<NonNullable<OystehrConfig['retry']>['jitter']>;\n delay: NonNullable<NonNullable<OystehrConfig['retry']>['delay']>;\n retryOn: NonNullable<NonNullable<OystehrConfig['retry']>['retryOn']>;\n};\nasync function retry<T>(work: (attempt: number) => Promise<T>, config: ConstructedRetryConfig): Promise<T> {\n let lastErr;\n for (const attempt of Array.from({ length: (config.retries ?? 0) + 1 }, (_, index) => index)) {\n try {\n return await work(attempt);\n } catch (e: any) {\n let isRetryable = false;\n if ('response' in e) {\n // error from API\n const err = e as FetcherError;\n isRetryable = config.retryOn.includes(err.code);\n // Removes response\n lastErr = { message: e.message, code: e.code };\n } else {\n lastErr = e;\n // error from fetch\n if ('code' in e && typeof e.code === 'string') {\n const err = e as { code: string };\n isRetryable = ERROR_CODES_TO_RETRY.includes(err.code);\n }\n }\n if (!isRetryable) {\n break;\n }\n const jitter = Math.floor(Math.random() * (config.jitter + 1));\n await new Promise((resolve) => setTimeout(resolve, config.delay + jitter));\n if (config.onRetry && attempt !== (config.retries ?? 0)) {\n config.onRetry(attempt + 1);\n }\n }\n }\n throw lastErr;\n}\n\n/**\n * Substitutes params in a path and returns the path with params substituted and any unused params.\n *\n * Uses the property names in the params object to determine the param to substitute in the path.\n *\n * @param path JSON API resource URI\n * @param params all params provided to the client method\n * @returns resource URI with params substituted and any unused params\n */\nfunction subParamsInPath(path: string, params: Record<string, unknown>): [string, Record<string, string>] {\n const unusedParams = { ...params };\n // capture everything of the form `{paramName}` and replace with the value of `params[paramName]`\n const subbedPath = path.replace(/\\{([^}]+)\\}/g, (_, paramName) => {\n delete unusedParams[paramName];\n // override for path params that are paths, indicated by a `+` at the end\n if (paramName.match(/^.*\\+$/)) {\n return params[paramName] + '';\n }\n // error if param value is empty\n if (!params[paramName] || params[paramName] === '') {\n throw new OystehrSdkError({ message: `Required path parameter is an empty string: ${paramName}`, code: 400 });\n }\n // encode search params\n if (params[paramName]) {\n return encodeURIComponent(params[paramName] + ''); // coerce to string\n }\n return '';\n });\n\n const unusedKeys = Object.keys(unusedParams);\n const addlParams = unusedKeys.length\n ? unusedKeys.reduce((acc, key) => ({ ...acc, [key]: unusedParams[key] }), {})\n : {};\n return [subbedPath, addlParams];\n}\n\n/**\n * Adds params to a URLSearchParams object in such a way as to preserve array values.\n * @param params params\n * @param search URLSearchParams object\n */\nexport function addParamsToSearch(params: Record<string, unknown>, search: URLSearchParams): void {\n for (const [key, value] of Object.entries(params)) {\n if (Array.isArray(value)) {\n value.forEach((v) => search.append(key, v as string));\n continue;\n }\n search.append(key, value as string);\n }\n}\n"],"names":["uuidv4"],"mappings":";;;AAMO,MAAM,oBAAoB,GAAG;AACpC,MAAM,iBAAiB,GAAG,6BAA6B;AACvD,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAC5D,MAAM,oBAAoB,GAAG;IAC3B,YAAY;IACZ,cAAc;IACd,OAAO;IACP,WAAW;IACX,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,gBAAgB;CACjB;MAiCY,WAAW,CAAA;AACH,IAAA,MAAM;AACzB,IAAA,WAAA,CAAY,MAAqB,EAAA;AAC/B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;IACtB;AAEU,IAAA,OAAO,CAAC,IAAY,EAAE,MAAc,EAAE,YAA0B,EAAA;AACxE,QAAA,OAAO,OAAO,MAAW,EAAE,OAA+B,KAA8B;YACtF,MAAM,WAAW,GAAG,MAAqB,IAAI,CAAC,MAAM;AACpD,YAAA,IAAI;AACF,gBAAA,OAAO,MAAM,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC;YAChF;YAAE,OAAO,GAAQ,EAAE;gBACjB,MAAM,KAAK,GAAG,GAAyD;gBACvE,MAAM,IAAI,eAAe,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;YAC7F;AACF,QAAA,CAAC;IACH;IAEU,W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I,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACjD,QAAA,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;AACxB,YAAA,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAW,CAAC,CAAC;YACrD;QACF;AACA,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAe,CAAC;IACrC;AACF;;;;"}
1
+ {"version":3,"file":"client.js","sources":["../../../src/client/client.ts"],"sourcesContent":["import { v4 as uuidv4, validate as uuidValidate } from 'uuid';\nimport { OystehrConfig } from '../config';\nimport { OystehrFHIRError, OystehrSdkError } from '../errors';\nimport { Logger } from '../logger';\nimport { FhirBundle, FhirResource, OperationOutcome } from '../resources/types';\n\ntype HttpMethod = 'get' | 'put' | 'post' | 'delete' | 'options' | 'head' | 'patch' | 'trace';\nexport const defaultProjectApiUrl = 'https://project-api.zapehr.com/v1';\nconst defaultFhirApiUrl = 'https://fhir-api.zapehr.com';\nconst STATUS_CODES_TO_RETRY = [408, 429, 500, 502, 503, 504];\nconst ERROR_CODES_TO_RETRY = [\n 'ECONNRESET',\n 'ECONNREFUSED',\n 'EPIPE',\n 'ETIMEDOUT',\n 'UND_ERR_CONNECT_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_HEADERS_TIMEOUT',\n 'UND_ERR_SOCKET',\n];\n\n/**\n * Optional parameter that can be passed to the client methods. It allows\n * overriding the access token or project ID, and setting various headers,\n * such as 'Content-Type'.\n */\nexport interface OystehrClientRequest {\n /**\n * The access token to use for the request. If not provided, the access token from `oystehr.init()` will be used.\n */\n accessToken?: string;\n /**\n * The project ID to use for the request. If not provided, the project ID from `oystehr.init()` will be used.\n */\n projectId?: string;\n /**\n * The value of the 'Content-Type' header to use for the request.\n */\n contentType?: string;\n /**\n * Unique identifier for this request.\n */\n requestId?: string;\n}\n\ninterface InternalClientRequest extends OystehrClientRequest {\n ifMatch?: string;\n}\n\ntype FhirData<T extends FhirResource> = T | T[] | FhirBundle<T>;\nexport type FhirFetcherResponse<T extends FhirData<FhirResource> = any> = T;\n\nexport class SDKResource {\n protected readonly config: OystehrConfig;\n protected readonly logger: Logger;\n constructor(config: OystehrConfig) {\n this.config = config;\n this.logger = new Logger({\n level: this.config.logLevel,\n });\n }\n\n protected request(path: string, method: string, baseUrlThunk: () => string): FetcherFunction {\n return async (params: any, request?: InternalClientRequest): Promise<FetcherResponse> => {\n const configThunk = (): OystehrConfig => this.config;\n const loggerThunk = (): Logger => this.logger;\n try {\n // must await here to catch\n return await fetcher(baseUrlThunk, configThunk, loggerThunk, path, method)(params, request);\n } catch (err: any) {\n const error = err as { message: string; code: number; cause?: unknown };\n this.logger.error(error.message, { code: error.code, cause: error.cause });\n throw new OystehrSdkError({ message: error.message, code: error.code, cause: error.cause });\n }\n };\n }\n\n protected fhirRequest<T extends FhirResource = any>(path: string, method: string) {\n return async (params: any, request?: InternalClientRequest): Promise<FhirFetcherResponse<T>> => {\n try {\n const baseUrlThunk = (): string => this.config.services?.fhirApiUrl ?? defaultFhirApiUrl;\n const configThunk = (): OystehrConfig => this.config;\n const loggerThunk = (): Logger => this.logger;\n // must await here to catch\n return await fetcher(baseUrlThunk, configThunk, loggerThunk, path, method)(params, request);\n } catch (err: unknown) {\n // FHIR API error messages are JSON strings\n const fullError = err as { message: string | Record<string, any>; code: number; cause?: unknown };\n if (typeof fullError.message === 'string') {\n throw new OystehrSdkError({\n message: fullError.message,\n code: fullError.code,\n cause: fullError.cause,\n });\n }\n throw new OystehrFHIRError({\n error: fullError.message as OperationOutcome,\n code: fullError.code,\n });\n }\n };\n }\n}\n\nexport type FetcherError = { message: string; code: number };\nexport type FetcherResponse = any;\nexport type FetcherFunction = (\n params?: Record<string, any> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n) => Promise<FetcherResponse>;\n\nfunction isInternalClientRequest(request: Record<string, any>): request is InternalClientRequest {\n return (\n 'accessToken' in request ||\n ('projectId' in request && uuidValidate(request.projectId)) ||\n ('contentType' in request && request.contentType?.split('/').length === 2) ||\n 'requestId' in request ||\n ('ifMatch' in request && request.ifMatch.startsWith('W/\"'))\n );\n}\n\n/**\n * Parse XML response in format <response><status>...</status><output>...</output></response>\n */\nfunction parseXmlResponse(xmlString: string): Record<string, unknown> | null {\n try {\n // Extract status\n const statusMatch = xmlString.match(/<status>(\\d+)<\\/status>/);\n const status = statusMatch ? parseInt(statusMatch[1], 10) : null;\n\n // Extract output - everything between <output> and </output>\n const outputMatch = xmlString.match(/<output>([\\s\\S]*?)<\\/output>/);\n const output = outputMatch ? outputMatch[1] : null;\n\n if (status === null || output === null) {\n return null;\n }\n\n return { status, output };\n } catch (_err) {\n return null;\n }\n}\n\nfunction fetcher(\n baseUrlThunk: () => string,\n configThunk: () => OystehrConfig,\n loggerThunk: () => Logger,\n path: string,\n methodParam: string\n): FetcherFunction {\n return async (\n params?: Record<string, unknown> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n ): Promise<FetcherResponse> => {\n // this function supports multiple signatures. fetcher(baseUrl, path, method)(params, request) or fetcher(baseUrl, path, method)(request)\n // or fetcher(baseUrl, path, method)(params) or fetcher(baseUrl, path, method)(). the types for this are handled by Client<Path, Methods>\n // and this is the backend implementation behind it. the heuristic we're using is that if the first param is an object with an accessToken\n // and there is no second param, assume the first one is the request object instead\n // eslint-disable-next-line prefer-const\n let [providedParams, requestCtx] = extractParamsAndRequest(params, request);\n requestCtx ??= {};\n requestCtx.requestId ??= uuidv4();\n const config = configThunk();\n const logger = loggerThunk();\n const method = methodParam.toLowerCase() as HttpMethod;\n logger.debug('Beginning fetch', {\n method,\n path,\n requestId: requestCtx?.requestId,\n });\n const fetchImpl = config.fetch ?? fetch;\n const accessToken = requestCtx?.accessToken ?? config.accessToken;\n const projectId = requestCtx?.projectId ?? config.projectId;\n let finalPath = path;\n let finalParams = providedParams;\n if (!Array.isArray(providedParams)) {\n const [subbedPath, addlParams] = subParamsInPath(path, providedParams);\n finalPath = subbedPath;\n finalParams = addlParams;\n }\n logger.debug('Substituted parameters in path', {\n method,\n path,\n requestId: requestCtx?.requestId,\n });\n finalPath = finalPath.replace(/^\\//, ''); // remove leading slash\n const baseUrlEvaluated = baseUrlThunk();\n const fullBaseUrl = baseUrlEvaluated.endsWith('/') ? baseUrlEvaluated : baseUrlEvaluated + '/';\n const url = new URL(finalPath, fullBaseUrl);\n let body: any;\n\n if (Array.isArray(finalParams)) {\n body = JSON.stringify(finalParams);\n } else if (Object.keys(finalParams).length) {\n if (method === 'get') {\n addParamsToSearch(finalParams, url.searchParams);\n } else if (requestCtx?.contentType === 'application/x-www-form-urlencoded') {\n const search = new URLSearchParams();\n addParamsToSearch(finalParams, search);\n body = search.toString();\n } else {\n body = JSON.stringify(finalParams);\n }\n } else {\n // override for rpc call\n if (requestCtx?.contentType !== 'application/x-www-form-urlencoded' && method === 'post') {\n body = '{}';\n }\n }\n logger.debug('Prepared request body', {\n method,\n path,\n requestId: requestCtx?.requestId,\n });\n\n const headers: Record<string, string> = Object.assign(\n projectId\n ? {\n 'x-zapehr-project-id': projectId,\n 'x-oystehr-project-id': projectId,\n }\n : {},\n {\n 'content-type': requestCtx?.contentType ?? 'application/json',\n },\n accessToken ? { Authorization: `Bearer ${accessToken}` } : {},\n requestCtx?.ifMatch ? { 'If-Match': requestCtx.ifMatch } : {},\n { 'x-oystehr-request-id': requestCtx?.requestId }\n );\n const retryConfig: ConstructedRetryConfig = {\n retries: config.retry?.retries ?? 3,\n jitter: config.retry?.jitter ?? 20,\n delay: config.retry?.delay ?? 100,\n onRetry: config.retry?.onRetry,\n // Using array instead of set because the length is too short for uniqueness to be important\n retryOn: [...(config.retry?.retryOn ?? []), ...STATUS_CODES_TO_RETRY],\n };\n retryConfig.retryOn.push(...STATUS_CODES_TO_RETRY);\n return retry(async () => {\n logger.info('Request start', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n const now = Date.now();\n const response = await fetchImpl(\n new Request(url, {\n method: method.toUpperCase(),\n body,\n headers,\n })\n );\n logger.info('Request end', {\n method,\n url,\n duration: Date.now() - now,\n requestId: requestCtx?.requestId,\n });\n const responseBody = response.body ? await response.text() : null;\n let responseJson: Record<string, unknown> | null;\n const contentType = response.headers.get('content-type');\n try {\n if (\n responseBody &&\n (contentType?.includes('application/json') || contentType?.includes('application/fhir+json'))\n ) {\n logger.time('Deserialized JSON response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n responseJson = JSON.parse(responseBody);\n logger.timeEnd('Deserialized JSON response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n } else if (responseBody && (contentType?.includes('application/xml') || contentType?.includes('text/xml'))) {\n // Parse XML response into { status, output } structure\n logger.time('Deserialized XML response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n responseJson = parseXmlResponse(responseBody);\n logger.timeEnd('Deserialized XML response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n } else {\n responseJson = null;\n }\n } catch (_err) {\n // ignore JSON.parse errors\n responseJson = null;\n }\n logger.debug('Deserialized response', {\n method,\n url,\n requestId: requestCtx?.requestId,\n });\n const isError = !response.ok || response.status >= 400;\n if (isError) {\n const errObj = {\n message:\n (typeof responseJson?.output === 'string'\n ? responseJson.output // XML error case - output is XML string\n : (responseJson?.output as Record<string, unknown>)?.message) ?? // official zambda output format (JSON)\n responseJson?.message ?? // normal endpoint output format\n responseJson ?? // parsable json\n responseBody ?? // raw response\n response.statusText, // fallback to status text\n code:\n (responseJson?.output as Record<string, unknown>)?.code ?? // official zambda output format\n responseJson?.code ?? // normal endpoint output format\n response.status, // fallback to status code\n response,\n };\n throw errObj;\n }\n return responseJson;\n }, retryConfig);\n };\n}\n\ntype ConstructedRetryConfig = Omit<NonNullable<OystehrConfig['retry']>, 'retryOn'> & {\n jitter: NonNullable<NonNullable<OystehrConfig['retry']>['jitter']>;\n delay: NonNullable<NonNullable<OystehrConfig['retry']>['delay']>;\n retryOn: NonNullable<NonNullable<OystehrConfig['retry']>['retryOn']>;\n};\nasync function retry<T>(work: (attempt: number) => Promise<T>, config: ConstructedRetryConfig): Promise<T> {\n let lastErr;\n for (const attempt of Array.from({ length: (config.retries ?? 0) + 1 }, (_, index) => index)) {\n try {\n return await work(attempt);\n } catch (e: any) {\n let isRetryable = false;\n if ('response' in e) {\n // error from API\n const err = e as FetcherError;\n isRetryable = config.retryOn.includes(err.code);\n // Removes response\n lastErr = { message: e.message, code: e.code };\n } else {\n lastErr = e;\n // error from fetch\n if ('code' in e && typeof e.code === 'string') {\n const err = e as { code: string };\n isRetryable = ERROR_CODES_TO_RETRY.includes(err.code);\n }\n }\n if (!isRetryable) {\n break;\n }\n const jitter = Math.floor(Math.random() * (config.jitter + 1));\n await new Promise((resolve) => setTimeout(resolve, config.delay + jitter));\n if (config.onRetry && attempt !== (config.retries ?? 0)) {\n config.onRetry(attempt + 1);\n }\n }\n }\n throw lastErr;\n}\n\n/**\n * Substitutes params in a path and returns the path with params substituted and any unused params.\n *\n * Uses the property names in the params object to determine the param to substitute in the path.\n *\n * @param path JSON API resource URI\n * @param params all params provided to the client method\n * @returns resource URI with params substituted and any unused params\n */\nfunction subParamsInPath(path: string, params: Record<string, unknown>): [string, Record<string, string>] {\n const unusedParams = { ...params };\n // capture everything of the form `{paramName}` and replace with the value of `params[paramName]`\n const subbedPath = path.replace(/\\{([^}]+)\\}/g, (_, paramName) => {\n delete unusedParams[paramName];\n // override for path params that are paths, indicated by a `+` at the end\n if (paramName.match(/^.*\\+$/)) {\n return params[paramName] + '';\n }\n // error if param value is empty\n if (!params[paramName] || params[paramName] === '') {\n throw new OystehrSdkError({ message: `Required path parameter is an empty string: ${paramName}`, code: 400 });\n }\n // encode search params\n if (params[paramName]) {\n return encodeURIComponent(params[paramName] + ''); // coerce to string\n }\n return '';\n });\n\n const unusedKeys = Object.keys(unusedParams);\n const addlParams = unusedKeys.length\n ? unusedKeys.reduce((acc, key) => ({ ...acc, [key]: unusedParams[key] }), {})\n : {};\n return [subbedPath, addlParams];\n}\n\n/**\n * Adds params to a URLSearchParams object in such a way as to preserve array values.\n * @param params params\n * @param search URLSearchParams object\n */\nexport function addParamsToSearch(params: Record<string, unknown>, search: URLSearchParams): void {\n for (const [key, value] of Object.entries(params)) {\n if (Array.isArray(value)) {\n value.forEach((v) => search.append(key, v as string));\n continue;\n }\n search.append(key, value as string);\n }\n}\n\nexport function extractParamsAndRequest(\n params?: Record<string, unknown> | [any] | InternalClientRequest,\n request?: InternalClientRequest\n): [Record<string, unknown>, InternalClientRequest | undefined] {\n const providedParams: Record<string, unknown> | [any] =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? {}\n : (params as Record<string, unknown>) ?? {};\n const requestCtx =\n !!params && !request && !Array.isArray(params) && isInternalClientRequest(params)\n ? (params as InternalClientRequest)\n : request;\n return [providedParams, requestCtx];\n}\n"],"names":["uuidValidate","uuidv4"],"mappings":";;;;AAOO,MAAM,oBAAoB,GAAG;AACpC,MAAM,iBAAiB,GAAG,6BAA6B;AACvD,MAAM,qBAAqB,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC;AAC5D,MAAM,oBAAoB,GAAG;IAC3B,YAAY;IACZ,cAAc;IACd,OAAO;IACP,WAAW;IACX,yBAAyB;IACzB,yBAAyB;IACzB,yBAAyB;IACzB,gBAAgB;CACjB;MAiCY,WAAW,CAAA;AACH,IAAA,MAAM;AACN,IAAA,MAAM;AACzB,IAAA,WAAA,CAAY,MAAqB,EAAA;AAC/B,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM;AACpB,QAAA,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;AACvB,YAAA,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;AAC5B,SAAA,CAAC;IACJ;AAEU,IAAA,OAAO,CAAC,IAAY,EAAE,MAAc,EAAE,YAA0B,EAAA;AACxE,QAAA,OA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KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,CAAW,CAAC,CAAC;YACrD;QACF;AACA,QAAA,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,KAAe,CAAC;IACrC;AACF;AAEM,SAAU,uBAAuB,CACrC,MAAgE,EAChE,OAA+B,EAAA;IAE/B,MAAM,cAAc,GAClB,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,uBAAuB,CAAC,MAAM;AAC9E,UAAE;AACF,UAAG,MAAkC,IAAI,EAAE;IAC/C,MAAM,UAAU,GACd,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,uBAAuB,CAAC,MAAM;AAC9E,UAAG;UACD,OAAO;AACb,IAAA,OAAO,CAAC,cAAc,EAAE,UAAU,CAAC;AACrC;;;;"}
@@ -10,6 +10,10 @@ export interface OystehrConfig {
10
10
  * Optional Oystehr Project ID. Required for developer accessTokens.
11
11
  */
12
12
  projectId?: string;
13
+ /**
14
+ * Optional log level for the SDK logger. Possible values are 'error', 'info', and 'debug'.
15
+ */
16
+ logLevel?: 'error' | 'info' | 'debug';
13
17
  fhirApiUrl?: string;
14
18
  projectApiUrl?: string;
15
19
  services?: {
@@ -18,7 +22,9 @@ export interface OystehrConfig {
18
22
  fhirApiUrl?: string;
19
23
  labApiUrl?: string;
20
24
  projectApiUrl?: string;
25
+ rcmApiUrl?: string;
21
26
  terminologyApiUrl?: string;
27
+ zambdaApiUrl?: string;
22
28
  };
23
29
  /**
24
30
  * Optionally provide a custom fetch implementation. This must conform to the