@medplum/agent 4.2.0 → 4.2.2
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 +520 -357
- package/package.json +5 -5
package/dist/cjs/index.cjs
CHANGED
|
@@ -1634,7 +1634,7 @@ var require_dbcs_codec = __commonJS({
|
|
|
1634
1634
|
} else if (4080 < code && code <= 4095) {
|
|
1635
1635
|
var len = 4095 - code + 2;
|
|
1636
1636
|
var seq = [];
|
|
1637
|
-
for (var
|
|
1637
|
+
for (var m = 0; m < len; m++)
|
|
1638
1638
|
seq.push(part.charCodeAt(l3++));
|
|
1639
1639
|
writeTable[curAddr++] = SEQ_START - this.decodeTableSeq.length;
|
|
1640
1640
|
this.decodeTableSeq.push(seq);
|
|
@@ -7947,9 +7947,9 @@ var require_dcmjs = __commonJS({
|
|
|
7947
7947
|
const d_code = (dist2) => {
|
|
7948
7948
|
return dist2 < 256 ? _dist_code[dist2] : _dist_code[256 + (dist2 >>> 7)];
|
|
7949
7949
|
};
|
|
7950
|
-
const put_short = (s,
|
|
7951
|
-
s.pending_buf[s.pending++] =
|
|
7952
|
-
s.pending_buf[s.pending++] =
|
|
7950
|
+
const put_short = (s, w3) => {
|
|
7951
|
+
s.pending_buf[s.pending++] = w3 & 255;
|
|
7952
|
+
s.pending_buf[s.pending++] = w3 >>> 8 & 255;
|
|
7953
7953
|
};
|
|
7954
7954
|
const send_bits = (s, value, length2) => {
|
|
7955
7955
|
if (s.bi_valid > Buf_size - length2) {
|
|
@@ -7999,7 +7999,7 @@ var require_dcmjs = __commonJS({
|
|
|
7999
7999
|
const base = desc.stat_desc.extra_base;
|
|
8000
8000
|
const max_length = desc.stat_desc.max_length;
|
|
8001
8001
|
let h4;
|
|
8002
|
-
let n,
|
|
8002
|
+
let n, m;
|
|
8003
8003
|
let bits;
|
|
8004
8004
|
let xbits;
|
|
8005
8005
|
let f3;
|
|
@@ -8046,13 +8046,13 @@ var require_dcmjs = __commonJS({
|
|
|
8046
8046
|
for (bits = max_length; bits !== 0; bits--) {
|
|
8047
8047
|
n = s.bl_count[bits];
|
|
8048
8048
|
while (n !== 0) {
|
|
8049
|
-
|
|
8050
|
-
if (
|
|
8049
|
+
m = s.heap[--h4];
|
|
8050
|
+
if (m > max_code) {
|
|
8051
8051
|
continue;
|
|
8052
8052
|
}
|
|
8053
|
-
if (tree[
|
|
8054
|
-
s.opt_len += (bits - tree[
|
|
8055
|
-
tree[
|
|
8053
|
+
if (tree[m * 2 + 1] !== bits) {
|
|
8054
|
+
s.opt_len += (bits - tree[m * 2 + 1]) * tree[m * 2];
|
|
8055
|
+
tree[m * 2 + 1] = bits;
|
|
8056
8056
|
}
|
|
8057
8057
|
n--;
|
|
8058
8058
|
}
|
|
@@ -8161,10 +8161,10 @@ var require_dcmjs = __commonJS({
|
|
|
8161
8161
|
s.bi_buf = 0;
|
|
8162
8162
|
s.bi_valid = 0;
|
|
8163
8163
|
};
|
|
8164
|
-
const smaller = (tree, n,
|
|
8164
|
+
const smaller = (tree, n, m, depth) => {
|
|
8165
8165
|
const _n2 = n * 2;
|
|
8166
|
-
const _m2 =
|
|
8167
|
-
return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[
|
|
8166
|
+
const _m2 = m * 2;
|
|
8167
|
+
return tree[_n2] < tree[_m2] || tree[_n2] === tree[_m2] && depth[n] <= depth[m];
|
|
8168
8168
|
};
|
|
8169
8169
|
const pqdownheap = (s, tree, k2) => {
|
|
8170
8170
|
const v3 = s.heap[k2];
|
|
@@ -8221,7 +8221,7 @@ var require_dcmjs = __commonJS({
|
|
|
8221
8221
|
const stree = desc.stat_desc.static_tree;
|
|
8222
8222
|
const has_stree = desc.stat_desc.has_stree;
|
|
8223
8223
|
const elems = desc.stat_desc.elems;
|
|
8224
|
-
let n,
|
|
8224
|
+
let n, m;
|
|
8225
8225
|
let max_code = -1;
|
|
8226
8226
|
let node;
|
|
8227
8227
|
s.heap_len = 0;
|
|
@@ -8263,15 +8263,15 @@ var require_dcmjs = __commonJS({
|
|
|
8263
8263
|
1
|
|
8264
8264
|
/*SMALLEST*/
|
|
8265
8265
|
);
|
|
8266
|
-
|
|
8266
|
+
m = s.heap[
|
|
8267
8267
|
1
|
|
8268
8268
|
/*SMALLEST*/
|
|
8269
8269
|
];
|
|
8270
8270
|
s.heap[--s.heap_max] = n;
|
|
8271
|
-
s.heap[--s.heap_max] =
|
|
8272
|
-
tree[node * 2] = tree[n * 2] + tree[
|
|
8273
|
-
s.depth[node] = (s.depth[n] >= s.depth[
|
|
8274
|
-
tree[n * 2 + 1] = tree[
|
|
8271
|
+
s.heap[--s.heap_max] = m;
|
|
8272
|
+
tree[node * 2] = tree[n * 2] + tree[m * 2];
|
|
8273
|
+
s.depth[node] = (s.depth[n] >= s.depth[m] ? s.depth[n] : s.depth[m]) + 1;
|
|
8274
|
+
tree[n * 2 + 1] = tree[m * 2 + 1] = node;
|
|
8275
8275
|
s.heap[
|
|
8276
8276
|
1
|
|
8277
8277
|
/*SMALLEST*/
|
|
@@ -8671,20 +8671,20 @@ var require_dcmjs = __commonJS({
|
|
|
8671
8671
|
}
|
|
8672
8672
|
};
|
|
8673
8673
|
const slide_hash = (s) => {
|
|
8674
|
-
let n,
|
|
8674
|
+
let n, m;
|
|
8675
8675
|
let p;
|
|
8676
8676
|
let wsize = s.w_size;
|
|
8677
8677
|
n = s.hash_size;
|
|
8678
8678
|
p = n;
|
|
8679
8679
|
do {
|
|
8680
|
-
|
|
8681
|
-
s.head[p] =
|
|
8680
|
+
m = s.head[--p];
|
|
8681
|
+
s.head[p] = m >= wsize ? m - wsize : 0;
|
|
8682
8682
|
} while (--n);
|
|
8683
8683
|
n = wsize;
|
|
8684
8684
|
p = n;
|
|
8685
8685
|
do {
|
|
8686
|
-
|
|
8687
|
-
s.prev[p] =
|
|
8686
|
+
m = s.prev[--p];
|
|
8687
|
+
s.prev[p] = m >= wsize ? m - wsize : 0;
|
|
8688
8688
|
} while (--n);
|
|
8689
8689
|
};
|
|
8690
8690
|
let HASH_ZLIB = (s, prev, data3) => (prev << s.hash_shift ^ data3) & s.hash_mask;
|
|
@@ -14032,8 +14032,8 @@ var require_dcmjs = __commonJS({
|
|
|
14032
14032
|
if (undef) {
|
|
14033
14033
|
var stack = 0;
|
|
14034
14034
|
while (1) {
|
|
14035
|
-
var
|
|
14036
|
-
if (
|
|
14035
|
+
var g3 = stream.readUint16();
|
|
14036
|
+
if (g3 == 65534) {
|
|
14037
14037
|
var ge2 = stream.readUint16();
|
|
14038
14038
|
var itemLength = stream.readUint32();
|
|
14039
14039
|
stream.increment(-4);
|
|
@@ -19469,10 +19469,10 @@ var require_dcmjs = __commonJS({
|
|
|
19469
19469
|
var sharedImageOrientationPatient = SharedFunctionalGroupsSequence.PlaneOrientationSequence ? SharedFunctionalGroupsSequence.PlaneOrientationSequence.ImageOrientationPatient : void 0;
|
|
19470
19470
|
var sliceLength = Columns * Rows;
|
|
19471
19471
|
var arrayBufferLength = sliceLength * imageIds.length * 2;
|
|
19472
|
-
var
|
|
19473
|
-
var
|
|
19474
|
-
var tempBuffer = labelmapBufferArray[
|
|
19475
|
-
var tempSegmentsOnFrame = cloneDeep(segmentsOnFrameArray[
|
|
19472
|
+
var M = 1;
|
|
19473
|
+
var m = 0;
|
|
19474
|
+
var tempBuffer = labelmapBufferArray[m].slice(0);
|
|
19475
|
+
var tempSegmentsOnFrame = cloneDeep(segmentsOnFrameArray[m]);
|
|
19476
19476
|
var numberOfSegs = multiframe.SegmentSequence.length;
|
|
19477
19477
|
for (var segmentIndexToProcess = 1; segmentIndexToProcess <= numberOfSegs; ++segmentIndexToProcess) {
|
|
19478
19478
|
var _loop4 = function _loop42(_i2) {
|
|
@@ -19517,14 +19517,14 @@ var require_dcmjs = __commonJS({
|
|
|
19517
19517
|
for (var j = 0, len2 = alignedPixelDataI.data.length; j < len2; ++j) {
|
|
19518
19518
|
if (data3[j]) {
|
|
19519
19519
|
if (labelmap2DView[j] !== 0) {
|
|
19520
|
-
|
|
19521
|
-
if (
|
|
19522
|
-
labelmapBufferArray[
|
|
19523
|
-
segmentsOnFrameArray[
|
|
19524
|
-
|
|
19520
|
+
m++;
|
|
19521
|
+
if (m >= M) {
|
|
19522
|
+
labelmapBufferArray[m] = new ArrayBuffer(arrayBufferLength);
|
|
19523
|
+
segmentsOnFrameArray[m] = [];
|
|
19524
|
+
M++;
|
|
19525
19525
|
}
|
|
19526
|
-
tempBuffer = labelmapBufferArray[
|
|
19527
|
-
tempSegmentsOnFrame = cloneDeep(segmentsOnFrameArray[
|
|
19526
|
+
tempBuffer = labelmapBufferArray[m].slice(0);
|
|
19527
|
+
tempSegmentsOnFrame = cloneDeep(segmentsOnFrameArray[m]);
|
|
19528
19528
|
_i2 = 0;
|
|
19529
19529
|
break;
|
|
19530
19530
|
} else {
|
|
@@ -19549,11 +19549,11 @@ var require_dcmjs = __commonJS({
|
|
|
19549
19549
|
_ret2 = _loop4(i2);
|
|
19550
19550
|
if (_ret2 === 0) continue;
|
|
19551
19551
|
}
|
|
19552
|
-
labelmapBufferArray[
|
|
19553
|
-
segmentsOnFrameArray[
|
|
19554
|
-
|
|
19555
|
-
tempBuffer = labelmapBufferArray[
|
|
19556
|
-
tempSegmentsOnFrame = cloneDeep(segmentsOnFrameArray[
|
|
19552
|
+
labelmapBufferArray[m] = tempBuffer.slice(0);
|
|
19553
|
+
segmentsOnFrameArray[m] = cloneDeep(tempSegmentsOnFrame);
|
|
19554
|
+
m = 0;
|
|
19555
|
+
tempBuffer = labelmapBufferArray[m].slice(0);
|
|
19556
|
+
tempSegmentsOnFrame = cloneDeep(segmentsOnFrameArray[m]);
|
|
19557
19557
|
}
|
|
19558
19558
|
}
|
|
19559
19559
|
var getSegmentIndex = function getSegmentIndex2(multiframe, frame) {
|
|
@@ -20778,20 +20778,20 @@ var require_dcmjs = __commonJS({
|
|
|
20778
20778
|
out[2] = z2 * scale2;
|
|
20779
20779
|
return out;
|
|
20780
20780
|
}
|
|
20781
|
-
function transformMat4(out, a2,
|
|
20781
|
+
function transformMat4(out, a2, m) {
|
|
20782
20782
|
var x = a2[0], y3 = a2[1], z2 = a2[2];
|
|
20783
|
-
var
|
|
20784
|
-
|
|
20785
|
-
out[0] = (
|
|
20786
|
-
out[1] = (
|
|
20787
|
-
out[2] = (
|
|
20783
|
+
var w3 = m[3] * x + m[7] * y3 + m[11] * z2 + m[15];
|
|
20784
|
+
w3 = w3 || 1;
|
|
20785
|
+
out[0] = (m[0] * x + m[4] * y3 + m[8] * z2 + m[12]) / w3;
|
|
20786
|
+
out[1] = (m[1] * x + m[5] * y3 + m[9] * z2 + m[13]) / w3;
|
|
20787
|
+
out[2] = (m[2] * x + m[6] * y3 + m[10] * z2 + m[14]) / w3;
|
|
20788
20788
|
return out;
|
|
20789
20789
|
}
|
|
20790
|
-
function transformMat3(out, a2,
|
|
20790
|
+
function transformMat3(out, a2, m) {
|
|
20791
20791
|
var x = a2[0], y3 = a2[1], z2 = a2[2];
|
|
20792
|
-
out[0] = x *
|
|
20793
|
-
out[1] = x *
|
|
20794
|
-
out[2] = x *
|
|
20792
|
+
out[0] = x * m[0] + y3 * m[3] + z2 * m[6];
|
|
20793
|
+
out[1] = x * m[1] + y3 * m[4] + z2 * m[7];
|
|
20794
|
+
out[2] = x * m[2] + y3 * m[5] + z2 * m[8];
|
|
20795
20795
|
return out;
|
|
20796
20796
|
}
|
|
20797
20797
|
function transformQuat(out, a2, q2) {
|
|
@@ -20799,10 +20799,10 @@ var require_dcmjs = __commonJS({
|
|
|
20799
20799
|
var x = a2[0], y3 = a2[1], z2 = a2[2];
|
|
20800
20800
|
var uvx = qy * z2 - qz * y3, uvy = qz * x - qx * z2, uvz = qx * y3 - qy * x;
|
|
20801
20801
|
var uuvx = qy * uvz - qz * uvy, uuvy = qz * uvx - qx * uvz, uuvz = qx * uvy - qy * uvx;
|
|
20802
|
-
var
|
|
20803
|
-
uvx *=
|
|
20804
|
-
uvy *=
|
|
20805
|
-
uvz *=
|
|
20802
|
+
var w22 = qw * 2;
|
|
20803
|
+
uvx *= w22;
|
|
20804
|
+
uvy *= w22;
|
|
20805
|
+
uvz *= w22;
|
|
20806
20806
|
uuvx *= 2;
|
|
20807
20807
|
uuvy *= 2;
|
|
20808
20808
|
uuvz *= 2;
|
|
@@ -26162,7 +26162,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26162
26162
|
"use strict";
|
|
26163
26163
|
e.exports = __WEBPACK_EXTERNAL_MODULE__111__;
|
|
26164
26164
|
}, 190: (e, t, r6) => {
|
|
26165
|
-
const { Implementation: s, StorageClass: o, TranscodeMap: i2, TransferSyntax: n } = r6(492), { Codec: a2 } = r6(258), l3 = r6(111), { DicomDict: c, DicomMessage: d3, DicomMetaDictionary: p, ReadBufferStream: h3, WriteBufferStream:
|
|
26165
|
+
const { Implementation: s, StorageClass: o, TranscodeMap: i2, TransferSyntax: n } = r6(492), { Codec: a2 } = r6(258), l3 = r6(111), { DicomDict: c, DicomMessage: d3, DicomMetaDictionary: p, ReadBufferStream: h3, WriteBufferStream: m } = l3.data, u2 = l3.log;
|
|
26166
26166
|
e.exports = class {
|
|
26167
26167
|
constructor(e2, t2, r7 = {}) {
|
|
26168
26168
|
r7 = { ignoreErrors: true, ...r7 }, u2.level = "error", this.transferSyntaxUid = t2 || n.ImplicitVRLittleEndian, e2 instanceof ArrayBuffer ? t2 ? this._fromElementsBuffer(e2, t2, r7) : this._fromP10Buffer(e2) : this.elements = e2 || {};
|
|
@@ -26195,7 +26195,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26195
26195
|
}
|
|
26196
26196
|
getDicomDataset(e2, t2) {
|
|
26197
26197
|
e2 = { fragmentMultiframe: false, ...e2 };
|
|
26198
|
-
const r7 = t2 ? p.denaturalizeDataset(this.getElements(), { ...p.nameMap, ...t2 }) : p.denaturalizeDataset(this.getElements()), s2 = new
|
|
26198
|
+
const r7 = t2 ? p.denaturalizeDataset(this.getElements(), { ...p.nameMap, ...t2 }) : p.denaturalizeDataset(this.getElements()), s2 = new m();
|
|
26199
26199
|
return d3.write(r7, s2, this.transferSyntaxUid, e2), s2.getBuffer();
|
|
26200
26200
|
}
|
|
26201
26201
|
getDicomPart10(e2, t2) {
|
|
@@ -26256,7 +26256,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26256
26256
|
}
|
|
26257
26257
|
function h3(e3, r8) {
|
|
26258
26258
|
var n2, a3, l4, d4 = this, h4 = "loglevel";
|
|
26259
|
-
function
|
|
26259
|
+
function m2(e4) {
|
|
26260
26260
|
var r9 = (s2[e4] || "silent").toUpperCase();
|
|
26261
26261
|
if (typeof window !== t2 && h4) {
|
|
26262
26262
|
try {
|
|
@@ -26284,7 +26284,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26284
26284
|
return void 0 === d4.levels[e4] && (e4 = void 0), e4;
|
|
26285
26285
|
}
|
|
26286
26286
|
}
|
|
26287
|
-
function
|
|
26287
|
+
function g3() {
|
|
26288
26288
|
if (typeof window !== t2 && h4) {
|
|
26289
26289
|
try {
|
|
26290
26290
|
window.localStorage.removeItem(h4);
|
|
@@ -26304,11 +26304,11 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26304
26304
|
"string" == typeof e3 ? h4 += ":" + e3 : "symbol" == typeof e3 && (h4 = void 0), d4.name = e3, d4.levels = { TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, SILENT: 5 }, d4.methodFactory = r8 || p, d4.getLevel = function() {
|
|
26305
26305
|
return null != l4 ? l4 : null != a3 ? a3 : n2;
|
|
26306
26306
|
}, d4.setLevel = function(e4, t3) {
|
|
26307
|
-
return l4 = f3(e4), false !== t3 &&
|
|
26307
|
+
return l4 = f3(e4), false !== t3 && m2(l4), c.call(d4);
|
|
26308
26308
|
}, d4.setDefaultLevel = function(e4) {
|
|
26309
26309
|
a3 = f3(e4), u2() || d4.setLevel(e4, false);
|
|
26310
26310
|
}, d4.resetLevel = function() {
|
|
26311
|
-
l4 = null,
|
|
26311
|
+
l4 = null, g3(), c.call(d4);
|
|
26312
26312
|
}, d4.enableAll = function(e4) {
|
|
26313
26313
|
d4.setLevel(d4.levels.TRACE, e4);
|
|
26314
26314
|
}, d4.disableAll = function(e4) {
|
|
@@ -26316,17 +26316,17 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26316
26316
|
}, d4.rebuild = function() {
|
|
26317
26317
|
if (i2 !== d4 && (n2 = f3(i2.getLevel())), c.call(d4), i2 === d4) for (var e4 in o2) o2[e4].rebuild();
|
|
26318
26318
|
}, n2 = f3(i2 ? i2.getLevel() : "WARN");
|
|
26319
|
-
var
|
|
26320
|
-
null !=
|
|
26319
|
+
var w3 = u2();
|
|
26320
|
+
null != w3 && (l4 = f3(w3)), c.call(d4);
|
|
26321
26321
|
}
|
|
26322
26322
|
(i2 = new h3()).getLogger = function(e3) {
|
|
26323
26323
|
if ("symbol" != typeof e3 && "string" != typeof e3 || "" === e3) throw new TypeError("You must supply a name when creating a logger.");
|
|
26324
26324
|
var t3 = o2[e3];
|
|
26325
26325
|
return t3 || (t3 = o2[e3] = new h3(e3, i2.methodFactory)), t3;
|
|
26326
26326
|
};
|
|
26327
|
-
var
|
|
26327
|
+
var m = typeof window !== t2 ? window.log : void 0;
|
|
26328
26328
|
return i2.noConflict = function() {
|
|
26329
|
-
return typeof window !== t2 && window.log === i2 && (window.log =
|
|
26329
|
+
return typeof window !== t2 && window.log === i2 && (window.log = m), i2;
|
|
26330
26330
|
}, i2.getLoggers = function() {
|
|
26331
26331
|
return o2;
|
|
26332
26332
|
}, i2.default = i2, i2;
|
|
@@ -26422,11 +26422,11 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26422
26422
|
}
|
|
26423
26423
|
e.exports = o;
|
|
26424
26424
|
}, 237: (e, t, r6) => {
|
|
26425
|
-
const { Codec: s, ExplicitVRBigEndianCodec: o, ExplicitVRLittleEndianCodec: i2, HtJpeg2000LosslessCodec: n, HtJpeg2000LosslessRpclCodec: a2, HtJpeg2000LossyCodec: l3, ImplicitVRLittleEndianCodec: c, Jpeg2000LosslessCodec: d3, Jpeg2000LossyCodec: p, JpegBaselineProcess1Codec: h3, JpegLosslessProcess14V1Codec:
|
|
26425
|
+
const { Codec: s, ExplicitVRBigEndianCodec: o, ExplicitVRLittleEndianCodec: i2, HtJpeg2000LosslessCodec: n, HtJpeg2000LosslessRpclCodec: a2, HtJpeg2000LossyCodec: l3, ImplicitVRLittleEndianCodec: c, Jpeg2000LosslessCodec: d3, Jpeg2000LossyCodec: p, JpegBaselineProcess1Codec: h3, JpegLosslessProcess14V1Codec: m, JpegLsLosslessCodec: u2, JpegLsLossyCodec: g3, RleLosslessCodec: f3 } = r6(258), { Jpeg2000ProgressionOrder: w3, JpegSampleFactor: P, PhotometricInterpretation: y3, PixelRepresentation: x, PlanarConfiguration: C2, TransferSyntax: b2 } = r6(492), _2 = r6(234), I2 = r6(25), A2 = r6(190), S2 = { codecs: { Codec: s, ExplicitVRBigEndianCodec: o, ExplicitVRLittleEndianCodec: i2, HtJpeg2000LosslessCodec: n, HtJpeg2000LosslessRpclCodec: a2, HtJpeg2000LossyCodec: l3, ImplicitVRLittleEndianCodec: c, Jpeg2000LosslessCodec: d3, Jpeg2000LossyCodec: p, JpegBaselineProcess1Codec: h3, JpegLosslessProcess14V1Codec: m, JpegLsLosslessCodec: u2, JpegLsLossyCodec: g3, RleLosslessCodec: f3 }, constants: { Jpeg2000ProgressionOrder: w3, JpegSampleFactor: P, PhotometricInterpretation: y3, PixelRepresentation: x, PlanarConfiguration: C2, TransferSyntax: b2 }, Context: _2, log: r6(547), NativeCodecs: I2, Transcoder: A2, version: r6(837) };
|
|
26426
26426
|
e.exports = S2;
|
|
26427
26427
|
}, 258: (e, t, r6) => {
|
|
26428
26428
|
const { Jpeg2000ProgressionOrder: s, JpegSampleFactor: o, PhotometricInterpretation: i2, PlanarConfiguration: n, TransferSyntax: a2 } = r6(492), { FrameConverter: l3, Frames: c } = r6(859), d3 = r6(234), p = r6(25), h3 = r6(984);
|
|
26429
|
-
class
|
|
26429
|
+
class m {
|
|
26430
26430
|
encode(e2, t2, r7 = {}) {
|
|
26431
26431
|
throw new Error("encode should be implemented");
|
|
26432
26432
|
}
|
|
@@ -26434,7 +26434,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26434
26434
|
throw new Error("decode should be implemented");
|
|
26435
26435
|
}
|
|
26436
26436
|
static getCodec(e2) {
|
|
26437
|
-
const t2 = { [a2.ImplicitVRLittleEndian]: u2, [a2.ExplicitVRLittleEndian]:
|
|
26437
|
+
const t2 = { [a2.ImplicitVRLittleEndian]: u2, [a2.ExplicitVRLittleEndian]: g3, [a2.ExplicitVRBigEndian]: f3, [a2.RleLossless]: w3, [a2.JpegBaselineProcess1]: y3, [a2.JpegLosslessProcess14V1]: x, [a2.JpegLsLossless]: b2, [a2.JpegLsLossy]: _2, [a2.Jpeg2000Lossless]: A2, [a2.Jpeg2000Lossy]: S2, [a2.HtJpeg2000Lossless]: E2, [a2.HtJpeg2000LosslessRpcl]: v2, [a2.HtJpeg2000Lossy]: B2 }[e2];
|
|
26438
26438
|
if (!t2) throw new Error(`Codec for transfer syntax UID ${e2} is not implemented`);
|
|
26439
26439
|
return new t2();
|
|
26440
26440
|
}
|
|
@@ -26445,9 +26445,9 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26445
26445
|
s2.unpackLow16 && (i4 = l3.unpackLow16(i4)), s2.convertYbrFullToRgb && (i4 = l3.ybrFullToRgb(i4)), s2.convertYbrFull422ToRgb && (i4 = l3.ybrFull422ToRgb(i4, o2.getWidth())), s2.updatePlanarConfiguration && (i4 = l3.changePlanarConfiguration(i4, e2.BitsAllocated, e2.SamplesPerPixel, n.Planar));
|
|
26446
26446
|
const c2 = d3.fromDicomElements(e2);
|
|
26447
26447
|
c2.setDecodedBuffer(i4);
|
|
26448
|
-
const
|
|
26449
|
-
let u3 =
|
|
26450
|
-
u3.length % 2 != 0 && (u3 = h3.concatBuffers([u3, Uint8Array.from([0])])), a3.push(u3.buffer.slice(u3.byteOffset, u3.byteOffset + u3.byteLength)), Object.assign(e2,
|
|
26448
|
+
const m2 = p[r7](c2, s2);
|
|
26449
|
+
let u3 = m2.getEncodedBuffer();
|
|
26450
|
+
u3.length % 2 != 0 && (u3 = h3.concatBuffers([u3, Uint8Array.from([0])])), a3.push(u3.buffer.slice(u3.byteOffset, u3.byteOffset + u3.byteLength)), Object.assign(e2, m2.toDicomElements());
|
|
26451
26451
|
}
|
|
26452
26452
|
return e2._vrMap = { PixelData: 1 === o2.getBytesAllocated() ? "OB" : "OW" }, e2.PixelData = a3, e2;
|
|
26453
26453
|
}
|
|
@@ -26456,14 +26456,14 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26456
26456
|
for (let t3 = 0; t3 < i3; t3++) {
|
|
26457
26457
|
const i4 = o2.getFrameBuffer(t3), c2 = d3.fromDicomElements(e2);
|
|
26458
26458
|
c2.setEncodedBuffer(i4);
|
|
26459
|
-
const
|
|
26460
|
-
let u3 =
|
|
26461
|
-
u3.length % 2 != 0 && (u3 = h3.concatBuffers([u3, Uint8Array.from([0])])), s2.updatePlanarConfiguration && (u3 = l3.changePlanarConfiguration(u3, e2.BitsAllocated, e2.SamplesPerPixel, n.Interleaved)), a3.push(u3.buffer.slice(u3.byteOffset, u3.byteOffset + u3.byteLength)), Object.assign(e2,
|
|
26459
|
+
const m2 = p[r7](c2, s2);
|
|
26460
|
+
let u3 = m2.getDecodedBuffer();
|
|
26461
|
+
u3.length % 2 != 0 && (u3 = h3.concatBuffers([u3, Uint8Array.from([0])])), s2.updatePlanarConfiguration && (u3 = l3.changePlanarConfiguration(u3, e2.BitsAllocated, e2.SamplesPerPixel, n.Interleaved)), a3.push(u3.buffer.slice(u3.byteOffset, u3.byteOffset + u3.byteLength)), Object.assign(e2, m2.toDicomElements());
|
|
26462
26462
|
}
|
|
26463
26463
|
return e2._vrMap = { PixelData: 1 === o2.getBytesAllocated() ? "OB" : "OW" }, e2.PixelData = [h3.concatBuffers(a3)], e2;
|
|
26464
26464
|
}
|
|
26465
26465
|
}
|
|
26466
|
-
class u2 extends
|
|
26466
|
+
class u2 extends m {
|
|
26467
26467
|
encode(e2, t2, r7 = {}) {
|
|
26468
26468
|
return e2;
|
|
26469
26469
|
}
|
|
@@ -26471,7 +26471,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26471
26471
|
return e2;
|
|
26472
26472
|
}
|
|
26473
26473
|
}
|
|
26474
|
-
class
|
|
26474
|
+
class g3 extends m {
|
|
26475
26475
|
encode(e2, t2, r7 = {}) {
|
|
26476
26476
|
return e2;
|
|
26477
26477
|
}
|
|
@@ -26479,7 +26479,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26479
26479
|
return e2;
|
|
26480
26480
|
}
|
|
26481
26481
|
}
|
|
26482
|
-
class f3 extends
|
|
26482
|
+
class f3 extends m {
|
|
26483
26483
|
encode(e2, t2, r7 = {}) {
|
|
26484
26484
|
return this._swapPixelData(e2, t2);
|
|
26485
26485
|
}
|
|
@@ -26499,7 +26499,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26499
26499
|
return e2._vrMap = { PixelData: 1 === r7.getBytesAllocated() ? "OB" : "OW" }, e2.PixelData = [h3.concatBuffers(o2)], e2;
|
|
26500
26500
|
}
|
|
26501
26501
|
}
|
|
26502
|
-
class
|
|
26502
|
+
class w3 extends m {
|
|
26503
26503
|
encode(e2, t2, r7 = {}) {
|
|
26504
26504
|
return this._baseEncodeImpl(e2, t2, "encodeRle", r7);
|
|
26505
26505
|
}
|
|
@@ -26507,7 +26507,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26507
26507
|
return this._baseDecodeImpl(e2, t2, "decodeRle", r7);
|
|
26508
26508
|
}
|
|
26509
26509
|
}
|
|
26510
|
-
class P extends
|
|
26510
|
+
class P extends m {
|
|
26511
26511
|
encode(e2, t2, r7 = {}) {
|
|
26512
26512
|
const s2 = { ...r7 };
|
|
26513
26513
|
if (e2.PhotometricInterpretation === i2.YbrIct || e2.PhotometricInterpretation === i2.YbrRct) throw new Error(`Photometric Interpretation ${e2.PhotometricInterpretation} not supported by JPEG encoder`);
|
|
@@ -26547,7 +26547,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26547
26547
|
return super.decode(e2, t2, r7);
|
|
26548
26548
|
}
|
|
26549
26549
|
}
|
|
26550
|
-
class C2 extends
|
|
26550
|
+
class C2 extends m {
|
|
26551
26551
|
encode(e2, t2, r7 = {}) {
|
|
26552
26552
|
const s2 = { ...r7 };
|
|
26553
26553
|
if (e2.PhotometricInterpretation === i2.YbrPartial422 || e2.PhotometricInterpretation === i2.YbrPartial420) throw new Error(`Photometric Interpretation ${e2.PhotometricInterpretation} not supported by JPEG-LS encoder`);
|
|
@@ -26586,7 +26586,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26586
26586
|
return super.decode(e2, t2, r7);
|
|
26587
26587
|
}
|
|
26588
26588
|
}
|
|
26589
|
-
class I2 extends
|
|
26589
|
+
class I2 extends m {
|
|
26590
26590
|
encode(e2, t2, r7, s2 = {}) {
|
|
26591
26591
|
const o2 = { ...s2 };
|
|
26592
26592
|
if (e2.PhotometricInterpretation === i2.YbrPartial422 || e2.PhotometricInterpretation === i2.YbrPartial420) throw new Error(`Photometric Interpretation ${e2.PhotometricInterpretation} not supported by JPEG 2000 encoder`);
|
|
@@ -26650,7 +26650,7 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26650
26650
|
return super.decode(e2, t2, "decodeHtJpeg2000", r7);
|
|
26651
26651
|
}
|
|
26652
26652
|
}
|
|
26653
|
-
e.exports = { Codec:
|
|
26653
|
+
e.exports = { Codec: m, ExplicitVRBigEndianCodec: f3, ExplicitVRLittleEndianCodec: g3, HtJpeg2000LosslessCodec: E2, HtJpeg2000LosslessRpclCodec: v2, HtJpeg2000LossyCodec: B2, ImplicitVRLittleEndianCodec: u2, Jpeg2000LosslessCodec: A2, Jpeg2000LossyCodec: S2, JpegBaselineProcess1Codec: y3, JpegLosslessProcess14V1Codec: x, JpegLsLosslessCodec: b2, JpegLsLossyCodec: _2, RleLosslessCodec: w3 };
|
|
26654
26654
|
}, 492: (e) => {
|
|
26655
26655
|
const t = { ImplicitVRLittleEndian: "1.2.840.10008.1.2", ExplicitVRLittleEndian: "1.2.840.10008.1.2.1", ExplicitVRBigEndian: "1.2.840.10008.1.2.2", RleLossless: "1.2.840.10008.1.2.5", JpegBaselineProcess1: "1.2.840.10008.1.2.4.50", JpegLosslessProcess14V1: "1.2.840.10008.1.2.4.70", JpegLsLossless: "1.2.840.10008.1.2.4.80", JpegLsLossy: "1.2.840.10008.1.2.4.81", Jpeg2000Lossless: "1.2.840.10008.1.2.4.90", Jpeg2000Lossy: "1.2.840.10008.1.2.4.91", JpegXlLossless: "1.2.840.10008.1.2.4.110", JpegXlRecompression: "1.2.840.10008.1.2.4.111", JpegXl: "1.2.840.10008.1.2.4.112", HtJpeg2000Lossless: "1.2.840.10008.1.2.4.201", HtJpeg2000LosslessRpcl: "1.2.840.10008.1.2.4.202", HtJpeg2000Lossy: "1.2.840.10008.1.2.4.203" };
|
|
26656
26656
|
Object.freeze(t);
|
|
@@ -26833,8 +26833,8 @@ var require_dcmjs_codecs_min = __commonJS({
|
|
|
26833
26833
|
return function() {
|
|
26834
26834
|
for (var t4 = "", n3 = arguments.length, p = Array(n3), h3 = 0; h3 < n3; h3++) p[h3] = arguments[h3];
|
|
26835
26835
|
if (a3 || !i2[r9]) {
|
|
26836
|
-
var
|
|
26837
|
-
o3.format ? t4 += o3.format(u2,
|
|
26836
|
+
var m = o3.timestampFormatter(/* @__PURE__ */ new Date()), u2 = o3.levelFormatter(e4), g3 = o3.nameFormatter(r9);
|
|
26837
|
+
o3.format ? t4 += o3.format(u2, g3, m) : (t4 += o3.template, l4 && (t4 = t4.replace(/%t/, m)), c2 && (t4 = t4.replace(/%l/, u2)), d3 && (t4 = t4.replace(/%n/, g3))), p.length && "string" == typeof p[0] ? p[0] = t4 + " " + p[0] : p.unshift(t4);
|
|
26838
26838
|
}
|
|
26839
26839
|
s3.apply(void 0, p);
|
|
26840
26840
|
};
|
|
@@ -27937,23 +27937,23 @@ var require_AsyncEventEmitter = __commonJS({
|
|
|
27937
27937
|
return self2;
|
|
27938
27938
|
};
|
|
27939
27939
|
AsyncEventEmitter.prototype.once = function(type, listener) {
|
|
27940
|
-
var self2 = this,
|
|
27940
|
+
var self2 = this, g3;
|
|
27941
27941
|
if (typeof listener !== "function") {
|
|
27942
27942
|
throw new TypeError("listener must be a function");
|
|
27943
27943
|
}
|
|
27944
27944
|
if (listener.length >= 2) {
|
|
27945
|
-
|
|
27946
|
-
self2.removeListener(type,
|
|
27945
|
+
g3 = function(e, next) {
|
|
27946
|
+
self2.removeListener(type, g3);
|
|
27947
27947
|
listener(e, next);
|
|
27948
27948
|
};
|
|
27949
27949
|
} else {
|
|
27950
|
-
|
|
27951
|
-
self2.removeListener(type,
|
|
27950
|
+
g3 = function(e) {
|
|
27951
|
+
self2.removeListener(type, g3);
|
|
27952
27952
|
listener(e);
|
|
27953
27953
|
};
|
|
27954
27954
|
}
|
|
27955
|
-
|
|
27956
|
-
self2.on(type,
|
|
27955
|
+
g3.listener = listener;
|
|
27956
|
+
self2.on(type, g3);
|
|
27957
27957
|
return self2;
|
|
27958
27958
|
};
|
|
27959
27959
|
AsyncEventEmitter.prototype.first = function(event, listener) {
|
|
@@ -29305,7 +29305,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29305
29305
|
"use strict";
|
|
29306
29306
|
e2.exports = t;
|
|
29307
29307
|
}, 237: (e2, t2, s2) => {
|
|
29308
|
-
const { Association: n2, PresentationContext: i3 } = s2(570), { Scp: r7, Server: a3 } = s2(538), { CCancelRequest: o2, CEchoRequest: c2, CEchoResponse: d4, CFindRequest: u2, CFindResponse: h3, CGetRequest:
|
|
29308
|
+
const { Association: n2, PresentationContext: i3 } = s2(570), { Scp: r7, Server: a3 } = s2(538), { CCancelRequest: o2, CEchoRequest: c2, CEchoResponse: d4, CFindRequest: u2, CFindResponse: h3, CGetRequest: m, CGetResponse: g3, CMoveRequest: l3, CMoveResponse: p, CStoreRequest: R2, CStoreResponse: S2, NActionRequest: y3, NActionResponse: f3, NCreateRequest: I2, NCreateResponse: C2, NDeleteRequest: P, NDeleteResponse: A2, NEventReportRequest: v2, NEventReportResponse: x, NGetRequest: w3, NGetResponse: U, NSetRequest: q2, NSetResponse: D2 } = s2(940), { AbortReason: E2, AbortSource: T, CommandFieldType: b2, PresentationContextResult: O2, Priority: N2, RawPduType: M, RejectReason: B2, RejectResult: L2, RejectSource: F2, SopClass: k2, Status: $, StorageClass: j, TransferSyntax: V2, Uid: _2, UserIdentityType: G2 } = s2(492), z2 = s2(422), Q2 = s2(825), W2 = s2(139), J2 = s2(906), X2 = s2(73), H = { association: { Association: n2, PresentationContext: i3 }, Client: z2, constants: { AbortReason: E2, AbortSource: T, CommandFieldType: b2, PresentationContextResult: O2, Priority: N2, RawPduType: M, RejectReason: B2, RejectResult: L2, RejectSource: F2, SopClass: k2, Status: $, StorageClass: j, TransferSyntax: V2, Uid: _2, UserIdentityType: G2 }, Dataset: Q2, Implementation: W2, log: s2(547), requests: { CCancelRequest: o2, CEchoRequest: c2, CFindRequest: u2, CGetRequest: m, CMoveRequest: l3, CStoreRequest: R2, NActionRequest: y3, NCreateRequest: I2, NDeleteRequest: P, NEventReportRequest: v2, NGetRequest: w3, NSetRequest: q2 }, responses: { CEchoResponse: d4, CFindResponse: h3, CGetResponse: g3, CMoveResponse: p, CStoreResponse: S2, NActionResponse: f3, NCreateResponse: C2, NDeleteResponse: A2, NEventReportResponse: x, NGetResponse: U, NSetResponse: D2 }, Scp: r7, Server: a3, Statistics: J2, Transcoding: X2, version: s2(837) };
|
|
29309
29309
|
e2.exports = H;
|
|
29310
29310
|
}, 278: (e2) => {
|
|
29311
29311
|
"use strict";
|
|
@@ -29314,7 +29314,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29314
29314
|
"use strict";
|
|
29315
29315
|
e2.exports = s;
|
|
29316
29316
|
}, 371: (e2, t2, s2) => {
|
|
29317
|
-
const { Association: n2 } = s2(570), { AAbort: i3, AAssociateAC: r7, AAssociateRJ: a3, AAssociateRQ: o2, AReleaseRP: c2, AReleaseRQ: d4, PDataTF: u2, Pdv: h3, RawPdu:
|
|
29317
|
+
const { Association: n2 } = s2(570), { AAbort: i3, AAssociateAC: r7, AAssociateRJ: a3, AAssociateRQ: o2, AReleaseRP: c2, AReleaseRQ: d4, PDataTF: u2, Pdv: h3, RawPdu: m } = s2(942), { CommandFieldType: g3, RawPduType: l3, Status: p } = s2(492), { CCancelRequest: R2, CEchoRequest: S2, CEchoResponse: y3, CFindRequest: f3, CFindResponse: I2, CGetRequest: C2, CGetResponse: P, CMoveRequest: A2, CMoveResponse: v2, Command: x, CStoreRequest: w3, CStoreResponse: U, NActionRequest: q2, NActionResponse: D2, NCreateRequest: E2, NCreateResponse: T, NDeleteRequest: b2, NDeleteResponse: O2, NEventReportRequest: N2, NEventReportResponse: M, NGetRequest: B2, NGetResponse: L2, NSetRequest: F2, NSetResponse: k2, Response: $ } = s2(940), j = s2(825), V2 = s2(139), _2 = s2(906), G2 = s2(73), z2 = s2(547), { SmartBuffer: Q2 } = s2(766), { EOL: W2 } = s2(857), J2 = s2(733), X2 = s2(235);
|
|
29318
29318
|
class H extends J2 {
|
|
29319
29319
|
constructor() {
|
|
29320
29320
|
super();
|
|
@@ -29422,7 +29422,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29422
29422
|
if (!t3) return void this.emit("done");
|
|
29423
29423
|
const s3 = this.association.getAcceptedPresentationContextFromRequest(t3);
|
|
29424
29424
|
if (s3) {
|
|
29425
|
-
t3 instanceof
|
|
29425
|
+
t3 instanceof w3 && t3.loadFullDatasetIfNeeded(), t3.setMessageId(this._getNextMessageId()), this.pending.push(t3);
|
|
29426
29426
|
const n3 = { context: s3, command: t3 };
|
|
29427
29427
|
n3.command.on("done", () => {
|
|
29428
29428
|
e3();
|
|
@@ -29468,7 +29468,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29468
29468
|
}
|
|
29469
29469
|
}
|
|
29470
29470
|
async _processPdu(e3) {
|
|
29471
|
-
const t3 = new
|
|
29471
|
+
const t3 = new m(e3);
|
|
29472
29472
|
try {
|
|
29473
29473
|
switch (t3.readPdu(), t3.getType()) {
|
|
29474
29474
|
case l3.AAssociateRQ:
|
|
@@ -29513,76 +29513,76 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29513
29513
|
const s3 = e3.getPdvs();
|
|
29514
29514
|
for (let e4 = 0; e4 < s3.length; e4++) {
|
|
29515
29515
|
const n3 = s3[e4], i4 = this.association.getPresentationContext(n3.getPresentationContextId());
|
|
29516
|
-
if (this.dimse && this.dimse.getCommandFieldType() ===
|
|
29516
|
+
if (this.dimse && this.dimse.getCommandFieldType() === g3.CStoreRequest ? this.dimseStoreStream || (this.dimseStream = void 0, this.dimseStoreStream = this.createStoreWritableStream(i4, this.dimse), t3 = new Promise((e5) => this.dimseStoreStream.once("drain", e5))) : this.dimseStream || (this.dimseStream = X2.createWriteStream(), this.dimseStoreStream = void 0), !(this.dimseStream || this.dimseStoreStream).write(n3.getValue()) && t3 && await t3, n3.isLastFragment()) if (n3.isCommand()) {
|
|
29517
29517
|
const e5 = new x(new j(this.dimseStream.toBuffer()));
|
|
29518
29518
|
switch (e5.getCommandFieldType()) {
|
|
29519
|
-
case
|
|
29519
|
+
case g3.CEchoRequest:
|
|
29520
29520
|
this.dimse = Object.assign(new S2(), e5);
|
|
29521
29521
|
break;
|
|
29522
|
-
case
|
|
29522
|
+
case g3.CEchoResponse:
|
|
29523
29523
|
this.dimse = Object.assign(new y3(), e5);
|
|
29524
29524
|
break;
|
|
29525
|
-
case
|
|
29525
|
+
case g3.CFindRequest:
|
|
29526
29526
|
this.dimse = Object.assign(new f3(), e5);
|
|
29527
29527
|
break;
|
|
29528
|
-
case
|
|
29528
|
+
case g3.CFindResponse:
|
|
29529
29529
|
this.dimse = Object.assign(new I2(), e5);
|
|
29530
29530
|
break;
|
|
29531
|
-
case
|
|
29532
|
-
this.dimse = Object.assign(new
|
|
29531
|
+
case g3.CStoreRequest:
|
|
29532
|
+
this.dimse = Object.assign(new w3(), e5);
|
|
29533
29533
|
break;
|
|
29534
|
-
case
|
|
29534
|
+
case g3.CStoreResponse:
|
|
29535
29535
|
this.dimse = Object.assign(new U(), e5);
|
|
29536
29536
|
break;
|
|
29537
|
-
case
|
|
29537
|
+
case g3.CMoveRequest:
|
|
29538
29538
|
this.dimse = Object.assign(new A2(), e5);
|
|
29539
29539
|
break;
|
|
29540
|
-
case
|
|
29540
|
+
case g3.CMoveResponse:
|
|
29541
29541
|
this.dimse = Object.assign(new v2(), e5);
|
|
29542
29542
|
break;
|
|
29543
|
-
case
|
|
29543
|
+
case g3.CGetRequest:
|
|
29544
29544
|
this.dimse = Object.assign(new C2(), e5);
|
|
29545
29545
|
break;
|
|
29546
|
-
case
|
|
29546
|
+
case g3.CGetResponse:
|
|
29547
29547
|
this.dimse = Object.assign(new P(), e5);
|
|
29548
29548
|
break;
|
|
29549
|
-
case
|
|
29549
|
+
case g3.NCreateRequest:
|
|
29550
29550
|
this.dimse = Object.assign(new E2(), e5);
|
|
29551
29551
|
break;
|
|
29552
|
-
case
|
|
29552
|
+
case g3.NCreateResponse:
|
|
29553
29553
|
this.dimse = Object.assign(new T(), e5);
|
|
29554
29554
|
break;
|
|
29555
|
-
case
|
|
29555
|
+
case g3.NActionRequest:
|
|
29556
29556
|
this.dimse = Object.assign(new q2(), e5);
|
|
29557
29557
|
break;
|
|
29558
|
-
case
|
|
29558
|
+
case g3.NActionResponse:
|
|
29559
29559
|
this.dimse = Object.assign(new D2(), e5);
|
|
29560
29560
|
break;
|
|
29561
|
-
case
|
|
29561
|
+
case g3.NDeleteRequest:
|
|
29562
29562
|
this.dimse = Object.assign(new b2(), e5);
|
|
29563
29563
|
break;
|
|
29564
|
-
case
|
|
29564
|
+
case g3.NDeleteResponse:
|
|
29565
29565
|
this.dimse = Object.assign(new O2(), e5);
|
|
29566
29566
|
break;
|
|
29567
|
-
case
|
|
29567
|
+
case g3.NEventReportRequest:
|
|
29568
29568
|
this.dimse = Object.assign(new N2(), e5);
|
|
29569
29569
|
break;
|
|
29570
|
-
case
|
|
29571
|
-
this.dimse = Object.assign(new
|
|
29570
|
+
case g3.NEventReportResponse:
|
|
29571
|
+
this.dimse = Object.assign(new M(), e5);
|
|
29572
29572
|
break;
|
|
29573
|
-
case
|
|
29573
|
+
case g3.NGetRequest:
|
|
29574
29574
|
this.dimse = Object.assign(new B2(), e5);
|
|
29575
29575
|
break;
|
|
29576
|
-
case
|
|
29576
|
+
case g3.NGetResponse:
|
|
29577
29577
|
this.dimse = Object.assign(new L2(), e5);
|
|
29578
29578
|
break;
|
|
29579
|
-
case
|
|
29579
|
+
case g3.NSetRequest:
|
|
29580
29580
|
this.dimse = Object.assign(new F2(), e5);
|
|
29581
29581
|
break;
|
|
29582
|
-
case
|
|
29582
|
+
case g3.NSetResponse:
|
|
29583
29583
|
this.dimse = Object.assign(new k2(), e5);
|
|
29584
29584
|
break;
|
|
29585
|
-
case
|
|
29585
|
+
case g3.CCancelRequest:
|
|
29586
29586
|
this.dimse = Object.assign(new R2(), e5);
|
|
29587
29587
|
break;
|
|
29588
29588
|
default:
|
|
@@ -29590,7 +29590,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29590
29590
|
}
|
|
29591
29591
|
if (z2.info(`${this.logId} <- ${this.dimse.toString({ includeCommandDataset: this.logCommandDatasets, includeDataset: this.logDatasets })} [pc: ${n3.getPresentationContextId()}]`), !this.dimse.hasDataset()) return this._performDimse(i4, this.dimse), void (this.dimse = void 0);
|
|
29592
29592
|
this.dimseStream = void 0, this.dimseStoreStream = void 0;
|
|
29593
|
-
} else if (this.dimse.getCommandFieldType() ===
|
|
29593
|
+
} else if (this.dimse.getCommandFieldType() === g3.CStoreRequest) this.dimseStoreStream.end(), this.createDatasetFromStoreWritableStream(this.dimseStoreStream, i4, (e5) => {
|
|
29594
29594
|
this.dimse.setDataset(e5), this._performDimse(i4, this.dimse), this.dimseStream = void 0, this.dimseStoreStream = void 0, this.dimse = void 0;
|
|
29595
29595
|
});
|
|
29596
29596
|
else {
|
|
@@ -29607,35 +29607,35 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29607
29607
|
if (t3 instanceof $) {
|
|
29608
29608
|
const e4 = Object.assign(Object.create(Object.getPrototypeOf(t3)), t3), s3 = this.pending.find((e5) => e5.getMessageId() === t3.getMessageIdBeingRespondedTo());
|
|
29609
29609
|
s3 && (s3.raiseResponseEvent(e4), e4.getStatus() !== p.Pending && s3.raiseDoneEvent());
|
|
29610
|
-
} else t3.getCommandFieldType() ===
|
|
29610
|
+
} else t3.getCommandFieldType() === g3.CEchoRequest ? this.emit("cEchoRequest", t3, (t4) => {
|
|
29611
29611
|
this._sendDimse({ context: e3, command: t4 });
|
|
29612
|
-
}) : t3.getCommandFieldType() ===
|
|
29612
|
+
}) : t3.getCommandFieldType() === g3.CFindRequest ? this.emit("cFindRequest", t3, (t4) => {
|
|
29613
29613
|
(Array.isArray(t4) ? t4 : [t4]).forEach((t5) => {
|
|
29614
29614
|
this._sendDimse({ context: e3, command: t5 });
|
|
29615
29615
|
});
|
|
29616
|
-
}) : t3.getCommandFieldType() ===
|
|
29616
|
+
}) : t3.getCommandFieldType() === g3.CStoreRequest ? this.emit("cStoreRequest", t3, (t4) => {
|
|
29617
29617
|
this._sendDimse({ context: e3, command: t4 });
|
|
29618
|
-
}) : t3.getCommandFieldType() ===
|
|
29618
|
+
}) : t3.getCommandFieldType() === g3.CMoveRequest ? this.emit("cMoveRequest", t3, (t4) => {
|
|
29619
29619
|
(Array.isArray(t4) ? t4 : [t4]).forEach((t5) => {
|
|
29620
29620
|
this._sendDimse({ context: e3, command: t5 });
|
|
29621
29621
|
});
|
|
29622
|
-
}) : t3.getCommandFieldType() ===
|
|
29622
|
+
}) : t3.getCommandFieldType() === g3.CGetRequest ? this.emit("cGetRequest", t3, (t4) => {
|
|
29623
29623
|
(Array.isArray(t4) ? t4 : [t4]).forEach((t5) => {
|
|
29624
29624
|
this._sendDimse({ context: e3, command: t5 });
|
|
29625
29625
|
});
|
|
29626
|
-
}) : t3.getCommandFieldType() ===
|
|
29626
|
+
}) : t3.getCommandFieldType() === g3.NCreateRequest ? this.emit("nCreateRequest", t3, (t4) => {
|
|
29627
29627
|
this._sendDimse({ context: e3, command: t4 });
|
|
29628
|
-
}) : t3.getCommandFieldType() ===
|
|
29628
|
+
}) : t3.getCommandFieldType() === g3.NActionRequest ? this.emit("nActionRequest", t3, (t4) => {
|
|
29629
29629
|
this._sendDimse({ context: e3, command: t4 });
|
|
29630
|
-
}) : t3.getCommandFieldType() ===
|
|
29630
|
+
}) : t3.getCommandFieldType() === g3.NDeleteRequest ? this.emit("nDeleteRequest", t3, (t4) => {
|
|
29631
29631
|
this._sendDimse({ context: e3, command: t4 });
|
|
29632
|
-
}) : t3.getCommandFieldType() ===
|
|
29632
|
+
}) : t3.getCommandFieldType() === g3.NEventReportRequest ? this.emit("nEventReportRequest", t3, (t4) => {
|
|
29633
29633
|
this._sendDimse({ context: e3, command: t4 });
|
|
29634
|
-
}) : t3.getCommandFieldType() ===
|
|
29634
|
+
}) : t3.getCommandFieldType() === g3.NGetRequest ? this.emit("nGetRequest", t3, (t4) => {
|
|
29635
29635
|
this._sendDimse({ context: e3, command: t4 });
|
|
29636
|
-
}) : t3.getCommandFieldType() ===
|
|
29636
|
+
}) : t3.getCommandFieldType() === g3.NSetRequest ? this.emit("nSetRequest", t3, (t4) => {
|
|
29637
29637
|
this._sendDimse({ context: e3, command: t4 });
|
|
29638
|
-
}) : t3.getCommandFieldType() ===
|
|
29638
|
+
}) : t3.getCommandFieldType() === g3.CCancelRequest && this.emit("cCancelRequest", t3);
|
|
29639
29639
|
}
|
|
29640
29640
|
_wrapSocket() {
|
|
29641
29641
|
this.socket.setTimeout(this.connectTimeout), this.socket.on("connect", () => {
|
|
@@ -29671,7 +29671,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29671
29671
|
}
|
|
29672
29672
|
};
|
|
29673
29673
|
}, 422: (e2, t2, s2) => {
|
|
29674
|
-
const { Association: n2, PresentationContext: i3 } = s2(570), { TransferSyntax: r7, UserIdentityType: a3 } = s2(492), { Request: o2 } = s2(940), c2 = s2(371), d4 = s2(906), u2 = s2(547), h3 = s2(733),
|
|
29674
|
+
const { Association: n2, PresentationContext: i3 } = s2(570), { TransferSyntax: r7, UserIdentityType: a3 } = s2(492), { Request: o2 } = s2(940), c2 = s2(371), d4 = s2(906), u2 = s2(547), h3 = s2(733), m = s2(278), g3 = s2(756);
|
|
29675
29675
|
e2.exports = class extends h3 {
|
|
29676
29676
|
constructor() {
|
|
29677
29677
|
super(), this.requests = [], this.additionalPresentationContexts = [], this.network = void 0, this.statistics = new d4();
|
|
@@ -29700,7 +29700,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29700
29700
|
});
|
|
29701
29701
|
let h4 = {};
|
|
29702
29702
|
o3.securityOptions && (h4 = { key: o3.securityOptions.key, cert: o3.securityOptions.cert, ca: o3.securityOptions.ca, requestCert: o3.securityOptions.requestCert, rejectUnauthorized: o3.securityOptions.rejectUnauthorized, minVersion: o3.securityOptions.minVersion, maxVersion: o3.securityOptions.maxVersion, ciphers: o3.securityOptions.ciphers }), u2.info(`Connecting to ${e3}:${t3} ${o3.securityOptions ? "(TLS)" : ""}`);
|
|
29703
|
-
const l3 = (o3.securityOptions ?
|
|
29703
|
+
const l3 = (o3.securityOptions ? g3 : m).connect({ host: e3, port: t3, ...h4 }), p = new c2(l3, o3);
|
|
29704
29704
|
p.on("connect", () => {
|
|
29705
29705
|
this.emit("connected"), p.sendAssociationRequest(d5);
|
|
29706
29706
|
}), p.on("associationAccepted", (e4) => {
|
|
@@ -29759,10 +29759,10 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29759
29759
|
Object.freeze(u2);
|
|
29760
29760
|
const h3 = { Success: 0, Cancel: 65024, Pending: 65280, ClassInstanceConflict: 281, DataSetSopClassMismatch: 43264, DuplicateSOPInstance: 273, DuplicateInvocation: 528, InvalidArgumentValue: 277, InvalidAttributeValue: 262, InvalidObjectInstance: 279, MissingAttribute: 288, MissingAttributeValue: 289, MistypedArgument: 530, MoveDestinationUnknown: 43009, NoSuchActionType: 291, NoSuchArgument: 276, NoSuchEventType: 275, NoSuchObjectInstance: 274, NoSuchSopClass: 280, NotAuthorized: 292, OutOfResourcesNumberOfMatches: 42753, OutOfResourcesSubOperations: 42754, ProcessingFailure: 272, ResourceLimitation: 531, SopClassNotSupported: 290, UnrecognizedOperation: 529 };
|
|
29761
29761
|
Object.freeze(h3);
|
|
29762
|
-
const
|
|
29763
|
-
Object.freeze(
|
|
29764
|
-
const
|
|
29765
|
-
Object.freeze(
|
|
29762
|
+
const m = { ApplicationContextName: "1.2.840.10008.3.1.1.1" };
|
|
29763
|
+
Object.freeze(m);
|
|
29764
|
+
const g3 = { BasicTextSrStorage: "1.2.840.10008.5.1.4.1.1.88.11", BreastProjectionXRayImageStorageForPresentation: "1.2.840.10008.5.1.4.1.1.13.1.4", BreastProjectionXRayImageStorageForProcessing: "1.2.840.10008.5.1.4.1.1.13.1.5", BreastTomosynthesisImageStorage: "1.2.840.10008.5.1.4.1.1.13.1.3", ChestCadSrStorage: "1.2.840.10008.5.1.4.1.1.88.65", ComprehensiveSrStorage: "1.2.840.10008.5.1.4.1.1.88.33", ComputedRadiographyImageStorage: "1.2.840.10008.5.1.4.1.1.1", CtImageStorage: "1.2.840.10008.5.1.4.1.1.2", DigitalIntraOralXRayImageStorageForPresentation: "1.2.840.10008.5.1.4.1.1.1.3", DigitalIntraOralXRayImageStorageForProcessing: "1.2.840.10008.5.1.4.1.1.1.3.1", DigitalMammographyXRayImageStorageForPresentation: "1.2.840.10008.5.1.4.1.1.1.2", DigitalMammographyXRayImageStorageForProcessing: "1.2.840.10008.5.1.4.1.1.1.2.1", DigitalXRayImageStorageForPresentation: "1.2.840.10008.5.1.4.1.1.1.1", DigitalXRayImageStorageForProcessing: "1.2.840.10008.5.1.4.1.1.1.1.1", EncapsulatedCdaStorage: "1.2.840.10008.5.1.4.1.1.104.2", EncapsulatedPdfStorage: "1.2.840.10008.5.1.4.1.1.104.1", EnhancedCtImageStorage: "1.2.840.10008.5.1.4.1.1.2.1", EnhancedMrColorImageStorage: "1.2.840.10008.5.1.4.1.1.4.3", EnhancedMrImageStorage: "1.2.840.10008.5.1.4.1.1.4.1", EnhancedPetImageStorage: "1.2.840.10008.5.1.4.1.1.130", EnhancedSrStorage: "1.2.840.10008.5.1.4.1.1.88.22", EnhancedXaImageStorage: "1.2.840.10008.5.1.4.1.1.12.1.1", EnhancedXrfImageStorage: "1.2.840.10008.5.1.4.1.1.12.2.1", IntravascularOpticalCoherenceTomographyImageStorageForPresentation: "1.2.840.10008.5.1.4.1.1.14.1", IntravascularOpticalCoherenceTomographyImageStorageForProcessing: "1.2.840.10008.5.1.4.1.1.14.2", LegacyConvertedEnhancedCTImageStorage: "1.2.840.10008.5.1.4.1.1.2.2", LegacyConvertedEnhancedMRImageStorage: "1.2.840.10008.5.1.4.1.1.4.4", LegacyConvertedEnhancedPETImageStorage: "1.2.840.10008.5.1.4.1.1.128.1", MammographyCadSrStorage: "1.2.840.10008.5.1.4.1.1.88.50", MrImageStorage: "1.2.840.10008.5.1.4.1.1.4", MultiframeGrayscaleByteSecondaryCaptureImageStorage: "1.2.840.10008.5.1.4.1.1.7.2", MultiframeGrayscaleWordSecondaryCaptureImageStorage: "1.2.840.10008.5.1.4.1.1.7.3", MultiframeSingleBitSecondaryCaptureImageStorage: "1.2.840.10008.5.1.4.1.1.7.1", MultiframeTrueColorSecondaryCaptureImageStorage: "1.2.840.10008.5.1.4.1.1.7.4", NuclearMedicineImageStorage: "1.2.840.10008.5.1.4.1.1.20", OphthalmicOpticalCoherenceTomographyEnFaceImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.5.7", OphthalmicPhotography16BitImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.5.2", OphthalmicPhotography8BitImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.5.1", OphthalmicTomographyImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.5.4", PositronEmissionTomographyImageStorage: "1.2.840.10008.5.1.4.1.1.128", RtImageStorage: "1.2.840.10008.5.1.4.1.1.481.1", SecondaryCaptureImageStorage: "1.2.840.10008.5.1.4.1.1.7", UltrasoundImageStorage: "1.2.840.10008.5.1.4.1.1.6.1", UltrasoundMultiframeImageStorage: "1.2.840.10008.5.1.4.1.1.3.1", VideoEndoscopicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.1.1", VideoMicroscopicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.2.1", VideoPhotographicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.4.1", VlEndoscopicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.1", VlMicroscopicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.2", VlPhotographicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.4", VlSlideCoordinatesMicroscopicImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.3", VlWholeSlideMicroscopyImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.6", WideFieldOphthalmicPhotography3dCoordinatesImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.5.6", WideFieldOphthalmicPhotographyStereographicProjectionImageStorage: "1.2.840.10008.5.1.4.1.1.77.1.5.5", XRay3dAngiographicImageStorage: "1.2.840.10008.5.1.4.1.1.13.1.1", XRay3dCraniofacialImageStorage: "1.2.840.10008.5.1.4.1.1.13.1.2", XRayAngiographicImageStorage: "1.2.840.10008.5.1.4.1.1.12.1", XRayRadiationDoseSRStorage: "1.2.840.10008.5.1.4.1.1.88.67", XRayRadiofluoroscopicImageStorage: "1.2.840.10008.5.1.4.1.1.12.2" };
|
|
29765
|
+
Object.freeze(g3);
|
|
29766
29766
|
const l3 = { Verification: "1.2.840.10008.1.1", StudyRootQueryRetrieveInformationModelFind: "1.2.840.10008.5.1.4.1.2.2.1", ModalityWorklistInformationModelFind: "1.2.840.10008.5.1.4.31", ModalityPerformedProcedureStep: "1.2.840.10008.3.1.2.3.3", StudyRootQueryRetrieveInformationModelMove: "1.2.840.10008.5.1.4.1.2.2.2", StudyRootQueryRetrieveInformationModelGet: "1.2.840.10008.5.1.4.1.2.2.3", StorageCommitmentPushModel: "1.2.840.10008.1.20.1", BasicFilmSession: "1.2.840.10008.5.1.1.1", PrintJob: "1.2.840.10008.5.1.1.14", BasicAnnotationBox: "1.2.840.10008.5.1.1.15", Printer: "1.2.840.10008.5.1.1.16", PrinterConfigurationRetrieval: "1.2.840.10008.5.1.1.16.376", BasicGrayscalePrintManagementMeta: "1.2.840.10008.5.1.1.9", BasicColorPrintManagementMeta: "1.2.840.10008.5.1.1.18", BasicFilmBox: "1.2.840.10008.5.1.1.2", PresentationLut: "1.2.840.10008.5.1.1.23", BasicGrayscaleImageBox: "1.2.840.10008.5.1.1.4", BasicColorImageBox: "1.2.840.10008.5.1.1.4.1", InstanceAvailabilityNotification: "1.2.840.10008.5.1.4.33" };
|
|
29767
29767
|
Object.freeze(l3);
|
|
29768
29768
|
const p = { ImplicitVRLittleEndian: "1.2.840.10008.1.2", ExplicitVRLittleEndian: "1.2.840.10008.1.2.1", DeflatedExplicitVRLittleEndian: "1.2.840.10008.1.2.1.99", ExplicitVRBigEndian: "1.2.840.10008.1.2.2", RleLossless: "1.2.840.10008.1.2.5", JpegBaseline: "1.2.840.10008.1.2.4.50", JpegLossless: "1.2.840.10008.1.2.4.70", JpegLsLossless: "1.2.840.10008.1.2.4.80", JpegLsLossy: "1.2.840.10008.1.2.4.81", Jpeg2000Lossless: "1.2.840.10008.1.2.4.90", Jpeg2000Lossy: "1.2.840.10008.1.2.4.91", JpegXlLossless: "1.2.840.10008.1.2.4.110", JpegXlRecompression: "1.2.840.10008.1.2.4.111", JpegXl: "1.2.840.10008.1.2.4.112", HtJpeg2000Lossless: "1.2.840.10008.1.2.4.201", HtJpeg2000LosslessRpcl: "1.2.840.10008.1.2.4.202", HtJpeg2000Lossy: "1.2.840.10008.1.2.4.203" };
|
|
@@ -29770,9 +29770,9 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29770
29770
|
const R2 = [p.ImplicitVRLittleEndian, p.ExplicitVRLittleEndian, p.ExplicitVRBigEndian, p.RleLossless, p.JpegBaseline, p.JpegLossless, p.JpegLsLossless, p.JpegLsLossy, p.Jpeg2000Lossless, p.Jpeg2000Lossy, p.HtJpeg2000Lossless, p.HtJpeg2000LosslessRpcl, p.HtJpeg2000Lossy];
|
|
29771
29771
|
Object.freeze(R2);
|
|
29772
29772
|
const S2 = { ImplementationClassUid: "1.2.826.0.1.3680043.10.854", ImplementationVersion: "DCMJS-DIMSE-V0.2", MaxPduLength: 262144 };
|
|
29773
|
-
Object.freeze(S2), e2.exports = { AbortReason: a3, AbortSource: r7, CommandFieldType: s2, DefaultImplementation: S2, PresentationContextResult: n2, Priority: u2, RawPduType: t2, RejectReason: d4, RejectResult: o2, RejectSource: c2, SopClass: l3, Status: h3, StorageClass:
|
|
29773
|
+
Object.freeze(S2), e2.exports = { AbortReason: a3, AbortSource: r7, CommandFieldType: s2, DefaultImplementation: S2, PresentationContextResult: n2, Priority: u2, RawPduType: t2, RejectReason: d4, RejectResult: o2, RejectSource: c2, SopClass: l3, Status: h3, StorageClass: g3, TranscodableTransferSyntaxes: R2, TransferSyntax: p, Uid: m, UserIdentityType: i3 };
|
|
29774
29774
|
}, 538: (e2, t2, s2) => {
|
|
29775
|
-
const { CEchoResponse: n2, CFindResponse: i3, CGetResponse: r7, CMoveResponse: a3, CStoreResponse: o2, NActionResponse: c2, NCreateResponse: d4, NDeleteResponse: u2, NEventReportResponse: h3, NGetResponse:
|
|
29775
|
+
const { CEchoResponse: n2, CFindResponse: i3, CGetResponse: r7, CMoveResponse: a3, CStoreResponse: o2, NActionResponse: c2, NCreateResponse: d4, NDeleteResponse: u2, NEventReportResponse: h3, NGetResponse: m, NSetResponse: g3 } = s2(940), l3 = s2(371), p = s2(906), R2 = s2(547), S2 = s2(733), y3 = s2(278), f3 = s2(756);
|
|
29776
29776
|
e2.exports = { Scp: class extends l3 {
|
|
29777
29777
|
constructor(e3, t3) {
|
|
29778
29778
|
super(e3, t3), this.on("associationRequested", (e4) => {
|
|
@@ -29847,10 +29847,10 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29847
29847
|
R2.error("nEventReportRequest method must be implemented"), t3(h3.fromRequest(e3));
|
|
29848
29848
|
}
|
|
29849
29849
|
nGetRequest(e3, t3) {
|
|
29850
|
-
R2.error("nGetRequest method must be implemented"), t3(
|
|
29850
|
+
R2.error("nGetRequest method must be implemented"), t3(m.fromRequest(e3));
|
|
29851
29851
|
}
|
|
29852
29852
|
nSetRequest(e3, t3) {
|
|
29853
|
-
R2.error("nSetRequest method must be implemented"), t3(
|
|
29853
|
+
R2.error("nSetRequest method must be implemented"), t3(g3.fromRequest(e3));
|
|
29854
29854
|
}
|
|
29855
29855
|
cCancelRequest(e3) {
|
|
29856
29856
|
R2.error("cCancelRequest method must be implemented");
|
|
@@ -29892,7 +29892,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29892
29892
|
const n2 = s2(360), i3 = s2(707);
|
|
29893
29893
|
i3.reg(n2), n2.enableAll(false), i3.apply(n2, { format: (e3, t3, s3) => `${s3} -- ${e3.toUpperCase()} --`, timestampFormatter: (e3) => e3.toISOString() }), e2.exports = n2;
|
|
29894
29894
|
}, 570: (e2, t2, s2) => {
|
|
29895
|
-
const { CGetRequest: n2, CStoreRequest: i3 } = s2(940), { CommandFieldType: r7, PresentationContextResult: a3, SopClass: o2, StorageClass: c2, TransferSyntax: d4, Uid: u2, UserIdentityType: h3 } = s2(492),
|
|
29895
|
+
const { CGetRequest: n2, CStoreRequest: i3 } = s2(940), { CommandFieldType: r7, PresentationContextResult: a3, SopClass: o2, StorageClass: c2, TransferSyntax: d4, Uid: u2, UserIdentityType: h3 } = s2(492), m = s2(139), { EOL: g3 } = s2(857);
|
|
29896
29896
|
class l3 {
|
|
29897
29897
|
constructor(e3, t3, s3, n3) {
|
|
29898
29898
|
this.pcId = e3, this.abstractSyntaxUid = t3, this.transferSyntaxes = [], s3 && this.transferSyntaxes.push(s3), this.result = n3 || a3.Proposed;
|
|
@@ -29950,12 +29950,12 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
29950
29950
|
const e3 = [];
|
|
29951
29951
|
return e3.push(`Presentation Context: ${this.getPresentationContextId()} [${this.getResultDescription()}]`), e3.push(` Abstract: ${this.getAbstractSyntaxUid()}`), this.getTransferSyntaxUids().forEach((t3) => {
|
|
29952
29952
|
e3.push(` Transfer: ${t3}`);
|
|
29953
|
-
}), e3.join(
|
|
29953
|
+
}), e3.join(g3);
|
|
29954
29954
|
}
|
|
29955
29955
|
}
|
|
29956
29956
|
e2.exports = { Association: class {
|
|
29957
29957
|
constructor(e3, t3) {
|
|
29958
|
-
this.callingAeTitle = e3, this.calledAeTitle = t3, this.maxPduLength =
|
|
29958
|
+
this.callingAeTitle = e3, this.calledAeTitle = t3, this.maxPduLength = m.getMaxPduLength(), this.applicationContextName = u2.ApplicationContextName, this.implementationClassUid = m.getImplementationClassUid(), this.implementationVersion = m.getImplementationVersion(), this.presentationContexts = [], this.negotiateAsyncOps = false, this.maxAsyncOpsInvoked = 1, this.maxAsyncOpsPerformed = 1, this.negotiateUserIdentity = false, this.userIdentityType = h3.Username, this.userIdentityPositiveResponseRequested = false, this.userIdentityPrimaryField = "", this.userIdentitySecondaryField = "", this.negotiateUserIdentityServerResponse = false, this.userIdentityServerResponse = "";
|
|
29959
29959
|
}
|
|
29960
29960
|
getCallingAeTitle() {
|
|
29961
29961
|
return this.callingAeTitle;
|
|
@@ -30129,7 +30129,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30129
30129
|
e3.push(` Presentation Context: ${t3.id} [${s3.getResultDescription()}]`), e3.push(` Abstract: ${this._uidNameFromValue([o2, c2], s3.getAbstractSyntaxUid()) || s3.getAbstractSyntaxUid()}`), s3.getTransferSyntaxUids().forEach((t4) => {
|
|
30130
30130
|
e3.push(` Transfer: ${this._uidNameFromValue(d4, t4) || t4}`);
|
|
30131
30131
|
});
|
|
30132
|
-
}), e3.push(""), e3.join(
|
|
30132
|
+
}), e3.push(""), e3.join(g3);
|
|
30133
30133
|
}
|
|
30134
30134
|
_uidNameFromValue(e3, t3) {
|
|
30135
30135
|
const s3 = Array.isArray(e3) ? Object.assign({}, ...e3) : e3;
|
|
@@ -30188,7 +30188,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30188
30188
|
"use strict";
|
|
30189
30189
|
e2.exports = o;
|
|
30190
30190
|
}, 825: (e2, t2, s2) => {
|
|
30191
|
-
const { StorageClass: n2, TransferSyntax: i3 } = s2(492), r7 = s2(139), { readFile: a3, readFileSync: o2, writeFile: c2, writeFileSync: d4 } = s2(896), { EOL: u2 } = s2(857), h3 = s2(111), { DicomDict:
|
|
30191
|
+
const { StorageClass: n2, TransferSyntax: i3 } = s2(492), r7 = s2(139), { readFile: a3, readFileSync: o2, writeFile: c2, writeFileSync: d4 } = s2(896), { EOL: u2 } = s2(857), h3 = s2(111), { DicomDict: m, DicomMessage: g3, DicomMetaDictionary: l3, ReadBufferStream: p, WriteBufferStream: R2 } = h3.data, S2 = h3.log;
|
|
30192
30192
|
class y3 {
|
|
30193
30193
|
constructor(e3, t3, s3) {
|
|
30194
30194
|
s3 = s3 || {}, s3 = { ignoreErrors: true, ...s3 }, S2.level = "error", this.transferSyntaxUid = t3 || i3.ImplicitVRLittleEndian, Buffer.isBuffer(e3) ? this.elements = this._fromElementsBuffer(e3, this.transferSyntaxUid, s3) : this.elements = e3 || {};
|
|
@@ -30210,11 +30210,11 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30210
30210
|
}
|
|
30211
30211
|
getDenaturalizedDataset(e3, t3) {
|
|
30212
30212
|
const s3 = t3 ? l3.denaturalizeDataset(this.getElements(), { ...l3.nameMap, ...t3 }) : l3.denaturalizeDataset(this.getElements()), n3 = new R2();
|
|
30213
|
-
return
|
|
30213
|
+
return g3.write(s3, n3, this.transferSyntaxUid, e3), Buffer.from(n3.getBuffer());
|
|
30214
30214
|
}
|
|
30215
30215
|
getDenaturalizedCommandDataset(e3) {
|
|
30216
30216
|
const t3 = l3.denaturalizeDataset(this.getElements()), s3 = new R2(), n3 = new R2();
|
|
30217
|
-
return
|
|
30217
|
+
return g3.write(t3, n3, i3.ImplicitVRLittleEndian, e3), g3.writeTagObject(s3, "00000000", "UL", n3.size, i3.ImplicitVRLittleEndian, e3), s3.concat(n3), Buffer.from(s3.getBuffer());
|
|
30218
30218
|
}
|
|
30219
30219
|
static fromFile(e3, t3, s3) {
|
|
30220
30220
|
if (!(void 0 !== t3 && t3 instanceof Function)) return this._fromP10Buffer(o2(e3), s3);
|
|
@@ -30228,7 +30228,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30228
30228
|
});
|
|
30229
30229
|
}
|
|
30230
30230
|
toFile(e3, t3, s3, i4) {
|
|
30231
|
-
const a4 = { _meta: { FileMetaInformationVersion: new Uint8Array([0, 1]).buffer, MediaStorageSOPClassUID: this.getElement("SOPClassUID") || n2.SecondaryCaptureImageStorage, MediaStorageSOPInstanceUID: this.getElement("SOPInstanceUID") || y3.generateDerivedUid(), TransferSyntaxUID: this.getTransferSyntaxUid(), ImplementationClassUID: r7.getImplementationClassUid(), ImplementationVersionName: r7.getImplementationVersion() }, ...this.getElements() }, o3 = l3.denaturalizeDataset(a4._meta), u3 = new
|
|
30231
|
+
const a4 = { _meta: { FileMetaInformationVersion: new Uint8Array([0, 1]).buffer, MediaStorageSOPClassUID: this.getElement("SOPClassUID") || n2.SecondaryCaptureImageStorage, MediaStorageSOPInstanceUID: this.getElement("SOPInstanceUID") || y3.generateDerivedUid(), TransferSyntaxUID: this.getTransferSyntaxUid(), ImplementationClassUID: r7.getImplementationClassUid(), ImplementationVersionName: r7.getImplementationVersion() }, ...this.getElements() }, o3 = l3.denaturalizeDataset(a4._meta), u3 = new m(o3);
|
|
30232
30232
|
u3.dict = s3 ? l3.denaturalizeDataset(a4, { ...l3.nameMap, ...s3 }) : l3.denaturalizeDataset(a4), t3 instanceof Function ? c2(e3, Buffer.from(u3.write(i4)), (e4) => {
|
|
30233
30233
|
t3(e4 || void 0);
|
|
30234
30234
|
}) : d4(e3, Buffer.from(u3.write(i4)));
|
|
@@ -30242,11 +30242,11 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30242
30242
|
}
|
|
30243
30243
|
static _fromP10Buffer(e3, t3) {
|
|
30244
30244
|
t3 = t3 || {}, t3 = { ignoreErrors: true, ...t3 };
|
|
30245
|
-
const s3 =
|
|
30245
|
+
const s3 = g3.readFile(e3.buffer.slice(e3.byteOffset, e3.byteOffset + e3.byteLength), t3), n3 = l3.naturalizeDataset(s3.meta).TransferSyntaxUID, i4 = l3.naturalizeDataset(s3.dict);
|
|
30246
30246
|
return new y3(i4, n3);
|
|
30247
30247
|
}
|
|
30248
30248
|
_fromElementsBuffer(e3, t3, s3) {
|
|
30249
|
-
const n3 = new p(e3.buffer.slice(e3.byteOffset, e3.byteOffset + e3.byteLength)), r8 = t3 === i3.ImplicitVRLittleEndian ? i3.ImplicitVRLittleEndian : t3 === i3.ExplicitVRBigEndian ? i3.ExplicitVRBigEndian : i3.ExplicitVRLittleEndian, a4 =
|
|
30249
|
+
const n3 = new p(e3.buffer.slice(e3.byteOffset, e3.byteOffset + e3.byteLength)), r8 = t3 === i3.ImplicitVRLittleEndian ? i3.ImplicitVRLittleEndian : t3 === i3.ExplicitVRBigEndian ? i3.ExplicitVRBigEndian : i3.ExplicitVRLittleEndian, a4 = g3._read(n3, r8, s3);
|
|
30250
30250
|
return l3.naturalizeDataset(a4);
|
|
30251
30251
|
}
|
|
30252
30252
|
}
|
|
@@ -30292,8 +30292,8 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30292
30292
|
}
|
|
30293
30293
|
};
|
|
30294
30294
|
}, 940: (e2, t2, s2) => {
|
|
30295
|
-
const { CommandFieldType: n2, Priority: i3, SopClass: r7, Status: a3 } = s2(492), o2 = s2(825), { Mixin: c2 } = s2(429), { EOL: d4 } = s2(857), u2 = s2(733), h3 = s2(111), { DicomMetaDictionary:
|
|
30296
|
-
class
|
|
30295
|
+
const { CommandFieldType: n2, Priority: i3, SopClass: r7, Status: a3 } = s2(492), o2 = s2(825), { Mixin: c2 } = s2(429), { EOL: d4 } = s2(857), u2 = s2(733), h3 = s2(111), { DicomMetaDictionary: m } = h3.data;
|
|
30296
|
+
class g3 {
|
|
30297
30297
|
constructor(e3, t3) {
|
|
30298
30298
|
this.commandDataset = e3 || new o2(), this.dataset = t3;
|
|
30299
30299
|
}
|
|
@@ -30372,7 +30372,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30372
30372
|
}
|
|
30373
30373
|
}
|
|
30374
30374
|
}
|
|
30375
|
-
class l3 extends c2(
|
|
30375
|
+
class l3 extends c2(g3, u2) {
|
|
30376
30376
|
constructor(e3, t3, s3, i4) {
|
|
30377
30377
|
switch (super(new o2({ CommandField: e3, CommandDataSetType: s3 ? 514 : 257 })), e3) {
|
|
30378
30378
|
case n2.NGetRequest:
|
|
@@ -30435,7 +30435,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30435
30435
|
return `${super.toString(e3)} [id: ${this.getMessageId() || ""}]`;
|
|
30436
30436
|
}
|
|
30437
30437
|
}
|
|
30438
|
-
class p extends
|
|
30438
|
+
class p extends g3 {
|
|
30439
30439
|
constructor(e3, t3, s3, i4, r8) {
|
|
30440
30440
|
switch (super(new o2({ CommandField: e3, CommandDataSetType: s3 ? 514 : 257, Status: i4, ErrorComment: r8 })), e3) {
|
|
30441
30441
|
case n2.NGetRequest:
|
|
@@ -30763,7 +30763,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30763
30763
|
return t3.setMessageIdBeingRespondedTo(e3.getMessageId()), t3;
|
|
30764
30764
|
}
|
|
30765
30765
|
}
|
|
30766
|
-
class
|
|
30766
|
+
class w3 extends l3 {
|
|
30767
30767
|
constructor(e3, t3, s3) {
|
|
30768
30768
|
super(n2.NCreateRequest, e3, false), this.setAffectedSopInstanceUid(t3), this.setMetaSopClassUid(s3);
|
|
30769
30769
|
}
|
|
@@ -30773,7 +30773,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30773
30773
|
super(n2.NCreateResponse, e3, false, s3, i4), this.setAffectedSopInstanceUid(t3);
|
|
30774
30774
|
}
|
|
30775
30775
|
static fromRequest(e3) {
|
|
30776
|
-
if (!(e3 instanceof
|
|
30776
|
+
if (!(e3 instanceof w3)) throw new Error("Request should be an instance of NCreateRequest");
|
|
30777
30777
|
const t3 = new U(e3.getAffectedSopClassUid(), e3.getAffectedSopInstanceUid(), a3.ProcessingFailure);
|
|
30778
30778
|
return t3.setMessageIdBeingRespondedTo(e3.getMessageId()), t3;
|
|
30779
30779
|
}
|
|
@@ -30854,14 +30854,14 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30854
30854
|
getAttributeIdentifierList() {
|
|
30855
30855
|
const e3 = this.getCommandDataset().getElement("AttributeIdentifierList"), t3 = [];
|
|
30856
30856
|
return void 0 !== e3 && Array.isArray(e3) && e3.length > 0 && e3.forEach((e4) => {
|
|
30857
|
-
const s3 = e4 >> 16, n3 = 65535 & e4, i4 = `(${this._getPaddedHexString(s3, 4)},${this._getPaddedHexString(n3, 4)})`, r8 =
|
|
30857
|
+
const s3 = e4 >> 16, n3 = 65535 & e4, i4 = `(${this._getPaddedHexString(s3, 4)},${this._getPaddedHexString(n3, 4)})`, r8 = m.dictionary[i4.toUpperCase()];
|
|
30858
30858
|
r8 && t3.push(r8.name);
|
|
30859
30859
|
}), t3;
|
|
30860
30860
|
}
|
|
30861
30861
|
setAttributeIdentifierList(e3) {
|
|
30862
30862
|
const t3 = [];
|
|
30863
|
-
Object.keys(
|
|
30864
|
-
const n3 =
|
|
30863
|
+
Object.keys(m.dictionary).forEach((s3) => {
|
|
30864
|
+
const n3 = m.dictionary[s3];
|
|
30865
30865
|
if ("DICOM" === n3.version && e3.includes(n3.name)) {
|
|
30866
30866
|
const e4 = parseInt(n3.tag.substring(1, 5), 16), s4 = parseInt(n3.tag.substring(6, 10), 16);
|
|
30867
30867
|
t3.push(e4 << 16 | 65535 & s4);
|
|
@@ -30873,13 +30873,13 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30873
30873
|
return "0".repeat(t3 - s3.length) + s3;
|
|
30874
30874
|
}
|
|
30875
30875
|
}
|
|
30876
|
-
class
|
|
30876
|
+
class M extends p {
|
|
30877
30877
|
constructor(e3, t3, s3, i4) {
|
|
30878
30878
|
super(n2.NGetResponse, e3, false, s3, i4), this.setAffectedSopInstanceUid(t3);
|
|
30879
30879
|
}
|
|
30880
30880
|
static fromRequest(e3) {
|
|
30881
30881
|
if (!(e3 instanceof N2)) throw new Error("Request should be an instance of NGetRequest");
|
|
30882
|
-
const t3 = new
|
|
30882
|
+
const t3 = new M(e3.getRequestedSopClassUid(), e3.getRequestedSopInstanceUid(), a3.ProcessingFailure);
|
|
30883
30883
|
return t3.setMessageIdBeingRespondedTo(e3.getMessageId()), t3;
|
|
30884
30884
|
}
|
|
30885
30885
|
}
|
|
@@ -30913,10 +30913,10 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
30913
30913
|
return new F2(e3.getAffectedSopClassUid(), e3.getMessageId());
|
|
30914
30914
|
}
|
|
30915
30915
|
}
|
|
30916
|
-
e2.exports = { CCancelRequest: F2, CEchoRequest: R2, CEchoResponse: S2, CFindRequest: y3, CFindResponse: f3, CGetRequest: v2, CGetResponse: x, CMoveRequest: P, CMoveResponse: A2, Command:
|
|
30916
|
+
e2.exports = { CCancelRequest: F2, CEchoRequest: R2, CEchoResponse: S2, CFindRequest: y3, CFindResponse: f3, CGetRequest: v2, CGetResponse: x, CMoveRequest: P, CMoveResponse: A2, Command: g3, CStoreRequest: I2, CStoreResponse: C2, NActionRequest: q2, NActionResponse: D2, NCreateRequest: w3, NCreateResponse: U, NDeleteRequest: E2, NDeleteResponse: T, NEventReportRequest: b2, NEventReportResponse: O2, NGetRequest: N2, NGetResponse: M, NSetRequest: B2, NSetResponse: L2, Request: l3, Response: p };
|
|
30917
30917
|
}, 942: (e2, t2, s2) => {
|
|
30918
30918
|
const { AbortReason: n2, AbortSource: i3, RawPduType: r7, RejectReason: a3, RejectResult: o2, RejectSource: c2, TransferSyntax: d4 } = s2(492), { SmartBuffer: u2 } = s2(766), { EOL: h3 } = s2(857);
|
|
30919
|
-
class
|
|
30919
|
+
class m {
|
|
30920
30920
|
constructor(e3) {
|
|
30921
30921
|
if (this.m16 = [], this.m32 = [], Buffer.isBuffer(e3)) return this.buffer = u2.fromBuffer(e3, "ascii"), void (this.type = this.buffer.readUInt8());
|
|
30922
30922
|
this.buffer = u2.fromOptions({ encoding: "ascii" }), this.type = e3;
|
|
@@ -31007,7 +31007,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
31007
31007
|
return s3 > 0 || n3 < e3.length ? e3.substring(s3, n3) : e3;
|
|
31008
31008
|
}
|
|
31009
31009
|
}
|
|
31010
|
-
class
|
|
31010
|
+
class g3 {
|
|
31011
31011
|
constructor(e3, t3, s3, n3) {
|
|
31012
31012
|
this.pcId = e3, this.value = t3, this.command = s3, this.last = n3;
|
|
31013
31013
|
}
|
|
@@ -31051,7 +31051,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
31051
31051
|
return this.reason;
|
|
31052
31052
|
}
|
|
31053
31053
|
write() {
|
|
31054
|
-
const e3 = new
|
|
31054
|
+
const e3 = new m(r7.AAbort);
|
|
31055
31055
|
return e3.writeByte("Reserved", 0), e3.writeByte("Reserved", 0), e3.writeByte("Source", this.source), e3.writeByte("Reason", this.reason), e3;
|
|
31056
31056
|
}
|
|
31057
31057
|
read(e3) {
|
|
@@ -31098,7 +31098,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
31098
31098
|
return this.association;
|
|
31099
31099
|
}
|
|
31100
31100
|
write() {
|
|
31101
|
-
const e3 = new
|
|
31101
|
+
const e3 = new m(r7.AAssociateAC);
|
|
31102
31102
|
return e3.writeUInt16("Version", 1), e3.writeByteMultiple("Reserved", 0, 2), e3.writeStringWithPadding("Called AE", this.association.getCalledAeTitle(), 16, " "), e3.writeStringWithPadding("Calling AE", this.association.getCallingAeTitle(), 16, " "), e3.writeByteMultiple("Reserved", 0, 32), e3.writeByte("Item-Type", 16), e3.writeByte("Reserved", 0), e3.markLength16("Item-Length"), e3.writeString("Application Context Name", this.association.getApplicationContextName()), e3.writeLength16(), this.association.getPresentationContexts().forEach((t3) => {
|
|
31103
31103
|
const s3 = this.association.getPresentationContext(t3.id);
|
|
31104
31104
|
e3.writeByte("Item-Type", 33), e3.writeByte("Reserved", 0), e3.markLength16("Item-Length"), e3.writeByte("Presentation Context ID", s3.getPresentationContextId()), e3.writeByte("Reserved", 0), e3.writeByte("Result", s3.getResult()), e3.writeByte("Reserved", 0), e3.writeByte("Item-Type", 64), e3.writeByte("Reserved", 0), e3.markLength16("Item-Length"), e3.writeString("Transfer Syntax UID", s3.getAcceptedTransferSyntaxUid() || d4.ImplicitVRLittleEndian), e3.writeLength16(), e3.writeLength16();
|
|
@@ -31163,7 +31163,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
31163
31163
|
return this.reason;
|
|
31164
31164
|
}
|
|
31165
31165
|
write() {
|
|
31166
|
-
const e3 = new
|
|
31166
|
+
const e3 = new m(r7.AAssociateRJ);
|
|
31167
31167
|
return e3.writeByte("Reserved", 0), e3.writeByte("Result", this.result), e3.writeByte("Source", this.source), e3.writeByte("Reason", this.reason), e3;
|
|
31168
31168
|
}
|
|
31169
31169
|
read(e3) {
|
|
@@ -31233,7 +31233,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
31233
31233
|
return this.association;
|
|
31234
31234
|
}
|
|
31235
31235
|
write() {
|
|
31236
|
-
const e3 = new
|
|
31236
|
+
const e3 = new m(r7.AAssociateRQ);
|
|
31237
31237
|
return e3.writeUInt16("Version", 1), e3.writeByteMultiple("Reserved", 0, 2), e3.writeStringWithPadding("Called AE", this.association.getCalledAeTitle(), 16, " "), e3.writeStringWithPadding("Calling AE", this.association.getCallingAeTitle(), 16, " "), e3.writeByteMultiple("Reserved", 0, 32), e3.writeByte("Item-Type", 16), e3.writeByte("Reserved", 0), e3.markLength16("Item-Length"), e3.writeString("Application Context Name", this.association.getApplicationContextName()), e3.writeLength16(), this.association.getPresentationContexts().forEach((t3) => {
|
|
31238
31238
|
const s3 = this.association.getPresentationContext(t3.id);
|
|
31239
31239
|
e3.writeByte("Item-Type", 32), e3.writeByte("Reserved", 0), e3.markLength16("Item-Length"), e3.writeByte("Presentation Context ID", s3.getPresentationContextId()), e3.writeByteMultiple("Reserved", 0, 3), e3.writeByte("Item-Type", 48), e3.writeByte("Reserved", 0), e3.markLength16("Item-Length"), e3.writeString("Abstract Syntax UID", s3.getAbstractSyntaxUid()), e3.writeLength16(), s3.getTransferSyntaxUids().forEach((t4) => {
|
|
@@ -31281,7 +31281,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
31281
31281
|
constructor() {
|
|
31282
31282
|
}
|
|
31283
31283
|
write() {
|
|
31284
|
-
const e3 = new
|
|
31284
|
+
const e3 = new m(r7.AReleaseRP);
|
|
31285
31285
|
return e3.writeUInt32("Reserved", 0), e3;
|
|
31286
31286
|
}
|
|
31287
31287
|
read(e3) {
|
|
@@ -31294,7 +31294,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
31294
31294
|
constructor() {
|
|
31295
31295
|
}
|
|
31296
31296
|
write() {
|
|
31297
|
-
const e3 = new
|
|
31297
|
+
const e3 = new m(r7.AReleaseRQ);
|
|
31298
31298
|
return e3.writeUInt32("Reserved", 0), e3;
|
|
31299
31299
|
}
|
|
31300
31300
|
read(e3) {
|
|
@@ -31326,7 +31326,7 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
31326
31326
|
}), e3;
|
|
31327
31327
|
}
|
|
31328
31328
|
write() {
|
|
31329
|
-
const e3 = new
|
|
31329
|
+
const e3 = new m(r7.PDataTF);
|
|
31330
31330
|
return this.pdvs.forEach((t3) => {
|
|
31331
31331
|
t3.write(e3);
|
|
31332
31332
|
}), e3;
|
|
@@ -31335,14 +31335,14 @@ var require_dcmjs_dimse_min = __commonJS({
|
|
|
31335
31335
|
const t3 = e3.getLength();
|
|
31336
31336
|
let s3 = 0;
|
|
31337
31337
|
for (; s3 < t3; ) {
|
|
31338
|
-
const t4 = new
|
|
31338
|
+
const t4 = new g3();
|
|
31339
31339
|
s3 += t4.read(e3), this.pdvs.push(t4);
|
|
31340
31340
|
}
|
|
31341
31341
|
}
|
|
31342
31342
|
toString() {
|
|
31343
31343
|
return `(P-DATA-TF) [PDV count: ${this.getPdvCount()}, PDV length: ${this.getLengthOfPdvs()}]`;
|
|
31344
31344
|
}
|
|
31345
|
-
}, Pdv:
|
|
31345
|
+
}, Pdv: g3, RawPdu: m };
|
|
31346
31346
|
} }, d3 = {}, function e2(t2) {
|
|
31347
31347
|
var s2 = d3[t2];
|
|
31348
31348
|
if (void 0 !== s2) return s2.exports;
|
|
@@ -31709,8 +31709,8 @@ function wo(r6, e, t) {
|
|
|
31709
31709
|
if (!i2 || i2.length === 0) return;
|
|
31710
31710
|
let o, s = "undefined", a2, c = t.path.lastIndexOf("."), u2 = t.path.substring(c + 1);
|
|
31711
31711
|
for (let p of i2) {
|
|
31712
|
-
let
|
|
31713
|
-
if (o = n[
|
|
31712
|
+
let m = u2.replace("[x]", I(p.code));
|
|
31713
|
+
if (o = n[m], a2 = n["_" + m], o !== void 0 || a2 !== void 0) {
|
|
31714
31714
|
s = p.code;
|
|
31715
31715
|
break;
|
|
31716
31716
|
}
|
|
@@ -31898,10 +31898,10 @@ function ht(r6, e) {
|
|
|
31898
31898
|
n.setUTCHours(0, 0, 0, 0);
|
|
31899
31899
|
let i2 = t.getUTCFullYear(), o = t.getUTCMonth(), s = t.getUTCDate(), a2 = n.getUTCFullYear(), c = n.getUTCMonth(), u2 = n.getUTCDate(), p = a2 - i2;
|
|
31900
31900
|
(c < o || c === o && u2 < s) && p--;
|
|
31901
|
-
let
|
|
31902
|
-
u2 < s &&
|
|
31901
|
+
let m = a2 * 12 + c - (i2 * 12 + o);
|
|
31902
|
+
u2 < s && m--;
|
|
31903
31903
|
let x = Math.floor((n.getTime() - t.getTime()) / (1e3 * 60 * 60 * 24));
|
|
31904
|
-
return { years: p, months:
|
|
31904
|
+
return { years: p, months: m, days: x };
|
|
31905
31905
|
}
|
|
31906
31906
|
function ne(r6, ...e) {
|
|
31907
31907
|
let t = r6;
|
|
@@ -33205,7 +33205,7 @@ var $t = class {
|
|
|
33205
33205
|
return this.masterSubEmitter || (this.masterSubEmitter = new Ye(...Array.from(this.criteriaEntries.keys()))), this.masterSubEmitter;
|
|
33206
33206
|
}
|
|
33207
33207
|
};
|
|
33208
|
-
var Yr = "4.2.
|
|
33208
|
+
var Yr = "4.2.2-aecf657d9";
|
|
33209
33209
|
var ma = w.FHIR_JSON + ", */*; q=0.1";
|
|
33210
33210
|
var ya = "https://api.medplum.com/";
|
|
33211
33211
|
var ga = 1e3;
|
|
@@ -33510,8 +33510,8 @@ var Gt = class extends J {
|
|
|
33510
33510
|
async createAttachment(t, n, i2, o, s) {
|
|
33511
33511
|
let a2 = Ni(t, n, i2, o);
|
|
33512
33512
|
if (a2.contentType === w.XML) {
|
|
33513
|
-
let p = a2.data,
|
|
33514
|
-
p instanceof Blob ?
|
|
33513
|
+
let p = a2.data, m;
|
|
33514
|
+
p instanceof Blob ? m = await new Promise((x, U) => {
|
|
33515
33515
|
let $ = new FileReader();
|
|
33516
33516
|
$.onload = () => {
|
|
33517
33517
|
if (!$.result) {
|
|
@@ -33520,24 +33520,24 @@ var Gt = class extends J {
|
|
|
33520
33520
|
}
|
|
33521
33521
|
x($.result);
|
|
33522
33522
|
}, $.readAsText(p, "utf-8");
|
|
33523
|
-
}) : ArrayBuffer.isView(p) ?
|
|
33523
|
+
}) : ArrayBuffer.isView(p) ? m = new TextDecoder().decode(p) : m = p, m.includes("<ClinicalDocument") && m.includes("urn:hl7-org:v3") && (a2 = { ...a2, contentType: w.CDA_XML });
|
|
33524
33524
|
}
|
|
33525
33525
|
let c = s ?? (typeof n == "object" ? n : {}), u2 = await this.createBinary(a2, c);
|
|
33526
33526
|
return { contentType: a2.contentType, url: u2.url, title: a2.filename };
|
|
33527
33527
|
}
|
|
33528
33528
|
createBinary(t, n, i2, o, s) {
|
|
33529
|
-
let a2 = Ni(t, n, i2, o), c = s ?? (typeof n == "object" ? n : {}), { data: u2, contentType: p, filename:
|
|
33530
|
-
return
|
|
33529
|
+
let a2 = Ni(t, n, i2, o), c = s ?? (typeof n == "object" ? n : {}), { data: u2, contentType: p, filename: m, securityContext: x, onProgress: U } = a2, $ = this.fhirUrl("Binary");
|
|
33530
|
+
return m && $.searchParams.set("_filename", m), x?.reference && this.setRequestHeader(c, "X-Security-Context", x.reference), U ? this.uploadwithProgress($, u2, p, U, c) : this.post($, u2, p, c);
|
|
33531
33531
|
}
|
|
33532
33532
|
uploadwithProgress(t, n, i2, o, s) {
|
|
33533
33533
|
return new Promise((a2, c) => {
|
|
33534
33534
|
let u2 = new XMLHttpRequest(), p = () => u2.abort();
|
|
33535
33535
|
s?.signal?.addEventListener("abort", p);
|
|
33536
|
-
let
|
|
33536
|
+
let m = (x) => {
|
|
33537
33537
|
s?.signal?.removeEventListener("abort", p), x instanceof Error ? c(x) : a2(x);
|
|
33538
33538
|
};
|
|
33539
|
-
if (u2.responseType = "json", u2.onabort = () =>
|
|
33540
|
-
u2.status >= 200 && u2.status < 300 ?
|
|
33539
|
+
if (u2.responseType = "json", u2.onabort = () => m(new DOMException("Request aborted", "AbortError")), u2.onerror = () => m(new Error("Request error")), o && (u2.upload.onprogress = (x) => o(x), u2.upload.onload = (x) => o(x)), u2.onload = () => {
|
|
33540
|
+
u2.status >= 200 && u2.status < 300 ? m(u2.response) : m(new d(st(u2.response || u2.statusText)));
|
|
33541
33541
|
}, u2.open("POST", t), u2.withCredentials = true, u2.setRequestHeader("Authorization", "Bearer " + this.accessToken), u2.setRequestHeader("Cache-Control", "no-cache, no-store, max-age=0"), u2.setRequestHeader("Content-Type", i2), this.options.extendedMode !== false && u2.setRequestHeader("X-Medplum", "extended"), s?.headers) {
|
|
33542
33542
|
let x = s.headers;
|
|
33543
33543
|
for (let [U, $] of Object.entries(x)) u2.setRequestHeader(U, $);
|
|
@@ -33547,7 +33547,7 @@ var Gt = class extends J {
|
|
|
33547
33547
|
}
|
|
33548
33548
|
async createPdf(t, n, i2, o) {
|
|
33549
33549
|
if (!this.createPdfImpl) throw new Error("PDF creation not enabled");
|
|
33550
|
-
let s = wa(t, n, i2, o), a2 = typeof n == "object" ? n : {}, { docDefinition: c, tableLayouts: u2, fonts: p, ...
|
|
33550
|
+
let s = wa(t, n, i2, o), a2 = typeof n == "object" ? n : {}, { docDefinition: c, tableLayouts: u2, fonts: p, ...m } = s, x = await this.createPdfImpl(c, u2, p), U = { ...m, data: x, contentType: "application/pdf" };
|
|
33551
33551
|
return this.createBinary(U, a2);
|
|
33552
33552
|
}
|
|
33553
33553
|
createComment(t, n, i2) {
|
|
@@ -33594,7 +33594,8 @@ var Gt = class extends J {
|
|
|
33594
33594
|
return this.get(`${this.fhirUrl(t, n)}/$graph?graph=${i2}`, o);
|
|
33595
33595
|
}
|
|
33596
33596
|
pushToAgent(t, n, i2, o, s, a2) {
|
|
33597
|
-
|
|
33597
|
+
let { waitTimeout: c, ...u2 } = a2 ?? {};
|
|
33598
|
+
return this.post(this.fhirUrl("Agent", me(t), "$push"), { destination: typeof n == "string" ? n : B(n), body: i2, contentType: o, waitForResponse: s, ...c !== void 0 ? { waitTimeout: c } : void 0 }, w.FHIR_JSON, u2);
|
|
33598
33599
|
}
|
|
33599
33600
|
getActiveLogin() {
|
|
33600
33601
|
return this.storage.getObject("activeLogin");
|
|
@@ -33722,8 +33723,8 @@ var Gt = class extends J {
|
|
|
33722
33723
|
if (p) return this.request("GET", p, { ...i2, body: void 0 });
|
|
33723
33724
|
}
|
|
33724
33725
|
if (s.status === 202 && i2.pollStatusOnAccepted) {
|
|
33725
|
-
let
|
|
33726
|
-
if (
|
|
33726
|
+
let m = await Li(s, u2) ?? o.statusUrl;
|
|
33727
|
+
if (m) return this.pollStatus(m, i2, o);
|
|
33727
33728
|
}
|
|
33728
33729
|
if (s.status >= 400) throw new d(st(u2));
|
|
33729
33730
|
return u2;
|
|
@@ -34197,7 +34198,7 @@ async function ln(r6, e, t) {
|
|
|
34197
34198
|
return n;
|
|
34198
34199
|
}
|
|
34199
34200
|
function Pc(r6) {
|
|
34200
|
-
return /^\d+\.\d+\.\d
|
|
34201
|
+
return /^\d+\.\d+\.\d+(-[0-9a-z]{7})?$/.test(r6);
|
|
34201
34202
|
}
|
|
34202
34203
|
async function om(r6, e) {
|
|
34203
34204
|
if (!Pc(e)) return false;
|
|
@@ -34214,8 +34215,13 @@ async function sm(r6) {
|
|
|
34214
34215
|
return e.tag_name.slice(1);
|
|
34215
34216
|
}
|
|
34216
34217
|
|
|
34218
|
+
// src/main.ts
|
|
34219
|
+
var import_node_child_process3 = require("node:child_process");
|
|
34220
|
+
var import_node_fs7 = require("node:fs");
|
|
34221
|
+
var import_node_path4 = __toESM(require("node:path"));
|
|
34222
|
+
|
|
34217
34223
|
// src/agent-main.ts
|
|
34218
|
-
var
|
|
34224
|
+
var import_node_fs5 = require("node:fs");
|
|
34219
34225
|
|
|
34220
34226
|
// ../hl7/dist/esm/index.mjs
|
|
34221
34227
|
var import_node_net = require("node:net");
|
|
@@ -34252,7 +34258,7 @@ var d2 = class extends a {
|
|
|
34252
34258
|
this.socket = e, this.encoding = s, this.enhancedMode = r6, e.on("data", (n) => {
|
|
34253
34259
|
try {
|
|
34254
34260
|
if (this.appendData(n), n.at(-2) === 28 && n.at(-1) === 13) {
|
|
34255
|
-
let o = Buffer.concat(this.chunks),
|
|
34261
|
+
let o = Buffer.concat(this.chunks), p = o.subarray(1, o.length - 2), E2 = import_iconv_lite.default.decode(p, this.encoding), k2 = io.parse(E2);
|
|
34256
34262
|
this.dispatchEvent(new h2(this, k2)), this.resetBuffer();
|
|
34257
34263
|
}
|
|
34258
34264
|
} catch (o) {
|
|
@@ -34296,7 +34302,7 @@ var d2 = class extends a {
|
|
|
34296
34302
|
this.chunks = [];
|
|
34297
34303
|
}
|
|
34298
34304
|
};
|
|
34299
|
-
var
|
|
34305
|
+
var f2 = class extends a {
|
|
34300
34306
|
constructor(t) {
|
|
34301
34307
|
super(), this.options = t, this.host = this.options.host, this.port = this.options.port, this.encoding = this.options.encoding, this.keepAlive = this.options.keepAlive ?? false, this.connectTimeout = this.options.connectTimeout ?? 3e4;
|
|
34302
34308
|
}
|
|
@@ -34328,16 +34334,20 @@ var u = class extends a {
|
|
|
34328
34334
|
this.socket && (this.socket.removeAllListeners(), this.socket.destroy(), this.socket = void 0), this.connection && (this.connection.close(), delete this.connection);
|
|
34329
34335
|
}
|
|
34330
34336
|
};
|
|
34331
|
-
var
|
|
34337
|
+
var g2 = class {
|
|
34332
34338
|
constructor(t) {
|
|
34333
34339
|
this.handler = t;
|
|
34334
34340
|
}
|
|
34335
34341
|
start(t, e, s = false) {
|
|
34336
|
-
let r6 = import_node_net2.default.createServer((
|
|
34337
|
-
let
|
|
34338
|
-
this.handler(
|
|
34339
|
-
})
|
|
34340
|
-
|
|
34342
|
+
let r6 = import_node_net2.default.createServer((o) => {
|
|
34343
|
+
let p = new d2(o, e, s);
|
|
34344
|
+
this.handler(p);
|
|
34345
|
+
}), n = async (o) => {
|
|
34346
|
+
o?.code === "EADDRINUSE" && (await _r(50), r6.close(), r6.listen(t));
|
|
34347
|
+
};
|
|
34348
|
+
r6.on("error", n), r6.once("listening", () => {
|
|
34349
|
+
r6.off("error", n);
|
|
34350
|
+
}), r6.listen(t), this.server = r6;
|
|
34341
34351
|
}
|
|
34342
34352
|
async stop() {
|
|
34343
34353
|
return new Promise((t, e) => {
|
|
@@ -34358,10 +34368,10 @@ var f2 = class {
|
|
|
34358
34368
|
|
|
34359
34369
|
// src/app.ts
|
|
34360
34370
|
var import_node_child_process = require("node:child_process");
|
|
34361
|
-
var
|
|
34371
|
+
var import_node_fs4 = require("node:fs");
|
|
34362
34372
|
var import_node_net3 = require("node:net");
|
|
34363
|
-
var
|
|
34364
|
-
var
|
|
34373
|
+
var import_node_os4 = require("node:os");
|
|
34374
|
+
var import_node_process2 = __toESM(require("node:process"));
|
|
34365
34375
|
|
|
34366
34376
|
// ../../node_modules/ws/wrapper.mjs
|
|
34367
34377
|
var import_stream = __toESM(require_stream(), 1);
|
|
@@ -34545,8 +34555,16 @@ var AgentDicomChannel = class extends BaseChannel {
|
|
|
34545
34555
|
this.started = true;
|
|
34546
34556
|
const address = new URL(this.getEndpoint().address);
|
|
34547
34557
|
this.log.info(`Channel starting on ${address}`);
|
|
34548
|
-
|
|
34549
|
-
this.server.
|
|
34558
|
+
const port = Number.parseInt(address.port, 10);
|
|
34559
|
+
this.server.on("networkError", async (err) => {
|
|
34560
|
+
this.log.error("Network error: ", { err });
|
|
34561
|
+
if (err?.code === "EADDRINUSE") {
|
|
34562
|
+
await _r(50);
|
|
34563
|
+
this.server.close();
|
|
34564
|
+
this.server.listen(port);
|
|
34565
|
+
}
|
|
34566
|
+
});
|
|
34567
|
+
this.server.listen(port);
|
|
34550
34568
|
this.log.info("Channel started successfully");
|
|
34551
34569
|
}
|
|
34552
34570
|
async stop() {
|
|
@@ -34575,7 +34593,7 @@ var AgentHl7Channel = class extends BaseChannel {
|
|
|
34575
34593
|
super(app, definition, endpoint);
|
|
34576
34594
|
this.started = false;
|
|
34577
34595
|
this.connections = /* @__PURE__ */ new Map();
|
|
34578
|
-
this.server = new
|
|
34596
|
+
this.server = new g2((connection) => this.handleNewConnection(connection));
|
|
34579
34597
|
this.log = app.log.clone({ options: { prefix: `[HL7:${definition.name}] ` } });
|
|
34580
34598
|
}
|
|
34581
34599
|
start() {
|
|
@@ -34640,26 +34658,169 @@ var AgentHl7ChannelConnection = class {
|
|
|
34640
34658
|
}
|
|
34641
34659
|
};
|
|
34642
34660
|
|
|
34643
|
-
// src/
|
|
34644
|
-
var import_node_fs2 = require("node:fs");
|
|
34661
|
+
// src/pid.ts
|
|
34662
|
+
var import_node_fs2 = __toESM(require("node:fs"));
|
|
34645
34663
|
var import_node_os2 = require("node:os");
|
|
34646
|
-
var import_node_path2 = require("node:path");
|
|
34664
|
+
var import_node_path2 = __toESM(require("node:path"));
|
|
34665
|
+
var import_node_process = __toESM(require("node:process"));
|
|
34666
|
+
var EXIT_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
34667
|
+
var pidLogger = new oo((msg) => `[PID]: ${msg}`);
|
|
34668
|
+
var pidFileApps = /* @__PURE__ */ new Set();
|
|
34669
|
+
var processExitListener = () => {
|
|
34670
|
+
removeAllPidFiles();
|
|
34671
|
+
};
|
|
34672
|
+
var signalListener = () => {
|
|
34673
|
+
removeAllPidFiles();
|
|
34674
|
+
import_node_process.default.exit(0);
|
|
34675
|
+
};
|
|
34676
|
+
var uncaughtExceptionListener = (err) => {
|
|
34677
|
+
pidLogger.error("Uncaught exception:", err);
|
|
34678
|
+
removeAllPidFiles();
|
|
34679
|
+
import_node_process.default.exit(1);
|
|
34680
|
+
};
|
|
34681
|
+
var agentCleanupSetup = false;
|
|
34682
|
+
function getPidFilePath(appName) {
|
|
34683
|
+
switch ((0, import_node_os2.platform)()) {
|
|
34684
|
+
case "linux":
|
|
34685
|
+
case "darwin":
|
|
34686
|
+
return import_node_path2.default.join((0, import_node_os2.tmpdir)(), "medplum-agent", `${appName}.pid`);
|
|
34687
|
+
case "win32":
|
|
34688
|
+
return import_node_path2.default.join("C:", "ProgramData", "MedplumAgent", "pids", `${appName}.pid`);
|
|
34689
|
+
default:
|
|
34690
|
+
throw new Error("Invalid OS");
|
|
34691
|
+
}
|
|
34692
|
+
}
|
|
34693
|
+
function removePidFile(appName) {
|
|
34694
|
+
const pidFilePath = getPidFilePath(appName);
|
|
34695
|
+
if (import_node_fs2.default.existsSync(pidFilePath)) {
|
|
34696
|
+
try {
|
|
34697
|
+
import_node_fs2.default.unlinkSync(pidFilePath);
|
|
34698
|
+
pidLogger.info(`PID file removed: ${pidFilePath}`);
|
|
34699
|
+
} catch (err) {
|
|
34700
|
+
pidLogger.error(`Error removing PID file: ${pidFilePath}`, err);
|
|
34701
|
+
}
|
|
34702
|
+
}
|
|
34703
|
+
pidFileApps.delete(appName);
|
|
34704
|
+
}
|
|
34705
|
+
function forceKillApp(appName) {
|
|
34706
|
+
const pid = getAppPid(appName);
|
|
34707
|
+
if (pid === void 0) {
|
|
34708
|
+
pidLogger.info(`${appName} not running, skipping killing app`);
|
|
34709
|
+
return;
|
|
34710
|
+
}
|
|
34711
|
+
import_node_process.default.kill(pid, "SIGTERM");
|
|
34712
|
+
}
|
|
34713
|
+
function checkProcessExists(pid) {
|
|
34714
|
+
try {
|
|
34715
|
+
import_node_process.default.kill(pid, 0);
|
|
34716
|
+
return true;
|
|
34717
|
+
} catch (err) {
|
|
34718
|
+
if (err.code === "ESRCH") {
|
|
34719
|
+
return false;
|
|
34720
|
+
}
|
|
34721
|
+
if (err.code === "EPERM") {
|
|
34722
|
+
return true;
|
|
34723
|
+
}
|
|
34724
|
+
throw err;
|
|
34725
|
+
}
|
|
34726
|
+
}
|
|
34727
|
+
function isAppRunning(appName) {
|
|
34728
|
+
return getAppPidState(appName) === "running";
|
|
34729
|
+
}
|
|
34730
|
+
function getAppPid(appName) {
|
|
34731
|
+
const pidFilePath = getPidFilePath(appName);
|
|
34732
|
+
if (!import_node_fs2.default.existsSync(pidFilePath)) {
|
|
34733
|
+
return void 0;
|
|
34734
|
+
}
|
|
34735
|
+
const existingPidStr = import_node_fs2.default.readFileSync(pidFilePath, "utf8").trim();
|
|
34736
|
+
const existingPid = Number.parseInt(existingPidStr, 10);
|
|
34737
|
+
if (Number.isNaN(existingPid)) {
|
|
34738
|
+
pidLogger.warn("PID file does not contain a valid numeric PID");
|
|
34739
|
+
return void 0;
|
|
34740
|
+
}
|
|
34741
|
+
return existingPid;
|
|
34742
|
+
}
|
|
34743
|
+
function getAppPidState(appName) {
|
|
34744
|
+
const pid = getAppPid(appName);
|
|
34745
|
+
if (pid === void 0) {
|
|
34746
|
+
return "clean";
|
|
34747
|
+
}
|
|
34748
|
+
pidLogger.info(`PID file for ${appName} already exists, checking if process is running`);
|
|
34749
|
+
if (checkProcessExists(pid)) {
|
|
34750
|
+
return "running";
|
|
34751
|
+
}
|
|
34752
|
+
return "stale";
|
|
34753
|
+
}
|
|
34754
|
+
function createPidFile(appName) {
|
|
34755
|
+
const pid = import_node_process.default.pid;
|
|
34756
|
+
const pidFilePath = getPidFilePath(appName);
|
|
34757
|
+
const pidState = getAppPidState(appName);
|
|
34758
|
+
if (pidState === "running") {
|
|
34759
|
+
throw new Error(`${appName} already running`);
|
|
34760
|
+
}
|
|
34761
|
+
if (pidState === "stale") {
|
|
34762
|
+
pidLogger.info("Stale PID file found. Overwriting...");
|
|
34763
|
+
import_node_fs2.default.unlinkSync(pidFilePath);
|
|
34764
|
+
}
|
|
34765
|
+
ensureDirectoryExists(import_node_path2.default.dirname(pidFilePath));
|
|
34766
|
+
import_node_fs2.default.writeFileSync(pidFilePath, pid.toString(), { flag: "wx" });
|
|
34767
|
+
pidLogger.info(`PID file created at: ${pidFilePath}`);
|
|
34768
|
+
pidFileApps.add(appName);
|
|
34769
|
+
return pidFilePath;
|
|
34770
|
+
}
|
|
34771
|
+
function ensureDirectoryExists(directoryPath) {
|
|
34772
|
+
if (!import_node_fs2.default.existsSync(directoryPath)) {
|
|
34773
|
+
import_node_fs2.default.mkdirSync(directoryPath, { recursive: true });
|
|
34774
|
+
pidLogger.info(`Directory created: ${directoryPath}`);
|
|
34775
|
+
} else {
|
|
34776
|
+
pidLogger.info(`Directory already exists: ${directoryPath}`);
|
|
34777
|
+
}
|
|
34778
|
+
}
|
|
34779
|
+
async function waitForPidFile(appName, timeoutMs = 3e3) {
|
|
34780
|
+
const startTime = Date.now();
|
|
34781
|
+
while (!(0, import_node_fs2.existsSync)(getPidFilePath(appName))) {
|
|
34782
|
+
if (Date.now() - startTime > timeoutMs) {
|
|
34783
|
+
throw new Error("Timeout while waiting for PID file");
|
|
34784
|
+
}
|
|
34785
|
+
await _r(0);
|
|
34786
|
+
}
|
|
34787
|
+
}
|
|
34788
|
+
function removeAllPidFiles() {
|
|
34789
|
+
for (const appName of pidFileApps) {
|
|
34790
|
+
removePidFile(appName);
|
|
34791
|
+
}
|
|
34792
|
+
}
|
|
34793
|
+
function registerAgentCleanup() {
|
|
34794
|
+
if (!agentCleanupSetup) {
|
|
34795
|
+
import_node_process.default.on("exit", processExitListener);
|
|
34796
|
+
for (const signal of EXIT_SIGNALS) {
|
|
34797
|
+
import_node_process.default.on(signal, signalListener);
|
|
34798
|
+
}
|
|
34799
|
+
import_node_process.default.on("uncaughtException", uncaughtExceptionListener);
|
|
34800
|
+
agentCleanupSetup = true;
|
|
34801
|
+
}
|
|
34802
|
+
}
|
|
34803
|
+
|
|
34804
|
+
// src/upgrader-utils.ts
|
|
34805
|
+
var import_node_fs3 = require("node:fs");
|
|
34806
|
+
var import_node_os3 = require("node:os");
|
|
34807
|
+
var import_node_path3 = require("node:path");
|
|
34647
34808
|
var import_node_stream = require("node:stream");
|
|
34648
|
-
var UPGRADE_MANIFEST_PATH = (0,
|
|
34649
|
-
var UPGRADER_LOG_PATH = (0,
|
|
34809
|
+
var UPGRADE_MANIFEST_PATH = (0, import_node_path3.resolve)(__dirname, "upgrade.json");
|
|
34810
|
+
var UPGRADER_LOG_PATH = (0, import_node_path3.resolve)(
|
|
34650
34811
|
__dirname,
|
|
34651
34812
|
`upgrader-logs-${(/* @__PURE__ */ new Date()).toISOString().replace(/:\s*/g, "-")}.txt`
|
|
34652
34813
|
);
|
|
34653
|
-
var RELEASES_PATH = (0,
|
|
34654
|
-
async function downloadRelease(version,
|
|
34814
|
+
var RELEASES_PATH = (0, import_node_path3.resolve)(__dirname);
|
|
34815
|
+
async function downloadRelease(version, path4) {
|
|
34655
34816
|
const release = await ln("agent-upgrader", version);
|
|
34656
|
-
const downloadUrl = parseDownloadUrl(release, (0,
|
|
34817
|
+
const downloadUrl = parseDownloadUrl(release, (0, import_node_os3.platform)());
|
|
34657
34818
|
const { body } = await fetch(downloadUrl);
|
|
34658
34819
|
if (!body) {
|
|
34659
34820
|
throw new Error("Body not present on Response");
|
|
34660
34821
|
}
|
|
34661
34822
|
const readable = import_node_stream.Readable.fromWeb(body);
|
|
34662
|
-
const writeStream = readable.pipe((0,
|
|
34823
|
+
const writeStream = readable.pipe((0, import_node_fs3.createWriteStream)(path4));
|
|
34663
34824
|
return new Promise((resolve2) => {
|
|
34664
34825
|
writeStream.once("close", resolve2);
|
|
34665
34826
|
});
|
|
@@ -34685,7 +34846,7 @@ function parseDownloadUrl(release, os) {
|
|
|
34685
34846
|
}
|
|
34686
34847
|
function getReleaseBinPath(version) {
|
|
34687
34848
|
let binaryName;
|
|
34688
|
-
switch ((0,
|
|
34849
|
+
switch ((0, import_node_os3.platform)()) {
|
|
34689
34850
|
case "win32":
|
|
34690
34851
|
binaryName = `medplum-agent-installer-${version}.exe`;
|
|
34691
34852
|
break;
|
|
@@ -34693,9 +34854,9 @@ function getReleaseBinPath(version) {
|
|
|
34693
34854
|
binaryName = `medplum-agent-${version}-linux`;
|
|
34694
34855
|
break;
|
|
34695
34856
|
default:
|
|
34696
|
-
throw new Error(`Unsupported platform: ${(0,
|
|
34857
|
+
throw new Error(`Unsupported platform: ${(0, import_node_os3.platform)()}`);
|
|
34697
34858
|
}
|
|
34698
|
-
return (0,
|
|
34859
|
+
return (0, import_node_path3.resolve)(RELEASES_PATH, binaryName);
|
|
34699
34860
|
}
|
|
34700
34861
|
|
|
34701
34862
|
// src/app.ts
|
|
@@ -34731,8 +34892,8 @@ var App = class _App {
|
|
|
34731
34892
|
async start() {
|
|
34732
34893
|
this.log.info("Medplum service starting...");
|
|
34733
34894
|
await this.startWebSocket();
|
|
34734
|
-
await this.maybeFinalizeUpgrade();
|
|
34735
34895
|
await this.reloadConfig();
|
|
34896
|
+
await this.maybeFinalizeUpgrade();
|
|
34736
34897
|
this.medplum.addEventListener("change", () => {
|
|
34737
34898
|
if (!this.webSocket) {
|
|
34738
34899
|
this.connectWebSocket().catch(this.log.error);
|
|
@@ -34743,10 +34904,10 @@ var App = class _App {
|
|
|
34743
34904
|
this.log.info("Medplum service started successfully");
|
|
34744
34905
|
}
|
|
34745
34906
|
async maybeFinalizeUpgrade() {
|
|
34746
|
-
if ((0,
|
|
34747
|
-
const upgradeFile = (0,
|
|
34907
|
+
if ((0, import_node_fs4.existsSync)(UPGRADE_MANIFEST_PATH)) {
|
|
34908
|
+
const upgradeFile = (0, import_node_fs4.readFileSync)(UPGRADE_MANIFEST_PATH, { encoding: "utf-8" });
|
|
34748
34909
|
const upgradeDetails = JSON.parse(upgradeFile);
|
|
34749
|
-
if (upgradeDetails.targetVersion
|
|
34910
|
+
if (Yr.startsWith(upgradeDetails.targetVersion)) {
|
|
34750
34911
|
await this.sendToWebSocket({
|
|
34751
34912
|
type: "agent:upgrade:response",
|
|
34752
34913
|
statusCode: 200,
|
|
@@ -34762,7 +34923,28 @@ var App = class _App {
|
|
|
34762
34923
|
});
|
|
34763
34924
|
this.log.error(errMsg);
|
|
34764
34925
|
}
|
|
34765
|
-
(0,
|
|
34926
|
+
(0, import_node_fs4.unlinkSync)(UPGRADE_MANIFEST_PATH);
|
|
34927
|
+
await this.tryToCreateAgentPidFile();
|
|
34928
|
+
await waitForPidFile("medplum-upgrading-agent");
|
|
34929
|
+
removePidFile("medplum-upgrading-agent");
|
|
34930
|
+
}
|
|
34931
|
+
}
|
|
34932
|
+
async tryToCreateAgentPidFile() {
|
|
34933
|
+
const maxAttempts = 1e3;
|
|
34934
|
+
let attempt = 0;
|
|
34935
|
+
let success = false;
|
|
34936
|
+
while (!success) {
|
|
34937
|
+
try {
|
|
34938
|
+
createPidFile("medplum-agent");
|
|
34939
|
+
success = true;
|
|
34940
|
+
} catch (_err) {
|
|
34941
|
+
this.log.info("Unable to create agent PID file, trying again...");
|
|
34942
|
+
attempt++;
|
|
34943
|
+
if (attempt === maxAttempts) {
|
|
34944
|
+
throw new Error("Too many unsuccessful attempts to create agent PID file");
|
|
34945
|
+
}
|
|
34946
|
+
await _r(500);
|
|
34947
|
+
}
|
|
34766
34948
|
}
|
|
34767
34949
|
}
|
|
34768
34950
|
async startWebSocket() {
|
|
@@ -34899,7 +35081,7 @@ var App = class _App {
|
|
|
34899
35081
|
});
|
|
34900
35082
|
}
|
|
34901
35083
|
async reloadConfig() {
|
|
34902
|
-
const agent = await this.medplum.readResource("Agent", this.agentId);
|
|
35084
|
+
const agent = await this.medplum.readResource("Agent", this.agentId, { cache: "no-cache" });
|
|
34903
35085
|
const keepAlive = agent?.setting?.find((setting) => setting.name === "keepAlive")?.valueBoolean;
|
|
34904
35086
|
if (!keepAlive && this.hl7Clients.size !== 0) {
|
|
34905
35087
|
for (const client of this.hl7Clients.values()) {
|
|
@@ -34925,7 +35107,9 @@ var App = class _App {
|
|
|
34925
35107
|
}
|
|
34926
35108
|
const endpointPromises = [];
|
|
34927
35109
|
for (const definition of channels) {
|
|
34928
|
-
endpointPromises.push(
|
|
35110
|
+
endpointPromises.push(
|
|
35111
|
+
this.medplum.readReference(definition.endpoint, { cache: "no-cache" })
|
|
35112
|
+
);
|
|
34929
35113
|
}
|
|
34930
35114
|
const endpoints = await Promise.all(endpointPromises);
|
|
34931
35115
|
this.validateAgentEndpoints(channels, endpoints);
|
|
@@ -35086,7 +35270,7 @@ var App = class _App {
|
|
|
35086
35270
|
}
|
|
35087
35271
|
// This covers Windows, Linux, and Mac
|
|
35088
35272
|
getPingCommand(host, count = 1) {
|
|
35089
|
-
return (0,
|
|
35273
|
+
return (0, import_node_os4.platform)() === "win32" ? `ping /n ${count} ${host}` : `ping -c ${count} ${host}`;
|
|
35090
35274
|
}
|
|
35091
35275
|
async tryPingHost(message) {
|
|
35092
35276
|
try {
|
|
@@ -35153,7 +35337,8 @@ ${result}`);
|
|
|
35153
35337
|
}
|
|
35154
35338
|
}
|
|
35155
35339
|
async tryUpgradeAgent(message) {
|
|
35156
|
-
|
|
35340
|
+
this.log.info(`Attempting to upgrade from ${Yr} to ${message.version ?? "latest"}...`);
|
|
35341
|
+
if ((0, import_node_os4.platform)() !== "win32") {
|
|
35157
35342
|
const errMsg = "Auto-upgrading is currently only supported on Windows";
|
|
35158
35343
|
this.log.error(errMsg);
|
|
35159
35344
|
await this.sendToWebSocket({
|
|
@@ -35163,6 +35348,17 @@ ${result}`);
|
|
|
35163
35348
|
});
|
|
35164
35349
|
return;
|
|
35165
35350
|
}
|
|
35351
|
+
const upgradeInProgress = this.isAgentUpgrading();
|
|
35352
|
+
if (upgradeInProgress && !message.force) {
|
|
35353
|
+
const errMsg = "Pending upgrade is already in progress";
|
|
35354
|
+
this.log.error(errMsg);
|
|
35355
|
+
await this.sendToWebSocket({
|
|
35356
|
+
type: "agent:error",
|
|
35357
|
+
callback: message.callback,
|
|
35358
|
+
body: errMsg
|
|
35359
|
+
});
|
|
35360
|
+
return;
|
|
35361
|
+
}
|
|
35166
35362
|
let child;
|
|
35167
35363
|
if (message.version && !await om("agent-upgrader", message.version)) {
|
|
35168
35364
|
const versionTag = message.version ? `v${message.version}` : "latest";
|
|
@@ -35188,15 +35384,28 @@ ${result}`);
|
|
|
35188
35384
|
}
|
|
35189
35385
|
this.log.info(`Forcing upgrade from ${Yr} to ${targetVersion}`);
|
|
35190
35386
|
}
|
|
35387
|
+
if (upgradeInProgress && message.force) {
|
|
35388
|
+
if (isAppRunning("medplum-upgrading-agent")) {
|
|
35389
|
+
removePidFile("medplum-upgrading-agent");
|
|
35390
|
+
}
|
|
35391
|
+
if (isAppRunning("medplum-agent-upgrader")) {
|
|
35392
|
+
forceKillApp("medplum-agent-upgrader");
|
|
35393
|
+
removePidFile("medplum-agent-upgrader");
|
|
35394
|
+
}
|
|
35395
|
+
(0, import_node_fs4.unlinkSync)(UPGRADE_MANIFEST_PATH);
|
|
35396
|
+
}
|
|
35191
35397
|
try {
|
|
35192
35398
|
const command = __filename;
|
|
35193
|
-
const logFile = (0,
|
|
35194
|
-
child = (0, import_node_child_process.spawn)(command, ["--upgrade"], {
|
|
35399
|
+
const logFile = (0, import_node_fs4.openSync)(UPGRADER_LOG_PATH, "w+");
|
|
35400
|
+
child = (0, import_node_child_process.spawn)(command, ["--upgrade"], {
|
|
35401
|
+
detached: true,
|
|
35402
|
+
stdio: ["ignore", logFile, logFile, "ipc"]
|
|
35403
|
+
});
|
|
35195
35404
|
child.unref();
|
|
35196
35405
|
await new Promise((resolve2, reject) => {
|
|
35197
35406
|
const childTimeout = setTimeout(
|
|
35198
35407
|
() => reject(new Error("Timed out while waiting for message from child")),
|
|
35199
|
-
|
|
35408
|
+
15e3
|
|
35200
35409
|
);
|
|
35201
35410
|
child.on("message", (msg) => {
|
|
35202
35411
|
clearTimeout(childTimeout);
|
|
@@ -35206,9 +35415,10 @@ ${result}`);
|
|
|
35206
35415
|
reject(new Error(`Received unexpected message type ${msg.type} when expected type STARTED`));
|
|
35207
35416
|
}
|
|
35208
35417
|
});
|
|
35209
|
-
|
|
35210
|
-
|
|
35211
|
-
|
|
35418
|
+
child.on("error", (err) => {
|
|
35419
|
+
this.log.error(Oe(err));
|
|
35420
|
+
reject(err);
|
|
35421
|
+
});
|
|
35212
35422
|
});
|
|
35213
35423
|
} catch (err) {
|
|
35214
35424
|
const versionTag = message.version ? `v${message.version}` : "latest";
|
|
@@ -35222,10 +35432,8 @@ ${result}`);
|
|
|
35222
35432
|
return;
|
|
35223
35433
|
}
|
|
35224
35434
|
try {
|
|
35225
|
-
await this.stop();
|
|
35226
|
-
this.log.info("Successfully stopped agent network services");
|
|
35227
35435
|
this.log.info("Writing upgrade manifest...", { previousVersion: Yr, targetVersion });
|
|
35228
|
-
(0,
|
|
35436
|
+
(0, import_node_fs4.writeFileSync)(
|
|
35229
35437
|
UPGRADE_MANIFEST_PATH,
|
|
35230
35438
|
JSON.stringify({
|
|
35231
35439
|
previousVersion: Yr,
|
|
@@ -35240,7 +35448,7 @@ ${result}`);
|
|
|
35240
35448
|
this.log.error(
|
|
35241
35449
|
`Error while stopping agent or messaging child process as part of upgrade: ${Oe(err)}`
|
|
35242
35450
|
);
|
|
35243
|
-
|
|
35451
|
+
import_node_process2.default.exit(1);
|
|
35244
35452
|
}
|
|
35245
35453
|
}
|
|
35246
35454
|
async sendToWebSocket(message) {
|
|
@@ -35274,7 +35482,7 @@ ${result}`);
|
|
|
35274
35482
|
} else {
|
|
35275
35483
|
const encoding = address.searchParams.get("encoding") ?? void 0;
|
|
35276
35484
|
const keepAlive = this.keepAlive;
|
|
35277
|
-
client = new
|
|
35485
|
+
client = new f2({
|
|
35278
35486
|
host: address.hostname,
|
|
35279
35487
|
port: Number.parseInt(address.port, 10),
|
|
35280
35488
|
encoding,
|
|
@@ -35328,6 +35536,15 @@ ${result}`);
|
|
|
35328
35536
|
}
|
|
35329
35537
|
});
|
|
35330
35538
|
}
|
|
35539
|
+
isAgentUpgrading() {
|
|
35540
|
+
if ((0, import_node_fs4.existsSync)(UPGRADE_MANIFEST_PATH)) {
|
|
35541
|
+
return true;
|
|
35542
|
+
}
|
|
35543
|
+
if (isAppRunning("medplum-upgrading-agent") || isAppRunning("medplum-agent-upgrader")) {
|
|
35544
|
+
return true;
|
|
35545
|
+
}
|
|
35546
|
+
return false;
|
|
35547
|
+
}
|
|
35331
35548
|
};
|
|
35332
35549
|
|
|
35333
35550
|
// src/agent-main.ts
|
|
@@ -35342,7 +35559,7 @@ async function agentMain(argv) {
|
|
|
35342
35559
|
console.log(" clientSecret: The OAuth client secret.");
|
|
35343
35560
|
console.log(" agentId: The Medplum agent ID.");
|
|
35344
35561
|
process.exit(0);
|
|
35345
|
-
} else if ((0,
|
|
35562
|
+
} else if ((0, import_node_fs5.existsSync)("agent.properties")) {
|
|
35346
35563
|
args = readPropertiesFile("agent.properties");
|
|
35347
35564
|
} else {
|
|
35348
35565
|
console.log("Missing arguments");
|
|
@@ -35390,109 +35607,10 @@ function readCommandLineArgs(argv) {
|
|
|
35390
35607
|
}
|
|
35391
35608
|
function readPropertiesFile(fileName) {
|
|
35392
35609
|
return Object.fromEntries(
|
|
35393
|
-
(0,
|
|
35610
|
+
(0, import_node_fs5.readFileSync)(fileName).toString().split("\n").map((line) => line.split("=").map((s) => s.trim()))
|
|
35394
35611
|
);
|
|
35395
35612
|
}
|
|
35396
35613
|
|
|
35397
|
-
// src/pid.ts
|
|
35398
|
-
var import_node_fs5 = __toESM(require("node:fs"));
|
|
35399
|
-
var import_node_os4 = require("node:os");
|
|
35400
|
-
var import_node_path3 = __toESM(require("node:path"));
|
|
35401
|
-
var import_node_process2 = __toESM(require("node:process"));
|
|
35402
|
-
var EXIT_SIGNALS = ["SIGINT", "SIGTERM", "SIGHUP"];
|
|
35403
|
-
var pidLogger = new oo((msg) => `[PID]: ${msg}`);
|
|
35404
|
-
var pidFilePaths = /* @__PURE__ */ new Set();
|
|
35405
|
-
var processExitListener = () => {
|
|
35406
|
-
removeAllPidFiles();
|
|
35407
|
-
};
|
|
35408
|
-
var signalListener = () => {
|
|
35409
|
-
removeAllPidFiles();
|
|
35410
|
-
import_node_process2.default.exit(0);
|
|
35411
|
-
};
|
|
35412
|
-
var uncaughtExceptionListener = (err) => {
|
|
35413
|
-
pidLogger.error("Uncaught exception:", err);
|
|
35414
|
-
removeAllPidFiles();
|
|
35415
|
-
import_node_process2.default.exit(1);
|
|
35416
|
-
};
|
|
35417
|
-
var agentCleanupSetup = false;
|
|
35418
|
-
function getPidFilePath(appName) {
|
|
35419
|
-
switch ((0, import_node_os4.platform)()) {
|
|
35420
|
-
case "linux":
|
|
35421
|
-
case "darwin":
|
|
35422
|
-
return import_node_path3.default.join((0, import_node_os4.tmpdir)(), "medplum-agent", `${appName}.pid`);
|
|
35423
|
-
case "win32":
|
|
35424
|
-
return import_node_path3.default.join("C:", "ProgramData", "MedplumAgent", "pids", `${appName}.pid`);
|
|
35425
|
-
default:
|
|
35426
|
-
throw new Error("Invalid OS");
|
|
35427
|
-
}
|
|
35428
|
-
}
|
|
35429
|
-
function removePidFile(pidFilePath) {
|
|
35430
|
-
if (import_node_fs5.default.existsSync(pidFilePath)) {
|
|
35431
|
-
try {
|
|
35432
|
-
import_node_fs5.default.unlinkSync(pidFilePath);
|
|
35433
|
-
pidLogger.info(`PID file removed: ${pidFilePath}`);
|
|
35434
|
-
} catch (err) {
|
|
35435
|
-
pidLogger.error(`Error removing PID file: ${pidFilePath}`, err);
|
|
35436
|
-
}
|
|
35437
|
-
}
|
|
35438
|
-
pidFilePaths.delete(pidFilePath);
|
|
35439
|
-
}
|
|
35440
|
-
function checkProcessExists(pid) {
|
|
35441
|
-
try {
|
|
35442
|
-
import_node_process2.default.kill(pid, 0);
|
|
35443
|
-
return true;
|
|
35444
|
-
} catch (err) {
|
|
35445
|
-
if (err.code === "ESRCH") {
|
|
35446
|
-
return false;
|
|
35447
|
-
}
|
|
35448
|
-
if (err.code === "EPERM") {
|
|
35449
|
-
return true;
|
|
35450
|
-
}
|
|
35451
|
-
throw err;
|
|
35452
|
-
}
|
|
35453
|
-
}
|
|
35454
|
-
function createPidFile(appName) {
|
|
35455
|
-
const pid = import_node_process2.default.pid;
|
|
35456
|
-
const pidFilePath = getPidFilePath(appName);
|
|
35457
|
-
if (import_node_fs5.default.existsSync(pidFilePath)) {
|
|
35458
|
-
const existingPid = import_node_fs5.default.readFileSync(pidFilePath, "utf8").trim();
|
|
35459
|
-
pidLogger.info("Checking if process is running");
|
|
35460
|
-
if (checkProcessExists(Number.parseInt(existingPid, 10))) {
|
|
35461
|
-
throw new Error(`${appName} already running`);
|
|
35462
|
-
}
|
|
35463
|
-
pidLogger.info("Stale PID file found. Overwriting...");
|
|
35464
|
-
import_node_fs5.default.unlinkSync(pidFilePath);
|
|
35465
|
-
}
|
|
35466
|
-
ensureDirectoryExists(import_node_path3.default.dirname(pidFilePath));
|
|
35467
|
-
import_node_fs5.default.writeFileSync(pidFilePath, pid.toString(), { flag: "wx" });
|
|
35468
|
-
pidLogger.info(`PID file created at: ${pidFilePath}`);
|
|
35469
|
-
pidFilePaths.add(pidFilePath);
|
|
35470
|
-
return pidFilePath;
|
|
35471
|
-
}
|
|
35472
|
-
function ensureDirectoryExists(directoryPath) {
|
|
35473
|
-
if (!import_node_fs5.default.existsSync(directoryPath)) {
|
|
35474
|
-
import_node_fs5.default.mkdirSync(directoryPath, { recursive: true });
|
|
35475
|
-
pidLogger.info(`Directory created: ${directoryPath}`);
|
|
35476
|
-
} else {
|
|
35477
|
-
pidLogger.info(`Directory already exists: ${directoryPath}`);
|
|
35478
|
-
}
|
|
35479
|
-
}
|
|
35480
|
-
function removeAllPidFiles() {
|
|
35481
|
-
for (const pidFilePath of pidFilePaths) {
|
|
35482
|
-
removePidFile(pidFilePath);
|
|
35483
|
-
}
|
|
35484
|
-
}
|
|
35485
|
-
function registerAgentCleanup() {
|
|
35486
|
-
if (!agentCleanupSetup) {
|
|
35487
|
-
import_node_process2.default.on("exit", processExitListener);
|
|
35488
|
-
for (const signal of EXIT_SIGNALS) {
|
|
35489
|
-
import_node_process2.default.on(signal, signalListener);
|
|
35490
|
-
}
|
|
35491
|
-
import_node_process2.default.on("uncaughtException", uncaughtExceptionListener);
|
|
35492
|
-
agentCleanupSetup = true;
|
|
35493
|
-
}
|
|
35494
|
-
}
|
|
35495
|
-
|
|
35496
35614
|
// src/upgrader.ts
|
|
35497
35615
|
var import_node_child_process2 = require("node:child_process");
|
|
35498
35616
|
var import_node_fs6 = require("node:fs");
|
|
@@ -35510,11 +35628,8 @@ async function upgraderMain(argv) {
|
|
|
35510
35628
|
let rejectOnTimeout;
|
|
35511
35629
|
const disconnectedPromise = new Promise((resolve2, reject) => {
|
|
35512
35630
|
rejectOnTimeout = () => reject(new Error("Timed out while waiting for IPC to disconnect"));
|
|
35513
|
-
import_node_process3.default.once("disconnect",
|
|
35514
|
-
resolve2();
|
|
35515
|
-
});
|
|
35631
|
+
import_node_process3.default.once("disconnect", resolve2);
|
|
35516
35632
|
});
|
|
35517
|
-
import_node_process3.default.send({ type: "STARTED" });
|
|
35518
35633
|
if (argv[3] && !Pc(argv[3])) {
|
|
35519
35634
|
throw new Error("Invalid version specified");
|
|
35520
35635
|
}
|
|
@@ -35525,20 +35640,14 @@ async function upgraderMain(argv) {
|
|
|
35525
35640
|
await downloadRelease(version, binPath);
|
|
35526
35641
|
globalLogger.info("Release successfully downloaded");
|
|
35527
35642
|
}
|
|
35643
|
+
import_node_process3.default.send({ type: "STARTED" });
|
|
35528
35644
|
globalLogger.info("Waiting for parent to disconnect from IPC...");
|
|
35529
35645
|
const disconnectTimeout = setTimeout(rejectOnTimeout, 5e3);
|
|
35530
35646
|
await disconnectedPromise;
|
|
35531
35647
|
clearTimeout(disconnectTimeout);
|
|
35532
|
-
try {
|
|
35533
|
-
globalLogger.info("Stopping running agent service...");
|
|
35534
|
-
(0, import_node_child_process2.execSync)('net stop "Medplum Agent"');
|
|
35535
|
-
globalLogger.info("Agent service stopped succesfully");
|
|
35536
|
-
} catch (_err) {
|
|
35537
|
-
globalLogger.info("Agent service not running, skipping stopping the service");
|
|
35538
|
-
}
|
|
35539
35648
|
try {
|
|
35540
35649
|
globalLogger.info("Running installer silently", { binPath });
|
|
35541
|
-
(0, import_node_child_process2.spawnSync)(binPath
|
|
35650
|
+
(0, import_node_child_process2.spawnSync)(`"${binPath}" /S`, { windowsHide: true, shell: true });
|
|
35542
35651
|
globalLogger.info(`Agent version ${version} successfully installed`);
|
|
35543
35652
|
} catch (err) {
|
|
35544
35653
|
globalLogger.error(`Error while attempting to run installer: ${Oe(err)}`);
|
|
@@ -35555,11 +35664,65 @@ async function upgraderMain(argv) {
|
|
|
35555
35664
|
}
|
|
35556
35665
|
|
|
35557
35666
|
// src/main.ts
|
|
35667
|
+
var TEMP_LOG_FILE = import_node_path4.default.join(
|
|
35668
|
+
(0, import_node_path4.dirname)(UPGRADE_MANIFEST_PATH),
|
|
35669
|
+
`stop-service-logs-${(/* @__PURE__ */ new Date()).toISOString().replace(/:\s*/g, "-")}.txt`
|
|
35670
|
+
);
|
|
35558
35671
|
async function main(argv) {
|
|
35559
35672
|
registerAgentCleanup();
|
|
35560
35673
|
if (argv[2] === "--upgrade") {
|
|
35561
35674
|
createPidFile("medplum-agent-upgrader");
|
|
35562
35675
|
await upgraderMain(argv);
|
|
35676
|
+
} else if (argv[2] === "--remove-old-services") {
|
|
35677
|
+
const logFileFd = (0, import_node_fs7.openSync)(TEMP_LOG_FILE, "a");
|
|
35678
|
+
let allAgentServices = [];
|
|
35679
|
+
const currentServiceName = `MedplumAgent_${Yr}`;
|
|
35680
|
+
while (!allAgentServices.includes(currentServiceName)) {
|
|
35681
|
+
const output = (0, import_node_child_process3.execSync)('cmd.exe /c sc query type= service state= all | findstr /i "SERVICE_NAME.*MedplumAgent"');
|
|
35682
|
+
(0, import_node_fs7.appendFileSync)(logFileFd, `${output}\r
|
|
35683
|
+
`, { encoding: "utf-8" });
|
|
35684
|
+
allAgentServices = output.toString().trim().split("\n").map((line) => line.replace("SERVICE_NAME: ", "").trim());
|
|
35685
|
+
(0, import_node_fs7.appendFileSync)(logFileFd, `All services: \r
|
|
35686
|
+
${allAgentServices.join("\r\n")}\r
|
|
35687
|
+
`, { encoding: "utf-8" });
|
|
35688
|
+
}
|
|
35689
|
+
const servicesToRemove = argv[3] === "--all" ? allAgentServices : allAgentServices.filter((serviceName) => serviceName !== `MedplumAgent_${Yr}`);
|
|
35690
|
+
(0, import_node_fs7.appendFileSync)(logFileFd, `Medplum agent service to filter out: MedplumAgent_${Yr}\r
|
|
35691
|
+
`, {
|
|
35692
|
+
encoding: "utf-8"
|
|
35693
|
+
});
|
|
35694
|
+
for (const serviceName of servicesToRemove) {
|
|
35695
|
+
try {
|
|
35696
|
+
(0, import_node_child_process3.execSync)(`net stop ${serviceName}`);
|
|
35697
|
+
(0, import_node_fs7.appendFileSync)(logFileFd, `${serviceName} stopped\r
|
|
35698
|
+
`, { encoding: "utf-8" });
|
|
35699
|
+
console.log(`${serviceName} stopped`);
|
|
35700
|
+
} catch (err) {
|
|
35701
|
+
(0, import_node_fs7.appendFileSync)(logFileFd, `Failed to stop service: ${serviceName}\r
|
|
35702
|
+
`, { encoding: "utf-8" });
|
|
35703
|
+
(0, import_node_fs7.appendFileSync)(logFileFd, `${Oe(err)}\r
|
|
35704
|
+
`, { encoding: "utf-8" });
|
|
35705
|
+
console.error(`Failed to stop service: ${serviceName}`);
|
|
35706
|
+
console.error(Oe(err));
|
|
35707
|
+
}
|
|
35708
|
+
try {
|
|
35709
|
+
(0, import_node_child_process3.execSync)(`sc.exe delete ${serviceName}`);
|
|
35710
|
+
(0, import_node_fs7.appendFileSync)(logFileFd, `${serviceName} deleted\r
|
|
35711
|
+
`, { encoding: "utf-8" });
|
|
35712
|
+
console.log(`${serviceName} deleted`);
|
|
35713
|
+
} catch (err) {
|
|
35714
|
+
(0, import_node_fs7.appendFileSync)(logFileFd, `Failed to delete service: ${serviceName}\r
|
|
35715
|
+
`, { encoding: "utf-8" });
|
|
35716
|
+
(0, import_node_fs7.appendFileSync)(logFileFd, `${Oe(err)}\r
|
|
35717
|
+
`, { encoding: "utf-8" });
|
|
35718
|
+
console.error(`Failed to delete service: ${serviceName}`);
|
|
35719
|
+
console.error(Oe(err));
|
|
35720
|
+
}
|
|
35721
|
+
}
|
|
35722
|
+
(0, import_node_fs7.closeSync)(logFileFd);
|
|
35723
|
+
} else if ((0, import_node_fs7.existsSync)(UPGRADE_MANIFEST_PATH)) {
|
|
35724
|
+
createPidFile("medplum-upgrading-agent");
|
|
35725
|
+
await agentMain(argv);
|
|
35563
35726
|
} else {
|
|
35564
35727
|
createPidFile("medplum-agent");
|
|
35565
35728
|
await agentMain(argv);
|