@medplum/agent 2.0.28 → 2.0.29

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.
@@ -0,0 +1 @@
1
+ {"type": "commonjs"}
package/esbuild.mjs ADDED
@@ -0,0 +1,28 @@
1
+ /* global console */
2
+ /* eslint no-console: "off" */
3
+
4
+ import esbuild from 'esbuild';
5
+ import { writeFileSync } from 'fs';
6
+
7
+ const options = {
8
+ entryPoints: ['./src/main.ts'],
9
+ bundle: true,
10
+ platform: 'node',
11
+ loader: { '.js': 'js', '.ts': 'ts' },
12
+ resolveExtensions: ['.js', '.ts'],
13
+ target: 'es2021',
14
+ tsconfig: 'tsconfig.json',
15
+ external: ['iconv-lite', 'pdfmake'],
16
+ };
17
+
18
+ // The single executable application feature only supports running a single embedded CommonJS file.
19
+ // https://nodejs.org/dist/latest-v18.x/docs/api/single-executable-applications.html
20
+
21
+ esbuild
22
+ .build({
23
+ ...options,
24
+ format: 'cjs',
25
+ outfile: './dist/cjs/index.cjs',
26
+ })
27
+ .then(() => writeFileSync('./dist/cjs/package.json', '{"type": "commonjs"}'))
28
+ .catch(console.error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@medplum/agent",
3
- "version": "2.0.28",
3
+ "version": "2.0.29",
4
4
  "description": "Medplum Agent",
5
5
  "author": "Medplum <hello@medplum.com>",
6
6
  "license": "Apache-2.0",
@@ -15,8 +15,9 @@
15
15
  },
16
16
  "scripts": {
17
17
  "clean": "rimraf dist",
18
- "build": "npm run clean && tsc",
19
- "test": "jest"
18
+ "build": "npm run clean && tsc && node esbuild.mjs",
19
+ "test": "jest",
20
+ "package": "pkg ./dist/cjs/index.cjs --targets node18-win-x64 --output dist/medplum-agent-win-x64.exe"
20
21
  },
21
22
  "dependencies": {
22
23
  "@medplum/core": "*",
package/src/main.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MedplumClient, normalizeErrorString } from '@medplum/core';
1
+ import { ContentType, MedplumClient, normalizeErrorString } from '@medplum/core';
2
2
  import { Bot } from '@medplum/fhirtypes';
3
3
  import { Hl7MessageEvent, Hl7Server } from '@medplum/hl7';
4
4
  import { EventLogger } from 'node-windows';
@@ -8,8 +8,6 @@ const log = new EventLogger({
8
8
  eventLog: 'SYSTEM',
9
9
  });
10
10
 
11
- const HL7_CONTENT_TYPE = 'x-application/hl7-v2+er7';
12
-
13
11
  export class App {
14
12
  readonly log: EventLogger;
15
13
  readonly server: Hl7Server;
@@ -39,17 +37,17 @@ export class App {
39
37
  private async handler(event: Hl7MessageEvent): Promise<void> {
40
38
  try {
41
39
  console.log('Received:');
42
- console.log(event.message.toString());
40
+ console.log(event.message.toString().replaceAll('\r', '\n'));
43
41
 
44
42
  await this.medplum.post(
45
43
  this.medplum.fhirUrl('Bot', this.bot.id as string, '$execute'),
46
44
  event.message.toString(),
47
- HL7_CONTENT_TYPE
45
+ ContentType.HL7_V2
48
46
  );
49
47
 
50
48
  const ack = event.message.buildAck();
51
49
  console.log('Response:');
52
- console.log(ack.toString());
50
+ console.log(ack.toString().replaceAll('\r', '\n'));
53
51
  event.send(ack);
54
52
  } catch (err) {
55
53
  console.log('HL7 error', err);