@medplum/agent 2.0.31 → 2.0.32

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.
@@ -5485,6 +5485,7 @@ var AgentHl7ChannelConnection = class {
5485
5485
  JSON.stringify({
5486
5486
  type: "connect",
5487
5487
  accessToken: medplum.getAccessToken(),
5488
+ agentId: channel.app.agentId,
5488
5489
  botId: Ro(channel.definition.targetReference)
5489
5490
  })
5490
5491
  );
@@ -5528,6 +5529,7 @@ var AgentHl7ChannelConnection = class {
5528
5529
  this.webSocket.send(
5529
5530
  JSON.stringify({
5530
5531
  type: "transmit",
5532
+ forwardedFor: this.hl7Connection.socket.remoteAddress,
5531
5533
  message: msg.toString()
5532
5534
  })
5533
5535
  );
package/installer.nsi CHANGED
@@ -30,11 +30,20 @@ RequestExecutionLevel admin
30
30
 
31
31
  Var WelcomeDialog
32
32
  Var WelcomeLabel
33
+ Var alreadyInstalled
33
34
  Var baseUrl
34
35
  Var clientId
35
36
  Var clientSecret
36
37
  Var agentId
37
38
 
39
+ # The onInit handler is called when the installer is nearly finished initializing.
40
+ # See: https://nsis.sourceforge.io/Reference/.onInit
41
+ Function .onInit
42
+ ${If} ${FileExists} "$INSTDIR\winsw.xml"
43
+ StrCpy $alreadyInstalled 1
44
+ ${EndIf}
45
+ FunctionEnd
46
+
38
47
  Page custom WelcomePage
39
48
  Page custom InputPage InputPageLeave
40
49
  Page instfiles
@@ -56,6 +65,10 @@ FunctionEnd
56
65
 
57
66
  # The InputPage captures all of the user input for the agent.
58
67
  Function InputPage
68
+ ${If} $alreadyInstalled == 1
69
+ Abort ; This skips the page
70
+ ${EndIf}
71
+
59
72
  nsDialogs::Create 1018
60
73
  Pop $0
61
74
 
@@ -91,29 +104,49 @@ Function InputPageLeave
91
104
  ${NSD_GetText} $R7 $agentId
92
105
  FunctionEnd
93
106
 
94
- # Do the actual installation.
95
- # Install all of the files.
96
- # Install the Windows Service.
107
+ # Main installation entry point.
97
108
  Section
98
109
  DetailPrint "${APP_NAME}"
110
+ SetOutPath "$INSTDIR"
99
111
 
100
- # Call userInfo plugin to get user info. The plugin puts the result in the stack
101
- userInfo::getAccountType
112
+ ${If} $alreadyInstalled == 1
113
+ Call UpgradeApp
114
+ ${Else}
115
+ Call InstallApp
116
+ ${EndIf}
102
117
 
103
- # Pop the result from the stack into $0
104
- Pop $0
118
+ SectionEnd
105
119
 
106
- # Compare the result with the string "Admin" to see if the user is admin.
107
- # If match, jump 3 lines down.
108
- strCmp $0 "Admin" +3
120
+ # Upgrade an existing installation.
121
+ # This only copies files, and restarts the Windows Service.
122
+ # It does not modify the existing configuration settings.
123
+ Function UpgradeApp
109
124
 
110
- # If there is not a match, print message and return
111
- DetailPrint "User is not admin: $0"
112
- return
125
+ # Stop the service
126
+ DetailPrint "Stopping service..."
127
+ ExecWait "winsw.exe stop --force" $1
128
+ DetailPrint "Stop service returned $1"
113
129
 
114
- # Otherwise, confirm and return
115
- DetailPrint "User is admin"
130
+ # Sleep for 3 seconds to let the service fully stop
131
+ # We cannot write the new version of the exe while the process is running
132
+ DetailPrint "Sleeping..."
133
+ Sleep 3000
116
134
 
135
+ # Copy the new files to the installation directory
136
+ File dist\medplum-agent-win-x64.exe
137
+ File README.md
138
+
139
+ # Start the service
140
+ DetailPrint "Starting service..."
141
+ ExecWait "winsw.exe start" $1
142
+ DetailPrint "Start service returned $1"
143
+
144
+ FunctionEnd
145
+
146
+ # Do the actual installation.
147
+ # Install all of the files.
148
+ # Install the Windows Service.
149
+ Function InstallApp
117
150
  # Print user input
118
151
  DetailPrint "Base URL: $baseUrl"
119
152
  DetailPrint "Client ID: $clientId"
@@ -121,7 +154,6 @@ Section
121
154
  DetailPrint "Agent ID: $agentId"
122
155
 
123
156
  # Copy the service files to the root directory
124
- SetOutPath "$INSTDIR"
125
157
  File ..\..\node_modules\node-windows\bin\winsw\winsw.exe
126
158
  File dist\medplum-agent-win-x64.exe
127
159
  File README.md
@@ -141,16 +173,12 @@ Section
141
173
 
142
174
  # Install the service
143
175
  DetailPrint "Installing service..."
144
- StrCpy $0 "winsw.exe install"
145
- #DetailPrint "$0"
146
- ExecWait $0 $1
176
+ ExecWait "winsw.exe install" $1
147
177
  DetailPrint "Install returned $1"
148
178
 
149
179
  # Start the service
150
180
  DetailPrint "Starting service..."
151
- StrCpy $0 "winsw.exe start"
152
- #DetailPrint "$0"
153
- ExecWait $0 $1
181
+ ExecWait "winsw.exe start" $1
154
182
  DetailPrint "Start service returned $1"
155
183
 
156
184
  # Create the uninstaller
@@ -170,8 +198,7 @@ Section
170
198
  CreateDirectory "$SMPROGRAMS\${APP_NAME}"
171
199
  CreateShortCut "$SMPROGRAMS\${APP_NAME}\${APP_NAME} Uninstall.lnk" "$INSTDIR\uninstall.exe"
172
200
 
173
- # default section end
174
- SectionEnd
201
+ FunctionEnd
175
202
 
176
203
  # Start the uninstaller
177
204
  Section Uninstall
@@ -179,9 +206,7 @@ Section Uninstall
179
206
  # Uninstall the service
180
207
  DetailPrint "Uninstalling service..."
181
208
  SetOutPath "$INSTDIR"
182
- StrCpy $0 "winsw.exe uninstall"
183
- #DetailPrint "$0"
184
- ExecWait $0 $1
209
+ ExecWait "winsw.exe uninstall" $1
185
210
  DetailPrint "Uninstall returned $1"
186
211
 
187
212
  # Get out of the service directory so we can delete it
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/agent",
3
- "version": "2.0.31",
3
+ "version": "2.0.32",
4
4
  "description": "Medplum Agent",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",
package/src/main.ts CHANGED
@@ -104,6 +104,7 @@ export class AgentHl7ChannelConnection {
104
104
  JSON.stringify({
105
105
  type: 'connect',
106
106
  accessToken: medplum.getAccessToken(),
107
+ agentId: channel.app.agentId,
107
108
  botId: resolveId(channel.definition.targetReference as Reference<Bot>),
108
109
  })
109
110
  );
@@ -150,6 +151,7 @@ export class AgentHl7ChannelConnection {
150
151
  this.webSocket.send(
151
152
  JSON.stringify({
152
153
  type: 'transmit',
154
+ forwardedFor: this.hl7Connection.socket.remoteAddress,
153
155
  message: msg.toString(),
154
156
  })
155
157
  );