@openhi/constructs 0.0.134 → 0.0.136
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/index.d.mts +145 -37
- package/lib/index.d.ts +146 -38
- package/lib/index.js +183 -51
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +181 -51
- package/lib/index.mjs.map +1 -1
- package/lib/rest-api-lambda.handler.js +554 -66
- package/lib/rest-api-lambda.handler.js.map +1 -1
- package/lib/rest-api-lambda.handler.mjs +554 -66
- package/lib/rest-api-lambda.handler.mjs.map +1 -1
- package/package.json +3 -3
package/lib/index.js
CHANGED
|
@@ -766,6 +766,7 @@ var require_lib2 = __commonJS({
|
|
|
766
766
|
// src/index.ts
|
|
767
767
|
var src_exports = {};
|
|
768
768
|
__export(src_exports, {
|
|
769
|
+
ADMIN_DOMAIN_PREFIX: () => ADMIN_DOMAIN_PREFIX,
|
|
769
770
|
BRIDGED_STATUSES: () => BRIDGED_STATUSES,
|
|
770
771
|
CLOUDFORMATION_EVENT_SOURCE: () => CLOUDFORMATION_EVENT_SOURCE,
|
|
771
772
|
CLOUDFORMATION_STACK_STATUS_CHANGE_DETAIL_TYPE: () => CLOUDFORMATION_STACK_STATUS_CHANGE_DETAIL_TYPE,
|
|
@@ -790,6 +791,7 @@ __export(src_exports, {
|
|
|
790
791
|
DEMO_PERIOD: () => DEMO_PERIOD,
|
|
791
792
|
DEMO_TENANT_SPECS: () => DEMO_TENANT_SPECS,
|
|
792
793
|
DEMO_URN_SYSTEM: () => DEMO_URN_SYSTEM,
|
|
794
|
+
DEV_CORS_ALLOW_ORIGINS: () => DEV_CORS_ALLOW_ORIGINS,
|
|
793
795
|
DEV_USERS: () => DEV_USERS,
|
|
794
796
|
DataEventBus: () => DataEventBus,
|
|
795
797
|
DataStoreHistoricalArchive: () => DataStoreHistoricalArchive,
|
|
@@ -1104,12 +1106,14 @@ var import_utils2 = require("@codedrifters/utils");
|
|
|
1104
1106
|
var import_config3 = __toESM(require_lib());
|
|
1105
1107
|
var import_aws_cdk_lib4 = require("aws-cdk-lib");
|
|
1106
1108
|
var import_change_case = require("change-case");
|
|
1109
|
+
var DEFAULT_RELEASE_BRANCH = "main";
|
|
1110
|
+
var CHILD_ZONE_PREFIX_MAX_LENGTH = 56;
|
|
1107
1111
|
var OPENHI_TAG_SUFFIX_REPO_NAME = "repo-name";
|
|
1108
1112
|
var OPENHI_TAG_SUFFIX_BRANCH_NAME = "branch-name";
|
|
1109
1113
|
var OPENHI_TAG_SUFFIX_SERVICE_TYPE = "service-type";
|
|
1110
1114
|
var OPENHI_TAG_SUFFIX_STAGE_TYPE = "stage-type";
|
|
1111
1115
|
var openHiTagKey = (appName, suffix) => `${appName}:${suffix}`;
|
|
1112
|
-
var OpenHiService = class extends import_aws_cdk_lib4.Stack {
|
|
1116
|
+
var OpenHiService = class _OpenHiService extends import_aws_cdk_lib4.Stack {
|
|
1113
1117
|
/**
|
|
1114
1118
|
* Creates a new OpenHI service stack.
|
|
1115
1119
|
*
|
|
@@ -1129,8 +1133,12 @@ var OpenHiService = class extends import_aws_cdk_lib4.Stack {
|
|
|
1129
1133
|
}
|
|
1130
1134
|
const appName = props.appName ?? ohEnv.ohStage.ohApp.appName ?? "openhi";
|
|
1131
1135
|
const repoName = props.repoName ?? (0, import_utils2.findGitRepoName)();
|
|
1132
|
-
const defaultReleaseBranch =
|
|
1133
|
-
|
|
1136
|
+
const { branchName, defaultReleaseBranch } = _OpenHiService.resolveBranchContext(ohEnv, {
|
|
1137
|
+
...props.branchName !== void 0 && { branchName: props.branchName },
|
|
1138
|
+
...props.defaultReleaseBranch !== void 0 && {
|
|
1139
|
+
defaultReleaseBranch: props.defaultReleaseBranch
|
|
1140
|
+
}
|
|
1141
|
+
});
|
|
1134
1142
|
const environmentHash = (0, import_utils2.hashString)(
|
|
1135
1143
|
[appName, ohEnv.deploymentTargetRole, account, region].join("-"),
|
|
1136
1144
|
6
|
|
@@ -1205,6 +1213,50 @@ var OpenHiService = class extends import_aws_cdk_lib4.Stack {
|
|
|
1205
1213
|
ohEnv.ohStage.stageType.slice(0, 255)
|
|
1206
1214
|
);
|
|
1207
1215
|
}
|
|
1216
|
+
/**
|
|
1217
|
+
* Compose the full per-deploy domain for an OpenHI service.
|
|
1218
|
+
*
|
|
1219
|
+
* On the release branch (`branchName === defaultReleaseBranch`), the
|
|
1220
|
+
* full domain is `<domainPrefix>.<zoneName>`. On every other branch
|
|
1221
|
+
* the per-PR preview hostname is
|
|
1222
|
+
* `<domainPrefix>-<childZonePrefix>.<zoneName>`.
|
|
1223
|
+
*
|
|
1224
|
+
* Pure helper — reads no environment state. Subclasses expose thin
|
|
1225
|
+
* statics (`composeFullDomain`) that fill in `domainPrefix` from their
|
|
1226
|
+
* own service constant and delegate here.
|
|
1227
|
+
*/
|
|
1228
|
+
static composeServiceDomain(opts) {
|
|
1229
|
+
const isRelease = opts.branchName === opts.defaultReleaseBranch;
|
|
1230
|
+
const subDomain = isRelease ? opts.domainPrefix : `${opts.domainPrefix}-${opts.childZonePrefix}`;
|
|
1231
|
+
return `${subDomain}.${opts.zoneName}`;
|
|
1232
|
+
}
|
|
1233
|
+
/**
|
|
1234
|
+
* Compute the `childZonePrefix` segment for a given branch — kebab-cased
|
|
1235
|
+
* and truncated to {@link CHILD_ZONE_PREFIX_MAX_LENGTH}. Matches the
|
|
1236
|
+
* per-instance {@link OpenHiService.childZonePrefix} getter so consumers
|
|
1237
|
+
* can compose hostnames identical to the service's own without
|
|
1238
|
+
* instantiating it.
|
|
1239
|
+
*/
|
|
1240
|
+
static computeChildZonePrefix(branchName) {
|
|
1241
|
+
return (0, import_change_case.paramCase)(branchName).slice(0, CHILD_ZONE_PREFIX_MAX_LENGTH);
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* Resolve the branch context the service would compute internally given
|
|
1245
|
+
* an environment and optional overrides. Mirrors the same defaulting
|
|
1246
|
+
* (props override → JEST sentinel → `GIT_BRANCH_NAME` env → git
|
|
1247
|
+
* detection on DEV → release branch on stage/prod) the
|
|
1248
|
+
* {@link OpenHiService} constructor uses.
|
|
1249
|
+
*
|
|
1250
|
+
* Consumers (e.g. sibling stack entries) call this to predict the
|
|
1251
|
+
* branch values a service will see at synth time so they can compose
|
|
1252
|
+
* hostnames against the same inputs.
|
|
1253
|
+
*/
|
|
1254
|
+
static resolveBranchContext(ohEnv, overrides = {}) {
|
|
1255
|
+
const defaultReleaseBranch = overrides.defaultReleaseBranch ?? DEFAULT_RELEASE_BRANCH;
|
|
1256
|
+
const branchName = overrides.branchName ?? (process.env.JEST_WORKER_ID ? "test-branch" : process.env.GIT_BRANCH_NAME?.trim() || (ohEnv.ohStage.stageType === import_config3.OPEN_HI_STAGE.DEV ? (0, import_utils2.findGitBranch)() : defaultReleaseBranch));
|
|
1257
|
+
const childZonePrefix = _OpenHiService.computeChildZonePrefix(branchName);
|
|
1258
|
+
return { branchName, defaultReleaseBranch, childZonePrefix };
|
|
1259
|
+
}
|
|
1208
1260
|
/**
|
|
1209
1261
|
* DNS prefix for this branche's child zone. Capped at 56 chars so
|
|
1210
1262
|
* that a `<service>-<prefix>` hostname segment stays under the 63-byte
|
|
@@ -1213,7 +1265,7 @@ var OpenHiService = class extends import_aws_cdk_lib4.Stack {
|
|
|
1213
1265
|
* headroom on the longer side.
|
|
1214
1266
|
*/
|
|
1215
1267
|
get childZonePrefix() {
|
|
1216
|
-
return
|
|
1268
|
+
return _OpenHiService.computeChildZonePrefix(this.branchName);
|
|
1217
1269
|
}
|
|
1218
1270
|
};
|
|
1219
1271
|
|
|
@@ -2550,7 +2602,9 @@ var _StaticHosting = class _StaticHosting extends import_constructs8.Construct {
|
|
|
2550
2602
|
"config-json-rewrite-function",
|
|
2551
2603
|
{
|
|
2552
2604
|
functionName: `static-hosting-config-json-rewrite-${branchHash}`,
|
|
2553
|
-
|
|
2605
|
+
// CloudFront caps `Comment` at 128 chars; the full rationale is in
|
|
2606
|
+
// the preceding code comment.
|
|
2607
|
+
comment: "Rewrites /config.json to the runtime-config path; copies Host into x-viewer-host.",
|
|
2554
2608
|
code: import_aws_cloudfront.FunctionCode.fromInline(
|
|
2555
2609
|
[
|
|
2556
2610
|
"function handler(event) {",
|
|
@@ -2570,7 +2624,9 @@ var _StaticHosting = class _StaticHosting extends import_constructs8.Construct {
|
|
|
2570
2624
|
"host-copy-function",
|
|
2571
2625
|
{
|
|
2572
2626
|
functionName: `static-hosting-host-copy-${branchHash}`,
|
|
2573
|
-
|
|
2627
|
+
// CloudFront caps `Comment` at 128 chars; the full rationale is in
|
|
2628
|
+
// the preceding code comment.
|
|
2629
|
+
comment: "Copies viewer Host into x-viewer-host for the origin-request Lambda@Edge.",
|
|
2574
2630
|
code: import_aws_cloudfront.FunctionCode.fromInline(
|
|
2575
2631
|
[
|
|
2576
2632
|
"function handler(event) {",
|
|
@@ -7113,6 +7169,7 @@ _OpenHiAuthService.SERVICE_TYPE = "auth";
|
|
|
7113
7169
|
var OpenHiAuthService = _OpenHiAuthService;
|
|
7114
7170
|
|
|
7115
7171
|
// src/services/open-hi-rest-api-service.ts
|
|
7172
|
+
var import_config5 = __toESM(require_lib());
|
|
7116
7173
|
var import_aws_apigatewayv22 = require("aws-cdk-lib/aws-apigatewayv2");
|
|
7117
7174
|
var import_aws_apigatewayv2_authorizers = require("aws-cdk-lib/aws-apigatewayv2-authorizers");
|
|
7118
7175
|
var import_aws_apigatewayv2_integrations = require("aws-cdk-lib/aws-apigatewayv2-integrations");
|
|
@@ -7191,7 +7248,31 @@ var RestApiLambda = class extends import_constructs20.Construct {
|
|
|
7191
7248
|
// src/services/open-hi-rest-api-service.ts
|
|
7192
7249
|
var REST_API_BASE_URL_SSM_NAME = "REST_API_BASE_URL";
|
|
7193
7250
|
var REST_API_DOMAIN_NAME_SSM_NAME = "REST_API_DOMAIN_NAME";
|
|
7251
|
+
var DEV_CORS_ALLOW_ORIGINS = [
|
|
7252
|
+
"http://localhost:3000",
|
|
7253
|
+
"https://localhost:3000",
|
|
7254
|
+
"http://localhost:5173",
|
|
7255
|
+
"https://localhost:5173",
|
|
7256
|
+
"http://127.0.0.1:3000",
|
|
7257
|
+
"https://127.0.0.1:3000",
|
|
7258
|
+
"http://127.0.0.1:5173",
|
|
7259
|
+
"https://127.0.0.1:5173"
|
|
7260
|
+
];
|
|
7194
7261
|
var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
7262
|
+
/**
|
|
7263
|
+
* Compose the REST API's full per-deploy domain. Thin wrapper over
|
|
7264
|
+
* {@link OpenHiService.composeServiceDomain} that pins `domainPrefix`
|
|
7265
|
+
* to {@link API_DOMAIN_PREFIX}.
|
|
7266
|
+
*
|
|
7267
|
+
* Use from sibling stacks that need to predict the API's hostname
|
|
7268
|
+
* before the REST API stack is synthesised.
|
|
7269
|
+
*/
|
|
7270
|
+
static composeFullDomain(opts) {
|
|
7271
|
+
return OpenHiService.composeServiceDomain({
|
|
7272
|
+
...opts,
|
|
7273
|
+
domainPrefix: _OpenHiRestApiService.API_DOMAIN_PREFIX
|
|
7274
|
+
});
|
|
7275
|
+
}
|
|
7195
7276
|
/**
|
|
7196
7277
|
* Returns an IHttpApi by looking up the REST API stack's HTTP API ID from SSM.
|
|
7197
7278
|
*/
|
|
@@ -7275,11 +7356,18 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
7275
7356
|
}
|
|
7276
7357
|
/**
|
|
7277
7358
|
* Returns the API domain name string (e.g. api.example.com or api-\{prefix\}.example.com).
|
|
7359
|
+
* Delegates to {@link OpenHiRestApiService.composeFullDomain} so the
|
|
7360
|
+
* release-vs-feature composition stays in one place; picks up
|
|
7361
|
+
* `this.defaultReleaseBranch` (not a hard-coded `"main"`).
|
|
7278
7362
|
* Override to customize.
|
|
7279
7363
|
*/
|
|
7280
7364
|
createApiDomainNameString(hostedZone) {
|
|
7281
|
-
|
|
7282
|
-
|
|
7365
|
+
return _OpenHiRestApiService.composeFullDomain({
|
|
7366
|
+
branchName: this.branchName,
|
|
7367
|
+
defaultReleaseBranch: this.defaultReleaseBranch,
|
|
7368
|
+
childZonePrefix: this.childZonePrefix,
|
|
7369
|
+
zoneName: hostedZone.zoneName
|
|
7370
|
+
});
|
|
7283
7371
|
}
|
|
7284
7372
|
/**
|
|
7285
7373
|
* Creates the SSM parameter for the REST API base URL.
|
|
@@ -7338,7 +7426,7 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
7338
7426
|
postgresSecretArn,
|
|
7339
7427
|
postgresDatabase,
|
|
7340
7428
|
postgresSchema,
|
|
7341
|
-
|
|
7429
|
+
extraEnvironment
|
|
7342
7430
|
});
|
|
7343
7431
|
lambda.addToRolePolicy(
|
|
7344
7432
|
new import_aws_iam7.PolicyStatement({
|
|
@@ -7428,7 +7516,10 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
7428
7516
|
routeKey: import_aws_apigatewayv22.HttpRouteKey.with("/{proxy+}", import_aws_apigatewayv22.HttpMethod.ANY),
|
|
7429
7517
|
integration
|
|
7430
7518
|
});
|
|
7431
|
-
const apiPrefix = this.
|
|
7519
|
+
const apiPrefix = this.apiDomainName.slice(
|
|
7520
|
+
0,
|
|
7521
|
+
-(hostedZone.zoneName.length + 1)
|
|
7522
|
+
);
|
|
7432
7523
|
new import_aws_route535.ARecord(this, `api-a-record-${apiPrefix}`, {
|
|
7433
7524
|
zone: hostedZone,
|
|
7434
7525
|
recordName: apiPrefix,
|
|
@@ -7454,27 +7545,10 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
7454
7545
|
{ userPoolClients: [userPoolClient] }
|
|
7455
7546
|
);
|
|
7456
7547
|
const { corsPreflight: cors, ...restRootHttpApiProps } = this.props.rootHttpApiProps ?? {};
|
|
7457
|
-
const
|
|
7458
|
-
|
|
7459
|
-
|
|
7460
|
-
|
|
7461
|
-
import_aws_apigatewayv22.CorsHttpMethod.HEAD,
|
|
7462
|
-
import_aws_apigatewayv22.CorsHttpMethod.POST,
|
|
7463
|
-
import_aws_apigatewayv22.CorsHttpMethod.PUT,
|
|
7464
|
-
import_aws_apigatewayv22.CorsHttpMethod.PATCH,
|
|
7465
|
-
import_aws_apigatewayv22.CorsHttpMethod.DELETE,
|
|
7466
|
-
import_aws_apigatewayv22.CorsHttpMethod.OPTIONS
|
|
7467
|
-
],
|
|
7468
|
-
allowHeaders: cors.allowHeaders ?? [
|
|
7469
|
-
"Content-Type",
|
|
7470
|
-
"Authorization"
|
|
7471
|
-
],
|
|
7472
|
-
allowCredentials: cors.allowCredentials ?? true,
|
|
7473
|
-
maxAge: cors.maxAge ?? import_core2.Duration.days(1),
|
|
7474
|
-
...cors.exposeHeaders !== void 0 && {
|
|
7475
|
-
exposeHeaders: cors.exposeHeaders
|
|
7476
|
-
}
|
|
7477
|
-
} : void 0;
|
|
7548
|
+
const isNonProd = this.ohEnv.ohStage.stageType !== import_config5.OPEN_HI_STAGE.PROD;
|
|
7549
|
+
const callerOrigins = cors?.allowOrigins ?? [];
|
|
7550
|
+
const mergedOrigins = isNonProd ? Array.from(/* @__PURE__ */ new Set([...callerOrigins, ...DEV_CORS_ALLOW_ORIGINS])) : callerOrigins;
|
|
7551
|
+
const corsPreflight = cors !== void 0 || isNonProd ? this.buildCorsPreflightOptions(mergedOrigins, cors) : void 0;
|
|
7478
7552
|
const rootHttpApi = new RootHttpApi(this, {
|
|
7479
7553
|
...restRootHttpApiProps,
|
|
7480
7554
|
...corsPreflight !== void 0 && { corsPreflight },
|
|
@@ -7491,21 +7565,43 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
7491
7565
|
});
|
|
7492
7566
|
return rootHttpApi;
|
|
7493
7567
|
}
|
|
7568
|
+
/**
|
|
7569
|
+
* Builds the full `CorsPreflightOptions` from a merged origins array,
|
|
7570
|
+
* filling defaults for `allowMethods`/`allowHeaders`/`allowCredentials`/
|
|
7571
|
+
* `maxAge` from the caller-supplied block when present.
|
|
7572
|
+
*/
|
|
7573
|
+
buildCorsPreflightOptions(allowOrigins, cors) {
|
|
7574
|
+
return {
|
|
7575
|
+
allowOrigins: [...allowOrigins],
|
|
7576
|
+
allowMethods: cors?.allowMethods ?? [
|
|
7577
|
+
import_aws_apigatewayv22.CorsHttpMethod.GET,
|
|
7578
|
+
import_aws_apigatewayv22.CorsHttpMethod.HEAD,
|
|
7579
|
+
import_aws_apigatewayv22.CorsHttpMethod.POST,
|
|
7580
|
+
import_aws_apigatewayv22.CorsHttpMethod.PUT,
|
|
7581
|
+
import_aws_apigatewayv22.CorsHttpMethod.PATCH,
|
|
7582
|
+
import_aws_apigatewayv22.CorsHttpMethod.DELETE,
|
|
7583
|
+
import_aws_apigatewayv22.CorsHttpMethod.OPTIONS
|
|
7584
|
+
],
|
|
7585
|
+
allowHeaders: cors?.allowHeaders ?? ["Content-Type", "Authorization"],
|
|
7586
|
+
allowCredentials: cors?.allowCredentials ?? true,
|
|
7587
|
+
maxAge: cors?.maxAge ?? import_core2.Duration.days(1),
|
|
7588
|
+
...cors?.exposeHeaders !== void 0 && {
|
|
7589
|
+
exposeHeaders: cors.exposeHeaders
|
|
7590
|
+
}
|
|
7591
|
+
};
|
|
7592
|
+
}
|
|
7494
7593
|
/**
|
|
7495
7594
|
* Builds the `OPENHI_RUNTIME_CONFIG_*` env-var map the REST API Lambda
|
|
7496
|
-
* exposes through `GET /control/runtime-config`.
|
|
7497
|
-
*
|
|
7498
|
-
*
|
|
7499
|
-
*
|
|
7500
|
-
*
|
|
7501
|
-
*
|
|
7502
|
-
*
|
|
7503
|
-
*
|
|
7595
|
+
* exposes through `GET /control/runtime-config`. The four values are
|
|
7596
|
+
* always populated — the three Cognito IDs are resolved via SSM lookups
|
|
7597
|
+
* against the auth stack from a dedicated sub-scope (`runtime-config`)
|
|
7598
|
+
* so they don't collide with the user-pool / user-pool-client constructs
|
|
7599
|
+
* already created in {@link createRootHttpApi}, and `apiBaseUrl` is
|
|
7600
|
+
* derived from this stack's own custom domain. The OAuth callback URL
|
|
7601
|
+
* is no longer plumbed through the API — the admin-console derives it
|
|
7602
|
+
* client-side from `window.location.origin`.
|
|
7504
7603
|
*/
|
|
7505
7604
|
resolveRuntimeConfigEnvVars() {
|
|
7506
|
-
if (this.props.runtimeConfig === void 0) {
|
|
7507
|
-
return void 0;
|
|
7508
|
-
}
|
|
7509
7605
|
const cognitoScope = new import_constructs21.Construct(this, "runtime-config");
|
|
7510
7606
|
const userPool = OpenHiAuthService.userPoolFromConstruct(cognitoScope);
|
|
7511
7607
|
const userPoolClient = OpenHiAuthService.userPoolClientFromConstruct(cognitoScope);
|
|
@@ -7514,12 +7610,16 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
|
|
|
7514
7610
|
OPENHI_RUNTIME_CONFIG_COGNITO_USER_POOL_ID: userPool.userPoolId,
|
|
7515
7611
|
OPENHI_RUNTIME_CONFIG_COGNITO_USER_POOL_CLIENT_ID: userPoolClient.userPoolClientId,
|
|
7516
7612
|
OPENHI_RUNTIME_CONFIG_COGNITO_DOMAIN_URL: cognitoDomainUrl,
|
|
7517
|
-
OPENHI_RUNTIME_CONFIG_COGNITO_REDIRECT_URI: this.props.runtimeConfig.cognitoRedirectUri,
|
|
7518
7613
|
OPENHI_RUNTIME_CONFIG_API_BASE_URL: `https://${this.apiDomainName}`
|
|
7519
7614
|
};
|
|
7520
7615
|
}
|
|
7521
7616
|
};
|
|
7522
7617
|
_OpenHiRestApiService.SERVICE_TYPE = "rest-api";
|
|
7618
|
+
/**
|
|
7619
|
+
* Sub-domain prefix used by the REST API. Release-branch hostname is
|
|
7620
|
+
* `api.<zone>`; per-PR preview hostname is `api-<childZonePrefix>.<zone>`.
|
|
7621
|
+
*/
|
|
7622
|
+
_OpenHiRestApiService.API_DOMAIN_PREFIX = "api";
|
|
7523
7623
|
var OpenHiRestApiService = _OpenHiRestApiService;
|
|
7524
7624
|
|
|
7525
7625
|
// src/services/open-hi-graphql-service.ts
|
|
@@ -7560,10 +7660,26 @@ _OpenHiGraphqlService.SERVICE_TYPE = "graphql-api";
|
|
|
7560
7660
|
var OpenHiGraphqlService = _OpenHiGraphqlService;
|
|
7561
7661
|
|
|
7562
7662
|
// src/services/open-hi-website-service.ts
|
|
7563
|
-
var
|
|
7663
|
+
var import_config6 = __toESM(require_lib());
|
|
7564
7664
|
var import_aws_s32 = require("aws-cdk-lib/aws-s3");
|
|
7565
7665
|
var SSM_PARAM_NAME_FULL_DOMAIN = "WEBSITE_FULL_DOMAIN";
|
|
7666
|
+
var ADMIN_DOMAIN_PREFIX = "admin";
|
|
7566
7667
|
var _OpenHiWebsiteService = class _OpenHiWebsiteService extends OpenHiService {
|
|
7668
|
+
/**
|
|
7669
|
+
* Compose the website's full per-deploy domain. Thin wrapper over
|
|
7670
|
+
* {@link OpenHiService.composeServiceDomain} that fills in
|
|
7671
|
+
* {@link DEFAULT_DOMAIN_PREFIX} when `domainPrefix` is omitted.
|
|
7672
|
+
*
|
|
7673
|
+
* Use from sibling stacks that need to predict the website's hostname
|
|
7674
|
+
* before the website stack is synthesised — e.g. the REST API stack
|
|
7675
|
+
* computing its CORS `allowOrigins` for the admin-console.
|
|
7676
|
+
*/
|
|
7677
|
+
static composeFullDomain(opts) {
|
|
7678
|
+
return OpenHiService.composeServiceDomain({
|
|
7679
|
+
...opts,
|
|
7680
|
+
domainPrefix: opts.domainPrefix ?? _OpenHiWebsiteService.DEFAULT_DOMAIN_PREFIX
|
|
7681
|
+
});
|
|
7682
|
+
}
|
|
7567
7683
|
/**
|
|
7568
7684
|
* Looks up the static-hosting bucket ARN published by the release-branch
|
|
7569
7685
|
* deploy of this service.
|
|
@@ -7682,16 +7798,24 @@ var _OpenHiWebsiteService = class _OpenHiWebsiteService extends OpenHiService {
|
|
|
7682
7798
|
* every other deploy serves a per-PR preview at
|
|
7683
7799
|
* `\<domainPrefix\>-\<childZonePrefix\>.\<zone\>`
|
|
7684
7800
|
* (e.g. `admin-feat-1093-patient-migration.dev.openhi.org`).
|
|
7801
|
+
*
|
|
7802
|
+
* Delegates to {@link OpenHiWebsiteService.composeFullDomain} so the
|
|
7803
|
+
* release-vs-feature composition stays in one place.
|
|
7685
7804
|
*/
|
|
7686
7805
|
computeFullDomain(hostedZone) {
|
|
7687
|
-
|
|
7688
|
-
|
|
7806
|
+
return _OpenHiWebsiteService.composeFullDomain({
|
|
7807
|
+
domainPrefix: this.props.domainPrefix,
|
|
7808
|
+
branchName: this.branchName,
|
|
7809
|
+
defaultReleaseBranch: this.defaultReleaseBranch,
|
|
7810
|
+
childZonePrefix: this.childZonePrefix,
|
|
7811
|
+
zoneName: hostedZone.zoneName
|
|
7812
|
+
});
|
|
7689
7813
|
}
|
|
7690
7814
|
/**
|
|
7691
7815
|
* Returns the sub-domain label (left of the zone) for the current
|
|
7692
|
-
* deploy. Used
|
|
7693
|
-
*
|
|
7694
|
-
*
|
|
7816
|
+
* deploy. Used for the per-branch S3 key prefix passed to
|
|
7817
|
+
* {@link StaticContent} so the upload prefix always matches the
|
|
7818
|
+
* served hostname.
|
|
7695
7819
|
*
|
|
7696
7820
|
* Non-release deploys compose the per-PR slug as
|
|
7697
7821
|
* `\<domainPrefix\>-\<childZonePrefix\>`, mirroring the REST API's
|
|
@@ -7702,7 +7826,7 @@ var _OpenHiWebsiteService = class _OpenHiWebsiteService extends OpenHiService {
|
|
|
7702
7826
|
*/
|
|
7703
7827
|
computeSubDomain() {
|
|
7704
7828
|
const isReleaseBranch = this.branchName === this.defaultReleaseBranch;
|
|
7705
|
-
const domainPrefix = this.props.domainPrefix ??
|
|
7829
|
+
const domainPrefix = this.props.domainPrefix ?? _OpenHiWebsiteService.DEFAULT_DOMAIN_PREFIX;
|
|
7706
7830
|
if (isReleaseBranch) {
|
|
7707
7831
|
return domainPrefix;
|
|
7708
7832
|
}
|
|
@@ -7729,7 +7853,7 @@ var _OpenHiWebsiteService = class _OpenHiWebsiteService extends OpenHiService {
|
|
|
7729
7853
|
domainNames: [this.fullDomain, wildcardSan],
|
|
7730
7854
|
description: `OpenHI website (${this.fullDomain})`,
|
|
7731
7855
|
prefixPattern: PER_BRANCH_PREVIEW_PREFIX,
|
|
7732
|
-
enablePreviewLifecycle: this.ohEnv.ohStage.stageType !==
|
|
7856
|
+
enablePreviewLifecycle: this.ohEnv.ohStage.stageType !== import_config6.OPEN_HI_STAGE.PROD,
|
|
7733
7857
|
...restApi !== void 0 && { restApi }
|
|
7734
7858
|
});
|
|
7735
7859
|
}
|
|
@@ -7815,6 +7939,12 @@ var _OpenHiWebsiteService = class _OpenHiWebsiteService extends OpenHiService {
|
|
|
7815
7939
|
}
|
|
7816
7940
|
};
|
|
7817
7941
|
_OpenHiWebsiteService.SERVICE_TYPE = "website";
|
|
7942
|
+
/**
|
|
7943
|
+
* Default `domainPrefix` for this service when none is supplied.
|
|
7944
|
+
* Release-branch hostname is `www.<zone>`; per-PR preview hostname is
|
|
7945
|
+
* `www-<childZonePrefix>.<zone>`.
|
|
7946
|
+
*/
|
|
7947
|
+
_OpenHiWebsiteService.DEFAULT_DOMAIN_PREFIX = "www";
|
|
7818
7948
|
var OpenHiWebsiteService = _OpenHiWebsiteService;
|
|
7819
7949
|
|
|
7820
7950
|
// src/workflows/control-plane/owning-delete-cascade/events.ts
|
|
@@ -8319,6 +8449,7 @@ var RenameCascadeWorkflow = class extends import_constructs25.Construct {
|
|
|
8319
8449
|
};
|
|
8320
8450
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8321
8451
|
0 && (module.exports = {
|
|
8452
|
+
ADMIN_DOMAIN_PREFIX,
|
|
8322
8453
|
BRIDGED_STATUSES,
|
|
8323
8454
|
CLOUDFORMATION_EVENT_SOURCE,
|
|
8324
8455
|
CLOUDFORMATION_STACK_STATUS_CHANGE_DETAIL_TYPE,
|
|
@@ -8343,6 +8474,7 @@ var RenameCascadeWorkflow = class extends import_constructs25.Construct {
|
|
|
8343
8474
|
DEMO_PERIOD,
|
|
8344
8475
|
DEMO_TENANT_SPECS,
|
|
8345
8476
|
DEMO_URN_SYSTEM,
|
|
8477
|
+
DEV_CORS_ALLOW_ORIGINS,
|
|
8346
8478
|
DEV_USERS,
|
|
8347
8479
|
DataEventBus,
|
|
8348
8480
|
DataStoreHistoricalArchive,
|