@openhi/constructs 0.0.159 → 0.0.161
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-HQ67J7BP.mjs → chunk-5S6VFBLT.mjs} +12 -70
- package/lib/chunk-5S6VFBLT.mjs.map +1 -0
- package/lib/{chunk-MVQWAIMC.mjs → chunk-6BB4CRSS.mjs} +3 -312
- package/lib/chunk-6BB4CRSS.mjs.map +1 -0
- package/lib/{chunk-WPCBVDFZ.mjs → chunk-76UM2LQ5.mjs} +2 -2
- package/lib/chunk-7TRO2STL.mjs +4616 -0
- package/lib/chunk-7TRO2STL.mjs.map +1 -0
- package/lib/chunk-BUAYVN3C.mjs +87 -0
- package/lib/chunk-BUAYVN3C.mjs.map +1 -0
- package/lib/{chunk-23PUSHBV.mjs → chunk-D2Y6DDOC.mjs} +2 -2
- package/lib/chunk-DWSWCUZR.mjs +123 -0
- package/lib/chunk-DWSWCUZR.mjs.map +1 -0
- package/lib/{chunk-VZCPGQXA.mjs → chunk-EUIP2U5F.mjs} +69 -1
- package/lib/{chunk-VZCPGQXA.mjs.map → chunk-EUIP2U5F.mjs.map} +1 -1
- package/lib/chunk-GJTPXJKD.mjs +46 -0
- package/lib/chunk-GJTPXJKD.mjs.map +1 -0
- package/lib/chunk-I6LUPJUY.mjs +61 -0
- package/lib/chunk-I6LUPJUY.mjs.map +1 -0
- package/lib/{chunk-KR2Y2CVQ.mjs → chunk-KA3OMP3X.mjs} +2 -2
- package/lib/{chunk-ZM4GDHHC.mjs → chunk-KMEWULMX.mjs} +51 -3
- package/lib/chunk-KMEWULMX.mjs.map +1 -0
- package/lib/chunk-LKKLO66E.mjs +25 -0
- package/lib/chunk-LKKLO66E.mjs.map +1 -0
- package/lib/{chunk-CFJDATDK.mjs → chunk-MLFMW5IF.mjs} +43 -9
- package/lib/chunk-MLFMW5IF.mjs.map +1 -0
- package/lib/chunk-O5VQWB6U.mjs +315 -0
- package/lib/chunk-O5VQWB6U.mjs.map +1 -0
- package/lib/{chunk-7BQHLC7U.mjs → chunk-P3CTZWC2.mjs} +8 -40
- package/lib/chunk-P3CTZWC2.mjs.map +1 -0
- package/lib/chunk-P3NFCKTZ.mjs +502 -0
- package/lib/chunk-P3NFCKTZ.mjs.map +1 -0
- package/lib/{chunk-M7Y3BOQW.mjs → chunk-Q3MKITPY.mjs} +5 -5
- package/lib/chunk-Q64MOYJ7.mjs +218 -0
- package/lib/chunk-Q64MOYJ7.mjs.map +1 -0
- package/lib/chunk-RQKJNMX5.mjs +89 -0
- package/lib/chunk-RQKJNMX5.mjs.map +1 -0
- package/lib/{chunk-ZWSGM6PZ.mjs → chunk-SD7J3N3C.mjs} +2 -2
- package/lib/{chunk-7RZHFI77.mjs → chunk-VESULYQQ.mjs} +2 -2
- package/lib/{chunk-AOSEKL7U.mjs → chunk-WOTU36P3.mjs} +6 -103
- package/lib/chunk-WOTU36P3.mjs.map +1 -0
- package/lib/{chunk-X5E4YJGZ.mjs → chunk-YPTJJ35S.mjs} +2 -2
- package/lib/counter-apply-operation-DZM3MIDm.d.mts +63 -0
- package/lib/counter-apply-operation-DZM3MIDm.d.ts +63 -0
- package/lib/counter-maintenance.handler.d.mts +38 -0
- package/lib/counter-maintenance.handler.d.ts +38 -0
- package/lib/counter-maintenance.handler.js +2885 -0
- package/lib/counter-maintenance.handler.js.map +1 -0
- package/lib/counter-maintenance.handler.mjs +180 -0
- package/lib/counter-maintenance.handler.mjs.map +1 -0
- package/lib/counter-reconciliation.handler.d.mts +116 -0
- package/lib/counter-reconciliation.handler.d.ts +116 -0
- package/lib/counter-reconciliation.handler.js +3324 -0
- package/lib/counter-reconciliation.handler.js.map +1 -0
- package/lib/counter-reconciliation.handler.mjs +295 -0
- package/lib/counter-reconciliation.handler.mjs.map +1 -0
- package/lib/data-store-postgres-replication.handler.js +50 -2
- package/lib/data-store-postgres-replication.handler.js.map +1 -1
- package/lib/data-store-postgres-replication.handler.mjs +2 -2
- package/lib/delete-chunk.handler.js +118 -2
- package/lib/delete-chunk.handler.js.map +1 -1
- package/lib/delete-chunk.handler.mjs +3 -3
- package/lib/{events-DTgo2dcW.d.mts → events-TG654e7L.d.mts} +68 -19
- package/lib/{events-DTgo2dcW.d.ts → events-TG654e7L.d.ts} +68 -19
- package/lib/finalize.handler.js +50 -2
- package/lib/finalize.handler.js.map +1 -1
- package/lib/finalize.handler.mjs +4 -4
- package/lib/firehose-archive-transform.handler.js +50 -2
- package/lib/firehose-archive-transform.handler.js.map +1 -1
- package/lib/firehose-archive-transform.handler.mjs +2 -2
- package/lib/index.d.mts +1283 -4
- package/lib/index.d.ts +1389 -24
- package/lib/index.js +4113 -320
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +602 -195
- package/lib/index.mjs.map +1 -1
- package/lib/list-chunks.handler.js +118 -2
- package/lib/list-chunks.handler.js.map +1 -1
- package/lib/list-chunks.handler.mjs +3 -3
- package/lib/platform-deploy-bridge.handler.js +50 -2
- package/lib/platform-deploy-bridge.handler.js.map +1 -1
- package/lib/platform-deploy-bridge.handler.mjs +1 -1
- package/lib/pre-token-generation.handler.js +68 -0
- package/lib/pre-token-generation.handler.js.map +1 -1
- package/lib/pre-token-generation.handler.mjs +9 -5
- package/lib/pre-token-generation.handler.mjs.map +1 -1
- package/lib/provision-default-workspace.handler.js +887 -4
- package/lib/provision-default-workspace.handler.js.map +1 -1
- package/lib/provision-default-workspace.handler.mjs +14 -9
- package/lib/provision-default-workspace.handler.mjs.map +1 -1
- package/lib/rename-finalize.handler.js +50 -2
- package/lib/rename-finalize.handler.js.map +1 -1
- package/lib/rename-finalize.handler.mjs +2 -2
- package/lib/rename-list-targets.handler.js +118 -2
- package/lib/rename-list-targets.handler.js.map +1 -1
- package/lib/rename-list-targets.handler.mjs +11 -9
- package/lib/rename-list-targets.handler.mjs.map +1 -1
- package/lib/rename-rewrite-chunk.handler.js +68 -0
- package/lib/rename-rewrite-chunk.handler.js.map +1 -1
- package/lib/rename-rewrite-chunk.handler.mjs +2 -2
- package/lib/rest-api-lambda.handler.js +1454 -251
- package/lib/rest-api-lambda.handler.js.map +1 -1
- package/lib/rest-api-lambda.handler.mjs +673 -821
- package/lib/rest-api-lambda.handler.mjs.map +1 -1
- package/lib/seed-demo-data.handler.d.mts +1 -1
- package/lib/seed-demo-data.handler.d.ts +1 -1
- package/lib/seed-demo-data.handler.js +4004 -201
- package/lib/seed-demo-data.handler.js.map +1 -1
- package/lib/seed-demo-data.handler.mjs +10 -7
- package/lib/seed-system-data.handler.js +118 -2
- package/lib/seed-system-data.handler.js.map +1 -1
- package/lib/seed-system-data.handler.mjs +5 -5
- package/package.json +1 -1
- package/lib/chunk-7BQHLC7U.mjs.map +0 -1
- package/lib/chunk-AOSEKL7U.mjs.map +0 -1
- package/lib/chunk-BQMJSDOD.mjs +0 -1136
- package/lib/chunk-BQMJSDOD.mjs.map +0 -1
- package/lib/chunk-CFJDATDK.mjs.map +0 -1
- package/lib/chunk-E6MCKJVS.mjs +0 -212
- package/lib/chunk-E6MCKJVS.mjs.map +0 -1
- package/lib/chunk-HQ67J7BP.mjs.map +0 -1
- package/lib/chunk-MVQWAIMC.mjs.map +0 -1
- package/lib/chunk-ZM4GDHHC.mjs.map +0 -1
- /package/lib/{chunk-WPCBVDFZ.mjs.map → chunk-76UM2LQ5.mjs.map} +0 -0
- /package/lib/{chunk-23PUSHBV.mjs.map → chunk-D2Y6DDOC.mjs.map} +0 -0
- /package/lib/{chunk-KR2Y2CVQ.mjs.map → chunk-KA3OMP3X.mjs.map} +0 -0
- /package/lib/{chunk-M7Y3BOQW.mjs.map → chunk-Q3MKITPY.mjs.map} +0 -0
- /package/lib/{chunk-ZWSGM6PZ.mjs.map → chunk-SD7J3N3C.mjs.map} +0 -0
- /package/lib/{chunk-7RZHFI77.mjs.map → chunk-VESULYQQ.mjs.map} +0 -0
- /package/lib/{chunk-X5E4YJGZ.mjs.map → chunk-YPTJJ35S.mjs.map} +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-028 atomic counter mutation against a canonical control-plane
|
|
3
|
+
* record. Each call applies one concurrency-safe DynamoDB `ADD` delta
|
|
4
|
+
* (`+1` on a relationship/lifecycle create, `-1` on delete) to a single
|
|
5
|
+
* named counter attribute on the canonical Tenant / Workspace / User row.
|
|
6
|
+
*
|
|
7
|
+
* The mutation goes through ElectroDB's `patch(key).add({ counter })`,
|
|
8
|
+
* which compiles to a DynamoDB `ADD` update expression — atomic, no
|
|
9
|
+
* read-modify-write. `patch` also stamps an `attribute_exists` guard on
|
|
10
|
+
* the partition key, so a counter is never written onto a phantom /
|
|
11
|
+
* deleted canonical record. Using ElectroDB (rather than a raw
|
|
12
|
+
* `UpdateItemCommand`) keeps the composite-key casing in lockstep with
|
|
13
|
+
* the entity definitions.
|
|
14
|
+
*
|
|
15
|
+
* Floor guard contract (ADR-028 § Floor guard): a `-1` against an
|
|
16
|
+
* absent / `0` counter is clamped to a no-op via a `.where(counter > 0)`
|
|
17
|
+
* condition — when the condition fails ElectroDB throws and the
|
|
18
|
+
* operation swallows it, returning `false`. The guard is a safety net,
|
|
19
|
+
* not the source of truth: ADR-028's reconciliation job recomputes the
|
|
20
|
+
* real value from canonical data and owns correctness.
|
|
21
|
+
*
|
|
22
|
+
* @see sites/www-docs/content/packages/@openhi/constructs/data/operations/control/counters/counter-apply-operation.md
|
|
23
|
+
*/
|
|
24
|
+
/** Counter attribute names per ADR-028, grouped by the canonical record they live on. */
|
|
25
|
+
declare const TENANT_COUNTERS: readonly ["usersInTenant", "workspacesInTenant"];
|
|
26
|
+
declare const WORKSPACE_COUNTERS: readonly ["usersInWorkspace", "adminUsersInWorkspace", "normalUsersInWorkspace"];
|
|
27
|
+
declare const USER_COUNTERS: readonly ["tenantsForUser", "workspacesForUser"];
|
|
28
|
+
type TenantCounter = (typeof TENANT_COUNTERS)[number];
|
|
29
|
+
type WorkspaceCounter = (typeof WORKSPACE_COUNTERS)[number];
|
|
30
|
+
type UserCounter = (typeof USER_COUNTERS)[number];
|
|
31
|
+
/** The `+1` (create) / `-1` (delete) delta direction. */
|
|
32
|
+
type CounterDelta = 1 | -1;
|
|
33
|
+
/** Which canonical entity the counter lives on. */
|
|
34
|
+
declare const COUNTER_TARGET: {
|
|
35
|
+
readonly Tenant: "Tenant";
|
|
36
|
+
readonly Workspace: "Workspace";
|
|
37
|
+
readonly User: "User";
|
|
38
|
+
};
|
|
39
|
+
type CounterTarget = (typeof COUNTER_TARGET)[keyof typeof COUNTER_TARGET];
|
|
40
|
+
/**
|
|
41
|
+
* A resolved counter mutation: which canonical record (target + the
|
|
42
|
+
* ElectroDB composite-key fields that identify it), the attribute, and
|
|
43
|
+
* the delta. The router emits these; the operation applies them.
|
|
44
|
+
*/
|
|
45
|
+
type CounterMutation = {
|
|
46
|
+
readonly target: typeof COUNTER_TARGET.Tenant;
|
|
47
|
+
readonly tenantId: string;
|
|
48
|
+
readonly attribute: TenantCounter;
|
|
49
|
+
readonly delta: CounterDelta;
|
|
50
|
+
} | {
|
|
51
|
+
readonly target: typeof COUNTER_TARGET.Workspace;
|
|
52
|
+
readonly tenantId: string;
|
|
53
|
+
readonly workspaceId: string;
|
|
54
|
+
readonly attribute: WorkspaceCounter;
|
|
55
|
+
readonly delta: CounterDelta;
|
|
56
|
+
} | {
|
|
57
|
+
readonly target: typeof COUNTER_TARGET.User;
|
|
58
|
+
readonly userId: string;
|
|
59
|
+
readonly attribute: UserCounter;
|
|
60
|
+
readonly delta: CounterDelta;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type { CounterMutation as C, CounterTarget as a };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ADR-028 atomic counter mutation against a canonical control-plane
|
|
3
|
+
* record. Each call applies one concurrency-safe DynamoDB `ADD` delta
|
|
4
|
+
* (`+1` on a relationship/lifecycle create, `-1` on delete) to a single
|
|
5
|
+
* named counter attribute on the canonical Tenant / Workspace / User row.
|
|
6
|
+
*
|
|
7
|
+
* The mutation goes through ElectroDB's `patch(key).add({ counter })`,
|
|
8
|
+
* which compiles to a DynamoDB `ADD` update expression — atomic, no
|
|
9
|
+
* read-modify-write. `patch` also stamps an `attribute_exists` guard on
|
|
10
|
+
* the partition key, so a counter is never written onto a phantom /
|
|
11
|
+
* deleted canonical record. Using ElectroDB (rather than a raw
|
|
12
|
+
* `UpdateItemCommand`) keeps the composite-key casing in lockstep with
|
|
13
|
+
* the entity definitions.
|
|
14
|
+
*
|
|
15
|
+
* Floor guard contract (ADR-028 § Floor guard): a `-1` against an
|
|
16
|
+
* absent / `0` counter is clamped to a no-op via a `.where(counter > 0)`
|
|
17
|
+
* condition — when the condition fails ElectroDB throws and the
|
|
18
|
+
* operation swallows it, returning `false`. The guard is a safety net,
|
|
19
|
+
* not the source of truth: ADR-028's reconciliation job recomputes the
|
|
20
|
+
* real value from canonical data and owns correctness.
|
|
21
|
+
*
|
|
22
|
+
* @see sites/www-docs/content/packages/@openhi/constructs/data/operations/control/counters/counter-apply-operation.md
|
|
23
|
+
*/
|
|
24
|
+
/** Counter attribute names per ADR-028, grouped by the canonical record they live on. */
|
|
25
|
+
declare const TENANT_COUNTERS: readonly ["usersInTenant", "workspacesInTenant"];
|
|
26
|
+
declare const WORKSPACE_COUNTERS: readonly ["usersInWorkspace", "adminUsersInWorkspace", "normalUsersInWorkspace"];
|
|
27
|
+
declare const USER_COUNTERS: readonly ["tenantsForUser", "workspacesForUser"];
|
|
28
|
+
type TenantCounter = (typeof TENANT_COUNTERS)[number];
|
|
29
|
+
type WorkspaceCounter = (typeof WORKSPACE_COUNTERS)[number];
|
|
30
|
+
type UserCounter = (typeof USER_COUNTERS)[number];
|
|
31
|
+
/** The `+1` (create) / `-1` (delete) delta direction. */
|
|
32
|
+
type CounterDelta = 1 | -1;
|
|
33
|
+
/** Which canonical entity the counter lives on. */
|
|
34
|
+
declare const COUNTER_TARGET: {
|
|
35
|
+
readonly Tenant: "Tenant";
|
|
36
|
+
readonly Workspace: "Workspace";
|
|
37
|
+
readonly User: "User";
|
|
38
|
+
};
|
|
39
|
+
type CounterTarget = (typeof COUNTER_TARGET)[keyof typeof COUNTER_TARGET];
|
|
40
|
+
/**
|
|
41
|
+
* A resolved counter mutation: which canonical record (target + the
|
|
42
|
+
* ElectroDB composite-key fields that identify it), the attribute, and
|
|
43
|
+
* the delta. The router emits these; the operation applies them.
|
|
44
|
+
*/
|
|
45
|
+
type CounterMutation = {
|
|
46
|
+
readonly target: typeof COUNTER_TARGET.Tenant;
|
|
47
|
+
readonly tenantId: string;
|
|
48
|
+
readonly attribute: TenantCounter;
|
|
49
|
+
readonly delta: CounterDelta;
|
|
50
|
+
} | {
|
|
51
|
+
readonly target: typeof COUNTER_TARGET.Workspace;
|
|
52
|
+
readonly tenantId: string;
|
|
53
|
+
readonly workspaceId: string;
|
|
54
|
+
readonly attribute: WorkspaceCounter;
|
|
55
|
+
readonly delta: CounterDelta;
|
|
56
|
+
} | {
|
|
57
|
+
readonly target: typeof COUNTER_TARGET.User;
|
|
58
|
+
readonly userId: string;
|
|
59
|
+
readonly attribute: UserCounter;
|
|
60
|
+
readonly delta: CounterDelta;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export type { CounterMutation as C, CounterTarget as a };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { WorkflowDedupClient } from '@openhi/workflows';
|
|
2
|
+
import { EventBridgeEvent } from 'aws-lambda';
|
|
3
|
+
import { C as CounterMutation } from './counter-apply-operation-DZM3MIDm.mjs';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @see sites/www-docs/content/packages/@openhi/constructs/workflows/control-plane/counter-maintenance/counter-maintenance-handler.md
|
|
7
|
+
*
|
|
8
|
+
* ADR-028 counter-maintenance consumer. Invoked once per control-plane
|
|
9
|
+
* domain event on the control event bus. Dedupes the event on
|
|
10
|
+
* `(consumerName, eventId, attempt)` via the TR-015 `WorkflowDedupTable`,
|
|
11
|
+
* then applies the resolved atomic-ADD counter deltas to the affected
|
|
12
|
+
* canonical Tenant / Workspace / User records.
|
|
13
|
+
*
|
|
14
|
+
* Idempotency: an atomic ADD is not idempotent, so a replayed event must
|
|
15
|
+
* be a no-op. `recordIfAbsent` is the circuit-breaker — when it returns
|
|
16
|
+
* `recorded: false` a prior delivery of this exact `(eventId, attempt)`
|
|
17
|
+
* already applied the deltas, so the handler exits without re-applying.
|
|
18
|
+
* The dedup write happens-before the counter mutations, exactly as
|
|
19
|
+
* ADR-028 § Consume requires.
|
|
20
|
+
*/
|
|
21
|
+
type CounterMaintenanceEvent = EventBridgeEvent<string, unknown>;
|
|
22
|
+
/** Dependency seam for tests; production wires the real dedup client. */
|
|
23
|
+
interface CounterMaintenanceDependencies {
|
|
24
|
+
readonly dedupClient: WorkflowDedupClient;
|
|
25
|
+
/**
|
|
26
|
+
* Apply one resolved counter mutation. Defaults to
|
|
27
|
+
* {@link applyCounterDeltaOperation}; tests inject a spy.
|
|
28
|
+
*/
|
|
29
|
+
readonly applyMutation: (mutation: CounterMutation) => Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Test-visible orchestrator. The production `handler` calls this with
|
|
33
|
+
* real dependencies; unit tests inject fakes.
|
|
34
|
+
*/
|
|
35
|
+
declare const runCounterMaintenance: (event: CounterMaintenanceEvent, deps: CounterMaintenanceDependencies) => Promise<void>;
|
|
36
|
+
declare const handler: (event: CounterMaintenanceEvent) => Promise<void>;
|
|
37
|
+
|
|
38
|
+
export { type CounterMaintenanceDependencies, handler, runCounterMaintenance };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { WorkflowDedupClient } from '@openhi/workflows';
|
|
2
|
+
import { EventBridgeEvent } from 'aws-lambda';
|
|
3
|
+
import { C as CounterMutation } from './counter-apply-operation-DZM3MIDm.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @see sites/www-docs/content/packages/@openhi/constructs/workflows/control-plane/counter-maintenance/counter-maintenance-handler.md
|
|
7
|
+
*
|
|
8
|
+
* ADR-028 counter-maintenance consumer. Invoked once per control-plane
|
|
9
|
+
* domain event on the control event bus. Dedupes the event on
|
|
10
|
+
* `(consumerName, eventId, attempt)` via the TR-015 `WorkflowDedupTable`,
|
|
11
|
+
* then applies the resolved atomic-ADD counter deltas to the affected
|
|
12
|
+
* canonical Tenant / Workspace / User records.
|
|
13
|
+
*
|
|
14
|
+
* Idempotency: an atomic ADD is not idempotent, so a replayed event must
|
|
15
|
+
* be a no-op. `recordIfAbsent` is the circuit-breaker — when it returns
|
|
16
|
+
* `recorded: false` a prior delivery of this exact `(eventId, attempt)`
|
|
17
|
+
* already applied the deltas, so the handler exits without re-applying.
|
|
18
|
+
* The dedup write happens-before the counter mutations, exactly as
|
|
19
|
+
* ADR-028 § Consume requires.
|
|
20
|
+
*/
|
|
21
|
+
type CounterMaintenanceEvent = EventBridgeEvent<string, unknown>;
|
|
22
|
+
/** Dependency seam for tests; production wires the real dedup client. */
|
|
23
|
+
interface CounterMaintenanceDependencies {
|
|
24
|
+
readonly dedupClient: WorkflowDedupClient;
|
|
25
|
+
/**
|
|
26
|
+
* Apply one resolved counter mutation. Defaults to
|
|
27
|
+
* {@link applyCounterDeltaOperation}; tests inject a spy.
|
|
28
|
+
*/
|
|
29
|
+
readonly applyMutation: (mutation: CounterMutation) => Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Test-visible orchestrator. The production `handler` calls this with
|
|
33
|
+
* real dependencies; unit tests inject fakes.
|
|
34
|
+
*/
|
|
35
|
+
declare const runCounterMaintenance: (event: CounterMaintenanceEvent, deps: CounterMaintenanceDependencies) => Promise<void>;
|
|
36
|
+
declare const handler: (event: CounterMaintenanceEvent) => Promise<void>;
|
|
37
|
+
|
|
38
|
+
export { type CounterMaintenanceDependencies, handler, runCounterMaintenance };
|