@openhi/constructs 0.0.103 → 0.0.105
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/README.md +14 -0
- package/lib/chunk-2PM2NGXI.mjs +31 -0
- package/lib/chunk-2PM2NGXI.mjs.map +1 -0
- package/lib/chunk-36YCDLLA.mjs +1258 -0
- package/lib/chunk-36YCDLLA.mjs.map +1 -0
- package/lib/chunk-BXEG7IOZ.mjs +108 -0
- package/lib/chunk-BXEG7IOZ.mjs.map +1 -0
- package/lib/chunk-WNUH2WDZ.mjs +45 -0
- package/lib/chunk-WNUH2WDZ.mjs.map +1 -0
- package/lib/events-CVA3_eEB.d.mts +23 -0
- package/lib/events-CVA3_eEB.d.ts +23 -0
- package/lib/index.d.mts +92 -21
- package/lib/index.d.ts +112 -22
- package/lib/index.js +214 -72
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +190 -74
- package/lib/index.mjs.map +1 -1
- package/lib/post-confirmation.handler.js +50 -904
- package/lib/post-confirmation.handler.js.map +1 -1
- package/lib/post-confirmation.handler.mjs +36 -111
- package/lib/post-confirmation.handler.mjs.map +1 -1
- package/lib/pre-token-generation.handler.js +62 -27
- package/lib/pre-token-generation.handler.js.map +1 -1
- package/lib/pre-token-generation.handler.mjs +22 -31
- package/lib/pre-token-generation.handler.mjs.map +1 -1
- package/lib/provision-default-workspace.handler.d.mts +13 -0
- package/lib/provision-default-workspace.handler.d.ts +13 -0
- package/lib/{chunk-MLTYFMSE.mjs → provision-default-workspace.handler.js} +346 -26
- package/lib/provision-default-workspace.handler.js.map +1 -0
- package/lib/provision-default-workspace.handler.mjs +173 -0
- package/lib/provision-default-workspace.handler.mjs.map +1 -0
- package/lib/rest-api-lambda.handler.mjs +40 -546
- package/lib/rest-api-lambda.handler.mjs.map +1 -1
- package/package.json +2 -2
- package/lib/chunk-MLTYFMSE.mjs.map +0 -1
|
@@ -1,10 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/workflows/control-plane/user-onboarding/provision-default-workspace.handler.ts
|
|
21
|
+
var provision_default_workspace_handler_exports = {};
|
|
22
|
+
__export(provision_default_workspace_handler_exports, {
|
|
23
|
+
handler: () => handler
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(provision_default_workspace_handler_exports);
|
|
26
|
+
var import_node_crypto = require("crypto");
|
|
27
|
+
var import_types8 = require("@openhi/types");
|
|
28
|
+
|
|
1
29
|
// src/data/dynamo/dynamo-control-service.ts
|
|
2
|
-
|
|
30
|
+
var import_electrodb8 = require("electrodb");
|
|
3
31
|
|
|
4
32
|
// src/data/dynamo/dynamo-client.ts
|
|
5
|
-
|
|
33
|
+
var import_client_dynamodb = require("@aws-sdk/client-dynamodb");
|
|
6
34
|
var defaultTableName = process.env.DYNAMO_TABLE_NAME ?? "jesttesttable";
|
|
7
|
-
var dynamoClient = new DynamoDBClient({
|
|
35
|
+
var dynamoClient = new import_client_dynamodb.DynamoDBClient({
|
|
8
36
|
...process.env.MOCK_DYNAMODB_ENDPOINT && {
|
|
9
37
|
endpoint: process.env.MOCK_DYNAMODB_ENDPOINT,
|
|
10
38
|
sslEnabled: false,
|
|
@@ -13,7 +41,7 @@ var dynamoClient = new DynamoDBClient({
|
|
|
13
41
|
});
|
|
14
42
|
|
|
15
43
|
// src/data/dynamo/entities/control/configuration-entity.ts
|
|
16
|
-
|
|
44
|
+
var import_electrodb = require("electrodb");
|
|
17
45
|
|
|
18
46
|
// src/data/dynamo/shard.ts
|
|
19
47
|
var SHARD_COUNT = 4;
|
|
@@ -39,7 +67,7 @@ var gsi1ShardAttribute = {
|
|
|
39
67
|
};
|
|
40
68
|
|
|
41
69
|
// src/data/dynamo/entities/control/configuration-entity.ts
|
|
42
|
-
var ConfigurationEntity = new Entity({
|
|
70
|
+
var ConfigurationEntity = new import_electrodb.Entity({
|
|
43
71
|
model: {
|
|
44
72
|
entity: "configuration",
|
|
45
73
|
service: "control",
|
|
@@ -163,8 +191,8 @@ var ConfigurationEntity = new Entity({
|
|
|
163
191
|
});
|
|
164
192
|
|
|
165
193
|
// src/data/dynamo/entities/control/membership-entity.ts
|
|
166
|
-
|
|
167
|
-
var MembershipEntity = new
|
|
194
|
+
var import_electrodb2 = require("electrodb");
|
|
195
|
+
var MembershipEntity = new import_electrodb2.Entity({
|
|
168
196
|
model: {
|
|
169
197
|
entity: "membership",
|
|
170
198
|
service: "control",
|
|
@@ -261,8 +289,8 @@ var MembershipEntity = new Entity2({
|
|
|
261
289
|
});
|
|
262
290
|
|
|
263
291
|
// src/data/dynamo/entities/control/role-entity.ts
|
|
264
|
-
|
|
265
|
-
var RoleEntity = new
|
|
292
|
+
var import_electrodb3 = require("electrodb");
|
|
293
|
+
var RoleEntity = new import_electrodb3.Entity({
|
|
266
294
|
model: {
|
|
267
295
|
entity: "role",
|
|
268
296
|
service: "control",
|
|
@@ -354,8 +382,8 @@ var RoleEntity = new Entity3({
|
|
|
354
382
|
});
|
|
355
383
|
|
|
356
384
|
// src/data/dynamo/entities/control/roleassignment-entity.ts
|
|
357
|
-
|
|
358
|
-
var RoleAssignmentEntity = new
|
|
385
|
+
var import_electrodb4 = require("electrodb");
|
|
386
|
+
var RoleAssignmentEntity = new import_electrodb4.Entity({
|
|
359
387
|
model: {
|
|
360
388
|
entity: "roleassignment",
|
|
361
389
|
service: "control",
|
|
@@ -452,8 +480,8 @@ var RoleAssignmentEntity = new Entity4({
|
|
|
452
480
|
});
|
|
453
481
|
|
|
454
482
|
// src/data/dynamo/entities/control/tenant-entity.ts
|
|
455
|
-
|
|
456
|
-
var TenantEntity = new
|
|
483
|
+
var import_electrodb5 = require("electrodb");
|
|
484
|
+
var TenantEntity = new import_electrodb5.Entity({
|
|
457
485
|
model: {
|
|
458
486
|
entity: "tenant",
|
|
459
487
|
service: "control",
|
|
@@ -550,8 +578,8 @@ var TenantEntity = new Entity5({
|
|
|
550
578
|
});
|
|
551
579
|
|
|
552
580
|
// src/data/dynamo/entities/control/user-entity.ts
|
|
553
|
-
|
|
554
|
-
var UserEntity = new
|
|
581
|
+
var import_electrodb6 = require("electrodb");
|
|
582
|
+
var UserEntity = new import_electrodb6.Entity({
|
|
555
583
|
model: {
|
|
556
584
|
entity: "user",
|
|
557
585
|
service: "control",
|
|
@@ -672,8 +700,8 @@ var UserEntity = new Entity6({
|
|
|
672
700
|
});
|
|
673
701
|
|
|
674
702
|
// src/data/dynamo/entities/control/workspace-entity.ts
|
|
675
|
-
|
|
676
|
-
var WorkspaceEntity = new
|
|
703
|
+
var import_electrodb7 = require("electrodb");
|
|
704
|
+
var WorkspaceEntity = new import_electrodb7.Entity({
|
|
677
705
|
model: {
|
|
678
706
|
entity: "workspace",
|
|
679
707
|
service: "control",
|
|
@@ -779,7 +807,7 @@ var controlPlaneEntities = {
|
|
|
779
807
|
user: UserEntity,
|
|
780
808
|
workspace: WorkspaceEntity
|
|
781
809
|
};
|
|
782
|
-
var controlPlaneService = new Service(controlPlaneEntities, {
|
|
810
|
+
var controlPlaneService = new import_electrodb8.Service(controlPlaneEntities, {
|
|
783
811
|
table: defaultTableName,
|
|
784
812
|
client: dynamoClient
|
|
785
813
|
});
|
|
@@ -788,7 +816,7 @@ var DynamoControlService = {
|
|
|
788
816
|
};
|
|
789
817
|
function getDynamoControlService(tableName) {
|
|
790
818
|
const resolved = tableName ?? defaultTableName;
|
|
791
|
-
const service = new Service(controlPlaneEntities, {
|
|
819
|
+
const service = new import_electrodb8.Service(controlPlaneEntities, {
|
|
792
820
|
table: resolved,
|
|
793
821
|
client: dynamoClient
|
|
794
822
|
});
|
|
@@ -797,11 +825,303 @@ function getDynamoControlService(tableName) {
|
|
|
797
825
|
};
|
|
798
826
|
}
|
|
799
827
|
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
828
|
+
// src/data/operations/control/membership/membership-create-operation.ts
|
|
829
|
+
var import_types = require("@openhi/types");
|
|
830
|
+
async function createMembershipOperation(params) {
|
|
831
|
+
const { context, body, tableName } = params;
|
|
832
|
+
const service = getDynamoControlService(tableName);
|
|
833
|
+
const id = body.id ?? `membership-${Date.now()}`;
|
|
834
|
+
const parsedResource = typeof body.resource === "string" ? JSON.parse(body.resource) : body.resource ?? {};
|
|
835
|
+
const lastUpdated = context.date ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
836
|
+
const vid = `1`;
|
|
837
|
+
const resource = { resourceType: "Membership", id, ...parsedResource };
|
|
838
|
+
const summary = JSON.stringify((0, import_types.extractSummary)(resource));
|
|
839
|
+
await service.entities.membership.put({
|
|
840
|
+
tenantId: context.tenantId,
|
|
841
|
+
id,
|
|
842
|
+
resource: JSON.stringify(resource),
|
|
843
|
+
summary,
|
|
844
|
+
vid,
|
|
845
|
+
lastUpdated
|
|
846
|
+
}).go();
|
|
847
|
+
return {
|
|
848
|
+
id,
|
|
849
|
+
resource,
|
|
850
|
+
meta: { lastUpdated, versionId: vid }
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
// src/data/operations/control/roleassignment/roleassignment-create-operation.ts
|
|
855
|
+
var import_types2 = require("@openhi/types");
|
|
856
|
+
async function createRoleAssignmentOperation(params) {
|
|
857
|
+
const { context, body, tableName } = params;
|
|
858
|
+
const service = getDynamoControlService(tableName);
|
|
859
|
+
const id = body.id ?? `roleassignment-${Date.now()}`;
|
|
860
|
+
const parsedResource = typeof body.resource === "string" ? JSON.parse(body.resource) : body.resource ?? {};
|
|
861
|
+
const lastUpdated = context.date ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
862
|
+
const vid = `1`;
|
|
863
|
+
const resource = { resourceType: "RoleAssignment", id, ...parsedResource };
|
|
864
|
+
const summary = JSON.stringify((0, import_types2.extractSummary)(resource));
|
|
865
|
+
await service.entities.roleAssignment.put({
|
|
866
|
+
tenantId: context.tenantId,
|
|
867
|
+
id,
|
|
868
|
+
resource: JSON.stringify(resource),
|
|
869
|
+
summary,
|
|
870
|
+
vid,
|
|
871
|
+
lastUpdated
|
|
872
|
+
}).go();
|
|
873
|
+
return {
|
|
874
|
+
id,
|
|
875
|
+
resource,
|
|
876
|
+
meta: { lastUpdated, versionId: vid }
|
|
877
|
+
};
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// src/data/operations/control/tenant/tenant-create-operation.ts
|
|
881
|
+
var import_types3 = require("@openhi/types");
|
|
882
|
+
async function createTenantOperation(params) {
|
|
883
|
+
const { context, body, tableName } = params;
|
|
884
|
+
const service = getDynamoControlService(tableName);
|
|
885
|
+
const id = body.id ?? `tenant-${Date.now()}`;
|
|
886
|
+
const lastUpdated = context.date;
|
|
887
|
+
const vid = lastUpdated.replace(/[-:T.Z]/g, "").slice(0, 12) || Date.now().toString(36);
|
|
888
|
+
const parsedResource = typeof body.resource === "string" ? JSON.parse(body.resource) : body.resource ?? {};
|
|
889
|
+
const resource = { resourceType: "Tenant", id, ...parsedResource };
|
|
890
|
+
const summary = JSON.stringify((0, import_types3.extractSummary)(resource));
|
|
891
|
+
await service.entities.tenant.put({
|
|
892
|
+
tenantId: id,
|
|
893
|
+
id,
|
|
894
|
+
resource: JSON.stringify(resource),
|
|
895
|
+
summary,
|
|
896
|
+
vid,
|
|
897
|
+
lastUpdated
|
|
898
|
+
}).go();
|
|
899
|
+
return { id, resource, meta: { lastUpdated, versionId: vid } };
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
// src/data/operations/control/user/user-create-operation.ts
|
|
903
|
+
var import_types4 = require("@openhi/types");
|
|
904
|
+
|
|
905
|
+
// src/data/operations/control/user/user-find-by-sub-operation.ts
|
|
906
|
+
async function findUserBySubOperation(params) {
|
|
907
|
+
const { cognitoSub, tableName } = params;
|
|
908
|
+
const service = getDynamoControlService(tableName);
|
|
909
|
+
const result = await service.entities.user.query.gsi2({ cognitoSub }).go({ limit: 1 });
|
|
910
|
+
const item = result.data?.[0];
|
|
911
|
+
if (!item) {
|
|
912
|
+
return void 0;
|
|
913
|
+
}
|
|
914
|
+
return {
|
|
915
|
+
id: item.id,
|
|
916
|
+
cognitoSub: item.cognitoSub,
|
|
917
|
+
resource: item.resource,
|
|
918
|
+
vid: item.vid
|
|
919
|
+
};
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
// src/data/operations/data-operations-common.ts
|
|
923
|
+
var import_types5 = require("@openhi/types");
|
|
924
|
+
|
|
925
|
+
// src/lib/compression.ts
|
|
926
|
+
var import_node_zlib = require("zlib");
|
|
927
|
+
|
|
928
|
+
// src/data/operations/control/user/user-update-operation.ts
|
|
929
|
+
var import_types6 = require("@openhi/types");
|
|
930
|
+
|
|
931
|
+
// src/data/operations/control/user/user-resource-helpers.ts
|
|
932
|
+
function parseUserResource(resource) {
|
|
933
|
+
try {
|
|
934
|
+
return JSON.parse(resource);
|
|
935
|
+
} catch {
|
|
936
|
+
return void 0;
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
// src/data/operations/control/workspace/workspace-create-operation.ts
|
|
941
|
+
var import_types7 = require("@openhi/types");
|
|
942
|
+
async function createWorkspaceOperation(params) {
|
|
943
|
+
const { context, body, tableName } = params;
|
|
944
|
+
const { tenantId } = context;
|
|
945
|
+
const service = getDynamoControlService(tableName);
|
|
946
|
+
const id = body.id ?? `workspace-${Date.now()}`;
|
|
947
|
+
const lastUpdated = context.date;
|
|
948
|
+
const vid = lastUpdated.replace(/[-:T.Z]/g, "").slice(0, 12) || Date.now().toString(36);
|
|
949
|
+
const parsedResource = typeof body.resource === "string" ? JSON.parse(body.resource) : body.resource ?? {};
|
|
950
|
+
const resource = { resourceType: "Workspace", id, ...parsedResource };
|
|
951
|
+
const summary = JSON.stringify((0, import_types7.extractSummary)(resource));
|
|
952
|
+
await service.entities.workspace.put({
|
|
953
|
+
tenantId,
|
|
954
|
+
id,
|
|
955
|
+
resource: JSON.stringify(resource),
|
|
956
|
+
summary,
|
|
957
|
+
vid,
|
|
958
|
+
lastUpdated
|
|
959
|
+
}).go();
|
|
960
|
+
return { id, resource, meta: { lastUpdated, versionId: vid } };
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
// src/data/operations/fhir-reference.ts
|
|
964
|
+
function idFromReference(reference, prefix) {
|
|
965
|
+
if (!reference || !reference.startsWith(prefix)) {
|
|
966
|
+
return void 0;
|
|
967
|
+
}
|
|
968
|
+
const id = reference.slice(prefix.length);
|
|
969
|
+
return id.length > 0 ? id : void 0;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
// src/workflows/control-plane/user-onboarding/provision-default-workspace.handler.ts
|
|
973
|
+
var CURRENT_SK = "CURRENT";
|
|
974
|
+
var VID = "1";
|
|
975
|
+
var summaryFor = (resource) => {
|
|
976
|
+
return JSON.stringify((0, import_types8.extractSummary)(resource));
|
|
977
|
+
};
|
|
978
|
+
var stableOnboardingId = (kind, cognitoSub) => {
|
|
979
|
+
return (0, import_node_crypto.createHash)("sha256").update(kind).update("\0").update(cognitoSub).digest("hex").slice(0, 26).toUpperCase();
|
|
806
980
|
};
|
|
807
|
-
|
|
981
|
+
var handler = async (event) => {
|
|
982
|
+
const detail = event.detail;
|
|
983
|
+
if (!detail?.cognitoSub) {
|
|
984
|
+
console.warn(
|
|
985
|
+
"ProvisionDefaultWorkspace: event missing cognitoSub; skipping"
|
|
986
|
+
);
|
|
987
|
+
return;
|
|
988
|
+
}
|
|
989
|
+
const service = getDynamoControlService();
|
|
990
|
+
const existingUser = await findUserBySubOperation({
|
|
991
|
+
context: {
|
|
992
|
+
tenantId: "",
|
|
993
|
+
workspaceId: "",
|
|
994
|
+
date: "",
|
|
995
|
+
actorId: "",
|
|
996
|
+
actorName: "",
|
|
997
|
+
actorType: "internal-system"
|
|
998
|
+
},
|
|
999
|
+
cognitoSub: detail.cognitoSub
|
|
1000
|
+
});
|
|
1001
|
+
const existingResource = existingUser ? parseUserResource(existingUser.resource) : void 0;
|
|
1002
|
+
const existingTenantId = idFromReference(
|
|
1003
|
+
existingResource?.currentTenant?.reference,
|
|
1004
|
+
"Tenant/"
|
|
1005
|
+
);
|
|
1006
|
+
const existingWorkspaceId = idFromReference(
|
|
1007
|
+
existingResource?.currentWorkspace?.reference,
|
|
1008
|
+
"Workspace/"
|
|
1009
|
+
);
|
|
1010
|
+
if (existingUser && existingTenantId && existingWorkspaceId) {
|
|
1011
|
+
return;
|
|
1012
|
+
}
|
|
1013
|
+
const displayName = detail.displayName || detail.email || event.resources?.[0] || detail.cognitoSub;
|
|
1014
|
+
const userId = existingUser?.id ?? detail.userId ?? stableOnboardingId("user", detail.cognitoSub);
|
|
1015
|
+
const tenantId = stableOnboardingId("tenant", detail.cognitoSub);
|
|
1016
|
+
const workspaceId = stableOnboardingId("workspace", detail.cognitoSub);
|
|
1017
|
+
const userTenantMembershipId = stableOnboardingId(
|
|
1018
|
+
"tenant-membership",
|
|
1019
|
+
detail.cognitoSub
|
|
1020
|
+
);
|
|
1021
|
+
const userWorkspaceMembershipId = stableOnboardingId(
|
|
1022
|
+
"workspace-membership",
|
|
1023
|
+
detail.cognitoSub
|
|
1024
|
+
);
|
|
1025
|
+
const roleAssignmentId = stableOnboardingId(
|
|
1026
|
+
"tenant-user-role-assignment",
|
|
1027
|
+
detail.cognitoSub
|
|
1028
|
+
);
|
|
1029
|
+
const lastUpdated = (/* @__PURE__ */ new Date()).toISOString();
|
|
1030
|
+
const context = {
|
|
1031
|
+
tenantId,
|
|
1032
|
+
workspaceId,
|
|
1033
|
+
date: lastUpdated,
|
|
1034
|
+
actorId: userId,
|
|
1035
|
+
actorName: displayName,
|
|
1036
|
+
actorType: "internal-system"
|
|
1037
|
+
};
|
|
1038
|
+
const tenantResource = {
|
|
1039
|
+
id: tenantId,
|
|
1040
|
+
displayName: `${displayName}'s Practice`,
|
|
1041
|
+
status: "active"
|
|
1042
|
+
};
|
|
1043
|
+
const workspaceResource = {
|
|
1044
|
+
id: workspaceId,
|
|
1045
|
+
displayName: "Default Workspace",
|
|
1046
|
+
status: "active",
|
|
1047
|
+
tenant: { reference: `Tenant/${tenantId}` }
|
|
1048
|
+
};
|
|
1049
|
+
const userResource = {
|
|
1050
|
+
...existingResource ?? {},
|
|
1051
|
+
resourceType: "User",
|
|
1052
|
+
id: userId,
|
|
1053
|
+
name: existingResource?.name ?? [{ text: displayName }],
|
|
1054
|
+
status: "active",
|
|
1055
|
+
currentTenant: { reference: `Tenant/${tenantId}` },
|
|
1056
|
+
currentWorkspace: { reference: `Workspace/${workspaceId}` }
|
|
1057
|
+
};
|
|
1058
|
+
const userTenantMembershipResource = {
|
|
1059
|
+
id: userTenantMembershipId,
|
|
1060
|
+
status: "active",
|
|
1061
|
+
user: { reference: `User/${userId}` },
|
|
1062
|
+
tenant: { reference: `Tenant/${tenantId}` }
|
|
1063
|
+
};
|
|
1064
|
+
const userWorkspaceMembershipResource = {
|
|
1065
|
+
id: userWorkspaceMembershipId,
|
|
1066
|
+
status: "active",
|
|
1067
|
+
user: { reference: `User/${userId}` },
|
|
1068
|
+
tenant: { reference: `Tenant/${tenantId}` },
|
|
1069
|
+
workspace: { reference: `Workspace/${workspaceId}` }
|
|
1070
|
+
};
|
|
1071
|
+
const roleAssignmentResource = {
|
|
1072
|
+
id: roleAssignmentId,
|
|
1073
|
+
status: "active",
|
|
1074
|
+
user: { reference: `User/${userId}` },
|
|
1075
|
+
tenant: { reference: `Tenant/${tenantId}` },
|
|
1076
|
+
role: "tenant-user"
|
|
1077
|
+
};
|
|
1078
|
+
await createTenantOperation({
|
|
1079
|
+
context,
|
|
1080
|
+
body: { id: tenantId, resource: tenantResource }
|
|
1081
|
+
});
|
|
1082
|
+
await createWorkspaceOperation({
|
|
1083
|
+
context,
|
|
1084
|
+
body: { id: workspaceId, resource: workspaceResource }
|
|
1085
|
+
});
|
|
1086
|
+
if (existingUser) {
|
|
1087
|
+
await service.entities.user.patch({ id: userId, sk: CURRENT_SK }).set({
|
|
1088
|
+
resource: JSON.stringify(userResource),
|
|
1089
|
+
summary: summaryFor(userResource),
|
|
1090
|
+
cognitoSub: detail.cognitoSub,
|
|
1091
|
+
vid: VID,
|
|
1092
|
+
lastUpdated
|
|
1093
|
+
}).go();
|
|
1094
|
+
} else {
|
|
1095
|
+
await service.entities.user.put({
|
|
1096
|
+
id: userId,
|
|
1097
|
+
cognitoSub: detail.cognitoSub,
|
|
1098
|
+
resource: JSON.stringify(userResource),
|
|
1099
|
+
summary: summaryFor(userResource),
|
|
1100
|
+
vid: VID,
|
|
1101
|
+
lastUpdated
|
|
1102
|
+
}).go();
|
|
1103
|
+
}
|
|
1104
|
+
await createMembershipOperation({
|
|
1105
|
+
context,
|
|
1106
|
+
body: {
|
|
1107
|
+
id: userTenantMembershipId,
|
|
1108
|
+
resource: userTenantMembershipResource
|
|
1109
|
+
}
|
|
1110
|
+
});
|
|
1111
|
+
await createMembershipOperation({
|
|
1112
|
+
context,
|
|
1113
|
+
body: {
|
|
1114
|
+
id: userWorkspaceMembershipId,
|
|
1115
|
+
resource: userWorkspaceMembershipResource
|
|
1116
|
+
}
|
|
1117
|
+
});
|
|
1118
|
+
await createRoleAssignmentOperation({
|
|
1119
|
+
context,
|
|
1120
|
+
body: { id: roleAssignmentId, resource: roleAssignmentResource }
|
|
1121
|
+
});
|
|
1122
|
+
};
|
|
1123
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
1124
|
+
0 && (module.exports = {
|
|
1125
|
+
handler
|
|
1126
|
+
});
|
|
1127
|
+
//# sourceMappingURL=provision-default-workspace.handler.js.map
|