@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.
- package/lib/chunk-36UPY7YQ.mjs +529 -0
- package/lib/chunk-36UPY7YQ.mjs.map +1 -0
- package/lib/chunk-AGF3RAAZ.mjs +20 -0
- package/lib/chunk-AGF3RAAZ.mjs.map +1 -0
- package/lib/{chunk-BXEG7IOZ.mjs → chunk-AO3E22CS.mjs} +2 -2
- package/lib/{chunk-WNUH2WDZ.mjs → chunk-CHPEQRXU.mjs} +2 -2
- package/lib/chunk-JUNL76HF.mjs +428 -0
- package/lib/chunk-JUNL76HF.mjs.map +1 -0
- package/lib/chunk-L6UAP4KP.mjs +27 -0
- package/lib/chunk-L6UAP4KP.mjs.map +1 -0
- package/lib/{chunk-3QS3WKRC.mjs → chunk-LZOMFHX3.mjs} +9 -2
- package/lib/chunk-SYBADQXI.mjs +607 -0
- package/lib/chunk-SYBADQXI.mjs.map +1 -0
- package/lib/chunk-VXX4I3EF.mjs +19 -0
- package/lib/chunk-VXX4I3EF.mjs.map +1 -0
- package/lib/{chunk-36YCDLLA.mjs → chunk-VYDIGFIX.mjs} +75 -481
- package/lib/chunk-VYDIGFIX.mjs.map +1 -0
- package/lib/chunk-YU2HRNUP.mjs +33 -0
- package/lib/chunk-YU2HRNUP.mjs.map +1 -0
- package/lib/chunk-YZZDUJHI.mjs +37 -0
- package/lib/chunk-YZZDUJHI.mjs.map +1 -0
- package/lib/cors-options-lambda.handler.mjs +1 -1
- package/lib/data-store-postgres-replication.handler.mjs +1 -1
- package/lib/events-BfrkMoBD.d.mts +44 -0
- package/lib/events-BfrkMoBD.d.ts +44 -0
- package/lib/events-DPodvl07.d.mts +207 -0
- package/lib/events-DPodvl07.d.ts +207 -0
- package/lib/firehose-archive-transform.handler.mjs +1 -1
- package/lib/index.d.mts +417 -9
- package/lib/index.d.ts +663 -10
- package/lib/index.js +2398 -111
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +779 -104
- package/lib/index.mjs.map +1 -1
- package/lib/openhi-context-CaBH8SFo.d.mts +39 -0
- package/lib/openhi-context-CaBH8SFo.d.ts +39 -0
- package/lib/platform-deploy-bridge.handler.d.mts +14 -0
- package/lib/platform-deploy-bridge.handler.d.ts +14 -0
- package/lib/platform-deploy-bridge.handler.js +762 -0
- package/lib/platform-deploy-bridge.handler.js.map +1 -0
- package/lib/platform-deploy-bridge.handler.mjs +134 -0
- package/lib/platform-deploy-bridge.handler.mjs.map +1 -0
- package/lib/post-authentication.handler.mjs +1 -1
- package/lib/post-confirmation.handler.mjs +1 -1
- package/lib/pre-token-generation.handler.js +76 -31
- package/lib/pre-token-generation.handler.js.map +1 -1
- package/lib/pre-token-generation.handler.mjs +5 -3
- package/lib/pre-token-generation.handler.mjs.map +1 -1
- package/lib/provision-default-workspace.handler.js +86 -41
- package/lib/provision-default-workspace.handler.js.map +1 -1
- package/lib/provision-default-workspace.handler.mjs +6 -4
- package/lib/provision-default-workspace.handler.mjs.map +1 -1
- package/lib/rest-api-lambda.handler.js +114 -59
- package/lib/rest-api-lambda.handler.js.map +1 -1
- package/lib/rest-api-lambda.handler.mjs +40 -61
- package/lib/rest-api-lambda.handler.mjs.map +1 -1
- package/lib/seed-demo-data.handler.d.mts +107 -0
- package/lib/seed-demo-data.handler.d.ts +107 -0
- package/lib/seed-demo-data.handler.js +2037 -0
- package/lib/seed-demo-data.handler.js.map +1 -0
- package/lib/seed-demo-data.handler.mjs +23 -0
- package/lib/seed-demo-data.handler.mjs.map +1 -0
- package/lib/seed-system-data.handler.d.mts +64 -0
- package/lib/seed-system-data.handler.d.ts +64 -0
- package/lib/seed-system-data.handler.js +1631 -0
- package/lib/seed-system-data.handler.js.map +1 -0
- package/lib/seed-system-data.handler.mjs +135 -0
- package/lib/seed-system-data.handler.mjs.map +1 -0
- package/package.json +4 -2
- package/lib/chunk-36YCDLLA.mjs.map +0 -1
- /package/lib/{chunk-BXEG7IOZ.mjs.map → chunk-AO3E22CS.mjs.map} +0 -0
- /package/lib/{chunk-WNUH2WDZ.mjs.map → chunk-CHPEQRXU.mjs.map} +0 -0
- /package/lib/{chunk-3QS3WKRC.mjs.map → chunk-LZOMFHX3.mjs.map} +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { WorkflowDedupClient } from '@openhi/workflows';
|
|
2
|
+
import { EventBridgeEvent } from 'aws-lambda';
|
|
3
|
+
import { d as DemoDevUser } from './events-DPodvl07.mjs';
|
|
4
|
+
import { O as OpenHiContext } from './openhi-context-CaBH8SFo.mjs';
|
|
5
|
+
import '@openhi/types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @see sites/www-docs/content/packages/@openhi/constructs/workflows/control-plane/seed-demo-data/seed-demo-data-handler.md
|
|
9
|
+
*
|
|
10
|
+
* EventBridge workflow handler invoked once per platform-deploy event
|
|
11
|
+
* on the control event bus. Pre-flight verifies that
|
|
12
|
+
* `seed-system-data` has already seeded the canonical Role records,
|
|
13
|
+
* then idempotently re-asserts the demo-data graph: the placeholder
|
|
14
|
+
* Tenant + Workspace, the three demo tenants + their workspaces, and
|
|
15
|
+
* for each entry in {@link DEV_USERS} a Cognito user, a DynamoDB User,
|
|
16
|
+
* 4 Memberships, 4 `tenant-admin` RoleAssignments, plus 1
|
|
17
|
+
* platform-scoped `system-admin` RoleAssignment.
|
|
18
|
+
*/
|
|
19
|
+
type SeedDemoDataEvent = EventBridgeEvent<"platform.system-data-seeded.v1", unknown>;
|
|
20
|
+
/** Env var the lambda construct injects with the Cognito User Pool ID. */
|
|
21
|
+
declare const SEED_DEMO_DATA_USER_POOL_ID_ENV_VAR = "SEED_DEMO_DATA_USER_POOL_ID";
|
|
22
|
+
/** Inputs the handler needs to provision Cognito users for every dev. */
|
|
23
|
+
interface CognitoProvisioner {
|
|
24
|
+
/**
|
|
25
|
+
* Ensure a Cognito user exists for `email`. Returns the user's
|
|
26
|
+
* `sub`. Implementations MUST be idempotent: a second invocation
|
|
27
|
+
* for the same email returns the existing user's sub without
|
|
28
|
+
* resetting its password or touching any attribute.
|
|
29
|
+
*/
|
|
30
|
+
readonly ensureUser: (email: string) => Promise<string>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Dependency seam for tests. The factory mirrors the production
|
|
34
|
+
* arrangement: a real DynamoDB client + the real `workflowDedupClient`
|
|
35
|
+
* factory bound to the `OPENHI_WORKFLOW_DEDUP_TABLE_NAME` env var the
|
|
36
|
+
* construct injects via `grantConsumer`.
|
|
37
|
+
*/
|
|
38
|
+
interface SeedDemoDataDependencies {
|
|
39
|
+
readonly dedupClient: WorkflowDedupClient;
|
|
40
|
+
/**
|
|
41
|
+
* Reads every id in `PLATFORM_ROLE_IDS`. Throws when any Role
|
|
42
|
+
* record is missing — that means `seed-system-data` has not yet
|
|
43
|
+
* run on this environment, and emitting demo RoleAssignments that
|
|
44
|
+
* reference non-existent Roles would produce orphaned records.
|
|
45
|
+
*/
|
|
46
|
+
readonly verifyRoles: () => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Upserts every Tenant + Workspace in {@link DEMO_TENANT_SPECS},
|
|
49
|
+
* plus per-dev-user Cognito users, DynamoDB User records,
|
|
50
|
+
* Memberships, and RoleAssignments.
|
|
51
|
+
*/
|
|
52
|
+
readonly seedDemoGraph: (params: {
|
|
53
|
+
readonly baseContext: OpenHiContext;
|
|
54
|
+
readonly devUsers: ReadonlyArray<DemoDevUser>;
|
|
55
|
+
readonly cognito: CognitoProvisioner;
|
|
56
|
+
}) => Promise<void>;
|
|
57
|
+
/** Cognito provisioner threaded into `seedDemoGraph`. */
|
|
58
|
+
readonly cognito: CognitoProvisioner;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Upsert the full demo-data graph. Walks each spec in
|
|
62
|
+
* {@link DEMO_TENANT_SPECS}: Tenant → Workspaces. Then per dev user:
|
|
63
|
+
* Cognito user → DynamoDB User → per-tenant Membership +
|
|
64
|
+
* `tenant-admin` RoleAssignment → platform-scoped `system-admin`
|
|
65
|
+
* RoleAssignment. Every put is keyed by a deterministic stable id so
|
|
66
|
+
* re-runs after dedup-TTL expiry upsert the same records.
|
|
67
|
+
*
|
|
68
|
+
* Exported so the seeder test file can exercise it directly against
|
|
69
|
+
* a mocked DynamoControlService; the production handler reaches it
|
|
70
|
+
* through {@link SeedDemoDataDependencies.seedDemoGraph}.
|
|
71
|
+
*/
|
|
72
|
+
declare const seedDemoGraph: (params: {
|
|
73
|
+
baseContext: OpenHiContext;
|
|
74
|
+
devUsers: ReadonlyArray<DemoDevUser>;
|
|
75
|
+
cognito: CognitoProvisioner;
|
|
76
|
+
}) => Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Test-visible orchestrator. The production `handler` calls this with
|
|
79
|
+
* real dependencies and the hardcoded {@link DEV_USERS} list; unit
|
|
80
|
+
* tests inject fakes and pass the dev-user list directly.
|
|
81
|
+
*/
|
|
82
|
+
declare const runSeedDemoData: (event: SeedDemoDataEvent, deps: SeedDemoDataDependencies, devUsers: ReadonlyArray<DemoDevUser>) => Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Deterministic password derived from the user's email. Re-running
|
|
85
|
+
* the algorithm with the same email reproduces the password, so devs
|
|
86
|
+
* can recover their own credentials from the docs page without the
|
|
87
|
+
* workflow ever surfacing them. The shape satisfies the default
|
|
88
|
+
* Cognito password policy (≥8 chars, upper + lower + number + symbol).
|
|
89
|
+
*/
|
|
90
|
+
declare const devPasswordForEmail: (email: string) => string;
|
|
91
|
+
/**
|
|
92
|
+
* Production Cognito provisioner backed by the AWS SDK. Reads the
|
|
93
|
+
* user-pool id from the env var the lambda construct injects.
|
|
94
|
+
*
|
|
95
|
+
* Idempotency contract:
|
|
96
|
+
* - On first invocation, calls `AdminCreateUser` (with
|
|
97
|
+
* `MessageAction: SUPPRESS` so no invitation email fires) then
|
|
98
|
+
* `AdminSetUserPassword` (permanent). Returns the new user's sub.
|
|
99
|
+
* - On subsequent invocations, `AdminCreateUser` throws
|
|
100
|
+
* `UsernameExistsException`; the provisioner catches it, calls
|
|
101
|
+
* `AdminGetUser` to read the existing user's sub, and returns
|
|
102
|
+
* **without** touching the password or any attribute.
|
|
103
|
+
*/
|
|
104
|
+
declare const productionCognitoProvisioner: () => CognitoProvisioner;
|
|
105
|
+
declare const handler: (event: SeedDemoDataEvent) => Promise<void>;
|
|
106
|
+
|
|
107
|
+
export { type CognitoProvisioner, SEED_DEMO_DATA_USER_POOL_ID_ENV_VAR, type SeedDemoDataDependencies, devPasswordForEmail, handler, productionCognitoProvisioner, runSeedDemoData, seedDemoGraph };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { WorkflowDedupClient } from '@openhi/workflows';
|
|
2
|
+
import { EventBridgeEvent } from 'aws-lambda';
|
|
3
|
+
import { d as DemoDevUser } from './events-DPodvl07.js';
|
|
4
|
+
import { O as OpenHiContext } from './openhi-context-CaBH8SFo.js';
|
|
5
|
+
import '@openhi/types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @see sites/www-docs/content/packages/@openhi/constructs/workflows/control-plane/seed-demo-data/seed-demo-data-handler.md
|
|
9
|
+
*
|
|
10
|
+
* EventBridge workflow handler invoked once per platform-deploy event
|
|
11
|
+
* on the control event bus. Pre-flight verifies that
|
|
12
|
+
* `seed-system-data` has already seeded the canonical Role records,
|
|
13
|
+
* then idempotently re-asserts the demo-data graph: the placeholder
|
|
14
|
+
* Tenant + Workspace, the three demo tenants + their workspaces, and
|
|
15
|
+
* for each entry in {@link DEV_USERS} a Cognito user, a DynamoDB User,
|
|
16
|
+
* 4 Memberships, 4 `tenant-admin` RoleAssignments, plus 1
|
|
17
|
+
* platform-scoped `system-admin` RoleAssignment.
|
|
18
|
+
*/
|
|
19
|
+
type SeedDemoDataEvent = EventBridgeEvent<"platform.system-data-seeded.v1", unknown>;
|
|
20
|
+
/** Env var the lambda construct injects with the Cognito User Pool ID. */
|
|
21
|
+
declare const SEED_DEMO_DATA_USER_POOL_ID_ENV_VAR = "SEED_DEMO_DATA_USER_POOL_ID";
|
|
22
|
+
/** Inputs the handler needs to provision Cognito users for every dev. */
|
|
23
|
+
interface CognitoProvisioner {
|
|
24
|
+
/**
|
|
25
|
+
* Ensure a Cognito user exists for `email`. Returns the user's
|
|
26
|
+
* `sub`. Implementations MUST be idempotent: a second invocation
|
|
27
|
+
* for the same email returns the existing user's sub without
|
|
28
|
+
* resetting its password or touching any attribute.
|
|
29
|
+
*/
|
|
30
|
+
readonly ensureUser: (email: string) => Promise<string>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Dependency seam for tests. The factory mirrors the production
|
|
34
|
+
* arrangement: a real DynamoDB client + the real `workflowDedupClient`
|
|
35
|
+
* factory bound to the `OPENHI_WORKFLOW_DEDUP_TABLE_NAME` env var the
|
|
36
|
+
* construct injects via `grantConsumer`.
|
|
37
|
+
*/
|
|
38
|
+
interface SeedDemoDataDependencies {
|
|
39
|
+
readonly dedupClient: WorkflowDedupClient;
|
|
40
|
+
/**
|
|
41
|
+
* Reads every id in `PLATFORM_ROLE_IDS`. Throws when any Role
|
|
42
|
+
* record is missing — that means `seed-system-data` has not yet
|
|
43
|
+
* run on this environment, and emitting demo RoleAssignments that
|
|
44
|
+
* reference non-existent Roles would produce orphaned records.
|
|
45
|
+
*/
|
|
46
|
+
readonly verifyRoles: () => Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Upserts every Tenant + Workspace in {@link DEMO_TENANT_SPECS},
|
|
49
|
+
* plus per-dev-user Cognito users, DynamoDB User records,
|
|
50
|
+
* Memberships, and RoleAssignments.
|
|
51
|
+
*/
|
|
52
|
+
readonly seedDemoGraph: (params: {
|
|
53
|
+
readonly baseContext: OpenHiContext;
|
|
54
|
+
readonly devUsers: ReadonlyArray<DemoDevUser>;
|
|
55
|
+
readonly cognito: CognitoProvisioner;
|
|
56
|
+
}) => Promise<void>;
|
|
57
|
+
/** Cognito provisioner threaded into `seedDemoGraph`. */
|
|
58
|
+
readonly cognito: CognitoProvisioner;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Upsert the full demo-data graph. Walks each spec in
|
|
62
|
+
* {@link DEMO_TENANT_SPECS}: Tenant → Workspaces. Then per dev user:
|
|
63
|
+
* Cognito user → DynamoDB User → per-tenant Membership +
|
|
64
|
+
* `tenant-admin` RoleAssignment → platform-scoped `system-admin`
|
|
65
|
+
* RoleAssignment. Every put is keyed by a deterministic stable id so
|
|
66
|
+
* re-runs after dedup-TTL expiry upsert the same records.
|
|
67
|
+
*
|
|
68
|
+
* Exported so the seeder test file can exercise it directly against
|
|
69
|
+
* a mocked DynamoControlService; the production handler reaches it
|
|
70
|
+
* through {@link SeedDemoDataDependencies.seedDemoGraph}.
|
|
71
|
+
*/
|
|
72
|
+
declare const seedDemoGraph: (params: {
|
|
73
|
+
baseContext: OpenHiContext;
|
|
74
|
+
devUsers: ReadonlyArray<DemoDevUser>;
|
|
75
|
+
cognito: CognitoProvisioner;
|
|
76
|
+
}) => Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Test-visible orchestrator. The production `handler` calls this with
|
|
79
|
+
* real dependencies and the hardcoded {@link DEV_USERS} list; unit
|
|
80
|
+
* tests inject fakes and pass the dev-user list directly.
|
|
81
|
+
*/
|
|
82
|
+
declare const runSeedDemoData: (event: SeedDemoDataEvent, deps: SeedDemoDataDependencies, devUsers: ReadonlyArray<DemoDevUser>) => Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Deterministic password derived from the user's email. Re-running
|
|
85
|
+
* the algorithm with the same email reproduces the password, so devs
|
|
86
|
+
* can recover their own credentials from the docs page without the
|
|
87
|
+
* workflow ever surfacing them. The shape satisfies the default
|
|
88
|
+
* Cognito password policy (≥8 chars, upper + lower + number + symbol).
|
|
89
|
+
*/
|
|
90
|
+
declare const devPasswordForEmail: (email: string) => string;
|
|
91
|
+
/**
|
|
92
|
+
* Production Cognito provisioner backed by the AWS SDK. Reads the
|
|
93
|
+
* user-pool id from the env var the lambda construct injects.
|
|
94
|
+
*
|
|
95
|
+
* Idempotency contract:
|
|
96
|
+
* - On first invocation, calls `AdminCreateUser` (with
|
|
97
|
+
* `MessageAction: SUPPRESS` so no invitation email fires) then
|
|
98
|
+
* `AdminSetUserPassword` (permanent). Returns the new user's sub.
|
|
99
|
+
* - On subsequent invocations, `AdminCreateUser` throws
|
|
100
|
+
* `UsernameExistsException`; the provisioner catches it, calls
|
|
101
|
+
* `AdminGetUser` to read the existing user's sub, and returns
|
|
102
|
+
* **without** touching the password or any attribute.
|
|
103
|
+
*/
|
|
104
|
+
declare const productionCognitoProvisioner: () => CognitoProvisioner;
|
|
105
|
+
declare const handler: (event: SeedDemoDataEvent) => Promise<void>;
|
|
106
|
+
|
|
107
|
+
export { type CognitoProvisioner, SEED_DEMO_DATA_USER_POOL_ID_ENV_VAR, type SeedDemoDataDependencies, devPasswordForEmail, handler, productionCognitoProvisioner, runSeedDemoData, seedDemoGraph };
|