@medplum/core 0.9.27 → 0.9.30
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/README.md +1 -1
- package/dist/cjs/cache.d.ts +34 -0
- package/dist/cjs/client.d.ts +1093 -0
- package/dist/cjs/crypto.d.ts +9 -0
- package/dist/cjs/eventtarget.d.ts +13 -0
- package/dist/cjs/fhirpath/atoms.d.ts +150 -0
- package/dist/cjs/fhirpath/date.d.ts +1 -0
- package/dist/cjs/fhirpath/functions.d.ts +5 -0
- package/dist/cjs/fhirpath/index.d.ts +4 -0
- package/dist/cjs/fhirpath/parse.d.ts +24 -0
- package/dist/cjs/fhirpath/tokenize.d.ts +5 -0
- package/dist/cjs/fhirpath/utils.d.ts +95 -0
- package/dist/cjs/format.d.ts +21 -0
- package/dist/cjs/hl7.d.ts +43 -0
- package/dist/cjs/index.d.ts +12 -0
- package/dist/cjs/index.js +257 -48
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/cjs/jwt.d.ts +5 -0
- package/dist/cjs/outcomes.d.ts +30 -0
- package/dist/cjs/readablepromise.d.ts +48 -0
- package/dist/cjs/search.d.ts +64 -0
- package/dist/cjs/searchparams.d.ts +35 -0
- package/dist/cjs/storage.d.ts +47 -0
- package/dist/cjs/types.d.ts +148 -0
- package/dist/cjs/utils.d.ts +239 -0
- package/dist/esm/client.d.ts +11 -11
- package/dist/esm/client.js +50 -38
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/fhirpath/utils.js +12 -3
- package/dist/esm/fhirpath/utils.js.map +1 -1
- package/dist/esm/format.d.ts +7 -1
- package/dist/esm/format.js +108 -1
- package/dist/esm/format.js.map +1 -1
- package/dist/esm/index.js +3 -3
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/dist/esm/outcomes.d.ts +9 -1
- package/dist/esm/outcomes.js +63 -7
- package/dist/esm/outcomes.js.map +1 -1
- package/dist/esm/utils.d.ts +15 -0
- package/dist/esm/utils.js +18 -1
- package/dist/esm/utils.js.map +1 -1
- package/package.json +3 -3
- package/stats.html +4034 -0
package/dist/cjs/index.js
CHANGED
|
@@ -156,6 +156,111 @@
|
|
|
156
156
|
function formatFamilyName(name) {
|
|
157
157
|
return name.family || '';
|
|
158
158
|
}
|
|
159
|
+
function isValidDate(date) {
|
|
160
|
+
return date instanceof Date && !isNaN(date.getTime());
|
|
161
|
+
}
|
|
162
|
+
function formatDate(date, options) {
|
|
163
|
+
if (!date) {
|
|
164
|
+
return '';
|
|
165
|
+
}
|
|
166
|
+
const d = new Date(date);
|
|
167
|
+
if (!isValidDate(d)) {
|
|
168
|
+
return '';
|
|
169
|
+
}
|
|
170
|
+
return d.toLocaleDateString(undefined, options);
|
|
171
|
+
}
|
|
172
|
+
function formatTime(time, options) {
|
|
173
|
+
if (!time) {
|
|
174
|
+
return '';
|
|
175
|
+
}
|
|
176
|
+
const d = new Date('2000-01-01T' + time + 'Z');
|
|
177
|
+
if (!isValidDate(d)) {
|
|
178
|
+
return '';
|
|
179
|
+
}
|
|
180
|
+
return d.toLocaleTimeString(undefined, options);
|
|
181
|
+
}
|
|
182
|
+
function formatDateTime(dateTime, options) {
|
|
183
|
+
if (!dateTime) {
|
|
184
|
+
return '';
|
|
185
|
+
}
|
|
186
|
+
const d = new Date(dateTime);
|
|
187
|
+
if (!isValidDate(d)) {
|
|
188
|
+
return '';
|
|
189
|
+
}
|
|
190
|
+
return d.toLocaleString(undefined, options);
|
|
191
|
+
}
|
|
192
|
+
function formatPeriod(period) {
|
|
193
|
+
if (!period || (!period.start && !period.end)) {
|
|
194
|
+
return '';
|
|
195
|
+
}
|
|
196
|
+
return formatDateTime(period.start) + ' - ' + formatDateTime(period.end);
|
|
197
|
+
}
|
|
198
|
+
const unitAdverbForm = {
|
|
199
|
+
s: 'every second',
|
|
200
|
+
min: 'every minute',
|
|
201
|
+
h: 'hourly',
|
|
202
|
+
d: 'daily',
|
|
203
|
+
wk: 'weekly',
|
|
204
|
+
mo: 'monthly',
|
|
205
|
+
a: 'annually',
|
|
206
|
+
};
|
|
207
|
+
const singularUnits = {
|
|
208
|
+
s: 'second',
|
|
209
|
+
min: 'minute',
|
|
210
|
+
h: 'hour',
|
|
211
|
+
d: 'day',
|
|
212
|
+
wk: 'week',
|
|
213
|
+
mo: 'month',
|
|
214
|
+
a: 'year',
|
|
215
|
+
};
|
|
216
|
+
const pluralUnits = {
|
|
217
|
+
s: 'seconds',
|
|
218
|
+
min: 'minutes',
|
|
219
|
+
h: 'hours',
|
|
220
|
+
d: 'days',
|
|
221
|
+
wk: 'weeks',
|
|
222
|
+
mo: 'months',
|
|
223
|
+
a: 'years',
|
|
224
|
+
};
|
|
225
|
+
function formatTiming(timing) {
|
|
226
|
+
var _a;
|
|
227
|
+
if (!timing) {
|
|
228
|
+
return '';
|
|
229
|
+
}
|
|
230
|
+
const builder = [];
|
|
231
|
+
if ((_a = timing.repeat) === null || _a === void 0 ? void 0 : _a.periodUnit) {
|
|
232
|
+
const frequency = timing.repeat.frequency || 1;
|
|
233
|
+
const period = timing.repeat.period || 1;
|
|
234
|
+
const periodUnit = timing.repeat.periodUnit;
|
|
235
|
+
if (frequency === 1 && period === 1) {
|
|
236
|
+
builder.push(unitAdverbForm[periodUnit]);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
if (frequency === 1) {
|
|
240
|
+
builder.push('once');
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
builder.push(frequency + ' times');
|
|
244
|
+
}
|
|
245
|
+
if (period === 1) {
|
|
246
|
+
builder.push('per ' + singularUnits[periodUnit]);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
builder.push('per ' + period + ' ' + pluralUnits[periodUnit]);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (timing.repeat.dayOfWeek) {
|
|
253
|
+
builder.push('on ' + timing.repeat.dayOfWeek.map(capitalize).join(', '));
|
|
254
|
+
}
|
|
255
|
+
if (timing.repeat.timeOfDay) {
|
|
256
|
+
builder.push('at ' + timing.repeat.timeOfDay.map((t) => formatTime(t)).join(', '));
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
if (timing.event) {
|
|
260
|
+
builder.push(timing.event.map((d) => formatDateTime(d)).join(', '));
|
|
261
|
+
}
|
|
262
|
+
return capitalize(builder.join(' ').trim());
|
|
263
|
+
}
|
|
159
264
|
|
|
160
265
|
/**
|
|
161
266
|
* Creates a reference resource.
|
|
@@ -509,6 +614,23 @@
|
|
|
509
614
|
}
|
|
510
615
|
return true;
|
|
511
616
|
}
|
|
617
|
+
/**
|
|
618
|
+
* Creates a deep clone of the input value.
|
|
619
|
+
*
|
|
620
|
+
* Limitations:
|
|
621
|
+
* - Only supports JSON primitives and arrays.
|
|
622
|
+
* - Does not support Functions, lambdas, etc.
|
|
623
|
+
* - Does not support circular references.
|
|
624
|
+
*
|
|
625
|
+
* See: https://web.dev/structured-clone/
|
|
626
|
+
* See: https://stackoverflow.com/questions/40488190/how-is-structured-clone-algorithm-different-from-deep-copy
|
|
627
|
+
*
|
|
628
|
+
* @param input The input to clone.
|
|
629
|
+
* @returns A deep clone of the input.
|
|
630
|
+
*/
|
|
631
|
+
function deepClone(input) {
|
|
632
|
+
return JSON.parse(JSON.stringify(input));
|
|
633
|
+
}
|
|
512
634
|
/**
|
|
513
635
|
* Returns true if the input string is a UUID.
|
|
514
636
|
* @param input The input string.
|
|
@@ -6091,13 +6213,13 @@
|
|
|
6091
6213
|
*/
|
|
6092
6214
|
const globalSchema = baseSchema;
|
|
6093
6215
|
|
|
6094
|
-
// PKCE auth
|
|
6216
|
+
// PKCE auth based on:
|
|
6095
6217
|
// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
|
|
6096
6218
|
var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_createPdf, _MedplumClient_storage, _MedplumClient_requestCache, _MedplumClient_cacheTime, _MedplumClient_baseUrl, _MedplumClient_clientId, _MedplumClient_authorizeUrl, _MedplumClient_tokenUrl, _MedplumClient_logoutUrl, _MedplumClient_onUnauthenticated, _MedplumClient_accessToken, _MedplumClient_refreshToken, _MedplumClient_refreshPromise, _MedplumClient_profilePromise, _MedplumClient_profile, _MedplumClient_config, _MedplumClient_addLogin, _MedplumClient_refreshProfile, _MedplumClient_getCacheEntry, _MedplumClient_setCacheEntry, _MedplumClient_request, _MedplumClient_addFetchOptionsDefaults, _MedplumClient_setRequestContentType, _MedplumClient_setRequestBody, _MedplumClient_handleUnauthenticated, _MedplumClient_startPkce, _MedplumClient_requestAuthorization, _MedplumClient_refresh, _MedplumClient_fetchTokens, _MedplumClient_verifyTokens, _MedplumClient_setupStorageListener;
|
|
6097
6219
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
6098
6220
|
const DEFAULT_SCOPE = 'launch/patient openid fhirUser offline_access user/*.*';
|
|
6099
6221
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
6100
|
-
const DEFAULT_CACHE_TIME =
|
|
6222
|
+
const DEFAULT_CACHE_TIME = 60000; // 60 seconds
|
|
6101
6223
|
const JSON_CONTENT_TYPE = 'application/json';
|
|
6102
6224
|
const FHIR_CONTENT_TYPE = 'application/fhir+json';
|
|
6103
6225
|
const PATCH_CONTENT_TYPE = 'application/json-patch+json';
|
|
@@ -6174,16 +6296,13 @@
|
|
|
6174
6296
|
if (!options.baseUrl.startsWith('http')) {
|
|
6175
6297
|
throw new Error('Base URL must start with http or https');
|
|
6176
6298
|
}
|
|
6177
|
-
if (!options.baseUrl.endsWith('/')) {
|
|
6178
|
-
throw new Error('Base URL must end with a trailing slash');
|
|
6179
|
-
}
|
|
6180
6299
|
}
|
|
6181
6300
|
__classPrivateFieldSet(this, _MedplumClient_fetch, (options === null || options === void 0 ? void 0 : options.fetch) || window.fetch.bind(window), "f");
|
|
6182
6301
|
__classPrivateFieldSet(this, _MedplumClient_createPdf, options === null || options === void 0 ? void 0 : options.createPdf, "f");
|
|
6183
6302
|
__classPrivateFieldSet(this, _MedplumClient_storage, new ClientStorage(), "f");
|
|
6184
6303
|
__classPrivateFieldSet(this, _MedplumClient_requestCache, new LRUCache((_a = options === null || options === void 0 ? void 0 : options.resourceCacheSize) !== null && _a !== void 0 ? _a : DEFAULT_RESOURCE_CACHE_SIZE), "f");
|
|
6185
6304
|
__classPrivateFieldSet(this, _MedplumClient_cacheTime, (_b = options === null || options === void 0 ? void 0 : options.cacheTime) !== null && _b !== void 0 ? _b : DEFAULT_CACHE_TIME, "f");
|
|
6186
|
-
__classPrivateFieldSet(this, _MedplumClient_baseUrl, (options === null || options === void 0 ? void 0 : options.baseUrl) || DEFAULT_BASE_URL, "f");
|
|
6305
|
+
__classPrivateFieldSet(this, _MedplumClient_baseUrl, ensureTrailingSlash(options === null || options === void 0 ? void 0 : options.baseUrl) || DEFAULT_BASE_URL, "f");
|
|
6187
6306
|
__classPrivateFieldSet(this, _MedplumClient_clientId, (options === null || options === void 0 ? void 0 : options.clientId) || '', "f");
|
|
6188
6307
|
__classPrivateFieldSet(this, _MedplumClient_authorizeUrl, (options === null || options === void 0 ? void 0 : options.authorizeUrl) || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/authorize', "f");
|
|
6189
6308
|
__classPrivateFieldSet(this, _MedplumClient_tokenUrl, (options === null || options === void 0 ? void 0 : options.tokenUrl) || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/token', "f");
|
|
@@ -6432,7 +6551,6 @@
|
|
|
6432
6551
|
*/
|
|
6433
6552
|
signOut() {
|
|
6434
6553
|
this.clear();
|
|
6435
|
-
return Promise.resolve();
|
|
6436
6554
|
}
|
|
6437
6555
|
/**
|
|
6438
6556
|
* Tries to sign in the user.
|
|
@@ -6441,15 +6559,17 @@
|
|
|
6441
6559
|
* @category Authentication
|
|
6442
6560
|
*/
|
|
6443
6561
|
signInWithRedirect() {
|
|
6444
|
-
|
|
6445
|
-
|
|
6446
|
-
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
-
|
|
6452
|
-
|
|
6562
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6563
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
6564
|
+
const code = urlParams.get('code');
|
|
6565
|
+
if (!code) {
|
|
6566
|
+
yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_requestAuthorization).call(this);
|
|
6567
|
+
return undefined;
|
|
6568
|
+
}
|
|
6569
|
+
else {
|
|
6570
|
+
return this.processCode(code);
|
|
6571
|
+
}
|
|
6572
|
+
});
|
|
6453
6573
|
}
|
|
6454
6574
|
/**
|
|
6455
6575
|
* Tries to sign out the user.
|
|
@@ -6840,7 +6960,6 @@
|
|
|
6840
6960
|
*
|
|
6841
6961
|
* ```typescript
|
|
6842
6962
|
* const result = await medplum.createResourceIfNoneExist(
|
|
6843
|
-
* 'Patient?identifier=123',
|
|
6844
6963
|
* {
|
|
6845
6964
|
* resourceType: 'Patient',
|
|
6846
6965
|
* identifier: [{
|
|
@@ -6851,14 +6970,16 @@
|
|
|
6851
6970
|
* family: 'Smith',
|
|
6852
6971
|
* given: ['John']
|
|
6853
6972
|
* }]
|
|
6854
|
-
* }
|
|
6973
|
+
* },
|
|
6974
|
+
* 'identifier=123'
|
|
6975
|
+
* );
|
|
6855
6976
|
* console.log(result.id);
|
|
6856
6977
|
* ```
|
|
6857
6978
|
*
|
|
6858
6979
|
* This method is syntactic sugar for:
|
|
6859
6980
|
*
|
|
6860
6981
|
* ```typescript
|
|
6861
|
-
* return searchOne(query) ?? createResource(resource);
|
|
6982
|
+
* return searchOne(resourceType, query) ?? createResource(resource);
|
|
6862
6983
|
* ```
|
|
6863
6984
|
*
|
|
6864
6985
|
* The query parameter only contains the search parameters (what would be in the URL following the "?").
|
|
@@ -6867,7 +6988,7 @@
|
|
|
6867
6988
|
*
|
|
6868
6989
|
* @category Create
|
|
6869
6990
|
* @param resource The FHIR resource to create.
|
|
6870
|
-
* @param query The search query for an equivalent resource.
|
|
6991
|
+
* @param query The search query for an equivalent resource (should not include resource type or "?").
|
|
6871
6992
|
* @returns The result of the create operation.
|
|
6872
6993
|
*/
|
|
6873
6994
|
createResourceIfNoneExist(resource, query) {
|
|
@@ -6999,14 +7120,19 @@
|
|
|
6999
7120
|
* @returns The result of the update operation.
|
|
7000
7121
|
*/
|
|
7001
7122
|
updateResource(resource) {
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
7008
|
-
|
|
7009
|
-
|
|
7123
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7124
|
+
if (!resource.resourceType) {
|
|
7125
|
+
throw new Error('Missing resourceType');
|
|
7126
|
+
}
|
|
7127
|
+
if (!resource.id) {
|
|
7128
|
+
throw new Error('Missing id');
|
|
7129
|
+
}
|
|
7130
|
+
this.invalidateSearches(resource.resourceType);
|
|
7131
|
+
const result = yield this.put(this.fhirUrl(resource.resourceType, resource.id), resource);
|
|
7132
|
+
// On 304 not modified, result will be undefined
|
|
7133
|
+
// Return the user input instead
|
|
7134
|
+
return result !== null && result !== void 0 ? result : resource;
|
|
7135
|
+
});
|
|
7010
7136
|
}
|
|
7011
7137
|
/**
|
|
7012
7138
|
* Updates a FHIR resource using JSONPatch operations.
|
|
@@ -7443,16 +7569,18 @@
|
|
|
7443
7569
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setString('codeChallenge', codeChallenge);
|
|
7444
7570
|
});
|
|
7445
7571
|
}, _MedplumClient_requestAuthorization = function _MedplumClient_requestAuthorization() {
|
|
7446
|
-
|
|
7447
|
-
|
|
7448
|
-
|
|
7449
|
-
|
|
7450
|
-
|
|
7451
|
-
|
|
7452
|
-
|
|
7453
|
-
|
|
7454
|
-
|
|
7455
|
-
|
|
7572
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
7573
|
+
yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_startPkce).call(this);
|
|
7574
|
+
const url = new URL(__classPrivateFieldGet(this, _MedplumClient_authorizeUrl, "f"));
|
|
7575
|
+
url.searchParams.set('response_type', 'code');
|
|
7576
|
+
url.searchParams.set('state', __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('pkceState'));
|
|
7577
|
+
url.searchParams.set('client_id', __classPrivateFieldGet(this, _MedplumClient_clientId, "f"));
|
|
7578
|
+
url.searchParams.set('redirect_uri', getBaseUrl());
|
|
7579
|
+
url.searchParams.set('scope', DEFAULT_SCOPE);
|
|
7580
|
+
url.searchParams.set('code_challenge_method', 'S256');
|
|
7581
|
+
url.searchParams.set('code_challenge', __classPrivateFieldGet(this, _MedplumClient_storage, "f").getString('codeChallenge'));
|
|
7582
|
+
window.location.assign(url.toString());
|
|
7583
|
+
});
|
|
7456
7584
|
}, _MedplumClient_refresh = function _MedplumClient_refresh() {
|
|
7457
7585
|
return __awaiter(this, void 0, void 0, function* () {
|
|
7458
7586
|
if (__classPrivateFieldGet(this, _MedplumClient_refreshPromise, "f")) {
|
|
@@ -7528,6 +7656,12 @@
|
|
|
7528
7656
|
function getBaseUrl() {
|
|
7529
7657
|
return window.location.protocol + '//' + window.location.host + '/';
|
|
7530
7658
|
}
|
|
7659
|
+
function ensureTrailingSlash(url) {
|
|
7660
|
+
if (!url) {
|
|
7661
|
+
return url;
|
|
7662
|
+
}
|
|
7663
|
+
return url.endsWith('/') ? url : url + '/';
|
|
7664
|
+
}
|
|
7531
7665
|
|
|
7532
7666
|
/**
|
|
7533
7667
|
* Returns a single element array with a typed boolean value.
|
|
@@ -7668,9 +7802,18 @@
|
|
|
7668
7802
|
result = input[path];
|
|
7669
7803
|
}
|
|
7670
7804
|
else {
|
|
7671
|
-
|
|
7672
|
-
|
|
7673
|
-
|
|
7805
|
+
// Only support property names that would be valid types
|
|
7806
|
+
// Examples:
|
|
7807
|
+
// value + valueString = ok, because "string" is valid
|
|
7808
|
+
// value + valueDecimal = ok, because "decimal" is valid
|
|
7809
|
+
// id + identifiier = not ok, because "entifier" is not a valid type
|
|
7810
|
+
// resource + resourceType = not ok, because "type" is not a valid type
|
|
7811
|
+
for (const propertyType in exports.PropertyType) {
|
|
7812
|
+
const propertyName = path + capitalize(propertyType);
|
|
7813
|
+
if (propertyName in input) {
|
|
7814
|
+
result = input[propertyName];
|
|
7815
|
+
break;
|
|
7816
|
+
}
|
|
7674
7817
|
}
|
|
7675
7818
|
}
|
|
7676
7819
|
if (result === undefined) {
|
|
@@ -10277,7 +10420,9 @@
|
|
|
10277
10420
|
const GONE_ID = 'gone';
|
|
10278
10421
|
const NOT_MODIFIED_ID = 'not-modified';
|
|
10279
10422
|
const NOT_FOUND_ID = 'not-found';
|
|
10280
|
-
const
|
|
10423
|
+
const UNAUTHORIZED_ID = 'unauthorized';
|
|
10424
|
+
const FORBIDDEN_ID = 'forbidden';
|
|
10425
|
+
const TOO_MANY_REQUESTS_ID = 'too-many-requests';
|
|
10281
10426
|
const allOk = {
|
|
10282
10427
|
resourceType: 'OperationOutcome',
|
|
10283
10428
|
id: OK_ID,
|
|
@@ -10330,6 +10475,32 @@
|
|
|
10330
10475
|
},
|
|
10331
10476
|
],
|
|
10332
10477
|
};
|
|
10478
|
+
const unauthorized = {
|
|
10479
|
+
resourceType: 'OperationOutcome',
|
|
10480
|
+
id: UNAUTHORIZED_ID,
|
|
10481
|
+
issue: [
|
|
10482
|
+
{
|
|
10483
|
+
severity: 'error',
|
|
10484
|
+
code: 'login',
|
|
10485
|
+
details: {
|
|
10486
|
+
text: 'Unauthorized',
|
|
10487
|
+
},
|
|
10488
|
+
},
|
|
10489
|
+
],
|
|
10490
|
+
};
|
|
10491
|
+
const forbidden = {
|
|
10492
|
+
resourceType: 'OperationOutcome',
|
|
10493
|
+
id: FORBIDDEN_ID,
|
|
10494
|
+
issue: [
|
|
10495
|
+
{
|
|
10496
|
+
severity: 'error',
|
|
10497
|
+
code: 'forbidden',
|
|
10498
|
+
details: {
|
|
10499
|
+
text: 'Forbidden',
|
|
10500
|
+
},
|
|
10501
|
+
},
|
|
10502
|
+
],
|
|
10503
|
+
};
|
|
10333
10504
|
const gone = {
|
|
10334
10505
|
resourceType: 'OperationOutcome',
|
|
10335
10506
|
id: GONE_ID,
|
|
@@ -10343,15 +10514,15 @@
|
|
|
10343
10514
|
},
|
|
10344
10515
|
],
|
|
10345
10516
|
};
|
|
10346
|
-
const
|
|
10517
|
+
const tooManyRequests = {
|
|
10347
10518
|
resourceType: 'OperationOutcome',
|
|
10348
|
-
id:
|
|
10519
|
+
id: TOO_MANY_REQUESTS_ID,
|
|
10349
10520
|
issue: [
|
|
10350
10521
|
{
|
|
10351
10522
|
severity: 'error',
|
|
10352
|
-
code: '
|
|
10523
|
+
code: 'throttled',
|
|
10353
10524
|
details: {
|
|
10354
|
-
text: '
|
|
10525
|
+
text: 'Too Many Requests',
|
|
10355
10526
|
},
|
|
10356
10527
|
},
|
|
10357
10528
|
],
|
|
@@ -10390,7 +10561,10 @@
|
|
|
10390
10561
|
else if (outcome.id === NOT_MODIFIED_ID) {
|
|
10391
10562
|
return 304;
|
|
10392
10563
|
}
|
|
10393
|
-
else if (outcome.id ===
|
|
10564
|
+
else if (outcome.id === UNAUTHORIZED_ID) {
|
|
10565
|
+
return 401;
|
|
10566
|
+
}
|
|
10567
|
+
else if (outcome.id === FORBIDDEN_ID) {
|
|
10394
10568
|
return 403;
|
|
10395
10569
|
}
|
|
10396
10570
|
else if (outcome.id === NOT_FOUND_ID) {
|
|
@@ -10399,6 +10573,9 @@
|
|
|
10399
10573
|
else if (outcome.id === GONE_ID) {
|
|
10400
10574
|
return 410;
|
|
10401
10575
|
}
|
|
10576
|
+
else if (outcome.id === TOO_MANY_REQUESTS_ID) {
|
|
10577
|
+
return 429;
|
|
10578
|
+
}
|
|
10402
10579
|
else {
|
|
10403
10580
|
return 400;
|
|
10404
10581
|
}
|
|
@@ -10420,6 +10597,28 @@
|
|
|
10420
10597
|
this.outcome = outcome;
|
|
10421
10598
|
}
|
|
10422
10599
|
}
|
|
10600
|
+
/**
|
|
10601
|
+
* Normalizes an error object into a displayable error string.
|
|
10602
|
+
* @param error The error value which could be a string, Error, OperationOutcome, or other unknown type.
|
|
10603
|
+
* @returns A display string for the error.
|
|
10604
|
+
*/
|
|
10605
|
+
function normalizeErrorString(error) {
|
|
10606
|
+
var _a, _b, _c, _d;
|
|
10607
|
+
if (!error) {
|
|
10608
|
+
return 'Unknown error';
|
|
10609
|
+
}
|
|
10610
|
+
if (typeof error === 'string') {
|
|
10611
|
+
return error;
|
|
10612
|
+
}
|
|
10613
|
+
if (error instanceof Error) {
|
|
10614
|
+
return error.message;
|
|
10615
|
+
}
|
|
10616
|
+
if (typeof error === 'object' && 'resourceType' in error) {
|
|
10617
|
+
const outcome = error;
|
|
10618
|
+
return (_d = (_c = (_b = (_a = outcome.issue) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.details) === null || _c === void 0 ? void 0 : _c.text) !== null && _d !== void 0 ? _d : 'Unknown error';
|
|
10619
|
+
}
|
|
10620
|
+
return JSON.stringify(error);
|
|
10621
|
+
}
|
|
10423
10622
|
|
|
10424
10623
|
const DEFAULT_SEARCH_COUNT = 20;
|
|
10425
10624
|
/**
|
|
@@ -10799,7 +10998,6 @@
|
|
|
10799
10998
|
exports.UnaryOperatorAtom = UnaryOperatorAtom;
|
|
10800
10999
|
exports.UnionAtom = UnionAtom;
|
|
10801
11000
|
exports.XorAtom = XorAtom;
|
|
10802
|
-
exports.accessDenied = accessDenied;
|
|
10803
11001
|
exports.allOk = allOk;
|
|
10804
11002
|
exports.arrayBufferToBase64 = arrayBufferToBase64;
|
|
10805
11003
|
exports.arrayBufferToHex = arrayBufferToHex;
|
|
@@ -10814,6 +11012,7 @@
|
|
|
10814
11012
|
exports.createSchema = createSchema;
|
|
10815
11013
|
exports.createTypeSchema = createTypeSchema;
|
|
10816
11014
|
exports.created = created;
|
|
11015
|
+
exports.deepClone = deepClone;
|
|
10817
11016
|
exports.deepEquals = deepEquals$1;
|
|
10818
11017
|
exports.evalFhirPath = evalFhirPath;
|
|
10819
11018
|
exports.evalFhirPathTyped = evalFhirPathTyped;
|
|
@@ -10825,11 +11024,17 @@
|
|
|
10825
11024
|
exports.fhirPathNot = fhirPathNot;
|
|
10826
11025
|
exports.findObservationInterval = findObservationInterval;
|
|
10827
11026
|
exports.findObservationReferenceRange = findObservationReferenceRange;
|
|
11027
|
+
exports.forbidden = forbidden;
|
|
10828
11028
|
exports.formatAddress = formatAddress;
|
|
11029
|
+
exports.formatDate = formatDate;
|
|
11030
|
+
exports.formatDateTime = formatDateTime;
|
|
10829
11031
|
exports.formatFamilyName = formatFamilyName;
|
|
10830
11032
|
exports.formatGivenName = formatGivenName;
|
|
10831
11033
|
exports.formatHumanName = formatHumanName;
|
|
11034
|
+
exports.formatPeriod = formatPeriod;
|
|
10832
11035
|
exports.formatSearchQuery = formatSearchQuery;
|
|
11036
|
+
exports.formatTime = formatTime;
|
|
11037
|
+
exports.formatTiming = formatTiming;
|
|
10833
11038
|
exports.getCodeBySystem = getCodeBySystem;
|
|
10834
11039
|
exports.getDateProperty = getDateProperty;
|
|
10835
11040
|
exports.getDisplayString = getDisplayString;
|
|
@@ -10859,7 +11064,9 @@
|
|
|
10859
11064
|
exports.isQuantityEquivalent = isQuantityEquivalent;
|
|
10860
11065
|
exports.isStringArray = isStringArray;
|
|
10861
11066
|
exports.isUUID = isUUID;
|
|
11067
|
+
exports.isValidDate = isValidDate;
|
|
10862
11068
|
exports.matchesRange = matchesRange;
|
|
11069
|
+
exports.normalizeErrorString = normalizeErrorString;
|
|
10863
11070
|
exports.notFound = notFound;
|
|
10864
11071
|
exports.notModified = notModified;
|
|
10865
11072
|
exports.parseFhirPath = parseFhirPath;
|
|
@@ -10877,6 +11084,8 @@
|
|
|
10877
11084
|
exports.toJsBoolean = toJsBoolean;
|
|
10878
11085
|
exports.toTypedValue = toTypedValue;
|
|
10879
11086
|
exports.tokenize = tokenize;
|
|
11087
|
+
exports.tooManyRequests = tooManyRequests;
|
|
11088
|
+
exports.unauthorized = unauthorized;
|
|
10880
11089
|
|
|
10881
11090
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
10882
11091
|
|