@openhi/constructs 0.0.105 → 0.0.107

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.
Files changed (73) hide show
  1. package/lib/chunk-36UPY7YQ.mjs +529 -0
  2. package/lib/chunk-36UPY7YQ.mjs.map +1 -0
  3. package/lib/chunk-AGF3RAAZ.mjs +20 -0
  4. package/lib/chunk-AGF3RAAZ.mjs.map +1 -0
  5. package/lib/{chunk-BXEG7IOZ.mjs → chunk-AO3E22CS.mjs} +2 -2
  6. package/lib/{chunk-WNUH2WDZ.mjs → chunk-CHPEQRXU.mjs} +2 -2
  7. package/lib/chunk-JUNL76HF.mjs +428 -0
  8. package/lib/chunk-JUNL76HF.mjs.map +1 -0
  9. package/lib/chunk-L6UAP4KP.mjs +27 -0
  10. package/lib/chunk-L6UAP4KP.mjs.map +1 -0
  11. package/lib/{chunk-3QS3WKRC.mjs → chunk-LZOMFHX3.mjs} +9 -2
  12. package/lib/chunk-SYBADQXI.mjs +607 -0
  13. package/lib/chunk-SYBADQXI.mjs.map +1 -0
  14. package/lib/chunk-VXX4I3EF.mjs +19 -0
  15. package/lib/chunk-VXX4I3EF.mjs.map +1 -0
  16. package/lib/{chunk-36YCDLLA.mjs → chunk-VYDIGFIX.mjs} +75 -481
  17. package/lib/chunk-VYDIGFIX.mjs.map +1 -0
  18. package/lib/chunk-YU2HRNUP.mjs +33 -0
  19. package/lib/chunk-YU2HRNUP.mjs.map +1 -0
  20. package/lib/chunk-YZZDUJHI.mjs +37 -0
  21. package/lib/chunk-YZZDUJHI.mjs.map +1 -0
  22. package/lib/cors-options-lambda.handler.mjs +1 -1
  23. package/lib/data-store-postgres-replication.handler.mjs +1 -1
  24. package/lib/events-BfrkMoBD.d.mts +44 -0
  25. package/lib/events-BfrkMoBD.d.ts +44 -0
  26. package/lib/events-DPodvl07.d.mts +207 -0
  27. package/lib/events-DPodvl07.d.ts +207 -0
  28. package/lib/firehose-archive-transform.handler.mjs +1 -1
  29. package/lib/index.d.mts +417 -9
  30. package/lib/index.d.ts +663 -10
  31. package/lib/index.js +2398 -111
  32. package/lib/index.js.map +1 -1
  33. package/lib/index.mjs +779 -104
  34. package/lib/index.mjs.map +1 -1
  35. package/lib/openhi-context-CaBH8SFo.d.mts +39 -0
  36. package/lib/openhi-context-CaBH8SFo.d.ts +39 -0
  37. package/lib/platform-deploy-bridge.handler.d.mts +14 -0
  38. package/lib/platform-deploy-bridge.handler.d.ts +14 -0
  39. package/lib/platform-deploy-bridge.handler.js +762 -0
  40. package/lib/platform-deploy-bridge.handler.js.map +1 -0
  41. package/lib/platform-deploy-bridge.handler.mjs +134 -0
  42. package/lib/platform-deploy-bridge.handler.mjs.map +1 -0
  43. package/lib/post-authentication.handler.mjs +1 -1
  44. package/lib/post-confirmation.handler.mjs +1 -1
  45. package/lib/pre-token-generation.handler.js +76 -31
  46. package/lib/pre-token-generation.handler.js.map +1 -1
  47. package/lib/pre-token-generation.handler.mjs +5 -3
  48. package/lib/pre-token-generation.handler.mjs.map +1 -1
  49. package/lib/provision-default-workspace.handler.js +86 -41
  50. package/lib/provision-default-workspace.handler.js.map +1 -1
  51. package/lib/provision-default-workspace.handler.mjs +6 -4
  52. package/lib/provision-default-workspace.handler.mjs.map +1 -1
  53. package/lib/rest-api-lambda.handler.js +114 -59
  54. package/lib/rest-api-lambda.handler.js.map +1 -1
  55. package/lib/rest-api-lambda.handler.mjs +40 -61
  56. package/lib/rest-api-lambda.handler.mjs.map +1 -1
  57. package/lib/seed-demo-data.handler.d.mts +107 -0
  58. package/lib/seed-demo-data.handler.d.ts +107 -0
  59. package/lib/seed-demo-data.handler.js +2037 -0
  60. package/lib/seed-demo-data.handler.js.map +1 -0
  61. package/lib/seed-demo-data.handler.mjs +23 -0
  62. package/lib/seed-demo-data.handler.mjs.map +1 -0
  63. package/lib/seed-system-data.handler.d.mts +64 -0
  64. package/lib/seed-system-data.handler.d.ts +64 -0
  65. package/lib/seed-system-data.handler.js +1631 -0
  66. package/lib/seed-system-data.handler.js.map +1 -0
  67. package/lib/seed-system-data.handler.mjs +135 -0
  68. package/lib/seed-system-data.handler.mjs.map +1 -0
  69. package/package.json +4 -2
  70. package/lib/chunk-36YCDLLA.mjs.map +0 -1
  71. /package/lib/{chunk-BXEG7IOZ.mjs.map → chunk-AO3E22CS.mjs.map} +0 -0
  72. /package/lib/{chunk-WNUH2WDZ.mjs.map → chunk-CHPEQRXU.mjs.map} +0 -0
  73. /package/lib/{chunk-3QS3WKRC.mjs.map → chunk-LZOMFHX3.mjs.map} +0 -0
package/lib/index.d.mts CHANGED
@@ -15,14 +15,18 @@ import * as kinesisfirehose from 'aws-cdk-lib/aws-kinesisfirehose';
15
15
  import * as s3 from 'aws-cdk-lib/aws-s3';
16
16
  import { IBucket, BucketProps } from 'aws-cdk-lib/aws-s3';
17
17
  import { Table, TableProps, ITable } from 'aws-cdk-lib/aws-dynamodb';
18
+ import { Function, IFunction } from 'aws-cdk-lib/aws-lambda';
18
19
  import * as ec2 from 'aws-cdk-lib/aws-ec2';
19
20
  import * as rds from 'aws-cdk-lib/aws-rds';
20
21
  import { HostedZone, HostedZoneProps, IHostedZone, HostedZoneAttributes } from 'aws-cdk-lib/aws-route53';
21
22
  import { StringParameterProps, StringParameter } from 'aws-cdk-lib/aws-ssm';
22
23
  import { Distribution, DistributionProps } from 'aws-cdk-lib/aws-cloudfront';
23
- import { IFunction } from 'aws-cdk-lib/aws-lambda';
24
+ export { B as BRIDGED_STATUSES, a as BridgedStatus, C as CLOUDFORMATION_EVENT_SOURCE, b as CLOUDFORMATION_STACK_STATUS_CHANGE_DETAIL_TYPE, c as CONTROL_EVENT_BUS_NAME_ENV_VAR, d as CloudFormationStackStatusChangeDetail, O as OPENHI_REPO_TAG_KEY_ENV_VAR, e as OPENHI_TAG_KEY_PREFIX_ENV_VAR, P as PLATFORM_DEPLOY_BRIDGE_ACTOR_SYSTEM } from './events-BfrkMoBD.mjs';
25
+ export { D as DEMO_PERIOD, a as DEMO_TENANT_SPECS, b as DEMO_URN_SYSTEM, c as DEV_USERS, d as DemoDevUser, e as DemoTenantSpec, f as DemoWorkspaceSpec, O as OPENHI_RESOURCE_URN_SYSTEM, P as PLACEHOLDER_TENANT_ID, g as PLACEHOLDER_WORKSPACE_ID, h as PLATFORM_SCOPE_TENANT_ID, S as SEED_DEMO_DATA_CONSUMER_NAME, i as demoBasePartitionKeys, j as demoDevUserPartitionKeys, k as demoMembershipId, l as demoMembershipPartitionKey, m as demoRoleAssignmentId, n as demoRoleAssignmentPartitionKey, o as demoRolesForUserInTenant, p as demoScenarioIdentifier, q as demoTenantPartitionKey, r as demoUserPartitionKey, s as demoWorkspacePartitionKey, t as openhiResourceIdentifier, u as rolePartitionKey } from './events-DPodvl07.mjs';
24
26
  export { P as PROVISION_DEFAULT_WORKSPACE_DETAIL_TYPE, a as ProvisionDefaultWorkspaceRequestedDetail, U as USER_ONBOARDING_EVENT_SOURCE, b as buildProvisionDefaultWorkspaceRequestedDetail } from './events-CVA3_eEB.mjs';
27
+ export { PlatformDeploymentCompletedV1, PlatformSystemDataSeededV1 } from '@openhi/workflows';
25
28
  import '@aws-sdk/client-dynamodb';
29
+ import '@openhi/types';
26
30
  import 'aws-lambda';
27
31
 
28
32
  /**
@@ -239,6 +243,28 @@ declare class OpenHiApp extends App {
239
243
  * @public
240
244
  */
241
245
  type OpenHiServiceType = "auth" | "rest-api" | "data" | "global" | "graphql-api";
246
+ /**
247
+ * Tag-key suffixes applied by every OpenHiService stack via Tags.of().
248
+ * Full keys are composed `${appName}:${suffix}` — see {@link openHiTagKey}.
249
+ * Consumers that filter or project these tags (e.g. the platform-deploy
250
+ * bridge) import these suffixes rather than redeclaring the strings.
251
+ *
252
+ * @public
253
+ */
254
+ declare const OPENHI_TAG_SUFFIX_REPO_NAME = "repo-name";
255
+ /** @public */
256
+ declare const OPENHI_TAG_SUFFIX_BRANCH_NAME = "branch-name";
257
+ /** @public */
258
+ declare const OPENHI_TAG_SUFFIX_SERVICE_TYPE = "service-type";
259
+ /** @public */
260
+ declare const OPENHI_TAG_SUFFIX_STAGE_TYPE = "stage-type";
261
+ /**
262
+ * Compose a full stack-tag key from an `appName` and a suffix from
263
+ * {@link OPENHI_TAG_SUFFIX_REPO_NAME} et al.
264
+ *
265
+ * @public
266
+ */
267
+ declare const openHiTagKey: (appName: string, suffix: string) => string;
242
268
  /**
243
269
  * Properties for creating an {@link OpenHiService} stack.
244
270
  *
@@ -631,6 +657,108 @@ declare class DynamoDbDataStore extends Table {
631
657
  constructor(scope: Construct, id: string, props?: DynamoDbDataStoreProps);
632
658
  }
633
659
 
660
+ /**
661
+ * @see sites/www-docs/content/packages/@openhi/constructs/components/dynamodb/workflow-dedup-table.md
662
+ */
663
+ /**
664
+ * Deterministic table name for the shared workflow dedup table.
665
+ * Mirrors `getDynamoDbDataStoreTableName` naming: `workflow-dedup-${branchHash}`.
666
+ */
667
+ declare function getWorkflowDedupTableName(scope: Construct): string;
668
+ /** Props for `WorkflowDedupTable`. */
669
+ interface WorkflowDedupTableProps {
670
+ /**
671
+ * Optional removal policy override. Defaults to the service's default
672
+ * (RETAIN for prod, DESTROY otherwise).
673
+ */
674
+ readonly removalPolicy?: RemovalPolicy;
675
+ }
676
+ /** Options for `WorkflowDedupTable.grantConsumer`. */
677
+ interface GrantConsumerOptions {
678
+ /**
679
+ * Override the default TTL applied by the runtime client. The 14-day
680
+ * default lives in `@openhi/workflows`; per-consumer overrides clamp
681
+ * shorter per TR-015. Stored in the consumer's environment so the
682
+ * `WorkflowDedupClient` factory can pick it up.
683
+ */
684
+ readonly defaultTtlSeconds?: number;
685
+ }
686
+ /**
687
+ * Shared platform-level dedup table every retryable workflow consumer
688
+ * dedupes against. Provisioned exactly once at the platform stack.
689
+ *
690
+ * Schema (per TR-015):
691
+ * - Partition key `consumerName` (S)
692
+ * - Sort key `sk` (S) — encodes `<eventId>#<attempt>`
693
+ * - TTL attribute `expiresAt` (N, Unix epoch seconds)
694
+ * - On-demand billing
695
+ *
696
+ * @see https://github.com/codedrifters/openhi-planning/blob/main/docs/src/content/docs/requirements/technical-requirements/TR-015-workflow-dedup-table.md
697
+ */
698
+ declare class WorkflowDedupTable extends Construct {
699
+ /** SSM param name (short) used by `DiscoverableStringParameter` for the table name lookup. */
700
+ static readonly TABLE_NAME_SSM_PARAM_NAME = "workflow-dedup-table-name";
701
+ /** SSM param name (short) used by `DiscoverableStringParameter` for the table ARN lookup. */
702
+ static readonly TABLE_ARN_SSM_PARAM_NAME = "workflow-dedup-table-arn";
703
+ /** Cross-stack lookup for the table name. */
704
+ static tableNameFromLookup(scope: Construct): string;
705
+ /** Cross-stack lookup for the table ARN. */
706
+ static tableArnFromLookup(scope: Construct): string;
707
+ /**
708
+ * Cross-stack equivalent of {@link grantConsumer}. Use when the dedup
709
+ * table is on a different stack than the consumer Lambda — the
710
+ * grant resolves the table name + ARN via SSM at synth time, so the
711
+ * consumer stack does not pick up a CloudFormation export dependency
712
+ * on the global stack.
713
+ *
714
+ * Inverts the singleton-guard semantics of `grantConsumer`: there is
715
+ * no synth-time check that the same `consumerName` was registered
716
+ * twice across stacks. Consumer names are agreed by convention
717
+ * (see TR-015); double-registration is operator error caught at
718
+ * design time, not synth time.
719
+ */
720
+ static grantConsumerFromLookup(scope: Construct, fn: Function, consumerName: string, options?: GrantConsumerOptions): void;
721
+ /**
722
+ * Service-type the publishing stack runs under. The cross-stack lookups
723
+ * pin to this value so consumer stacks on a different service-type
724
+ * (e.g. `data`, `auth`) resolve the parameter at the publisher's SSM
725
+ * path instead of their own. Typed against `OpenHiServiceType` so a
726
+ * future rename of the literal triggers a compile error; not pulled
727
+ * from `OpenHiGlobalService.SERVICE_TYPE` because
728
+ * `OpenHiGlobalService` already imports `WorkflowDedupTable` — a
729
+ * back-import would create a circular dependency.
730
+ */
731
+ private static readonly PUBLISHER_SERVICE_TYPE;
732
+ /**
733
+ * Standalone consumer-name validator shared by the instance method
734
+ * and `grantConsumerFromLookup` so the two grants enforce identical
735
+ * invariants.
736
+ */
737
+ private static assertConsumerNameStatic;
738
+ /** The underlying DynamoDB table. */
739
+ readonly table: Table;
740
+ private readonly registeredConsumers;
741
+ constructor(scope: Construct, id: string, props?: WorkflowDedupTableProps);
742
+ /**
743
+ * Wire a Lambda consumer to this table. Injects the table-name env var
744
+ * so the runtime `WorkflowDedupClient` can resolve it, then attaches a
745
+ * per-consumer IAM grant scoped by `dynamodb:LeadingKeys` so the
746
+ * consumer can only read/write its own partition.
747
+ */
748
+ grantConsumer(fn: Function, consumerName: string, options?: GrantConsumerOptions): void;
749
+ private assertConsumerName;
750
+ }
751
+ /** Thrown when a second `WorkflowDedupTable` is instantiated in the same app. */
752
+ declare class WorkflowDedupTableDuplicateError extends Error {
753
+ /** @param message - human-readable description of the duplicate. */
754
+ constructor(message: string);
755
+ }
756
+ /** Thrown when a consumerName violates the TR-015 invariants. */
757
+ declare class WorkflowDedupConsumerNameInvalidError extends Error {
758
+ /** @param message - human-readable description of the invariant violation. */
759
+ constructor(message: string);
760
+ }
761
+
634
762
  /**
635
763
  * @see sites/www-docs/content/packages/@openhi/constructs/components/event-bridge/data-event-bus.md
636
764
  */
@@ -991,7 +1119,7 @@ interface OpenHiAuthServiceProps extends OpenHiServiceProps {
991
1119
  * @public
992
1120
  */
993
1121
  declare class OpenHiAuthService extends OpenHiService {
994
- static readonly SERVICE_TYPE = "auth";
1122
+ static readonly SERVICE_TYPE: "auth";
995
1123
  /**
996
1124
  * Returns an IUserPool by looking up the Auth stack's User Pool ID from SSM.
997
1125
  */
@@ -1134,6 +1262,52 @@ declare class OpenHiAuthService extends OpenHiService {
1134
1262
  protected createUserPoolDomain(): IUserPoolDomain;
1135
1263
  }
1136
1264
 
1265
+ interface PlatformDeployBridgeLambdaProps {
1266
+ /** Destination control event bus the bridge republishes onto. */
1267
+ readonly controlEventBus: IEventBus;
1268
+ }
1269
+ /**
1270
+ * Lambda that bridges CloudFormation Stack Status Change events from the
1271
+ * default AWS bus into typed `platform.deployment-completed.v1` envelopes on
1272
+ * the OpenHI control event bus.
1273
+ *
1274
+ * Owns its EventBridge Rule (on the default AWS bus) and the IAM
1275
+ * permissions it needs — colocating routing + permissions with the
1276
+ * function they target.
1277
+ *
1278
+ * The EventBridge rule pre-filters by stack-id prefix so the rule (and
1279
+ * therefore the Lambda) only fires on the host stack's own branch deploys.
1280
+ * This prevents cross-branch leak when multiple branches are deployed into
1281
+ * the same account.
1282
+ */
1283
+ declare class PlatformDeployBridgeLambda extends Construct {
1284
+ readonly lambda: NodejsFunction;
1285
+ readonly rule: Rule;
1286
+ constructor(scope: Construct, props: PlatformDeployBridgeLambdaProps);
1287
+ }
1288
+
1289
+ /**
1290
+ * @see sites/www-docs/content/packages/@openhi/constructs/workflows/control-plane/platform-deploy-bridge/index.md
1291
+ */
1292
+ interface PlatformDeployBridgeProps {
1293
+ /** Destination control event bus the bridge republishes onto. */
1294
+ readonly controlEventBus: IEventBus;
1295
+ }
1296
+ /**
1297
+ * Source-side reactor that watches CloudFormation Stack Status Change
1298
+ * events on the default AWS bus and republishes terminal-success events
1299
+ * (`CREATE_COMPLETE` / `UPDATE_COMPLETE`) for OpenHi-tagged stacks onto
1300
+ * the control event bus as `platform.deployment-completed.v1`.
1301
+ *
1302
+ * Implements row 4 of the workflow placement matrix
1303
+ * (codedrifters/openhi#953): ops-plane reactor → republishes to
1304
+ * control event bus.
1305
+ */
1306
+ declare class PlatformDeployBridge extends Construct {
1307
+ readonly bridgeLambda: PlatformDeployBridgeLambda;
1308
+ constructor(scope: Construct, props: PlatformDeployBridgeProps);
1309
+ }
1310
+
1137
1311
  /**
1138
1312
  * @see sites/www-docs/content/packages/@openhi/constructs/services/open-hi-global-service.md
1139
1313
  */
@@ -1146,7 +1320,7 @@ interface OpenHiGlobalServiceProps extends OpenHiServiceProps {
1146
1320
  * protected methods; subclasses may override to customize.
1147
1321
  */
1148
1322
  declare class OpenHiGlobalService extends OpenHiService {
1149
- static readonly SERVICE_TYPE = "global";
1323
+ static readonly SERVICE_TYPE: "global";
1150
1324
  /**
1151
1325
  * Returns an IHostedZone from the given attributes (no SSM). Use when the zone is imported from config.
1152
1326
  */
@@ -1174,6 +1348,15 @@ declare class OpenHiGlobalService extends OpenHiService {
1174
1348
  * Returns the control-plane event bus by name (deterministic per branch). Use from other stacks to obtain an IEventBus reference.
1175
1349
  */
1176
1350
  static controlEventBusFromConstruct(scope: Construct): IEventBus;
1351
+ /**
1352
+ * Returns the workflow dedup table by name (deterministic per branch).
1353
+ * Use from other stacks to obtain an ITable reference. Consumer Lambdas
1354
+ * are typically wired via `WorkflowDedupTable.grantConsumer(fn, name)`
1355
+ * on the owning service's `workflowDedupTable` reference; the
1356
+ * `tableNameFromLookup` / `tableArnFromLookup` SSM helpers on the
1357
+ * construct cover cross-stack consumers that need only the name/ARN.
1358
+ */
1359
+ static workflowDedupTableNameFromLookup(scope: Construct): string;
1177
1360
  get serviceType(): string;
1178
1361
  /** Override so this.props is typed with this service's options. */
1179
1362
  props: OpenHiGlobalServiceProps;
@@ -1195,6 +1378,18 @@ declare class OpenHiGlobalService extends OpenHiService {
1195
1378
  * Other stacks obtain it via {@link OpenHiGlobalService.controlEventBusFromConstruct}.
1196
1379
  */
1197
1380
  readonly controlEventBus: IEventBus;
1381
+ /**
1382
+ * Bridge that watches CloudFormation Stack Status Change events on the
1383
+ * default AWS bus and republishes terminal-success events for OpenHi-tagged
1384
+ * stacks onto {@link controlEventBus} as `platform.deployment-completed.v1`.
1385
+ */
1386
+ readonly platformDeployBridge: PlatformDeployBridge;
1387
+ /**
1388
+ * Shared dedup table every retryable workflow consumer dedupes against
1389
+ * (TR-015). Singleton per deployment — provisioned here on the global
1390
+ * stack so consumer stacks reach it via SSM lookups, not props.
1391
+ */
1392
+ readonly workflowDedupTable: WorkflowDedupTable;
1198
1393
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiGlobalServiceProps);
1199
1394
  /**
1200
1395
  * Validates that config required for the Global stack is present.
@@ -1233,6 +1428,17 @@ declare class OpenHiGlobalService extends OpenHiService {
1233
1428
  * Override to customize.
1234
1429
  */
1235
1430
  protected createControlEventBus(): IEventBus;
1431
+ /**
1432
+ * Creates the platform deploy bridge that republishes CloudFormation
1433
+ * Stack Status Change events onto the control event bus.
1434
+ * Override to customize.
1435
+ */
1436
+ protected createPlatformDeployBridge(): PlatformDeployBridge;
1437
+ /**
1438
+ * Creates the shared workflow dedup table (TR-015 singleton).
1439
+ * Override to customize.
1440
+ */
1441
+ protected createWorkflowDedupTable(): WorkflowDedupTable;
1236
1442
  }
1237
1443
 
1238
1444
  /**
@@ -1255,7 +1461,7 @@ declare const REST_API_BASE_URL_SSM_NAME = "REST_API_BASE_URL";
1255
1461
  * Resources are created in protected methods; subclasses may override to customize.
1256
1462
  */
1257
1463
  declare class OpenHiRestApiService extends OpenHiService {
1258
- static readonly SERVICE_TYPE = "rest-api";
1464
+ static readonly SERVICE_TYPE: "rest-api";
1259
1465
  /**
1260
1466
  * Returns an IHttpApi by looking up the REST API stack's HTTP API ID from SSM.
1261
1467
  */
@@ -1313,11 +1519,167 @@ declare class OpenHiRestApiService extends OpenHiService {
1313
1519
  protected createRootHttpApi(domainName: DomainName): RootHttpApi;
1314
1520
  }
1315
1521
 
1522
+ interface SeedDemoDataLambdaProps {
1523
+ /**
1524
+ * Data-store table the workflow upserts demo-data records into.
1525
+ * Wired via `DYNAMO_TABLE_NAME` env var; granted scoped read on the
1526
+ * Role PKs (pre-flight check) and scoped write on the enumerated
1527
+ * demo Tenant / Workspace / Membership / RoleAssignment / User PKs.
1528
+ */
1529
+ readonly dataStoreTable: ITable;
1530
+ /**
1531
+ * Control event bus that re-publishes
1532
+ * `platform.deployment-completed.v1` from the platform-deploy bridge.
1533
+ * The Rule mounts here.
1534
+ */
1535
+ readonly controlEventBus: IEventBus;
1536
+ /**
1537
+ * Cognito User Pool the workflow provisions dev users into. The
1538
+ * Lambda's IAM grant is scoped to this exact user-pool ARN — the
1539
+ * grant uses the user-pool ARN, **not** the wildcard formatArn
1540
+ * pattern used by `post-authentication-lambda` (that Lambda's
1541
+ * trigger-driven dependency cycle does not apply here, so the
1542
+ * tighter scope is safe).
1543
+ */
1544
+ readonly userPool: IUserPool;
1545
+ }
1316
1546
  /**
1317
- * @see sites/www-docs/content/packages/@openhi/constructs/services/open-hi-data-service.md
1547
+ * Lambda + EventBridge Rule pair for the seed-demo-data workflow.
1548
+ * Owns the routing (`source` / `detail-type` pattern), the scoped
1549
+ * DynamoDB grants, and the scoped Cognito Admin grant — co-locating
1550
+ * routing + permissions with the function they target. Wiring to the
1551
+ * workflow dedup table is the parent construct's job (it has the
1552
+ * singleton reference) and happens via `WorkflowDedupTable.grantConsumer`.
1553
+ *
1554
+ * Stage-gating is the parent's job too — this construct itself never
1555
+ * checks the stage. The CDK stage-router (`OpenHiDataService`)
1556
+ * decides whether to instantiate it at all on each stage.
1318
1557
  */
1319
- interface OpenHiDataServiceProps extends OpenHiServiceProps {
1558
+ declare class SeedDemoDataLambda extends Construct {
1559
+ readonly lambda: NodejsFunction;
1560
+ readonly rule: Rule;
1561
+ constructor(scope: Construct, props: SeedDemoDataLambdaProps);
1320
1562
  }
1563
+
1564
+ /**
1565
+ * @see sites/www-docs/content/packages/@openhi/constructs/workflows/control-plane/seed-demo-data/seed-demo-data-workflow.md
1566
+ */
1567
+ interface SeedDemoDataWorkflowProps {
1568
+ /** Control event bus carrying `platform.system-data-seeded.v1`. */
1569
+ readonly controlEventBus: IEventBus;
1570
+ /** Data-store table the workflow upserts demo-data records into. */
1571
+ readonly dataStoreTable: ITable;
1572
+ /** Cognito User Pool the workflow provisions dev users into. */
1573
+ readonly userPool: IUserPool;
1574
+ }
1575
+ /**
1576
+ * Control-plane workflow that fires on every platform deploy and
1577
+ * idempotently re-asserts the demo-data graph: placeholder tenant +
1578
+ * workspace, 3 demo tenants + 4 workspaces, and per-dev-user Cognito
1579
+ * users with their DynamoDB User records, Memberships, and
1580
+ * RoleAssignments.
1581
+ *
1582
+ * Mounted on the data-service stack so the IAM grants against the
1583
+ * data-store table stay local. The control event bus and the workflow
1584
+ * dedup table reach in cross-stack via the SSM lookups
1585
+ * `OpenHiGlobalService.controlEventBusFromConstruct` and
1586
+ * `WorkflowDedupTable.grantConsumerFromLookup` respectively. The
1587
+ * Cognito User Pool similarly reaches in via
1588
+ * `OpenHiAuthService.userPoolFromConstruct`.
1589
+ *
1590
+ * Non-prod-only: the CDK stage-router (`OpenHiDataService`)
1591
+ * conditionally constructs this workflow only on non-prod stages.
1592
+ * The construct itself never checks the stage — its absence in prod
1593
+ * stacks is the gate.
1594
+ */
1595
+ declare class SeedDemoDataWorkflow extends Construct {
1596
+ readonly seedDemoData: SeedDemoDataLambda;
1597
+ constructor(scope: Construct, props: SeedDemoDataWorkflowProps);
1598
+ }
1599
+
1600
+ /**
1601
+ * @see sites/www-docs/content/packages/@openhi/constructs/workflows/control-plane/seed-system-data/events.md
1602
+ */
1603
+ /**
1604
+ * Stable logical name this workflow registers with the shared
1605
+ * `WorkflowDedupTable` (TR-015). Used in both the construct grant
1606
+ * (`workflowDedupTable.grantConsumer(lambda, SEED_SYSTEM_DATA_CONSUMER_NAME)`)
1607
+ * and the handler's runtime `recordIfAbsent` call — keep them aligned by
1608
+ * importing this constant in both places.
1609
+ */
1610
+ declare const SEED_SYSTEM_DATA_CONSUMER_NAME = "seed-system-data";
1611
+ /**
1612
+ * Free-form `actor.system` value the handler stamps on the
1613
+ * `platform.system-data-seeded.v1` event it publishes when seeding
1614
+ * completes. Pinned here so the test can assert the wire value without
1615
+ * importing private handler internals.
1616
+ */
1617
+ declare const SEED_SYSTEM_DATA_ACTOR_SYSTEM = "seed-system-data";
1618
+ /**
1619
+ * Env var the Lambda construct injects with the control event bus
1620
+ * name. The handler reads it to build the publisher target when
1621
+ * emitting `platform.system-data-seeded.v1` after a successful seed.
1622
+ */
1623
+ declare const SEED_SYSTEM_DATA_CONTROL_BUS_ENV_VAR = "CONTROL_EVENT_BUS_NAME";
1624
+
1625
+ interface SeedSystemDataLambdaProps {
1626
+ /**
1627
+ * Data-store table the workflow upserts platform-singleton control-plane
1628
+ * records into. Wired via `DYNAMO_TABLE_NAME` env var; granted scoped
1629
+ * write permission to the role records' partition keys only.
1630
+ */
1631
+ readonly dataStoreTable: ITable;
1632
+ /**
1633
+ * Control event bus that re-publishes
1634
+ * `platform.deployment-completed.v1` from the platform-deploy bridge.
1635
+ * The Rule mounts here.
1636
+ */
1637
+ readonly controlEventBus: IEventBus;
1638
+ }
1639
+ /**
1640
+ * Lambda + EventBridge Rule pair for the seed-system-data workflow. Owns
1641
+ * the routing (`source` / `detail-type` pattern) and the scoped data-store
1642
+ * grants — co-locating routing + permissions with the function they
1643
+ * target. Wiring to the workflow dedup table is the parent construct's
1644
+ * job (it has the singleton reference) and happens via
1645
+ * `WorkflowDedupTable.grantConsumer`.
1646
+ */
1647
+ declare class SeedSystemDataLambda extends Construct {
1648
+ readonly lambda: NodejsFunction;
1649
+ readonly rule: Rule;
1650
+ constructor(scope: Construct, props: SeedSystemDataLambdaProps);
1651
+ }
1652
+
1653
+ /**
1654
+ * @see sites/www-docs/content/packages/@openhi/constructs/workflows/control-plane/seed-system-data/seed-system-data-workflow.md
1655
+ */
1656
+ interface SeedSystemDataWorkflowProps {
1657
+ /** Control event bus carrying `platform.deployment-completed.v1`. */
1658
+ readonly controlEventBus: IEventBus;
1659
+ /** Data-store table the workflow upserts platform-singleton records into. */
1660
+ readonly dataStoreTable: ITable;
1661
+ }
1662
+ /**
1663
+ * Control-plane workflow that fires on every platform deploy and
1664
+ * idempotently re-asserts the platform-singleton control-plane records
1665
+ * (today: the three canonical Roles; future: additional system data
1666
+ * slotted in as sibling steps under the same dedup record).
1667
+ *
1668
+ * Mounted on the data-service stack so the IAM grants against the
1669
+ * data-store table stay local. The control event bus and the
1670
+ * workflow dedup table reach in cross-stack via the SSM lookups
1671
+ * `OpenHiGlobalService.controlEventBusFromConstruct` and
1672
+ * `WorkflowDedupTable.grantConsumerFromLookup` respectively.
1673
+ */
1674
+ declare class SeedSystemDataWorkflow extends Construct {
1675
+ readonly seedSystemData: SeedSystemDataLambda;
1676
+ constructor(scope: Construct, props: SeedSystemDataWorkflowProps);
1677
+ }
1678
+
1679
+ /**
1680
+ * @see sites/www-docs/content/packages/@openhi/constructs/services/open-hi-data-service.md
1681
+ */
1682
+ type OpenHiDataServiceProps = OpenHiServiceProps;
1321
1683
  /**
1322
1684
  * Data storage service stack: centralizes DynamoDB, S3, and other persistence
1323
1685
  * resources for OpenHI. Creates the single-table data store in a protected
@@ -1326,7 +1688,7 @@ interface OpenHiDataServiceProps extends OpenHiServiceProps {
1326
1688
  * ahead of regional services.
1327
1689
  */
1328
1690
  declare class OpenHiDataService extends OpenHiService {
1329
- static readonly SERVICE_TYPE = "data";
1691
+ static readonly SERVICE_TYPE: "data";
1330
1692
  /**
1331
1693
  * Returns the data store table by name. Use from other stacks (e.g. REST API Lambda) to obtain an ITable reference.
1332
1694
  */
@@ -1355,7 +1717,53 @@ declare class OpenHiDataService extends OpenHiService {
1355
1717
  * the read path is not wired up yet.
1356
1718
  */
1357
1719
  readonly dataStorePostgresReplica: DataStorePostgresReplica;
1720
+ /**
1721
+ * Deploy-triggered workflow that idempotently re-asserts the
1722
+ * platform-singleton control-plane records (today: the three canonical
1723
+ * Roles via `PLATFORM_ROLE_CONCEPTS`; future: additional system
1724
+ * data). Subscribes to `platform.deployment-completed.v1` on the
1725
+ * control event bus and dedups via the shared `WorkflowDedupTable`.
1726
+ */
1727
+ readonly seedSystemDataWorkflow: SeedSystemDataWorkflow;
1728
+ /**
1729
+ * Deploy-triggered workflow that idempotently re-asserts the demo
1730
+ * data graph (placeholder + 3 demo Tenants + 5 Workspaces; per
1731
+ * dev-user Cognito users with their DynamoDB User records,
1732
+ * Memberships, and RoleAssignments). **Non-prod only** —
1733
+ * `undefined` on prod stages. The synth-time stage gate in
1734
+ * {@link createSeedDemoDataWorkflow} is the only guarantee
1735
+ * separating prod stacks from the workflow's IAM grants and rule
1736
+ * target; the construct itself never checks the stage.
1737
+ */
1738
+ readonly seedDemoDataWorkflow?: SeedDemoDataWorkflow;
1739
+ /**
1740
+ * Cached control-event-bus lookup. `OpenHiGlobalService.controlEventBusFromConstruct`
1741
+ * registers a child `EventBus.fromEventBusName` construct with a
1742
+ * fixed id under the scope it is passed, so calling it twice on the
1743
+ * same `OpenHiDataService` instance collides. The cache mirrors the
1744
+ * `private controlEventBus()` pattern already used in
1745
+ * `OpenHiAuthService`. Use {@link controlEventBus} from this class
1746
+ * — never call the static lookup from inside `OpenHiDataService`.
1747
+ */
1748
+ private _controlEventBus;
1358
1749
  constructor(ohEnv: OpenHiEnvironment, props?: OpenHiDataServiceProps);
1750
+ /**
1751
+ * Lazily looks up the control event bus exactly once per
1752
+ * `OpenHiDataService` instance and caches the reference. Every
1753
+ * workflow that consumes the bus must read it through this method
1754
+ * — see {@link _controlEventBus} for the underlying collision risk.
1755
+ */
1756
+ private controlEventBus;
1757
+ /**
1758
+ * Creates the seed-system-data workflow. Override to customize.
1759
+ */
1760
+ protected createSeedSystemDataWorkflow(): SeedSystemDataWorkflow;
1761
+ /**
1762
+ * Creates the seed-demo-data workflow — but only on non-prod
1763
+ * stages. Returns `undefined` on prod so the workflow literally
1764
+ * does not exist in prod stacks. Override to customize.
1765
+ */
1766
+ protected createSeedDemoDataWorkflow(): SeedDemoDataWorkflow | undefined;
1359
1767
  /**
1360
1768
  * Creates the single-table DynamoDB data store.
1361
1769
  * Override to customize.
@@ -1371,7 +1779,7 @@ interface OpenHiGraphqlServiceProps extends OpenHiServiceProps {
1371
1779
  * {@link OpenHiGraphqlService.graphqlApiFromConstruct}.
1372
1780
  */
1373
1781
  declare class OpenHiGraphqlService extends OpenHiService {
1374
- static readonly SERVICE_TYPE = "graphql-api";
1782
+ static readonly SERVICE_TYPE: "graphql-api";
1375
1783
  /**
1376
1784
  * Returns the GraphQL API by looking up the GraphQL stack's API ID from SSM.
1377
1785
  * Use from other stacks to obtain an IGraphqlApi reference.
@@ -1385,4 +1793,4 @@ declare class OpenHiGraphqlService extends OpenHiService {
1385
1793
  protected createRootGraphqlApi(): RootGraphqlApi;
1386
1794
  }
1387
1795
 
1388
- export { type BuildParameterNameProps, ChildHostedZone, type ChildHostedZoneProps, CognitoFixtureSeederClient, type CognitoFixtureSeederClientProps, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, ControlEventBus, DATA_STORE_CHANGE_DETAIL_MAX_UTF8_BYTES, DATA_STORE_CHANGE_DETAIL_TYPE, DATA_STORE_CHANGE_EVENT_SOURCE, DataEventBus, DataStoreHistoricalArchive, type DataStoreHistoricalArchiveProps, DataStorePostgresReplica, type DataStorePostgresReplicaProps, DiscoverableStringParameter, type DiscoverableStringParameterProps, DynamoDbDataStore, type DynamoDbDataStoreProps, type FhirCurrentResourceChangeDetail, 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, POSTGRES_REPLICA_CLUSTER_ARN_SSM_NAME, POSTGRES_REPLICA_DATABASE_NAME_SSM_NAME, POSTGRES_REPLICA_SECRET_ARN_SSM_NAME, PostAuthenticationLambda, PostConfirmationLambda, type PostConfirmationLambdaProps, PreTokenGenerationLambda, type PreTokenGenerationLambdaProps, ProvisionDefaultWorkspaceLambda, type ProvisionDefaultWorkspaceLambdaProps, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, type RootGraphqlApiProps, RootHostedZone, RootHttpApi, type RootHttpApiProps, RootWildcardCertificate, STATIC_HOSTING_SERVICE_TYPE, StaticHosting, type StaticHostingProps, UserOnboardingWorkflow, type UserOnboardingWorkflowProps, buildFhirCurrentResourceChangeDetail, getDynamoDbDataStoreTableName, getPostgresReplicaSchemaName };
1796
+ export { type BuildParameterNameProps, ChildHostedZone, type ChildHostedZoneProps, CognitoFixtureSeederClient, type CognitoFixtureSeederClientProps, CognitoUserPool, CognitoUserPoolClient, CognitoUserPoolDomain, CognitoUserPoolKmsKey, ControlEventBus, DATA_STORE_CHANGE_DETAIL_MAX_UTF8_BYTES, DATA_STORE_CHANGE_DETAIL_TYPE, DATA_STORE_CHANGE_EVENT_SOURCE, DataEventBus, DataStoreHistoricalArchive, type DataStoreHistoricalArchiveProps, DataStorePostgresReplica, type DataStorePostgresReplicaProps, DiscoverableStringParameter, type DiscoverableStringParameterProps, DynamoDbDataStore, type DynamoDbDataStoreProps, type FhirCurrentResourceChangeDetail, type GrantConsumerOptions, OPENHI_TAG_SUFFIX_BRANCH_NAME, OPENHI_TAG_SUFFIX_REPO_NAME, OPENHI_TAG_SUFFIX_SERVICE_TYPE, OPENHI_TAG_SUFFIX_STAGE_TYPE, 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, POSTGRES_REPLICA_CLUSTER_ARN_SSM_NAME, POSTGRES_REPLICA_DATABASE_NAME_SSM_NAME, POSTGRES_REPLICA_SECRET_ARN_SSM_NAME, PlatformDeployBridge, PlatformDeployBridgeLambda, type PlatformDeployBridgeLambdaProps, type PlatformDeployBridgeProps, PostAuthenticationLambda, PostConfirmationLambda, type PostConfirmationLambdaProps, PreTokenGenerationLambda, type PreTokenGenerationLambdaProps, ProvisionDefaultWorkspaceLambda, type ProvisionDefaultWorkspaceLambdaProps, REST_API_BASE_URL_SSM_NAME, RootGraphqlApi, type RootGraphqlApiProps, RootHostedZone, RootHttpApi, type RootHttpApiProps, RootWildcardCertificate, SEED_SYSTEM_DATA_ACTOR_SYSTEM, SEED_SYSTEM_DATA_CONSUMER_NAME, SEED_SYSTEM_DATA_CONTROL_BUS_ENV_VAR, STATIC_HOSTING_SERVICE_TYPE, SeedDemoDataLambda, type SeedDemoDataLambdaProps, SeedDemoDataWorkflow, type SeedDemoDataWorkflowProps, SeedSystemDataLambda, type SeedSystemDataLambdaProps, SeedSystemDataWorkflow, type SeedSystemDataWorkflowProps, StaticHosting, type StaticHostingProps, UserOnboardingWorkflow, type UserOnboardingWorkflowProps, WorkflowDedupConsumerNameInvalidError, WorkflowDedupTable, WorkflowDedupTableDuplicateError, type WorkflowDedupTableProps, buildFhirCurrentResourceChangeDetail, getDynamoDbDataStoreTableName, getPostgresReplicaSchemaName, getWorkflowDedupTableName, openHiTagKey };