@openhi/constructs 0.0.115 → 0.0.117
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/lib/{chunk-X5MHU7DA.mjs → chunk-I7IIPV5X.mjs} +25 -5
- package/lib/chunk-I7IIPV5X.mjs.map +1 -0
- package/lib/data-store-postgres-replication.handler.js +24 -4
- package/lib/data-store-postgres-replication.handler.js.map +1 -1
- package/lib/data-store-postgres-replication.handler.mjs +1 -1
- package/lib/firehose-archive-transform.handler.js +24 -4
- package/lib/firehose-archive-transform.handler.js.map +1 -1
- package/lib/firehose-archive-transform.handler.mjs +1 -1
- package/lib/index.d.mts +287 -14
- package/lib/index.d.ts +302 -15
- package/lib/index.js +426 -131
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +473 -169
- package/lib/index.mjs.map +1 -1
- package/lib/static-hosting.viewer-request-handler.d.mts +54 -0
- package/lib/static-hosting.viewer-request-handler.d.ts +54 -0
- package/lib/static-hosting.viewer-request-handler.js +79 -0
- package/lib/static-hosting.viewer-request-handler.js.map +1 -0
- package/lib/static-hosting.viewer-request-handler.mjs +53 -0
- package/lib/static-hosting.viewer-request-handler.mjs.map +1 -0
- package/package.json +3 -3
- package/lib/chunk-X5MHU7DA.mjs.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CloudFrontRequest, CloudFrontRequestEvent } from 'aws-lambda';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @see sites/www-docs/content/packages/@openhi/constructs/components/static-hosting/static-hosting.viewer-request-handler.md
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Hosting mode controls how path-like URIs get a default document.
|
|
8
|
+
*
|
|
9
|
+
* - `spa`: path-like URIs (e.g. `/dashboard`, `/patients/123`) rewrite to
|
|
10
|
+
* `/index.html` so the single-page app's root index is served and the
|
|
11
|
+
* client-side router handles the path.
|
|
12
|
+
* - `static`: path-like URIs append `/index.html` (e.g. `/docs` becomes
|
|
13
|
+
* `/docs/index.html`) so multi-page static sites can serve distinct
|
|
14
|
+
* HTML per path.
|
|
15
|
+
*/
|
|
16
|
+
type HostingMode = "spa" | "static";
|
|
17
|
+
/**
|
|
18
|
+
* Viewer Request Handler for SPA mode.
|
|
19
|
+
*
|
|
20
|
+
* - Logs the request
|
|
21
|
+
* - Rewrites path-like URIs to `/index.html`
|
|
22
|
+
* - Prepends the Host header as a folder for multi-tenant routing
|
|
23
|
+
*/
|
|
24
|
+
declare const spaHandler: (event: CloudFrontRequestEvent) => Promise<CloudFrontRequest>;
|
|
25
|
+
/**
|
|
26
|
+
* Viewer Request Handler for static (non-SPA) mode.
|
|
27
|
+
*
|
|
28
|
+
* - Logs the request
|
|
29
|
+
* - Rewrites path-like URIs to `<path>/index.html`
|
|
30
|
+
* - Prepends the Host header as a folder for multi-tenant routing
|
|
31
|
+
*/
|
|
32
|
+
declare const staticHandler: (event: CloudFrontRequestEvent) => Promise<CloudFrontRequest>;
|
|
33
|
+
/**
|
|
34
|
+
* Adds a default document to the request URI based on the hosting mode.
|
|
35
|
+
*
|
|
36
|
+
* In both modes:
|
|
37
|
+
* - `/` and `/index.html` become `/index.html`
|
|
38
|
+
* - URIs whose last segment contains a dot are treated as static files and
|
|
39
|
+
* left unchanged.
|
|
40
|
+
*
|
|
41
|
+
* In `spa` mode, all other path-like URIs rewrite to `/index.html`.
|
|
42
|
+
* In `static` mode, path-like URIs append `/index.html` (trailing slash
|
|
43
|
+
* preserved as a single slash): `/docs` and `/docs/` both become
|
|
44
|
+
* `/docs/index.html`.
|
|
45
|
+
*/
|
|
46
|
+
declare const addDefaultDocument: (request: CloudFrontRequest, mode: HostingMode) => CloudFrontRequest;
|
|
47
|
+
/**
|
|
48
|
+
* Prepends the Host header as a folder to the request URI. Used for
|
|
49
|
+
* multi-tenant routing where each domain maps to a folder in the S3
|
|
50
|
+
* bucket (e.g. `example.com/foo` -> `/example.com/foo`).
|
|
51
|
+
*/
|
|
52
|
+
declare const addDomainFolder: (request: CloudFrontRequest) => CloudFrontRequest;
|
|
53
|
+
|
|
54
|
+
export { type HostingMode, addDefaultDocument, addDomainFolder, spaHandler, staticHandler };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { CloudFrontRequest, CloudFrontRequestEvent } from 'aws-lambda';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @see sites/www-docs/content/packages/@openhi/constructs/components/static-hosting/static-hosting.viewer-request-handler.md
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Hosting mode controls how path-like URIs get a default document.
|
|
8
|
+
*
|
|
9
|
+
* - `spa`: path-like URIs (e.g. `/dashboard`, `/patients/123`) rewrite to
|
|
10
|
+
* `/index.html` so the single-page app's root index is served and the
|
|
11
|
+
* client-side router handles the path.
|
|
12
|
+
* - `static`: path-like URIs append `/index.html` (e.g. `/docs` becomes
|
|
13
|
+
* `/docs/index.html`) so multi-page static sites can serve distinct
|
|
14
|
+
* HTML per path.
|
|
15
|
+
*/
|
|
16
|
+
type HostingMode = "spa" | "static";
|
|
17
|
+
/**
|
|
18
|
+
* Viewer Request Handler for SPA mode.
|
|
19
|
+
*
|
|
20
|
+
* - Logs the request
|
|
21
|
+
* - Rewrites path-like URIs to `/index.html`
|
|
22
|
+
* - Prepends the Host header as a folder for multi-tenant routing
|
|
23
|
+
*/
|
|
24
|
+
declare const spaHandler: (event: CloudFrontRequestEvent) => Promise<CloudFrontRequest>;
|
|
25
|
+
/**
|
|
26
|
+
* Viewer Request Handler for static (non-SPA) mode.
|
|
27
|
+
*
|
|
28
|
+
* - Logs the request
|
|
29
|
+
* - Rewrites path-like URIs to `<path>/index.html`
|
|
30
|
+
* - Prepends the Host header as a folder for multi-tenant routing
|
|
31
|
+
*/
|
|
32
|
+
declare const staticHandler: (event: CloudFrontRequestEvent) => Promise<CloudFrontRequest>;
|
|
33
|
+
/**
|
|
34
|
+
* Adds a default document to the request URI based on the hosting mode.
|
|
35
|
+
*
|
|
36
|
+
* In both modes:
|
|
37
|
+
* - `/` and `/index.html` become `/index.html`
|
|
38
|
+
* - URIs whose last segment contains a dot are treated as static files and
|
|
39
|
+
* left unchanged.
|
|
40
|
+
*
|
|
41
|
+
* In `spa` mode, all other path-like URIs rewrite to `/index.html`.
|
|
42
|
+
* In `static` mode, path-like URIs append `/index.html` (trailing slash
|
|
43
|
+
* preserved as a single slash): `/docs` and `/docs/` both become
|
|
44
|
+
* `/docs/index.html`.
|
|
45
|
+
*/
|
|
46
|
+
declare const addDefaultDocument: (request: CloudFrontRequest, mode: HostingMode) => CloudFrontRequest;
|
|
47
|
+
/**
|
|
48
|
+
* Prepends the Host header as a folder to the request URI. Used for
|
|
49
|
+
* multi-tenant routing where each domain maps to a folder in the S3
|
|
50
|
+
* bucket (e.g. `example.com/foo` -> `/example.com/foo`).
|
|
51
|
+
*/
|
|
52
|
+
declare const addDomainFolder: (request: CloudFrontRequest) => CloudFrontRequest;
|
|
53
|
+
|
|
54
|
+
export { type HostingMode, addDefaultDocument, addDomainFolder, spaHandler, staticHandler };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/static-hosting/static-hosting.viewer-request-handler.ts
|
|
21
|
+
var static_hosting_viewer_request_handler_exports = {};
|
|
22
|
+
__export(static_hosting_viewer_request_handler_exports, {
|
|
23
|
+
addDefaultDocument: () => addDefaultDocument,
|
|
24
|
+
addDomainFolder: () => addDomainFolder,
|
|
25
|
+
spaHandler: () => spaHandler,
|
|
26
|
+
staticHandler: () => staticHandler
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(static_hosting_viewer_request_handler_exports);
|
|
29
|
+
var isTestEnv = process.env.JEST_WORKER_ID !== void 0;
|
|
30
|
+
var spaHandler = async (event) => {
|
|
31
|
+
return runHandler(event, "spa");
|
|
32
|
+
};
|
|
33
|
+
var staticHandler = async (event) => {
|
|
34
|
+
return runHandler(event, "static");
|
|
35
|
+
};
|
|
36
|
+
var runHandler = async (event, mode) => {
|
|
37
|
+
if (!isTestEnv) {
|
|
38
|
+
console.log("Request Event: ", JSON.stringify(event, null, 2));
|
|
39
|
+
}
|
|
40
|
+
let request = event.Records[0].cf.request;
|
|
41
|
+
request = addDefaultDocument(request, mode);
|
|
42
|
+
request = addDomainFolder(request);
|
|
43
|
+
if (!isTestEnv) {
|
|
44
|
+
console.log("Resulting Request: ", JSON.stringify(request, null, 2));
|
|
45
|
+
}
|
|
46
|
+
return request;
|
|
47
|
+
};
|
|
48
|
+
var addDefaultDocument = (request, mode) => {
|
|
49
|
+
if (request.uri === "/" || request.uri === "/index.html") {
|
|
50
|
+
request.uri = "/index.html";
|
|
51
|
+
return request;
|
|
52
|
+
}
|
|
53
|
+
const segments = request.uri.split("/").filter(Boolean);
|
|
54
|
+
const lastSegment = segments[segments.length - 1] ?? "";
|
|
55
|
+
const looksLikeStaticFile = lastSegment.includes(".");
|
|
56
|
+
if (looksLikeStaticFile) {
|
|
57
|
+
return request;
|
|
58
|
+
}
|
|
59
|
+
if (mode === "spa") {
|
|
60
|
+
request.uri = "/index.html";
|
|
61
|
+
return request;
|
|
62
|
+
}
|
|
63
|
+
const normalized = request.uri.endsWith("/") ? request.uri.slice(0, -1) : request.uri;
|
|
64
|
+
request.uri = `${normalized}/index.html`;
|
|
65
|
+
return request;
|
|
66
|
+
};
|
|
67
|
+
var addDomainFolder = (request) => {
|
|
68
|
+
const hostHeader = request.headers.host[0].value;
|
|
69
|
+
request.uri = `/${hostHeader}${request.uri}`;
|
|
70
|
+
return request;
|
|
71
|
+
};
|
|
72
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
+
0 && (module.exports = {
|
|
74
|
+
addDefaultDocument,
|
|
75
|
+
addDomainFolder,
|
|
76
|
+
spaHandler,
|
|
77
|
+
staticHandler
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=static-hosting.viewer-request-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/static-hosting/static-hosting.viewer-request-handler.ts"],"sourcesContent":["import { CloudFrontRequest, CloudFrontRequestEvent } from \"aws-lambda\";\n\n/**\n * @see sites/www-docs/content/packages/@openhi/constructs/components/static-hosting/static-hosting.viewer-request-handler.md\n */\n\n/**\n * Hosting mode controls how path-like URIs get a default document.\n *\n * - `spa`: path-like URIs (e.g. `/dashboard`, `/patients/123`) rewrite to\n * `/index.html` so the single-page app's root index is served and the\n * client-side router handles the path.\n * - `static`: path-like URIs append `/index.html` (e.g. `/docs` becomes\n * `/docs/index.html`) so multi-page static sites can serve distinct\n * HTML per path.\n */\nexport type HostingMode = \"spa\" | \"static\";\n\nconst isTestEnv = process.env.JEST_WORKER_ID !== undefined;\n\n/**\n * Viewer Request Handler for SPA mode.\n *\n * - Logs the request\n * - Rewrites path-like URIs to `/index.html`\n * - Prepends the Host header as a folder for multi-tenant routing\n */\nexport const spaHandler = async (\n event: CloudFrontRequestEvent,\n): Promise<CloudFrontRequest> => {\n return runHandler(event, \"spa\");\n};\n\n/**\n * Viewer Request Handler for static (non-SPA) mode.\n *\n * - Logs the request\n * - Rewrites path-like URIs to `<path>/index.html`\n * - Prepends the Host header as a folder for multi-tenant routing\n */\nexport const staticHandler = async (\n event: CloudFrontRequestEvent,\n): Promise<CloudFrontRequest> => {\n return runHandler(event, \"static\");\n};\n\nconst runHandler = async (\n event: CloudFrontRequestEvent,\n mode: HostingMode,\n): Promise<CloudFrontRequest> => {\n if (!isTestEnv) {\n console.log(\"Request Event: \", JSON.stringify(event, null, 2));\n }\n\n let request = event.Records[0].cf.request;\n\n // add index if needed\n request = addDefaultDocument(request, mode);\n\n // prepend folder with domain\n request = addDomainFolder(request);\n\n if (!isTestEnv) {\n console.log(\"Resulting Request: \", JSON.stringify(request, null, 2));\n }\n\n return request;\n};\n\n/**\n * Adds a default document to the request URI based on the hosting mode.\n *\n * In both modes:\n * - `/` and `/index.html` become `/index.html`\n * - URIs whose last segment contains a dot are treated as static files and\n * left unchanged.\n *\n * In `spa` mode, all other path-like URIs rewrite to `/index.html`.\n * In `static` mode, path-like URIs append `/index.html` (trailing slash\n * preserved as a single slash): `/docs` and `/docs/` both become\n * `/docs/index.html`.\n */\nexport const addDefaultDocument = (\n request: CloudFrontRequest,\n mode: HostingMode,\n) => {\n if (request.uri === \"/\" || request.uri === \"/index.html\") {\n request.uri = \"/index.html\";\n return request;\n }\n\n const segments = request.uri.split(\"/\").filter(Boolean);\n const lastSegment = segments[segments.length - 1] ?? \"\";\n const looksLikeStaticFile = lastSegment.includes(\".\");\n\n if (looksLikeStaticFile) {\n return request;\n }\n\n if (mode === \"spa\") {\n request.uri = \"/index.html\";\n return request;\n }\n\n // static mode: append /index.html to the path, collapsing any trailing slash\n const normalized = request.uri.endsWith(\"/\")\n ? request.uri.slice(0, -1)\n : request.uri;\n request.uri = `${normalized}/index.html`;\n return request;\n};\n\n/**\n * Prepends the Host header as a folder to the request URI. Used for\n * multi-tenant routing where each domain maps to a folder in the S3\n * bucket (e.g. `example.com/foo` -> `/example.com/foo`).\n */\nexport const addDomainFolder = (request: CloudFrontRequest) => {\n const hostHeader = request.headers.host[0].value;\n request.uri = `/${hostHeader}${request.uri}`;\n return request;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,IAAM,YAAY,QAAQ,IAAI,mBAAmB;AAS1C,IAAM,aAAa,OACxB,UAC+B;AAC/B,SAAO,WAAW,OAAO,KAAK;AAChC;AASO,IAAM,gBAAgB,OAC3B,UAC+B;AAC/B,SAAO,WAAW,OAAO,QAAQ;AACnC;AAEA,IAAM,aAAa,OACjB,OACA,SAC+B;AAC/B,MAAI,CAAC,WAAW;AACd,YAAQ,IAAI,mBAAmB,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC;AAAA,EAC/D;AAEA,MAAI,UAAU,MAAM,QAAQ,CAAC,EAAE,GAAG;AAGlC,YAAU,mBAAmB,SAAS,IAAI;AAG1C,YAAU,gBAAgB,OAAO;AAEjC,MAAI,CAAC,WAAW;AACd,YAAQ,IAAI,uBAAuB,KAAK,UAAU,SAAS,MAAM,CAAC,CAAC;AAAA,EACrE;AAEA,SAAO;AACT;AAeO,IAAM,qBAAqB,CAChC,SACA,SACG;AACH,MAAI,QAAQ,QAAQ,OAAO,QAAQ,QAAQ,eAAe;AACxD,YAAQ,MAAM;AACd,WAAO;AAAA,EACT;AAEA,QAAM,WAAW,QAAQ,IAAI,MAAM,GAAG,EAAE,OAAO,OAAO;AACtD,QAAM,cAAc,SAAS,SAAS,SAAS,CAAC,KAAK;AACrD,QAAM,sBAAsB,YAAY,SAAS,GAAG;AAEpD,MAAI,qBAAqB;AACvB,WAAO;AAAA,EACT;AAEA,MAAI,SAAS,OAAO;AAClB,YAAQ,MAAM;AACd,WAAO;AAAA,EACT;AAGA,QAAM,aAAa,QAAQ,IAAI,SAAS,GAAG,IACvC,QAAQ,IAAI,MAAM,GAAG,EAAE,IACvB,QAAQ;AACZ,UAAQ,MAAM,GAAG,UAAU;AAC3B,SAAO;AACT;AAOO,IAAM,kBAAkB,CAAC,YAA+B;AAC7D,QAAM,aAAa,QAAQ,QAAQ,KAAK,CAAC,EAAE;AAC3C,UAAQ,MAAM,IAAI,UAAU,GAAG,QAAQ,GAAG;AAC1C,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import "./chunk-LZOMFHX3.mjs";
|
|
2
|
+
|
|
3
|
+
// src/components/static-hosting/static-hosting.viewer-request-handler.ts
|
|
4
|
+
var isTestEnv = process.env.JEST_WORKER_ID !== void 0;
|
|
5
|
+
var spaHandler = async (event) => {
|
|
6
|
+
return runHandler(event, "spa");
|
|
7
|
+
};
|
|
8
|
+
var staticHandler = async (event) => {
|
|
9
|
+
return runHandler(event, "static");
|
|
10
|
+
};
|
|
11
|
+
var runHandler = async (event, mode) => {
|
|
12
|
+
if (!isTestEnv) {
|
|
13
|
+
console.log("Request Event: ", JSON.stringify(event, null, 2));
|
|
14
|
+
}
|
|
15
|
+
let request = event.Records[0].cf.request;
|
|
16
|
+
request = addDefaultDocument(request, mode);
|
|
17
|
+
request = addDomainFolder(request);
|
|
18
|
+
if (!isTestEnv) {
|
|
19
|
+
console.log("Resulting Request: ", JSON.stringify(request, null, 2));
|
|
20
|
+
}
|
|
21
|
+
return request;
|
|
22
|
+
};
|
|
23
|
+
var addDefaultDocument = (request, mode) => {
|
|
24
|
+
if (request.uri === "/" || request.uri === "/index.html") {
|
|
25
|
+
request.uri = "/index.html";
|
|
26
|
+
return request;
|
|
27
|
+
}
|
|
28
|
+
const segments = request.uri.split("/").filter(Boolean);
|
|
29
|
+
const lastSegment = segments[segments.length - 1] ?? "";
|
|
30
|
+
const looksLikeStaticFile = lastSegment.includes(".");
|
|
31
|
+
if (looksLikeStaticFile) {
|
|
32
|
+
return request;
|
|
33
|
+
}
|
|
34
|
+
if (mode === "spa") {
|
|
35
|
+
request.uri = "/index.html";
|
|
36
|
+
return request;
|
|
37
|
+
}
|
|
38
|
+
const normalized = request.uri.endsWith("/") ? request.uri.slice(0, -1) : request.uri;
|
|
39
|
+
request.uri = `${normalized}/index.html`;
|
|
40
|
+
return request;
|
|
41
|
+
};
|
|
42
|
+
var addDomainFolder = (request) => {
|
|
43
|
+
const hostHeader = request.headers.host[0].value;
|
|
44
|
+
request.uri = `/${hostHeader}${request.uri}`;
|
|
45
|
+
return request;
|
|
46
|
+
};
|
|
47
|
+
export {
|
|
48
|
+
addDefaultDocument,
|
|
49
|
+
addDomainFolder,
|
|
50
|
+
spaHandler,
|
|
51
|
+
staticHandler
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=static-hosting.viewer-request-handler.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/static-hosting/static-hosting.viewer-request-handler.ts"],"sourcesContent":["import { CloudFrontRequest, CloudFrontRequestEvent } from \"aws-lambda\";\n\n/**\n * @see sites/www-docs/content/packages/@openhi/constructs/components/static-hosting/static-hosting.viewer-request-handler.md\n */\n\n/**\n * Hosting mode controls how path-like URIs get a default document.\n *\n * - `spa`: path-like URIs (e.g. `/dashboard`, `/patients/123`) rewrite to\n * `/index.html` so the single-page app's root index is served and the\n * client-side router handles the path.\n * - `static`: path-like URIs append `/index.html` (e.g. `/docs` becomes\n * `/docs/index.html`) so multi-page static sites can serve distinct\n * HTML per path.\n */\nexport type HostingMode = \"spa\" | \"static\";\n\nconst isTestEnv = process.env.JEST_WORKER_ID !== undefined;\n\n/**\n * Viewer Request Handler for SPA mode.\n *\n * - Logs the request\n * - Rewrites path-like URIs to `/index.html`\n * - Prepends the Host header as a folder for multi-tenant routing\n */\nexport const spaHandler = async (\n event: CloudFrontRequestEvent,\n): Promise<CloudFrontRequest> => {\n return runHandler(event, \"spa\");\n};\n\n/**\n * Viewer Request Handler for static (non-SPA) mode.\n *\n * - Logs the request\n * - Rewrites path-like URIs to `<path>/index.html`\n * - Prepends the Host header as a folder for multi-tenant routing\n */\nexport const staticHandler = async (\n event: CloudFrontRequestEvent,\n): Promise<CloudFrontRequest> => {\n return runHandler(event, \"static\");\n};\n\nconst runHandler = async (\n event: CloudFrontRequestEvent,\n mode: HostingMode,\n): Promise<CloudFrontRequest> => {\n if (!isTestEnv) {\n console.log(\"Request Event: \", JSON.stringify(event, null, 2));\n }\n\n let request = event.Records[0].cf.request;\n\n // add index if needed\n request = addDefaultDocument(request, mode);\n\n // prepend folder with domain\n request = addDomainFolder(request);\n\n if (!isTestEnv) {\n console.log(\"Resulting Request: \", JSON.stringify(request, null, 2));\n }\n\n return request;\n};\n\n/**\n * Adds a default document to the request URI based on the hosting mode.\n *\n * In both modes:\n * - `/` and `/index.html` become `/index.html`\n * - URIs whose last segment contains a dot are treated as static files and\n * left unchanged.\n *\n * In `spa` mode, all other path-like URIs rewrite to `/index.html`.\n * In `static` mode, path-like URIs append `/index.html` (trailing slash\n * preserved as a single slash): `/docs` and `/docs/` both become\n * `/docs/index.html`.\n */\nexport const addDefaultDocument = (\n request: CloudFrontRequest,\n mode: HostingMode,\n) => {\n if (request.uri === \"/\" || request.uri === \"/index.html\") {\n request.uri = \"/index.html\";\n return request;\n }\n\n const segments = request.uri.split(\"/\").filter(Boolean);\n const lastSegment = segments[segments.length - 1] ?? \"\";\n const looksLikeStaticFile = lastSegment.includes(\".\");\n\n if (looksLikeStaticFile) {\n return request;\n }\n\n if (mode === \"spa\") {\n request.uri = \"/index.html\";\n return request;\n }\n\n // static mode: append /index.html to the path, collapsing any trailing slash\n const normalized = request.uri.endsWith(\"/\")\n ? request.uri.slice(0, -1)\n : request.uri;\n request.uri = `${normalized}/index.html`;\n return request;\n};\n\n/**\n * Prepends the Host header as a folder to the request URI. Used for\n * multi-tenant routing where each domain maps to a folder in the S3\n * bucket (e.g. `example.com/foo` -> `/example.com/foo`).\n */\nexport const addDomainFolder = (request: CloudFrontRequest) => {\n const hostHeader = request.headers.host[0].value;\n request.uri = `/${hostHeader}${request.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AAQ,GAAG;AAC1C,SAAO;AACT;","names":[]}
|
package/package.json
CHANGED
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"pg": "^8.20.0",
|
|
56
56
|
"type-fest": "^4",
|
|
57
57
|
"ulid": "^3.0.2",
|
|
58
|
-
"@openhi/
|
|
58
|
+
"@openhi/types": "0.0.0",
|
|
59
59
|
"@openhi/workflows": "0.0.0",
|
|
60
|
-
"@openhi/
|
|
60
|
+
"@openhi/config": "0.0.0"
|
|
61
61
|
},
|
|
62
62
|
"devEngines": {
|
|
63
63
|
"packageManager": {
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"version": "0.0.
|
|
74
|
+
"version": "0.0.117",
|
|
75
75
|
"types": "lib/index.d.ts",
|
|
76
76
|
"//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"pnpm exec projen\".",
|
|
77
77
|
"scripts": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/dynamodb/firehose-archive-transform.handler.ts"],"sourcesContent":["import { randomUUID } from \"node:crypto\";\nimport type { AttributeValue } from \"@aws-sdk/client-dynamodb\";\nimport {\n EventBridgeClient,\n PutEventsCommand,\n type PutEventsRequestEntry,\n type PutEventsResultEntry,\n} from \"@aws-sdk/client-eventbridge\";\nimport { PutObjectCommand, S3Client } from \"@aws-sdk/client-s3\";\nimport type {\n FirehoseTransformationEvent,\n FirehoseTransformationResult,\n FirehoseTransformationResultRecord,\n} from \"aws-lambda\";\nimport {\n DATA_STORE_CHANGE_DETAIL_MAX_UTF8_BYTES,\n DATA_STORE_CHANGE_DETAIL_TYPE,\n DATA_STORE_CHANGE_EVENT_SOURCE,\n buildFhirCurrentResourceChangeDetail,\n} from \"./data-store-change-events\";\nimport {\n type DynamoDbStreamKinesisRecord,\n dynamodbImageToPlain,\n} from \"./dynamodb-stream-record\";\n\nexport type { DynamoDbStreamKinesisRecord } from \"./dynamodb-stream-record\";\n\n/**\n * Firehose data-transformation handler: filters DynamoDB change records to\n * current FHIR resource items (SK = CURRENT, TID#…#WID#…#RT#…#ID#… PK),\n * writes archive JSON to S3 via Firehose, sets dynamic partition keys per\n * ADR 2026-03-11-02, and publishes de-identified change notifications to the\n * data event bus via PutEvents per ADR 2026-03-02-01, with retries and an S3\n * dead-letter bucket for entries that still fail.\n */\n\nconst CURRENT_SK = \"CURRENT\";\nconst PK_PATTERN =\n /^TID#(?<tenantId>[^#]+)#WID#(?<workspaceId>[^#]+)#RT#(?<resourceType>[^#]+)#ID#(?<resourceId>.+)$/;\n\n/** DynamoDB-managed attribute on global table items (see AWS Global Tables legacy / replication docs). */\nconst AWS_REP_UPDATE_REGION = \"aws:rep:updateregion\";\n\nfunction getDynamoDbStringAttr(\n image: Record<string, AttributeValue> | undefined,\n name: string,\n): string | undefined {\n if (!image) {\n return undefined;\n }\n const av = image[name];\n if (typeof av?.S === \"string\" && av.S.trim() !== \"\") {\n return av.S.trim();\n }\n return undefined;\n}\n\nfunction primaryImageForReplicationCheck(\n record: DynamoDbStreamKinesisRecord,\n): Record<string, AttributeValue> | undefined {\n if (record.eventName === \"REMOVE\") {\n return record.dynamodb?.OldImage;\n }\n return record.dynamodb?.NewImage;\n}\n\n/**\n * Returns true when this stream/Kinesis record should not be archived because it\n * represents a **replica-side application** of a global-table change (the logical\n * write originated in another Region).\n *\n * - If `aws:rep:updateregion` is present on the item image and differs from\n * `archiveLambdaRegion`, the change was replicated into this Region (archive\n * only in the Region that matches `aws:rep:updateregion`).\n * - Otherwise, if `userIdentity` matches the DynamoDB replication service SLR,\n * treat as replication. **Excluded:** TTL deletes (`type` Service and\n * `principalId` `dynamodb.amazonaws.com`) per AWS stream Identity docs.\n *\n * For MREC global tables version 2019.11.21, AWS documents that stream records\n * may not carry distinguishable metadata; the recommended approach is a custom\n * “write region” attribute on items. If neither that attribute nor\n * `aws:rep:updateregion` nor replication `userIdentity` applies, this function\n * returns false (no drop)—duplicate archives are possible if identical pipelines\n * run in every Region without those signals.\n */\nexport function shouldDropAsGlobalTableReplicationRecord(\n record: DynamoDbStreamKinesisRecord,\n archiveLambdaRegion: string,\n): boolean {\n const image = primaryImageForReplicationCheck(record);\n const updateRegion = getDynamoDbStringAttr(image, AWS_REP_UPDATE_REGION);\n if (\n updateRegion &&\n archiveLambdaRegion &&\n updateRegion !== archiveLambdaRegion\n ) {\n return true;\n }\n\n return isDynamoDbReplicationUserIdentity(record.userIdentity);\n}\n\nfunction isDynamoDbReplicationUserIdentity(userIdentity: unknown): boolean {\n if (!userIdentity || typeof userIdentity !== \"object\") {\n return false;\n }\n const ui = userIdentity as Record<string, unknown>;\n const principalRaw = ui.principalId ?? ui.PrincipalId;\n const typeRaw = ui.type ?? ui.Type;\n const principal =\n typeof principalRaw === \"string\" ? principalRaw.toLowerCase() : \"\";\n const type = typeof typeRaw === \"string\" ? typeRaw.toLowerCase() : \"\";\n\n if (type === \"service\" && principal === \"dynamodb.amazonaws.com\") {\n return false;\n }\n\n const replicationMarkers = [\n \"awsservicerolefordynamodbreplication\",\n \"replication.dynamodb.amazonaws.com\",\n ];\n return replicationMarkers.some((m) => principal.includes(m));\n}\n\nexport function parseCurrentResourceKeys(record: DynamoDbStreamKinesisRecord): {\n tenantId: string;\n workspaceId: string;\n resourceType: string;\n resourceId: string;\n version: string;\n} | null {\n const keys = record.dynamodb?.Keys;\n if (!keys) {\n return null;\n }\n const pkAttr = keys.PK?.S;\n const skAttr = keys.SK?.S;\n if (!pkAttr || skAttr !== CURRENT_SK) {\n return null;\n }\n const m = PK_PATTERN.exec(pkAttr);\n if (!m?.groups) {\n return null;\n }\n const { tenantId, workspaceId, resourceType, resourceId } = m.groups;\n const image =\n record.eventName === \"REMOVE\"\n ? record.dynamodb?.OldImage\n : record.dynamodb?.NewImage;\n if (!image) {\n return null;\n }\n const plain = dynamodbImageToPlain(image as Record<string, AttributeValue>);\n const version = typeof plain.vid === \"string\" ? plain.vid : null;\n if (!version) {\n return null;\n }\n return { tenantId, workspaceId, resourceType, resourceId, version };\n}\n\nfunction partitionToken(value: string): string {\n if (!value || value.trim() === \"\") {\n return \"-\";\n }\n return value.replace(/[/\\\\]/g, \"_\");\n}\n\nfunction buildArchivePayload(\n record: DynamoDbStreamKinesisRecord,\n keys: ReturnType<typeof parseCurrentResourceKeys>,\n): Record<string, unknown> {\n const newImage = record.dynamodb?.NewImage;\n const oldImage = record.dynamodb?.OldImage;\n const resourceImage = record.eventName === \"REMOVE\" ? oldImage : newImage;\n const resourcePlain = resourceImage\n ? dynamodbImageToPlain(resourceImage as Record<string, AttributeValue>)\n : {};\n\n if (typeof resourcePlain.resource === \"string\") {\n try {\n resourcePlain.resource = JSON.parse(resourcePlain.resource) as unknown;\n } catch {\n /* keep raw string if not valid JSON */\n }\n }\n\n return {\n eventName: record.eventName,\n archivedAt: new Date().toISOString(),\n tenantId: keys!.tenantId,\n workspaceId: keys!.workspaceId,\n resourceType: keys!.resourceType,\n resourceId: keys!.resourceId,\n version: keys!.version,\n resource: resourcePlain,\n };\n}\n\nconst PUT_EVENTS_BATCH_SIZE = 10;\n\n/** Full PutEvents rounds per chunk (initial attempt + failure-driven retries). */\nconst MAX_PUT_EVENTS_ROUNDS = 3;\n\nlet eventBridgeClient: EventBridgeClient | undefined;\n\nfunction getEventBridgeClient(): EventBridgeClient | undefined {\n const bus = process.env.DATA_EVENT_BUS_NAME?.trim();\n if (!bus) {\n return undefined;\n }\n if (!eventBridgeClient) {\n eventBridgeClient = new EventBridgeClient({});\n }\n return eventBridgeClient;\n}\n\nlet s3ClientForDlq: S3Client | undefined;\n\nfunction getS3ClientForDlq(): S3Client | undefined {\n const bucket = process.env.DATA_STORE_PUT_EVENTS_DLQ_BUCKET?.trim();\n if (!bucket) {\n return undefined;\n }\n if (!s3ClientForDlq) {\n s3ClientForDlq = new S3Client({});\n }\n return s3ClientForDlq;\n}\n\ntype PutEventsEntry = PutEventsRequestEntry;\n\ninterface PutEventsDlqPayload {\n dlqSchemaVersion: 1;\n failedAt: string;\n reason: \"put_events_partial_failure\" | \"put_events_sdk_error\";\n attemptRounds: number;\n entries: PutEventsEntry[];\n putEventsResultEntries?: PutEventsResultEntry[];\n sdkError?: string;\n}\n\nasync function writePutEventsFailuresToDlq(\n payload: PutEventsDlqPayload,\n): Promise<void> {\n const bucket = process.env.DATA_STORE_PUT_EVENTS_DLQ_BUCKET?.trim();\n const client = getS3ClientForDlq();\n if (!bucket || !client) {\n throw new Error(\n `PutEvents exhausted retries but DATA_STORE_PUT_EVENTS_DLQ_BUCKET is not set (${payload.reason})`,\n );\n }\n const day = payload.failedAt.slice(0, 10);\n const key = `put-events-failed/${day}/${randomUUID()}.json`;\n await client.send(\n new PutObjectCommand({\n Bucket: bucket,\n Key: key,\n Body: JSON.stringify(payload),\n ContentType: \"application/json\",\n }),\n );\n}\n\n/**\n * Sends one PutEvents batch (≤10 entries) with up to {@link MAX_PUT_EVENTS_ROUNDS}\n * rounds. After the last round, remaining failures or a final SDK error are\n * written to the DLQ S3 bucket (if configured); DLQ write failure throws.\n */\nasync function putEventsChunkWithRetriesAndDlq(\n client: EventBridgeClient,\n entries: PutEventsEntry[],\n): Promise<void> {\n if (entries.length === 0) {\n return;\n }\n\n let pending = [...entries];\n\n for (let round = 1; round <= MAX_PUT_EVENTS_ROUNDS; round++) {\n try {\n const out = await client.send(new PutEventsCommand({ Entries: pending }));\n const failed = out.FailedEntryCount ?? 0;\n if (failed === 0) {\n return;\n }\n\n const nextPending: PutEventsEntry[] = [];\n out.Entries?.forEach((e: PutEventsResultEntry | undefined, i: number) => {\n if (e?.ErrorCode && pending[i]) {\n nextPending.push(pending[i]!);\n }\n });\n pending = nextPending;\n\n if (pending.length === 0) {\n return;\n }\n\n if (round === MAX_PUT_EVENTS_ROUNDS) {\n await writePutEventsFailuresToDlq({\n dlqSchemaVersion: 1,\n failedAt: new Date().toISOString(),\n reason: \"put_events_partial_failure\",\n attemptRounds: MAX_PUT_EVENTS_ROUNDS,\n entries: pending,\n putEventsResultEntries: out.Entries,\n });\n return;\n }\n } catch (sdkErr) {\n const sdkMessage =\n sdkErr instanceof Error ? sdkErr.message : String(sdkErr);\n if (round === MAX_PUT_EVENTS_ROUNDS) {\n await writePutEventsFailuresToDlq({\n dlqSchemaVersion: 1,\n failedAt: new Date().toISOString(),\n reason: \"put_events_sdk_error\",\n attemptRounds: MAX_PUT_EVENTS_ROUNDS,\n entries: pending,\n sdkError: sdkMessage,\n });\n return;\n }\n await new Promise((r) => setTimeout(r, 50 * round));\n }\n }\n}\n\nasync function publishDataStoreChangeEvents(\n pending: Array<{\n change: DynamoDbStreamKinesisRecord;\n keys: NonNullable<ReturnType<typeof parseCurrentResourceKeys>>;\n }>,\n): Promise<void> {\n const client = getEventBridgeClient();\n const busName = process.env.DATA_EVENT_BUS_NAME?.trim();\n if (!client || !busName || pending.length === 0) {\n return;\n }\n\n const entries: PutEventsEntry[] = [];\n for (const { change, keys } of pending) {\n const detailObj = buildFhirCurrentResourceChangeDetail(change, keys);\n const detail = JSON.stringify(detailObj);\n const detailBytes = Buffer.byteLength(detail, \"utf8\");\n if (detailBytes > DATA_STORE_CHANGE_DETAIL_MAX_UTF8_BYTES) {\n throw new Error(\n `Event detail is ${detailBytes} bytes (max ${DATA_STORE_CHANGE_DETAIL_MAX_UTF8_BYTES}); ` +\n `oversize strategy deferred per ADR 2026-03-02-01 (${keys.resourceType}/${keys.resourceId}).`,\n );\n }\n entries.push({\n Source: DATA_STORE_CHANGE_EVENT_SOURCE,\n DetailType: DATA_STORE_CHANGE_DETAIL_TYPE,\n Detail: detail,\n EventBusName: busName,\n });\n }\n\n for (let i = 0; i < entries.length; i += PUT_EVENTS_BATCH_SIZE) {\n const chunk = entries.slice(i, i + PUT_EVENTS_BATCH_SIZE);\n await putEventsChunkWithRetriesAndDlq(client, chunk);\n }\n}\n\nexport async function handler(\n event: FirehoseTransformationEvent,\n): Promise<FirehoseTransformationResult> {\n const records: FirehoseTransformationResultRecord[] = [];\n const archiveLambdaRegion = process.env.AWS_REGION ?? \"\";\n const pendingPublish: Array<{\n change: DynamoDbStreamKinesisRecord;\n keys: NonNullable<ReturnType<typeof parseCurrentResourceKeys>>;\n }> = [];\n\n for (const rec of event.records) {\n try {\n const payload = Buffer.from(rec.data, \"base64\").toString(\"utf8\");\n const change = JSON.parse(payload) as DynamoDbStreamKinesisRecord;\n\n if (\n shouldDropAsGlobalTableReplicationRecord(change, archiveLambdaRegion)\n ) {\n records.push({\n recordId: rec.recordId,\n result: \"Dropped\",\n data: rec.data,\n });\n continue;\n }\n\n const keys = parseCurrentResourceKeys(change);\n\n if (!keys) {\n records.push({\n recordId: rec.recordId,\n result: \"Dropped\",\n data: rec.data,\n });\n continue;\n }\n\n const archive = buildArchivePayload(change, keys);\n const out = Buffer.from(`${JSON.stringify(archive)}\\n`).toString(\n \"base64\",\n );\n\n pendingPublish.push({ change, keys });\n\n records.push({\n recordId: rec.recordId,\n result: \"Ok\",\n data: out,\n metadata: {\n partitionKeys: {\n tenantId: partitionToken(keys.tenantId),\n workspaceId: partitionToken(keys.workspaceId),\n resourceType: partitionToken(keys.resourceType),\n resourceId: partitionToken(keys.resourceId),\n version: partitionToken(keys.version),\n },\n },\n });\n } catch {\n records.push({\n recordId: rec.recordId,\n result: \"ProcessingFailed\",\n data: rec.data,\n });\n }\n }\n\n await publishDataStoreChangeEvents(pendingPublish);\n\n return { records };\n}\n"],"mappings":";;;;;;;;;AAAA,SAAS,kBAAkB;AAE3B;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,kBAAkB,gBAAgB;AA4B3C,IAAM,aAAa;AACnB,IAAM,aACJ;AAGF,IAAM,wBAAwB;AAE9B,SAAS,sBACP,OACA,MACoB;AACpB,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AACA,QAAM,KAAK,MAAM,IAAI;AACrB,MAAI,OAAO,IAAI,MAAM,YAAY,GAAG,EAAE,KAAK,MAAM,IAAI;AACnD,WAAO,GAAG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