@medplum/cli 0.9.4 → 0.9.5
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/index.d.ts +3 -3
- package/dist/index.js +78 -79
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { MedplumClient } from '@medplum/core';
|
|
3
|
-
export declare function main(medplum: MedplumClient, argv: string[]): Promise<void>;
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { MedplumClient } from '@medplum/core';
|
|
3
|
+
export declare function main(medplum: MedplumClient, argv: string[]): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -1,80 +1,79 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.main = void 0;
|
|
17
|
-
const core_1 = require("@medplum/core");
|
|
18
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
19
|
-
const fs_1 = require("fs");
|
|
20
|
-
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
21
|
-
const path_1 = require("path");
|
|
22
|
-
function main(medplum, argv) {
|
|
23
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
-
if (argv.length < 3) {
|
|
25
|
-
console.log('Usage: medplum <command>');
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const command = argv[2];
|
|
29
|
-
if (command === 'deploy-bot') {
|
|
30
|
-
yield deployBot(medplum, argv);
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
console.log(`Unknown command: ${command}`);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
exports.main = main;
|
|
38
|
-
function deployBot(medplum, argv) {
|
|
39
|
-
var _a;
|
|
40
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
if (argv.length < 5) {
|
|
42
|
-
console.log('Usage: medplum deploy-bot <bot-name> <bot-id>');
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const botId = argv[4];
|
|
46
|
-
if (!botId) {
|
|
47
|
-
console.log('Error: Bot ID is not set');
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const filePath = (0, path_1.resolve)(process.cwd(), argv[3]);
|
|
51
|
-
if (!(0, fs_1.existsSync)(filePath)) {
|
|
52
|
-
console.log('Error: Bot file does not exist: ' + filePath);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const bot = yield medplum.readResource('Bot', botId);
|
|
56
|
-
if (!bot) {
|
|
57
|
-
console.log('Error: Bot does not exist: ' + botId);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
.
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
14
|
+
};
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.main = void 0;
|
|
17
|
+
const core_1 = require("@medplum/core");
|
|
18
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
19
|
+
const fs_1 = require("fs");
|
|
20
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
21
|
+
const path_1 = require("path");
|
|
22
|
+
function main(medplum, argv) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
if (argv.length < 3) {
|
|
25
|
+
console.log('Usage: medplum <command>');
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const command = argv[2];
|
|
29
|
+
if (command === 'deploy-bot') {
|
|
30
|
+
yield deployBot(medplum, argv);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
console.log(`Unknown command: ${command}`);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.main = main;
|
|
38
|
+
function deployBot(medplum, argv) {
|
|
39
|
+
var _a;
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
if (argv.length < 5) {
|
|
42
|
+
console.log('Usage: medplum deploy-bot <bot-name> <bot-id>');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const botId = argv[4];
|
|
46
|
+
if (!botId) {
|
|
47
|
+
console.log('Error: Bot ID is not set');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const filePath = (0, path_1.resolve)(process.cwd(), argv[3]);
|
|
51
|
+
if (!(0, fs_1.existsSync)(filePath)) {
|
|
52
|
+
console.log('Error: Bot file does not exist: ' + filePath);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
const bot = yield medplum.readResource('Bot', botId);
|
|
56
|
+
if (!bot) {
|
|
57
|
+
console.log('Error: Bot does not exist: ' + botId);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
console.log('Update bot code.....');
|
|
62
|
+
const result = yield medplum.updateResource(Object.assign(Object.assign({}, bot), { code: (0, fs_1.readFileSync)(filePath, 'utf8') }));
|
|
63
|
+
console.log('Success! New bot version: ' + ((_a = result.meta) === null || _a === void 0 ? void 0 : _a.versionId));
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
console.log('Update error: ', err);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (require.main === module) {
|
|
71
|
+
dotenv_1.default.config();
|
|
72
|
+
const medplum = new core_1.MedplumClient({ fetch: node_fetch_1.default });
|
|
73
|
+
medplum
|
|
74
|
+
.clientCredentials(process.env['MEDPLUM_CLIENT_ID'], process.env['MEDPLUM_CLIENT_SECRET'])
|
|
75
|
+
.then(() => {
|
|
76
|
+
main(medplum, process.argv).catch((err) => console.error('Unhandled error:', err));
|
|
77
|
+
});
|
|
78
|
+
}
|
|
80
79
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3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AAG,GAAG,MAAM,OAAO,CAAC,YAAY,CAAM,KAAK,EAAE,KAAK,CAAC,CAAC;QAC1D,IAAI,CAAC,GAAG,EAAE;YACR,OAAO,CAAC,GAAG,CAAC,6BAA6B,GAAG,KAAK,CAAC,CAAC;YACnD,OAAO;SACR;QAED,IAAI;YACF,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;YACpC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,cAAc,iCACtC,GAAG,KACN,IAAI,EAAE,IAAA,iBAAY,EAAC,QAAQ,EAAE,MAAM,CAAC,IACpC,CAAC;YACH,OAAO,CAAC,GAAG,CAAC,4BAA4B,IAAG,MAAA,MAAM,CAAC,IAAI,0CAAE,SAAS,CAAA,CAAC,CAAC;SACpE;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAC;SACpC;;CACF;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;IAC3B,gBAAM,CAAC,MAAM,EAAE,CAAC;IAChB,MAAM,OAAO,GAAG,IAAI,oBAAa,CAAC,EAAE,KAAK,EAAL,oBAAK,EAAE,CAAC,CAAC;IAC7C,OAAO;SACJ,iBAAiB,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAW,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAW,CAAC;SAC7G,IAAI,CAAC,GAAG,EAAE;QACT,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC,CAAC;IACrF,CAAC,CAAC,CAAC;CACN","sourcesContent":["#!/usr/bin/env node\nimport { MedplumClient } from '@medplum/core';\nimport { Bot } from '@medplum/fhirtypes';\nimport dotenv from 'dotenv';\nimport { existsSync, readFileSync } from 'fs';\nimport fetch from 'node-fetch';\nimport { resolve } from 'path';\n\nexport async function main(medplum: MedplumClient, argv: string[]): Promise<void> {\n if (argv.length < 3) {\n console.log('Usage: medplum <command>');\n return;\n }\n\n const command = argv[2];\n if (command === 'deploy-bot') {\n await deployBot(medplum, argv);\n } else {\n console.log(`Unknown command: ${command}`);\n }\n}\n\nasync function deployBot(medplum: MedplumClient, argv: string[]): Promise<void> {\n if (argv.length < 5) {\n console.log('Usage: medplum deploy-bot <bot-name> <bot-id>');\n return;\n }\n\n const botId = argv[4];\n if (!botId) {\n console.log('Error: Bot ID is not set');\n return;\n }\n\n const filePath = resolve(process.cwd(), argv[3]);\n if (!existsSync(filePath)) {\n console.log('Error: Bot file does not exist: ' + filePath);\n return;\n }\n\n const bot = await medplum.readResource<Bot>('Bot', botId);\n if (!bot) {\n console.log('Error: Bot does not exist: ' + botId);\n return;\n }\n\n try {\n console.log('Update bot code.....');\n const result = await medplum.updateResource({\n ...bot,\n code: readFileSync(filePath, 'utf8'),\n });\n console.log('Success! New bot version: ' + result.meta?.versionId);\n } catch (err) {\n console.log('Update error: ', err);\n }\n}\n\nif (require.main === module) {\n dotenv.config();\n const medplum = new MedplumClient({ fetch });\n medplum\n .clientCredentials(process.env['MEDPLUM_CLIENT_ID'] as string, process.env['MEDPLUM_CLIENT_SECRET'] as string)\n .then(() => {\n main(medplum, process.argv).catch((err) => console.error('Unhandled error:', err));\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medplum/cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.5",
|
|
4
4
|
"description": "Medplum Command Line Interface",
|
|
5
5
|
"author": "Medplum <hello@medplum.com>",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"test": "jest"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@medplum/core": "0.9.
|
|
19
|
+
"@medplum/core": "0.9.5",
|
|
20
20
|
"dotenv": "16.0.0",
|
|
21
21
|
"node-fetch": "2.6.7"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@medplum/fhirtypes": "0.9.
|
|
25
|
-
"@medplum/mock": "0.9.
|
|
24
|
+
"@medplum/fhirtypes": "0.9.5",
|
|
25
|
+
"@medplum/mock": "0.9.5"
|
|
26
26
|
},
|
|
27
27
|
"bin": {
|
|
28
28
|
"medplum": "./dist/index.js"
|