@openhi/constructs 0.0.131 → 0.0.133

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 CHANGED
@@ -1708,16 +1708,14 @@ declare class OpenHiGlobalService extends OpenHiService {
1708
1708
  /**
1709
1709
  * Caller-supplied portion of the runtime-config payload exposed through the
1710
1710
  * public `GET /control/runtime-config` route. The three Cognito IDs are
1711
- * resolved inside the service via SSM lookups against the auth stack, so the
1712
- * caller only supplies the values the service cannot derive itself: the
1713
- * OAuth redirect URI (depends on the website's domain) and the API base URL
1714
- * (depends on the integration path the website's CloudFront uses).
1711
+ * resolved inside the service via SSM lookups against the auth stack, and
1712
+ * the API base URL is derived from this stack's own custom domain — so the
1713
+ * caller only supplies the OAuth redirect URI (depends on the website's
1714
+ * domain).
1715
1715
  */
1716
1716
  interface OpenHiRestApiRuntimeConfig {
1717
1717
  /** OAuth redirect URI registered on the User Pool client (e.g. https://admin.example.com/oauth/callback). */
1718
1718
  readonly cognitoRedirectUri: string;
1719
- /** Base URL the admin-console uses to reach the REST API (typically a same-origin `/api` relative path). */
1720
- readonly apiBaseUrl: string;
1721
1719
  }
1722
1720
  interface OpenHiRestApiServiceProps extends OpenHiServiceProps {
1723
1721
  /**
@@ -1729,10 +1727,9 @@ interface OpenHiRestApiServiceProps extends OpenHiServiceProps {
1729
1727
  * Values exposed through the public `GET /control/runtime-config` route.
1730
1728
  * When supplied, the service plumbs five `OPENHI_RUNTIME_CONFIG_*`
1731
1729
  * environment variables to the REST API Lambda — the three Cognito IDs
1732
- * are resolved internally from the auth stack via SSM, and the two
1733
- * fields on this prop are passed verbatim. The website's CloudFront
1734
- * distribution proxies `/api/*` to this endpoint so the admin-console can
1735
- * fetch its bootstrap config same-origin and stay branch-agnostic.
1730
+ * are resolved internally from the auth stack via SSM, the API base URL
1731
+ * is derived from this stack's own custom domain (e.g.
1732
+ * `https://api.<zone>`), and the OAuth redirect URI is passed verbatim.
1736
1733
  *
1737
1734
  * Omit to leave the route returning 500 (missing-env-var diagnostic).
1738
1735
  */
@@ -1775,6 +1772,12 @@ declare class OpenHiRestApiService extends OpenHiService {
1775
1772
  /** Override so this.props is typed with this service's options (e.g. rootHttpApiProps). */
1776
1773
  props: OpenHiRestApiServiceProps;
1777
1774
  readonly rootHttpApi: RootHttpApi;
1775
+ /**
1776
+ * REST API custom domain (bare hostname, no scheme — e.g.
1777
+ * `api.dev.openhi.org`). Captured so {@link resolveRuntimeConfigEnvVars}
1778
+ * can derive the public `apiBaseUrl` without callers having to hardcode it.
1779
+ */
1780
+ private readonly apiDomainName;
1778
1781
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiRestApiServiceProps);
1779
1782
  /**
1780
1783
  * Validates that config required for the REST API stack is present.
@@ -1833,7 +1836,8 @@ declare class OpenHiRestApiService extends OpenHiService {
1833
1836
  * The three Cognito IDs are resolved via SSM lookups against the auth
1834
1837
  * stack from a dedicated sub-scope (`runtime-config`) so they don't
1835
1838
  * collide with the user-pool / user-pool-client constructs already
1836
- * created in {@link createRootHttpApi}.
1839
+ * created in {@link createRootHttpApi}. `apiBaseUrl` is derived from
1840
+ * this stack's own custom domain so callers don't have to hardcode it.
1837
1841
  */
1838
1842
  protected resolveRuntimeConfigEnvVars(): Record<string, string> | undefined;
1839
1843
  }
package/lib/index.d.ts CHANGED
@@ -2345,16 +2345,14 @@ declare class OpenHiGlobalService extends OpenHiService {
2345
2345
  /**
2346
2346
  * Caller-supplied portion of the runtime-config payload exposed through the
2347
2347
  * public `GET /control/runtime-config` route. The three Cognito IDs are
2348
- * resolved inside the service via SSM lookups against the auth stack, so the
2349
- * caller only supplies the values the service cannot derive itself: the
2350
- * OAuth redirect URI (depends on the website's domain) and the API base URL
2351
- * (depends on the integration path the website's CloudFront uses).
2348
+ * resolved inside the service via SSM lookups against the auth stack, and
2349
+ * the API base URL is derived from this stack's own custom domain — so the
2350
+ * caller only supplies the OAuth redirect URI (depends on the website's
2351
+ * domain).
2352
2352
  */
2353
2353
  interface OpenHiRestApiRuntimeConfig {
2354
2354
  /** OAuth redirect URI registered on the User Pool client (e.g. https://admin.example.com/oauth/callback). */
2355
2355
  readonly cognitoRedirectUri: string;
2356
- /** Base URL the admin-console uses to reach the REST API (typically a same-origin `/api` relative path). */
2357
- readonly apiBaseUrl: string;
2358
2356
  }
2359
2357
  interface OpenHiRestApiServiceProps extends OpenHiServiceProps {
2360
2358
  /**
@@ -2366,10 +2364,9 @@ interface OpenHiRestApiServiceProps extends OpenHiServiceProps {
2366
2364
  * Values exposed through the public `GET /control/runtime-config` route.
2367
2365
  * When supplied, the service plumbs five `OPENHI_RUNTIME_CONFIG_*`
2368
2366
  * environment variables to the REST API Lambda — the three Cognito IDs
2369
- * are resolved internally from the auth stack via SSM, and the two
2370
- * fields on this prop are passed verbatim. The website's CloudFront
2371
- * distribution proxies `/api/*` to this endpoint so the admin-console can
2372
- * fetch its bootstrap config same-origin and stay branch-agnostic.
2367
+ * are resolved internally from the auth stack via SSM, the API base URL
2368
+ * is derived from this stack's own custom domain (e.g.
2369
+ * `https://api.<zone>`), and the OAuth redirect URI is passed verbatim.
2373
2370
  *
2374
2371
  * Omit to leave the route returning 500 (missing-env-var diagnostic).
2375
2372
  */
@@ -2412,6 +2409,12 @@ declare class OpenHiRestApiService extends OpenHiService {
2412
2409
  /** Override so this.props is typed with this service's options (e.g. rootHttpApiProps). */
2413
2410
  props: OpenHiRestApiServiceProps;
2414
2411
  readonly rootHttpApi: RootHttpApi;
2412
+ /**
2413
+ * REST API custom domain (bare hostname, no scheme — e.g.
2414
+ * `api.dev.openhi.org`). Captured so {@link resolveRuntimeConfigEnvVars}
2415
+ * can derive the public `apiBaseUrl` without callers having to hardcode it.
2416
+ */
2417
+ private readonly apiDomainName;
2415
2418
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiRestApiServiceProps);
2416
2419
  /**
2417
2420
  * Validates that config required for the REST API stack is present.
@@ -2470,7 +2473,8 @@ declare class OpenHiRestApiService extends OpenHiService {
2470
2473
  * The three Cognito IDs are resolved via SSM lookups against the auth
2471
2474
  * stack from a dedicated sub-scope (`runtime-config`) so they don't
2472
2475
  * collide with the user-pool / user-pool-client constructs already
2473
- * created in {@link createRootHttpApi}.
2476
+ * created in {@link createRootHttpApi}. `apiBaseUrl` is derived from
2477
+ * this stack's own custom domain so callers don't have to hardcode it.
2474
2478
  */
2475
2479
  protected resolveRuntimeConfigEnvVars(): Record<string, string> | undefined;
2476
2480
  }
package/lib/index.js CHANGED
@@ -2466,7 +2466,7 @@ var _StaticHosting = class _StaticHosting extends import_constructs8.Construct {
2466
2466
  if (_StaticHosting.isWildcardDomain(domainName)) {
2467
2467
  return;
2468
2468
  }
2469
- new import_aws_route532.ARecord(this, `dns-record-${index}`, {
2469
+ new import_aws_route532.ARecord(this, `dns-record-${index}-${domainName}`, {
2470
2470
  zone: props.hostedZone,
2471
2471
  recordName: domainName,
2472
2472
  target: import_aws_route532.RecordTarget.fromAlias(
@@ -7105,9 +7105,9 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
7105
7105
  this.validateConfig(props);
7106
7106
  const hostedZone = this.createHostedZone();
7107
7107
  const certificate = this.createCertificate();
7108
- const apiDomainName = this.createApiDomainNameString(hostedZone);
7109
- this.createRestApiBaseUrlParameter(apiDomainName);
7110
- this.createRestApiDomainNameParameter(apiDomainName);
7108
+ this.apiDomainName = this.createApiDomainNameString(hostedZone);
7109
+ this.createRestApiBaseUrlParameter(this.apiDomainName);
7110
+ this.createRestApiDomainNameParameter(this.apiDomainName);
7111
7111
  const domainName = this.createDomainName(hostedZone, certificate);
7112
7112
  this.rootHttpApi = this.createRootHttpApi(domainName);
7113
7113
  this.createRestApiLambdaAndRoutes(hostedZone, domainName);
@@ -7371,7 +7371,8 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
7371
7371
  * The three Cognito IDs are resolved via SSM lookups against the auth
7372
7372
  * stack from a dedicated sub-scope (`runtime-config`) so they don't
7373
7373
  * collide with the user-pool / user-pool-client constructs already
7374
- * created in {@link createRootHttpApi}.
7374
+ * created in {@link createRootHttpApi}. `apiBaseUrl` is derived from
7375
+ * this stack's own custom domain so callers don't have to hardcode it.
7375
7376
  */
7376
7377
  resolveRuntimeConfigEnvVars() {
7377
7378
  if (this.props.runtimeConfig === void 0) {
@@ -7386,7 +7387,7 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
7386
7387
  OPENHI_RUNTIME_CONFIG_COGNITO_USER_POOL_CLIENT_ID: userPoolClient.userPoolClientId,
7387
7388
  OPENHI_RUNTIME_CONFIG_COGNITO_DOMAIN_URL: cognitoDomainUrl,
7388
7389
  OPENHI_RUNTIME_CONFIG_COGNITO_REDIRECT_URI: this.props.runtimeConfig.cognitoRedirectUri,
7389
- OPENHI_RUNTIME_CONFIG_API_BASE_URL: this.props.runtimeConfig.apiBaseUrl
7390
+ OPENHI_RUNTIME_CONFIG_API_BASE_URL: `https://${this.apiDomainName}`
7390
7391
  };
7391
7392
  }
7392
7393
  };