@fhirust/sdk 0.2.0
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/bin/cli.d.ts +10 -0
- package/dist/bin/cli.d.ts.map +1 -0
- package/dist/bin/cli.js +217 -0
- package/dist/bin/cli.js.map +1 -0
- package/dist/events.d.ts +18 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +22 -0
- package/dist/events.js.map +1 -0
- package/dist/fhir-client.d.ts +80 -0
- package/dist/fhir-client.d.ts.map +1 -0
- package/dist/fhir-client.js +65 -0
- package/dist/fhir-client.js.map +1 -0
- package/dist/helpers.d.ts +19 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +38 -0
- package/dist/helpers.js.map +1 -0
- package/dist/http-client.d.ts +63 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +98 -0
- package/dist/http-client.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +22 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +27 -0
- package/dist/logger.js.map +1 -0
- package/dist/plugin.d.ts +70 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +219 -0
- package/dist/plugin.js.map +1 -0
- package/dist/r4/allergy-intolerance.d.ts +37 -0
- package/dist/r4/allergy-intolerance.d.ts.map +1 -0
- package/dist/r4/allergy-intolerance.js +2 -0
- package/dist/r4/allergy-intolerance.js.map +1 -0
- package/dist/r4/common.d.ts +148 -0
- package/dist/r4/common.d.ts.map +1 -0
- package/dist/r4/common.js +5 -0
- package/dist/r4/common.js.map +1 -0
- package/dist/r4/condition.d.ts +42 -0
- package/dist/r4/condition.d.ts.map +1 -0
- package/dist/r4/condition.js +2 -0
- package/dist/r4/condition.js.map +1 -0
- package/dist/r4/diagnostic-report.d.ts +31 -0
- package/dist/r4/diagnostic-report.d.ts.map +1 -0
- package/dist/r4/diagnostic-report.js +2 -0
- package/dist/r4/diagnostic-report.js.map +1 -0
- package/dist/r4/encounter.d.ts +66 -0
- package/dist/r4/encounter.d.ts.map +1 -0
- package/dist/r4/encounter.js +2 -0
- package/dist/r4/encounter.js.map +1 -0
- package/dist/r4/index.d.ts +19 -0
- package/dist/r4/index.d.ts.map +1 -0
- package/dist/r4/index.js +9 -0
- package/dist/r4/index.js.map +1 -0
- package/dist/r4/medication-request.d.ts +54 -0
- package/dist/r4/medication-request.d.ts.map +1 -0
- package/dist/r4/medication-request.js +2 -0
- package/dist/r4/medication-request.js.map +1 -0
- package/dist/r4/observation.d.ts +65 -0
- package/dist/r4/observation.d.ts.map +1 -0
- package/dist/r4/observation.js +2 -0
- package/dist/r4/observation.js.map +1 -0
- package/dist/r4/organization.d.ts +24 -0
- package/dist/r4/organization.d.ts.map +1 -0
- package/dist/r4/organization.js +2 -0
- package/dist/r4/organization.js.map +1 -0
- package/dist/r4/patient.d.ts +43 -0
- package/dist/r4/patient.d.ts.map +1 -0
- package/dist/r4/patient.js +2 -0
- package/dist/r4/patient.js.map +1 -0
- package/dist/r4/practitioner.d.ts +24 -0
- package/dist/r4/practitioner.d.ts.map +1 -0
- package/dist/r4/practitioner.js +2 -0
- package/dist/r4/practitioner.js.map +1 -0
- package/dist/r4/procedure.d.ts +42 -0
- package/dist/r4/procedure.d.ts.map +1 -0
- package/dist/r4/procedure.js +2 -0
- package/dist/r4/procedure.js.map +1 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +30 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -0
- package/wit/plugin.wit +114 -0
- package/wit/world.wit +12 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ergonomic HTTP client wrapper over the WIT http.fetch import.
|
|
3
|
+
*
|
|
4
|
+
* Usage inside hooks:
|
|
5
|
+
* const resp = plugin.http.post("https://example.com/webhook", {
|
|
6
|
+
* body: { event: "patient-created", id: "123" },
|
|
7
|
+
* timeout: 3000,
|
|
8
|
+
* });
|
|
9
|
+
* if (resp.ok) { ... }
|
|
10
|
+
*/
|
|
11
|
+
export class HttpResponse {
|
|
12
|
+
status;
|
|
13
|
+
headers;
|
|
14
|
+
body;
|
|
15
|
+
constructor(status, headers, body) {
|
|
16
|
+
this.status = status;
|
|
17
|
+
this.headers = headers;
|
|
18
|
+
this.body = body;
|
|
19
|
+
}
|
|
20
|
+
/** True if status is 200-299 */
|
|
21
|
+
get ok() {
|
|
22
|
+
return this.status >= 200 && this.status < 300;
|
|
23
|
+
}
|
|
24
|
+
/** Parse body as JSON */
|
|
25
|
+
json() {
|
|
26
|
+
return JSON.parse(this.body);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export class HttpClientError extends Error {
|
|
30
|
+
constructor(message) {
|
|
31
|
+
super(message);
|
|
32
|
+
this.name = "HttpClientError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class HttpClient {
|
|
36
|
+
http = null;
|
|
37
|
+
/** @internal Called by FhirPlugin to inject WIT bindings */
|
|
38
|
+
_bind(http) {
|
|
39
|
+
this.http = http;
|
|
40
|
+
}
|
|
41
|
+
ensureBound() {
|
|
42
|
+
if (!this.http) {
|
|
43
|
+
throw new Error("HTTP client not available — host did not provide http bindings");
|
|
44
|
+
}
|
|
45
|
+
return this.http;
|
|
46
|
+
}
|
|
47
|
+
doFetch(url, method, options = {}) {
|
|
48
|
+
const headers = [];
|
|
49
|
+
if (options.headers) {
|
|
50
|
+
for (const [k, v] of Object.entries(options.headers)) {
|
|
51
|
+
headers.push([k, v]);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
let body;
|
|
55
|
+
if (options.body !== undefined) {
|
|
56
|
+
if (typeof options.body === "string") {
|
|
57
|
+
body = options.body;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
body = JSON.stringify(options.body);
|
|
61
|
+
// Auto-add Content-Type if not set
|
|
62
|
+
if (!headers.some(([k]) => k.toLowerCase() === "content-type")) {
|
|
63
|
+
headers.push(["Content-Type", "application/json"]);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const timeout = options.timeout ?? 5000;
|
|
68
|
+
const result = this.ensureBound().fetch(url, method, headers, body, timeout);
|
|
69
|
+
if (result.tag === "err") {
|
|
70
|
+
throw new HttpClientError(result.val);
|
|
71
|
+
}
|
|
72
|
+
const respHeaders = {};
|
|
73
|
+
for (const [k, v] of result.val.headers) {
|
|
74
|
+
respHeaders[k] = v;
|
|
75
|
+
}
|
|
76
|
+
return new HttpResponse(result.val.status, respHeaders, result.val.body);
|
|
77
|
+
}
|
|
78
|
+
get(url, options) {
|
|
79
|
+
return this.doFetch(url, "GET", options);
|
|
80
|
+
}
|
|
81
|
+
post(url, options) {
|
|
82
|
+
return this.doFetch(url, "POST", options);
|
|
83
|
+
}
|
|
84
|
+
put(url, options) {
|
|
85
|
+
return this.doFetch(url, "PUT", options);
|
|
86
|
+
}
|
|
87
|
+
delete(url, options) {
|
|
88
|
+
return this.doFetch(url, "DELETE", options);
|
|
89
|
+
}
|
|
90
|
+
patch(url, options) {
|
|
91
|
+
return this.doFetch(url, "PATCH", options);
|
|
92
|
+
}
|
|
93
|
+
/** Raw fetch matching the WIT signature more closely */
|
|
94
|
+
fetch(url, options) {
|
|
95
|
+
return this.doFetch(url, options.method, options);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=http-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../src/http-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA2BH,MAAM,OAAO,YAAY;IACd,MAAM,CAAS;IACf,OAAO,CAAyB;IAChC,IAAI,CAAS;IAEtB,YAAY,MAAc,EAAE,OAA+B,EAAE,IAAY;QACvE,IAAI,CAAC,MAAM,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,CAAC;IAC3C,CAAC;IAED,IAAI,CAAC,GAAW,EAAE,OAAwB;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,OAAwB;QACvC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,GAAW,EAAE,OAAwB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,OAAwB;QACzC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IAC7C,CAAC;IAED,wDAAwD;IACxD,KAAK,CAAC,GAAW,EAAE,OAA4C;QAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpD,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fhirust/sdk — TypeScript SDK for building FHIRust WASM plugins.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { FhirPlugin, reject } from "@fhirust/sdk";
|
|
6
|
+
* import type { Patient } from "@fhirust/sdk/r4";
|
|
7
|
+
*
|
|
8
|
+
* const plugin = new FhirPlugin("my-plugin", "1.0.0");
|
|
9
|
+
*
|
|
10
|
+
* plugin.beforeCreate<Patient>("Patient", (patient, ctx) => {
|
|
11
|
+
* if (!patient.name?.length) return reject("Patient must have at least one name");
|
|
12
|
+
* patient.meta.tag.push({ system: "http://example.com", code: "validated" });
|
|
13
|
+
* return patient;
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* export const { getMetadata, executeHook } = plugin.exports();
|
|
17
|
+
*/
|
|
18
|
+
export { FhirPlugin } from "./plugin.js";
|
|
19
|
+
export { reject, outcome } from "./helpers.js";
|
|
20
|
+
export { FhirClient, FhirClientError } from "./fhir-client.js";
|
|
21
|
+
export { HttpClient, HttpResponse, HttpClientError } from "./http-client.js";
|
|
22
|
+
export { Logger } from "./logger.js";
|
|
23
|
+
export { EventEmitter } from "./events.js";
|
|
24
|
+
export type { HookType, HookContext, BeforeHook, AfterHook, BeforeReadHook, BeforeDeleteHook, AfterDeleteHook, OperationOutcome, OperationOutcomeIssue, Bundle, BundleEntry, BundleLink, } from "./types.js";
|
|
25
|
+
export { Rejection } from "./types.js";
|
|
26
|
+
export type { RequestOptions } from "./http-client.js";
|
|
27
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAG3C,YAAY,EACV,QAAQ,EACR,WAAW,EACX,UAAU,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,MAAM,EACN,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fhirust/sdk — TypeScript SDK for building FHIRust WASM plugins.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import { FhirPlugin, reject } from "@fhirust/sdk";
|
|
6
|
+
* import type { Patient } from "@fhirust/sdk/r4";
|
|
7
|
+
*
|
|
8
|
+
* const plugin = new FhirPlugin("my-plugin", "1.0.0");
|
|
9
|
+
*
|
|
10
|
+
* plugin.beforeCreate<Patient>("Patient", (patient, ctx) => {
|
|
11
|
+
* if (!patient.name?.length) return reject("Patient must have at least one name");
|
|
12
|
+
* patient.meta.tag.push({ system: "http://example.com", code: "validated" });
|
|
13
|
+
* return patient;
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* export const { getMetadata, executeHook } = plugin.exports();
|
|
17
|
+
*/
|
|
18
|
+
// Main class
|
|
19
|
+
export { FhirPlugin } from "./plugin.js";
|
|
20
|
+
// Helpers
|
|
21
|
+
export { reject, outcome } from "./helpers.js";
|
|
22
|
+
// Client wrappers (also accessible via plugin.fhir, plugin.http, etc.)
|
|
23
|
+
export { FhirClient, FhirClientError } from "./fhir-client.js";
|
|
24
|
+
export { HttpClient, HttpResponse, HttpClientError } from "./http-client.js";
|
|
25
|
+
export { Logger } from "./logger.js";
|
|
26
|
+
export { EventEmitter } from "./events.js";
|
|
27
|
+
export { Rejection } from "./types.js";
|
|
28
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,aAAa;AACb,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,UAAU;AACV,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE/C,uEAAuE;AACvE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAkB3C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed wrapper around the WIT utils.log function.
|
|
3
|
+
*
|
|
4
|
+
* Usage inside hooks:
|
|
5
|
+
* plugin.log.info("Patient created");
|
|
6
|
+
* plugin.log.warn("Missing identifier");
|
|
7
|
+
*/
|
|
8
|
+
/** Raw WIT utils interface */
|
|
9
|
+
export interface WitUtils {
|
|
10
|
+
log(level: string, message: string): void;
|
|
11
|
+
emitEvent(eventType: string, payload: string): void;
|
|
12
|
+
}
|
|
13
|
+
export declare class Logger {
|
|
14
|
+
private utils;
|
|
15
|
+
/** @internal Called by FhirPlugin to inject WIT bindings */
|
|
16
|
+
_bind(utils: WitUtils): void;
|
|
17
|
+
debug(message: string): void;
|
|
18
|
+
info(message: string): void;
|
|
19
|
+
warn(message: string): void;
|
|
20
|
+
error(message: string): void;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,8BAA8B;AAC9B,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;CACrD;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,KAAK,CAAyB;IAEtC,4DAA4D;IAC5D,KAAK,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAI5B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI5B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAI3B,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAG7B"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed wrapper around the WIT utils.log function.
|
|
3
|
+
*
|
|
4
|
+
* Usage inside hooks:
|
|
5
|
+
* plugin.log.info("Patient created");
|
|
6
|
+
* plugin.log.warn("Missing identifier");
|
|
7
|
+
*/
|
|
8
|
+
export class Logger {
|
|
9
|
+
utils = null;
|
|
10
|
+
/** @internal Called by FhirPlugin to inject WIT bindings */
|
|
11
|
+
_bind(utils) {
|
|
12
|
+
this.utils = utils;
|
|
13
|
+
}
|
|
14
|
+
debug(message) {
|
|
15
|
+
this.utils?.log("debug", message);
|
|
16
|
+
}
|
|
17
|
+
info(message) {
|
|
18
|
+
this.utils?.log("info", message);
|
|
19
|
+
}
|
|
20
|
+
warn(message) {
|
|
21
|
+
this.utils?.log("warn", message);
|
|
22
|
+
}
|
|
23
|
+
error(message) {
|
|
24
|
+
this.utils?.log("error", message);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH,MAAM,OAAO,MAAM;IACT,KAAK,GAAoB,IAAI,CAAC;IAEtC,4DAA4D;IAC5D,KAAK,CAAC,KAAe;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,OAAe;QACnB,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,IAAI,CAAC,OAAe;QAClB,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,OAAe;QACnB,IAAI,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IACpC,CAAC;CACF"}
|
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FhirPlugin — the main entry point for writing FHIRust plugins.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* const plugin = new FhirPlugin("my-plugin", "1.0.0");
|
|
6
|
+
*
|
|
7
|
+
* plugin.beforeCreate<Patient>("Patient", (patient, ctx) => {
|
|
8
|
+
* if (!patient.name?.length) return reject("Patient must have at least one name");
|
|
9
|
+
* return patient;
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* export const { getMetadata, executeHook } = plugin.exports();
|
|
13
|
+
*/
|
|
14
|
+
import { FhirClient } from "./fhir-client.js";
|
|
15
|
+
import { HttpClient } from "./http-client.js";
|
|
16
|
+
import { Logger } from "./logger.js";
|
|
17
|
+
import { EventEmitter } from "./events.js";
|
|
18
|
+
import { type HookType, type WitHookContext, type WitPluginMetadata, type WitResourceType, type WitResult, type BeforeHook, type AfterHook, type BeforeReadHook, type BeforeDeleteHook, type AfterDeleteHook } from "./types.js";
|
|
19
|
+
export declare class FhirPlugin {
|
|
20
|
+
private readonly name;
|
|
21
|
+
private readonly version;
|
|
22
|
+
private readonly handlers;
|
|
23
|
+
/** Typed FHIR data access client */
|
|
24
|
+
readonly fhir: FhirClient;
|
|
25
|
+
/** Typed HTTP client */
|
|
26
|
+
readonly http: HttpClient;
|
|
27
|
+
/** Structured logger */
|
|
28
|
+
readonly log: Logger;
|
|
29
|
+
/** Fire-and-forget event emitter */
|
|
30
|
+
readonly events: EventEmitter;
|
|
31
|
+
private bound;
|
|
32
|
+
constructor(name: string, version: string);
|
|
33
|
+
/** Register a before-create hook. Return the resource to modify, reject() to fail, or void to pass through. */
|
|
34
|
+
beforeCreate<T = any>(resourceType: string, handler: BeforeHook<T>): void;
|
|
35
|
+
/** Register an after-create hook. Observe only — return value is ignored. */
|
|
36
|
+
afterCreate<T = any>(resourceType: string, handler: AfterHook<T>): void;
|
|
37
|
+
/** Register a before-read hook. Can reject() to deny the read. */
|
|
38
|
+
beforeRead(resourceType: string, handler: BeforeReadHook): void;
|
|
39
|
+
/** Register an after-read hook. Observe or transform the returned resource. */
|
|
40
|
+
afterRead<T = any>(resourceType: string, handler: AfterHook<T>): void;
|
|
41
|
+
/** Register a before-update hook. Return the resource to modify, reject() to fail, or void to pass through. */
|
|
42
|
+
beforeUpdate<T = any>(resourceType: string, handler: BeforeHook<T>): void;
|
|
43
|
+
/** Register an after-update hook. Observe only. */
|
|
44
|
+
afterUpdate<T = any>(resourceType: string, handler: AfterHook<T>): void;
|
|
45
|
+
/** Register a before-delete hook. Can reject() to deny the delete. */
|
|
46
|
+
beforeDelete(resourceType: string, handler: BeforeDeleteHook): void;
|
|
47
|
+
/** Register an after-delete hook. Observe only. */
|
|
48
|
+
afterDelete(resourceType: string, handler: AfterDeleteHook): void;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the WIT-compatible exports that the user must re-export.
|
|
51
|
+
*
|
|
52
|
+
* The WIT world exports two interfaces: `lifecycle` and `hooks`.
|
|
53
|
+
* componentize-js expects these as named JS exports:
|
|
54
|
+
*
|
|
55
|
+
* export const { lifecycle, hooks } = plugin.exports();
|
|
56
|
+
*/
|
|
57
|
+
exports(): {
|
|
58
|
+
lifecycle: {
|
|
59
|
+
getMetadata: () => WitPluginMetadata;
|
|
60
|
+
};
|
|
61
|
+
hooks: {
|
|
62
|
+
executeHook: (hookType: HookType, resourceType: WitResourceType, resourceJson: string, context: WitHookContext) => WitResult;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
/** Lazily bind host services on first dispatch */
|
|
66
|
+
private bindIfNeeded;
|
|
67
|
+
private buildMetadata;
|
|
68
|
+
private dispatch;
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAgB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAgB,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAiB,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAIL,KAAK,QAAQ,EAEb,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACrB,MAAM,YAAY,CAAC;AAUpB,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsB;IAE/C,oCAAoC;IACpC,QAAQ,CAAC,IAAI,aAAoB;IACjC,wBAAwB;IACxB,QAAQ,CAAC,IAAI,aAAoB;IACjC,wBAAwB;IACxB,QAAQ,CAAC,GAAG,SAAgB;IAC5B,oCAAoC;IACpC,QAAQ,CAAC,MAAM,eAAsB;IAErC,OAAO,CAAC,KAAK,C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CAAC;KACH;IAkBD,kDAAkD;IAClD,OAAO,CAAC,YAAY;IA8BpB,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,QAAQ;CAwFjB"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FhirPlugin — the main entry point for writing FHIRust plugins.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* const plugin = new FhirPlugin("my-plugin", "1.0.0");
|
|
6
|
+
*
|
|
7
|
+
* plugin.beforeCreate<Patient>("Patient", (patient, ctx) => {
|
|
8
|
+
* if (!patient.name?.length) return reject("Patient must have at least one name");
|
|
9
|
+
* return patient;
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* export const { getMetadata, executeHook } = plugin.exports();
|
|
13
|
+
*/
|
|
14
|
+
import { FhirClient } from "./fhir-client.js";
|
|
15
|
+
import { HttpClient } from "./http-client.js";
|
|
16
|
+
import { Logger } from "./logger.js";
|
|
17
|
+
import { EventEmitter } from "./events.js";
|
|
18
|
+
import { Rejection, toWitResourceType, fromWitResourceType, } from "./types.js";
|
|
19
|
+
export class FhirPlugin {
|
|
20
|
+
name;
|
|
21
|
+
version;
|
|
22
|
+
handlers = [];
|
|
23
|
+
/** Typed FHIR data access client */
|
|
24
|
+
fhir = new FhirClient();
|
|
25
|
+
/** Typed HTTP client */
|
|
26
|
+
http = new HttpClient();
|
|
27
|
+
/** Structured logger */
|
|
28
|
+
log = new Logger();
|
|
29
|
+
/** Fire-and-forget event emitter */
|
|
30
|
+
events = new EventEmitter();
|
|
31
|
+
bound = false;
|
|
32
|
+
constructor(name, version) {
|
|
33
|
+
this.name = name;
|
|
34
|
+
this.version = version;
|
|
35
|
+
}
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
// Hook registration
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
/** Register a before-create hook. Return the resource to modify, reject() to fail, or void to pass through. */
|
|
40
|
+
beforeCreate(resourceType, handler) {
|
|
41
|
+
this.handlers.push({ resourceType, hookType: "before-create", handler });
|
|
42
|
+
}
|
|
43
|
+
/** Register an after-create hook. Observe only — return value is ignored. */
|
|
44
|
+
afterCreate(resourceType, handler) {
|
|
45
|
+
this.handlers.push({ resourceType, hookType: "after-create", handler });
|
|
46
|
+
}
|
|
47
|
+
/** Register a before-read hook. Can reject() to deny the read. */
|
|
48
|
+
beforeRead(resourceType, handler) {
|
|
49
|
+
this.handlers.push({ resourceType, hookType: "before-read", handler });
|
|
50
|
+
}
|
|
51
|
+
/** Register an after-read hook. Observe or transform the returned resource. */
|
|
52
|
+
afterRead(resourceType, handler) {
|
|
53
|
+
this.handlers.push({ resourceType, hookType: "after-read", handler });
|
|
54
|
+
}
|
|
55
|
+
/** Register a before-update hook. Return the resource to modify, reject() to fail, or void to pass through. */
|
|
56
|
+
beforeUpdate(resourceType, handler) {
|
|
57
|
+
this.handlers.push({ resourceType, hookType: "before-update", handler });
|
|
58
|
+
}
|
|
59
|
+
/** Register an after-update hook. Observe only. */
|
|
60
|
+
afterUpdate(resourceType, handler) {
|
|
61
|
+
this.handlers.push({ resourceType, hookType: "after-update", handler });
|
|
62
|
+
}
|
|
63
|
+
/** Register a before-delete hook. Can reject() to deny the delete. */
|
|
64
|
+
beforeDelete(resourceType, handler) {
|
|
65
|
+
this.handlers.push({ resourceType, hookType: "before-delete", handler });
|
|
66
|
+
}
|
|
67
|
+
/** Register an after-delete hook. Observe only. */
|
|
68
|
+
afterDelete(resourceType, handler) {
|
|
69
|
+
this.handlers.push({ resourceType, hookType: "after-delete", handler });
|
|
70
|
+
}
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
// WIT export wiring
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
/**
|
|
75
|
+
* Returns the WIT-compatible exports that the user must re-export.
|
|
76
|
+
*
|
|
77
|
+
* The WIT world exports two interfaces: `lifecycle` and `hooks`.
|
|
78
|
+
* componentize-js expects these as named JS exports:
|
|
79
|
+
*
|
|
80
|
+
* export const { lifecycle, hooks } = plugin.exports();
|
|
81
|
+
*/
|
|
82
|
+
exports() {
|
|
83
|
+
const self = this;
|
|
84
|
+
return {
|
|
85
|
+
lifecycle: {
|
|
86
|
+
getMetadata: () => self.buildMetadata(),
|
|
87
|
+
},
|
|
88
|
+
hooks: {
|
|
89
|
+
executeHook: (hookType, resourceType, resourceJson, context) => self.dispatch(hookType, resourceType, resourceJson, context),
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
// Internal
|
|
95
|
+
// ---------------------------------------------------------------------------
|
|
96
|
+
/** Lazily bind host services on first dispatch */
|
|
97
|
+
bindIfNeeded() {
|
|
98
|
+
if (this.bound)
|
|
99
|
+
return;
|
|
100
|
+
this.bound = true;
|
|
101
|
+
// componentize-js makes WIT imports available via the fhirust:plugin/ specifier.
|
|
102
|
+
// At runtime inside the WASM component, these are injected by the host.
|
|
103
|
+
// We access them through a try/catch since they may not be available during
|
|
104
|
+
// unit testing outside the WASM runtime.
|
|
105
|
+
try {
|
|
106
|
+
// The WIT imports are available as ambient globals injected by componentize-js.
|
|
107
|
+
// Different versions of componentize-js expose them differently, so we try
|
|
108
|
+
// multiple access patterns.
|
|
109
|
+
const g = globalThis;
|
|
110
|
+
// Pattern 1: componentize-js >= 0.14 puts imports on globalThis
|
|
111
|
+
const fhir = g.fhir ?? g["fhirust:plugin/fhir"];
|
|
112
|
+
const utils = g.utils ?? g["fhirust:plugin/utils"];
|
|
113
|
+
const http = g.http ?? g["fhirust:plugin/http"];
|
|
114
|
+
if (fhir)
|
|
115
|
+
this.fhir._bind(fhir);
|
|
116
|
+
if (utils) {
|
|
117
|
+
this.log._bind(utils);
|
|
118
|
+
this.events._bind(utils);
|
|
119
|
+
}
|
|
120
|
+
if (http)
|
|
121
|
+
this.http._bind(http);
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
// Running outside WASM — host services won't be available
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
buildMetadata() {
|
|
128
|
+
// Group handlers by resource type
|
|
129
|
+
const hooksByResource = new Map();
|
|
130
|
+
for (const entry of this.handlers) {
|
|
131
|
+
let hooks = hooksByResource.get(entry.resourceType);
|
|
132
|
+
if (!hooks) {
|
|
133
|
+
hooks = new Set();
|
|
134
|
+
hooksByResource.set(entry.resourceType, hooks);
|
|
135
|
+
}
|
|
136
|
+
hooks.add(entry.hookType);
|
|
137
|
+
}
|
|
138
|
+
const hooks = [];
|
|
139
|
+
for (const [resourceType, hookSet] of hooksByResource) {
|
|
140
|
+
hooks.push([toWitResourceType(resourceType), [...hookSet]]);
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
name: this.name,
|
|
144
|
+
version: this.version,
|
|
145
|
+
hooks,
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
dispatch(hookType, witResourceType, resourceJson, witContext) {
|
|
149
|
+
this.bindIfNeeded();
|
|
150
|
+
const resourceTypeName = fromWitResourceType(witResourceType);
|
|
151
|
+
// Find matching handler
|
|
152
|
+
const entry = this.handlers.find((h) => h.hookType === hookType && toWitResourceType(h.resourceType) === witResourceType);
|
|
153
|
+
if (!entry) {
|
|
154
|
+
// No handler — pass through
|
|
155
|
+
return { tag: "ok", val: { json: resourceJson } };
|
|
156
|
+
}
|
|
157
|
+
const ctx = {
|
|
158
|
+
requestId: witContext["request-id"],
|
|
159
|
+
userId: witContext["user-id"] ?? undefined,
|
|
160
|
+
timestamp: witContext.timestamp,
|
|
161
|
+
operation: witContext.operation,
|
|
162
|
+
};
|
|
163
|
+
try {
|
|
164
|
+
// Dispatch based on hook category
|
|
165
|
+
if (hookType === "before-read" || hookType === "before-delete") {
|
|
166
|
+
// These hooks get resource type + id (extracted from the JSON)
|
|
167
|
+
const parsed = JSON.parse(resourceJson);
|
|
168
|
+
const params = { resourceType: resourceTypeName, id: parsed.id ?? "" };
|
|
169
|
+
const result = entry.handler(params, ctx);
|
|
170
|
+
if (result instanceof Rejection) {
|
|
171
|
+
return { tag: "err", val: { json: JSON.stringify(result.outcome) } };
|
|
172
|
+
}
|
|
173
|
+
return { tag: "ok", val: { json: resourceJson } };
|
|
174
|
+
}
|
|
175
|
+
if (hookType === "after-delete") {
|
|
176
|
+
const parsed = JSON.parse(resourceJson);
|
|
177
|
+
const params = { resourceType: resourceTypeName, id: parsed.id ?? "" };
|
|
178
|
+
entry.handler(params, ctx);
|
|
179
|
+
return { tag: "ok", val: { json: resourceJson } };
|
|
180
|
+
}
|
|
181
|
+
if (hookType.startsWith("after-")) {
|
|
182
|
+
// After hooks: observe only, return value ignored
|
|
183
|
+
const resource = JSON.parse(resourceJson);
|
|
184
|
+
entry.handler(resource, ctx);
|
|
185
|
+
return { tag: "ok", val: { json: resourceJson } };
|
|
186
|
+
}
|
|
187
|
+
// Before hooks (before-create, before-update): can modify or reject
|
|
188
|
+
const resource = JSON.parse(resourceJson);
|
|
189
|
+
const result = entry.handler(resource, ctx);
|
|
190
|
+
if (result === undefined || result === null) {
|
|
191
|
+
// Pass-through
|
|
192
|
+
return { tag: "ok", val: { json: resourceJson } };
|
|
193
|
+
}
|
|
194
|
+
if (result instanceof Rejection) {
|
|
195
|
+
return { tag: "err", val: { json: JSON.stringify(result.outcome) } };
|
|
196
|
+
}
|
|
197
|
+
// Modified resource
|
|
198
|
+
return { tag: "ok", val: { json: JSON.stringify(result) } };
|
|
199
|
+
}
|
|
200
|
+
catch (err) {
|
|
201
|
+
return {
|
|
202
|
+
tag: "err",
|
|
203
|
+
val: {
|
|
204
|
+
json: JSON.stringify({
|
|
205
|
+
resourceType: "OperationOutcome",
|
|
206
|
+
issue: [
|
|
207
|
+
{
|
|
208
|
+
severity: "error",
|
|
209
|
+
code: "exception",
|
|
210
|
+
diagnostics: `Plugin "${this.name}" error: ${err?.message ?? String(err)}`,
|
|
211
|
+
},
|
|
212
|
+
],
|
|
213
|
+
}),
|
|
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C,SAAS,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;QAC9D,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO;gBACL,GAAG,EAAE,KAAK;gBACV,GAAG,EAAE;oBACH,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;wBACnB,YAAY,EAAE,kBAAkB;wBAChC,KAAK,EAAE;4BACL;gCACE,QAAQ,EAAE,OAAO;gCACjB,IAAI,EAAE,WAAW;gCACjB,WAAW,EAAE,WAAW,IAAI,CAAC,IAAI,YAAY,GAAG,EAAE,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE;6BAC3E;yBACF;qBACF,CAAC;iBACH;aACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Meta, Narrative, Identifier, CodeableConcept, Reference, Period, Age, Range, Annotation } from "./common.js";
|
|
2
|
+
export interface AllergyIntolerance {
|
|
3
|
+
resourceType: "AllergyIntolerance";
|
|
4
|
+
id?: string;
|
|
5
|
+
meta?: Meta;
|
|
6
|
+
text?: Narrative;
|
|
7
|
+
identifier?: Identifier[];
|
|
8
|
+
clinicalStatus?: CodeableConcept;
|
|
9
|
+
verificationStatus?: CodeableConcept;
|
|
10
|
+
type?: "allergy" | "intolerance";
|
|
11
|
+
category?: ("food" | "medication" | "environment" | "biologic")[];
|
|
12
|
+
criticality?: "low" | "high" | "unable-to-assess";
|
|
13
|
+
code?: CodeableConcept;
|
|
14
|
+
patient: Reference;
|
|
15
|
+
encounter?: Reference;
|
|
16
|
+
onsetDateTime?: string;
|
|
17
|
+
onsetAge?: Age;
|
|
18
|
+
onsetPeriod?: Period;
|
|
19
|
+
onsetRange?: Range;
|
|
20
|
+
onsetString?: string;
|
|
21
|
+
recordedDate?: string;
|
|
22
|
+
recorder?: Reference;
|
|
23
|
+
asserter?: Reference;
|
|
24
|
+
lastOccurrence?: string;
|
|
25
|
+
note?: Annotation[];
|
|
26
|
+
reaction?: AllergyIntoleranceReaction[];
|
|
27
|
+
}
|
|
28
|
+
export interface AllergyIntoleranceReaction {
|
|
29
|
+
substance?: CodeableConcept;
|
|
30
|
+
manifestation: CodeableConcept[];
|
|
31
|
+
description?: string;
|
|
32
|
+
onset?: string;
|
|
33
|
+
severity?: "mild" | "moderate" | "severe";
|
|
34
|
+
exposureRoute?: CodeableConcept;
|
|
35
|
+
note?: Annotation[];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=allergy-intolerance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allergy-intolerance.d.ts","sourceRoot":"","sources":["../../src/r4/allergy-intolerance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EACT,UAAU,EACV,eAAe,EACf,SAAS,EACT,MAAM,EACN,GAAG,EACH,KAAK,EACL,UAAU,EACX,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,oBAAoB,CAAC;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;IAC1B,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,kBAAkB,CAAC,EAAE,eAAe,CAAC;IACrC,IAAI,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IACjC,QAAQ,CAAC,EAAE,CAAC,MAAM,GAAG,YAAY,GAAG,aAAa,GAAG,UAAU,CAAC,EAAE,CAAC;IAClE,WAAW,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,kBAAkB,CAAC;IAClD,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,OAAO,EAAE,SAAS,CAAC;IACnB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,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