@openhi/constructs 0.0.32 → 0.0.34

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
@@ -2,7 +2,7 @@ import { OPEN_HI_STAGE, OPEN_HI_DEPLOYMENT_TARGET_ROLE, OpenHiEnvironmentConfig,
2
2
  import { Stage, StageProps, App, AppProps, Stack, StackProps, RemovalPolicy } from 'aws-cdk-lib';
3
3
  import { IConstruct, Construct } from 'constructs';
4
4
  import { Certificate, CertificateProps, ICertificate } from 'aws-cdk-lib/aws-certificatemanager';
5
- import { HttpApi, HttpApiProps, IHttpApi, CorsHttpMethod, DomainName } from 'aws-cdk-lib/aws-apigatewayv2';
5
+ import { HttpApiProps, HttpApi, IHttpApi, DomainName } from 'aws-cdk-lib/aws-apigatewayv2';
6
6
  import { GraphqlApi, IGraphqlApi, GraphqlApiProps } from 'aws-cdk-lib/aws-appsync';
7
7
  import { UserPool, UserPoolProps, UserPoolClient, UserPoolClientProps, UserPoolDomain, UserPoolDomainProps, IUserPool, IUserPoolClient, IUserPoolDomain } from 'aws-cdk-lib/aws-cognito';
8
8
  import { Key, KeyProps, IKey } from 'aws-cdk-lib/aws-kms';
@@ -14,7 +14,6 @@ import { StringParameterProps, StringParameter } from 'aws-cdk-lib/aws-ssm';
14
14
  import { Distribution, DistributionProps } from 'aws-cdk-lib/aws-cloudfront';
15
15
  import { IBucket, BucketProps } from 'aws-cdk-lib/aws-s3';
16
16
  import { IFunction } from 'aws-cdk-lib/aws-lambda';
17
- import { Duration } from 'aws-cdk-lib/core';
18
17
 
19
18
  /**
20
19
  * Properties for creating an OpenHiStage instance.
@@ -358,12 +357,14 @@ declare class RootWildcardCertificate extends Certificate {
358
357
  /**
359
358
  * @see sites/www-docs/content/packages/@openhi/constructs/components/api-gateway/root-http-api.md
360
359
  */
360
+ interface RootHttpApiProps extends HttpApiProps {
361
+ }
361
362
  declare class RootHttpApi extends HttpApi {
362
363
  /**
363
364
  * Used when storing the API ID in SSM.
364
365
  */
365
366
  static readonly SSM_PARAM_NAME = "ROOT_HTTP_API";
366
- constructor(scope: Construct, props?: HttpApiProps);
367
+ constructor(scope: Construct, props?: RootHttpApiProps);
367
368
  }
368
369
 
369
370
  /**
@@ -437,8 +438,7 @@ declare class PreTokenGenerationLambda extends Construct {
437
438
  */
438
439
  /**
439
440
  * DynamoDB table name for the data store. Used for cross-stack reference and
440
- * deterministic naming per branch. The table backs multiple use cases (e.g.
441
- * CRM, CMS, ERP, EHR).
441
+ * deterministic naming per branch. The table backs the app data store.
442
442
  */
443
443
  declare function getDynamoDbDataStoreTableName(scope: Construct): string;
444
444
  interface DynamoDbDataStoreProps extends Omit<TableProps, "tableName" | "removalPolicy"> {
@@ -450,7 +450,7 @@ interface DynamoDbDataStoreProps extends Omit<TableProps, "tableName" | "removal
450
450
  }
451
451
  /**
452
452
  * DynamoDB table implementing the single-table design for app data (e.g. FHIR
453
- * resources, CRM, CMS, ERP, EHR).
453
+ * resources and configuration).
454
454
  *
455
455
  * @see {@link https://github.com/codedrifters/openhi/blob/main/sites/www-docs/content/architecture/dynamodb-single-table-design.md | DynamoDB Single-Table Design}
456
456
  *
@@ -778,29 +778,12 @@ declare class OpenHiGlobalService extends OpenHiService {
778
778
  /**
779
779
  * @see sites/www-docs/content/packages/@openhi/constructs/services/open-hi-rest-api-service.md
780
780
  */
781
- /**
782
- * CORS configuration for the REST API HTTP API (API Gateway v2).
783
- * When origins are set, API Gateway sends CORS headers; backend CORS headers are ignored for browser requests.
784
- */
785
- interface RestApiCorsOptions {
786
- /** Allowed origins (e.g. https://app.example.com, http://localhost:3000). Required when enabling CORS. */
787
- readonly allowOrigins: string[];
788
- /** Allowed HTTP methods. Defaults to GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS. */
789
- readonly allowMethods?: CorsHttpMethod[];
790
- /** Allowed request headers. Defaults to Content-Type, Authorization. */
791
- readonly allowHeaders?: string[];
792
- /** Whether to allow credentials (cookies, auth headers). Default true. */
793
- readonly allowCredentials?: boolean;
794
- /** How long preflight results can be cached. Default 1 day. */
795
- readonly maxAge?: Duration;
796
- }
797
781
  interface OpenHiRestApiServiceProps extends OpenHiServiceProps {
798
782
  /**
799
- * Optional CORS configuration for the root HTTP API.
800
- * When set, API Gateway will send CORS headers for the given origins.
801
- * When omitted, no CORS is configured at the gateway (Express CORS in the Lambda still applies for direct or non-browser use).
783
+ * Optional props passed through to the RootHttpApi (API Gateway HTTP API) construct.
784
+ * Use corsPreflight (CDK CorsPreflightOptions) for CORS; other HttpApiProps (e.g. description, disableExecuteApiEndpoint) apply as well.
802
785
  */
803
- readonly cors?: RestApiCorsOptions;
786
+ readonly rootHttpApiProps?: RootHttpApiProps;
804
787
  }
805
788
  /**
806
789
  * SSM parameter name suffix for the REST API base URL.
@@ -823,7 +806,7 @@ declare class OpenHiRestApiService extends OpenHiService {
823
806
  */
824
807
  static restApiBaseUrlFromConstruct(scope: Construct): string;
825
808
  get serviceType(): string;
826
- /** Override so this.props is typed with this service's options (e.g. cors). */
809
+ /** Override so this.props is typed with this service's options (e.g. rootHttpApiProps). */
827
810
  props: OpenHiRestApiServiceProps;
828
811
  readonly rootHttpApi: RootHttpApi;
829
812
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiRestApiServiceProps);
@@ -878,7 +861,7 @@ interface OpenHiDataServiceProps extends OpenHiServiceProps {
878
861
  /**
879
862
  * Data storage service stack: centralizes DynamoDB, S3, EventBridge event buses,
880
863
  * and other persistence resources for OpenHI. Creates the single-table data store
881
- * (CRM, CMS, ERP, EHR) and the data/ops event buses in protected methods;
864
+ * and the data/ops event buses in protected methods;
882
865
  * subclasses may override to customize.
883
866
  */
884
867
  declare class OpenHiDataService extends OpenHiService {
@@ -953,4 +936,4 @@ declare class OpenHiGraphqlService extends OpenHiService {
953
936
  protected createRootGraphqlApi(): RootGraphqlApi;
954
937
  }
955
938
 
956
- 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, OpenHiGraphqlService, type OpenHiGraphqlServiceProps, OpenHiRestApiService, type OpenHiRestApiServiceProps, OpenHiService, type OpenHiServiceProps, type OpenHiServiceType, OpenHiStage, type OpenHiStageProps, OpsEventBus, PreTokenGenerationLambda, REST_API_BASE_URL_SSM_NAME, type RestApiCorsOptions, RootGraphqlApi, type RootGraphqlApiProps, RootHostedZone, RootHttpApi, RootWildcardCertificate, STATIC_HOSTING_SERVICE_TYPE, StaticHosting, type StaticHostingProps, getDynamoDbDataStoreTableName };
939
+ 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, OpenHiGraphqlService, type OpenHiGraphqlServiceProps, OpenHiRestApiService, type OpenHiRestApiServiceProps, OpenHiService, type OpenHiServiceProps, type OpenHiServiceType, OpenHiStage, type OpenHiStageProps, OpsEventBus, PreTokenGenerationLambda, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, type RootGraphqlApiProps, RootHostedZone, RootHttpApi, type RootHttpApiProps, RootWildcardCertificate, STATIC_HOSTING_SERVICE_TYPE, StaticHosting, type StaticHostingProps, getDynamoDbDataStoreTableName };
package/lib/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RemovalPolicy, App, AppProps, Stage, StageProps, Stack, StackProps } from 'aws-cdk-lib';
2
2
  import { Construct, IConstruct } from 'constructs';
3
3
  import { ICertificate, Certificate, CertificateProps } from 'aws-cdk-lib/aws-certificatemanager';
4
- import { IHttpApi, CorsHttpMethod, HttpApi, HttpApiProps, DomainName } from 'aws-cdk-lib/aws-apigatewayv2';
4
+ import { IHttpApi, HttpApiProps, HttpApi, DomainName } from 'aws-cdk-lib/aws-apigatewayv2';
5
5
  import { IGraphqlApi, GraphqlApi, GraphqlApiProps } from 'aws-cdk-lib/aws-appsync';
6
6
  import { UserPool, UserPoolProps, UserPoolClient, UserPoolClientProps, UserPoolDomain, UserPoolDomainProps, IUserPool, IUserPoolClient, IUserPoolDomain } from 'aws-cdk-lib/aws-cognito';
7
7
  import { Key, KeyProps, IKey } from 'aws-cdk-lib/aws-kms';
@@ -13,7 +13,6 @@ import { StringParameterProps, StringParameter } from 'aws-cdk-lib/aws-ssm';
13
13
  import { Distribution, DistributionProps } from 'aws-cdk-lib/aws-cloudfront';
14
14
  import { IBucket, BucketProps } from 'aws-cdk-lib/aws-s3';
15
15
  import { IFunction } from 'aws-cdk-lib/aws-lambda';
16
- import { Duration } from 'aws-cdk-lib/core';
17
16
 
18
17
  /*******************************************************************************
19
18
  *
@@ -438,12 +437,14 @@ declare class RootWildcardCertificate extends Certificate {
438
437
  /**
439
438
  * @see sites/www-docs/content/packages/@openhi/constructs/components/api-gateway/root-http-api.md
440
439
  */
440
+ interface RootHttpApiProps extends HttpApiProps {
441
+ }
441
442
  declare class RootHttpApi extends HttpApi {
442
443
  /**
443
444
  * Used when storing the API ID in SSM.
444
445
  */
445
446
  static readonly SSM_PARAM_NAME = "ROOT_HTTP_API";
446
- constructor(scope: Construct, props?: HttpApiProps);
447
+ constructor(scope: Construct, props?: RootHttpApiProps);
447
448
  }
448
449
 
449
450
  /**
@@ -517,8 +518,7 @@ declare class PreTokenGenerationLambda extends Construct {
517
518
  */
518
519
  /**
519
520
  * DynamoDB table name for the data store. Used for cross-stack reference and
520
- * deterministic naming per branch. The table backs multiple use cases (e.g.
521
- * CRM, CMS, ERP, EHR).
521
+ * deterministic naming per branch. The table backs the app data store.
522
522
  */
523
523
  declare function getDynamoDbDataStoreTableName(scope: Construct): string;
524
524
  interface DynamoDbDataStoreProps extends Omit<TableProps, "tableName" | "removalPolicy"> {
@@ -530,7 +530,7 @@ interface DynamoDbDataStoreProps extends Omit<TableProps, "tableName" | "removal
530
530
  }
531
531
  /**
532
532
  * DynamoDB table implementing the single-table design for app data (e.g. FHIR
533
- * resources, CRM, CMS, ERP, EHR).
533
+ * resources and configuration).
534
534
  *
535
535
  * @see {@link https://github.com/codedrifters/openhi/blob/main/sites/www-docs/content/architecture/dynamodb-single-table-design.md | DynamoDB Single-Table Design}
536
536
  *
@@ -858,29 +858,12 @@ declare class OpenHiGlobalService extends OpenHiService {
858
858
  /**
859
859
  * @see sites/www-docs/content/packages/@openhi/constructs/services/open-hi-rest-api-service.md
860
860
  */
861
- /**
862
- * CORS configuration for the REST API HTTP API (API Gateway v2).
863
- * When origins are set, API Gateway sends CORS headers; backend CORS headers are ignored for browser requests.
864
- */
865
- interface RestApiCorsOptions {
866
- /** Allowed origins (e.g. https://app.example.com, http://localhost:3000). Required when enabling CORS. */
867
- readonly allowOrigins: string[];
868
- /** Allowed HTTP methods. Defaults to GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS. */
869
- readonly allowMethods?: CorsHttpMethod[];
870
- /** Allowed request headers. Defaults to Content-Type, Authorization. */
871
- readonly allowHeaders?: string[];
872
- /** Whether to allow credentials (cookies, auth headers). Default true. */
873
- readonly allowCredentials?: boolean;
874
- /** How long preflight results can be cached. Default 1 day. */
875
- readonly maxAge?: Duration;
876
- }
877
861
  interface OpenHiRestApiServiceProps extends OpenHiServiceProps {
878
862
  /**
879
- * Optional CORS configuration for the root HTTP API.
880
- * When set, API Gateway will send CORS headers for the given origins.
881
- * When omitted, no CORS is configured at the gateway (Express CORS in the Lambda still applies for direct or non-browser use).
863
+ * Optional props passed through to the RootHttpApi (API Gateway HTTP API) construct.
864
+ * Use corsPreflight (CDK CorsPreflightOptions) for CORS; other HttpApiProps (e.g. description, disableExecuteApiEndpoint) apply as well.
882
865
  */
883
- readonly cors?: RestApiCorsOptions;
866
+ readonly rootHttpApiProps?: RootHttpApiProps;
884
867
  }
885
868
  /**
886
869
  * SSM parameter name suffix for the REST API base URL.
@@ -903,7 +886,7 @@ declare class OpenHiRestApiService extends OpenHiService {
903
886
  */
904
887
  static restApiBaseUrlFromConstruct(scope: Construct): string;
905
888
  get serviceType(): string;
906
- /** Override so this.props is typed with this service's options (e.g. cors). */
889
+ /** Override so this.props is typed with this service's options (e.g. rootHttpApiProps). */
907
890
  props: OpenHiRestApiServiceProps;
908
891
  readonly rootHttpApi: RootHttpApi;
909
892
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiRestApiServiceProps);
@@ -958,7 +941,7 @@ interface OpenHiDataServiceProps extends OpenHiServiceProps {
958
941
  /**
959
942
  * Data storage service stack: centralizes DynamoDB, S3, EventBridge event buses,
960
943
  * and other persistence resources for OpenHI. Creates the single-table data store
961
- * (CRM, CMS, ERP, EHR) and the data/ops event buses in protected methods;
944
+ * and the data/ops event buses in protected methods;
962
945
  * subclasses may override to customize.
963
946
  */
964
947
  declare class OpenHiDataService extends OpenHiService {
@@ -1034,4 +1017,4 @@ declare class OpenHiGraphqlService extends OpenHiService {
1034
1017
  }
1035
1018
 
1036
1019
  export { ChildHostedZone, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, DataEventBus, DiscoverableStringParameter, DynamoDbDataStore, OpenHiApp, OpenHiAuthService, OpenHiDataService, OpenHiEnvironment, OpenHiGlobalService, OpenHiGraphqlService, OpenHiRestApiService, OpenHiService, OpenHiStage, OpsEventBus, PreTokenGenerationLambda, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, RootHostedZone, RootHttpApi, RootWildcardCertificate, STATIC_HOSTING_SERVICE_TYPE, StaticHosting, getDynamoDbDataStoreTableName };
1037
- export type { BuildParameterNameProps, ChildHostedZoneProps, DiscoverableStringParameterProps, DynamoDbDataStoreProps, OpenHiAppProps, OpenHiAuthServiceProps, OpenHiDataServiceProps, OpenHiEnvironmentProps, OpenHiGlobalServiceProps, OpenHiGraphqlServiceProps, OpenHiRestApiServiceProps, OpenHiServiceProps, OpenHiServiceType, OpenHiStageProps, RestApiCorsOptions, RootGraphqlApiProps, StaticHostingProps };
1020
+ export type { BuildParameterNameProps, ChildHostedZoneProps, DiscoverableStringParameterProps, DynamoDbDataStoreProps, OpenHiAppProps, OpenHiAuthServiceProps, OpenHiDataServiceProps, OpenHiEnvironmentProps, OpenHiGlobalServiceProps, OpenHiGraphqlServiceProps, OpenHiRestApiServiceProps, OpenHiServiceProps, OpenHiServiceType, OpenHiStageProps, RootGraphqlApiProps, RootHttpApiProps, StaticHostingProps };
package/lib/index.js CHANGED
@@ -1153,7 +1153,6 @@ var import_aws_apigatewayv2_integrations = require("aws-cdk-lib/aws-apigatewayv2
1153
1153
  var import_aws_iam = require("aws-cdk-lib/aws-iam");
1154
1154
  var import_aws_route533 = require("aws-cdk-lib/aws-route53");
1155
1155
  var import_aws_route53_targets = require("aws-cdk-lib/aws-route53-targets");
1156
- var import_core2 = require("aws-cdk-lib/core");
1157
1156
 
1158
1157
  // src/services/open-hi-data-service.ts
1159
1158
  var import_aws_dynamodb2 = require("aws-cdk-lib/aws-dynamodb");
@@ -1272,6 +1271,10 @@ var RestApiLambda = class extends import_constructs5.Construct {
1272
1271
  DYNAMO_TABLE_NAME: props.dynamoTableName,
1273
1272
  BRANCH_TAG_VALUE: props.branchTagValue,
1274
1273
  HTTP_API_TAG_VALUE: props.httpApiTagValue
1274
+ },
1275
+ bundling: {
1276
+ minify: true,
1277
+ sourceMap: false
1275
1278
  }
1276
1279
  });
1277
1280
  }
@@ -1475,32 +1478,13 @@ var _OpenHiRestApiService = class _OpenHiRestApiService extends OpenHiService {
1475
1478
  userPool,
1476
1479
  { userPoolClients: [userPoolClient] }
1477
1480
  );
1478
- const cors = this.props.cors;
1479
- const corsPreflight = cors && cors.allowOrigins.length > 0 ? {
1480
- allowOrigins: cors.allowOrigins,
1481
- allowMethods: cors.allowMethods ?? [
1482
- import_aws_apigatewayv22.CorsHttpMethod.GET,
1483
- import_aws_apigatewayv22.CorsHttpMethod.HEAD,
1484
- import_aws_apigatewayv22.CorsHttpMethod.POST,
1485
- import_aws_apigatewayv22.CorsHttpMethod.PUT,
1486
- import_aws_apigatewayv22.CorsHttpMethod.PATCH,
1487
- import_aws_apigatewayv22.CorsHttpMethod.DELETE,
1488
- import_aws_apigatewayv22.CorsHttpMethod.OPTIONS
1489
- ],
1490
- allowHeaders: cors.allowHeaders ?? [
1491
- "Content-Type",
1492
- "Authorization"
1493
- ],
1494
- allowCredentials: cors.allowCredentials ?? true,
1495
- maxAge: cors.maxAge ?? import_core2.Duration.days(1)
1496
- } : void 0;
1497
1481
  const rootHttpApi = new RootHttpApi(this, {
1482
+ ...this.props.rootHttpApiProps,
1498
1483
  defaultDomainMapping: {
1499
1484
  domainName,
1500
1485
  mappingKey: void 0
1501
1486
  },
1502
- defaultAuthorizer: cognitoAuthorizer,
1503
- ...corsPreflight && { corsPreflight }
1487
+ defaultAuthorizer: cognitoAuthorizer
1504
1488
  });
1505
1489
  new DiscoverableStringParameter(this, "http-api-url-param", {
1506
1490
  ssmParamName: RootHttpApi.SSM_PARAM_NAME,