@fhirfly-io/shl 0.3.1 → 0.4.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/{chunk-QXSWM5QV.cjs → chunk-JOZ6XZPO.cjs} +72 -5
- package/dist/chunk-JOZ6XZPO.cjs.map +1 -0
- package/dist/{chunk-ZEE5RXIS.js → chunk-KGEFZQ6W.js} +72 -5
- package/dist/chunk-KGEFZQ6W.js.map +1 -0
- package/dist/{chunk-63Q54EKN.cjs → chunk-SK77O3SG.cjs} +151 -35
- package/dist/chunk-SK77O3SG.cjs.map +1 -0
- package/dist/{chunk-YBDRWUQU.js → chunk-UU434UFQ.js} +151 -35
- package/dist/chunk-UU434UFQ.js.map +1 -0
- package/dist/cli.cjs +11 -11
- package/dist/cli.js +2 -2
- package/dist/express.cjs +12 -3
- package/dist/express.cjs.map +1 -1
- package/dist/express.d.cts +3 -2
- package/dist/express.d.ts +3 -2
- package/dist/express.js +11 -2
- package/dist/express.js.map +1 -1
- package/dist/fastify.cjs +22 -5
- package/dist/fastify.cjs.map +1 -1
- package/dist/fastify.d.cts +3 -2
- package/dist/fastify.d.ts +3 -2
- package/dist/fastify.js +21 -4
- package/dist/fastify.js.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +1 -1
- package/dist/lambda.cjs +4 -3
- package/dist/lambda.cjs.map +1 -1
- package/dist/lambda.d.cts +3 -2
- package/dist/lambda.d.ts +3 -2
- package/dist/lambda.js +3 -2
- package/dist/lambda.js.map +1 -1
- package/dist/server.cjs +2 -2
- package/dist/server.d.cts +4 -4
- package/dist/server.d.ts +4 -4
- package/dist/server.js +1 -1
- package/dist/{storage-BwszYwFo.d.cts → storage-BbzK-kFf.d.cts} +1 -1
- package/dist/{storage-B3GyJD2y.d.ts → storage-Cx7uXUl8.d.ts} +1 -1
- package/dist/{types-BegxU0wQ.d.ts → types-6Vw5fiat.d.ts} +7 -1
- package/dist/{types-Doq5cGNm.d.ts → types-BLLJeWe_.d.cts} +14 -0
- package/dist/{types-Doq5cGNm.d.cts → types-BLLJeWe_.d.ts} +14 -0
- package/dist/{types-hHf-a3hH.d.cts → types-Cdi4IkC9.d.cts} +7 -1
- package/package.json +3 -3
- package/dist/chunk-63Q54EKN.cjs.map +0 -1
- package/dist/chunk-QXSWM5QV.cjs.map +0 -1
- package/dist/chunk-YBDRWUQU.js.map +0 -1
- package/dist/chunk-ZEE5RXIS.js.map +0 -1
package/dist/express.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHandler } from './chunk-
|
|
1
|
+
import { createHandler } from './chunk-KGEFZQ6W.js';
|
|
2
2
|
import './chunk-PZ5AY32C.js';
|
|
3
3
|
|
|
4
4
|
// src/adapters/express.ts
|
|
@@ -9,7 +9,8 @@ function expressMiddleware(config) {
|
|
|
9
9
|
method: req.method,
|
|
10
10
|
path: req.path,
|
|
11
11
|
body: req.body,
|
|
12
|
-
headers: normalizeHeaders(req.headers)
|
|
12
|
+
headers: normalizeHeaders(req.headers),
|
|
13
|
+
query: normalizeQuery(req.query)
|
|
13
14
|
};
|
|
14
15
|
handle(handlerReq).then((result) => {
|
|
15
16
|
res.status(result.status).set(result.headers).send(
|
|
@@ -29,6 +30,14 @@ function normalizeHeaders(headers) {
|
|
|
29
30
|
}
|
|
30
31
|
return result;
|
|
31
32
|
}
|
|
33
|
+
function normalizeQuery(query) {
|
|
34
|
+
if (!query) return void 0;
|
|
35
|
+
const result = {};
|
|
36
|
+
for (const [key, value] of Object.entries(query)) {
|
|
37
|
+
result[key] = Array.isArray(value) ? value[0] : value;
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
32
41
|
|
|
33
42
|
export { expressMiddleware };
|
|
34
43
|
//# sourceMappingURL=express.js.map
|
package/dist/express.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/express.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O,GAAA,CAAI,WAAA,EAAa,CAAA,GAAI,KAAA,CAAM,QAAQ,KAAK,CAAA,GAAI,KAAA,CAAM,CAAC,CAAA,GAAI,KAAA;AAAA,EAChE;AACA,EAAA,OAAO,MAAA;AACT;AAEA,SAAS,eACP,KAAA,EACgD;AAChD,EAAA,IAAI,CAAC,OAAO,OAAO,MAAA;AACnB,EAAA,MAAM,SAA6C,EAAC;AACpD,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,KAAK,CAAA,EAAG;AAChD,IAAA,MAAA,CAAO,GAAG,IAAI,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAA,GAAI,KAAA,CAAM,CAAC,CAAA,GAAI,KAAA;AAAA,EAClD;AACA,EAAA,OAAO,MAAA;AACT","file":"express.js","sourcesContent":["// Copyright 2026 FHIRfly.io LLC. All rights reserved.\n// Licensed under the MIT License. See LICENSE file in the project root.\nimport { createHandler } from \"../server/handler.js\";\nimport type { SHLHandlerConfig, HandlerRequest } from \"../server/types.js\";\n\n// Minimal Express types — avoids requiring @types/express at runtime\ninterface ExpressRequest {\n method: string;\n path: string;\n body?: unknown;\n headers: Record<string, string | string[] | undefined>;\n query?: Record<string, string | string[] | undefined>;\n}\n\ninterface ExpressResponse {\n status(code: number): ExpressResponse;\n set(headers: Record<string, string>): ExpressResponse;\n send(body: string | Buffer): void;\n}\n\n/**\n * Create an Express-compatible middleware for serving SMART Health Links.\n *\n * Mount this on the path prefix where your SHL server lives. The middleware\n * handles `POST /:shlId` (manifest) and `GET /:shlId/content` (encrypted content).\n *\n * @example\n * ```ts\n * import express from \"express\";\n * import { expressMiddleware } from \"@fhirfly-io/shl/express\";\n * import { ServerLocalStorage } from \"@fhirfly-io/shl/server\";\n *\n * const app = express();\n * app.use(express.json());\n * app.use(\"/shl\", expressMiddleware({\n * storage: new ServerLocalStorage({\n * directory: \"./shl-data\",\n * baseUrl: \"https://shl.example.com\",\n * }),\n * }));\n * ```\n */\nexport function expressMiddleware(\n config: SHLHandlerConfig,\n): (req: ExpressRequest, res: ExpressResponse) => void {\n const handle = createHandler(config);\n\n return (req: ExpressRequest, res: ExpressResponse): void => {\n const handlerReq: HandlerRequest = {\n method: req.method,\n path: req.path,\n body: req.body,\n headers: normalizeHeaders(req.headers),\n query: normalizeQuery(req.query),\n };\n\n handle(handlerReq)\n .then((result) => {\n res.status(result.status).set(result.headers).send(\n typeof result.body === \"string\" ? result.body : Buffer.from(result.body),\n );\n })\n .catch(() => {\n res.status(500).set({ \"content-type\": \"application/json\" }).send(\n JSON.stringify({ error: \"Internal server error\" }),\n );\n });\n };\n}\n\nfunction normalizeHeaders(\n headers: Record<string, string | string[] | undefined>,\n): Record<string, string | undefined> {\n const result: Record<string, string | undefined> = {};\n for (const [key, value] of Object.entries(headers)) {\n result[key.toLowerCase()] = Array.isArray(value) ? value[0] : value;\n }\n return result;\n}\n\nfunction normalizeQuery(\n query?: Record<string, string | string[] | undefined>,\n): Record<string, string | undefined> | undefined {\n if (!query) return undefined;\n const result: Record<string, string | undefined> = {};\n for (const [key, value] of Object.entries(query)) {\n result[key] = Array.isArray(value) ? value[0] : value;\n }\n return result;\n}\n"]}
|
package/dist/fastify.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkJOZ6XZPO_cjs = require('./chunk-JOZ6XZPO.cjs');
|
|
4
4
|
require('./chunk-Q7SFCCGT.cjs');
|
|
5
5
|
|
|
6
6
|
// src/adapters/fastify.ts
|
|
7
7
|
function fastifyPlugin(config) {
|
|
8
|
-
const handle =
|
|
8
|
+
const handle = chunkJOZ6XZPO_cjs.createHandler(config);
|
|
9
9
|
return (fastify, _opts, done) => {
|
|
10
10
|
fastify.post("/:shlId", async (req, reply) => {
|
|
11
11
|
const shlId = req.params["shlId"] ?? "";
|
|
@@ -13,7 +13,22 @@ function fastifyPlugin(config) {
|
|
|
13
13
|
method: "POST",
|
|
14
14
|
path: `/${shlId}`,
|
|
15
15
|
body: req.body,
|
|
16
|
-
headers: normalizeHeaders(req.headers)
|
|
16
|
+
headers: normalizeHeaders(req.headers),
|
|
17
|
+
query: req.query
|
|
18
|
+
};
|
|
19
|
+
const result = await handle(handlerReq);
|
|
20
|
+
reply.status(result.status).headers(result.headers).send(
|
|
21
|
+
typeof result.body === "string" ? result.body : Buffer.from(result.body)
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
fastify.get("/:shlId", async (req, reply) => {
|
|
25
|
+
const shlId = req.params["shlId"] ?? "";
|
|
26
|
+
const handlerReq = {
|
|
27
|
+
method: "GET",
|
|
28
|
+
path: `/${shlId}`,
|
|
29
|
+
body: void 0,
|
|
30
|
+
headers: normalizeHeaders(req.headers),
|
|
31
|
+
query: req.query
|
|
17
32
|
};
|
|
18
33
|
const result = await handle(handlerReq);
|
|
19
34
|
reply.status(result.status).headers(result.headers).send(
|
|
@@ -26,7 +41,8 @@ function fastifyPlugin(config) {
|
|
|
26
41
|
method: "GET",
|
|
27
42
|
path: `/${shlId}/content`,
|
|
28
43
|
body: void 0,
|
|
29
|
-
headers: normalizeHeaders(req.headers)
|
|
44
|
+
headers: normalizeHeaders(req.headers),
|
|
45
|
+
query: req.query
|
|
30
46
|
};
|
|
31
47
|
const result = await handle(handlerReq);
|
|
32
48
|
reply.status(result.status).headers(result.headers).send(
|
|
@@ -40,7 +56,8 @@ function fastifyPlugin(config) {
|
|
|
40
56
|
method: "GET",
|
|
41
57
|
path: `/${shlId}/attachment/${index}`,
|
|
42
58
|
body: void 0,
|
|
43
|
-
headers: normalizeHeaders(req.headers)
|
|
59
|
+
headers: normalizeHeaders(req.headers),
|
|
60
|
+
query: req.query
|
|
44
61
|
};
|
|
45
62
|
const result = await handle(handlerReq);
|
|
46
63
|
reply.status(result.status).headers(result.headers).send(
|
package/dist/fastify.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources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A,EAAqB,KAAA,KAAwB;AAC3F,MAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,MAAA,CAAO,OAAO,CAAA,IAAK,EAAA;AACrC,MAAA,MAAM,KAAA,GAAQ,GAAA,CAAI,MAAA,CAAO,OAAO,CAAA,IAAK,EAAA;AACrC,MAAA,MAAM,UAAA,GAA6B;AAAA,QACjC,MAAA,EAAQ,KAAA;AAAA,QACR,IAAA,EAAM,CAAA,CAAA,EAAI,KAAK,CAAA,YAAA,EAAe,KAAK,CAAA,CAAA;AAAA,QACnC,IAAA,EAAM,MAAA;AAAA,QACN,OAAA,EAAS,gBAAA,CAAiB,GAAA,CAAI,OAAO,CAAA;AAAA,QACrC,OAAO,GAAA,CAAI;AAAA,OACb;AAEA,MAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,UAAU,CAAA;AACtC,MAAA,KAAA,CAAM,OAAO,MAAA,CAAO,MAAM,EAAE,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA;AAAA,QAClD,OAAO,OAAO,IAAA,KAAS,QAAA,GAAW,OAAO,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,IAAI;AAAA,OACzE;AAAA,IACF,CAAC,CAAA;AAED,IAAA,IAAA,EAAK;AAAA,EACP,CAAA;AACF;AAEA,SAAS,iBACP,OAAA,EACoC;AACpC,EAAA,MAAM,SAA6C,EAAC;AACpD,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AAClD,IAAA,MAAA,CAAO,GAAA,CAAI,WAAA,EAAa,CAAA,GAAI,KAAA,CAAM,QAAQ,KAAK,CAAA,GAAI,KAAA,CAAM,CAAC,CAAA,GAAI,KAAA;AAAA,EAChE;AACA,EAAA,OAAO,MAAA;AACT","file":"fastify.cjs","sourcesContent":["// Copyright 2026 FHIRfly.io LLC. All rights reserved.\n// Licensed under the MIT License. See LICENSE file in the project root.\nimport { createHandler } from \"../server/handler.js\";\nimport type { SHLHandlerConfig, HandlerRequest } from \"../server/types.js\";\n\n// Minimal Fastify types — avoids requiring fastify at runtime\ninterface FastifyRequest {\n method: string;\n body?: unknown;\n params: Record<string, string>;\n headers: Record<string, string | string[] | undefined>;\n query?: Record<string, string | undefined>;\n}\n\ninterface FastifyReply {\n status(code: number): FastifyReply;\n headers(headers: Record<string, string>): FastifyReply;\n send(body: string | Buffer): void;\n}\n\ninterface FastifyInstance {\n post(\n path: string,\n handler: (req: FastifyRequest, reply: FastifyReply) => Promise<void>,\n ): void;\n get(\n path: string,\n handler: (req: FastifyRequest, reply: FastifyReply) => Promise<void>,\n ): void;\n}\n\ntype FastifyDone = (err?: Error) => void;\n\n/**\n * Create a Fastify plugin for serving SMART Health Links.\n *\n * Register this plugin with a prefix to mount the SHL routes.\n * The plugin registers `POST /:shlId`, `GET /:shlId/content`, and `GET /:shlId/attachment/:index`.\n *\n * @example\n * ```ts\n * import Fastify from \"fastify\";\n * import { fastifyPlugin } from \"@fhirfly-io/shl/fastify\";\n * import { ServerLocalStorage } from \"@fhirfly-io/shl/server\";\n *\n * const app = Fastify();\n * app.register(fastifyPlugin({\n * storage: new ServerLocalStorage({\n * directory: \"./shl-data\",\n * baseUrl: \"https://shl.example.com\",\n * }),\n * }), { prefix: \"/shl\" });\n * ```\n */\nexport function fastifyPlugin(\n config: SHLHandlerConfig,\n): (fastify: FastifyInstance, opts: unknown, done: FastifyDone) => void {\n const handle = createHandler(config);\n\n return (fastify: FastifyInstance, _opts: unknown, done: FastifyDone): void => {\n // POST /:shlId — manifest endpoint\n fastify.post(\"/:shlId\", async (req: FastifyRequest, reply: FastifyReply) => {\n const shlId = req.params[\"shlId\"] ?? \"\";\n const handlerReq: HandlerRequest = {\n method: \"POST\",\n path: `/${shlId}`,\n body: req.body,\n headers: normalizeHeaders(req.headers),\n query: req.query,\n };\n\n const result = await handle(handlerReq);\n reply.status(result.status).headers(result.headers).send(\n typeof result.body === \"string\" ? result.body : Buffer.from(result.body),\n );\n });\n\n // GET /:shlId — direct access endpoint (flag U)\n fastify.get(\"/:shlId\", async (req: FastifyRequest, reply: FastifyReply) => {\n const shlId = req.params[\"shlId\"] ?? \"\";\n const handlerReq: HandlerRequest = {\n method: \"GET\",\n path: `/${shlId}`,\n body: undefined,\n headers: normalizeHeaders(req.headers),\n query: req.query,\n };\n\n const result = await handle(handlerReq);\n reply.status(result.status).headers(result.headers).send(\n typeof result.body === \"string\" ? result.body : Buffer.from(result.body),\n );\n });\n\n // GET /:shlId/content — content endpoint\n fastify.get(\"/:shlId/content\", async (req: FastifyRequest, reply: FastifyReply) => {\n const shlId = req.params[\"shlId\"] ?? \"\";\n const handlerReq: HandlerRequest = {\n method: \"GET\",\n path: `/${shlId}/content`,\n body: undefined,\n headers: normalizeHeaders(req.headers),\n query: req.query,\n };\n\n const result = await handle(handlerReq);\n reply.status(result.status).headers(result.headers).send(\n typeof result.body === \"string\" ? result.body : Buffer.from(result.body),\n );\n });\n\n // GET /:shlId/attachment/:index — attachment endpoint\n fastify.get(\"/:shlId/attachment/:index\", async (req: FastifyRequest, reply: FastifyReply) => {\n const shlId = req.params[\"shlId\"] ?? \"\";\n const index = req.params[\"index\"] ?? \"\";\n const handlerReq: HandlerRequest = {\n method: \"GET\",\n path: `/${shlId}/attachment/${index}`,\n body: undefined,\n headers: normalizeHeaders(req.headers),\n query: req.query,\n };\n\n const result = await handle(handlerReq);\n reply.status(result.status).headers(result.headers).send(\n typeof result.body === \"string\" ? result.body : Buffer.from(result.body),\n );\n });\n\n done();\n };\n}\n\nfunction normalizeHeaders(\n headers: Record<string, string | string[] | undefined>,\n): Record<string, string | undefined> {\n const result: Record<string, string | undefined> = {};\n for (const [key, value] of Object.entries(headers)) {\n result[key.toLowerCase()] = Array.isArray(value) ? value[0] : value;\n }\n return result;\n}\n"]}
|
package/dist/fastify.d.cts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { S as SHLHandlerConfig } from './types-
|
|
2
|
-
import './types-
|
|
1
|
+
import { S as SHLHandlerConfig } from './types-Cdi4IkC9.cjs';
|
|
2
|
+
import './types-BLLJeWe_.cjs';
|
|
3
3
|
|
|
4
4
|
interface FastifyRequest {
|
|
5
5
|
method: string;
|
|
6
6
|
body?: unknown;
|
|
7
7
|
params: Record<string, string>;
|
|
8
8
|
headers: Record<string, string | string[] | undefined>;
|
|
9
|
+
query?: Record<string, string | undefined>;
|
|
9
10
|
}
|
|
10
11
|
interface FastifyReply {
|
|
11
12
|
status(code: number): FastifyReply;
|
package/dist/fastify.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { S as SHLHandlerConfig } from './types-
|
|
2
|
-
import './types-
|
|
1
|
+
import { S as SHLHandlerConfig } from './types-6Vw5fiat.js';
|
|
2
|
+
import './types-BLLJeWe_.js';
|
|
3
3
|
|
|
4
4
|
interface FastifyRequest {
|
|
5
5
|
method: string;
|
|
6
6
|
body?: unknown;
|
|
7
7
|
params: Record<string, string>;
|
|
8
8
|
headers: Record<string, string | string[] | undefined>;
|
|
9
|
+
query?: Record<string, string | undefined>;
|
|
9
10
|
}
|
|
10
11
|
interface FastifyReply {
|
|
11
12
|
status(code: number): FastifyReply;
|
package/dist/fastify.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHandler } from './chunk-
|
|
1
|
+
import { createHandler } from './chunk-KGEFZQ6W.js';
|
|
2
2
|
import './chunk-PZ5AY32C.js';
|
|
3
3
|
|
|
4
4
|
// src/adapters/fastify.ts
|
|
@@ -11,7 +11,22 @@ function fastifyPlugin(config) {
|
|
|
11
11
|
method: "POST",
|
|
12
12
|
path: `/${shlId}`,
|
|
13
13
|
body: req.body,
|
|
14
|
-
headers: normalizeHeaders(req.headers)
|
|
14
|
+
headers: normalizeHeaders(req.headers),
|
|
15
|
+
query: req.query
|
|
16
|
+
};
|
|
17
|
+
const result = await handle(handlerReq);
|
|
18
|
+
reply.status(result.status).headers(result.headers).send(
|
|
19
|
+
typeof result.body === "string" ? result.body : Buffer.from(result.body)
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
fastify.get("/:shlId", async (req, reply) => {
|
|
23
|
+
const shlId = req.params["shlId"] ?? "";
|
|
24
|
+
const handlerReq = {
|
|
25
|
+
method: "GET",
|
|
26
|
+
path: `/${shlId}`,
|
|
27
|
+
body: void 0,
|
|
28
|
+
headers: normalizeHeaders(req.headers),
|
|
29
|
+
query: req.query
|
|
15
30
|
};
|
|
16
31
|
const result = await handle(handlerReq);
|
|
17
32
|
reply.status(result.status).headers(result.headers).send(
|
|
@@ -24,7 +39,8 @@ function fastifyPlugin(config) {
|
|
|
24
39
|
method: "GET",
|
|
25
40
|
path: `/${shlId}/content`,
|
|
26
41
|
body: void 0,
|
|
27
|
-
headers: normalizeHeaders(req.headers)
|
|
42
|
+
headers: normalizeHeaders(req.headers),
|
|
43
|
+
query: req.query
|
|
28
44
|
};
|
|
29
45
|
const result = await handle(handlerReq);
|
|
30
46
|
reply.status(result.status).headers(result.headers).send(
|
|
@@ -38,7 +54,8 @@ function fastifyPlugin(config) {
|
|
|
38
54
|
method: "GET",
|
|
39
55
|
path: `/${shlId}/attachment/${index}`,
|
|
40
56
|
body: void 0,
|
|
41
|
-
headers: normalizeHeaders(req.headers)
|
|
57
|
+
headers: normalizeHeaders(req.headers),
|
|
58
|
+
query: req.query
|
|
42
59
|
};
|
|
43
60
|
const result = await handle(handlerReq);
|
|
44
61
|
reply.status(result.status).headers(result.headers).send(
|
package/dist/fastify.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/fastify.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../src/adapters/fastify.ts"],"names":[],"mappings":";;;;AAsDO,SAAS,cACd,MAAA,EACsE;AACtE,EAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AAEnC,EAAA,OAAO,CAAC,OAAA,EAA0B,KAA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,KAAA;AAAA,QACR,IAAA,EAAM,CAAA,CAAA,EAAI,KAAK,CAAA,YAAA,EAAe,KAAK,CAAA,CAAA;AAAA,QACnC,IAAA,EAAM,MAAA;AAAA,QACN,OAAA,EAAS,gBAAA,CAAiB,GAAA,CAAI,OAAO,CAAA;AAAA,QACrC,OAAO,GAAA,CAAI;AAAA,OACb;AAEA,MAAA,MAAM,MAAA,GAAS,MAAM,MAAA,CAAO,UAAU,CAAA;AACtC,MAAA,KAAA,CAAM,OAAO,MAAA,CAAO,MAAM,EAAE,OAAA,CAAQ,MAAA,CAAO,OAAO,CAAA,CAAE,IAAA;AAAA,QAClD,OAAO,OAAO,IAAA,KAAS,QAAA,GAAW,OAAO,IAAA,GAAO,MAAA,CAAO,IAAA,CAAK,MAAA,CAAO,IAAI;AAAA,OACzE;AAAA,IACF,CAAC,CAAA;AAED,IAAA,IAAA,EAAK;AAAA,EACP,CAAA;AACF;AAEA,SAAS,iBACP,OAAA,EACoC;AACpC,EAAA,MAAM,SAA6C,EAAC;AACpD,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AAClD,IAAA,MAAA,CAAO,GAAA,CAAI,WAAA,EAAa,CAAA,GAAI,KAAA,CAAM,QAAQ,KAAK,CAAA,GAAI,KAAA,CAAM,CAAC,CAAA,GAAI,KAAA;AAAA,EAChE;AACA,EAAA,OAAO,MAAA;AACT","file":"fastify.js","sourcesContent":["// Copyright 2026 FHIRfly.io LLC. All rights reserved.\n// Licensed under the MIT License. See LICENSE file in the project root.\nimport { createHandler } from \"../server/handler.js\";\nimport type { SHLHandlerConfig, HandlerRequest } from \"../server/types.js\";\n\n// Minimal Fastify types — avoids requiring fastify at runtime\ninterface FastifyRequest {\n method: string;\n body?: unknown;\n params: Record<string, string>;\n headers: Record<string, string | string[] | undefined>;\n query?: Record<string, string | undefined>;\n}\n\ninterface FastifyReply {\n status(code: number): FastifyReply;\n headers(headers: Record<string, string>): FastifyReply;\n send(body: string | Buffer): void;\n}\n\ninterface FastifyInstance {\n post(\n path: string,\n handler: (req: FastifyRequest, reply: FastifyReply) => Promise<void>,\n ): void;\n get(\n path: string,\n handler: (req: FastifyRequest, reply: FastifyReply) => Promise<void>,\n ): void;\n}\n\ntype FastifyDone = (err?: Error) => void;\n\n/**\n * Create a Fastify plugin for serving SMART Health Links.\n *\n * Register this plugin with a prefix to mount the SHL routes.\n * The plugin registers `POST /:shlId`, `GET /:shlId/content`, and `GET /:shlId/attachment/:index`.\n *\n * @example\n * ```ts\n * import Fastify from \"fastify\";\n * import { fastifyPlugin } from \"@fhirfly-io/shl/fastify\";\n * import { ServerLocalStorage } from \"@fhirfly-io/shl/server\";\n *\n * const app = Fastify();\n * app.register(fastifyPlugin({\n * storage: new ServerLocalStorage({\n * directory: \"./shl-data\",\n * baseUrl: \"https://shl.example.com\",\n * }),\n * }), { prefix: \"/shl\" });\n * ```\n */\nexport function fastifyPlugin(\n config: SHLHandlerConfig,\n): (fastify: FastifyInstance, opts: unknown, done: FastifyDone) => void {\n const handle = createHandler(config);\n\n return (fastify: FastifyInstance, _opts: unknown, done: FastifyDone): void => {\n // POST /:shlId — manifest endpoint\n fastify.post(\"/:shlId\", async (req: FastifyRequest, reply: FastifyReply) => {\n const shlId = req.params[\"shlId\"] ?? \"\";\n const handlerReq: HandlerRequest = {\n method: \"POST\",\n path: `/${shlId}`,\n body: req.body,\n headers: normalizeHeaders(req.headers),\n query: req.query,\n };\n\n const result = await handle(handlerReq);\n reply.status(result.status).headers(result.headers).send(\n typeof result.body === \"string\" ? result.body : Buffer.from(result.body),\n );\n });\n\n // GET /:shlId — direct access endpoint (flag U)\n fastify.get(\"/:shlId\", async (req: FastifyRequest, reply: FastifyReply) => {\n const shlId = req.params[\"shlId\"] ?? \"\";\n const handlerReq: HandlerRequest = {\n method: \"GET\",\n path: `/${shlId}`,\n body: undefined,\n headers: normalizeHeaders(req.headers),\n query: req.query,\n };\n\n const result = await handle(handlerReq);\n reply.status(result.status).headers(result.headers).send(\n typeof result.body === \"string\" ? result.body : Buffer.from(result.body),\n );\n });\n\n // GET /:shlId/content — content endpoint\n fastify.get(\"/:shlId/content\", async (req: FastifyRequest, reply: FastifyReply) => {\n const shlId = req.params[\"shlId\"] ?? \"\";\n const handlerReq: HandlerRequest = {\n method: \"GET\",\n path: `/${shlId}/content`,\n body: undefined,\n headers: normalizeHeaders(req.headers),\n query: req.query,\n };\n\n const result = await handle(handlerReq);\n reply.status(result.status).headers(result.headers).send(\n typeof result.body === \"string\" ? result.body : Buffer.from(result.body),\n );\n });\n\n // GET /:shlId/attachment/:index — attachment endpoint\n fastify.get(\"/:shlId/attachment/:index\", async (req: FastifyRequest, reply: FastifyReply) => {\n const shlId = req.params[\"shlId\"] ?? \"\";\n const index = req.params[\"index\"] ?? \"\";\n const handlerReq: HandlerRequest = {\n method: \"GET\",\n path: `/${shlId}/attachment/${index}`,\n body: undefined,\n headers: normalizeHeaders(req.headers),\n query: req.query,\n };\n\n const result = await handle(handlerReq);\n reply.status(result.status).headers(result.headers).send(\n typeof result.body === \"string\" ? result.body : Buffer.from(result.body),\n );\n });\n\n done();\n };\n}\n\nfunction normalizeHeaders(\n headers: Record<string, string | string[] | undefined>,\n): Record<string, string | undefined> {\n const result: Record<string, string | undefined> = {};\n for (const [key, value] of Object.entries(headers)) {\n result[key.toLowerCase()] = Array.isArray(value) ? value[0] : value;\n }\n return result;\n}\n"]}
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkSK77O3SG_cjs = require('./chunk-SK77O3SG.cjs');
|
|
4
4
|
var chunkUDS6UJAL_cjs = require('./chunk-UDS6UJAL.cjs');
|
|
5
5
|
require('./chunk-Q7SFCCGT.cjs');
|
|
6
6
|
|
|
@@ -8,11 +8,11 @@ require('./chunk-Q7SFCCGT.cjs');
|
|
|
8
8
|
|
|
9
9
|
Object.defineProperty(exports, "IPS", {
|
|
10
10
|
enumerable: true,
|
|
11
|
-
get: function () { return
|
|
11
|
+
get: function () { return chunkSK77O3SG_cjs.ips_exports; }
|
|
12
12
|
});
|
|
13
13
|
Object.defineProperty(exports, "SHL", {
|
|
14
14
|
enumerable: true,
|
|
15
|
-
get: function () { return
|
|
15
|
+
get: function () { return chunkSK77O3SG_cjs.shl_exports; }
|
|
16
16
|
});
|
|
17
17
|
Object.defineProperty(exports, "EncryptionError", {
|
|
18
18
|
enumerable: true,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as SHLOptions, c as SHLResult, M as ManifestEntry, S as SHLStorage, d as Manifest, e as SHLAttachment, a as SHLMetadata } from './types-
|
|
2
|
-
import { A as AzureStorage, a as AzureStorageConfig, F as FhirflyStorage, d as FhirflyStorageConfig, G as GCSStorage, b as GCSStorageConfig, L as LocalStorage, c as LocalStorageConfig, e as S3Storage, S as S3StorageConfig } from './storage-
|
|
1
|
+
import { b as SHLOptions, c as SHLResult, M as ManifestEntry, S as SHLStorage, d as Manifest, e as SHLAttachment, a as SHLMetadata } from './types-BLLJeWe_.cjs';
|
|
2
|
+
import { A as AzureStorage, a as AzureStorageConfig, F as FhirflyStorage, d as FhirflyStorageConfig, G as GCSStorage, b as GCSStorageConfig, L as LocalStorage, c as LocalStorageConfig, e as S3Storage, S as S3StorageConfig } from './storage-BbzK-kFf.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Shared FHIR R4 datatypes used across IPS bundle construction.
|
|
@@ -170,12 +170,14 @@ interface PatientContact {
|
|
|
170
170
|
* full has `name: HumanName[]`.
|
|
171
171
|
*/
|
|
172
172
|
type PatientDemographics = PatientShorthand | PatientFull;
|
|
173
|
+
/** FHIR bundle profile: IPS (full conformance), R4 (plain), or PSHD (CMS patient-shared). */
|
|
174
|
+
type BundleProfile = "ips" | "r4" | "pshd";
|
|
173
175
|
/**
|
|
174
176
|
* Options for building an IPS bundle.
|
|
175
177
|
*/
|
|
176
178
|
interface BuildOptions {
|
|
177
179
|
/** FHIR profile to validate against */
|
|
178
|
-
profile:
|
|
180
|
+
profile: BundleProfile;
|
|
179
181
|
/** Bundle identifier (auto-generated if not provided) */
|
|
180
182
|
bundleId?: string;
|
|
181
183
|
/** Composition date (defaults to now) */
|
|
@@ -623,6 +625,7 @@ declare class Bundle {
|
|
|
623
625
|
*/
|
|
624
626
|
validate(options?: BuildOptions): ValidationResult;
|
|
625
627
|
private hasValidName;
|
|
628
|
+
private buildPshdBundle;
|
|
626
629
|
private buildComposition;
|
|
627
630
|
private buildMedicationSection;
|
|
628
631
|
private buildAllergySection;
|
|
@@ -642,6 +645,10 @@ declare const CODE_SYSTEMS: {
|
|
|
642
645
|
readonly ICD10CM: "http://hl7.org/fhir/sid/icd-10-cm";
|
|
643
646
|
readonly CONDITION_CLINICAL: "http://terminology.hl7.org/CodeSystem/condition-clinical";
|
|
644
647
|
readonly ALLERGY_CLINICAL: "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical";
|
|
648
|
+
/** CMS Patient-Shared Health Document category code system */
|
|
649
|
+
readonly CMS_PATIENT_SHARED_CATEGORY: "https://cms.gov/fhir/CodeSystem/patient-shared-category";
|
|
650
|
+
/** V3 ActCode security label for patient-asserted data */
|
|
651
|
+
readonly SECURITY_PATAST: "PATAST";
|
|
645
652
|
};
|
|
646
653
|
|
|
647
654
|
type index$1_Address = Address;
|
|
@@ -654,6 +661,7 @@ type index$1_AllergyOptions = AllergyOptions;
|
|
|
654
661
|
type index$1_BuildOptions = BuildOptions;
|
|
655
662
|
type index$1_Bundle = Bundle;
|
|
656
663
|
declare const index$1_Bundle: typeof Bundle;
|
|
664
|
+
type index$1_BundleProfile = BundleProfile;
|
|
657
665
|
declare const index$1_CODE_SYSTEMS: typeof CODE_SYSTEMS;
|
|
658
666
|
type index$1_CodeableConcept = CodeableConcept;
|
|
659
667
|
type index$1_Coding = Coding;
|
|
@@ -694,7 +702,7 @@ type index$1_ResultOptions = ResultOptions;
|
|
|
694
702
|
type index$1_ValidationIssue = ValidationIssue;
|
|
695
703
|
type index$1_ValidationResult = ValidationResult;
|
|
696
704
|
declare namespace index$1 {
|
|
697
|
-
export { type index$1_Address as Address, type index$1_AdministrativeGender as AdministrativeGender, type index$1_AllergyBySNOMED as AllergyBySNOMED, type index$1_AllergyClinicalStatus as AllergyClinicalStatus, type index$1_AllergyFromResource as AllergyFromResource, type index$1_AllergyManual as AllergyManual, type index$1_AllergyOptions as AllergyOptions, type index$1_BuildOptions as BuildOptions, index$1_Bundle as Bundle, index$1_CODE_SYSTEMS as CODE_SYSTEMS, type index$1_CodeableConcept as CodeableConcept, type index$1_Coding as Coding, type index$1_ConditionByICD10 as ConditionByICD10, type index$1_ConditionBySNOMED as ConditionBySNOMED, type index$1_ConditionClinicalStatus as ConditionClinicalStatus, type index$1_ConditionFromResource as ConditionFromResource, type index$1_ConditionManual as ConditionManual, type index$1_ConditionOptions as ConditionOptions, type index$1_ContactPoint as ContactPoint, type index$1_DocumentOptions as DocumentOptions, type index$1_FhirflyClient as FhirflyClient, type index$1_HumanName as HumanName, type index$1_Identifier as Identifier, type index$1_ImmunizationByCVX as ImmunizationByCVX, type index$1_ImmunizationFromResource as ImmunizationFromResource, type index$1_ImmunizationManual as ImmunizationManual, type index$1_ImmunizationOptions as ImmunizationOptions, type index$1_MedicationByNDC as MedicationByNDC, type index$1_MedicationByRxNorm as MedicationByRxNorm, type index$1_MedicationBySNOMED as MedicationBySNOMED, type index$1_MedicationFromResource as MedicationFromResource, type index$1_MedicationManual as MedicationManual, type index$1_MedicationOptions as MedicationOptions, type index$1_MedicationStatus as MedicationStatus, type index$1_ObservationStatus as ObservationStatus, type index$1_PatientCommunication as PatientCommunication, type index$1_PatientContact as PatientContact, type index$1_PatientDemographics as PatientDemographics, type index$1_PatientFull as PatientFull, type index$1_PatientShorthand as PatientShorthand, type index$1_Period as Period, type index$1_Reference as Reference, type index$1_ResultByLOINC as ResultByLOINC, type index$1_ResultFromResource as ResultFromResource, type index$1_ResultManual as ResultManual, type index$1_ResultOptions as ResultOptions, type index$1_ValidationIssue as ValidationIssue, type index$1_ValidationResult as ValidationResult };
|
|
705
|
+
export { type index$1_Address as Address, type index$1_AdministrativeGender as AdministrativeGender, type index$1_AllergyBySNOMED as AllergyBySNOMED, type index$1_AllergyClinicalStatus as AllergyClinicalStatus, type index$1_AllergyFromResource as AllergyFromResource, type index$1_AllergyManual as AllergyManual, type index$1_AllergyOptions as AllergyOptions, type index$1_BuildOptions as BuildOptions, index$1_Bundle as Bundle, type index$1_BundleProfile as BundleProfile, index$1_CODE_SYSTEMS as CODE_SYSTEMS, type index$1_CodeableConcept as CodeableConcept, type index$1_Coding as Coding, type index$1_ConditionByICD10 as ConditionByICD10, type index$1_ConditionBySNOMED as ConditionBySNOMED, type index$1_ConditionClinicalStatus as ConditionClinicalStatus, type index$1_ConditionFromResource as ConditionFromResource, type index$1_ConditionManual as ConditionManual, type index$1_ConditionOptions as ConditionOptions, type index$1_ContactPoint as ContactPoint, type index$1_DocumentOptions as DocumentOptions, type index$1_FhirflyClient as FhirflyClient, type index$1_HumanName as HumanName, type index$1_Identifier as Identifier, type index$1_ImmunizationByCVX as ImmunizationByCVX, type index$1_ImmunizationFromResource as ImmunizationFromResource, type index$1_ImmunizationManual as ImmunizationManual, type index$1_ImmunizationOptions as ImmunizationOptions, type index$1_MedicationByNDC as MedicationByNDC, type index$1_MedicationByRxNorm as MedicationByRxNorm, type index$1_MedicationBySNOMED as MedicationBySNOMED, type index$1_MedicationFromResource as MedicationFromResource, type index$1_MedicationManual as MedicationManual, type index$1_MedicationOptions as MedicationOptions, type index$1_MedicationStatus as MedicationStatus, type index$1_ObservationStatus as ObservationStatus, type index$1_PatientCommunication as PatientCommunication, type index$1_PatientContact as PatientContact, type index$1_PatientDemographics as PatientDemographics, type index$1_PatientFull as PatientFull, type index$1_PatientShorthand as PatientShorthand, type index$1_Period as Period, type index$1_Reference as Reference, type index$1_ResultByLOINC as ResultByLOINC, type index$1_ResultFromResource as ResultFromResource, type index$1_ResultManual as ResultManual, type index$1_ResultOptions as ResultOptions, type index$1_ValidationIssue as ValidationIssue, type index$1_ValidationResult as ValidationResult };
|
|
698
706
|
}
|
|
699
707
|
|
|
700
708
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { b as SHLOptions, c as SHLResult, M as ManifestEntry, S as SHLStorage, d as Manifest, e as SHLAttachment, a as SHLMetadata } from './types-
|
|
2
|
-
import { A as AzureStorage, a as AzureStorageConfig, F as FhirflyStorage, d as FhirflyStorageConfig, G as GCSStorage, b as GCSStorageConfig, L as LocalStorage, c as LocalStorageConfig, e as S3Storage, S as S3StorageConfig } from './storage-
|
|
1
|
+
import { b as SHLOptions, c as SHLResult, M as ManifestEntry, S as SHLStorage, d as Manifest, e as SHLAttachment, a as SHLMetadata } from './types-BLLJeWe_.js';
|
|
2
|
+
import { A as AzureStorage, a as AzureStorageConfig, F as FhirflyStorage, d as FhirflyStorageConfig, G as GCSStorage, b as GCSStorageConfig, L as LocalStorage, c as LocalStorageConfig, e as S3Storage, S as S3StorageConfig } from './storage-Cx7uXUl8.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Shared FHIR R4 datatypes used across IPS bundle construction.
|
|
@@ -170,12 +170,14 @@ interface PatientContact {
|
|
|
170
170
|
* full has `name: HumanName[]`.
|
|
171
171
|
*/
|
|
172
172
|
type PatientDemographics = PatientShorthand | PatientFull;
|
|
173
|
+
/** FHIR bundle profile: IPS (full conformance), R4 (plain), or PSHD (CMS patient-shared). */
|
|
174
|
+
type BundleProfile = "ips" | "r4" | "pshd";
|
|
173
175
|
/**
|
|
174
176
|
* Options for building an IPS bundle.
|
|
175
177
|
*/
|
|
176
178
|
interface BuildOptions {
|
|
177
179
|
/** FHIR profile to validate against */
|
|
178
|
-
profile:
|
|
180
|
+
profile: BundleProfile;
|
|
179
181
|
/** Bundle identifier (auto-generated if not provided) */
|
|
180
182
|
bundleId?: string;
|
|
181
183
|
/** Composition date (defaults to now) */
|
|
@@ -623,6 +625,7 @@ declare class Bundle {
|
|
|
623
625
|
*/
|
|
624
626
|
validate(options?: BuildOptions): ValidationResult;
|
|
625
627
|
private hasValidName;
|
|
628
|
+
private buildPshdBundle;
|
|
626
629
|
private buildComposition;
|
|
627
630
|
private buildMedicationSection;
|
|
628
631
|
private buildAllergySection;
|
|
@@ -642,6 +645,10 @@ declare const CODE_SYSTEMS: {
|
|
|
642
645
|
readonly ICD10CM: "http://hl7.org/fhir/sid/icd-10-cm";
|
|
643
646
|
readonly CONDITION_CLINICAL: "http://terminology.hl7.org/CodeSystem/condition-clinical";
|
|
644
647
|
readonly ALLERGY_CLINICAL: "http://terminology.hl7.org/CodeSystem/allergyintolerance-clinical";
|
|
648
|
+
/** CMS Patient-Shared Health Document category code system */
|
|
649
|
+
readonly CMS_PATIENT_SHARED_CATEGORY: "https://cms.gov/fhir/CodeSystem/patient-shared-category";
|
|
650
|
+
/** V3 ActCode security label for patient-asserted data */
|
|
651
|
+
readonly SECURITY_PATAST: "PATAST";
|
|
645
652
|
};
|
|
646
653
|
|
|
647
654
|
type index$1_Address = Address;
|
|
@@ -654,6 +661,7 @@ type index$1_AllergyOptions = AllergyOptions;
|
|
|
654
661
|
type index$1_BuildOptions = BuildOptions;
|
|
655
662
|
type index$1_Bundle = Bundle;
|
|
656
663
|
declare const index$1_Bundle: typeof Bundle;
|
|
664
|
+
type index$1_BundleProfile = BundleProfile;
|
|
657
665
|
declare const index$1_CODE_SYSTEMS: typeof CODE_SYSTEMS;
|
|
658
666
|
type index$1_CodeableConcept = CodeableConcept;
|
|
659
667
|
type index$1_Coding = Coding;
|
|
@@ -694,7 +702,7 @@ type index$1_ResultOptions = ResultOptions;
|
|
|
694
702
|
type index$1_ValidationIssue = ValidationIssue;
|
|
695
703
|
type index$1_ValidationResult = ValidationResult;
|
|
696
704
|
declare namespace index$1 {
|
|
697
|
-
export { type index$1_Address as Address, type index$1_AdministrativeGender as AdministrativeGender, type index$1_AllergyBySNOMED as AllergyBySNOMED, type index$1_AllergyClinicalStatus as AllergyClinicalStatus, type index$1_AllergyFromResource as AllergyFromResource, type index$1_AllergyManual as AllergyManual, type index$1_AllergyOptions as AllergyOptions, type index$1_BuildOptions as BuildOptions, index$1_Bundle as Bundle, index$1_CODE_SYSTEMS as CODE_SYSTEMS, type index$1_CodeableConcept as CodeableConcept, type index$1_Coding as Coding, type index$1_ConditionByICD10 as ConditionByICD10, type index$1_ConditionBySNOMED as ConditionBySNOMED, type index$1_ConditionClinicalStatus as ConditionClinicalStatus, type index$1_ConditionFromResource as ConditionFromResource, type index$1_ConditionManual as ConditionManual, type index$1_ConditionOptions as ConditionOptions, type index$1_ContactPoint as ContactPoint, type index$1_DocumentOptions as DocumentOptions, type index$1_FhirflyClient as FhirflyClient, type index$1_HumanName as HumanName, type index$1_Identifier as Identifier, type index$1_ImmunizationByCVX as ImmunizationByCVX, type index$1_ImmunizationFromResource as ImmunizationFromResource, type index$1_ImmunizationManual as ImmunizationManual, type index$1_ImmunizationOptions as ImmunizationOptions, type index$1_MedicationByNDC as MedicationByNDC, type index$1_MedicationByRxNorm as MedicationByRxNorm, type index$1_MedicationBySNOMED as MedicationBySNOMED, type index$1_MedicationFromResource as MedicationFromResource, type index$1_MedicationManual as MedicationManual, type index$1_MedicationOptions as MedicationOptions, type index$1_MedicationStatus as MedicationStatus, type index$1_ObservationStatus as ObservationStatus, type index$1_PatientCommunication as PatientCommunication, type index$1_PatientContact as PatientContact, type index$1_PatientDemographics as PatientDemographics, type index$1_PatientFull as PatientFull, type index$1_PatientShorthand as PatientShorthand, type index$1_Period as Period, type index$1_Reference as Reference, type index$1_ResultByLOINC as ResultByLOINC, type index$1_ResultFromResource as ResultFromResource, type index$1_ResultManual as ResultManual, type index$1_ResultOptions as ResultOptions, type index$1_ValidationIssue as ValidationIssue, type index$1_ValidationResult as ValidationResult };
|
|
705
|
+
export { type index$1_Address as Address, type index$1_AdministrativeGender as AdministrativeGender, type index$1_AllergyBySNOMED as AllergyBySNOMED, type index$1_AllergyClinicalStatus as AllergyClinicalStatus, type index$1_AllergyFromResource as AllergyFromResource, type index$1_AllergyManual as AllergyManual, type index$1_AllergyOptions as AllergyOptions, type index$1_BuildOptions as BuildOptions, index$1_Bundle as Bundle, type index$1_BundleProfile as BundleProfile, index$1_CODE_SYSTEMS as CODE_SYSTEMS, type index$1_CodeableConcept as CodeableConcept, type index$1_Coding as Coding, type index$1_ConditionByICD10 as ConditionByICD10, type index$1_ConditionBySNOMED as ConditionBySNOMED, type index$1_ConditionClinicalStatus as ConditionClinicalStatus, type index$1_ConditionFromResource as ConditionFromResource, type index$1_ConditionManual as ConditionManual, type index$1_ConditionOptions as ConditionOptions, type index$1_ContactPoint as ContactPoint, type index$1_DocumentOptions as DocumentOptions, type index$1_FhirflyClient as FhirflyClient, type index$1_HumanName as HumanName, type index$1_Identifier as Identifier, type index$1_ImmunizationByCVX as ImmunizationByCVX, type index$1_ImmunizationFromResource as ImmunizationFromResource, type index$1_ImmunizationManual as ImmunizationManual, type index$1_ImmunizationOptions as ImmunizationOptions, type index$1_MedicationByNDC as MedicationByNDC, type index$1_MedicationByRxNorm as MedicationByRxNorm, type index$1_MedicationBySNOMED as MedicationBySNOMED, type index$1_MedicationFromResource as MedicationFromResource, type index$1_MedicationManual as MedicationManual, type index$1_MedicationOptions as MedicationOptions, type index$1_MedicationStatus as MedicationStatus, type index$1_ObservationStatus as ObservationStatus, type index$1_PatientCommunication as PatientCommunication, type index$1_PatientContact as PatientContact, type index$1_PatientDemographics as PatientDemographics, type index$1_PatientFull as PatientFull, type index$1_PatientShorthand as PatientShorthand, type index$1_Period as Period, type index$1_Reference as Reference, type index$1_ResultByLOINC as ResultByLOINC, type index$1_ResultFromResource as ResultFromResource, type index$1_ResultManual as ResultManual, type index$1_ResultOptions as ResultOptions, type index$1_ValidationIssue as ValidationIssue, type index$1_ValidationResult as ValidationResult };
|
|
698
706
|
}
|
|
699
707
|
|
|
700
708
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { ips_exports as IPS, shl_exports as SHL } from './chunk-
|
|
1
|
+
export { ips_exports as IPS, shl_exports as SHL } from './chunk-UU434UFQ.js';
|
|
2
2
|
export { EncryptionError, ShlError, StorageError, ValidationError } from './chunk-VKB3ESIV.js';
|
|
3
3
|
import './chunk-PZ5AY32C.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/lambda.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkJOZ6XZPO_cjs = require('./chunk-JOZ6XZPO.cjs');
|
|
4
4
|
require('./chunk-Q7SFCCGT.cjs');
|
|
5
5
|
|
|
6
6
|
// src/adapters/lambda.ts
|
|
7
7
|
function lambdaHandler(config) {
|
|
8
|
-
const handle =
|
|
8
|
+
const handle = chunkJOZ6XZPO_cjs.createHandler(config);
|
|
9
9
|
const prefix = config.pathPrefix?.replace(/\/+$/, "") ?? "";
|
|
10
10
|
return async (event) => {
|
|
11
11
|
let path = event.requestContext.http.path;
|
|
@@ -25,7 +25,8 @@ function lambdaHandler(config) {
|
|
|
25
25
|
method: event.requestContext.http.method,
|
|
26
26
|
path,
|
|
27
27
|
body,
|
|
28
|
-
headers: normalizeHeaders(event.headers)
|
|
28
|
+
headers: normalizeHeaders(event.headers),
|
|
29
|
+
query: event.queryStringParameters
|
|
29
30
|
};
|
|
30
31
|
try {
|
|
31
32
|
const result = await handle(handlerReq);
|
package/dist/lambda.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/lambda.ts"],"names":["createHandler"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/adapters/lambda.ts"],"names":["createHandler"],"mappings":";;;;;;AAyDO,SAA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CAAO,MAAA;AAAA,UACnB,SAAS,MAAA,CAAO,OAAA;AAAA,UAChB,MAAM,MAAA,CAAO,IAAA,CAAK,OAAO,IAAI,CAAA,CAAE,SAAS,QAAQ,CAAA;AAAA,UAChD,eAAA,EAAiB;AAAA,SACnB;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,YAAY,MAAA,CAAO,MAAA;AAAA,QACnB,SAAS,MAAA,CAAO,OAAA;AAAA,QAChB,MAAM,MAAA,CAAO;AAAA,OACf;AAAA,IACF,CAAA,CAAA,MAAQ;AACN,MAAA,OAAO;AAAA,QACL,UAAA,EAAY,GAAA;AAAA,QACZ,OAAA,EAAS,EAAE,cAAA,EAAgB,kBAAA,EAAmB;AAAA,QAC9C,MAAM,IAAA,CAAK,SAAA,CAAU,EAAE,KAAA,EAAO,yBAAyB;AAAA,OACzD;AAAA,IACF;AAAA,EACF,CAAA;AACF;AAEA,SAAS,iBACP,OAAA,EACoC;AACpC,EAAA,MAAM,SAA6C,EAAC;AACpD,EAAA,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AAClD,IAAA,MAAA,CAAO,GAAA,CAAI,WAAA,EAAa,CAAA,GAAI,KAAA;AAAA,EAC9B;AACA,EAAA,OAAO,MAAA;AACT","file":"lambda.cjs","sourcesContent":["// Copyright 2026 FHIRfly.io LLC. All rights reserved.\n// Licensed under the MIT License. See LICENSE file in the project root.\nimport { createHandler } from \"../server/handler.js\";\nimport type { SHLHandlerConfig, HandlerRequest } from \"../server/types.js\";\n\n// Inline API Gateway v2 types — no @types/aws-lambda dependency needed\ninterface APIGatewayProxyEventV2 {\n requestContext: {\n http: {\n method: string;\n path: string;\n };\n };\n headers: Record<string, string | undefined>;\n queryStringParameters?: Record<string, string | undefined>;\n body?: string;\n isBase64Encoded?: boolean;\n}\n\ninterface APIGatewayProxyResultV2 {\n statusCode: number;\n headers: Record<string, string>;\n body: string;\n isBase64Encoded?: boolean;\n}\n\nexport interface LambdaHandlerConfig extends SHLHandlerConfig {\n /**\n * Path prefix to strip from the incoming event path.\n *\n * For example, if your API Gateway route is `/shl/{proxy+}`,\n * set `pathPrefix: \"/shl\"` so that `/shl/abc123` becomes `/abc123`.\n */\n pathPrefix?: string;\n}\n\n/**\n * Create an AWS Lambda handler for serving SMART Health Links.\n *\n * Designed for API Gateway v2 (HTTP API) event format. Strips the\n * optional `pathPrefix` from the incoming path before routing.\n *\n * @example\n * ```ts\n * import { lambdaHandler } from \"@fhirfly-io/shl/lambda\";\n * import { ServerS3Storage } from \"@fhirfly-io/shl/server\";\n *\n * export const handler = lambdaHandler({\n * storage: new ServerS3Storage({\n * bucket: \"my-shl-bucket\",\n * region: \"us-east-1\",\n * baseUrl: \"https://shl.example.com\",\n * }),\n * pathPrefix: \"/shl\",\n * });\n * ```\n */\nexport function lambdaHandler(\n config: LambdaHandlerConfig,\n): (event: APIGatewayProxyEventV2) => Promise<APIGatewayProxyResultV2> {\n const handle = createHandler(config);\n const prefix = config.pathPrefix?.replace(/\\/+$/, \"\") ?? \"\";\n\n return async (event: APIGatewayProxyEventV2): Promise<APIGatewayProxyResultV2> => {\n // Strip path prefix\n let path = event.requestContext.http.path;\n if (prefix && path.startsWith(prefix)) {\n path = path.slice(prefix.length) || \"/\";\n }\n\n // Parse body\n let body: unknown;\n if (event.body) {\n try {\n const raw = event.isBase64Encoded\n ? Buffer.from(event.body, \"base64\").toString(\"utf8\")\n : event.body;\n body = JSON.parse(raw);\n } catch {\n body = undefined;\n }\n }\n\n const handlerReq: HandlerRequest = {\n method: event.requestContext.http.method,\n path,\n body,\n headers: normalizeHeaders(event.headers),\n query: event.queryStringParameters,\n };\n\n try {\n const result = await handle(handlerReq);\n\n // Binary bodies (Uint8Array) need base64 encoding\n if (result.body instanceof Uint8Array) {\n return {\n statusCode: result.status,\n headers: result.headers,\n body: Buffer.from(result.body).toString(\"base64\"),\n isBase64Encoded: true,\n };\n }\n\n return {\n statusCode: result.status,\n headers: result.headers,\n body: result.body,\n };\n } catch {\n return {\n statusCode: 500,\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ error: \"Internal server error\" }),\n };\n }\n };\n}\n\nfunction normalizeHeaders(\n headers: Record<string, string | undefined>,\n): Record<string, string | undefined> {\n const result: Record<string, string | undefined> = {};\n for (const [key, value] of Object.entries(headers)) {\n result[key.toLowerCase()] = value;\n }\n return result;\n}\n"]}
|
package/dist/lambda.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SHLHandlerConfig } from './types-
|
|
2
|
-
import './types-
|
|
1
|
+
import { S as SHLHandlerConfig } from './types-Cdi4IkC9.cjs';
|
|
2
|
+
import './types-BLLJeWe_.cjs';
|
|
3
3
|
|
|
4
4
|
interface APIGatewayProxyEventV2 {
|
|
5
5
|
requestContext: {
|
|
@@ -9,6 +9,7 @@ interface APIGatewayProxyEventV2 {
|
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
headers: Record<string, string | undefined>;
|
|
12
|
+
queryStringParameters?: Record<string, string | undefined>;
|
|
12
13
|
body?: string;
|
|
13
14
|
isBase64Encoded?: boolean;
|
|
14
15
|
}
|
package/dist/lambda.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SHLHandlerConfig } from './types-
|
|
2
|
-
import './types-
|
|
1
|
+
import { S as SHLHandlerConfig } from './types-6Vw5fiat.js';
|
|
2
|
+
import './types-BLLJeWe_.js';
|
|
3
3
|
|
|
4
4
|
interface APIGatewayProxyEventV2 {
|
|
5
5
|
requestContext: {
|
|
@@ -9,6 +9,7 @@ interface APIGatewayProxyEventV2 {
|
|
|
9
9
|
};
|
|
10
10
|
};
|
|
11
11
|
headers: Record<string, string | undefined>;
|
|
12
|
+
queryStringParameters?: Record<string, string | undefined>;
|
|
12
13
|
body?: string;
|
|
13
14
|
isBase64Encoded?: boolean;
|
|
14
15
|
}
|
package/dist/lambda.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHandler } from './chunk-
|
|
1
|
+
import { createHandler } from './chunk-KGEFZQ6W.js';
|
|
2
2
|
import './chunk-PZ5AY32C.js';
|
|
3
3
|
|
|
4
4
|
// src/adapters/lambda.ts
|
|
@@ -23,7 +23,8 @@ function lambdaHandler(config) {
|
|
|
23
23
|
method: event.requestContext.http.method,
|
|
24
24
|
path,
|
|
25
25
|
body,
|
|
26
|
-
headers: normalizeHeaders(event.headers)
|
|
26
|
+
headers: normalizeHeaders(event.headers),
|
|
27
|
+
query: event.queryStringParameters
|
|
27
28
|
};
|
|
28
29
|
try {
|
|
29
30
|
const result = await handle(handlerReq);
|
package/dist/lambda.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/lambda.ts"],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"sources":["../src/adapters/lambda.ts"],"names":[],"mappings":";;;;AAyDO,SAAS,cACd,MAAA,EACqE;AACrE,EAAA,MAAM,MAAA,GAAS,cAAc,MAAM,CAAA;AACnC,EAAA,MAAM,SAAS,MAAA,CAAO,UAAA,EAAY,OAAA,CAAQ,MAAA,EAAQ,EAAE,CAAA,IAAK,EAAA;AAEzD,EAAA,OAAO,OAAO,KAAA,KAAoE;AAEhF,IAAA,IAAI,IAAA,GAAO,KAAA,CAAM,cAAA,CAAe,IAAA,CAAK,IAAA;AACrC,IAAA,IAAI,MAAA,IAAU,IAAA,CAAK,UAAA,CAAW,MAAM,CAAA,EAAG;AACrC,MAAA,IAAA,GAAO,IAAA,CAAK,KAAA,CAAM,MAAA,CAAO,MAAM,CAAA,IAAK,GAAA;AAAA,IACtC;AAGA,IAAA,IAAI,IAAA;AACJ,IAAA,IAAI,MAAM,IAAA,EAAM;AACd,MAAA,IAAI;AACF,QAAA,MAAM,GAAA,GAAM,KAAA,CAAM,eAAA,GACd,MAAA,CAAO,IAAA,CAAK,KAAA,CAAM,IAAA,EAAM,QAAQ,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,KAAA,MAAW,CAAC,GAAA,EAAK,KAAK,KAAK,MAAA,CAAO,OAAA,CAAQ,OAAO,CAAA,EAAG;AAClD,IAAA,MAAA,CAAO,GAAA,CAAI,WAAA,EAAa,CAAA,GAAI,KAAA;AAAA,EAC9B;AACA,EAAA,OAAO,MAAA;AACT","file":"lambda.js","sourcesContent":["// Copyright 2026 FHIRfly.io LLC. All rights reserved.\n// Licensed under the MIT License. See LICENSE file in the project root.\nimport { createHandler } from \"../server/handler.js\";\nimport type { SHLHandlerConfig, HandlerRequest } from \"../server/types.js\";\n\n// Inline API Gateway v2 types — no @types/aws-lambda dependency needed\ninterface APIGatewayProxyEventV2 {\n requestContext: {\n http: {\n method: string;\n path: string;\n };\n };\n headers: Record<string, string | undefined>;\n queryStringParameters?: Record<string, string | undefined>;\n body?: string;\n isBase64Encoded?: boolean;\n}\n\ninterface APIGatewayProxyResultV2 {\n statusCode: number;\n headers: Record<string, string>;\n body: string;\n isBase64Encoded?: boolean;\n}\n\nexport interface LambdaHandlerConfig extends SHLHandlerConfig {\n /**\n * Path prefix to strip from the incoming event path.\n *\n * For example, if your API Gateway route is `/shl/{proxy+}`,\n * set `pathPrefix: \"/shl\"` so that `/shl/abc123` becomes `/abc123`.\n */\n pathPrefix?: string;\n}\n\n/**\n * Create an AWS Lambda handler for serving SMART Health Links.\n *\n * Designed for API Gateway v2 (HTTP API) event format. Strips the\n * optional `pathPrefix` from the incoming path before routing.\n *\n * @example\n * ```ts\n * import { lambdaHandler } from \"@fhirfly-io/shl/lambda\";\n * import { ServerS3Storage } from \"@fhirfly-io/shl/server\";\n *\n * export const handler = lambdaHandler({\n * storage: new ServerS3Storage({\n * bucket: \"my-shl-bucket\",\n * region: \"us-east-1\",\n * baseUrl: \"https://shl.example.com\",\n * }),\n * pathPrefix: \"/shl\",\n * });\n * ```\n */\nexport function lambdaHandler(\n config: LambdaHandlerConfig,\n): (event: APIGatewayProxyEventV2) => Promise<APIGatewayProxyResultV2> {\n const handle = createHandler(config);\n const prefix = config.pathPrefix?.replace(/\\/+$/, \"\") ?? \"\";\n\n return async (event: APIGatewayProxyEventV2): Promise<APIGatewayProxyResultV2> => {\n // Strip path prefix\n let path = event.requestContext.http.path;\n if (prefix && path.startsWith(prefix)) {\n path = path.slice(prefix.length) || \"/\";\n }\n\n // Parse body\n let body: unknown;\n if (event.body) {\n try {\n const raw = event.isBase64Encoded\n ? Buffer.from(event.body, \"base64\").toString(\"utf8\")\n : event.body;\n body = JSON.parse(raw);\n } catch {\n body = undefined;\n }\n }\n\n const handlerReq: HandlerRequest = {\n method: event.requestContext.http.method,\n path,\n body,\n headers: normalizeHeaders(event.headers),\n query: event.queryStringParameters,\n };\n\n try {\n const result = await handle(handlerReq);\n\n // Binary bodies (Uint8Array) need base64 encoding\n if (result.body instanceof Uint8Array) {\n return {\n statusCode: result.status,\n headers: result.headers,\n body: Buffer.from(result.body).toString(\"base64\"),\n isBase64Encoded: true,\n };\n }\n\n return {\n statusCode: result.status,\n headers: result.headers,\n body: result.body,\n };\n } catch {\n return {\n statusCode: 500,\n headers: { \"content-type\": \"application/json\" },\n body: JSON.stringify({ error: \"Internal server error\" }),\n };\n }\n };\n}\n\nfunction normalizeHeaders(\n headers: Record<string, string | undefined>,\n): Record<string, string | undefined> {\n const result: Record<string, string | undefined> = {};\n for (const [key, value] of Object.entries(headers)) {\n result[key.toLowerCase()] = value;\n }\n return result;\n}\n"]}
|
package/dist/server.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkLXJB46WB_cjs = require('./chunk-LXJB46WB.cjs');
|
|
4
4
|
require('./chunk-UDS6UJAL.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkJOZ6XZPO_cjs = require('./chunk-JOZ6XZPO.cjs');
|
|
6
6
|
require('./chunk-Q7SFCCGT.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
@@ -25,7 +25,7 @@ Object.defineProperty(exports, "ServerS3Storage", {
|
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "createHandler", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function () { return
|
|
28
|
+
get: function () { return chunkJOZ6XZPO_cjs.createHandler; }
|
|
29
29
|
});
|
|
30
30
|
//# sourceMappingURL=server.cjs.map
|
|
31
31
|
//# sourceMappingURL=server.cjs.map
|
package/dist/server.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as SHLHandlerConfig, H as HandlerRequest, a as HandlerResponse, b as SHLServerStorage } from './types-
|
|
2
|
-
export { A as AccessEvent, C as CorsConfig } from './types-
|
|
3
|
-
import { A as AzureStorage, a as AzureStorageConfig, G as GCSStorage, b as GCSStorageConfig, L as LocalStorage, c as LocalStorageConfig, S as S3StorageConfig } from './storage-
|
|
4
|
-
import { a as SHLMetadata } from './types-
|
|
1
|
+
import { S as SHLHandlerConfig, H as HandlerRequest, a as HandlerResponse, b as SHLServerStorage } from './types-Cdi4IkC9.cjs';
|
|
2
|
+
export { A as AccessEvent, C as CorsConfig } from './types-Cdi4IkC9.cjs';
|
|
3
|
+
import { A as AzureStorage, a as AzureStorageConfig, G as GCSStorage, b as GCSStorageConfig, L as LocalStorage, c as LocalStorageConfig, S as S3StorageConfig } from './storage-BbzK-kFf.cjs';
|
|
4
|
+
import { a as SHLMetadata } from './types-BLLJeWe_.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a framework-agnostic SHL request handler.
|
package/dist/server.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { S as SHLHandlerConfig, H as HandlerRequest, a as HandlerResponse, b as SHLServerStorage } from './types-
|
|
2
|
-
export { A as AccessEvent, C as CorsConfig } from './types-
|
|
3
|
-
import { A as AzureStorage, a as AzureStorageConfig, G as GCSStorage, b as GCSStorageConfig, L as LocalStorage, c as LocalStorageConfig, S as S3StorageConfig } from './storage-
|
|
4
|
-
import { a as SHLMetadata } from './types-
|
|
1
|
+
import { S as SHLHandlerConfig, H as HandlerRequest, a as HandlerResponse, b as SHLServerStorage } from './types-6Vw5fiat.js';
|
|
2
|
+
export { A as AccessEvent, C as CorsConfig } from './types-6Vw5fiat.js';
|
|
3
|
+
import { A as AzureStorage, a as AzureStorageConfig, G as GCSStorage, b as GCSStorageConfig, L as LocalStorage, c as LocalStorageConfig, S as S3StorageConfig } from './storage-Cx7uXUl8.js';
|
|
4
|
+
import { a as SHLMetadata } from './types-BLLJeWe_.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Create a framework-agnostic SHL request handler.
|