@medplum/agent 5.0.8 → 5.0.9

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 (2) hide show
  1. package/dist/cjs/index.cjs +34 -24
  2. package/package.json +5 -5
@@ -67624,7 +67624,7 @@ var ur = class {
67624
67624
  }
67625
67625
  consumeAndParse(e = 1 / 0) {
67626
67626
  let t = this.consume(), n = this.prefixParselets[t.id];
67627
- if (!n) throw Error(`Parse error at "${t.value}" (line ${t.line}, column ${t.column}). No matching prefix parselet.`);
67627
+ if (!n) throw new Error(`Parse error at "${t.value}" (line ${t.line}, column ${t.column}). No matching prefix parselet.`);
67628
67628
  let i = n.parse(this, t);
67629
67629
  for (; e > this.getPrecedence(); ) {
67630
67630
  let o2 = this.consume();
@@ -67639,14 +67639,14 @@ var ur = class {
67639
67639
  return t ? t.precedence : 1 / 0;
67640
67640
  }
67641
67641
  consume(e, t) {
67642
- if (!this.tokens.length) throw Error("Cant consume unknown more tokens.");
67642
+ if (!this.tokens.length) throw new Error("Cant consume unknown more tokens.");
67643
67643
  if (e && this.peek()?.id !== e) {
67644
67644
  let n = this.peek();
67645
- throw Error(`Expected ${e} but got "${n.id}" (${n.value}) at line ${n.line} column ${n.column}.`);
67645
+ throw new Error(`Expected ${e} but got "${n.id}" (${n.value}) at line ${n.line} column ${n.column}.`);
67646
67646
  }
67647
67647
  if (t && this.peek()?.value !== t) {
67648
67648
  let n = this.peek();
67649
- throw Error(`Expected "${t}" but got "${n.value}" at line ${n.line} column ${n.column}.`);
67649
+ throw new Error(`Expected "${t}" but got "${n.value}" at line ${n.line} column ${n.column}.`);
67650
67650
  }
67651
67651
  return this.tokens.shift();
67652
67652
  }
@@ -68216,7 +68216,7 @@ function si(r6) {
68216
68216
  }
68217
68217
  function ai(r6) {
68218
68218
  let e = ci(r6), t = new Uint8Array(e), n = new Array(t.length);
68219
- for (let i = 0; i < t.length; i++) n[i] = String.fromCharCode(t[i]);
68219
+ for (let i = 0; i < t.length; i++) n[i] = String.fromCodePoint(t[i]);
68220
68220
  return window.btoa(n.join(""));
68221
68221
  }
68222
68222
  function ci(r6) {
@@ -68256,7 +68256,7 @@ function fi(r6) {
68256
68256
  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();
68257
68257
  }
68258
68258
  var ds = /^(([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])$/;
68259
- function jl(r6) {
68259
+ function $l(r6) {
68260
68260
  return ds.test(r6);
68261
68261
  }
68262
68262
  function Xe(r6, e) {
@@ -68822,7 +68822,7 @@ var ie = { assign(r6) {
68822
68822
  } };
68823
68823
  function fa(r6) {
68824
68824
  if (q()) {
68825
- let t = window.atob(r6), n = Uint8Array.from(t, (i) => i.charCodeAt(0));
68825
+ let t = window.atob(r6), n = Uint8Array.from(t, (i) => i.codePointAt(0));
68826
68826
  return new window.TextDecoder().decode(n);
68827
68827
  }
68828
68828
  let e = Xr();
@@ -68831,7 +68831,7 @@ function fa(r6) {
68831
68831
  }
68832
68832
  function Wt(r6) {
68833
68833
  if (q()) {
68834
- let t = new window.TextEncoder().encode(r6), n = String.fromCharCode.apply(null, t);
68834
+ let t = new window.TextEncoder().encode(r6), n = String.fromCodePoint.apply(null, t);
68835
68835
  return window.btoa(n);
68836
68836
  }
68837
68837
  let e = Xr();
@@ -69528,7 +69528,7 @@ var zt = class {
69528
69528
  return this.masterSubEmitter || (this.masterSubEmitter = new it(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
69529
69529
  }
69530
69530
  };
69531
- var an = "5.0.8-2b1f5fb";
69531
+ var an = "5.0.9-8924a17";
69532
69532
  var La = w.FHIR_JSON + ", */*; q=0.1";
69533
69533
  var Fa = "https://api.medplum.com/";
69534
69534
  var Na = 1e3;
@@ -69577,8 +69577,9 @@ var Jt = class extends Z {
69577
69577
  c(this, "initPromise");
69578
69578
  c(this, "initComplete", true);
69579
69579
  c(this, "keyValueClient");
69580
+ c(this, "logLevel");
69580
69581
  if (t?.baseUrl && !t.baseUrl.startsWith("http")) throw new Error("Base URL must start with http or https");
69581
- this.options = t ?? {}, this.fetch = t?.fetch ?? Ha(), this.storage = t?.storage ?? new nt(void 0, t?.storagePrefix), this.createPdfImpl = t?.createPdf, this.baseUrl = Hr(t?.baseUrl ?? Fa), this.fhirBaseUrl = H(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = H(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = H(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = H(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.fhircastHubUrl = H(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 ?? Wa, this.cacheTime = t?.cacheTime ?? (q() ? Ua : Ba), this.cacheTime > 0 ? this.requestCache = new Ve(t?.resourceCacheSize ?? Na) : 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(() => {
69582
+ this.options = t ?? {}, this.fetch = t?.fetch ?? Ha(), this.storage = t?.storage ?? new nt(void 0, t?.storagePrefix), this.createPdfImpl = t?.createPdf, this.baseUrl = Hr(t?.baseUrl ?? Fa), this.fhirBaseUrl = H(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4"), this.authorizeUrl = H(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = H(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = H(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.fhircastHubUrl = H(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 ?? Wa, this.logLevel = this.initializeLogLevel(t), this.cacheTime = t?.cacheTime ?? (q() ? Ua : Ba), this.cacheTime > 0 ? this.requestCache = new Ve(t?.resourceCacheSize ?? Na) : 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(() => {
69582
69583
  t?.accessToken || this.attemptResumeActiveLogin().catch(console.error), this.initComplete = true, this.dispatchEvent({ type: "storageInitialized" });
69583
69584
  }).catch((n) => {
69584
69585
  console.error(n), this.initComplete = true, this.dispatchEvent({ type: "storageInitFailed", payload: { error: n } });
@@ -69590,6 +69591,9 @@ var Jt = class extends Z {
69590
69591
  getInitPromise() {
69591
69592
  return this.initPromise;
69592
69593
  }
69594
+ initializeLogLevel(t) {
69595
+ return t?.logLevel ? t.logLevel : t?.verbose !== void 0 && t.verbose ? "verbose" : "none";
69596
+ }
69593
69597
  async attemptResumeActiveLogin() {
69594
69598
  let t = this.getActiveLogin();
69595
69599
  t && (this.setAccessToken(t.accessToken, t.refreshToken), await this.refreshProfile());
@@ -70111,9 +70115,9 @@ var Jt = class extends Z {
70111
70115
  t.startsWith("http") || (t = H(this.baseUrl, t));
70112
70116
  let i = n?.maxRetries ?? 2;
70113
70117
  for (let o2 = 0; o2 <= i; o2++) try {
70114
- this.options.verbose && this.logRequest(t, n);
70118
+ this.logLevel !== "none" && this.logRequest(t, n);
70115
70119
  let s = await this.fetch(t, n);
70116
- if (this.options.verbose && this.logResponse(s), this.setCurrentRateLimit(s), o2 >= i || !Ja(s)) return s;
70120
+ if (this.logLevel !== "none" && this.logResponse(s), this.setCurrentRateLimit(s), o2 >= i || !Ja(s)) return s;
70117
70121
  let a = this.getRetryDelay(o2), u2 = n.maxRetryTime ?? 2e3;
70118
70122
  if (a > u2) return s;
70119
70123
  await $r(a);
@@ -70123,13 +70127,13 @@ var Jt = class extends Z {
70123
70127
  throw new Error("Unreachable");
70124
70128
  }
70125
70129
  logRequest(t, n) {
70126
- if (console.log(`> ${n.method} ${t}`), n.headers) {
70130
+ if (console.log(`> ${n.method} ${t}`), this.logLevel === "verbose" && n.headers) {
70127
70131
  let i = n.headers;
70128
70132
  for (let o2 of Rt(Object.keys(i))) console.log(`> ${o2}: ${i[o2]}`);
70129
70133
  }
70130
70134
  }
70131
70135
  logResponse(t) {
70132
- console.log(`< ${t.status} ${t.statusText}`), t.headers && t.headers.forEach((n, i) => console.log(`< ${i}: ${n}`));
70136
+ console.log(`< ${t.status} ${t.statusText}`), this.logLevel === "verbose" && t.headers && t.headers.forEach((n, i) => console.log(`< ${i}: ${n}`));
70133
70137
  }
70134
70138
  setCurrentRateLimit(t) {
70135
70139
  if (!t?.headers || typeof t.headers.get != "function") return;
@@ -70242,8 +70246,14 @@ var Jt = class extends Z {
70242
70246
  setBasicAuth(t, n) {
70243
70247
  this.clientId = t, this.clientSecret = n, this.basicAuth = Wt(t + ":" + n);
70244
70248
  }
70249
+ setLogLevel(t) {
70250
+ this.logLevel = t, this.options.verbose = t === "verbose";
70251
+ }
70252
+ getLogLevel() {
70253
+ return this.logLevel;
70254
+ }
70245
70255
  setVerbose(t) {
70246
- this.options.verbose = t;
70256
+ this.logLevel = t ? "verbose" : "none", this.options.verbose = t;
70247
70257
  }
70248
70258
  async fhircastSubscribe(t, n) {
70249
70259
  if (!(typeof t == "string" && t !== "")) throw new f(g("Invalid topic provided. Topic must be a valid string."));
@@ -70555,7 +70565,7 @@ var mo = class r5 {
70555
70565
  this.write(JSON.stringify({ level: Fc[e], timestamp: (/* @__PURE__ */ new Date()).toISOString(), msg: this.prefix ? `${this.prefix}${t}` : t, ...i, ...this.metadata }));
70556
70566
  }
70557
70567
  };
70558
- function Zh(r6) {
70568
+ function em(r6) {
70559
70569
  let e = $e[r6.toUpperCase()];
70560
70570
  if (e === void 0) throw new Error(`Invalid log level: ${r6}`);
70561
70571
  return e;
@@ -70608,7 +70618,7 @@ async function xn(r6, e, t) {
70608
70618
  function Xc(r6) {
70609
70619
  return /^\d+\.\d+\.\d+(-[0-9a-z]{7})?$/.test(r6);
70610
70620
  }
70611
- async function Pm(r6, e) {
70621
+ async function wm(r6, e) {
70612
70622
  if (!Xc(e)) return false;
70613
70623
  try {
70614
70624
  await xn(r6, e);
@@ -70617,7 +70627,7 @@ async function Pm(r6, e) {
70617
70627
  }
70618
70628
  return true;
70619
70629
  }
70620
- async function wm(r6) {
70630
+ async function Am(r6) {
70621
70631
  let e = await xn(r6);
70622
70632
  if (!e.tag_name.startsWith("v")) throw new Error(`Invalid release name found. Release tag '${e.tag_name}' did not start with 'v'`);
70623
70633
  return e.tag_name.slice(1);
@@ -72160,7 +72170,7 @@ function parseLoggerConfigFromArgs(args) {
72160
72170
  let configValue;
72161
72171
  if (settingName === "logLevel") {
72162
72172
  try {
72163
- configValue = Zh(propVal);
72173
+ configValue = em(propVal);
72164
72174
  } catch (err) {
72165
72175
  warnings.push(`Error while parsing ${propName}: ${Me(err)}`);
72166
72176
  }
@@ -73089,7 +73099,7 @@ IPv6 is currently unsupported.`;
73089
73099
  this.log.error(errMsg);
73090
73100
  throw new Error(errMsg);
73091
73101
  }
73092
- if (!((0, import_node_net4.isIPv4)(message.remote) || jl(message.remote))) {
73102
+ if (!((0, import_node_net4.isIPv4)(message.remote) || $l(message.remote))) {
73093
73103
  const errMsg = `Attempted to ping an invalid host.
73094
73104
 
73095
73105
  "${message.remote}" is not a valid IPv4 address or a resolvable hostname.`;
@@ -73164,7 +73174,7 @@ ${result}`);
73164
73174
  return;
73165
73175
  }
73166
73176
  let child;
73167
- if (message.version && !await Pm("agent-upgrader", message.version)) {
73177
+ if (message.version && !await wm("agent-upgrader", message.version)) {
73168
73178
  const versionTag = message.version ? `v${message.version}` : "latest";
73169
73179
  const errMsg = `Error during upgrading to version '${versionTag}'. '${message.version}' is not a valid version`;
73170
73180
  this.log.error(errMsg);
@@ -73175,7 +73185,7 @@ ${result}`);
73175
73185
  });
73176
73186
  return;
73177
73187
  }
73178
- const targetVersion = message.version ?? await wm("agent-upgrader");
73188
+ const targetVersion = message.version ?? await Am("agent-upgrader");
73179
73189
  if (an.startsWith(targetVersion)) {
73180
73190
  if (!message?.force) {
73181
73191
  this.log.info(`Attempted to upgrade to version ${targetVersion}, but agent is already on that version`);
@@ -73463,7 +73473,7 @@ async function agentMain(argv) {
73463
73473
  for (const warning of warnings) {
73464
73474
  mainLogger.warn(warning);
73465
73475
  }
73466
- const app = new App(medplum, agentId, args.logLevel ? Zh(args.logLevel) : void 0, {
73476
+ const app = new App(medplum, agentId, args.logLevel ? em(args.logLevel) : void 0, {
73467
73477
  mainLogger,
73468
73478
  channelLogger
73469
73479
  });
@@ -73508,7 +73518,7 @@ async function upgraderMain(argv) {
73508
73518
  if (argv[3] && !Xc(argv[3])) {
73509
73519
  throw new Error("Invalid version specified");
73510
73520
  }
73511
- const version = argv[3] ?? await wm("agent-upgrader");
73521
+ const version = argv[3] ?? await Am("agent-upgrader");
73512
73522
  const binPath = getReleaseBinPath(version);
73513
73523
  if (!(0, import_node_fs6.existsSync)(binPath)) {
73514
73524
  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.8",
3
+ "version": "5.0.9",
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.8",
30
- "@medplum/hl7": "5.0.8",
29
+ "@medplum/core": "5.0.9",
30
+ "@medplum/hl7": "5.0.9",
31
31
  "dcmjs-dimse": "0.3.1",
32
32
  "iconv-lite": "0.7.0",
33
33
  "semver": "7.7.3",
@@ -36,8 +36,8 @@
36
36
  "ws": "8.18.3"
37
37
  },
38
38
  "devDependencies": {
39
- "@medplum/fhirtypes": "5.0.8",
40
- "@medplum/mock": "5.0.8",
39
+ "@medplum/fhirtypes": "5.0.9",
40
+ "@medplum/mock": "5.0.9",
41
41
  "@types/async-eventemitter": "0.2.4",
42
42
  "@types/ws": "8.18.1",
43
43
  "mock-socket": "9.3.1",