@medplum/agent 4.1.2 → 4.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +80 -70
- package/package.json +5 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -31427,6 +31427,30 @@ var Xt = class {
|
|
|
31427
31427
|
return this.infixParselets[e.id === "Symbol" ? e.value : e.id];
|
|
31428
31428
|
}
|
|
31429
31429
|
};
|
|
31430
|
+
var Ee = class {
|
|
31431
|
+
constructor(e = 10) {
|
|
31432
|
+
this.max = e, this.cache = /* @__PURE__ */ new Map();
|
|
31433
|
+
}
|
|
31434
|
+
clear() {
|
|
31435
|
+
this.cache.clear();
|
|
31436
|
+
}
|
|
31437
|
+
get(e) {
|
|
31438
|
+
let t = this.cache.get(e);
|
|
31439
|
+
return t && (this.cache.delete(e), this.cache.set(e, t)), t;
|
|
31440
|
+
}
|
|
31441
|
+
set(e, t) {
|
|
31442
|
+
this.cache.has(e) ? this.cache.delete(e) : this.cache.size >= this.max && this.cache.delete(this.first()), this.cache.set(e, t);
|
|
31443
|
+
}
|
|
31444
|
+
delete(e) {
|
|
31445
|
+
this.cache.delete(e);
|
|
31446
|
+
}
|
|
31447
|
+
keys() {
|
|
31448
|
+
return this.cache.keys();
|
|
31449
|
+
}
|
|
31450
|
+
first() {
|
|
31451
|
+
return this.cache.keys().next().value;
|
|
31452
|
+
}
|
|
31453
|
+
};
|
|
31430
31454
|
var er = "ok";
|
|
31431
31455
|
var it = "created";
|
|
31432
31456
|
var rr = "not-modified";
|
|
@@ -31434,9 +31458,9 @@ var ir = "not-found";
|
|
|
31434
31458
|
var sr = "unauthorized";
|
|
31435
31459
|
var ot = "accepted";
|
|
31436
31460
|
var mn = { resourceType: "OperationOutcome", id: ir, issue: [{ severity: "error", code: "not-found", details: { text: "Not found" } }] };
|
|
31437
|
-
var
|
|
31438
|
-
var yn = { ...
|
|
31439
|
-
var ar = { ...
|
|
31461
|
+
var Re = { resourceType: "OperationOutcome", id: sr, issue: [{ severity: "error", code: "login", details: { text: "Unauthorized" } }] };
|
|
31462
|
+
var yn = { ...Re, issue: [...Re.issue, { severity: "error", code: "expired", details: { text: "Token expired" } }] };
|
|
31463
|
+
var ar = { ...Re, issue: [...Re.issue, { severity: "error", code: "invalid", details: { text: "Token not issued for this audience" } }] };
|
|
31440
31464
|
function S(r7, e) {
|
|
31441
31465
|
return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "invalid", details: { text: r7 }, ...e ? { expression: [e] } : void 0 }] };
|
|
31442
31466
|
}
|
|
@@ -31446,7 +31470,7 @@ function y(r7) {
|
|
|
31446
31470
|
function gn(r7) {
|
|
31447
31471
|
return { resourceType: "OperationOutcome", issue: [{ severity: "error", code: "exception", details: { text: "Internal server error" }, diagnostics: r7.toString() }] };
|
|
31448
31472
|
}
|
|
31449
|
-
function
|
|
31473
|
+
function Ce(r7) {
|
|
31450
31474
|
return typeof r7 == "object" && r7 !== null && r7.resourceType === "OperationOutcome";
|
|
31451
31475
|
}
|
|
31452
31476
|
function cr(r7) {
|
|
@@ -31458,10 +31482,10 @@ var d = class extends Error {
|
|
|
31458
31482
|
}
|
|
31459
31483
|
};
|
|
31460
31484
|
function st(r7) {
|
|
31461
|
-
return r7 instanceof d ? r7.outcome :
|
|
31485
|
+
return r7 instanceof d ? r7.outcome : Ce(r7) ? r7 : S(Pe(r7));
|
|
31462
31486
|
}
|
|
31463
|
-
function
|
|
31464
|
-
return r7 ? typeof r7 == "string" ? r7 : r7 instanceof Error ? r7.message :
|
|
31487
|
+
function Pe(r7) {
|
|
31488
|
+
return r7 ? typeof r7 == "string" ? r7 : r7 instanceof Error ? r7.message : Ce(r7) ? xn(r7) : typeof r7 == "object" && "code" in r7 && typeof r7.code == "string" ? r7.code : JSON.stringify(r7) : "Unknown error";
|
|
31465
31489
|
}
|
|
31466
31490
|
function xn(r7) {
|
|
31467
31491
|
let e = r7.issue?.map(to) ?? [];
|
|
@@ -31554,12 +31578,12 @@ var lr = class {
|
|
|
31554
31578
|
return this.checkFieldExit(), this.innerTypes.length > 0 && (this.resourceSchema.innerTypes = this.innerTypes), this.resourceSchema;
|
|
31555
31579
|
}
|
|
31556
31580
|
checkFieldEnter(e, t) {
|
|
31557
|
-
this.isInnerType(e) && this.enterInnerType(e), this.slicingContext && !
|
|
31581
|
+
this.isInnerType(e) && this.enterInnerType(e), this.slicingContext && !we(this.slicingContext.path, e?.path) && (this.slicingContext = void 0), e.slicing && !this.slicingContext && this.enterSlice(e, t);
|
|
31558
31582
|
}
|
|
31559
31583
|
enterInnerType(e) {
|
|
31560
|
-
for (; this.backboneContext && !
|
|
31584
|
+
for (; this.backboneContext && !we(this.backboneContext?.path, e.path); ) this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
|
|
31561
31585
|
let t = pr(e);
|
|
31562
|
-
this.backboneContext = { type: { name: t, type: t, path: e.path, title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path, parent:
|
|
31586
|
+
this.backboneContext = { type: { name: t, type: t, path: e.path, title: e.label, description: e.definition, elements: {}, constraints: this.parseElementDefinition(e).constraints, innerTypes: [] }, path: e.path, parent: we(this.backboneContext?.path, e.path) ? this.backboneContext : this.backboneContext?.parent };
|
|
31563
31587
|
}
|
|
31564
31588
|
enterSlice(e, t) {
|
|
31565
31589
|
co(e) && !this.peek()?.sliceName || (t.slicing = { discriminator: (e.slicing?.discriminator ?? []).map((n) => {
|
|
@@ -31568,9 +31592,9 @@ var lr = class {
|
|
|
31568
31592
|
}), slices: [], ordered: e.slicing?.ordered ?? false, rule: e.slicing?.rules }, this.slicingContext = { field: t.slicing, path: e.path ?? "" });
|
|
31569
31593
|
}
|
|
31570
31594
|
checkFieldExit(e = void 0) {
|
|
31571
|
-
if (this.backboneContext && !
|
|
31595
|
+
if (this.backboneContext && !we(this.backboneContext.path, e?.path)) if (this.backboneContext.parent) do
|
|
31572
31596
|
this.innerTypes.push(this.backboneContext.type), this.backboneContext = this.backboneContext.parent;
|
|
31573
|
-
while (this.backboneContext && !
|
|
31597
|
+
while (this.backboneContext && !we(this.backboneContext.path, e?.path));
|
|
31574
31598
|
else this.innerTypes.push(this.backboneContext.type), this.backboneContext = void 0;
|
|
31575
31599
|
}
|
|
31576
31600
|
next() {
|
|
@@ -31589,7 +31613,7 @@ var lr = class {
|
|
|
31589
31613
|
}
|
|
31590
31614
|
isInnerType(e) {
|
|
31591
31615
|
let t = this.peek();
|
|
31592
|
-
return !!(
|
|
31616
|
+
return !!(we(e?.path, t?.path) && e.type?.some((n) => ["BackboneElement", "Element"].includes(n.code)));
|
|
31593
31617
|
}
|
|
31594
31618
|
parseSliceStart(e) {
|
|
31595
31619
|
if (!this.slicingContext) throw new Error(`Invalid slice start before discriminator: ${e.sliceName} (${e.id})`);
|
|
@@ -31615,7 +31639,7 @@ function ur(r7, e = "") {
|
|
|
31615
31639
|
function ao(r7, e) {
|
|
31616
31640
|
return r7 ? e && r7.startsWith(e) ? r7.substring(e.length + 1) : r7 : "";
|
|
31617
31641
|
}
|
|
31618
|
-
function
|
|
31642
|
+
function we(r7, e) {
|
|
31619
31643
|
return !r7 || !e ? false : e.startsWith(r7 + ".") || e === r7;
|
|
31620
31644
|
}
|
|
31621
31645
|
function Pn(r7) {
|
|
@@ -31629,31 +31653,7 @@ function uo(r7) {
|
|
|
31629
31653
|
let e = r7.description;
|
|
31630
31654
|
return e?.startsWith(`Base StructureDefinition for ${r7.name} Type: `) && (e = e.substring(`Base StructureDefinition for ${r7.name} Type: `.length)), e;
|
|
31631
31655
|
}
|
|
31632
|
-
var
|
|
31633
|
-
constructor(e = 10) {
|
|
31634
|
-
this.max = e, this.cache = /* @__PURE__ */ new Map();
|
|
31635
|
-
}
|
|
31636
|
-
clear() {
|
|
31637
|
-
this.cache.clear();
|
|
31638
|
-
}
|
|
31639
|
-
get(e) {
|
|
31640
|
-
let t = this.cache.get(e);
|
|
31641
|
-
return t && (this.cache.delete(e), this.cache.set(e, t)), t;
|
|
31642
|
-
}
|
|
31643
|
-
set(e, t) {
|
|
31644
|
-
this.cache.has(e) ? this.cache.delete(e) : this.cache.size >= this.max && this.cache.delete(this.first()), this.cache.set(e, t);
|
|
31645
|
-
}
|
|
31646
|
-
delete(e) {
|
|
31647
|
-
this.cache.delete(e);
|
|
31648
|
-
}
|
|
31649
|
-
keys() {
|
|
31650
|
-
return this.cache.keys();
|
|
31651
|
-
}
|
|
31652
|
-
first() {
|
|
31653
|
-
return this.cache.keys().next().value;
|
|
31654
|
-
}
|
|
31655
|
-
};
|
|
31656
|
-
var fo = new Ae(1e3);
|
|
31656
|
+
var fo = new Ee(1e3);
|
|
31657
31657
|
var ut = { base64Binary: /^([A-Za-z\d+/]{4})*([A-Za-z\d+/]{2}==|[A-Za-z\d+/]{3}=)?$/, canonical: /^\S*$/, code: /^[^\s]+( [^\s]+)*$/, date: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1]))?)?$/, dateTime: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2]\d|3[0-1])(T([01]\d|2[0-3])(:[0-5]\d:([0-5]\d|60)(\.\d{1,9})?)?)?)?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00)?)?)?$/, id: /^[A-Za-z0-9\-.]{1,64}$/, instant: /^(\d(\d(\d[1-9]|[1-9]0)|[1-9]00)|[1-9]000)-(0[1-9]|1[0-2])-(0[1-9]|[1-2]\d|3[0-1])T([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?(Z|[+-]((0\d|1[0-3]):[0-5]\d|14:00))$/, markdown: /^[\r\n\t\u0020-\uFFFF]+$/, oid: /^urn:oid:[0-2](\.(0|[1-9]\d*))+$/, string: /^[\r\n\t\u0020-\uFFFF]+$/, time: /^([01]\d|2[0-3]):[0-5]\d:([0-5]\d|60)(\.\d{1,9})?$/, uri: /^\S*$/, url: /^\S*$/, uuid: /^urn:uuid:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/, xhtml: /.*/ };
|
|
31658
31658
|
function h(r7) {
|
|
31659
31659
|
return [{ type: l.boolean, value: r7 }];
|
|
@@ -33136,7 +33136,7 @@ var Wt = class {
|
|
|
33136
33136
|
let [t, n] = await this.getTokenForCriteria(e);
|
|
33137
33137
|
e.subscriptionId = t, e.token = n, this.criteriaEntriesBySubscriptionId.set(t, e), this.ws.send(JSON.stringify({ type: "bind-with-token", payload: { token: n } }));
|
|
33138
33138
|
} catch (t) {
|
|
33139
|
-
console.error(
|
|
33139
|
+
console.error(Pe(t)), this.emitError(e, t), this.removeCriteriaEntry(e);
|
|
33140
33140
|
}
|
|
33141
33141
|
}
|
|
33142
33142
|
}
|
|
@@ -33175,7 +33175,7 @@ var Wt = class {
|
|
|
33175
33175
|
return this.masterSubEmitter || (this.masterSubEmitter = new Ze(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
|
|
33176
33176
|
}
|
|
33177
33177
|
};
|
|
33178
|
-
var Kr = "4.1.
|
|
33178
|
+
var Kr = "4.1.4-c55644ef1";
|
|
33179
33179
|
var ua = w.FHIR_JSON + ", */*; q=0.1";
|
|
33180
33180
|
var la = "https://api.medplum.com/";
|
|
33181
33181
|
var pa = 1e3;
|
|
@@ -33192,7 +33192,7 @@ var qt = class extends z {
|
|
|
33192
33192
|
super();
|
|
33193
33193
|
this.initComplete = true;
|
|
33194
33194
|
if (t?.baseUrl && !t.baseUrl.startsWith("http")) throw new Error("Base URL must start with http or https");
|
|
33195
|
-
this.options = t ?? {}, this.fetch = t?.fetch ?? xa(), this.storage = t?.storage ?? new Ye(), this.createPdfImpl = t?.createPdf, this.baseUrl = Vr(t?.baseUrl ?? la), this.fhirBaseUrl = B(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = B(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = B(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = B(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.fhircastHubUrl = B(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 ?? ha, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? fa : da), this.cacheTime > 0 ? this.requestCache = new
|
|
33195
|
+
this.options = t ?? {}, this.fetch = t?.fetch ?? xa(), this.storage = t?.storage ?? new Ye(), this.createPdfImpl = t?.createPdf, this.baseUrl = Vr(t?.baseUrl ?? la), this.fhirBaseUrl = B(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = B(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = B(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = B(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.fhircastHubUrl = B(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 ?? ha, this.cacheTime = t?.cacheTime ?? (typeof window > "u" ? fa : da), this.cacheTime > 0 ? this.requestCache = new Ee(t?.resourceCacheSize ?? pa) : 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(() => {
|
|
33196
33196
|
t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initComplete = true, this.dispatchEvent({ type: "storageInitialized" });
|
|
33197
33197
|
}).catch((n) => {
|
|
33198
33198
|
console.error(n), this.initComplete = true, this.dispatchEvent({ type: "storageInitFailed", payload: { error: n } });
|
|
@@ -33770,7 +33770,7 @@ var qt = class extends z {
|
|
|
33770
33770
|
typeof n == "string" || typeof Blob < "u" && (n instanceof Blob || n?.constructor.name === "Blob") || typeof File < "u" && (n instanceof File || n?.constructor.name === "File") || typeof Uint8Array < "u" && (n instanceof Uint8Array || n?.constructor.name === "Uint8Array") ? t.body = n : n && (t.body = JSON.stringify(n));
|
|
33771
33771
|
}
|
|
33772
33772
|
handleUnauthenticated(t, n, i) {
|
|
33773
|
-
return this.refresh() ? this.request(t, n, i) : (this.clear(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new d(
|
|
33773
|
+
return this.refresh() ? this.request(t, n, i) : (this.clear(), this.onUnauthenticated && this.onUnauthenticated(), Promise.reject(new d(Re)));
|
|
33774
33774
|
}
|
|
33775
33775
|
async startPkce() {
|
|
33776
33776
|
let t = qr();
|
|
@@ -33831,7 +33831,7 @@ var qt = class extends z {
|
|
|
33831
33831
|
return vi(n) ? this.post(this.fhircastHubUrl, Qr(t, n, i, o), w.JSON) : (Si(n), this.post(this.fhircastHubUrl, Qr(t, n, i), w.JSON));
|
|
33832
33832
|
}
|
|
33833
33833
|
async fhircastGetContext(t) {
|
|
33834
|
-
return this.get(`${this.fhircastHubUrl}/${t}
|
|
33834
|
+
return this.get(`${this.fhircastHubUrl}/${t}`, { cache: "no-cache" });
|
|
33835
33835
|
}
|
|
33836
33836
|
async invite(t, n) {
|
|
33837
33837
|
return this.post("admin/projects/" + t + "/invite", n);
|
|
@@ -33908,7 +33908,7 @@ async function Di(r7, e) {
|
|
|
33908
33908
|
if (t) return t;
|
|
33909
33909
|
let n = r7.headers.get("location");
|
|
33910
33910
|
if (n) return n;
|
|
33911
|
-
if (
|
|
33911
|
+
if (Ce(e) && e.issue?.[0]?.diagnostics) return e.issue[0].diagnostics;
|
|
33912
33912
|
}
|
|
33913
33913
|
function Vi(r7) {
|
|
33914
33914
|
let e = r7.entry?.map((t) => t.resource) ?? [];
|
|
@@ -34088,7 +34088,7 @@ async function an(r7, e, t) {
|
|
|
34088
34088
|
try {
|
|
34089
34089
|
c = (await s.json()).message;
|
|
34090
34090
|
} catch (u2) {
|
|
34091
|
-
console.error(`Failed to parse message from body: ${
|
|
34091
|
+
console.error(`Failed to parse message from body: ${Pe(u2)}`);
|
|
34092
34092
|
}
|
|
34093
34093
|
throw new Error(`Received status code ${s.status} while fetching manifest for version '${e ?? "latest"}'. Message: ${c}`);
|
|
34094
34094
|
}
|
|
@@ -34319,6 +34319,11 @@ function getChannelTypeShortName(endpoint) {
|
|
|
34319
34319
|
}
|
|
34320
34320
|
}
|
|
34321
34321
|
|
|
34322
|
+
// src/constants.ts
|
|
34323
|
+
var RETRY_WAIT_DURATION_MS = 1e4;
|
|
34324
|
+
var DEFAULT_PING_TIMEOUT = 3600;
|
|
34325
|
+
var MAX_MISSED_HEARTBEATS = 1;
|
|
34326
|
+
|
|
34322
34327
|
// src/dicom.ts
|
|
34323
34328
|
var dcmjs = __toESM(require_dcmjs());
|
|
34324
34329
|
var dimse = __toESM(require_dcmjs_dimse_min());
|
|
@@ -34413,7 +34418,7 @@ var AgentDicomChannel = class extends BaseChannel {
|
|
|
34413
34418
|
});
|
|
34414
34419
|
response2.setStatus(dimse.constants.Status.Success);
|
|
34415
34420
|
} catch (err) {
|
|
34416
|
-
DcmjsDimseScp.channel.log.error(`DICOM error: ${
|
|
34421
|
+
DcmjsDimseScp.channel.log.error(`DICOM error: ${Pe(err)}`);
|
|
34417
34422
|
response2.setStatus(dimse.constants.Status.ProcessingFailure);
|
|
34418
34423
|
}
|
|
34419
34424
|
return response2;
|
|
@@ -34517,7 +34522,7 @@ var AgentHl7ChannelConnection = class {
|
|
|
34517
34522
|
callback: `Agent/${this.channel.app.agentId}-${(0, import_node_crypto2.randomUUID)()}`
|
|
34518
34523
|
});
|
|
34519
34524
|
} catch (err) {
|
|
34520
|
-
this.channel.log.error(`HL7 error: ${
|
|
34525
|
+
this.channel.log.error(`HL7 error: ${Pe(err)}`);
|
|
34521
34526
|
}
|
|
34522
34527
|
}
|
|
34523
34528
|
close() {
|
|
@@ -34596,8 +34601,6 @@ async function execAsync(command, options) {
|
|
|
34596
34601
|
});
|
|
34597
34602
|
});
|
|
34598
34603
|
}
|
|
34599
|
-
var DEFAULT_PING_TIMEOUT = 3600;
|
|
34600
|
-
var MAX_MISSED_HEARTBEATS = 1;
|
|
34601
34604
|
var App = class _App {
|
|
34602
34605
|
constructor(medplum, agentId, logLevel) {
|
|
34603
34606
|
this.webSocketQueue = [];
|
|
@@ -34759,7 +34762,7 @@ var App = class _App {
|
|
|
34759
34762
|
} catch (err) {
|
|
34760
34763
|
await this.sendToWebSocket({
|
|
34761
34764
|
type: "agent:error",
|
|
34762
|
-
body:
|
|
34765
|
+
body: Pe(err),
|
|
34763
34766
|
callback: command.callback
|
|
34764
34767
|
});
|
|
34765
34768
|
}
|
|
@@ -34774,16 +34777,13 @@ var App = class _App {
|
|
|
34774
34777
|
this.log.error(`Unknown message type: ${command.type}`);
|
|
34775
34778
|
}
|
|
34776
34779
|
} catch (err) {
|
|
34777
|
-
this.log.error(`WebSocket error on incoming message: ${
|
|
34780
|
+
this.log.error(`WebSocket error on incoming message: ${Pe(err)}`);
|
|
34778
34781
|
}
|
|
34779
34782
|
});
|
|
34780
|
-
return new Promise((resolve2
|
|
34781
|
-
const
|
|
34782
|
-
() => reject(new Error("Timeout when attempting to connect to server WebSocket")),
|
|
34783
|
-
1e4
|
|
34784
|
-
);
|
|
34783
|
+
return new Promise((resolve2) => {
|
|
34784
|
+
const connectInterval = setInterval(() => this.webSocket?.reconnect(), RETRY_WAIT_DURATION_MS);
|
|
34785
34785
|
this.webSocket?.addEventListener("open", () => {
|
|
34786
|
-
|
|
34786
|
+
clearInterval(connectInterval);
|
|
34787
34787
|
resolve2();
|
|
34788
34788
|
});
|
|
34789
34789
|
});
|
|
@@ -34849,7 +34849,7 @@ var App = class _App {
|
|
|
34849
34849
|
try {
|
|
34850
34850
|
await this.startOrReloadChannel(definition, endpoint);
|
|
34851
34851
|
} catch (err) {
|
|
34852
|
-
this.log.error(
|
|
34852
|
+
this.log.error(Pe(err));
|
|
34853
34853
|
}
|
|
34854
34854
|
}
|
|
34855
34855
|
}
|
|
@@ -34875,7 +34875,7 @@ var App = class _App {
|
|
|
34875
34875
|
parsedEndpoint = new URL(endpoint.address);
|
|
34876
34876
|
} catch (err) {
|
|
34877
34877
|
throw new Error(
|
|
34878
|
-
`Error while validating endpoint address for channel '${channel.name}': ${
|
|
34878
|
+
`Error while validating endpoint address for channel '${channel.name}': ${Pe(err)}`
|
|
34879
34879
|
);
|
|
34880
34880
|
}
|
|
34881
34881
|
if (seenPorts.has(parsedEndpoint.port)) {
|
|
@@ -34954,7 +34954,7 @@ var App = class _App {
|
|
|
34954
34954
|
try {
|
|
34955
34955
|
await this.sendToWebSocket(msg);
|
|
34956
34956
|
} catch (err) {
|
|
34957
|
-
this.log.error(`WebSocket error while attempting to send message: ${
|
|
34957
|
+
this.log.error(`WebSocket error while attempting to send message: ${Pe(err)}`);
|
|
34958
34958
|
this.webSocketQueue.unshift(msg);
|
|
34959
34959
|
throw err;
|
|
34960
34960
|
}
|
|
@@ -35030,7 +35030,7 @@ ${result}`);
|
|
|
35030
35030
|
body: result
|
|
35031
35031
|
});
|
|
35032
35032
|
} catch (err) {
|
|
35033
|
-
this.log.error(`Error during ping attempt to ${message.remote ?? "NO_HOST_GIVEN"}: ${
|
|
35033
|
+
this.log.error(`Error during ping attempt to ${message.remote ?? "NO_HOST_GIVEN"}: ${Pe(err)}`);
|
|
35034
35034
|
this.addToWebSocketQueue({
|
|
35035
35035
|
type: "agent:transmit:response",
|
|
35036
35036
|
channel: message.channel,
|
|
@@ -35038,7 +35038,7 @@ ${result}`);
|
|
|
35038
35038
|
remote: message.remote,
|
|
35039
35039
|
callback: message.callback,
|
|
35040
35040
|
statusCode: 400,
|
|
35041
|
-
body:
|
|
35041
|
+
body: Pe(err)
|
|
35042
35042
|
});
|
|
35043
35043
|
}
|
|
35044
35044
|
}
|
|
@@ -35098,11 +35098,11 @@ ${result}`);
|
|
|
35098
35098
|
});
|
|
35099
35099
|
});
|
|
35100
35100
|
child.on("error", (err) => {
|
|
35101
|
-
this.log.error(
|
|
35101
|
+
this.log.error(Pe(err));
|
|
35102
35102
|
});
|
|
35103
35103
|
} catch (err) {
|
|
35104
35104
|
const versionTag = message.version ? `v${message.version}` : "latest";
|
|
35105
|
-
const errMsg = `Error during upgrading to version '${versionTag}': ${
|
|
35105
|
+
const errMsg = `Error during upgrading to version '${versionTag}': ${Pe(err)}`;
|
|
35106
35106
|
this.log.error(errMsg);
|
|
35107
35107
|
await this.sendToWebSocket({
|
|
35108
35108
|
type: "agent:error",
|
|
@@ -35128,7 +35128,7 @@ ${result}`);
|
|
|
35128
35128
|
child.disconnect();
|
|
35129
35129
|
} catch (err) {
|
|
35130
35130
|
this.log.error(
|
|
35131
|
-
`Error while stopping agent or messaging child process as part of upgrade: ${
|
|
35131
|
+
`Error while stopping agent or messaging child process as part of upgrade: ${Pe(err)}`
|
|
35132
35132
|
);
|
|
35133
35133
|
import_node_process.default.exit(1);
|
|
35134
35134
|
}
|
|
@@ -35198,7 +35198,7 @@ ${result}`);
|
|
|
35198
35198
|
body: response2.toString()
|
|
35199
35199
|
});
|
|
35200
35200
|
}).catch((err) => {
|
|
35201
|
-
this.log.error(`HL7 error: ${
|
|
35201
|
+
this.log.error(`HL7 error: ${Pe(err)}`);
|
|
35202
35202
|
this.addToWebSocketQueue({
|
|
35203
35203
|
type: "agent:transmit:response",
|
|
35204
35204
|
channel: message.channel,
|
|
@@ -35206,7 +35206,7 @@ ${result}`);
|
|
|
35206
35206
|
callback: message.callback,
|
|
35207
35207
|
contentType: w.TEXT,
|
|
35208
35208
|
statusCode: 400,
|
|
35209
|
-
body:
|
|
35209
|
+
body: Pe(err)
|
|
35210
35210
|
});
|
|
35211
35211
|
if (client.keepAlive) {
|
|
35212
35212
|
this.hl7Clients.delete(message.remote);
|
|
@@ -35254,7 +35254,17 @@ async function agentMain(argv) {
|
|
|
35254
35254
|
}
|
|
35255
35255
|
const { baseUrl, clientId, clientSecret, agentId } = args;
|
|
35256
35256
|
const medplum = new qt({ baseUrl, clientId });
|
|
35257
|
-
|
|
35257
|
+
let loggedIn = false;
|
|
35258
|
+
while (!loggedIn) {
|
|
35259
|
+
try {
|
|
35260
|
+
await medplum.startClientLogin(clientId, clientSecret);
|
|
35261
|
+
loggedIn = true;
|
|
35262
|
+
} catch (err) {
|
|
35263
|
+
console.error("Failed to login", { err: Pe(err) });
|
|
35264
|
+
console.log("Retrying login in 10 seconds...");
|
|
35265
|
+
await kr(RETRY_WAIT_DURATION_MS);
|
|
35266
|
+
}
|
|
35267
|
+
}
|
|
35258
35268
|
const app = new App(medplum, agentId, Rh(args.logLevel ?? "INFO"));
|
|
35259
35269
|
await app.start();
|
|
35260
35270
|
process.on("SIGINT", async () => {
|
|
@@ -35421,7 +35431,7 @@ async function upgraderMain(argv) {
|
|
|
35421
35431
|
(0, import_node_child_process2.spawnSync)(binPath, ["/S"]);
|
|
35422
35432
|
globalLogger.info(`Agent version ${version} successfully installed`);
|
|
35423
35433
|
} catch (err) {
|
|
35424
|
-
globalLogger.error(`Error while attempting to run installer: ${
|
|
35434
|
+
globalLogger.error(`Error while attempting to run installer: ${Pe(err)}`);
|
|
35425
35435
|
globalLogger.error("Failed to run installer, attempting to restart agent service...");
|
|
35426
35436
|
try {
|
|
35427
35437
|
(0, import_node_child_process2.execSync)('net start "Medplum Agent"');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medplum/agent",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.4",
|
|
4
4
|
"description": "Medplum Agent",
|
|
5
5
|
"homepage": "https://www.medplum.com/",
|
|
6
6
|
"bugs": {
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
"test": "jest"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@medplum/core": "4.1.
|
|
28
|
-
"@medplum/hl7": "4.1.
|
|
27
|
+
"@medplum/core": "4.1.4",
|
|
28
|
+
"@medplum/hl7": "4.1.4",
|
|
29
29
|
"dcmjs-dimse": "0.2.5",
|
|
30
30
|
"iconv-lite": "0.6.3",
|
|
31
31
|
"ws": "8.18.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@medplum/fhirtypes": "4.1.
|
|
35
|
-
"@medplum/mock": "4.1.
|
|
34
|
+
"@medplum/fhirtypes": "4.1.4",
|
|
35
|
+
"@medplum/mock": "4.1.4",
|
|
36
36
|
"@types/async-eventemitter": "0.2.4",
|
|
37
37
|
"@types/ws": "8.18.1",
|
|
38
38
|
"mock-socket": "9.3.1",
|