@vannizhang/living-atlas-content-validator 1.5.17 → 1.5.18-beta.2
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 +1376 -162
- package/dist/configureSettings.d.ts +133 -0
- package/dist/configureSettings.js +61 -0
- package/dist/configureSettings.js.map +1 -0
- package/dist/data/TitleSummaryMatchingPatterns_Locations.json +829 -0
- package/dist/data/TitleSummaryMatchingPatterns_Sources.json +382 -0
- package/dist/data/TitleSummaryMatchingPatterns_Time.json +25 -0
- package/dist/data/TitleSummaryMatchingPatterns_Topics.json +1365 -0
- package/dist/data/TitleSummaryRejectedPatterns.json +44 -0
- package/dist/index.d.ts +27 -9
- package/dist/index.js +55 -9
- package/dist/index.js.map +1 -1
- package/dist/lib/accessInformation/isValidAccessInformation.js +4 -6
- package/dist/lib/accessInformation/isValidAccessInformation.js.map +1 -1
- package/dist/lib/checkProfanities/checkProfanities.d.ts +7 -0
- package/dist/lib/checkProfanities/checkProfanities.js +26 -0
- package/dist/lib/checkProfanities/checkProfanities.js.map +1 -0
- package/dist/lib/checkTitleAndSnippetSearchability/checkTitleAndSnippetSearchability.d.ts +34 -0
- package/dist/lib/{recommendedText/checkRecommendedText.js → checkTitleAndSnippetSearchability/checkTitleAndSnippetSearchability.js} +51 -25
- package/dist/lib/checkTitleAndSnippetSearchability/checkTitleAndSnippetSearchability.js.map +1 -0
- package/dist/lib/checkTitleAndSnippetSearchability/config.d.ts +97 -0
- package/dist/lib/checkTitleAndSnippetSearchability/config.js +41 -0
- package/dist/lib/checkTitleAndSnippetSearchability/config.js.map +1 -0
- package/dist/lib/checkTitleAndSnippetSearchability/data.d.ts +0 -0
- package/dist/lib/checkTitleAndSnippetSearchability/data.js +693 -0
- package/dist/lib/checkTitleAndSnippetSearchability/data.js.map +1 -0
- package/dist/lib/checkTitleAndSnippetSearchability/helpers.d.ts +117 -0
- package/dist/lib/checkTitleAndSnippetSearchability/helpers.js +241 -0
- package/dist/lib/checkTitleAndSnippetSearchability/helpers.js.map +1 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchDateTimeInfo.d.ts +34 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchDateTimeInfo.js +207 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchDateTimeInfo.js.map +1 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchLocationInfo.d.ts +34 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchLocationInfo.js +170 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchLocationInfo.js.map +1 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchSourceInfo.d.ts +34 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchSourceInfo.js +172 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchSourceInfo.js.map +1 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchTopicInfo.d.ts +36 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchTopicInfo.js +175 -0
- package/dist/lib/checkTitleAndSnippetSearchability/matchTopicInfo.js.map +1 -0
- package/dist/lib/checkTitleAndSnippetSearchability/scoringConfig.js.map +1 -0
- package/dist/lib/config.d.ts +4 -1
- package/dist/lib/config.js +5 -5
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/deleteProtection/isDeleteProtectionEnabled.js +6 -2
- package/dist/lib/deleteProtection/isDeleteProtectionEnabled.js.map +1 -1
- package/dist/lib/deprecated/isDeprecated.js +5 -2
- package/dist/lib/deprecated/isDeprecated.js.map +1 -1
- package/dist/lib/description/isValidDescription.js +8 -5
- package/dist/lib/description/isValidDescription.js.map +1 -1
- package/dist/lib/licenseInfo/isValidLicenseInfo.js +5 -2
- package/dist/lib/licenseInfo/isValidLicenseInfo.js.map +1 -1
- package/dist/lib/sharing/isValidAccess.js +5 -2
- package/dist/lib/sharing/isValidAccess.js.map +1 -1
- package/dist/lib/ssl/isValidSSL.js +15 -6
- package/dist/lib/ssl/isValidSSL.js.map +1 -1
- package/dist/lib/summary/isValidSummary.js +6 -3
- package/dist/lib/summary/isValidSummary.js.map +1 -1
- package/dist/lib/tags/isValidTags.js +7 -3
- package/dist/lib/tags/isValidTags.js.map +1 -1
- package/dist/lib/thumbnail/isValidThumbnail.d.ts +6 -1
- package/dist/lib/thumbnail/isValidThumbnail.js +10 -7
- package/dist/lib/thumbnail/isValidThumbnail.js.map +1 -1
- package/dist/lib/title/isValidTitle.js +9 -3
- package/dist/lib/title/isValidTitle.js.map +1 -1
- package/dist/lib/userProfileDescription/isValidUserProfileDescription.js +44 -38
- package/dist/lib/userProfileDescription/isValidUserProfileDescription.js.map +1 -1
- package/dist/lib/userProfileName/isValidUserProfileName.js +8 -5
- package/dist/lib/userProfileName/isValidUserProfileName.js.map +1 -1
- package/dist/lib/userProfileThumbnail/isValidUserProfileThumbnail.js +6 -3
- package/dist/lib/userProfileThumbnail/isValidUserProfileThumbnail.js.map +1 -1
- package/dist/lib/util/containsNonEnglishCharacters.d.ts +13 -0
- package/dist/lib/util/containsNonEnglishCharacters.js +30 -0
- package/dist/lib/util/containsNonEnglishCharacters.js.map +1 -0
- package/dist/lib/util/countSentences.d.ts +23 -0
- package/dist/lib/util/countSentences.js +54 -0
- package/dist/lib/util/countSentences.js.map +1 -0
- package/dist/lib/util/createWordBoundaryRegex.d.ts +46 -0
- package/dist/lib/util/createWordBoundaryRegex.js +77 -0
- package/dist/lib/util/createWordBoundaryRegex.js.map +1 -0
- package/dist/lib/util/escapeSpecialCharacters.d.ts +7 -0
- package/dist/lib/util/escapeSpecialCharacters.js +22 -0
- package/dist/lib/util/escapeSpecialCharacters.js.map +1 -0
- package/dist/lib/util/getLivingAtlasSupportedItemTypes.d.ts +21 -0
- package/dist/lib/util/getLivingAtlasSupportedItemTypes.js +34 -0
- package/dist/lib/util/getLivingAtlasSupportedItemTypes.js.map +1 -0
- package/dist/lib/util/getNumberOfWords.js +6 -2
- package/dist/lib/util/getNumberOfWords.js.map +1 -1
- package/dist/lib/util/getScoringRules.js +6 -0
- package/dist/lib/util/getScoringRules.js.map +1 -1
- package/dist/lib/util/isLayer.js +3 -2
- package/dist/lib/util/isLayer.js.map +1 -1
- package/dist/lib/util/isUrl.d.ts +6 -0
- package/dist/lib/util/isUrl.js +16 -1
- package/dist/lib/util/isUrl.js.map +1 -1
- package/dist/lib/util/isValidRegexPattern.d.ts +7 -0
- package/dist/lib/util/isValidRegexPattern.js +20 -0
- package/dist/lib/util/isValidRegexPattern.js.map +1 -0
- package/dist/lib/util/sanitizeTags.d.ts +6 -0
- package/dist/lib/util/sanitizeTags.js +16 -0
- package/dist/lib/util/sanitizeTags.js.map +1 -0
- package/dist/lib/util/shouldValidateByBetaRules.js +6 -1
- package/dist/lib/util/shouldValidateByBetaRules.js.map +1 -1
- package/dist/lib/util/stringsConfig.d.ts +9 -0
- package/dist/lib/util/stringsConfig.js +9 -1
- package/dist/lib/util/stringsConfig.js.map +1 -1
- package/dist/lib/validate/validate.d.ts +57 -12
- package/dist/lib/validate/validate.js +87 -213
- package/dist/lib/validate/validate.js.map +1 -1
- package/dist/lib/validate/validateHelpers.d.ts +63 -0
- package/dist/lib/validate/validateHelpers.js +157 -0
- package/dist/lib/validate/validateHelpers.js.map +1 -0
- package/dist/locale/de.json +1 -1
- package/dist/locale/en.json +23 -23
- package/dist/locale/es.json +1 -1
- package/dist/locale/fr.json +1 -1
- package/dist/locale/ja.json +1 -1
- package/dist/locale/pt-br.json +1 -1
- package/dist/package-info.json +1 -1
- package/dist/services/content-validator-assets/config.d.ts +4 -0
- package/dist/services/content-validator-assets/config.js +8 -0
- package/dist/services/content-validator-assets/config.js.map +1 -0
- package/dist/services/content-validator-assets/fetchAdditonalPatterns4TitleAndSnippetSearchability.d.ts +95 -0
- package/dist/services/content-validator-assets/fetchAdditonalPatterns4TitleAndSnippetSearchability.js +92 -0
- package/dist/services/content-validator-assets/fetchAdditonalPatterns4TitleAndSnippetSearchability.js.map +1 -0
- package/dist/services/content-validator-assets/fetchProfanitiesData.d.ts +18 -0
- package/dist/services/content-validator-assets/fetchProfanitiesData.js +55 -0
- package/dist/services/content-validator-assets/fetchProfanitiesData.js.map +1 -0
- package/dist/services/content-validator-assets/helpers.d.ts +16 -0
- package/dist/services/content-validator-assets/helpers.js +35 -0
- package/dist/services/content-validator-assets/helpers.js.map +1 -0
- package/dist/services/custom-terms/config.d.ts +27 -0
- package/dist/services/custom-terms/config.js +79 -0
- package/dist/services/custom-terms/config.js.map +1 -0
- package/dist/services/custom-terms/customTerms.d.ts +229 -0
- package/dist/services/custom-terms/customTerms.js +394 -0
- package/dist/services/custom-terms/customTerms.js.map +1 -0
- package/dist/services/custom-terms/helpers.d.ts +8 -0
- package/dist/services/custom-terms/helpers.js +25 -0
- package/dist/services/custom-terms/helpers.js.map +1 -0
- package/dist/services/custom-terms/index.d.ts +3 -0
- package/dist/services/custom-terms/index.js +10 -0
- package/dist/services/custom-terms/index.js.map +1 -0
- package/dist/services/custom-terms-review-results/config.d.ts +31 -0
- package/dist/services/custom-terms-review-results/config.js +78 -0
- package/dist/services/custom-terms-review-results/config.js.map +1 -0
- package/dist/services/custom-terms-review-results/customTermsReviewResults.d.ts +133 -0
- package/dist/services/custom-terms-review-results/customTermsReviewResults.js +276 -0
- package/dist/services/custom-terms-review-results/customTermsReviewResults.js.map +1 -0
- package/dist/services/custom-terms-review-results/helpers.d.ts +24 -0
- package/dist/services/custom-terms-review-results/helpers.js +52 -0
- package/dist/services/custom-terms-review-results/helpers.js.map +1 -0
- package/dist/services/custom-terms-review-results/index.d.ts +4 -0
- package/dist/services/custom-terms-review-results/index.js +13 -0
- package/dist/services/custom-terms-review-results/index.js.map +1 -0
- package/dist/services/shared/addFeatures.d.ts +28 -0
- package/dist/services/shared/addFeatures.js +52 -0
- package/dist/services/shared/addFeatures.js.map +1 -0
- package/dist/services/shared/applyEdits.d.ts +28 -0
- package/dist/services/shared/applyEdits.js +53 -0
- package/dist/services/shared/applyEdits.js.map +1 -0
- package/dist/services/shared/config.d.ts +44 -0
- package/dist/services/shared/config.js +35 -0
- package/dist/services/shared/config.js.map +1 -0
- package/dist/services/shared/getItemInfo.d.ts +36 -0
- package/dist/services/shared/getItemInfo.js +56 -0
- package/dist/services/shared/getItemInfo.js.map +1 -0
- package/dist/types/index.d.ts +25 -22
- package/package.json +4 -3
- package/dist/__tests__/test-data/title-summary-data.json +0 -14654
- package/dist/data/TitleSummaryMatchingPatterns.json +0 -1902
- package/dist/lib/layers/isValidLayerCount.d.ts +0 -12
- package/dist/lib/layers/isValidLayerCount.js +0 -171
- package/dist/lib/layers/isValidLayerCount.js.map +0 -1
- package/dist/lib/layers/scoringConfig.d.ts +0 -10
- package/dist/lib/layers/scoringConfig.js +0 -20
- package/dist/lib/layers/scoringConfig.js.map +0 -1
- package/dist/lib/recommendedText/checkRecommendedText.d.ts +0 -15
- package/dist/lib/recommendedText/checkRecommendedText.js.map +0 -1
- package/dist/lib/recommendedText/helpers.d.ts +0 -15
- package/dist/lib/recommendedText/helpers.js +0 -62
- package/dist/lib/recommendedText/helpers.js.map +0 -1
- package/dist/lib/recommendedText/matchDateTimeInfo.d.ts +0 -9
- package/dist/lib/recommendedText/matchDateTimeInfo.js +0 -81
- package/dist/lib/recommendedText/matchDateTimeInfo.js.map +0 -1
- package/dist/lib/recommendedText/matchLocationInfo.d.ts +0 -9
- package/dist/lib/recommendedText/matchLocationInfo.js +0 -745
- package/dist/lib/recommendedText/matchLocationInfo.js.map +0 -1
- package/dist/lib/recommendedText/matchSourceInfo.d.ts +0 -9
- package/dist/lib/recommendedText/matchSourceInfo.js +0 -32
- package/dist/lib/recommendedText/matchSourceInfo.js.map +0 -1
- package/dist/lib/recommendedText/matchTopicInfo.d.ts +0 -9
- package/dist/lib/recommendedText/matchTopicInfo.js +0 -32
- package/dist/lib/recommendedText/matchTopicInfo.js.map +0 -1
- package/dist/lib/recommendedText/scoringConfig.js.map +0 -1
- /package/dist/lib/{recommendedText → checkTitleAndSnippetSearchability}/scoringConfig.d.ts +0 -0
- /package/dist/lib/{recommendedText → checkTitleAndSnippetSearchability}/scoringConfig.js +0 -0
|
@@ -9,6 +9,8 @@ const isEmpty_1 = require("../util/isEmpty");
|
|
|
9
9
|
const isEmail_1 = require("../util/isEmail");
|
|
10
10
|
const isUrl_1 = require("../util/isUrl");
|
|
11
11
|
const scoringConfig_1 = require("./scoringConfig");
|
|
12
|
+
const countSentences_1 = require("../util/countSentences");
|
|
13
|
+
const getNumberOfWords_1 = require("../util/getNumberOfWords");
|
|
12
14
|
/**
|
|
13
15
|
* Validate an item owner's profile description
|
|
14
16
|
*
|
|
@@ -33,9 +35,9 @@ const scoringConfig_1 = require("./scoringConfig");
|
|
|
33
35
|
const isValidUserProfileDescription = (userProfile
|
|
34
36
|
// item: IItem
|
|
35
37
|
) => {
|
|
36
|
-
const { description } = userProfile;
|
|
38
|
+
const { description } = userProfile || {};
|
|
37
39
|
// scoring rules locale
|
|
38
|
-
const locale = (0, getScoringRules_1.getScoringRulesLocale)(userProfile.culture);
|
|
40
|
+
const locale = (0, getScoringRules_1.getScoringRulesLocale)(userProfile === null || userProfile === void 0 ? void 0 : userProfile.culture);
|
|
39
41
|
const weightFactors = locale === 'en'
|
|
40
42
|
? scoringConfig_1.scoringConfig.weightFactors.DEFAULT
|
|
41
43
|
: scoringConfig_1.scoringConfig.weightFactors.INTERNATIONAL;
|
|
@@ -43,7 +45,7 @@ const isValidUserProfileDescription = (userProfile
|
|
|
43
45
|
// const SCORING = getScoringRules(item, scoringRulesConfig);
|
|
44
46
|
const stringsConfig = (0, stringsConfig_1.getStringsConfig)();
|
|
45
47
|
const issues = {
|
|
46
|
-
property: 'userProfileDescription',
|
|
48
|
+
// property: 'userProfileDescription',
|
|
47
49
|
label: stringsConfig.userProfileDescription.LABEL,
|
|
48
50
|
title: stringsConfig.userProfileDescription.TITLE,
|
|
49
51
|
maxScore: 0,
|
|
@@ -57,7 +59,10 @@ const isValidUserProfileDescription = (userProfile
|
|
|
57
59
|
messages: [],
|
|
58
60
|
weight: scoringConfig_1.scoringConfig.weight,
|
|
59
61
|
weightFactor: 0,
|
|
60
|
-
critical: true,
|
|
62
|
+
// critical: true,
|
|
63
|
+
// the status will be updated afterward based on the validation result
|
|
64
|
+
status: 'unknown',
|
|
65
|
+
isBinaryCheck: false,
|
|
61
66
|
};
|
|
62
67
|
if ((0, assertString_1.assertString)(description) === false || (0, isEmpty_1.isEmpty)(description)) {
|
|
63
68
|
issues.messages.push({
|
|
@@ -69,37 +74,38 @@ const isValidUserProfileDescription = (userProfile
|
|
|
69
74
|
// issues.score += SCORING.USER_PROFILE_DESCRIPTION_HAS_DESCRIPTION;
|
|
70
75
|
issues.weightFactor +=
|
|
71
76
|
weightFactors.USER_PROFILE_DESCRIPTION_HAS_DESCRIPTION_FACTOR;
|
|
72
|
-
let nWords = 0;
|
|
73
|
-
let
|
|
74
|
-
let
|
|
75
|
-
let
|
|
76
|
-
let
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
77
|
+
// let nWords = 0;
|
|
78
|
+
// let nEmailAddresses = 0;
|
|
79
|
+
// let nUrls = 0;
|
|
80
|
+
// let isAUrl = false;
|
|
81
|
+
// let isEmailAddress = false;
|
|
82
|
+
// const cleanedDescription = description.replace(/( | )/gm, ' ');
|
|
83
|
+
// const descriptionArray = cleanedDescription.split(' ');
|
|
84
|
+
const numSentences = (0, countSentences_1.countSentences)(description);
|
|
85
|
+
const numWords = (0, getNumberOfWords_1.getNumberOfWords)(description);
|
|
86
|
+
const containsEmail = (0, isEmail_1.isEmail)(description);
|
|
87
|
+
const foundUrl = (0, isUrl_1.containsUrl)(description);
|
|
88
|
+
// for (const word of descriptionArray) {
|
|
89
|
+
// // skip empty spaces
|
|
90
|
+
// if (!word.length) {
|
|
91
|
+
// continue;
|
|
92
|
+
// }
|
|
93
|
+
// if (isEmail(word)) {
|
|
94
|
+
// // isEmailAddress = true;
|
|
95
|
+
// nEmailAddresses += 1;
|
|
96
|
+
// } else if (isUrl(word)) {
|
|
97
|
+
// // isAUrl = true;
|
|
98
|
+
// nUrls += 1;
|
|
99
|
+
// } else {
|
|
100
|
+
// // if it is not an email and not a url
|
|
101
|
+
// // nWords += 1;
|
|
102
|
+
// }
|
|
103
|
+
// // const lastChar = word[word.length - 1];
|
|
104
|
+
// // if (lastChar === '.' || lastChar === '?' || lastChar === '!') {
|
|
105
|
+
// // nSentences += 1;
|
|
106
|
+
// // }
|
|
107
|
+
// }
|
|
108
|
+
if (containsEmail) {
|
|
103
109
|
// issues.score += SCORING.USER_PROFILE_DESCRIPTION_HAS_EMAIL;
|
|
104
110
|
issues.weightFactor +=
|
|
105
111
|
weightFactors.USER_PROFILE_DESCRIPTION_HAS_EMAIL_FACTOR;
|
|
@@ -110,7 +116,7 @@ const isValidUserProfileDescription = (userProfile
|
|
|
110
116
|
message: stringsConfig.userProfileDescription.NO_VALID_EMAIL_MESSAGE,
|
|
111
117
|
});
|
|
112
118
|
}
|
|
113
|
-
if (
|
|
119
|
+
if (foundUrl) {
|
|
114
120
|
// issues.score += SCORING.USER_PROFILE_DESCRIPTION_HAS_LINK;
|
|
115
121
|
issues.weightFactor +=
|
|
116
122
|
weightFactors.USER_PROFILE_DESCRIPTION_HAS_LINK_FACTOR;
|
|
@@ -122,7 +128,7 @@ const isValidUserProfileDescription = (userProfile
|
|
|
122
128
|
});
|
|
123
129
|
}
|
|
124
130
|
if (locale !== 'international') {
|
|
125
|
-
if (
|
|
131
|
+
if (numWords > 10) {
|
|
126
132
|
// issues.score += SCORING.USER_PROFILE_DESCRIPTION_HAS_MIN_NUM_WORDS;
|
|
127
133
|
issues.weightFactor +=
|
|
128
134
|
weightFactors.USER_PROFILE_DESCRIPTION_HAS_MIN_NUM_WORDS_FACTOR;
|
|
@@ -133,7 +139,7 @@ const isValidUserProfileDescription = (userProfile
|
|
|
133
139
|
message: stringsConfig.userProfileDescription.MIN_NUM_WORDS_MESSAGE,
|
|
134
140
|
});
|
|
135
141
|
}
|
|
136
|
-
if (
|
|
142
|
+
if (numSentences > 2) {
|
|
137
143
|
// issues.score +=
|
|
138
144
|
// SCORING.USER_PROFILE_DESCRIPTION_HAS_MIN_NUM_SENTENCES;
|
|
139
145
|
issues.weightFactor +=
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValidUserProfileDescription.js","sourceRoot":"","sources":["../../../src/lib/userProfileDescription/isValidUserProfileDescription.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,6DAGiC;AAEjC,yDAAyD;AACzD,uDAAoD;AACpD,6CAA0C;AAC1C,6CAA0C;AAC1C,
|
|
1
|
+
{"version":3,"file":"isValidUserProfileDescription.js","sourceRoot":"","sources":["../../../src/lib/userProfileDescription/isValidUserProfileDescription.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,6DAGiC;AAEjC,yDAAyD;AACzD,uDAAoD;AACpD,6CAA0C;AAC1C,6CAA0C;AAC1C,yCAAmD;AACnD,mDAAgD;AAChD,2DAAwD;AACxD,+DAA4D;AAE5D;;;;;;;;;;;;;;;;;;;;GAoBG;AACI,MAAM,6BAA6B,GAAG,CACzC,WAAkB;AAClB,cAAc;EACA,EAAE;IAChB,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,IAAI,EAAE,CAAC;IAE1C,uBAAuB;IACvB,MAAM,MAAM,GAAG,IAAA,uCAAqB,EAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,CAAC;IAE3D,MAAM,aAAa,GACf,MAAM,KAAK,IAAI;QACX,CAAC,CAAC,6BAAa,CAAC,aAA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C;SAC3E;aAAM;YACH,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACjB,6CAA6C;gBAC7C,+BAA+B;gBAC/B,OAAO,EACH,aAAa,CAAC,sBAAsB;qBAC/B,yBAAyB;aACrC,CAAC,CAAC;SACN;KACJ;IAED,2FAA2F;IAC3F,IAAI,MAAM,CAAC,YAAY,IAAI,QAAQ,EAAE;QACjC,MAAM,CAAC,YAAY,GAAG,CAAC,CAAC;KAC3B;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AApJW,QAAA,6BAA6B,iCAoJxC"}
|
|
@@ -19,15 +19,15 @@ const scoringConfig_1 = require("./scoringConfig");
|
|
|
19
19
|
const isValidUserProfileName = (userProfile
|
|
20
20
|
// item: IItem
|
|
21
21
|
) => {
|
|
22
|
-
const { fullName } = userProfile;
|
|
22
|
+
const { fullName } = userProfile || {};
|
|
23
23
|
// scoring rules locale
|
|
24
|
-
const locale = (0, getScoringRules_1.getScoringRulesLocale)(userProfile.culture);
|
|
24
|
+
const locale = (0, getScoringRules_1.getScoringRulesLocale)(userProfile === null || userProfile === void 0 ? void 0 : userProfile.culture);
|
|
25
25
|
// // scoring rules
|
|
26
26
|
// const SCORING = getScoringRules(item, scoringRulesConfig);
|
|
27
27
|
const stringsConfig = (0, stringsConfig_1.getStringsConfig)();
|
|
28
28
|
// issues
|
|
29
29
|
const issues = {
|
|
30
|
-
property: 'userProfileName',
|
|
30
|
+
// property: 'userProfileName',
|
|
31
31
|
label: stringsConfig.userProfileName.LABEL,
|
|
32
32
|
title: stringsConfig.userProfileName.TITLE,
|
|
33
33
|
maxScore: 0,
|
|
@@ -38,9 +38,12 @@ const isValidUserProfileName = (userProfile
|
|
|
38
38
|
messages: [],
|
|
39
39
|
weight: scoringConfig_1.scoringConfig.weight,
|
|
40
40
|
weightFactor: 0,
|
|
41
|
-
critical: false,
|
|
41
|
+
// critical: false,
|
|
42
|
+
// the status will be updated afterward based on the validation result
|
|
43
|
+
status: 'unknown',
|
|
44
|
+
isBinaryCheck: false,
|
|
42
45
|
};
|
|
43
|
-
if (!(0, assertString_1.assertString)(userProfile.fullName) || (0, isEmpty_1.isEmpty)(fullName)) {
|
|
46
|
+
if (!(0, assertString_1.assertString)(userProfile === null || userProfile === void 0 ? void 0 : userProfile.fullName) || (0, isEmpty_1.isEmpty)(fullName)) {
|
|
44
47
|
issues.messages.push({
|
|
45
48
|
// code: stringsConfig.userProfileName.EMPTY_STRING_CODE,
|
|
46
49
|
message: stringsConfig.userProfileName.EMPTY_STRING_MESSAGE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValidUserProfileName.js","sourceRoot":"","sources":["../../../src/lib/userProfileName/isValidUserProfileName.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,6DAGiC;AAEjC,yDAAyD;AACzD,uDAAoD;AACpD,6CAA0C;AAC1C,+CAA4C;AAC5C,mDAAgD;AAEhD;;;;;;;GAOG;AACI,MAAM,sBAAsB,GAAG,CAClC,WAAkB;AAClB,cAAc;EACA,EAAE;IAChB,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"isValidUserProfileName.js","sourceRoot":"","sources":["../../../src/lib/userProfileName/isValidUserProfileName.ts"],"names":[],"mappings":";;;AAAA,yDAAyD;AACzD,6DAGiC;AAEjC,yDAAyD;AACzD,uDAAoD;AACpD,6CAA0C;AAC1C,+CAA4C;AAC5C,mDAAgD;AAEhD;;;;;;;GAOG;AACI,MAAM,sBAAsB,GAAG,CAClC,WAAkB;AAClB,cAAc;EACA,EAAE;IAChB,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,IAAI,EAAE,CAAC;IAEvC,uBAAuB;IACvB,MAAM,MAAM,GAAG,IAAA,uCAAqB,EAAC,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,OAAO,CAAC,CAAC;IAE3D,mBAAmB;IACnB,6DAA6D;IAE7D,MAAM,aAAa,GAAG,IAAA,g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|
|
@@ -20,12 +20,12 @@ const scoringConfig_1 = require("./scoringConfig");
|
|
|
20
20
|
const isValidUserProfileThumbnail = (userProfile
|
|
21
21
|
// item: IItem
|
|
22
22
|
) => {
|
|
23
|
-
const { thumbnail } = userProfile;
|
|
23
|
+
const { thumbnail } = userProfile || {};
|
|
24
24
|
// // scoring rules
|
|
25
25
|
// const SCORING = getScoringRules(item, scoringRulesConfig);
|
|
26
26
|
const stringsConfig = (0, stringsConfig_1.getStringsConfig)();
|
|
27
27
|
const issues = {
|
|
28
|
-
property: 'userProfileThumbnail',
|
|
28
|
+
// property: 'userProfileThumbnail',
|
|
29
29
|
label: stringsConfig.userProfileThumbnail.LABEL,
|
|
30
30
|
title: stringsConfig.userProfileThumbnail.TITLE,
|
|
31
31
|
maxScore:
|
|
@@ -36,7 +36,10 @@ const isValidUserProfileThumbnail = (userProfile
|
|
|
36
36
|
messages: [],
|
|
37
37
|
weight: scoringConfig_1.scoringConfig.weight,
|
|
38
38
|
weightFactor: 0,
|
|
39
|
-
critical: false,
|
|
39
|
+
// critical: false,
|
|
40
|
+
// the status will be updated afterward based on the validation result
|
|
41
|
+
status: 'unknown',
|
|
42
|
+
isBinaryCheck: false,
|
|
40
43
|
};
|
|
41
44
|
if (!thumbnail) {
|
|
42
45
|
issues.messages.push({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isValidUserProfileThumbnail.js","sourceRoot":"","sources":["../../../src/lib/userProfileThumbnail/isValidUserProfileThumbnail.ts"],"names":[],"mappings":";;;AAGA,yDAAyD;AACzD,uEAAoE;AACpE,qGAAkG;AAClG,mDAAgD;AAEhD;;;;;;;;;;;GAWG;AACI,MAAM,2BAA2B,GAAG,CACvC,WAAkB;AAClB,cAAc;EACA,EAAE;IAChB,MAAM,EAAE,SAAS,EAAE,GAAG,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"isValidUserProfileThumbnail.js","sourceRoot":"","sources":["../../../src/lib/userProfileThumbnail/isValidUserProfileTh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,CAAC,iCAAiC,CAAC;KAC7E;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC;AApDW,QAAA,2BAA2B,+BAoDtC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a string contains non-English (non-ASCII) characters.
|
|
3
|
+
*
|
|
4
|
+
* This function determines whether a string contains any characters outside
|
|
5
|
+
* the ASCII range (0x00-0x7F).
|
|
6
|
+
*
|
|
7
|
+
* @param str - The string to check for non-English characters
|
|
8
|
+
* @returns True if the string contains any non-English characters after
|
|
9
|
+
* removing special characters and whitespace, false otherwise.
|
|
10
|
+
* Also returns false if the input is empty, null, or becomes empty
|
|
11
|
+
* after removing special characters.
|
|
12
|
+
*/
|
|
13
|
+
export declare const containsNonEnglishCharacters: (str: string) => boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.containsNonEnglishCharacters = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if a string contains non-English (non-ASCII) characters.
|
|
6
|
+
*
|
|
7
|
+
* This function determines whether a string contains any characters outside
|
|
8
|
+
* the ASCII range (0x00-0x7F).
|
|
9
|
+
*
|
|
10
|
+
* @param str - The string to check for non-English characters
|
|
11
|
+
* @returns True if the string contains any non-English characters after
|
|
12
|
+
* removing special characters and whitespace, false otherwise.
|
|
13
|
+
* Also returns false if the input is empty, null, or becomes empty
|
|
14
|
+
* after removing special characters.
|
|
15
|
+
*/
|
|
16
|
+
const containsNonEnglishCharacters = (str) => {
|
|
17
|
+
if (!str) {
|
|
18
|
+
return false; // If the string is empty or null, return false
|
|
19
|
+
}
|
|
20
|
+
// Regular expression to match non-English characters
|
|
21
|
+
const nonEnglishRegex = /[^\u0020-\u007F]/;
|
|
22
|
+
// remove all whitespace before checking
|
|
23
|
+
str = str.trim();
|
|
24
|
+
if (str.length === 0) {
|
|
25
|
+
return false; // If the string is empty after removing non-word characters, return false
|
|
26
|
+
}
|
|
27
|
+
return nonEnglishRegex.test(str);
|
|
28
|
+
};
|
|
29
|
+
exports.containsNonEnglishCharacters = containsNonEnglishCharacters;
|
|
30
|
+
//# sourceMappingURL=containsNonEnglishCharacters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"containsNonEnglishCharacters.js","sourceRoot":"","sources":["../../../src/lib/util/containsNonEnglishCharacters.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;GAWG;AACI,MAAM,4BAA4B,GAAG,CAAC,GAAW,EAAW,EAAE;IACjE,IAAI,CAAC,GAAG,EAAE;QACN,OAAO,KAAK,CAAC,CAAC,+CAA+C;KAChE;IAED,qDAAqD;IACrD,MAAM,eAAe,GAAG,kBAAkB,CAAC;IAE3C,wCAAwC;IACxC,GAAG,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAEjB,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;QAClB,OAAO,KAAK,CAAC,CAAC,0EAA0E;KAC3F;IAED,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACrC,CAAC,CAAC;AAhBW,QAAA,4BAA4B,gCAgBvC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Counts the number of sentences in a given text.
|
|
3
|
+
*
|
|
4
|
+
* This function handles:
|
|
5
|
+
* - Multiple paragraphs (separated by one or more new lines)
|
|
6
|
+
* - HTML new line characters ( and )
|
|
7
|
+
* - Multiple consecutive dots (replacing them with a single dot)
|
|
8
|
+
* - Empty paragraphs (skips them)
|
|
9
|
+
* - Sentences ending with punctuation marks (.!?) followed by spaces
|
|
10
|
+
* - Sentences at the end of the text
|
|
11
|
+
*
|
|
12
|
+
* @param text - The input text to count sentences in
|
|
13
|
+
* @returns The total number of sentences in the text
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Returns 2
|
|
17
|
+
* countSentences("Hello world. This is a test.");
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Also returns 2 (handles HTML newlines)
|
|
21
|
+
* countSentences("Hello world. This is a test.");
|
|
22
|
+
*/
|
|
23
|
+
export declare const countSentences: (text: string) => number;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.countSentences = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Counts the number of sentences in a given text.
|
|
6
|
+
*
|
|
7
|
+
* This function handles:
|
|
8
|
+
* - Multiple paragraphs (separated by one or more new lines)
|
|
9
|
+
* - HTML new line characters ( and )
|
|
10
|
+
* - Multiple consecutive dots (replacing them with a single dot)
|
|
11
|
+
* - Empty paragraphs (skips them)
|
|
12
|
+
* - Sentences ending with punctuation marks (.!?) followed by spaces
|
|
13
|
+
* - Sentences at the end of the text
|
|
14
|
+
*
|
|
15
|
+
* @param text - The input text to count sentences in
|
|
16
|
+
* @returns The total number of sentences in the text
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Returns 2
|
|
20
|
+
* countSentences("Hello world. This is a test.");
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Also returns 2 (handles HTML newlines)
|
|
24
|
+
* countSentences("Hello world. This is a test.");
|
|
25
|
+
*/
|
|
26
|
+
const countSentences = (text) => {
|
|
27
|
+
// split the text into paragraphs using new line as the delimiter
|
|
28
|
+
// it should also handle multiple new lines and HTML new lines like |
|
|
29
|
+
const paragraphs = text
|
|
30
|
+
.replace(/ | /g, '\n') // Replace HTML new lines with actual new lines
|
|
31
|
+
.split(/\n+/); // Split by one or more new lines
|
|
32
|
+
let sentenceCount = 0;
|
|
33
|
+
// iterate over each paragraph
|
|
34
|
+
for (const paragraph of paragraphs) {
|
|
35
|
+
// replace multiple dots with a single dot
|
|
36
|
+
let cleanedParagraph = paragraph.trim(); // trim leading and trailing spaces
|
|
37
|
+
if (!cleanedParagraph) {
|
|
38
|
+
continue; // skip empty paragraphs
|
|
39
|
+
}
|
|
40
|
+
cleanedParagraph = cleanedParagraph.replace(/\.{2,}/g, '.');
|
|
41
|
+
// Handle sentences ending with punctuation or the end of text
|
|
42
|
+
// Split by sentence-ending punctuation followed by a space or end of string
|
|
43
|
+
// (?<=[.!?])\s+ matches a space after a sentence-ending punctuation
|
|
44
|
+
// $ matches the end of the string
|
|
45
|
+
const sentences = cleanedParagraph.split(/(?<=[.!?])\s+|$/);
|
|
46
|
+
// Filter out empty sentences
|
|
47
|
+
const validSentences = sentences.filter((s) => s.trim().length > 0);
|
|
48
|
+
// Count the sentences
|
|
49
|
+
sentenceCount += validSentences.length;
|
|
50
|
+
}
|
|
51
|
+
return sentenceCount;
|
|
52
|
+
};
|
|
53
|
+
exports.countSentences = countSentences;
|
|
54
|
+
//# sourceMappingURL=countSentences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"countSentences.js","sourceRoot":"","sources":["../../../src/lib/util/countSentences.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACI,MAAM,cAAc,GAAG,CAAC,IAAY,EAAU,EAAE;IACnD,iEAAiE;IACjE,+EAA+E;IAC/E,MAAM,UAAU,GAAG,IAAI;SAClB,OAAO,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,+CAA+C;SAC7E,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,iCAAiC;IAEpD,IAAI,aAAa,GAAG,CAAC,CAAC;IAEtB,8BAA8B;IAC9B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE;QAChC,0CAA0C;QAC1C,IAAI,gBAAgB,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,mCAAmC;QAE5E,IAAI,CAAC,gBAAgB,EAAE;YACnB,SAAS,CAAC,wBAAwB;SACrC;QAED,gBAAgB,GAAG,gBAAgB,CAAC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;QAE5D,8DAA8D;QAC9D,4EAA4E;QAC5E,oEAAoE;QACpE,kCAAkC;QAClC,MAAM,SAAS,GAAG,gBAAgB,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;QAE5D,6BAA6B;QAC7B,MAAM,cAAc,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QAEpE,sBAAsB;QACtB,aAAa,IAAI,cAAc,CAAC,MAAM,CAAC;KAC1C;IAED,OAAO,aAAa,CAAC;AACzB,CAAC,CAAC;AAlCW,QAAA,cAAc,kBAkCzB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
type CreateWordBoundaryRegexOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* A flag indicating whether to avoid using word boundaries in the regular expression.
|
|
4
|
+
* If true, the resulting regex will not use word boundaries, which is useful for languages like Chinese and Japanese that do not use spaces between words.
|
|
5
|
+
*/
|
|
6
|
+
shouldAvoidUsingWordBoundary?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* A flag indicating whether to match plural forms of the patterns.
|
|
9
|
+
* If true, the resulting regex will match both singular and plural forms of the patterns.
|
|
10
|
+
*/
|
|
11
|
+
shouldMatchPlural?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Creates a regular expression that matches any of the provided patterns with optional word boundaries and plural forms.
|
|
15
|
+
*
|
|
16
|
+
* @param {string[]} patterns - An array of string patterns to be included in the regular expression.
|
|
17
|
+
* @param {CreateWordBoundaryRegexOptions} options - Options for creating the regular expression.
|
|
18
|
+
* @param {boolean} [options.shouldAvoidUsingWordBoundary=false] - A flag indicating whether to avoid using word boundaries in the regular expression.
|
|
19
|
+
* @param {boolean} [options.shouldMatchPlural=false] - A flag indicating whether to match plural forms of the patterns.
|
|
20
|
+
*
|
|
21
|
+
* @returns {RegExp} - A regular expression that matches any of the provided patterns. If the input patterns array is empty or invalid, returns a regular expression that never matches anything.
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - If `shouldAvoidUsingWordBoundary` is `true`, the resulting regular expression will not use word boundaries, which is useful for languages like Chinese and Japanese that do not use spaces between words.
|
|
25
|
+
* - If `shouldAvoidUsingWordBoundary` is `false`, the resulting regular expression will use word boundaries to match whole words only.
|
|
26
|
+
* - If `shouldMatchPlural` is `true`, the resulting regular expression will match both singular and plural forms of the patterns.
|
|
27
|
+
* - Special characters in the patterns are escaped to ensure they are treated as literal characters in the regular expression.
|
|
28
|
+
* - Patterns are sorted by length in descending order to prioritize longer matches.
|
|
29
|
+
* - The resulting regular expression is case-insensitive.
|
|
30
|
+
* - If an error occurs during the creation of the regular expression, a regular expression that never matches anything is returned.
|
|
31
|
+
*
|
|
32
|
+
* @throws Will log an error and return an empty regex if there is an error in creating the regex.
|
|
33
|
+
* @example
|
|
34
|
+
* // Returns /\b(foo|bar|baz)\b/gi
|
|
35
|
+
* createWordBoundaryRegex(['foo', 'bar', 'baz']);
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* // Returns /(foo|bar|baz)/giu
|
|
39
|
+
* createWordBoundaryRegex(['foo', 'bar', 'baz'], { shouldAvoidUsingWordBoundary: true });
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* // Returns /\b(foo|bars?|baz)\b/gi
|
|
43
|
+
* createWordBoundaryRegex(['foo', 'bar', 'baz'], { shouldMatchPlural: true });
|
|
44
|
+
*/
|
|
45
|
+
export declare const createWordBoundaryRegex: (patterns: string[], { shouldAvoidUsingWordBoundary, shouldMatchPlural, }?: CreateWordBoundaryRegexOptions) => RegExp;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createWordBoundaryRegex = void 0;
|
|
4
|
+
const escapeSpecialCharacters_1 = require("./escapeSpecialCharacters");
|
|
5
|
+
/**
|
|
6
|
+
* Creates a regular expression that matches any of the provided patterns with optional word boundaries and plural forms.
|
|
7
|
+
*
|
|
8
|
+
* @param {string[]} patterns - An array of string patterns to be included in the regular expression.
|
|
9
|
+
* @param {CreateWordBoundaryRegexOptions} options - Options for creating the regular expression.
|
|
10
|
+
* @param {boolean} [options.shouldAvoidUsingWordBoundary=false] - A flag indicating whether to avoid using word boundaries in the regular expression.
|
|
11
|
+
* @param {boolean} [options.shouldMatchPlural=false] - A flag indicating whether to match plural forms of the patterns.
|
|
12
|
+
*
|
|
13
|
+
* @returns {RegExp} - A regular expression that matches any of the provided patterns. If the input patterns array is empty or invalid, returns a regular expression that never matches anything.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* - If `shouldAvoidUsingWordBoundary` is `true`, the resulting regular expression will not use word boundaries, which is useful for languages like Chinese and Japanese that do not use spaces between words.
|
|
17
|
+
* - If `shouldAvoidUsingWordBoundary` is `false`, the resulting regular expression will use word boundaries to match whole words only.
|
|
18
|
+
* - If `shouldMatchPlural` is `true`, the resulting regular expression will match both singular and plural forms of the patterns.
|
|
19
|
+
* - Special characters in the patterns are escaped to ensure they are treated as literal characters in the regular expression.
|
|
20
|
+
* - Patterns are sorted by length in descending order to prioritize longer matches.
|
|
21
|
+
* - The resulting regular expression is case-insensitive.
|
|
22
|
+
* - If an error occurs during the creation of the regular expression, a regular expression that never matches anything is returned.
|
|
23
|
+
*
|
|
24
|
+
* @throws Will log an error and return an empty regex if there is an error in creating the regex.
|
|
25
|
+
* @example
|
|
26
|
+
* // Returns /\b(foo|bar|baz)\b/gi
|
|
27
|
+
* createWordBoundaryRegex(['foo', 'bar', 'baz']);
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* // Returns /(foo|bar|baz)/giu
|
|
31
|
+
* createWordBoundaryRegex(['foo', 'bar', 'baz'], { shouldAvoidUsingWordBoundary: true });
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Returns /\b(foo|bars?|baz)\b/gi
|
|
35
|
+
* createWordBoundaryRegex(['foo', 'bar', 'baz'], { shouldMatchPlural: true });
|
|
36
|
+
*/
|
|
37
|
+
const createWordBoundaryRegex = (patterns, { shouldAvoidUsingWordBoundary = false, shouldMatchPlural = false, } = {}) => {
|
|
38
|
+
// (?!.*) is a negative lookahead that always fails, meaning it never matches anything.
|
|
39
|
+
const emptyRegex = new RegExp('(?!.*)', 'gi');
|
|
40
|
+
if (!Array.isArray(patterns) || patterns.length === 0) {
|
|
41
|
+
return emptyRegex;
|
|
42
|
+
}
|
|
43
|
+
// Escape special regex characters in each pattern
|
|
44
|
+
const escapedPatterns = (0, escapeSpecialCharacters_1.escapeSpecialCharacters)(patterns);
|
|
45
|
+
if (!escapedPatterns || escapedPatterns.length === 0) {
|
|
46
|
+
return emptyRegex;
|
|
47
|
+
}
|
|
48
|
+
// Sort patterns by length in descending order to prioritize longer matches
|
|
49
|
+
// This helps to avoid partial matches on shorter patterns.
|
|
50
|
+
escapedPatterns.sort((a, b) => b.length - a.length);
|
|
51
|
+
try {
|
|
52
|
+
// Use a regex that works well for languages like Chinese and Japanese,
|
|
53
|
+
// that doesn't use spaces between words
|
|
54
|
+
if (shouldAvoidUsingWordBoundary) {
|
|
55
|
+
return new RegExp(`(${escapedPatterns.join('|')})`, 'giu');
|
|
56
|
+
}
|
|
57
|
+
// Add `s?` at end to make the letter s optional, allowing it to match both singular and plural forms.
|
|
58
|
+
if (shouldMatchPlural) {
|
|
59
|
+
return new RegExp(`(?<!\\w)(${escapedPatterns.join('|')})s?(?!\\w)`, 'gi');
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Enhances word boundary handling, including punctuation like periods.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* `(?<!\\w)`: Negative lookbehind ensures that the match is not preceded by a word character ([a-zA-Z0-9_])
|
|
66
|
+
* `(${escapedPatterns.join('|')})` Matches one of the provided patterns.
|
|
67
|
+
* `(?!\\w)`: Negative lookahead ensures that the match is not followed by a word character.
|
|
68
|
+
*/
|
|
69
|
+
return new RegExp(`(?<!\\w)(${escapedPatterns.join('|')})(?!\\w)`, 'gi');
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console.error('Error in createWordBoundaryRegex:', error);
|
|
73
|
+
return emptyRegex;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
exports.createWordBoundaryRegex = createWordBoundaryRegex;
|
|
77
|
+
//# sourceMappingURL=createWordBoundaryRegex.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createWordBoundaryRegex.js","sourceRoot":"","sources":["../../../src/lib/util/createWordBoundaryRegex.ts"],"names":[],"mappings":";;;AAAA,uEAAoE;AAepE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACI,MAAM,uBAAuB,GAAG,CACnC,QAAkB,EAClB,EACI,4BAA4B,GAAG,KAAK,EACpC,iBAAiB,GAAG,KAAK,MACO,EAAE,EAChC,EAAE;IACR,uFAAuF;IACvF,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAE9C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;QACnD,OAAO,UAAU,CAAC;KACrB;IAED,kDAAkD;IAClD,MAAM,eAAe,GAAG,IAAA,iDAAuB,EAAC,QAAQ,CAAC,CAAC;IAE1D,IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;QAClD,OAAO,UAAU,CAAC;KACrB;IAED,2EAA2E;IAC3E,2DAA2D;IAC3D,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;IAEpD,IAAI;QACA,uEAAuE;QACvE,wCAAwC;QACxC,IAAI,4BAA4B,EAAE;YAC9B,OAAO,IAAI,MAAM,CAAC,IAAI,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SAC9D;QAED,sGAAsG;QACtG,IAAI,iBAAiB,EAAE;YACnB,OAAO,IAAI,MAAM,CACb,YAAY,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EACjD,IAAI,CACP,CAAC;SACL;QAED;;;;;;;WAOG;QACH,OAAO,IAAI,MAAM,CACb,YAAY,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAC/C,IAAI,CACP,CAAC;KACL;IAAC,OAAO,KAAK,EAAE;QACZ,OAAO,CAAC,KAAK,CAAC,mCAAmC,EAAE,KAAK,CAAC,CAAC;QAC1D,OAAO,UAAU,CAAC;KACrB;AACL,CAAC,CAAC;AAxDW,QAAA,uBAAuB,2BAwDlC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cleans up an array of strings by escaping special characters and trimming whitespace.
|
|
3
|
+
*
|
|
4
|
+
* @param strs - An array of strings to be cleaned.
|
|
5
|
+
* @returns A new array of strings with special characters escaped and whitespace trimmed.
|
|
6
|
+
*/
|
|
7
|
+
export declare const escapeSpecialCharacters: (strs: string[]) => string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.escapeSpecialCharacters = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Cleans up an array of strings by escaping special characters and trimming whitespace.
|
|
6
|
+
*
|
|
7
|
+
* @param strs - An array of strings to be cleaned.
|
|
8
|
+
* @returns A new array of strings with special characters escaped and whitespace trimmed.
|
|
9
|
+
*/
|
|
10
|
+
const escapeSpecialCharacters = (strs) => {
|
|
11
|
+
if (!strs || strs.length === 0) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const output = strs.map((str) => {
|
|
15
|
+
// Find all special characters and replaces each one with its escaped version.
|
|
16
|
+
// The `\\$&` part means "replace with a backslash followed by the matched character".
|
|
17
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&').trim();
|
|
18
|
+
});
|
|
19
|
+
return output.filter((str) => str !== '');
|
|
20
|
+
};
|
|
21
|
+
exports.escapeSpecialCharacters = escapeSpecialCharacters;
|
|
22
|
+
//# sourceMappingURL=escapeSpecialCharacters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"escapeSpecialCharacters.js","sourceRoot":"","sources":["../../../src/lib/util/escapeSpecialCharacters.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACI,MAAM,uBAAuB,GAAG,CAAC,IAAc,EAAE,EAAE;IACtD,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QAC5B,OAAO,EAAE,CAAC;KACb;IAED,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAC5B,8EAA8E;QAC9E,sFAAsF;QACtF,OAAO,GAAG,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,CAAC;AAC9C,CAAC,CAAC;AAZW,QAAA,uBAAuB,2BAYlC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { IItem } from '../../types';
|
|
2
|
+
import { LivingAtlasSupportedItemType } from '../config';
|
|
3
|
+
/**
|
|
4
|
+
* Returns an array of item types supported by Living Atlas.
|
|
5
|
+
*
|
|
6
|
+
* This function creates a new array containing all the predefined item types
|
|
7
|
+
* that are supported by Living Atlas from the configuration.
|
|
8
|
+
*
|
|
9
|
+
* @returns {LivingAtlasSupportedItemType[]} An array of Living Atlas supported item types.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getLivingAtlasSupportedItemTypes: () => LivingAtlasSupportedItemType[];
|
|
12
|
+
/**
|
|
13
|
+
* Checks if a given item type is supported by Living Atlas.
|
|
14
|
+
*
|
|
15
|
+
* This function determines whether the provided item type string is included
|
|
16
|
+
* in the predefined list of item types supported by Living Atlas.
|
|
17
|
+
*
|
|
18
|
+
* @param {string} itemType - The item type to check for support.
|
|
19
|
+
* @returns {boolean} True if the item type is supported by Living Atlas, false otherwise.
|
|
20
|
+
*/
|
|
21
|
+
export declare const checkIsLivingAtlasSupportedItemType: (item: IItem) => boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkIsLivingAtlasSupportedItemType = exports.getLivingAtlasSupportedItemTypes = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
/**
|
|
6
|
+
* Returns an array of item types supported by Living Atlas.
|
|
7
|
+
*
|
|
8
|
+
* This function creates a new array containing all the predefined item types
|
|
9
|
+
* that are supported by Living Atlas from the configuration.
|
|
10
|
+
*
|
|
11
|
+
* @returns {LivingAtlasSupportedItemType[]} An array of Living Atlas supported item types.
|
|
12
|
+
*/
|
|
13
|
+
const getLivingAtlasSupportedItemTypes = () => {
|
|
14
|
+
return [...config_1.LIVING_ATLAS_SUPPORTED_ITEM_TYPES];
|
|
15
|
+
};
|
|
16
|
+
exports.getLivingAtlasSupportedItemTypes = getLivingAtlasSupportedItemTypes;
|
|
17
|
+
/**
|
|
18
|
+
* Checks if a given item type is supported by Living Atlas.
|
|
19
|
+
*
|
|
20
|
+
* This function determines whether the provided item type string is included
|
|
21
|
+
* in the predefined list of item types supported by Living Atlas.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} itemType - The item type to check for support.
|
|
24
|
+
* @returns {boolean} True if the item type is supported by Living Atlas, false otherwise.
|
|
25
|
+
*/
|
|
26
|
+
const checkIsLivingAtlasSupportedItemType = (item) => {
|
|
27
|
+
if (!item) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const itemType = item === null || item === void 0 ? void 0 : item.type;
|
|
31
|
+
return config_1.LIVING_ATLAS_SUPPORTED_ITEM_TYPES.includes(itemType);
|
|
32
|
+
};
|
|
33
|
+
exports.checkIsLivingAtlasSupportedItemType = checkIsLivingAtlasSupportedItemType;
|
|
34
|
+
//# sourceMappingURL=getLivingAtlasSupportedItemTypes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLivingAtlasSupportedItemTypes.js","sourceRoot":"","sources":["../../../src/lib/util/getLivingAtlasSupportedItemTypes.ts"],"names":[],"mappings":";;;AACA,sCAGmB;AAEnB;;;;;;;GAOG;AACI,MAAM,gCAAgC,GACzC,GAAmC,EAAE;IACjC,OAAO,CAAC,GAAG,0CAAiC,CAAC,CAAC;AAClD,CAAC,CAAC;AAHO,QAAA,gCAAgC,oCAGvC;AAEN;;;;;;;;GAQG;AACI,MAAM,mCAAmC,GAAG,CAAC,IAAW,EAAW,EAAE;IACxE,IAAI,CAAC,IAAI,EAAE;QACP,OAAO,KAAK,CAAC;KAChB;IAED,MAAM,QAAQ,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC;IAE5B,OAAO,0CAAiC,CAAC,QAAQ,CAC7C,QAAwC,CAC3C,CAAC;AACN,CAAC,CAAC;AAVW,QAAA,mCAAmC,uCAU9C"}
|
|
@@ -11,8 +11,12 @@ const getNumberOfWords = (s) => {
|
|
|
11
11
|
if (!(0, assertString_1.assertString)(s)) {
|
|
12
12
|
return 0;
|
|
13
13
|
}
|
|
14
|
-
//
|
|
15
|
-
let str = s.replace(/(^\s*)|(\s*$)/gi, '');
|
|
14
|
+
// trim the string to remove leading and trailing spaces
|
|
15
|
+
let str = s.trim(); //s.replace(/(^\s*)|(\s*$)/gi, '');
|
|
16
|
+
if (!str) {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
// inds any sequence of 2 or more spaces in the string and replaces it with a single space
|
|
16
20
|
str = str.replace(/[ ]{2,}/gi, ' ');
|
|
17
21
|
// exclude newline with a space at beginning
|
|
18
22
|
str = str.replace(/\n /, '\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getNumberOfWords.js","sourceRoot":"","sources":["../../../src/lib/util/getNumberOfWords.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAE9C;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,CAAC,CAAS,EAAU,EAAE;IAClD,IAAI,CAAC,IAAA,2BAAY,EAAC,CAAC,CAAC,EAAE;QAClB,OAAO,CAAC,CAAC;KACZ;IAED,
|
|
1
|
+
{"version":3,"file":"getNumberOfWords.js","sourceRoot":"","sources":["../../../src/lib/util/getNumberOfWords.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAE9C;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,CAAC,CAAS,EAAU,EAAE;IAClD,IAAI,CAAC,IAAA,2BAAY,EAAC,CAAC,CAAC,EAAE;QAClB,OAAO,CAAC,CAAC;KACZ;IAED,wDAAwD;IACxD,IAAI,GAAG,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,mCAAmC;IAEvD,IAAI,CAAC,GAAG,EAAE;QACN,OAAO,CAAC,CAAC;KACZ;IAED,0FAA0F;IAC1F,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAEpC,4CAA4C;IAC5C,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAE/B,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAClD,OAAO,CAAC,CAAC;KACZ;IAED,OAAO,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;AACjC,CAAC,CAAC;AAvBW,QAAA,gBAAgB,oBAuB3B;AAEF,mEAAmE;AAEnE,wBAAwB;AAExB,uDAAuD;AACvD,yBAAyB;AACzB,uCAAuC;AACvC,MAAM"}
|