@openhi/constructs 0.0.1 → 0.0.2

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