@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.
Files changed (129) hide show
  1. package/lib/{chunk-HQ67J7BP.mjs → chunk-5S6VFBLT.mjs} +12 -70
  2. package/lib/chunk-5S6VFBLT.mjs.map +1 -0
  3. package/lib/{chunk-MVQWAIMC.mjs → chunk-6BB4CRSS.mjs} +3 -312
  4. package/lib/chunk-6BB4CRSS.mjs.map +1 -0
  5. package/lib/{chunk-WPCBVDFZ.mjs → chunk-76UM2LQ5.mjs} +2 -2
  6. package/lib/chunk-7TRO2STL.mjs +4616 -0
  7. package/lib/chunk-7TRO2STL.mjs.map +1 -0
  8. package/lib/chunk-BUAYVN3C.mjs +87 -0
  9. package/lib/chunk-BUAYVN3C.mjs.map +1 -0
  10. package/lib/{chunk-23PUSHBV.mjs → chunk-D2Y6DDOC.mjs} +2 -2
  11. package/lib/chunk-DWSWCUZR.mjs +123 -0
  12. package/lib/chunk-DWSWCUZR.mjs.map +1 -0
  13. package/lib/{chunk-VZCPGQXA.mjs → chunk-EUIP2U5F.mjs} +69 -1
  14. package/lib/{chunk-VZCPGQXA.mjs.map → chunk-EUIP2U5F.mjs.map} +1 -1
  15. package/lib/chunk-GJTPXJKD.mjs +46 -0
  16. package/lib/chunk-GJTPXJKD.mjs.map +1 -0
  17. package/lib/chunk-I6LUPJUY.mjs +61 -0
  18. package/lib/chunk-I6LUPJUY.mjs.map +1 -0
  19. package/lib/{chunk-KR2Y2CVQ.mjs → chunk-KA3OMP3X.mjs} +2 -2
  20. package/lib/{chunk-ZM4GDHHC.mjs → chunk-KMEWULMX.mjs} +51 -3
  21. package/lib/chunk-KMEWULMX.mjs.map +1 -0
  22. package/lib/chunk-LKKLO66E.mjs +25 -0
  23. package/lib/chunk-LKKLO66E.mjs.map +1 -0
  24. package/lib/{chunk-CFJDATDK.mjs → chunk-MLFMW5IF.mjs} +43 -9
  25. package/lib/chunk-MLFMW5IF.mjs.map +1 -0
  26. package/lib/chunk-O5VQWB6U.mjs +315 -0
  27. package/lib/chunk-O5VQWB6U.mjs.map +1 -0
  28. package/lib/{chunk-7BQHLC7U.mjs → chunk-P3CTZWC2.mjs} +8 -40
  29. package/lib/chunk-P3CTZWC2.mjs.map +1 -0
  30. package/lib/chunk-P3NFCKTZ.mjs +502 -0
  31. package/lib/chunk-P3NFCKTZ.mjs.map +1 -0
  32. package/lib/{chunk-M7Y3BOQW.mjs → chunk-Q3MKITPY.mjs} +5 -5
  33. package/lib/chunk-Q64MOYJ7.mjs +218 -0
  34. package/lib/chunk-Q64MOYJ7.mjs.map +1 -0
  35. package/lib/chunk-RQKJNMX5.mjs +89 -0
  36. package/lib/chunk-RQKJNMX5.mjs.map +1 -0
  37. package/lib/{chunk-ZWSGM6PZ.mjs → chunk-SD7J3N3C.mjs} +2 -2
  38. package/lib/{chunk-7RZHFI77.mjs → chunk-VESULYQQ.mjs} +2 -2
  39. package/lib/{chunk-AOSEKL7U.mjs → chunk-WOTU36P3.mjs} +6 -103
  40. package/lib/chunk-WOTU36P3.mjs.map +1 -0
  41. package/lib/{chunk-X5E4YJGZ.mjs → chunk-YPTJJ35S.mjs} +2 -2
  42. package/lib/counter-apply-operation-DZM3MIDm.d.mts +63 -0
  43. package/lib/counter-apply-operation-DZM3MIDm.d.ts +63 -0
  44. package/lib/counter-maintenance.handler.d.mts +38 -0
  45. package/lib/counter-maintenance.handler.d.ts +38 -0
  46. package/lib/counter-maintenance.handler.js +2885 -0
  47. package/lib/counter-maintenance.handler.js.map +1 -0
  48. package/lib/counter-maintenance.handler.mjs +180 -0
  49. package/lib/counter-maintenance.handler.mjs.map +1 -0
  50. package/lib/counter-reconciliation.handler.d.mts +116 -0
  51. package/lib/counter-reconciliation.handler.d.ts +116 -0
  52. package/lib/counter-reconciliation.handler.js +3324 -0
  53. package/lib/counter-reconciliation.handler.js.map +1 -0
  54. package/lib/counter-reconciliation.handler.mjs +295 -0
  55. package/lib/counter-reconciliation.handler.mjs.map +1 -0
  56. package/lib/data-store-postgres-replication.handler.js +50 -2
  57. package/lib/data-store-postgres-replication.handler.js.map +1 -1
  58. package/lib/data-store-postgres-replication.handler.mjs +2 -2
  59. package/lib/delete-chunk.handler.js +118 -2
  60. package/lib/delete-chunk.handler.js.map +1 -1
  61. package/lib/delete-chunk.handler.mjs +3 -3
  62. package/lib/{events-DTgo2dcW.d.mts → events-TG654e7L.d.mts} +68 -19
  63. package/lib/{events-DTgo2dcW.d.ts → events-TG654e7L.d.ts} +68 -19
  64. package/lib/finalize.handler.js +50 -2
  65. package/lib/finalize.handler.js.map +1 -1
  66. package/lib/finalize.handler.mjs +4 -4
  67. package/lib/firehose-archive-transform.handler.js +50 -2
  68. package/lib/firehose-archive-transform.handler.js.map +1 -1
  69. package/lib/firehose-archive-transform.handler.mjs +2 -2
  70. package/lib/index.d.mts +1283 -4
  71. package/lib/index.d.ts +1389 -24
  72. package/lib/index.js +4113 -320
  73. package/lib/index.js.map +1 -1
  74. package/lib/index.mjs +602 -195
  75. package/lib/index.mjs.map +1 -1
  76. package/lib/list-chunks.handler.js +118 -2
  77. package/lib/list-chunks.handler.js.map +1 -1
  78. package/lib/list-chunks.handler.mjs +3 -3
  79. package/lib/platform-deploy-bridge.handler.js +50 -2
  80. package/lib/platform-deploy-bridge.handler.js.map +1 -1
  81. package/lib/platform-deploy-bridge.handler.mjs +1 -1
  82. package/lib/pre-token-generation.handler.js +68 -0
  83. package/lib/pre-token-generation.handler.js.map +1 -1
  84. package/lib/pre-token-generation.handler.mjs +9 -5
  85. package/lib/pre-token-generation.handler.mjs.map +1 -1
  86. package/lib/provision-default-workspace.handler.js +887 -4
  87. package/lib/provision-default-workspace.handler.js.map +1 -1
  88. package/lib/provision-default-workspace.handler.mjs +14 -9
  89. package/lib/provision-default-workspace.handler.mjs.map +1 -1
  90. package/lib/rename-finalize.handler.js +50 -2
  91. package/lib/rename-finalize.handler.js.map +1 -1
  92. package/lib/rename-finalize.handler.mjs +2 -2
  93. package/lib/rename-list-targets.handler.js +118 -2
  94. package/lib/rename-list-targets.handler.js.map +1 -1
  95. package/lib/rename-list-targets.handler.mjs +11 -9
  96. package/lib/rename-list-targets.handler.mjs.map +1 -1
  97. package/lib/rename-rewrite-chunk.handler.js +68 -0
  98. package/lib/rename-rewrite-chunk.handler.js.map +1 -1
  99. package/lib/rename-rewrite-chunk.handler.mjs +2 -2
  100. package/lib/rest-api-lambda.handler.js +1454 -251
  101. package/lib/rest-api-lambda.handler.js.map +1 -1
  102. package/lib/rest-api-lambda.handler.mjs +673 -821
  103. package/lib/rest-api-lambda.handler.mjs.map +1 -1
  104. package/lib/seed-demo-data.handler.d.mts +1 -1
  105. package/lib/seed-demo-data.handler.d.ts +1 -1
  106. package/lib/seed-demo-data.handler.js +4004 -201
  107. package/lib/seed-demo-data.handler.js.map +1 -1
  108. package/lib/seed-demo-data.handler.mjs +10 -7
  109. package/lib/seed-system-data.handler.js +118 -2
  110. package/lib/seed-system-data.handler.js.map +1 -1
  111. package/lib/seed-system-data.handler.mjs +5 -5
  112. package/package.json +1 -1
  113. package/lib/chunk-7BQHLC7U.mjs.map +0 -1
  114. package/lib/chunk-AOSEKL7U.mjs.map +0 -1
  115. package/lib/chunk-BQMJSDOD.mjs +0 -1136
  116. package/lib/chunk-BQMJSDOD.mjs.map +0 -1
  117. package/lib/chunk-CFJDATDK.mjs.map +0 -1
  118. package/lib/chunk-E6MCKJVS.mjs +0 -212
  119. package/lib/chunk-E6MCKJVS.mjs.map +0 -1
  120. package/lib/chunk-HQ67J7BP.mjs.map +0 -1
  121. package/lib/chunk-MVQWAIMC.mjs.map +0 -1
  122. package/lib/chunk-ZM4GDHHC.mjs.map +0 -1
  123. /package/lib/{chunk-WPCBVDFZ.mjs.map → chunk-76UM2LQ5.mjs.map} +0 -0
  124. /package/lib/{chunk-23PUSHBV.mjs.map → chunk-D2Y6DDOC.mjs.map} +0 -0
  125. /package/lib/{chunk-KR2Y2CVQ.mjs.map → chunk-KA3OMP3X.mjs.map} +0 -0
  126. /package/lib/{chunk-M7Y3BOQW.mjs.map → chunk-Q3MKITPY.mjs.map} +0 -0
  127. /package/lib/{chunk-ZWSGM6PZ.mjs.map → chunk-SD7J3N3C.mjs.map} +0 -0
  128. /package/lib/{chunk-7RZHFI77.mjs.map → chunk-VESULYQQ.mjs.map} +0 -0
  129. /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 };