@medplum/agent 5.0.13 → 5.0.14
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/index.cjs +92 -82
- package/package.json +5 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -29040,8 +29040,8 @@ var require_util = __commonJS({
|
|
|
29040
29040
|
};
|
|
29041
29041
|
exports2.nearestCommonProto = nearestCommonProto;
|
|
29042
29042
|
var hardMixProtos = (ingredients, constructor, exclude = []) => {
|
|
29043
|
-
var
|
|
29044
|
-
const base = (
|
|
29043
|
+
var _a2;
|
|
29044
|
+
const base = (_a2 = (0, exports2.nearestCommonProto)(...ingredients)) !== null && _a2 !== void 0 ? _a2 : Object.prototype;
|
|
29045
29045
|
const mixedProto = Object.create(base);
|
|
29046
29046
|
const visitedProtos = (0, exports2.protoChain)(base);
|
|
29047
29047
|
for (let prototype of ingredients) {
|
|
@@ -29171,8 +29171,8 @@ var require_mixin_tracking = __commonJS({
|
|
|
29171
29171
|
frontier.forEach((item) => visited.add(item));
|
|
29172
29172
|
const newFrontier = /* @__PURE__ */ new Set();
|
|
29173
29173
|
frontier.forEach((item) => {
|
|
29174
|
-
var
|
|
29175
|
-
const itemConstituents = (
|
|
29174
|
+
var _a2;
|
|
29175
|
+
const itemConstituents = (_a2 = mixins.get(item)) !== null && _a2 !== void 0 ? _a2 : (0, util_1.protoChain)(item.prototype).map((proto) => proto.constructor).filter((item2) => item2 !== null);
|
|
29176
29176
|
if (itemConstituents)
|
|
29177
29177
|
itemConstituents.forEach((constituent) => {
|
|
29178
29178
|
if (!visited.has(constituent) && !frontier.has(constituent))
|
|
@@ -29196,37 +29196,37 @@ var require_decorator = __commonJS({
|
|
|
29196
29196
|
var util_1 = require_util();
|
|
29197
29197
|
var mixin_tracking_1 = require_mixin_tracking();
|
|
29198
29198
|
var mergeObjectsOfDecorators = (o1, o2) => {
|
|
29199
|
-
var
|
|
29199
|
+
var _a2, _b;
|
|
29200
29200
|
const allKeys = (0, util_1.unique)([...Object.getOwnPropertyNames(o1), ...Object.getOwnPropertyNames(o2)]);
|
|
29201
29201
|
const mergedObject = {};
|
|
29202
29202
|
for (let key of allKeys)
|
|
29203
|
-
mergedObject[key] = (0, util_1.unique)([...(
|
|
29203
|
+
mergedObject[key] = (0, util_1.unique)([...(_a2 = o1 === null || o1 === void 0 ? void 0 : o1[key]) !== null && _a2 !== void 0 ? _a2 : [], ...(_b = o2 === null || o2 === void 0 ? void 0 : o2[key]) !== null && _b !== void 0 ? _b : []]);
|
|
29204
29204
|
return mergedObject;
|
|
29205
29205
|
};
|
|
29206
29206
|
var mergePropertyAndMethodDecorators = (d1, d2) => {
|
|
29207
|
-
var
|
|
29207
|
+
var _a2, _b, _c2, _d;
|
|
29208
29208
|
return {
|
|
29209
|
-
property: mergeObjectsOfDecorators((
|
|
29209
|
+
property: mergeObjectsOfDecorators((_a2 = d1 === null || d1 === void 0 ? void 0 : d1.property) !== null && _a2 !== void 0 ? _a2 : {}, (_b = d2 === null || d2 === void 0 ? void 0 : d2.property) !== null && _b !== void 0 ? _b : {}),
|
|
29210
29210
|
method: mergeObjectsOfDecorators((_c2 = d1 === null || d1 === void 0 ? void 0 : d1.method) !== null && _c2 !== void 0 ? _c2 : {}, (_d = d2 === null || d2 === void 0 ? void 0 : d2.method) !== null && _d !== void 0 ? _d : {})
|
|
29211
29211
|
};
|
|
29212
29212
|
};
|
|
29213
29213
|
var mergeDecorators = (d1, d2) => {
|
|
29214
|
-
var
|
|
29214
|
+
var _a2, _b, _c2, _d, _e2, _f;
|
|
29215
29215
|
return {
|
|
29216
|
-
class: (0, util_1.unique)([...(
|
|
29216
|
+
class: (0, util_1.unique)([...(_a2 = d1 === null || d1 === void 0 ? void 0 : d1.class) !== null && _a2 !== void 0 ? _a2 : [], ...(_b = d2 === null || d2 === void 0 ? void 0 : d2.class) !== null && _b !== void 0 ? _b : []]),
|
|
29217
29217
|
static: mergePropertyAndMethodDecorators((_c2 = d1 === null || d1 === void 0 ? void 0 : d1.static) !== null && _c2 !== void 0 ? _c2 : {}, (_d = d2 === null || d2 === void 0 ? void 0 : d2.static) !== null && _d !== void 0 ? _d : {}),
|
|
29218
29218
|
instance: mergePropertyAndMethodDecorators((_e2 = d1 === null || d1 === void 0 ? void 0 : d1.instance) !== null && _e2 !== void 0 ? _e2 : {}, (_f = d2 === null || d2 === void 0 ? void 0 : d2.instance) !== null && _f !== void 0 ? _f : {})
|
|
29219
29219
|
};
|
|
29220
29220
|
};
|
|
29221
29221
|
var decorators = /* @__PURE__ */ new Map();
|
|
29222
29222
|
var findAllConstituentClasses = (...classes) => {
|
|
29223
|
-
var
|
|
29223
|
+
var _a2;
|
|
29224
29224
|
const allClasses = /* @__PURE__ */ new Set();
|
|
29225
29225
|
const frontier = /* @__PURE__ */ new Set([...classes]);
|
|
29226
29226
|
while (frontier.size > 0) {
|
|
29227
29227
|
for (let clazz of frontier) {
|
|
29228
29228
|
const protoChainClasses = (0, util_1.protoChain)(clazz.prototype).map((proto) => proto.constructor);
|
|
29229
|
-
const mixinClasses = (
|
|
29229
|
+
const mixinClasses = (_a2 = (0, mixin_tracking_1.getMixinsForClass)(clazz)) !== null && _a2 !== void 0 ? _a2 : [];
|
|
29230
29230
|
const potentiallyNewClasses = [...protoChainClasses, ...mixinClasses];
|
|
29231
29231
|
const newClasses = potentiallyNewClasses.filter((c2) => !allClasses.has(c2));
|
|
29232
29232
|
for (let newClass of newClasses)
|
|
@@ -29275,12 +29275,12 @@ var require_decorator = __commonJS({
|
|
|
29275
29275
|
return decorator(clazz);
|
|
29276
29276
|
});
|
|
29277
29277
|
var decorateMember = (decorator) => ((object, key, ...otherArgs) => {
|
|
29278
|
-
var
|
|
29278
|
+
var _a2, _b, _c2;
|
|
29279
29279
|
const decoratorTargetType = typeof object === "function" ? "static" : "instance";
|
|
29280
29280
|
const decoratorType = typeof object[key] === "function" ? "method" : "property";
|
|
29281
29281
|
const clazz = decoratorTargetType === "static" ? object : object.constructor;
|
|
29282
29282
|
const decoratorsForClass = (0, exports2.getDecoratorsForClass)(clazz);
|
|
29283
|
-
const decoratorsForTargetType = (
|
|
29283
|
+
const decoratorsForTargetType = (_a2 = decoratorsForClass === null || decoratorsForClass === void 0 ? void 0 : decoratorsForClass[decoratorTargetType]) !== null && _a2 !== void 0 ? _a2 : {};
|
|
29284
29284
|
decoratorsForClass[decoratorTargetType] = decoratorsForTargetType;
|
|
29285
29285
|
let decoratorsForType = (_b = decoratorsForTargetType === null || decoratorsForTargetType === void 0 ? void 0 : decoratorsForTargetType[decoratorType]) !== null && _b !== void 0 ? _b : {};
|
|
29286
29286
|
decoratorsForTargetType[decoratorType] = decoratorsForType;
|
|
@@ -29310,7 +29310,7 @@ var require_mixins = __commonJS({
|
|
|
29310
29310
|
var decorator_1 = require_decorator();
|
|
29311
29311
|
var mixin_tracking_1 = require_mixin_tracking();
|
|
29312
29312
|
function Mixin(...constructors) {
|
|
29313
|
-
var
|
|
29313
|
+
var _a2, _b, _c2;
|
|
29314
29314
|
const prototypes = constructors.map((constructor) => constructor.prototype);
|
|
29315
29315
|
const initFunctionName = settings_1.settings.initFunction;
|
|
29316
29316
|
if (initFunctionName !== null) {
|
|
@@ -29333,7 +29333,7 @@ var require_mixins = __commonJS({
|
|
|
29333
29333
|
let DecoratedMixedClass = MixedClass;
|
|
29334
29334
|
if (settings_1.settings.decoratorInheritance !== "none") {
|
|
29335
29335
|
const classDecorators = settings_1.settings.decoratorInheritance === "deep" ? (0, decorator_1.deepDecoratorSearch)(...constructors) : (0, decorator_1.directDecoratorSearch)(...constructors);
|
|
29336
|
-
for (let decorator of (
|
|
29336
|
+
for (let decorator of (_a2 = classDecorators === null || classDecorators === void 0 ? void 0 : classDecorators.class) !== null && _a2 !== void 0 ? _a2 : []) {
|
|
29337
29337
|
const result = decorator(DecoratedMixedClass);
|
|
29338
29338
|
if (result) {
|
|
29339
29339
|
DecoratedMixedClass = result;
|
|
@@ -53814,8 +53814,8 @@ var require_fecha_umd = __commonJS({
|
|
|
53814
53814
|
for (var _i2 = 1; _i2 < arguments.length; _i2++) {
|
|
53815
53815
|
args[_i2 - 1] = arguments[_i2];
|
|
53816
53816
|
}
|
|
53817
|
-
for (var
|
|
53818
|
-
var obj = args_1[
|
|
53817
|
+
for (var _a2 = 0, args_1 = args; _a2 < args_1.length; _a2++) {
|
|
53818
|
+
var obj = args_1[_a2];
|
|
53819
53819
|
for (var key in obj) {
|
|
53820
53820
|
origObj[key] = obj[key];
|
|
53821
53821
|
}
|
|
@@ -54136,7 +54136,7 @@ var require_fecha_umd = __commonJS({
|
|
|
54136
54136
|
}
|
|
54137
54137
|
var combinedI18nSettings = assign(assign({}, globalI18n), i18n);
|
|
54138
54138
|
for (var i = 1; i < matches.length; i++) {
|
|
54139
|
-
var
|
|
54139
|
+
var _a2 = parseInfo[i - 1], field = _a2[0], parser = _a2[2];
|
|
54140
54140
|
var value = parser ? parser(matches[i], combinedI18nSettings) : +matches[i];
|
|
54141
54141
|
if (value == null) {
|
|
54142
54142
|
return null;
|
|
@@ -58434,8 +58434,8 @@ var require_index_cjs = __commonJS({
|
|
|
58434
58434
|
};
|
|
58435
58435
|
var LAB_FT = (6 / 29) ** 3;
|
|
58436
58436
|
function srgbNonlinearTransform(c2) {
|
|
58437
|
-
const
|
|
58438
|
-
return Math.min(Math.max(0,
|
|
58437
|
+
const cc = c2 > 31308e-7 ? 1.055 * c2 ** (1 / 2.4) - 0.055 : c2 * 12.92;
|
|
58438
|
+
return Math.min(Math.max(0, cc), 1);
|
|
58439
58439
|
}
|
|
58440
58440
|
function srgbNonlinearTransformInv(c2) {
|
|
58441
58441
|
return c2 > 0.04045 ? ((c2 + 0.055) / 1.055) ** 2.4 : c2 / 12.92;
|
|
@@ -68292,7 +68292,7 @@ function hi(r6) {
|
|
|
68292
68292
|
return typeof r6 == "object" && !Array.isArray(r6) && !(r6 instanceof URLSearchParams) && (r6 = Object.fromEntries(Object.entries(r6).filter((e) => e[1] !== void 0))), new URLSearchParams(r6).toString();
|
|
68293
68293
|
}
|
|
68294
68294
|
var fs2 = /^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-_]*[A-Za-z0-9])$/;
|
|
68295
|
-
function
|
|
68295
|
+
function Gl(r6) {
|
|
68296
68296
|
return fs2.test(r6);
|
|
68297
68297
|
}
|
|
68298
68298
|
var g = Object.freeze([]);
|
|
@@ -68838,7 +68838,7 @@ var Yr = { eq: h.EQUALS, ne: h.NOT_EQUALS, lt: h.LESS_THAN, le: h.LESS_THAN_OR_E
|
|
|
68838
68838
|
var $s = [h.MISSING, h.PRESENT];
|
|
68839
68839
|
var Ie = { READ: "read", VREAD: "vread", UPDATE: "update", DELETE: "delete", HISTORY: "history", CREATE: "create", SEARCH: "search" };
|
|
68840
68840
|
var pa = [Ie.READ, Ie.VREAD, Ie.HISTORY, Ie.SEARCH];
|
|
68841
|
-
var
|
|
68841
|
+
var Rd = { FIRST: "first", APPLICATION: "application" };
|
|
68842
68842
|
function j() {
|
|
68843
68843
|
return typeof window < "u";
|
|
68844
68844
|
}
|
|
@@ -69357,6 +69357,7 @@ var Jt = class r extends ee {
|
|
|
69357
69357
|
}
|
|
69358
69358
|
};
|
|
69359
69359
|
var Ma = 5e3;
|
|
69360
|
+
var _a = [WebSocket.CLOSING, WebSocket.CLOSED];
|
|
69360
69361
|
var at = class extends ee {
|
|
69361
69362
|
constructor(...t) {
|
|
69362
69363
|
super();
|
|
@@ -69521,7 +69522,7 @@ var Kt = class {
|
|
|
69521
69522
|
}) : s.bareCriteria = void 0, !s.bareCriteria && s.criteriaWithProps.length === 0 && (this.criteriaEntries.delete(t), this.masterSubEmitter?._removeCriteria(t)), i && this.criteriaEntriesBySubscriptionId.delete(i), o2 && this.ws.readyState === WebSocket.OPEN && this.ws.send(JSON.stringify({ type: "unbind-from-token", payload: { token: o2 } }));
|
|
69522
69523
|
}
|
|
69523
69524
|
async subscribeToCriteria(e) {
|
|
69524
|
-
if (!(this.ws.readyState !== WebSocket.OPEN || e.connecting)) {
|
|
69525
|
+
if (this.wsClosed && await this.reconnectIfNeeded(), !(this.ws.readyState !== WebSocket.OPEN || e.connecting)) {
|
|
69525
69526
|
e.connecting = true;
|
|
69526
69527
|
try {
|
|
69527
69528
|
let [t, n] = await this.getTokenForCriteria(e);
|
|
@@ -69565,19 +69566,27 @@ var Kt = class {
|
|
|
69565
69566
|
getMasterEmitter() {
|
|
69566
69567
|
return this.masterSubEmitter || (this.masterSubEmitter = new at(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
|
|
69567
69568
|
}
|
|
69569
|
+
async reconnectIfNeeded() {
|
|
69570
|
+
_a.includes(this.getWebSocket().readyState) && await new Promise((e) => {
|
|
69571
|
+
let t = () => {
|
|
69572
|
+
this.getWebSocket().removeEventListener("open", t), e();
|
|
69573
|
+
};
|
|
69574
|
+
this.getWebSocket().addEventListener("open", t), this.reconnectWebSocket();
|
|
69575
|
+
});
|
|
69576
|
+
}
|
|
69568
69577
|
};
|
|
69569
|
-
var cn = "5.0.
|
|
69570
|
-
var
|
|
69571
|
-
var
|
|
69572
|
-
var
|
|
69573
|
-
var
|
|
69574
|
-
var
|
|
69575
|
-
var
|
|
69576
|
-
var
|
|
69578
|
+
var cn = "5.0.14-7a77ead";
|
|
69579
|
+
var Na = w.FHIR_JSON + ", */*; q=0.1";
|
|
69580
|
+
var Ua = "https://api.medplum.com/";
|
|
69581
|
+
var Ba = 1e3;
|
|
69582
|
+
var qa = 6e4;
|
|
69583
|
+
var Wa = 0;
|
|
69584
|
+
var ja = 3e5;
|
|
69585
|
+
var $a = "Binary/";
|
|
69577
69586
|
var Hi = { resourceType: "Device", id: "system", deviceName: [{ type: "model-name", name: "System" }] };
|
|
69578
69587
|
var $e = { ClientCredentials: "client_credentials", AuthorizationCode: "authorization_code", RefreshToken: "refresh_token", JwtBearer: "urn:ietf:params:oauth:grant-type:jwt-bearer", TokenExchange: "urn:ietf:params:oauth:grant-type:token-exchange" };
|
|
69579
|
-
var
|
|
69580
|
-
var
|
|
69588
|
+
var Ha = { AccessToken: "urn:ietf:params:oauth:token-type:access_token", RefreshToken: "urn:ietf:params:oauth:token-type:refresh_token", IdToken: "urn:ietf:params:oauth:token-type:id_token", Saml1Token: "urn:ietf:params:oauth:token-type:saml1", Saml2Token: "urn:ietf:params:oauth:token-type:saml2" };
|
|
69589
|
+
var Ga = { JwtBearer: "urn:ietf:params:oauth:client-assertion-type:jwt-bearer" };
|
|
69581
69590
|
var Yt = class extends ee {
|
|
69582
69591
|
constructor(t) {
|
|
69583
69592
|
super();
|
|
@@ -69617,7 +69626,7 @@ var Yt = class extends ee {
|
|
|
69617
69626
|
c(this, "keyValueClient");
|
|
69618
69627
|
c(this, "logLevel");
|
|
69619
69628
|
if (t?.baseUrl && !t.baseUrl.startsWith("http")) throw new Error("Base URL must start with http or https");
|
|
69620
|
-
this.options = t ?? {}, this.fetch = t?.fetch ??
|
|
69629
|
+
this.options = t ?? {}, this.fetch = t?.fetch ?? Qa(), this.storage = t?.storage ?? new st(void 0, t?.storagePrefix), this.createPdfImpl = t?.createPdf, this.baseUrl = Qr(t?.baseUrl ?? Ua), this.fhirBaseUrl = G(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = G(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = G(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = G(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.fhircastHubUrl = G(this.baseUrl, t?.fhircastHubUrl ?? "fhircast/STU3"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.credentialsInHeader = t?.authCredentialsMethod === "header", this.defaultHeaders = t?.defaultHeaders ?? {}, this.onUnauthenticated = t?.onUnauthenticated, this.refreshGracePeriod = t?.refreshGracePeriod ?? ja, this.logLevel = this.initializeLogLevel(t), this.cacheTime = t?.cacheTime ?? (j() ? qa : Wa), this.cacheTime > 0 ? this.requestCache = new De(t?.resourceCacheSize ?? Ba) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken && this.setAccessToken(t.accessToken), this.storage.getInitPromise === void 0 ? (t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initPromise = Promise.resolve(), this.dispatchEvent({ type: "storageInitialized" })) : (this.initComplete = false, this.initPromise = this.storage.getInitPromise(), this.initPromise.then(() => {
|
|
69621
69630
|
t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initComplete = true, this.dispatchEvent({ type: "storageInitialized" });
|
|
69622
69631
|
}).catch((n) => {
|
|
69623
69632
|
console.error(n), this.initComplete = true, this.dispatchEvent({ type: "storageInitFailed", payload: { error: n } });
|
|
@@ -69730,9 +69739,10 @@ var Yt = class extends ee {
|
|
|
69730
69739
|
let a = o2;
|
|
69731
69740
|
s && (a = await this.ensureCodeChallenge(o2)), oe.assign(this.getExternalAuthRedirectUri(t, n, i, a, s));
|
|
69732
69741
|
}
|
|
69733
|
-
async exchangeExternalAccessToken(t, n) {
|
|
69742
|
+
async exchangeExternalAccessToken(t, n, i) {
|
|
69734
69743
|
if (n = n ?? this.clientId, !n) throw new Error("MedplumClient is missing clientId");
|
|
69735
|
-
|
|
69744
|
+
let o2 = { grant_type: $e.TokenExchange, subject_token_type: Ha.AccessToken, client_id: n, subject_token: t };
|
|
69745
|
+
return i && (o2.membership_id = i), this.fetchTokens(o2);
|
|
69736
69746
|
}
|
|
69737
69747
|
getExternalAuthRedirectUri(t, n, i, o2, s = true) {
|
|
69738
69748
|
let a = new URL(t);
|
|
@@ -69949,7 +69959,7 @@ var Yt = class extends ee {
|
|
|
69949
69959
|
}
|
|
69950
69960
|
async createPdf(t, n, i, o2) {
|
|
69951
69961
|
if (!this.createPdfImpl) throw new Error("PDF creation not enabled");
|
|
69952
|
-
let s =
|
|
69962
|
+
let s = Ka(t, n, i, o2), a = typeof n == "object" ? n : {}, { docDefinition: u2, tableLayouts: l2, fonts: p, ...y2 } = s, T = await this.createPdfImpl(u2, l2, p), $ = { ...y2, data: T, contentType: "application/pdf" };
|
|
69953
69963
|
return this.createBinary($, a);
|
|
69954
69964
|
}
|
|
69955
69965
|
createComment(t, n, i) {
|
|
@@ -70066,7 +70076,7 @@ var Yt = class extends ee {
|
|
|
70066
70076
|
async download(t, n = {}) {
|
|
70067
70077
|
this.refreshPromise && await this.refreshPromise;
|
|
70068
70078
|
let i = t.toString();
|
|
70069
|
-
i.startsWith(
|
|
70079
|
+
i.startsWith($a) && (t = this.fhirUrl(i));
|
|
70070
70080
|
let o2 = n.headers;
|
|
70071
70081
|
return o2 || (o2 = {}, n.headers = o2), o2.Accept || (o2.Accept = "*/*"), this.addFetchOptionsDefaults(n), (await this.fetchWithRetry(t.toString(), n)).blob();
|
|
70072
70082
|
}
|
|
@@ -70158,7 +70168,7 @@ var Yt = class extends ee {
|
|
|
70158
70168
|
for (let o2 = 0; o2 <= i; o2++) try {
|
|
70159
70169
|
this.logLevel !== "none" && this.logRequest(t, n);
|
|
70160
70170
|
let s = await this.fetch(t, n);
|
|
70161
|
-
if (this.logLevel !== "none" && this.logResponse(s), this.setCurrentRateLimit(s), o2 >= i || !
|
|
70171
|
+
if (this.logLevel !== "none" && this.logResponse(s), this.setCurrentRateLimit(s), o2 >= i || !Ya(s)) return s;
|
|
70162
70172
|
let a = this.getRetryDelay(o2), u2 = n.maxRetryTime ?? 2e3;
|
|
70163
70173
|
if (a > u2) return s;
|
|
70164
70174
|
await Gr(a, { signal: n.signal });
|
|
@@ -70227,7 +70237,7 @@ var Yt = class extends ee {
|
|
|
70227
70237
|
addFetchOptionsDefaults(t) {
|
|
70228
70238
|
Object.entries(this.defaultHeaders).forEach(([n, i]) => {
|
|
70229
70239
|
this.setRequestHeader(t, n, i);
|
|
70230
|
-
}), this.setRequestHeader(t, "Accept",
|
|
70240
|
+
}), this.setRequestHeader(t, "Accept", Na, true), this.options.extendedMode !== false && this.setRequestHeader(t, "X-Medplum", "extended"), t.body && this.setRequestHeader(t, "Content-Type", w.FHIR_JSON, true), this.accessToken ? this.setRequestHeader(t, "Authorization", "Bearer " + this.accessToken) : this.basicAuth && this.setRequestHeader(t, "Authorization", "Basic " + this.basicAuth), t.cache || (t.cache = "no-cache"), t.credentials || (t.credentials = "include");
|
|
70231
70241
|
}
|
|
70232
70242
|
setRequestContentType(t, n) {
|
|
70233
70243
|
this.setRequestHeader(t, "Content-Type", n);
|
|
@@ -70293,7 +70303,7 @@ var Yt = class extends ee {
|
|
|
70293
70303
|
return this.clientId = t, this.fetchTokens({ grant_type: $e.JwtBearer, client_id: t, assertion: n, scope: i });
|
|
70294
70304
|
}
|
|
70295
70305
|
async startJwtAssertionLogin(t) {
|
|
70296
|
-
return this.fetchTokens({ grant_type: $e.ClientCredentials, client_assertion_type:
|
|
70306
|
+
return this.fetchTokens({ grant_type: $e.ClientCredentials, client_assertion_type: Ga.JwtBearer, client_assertion: t });
|
|
70297
70307
|
}
|
|
70298
70308
|
setBasicAuth(t, n) {
|
|
70299
70309
|
this.clientId = t, this.clientSecret = n, this.basicAuth = jt(t + ":" + n);
|
|
@@ -70391,7 +70401,7 @@ var Yt = class extends ee {
|
|
|
70391
70401
|
return this.getSubscriptionManager().getMasterEmitter();
|
|
70392
70402
|
}
|
|
70393
70403
|
};
|
|
70394
|
-
function
|
|
70404
|
+
function Qa() {
|
|
70395
70405
|
if (!globalThis.fetch) throw new Error("Fetch not available in this environment");
|
|
70396
70406
|
return globalThis.fetch.bind(globalThis);
|
|
70397
70407
|
}
|
|
@@ -70406,28 +70416,28 @@ function Qi(r6) {
|
|
|
70406
70416
|
let e = r6.entry?.map((t) => t.resource) ?? [];
|
|
70407
70417
|
return Object.assign(e, { bundle: r6 });
|
|
70408
70418
|
}
|
|
70409
|
-
function
|
|
70419
|
+
function za(r6) {
|
|
70410
70420
|
return E(r6) && "data" in r6 && "contentType" in r6;
|
|
70411
70421
|
}
|
|
70412
70422
|
function zi(r6, e, t, n) {
|
|
70413
|
-
return
|
|
70423
|
+
return za(r6) ? r6 : { data: r6, filename: e, contentType: t, onProgress: n };
|
|
70414
70424
|
}
|
|
70415
|
-
function
|
|
70425
|
+
function Ja(r6) {
|
|
70416
70426
|
return E(r6) && "docDefinition" in r6;
|
|
70417
70427
|
}
|
|
70418
|
-
function
|
|
70419
|
-
return
|
|
70428
|
+
function Ka(r6, e, t, n) {
|
|
70429
|
+
return Ja(r6) ? r6 : { docDefinition: r6, filename: e, tableLayouts: t, fonts: n };
|
|
70420
70430
|
}
|
|
70421
|
-
function
|
|
70431
|
+
function Ya(r6) {
|
|
70422
70432
|
return r6.status === 429 || r6.status >= 500;
|
|
70423
70433
|
}
|
|
70424
|
-
var
|
|
70425
|
-
var
|
|
70426
|
-
var
|
|
70427
|
-
var
|
|
70428
|
-
var
|
|
70429
|
-
var
|
|
70430
|
-
var
|
|
70434
|
+
var uc = [...rt, "->", "<<", ">>", "=="];
|
|
70435
|
+
var dc = nt().registerInfix("->", { precedence: v.Arrow }).registerInfix(";", { precedence: v.Semicolon });
|
|
70436
|
+
var Ic = " ".repeat(2);
|
|
70437
|
+
var Vc = [...rt, "eq", "ne", "co"];
|
|
70438
|
+
var Dc = { eq: h.EXACT, ne: h.NOT_EQUALS, co: h.CONTAINS, sw: h.STARTS_WITH, ew: void 0, gt: h.GREATER_THAN, lt: h.LESS_THAN, ge: h.GREATER_THAN_OR_EQUALS, le: h.LESS_THAN_OR_EQUALS, ap: h.APPROXIMATELY, sa: h.STARTS_AFTER, eb: h.ENDS_BEFORE, pr: h.PRESENT, po: void 0, ss: void 0, sb: void 0, in: h.IN, ni: h.NOT_IN, re: h.EQUALS, identifier: h.IDENTIFIER };
|
|
70439
|
+
var _c = nt();
|
|
70440
|
+
var Lc = { AA: "OK", AE: "Application Error", AR: "Application Reject", CA: "Commit Accept", CE: "Commit Error", CR: "Commit Reject" };
|
|
70431
70441
|
var xe = class {
|
|
70432
70442
|
constructor(e = "\r", t = "|", n = "^", i = "~", o2 = "\\", s = "&") {
|
|
70433
70443
|
c(this, "segmentSeparator");
|
|
@@ -70471,7 +70481,7 @@ var mo = class r2 {
|
|
|
70471
70481
|
}
|
|
70472
70482
|
buildAck(e) {
|
|
70473
70483
|
let t = /* @__PURE__ */ new Date(), n = this.getSegment("MSH"), i = n?.getField(3)?.toString() ?? "", o2 = n?.getField(4)?.toString() ?? "", s = n?.getField(5)?.toString() ?? "", a = n?.getField(6)?.toString() ?? "", u2 = n?.getField(10)?.toString() ?? "", l2 = n?.getField(12)?.toString() ?? "2.5.1", p = e?.ackCode ?? "AA";
|
|
70474
|
-
return new r2([new lt(["MSH", this.context.getMsh2(), s, a, i, o2,
|
|
70484
|
+
return new r2([new lt(["MSH", this.context.getMsh2(), s, a, i, o2, Nc(t), "", this.buildAckMessageType(n), t.getTime().toString(), "P", l2], this.context), new lt(["MSA", p, u2, Lc[p]], this.context), ...e?.errSegment ? [e.errSegment] : []]);
|
|
70475
70485
|
}
|
|
70476
70486
|
buildAckMessageType(e) {
|
|
70477
70487
|
let t = e?.getField(9), n = t?.getComponent(2), i = t?.getComponent(3), o2 = "ACK";
|
|
@@ -70571,12 +70581,12 @@ var te = class r4 {
|
|
|
70571
70581
|
return true;
|
|
70572
70582
|
}
|
|
70573
70583
|
};
|
|
70574
|
-
function
|
|
70584
|
+
function Nc(r6) {
|
|
70575
70585
|
let e = r6 instanceof Date ? r6 : new Date(r6), n = e.toISOString().replaceAll(/[-:T]/g, "").replace(/(\.\d+)?Z$/, ""), i = e.getUTCMilliseconds();
|
|
70576
70586
|
return i > 0 && (n += "." + i.toString()), n;
|
|
70577
70587
|
}
|
|
70578
70588
|
var He = { NONE: 0, ERROR: 1, WARN: 2, INFO: 3, DEBUG: 4 };
|
|
70579
|
-
var
|
|
70589
|
+
var Uc = ["NONE", "ERROR", "WARN", "INFO", "DEBUG"];
|
|
70580
70590
|
var yo = class r5 {
|
|
70581
70591
|
constructor(e, t = {}, n = He.INFO, i = {}) {
|
|
70582
70592
|
c(this, "write");
|
|
@@ -70614,10 +70624,10 @@ var yo = class r5 {
|
|
|
70614
70624
|
i = { ...n };
|
|
70615
70625
|
for (let [o2, s] of Object.entries(i)) s instanceof Error && (i[o2] = ar(s));
|
|
70616
70626
|
}
|
|
70617
|
-
this.write(JSON.stringify({ level:
|
|
70627
|
+
this.write(JSON.stringify({ level: Uc[e], timestamp: (/* @__PURE__ */ new Date()).toISOString(), msg: this.prefix ? `${this.prefix}${t}` : t, ...i, ...this.metadata }));
|
|
70618
70628
|
}
|
|
70619
70629
|
};
|
|
70620
|
-
function
|
|
70630
|
+
function um(r6) {
|
|
70621
70631
|
let e = He[r6.toUpperCase()];
|
|
70622
70632
|
if (e === void 0) throw new Error(`Invalid log level: ${r6}`);
|
|
70623
70633
|
return e;
|
|
@@ -70635,9 +70645,9 @@ function ar(r6, e = 0, t = 10) {
|
|
|
70635
70645
|
}
|
|
70636
70646
|
return n;
|
|
70637
70647
|
}
|
|
70638
|
-
var
|
|
70648
|
+
var Yc = "https://meta.medplum.com/releases";
|
|
70639
70649
|
var lr = /* @__PURE__ */ new Map();
|
|
70640
|
-
function
|
|
70650
|
+
function Xc(r6) {
|
|
70641
70651
|
let e = r6;
|
|
70642
70652
|
if (!e.tag_name) throw new Error("Manifest missing tag_name");
|
|
70643
70653
|
let t = e.assets;
|
|
@@ -70650,7 +70660,7 @@ function Yc(r6) {
|
|
|
70650
70660
|
async function vn(r6, e, t) {
|
|
70651
70661
|
let n = lr.get(e ?? "latest");
|
|
70652
70662
|
if (!n) {
|
|
70653
|
-
let i = e ? `v${e}` : "latest", o2 = new URL(`${
|
|
70663
|
+
let i = e ? `v${e}` : "latest", o2 = new URL(`${Yc}/${i}.json`);
|
|
70654
70664
|
if (o2.searchParams.set("a", r6), o2.searchParams.set("c", cn), t) for (let [u2, l2] of Object.entries(t)) o2.searchParams.set(u2, l2);
|
|
70655
70665
|
let s = await fetch(o2.toString());
|
|
70656
70666
|
if (s.status !== 200) {
|
|
@@ -70663,15 +70673,15 @@ async function vn(r6, e, t) {
|
|
|
70663
70673
|
throw new Error(`Received status code ${s.status} while fetching manifest for version '${e ?? "latest"}'. Message: ${u2}`);
|
|
70664
70674
|
}
|
|
70665
70675
|
let a = await s.json();
|
|
70666
|
-
|
|
70676
|
+
Xc(a), n = a, lr.set(e ?? "latest", n), e || lr.set(n.tag_name.slice(1), n);
|
|
70667
70677
|
}
|
|
70668
70678
|
return n;
|
|
70669
70679
|
}
|
|
70670
|
-
function
|
|
70680
|
+
function Zc(r6) {
|
|
70671
70681
|
return /^\d+\.\d+\.\d+(-[0-9a-z]{7})?$/.test(r6);
|
|
70672
70682
|
}
|
|
70673
|
-
async function
|
|
70674
|
-
if (!
|
|
70683
|
+
async function Fm(r6, e) {
|
|
70684
|
+
if (!Zc(e)) return false;
|
|
70675
70685
|
try {
|
|
70676
70686
|
await vn(r6, e);
|
|
70677
70687
|
} catch {
|
|
@@ -70679,7 +70689,7 @@ async function Lm(r6, e) {
|
|
|
70679
70689
|
}
|
|
70680
70690
|
return true;
|
|
70681
70691
|
}
|
|
70682
|
-
async function
|
|
70692
|
+
async function Nm(r6) {
|
|
70683
70693
|
let e = await vn(r6);
|
|
70684
70694
|
if (!e.tag_name.startsWith("v")) throw new Error(`Invalid release name found. Release tag '${e.tag_name}' did not start with 'v'`);
|
|
70685
70695
|
return e.tag_name.slice(1);
|
|
@@ -70777,7 +70787,7 @@ var g2 = class extends m2 {
|
|
|
70777
70787
|
return;
|
|
70778
70788
|
}
|
|
70779
70789
|
let p = c2.message.getSegment("MSA")?.getField(1)?.toString()?.toUpperCase();
|
|
70780
|
-
p && (h2.returnAck ===
|
|
70790
|
+
p && (h2.returnAck === Rd.APPLICATION && p === "CA" || (h2.resolve(c2.message), this.pendingMessages.delete(a)));
|
|
70781
70791
|
});
|
|
70782
70792
|
}
|
|
70783
70793
|
isClosed() {
|
|
@@ -70830,7 +70840,7 @@ var g2 = class extends m2 {
|
|
|
70830
70840
|
let r6;
|
|
70831
70841
|
t?.timeoutMs && (r6 = setTimeout(() => {
|
|
70832
70842
|
this.pendingMessages.delete(c2), n(new f({ resourceType: "OperationOutcome", issue: [{ severity: "error", code: "timeout", details: { text: "Client timeout" }, diagnostics: `Request timed out after waiting ${t.timeoutMs} milliseconds for response` }] }));
|
|
70833
|
-
}, t.timeoutMs)), this.pendingMessages.set(c2, { message: e, resolve: s, reject: n, returnAck: t?.returnAck ??
|
|
70843
|
+
}, t.timeoutMs)), this.pendingMessages.set(c2, { message: e, resolve: s, reject: n, returnAck: t?.returnAck ?? Rd.APPLICATION, timer: r6 }), this.sendImpl(e);
|
|
70834
70844
|
});
|
|
70835
70845
|
}
|
|
70836
70846
|
async close() {
|
|
@@ -72216,7 +72226,7 @@ function cleanupLoggerConfig(config, configPathRoot = "config") {
|
|
|
72216
72226
|
warnings.push(`${configPathRoot}.filesToKeep must be a valid integer`);
|
|
72217
72227
|
config.filesToKeep = void 0;
|
|
72218
72228
|
}
|
|
72219
|
-
if (typeof config.logLevel !== "undefined" && !(typeof config.logLevel === "number" &&
|
|
72229
|
+
if (typeof config.logLevel !== "undefined" && !(typeof config.logLevel === "number" && Uc[config.logLevel] !== void 0)) {
|
|
72220
72230
|
warnings.push(`${configPathRoot}.logLevel must be a valid log level between LogLevel.NONE and LogLevel.DEBUG`);
|
|
72221
72231
|
config.logLevel = void 0;
|
|
72222
72232
|
}
|
|
@@ -72261,7 +72271,7 @@ function parseLoggerConfigFromArgs(args) {
|
|
|
72261
72271
|
let configValue;
|
|
72262
72272
|
if (settingName === "logLevel") {
|
|
72263
72273
|
try {
|
|
72264
|
-
configValue =
|
|
72274
|
+
configValue = um(propVal);
|
|
72265
72275
|
} catch (err) {
|
|
72266
72276
|
warnings.push(`Error while parsing ${propName}: ${_e(err)}`);
|
|
72267
72277
|
}
|
|
@@ -73188,7 +73198,7 @@ IPv6 is currently unsupported.`;
|
|
|
73188
73198
|
this.log.error(errMsg);
|
|
73189
73199
|
throw new Error(errMsg);
|
|
73190
73200
|
}
|
|
73191
|
-
if (!((0, import_node_net4.isIPv4)(message.remote) ||
|
|
73201
|
+
if (!((0, import_node_net4.isIPv4)(message.remote) || Gl(message.remote))) {
|
|
73192
73202
|
const errMsg = `Attempted to ping an invalid host.
|
|
73193
73203
|
|
|
73194
73204
|
"${message.remote}" is not a valid IPv4 address or a resolvable hostname.`;
|
|
@@ -73263,7 +73273,7 @@ ${result}`);
|
|
|
73263
73273
|
return;
|
|
73264
73274
|
}
|
|
73265
73275
|
let child;
|
|
73266
|
-
if (message.version && !await
|
|
73276
|
+
if (message.version && !await Fm("agent-upgrader", message.version)) {
|
|
73267
73277
|
const versionTag = message.version ? `v${message.version}` : "latest";
|
|
73268
73278
|
const errMsg = `Error during upgrading to version '${versionTag}'. '${message.version}' is not a valid version`;
|
|
73269
73279
|
this.log.error(errMsg);
|
|
@@ -73274,7 +73284,7 @@ ${result}`);
|
|
|
73274
73284
|
});
|
|
73275
73285
|
return;
|
|
73276
73286
|
}
|
|
73277
|
-
const targetVersion = message.version ?? await
|
|
73287
|
+
const targetVersion = message.version ?? await Nm("agent-upgrader");
|
|
73278
73288
|
if (cn.startsWith(targetVersion)) {
|
|
73279
73289
|
if (!message?.force) {
|
|
73280
73290
|
this.log.info(`Attempted to upgrade to version ${targetVersion}, but agent is already on that version`);
|
|
@@ -73440,7 +73450,7 @@ ${result}`);
|
|
|
73440
73450
|
} catch (err) {
|
|
73441
73451
|
this.log.warn(`${_e(err)} - falling back to default return ACK behavior of 'first'.`);
|
|
73442
73452
|
}
|
|
73443
|
-
const returnAck = msgReturnAck ?? defaultReturnAck ??
|
|
73453
|
+
const returnAck = msgReturnAck ?? defaultReturnAck ?? Rd.FIRST;
|
|
73444
73454
|
let pool;
|
|
73445
73455
|
if (this.hl7Clients.has(message.remote)) {
|
|
73446
73456
|
pool = this.hl7Clients.get(message.remote);
|
|
@@ -73538,10 +73548,10 @@ ${result}`);
|
|
|
73538
73548
|
}
|
|
73539
73549
|
const normalizedValue = rawValue.toLowerCase();
|
|
73540
73550
|
if (normalizedValue === "application") {
|
|
73541
|
-
return
|
|
73551
|
+
return Rd.APPLICATION;
|
|
73542
73552
|
}
|
|
73543
73553
|
if (normalizedValue === "first") {
|
|
73544
|
-
return
|
|
73554
|
+
return Rd.FIRST;
|
|
73545
73555
|
}
|
|
73546
73556
|
throw new Error(`Invalid value for returnAck; expected: 'first' or 'application', received: ${rawValue}`);
|
|
73547
73557
|
}
|
|
@@ -73604,7 +73614,7 @@ async function agentMain(argv) {
|
|
|
73604
73614
|
for (const warning of warnings) {
|
|
73605
73615
|
mainLogger.warn(warning);
|
|
73606
73616
|
}
|
|
73607
|
-
const app = new App(medplum, agentId, args.logLevel ?
|
|
73617
|
+
const app = new App(medplum, agentId, args.logLevel ? um(args.logLevel) : void 0, {
|
|
73608
73618
|
mainLogger,
|
|
73609
73619
|
channelLogger
|
|
73610
73620
|
});
|
|
@@ -73646,10 +73656,10 @@ async function upgraderMain(argv) {
|
|
|
73646
73656
|
rejectOnTimeout = () => reject(new Error("Timed out while waiting for IPC to disconnect"));
|
|
73647
73657
|
import_node_process3.default.once("disconnect", resolve2);
|
|
73648
73658
|
});
|
|
73649
|
-
if (argv[3] && !
|
|
73659
|
+
if (argv[3] && !Zc(argv[3])) {
|
|
73650
73660
|
throw new Error("Invalid version specified");
|
|
73651
73661
|
}
|
|
73652
|
-
const version = argv[3] ?? await
|
|
73662
|
+
const version = argv[3] ?? await Nm("agent-upgrader");
|
|
73653
73663
|
const binPath = getReleaseBinPath(version);
|
|
73654
73664
|
if (!(0, import_node_fs6.existsSync)(binPath)) {
|
|
73655
73665
|
globalLogger.info(`Could not find binary at "${binPath}". Downloading release from GitHub...`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medplum/agent",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.14",
|
|
4
4
|
"description": "Medplum Agent",
|
|
5
5
|
"homepage": "https://www.medplum.com/",
|
|
6
6
|
"bugs": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"test": "jest --runInBand"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@medplum/core": "5.0.
|
|
30
|
-
"@medplum/hl7": "5.0.
|
|
29
|
+
"@medplum/core": "5.0.14",
|
|
30
|
+
"@medplum/hl7": "5.0.14",
|
|
31
31
|
"dcmjs-dimse": "0.3.1",
|
|
32
32
|
"iconv-lite": "0.7.2",
|
|
33
33
|
"semver": "7.7.3",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"ws": "8.19.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@medplum/fhirtypes": "5.0.
|
|
40
|
-
"@medplum/mock": "5.0.
|
|
39
|
+
"@medplum/fhirtypes": "5.0.14",
|
|
40
|
+
"@medplum/mock": "5.0.14",
|
|
41
41
|
"@types/async-eventemitter": "0.2.4",
|
|
42
42
|
"@types/ws": "8.18.1",
|
|
43
43
|
"mock-socket": "9.3.1",
|