@casual-simulation/aux-records 3.2.13 → 3.2.14-alpha.7890390188

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 (46) hide show
  1. package/AIController.d.ts +7 -4
  2. package/AIController.js +11 -0
  3. package/AIController.js.map +1 -1
  4. package/AuthController.d.ts +2 -1
  5. package/AuthController.js +6 -3
  6. package/AuthController.js.map +1 -1
  7. package/AuthStore.d.ts +1 -21
  8. package/CachingPolicyStore.d.ts +16 -5
  9. package/CachingPolicyStore.js +66 -39
  10. package/CachingPolicyStore.js.map +1 -1
  11. package/DataRecordsController.d.ts +67 -5
  12. package/DataRecordsController.js +141 -78
  13. package/DataRecordsController.js.map +1 -1
  14. package/DataRecordsStore.d.ts +35 -1
  15. package/DataRecordsStore.js.map +1 -1
  16. package/EventRecordsController.d.ts +5 -5
  17. package/EventRecordsController.js +54 -35
  18. package/EventRecordsController.js.map +1 -1
  19. package/FileRecordsController.d.ts +6 -6
  20. package/FileRecordsController.js +142 -76
  21. package/FileRecordsController.js.map +1 -1
  22. package/MemoryStore.d.ts +28 -17
  23. package/MemoryStore.js +457 -110
  24. package/MemoryStore.js.map +1 -1
  25. package/PolicyController.d.ts +512 -677
  26. package/PolicyController.js +1196 -2934
  27. package/PolicyController.js.map +1 -1
  28. package/PolicyStore.d.ts +319 -90
  29. package/PolicyStore.js +125 -0
  30. package/PolicyStore.js.map +1 -1
  31. package/RecordsServer.d.ts +3 -4
  32. package/RecordsServer.js +88 -111
  33. package/RecordsServer.js.map +1 -1
  34. package/RecordsStore.d.ts +3 -0
  35. package/TestUtils.d.ts +1 -1
  36. package/TestUtils.js.map +1 -1
  37. package/Utils.d.ts +21 -3
  38. package/Utils.js +42 -3
  39. package/Utils.js.map +1 -1
  40. package/package.json +3 -3
  41. package/websockets/InstRecordsStore.d.ts +21 -0
  42. package/websockets/InstRecordsStore.js +43 -1
  43. package/websockets/InstRecordsStore.js.map +1 -1
  44. package/websockets/WebsocketController.d.ts +7 -7
  45. package/websockets/WebsocketController.js +153 -82
  46. package/websockets/WebsocketController.js.map +1 -1
package/MemoryStore.js CHANGED
@@ -18,10 +18,9 @@ var __rest = (this && this.__rest) || function (s, e) {
18
18
  }
19
19
  return t;
20
20
  };
21
- import { sortBy } from 'lodash';
21
+ import { cloneDeep, orderBy, sortBy } from 'lodash';
22
22
  import { v4 as uuid } from 'uuid';
23
- import { getExpireTime, } from './PolicyStore';
24
- import { DEFAULT_ANY_RESOURCE_POLICY_DOCUMENT, DEFAULT_PUBLIC_READ_POLICY_DOCUMENT, DEFAULT_PUBLIC_WRITE_POLICY_DOCUMENT, PUBLIC_READ_MARKER, PUBLIC_WRITE_MARKER, } from '@casual-simulation/aux-common';
23
+ import { getExpireTime, getSubjectUserId, } from './PolicyStore';
25
24
  import { DateTime } from 'luxon';
26
25
  export class MemoryStore {
27
26
  get users() {
@@ -109,6 +108,10 @@ export class MemoryStore {
109
108
  this._moderationConfiguration = null;
110
109
  this._recordNotifications = [];
111
110
  this._comIdRequests = [];
111
+ this._resourcePermissionAssignments = [];
112
+ this._markerPermissionAssignments = [];
113
+ // TODO: Support global permissions
114
+ // private _globalPermissionAssignments: GlobalPermissionAssignment[] = [];
112
115
  this.maxAllowedInstSize = Infinity;
113
116
  this._subscriptionConfiguration = config.subscriptions;
114
117
  this._privoConfiguration = (_a = config.privo) !== null && _a !== void 0 ? _a : null;
@@ -117,6 +120,50 @@ export class MemoryStore {
117
120
  this.roles = {};
118
121
  this.roleAssignments = {};
119
122
  }
123
+ /**
124
+ * Constructs a deep clone of this memory store.
125
+ * Effectively copies all the data in the store into a new one.
126
+ */
127
+ clone() {
128
+ const newStore = new MemoryStore({
129
+ subscriptions: cloneDeep(this._subscriptionConfiguration),
130
+ privo: cloneDeep(this._privoConfiguration),
131
+ moderation: cloneDeep(this._moderationConfiguration),
132
+ });
133
+ newStore._users = cloneDeep(this._users);
134
+ newStore._loginRequests = cloneDeep(this._loginRequests);
135
+ newStore._oidLoginRequests = cloneDeep(this._oidLoginRequests);
136
+ newStore._sessions = cloneDeep(this._sessions);
137
+ newStore._subscriptions = cloneDeep(this._subscriptions);
138
+ newStore._periods = cloneDeep(this._periods);
139
+ newStore._invoices = cloneDeep(this._invoices);
140
+ newStore._records = cloneDeep(this._records);
141
+ newStore._recordKeys = cloneDeep(this._recordKeys);
142
+ newStore._studios = cloneDeep(this._studios);
143
+ newStore._studioAssignments = cloneDeep(this._studioAssignments);
144
+ newStore._aiChatMetrics = cloneDeep(this._aiChatMetrics);
145
+ newStore._aiImageMetrics = cloneDeep(this._aiImageMetrics);
146
+ newStore._aiSkyboxMetrics = cloneDeep(this._aiSkyboxMetrics);
147
+ newStore._dataBuckets = cloneDeep(this._dataBuckets);
148
+ newStore._eventBuckets = cloneDeep(this._eventBuckets);
149
+ newStore._files = cloneDeep(this._files);
150
+ newStore._fileUploadUrl = cloneDeep(this._fileUploadUrl);
151
+ newStore._emailRules = cloneDeep(this._emailRules);
152
+ newStore._smsRules = cloneDeep(this._smsRules);
153
+ newStore._userInstReports = cloneDeep(this._userInstReports);
154
+ newStore._instRecords = cloneDeep(this._instRecords);
155
+ newStore._subscriptionConfiguration = cloneDeep(this._subscriptionConfiguration);
156
+ newStore._privoConfiguration = cloneDeep(this._privoConfiguration);
157
+ newStore._moderationConfiguration = cloneDeep(this._moderationConfiguration);
158
+ newStore._recordNotifications = cloneDeep(this._recordNotifications);
159
+ newStore._comIdRequests = cloneDeep(this._comIdRequests);
160
+ newStore._resourcePermissionAssignments = cloneDeep(this._resourcePermissionAssignments);
161
+ newStore._markerPermissionAssignments = cloneDeep(this._markerPermissionAssignments);
162
+ newStore.maxAllowedInstSize = this.maxAllowedInstSize;
163
+ newStore.roles = cloneDeep(this.roles);
164
+ newStore.roleAssignments = cloneDeep(this.roleAssignments);
165
+ return newStore;
166
+ }
120
167
  saveComIdRequest(request) {
121
168
  return __awaiter(this, void 0, void 0, function* () {
122
169
  this._comIdRequests.push(request);
@@ -398,6 +445,252 @@ export class MemoryStore {
398
445
  });
399
446
  });
400
447
  }
448
+ getUserPrivacyFeatures(userId) {
449
+ return __awaiter(this, void 0, void 0, function* () {
450
+ return yield this._getUserPrivacyFeatures(userId);
451
+ });
452
+ }
453
+ getRecordOwnerPrivacyFeatures(recordName) {
454
+ return __awaiter(this, void 0, void 0, function* () {
455
+ const record = yield this.getRecordByName(recordName);
456
+ if (!record || !record.ownerId) {
457
+ return null;
458
+ }
459
+ return yield this._getUserPrivacyFeatures(record.ownerId);
460
+ });
461
+ }
462
+ getPermissionForSubjectAndResource(subjectType, subjectId, recordName, resourceKind, resourceId, action, currentTimeMs) {
463
+ return __awaiter(this, void 0, void 0, function* () {
464
+ const existingRoles = subjectType === 'user'
465
+ ? yield this.listRolesForUser(recordName, subjectId)
466
+ : subjectType === 'inst'
467
+ ? yield this.listRolesForInst(recordName, subjectId)
468
+ : [];
469
+ const roles = existingRoles.map((r) => r.role);
470
+ const assignment = this._resourcePermissionAssignments.find((p) => p.recordName === recordName &&
471
+ ((p.subjectType === 'role' &&
472
+ roles.indexOf(p.subjectId) >= 0) ||
473
+ (p.subjectType === subjectType &&
474
+ p.subjectId === subjectId)) &&
475
+ p.resourceKind === resourceKind &&
476
+ p.resourceId === resourceId &&
477
+ (p.action === null || p.action === action) &&
478
+ (!p.expireTimeMs || p.expireTimeMs > currentTimeMs));
479
+ return {
480
+ success: true,
481
+ permissionAssignment: assignment,
482
+ };
483
+ });
484
+ }
485
+ getPermissionForSubjectAndMarkers(subjectType, subjectId, recordName, resourceKind, markers, action, currentTimeMs) {
486
+ return __awaiter(this, void 0, void 0, function* () {
487
+ const existingRoles = subjectType === 'user'
488
+ ? yield this.listRolesForUser(recordName, subjectId)
489
+ : subjectType === 'inst'
490
+ ? yield this.listRolesForInst(recordName, subjectId)
491
+ : [];
492
+ const roles = existingRoles.map((r) => r.role);
493
+ const assignment = this._markerPermissionAssignments.find((p) => p.recordName === recordName &&
494
+ markers.indexOf(p.marker) >= 0 &&
495
+ ((p.subjectType === 'role' &&
496
+ roles.indexOf(p.subjectId) >= 0) ||
497
+ (p.subjectType === subjectType &&
498
+ p.subjectId === subjectId)) &&
499
+ p.resourceKind === resourceKind &&
500
+ (p.action === null || p.action === action) &&
501
+ (!p.expireTimeMs || p.expireTimeMs > currentTimeMs));
502
+ return {
503
+ success: true,
504
+ permissionAssignment: assignment,
505
+ };
506
+ });
507
+ }
508
+ // TODO: Support global permissions
509
+ // async assignGlobalPermissionToSubject(
510
+ // subjectType: SubjectType,
511
+ // subjectId: string,
512
+ // resourceKind: ResourceKinds,
513
+ // action: ActionKinds,
514
+ // options: PermissionOptions,
515
+ // expireTimeMs: number
516
+ // ): Promise<AssignGlobalPermissionToSubjectResult> {
517
+ // const userId = getSubjectUserId(subjectType, subjectId);
518
+ // const assignment: GlobalPermissionAssignment = {
519
+ // id: uuid(),
520
+ // userId,
521
+ // subjectType,
522
+ // subjectId,
523
+ // resourceKind,
524
+ // action,
525
+ // options,
526
+ // expireTimeMs
527
+ // };
528
+ // this._globalPermissionAssignments.push(assignment);
529
+ // return {
530
+ // success: true,
531
+ // permissionAssignment: assignment,
532
+ // };
533
+ // }
534
+ assignPermissionToSubjectAndResource(recordName, subjectType, subjectId, resourceKind, resourceId, action, options, expireTimeMs) {
535
+ return __awaiter(this, void 0, void 0, function* () {
536
+ const assignmentIndex = this._resourcePermissionAssignments.findIndex((a) => a.recordName === recordName &&
537
+ a.subjectType === subjectType &&
538
+ a.subjectId === subjectId &&
539
+ a.resourceKind === resourceKind &&
540
+ a.resourceId === resourceId &&
541
+ a.action === action);
542
+ if (assignmentIndex >= 0) {
543
+ const assignment = this._resourcePermissionAssignments[assignmentIndex];
544
+ this._resourcePermissionAssignments[assignmentIndex] = Object.assign(Object.assign({}, assignment), { options,
545
+ expireTimeMs });
546
+ return {
547
+ success: true,
548
+ permissionAssignment: assignment,
549
+ };
550
+ }
551
+ const userId = getSubjectUserId(subjectType, subjectId);
552
+ const assignment = {
553
+ id: uuid(),
554
+ recordName,
555
+ userId,
556
+ subjectType,
557
+ subjectId,
558
+ resourceKind,
559
+ resourceId,
560
+ action,
561
+ options,
562
+ expireTimeMs,
563
+ };
564
+ this._resourcePermissionAssignments.push(assignment);
565
+ return {
566
+ success: true,
567
+ permissionAssignment: assignment,
568
+ };
569
+ });
570
+ }
571
+ assignPermissionToSubjectAndMarker(recordName, subjectType, subjectId, resourceKind, marker, action, options, expireTimeMs) {
572
+ return __awaiter(this, void 0, void 0, function* () {
573
+ const assignmentIndex = this._markerPermissionAssignments.findIndex((a) => a.recordName === recordName &&
574
+ a.subjectType === subjectType &&
575
+ a.subjectId === subjectId &&
576
+ a.marker === marker &&
577
+ a.resourceKind === resourceKind &&
578
+ a.action === action);
579
+ if (assignmentIndex >= 0) {
580
+ const assignment = this._markerPermissionAssignments[assignmentIndex];
581
+ this._markerPermissionAssignments[assignmentIndex] = Object.assign(Object.assign({}, assignment), { options,
582
+ expireTimeMs });
583
+ return {
584
+ success: true,
585
+ permissionAssignment: assignment,
586
+ };
587
+ }
588
+ const userId = getSubjectUserId(subjectType, subjectId);
589
+ const assignment = {
590
+ id: uuid(),
591
+ recordName,
592
+ userId,
593
+ subjectType,
594
+ subjectId,
595
+ resourceKind,
596
+ marker,
597
+ action,
598
+ options,
599
+ expireTimeMs,
600
+ };
601
+ this._markerPermissionAssignments.push(assignment);
602
+ return {
603
+ success: true,
604
+ permissionAssignment: assignment,
605
+ };
606
+ });
607
+ }
608
+ getMarkerPermissionAssignmentById(id) {
609
+ var _a;
610
+ return __awaiter(this, void 0, void 0, function* () {
611
+ return ((_a = this._markerPermissionAssignments.find((a) => a.id === id)) !== null && _a !== void 0 ? _a : null);
612
+ });
613
+ }
614
+ getResourcePermissionAssignmentById(id) {
615
+ var _a;
616
+ return __awaiter(this, void 0, void 0, function* () {
617
+ return ((_a = this._resourcePermissionAssignments.find((a) => a.id === id)) !== null && _a !== void 0 ? _a : null);
618
+ });
619
+ }
620
+ deleteResourcePermissionAssignment(assigment) {
621
+ return __awaiter(this, void 0, void 0, function* () {
622
+ this._resourcePermissionAssignments =
623
+ this._resourcePermissionAssignments.filter((p) => p.id !== assigment.id);
624
+ return {
625
+ success: true,
626
+ };
627
+ });
628
+ }
629
+ deleteResourcePermissionAssignmentById(id) {
630
+ return __awaiter(this, void 0, void 0, function* () {
631
+ this._resourcePermissionAssignments =
632
+ this._resourcePermissionAssignments.filter((p) => p.id !== id);
633
+ return {
634
+ success: true,
635
+ };
636
+ });
637
+ }
638
+ deleteMarkerPermissionAssignment(assigment) {
639
+ return __awaiter(this, void 0, void 0, function* () {
640
+ this._markerPermissionAssignments =
641
+ this._markerPermissionAssignments.filter((p) => p.id !== assigment.id);
642
+ return {
643
+ success: true,
644
+ };
645
+ });
646
+ }
647
+ deleteMarkerPermissionAssignmentById(id) {
648
+ return __awaiter(this, void 0, void 0, function* () {
649
+ this._markerPermissionAssignments =
650
+ this._markerPermissionAssignments.filter((p) => p.id !== id);
651
+ return {
652
+ success: true,
653
+ };
654
+ });
655
+ }
656
+ listPermissionsInRecord(recordName) {
657
+ return __awaiter(this, void 0, void 0, function* () {
658
+ const resourceAssignments = this._resourcePermissionAssignments.filter((p) => p.recordName === recordName);
659
+ const markerAssignments = this._markerPermissionAssignments.filter((p) => p.recordName === recordName);
660
+ return {
661
+ success: true,
662
+ resourceAssignments,
663
+ markerAssignments,
664
+ };
665
+ });
666
+ }
667
+ listPermissionsForResource(recordName, resourceKind, resourceId) {
668
+ return __awaiter(this, void 0, void 0, function* () {
669
+ return this._resourcePermissionAssignments.filter((p) => p.recordName === recordName &&
670
+ p.resourceKind === resourceKind &&
671
+ p.resourceId === resourceId);
672
+ });
673
+ }
674
+ listPermissionsForMarker(recordName, marker) {
675
+ return __awaiter(this, void 0, void 0, function* () {
676
+ return this._markerPermissionAssignments.filter((p) => p.recordName === recordName && p.marker === marker);
677
+ });
678
+ }
679
+ listPermissionsForSubject(recordName, subjectType, subjectId) {
680
+ return __awaiter(this, void 0, void 0, function* () {
681
+ const resourceAssignments = this._resourcePermissionAssignments.filter((p) => p.recordName === recordName &&
682
+ p.subjectType === subjectType &&
683
+ p.subjectId === subjectId);
684
+ const markerAssignments = this._markerPermissionAssignments.filter((p) => p.recordName === recordName &&
685
+ p.subjectType === subjectType &&
686
+ p.subjectId === subjectId);
687
+ return {
688
+ success: true,
689
+ resourceAssignments,
690
+ markerAssignments,
691
+ };
692
+ });
693
+ }
401
694
  countRecords(filter) {
402
695
  return __awaiter(this, void 0, void 0, function* () {
403
696
  let count = 0;
@@ -866,6 +1159,46 @@ export class MemoryStore {
866
1159
  success: true,
867
1160
  items,
868
1161
  totalCount: count,
1162
+ marker: null,
1163
+ };
1164
+ });
1165
+ }
1166
+ listDataByMarker(request) {
1167
+ var _a;
1168
+ return __awaiter(this, void 0, void 0, function* () {
1169
+ const marker = request.marker;
1170
+ let record = this._getDataRecord(request.recordName);
1171
+ let items = [];
1172
+ const address = request.startingAddress;
1173
+ const sortAscending = ((_a = request.sort) !== null && _a !== void 0 ? _a : 'ascending') === 'ascending';
1174
+ let count = 0;
1175
+ for (let [key, item] of record.entries()) {
1176
+ if (item.markers.includes(marker)) {
1177
+ count += 1;
1178
+ if (!address ||
1179
+ (sortAscending && key > address) ||
1180
+ (!sortAscending && key < address)) {
1181
+ items.push({
1182
+ address: key,
1183
+ data: item.data,
1184
+ markers: item.markers,
1185
+ });
1186
+ }
1187
+ }
1188
+ }
1189
+ if (request.sort) {
1190
+ if (request.sort === 'ascending') {
1191
+ items = sortBy(items, (i) => i.address);
1192
+ }
1193
+ else if (request.sort === 'descending') {
1194
+ items = orderBy(items, (i) => i.address, 'desc');
1195
+ }
1196
+ }
1197
+ return {
1198
+ success: true,
1199
+ items,
1200
+ totalCount: count,
1201
+ marker: marker,
869
1202
  };
870
1203
  });
871
1204
  }
@@ -1126,85 +1459,87 @@ export class MemoryStore {
1126
1459
  }
1127
1460
  return record;
1128
1461
  }
1129
- listUserPolicies(recordName, startingMarker) {
1130
- var _a;
1131
- return __awaiter(this, void 0, void 0, function* () {
1132
- const recordPolicies = (_a = this.policies[recordName]) !== null && _a !== void 0 ? _a : {};
1133
- const keys = sortBy(Object.keys(recordPolicies));
1134
- let results = [];
1135
- let start = !startingMarker;
1136
- for (let key of keys) {
1137
- if (start) {
1138
- results.push({
1139
- marker: key,
1140
- document: recordPolicies[key].document,
1141
- markers: recordPolicies[key].markers,
1142
- });
1143
- }
1144
- else if (key === startingMarker || key > startingMarker) {
1145
- start = true;
1146
- }
1147
- }
1148
- return {
1149
- success: true,
1150
- policies: results,
1151
- totalCount: results.length,
1152
- };
1153
- });
1154
- }
1155
- getUserPolicy(recordName, marker) {
1156
- var _a;
1157
- return __awaiter(this, void 0, void 0, function* () {
1158
- const policy = (_a = this.policies[recordName]) === null || _a === void 0 ? void 0 : _a[marker];
1159
- if (!policy) {
1160
- return {
1161
- success: false,
1162
- errorCode: 'policy_not_found',
1163
- errorMessage: 'The policy was not found.',
1164
- };
1165
- }
1166
- return {
1167
- success: true,
1168
- document: policy.document,
1169
- markers: policy.markers,
1170
- };
1171
- });
1172
- }
1173
- updateUserPolicy(recordName, marker, policy) {
1174
- return __awaiter(this, void 0, void 0, function* () {
1175
- if (!this.policies[recordName]) {
1176
- this.policies[recordName] = {};
1177
- }
1178
- this.policies[recordName][marker] = {
1179
- document: policy.document,
1180
- markers: policy.markers,
1181
- };
1182
- return {
1183
- success: true,
1184
- };
1185
- });
1186
- }
1187
- listPoliciesForMarkerAndUser(recordName, userId, marker) {
1188
- var _a;
1189
- return __awaiter(this, void 0, void 0, function* () {
1190
- const policies = [DEFAULT_ANY_RESOURCE_POLICY_DOCUMENT];
1191
- if (marker === PUBLIC_READ_MARKER) {
1192
- policies.push(DEFAULT_PUBLIC_READ_POLICY_DOCUMENT);
1193
- }
1194
- else if (marker === PUBLIC_WRITE_MARKER) {
1195
- policies.push(DEFAULT_PUBLIC_WRITE_POLICY_DOCUMENT);
1196
- }
1197
- const policy = (_a = this.policies[recordName]) === null || _a === void 0 ? void 0 : _a[marker];
1198
- if (policy) {
1199
- policies.push(policy.document);
1200
- }
1201
- return {
1202
- policies,
1203
- recordOwnerPrivacyFeatures: yield this._getRecordOwnerPrivacyFeatures(recordName),
1204
- userPrivacyFeatures: yield this._getUserPrivacyFeatures(userId),
1205
- };
1206
- });
1207
- }
1462
+ // async listUserPolicies(
1463
+ // recordName: string,
1464
+ // startingMarker: string
1465
+ // ): Promise<ListUserPoliciesStoreResult> {
1466
+ // const recordPolicies = this.policies[recordName] ?? {};
1467
+ // const keys = sortBy(Object.keys(recordPolicies));
1468
+ // let results: ListedUserPolicy[] = [];
1469
+ // let start = !startingMarker;
1470
+ // for (let key of keys) {
1471
+ // if (start) {
1472
+ // results.push({
1473
+ // marker: key,
1474
+ // document: recordPolicies[key].document,
1475
+ // markers: recordPolicies[key].markers,
1476
+ // });
1477
+ // } else if (key === startingMarker || key > startingMarker) {
1478
+ // start = true;
1479
+ // }
1480
+ // }
1481
+ // return {
1482
+ // success: true,
1483
+ // policies: results,
1484
+ // totalCount: results.length,
1485
+ // };
1486
+ // }
1487
+ // async getUserPolicy(
1488
+ // recordName: string,
1489
+ // marker: string
1490
+ // ): Promise<GetUserPolicyResult> {
1491
+ // const policy = this.policies[recordName]?.[marker];
1492
+ // if (!policy) {
1493
+ // return {
1494
+ // success: false,
1495
+ // errorCode: 'policy_not_found',
1496
+ // errorMessage: 'The policy was not found.',
1497
+ // };
1498
+ // }
1499
+ // return {
1500
+ // success: true,
1501
+ // document: policy.document,
1502
+ // markers: policy.markers,
1503
+ // };
1504
+ // }
1505
+ // async updateUserPolicy(
1506
+ // recordName: string,
1507
+ // marker: string,
1508
+ // policy: UserPolicyRecord
1509
+ // ): Promise<UpdateUserPolicyResult> {
1510
+ // if (!this.policies[recordName]) {
1511
+ // this.policies[recordName] = {};
1512
+ // }
1513
+ // this.policies[recordName][marker] = {
1514
+ // document: policy.document,
1515
+ // markers: policy.markers,
1516
+ // };
1517
+ // return {
1518
+ // success: true,
1519
+ // };
1520
+ // }
1521
+ // async listPoliciesForMarkerAndUser(
1522
+ // recordName: string,
1523
+ // userId: string,
1524
+ // marker: string
1525
+ // ): Promise<ListMarkerPoliciesResult> {
1526
+ // const policies = [DEFAULT_ANY_RESOURCE_POLICY_DOCUMENT];
1527
+ // if (marker === PUBLIC_READ_MARKER) {
1528
+ // policies.push(DEFAULT_PUBLIC_READ_POLICY_DOCUMENT);
1529
+ // } else if (marker === PUBLIC_WRITE_MARKER) {
1530
+ // policies.push(DEFAULT_PUBLIC_WRITE_POLICY_DOCUMENT);
1531
+ // }
1532
+ // const policy = this.policies[recordName]?.[marker];
1533
+ // if (policy) {
1534
+ // policies.push(policy.document);
1535
+ // }
1536
+ // return {
1537
+ // policies,
1538
+ // recordOwnerPrivacyFeatures:
1539
+ // await this._getRecordOwnerPrivacyFeatures(recordName),
1540
+ // userPrivacyFeatures: await this._getUserPrivacyFeatures(userId),
1541
+ // };
1542
+ // }
1208
1543
  _getRecordOwnerPrivacyFeatures(recordName) {
1209
1544
  return __awaiter(this, void 0, void 0, function* () {
1210
1545
  let record = yield this.getRecordByName(recordName);
@@ -1356,34 +1691,46 @@ export class MemoryStore {
1356
1691
  };
1357
1692
  });
1358
1693
  }
1359
- updateUserRoles(recordName, userId, update) {
1360
- return __awaiter(this, void 0, void 0, function* () {
1361
- if (!this.roleAssignments[recordName]) {
1362
- this.roleAssignments[recordName] = {};
1363
- }
1364
- const assignments = update.roles
1365
- .filter((r) => getExpireTime(r.expireTimeMs) > Date.now())
1366
- .map((r) => (Object.assign(Object.assign({}, r), { expireTimeMs: r.expireTimeMs === Infinity ? null : r.expireTimeMs })));
1367
- this.roleAssignments[recordName][userId] = assignments;
1368
- return {
1369
- success: true,
1370
- };
1371
- });
1372
- }
1373
- updateInstRoles(recordName, inst, update) {
1374
- return __awaiter(this, void 0, void 0, function* () {
1375
- if (!this.roleAssignments[recordName]) {
1376
- this.roleAssignments[recordName] = {};
1377
- }
1378
- const assignments = update.roles
1379
- .filter((r) => getExpireTime(r.expireTimeMs) > Date.now())
1380
- .map((r) => (Object.assign(Object.assign({}, r), { expireTimeMs: r.expireTimeMs === Infinity ? null : r.expireTimeMs })));
1381
- this.roleAssignments[recordName][inst] = assignments;
1382
- return {
1383
- success: true,
1384
- };
1385
- });
1386
- }
1694
+ // async updateUserRoles(
1695
+ // recordName: string,
1696
+ // userId: string,
1697
+ // update: UpdateRolesUpdate
1698
+ // ): Promise<UpdateUserRolesResult> {
1699
+ // if (!this.roleAssignments[recordName]) {
1700
+ // this.roleAssignments[recordName] = {};
1701
+ // }
1702
+ // const assignments = update.roles
1703
+ // .filter((r) => getExpireTime(r.expireTimeMs) > Date.now())
1704
+ // .map((r) => ({
1705
+ // ...r,
1706
+ // expireTimeMs:
1707
+ // r.expireTimeMs === Infinity ? null : r.expireTimeMs,
1708
+ // }));
1709
+ // this.roleAssignments[recordName][userId] = assignments;
1710
+ // return {
1711
+ // success: true,
1712
+ // };
1713
+ // }
1714
+ // async updateInstRoles(
1715
+ // recordName: string,
1716
+ // inst: string,
1717
+ // update: UpdateRolesUpdate
1718
+ // ): Promise<UpdateUserRolesResult> {
1719
+ // if (!this.roleAssignments[recordName]) {
1720
+ // this.roleAssignments[recordName] = {};
1721
+ // }
1722
+ // const assignments = update.roles
1723
+ // .filter((r) => getExpireTime(r.expireTimeMs) > Date.now())
1724
+ // .map((r) => ({
1725
+ // ...r,
1726
+ // expireTimeMs:
1727
+ // r.expireTimeMs === Infinity ? null : r.expireTimeMs,
1728
+ // }));
1729
+ // this.roleAssignments[recordName][inst] = assignments;
1730
+ // return {
1731
+ // success: true,
1732
+ // };
1733
+ // }
1387
1734
  _getRolesForEntity(recordName, id) {
1388
1735
  var _a, _b, _c, _d;
1389
1736
  const roles = (_b = (_a = this.roles[recordName]) === null || _a === void 0 ? void 0 : _a[id]) !== null && _b !== void 0 ? _b : new Set();