herum-shared 0.1.25 → 0.1.28
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/fesm2022/herum-shared-constants.mjs +9 -9
- package/fesm2022/herum-shared-constants.mjs.map +1 -1
- package/fesm2022/herum-shared-herum-types.mjs +3 -2
- package/fesm2022/herum-shared-herum-types.mjs.map +1 -1
- package/fesm2022/herum-shared-mongo-services.mjs +2 -2
- package/fesm2022/herum-shared-mongo-services.mjs.map +1 -1
- package/fesm2022/herum-shared-mongo.mjs +2 -2
- package/fesm2022/herum-shared-mongo.mjs.map +1 -1
- package/fesm2022/herum-shared-services.mjs +129 -22
- package/fesm2022/herum-shared-services.mjs.map +1 -1
- package/fesm2022/herum-shared-static-services.mjs +1 -69
- package/fesm2022/herum-shared-static-services.mjs.map +1 -1
- package/fesm2022/herum-shared-table.mjs +17 -4
- package/fesm2022/herum-shared-table.mjs.map +1 -1
- package/fesm2022/herum-shared-utils.mjs +34 -40
- package/fesm2022/herum-shared-utils.mjs.map +1 -1
- package/fesm2022/herum-shared.mjs +156 -166
- package/fesm2022/herum-shared.mjs.map +1 -1
- package/herum-types/index.d.ts +5 -3
- package/index.d.ts +6 -4
- package/mongo/index.d.ts +1 -1
- package/mongo/services/index.d.ts +1 -1
- package/package.json +1 -1
- package/services/index.d.ts +17 -4
- package/static-services/index.d.ts +1 -14
- package/table/index.d.ts +3 -1
- package/utils/index.d.ts +2 -3
|
@@ -7,11 +7,11 @@ import { shareReplay, map, switchMap, tap } from 'rxjs/operators';
|
|
|
7
7
|
import { StorageService } from 'herum-shared/static-services';
|
|
8
8
|
import { selfIsTeacherExample, closedListExample, permissionsTemplatesExample } from 'herum-shared/objectsExample';
|
|
9
9
|
import { HERUM_SHARED_CONFIG_TOKEN } from 'herum-shared/environment';
|
|
10
|
-
import { toHash, buildPath, setHeaders, remainJustWantedValueInDictionary,
|
|
10
|
+
import { toHash, buildPath, setHeaders, remainJustWantedValueInDictionary, getVersionPathParameter } from 'herum-shared/utils';
|
|
11
11
|
import * as i2 from '@angular/router';
|
|
12
|
-
import { regexExpressions, generalKeys, uploadsManagerKeys, skipToastHeader, assignmentMetadata, attributes, defaultGrade, defaultAuthorizationObject, resourceIdPlaceholder, resourcesFilesSuffixes, system } from 'herum-shared/constants';
|
|
12
|
+
import { regexExpressions, generalKeys, uploadsManagerKeys, skipToastHeader, assignmentMetadata, attributes, defaultGrade, defaultAuthorizationObject, resourceIdPlaceholder, getPublishAuthorization, getMongoMethodsDisplayedNamesMap, resourcesFilesSuffixes, system } from 'herum-shared/constants';
|
|
13
13
|
import * as i1$1 from 'herum-shared/herum-types';
|
|
14
|
-
import {
|
|
14
|
+
import { microResourceAuthorizationType } from 'herum-shared/herum-types';
|
|
15
15
|
import { cloneDeep } from 'lodash';
|
|
16
16
|
import { DOCUMENT } from '@angular/common';
|
|
17
17
|
import { SYSTEM_TRACK_TEXT_CHANGES_SERVICE } from 'herum-shared/tokens';
|
|
@@ -824,43 +824,43 @@ class MicroResourcesService {
|
|
|
824
824
|
collectionItemType: '',
|
|
825
825
|
openingTime,
|
|
826
826
|
closingTime,
|
|
827
|
-
authorizationType:
|
|
827
|
+
authorizationType: microResourceAuthorizationType.update
|
|
828
828
|
},
|
|
829
829
|
{
|
|
830
830
|
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[1]?.id, freeTextAnswerField),
|
|
831
831
|
collectionItemType: '',
|
|
832
832
|
openingTime,
|
|
833
833
|
closingTime,
|
|
834
|
-
authorizationType:
|
|
834
|
+
authorizationType: microResourceAuthorizationType.update
|
|
835
835
|
}];
|
|
836
836
|
}
|
|
837
837
|
getPublishGradeTimings(selectedResource, openingTime = new Date(2999, 1, 1), closingTime) {
|
|
838
838
|
return [{
|
|
839
|
-
authorizationType:
|
|
839
|
+
authorizationType: microResourceAuthorizationType.view,
|
|
840
840
|
closingTime: closingTime,
|
|
841
841
|
collectionItemType: "",
|
|
842
842
|
openingTime: openingTime,
|
|
843
843
|
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[0].id, gradeField)
|
|
844
844
|
}, {
|
|
845
|
-
authorizationType:
|
|
845
|
+
authorizationType: microResourceAuthorizationType.view,
|
|
846
846
|
closingTime: closingTime,
|
|
847
847
|
collectionItemType: "",
|
|
848
848
|
openingTime: openingTime,
|
|
849
849
|
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[1].id, gradeField)
|
|
850
850
|
}, {
|
|
851
|
-
authorizationType:
|
|
851
|
+
authorizationType: microResourceAuthorizationType.view,
|
|
852
852
|
closingTime: closingTime,
|
|
853
853
|
collectionItemType: "",
|
|
854
854
|
openingTime: openingTime,
|
|
855
855
|
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[0].id, answerNotesField)
|
|
856
856
|
}, {
|
|
857
|
-
authorizationType:
|
|
857
|
+
authorizationType: microResourceAuthorizationType.view,
|
|
858
858
|
closingTime: closingTime,
|
|
859
859
|
collectionItemType: "",
|
|
860
860
|
openingTime: openingTime,
|
|
861
861
|
propertyPath: this.buildQuestionPropertyPath(selectedResource.quiz.questions[1].id, answerNotesField)
|
|
862
862
|
}, {
|
|
863
|
-
authorizationType:
|
|
863
|
+
authorizationType: microResourceAuthorizationType.view,
|
|
864
864
|
closingTime: closingTime,
|
|
865
865
|
collectionItemType: "",
|
|
866
866
|
openingTime: openingTime,
|
|
@@ -882,7 +882,7 @@ class MicroResourcesService {
|
|
|
882
882
|
collectionItemType: microResource.collectionItemType,
|
|
883
883
|
openingTime: microResource.openingTime,
|
|
884
884
|
closingTime: microResource.closingTime,
|
|
885
|
-
authorizationType:
|
|
885
|
+
authorizationType: microResourceAuthorizationType.view
|
|
886
886
|
});
|
|
887
887
|
return this.updateUserMicroResourceAuthorization(user.student.id, lesson, resource, resource.microResourceAuthorizations);
|
|
888
888
|
}
|
|
@@ -916,7 +916,7 @@ class MicroResourcesService {
|
|
|
916
916
|
isQuestionPendingForCheck(resourceSubscription, questionData) {
|
|
917
917
|
const microResourceAuthorizations = resourceSubscription.microResourceAuthorizations;
|
|
918
918
|
const questionId = questionData.id;
|
|
919
|
-
const questionClosingTime = microResourceAuthorizations?.find(microResourceAuthorization => microResourceAuthorization.propertyPath === this.buildQuestionPropertyPath(questionId, freeTextAnswerField) && microResourceAuthorization.authorizationType ===
|
|
919
|
+
const questionClosingTime = microResourceAuthorizations?.find(microResourceAuthorization => microResourceAuthorization.propertyPath === this.buildQuestionPropertyPath(questionId, freeTextAnswerField) && microResourceAuthorization.authorizationType === microResourceAuthorizationType.update)?.closingTime;
|
|
920
920
|
const gradePublishOpeningTime = microResourceAuthorizations?.find(microResourceAuthorization => microResourceAuthorization.propertyPath === this.buildQuestionPropertyPath(questionId, gradeField))?.openingTime;
|
|
921
921
|
let isQuestionPendingForCheck = false;
|
|
922
922
|
if (questionClosingTime && questionData.grade === defaultGrade) {
|
|
@@ -931,16 +931,16 @@ class MicroResourcesService {
|
|
|
931
931
|
}
|
|
932
932
|
hasFillAuthorizationClosingTimePassed(innerAuthorizations, resource) {
|
|
933
933
|
const fillAuthorizationPropertyPath = defaultAuthorizationObject.fill().propertyPath.replace(resourceIdPlaceholder, resource.id);
|
|
934
|
-
const fillAuthorization = innerAuthorizations?.find(auth => auth.propertyPath == fillAuthorizationPropertyPath && auth.authorizationType ==
|
|
934
|
+
const fillAuthorization = innerAuthorizations?.find(auth => auth.propertyPath == fillAuthorizationPropertyPath && auth.authorizationType == microResourceAuthorizationType.fill);
|
|
935
935
|
return this.isTimePass(fillAuthorization?.closingTime);
|
|
936
936
|
}
|
|
937
937
|
isPublishGradeAuthenticated(innerAuthorizations, resource) {
|
|
938
|
-
const publishGradeInnerAuthorizations = this.getAuthorization(innerAuthorizations, defaultAuthorizationObject.resourceGrade(),
|
|
938
|
+
const publishGradeInnerAuthorizations = this.getAuthorization(innerAuthorizations, defaultAuthorizationObject.resourceGrade(), microResourceAuthorizationType.view, resource);
|
|
939
939
|
return publishGradeInnerAuthorizations ? this.isAuthenticated(publishGradeInnerAuthorizations) : false;
|
|
940
940
|
}
|
|
941
|
-
getAuthorization(innerAuthorizations, defaultAuthorizationObject,
|
|
941
|
+
getAuthorization(innerAuthorizations, defaultAuthorizationObject, microResourceAuthorizationType, resource) {
|
|
942
942
|
const fillAuthorizationPropertyPath = defaultAuthorizationObject.propertyPath.replace(resourceIdPlaceholder, resource.id);
|
|
943
|
-
return innerAuthorizations.find((innerAuthorization) => innerAuthorization.propertyPath === fillAuthorizationPropertyPath && innerAuthorization.authorizationType ===
|
|
943
|
+
return innerAuthorizations.find((innerAuthorization) => innerAuthorization.propertyPath === fillAuthorizationPropertyPath && innerAuthorization.authorizationType === microResourceAuthorizationType);
|
|
944
944
|
}
|
|
945
945
|
createMultiResourceDefaultAuthorizations(students, pageId, resourcesIds, defaultAuthorizations, authorizations) {
|
|
946
946
|
const updates = [];
|
|
@@ -973,6 +973,44 @@ class MicroResourcesService {
|
|
|
973
973
|
return this.http.post(this.environmentConfig?.environment?.siteServerPath + this.environmentConfig?.resourcePaths?.resourceUpdateAuthorizations, request);
|
|
974
974
|
}));
|
|
975
975
|
}
|
|
976
|
+
copyResourceStudentsAuthorizations(students, pageId, authSourceResourceId, authTargetResourceId, useDefaultGradePermissions) {
|
|
977
|
+
const updates = [];
|
|
978
|
+
students.forEach(student => {
|
|
979
|
+
let sourceResourceAuthorizations = student.innerAuthorizations.filter(innerAuthorization => innerAuthorization.propertyPath.includes(authSourceResourceId));
|
|
980
|
+
sourceResourceAuthorizations = cloneDeep(sourceResourceAuthorizations);
|
|
981
|
+
let targetResourceAuthorizations = sourceResourceAuthorizations.map(authorization => ({
|
|
982
|
+
...authorization,
|
|
983
|
+
lastUpDateTime: new Date(),
|
|
984
|
+
propertyPath: authorization.propertyPath.replace(authSourceResourceId, authTargetResourceId)
|
|
985
|
+
}));
|
|
986
|
+
if (useDefaultGradePermissions) {
|
|
987
|
+
let defaultGradePermissions = cloneDeep(getPublishAuthorization());
|
|
988
|
+
defaultGradePermissions.forEach(authorization => authorization.propertyPath = authorization.propertyPath.replace(resourceIdPlaceholder, authTargetResourceId));
|
|
989
|
+
targetResourceAuthorizations = targetResourceAuthorizations.filter(authorization => !defaultGradePermissions.some(defaultGradePermission => defaultGradePermission.propertyPath == authorization.propertyPath));
|
|
990
|
+
targetResourceAuthorizations = [...targetResourceAuthorizations, ...defaultGradePermissions];
|
|
991
|
+
}
|
|
992
|
+
updates.push({
|
|
993
|
+
userIds: [student.user?.id],
|
|
994
|
+
hadrachaPageId: pageId,
|
|
995
|
+
authorizations: [...(student.innerAuthorizations || []), ...(targetResourceAuthorizations || [])]
|
|
996
|
+
});
|
|
997
|
+
});
|
|
998
|
+
return forkJoin(updates.map(request => this.http.post(this.environmentConfig?.environment?.siteServerPath + this.environmentConfig?.resourcePaths?.resourceUpdateAuthorizations, request)));
|
|
999
|
+
}
|
|
1000
|
+
removeResourceAuthorizations(page, resourcesIdsToRemove) {
|
|
1001
|
+
const updates = [];
|
|
1002
|
+
resourcesIdsToRemove.forEach(resourceIdToRemove => {
|
|
1003
|
+
page.students.forEach(student => {
|
|
1004
|
+
let resourceAuthorizationsToKeep = student.innerAuthorizations.filter(innerAuthorization => innerAuthorization.propertyPath.includes(resourceIdToRemove));
|
|
1005
|
+
updates.push({
|
|
1006
|
+
userIds: [student.user?.id],
|
|
1007
|
+
hadrachaPageId: page.id,
|
|
1008
|
+
authorizations: resourceAuthorizationsToKeep
|
|
1009
|
+
});
|
|
1010
|
+
});
|
|
1011
|
+
});
|
|
1012
|
+
return forkJoin(updates.map(request => this.http.post(this.environmentConfig?.environment?.siteServerPath + this.environmentConfig?.resourcePaths?.resourceUpdateAuthorizations, request)));
|
|
1013
|
+
}
|
|
976
1014
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: MicroResourcesService, deps: [{ token: i1.HttpClient }, { token: HERUM_SHARED_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
977
1015
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: MicroResourcesService, providedIn: 'root' });
|
|
978
1016
|
}
|
|
@@ -986,21 +1024,90 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
|
|
|
986
1024
|
args: [HERUM_SHARED_CONFIG_TOKEN]
|
|
987
1025
|
}] }] });
|
|
988
1026
|
|
|
989
|
-
class
|
|
1027
|
+
class UtilsService {
|
|
990
1028
|
environmentConfig;
|
|
991
1029
|
constructor(environmentConfig) {
|
|
992
1030
|
this.environmentConfig = environmentConfig;
|
|
993
1031
|
}
|
|
1032
|
+
getDisplayedNameForMongoMethodByUserActivity(urlRequest) {
|
|
1033
|
+
let mongoMethodDisplayedName;
|
|
1034
|
+
const mongoMethodsDisplayedNamesMap = getMongoMethodsDisplayedNamesMap(this.environmentConfig?.mongoUpdates, this.environmentConfig?.authenticationPaths);
|
|
1035
|
+
Object.entries(mongoMethodsDisplayedNamesMap).forEach(([mongoMethod, displayedName]) => {
|
|
1036
|
+
const urlParts = urlRequest?.split('/');
|
|
1037
|
+
const matchedMethod = urlParts?.find(urlPart => urlPart === mongoMethod);
|
|
1038
|
+
if (matchedMethod)
|
|
1039
|
+
mongoMethodDisplayedName = displayedName;
|
|
1040
|
+
});
|
|
1041
|
+
return mongoMethodDisplayedName;
|
|
1042
|
+
}
|
|
1043
|
+
getUrlFromFileData(fileData) {
|
|
1044
|
+
if (!fileData?.key || !fileData?.bucket)
|
|
1045
|
+
return;
|
|
1046
|
+
const fileDataKeyWithoutTrailingSlash = fileData.key.endsWith('/') ? fileData.key.slice(0, -1) : fileData.key;
|
|
1047
|
+
return buildPath([this.environmentConfig?.environment?.s3ServerPath + fileData.bucket, fileDataKeyWithoutTrailingSlash]);
|
|
1048
|
+
}
|
|
1049
|
+
fetchFiles(fileId, resourceType, bucket) {
|
|
1050
|
+
if (!fileId)
|
|
1051
|
+
return Promise.reject();
|
|
1052
|
+
const bucketPath = bucket ? bucket : this.environmentConfig?.buckets[resourceType];
|
|
1053
|
+
if (fileId && fileId[0] != '/' && bucketPath[bucketPath.length - 1] != '/')
|
|
1054
|
+
fileId = "/" + fileId;
|
|
1055
|
+
const path = this.environmentConfig?.environment?.s3ServerPath + bucketPath + fileId;
|
|
1056
|
+
return fetch(path);
|
|
1057
|
+
}
|
|
1058
|
+
async initAudioFile(fileId, bucketName, signal) {
|
|
1059
|
+
const audioBucketName = bucketName ? (bucketName + "/") : this.environmentConfig?.buckets.Audio;
|
|
1060
|
+
return fetch(this.environmentConfig?.environment?.s3ServerPath + audioBucketName + fileId, { signal: signal })
|
|
1061
|
+
.then(async (response) => {
|
|
1062
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
1063
|
+
if (arrayBuffer.byteLength === 0) {
|
|
1064
|
+
const blob = await response.blob();
|
|
1065
|
+
const reader = new FileReader();
|
|
1066
|
+
reader.onload = () => {
|
|
1067
|
+
const arrayBuffer = reader.result;
|
|
1068
|
+
const file = new File([arrayBuffer], fileId, {
|
|
1069
|
+
type: 'audio/mp3',
|
|
1070
|
+
});
|
|
1071
|
+
return file;
|
|
1072
|
+
};
|
|
1073
|
+
reader.readAsArrayBuffer(blob);
|
|
1074
|
+
}
|
|
1075
|
+
else {
|
|
1076
|
+
const file = new File([arrayBuffer], fileId, {
|
|
1077
|
+
type: 'audio/mpeg',
|
|
1078
|
+
});
|
|
1079
|
+
return file;
|
|
1080
|
+
}
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: UtilsService, deps: [{ token: HERUM_SHARED_CONFIG_TOKEN }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1084
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: UtilsService, providedIn: 'root' });
|
|
1085
|
+
}
|
|
1086
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: UtilsService, decorators: [{
|
|
1087
|
+
type: Injectable,
|
|
1088
|
+
args: [{
|
|
1089
|
+
providedIn: 'root'
|
|
1090
|
+
}]
|
|
1091
|
+
}], ctorParameters: () => [{ type: undefined, decorators: [{
|
|
1092
|
+
type: Inject,
|
|
1093
|
+
args: [HERUM_SHARED_CONFIG_TOKEN]
|
|
1094
|
+
}] }] });
|
|
1095
|
+
|
|
1096
|
+
class ResourceDataBuilderService {
|
|
1097
|
+
utilsService;
|
|
1098
|
+
constructor(utilsService) {
|
|
1099
|
+
this.utilsService = utilsService;
|
|
1100
|
+
}
|
|
994
1101
|
buildFilePath(resource) {
|
|
995
|
-
return getUrlFromFileData(resource.resourceFile
|
|
1102
|
+
return this.utilsService.getUrlFromFileData(resource.resourceFile) + this.getVersionPathParameter(resource);
|
|
996
1103
|
}
|
|
997
1104
|
buildDirectoryPath(resource) {
|
|
998
|
-
return getUrlFromFileData(resource.resourceFile
|
|
1105
|
+
return this.utilsService.getUrlFromFileData(resource.resourceFile) + resourcesFilesSuffixes[resource.resourceType] + this.getVersionPathParameter(resource);
|
|
999
1106
|
}
|
|
1000
1107
|
getVersionPathParameter(resource) {
|
|
1001
1108
|
return getVersionPathParameter(new Date(resource.lastUpdateTime));
|
|
1002
1109
|
}
|
|
1003
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: ResourceDataBuilderService, deps:
|
|
1110
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: ResourceDataBuilderService, deps: [{ token: UtilsService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
1004
1111
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: ResourceDataBuilderService, providedIn: 'root' });
|
|
1005
1112
|
}
|
|
1006
1113
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImport: i0, type: ResourceDataBuilderService, decorators: [{
|
|
@@ -1008,7 +1115,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
|
|
|
1008
1115
|
args: [{
|
|
1009
1116
|
providedIn: 'root'
|
|
1010
1117
|
}]
|
|
1011
|
-
}], ctorParameters: () => [{ type:
|
|
1118
|
+
}], ctorParameters: () => [{ type: UtilsService }] });
|
|
1012
1119
|
|
|
1013
1120
|
class SystemStylingService {
|
|
1014
1121
|
document;
|
|
@@ -1103,5 +1210,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.17", ngImpo
|
|
|
1103
1210
|
* Generated bundle index. Do not edit.
|
|
1104
1211
|
*/
|
|
1105
1212
|
|
|
1106
|
-
export { AuthService, CommonGraphqlRequestsService, DbActionRequestsService, DbActionsInnerIdManagerService, GlobalKeyboardListenerService, GraphQLService, KeyPressService, LoaderManagerService, MicroResourcesService, NestedConditionSigniture, ResourceDataBuilderService, SystemStylingService, TrackTextChangesService, emptyValueFlagForCreationUniqListItem, freeTextAnswerField, innerUniqListItemKey, systemStylingFactory };
|
|
1213
|
+
export { AuthService, CommonGraphqlRequestsService, DbActionRequestsService, DbActionsInnerIdManagerService, GlobalKeyboardListenerService, GraphQLService, KeyPressService, LoaderManagerService, MicroResourcesService, NestedConditionSigniture, ResourceDataBuilderService, SystemStylingService, TrackTextChangesService, UtilsService, emptyValueFlagForCreationUniqListItem, freeTextAnswerField, innerUniqListItemKey, systemStylingFactory };
|
|
1107
1214
|
//# sourceMappingURL=herum-shared-services.mjs.map
|