@openhi/constructs 0.0.90 → 0.0.92

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.
@@ -0,0 +1,807 @@
1
+ // src/data/dynamo/dynamo-control-service.ts
2
+ import { Service } from "electrodb";
3
+
4
+ // src/data/dynamo/dynamo-client.ts
5
+ import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
6
+ var defaultTableName = process.env.DYNAMO_TABLE_NAME ?? "jesttesttable";
7
+ var dynamoClient = new DynamoDBClient({
8
+ ...process.env.MOCK_DYNAMODB_ENDPOINT && {
9
+ endpoint: process.env.MOCK_DYNAMODB_ENDPOINT,
10
+ sslEnabled: false,
11
+ region: "local"
12
+ }
13
+ });
14
+
15
+ // src/data/dynamo/entities/control/configuration-entity.ts
16
+ import { Entity } from "electrodb";
17
+
18
+ // src/data/dynamo/shard.ts
19
+ var SHARD_COUNT = 4;
20
+ function computeShard(id) {
21
+ let hash = 2166136261;
22
+ for (let i = 0; i < id.length; i++) {
23
+ hash ^= id.charCodeAt(i);
24
+ hash = Math.imul(hash, 16777619);
25
+ }
26
+ return (hash >>> 0) % SHARD_COUNT;
27
+ }
28
+
29
+ // src/data/dynamo/entities/control/control-entity-common.ts
30
+ var gsi1ShardAttribute = {
31
+ type: "string",
32
+ watch: ["id"],
33
+ set: (_val, item) => {
34
+ if (typeof item?.id !== "string" || item.id.length === 0) {
35
+ return void 0;
36
+ }
37
+ return String(computeShard(item.id));
38
+ }
39
+ };
40
+
41
+ // src/data/dynamo/entities/control/configuration-entity.ts
42
+ var ConfigurationEntity = new Entity({
43
+ model: {
44
+ entity: "configuration",
45
+ service: "control",
46
+ version: "01"
47
+ },
48
+ attributes: {
49
+ /** Sort key. "CURRENT" for current version; version history in S3. */
50
+ sk: {
51
+ type: "string",
52
+ required: true,
53
+ default: "CURRENT"
54
+ },
55
+ /** Tenant scope. Use "BASELINE" when the config is baseline default (no tenant). */
56
+ tenantId: {
57
+ type: "string",
58
+ required: true,
59
+ default: "BASELINE"
60
+ },
61
+ /** Workspace scope. Use "-" when absent. */
62
+ workspaceId: {
63
+ type: "string",
64
+ required: true,
65
+ default: "-"
66
+ },
67
+ /** User scope. Use "-" when absent. */
68
+ userId: {
69
+ type: "string",
70
+ required: true,
71
+ default: "-"
72
+ },
73
+ /** Role scope. Use "-" when absent. */
74
+ roleId: {
75
+ type: "string",
76
+ required: true,
77
+ default: "-"
78
+ },
79
+ /** Config type (category), e.g. endpoints, branding, display. */
80
+ key: {
81
+ type: "string",
82
+ required: true
83
+ },
84
+ /** FHIR Resource.id; logical id in URL and for the Configuration resource. */
85
+ id: {
86
+ type: "string",
87
+ required: true
88
+ },
89
+ /** Payload as JSON string. JSON.stringify(resource) on write; JSON.parse(item.resource) on read. */
90
+ resource: {
91
+ type: "string",
92
+ required: true
93
+ },
94
+ /**
95
+ * Summary projection (key display fields as JSON string: id, key, status).
96
+ * Populated on every write via extractSummary(resource); GSI1 INCLUDE surfaces it on lists.
97
+ */
98
+ summary: {
99
+ type: "string",
100
+ required: true
101
+ },
102
+ /** Version id (e.g. ULID). Tracks current version; S3 history key. */
103
+ vid: {
104
+ type: "string",
105
+ required: true
106
+ },
107
+ lastUpdated: {
108
+ type: "string",
109
+ required: true
110
+ },
111
+ gsi1Shard: gsi1ShardAttribute,
112
+ deleted: {
113
+ type: "boolean",
114
+ required: false
115
+ },
116
+ bundleId: {
117
+ type: "string",
118
+ required: false
119
+ },
120
+ msgId: {
121
+ type: "string",
122
+ required: false
123
+ }
124
+ },
125
+ indexes: {
126
+ /** Base table: PK, SK (data store key names). PK is built from tenantId, workspaceId, userId, roleId; SK is built from key and sk. Do not supply PK or SK from outside. */
127
+ record: {
128
+ pk: {
129
+ field: "PK",
130
+ composite: ["tenantId", "workspaceId", "userId", "roleId"],
131
+ template: "CONFIG#TID#${tenantId}#WID#${workspaceId}#UID#${userId}#RID#${roleId}"
132
+ },
133
+ sk: {
134
+ field: "SK",
135
+ composite: ["key", "sk"],
136
+ template: "KEY#${key}#SK#${sk}"
137
+ }
138
+ },
139
+ /**
140
+ * GSI1 — Unified Sharded List per ADR-011: list all Configuration entries for a
141
+ * (tenant, workspace) across the four shards. Use for "list configs scoped to this tenant"
142
+ * (workspaceId = "-") or "list configs scoped to this workspace". Does not support
143
+ * hierarchical resolution in one query; use base table GetItem in fallback order
144
+ * (user → workspace → tenant → baseline) for that.
145
+ * SK is `<ISO-8601 lastUpdated>#<id>` (control-plane unlabeled per DR-004).
146
+ * `casing: "none"` on the SK preserves ISO-8601 `T`/`Z`.
147
+ */
148
+ gsi1: {
149
+ index: "GSI1",
150
+ pk: {
151
+ field: "GSI1PK",
152
+ composite: ["tenantId", "workspaceId", "gsi1Shard"],
153
+ template: "TID#${tenantId}#WID#${workspaceId}#RT#Configuration#SHARD#${gsi1Shard}"
154
+ },
155
+ sk: {
156
+ field: "GSI1SK",
157
+ casing: "none",
158
+ composite: ["lastUpdated", "id"],
159
+ template: "${lastUpdated}#${id}"
160
+ }
161
+ }
162
+ }
163
+ });
164
+
165
+ // src/data/dynamo/entities/control/membership-entity.ts
166
+ import { Entity as Entity2 } from "electrodb";
167
+ var MembershipEntity = new Entity2({
168
+ model: {
169
+ entity: "membership",
170
+ service: "control",
171
+ version: "01"
172
+ },
173
+ attributes: {
174
+ /** Sort key sentinel. Always "CURRENT". */
175
+ sk: {
176
+ type: "string",
177
+ required: true,
178
+ default: "CURRENT"
179
+ },
180
+ /** Tenant in which the user has membership (required). */
181
+ tenantId: {
182
+ type: "string",
183
+ required: true
184
+ },
185
+ /** FHIR Resource.id; membership id. */
186
+ id: {
187
+ type: "string",
188
+ required: true
189
+ },
190
+ /** Full Membership resource serialized as JSON string. */
191
+ resource: {
192
+ type: "string",
193
+ required: true
194
+ },
195
+ /**
196
+ * Summary projection (key display fields as JSON string: id, displayName, status).
197
+ * Populated on every write via extractSummary(resource); GSI1 INCLUDE surfaces it on lists.
198
+ */
199
+ summary: {
200
+ type: "string",
201
+ required: true
202
+ },
203
+ /** Version id (e.g. ULID). */
204
+ vid: {
205
+ type: "string",
206
+ required: true
207
+ },
208
+ lastUpdated: {
209
+ type: "string",
210
+ required: true
211
+ },
212
+ gsi1Shard: gsi1ShardAttribute,
213
+ deleted: {
214
+ type: "boolean",
215
+ required: false
216
+ },
217
+ bundleId: {
218
+ type: "string",
219
+ required: false
220
+ },
221
+ msgId: {
222
+ type: "string",
223
+ required: false
224
+ }
225
+ },
226
+ indexes: {
227
+ /** Base table: PK = TID#<tenantId>#MEMBERSHIP#ID#<id>, SK = CURRENT. Do not supply PK or SK from outside. */
228
+ record: {
229
+ pk: {
230
+ field: "PK",
231
+ composite: ["tenantId", "id"],
232
+ template: "TID#${tenantId}#MEMBERSHIP#ID#${id}"
233
+ },
234
+ sk: {
235
+ field: "SK",
236
+ composite: ["sk"],
237
+ template: "${sk}"
238
+ }
239
+ },
240
+ /**
241
+ * GSI1 — Unified Sharded List per ADR-011: list all Memberships for a tenant across the
242
+ * four shards. Membership is tenant-scoped only, so `WID#-` is a sentinel.
243
+ * SK is `<ISO-8601 lastUpdated>#<id>` (control-plane unlabeled per DR-004).
244
+ * `casing: "none"` on the SK preserves ISO-8601 `T`/`Z`.
245
+ */
246
+ gsi1: {
247
+ index: "GSI1",
248
+ pk: {
249
+ field: "GSI1PK",
250
+ composite: ["tenantId", "gsi1Shard"],
251
+ template: "TID#${tenantId}#WID#-#RT#Membership#SHARD#${gsi1Shard}"
252
+ },
253
+ sk: {
254
+ field: "GSI1SK",
255
+ casing: "none",
256
+ composite: ["lastUpdated", "id"],
257
+ template: "${lastUpdated}#${id}"
258
+ }
259
+ }
260
+ }
261
+ });
262
+
263
+ // src/data/dynamo/entities/control/role-entity.ts
264
+ import { Entity as Entity3 } from "electrodb";
265
+ var RoleEntity = new Entity3({
266
+ model: {
267
+ entity: "role",
268
+ service: "control",
269
+ version: "01"
270
+ },
271
+ attributes: {
272
+ /** Sort key sentinel. Always "CURRENT". */
273
+ sk: {
274
+ type: "string",
275
+ required: true,
276
+ default: "CURRENT"
277
+ },
278
+ /** FHIR Resource.id; role id. */
279
+ id: {
280
+ type: "string",
281
+ required: true
282
+ },
283
+ /** Full Role resource serialized as JSON string. */
284
+ resource: {
285
+ type: "string",
286
+ required: true
287
+ },
288
+ /**
289
+ * Summary projection (key display fields as JSON string: id, displayName, status).
290
+ * Populated on every write via extractSummary(resource); GSI1 INCLUDE surfaces it on lists.
291
+ */
292
+ summary: {
293
+ type: "string",
294
+ required: true
295
+ },
296
+ /** Version id (e.g. ULID). */
297
+ vid: {
298
+ type: "string",
299
+ required: true
300
+ },
301
+ lastUpdated: {
302
+ type: "string",
303
+ required: true
304
+ },
305
+ gsi1Shard: gsi1ShardAttribute,
306
+ deleted: {
307
+ type: "boolean",
308
+ required: false
309
+ },
310
+ bundleId: {
311
+ type: "string",
312
+ required: false
313
+ },
314
+ msgId: {
315
+ type: "string",
316
+ required: false
317
+ }
318
+ },
319
+ indexes: {
320
+ /** Base table: PK = ROLE#ID#<id>, SK = CURRENT. Do not supply PK or SK from outside. */
321
+ record: {
322
+ pk: {
323
+ field: "PK",
324
+ composite: ["id"],
325
+ template: "ROLE#ID#${id}"
326
+ },
327
+ sk: {
328
+ field: "SK",
329
+ composite: ["sk"],
330
+ template: "${sk}"
331
+ }
332
+ },
333
+ /**
334
+ * GSI1 — Unified Sharded List per ADR-011: list all Roles across the four shards.
335
+ * Non-tenant-isolated, so `TID#-#WID#-` sentinels precede `RT#Role#SHARD#<n>`.
336
+ * SK is `<ISO-8601 lastUpdated>#<id>` (control-plane unlabeled per DR-004).
337
+ * `casing: "none"` on the SK preserves ISO-8601 `T`/`Z`.
338
+ */
339
+ gsi1: {
340
+ index: "GSI1",
341
+ pk: {
342
+ field: "GSI1PK",
343
+ composite: ["gsi1Shard"],
344
+ template: "TID#-#WID#-#RT#Role#SHARD#${gsi1Shard}"
345
+ },
346
+ sk: {
347
+ field: "GSI1SK",
348
+ casing: "none",
349
+ composite: ["lastUpdated", "id"],
350
+ template: "${lastUpdated}#${id}"
351
+ }
352
+ }
353
+ }
354
+ });
355
+
356
+ // src/data/dynamo/entities/control/roleassignment-entity.ts
357
+ import { Entity as Entity4 } from "electrodb";
358
+ var RoleAssignmentEntity = new Entity4({
359
+ model: {
360
+ entity: "roleassignment",
361
+ service: "control",
362
+ version: "01"
363
+ },
364
+ attributes: {
365
+ /** Sort key sentinel. Always "CURRENT". */
366
+ sk: {
367
+ type: "string",
368
+ required: true,
369
+ default: "CURRENT"
370
+ },
371
+ /** Tenant in which the role assignment applies (required). */
372
+ tenantId: {
373
+ type: "string",
374
+ required: true
375
+ },
376
+ /** FHIR Resource.id; role assignment id. */
377
+ id: {
378
+ type: "string",
379
+ required: true
380
+ },
381
+ /** Full RoleAssignment resource serialized as JSON string. */
382
+ resource: {
383
+ type: "string",
384
+ required: true
385
+ },
386
+ /**
387
+ * Summary projection (key display fields as JSON string: id, displayName, status).
388
+ * Populated on every write via extractSummary(resource); GSI1 INCLUDE surfaces it on lists.
389
+ */
390
+ summary: {
391
+ type: "string",
392
+ required: true
393
+ },
394
+ /** Version id (e.g. ULID). */
395
+ vid: {
396
+ type: "string",
397
+ required: true
398
+ },
399
+ lastUpdated: {
400
+ type: "string",
401
+ required: true
402
+ },
403
+ gsi1Shard: gsi1ShardAttribute,
404
+ deleted: {
405
+ type: "boolean",
406
+ required: false
407
+ },
408
+ bundleId: {
409
+ type: "string",
410
+ required: false
411
+ },
412
+ msgId: {
413
+ type: "string",
414
+ required: false
415
+ }
416
+ },
417
+ indexes: {
418
+ /** Base table: PK = TID#<tenantId>#ROLEASSIGNMENT#ID#<id>, SK = CURRENT. Do not supply PK or SK from outside. */
419
+ record: {
420
+ pk: {
421
+ field: "PK",
422
+ composite: ["tenantId", "id"],
423
+ template: "TID#${tenantId}#ROLEASSIGNMENT#ID#${id}"
424
+ },
425
+ sk: {
426
+ field: "SK",
427
+ composite: ["sk"],
428
+ template: "${sk}"
429
+ }
430
+ },
431
+ /**
432
+ * GSI1 — Unified Sharded List per ADR-011: list all RoleAssignments for a tenant across the
433
+ * four shards. Tenant-scoped only, so `WID#-` is a sentinel.
434
+ * SK is `<ISO-8601 lastUpdated>#<id>` (control-plane unlabeled per DR-004).
435
+ * `casing: "none"` on the SK preserves ISO-8601 `T`/`Z`.
436
+ */
437
+ gsi1: {
438
+ index: "GSI1",
439
+ pk: {
440
+ field: "GSI1PK",
441
+ composite: ["tenantId", "gsi1Shard"],
442
+ template: "TID#${tenantId}#WID#-#RT#RoleAssignment#SHARD#${gsi1Shard}"
443
+ },
444
+ sk: {
445
+ field: "GSI1SK",
446
+ casing: "none",
447
+ composite: ["lastUpdated", "id"],
448
+ template: "${lastUpdated}#${id}"
449
+ }
450
+ }
451
+ }
452
+ });
453
+
454
+ // src/data/dynamo/entities/control/tenant-entity.ts
455
+ import { Entity as Entity5 } from "electrodb";
456
+ var TenantEntity = new Entity5({
457
+ model: {
458
+ entity: "tenant",
459
+ service: "control",
460
+ version: "01"
461
+ },
462
+ attributes: {
463
+ /** Sort key sentinel. Always "CURRENT". */
464
+ sk: {
465
+ type: "string",
466
+ required: true,
467
+ default: "CURRENT"
468
+ },
469
+ /** The tenant's own id (= resource id). Drives the partition key. */
470
+ tenantId: {
471
+ type: "string",
472
+ required: true
473
+ },
474
+ /** FHIR Resource.id; logical id in URL. Equals tenantId. */
475
+ id: {
476
+ type: "string",
477
+ required: true
478
+ },
479
+ /** Full Tenant resource serialized as JSON string. */
480
+ resource: {
481
+ type: "string",
482
+ required: true
483
+ },
484
+ /**
485
+ * Summary projection (key display fields as JSON string: id, displayName, status).
486
+ * Populated on every write via extractSummary(resource); GSI1 INCLUDE surfaces it on lists.
487
+ */
488
+ summary: {
489
+ type: "string",
490
+ required: true
491
+ },
492
+ /** Version id (e.g. ULID). */
493
+ vid: {
494
+ type: "string",
495
+ required: true
496
+ },
497
+ lastUpdated: {
498
+ type: "string",
499
+ required: true
500
+ },
501
+ gsi1Shard: gsi1ShardAttribute,
502
+ deleted: {
503
+ type: "boolean",
504
+ required: false
505
+ },
506
+ bundleId: {
507
+ type: "string",
508
+ required: false
509
+ },
510
+ msgId: {
511
+ type: "string",
512
+ required: false
513
+ }
514
+ },
515
+ indexes: {
516
+ /** Base table: PK = TENANT#ID#<tenantId>, SK = CURRENT. Do not supply PK or SK from outside. */
517
+ record: {
518
+ pk: {
519
+ field: "PK",
520
+ composite: ["tenantId"],
521
+ template: "TENANT#ID#${tenantId}"
522
+ },
523
+ sk: {
524
+ field: "SK",
525
+ composite: ["sk"],
526
+ template: "${sk}"
527
+ }
528
+ },
529
+ /**
530
+ * GSI1 — Unified Sharded List per ADR-011: list all Tenants across the four shards.
531
+ * Tenant lives at the platform tier (no parent tenant or workspace), so `TID#-#WID#-`
532
+ * sentinels precede `RT#Tenant#SHARD#<n>`. SK is `<ISO-8601 lastUpdated>#<id>` (control-plane
533
+ * unlabeled per DR-004). `casing: "none"` on the SK preserves ISO-8601 `T`/`Z`.
534
+ */
535
+ gsi1: {
536
+ index: "GSI1",
537
+ pk: {
538
+ field: "GSI1PK",
539
+ composite: ["gsi1Shard"],
540
+ template: "TID#-#WID#-#RT#Tenant#SHARD#${gsi1Shard}"
541
+ },
542
+ sk: {
543
+ field: "GSI1SK",
544
+ casing: "none",
545
+ composite: ["lastUpdated", "id"],
546
+ template: "${lastUpdated}#${id}"
547
+ }
548
+ }
549
+ }
550
+ });
551
+
552
+ // src/data/dynamo/entities/control/user-entity.ts
553
+ import { Entity as Entity6 } from "electrodb";
554
+ var UserEntity = new Entity6({
555
+ model: {
556
+ entity: "user",
557
+ service: "control",
558
+ version: "01"
559
+ },
560
+ attributes: {
561
+ /** Sort key sentinel. Always "CURRENT". */
562
+ sk: {
563
+ type: "string",
564
+ required: true,
565
+ default: "CURRENT"
566
+ },
567
+ /** FHIR Resource.id; platform user id (ohi_uid). */
568
+ id: {
569
+ type: "string",
570
+ required: true
571
+ },
572
+ /** Full User resource serialized as JSON string. */
573
+ resource: {
574
+ type: "string",
575
+ required: true
576
+ },
577
+ /**
578
+ * Summary projection (key display fields as JSON string: id, displayName, status).
579
+ * Populated on every write via extractSummary(resource); GSI1 INCLUDE surfaces it on lists.
580
+ */
581
+ summary: {
582
+ type: "string",
583
+ required: true
584
+ },
585
+ /**
586
+ * Immutable Cognito-issued `sub` claim. Drives GSI2 (sub-lookup). Optional until the
587
+ * Post Confirmation Lambda (#770) lands; required thereafter.
588
+ */
589
+ cognitoSub: {
590
+ type: "string",
591
+ required: false
592
+ },
593
+ /** Version id (e.g. ULID). */
594
+ vid: {
595
+ type: "string",
596
+ required: true
597
+ },
598
+ lastUpdated: {
599
+ type: "string",
600
+ required: true
601
+ },
602
+ gsi1Shard: gsi1ShardAttribute,
603
+ deleted: {
604
+ type: "boolean",
605
+ required: false
606
+ },
607
+ bundleId: {
608
+ type: "string",
609
+ required: false
610
+ },
611
+ msgId: {
612
+ type: "string",
613
+ required: false
614
+ }
615
+ },
616
+ indexes: {
617
+ /** Base table: PK = USER#ID#<id>, SK = CURRENT. Do not supply PK or SK from outside. */
618
+ record: {
619
+ pk: {
620
+ field: "PK",
621
+ composite: ["id"],
622
+ template: "USER#ID#${id}"
623
+ },
624
+ sk: {
625
+ field: "SK",
626
+ composite: ["sk"],
627
+ template: "${sk}"
628
+ }
629
+ },
630
+ /**
631
+ * GSI1 — Unified Sharded List per ADR-011: list all Users across the four shards.
632
+ * Non-tenant-isolated, so `TID#-#WID#-` sentinels precede `RT#User#SHARD#<n>`.
633
+ * SK is `<ISO-8601 lastUpdated>#<id>` (control-plane unlabeled per DR-004).
634
+ * `casing: "none"` on the SK preserves ISO-8601 `T`/`Z` characters.
635
+ */
636
+ gsi1: {
637
+ index: "GSI1",
638
+ pk: {
639
+ field: "GSI1PK",
640
+ composite: ["gsi1Shard"],
641
+ template: "TID#-#WID#-#RT#User#SHARD#${gsi1Shard}"
642
+ },
643
+ sk: {
644
+ field: "GSI1SK",
645
+ casing: "none",
646
+ composite: ["lastUpdated", "id"],
647
+ template: "${lastUpdated}#${id}"
648
+ }
649
+ },
650
+ /**
651
+ * GSI2 — Cognito sub-lookup per ADR-011: resolves the UserEntity from a Cognito `sub` claim.
652
+ * `condition` skips the index when `cognitoSub` is missing so legacy items without a sub are
653
+ * not indexed.
654
+ */
655
+ gsi2: {
656
+ index: "GSI2",
657
+ condition: (attrs) => typeof attrs.cognitoSub === "string" && attrs.cognitoSub.length > 0,
658
+ pk: {
659
+ field: "GSI2PK",
660
+ casing: "none",
661
+ composite: ["cognitoSub"],
662
+ template: "USER#SUB#${cognitoSub}"
663
+ },
664
+ sk: {
665
+ field: "GSI2SK",
666
+ casing: "none",
667
+ composite: [],
668
+ template: "CURRENT"
669
+ }
670
+ }
671
+ }
672
+ });
673
+
674
+ // src/data/dynamo/entities/control/workspace-entity.ts
675
+ import { Entity as Entity7 } from "electrodb";
676
+ var WorkspaceEntity = new Entity7({
677
+ model: {
678
+ entity: "workspace",
679
+ service: "control",
680
+ version: "01"
681
+ },
682
+ attributes: {
683
+ /** Sort key sentinel. Always "CURRENT". */
684
+ sk: {
685
+ type: "string",
686
+ required: true,
687
+ default: "CURRENT"
688
+ },
689
+ /** Tenant that contains this workspace (required). */
690
+ tenantId: {
691
+ type: "string",
692
+ required: true
693
+ },
694
+ /** FHIR Resource.id; logical id in URL. */
695
+ id: {
696
+ type: "string",
697
+ required: true
698
+ },
699
+ /** Full Workspace resource serialized as JSON string. */
700
+ resource: {
701
+ type: "string",
702
+ required: true
703
+ },
704
+ /**
705
+ * Summary projection (key display fields as JSON string: id, displayName, status).
706
+ * Populated on every write via extractSummary(resource); GSI1 INCLUDE surfaces it on lists.
707
+ */
708
+ summary: {
709
+ type: "string",
710
+ required: true
711
+ },
712
+ /** Version id (e.g. ULID). */
713
+ vid: {
714
+ type: "string",
715
+ required: true
716
+ },
717
+ lastUpdated: {
718
+ type: "string",
719
+ required: true
720
+ },
721
+ gsi1Shard: gsi1ShardAttribute,
722
+ deleted: {
723
+ type: "boolean",
724
+ required: false
725
+ },
726
+ bundleId: {
727
+ type: "string",
728
+ required: false
729
+ },
730
+ msgId: {
731
+ type: "string",
732
+ required: false
733
+ }
734
+ },
735
+ indexes: {
736
+ /** Base table: PK = TID#<tenantId>#WORKSPACE#ID#<id>, SK = CURRENT. Do not supply PK or SK from outside. */
737
+ record: {
738
+ pk: {
739
+ field: "PK",
740
+ composite: ["tenantId", "id"],
741
+ template: "TID#${tenantId}#WORKSPACE#ID#${id}"
742
+ },
743
+ sk: {
744
+ field: "SK",
745
+ composite: ["sk"],
746
+ template: "${sk}"
747
+ }
748
+ },
749
+ /**
750
+ * GSI1 — Unified Sharded List per ADR-011: list all Workspaces for a tenant across the
751
+ * four shards. Workspace is itself the workspace identity, so `WID#-` is a sentinel.
752
+ * SK is `<ISO-8601 lastUpdated>#<id>` (control-plane unlabeled per DR-004).
753
+ * `casing: "none"` on the SK preserves ISO-8601 `T`/`Z`.
754
+ */
755
+ gsi1: {
756
+ index: "GSI1",
757
+ pk: {
758
+ field: "GSI1PK",
759
+ composite: ["tenantId", "gsi1Shard"],
760
+ template: "TID#${tenantId}#WID#-#RT#Workspace#SHARD#${gsi1Shard}"
761
+ },
762
+ sk: {
763
+ field: "GSI1SK",
764
+ casing: "none",
765
+ composite: ["lastUpdated", "id"],
766
+ template: "${lastUpdated}#${id}"
767
+ }
768
+ }
769
+ }
770
+ });
771
+
772
+ // src/data/dynamo/dynamo-control-service.ts
773
+ var controlPlaneEntities = {
774
+ configuration: ConfigurationEntity,
775
+ membership: MembershipEntity,
776
+ role: RoleEntity,
777
+ roleAssignment: RoleAssignmentEntity,
778
+ tenant: TenantEntity,
779
+ user: UserEntity,
780
+ workspace: WorkspaceEntity
781
+ };
782
+ var controlPlaneService = new Service(controlPlaneEntities, {
783
+ table: defaultTableName,
784
+ client: dynamoClient
785
+ });
786
+ var DynamoControlService = {
787
+ entities: controlPlaneService.entities
788
+ };
789
+ function getDynamoControlService(tableName) {
790
+ const resolved = tableName ?? defaultTableName;
791
+ const service = new Service(controlPlaneEntities, {
792
+ table: resolved,
793
+ client: dynamoClient
794
+ });
795
+ return {
796
+ entities: service.entities
797
+ };
798
+ }
799
+
800
+ export {
801
+ defaultTableName,
802
+ dynamoClient,
803
+ SHARD_COUNT,
804
+ computeShard,
805
+ getDynamoControlService
806
+ };
807
+ //# sourceMappingURL=chunk-MLTYFMSE.mjs.map