@medplum/agent 2.1.14 → 2.1.15

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.
@@ -3698,12 +3698,12 @@ function zt(r4, e) {
3698
3698
  return JSON.stringify(r4, xn, e ? 2 : void 0);
3699
3699
  }
3700
3700
  function xn(r4, e) {
3701
- return !Tn(r4) && S(e) ? void 0 : e;
3701
+ return !Tn(r4) && E(e) ? void 0 : e;
3702
3702
  }
3703
3703
  function Tn(r4) {
3704
3704
  return !!/\d+$/.exec(r4);
3705
3705
  }
3706
- function S(r4) {
3706
+ function E(r4) {
3707
3707
  if (r4 == null)
3708
3708
  return true;
3709
3709
  let e = typeof r4;
@@ -3786,7 +3786,7 @@ function $n(r4, e, t) {
3786
3786
  }
3787
3787
  }
3788
3788
  let s = r4.value["_" + e];
3789
- if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? cr(a ?? {}, s[c2]) : a) : i2 = cr(i2 ?? {}, s)), !S(i2))
3789
+ if (s && (Array.isArray(i2) ? i2 = i2.map((a, c2) => s[c2] ? cr(a ?? {}, s[c2]) : a) : i2 = cr(i2 ?? {}, s)), !E(i2))
3790
3790
  return (o === "Element" || o === "BackboneElement") && (o = t.type[0].code), Array.isArray(i2) ? i2.map((a) => or(a, o)) : or(i2, o);
3791
3791
  }
3792
3792
  function or(r4, e) {
@@ -3807,7 +3807,7 @@ function jn(r4, e) {
3807
3807
  break;
3808
3808
  }
3809
3809
  }
3810
- if (!S(n))
3810
+ if (!E(n))
3811
3811
  return Array.isArray(n) ? n.map(T) : T(n);
3812
3812
  }
3813
3813
  function Pe(r4) {
@@ -3935,11 +3935,11 @@ function Wn(r4) {
3935
3935
  let e;
3936
3936
  return r4.details?.text ? r4.diagnostics ? e = `${r4.details.text} (${r4.diagnostics})` : e = r4.details.text : r4.diagnostics ? e = r4.diagnostics : e = "Unknown error", r4.expression?.length && (e += ` (${r4.expression.join(", ")})`), e;
3937
3937
  }
3938
- function Et(r4) {
3938
+ function St(r4) {
3939
3939
  return new Tt(r4).parse();
3940
3940
  }
3941
3941
  var Q = nr(ir);
3942
- function Sr(r4) {
3942
+ function Er(r4) {
3943
3943
  let e = Array.isArray(r4) ? r4 : r4.entry?.map((t) => t.resource) ?? [];
3944
3944
  for (let t of e)
3945
3945
  Gn(t);
@@ -3949,7 +3949,7 @@ function Gn(r4) {
3949
3949
  throw new Error("Failed loading StructureDefinition from bundle");
3950
3950
  if (r4.resourceType !== "StructureDefinition")
3951
3951
  return;
3952
- let e = Et(r4);
3952
+ let e = St(r4);
3953
3953
  Q[r4.name] = e;
3954
3954
  for (let t of e.innerTypes)
3955
3955
  t.parentType = e, Q[t.name] = t;
@@ -4048,7 +4048,7 @@ var Tt = class {
4048
4048
  }
4049
4049
  parseElementDefinition(e) {
4050
4050
  let t = vr(e.max), n = e.base?.max ? vr(e.base.max) : t, i2 = { type: "ElementDefinition", value: e };
4051
- return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? vt(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: Er(I(i2, "fixed")), pattern: Er(I(i2, "pattern")), binding: e.binding };
4051
+ return { description: e.definition || "", path: e.path || e.base?.path || "", min: e.min ?? 0, max: t, isArray: n > 1, constraints: (e.constraint ?? []).map((o) => ({ key: o.key ?? "", severity: o.severity ?? "error", expression: o.expression ?? "", description: o.human ?? "" })), type: (e.type ?? []).map((o) => ({ code: ["BackboneElement", "Element"].includes(o.code) ? vt(e) : o.code ?? "", targetProfile: o.targetProfile })), fixed: Sr(I(i2, "fixed")), pattern: Sr(I(i2, "pattern")), binding: e.binding };
4052
4052
  }
4053
4053
  };
4054
4054
  function vr(r4) {
@@ -4063,8 +4063,8 @@ function Jn(r4, e) {
4063
4063
  function ee(r4, e) {
4064
4064
  return !r4 || !e ? false : e.startsWith(r4 + ".") || e === r4;
4065
4065
  }
4066
- function Er(r4) {
4067
- return Array.isArray(r4) && r4.length > 0 ? r4[0] : S(r4) ? void 0 : r4;
4066
+ function Sr(r4) {
4067
+ return Array.isArray(r4) && r4.length > 0 ? r4[0] : E(r4) ? void 0 : r4;
4068
4068
  }
4069
4069
  function Yn(r4) {
4070
4070
  let e = r4.slicing?.discriminator;
@@ -4112,7 +4112,7 @@ function re(r4) {
4112
4112
  }
4113
4113
  }
4114
4114
  var ce = () => [];
4115
- var E = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.filter((n) => L(t.eval(r4, [n]))).length > 0) : l(e.length > 0), all: (r4, e, t) => l(e.every((n) => L(t.eval(r4, [n])))), allTrue: (r4, e) => {
4115
+ var S = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.filter((n) => L(t.eval(r4, [n]))).length > 0) : l(e.length > 0), all: (r4, e, t) => l(e.every((n) => L(t.eval(r4, [n])))), allTrue: (r4, e) => {
4116
4116
  for (let t of e)
4117
4117
  if (!t.value)
4118
4118
  return l(false);
@@ -4137,7 +4137,7 @@ var E = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4137
4137
  for (let n of e)
4138
4138
  t.some((i2) => i2.value === n.value) || t.push(n);
4139
4139
  return t;
4140
- }, isDistinct: (r4, e) => l(e.length === E.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => L(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: ce, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
4140
+ }, isDistinct: (r4, e) => l(e.length === S.distinct(r4, e).length), where: (r4, e, t) => e.filter((n) => L(t.eval(r4, [n]))), select: (r4, e, t) => e.map((n) => t.eval(r4, [n])).flat(), repeat: ce, ofType: (r4, e, t) => e.filter((n) => n.type === t.name), single: (r4, e) => {
4141
4141
  if (e.length > 1)
4142
4142
  throw new Error("Expected input length one for single()");
4143
4143
  return e.length === 0 ? [] : e.slice(0, 1);
@@ -4196,37 +4196,37 @@ var E = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4196
4196
  return l(false);
4197
4197
  }
4198
4198
  return [];
4199
- }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : l(E.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4199
+ }, convertsToBoolean: (r4, e) => e.length === 0 ? [] : l(S.toBoolean(r4, e).length === 1), toInteger: (r4, e) => {
4200
4200
  if (e.length === 0)
4201
4201
  return [];
4202
4202
  let [{ value: t }] = U(e, 1);
4203
4203
  return typeof t == "number" ? [{ type: u.integer, value: t }] : typeof t == "string" && /^[+-]?\d+$/.exec(t) ? [{ type: u.integer, value: parseInt(t, 10) }] : typeof t == "boolean" ? [{ type: u.integer, value: t ? 1 : 0 }] : [];
4204
- }, convertsToInteger: (r4, e) => e.length === 0 ? [] : l(E.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4204
+ }, convertsToInteger: (r4, e) => e.length === 0 ? [] : l(S.toInteger(r4, e).length === 1), toDate: (r4, e) => {
4205
4205
  if (e.length === 0)
4206
4206
  return [];
4207
4207
  let [{ value: t }] = U(e, 1);
4208
4208
  return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.date, value: re(t) }] : [];
4209
- }, convertsToDate: (r4, e) => e.length === 0 ? [] : l(E.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4209
+ }, convertsToDate: (r4, e) => e.length === 0 ? [] : l(S.toDate(r4, e).length === 1), toDateTime: (r4, e) => {
4210
4210
  if (e.length === 0)
4211
4211
  return [];
4212
4212
  let [{ value: t }] = U(e, 1);
4213
4213
  return typeof t == "string" && /^\d{4}(-\d{2}(-\d{2})?)?/.exec(t) ? [{ type: u.dateTime, value: re(t) }] : [];
4214
- }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : l(E.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4214
+ }, convertsToDateTime: (r4, e) => e.length === 0 ? [] : l(S.toDateTime(r4, e).length === 1), toDecimal: (r4, e) => {
4215
4215
  if (e.length === 0)
4216
4216
  return [];
4217
4217
  let [{ value: t }] = U(e, 1);
4218
4218
  return typeof t == "number" ? [{ type: u.decimal, value: t }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?$/.exec(t) ? [{ type: u.decimal, value: parseFloat(t) }] : typeof t == "boolean" ? [{ type: u.decimal, value: t ? 1 : 0 }] : [];
4219
- }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : l(E.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4219
+ }, convertsToDecimal: (r4, e) => e.length === 0 ? [] : l(S.toDecimal(r4, e).length === 1), toQuantity: (r4, e) => {
4220
4220
  if (e.length === 0)
4221
4221
  return [];
4222
4222
  let [{ value: t }] = U(e, 1);
4223
4223
  return R(t) ? [{ type: u.Quantity, value: t }] : typeof t == "number" ? [{ type: u.Quantity, value: { value: t, unit: "1" } }] : typeof t == "string" && /^-?\d{1,9}(\.\d{1,9})?/.exec(t) ? [{ type: u.Quantity, value: { value: parseFloat(t), unit: "1" } }] : typeof t == "boolean" ? [{ type: u.Quantity, value: { value: t ? 1 : 0, unit: "1" } }] : [];
4224
- }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : l(E.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4224
+ }, convertsToQuantity: (r4, e) => e.length === 0 ? [] : l(S.toQuantity(r4, e).length === 1), toString: (r4, e) => {
4225
4225
  if (e.length === 0)
4226
4226
  return [];
4227
4227
  let [{ value: t }] = U(e, 1);
4228
4228
  return t == null ? [] : R(t) ? [{ type: u.string, value: `${t.value} '${t.unit}'` }] : [{ type: u.string, value: t.toString() }];
4229
- }, convertsToString: (r4, e) => e.length === 0 ? [] : l(E.toString(r4, e).length === 1), toTime: (r4, e) => {
4229
+ }, convertsToString: (r4, e) => e.length === 0 ? [] : l(S.toString(r4, e).length === 1), toTime: (r4, e) => {
4230
4230
  if (e.length === 0)
4231
4231
  return [];
4232
4232
  let [{ value: t }] = U(e, 1);
@@ -4236,14 +4236,14 @@ var E = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4236
4236
  return [{ type: u.time, value: re("T" + n[1]) }];
4237
4237
  }
4238
4238
  return [];
4239
- }, convertsToTime: (r4, e) => e.length === 0 ? [] : l(E.toTime(r4, e).length === 1), indexOf: (r4, e, t) => A((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => A((i2, o, s) => {
4239
+ }, convertsToTime: (r4, e) => e.length === 0 ? [] : l(S.toTime(r4, e).length === 1), indexOf: (r4, e, t) => A((n, i2) => n.indexOf(i2), r4, e, t), substring: (r4, e, t, n) => A((i2, o, s) => {
4240
4240
  let a = o, c2 = s ? a + s : i2.length;
4241
4241
  return a < 0 || a >= i2.length ? void 0 : i2.substring(a, c2);
4242
4242
  }, r4, e, t, n), startsWith: (r4, e, t) => A((n, i2) => n.startsWith(i2), r4, e, t), endsWith: (r4, e, t) => A((n, i2) => n.endsWith(i2), r4, e, t), contains: (r4, e, t) => A((n, i2) => n.includes(i2), r4, e, t), upper: (r4, e) => A((t) => t.toUpperCase(), r4, e), lower: (r4, e) => A((t) => t.toLowerCase(), r4, e), replace: (r4, e, t, n) => A((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), matches: (r4, e, t) => A((n, i2) => !!new RegExp(i2).exec(n), r4, e, t), replaceMatches: (r4, e, t, n) => A((i2, o, s) => i2.replaceAll(o, s), r4, e, t, n), length: (r4, e) => A((t) => t.length, r4, e), toChars: (r4, e) => A((t) => t ? t.split("") : void 0, r4, e), abs: (r4, e) => _(Math.abs, r4, e), ceiling: (r4, e) => _(Math.ceil, r4, e), exp: (r4, e) => _(Math.exp, r4, e), floor: (r4, e) => _(Math.floor, r4, e), ln: (r4, e) => _(Math.log, r4, e), log: (r4, e, t) => _((n, i2) => Math.log(n) / Math.log(i2), r4, e, t), power: (r4, e, t) => _(Math.pow, r4, e, t), round: (r4, e) => _(Math.round, r4, e), sqrt: (r4, e) => _(Math.sqrt, r4, e), truncate: (r4, e) => _((t) => t | 0, r4, e), children: ce, descendants: ce, trace: (r4, e, t) => (console.log("trace", e, t), e), now: () => [{ type: u.dateTime, value: (/* @__PURE__ */ new Date()).toISOString() }], timeOfDay: () => [{ type: u.time, value: (/* @__PURE__ */ new Date()).toISOString().substring(11) }], today: () => [{ type: u.date, value: (/* @__PURE__ */ new Date()).toISOString().substring(0, 10) }], between: (r4, e, t, n, i2) => {
4243
- let o = E.toDateTime(r4, t.eval(r4, e));
4243
+ let o = S.toDateTime(r4, t.eval(r4, e));
4244
4244
  if (o.length === 0)
4245
4245
  throw new Error("Invalid start date");
4246
- let s = E.toDateTime(r4, n.eval(r4, e));
4246
+ let s = S.toDateTime(r4, n.eval(r4, e));
4247
4247
  if (s.length === 0)
4248
4248
  throw new Error("Invalid end date");
4249
4249
  let a = i2.eval(r4, e)[0]?.value;
@@ -4254,7 +4254,7 @@ var E = { empty: (r4, e) => l(e.length === 0), exists: (r4, e, t) => t ? l(e.fil
4254
4254
  }, is: (r4, e, t) => {
4255
4255
  let n = "";
4256
4256
  return t instanceof M ? n = t.name : t instanceof H && (n = t.left.name + "." + t.right.name), n ? e.map((i2) => ({ type: u.boolean, value: Ae(i2, n) })) : [];
4257
- }, not: (r4, e) => E.toBoolean(r4, e).map((t) => ({ type: u.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
4257
+ }, not: (r4, e) => S.toBoolean(r4, e).map((t) => ({ type: u.boolean, value: !t.value })), resolve: (r4, e) => e.map((t) => {
4258
4258
  let n = t.value, i2;
4259
4259
  if (typeof n == "string")
4260
4260
  i2 = n;
@@ -4367,7 +4367,7 @@ var J = class extends $ {
4367
4367
  super("as", e, t);
4368
4368
  }
4369
4369
  eval(e, t) {
4370
- return E.ofType(e, this.left.eval(e, t), this.right);
4370
+ return S.ofType(e, this.left.eval(e, t), this.right);
4371
4371
  }
4372
4372
  };
4373
4373
  var v = class extends $ {
@@ -4525,7 +4525,7 @@ var B = class {
4525
4525
  this.args = t;
4526
4526
  }
4527
4527
  eval(e, t) {
4528
- let n = E[this.name];
4528
+ let n = S[this.name];
4529
4529
  if (!n)
4530
4530
  throw new Error("Unrecognized function: " + this.name);
4531
4531
  return n(e, t, ...this.args);
@@ -4846,8 +4846,8 @@ var w = class {
4846
4846
  };
4847
4847
  Yi = Symbol.toStringTag;
4848
4848
  var Ye = class {
4849
- constructor() {
4850
- this.storage = typeof localStorage < "u" ? localStorage : new Ut();
4849
+ constructor(e) {
4850
+ this.storage = e ?? (typeof localStorage < "u" ? localStorage : new Ut());
4851
4851
  }
4852
4852
  clear() {
4853
4853
  this.storage.clear();
@@ -4902,16 +4902,32 @@ var oo = ((e) => (e.JwtBearer = "urn:ietf:params:oauth:client-assertion-type:jwt
4902
4902
  var en = class extends he {
4903
4903
  constructor(t) {
4904
4904
  super();
4905
+ this.initComplete = true;
4905
4906
  if (t?.baseUrl && !t.baseUrl.startsWith("http"))
4906
4907
  throw new Error("Base URL must start with http or https");
4907
4908
  if (this.options = t ?? {}, this.fetch = t?.fetch ?? so(), this.storage = t?.storage ?? new Ye(), this.createPdfImpl = t?.createPdf, this.baseUrl = rn(t?.baseUrl ?? Zi), this.fhirBaseUrl = rn(Xe(this.baseUrl, t?.fhirUrlPath ?? "fhir/R4/")), this.authorizeUrl = Xe(this.baseUrl, t?.authorizeUrl ?? "oauth2/authorize"), this.tokenUrl = Xe(this.baseUrl, t?.tokenUrl ?? "oauth2/token"), this.logoutUrl = Xe(this.baseUrl, t?.logoutUrl ?? "oauth2/logout"), this.clientId = t?.clientId ?? "", this.clientSecret = t?.clientSecret ?? "", this.onUnauthenticated = t?.onUnauthenticated, this.cacheTime = t?.cacheTime ?? to, this.cacheTime > 0 ? this.requestCache = new We(t?.resourceCacheSize ?? eo) : this.requestCache = void 0, t?.autoBatchTime ? (this.autoBatchTime = t.autoBatchTime, this.autoBatchQueue = []) : (this.autoBatchTime = 0, this.autoBatchQueue = void 0), t?.accessToken)
4908
- this.setAccessToken(t.accessToken);
4909
- else {
4910
- let n = this.getActiveLogin();
4911
- n && (this.setAccessToken(n.accessToken, n.refreshToken), this.refreshProfile().catch(console.log));
4912
- }
4909
+ this.setAccessToken(t.accessToken), this.initPromise = Promise.resolve();
4910
+ else if (this.storage.getInitPromise !== void 0) {
4911
+ let n = this.storage.getInitPromise(), i2 = new Promise((o) => {
4912
+ n.then(() => {
4913
+ this.attemptResumeActiveLogin().then(o).catch(console.error), this.initComplete = true;
4914
+ }).catch(console.error);
4915
+ });
4916
+ this.initPromise = i2, this.initComplete = false;
4917
+ } else
4918
+ this.initPromise = this.attemptResumeActiveLogin().catch(console.error);
4913
4919
  this.setupStorageListener();
4914
4920
  }
4921
+ get isInitialized() {
4922
+ return this.initComplete;
4923
+ }
4924
+ getInitPromise() {
4925
+ return this.initPromise;
4926
+ }
4927
+ async attemptResumeActiveLogin() {
4928
+ let t = this.getActiveLogin();
4929
+ t && (this.setAccessToken(t.accessToken, t.refreshToken), await this.refreshProfile());
4930
+ }
4915
4931
  getBaseUrl() {
4916
4932
  return this.baseUrl;
4917
4933
  }
@@ -5139,7 +5155,7 @@ var en = class extends he {
5139
5155
  target
5140
5156
  }
5141
5157
  }`.replace(/\s+/g, " "), a = await this.graphql(s);
5142
- Sr(a.data.StructureDefinitionList);
5158
+ Er(a.data.StructureDefinitionList);
5143
5159
  for (let c2 of a.data.SearchParameterList)
5144
5160
  Rt(c2);
5145
5161
  })());
package/installer.nsi CHANGED
@@ -165,11 +165,21 @@ Function InstallApp
165
165
  ExecWait "shawl-v1.3.0-win64.exe add --name $\"${SERVICE_NAME}$\" -- $\"$INSTDIR\medplum-agent-win-x64.exe$\" $\"$baseUrl$\" $\"$clientId$\" $\"$clientSecret$\" $\"$agentId$\"" $1
166
166
  DetailPrint "Exit code $1"
167
167
 
168
+ # Set service display name
169
+ DetailPrint "Setting service display name..."
170
+ ExecWait "sc.exe config $\"${SERVICE_NAME}$\" displayname= $\"${APP_NAME}$\"" $1
171
+ DetailPrint "Exit code $1"
172
+
168
173
  # Set service description
169
174
  DetailPrint "Setting service description..."
170
175
  ExecWait "sc.exe description $\"${SERVICE_NAME}$\" $\"Securely connects local devices to ${COMPANY_NAME} cloud$\"" $1
171
176
  DetailPrint "Exit code $1"
172
177
 
178
+ # Set service to start automatically
179
+ DetailPrint "Setting service to start automatically..."
180
+ ExecWait "sc.exe config $\"${SERVICE_NAME}$\" start= auto" $1
181
+ DetailPrint "Exit code $1"
182
+
173
183
  # Start the service
174
184
  DetailPrint "Starting service..."
175
185
  ExecWait "sc.exe start $\"${SERVICE_NAME}$\"" $1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/agent",
3
- "version": "2.1.14",
3
+ "version": "2.1.15",
4
4
  "description": "Medplum Agent",
5
5
  "homepage": "https://www.medplum.com/",
6
6
  "repository": {