@openhi/constructs 0.0.1 → 0.0.3

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.ts CHANGED
@@ -1,15 +1,14 @@
1
- import { App, AppProps, Stage, StageProps, Stack, StackProps, RemovalPolicy } from 'aws-cdk-lib';
1
+ import { RemovalPolicy, App, AppProps, Stage, StageProps, Stack, StackProps } from 'aws-cdk-lib';
2
2
  import { Construct, IConstruct } from 'constructs';
3
- import { HttpApiProps, HttpApi, IHttpApi } from 'aws-cdk-lib/aws-apigatewayv2';
4
- import { GraphqlApiProps } from 'aws-cdk-lib/aws-appsync';
5
- import { EventBusProps } from 'aws-cdk-lib/aws-events';
3
+ import { ICertificate, Certificate, CertificateProps } from 'aws-cdk-lib/aws-certificatemanager';
4
+ import { IHttpApi, HttpApi, HttpApiProps, DomainName } from 'aws-cdk-lib/aws-apigatewayv2';
5
+ import { GraphqlApi, IGraphqlApi, GraphqlApiProps } from 'aws-cdk-lib/aws-appsync';
6
+ import { UserPool, UserPoolProps, UserPoolClient, UserPoolClientProps, UserPoolDomain, UserPoolDomainProps, IUserPool, IUserPoolClient, IUserPoolDomain } from 'aws-cdk-lib/aws-cognito';
7
+ import { Key, KeyProps, IKey } from 'aws-cdk-lib/aws-kms';
8
+ import { Table, TableProps, ITable } from 'aws-cdk-lib/aws-dynamodb';
9
+ import { EventBus, EventBusProps, IEventBus } from 'aws-cdk-lib/aws-events';
10
+ import { HostedZone, HostedZoneProps, IHostedZone, HostedZoneAttributes } from 'aws-cdk-lib/aws-route53';
6
11
  import { StringParameterProps, StringParameter } from 'aws-cdk-lib/aws-ssm';
7
- import { UserPoolProps, IUserPool, IUserPoolClient, IUserPoolDomain } from 'aws-cdk-lib/aws-cognito';
8
- import { IKey } from 'aws-cdk-lib/aws-kms';
9
- import { ICertificate } from 'aws-cdk-lib/aws-certificatemanager';
10
- import { HostedZoneAttributes, IHostedZone } from 'aws-cdk-lib/aws-route53';
11
- import { SetOptional } from 'type-fest';
12
- import { ITable } from 'aws-cdk-lib/aws-dynamodb';
13
12
 
14
13
  /*******************************************************************************
15
14
  *
@@ -296,74 +295,13 @@ declare class OpenHiApp extends App {
296
295
  get secondaryEnvironments(): Array<OpenHiEnvironment>;
297
296
  }
298
297
 
299
- interface CoreProps {
300
- /**
301
- * Pass in options for an event bus, optional.
302
- */
303
- readonly dataEventBusProps?: EventBusProps;
304
- /**
305
- * Pass in options for an event bus, optional.
306
- */
307
- readonly opsEventBusProps?: EventBusProps;
308
- /**
309
- * Optional args for creating HTTP API.
310
- */
311
- readonly httpApiProps?: HttpApiProps;
312
- /**
313
- * Optional args for creating the core GraphQL API.
314
- */
315
- readonly graphqlApiProps?: GraphqlApiProps;
316
- }
317
-
318
298
  /**
319
- * Service type identifiers for OpenHI services.
320
- *
321
- * @remarks
322
- * These constants define the different types of services that can be deployed
323
- * within the OpenHI platform. Each service type represents a distinct domain
324
- * or functional area with its own data model, API endpoints, and business logic.
325
- *
326
- * Service types are used for:
327
- * - Resource naming and tagging
328
- * - Service discovery and routing
329
- * - Deployment context calculations
330
- * - Cross-service communication patterns
299
+ * Known OpenHI service type strings. Each service class defines its own
300
+ * static SERVICE_TYPE (e.g. OpenHiAuthService.SERVICE_TYPE === "auth").
331
301
  *
332
302
  * @public
333
303
  */
334
- declare const OPEN_HI_SERVICE_TYPE: {
335
- /**
336
- * Authentication service.
337
- * *
338
- * Only one instance of the auth service should exist per environment.
339
- */
340
- readonly AUTH: "auth";
341
- /**
342
- * Root shared core services.
343
- *
344
- * Only one instance of the core service should exist per environment.
345
- */
346
- readonly CORE: "core";
347
- /**
348
- * Rest API service.
349
- */
350
- readonly REST_API: "rest-api";
351
- /**
352
- * Global Infrastructure stack (Route53, ACM).
353
- */
354
- readonly GLOBAL: "global";
355
- /**
356
- * Data service (DynamoDB, S3, persistence).
357
- */
358
- readonly DATA: "data";
359
- };
360
- /**
361
- * Type representing valid OpenHI service type values. This is a union of the
362
- * values from {@link OPEN_HI_SERVICE_TYPE}.
363
- *
364
- * @public
365
- */
366
- type OpenHiServiceType = (typeof OPEN_HI_SERVICE_TYPE)[keyof typeof OPEN_HI_SERVICE_TYPE];
304
+ type OpenHiServiceType = "auth" | "rest-api" | "data" | "global" | "graphql-api";
367
305
  /**
368
306
  * Properties for creating an {@link OpenHiService} stack.
369
307
  *
@@ -398,15 +336,12 @@ interface OpenHiServiceProps extends StackProps {
398
336
  * A constant that identifies the service type.
399
337
  */
400
338
  readonly serviceType?: OpenHiServiceType;
401
- /**
402
- * Optional props for the core construct.
403
- */
404
- readonly coreProps?: CoreProps;
405
339
  }
406
340
  /**
407
341
  * Represents an OpenHI service stack within the OpenHI platform.
342
+ * Subclasses must override {@link serviceType} to return their static SERVICE_TYPE.
408
343
  */
409
- declare class OpenHiService extends Stack {
344
+ declare abstract class OpenHiService extends Stack {
410
345
  ohEnv: OpenHiEnvironment;
411
346
  props: OpenHiServiceProps;
412
347
  /**
@@ -455,12 +390,10 @@ declare class OpenHiService extends Stack {
455
390
  */
456
391
  readonly config: OpenHiEnvironmentConfig;
457
392
  /**
458
- * A constant that identifies the service type.
459
- */
460
- readonly serviceType: (typeof OPEN_HI_SERVICE_TYPE)[keyof typeof OPEN_HI_SERVICE_TYPE] | string;
461
- /**
462
- * Core construct containing shared infrastructure.
393
+ * Service type identifier. Override in subclasses to return the class's static SERVICE_TYPE.
394
+ * Used for parameter names, tags, and service discovery.
463
395
  */
396
+ abstract get serviceType(): OpenHiServiceType | string;
464
397
  /**
465
398
  * Creates a new OpenHI service stack.
466
399
  *
@@ -472,15 +405,148 @@ declare class OpenHiService extends Stack {
472
405
  *
473
406
  */
474
407
  constructor(ohEnv: OpenHiEnvironment, id: string, props?: OpenHiServiceProps);
475
- /**
476
- * Creates or returns the core construct for shared infrastructure.
477
- */
478
408
  /**
479
409
  * DNS prefix for this branche's child zone.
480
410
  */
481
411
  get childZonePrefix(): string;
482
412
  }
483
413
 
414
+ declare class RootWildcardCertificate extends Certificate {
415
+ /**
416
+ * Used when storing the Certificate ARN in SSM.
417
+ */
418
+ static readonly SSM_PARAM_NAME = "ROOT_WILDCARD_CERT_ARN";
419
+ /**
420
+ * Using a special name here since this will be shared and used among many
421
+ * stacks and services. Use with OpenHiGlobalService.rootWildcardCertificateFromConstruct.
422
+ */
423
+ static ssmParameterName(): string;
424
+ constructor(scope: Construct, props: CertificateProps);
425
+ }
426
+
427
+ declare class RootHttpApi extends HttpApi {
428
+ /**
429
+ * Used when storing the API ID in SSM.
430
+ */
431
+ static readonly SSM_PARAM_NAME = "ROOT_HTTP_API";
432
+ constructor(scope: Construct, props?: HttpApiProps);
433
+ }
434
+
435
+ interface RootGraphqlApiProps extends GraphqlApiProps {
436
+ }
437
+ declare class RootGraphqlApi extends GraphqlApi {
438
+ /**
439
+ * Used when storing the GraphQl API ID in SSM.
440
+ */
441
+ static readonly SSM_PARAM_NAME = "ROOT_GRAPHQL_API";
442
+ static fromConstruct(scope: Construct): IGraphqlApi;
443
+ constructor(scope: Construct, props?: Omit<RootGraphqlApiProps, "name">);
444
+ }
445
+
446
+ declare class CognitoUserPool extends UserPool {
447
+ /**
448
+ * Used when storing the User Pool ID in SSM.
449
+ */
450
+ static readonly SSM_PARAM_NAME = "COGNITO_USER_POOL";
451
+ constructor(scope: Construct, props?: UserPoolProps);
452
+ }
453
+
454
+ declare class CognitoUserPoolClient extends UserPoolClient {
455
+ /**
456
+ * Used when storing the User Pool Client ID in SSM.
457
+ */
458
+ static readonly SSM_PARAM_NAME = "COGNITO_USER_POOL_CLIENT";
459
+ constructor(scope: Construct, props: UserPoolClientProps);
460
+ }
461
+
462
+ declare class CognitoUserPoolDomain extends UserPoolDomain {
463
+ /**
464
+ * Used when storing the User Pool Domain in SSM.
465
+ */
466
+ static readonly SSM_PARAM_NAME = "COGNITO_USER_POOL_DOMAIN";
467
+ constructor(scope: Construct, props: UserPoolDomainProps);
468
+ }
469
+
470
+ declare class CognitoUserPoolKmsKey extends Key {
471
+ /**
472
+ * Used when storing the KMS Key in SSM.
473
+ */
474
+ static readonly SSM_PARAM_NAME = "COGNITO_USER_POOL_KMS_KEY";
475
+ constructor(scope: Construct, props?: KeyProps);
476
+ }
477
+
478
+ /**
479
+ * DynamoDB table name for the data store. Used for cross-stack reference and
480
+ * deterministic naming per branch. The table backs multiple use cases (e.g.
481
+ * CRM, CMS, ERP, EHR).
482
+ */
483
+ declare function getDynamoDbDataStoreTableName(scope: Construct): string;
484
+ interface DynamoDbDataStoreProps extends Omit<TableProps, "tableName" | "removalPolicy"> {
485
+ /**
486
+ * Optional removal policy override. If not set, uses the service's default
487
+ * removal policy (RETAIN for prod, DESTROY otherwise).
488
+ */
489
+ readonly removalPolicy?: RemovalPolicy;
490
+ }
491
+ /**
492
+ * DynamoDB table implementing the single-table design for app data (e.g. FHIR
493
+ * resources, CRM, CMS, ERP, EHR).
494
+ *
495
+ * @see {@link https://github.com/codedrifters/openhi/blob/main/sites/www-docs/content/architecture/dynamodb-single-table-design.md | DynamoDB Single-Table Design}
496
+ *
497
+ * Primary key: PK (String), SK (String).
498
+ * GSIs: GSI1 (reverse reference), GSI2 (identifier lookup), GSI3 (facility ops), GSI4 (resource type list).
499
+ */
500
+ declare class DynamoDbDataStore extends Table {
501
+ constructor(scope: Construct, id: string, props?: DynamoDbDataStoreProps);
502
+ }
503
+
504
+ declare class DataEventBus extends EventBus {
505
+ /*****************************************************************************
506
+ *
507
+ * Return a name for this EventBus based on the stack environment hash. This
508
+ * name is common across all stacks since it's using the environment hash in
509
+ * it's name.
510
+ *
511
+ ****************************************************************************/
512
+ static getEventBusName(scope: Construct): string;
513
+ constructor(scope: Construct, props?: EventBusProps);
514
+ }
515
+
516
+ declare class OpsEventBus extends EventBus {
517
+ /*****************************************************************************
518
+ *
519
+ * Return a name for this EventBus based on the stack environment hash. This
520
+ * name is common across all stacks since it's using the environment hash in
521
+ * it's name.
522
+ *
523
+ ****************************************************************************/
524
+ static getEventBusName(scope: Construct): string;
525
+ constructor(scope: Construct, props?: EventBusProps);
526
+ }
527
+
528
+ interface ChildHostedZoneProps extends HostedZoneProps {
529
+ /**
530
+ * The root zone we will attach this sub-zone to.
531
+ */
532
+ readonly parentHostedZone: IHostedZone;
533
+ }
534
+ declare class ChildHostedZone extends HostedZone {
535
+ /**
536
+ * Used when storing the child zone ID in SSM. Use {@link OpenHiGlobalService.childHostedZoneFromConstruct} to look up.
537
+ */
538
+ static readonly SSM_PARAM_NAME = "CHILDHOSTEDZONE";
539
+ constructor(scope: Construct, id: string, props: ChildHostedZoneProps);
540
+ }
541
+
542
+ /**
543
+ * Placeholder for root hosted zone. Use {@link OpenHiGlobalService.rootHostedZoneFromConstruct}
544
+ * to obtain an IHostedZone from attributes (e.g. from config). The root zone is always
545
+ * created manually and imported via config.
546
+ */
547
+ declare class RootHostedZone extends Construct {
548
+ }
549
+
484
550
  /*******************************************************************************
485
551
  *
486
552
  * DiscoverableStringParameterProps: props for creating or looking up SSM
@@ -526,6 +592,12 @@ type BuildParameterNameProps = Pick<DiscoverableStringParameterProps, "ssmParamN
526
592
  * the parameter with the name constant.
527
593
  */
528
594
  declare class DiscoverableStringParameter extends StringParameter {
595
+ /**
596
+ * Version of the parameter name format / discoverability schema.
597
+ * Bump when buildParameterName or tagging semantics change.
598
+ * Also used to drive replacement of parameters during CloudFormation deploys.
599
+ */
600
+ static readonly version = "v1";
529
601
  /**
530
602
  * Build a param name based on predictable attributes found in services and
531
603
  * constructs. Used for storage and retrieval of SSM values across services.
@@ -539,175 +611,134 @@ declare class DiscoverableStringParameter extends StringParameter {
539
611
  constructor(scope: Construct, id: string, props: DiscoverableStringParameterProps);
540
612
  }
541
613
 
542
- interface OpenHiCoreServiceProps extends OpenHiServiceProps {
543
- }
544
- declare class OpenHiCoreService extends OpenHiService {
545
- /*****************************************************************************
546
- *
547
- * PROPS
548
- *
549
- * Final props calculated from inputs combined with default values.
550
- *
551
- ****************************************************************************/
552
- readonly props: OpenHiCoreServiceProps;
553
- constructor(ohEnv: OpenHiEnvironment, props?: OpenHiCoreServiceProps);
554
- }
555
-
556
- interface AuthProps {
614
+ interface OpenHiAuthServiceProps extends OpenHiServiceProps {
557
615
  /**
558
- * Optional props for creating the user pool.
616
+ * Optional props for the Cognito User Pool.
559
617
  */
560
618
  readonly userPoolProps?: UserPoolProps;
561
619
  }
562
620
  /**
563
- * Auth construct that manages Cognito authentication resources.
621
+ * OpenHI Auth Service stack.
564
622
  *
565
623
  * @remarks
566
- * The Auth construct provides authentication infrastructure including:
624
+ * The Auth service manages authentication infrastructure including:
567
625
  * - Cognito User Pool for user management and authentication
568
626
  * - User Pool Client for application integration
569
627
  * - User Pool Domain for hosting the Cognito hosted UI
570
628
  * - KMS Key for Cognito User Pool encryption
571
629
  *
572
- * When created in the Auth service (`serviceType === OPEN_HI_SERVICE_TYPE.AUTH`),
573
- * it creates concrete resources. Otherwise, it imports existing resources
574
- * from SSM Parameter Store.
630
+ * Resources are created in protected methods; subclasses may override to customize.
631
+ * Other stacks obtain auth by calling **OpenHiAuthService.userPoolFromConstruct(scope)**,
632
+ * **OpenHiAuthService.userPoolClientFromConstruct(scope)**,
633
+ * **OpenHiAuthService.userPoolDomainFromConstruct(scope)**,
634
+ * and **OpenHiAuthService.userPoolKmsKeyFromConstruct(scope)** for each resource needed.
575
635
  *
576
- * Use {@link Auth.fromConstruct} to obtain an Auth instance (with resources
577
- * imported from AUTH SSM parameters) when not in the Auth service, e.g. from
578
- * the Core construct.
636
+ * Only one instance of the auth service should exist per environment.
579
637
  *
580
638
  * @public
581
639
  */
582
- declare class Auth extends Construct {
640
+ declare class OpenHiAuthService extends OpenHiService {
641
+ props: OpenHiAuthServiceProps;
642
+ static readonly SERVICE_TYPE = "auth";
583
643
  /**
584
- * Returns an Auth instance that uses resources imported from AUTH SSM
585
- * parameters. Use this when creating Core or other stacks that consume
586
- * auth resources; the Auth stack must be deployed first.
587
- *
588
- * @param scope - Construct scope (e.g. Core); must be in a stack that has
589
- * access to the same account/region as the deployed Auth stack.
644
+ * Returns an IUserPool by looking up the Auth stack's User Pool ID from SSM.
590
645
  */
591
- static fromConstruct(scope: Construct): Auth;
646
+ static userPoolFromConstruct(scope: Construct): IUserPool;
592
647
  /**
593
- * Is this construct being created in the auth service or elsewhere?
648
+ * Returns an IUserPoolClient by looking up the Auth stack's User Pool Client ID from SSM.
594
649
  */
595
- readonly isAuthService: boolean;
650
+ static userPoolClientFromConstruct(scope: Construct): IUserPoolClient;
596
651
  /**
597
- * KMS Key used to encrypt the Cognito User Pool. We need a custom key so that
598
- * we can decrypt tokens when sending emails using something other than SES.
652
+ * Returns an IUserPoolDomain by looking up the Auth stack's User Pool Domain from SSM.
599
653
  */
600
- readonly userPoolKmsKey: IKey;
654
+ static userPoolDomainFromConstruct(scope: Construct): IUserPoolDomain;
601
655
  /**
602
- * Cognito User Pool for user management and authentication.
656
+ * Returns an IKey (KMS) by looking up the Auth stack's User Pool KMS Key ARN from SSM.
603
657
  */
658
+ static userPoolKmsKeyFromConstruct(scope: Construct): IKey;
659
+ get serviceType(): string;
660
+ readonly userPoolKmsKey: IKey;
604
661
  readonly userPool: IUserPool;
605
- /**
606
- * Cognito User Pool Client for application integration with the User Pool.
607
- */
608
662
  readonly userPoolClient: IUserPoolClient;
663
+ readonly userPoolDomain: IUserPoolDomain;
664
+ constructor(ohEnv: OpenHiEnvironment, props?: OpenHiAuthServiceProps);
609
665
  /**
610
- * Cognito User Pool Domain for hosting the Cognito hosted UI.
666
+ * Creates the KMS key for the Cognito User Pool and exports its ARN to SSM.
667
+ * Look up via {@link OpenHiAuthService.userPoolKmsKeyFromConstruct}.
668
+ * Override to customize.
611
669
  */
612
- readonly userPoolDomain: IUserPoolDomain;
613
- constructor(scope: Construct, props?: AuthProps);
614
- /*****************************************************************************
615
- *
616
- * Auth Support
617
- *
618
- ****************************************************************************/
619
670
  protected createUserPoolKmsKey(): IKey;
620
- protected createUserPool(props?: UserPoolProps): IUserPool;
621
- protected createUserPoolClient(props: {
622
- userPool: IUserPool;
623
- }): IUserPoolClient;
624
- protected createUserPoolDomain(props: {
625
- userPool: IUserPool;
626
- }): IUserPoolDomain;
627
- }
628
-
629
- interface OpenHiAuthServiceProps extends OpenHiServiceProps {
630
671
  /**
631
- * Optional props for the auth construct.
672
+ * Creates the Cognito User Pool and exports its ID to SSM.
673
+ * Look up via {@link OpenHiAuthService.userPoolFromConstruct}.
674
+ * Override to customize.
632
675
  */
633
- readonly authProps?: AuthProps;
634
- }
635
- /**
636
- * OpenHI Auth Service stack.
637
- *
638
- * @remarks
639
- * The Auth service manages authentication infrastructure including:
640
- * - Cognito User Pool for user management and authentication
641
- * - User Pool Client for application integration
642
- * - User Pool Domain for hosting the Cognito hosted UI
643
- * - KMS Key for Cognito User Pool encryption
644
- *
645
- * Only one instance of the auth service should exist per environment.
646
- *
647
- * @public
648
- */
649
- declare class OpenHiAuthService extends OpenHiService {
650
- props: OpenHiAuthServiceProps;
676
+ protected createUserPool(): IUserPool;
651
677
  /**
652
- * Auth construct containing authentication resources.
678
+ * Creates the User Pool Client and exports its ID to SSM (AUTH service type).
679
+ * Look up via {@link OpenHiAuthService.userPoolClientFromConstruct}.
680
+ * Override to customize.
653
681
  */
654
- readonly auth: Auth;
655
- constructor(ohEnv: OpenHiEnvironment, props?: OpenHiAuthServiceProps);
682
+ protected createUserPoolClient(): IUserPoolClient;
683
+ /**
684
+ * Creates the User Pool Domain (Cognito hosted UI) and exports domain name to SSM.
685
+ * Look up via {@link OpenHiAuthService.userPoolDomainFromConstruct}.
686
+ * Override to customize.
687
+ */
688
+ protected createUserPoolDomain(): IUserPoolDomain;
656
689
  }
657
690
 
658
- interface GlobalProps {
691
+ interface OpenHiGlobalServiceProps extends OpenHiServiceProps {
692
+ }
693
+ /**
694
+ * Global Infrastructure stack: owns global DNS and certificates.
695
+ * Resources (root zone, optional child zone, wildcard cert) are created
696
+ * in protected methods; subclasses may override to customize.
697
+ */
698
+ declare class OpenHiGlobalService extends OpenHiService {
699
+ static readonly SERVICE_TYPE = "global";
659
700
  /**
660
- * Root zone configuration attributes. Zone name is required, hosted zone ID
661
- * is optional.
701
+ * Returns an IHostedZone from the given attributes (no SSM). Use when the zone is imported from config.
662
702
  */
663
- readonly rootHostedZoneAttributes: HostedZoneAttributes;
703
+ static rootHostedZoneFromConstruct(scope: Construct, props: HostedZoneAttributes): IHostedZone;
664
704
  /**
665
- * Child zone configuration attributes. Zone name is required, hosted zone ID
666
- * is optional.
705
+ * Returns an ICertificate by looking up the Global stack's wildcard cert ARN from SSM.
667
706
  */
668
- readonly childHostedZoneAttributes?: SetOptional<HostedZoneAttributes, "hostedZoneId">;
669
- }
670
- /**
671
- * Global construct: owns global infrastructure (e.g. DNS and certificate resources).
672
-
673
- */
674
- declare class Global extends Construct {
675
- props: GlobalProps;
707
+ static rootWildcardCertificateFromConstruct(scope: Construct): ICertificate;
676
708
  /**
677
- * Root hosted zone when config provides zoneName.
709
+ * Returns an IHostedZone by looking up the child hosted zone ID from SSM. Defaults to GLOBAL service type.
678
710
  */
711
+ static childHostedZoneFromConstruct(scope: Construct, props: {
712
+ zoneName: string;
713
+ serviceType?: OpenHiServiceType;
714
+ }): IHostedZone;
715
+ get serviceType(): string;
679
716
  readonly rootHostedZone: IHostedZone;
717
+ readonly childHostedZone?: IHostedZone;
718
+ readonly rootWildcardCertificate: ICertificate;
719
+ constructor(ohEnv: OpenHiEnvironment, props?: OpenHiGlobalServiceProps);
680
720
  /**
681
- * Child hosted zone when root zone exists.
721
+ * Validates that config required for the Global stack is present.
682
722
  */
683
- readonly childHostedZone?: IHostedZone;
723
+ protected validateConfig(props: OpenHiGlobalServiceProps): void;
684
724
  /**
685
- * Root wildcard certificate.
725
+ * Creates the root hosted zone (imported via attributes from config).
726
+ * Override to customize or create the zone.
686
727
  */
687
- readonly rootWildcardCertificate: ICertificate;
688
- constructor(scope: Construct, id: string, props: GlobalProps);
689
- }
690
-
691
- interface OpenHiGlobalServiceProps extends OpenHiServiceProps {
692
- }
693
- /**
694
- * Global Infrastructure stack: owns global DNS and certificates
695
- */
696
- declare class OpenHiGlobalService extends OpenHiService {
728
+ protected createRootHostedZone(): IHostedZone;
697
729
  /**
698
- * Global construct.
730
+ * Creates the optional child hosted zone (e.g. branch subdomain).
731
+ * Override to create a child zone when config provides childHostedZoneAttributes.
732
+ * If you create a ChildHostedZone, also create a DiscoverableStringParameter
733
+ * with ChildHostedZone.SSM_PARAM_NAME and the zone's hostedZoneId.
699
734
  */
700
- readonly global: Global;
701
- constructor(ohEnv: OpenHiEnvironment, props?: OpenHiGlobalServiceProps);
702
- }
703
-
704
- declare class CoreHttpApi extends HttpApi {
735
+ protected createChildHostedZone(): IHostedZone | undefined;
705
736
  /**
706
- * Used when storing the API ID in SSM.
737
+ * Creates the root wildcard certificate. On main branch, creates a new cert
738
+ * with DNS validation; otherwise imports from SSM.
739
+ * Override to customize certificate creation.
707
740
  */
708
- static readonly SSM_PARAM_NAME = "CORE_HTTP_API";
709
- static fromConstruct(scope: Construct): IHttpApi;
710
- constructor(scope: Construct, props?: HttpApiProps);
741
+ protected createRootWildcardCertificate(): ICertificate;
711
742
  }
712
743
 
713
744
  interface OpenHiRestApiServiceProps extends OpenHiServiceProps {
@@ -719,27 +750,120 @@ interface OpenHiRestApiServiceProps extends OpenHiServiceProps {
719
750
  declare const REST_API_BASE_URL_SSM_NAME = "REST_API_BASE_URL";
720
751
  /**
721
752
  * REST API service stack: HTTP API, custom domain, and Lambda; exports base URL via SSM.
753
+ * Resources are created in protected methods; subclasses may override to customize.
722
754
  */
723
755
  declare class OpenHiRestApiService extends OpenHiService {
724
- readonly coreHttpApi: CoreHttpApi;
756
+ static readonly SERVICE_TYPE = "rest-api";
757
+ /**
758
+ * Returns an IHttpApi by looking up the REST API stack's HTTP API ID from SSM.
759
+ */
760
+ static rootHttpApiFromConstruct(scope: Construct): IHttpApi;
761
+ /**
762
+ * Returns the REST API base URL (e.g. https://api.example.com) by looking it up from SSM.
763
+ * Use in other stacks for E2E, scripts, or config.
764
+ */
765
+ static restApiBaseUrlFromConstruct(scope: Construct): string;
766
+ get serviceType(): string;
767
+ readonly rootHttpApi: RootHttpApi;
725
768
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiRestApiServiceProps);
769
+ /**
770
+ * Validates that config required for the REST API stack is present.
771
+ */
772
+ protected validateConfig(props: OpenHiRestApiServiceProps): void;
773
+ /**
774
+ * Creates the hosted zone reference (imported from config).
775
+ * Override to customize.
776
+ */
777
+ protected createHostedZone(): IHostedZone;
778
+ /**
779
+ * Creates the wildcard certificate (imported from Global stack via SSM).
780
+ * Override to customize.
781
+ */
782
+ protected createCertificate(): ICertificate;
783
+ /**
784
+ * Returns the API domain name string (e.g. api.example.com or api-{prefix}.example.com).
785
+ * Override to customize.
786
+ */
787
+ protected createApiDomainNameString(hostedZone: IHostedZone): string;
788
+ /**
789
+ * Creates the SSM parameter for the REST API base URL.
790
+ * Look up via {@link OpenHiRestApiService.restApiBaseUrlFromConstruct}.
791
+ * Override to customize.
792
+ */
793
+ protected createRestApiBaseUrlParameter(apiDomainName: string): void;
794
+ /**
795
+ * Creates the API Gateway custom domain name resource.
796
+ * Override to customize.
797
+ */
798
+ protected createDomainName(_hostedZone: IHostedZone, certificate: ICertificate): DomainName;
799
+ /**
800
+ * Creates the Lambda integration, HTTP routes, and API DNS record.
801
+ * Override to customize. Uses {@link rootHttpApi} set by the constructor.
802
+ */
803
+ protected createRestApiLambdaAndRoutes(hostedZone: IHostedZone, domainName: DomainName): void;
804
+ /**
805
+ * Creates the Root HTTP API with default domain mapping and exports API ID to SSM.
806
+ * Look up via {@link OpenHiRestApiService.rootHttpApiFromConstruct}.
807
+ * Override to customize.
808
+ */
809
+ protected createRootHttpApi(domainName: DomainName): RootHttpApi;
726
810
  }
727
811
 
728
812
  interface OpenHiDataServiceProps extends OpenHiServiceProps {
729
813
  }
730
814
  /**
731
- * Data storage service stack: centralizes DynamoDB, S3, and other persistence
732
- * resources for OpenHI. Creates the single-table data store (CRM, CMS, ERP,
733
- * EHR); add buckets or other resources as needed.
815
+ * Data storage service stack: centralizes DynamoDB, S3, EventBridge event buses,
816
+ * and other persistence resources for OpenHI. Creates the single-table data store
817
+ * (CRM, CMS, ERP, EHR) and the data/ops event buses in protected methods;
818
+ * subclasses may override to customize.
734
819
  */
735
820
  declare class OpenHiDataService extends OpenHiService {
821
+ static readonly SERVICE_TYPE = "data";
736
822
  /**
737
- * The single-table DynamoDB data store. Use {@link DynamoDbDataStore.fromConstruct}
823
+ * Returns the data event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
824
+ */
825
+ static dataEventBusFromConstruct(scope: Construct): IEventBus;
826
+ /**
827
+ * Returns the ops event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
828
+ */
829
+ static opsEventBusFromConstruct(scope: Construct): IEventBus;
830
+ /**
831
+ * Returns the data store table by name. Use from other stacks (e.g. REST API Lambda) to obtain an ITable reference.
832
+ */
833
+ static dynamoDbDataStoreFromConstruct(scope: Construct, id?: string): ITable;
834
+ get serviceType(): string;
835
+ /**
836
+ * Event bus for data-related events (ingestion, transformation, storage).
837
+ * Other stacks obtain it via {@link OpenHiDataService.dataEventBusFromConstruct}.
838
+ */
839
+ readonly dataEventBus: IEventBus;
840
+ /**
841
+ * Event bus for operational events (monitoring, alerting, system health).
842
+ * Other stacks obtain it via {@link OpenHiDataService.opsEventBusFromConstruct}.
843
+ */
844
+ readonly opsEventBus: IEventBus;
845
+ /**
846
+ * The single-table DynamoDB data store. Use {@link OpenHiDataService.dynamoDbDataStoreFromConstruct}
738
847
  * from other stacks to obtain an ITable reference by name.
739
848
  */
740
849
  readonly dataStore: ITable;
741
850
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiDataServiceProps);
851
+ /**
852
+ * Creates the data event bus.
853
+ * Override to customize.
854
+ */
855
+ protected createDataEventBus(): IEventBus;
856
+ /**
857
+ * Creates the ops event bus.
858
+ * Override to customize.
859
+ */
860
+ protected createOpsEventBus(): IEventBus;
861
+ /**
862
+ * Creates the single-table DynamoDB data store.
863
+ * Override to customize.
864
+ */
865
+ protected createDataStore(): ITable;
742
866
  }
743
867
 
744
- export { DiscoverableStringParameter, OPEN_HI_SERVICE_TYPE, OpenHiApp, OpenHiAuthService, OpenHiCoreService, OpenHiDataService, OpenHiEnvironment, OpenHiGlobalService, OpenHiRestApiService, OpenHiService, OpenHiStage, REST_API_BASE_URL_SSM_NAME };
745
- export type { BuildParameterNameProps, DiscoverableStringParameterProps, OpenHiAppProps, OpenHiAuthServiceProps, OpenHiCoreServiceProps, OpenHiDataServiceProps, OpenHiEnvironmentProps, OpenHiGlobalServiceProps, OpenHiRestApiServiceProps, OpenHiServiceProps, OpenHiServiceType, OpenHiStageProps };
868
+ export { ChildHostedZone, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, DataEventBus, DiscoverableStringParameter, DynamoDbDataStore, OpenHiApp, OpenHiAuthService, OpenHiDataService, OpenHiEnvironment, OpenHiGlobalService, OpenHiRestApiService, OpenHiService, OpenHiStage, OpsEventBus, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, RootHostedZone, RootHttpApi, RootWildcardCertificate, getDynamoDbDataStoreTableName };
869
+ export type { BuildParameterNameProps, ChildHostedZoneProps, DiscoverableStringParameterProps, DynamoDbDataStoreProps, OpenHiAppProps, OpenHiAuthServiceProps, OpenHiDataServiceProps, OpenHiEnvironmentProps, OpenHiGlobalServiceProps, OpenHiRestApiServiceProps, OpenHiServiceProps, OpenHiServiceType, OpenHiStageProps, RootGraphqlApiProps };