tods-competition-factory 1.8.26 → 1.8.27
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/dist/forge/generate.mjs +91 -38
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +101 -68
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +270 -202
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +444 -396
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -1709,6 +1709,14 @@ function getDevContext(contextCriteria) {
|
|
|
1709
1709
|
return (Object.keys(contextCriteria).every(function (key) { var _a; return ((_a = globalState.devContext) === null || _a === void 0 ? void 0 : _a[key]) === contextCriteria[key]; }) && globalState.devContext);
|
|
1710
1710
|
}
|
|
1711
1711
|
}
|
|
1712
|
+
function setGlobalLog(loggingFx) {
|
|
1713
|
+
if (typeof loggingFx === 'function') {
|
|
1714
|
+
globalState.globalLog = loggingFx;
|
|
1715
|
+
}
|
|
1716
|
+
else {
|
|
1717
|
+
delete globalState.globalLog;
|
|
1718
|
+
}
|
|
1719
|
+
}
|
|
1712
1720
|
function setDevContext(value) {
|
|
1713
1721
|
globalState.devContext = value;
|
|
1714
1722
|
}
|
|
@@ -1811,6 +1819,14 @@ function handleCaughtError(_a) {
|
|
|
1811
1819
|
err: err,
|
|
1812
1820
|
});
|
|
1813
1821
|
}
|
|
1822
|
+
function globalLog$1(engine, log) {
|
|
1823
|
+
if (globalState.globalLog) {
|
|
1824
|
+
return globalState.globalLog(engine, log);
|
|
1825
|
+
}
|
|
1826
|
+
else {
|
|
1827
|
+
console.log(engine, log);
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1814
1830
|
|
|
1815
1831
|
var validDateString = /^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/;
|
|
1816
1832
|
var validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
|
|
@@ -2913,7 +2929,7 @@ var matchUpFormatCode = {
|
|
|
2913
2929
|
};
|
|
2914
2930
|
|
|
2915
2931
|
function factoryVersion() {
|
|
2916
|
-
return '1.8.
|
|
2932
|
+
return '1.8.27';
|
|
2917
2933
|
}
|
|
2918
2934
|
|
|
2919
2935
|
function getObjectTieFormat(obj) {
|
|
@@ -2975,312 +2991,6 @@ function resolveTieFormat(_a) {
|
|
|
2975
2991
|
};
|
|
2976
2992
|
}
|
|
2977
2993
|
|
|
2978
|
-
var typeMatch = function (arr, type) {
|
|
2979
|
-
return arr.filter(Boolean).every(function (i) { return typeof i === type; });
|
|
2980
|
-
};
|
|
2981
|
-
var allNumeric = function (arr) { return arr.filter(Boolean).every(isNumeric); };
|
|
2982
|
-
function getCategoryAgeDetails(params) {
|
|
2983
|
-
var _a, _b;
|
|
2984
|
-
var category = params.category;
|
|
2985
|
-
if (typeof category !== 'object')
|
|
2986
|
-
return { error: INVALID_CATEGORY };
|
|
2987
|
-
var ageCategoryCode = category.ageCategoryCode, ageMaxDate = category.ageMaxDate, ageMinDate = category.ageMinDate, ageMax = category.ageMax, ageMin = category.ageMin;
|
|
2988
|
-
var categoryName = category.categoryName;
|
|
2989
|
-
var combinedAge;
|
|
2990
|
-
if (!typeMatch([ageCategoryCode, ageMaxDate, ageMinDate, categoryName], 'string') ||
|
|
2991
|
-
!allNumeric([ageMax, ageMin] ||
|
|
2992
|
-
![ageMaxDate, ageMinDate].filter(Boolean).every(isValidDateString)))
|
|
2993
|
-
return { error: INVALID_CATEGORY };
|
|
2994
|
-
var consideredDate = (_a = params.consideredDate) !== null && _a !== void 0 ? _a : extractDate(new Date().toLocaleDateString('sv'));
|
|
2995
|
-
if (!isValidDateString(consideredDate))
|
|
2996
|
-
return { error: INVALID_DATE };
|
|
2997
|
-
// const [consideredYear, month, day] = consideredDate
|
|
2998
|
-
var _c = __read(consideredDate
|
|
2999
|
-
.split('-')
|
|
3000
|
-
.slice(0, 3)
|
|
3001
|
-
.map(function (n) { return parseInt(n); }), 1), consideredYear = _c[0];
|
|
3002
|
-
// const monthDay = `${zeroPad(month)}-${zeroPad(day)}`;
|
|
3003
|
-
var previousDayDate = dateStringDaysChange(consideredDate, -1);
|
|
3004
|
-
var _d = __read(previousDayDate
|
|
3005
|
-
.split('-')
|
|
3006
|
-
.slice(1, 3)
|
|
3007
|
-
.map(function (n) { return parseInt(n); }), 2), previousDayMonth = _d[0], previousDay = _d[1];
|
|
3008
|
-
var previousMonthDay = "".concat(zeroPad(previousDayMonth), "-").concat(zeroPad(previousDay));
|
|
3009
|
-
var nextDayDate = dateStringDaysChange(consideredDate, 1);
|
|
3010
|
-
var _e = __read(nextDayDate
|
|
3011
|
-
.split('-')
|
|
3012
|
-
.slice(1, 3)
|
|
3013
|
-
.map(function (n) { return parseInt(n); }), 2), nextDayMonth = _e[0], nextDay = _e[1];
|
|
3014
|
-
var nextMonthDay = "".concat(zeroPad(nextDayMonth), "-").concat(zeroPad(nextDay));
|
|
3015
|
-
var calculatedAgeMaxDate = ageMin && dateStringDaysChange(consideredDate, -1 * 365 * ageMin);
|
|
3016
|
-
var calculatedAgeMinDate = ageMax && dateStringDaysChange(consideredDate, -1 * 365 * ageMax);
|
|
3017
|
-
// collect errors; e.g. provided ageMin does not equal calculated ageMin
|
|
3018
|
-
var errors = [];
|
|
3019
|
-
var addError = function (errorString) {
|
|
3020
|
-
return !errors.includes(errorString) && errors.push(errorString);
|
|
3021
|
-
};
|
|
3022
|
-
ageCategoryCode = ageCategoryCode !== null && ageCategoryCode !== void 0 ? ageCategoryCode : categoryName;
|
|
3023
|
-
var prePost = /^([UO]?)(\d{1,2})([UO]?)$/;
|
|
3024
|
-
var extractCombined = /^C(\d{1,2})-(\d{1,2})$/;
|
|
3025
|
-
var isBetween = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.includes('-');
|
|
3026
|
-
var isCombined = isBetween && (ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined));
|
|
3027
|
-
var isCoded = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(prePost);
|
|
3028
|
-
// construct min or max date with or without year
|
|
3029
|
-
//const isYYMM = (datePart) => datePart.match(/^\d{2}-\d{2}$/);
|
|
3030
|
-
var constructedDate = function (y, df) { return "".concat(y, "-").concat(df); };
|
|
3031
|
-
var uPre = function (ageInt) {
|
|
3032
|
-
var ageMinYear = consideredYear - ageInt;
|
|
3033
|
-
var newMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
3034
|
-
if (category.ageMinDate && category.ageMinDate !== newMinDate)
|
|
3035
|
-
addError("Invalid submitted ageMinDate: ".concat(ageMinDate));
|
|
3036
|
-
ageMinDate = newMinDate;
|
|
3037
|
-
if (ageCategoryCode) {
|
|
3038
|
-
if (category.ageMax && category.ageMax !== ageInt - 1) {
|
|
3039
|
-
addError("Invalid submitted ageMax: ".concat(ageMax));
|
|
3040
|
-
calculatedAgeMinDate = undefined;
|
|
3041
|
-
}
|
|
3042
|
-
ageMax = ageInt - 1;
|
|
3043
|
-
}
|
|
3044
|
-
};
|
|
3045
|
-
var uPost = function (ageInt) {
|
|
3046
|
-
var ageMinYear = consideredYear - ageInt - 1;
|
|
3047
|
-
var newMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
3048
|
-
if (category.ageMin && category.ageMin > ageInt) {
|
|
3049
|
-
addError("Invalid submitted ageMin: ".concat(ageMin));
|
|
3050
|
-
}
|
|
3051
|
-
if (category.ageMax && category.ageMax > ageInt) {
|
|
3052
|
-
addError("Invalid submitted ageMax: ".concat(ageMax));
|
|
3053
|
-
}
|
|
3054
|
-
if (category.ageMinDate && category.ageMinDate !== newMinDate)
|
|
3055
|
-
addError("Invalid submitted ageMinDate: ".concat(ageMinDate));
|
|
3056
|
-
ageMinDate = newMinDate;
|
|
3057
|
-
if (ageCategoryCode) {
|
|
3058
|
-
if (category.ageMax && category.ageMax !== ageInt) {
|
|
3059
|
-
addError("Invalid submitted ageMax: ".concat(ageMax));
|
|
3060
|
-
calculatedAgeMaxDate = undefined;
|
|
3061
|
-
}
|
|
3062
|
-
ageMax = ageInt;
|
|
3063
|
-
}
|
|
3064
|
-
};
|
|
3065
|
-
var oPre = function (ageInt) {
|
|
3066
|
-
var ageMaxYear = consideredYear - ageInt;
|
|
3067
|
-
var newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
3068
|
-
if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
|
|
3069
|
-
addError("Invalid submitted ageMaxDate: ".concat(ageMaxDate));
|
|
3070
|
-
ageMaxDate = newMaxDate;
|
|
3071
|
-
if (ageCategoryCode) {
|
|
3072
|
-
if (category.ageMin && category.ageMin !== ageInt + 1) {
|
|
3073
|
-
addError("Invalid submitted ageMin: ".concat(ageMin));
|
|
3074
|
-
calculatedAgeMaxDate = undefined;
|
|
3075
|
-
}
|
|
3076
|
-
ageMin = ageInt + 1;
|
|
3077
|
-
}
|
|
3078
|
-
};
|
|
3079
|
-
var oPost = function (ageInt) {
|
|
3080
|
-
var ageMaxYear = consideredYear - ageInt - 1;
|
|
3081
|
-
var newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
3082
|
-
if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
|
|
3083
|
-
addError("Invalid submitted ageMaxDate: ".concat(ageMaxDate));
|
|
3084
|
-
ageMaxDate = newMaxDate;
|
|
3085
|
-
if (ageCategoryCode) {
|
|
3086
|
-
if (category.ageMin && category.ageMin !== ageInt) {
|
|
3087
|
-
addError("Invalid submitted ageMin: ".concat(ageMin));
|
|
3088
|
-
calculatedAgeMaxDate = undefined;
|
|
3089
|
-
}
|
|
3090
|
-
ageMin = ageInt;
|
|
3091
|
-
}
|
|
3092
|
-
};
|
|
3093
|
-
var processCode = function (code) {
|
|
3094
|
-
var _a = __read((code.match(prePost) || []).slice(1), 3), pre = _a[0], age = _a[1], post = _a[2];
|
|
3095
|
-
var ageInt = parseInt(age);
|
|
3096
|
-
if (pre === 'U') {
|
|
3097
|
-
if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
|
|
3098
|
-
addError("Invalid submitted ageMaxDate: ".concat(category.ageMaxDate));
|
|
3099
|
-
}
|
|
3100
|
-
uPre(ageInt);
|
|
3101
|
-
}
|
|
3102
|
-
else if (pre === 'O') {
|
|
3103
|
-
oPre(ageInt);
|
|
3104
|
-
}
|
|
3105
|
-
if (post === 'U') {
|
|
3106
|
-
if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
|
|
3107
|
-
addError("Invalid submitted ageMaxDate: ".concat(category.ageMaxDate));
|
|
3108
|
-
}
|
|
3109
|
-
uPost(ageInt);
|
|
3110
|
-
}
|
|
3111
|
-
else if (post === 'O') {
|
|
3112
|
-
oPost(ageInt);
|
|
3113
|
-
}
|
|
3114
|
-
ageMaxDate = ageMaxDate !== null && ageMaxDate !== void 0 ? ageMaxDate : calculatedAgeMaxDate;
|
|
3115
|
-
ageMinDate = ageMinDate !== null && ageMinDate !== void 0 ? ageMinDate : calculatedAgeMinDate;
|
|
3116
|
-
};
|
|
3117
|
-
if (isCombined) {
|
|
3118
|
-
// min and max birthdates are not relevant
|
|
3119
|
-
// TODO: utility function to calculate combined age given two birthdates?
|
|
3120
|
-
ageMaxDate = undefined;
|
|
3121
|
-
ageMinDate = undefined;
|
|
3122
|
-
ageMax = undefined;
|
|
3123
|
-
ageMin = undefined;
|
|
3124
|
-
if (category.ageMin) {
|
|
3125
|
-
// calculate ageMaxDate
|
|
3126
|
-
var ageMaxYear = consideredYear - category.ageMin;
|
|
3127
|
-
ageMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
3128
|
-
}
|
|
3129
|
-
if (category.ageMax) {
|
|
3130
|
-
// calculate ageMinDate
|
|
3131
|
-
var ageMinYear = consideredYear - category.ageMax - 1;
|
|
3132
|
-
ageMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
3133
|
-
}
|
|
3134
|
-
var _f = __read(((_b = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined)) !== null && _b !== void 0 ? _b : [])
|
|
3135
|
-
.slice(1)
|
|
3136
|
-
.map(function (n) { return parseInt(n); }), 2), lowAge = _f[0], highAge = _f[1];
|
|
3137
|
-
if (lowAge <= highAge) {
|
|
3138
|
-
ageMin = lowAge;
|
|
3139
|
-
ageMax = highAge;
|
|
3140
|
-
combinedAge = true;
|
|
3141
|
-
}
|
|
3142
|
-
else {
|
|
3143
|
-
addError("Invalid combined age range ".concat(ageCategoryCode));
|
|
3144
|
-
}
|
|
3145
|
-
}
|
|
3146
|
-
else if (isBetween) {
|
|
3147
|
-
ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.split('-').forEach(processCode);
|
|
3148
|
-
}
|
|
3149
|
-
else if (isCoded) {
|
|
3150
|
-
processCode(ageCategoryCode);
|
|
3151
|
-
}
|
|
3152
|
-
else {
|
|
3153
|
-
if (ageMin)
|
|
3154
|
-
oPre(ageMin);
|
|
3155
|
-
if (ageMax)
|
|
3156
|
-
uPost(ageMax);
|
|
3157
|
-
}
|
|
3158
|
-
if (ageMax && category.ageMin && category.ageMin > ageMax) {
|
|
3159
|
-
addError("Invalid submitted ageMin: ".concat(category.ageMin));
|
|
3160
|
-
ageMin = undefined;
|
|
3161
|
-
}
|
|
3162
|
-
var result = definedAttributes({
|
|
3163
|
-
consideredDate: consideredDate,
|
|
3164
|
-
combinedAge: combinedAge,
|
|
3165
|
-
ageMaxDate: ageMaxDate,
|
|
3166
|
-
ageMinDate: ageMinDate,
|
|
3167
|
-
ageMax: ageMax,
|
|
3168
|
-
ageMin: ageMin,
|
|
3169
|
-
});
|
|
3170
|
-
if (errors.length)
|
|
3171
|
-
result.errors = errors;
|
|
3172
|
-
return result;
|
|
3173
|
-
}
|
|
3174
|
-
|
|
3175
|
-
function decorateResult(_a) {
|
|
3176
|
-
var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
|
|
3177
|
-
if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
|
|
3178
|
-
result.stack = [];
|
|
3179
|
-
if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
|
|
3180
|
-
result.stack.push(stack);
|
|
3181
|
-
}
|
|
3182
|
-
if (result && info) {
|
|
3183
|
-
result.info = info;
|
|
3184
|
-
}
|
|
3185
|
-
if (result && typeof context === 'object' && Object.keys(context).length) {
|
|
3186
|
-
Object.assign(result, definedAttributes(context));
|
|
3187
|
-
}
|
|
3188
|
-
if (result && !(result === null || result === void 0 ? void 0 : result.error) && !(result === null || result === void 0 ? void 0 : result.success)) {
|
|
3189
|
-
Object.assign(result, __assign({}, SUCCESS));
|
|
3190
|
-
}
|
|
3191
|
-
return result !== null && result !== void 0 ? result : { success: true };
|
|
3192
|
-
}
|
|
3193
|
-
|
|
3194
|
-
function validateCategory(_a) {
|
|
3195
|
-
var category = _a.category;
|
|
3196
|
-
if (!isObject(category))
|
|
3197
|
-
return { error: INVALID_VALUES };
|
|
3198
|
-
var categoryDetails = getCategoryAgeDetails({ category: category });
|
|
3199
|
-
if (categoryDetails.error)
|
|
3200
|
-
return { error: categoryDetails };
|
|
3201
|
-
var ratingMax = category.ratingMax, ratingMin = category.ratingMin;
|
|
3202
|
-
if (ratingMax && !isNumeric(ratingMax))
|
|
3203
|
-
return decorateResult({
|
|
3204
|
-
result: { error: INVALID_VALUES },
|
|
3205
|
-
context: { ratingMax: ratingMax },
|
|
3206
|
-
});
|
|
3207
|
-
if (ratingMin && !isNumeric(ratingMin))
|
|
3208
|
-
return decorateResult({
|
|
3209
|
-
result: { error: INVALID_VALUES },
|
|
3210
|
-
context: { ratingMin: ratingMin },
|
|
3211
|
-
});
|
|
3212
|
-
return __assign({}, categoryDetails);
|
|
3213
|
-
}
|
|
3214
|
-
|
|
3215
|
-
function categoryCanContain(_a) {
|
|
3216
|
-
var childCategory = _a.childCategory, withDetails = _a.withDetails, category = _a.category;
|
|
3217
|
-
var categoryDetails = validateCategory({ category: category });
|
|
3218
|
-
var childCategoryDetails = validateCategory({
|
|
3219
|
-
category: childCategory,
|
|
3220
|
-
});
|
|
3221
|
-
var invalidAgeMin = childCategoryDetails.ageMin &&
|
|
3222
|
-
((categoryDetails.ageMin &&
|
|
3223
|
-
childCategoryDetails.ageMin < categoryDetails.ageMin) ||
|
|
3224
|
-
(categoryDetails.ageMax &&
|
|
3225
|
-
childCategoryDetails.ageMin > categoryDetails.ageMax));
|
|
3226
|
-
var invalidAgeMax = childCategoryDetails.ageMax &&
|
|
3227
|
-
((categoryDetails.ageMax &&
|
|
3228
|
-
childCategoryDetails.ageMax > categoryDetails.ageMax) ||
|
|
3229
|
-
(categoryDetails.ageMin &&
|
|
3230
|
-
childCategoryDetails.ageMax < categoryDetails.ageMin));
|
|
3231
|
-
var invalidAgeMinDate = childCategoryDetails.ageMinDate &&
|
|
3232
|
-
categoryDetails.ageMaxDate &&
|
|
3233
|
-
new Date(childCategoryDetails.ageMinDate) >
|
|
3234
|
-
new Date(categoryDetails.ageMaxDate);
|
|
3235
|
-
var invalidAgeMaxDate = childCategoryDetails.ageMaxDate &&
|
|
3236
|
-
categoryDetails.ageMinDate &&
|
|
3237
|
-
new Date(childCategoryDetails.ageMaxDate) <
|
|
3238
|
-
new Date(categoryDetails.ageMinDate);
|
|
3239
|
-
var ratingComparison = category.ratingType &&
|
|
3240
|
-
childCategory.ratingType &&
|
|
3241
|
-
category.ratingType === childCategory.ratingType;
|
|
3242
|
-
var invalidRatingRange = ratingComparison &&
|
|
3243
|
-
((category.ratingMin &&
|
|
3244
|
-
childCategory.ratingMin &&
|
|
3245
|
-
childCategory.ratingMin < category.ratingMin) ||
|
|
3246
|
-
(category.ratingMax &&
|
|
3247
|
-
childCategory.ratingMax &&
|
|
3248
|
-
childCategory.ratingMax > category.ratingMax) ||
|
|
3249
|
-
(category.ratingMin &&
|
|
3250
|
-
childCategory.ratingMax &&
|
|
3251
|
-
childCategory.ratingMax < category.ratingMin) ||
|
|
3252
|
-
(category.ratingMax &&
|
|
3253
|
-
childCategory.ratingMin &&
|
|
3254
|
-
childCategory.ratingMin > category.ratingMax));
|
|
3255
|
-
var invalidBallType = category.ballType &&
|
|
3256
|
-
childCategory.ballType &&
|
|
3257
|
-
category.ballType !== childCategory.ballType;
|
|
3258
|
-
var valid = !invalidRatingRange &&
|
|
3259
|
-
!invalidAgeMinDate &&
|
|
3260
|
-
!invalidAgeMaxDate &&
|
|
3261
|
-
!invalidBallType &&
|
|
3262
|
-
!invalidAgeMax &&
|
|
3263
|
-
!invalidAgeMin;
|
|
3264
|
-
var ignoreFalse = true;
|
|
3265
|
-
var result = definedAttributes({
|
|
3266
|
-
invalidRatingRange: invalidRatingRange,
|
|
3267
|
-
invalidAgeMinDate: invalidAgeMinDate,
|
|
3268
|
-
invalidAgeMaxDate: invalidAgeMaxDate,
|
|
3269
|
-
invalidBallType: invalidBallType,
|
|
3270
|
-
invalidAgeMax: invalidAgeMax,
|
|
3271
|
-
invalidAgeMin: invalidAgeMin,
|
|
3272
|
-
valid: valid,
|
|
3273
|
-
}, ignoreFalse);
|
|
3274
|
-
if (withDetails) {
|
|
3275
|
-
Object.assign(result, { categoryDetails: categoryDetails, childCategoryDetails: childCategoryDetails });
|
|
3276
|
-
}
|
|
3277
|
-
return result;
|
|
3278
|
-
}
|
|
3279
|
-
|
|
3280
|
-
function mustBeAnArray(value) {
|
|
3281
|
-
return "".concat(value, " must be an array");
|
|
3282
|
-
}
|
|
3283
|
-
|
|
3284
2994
|
var DrawTypeEnum;
|
|
3285
2995
|
(function (DrawTypeEnum) {
|
|
3286
2996
|
DrawTypeEnum["AdHoc"] = "AD_HOC";
|
|
@@ -3841,6 +3551,350 @@ var SexEnum;
|
|
|
3841
3551
|
SexEnum["Other"] = "OTHER";
|
|
3842
3552
|
})(SexEnum || (SexEnum = {}));
|
|
3843
3553
|
|
|
3554
|
+
function decorateResult(_a) {
|
|
3555
|
+
var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
|
|
3556
|
+
if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
|
|
3557
|
+
result.stack = [];
|
|
3558
|
+
if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
|
|
3559
|
+
result.stack.push(stack);
|
|
3560
|
+
}
|
|
3561
|
+
if (result && info) {
|
|
3562
|
+
result.info = info;
|
|
3563
|
+
}
|
|
3564
|
+
if (result && typeof context === 'object' && Object.keys(context).length) {
|
|
3565
|
+
Object.assign(result, definedAttributes(context));
|
|
3566
|
+
}
|
|
3567
|
+
if (result && !(result === null || result === void 0 ? void 0 : result.error) && !(result === null || result === void 0 ? void 0 : result.success)) {
|
|
3568
|
+
Object.assign(result, __assign({}, SUCCESS));
|
|
3569
|
+
}
|
|
3570
|
+
return result !== null && result !== void 0 ? result : { success: true };
|
|
3571
|
+
}
|
|
3572
|
+
|
|
3573
|
+
var ANY = 'ANY';
|
|
3574
|
+
var MALE = 'MALE';
|
|
3575
|
+
var MIXED = 'MIXED';
|
|
3576
|
+
var OTHER$3 = 'OTHER';
|
|
3577
|
+
var FEMALE = 'FEMALE';
|
|
3578
|
+
var genderConstants = {
|
|
3579
|
+
ANY: ANY,
|
|
3580
|
+
MALE: MALE,
|
|
3581
|
+
FEMALE: FEMALE,
|
|
3582
|
+
MIXED: MIXED,
|
|
3583
|
+
OTHER: OTHER$3,
|
|
3584
|
+
};
|
|
3585
|
+
|
|
3586
|
+
function genderValidityCheck(_a) {
|
|
3587
|
+
var referenceGender = _a.referenceGender, matchUpType = _a.matchUpType, gender = _a.gender;
|
|
3588
|
+
var stack = 'genderValidityCheck';
|
|
3589
|
+
if (referenceGender &&
|
|
3590
|
+
gender &&
|
|
3591
|
+
[GenderEnum.Male, GenderEnum.Female].includes(referenceGender) &&
|
|
3592
|
+
[GenderEnum.Male, GenderEnum.Female].includes(gender)) {
|
|
3593
|
+
var valid = gender === referenceGender;
|
|
3594
|
+
return valid
|
|
3595
|
+
? { valid: true }
|
|
3596
|
+
: decorateResult({
|
|
3597
|
+
result: { valid: false, error: INVALID_GENDER },
|
|
3598
|
+
context: { gender: gender },
|
|
3599
|
+
stack: stack,
|
|
3600
|
+
});
|
|
3601
|
+
}
|
|
3602
|
+
if (matchUpType === TypeEnum.Singles && referenceGender === MIXED)
|
|
3603
|
+
return decorateResult({
|
|
3604
|
+
info: 'matchUpType SINGLES is invalid for gender MIXED',
|
|
3605
|
+
result: { error: INVALID_GENDER, valid: false },
|
|
3606
|
+
stack: stack,
|
|
3607
|
+
});
|
|
3608
|
+
return { valid: true };
|
|
3609
|
+
}
|
|
3610
|
+
|
|
3611
|
+
var typeMatch = function (arr, type) {
|
|
3612
|
+
return arr.filter(Boolean).every(function (i) { return typeof i === type; });
|
|
3613
|
+
};
|
|
3614
|
+
var allNumeric = function (arr) { return arr.filter(Boolean).every(isNumeric); };
|
|
3615
|
+
function getCategoryAgeDetails(params) {
|
|
3616
|
+
var _a, _b;
|
|
3617
|
+
var category = params.category;
|
|
3618
|
+
if (typeof category !== 'object')
|
|
3619
|
+
return { error: INVALID_CATEGORY };
|
|
3620
|
+
var ageCategoryCode = category.ageCategoryCode, ageMaxDate = category.ageMaxDate, ageMinDate = category.ageMinDate, ageMax = category.ageMax, ageMin = category.ageMin;
|
|
3621
|
+
var categoryName = category.categoryName;
|
|
3622
|
+
var combinedAge;
|
|
3623
|
+
if (!typeMatch([ageCategoryCode, ageMaxDate, ageMinDate, categoryName], 'string') ||
|
|
3624
|
+
!allNumeric([ageMax, ageMin] ||
|
|
3625
|
+
![ageMaxDate, ageMinDate].filter(Boolean).every(isValidDateString)))
|
|
3626
|
+
return { error: INVALID_CATEGORY };
|
|
3627
|
+
var consideredDate = (_a = params.consideredDate) !== null && _a !== void 0 ? _a : extractDate(new Date().toLocaleDateString('sv'));
|
|
3628
|
+
if (!isValidDateString(consideredDate))
|
|
3629
|
+
return { error: INVALID_DATE };
|
|
3630
|
+
// const [consideredYear, month, day] = consideredDate
|
|
3631
|
+
var _c = __read(consideredDate
|
|
3632
|
+
.split('-')
|
|
3633
|
+
.slice(0, 3)
|
|
3634
|
+
.map(function (n) { return parseInt(n); }), 1), consideredYear = _c[0];
|
|
3635
|
+
// const monthDay = `${zeroPad(month)}-${zeroPad(day)}`;
|
|
3636
|
+
var previousDayDate = dateStringDaysChange(consideredDate, -1);
|
|
3637
|
+
var _d = __read(previousDayDate
|
|
3638
|
+
.split('-')
|
|
3639
|
+
.slice(1, 3)
|
|
3640
|
+
.map(function (n) { return parseInt(n); }), 2), previousDayMonth = _d[0], previousDay = _d[1];
|
|
3641
|
+
var previousMonthDay = "".concat(zeroPad(previousDayMonth), "-").concat(zeroPad(previousDay));
|
|
3642
|
+
var nextDayDate = dateStringDaysChange(consideredDate, 1);
|
|
3643
|
+
var _e = __read(nextDayDate
|
|
3644
|
+
.split('-')
|
|
3645
|
+
.slice(1, 3)
|
|
3646
|
+
.map(function (n) { return parseInt(n); }), 2), nextDayMonth = _e[0], nextDay = _e[1];
|
|
3647
|
+
var nextMonthDay = "".concat(zeroPad(nextDayMonth), "-").concat(zeroPad(nextDay));
|
|
3648
|
+
var calculatedAgeMaxDate = ageMin && dateStringDaysChange(consideredDate, -1 * 365 * ageMin);
|
|
3649
|
+
var calculatedAgeMinDate = ageMax && dateStringDaysChange(consideredDate, -1 * 365 * ageMax);
|
|
3650
|
+
// collect errors; e.g. provided ageMin does not equal calculated ageMin
|
|
3651
|
+
var errors = [];
|
|
3652
|
+
var addError = function (errorString) {
|
|
3653
|
+
return !errors.includes(errorString) && errors.push(errorString);
|
|
3654
|
+
};
|
|
3655
|
+
ageCategoryCode = ageCategoryCode !== null && ageCategoryCode !== void 0 ? ageCategoryCode : categoryName;
|
|
3656
|
+
var prePost = /^([UO]?)(\d{1,2})([UO]?)$/;
|
|
3657
|
+
var extractCombined = /^C(\d{1,2})-(\d{1,2})$/;
|
|
3658
|
+
var isBetween = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.includes('-');
|
|
3659
|
+
var isCombined = isBetween && (ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined));
|
|
3660
|
+
var isCoded = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(prePost);
|
|
3661
|
+
// construct min or max date with or without year
|
|
3662
|
+
//const isYYMM = (datePart) => datePart.match(/^\d{2}-\d{2}$/);
|
|
3663
|
+
var constructedDate = function (y, df) { return "".concat(y, "-").concat(df); };
|
|
3664
|
+
var uPre = function (ageInt) {
|
|
3665
|
+
var ageMinYear = consideredYear - ageInt;
|
|
3666
|
+
var newMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
3667
|
+
if (category.ageMinDate && category.ageMinDate !== newMinDate)
|
|
3668
|
+
addError("Invalid submitted ageMinDate: ".concat(ageMinDate));
|
|
3669
|
+
ageMinDate = newMinDate;
|
|
3670
|
+
if (ageCategoryCode) {
|
|
3671
|
+
if (category.ageMax && category.ageMax !== ageInt - 1) {
|
|
3672
|
+
addError("Invalid submitted ageMax: ".concat(ageMax));
|
|
3673
|
+
calculatedAgeMinDate = undefined;
|
|
3674
|
+
}
|
|
3675
|
+
ageMax = ageInt - 1;
|
|
3676
|
+
}
|
|
3677
|
+
};
|
|
3678
|
+
var uPost = function (ageInt) {
|
|
3679
|
+
var ageMinYear = consideredYear - ageInt - 1;
|
|
3680
|
+
var newMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
3681
|
+
if (category.ageMin && category.ageMin > ageInt) {
|
|
3682
|
+
addError("Invalid submitted ageMin: ".concat(ageMin));
|
|
3683
|
+
}
|
|
3684
|
+
if (category.ageMax && category.ageMax > ageInt) {
|
|
3685
|
+
addError("Invalid submitted ageMax: ".concat(ageMax));
|
|
3686
|
+
}
|
|
3687
|
+
if (category.ageMinDate && category.ageMinDate !== newMinDate)
|
|
3688
|
+
addError("Invalid submitted ageMinDate: ".concat(ageMinDate));
|
|
3689
|
+
ageMinDate = newMinDate;
|
|
3690
|
+
if (ageCategoryCode) {
|
|
3691
|
+
if (category.ageMax && category.ageMax !== ageInt) {
|
|
3692
|
+
addError("Invalid submitted ageMax: ".concat(ageMax));
|
|
3693
|
+
calculatedAgeMaxDate = undefined;
|
|
3694
|
+
}
|
|
3695
|
+
ageMax = ageInt;
|
|
3696
|
+
}
|
|
3697
|
+
};
|
|
3698
|
+
var oPre = function (ageInt) {
|
|
3699
|
+
var ageMaxYear = consideredYear - ageInt;
|
|
3700
|
+
var newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
3701
|
+
if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
|
|
3702
|
+
addError("Invalid submitted ageMaxDate: ".concat(ageMaxDate));
|
|
3703
|
+
ageMaxDate = newMaxDate;
|
|
3704
|
+
if (ageCategoryCode) {
|
|
3705
|
+
if (category.ageMin && category.ageMin !== ageInt + 1) {
|
|
3706
|
+
addError("Invalid submitted ageMin: ".concat(ageMin));
|
|
3707
|
+
calculatedAgeMaxDate = undefined;
|
|
3708
|
+
}
|
|
3709
|
+
ageMin = ageInt + 1;
|
|
3710
|
+
}
|
|
3711
|
+
};
|
|
3712
|
+
var oPost = function (ageInt) {
|
|
3713
|
+
var ageMaxYear = consideredYear - ageInt - 1;
|
|
3714
|
+
var newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
3715
|
+
if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
|
|
3716
|
+
addError("Invalid submitted ageMaxDate: ".concat(ageMaxDate));
|
|
3717
|
+
ageMaxDate = newMaxDate;
|
|
3718
|
+
if (ageCategoryCode) {
|
|
3719
|
+
if (category.ageMin && category.ageMin !== ageInt) {
|
|
3720
|
+
addError("Invalid submitted ageMin: ".concat(ageMin));
|
|
3721
|
+
calculatedAgeMaxDate = undefined;
|
|
3722
|
+
}
|
|
3723
|
+
ageMin = ageInt;
|
|
3724
|
+
}
|
|
3725
|
+
};
|
|
3726
|
+
var processCode = function (code) {
|
|
3727
|
+
var _a = __read((code.match(prePost) || []).slice(1), 3), pre = _a[0], age = _a[1], post = _a[2];
|
|
3728
|
+
var ageInt = parseInt(age);
|
|
3729
|
+
if (pre === 'U') {
|
|
3730
|
+
if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
|
|
3731
|
+
addError("Invalid submitted ageMaxDate: ".concat(category.ageMaxDate));
|
|
3732
|
+
}
|
|
3733
|
+
uPre(ageInt);
|
|
3734
|
+
}
|
|
3735
|
+
else if (pre === 'O') {
|
|
3736
|
+
oPre(ageInt);
|
|
3737
|
+
}
|
|
3738
|
+
if (post === 'U') {
|
|
3739
|
+
if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
|
|
3740
|
+
addError("Invalid submitted ageMaxDate: ".concat(category.ageMaxDate));
|
|
3741
|
+
}
|
|
3742
|
+
uPost(ageInt);
|
|
3743
|
+
}
|
|
3744
|
+
else if (post === 'O') {
|
|
3745
|
+
oPost(ageInt);
|
|
3746
|
+
}
|
|
3747
|
+
ageMaxDate = ageMaxDate !== null && ageMaxDate !== void 0 ? ageMaxDate : calculatedAgeMaxDate;
|
|
3748
|
+
ageMinDate = ageMinDate !== null && ageMinDate !== void 0 ? ageMinDate : calculatedAgeMinDate;
|
|
3749
|
+
};
|
|
3750
|
+
if (isCombined) {
|
|
3751
|
+
// min and max birthdates are not relevant
|
|
3752
|
+
// TODO: utility function to calculate combined age given two birthdates?
|
|
3753
|
+
ageMaxDate = undefined;
|
|
3754
|
+
ageMinDate = undefined;
|
|
3755
|
+
ageMax = undefined;
|
|
3756
|
+
ageMin = undefined;
|
|
3757
|
+
if (category.ageMin) {
|
|
3758
|
+
// calculate ageMaxDate
|
|
3759
|
+
var ageMaxYear = consideredYear - category.ageMin;
|
|
3760
|
+
ageMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
3761
|
+
}
|
|
3762
|
+
if (category.ageMax) {
|
|
3763
|
+
// calculate ageMinDate
|
|
3764
|
+
var ageMinYear = consideredYear - category.ageMax - 1;
|
|
3765
|
+
ageMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
3766
|
+
}
|
|
3767
|
+
var _f = __read(((_b = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined)) !== null && _b !== void 0 ? _b : [])
|
|
3768
|
+
.slice(1)
|
|
3769
|
+
.map(function (n) { return parseInt(n); }), 2), lowAge = _f[0], highAge = _f[1];
|
|
3770
|
+
if (lowAge <= highAge) {
|
|
3771
|
+
ageMin = lowAge;
|
|
3772
|
+
ageMax = highAge;
|
|
3773
|
+
combinedAge = true;
|
|
3774
|
+
}
|
|
3775
|
+
else {
|
|
3776
|
+
addError("Invalid combined age range ".concat(ageCategoryCode));
|
|
3777
|
+
}
|
|
3778
|
+
}
|
|
3779
|
+
else if (isBetween) {
|
|
3780
|
+
ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.split('-').forEach(processCode);
|
|
3781
|
+
}
|
|
3782
|
+
else if (isCoded) {
|
|
3783
|
+
processCode(ageCategoryCode);
|
|
3784
|
+
}
|
|
3785
|
+
else {
|
|
3786
|
+
if (ageMin)
|
|
3787
|
+
oPre(ageMin);
|
|
3788
|
+
if (ageMax)
|
|
3789
|
+
uPost(ageMax);
|
|
3790
|
+
}
|
|
3791
|
+
if (ageMax && category.ageMin && category.ageMin > ageMax) {
|
|
3792
|
+
addError("Invalid submitted ageMin: ".concat(category.ageMin));
|
|
3793
|
+
ageMin = undefined;
|
|
3794
|
+
}
|
|
3795
|
+
var result = definedAttributes({
|
|
3796
|
+
consideredDate: consideredDate,
|
|
3797
|
+
combinedAge: combinedAge,
|
|
3798
|
+
ageMaxDate: ageMaxDate,
|
|
3799
|
+
ageMinDate: ageMinDate,
|
|
3800
|
+
ageMax: ageMax,
|
|
3801
|
+
ageMin: ageMin,
|
|
3802
|
+
});
|
|
3803
|
+
if (errors.length)
|
|
3804
|
+
result.errors = errors;
|
|
3805
|
+
return result;
|
|
3806
|
+
}
|
|
3807
|
+
|
|
3808
|
+
function validateCategory(_a) {
|
|
3809
|
+
var category = _a.category;
|
|
3810
|
+
if (!isObject(category))
|
|
3811
|
+
return { error: INVALID_VALUES };
|
|
3812
|
+
var categoryDetails = getCategoryAgeDetails({ category: category });
|
|
3813
|
+
if (categoryDetails.error)
|
|
3814
|
+
return { error: categoryDetails };
|
|
3815
|
+
var ratingMax = category.ratingMax, ratingMin = category.ratingMin;
|
|
3816
|
+
if (ratingMax && !isNumeric(ratingMax))
|
|
3817
|
+
return decorateResult({
|
|
3818
|
+
result: { error: INVALID_VALUES },
|
|
3819
|
+
context: { ratingMax: ratingMax },
|
|
3820
|
+
});
|
|
3821
|
+
if (ratingMin && !isNumeric(ratingMin))
|
|
3822
|
+
return decorateResult({
|
|
3823
|
+
result: { error: INVALID_VALUES },
|
|
3824
|
+
context: { ratingMin: ratingMin },
|
|
3825
|
+
});
|
|
3826
|
+
return __assign({}, categoryDetails);
|
|
3827
|
+
}
|
|
3828
|
+
|
|
3829
|
+
function categoryCanContain(_a) {
|
|
3830
|
+
var childCategory = _a.childCategory, withDetails = _a.withDetails, category = _a.category;
|
|
3831
|
+
var categoryDetails = validateCategory({ category: category });
|
|
3832
|
+
var childCategoryDetails = validateCategory({
|
|
3833
|
+
category: childCategory,
|
|
3834
|
+
});
|
|
3835
|
+
var invalidAgeMin = childCategoryDetails.ageMin &&
|
|
3836
|
+
((categoryDetails.ageMin &&
|
|
3837
|
+
childCategoryDetails.ageMin < categoryDetails.ageMin) ||
|
|
3838
|
+
(categoryDetails.ageMax &&
|
|
3839
|
+
childCategoryDetails.ageMin > categoryDetails.ageMax));
|
|
3840
|
+
var invalidAgeMax = childCategoryDetails.ageMax &&
|
|
3841
|
+
((categoryDetails.ageMax &&
|
|
3842
|
+
childCategoryDetails.ageMax > categoryDetails.ageMax) ||
|
|
3843
|
+
(categoryDetails.ageMin &&
|
|
3844
|
+
childCategoryDetails.ageMax < categoryDetails.ageMin));
|
|
3845
|
+
var invalidAgeMinDate = childCategoryDetails.ageMinDate &&
|
|
3846
|
+
categoryDetails.ageMaxDate &&
|
|
3847
|
+
new Date(childCategoryDetails.ageMinDate) >
|
|
3848
|
+
new Date(categoryDetails.ageMaxDate);
|
|
3849
|
+
var invalidAgeMaxDate = childCategoryDetails.ageMaxDate &&
|
|
3850
|
+
categoryDetails.ageMinDate &&
|
|
3851
|
+
new Date(childCategoryDetails.ageMaxDate) <
|
|
3852
|
+
new Date(categoryDetails.ageMinDate);
|
|
3853
|
+
var ratingComparison = category.ratingType &&
|
|
3854
|
+
childCategory.ratingType &&
|
|
3855
|
+
category.ratingType === childCategory.ratingType;
|
|
3856
|
+
var invalidRatingRange = ratingComparison &&
|
|
3857
|
+
((category.ratingMin &&
|
|
3858
|
+
childCategory.ratingMin &&
|
|
3859
|
+
childCategory.ratingMin < category.ratingMin) ||
|
|
3860
|
+
(category.ratingMax &&
|
|
3861
|
+
childCategory.ratingMax &&
|
|
3862
|
+
childCategory.ratingMax > category.ratingMax) ||
|
|
3863
|
+
(category.ratingMin &&
|
|
3864
|
+
childCategory.ratingMax &&
|
|
3865
|
+
childCategory.ratingMax < category.ratingMin) ||
|
|
3866
|
+
(category.ratingMax &&
|
|
3867
|
+
childCategory.ratingMin &&
|
|
3868
|
+
childCategory.ratingMin > category.ratingMax));
|
|
3869
|
+
var invalidBallType = category.ballType &&
|
|
3870
|
+
childCategory.ballType &&
|
|
3871
|
+
category.ballType !== childCategory.ballType;
|
|
3872
|
+
var valid = !invalidRatingRange &&
|
|
3873
|
+
!invalidAgeMinDate &&
|
|
3874
|
+
!invalidAgeMaxDate &&
|
|
3875
|
+
!invalidBallType &&
|
|
3876
|
+
!invalidAgeMax &&
|
|
3877
|
+
!invalidAgeMin;
|
|
3878
|
+
var ignoreFalse = true;
|
|
3879
|
+
var result = definedAttributes({
|
|
3880
|
+
invalidRatingRange: invalidRatingRange,
|
|
3881
|
+
invalidAgeMinDate: invalidAgeMinDate,
|
|
3882
|
+
invalidAgeMaxDate: invalidAgeMaxDate,
|
|
3883
|
+
invalidBallType: invalidBallType,
|
|
3884
|
+
invalidAgeMax: invalidAgeMax,
|
|
3885
|
+
invalidAgeMin: invalidAgeMin,
|
|
3886
|
+
valid: valid,
|
|
3887
|
+
}, ignoreFalse);
|
|
3888
|
+
if (withDetails) {
|
|
3889
|
+
Object.assign(result, { categoryDetails: categoryDetails, childCategoryDetails: childCategoryDetails });
|
|
3890
|
+
}
|
|
3891
|
+
return result;
|
|
3892
|
+
}
|
|
3893
|
+
|
|
3894
|
+
function mustBeAnArray(value) {
|
|
3895
|
+
return "".concat(value, " must be an array");
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3844
3898
|
function validateTieFormat(params) {
|
|
3845
3899
|
var _a, _b, _c, _d;
|
|
3846
3900
|
var checkCategory = !!((params === null || params === void 0 ? void 0 : params.enforceCategory) !== false && (params === null || params === void 0 ? void 0 : params.category));
|
|
@@ -3975,17 +4029,19 @@ function validateCollectionDefinition(_a) {
|
|
|
3975
4029
|
if (matchUpFormat && !matchUpFormatCode.isValid(matchUpFormat)) {
|
|
3976
4030
|
errors.push("Invalid matchUpFormat: ".concat(matchUpFormat));
|
|
3977
4031
|
}
|
|
3978
|
-
if (checkGender
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
errors.push("Invalid gender: ".concat(gender));
|
|
3984
|
-
return decorateResult({
|
|
3985
|
-
result: { error: INVALID_GENDER, errors: errors },
|
|
3986
|
-
context: { referenceGender: referenceGender, gender: gender },
|
|
3987
|
-
stack: stack,
|
|
4032
|
+
if (checkGender) {
|
|
4033
|
+
var result = genderValidityCheck({
|
|
4034
|
+
referenceGender: referenceGender,
|
|
4035
|
+
matchUpType: matchUpType,
|
|
4036
|
+
gender: gender,
|
|
3988
4037
|
});
|
|
4038
|
+
if (result.error) {
|
|
4039
|
+
return decorateResult({
|
|
4040
|
+
context: { referenceGender: referenceGender, gender: gender },
|
|
4041
|
+
result: result,
|
|
4042
|
+
stack: stack,
|
|
4043
|
+
});
|
|
4044
|
+
}
|
|
3989
4045
|
}
|
|
3990
4046
|
if (checkCategory && referenceCategory && category) {
|
|
3991
4047
|
var result = categoryCanContain({
|
|
@@ -6915,7 +6971,7 @@ var PUBLIC = 'PUBLIC';
|
|
|
6915
6971
|
var STATUS$1 = 'STATUS';
|
|
6916
6972
|
var MODIFICATION = 'MODIFICATION';
|
|
6917
6973
|
var RETRIEVAL = 'RETRIEVAL';
|
|
6918
|
-
var OTHER$
|
|
6974
|
+
var OTHER$2 = 'other';
|
|
6919
6975
|
var timeItemConstants = {
|
|
6920
6976
|
MUTUALLY_EXCLUSIVE_TIME_MODIFIERS: MUTUALLY_EXCLUSIVE_TIME_MODIFIERS,
|
|
6921
6977
|
AFTER_REST: AFTER_REST,
|
|
@@ -6934,7 +6990,7 @@ var timeItemConstants = {
|
|
|
6934
6990
|
MODIFICATION: MODIFICATION,
|
|
6935
6991
|
NEXT_AVAILABLE: NEXT_AVAILABLE,
|
|
6936
6992
|
NOT_BEFORE: NOT_BEFORE,
|
|
6937
|
-
OTHER: OTHER$
|
|
6993
|
+
OTHER: OTHER$2,
|
|
6938
6994
|
PENALTY: PENALTY$1,
|
|
6939
6995
|
PUBLIC: PUBLIC,
|
|
6940
6996
|
PUBLISH: PUBLISH,
|
|
@@ -9467,19 +9523,6 @@ function getSeeding(_a) {
|
|
|
9467
9523
|
});
|
|
9468
9524
|
}
|
|
9469
9525
|
|
|
9470
|
-
var ANY = 'ANY';
|
|
9471
|
-
var MALE = 'MALE';
|
|
9472
|
-
var MIXED = 'MIXED';
|
|
9473
|
-
var OTHER$2 = 'OTHER';
|
|
9474
|
-
var FEMALE = 'FEMALE';
|
|
9475
|
-
var genderConstants = {
|
|
9476
|
-
ANY: ANY,
|
|
9477
|
-
MALE: MALE,
|
|
9478
|
-
FEMALE: FEMALE,
|
|
9479
|
-
MIXED: MIXED,
|
|
9480
|
-
OTHER: OTHER$2,
|
|
9481
|
-
};
|
|
9482
|
-
|
|
9483
9526
|
function getAllStructureMatchUps(_a) {
|
|
9484
9527
|
var _b, _c, _d, _e, _f, _g, _h;
|
|
9485
9528
|
var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, tournamentAppliedPolicies = _a.tournamentAppliedPolicies, provisionalPositioning = _a.provisionalPositioning, tournamentParticipants = _a.tournamentParticipants, afterRecoveryTimes = _a.afterRecoveryTimes, policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, seedAssignments = _a.seedAssignments, contextFilters = _a.contextFilters, contextContent = _a.contextContent, matchUpFilters = _a.matchUpFilters, participantMap = _a.participantMap, scheduleTiming = _a.scheduleTiming, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, _j = _a.context, context = _j === void 0 ? {} : _j, exitProfiles = _a.exitProfiles, matchUpsMap = _a.matchUpsMap, structure = _a.structure, inContext = _a.inContext, event = _a.event;
|
|
@@ -23010,10 +23053,11 @@ function updateMatchUpStatusCodes(_a) {
|
|
|
23010
23053
|
// ... and fed positions are always sideNumber 1
|
|
23011
23054
|
(sourceMatchUp.structureId === (pairedMatchUp === null || pairedMatchUp === void 0 ? void 0 : pairedMatchUp.structureId) && 2) || 1;
|
|
23012
23055
|
matchUp.matchUpStatusCodes = ((_b = matchUp.matchUpStatusCodes) !== null && _b !== void 0 ? _b : []).map(function (code) {
|
|
23013
|
-
|
|
23014
|
-
|
|
23056
|
+
var value = isString(code) || !isNaN(code) ? { code: code } : code;
|
|
23057
|
+
if (value.sideNumber === sourceSideNumber_1) {
|
|
23058
|
+
return __assign(__assign({}, value), { previousMatchUpStatus: sourceMatchUpStatus });
|
|
23015
23059
|
}
|
|
23016
|
-
return
|
|
23060
|
+
return value;
|
|
23017
23061
|
});
|
|
23018
23062
|
}
|
|
23019
23063
|
}
|
|
@@ -41395,7 +41439,7 @@ function engineLogging(_a) {
|
|
|
41395
41439
|
log.result = result;
|
|
41396
41440
|
}
|
|
41397
41441
|
if (Object.keys(log).length > 1)
|
|
41398
|
-
|
|
41442
|
+
globalLog$1(engine, log);
|
|
41399
41443
|
if (result && devContext.makeDeepCopy)
|
|
41400
41444
|
result.deepCopyIterations = getDeepCopyIterations();
|
|
41401
41445
|
}
|
|
@@ -44346,6 +44390,50 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
|
|
|
44346
44390
|
return __assign(__assign({ inContextDrawMatchUps: inContextDrawMatchUps, drawDefinition: drawDefinition, matchUpsMap: matchUpsMap }, SUCCESS), { structures: structures, matchUps: matchUps, links: links });
|
|
44347
44391
|
}
|
|
44348
44392
|
|
|
44393
|
+
function processAccessors(_a) {
|
|
44394
|
+
var significantCharacters = _a.significantCharacters, _b = _a.accessors, accessors = _b === void 0 ? [] : _b, value = _a.value;
|
|
44395
|
+
var extractedValues = [];
|
|
44396
|
+
var accessor = accessors[0];
|
|
44397
|
+
if (value === null || value === void 0 ? void 0 : value[accessor]) {
|
|
44398
|
+
var remainingKeys_1 = accessors.slice(1);
|
|
44399
|
+
if (Array.isArray(value[accessor])) {
|
|
44400
|
+
var values = value[accessor];
|
|
44401
|
+
values.forEach(function (nestedValue) {
|
|
44402
|
+
var result = processAccessors({
|
|
44403
|
+
accessors: remainingKeys_1,
|
|
44404
|
+
significantCharacters: significantCharacters,
|
|
44405
|
+
value: nestedValue,
|
|
44406
|
+
});
|
|
44407
|
+
extractedValues.push.apply(extractedValues, __spreadArray([], __read(result), false));
|
|
44408
|
+
});
|
|
44409
|
+
}
|
|
44410
|
+
else {
|
|
44411
|
+
value = value[accessor];
|
|
44412
|
+
if (remainingKeys_1.length) {
|
|
44413
|
+
var result = processAccessors({
|
|
44414
|
+
accessors: remainingKeys_1,
|
|
44415
|
+
significantCharacters: significantCharacters,
|
|
44416
|
+
value: value,
|
|
44417
|
+
});
|
|
44418
|
+
extractedValues.push.apply(extractedValues, __spreadArray([], __read(result), false));
|
|
44419
|
+
}
|
|
44420
|
+
else {
|
|
44421
|
+
checkValue({ value: value });
|
|
44422
|
+
}
|
|
44423
|
+
}
|
|
44424
|
+
}
|
|
44425
|
+
function checkValue(_a) {
|
|
44426
|
+
var value = _a.value;
|
|
44427
|
+
if (value && ['string', 'number'].includes(typeof value)) {
|
|
44428
|
+
var extractedValue = significantCharacters
|
|
44429
|
+
? value.slice(0, significantCharacters)
|
|
44430
|
+
: value;
|
|
44431
|
+
extractedValues.push(extractedValue);
|
|
44432
|
+
}
|
|
44433
|
+
}
|
|
44434
|
+
return extractedValues;
|
|
44435
|
+
}
|
|
44436
|
+
|
|
44349
44437
|
function getAttributeGroupings(_a) {
|
|
44350
44438
|
var targetParticipantIds = _a.targetParticipantIds, policyAttributes = _a.policyAttributes, idCollections = _a.idCollections, participants = _a.participants;
|
|
44351
44439
|
if (!Array.isArray(policyAttributes)) {
|
|
@@ -44387,8 +44475,12 @@ function extractAttributeValues(_a) {
|
|
|
44387
44475
|
policyAttributes.forEach(function (policyAttribute) {
|
|
44388
44476
|
var _a = policyAttribute || {}, directive = _a.directive, groupings = _a.groupings, key = _a.key, significantCharacters = _a.significantCharacters;
|
|
44389
44477
|
if (key) {
|
|
44390
|
-
var
|
|
44391
|
-
|
|
44478
|
+
var accessors = key.split('.');
|
|
44479
|
+
extractedValues.push.apply(extractedValues, __spreadArray([], __read(processAccessors({
|
|
44480
|
+
significantCharacters: significantCharacters,
|
|
44481
|
+
value: participant,
|
|
44482
|
+
accessors: accessors,
|
|
44483
|
+
})), false));
|
|
44392
44484
|
}
|
|
44393
44485
|
else if (directive) {
|
|
44394
44486
|
// extractedValues are values to be avoided
|
|
@@ -44418,53 +44510,6 @@ function extractAttributeValues(_a) {
|
|
|
44418
44510
|
});
|
|
44419
44511
|
var values = unique(extractedValues);
|
|
44420
44512
|
return { values: values };
|
|
44421
|
-
function processKeys(_a) {
|
|
44422
|
-
var e_1, _b;
|
|
44423
|
-
var value = _a.value, _c = _a.keys, keys = _c === void 0 ? [] : _c, significantCharacters = _a.significantCharacters;
|
|
44424
|
-
var _loop_1 = function (index, key) {
|
|
44425
|
-
if (value === null || value === void 0 ? void 0 : value[key]) {
|
|
44426
|
-
if (Array.isArray(value[key])) {
|
|
44427
|
-
var values_1 = value[key];
|
|
44428
|
-
var remainingKeys_1 = keys.slice(index);
|
|
44429
|
-
values_1.forEach(function (nestedValue) {
|
|
44430
|
-
return processKeys({
|
|
44431
|
-
value: nestedValue,
|
|
44432
|
-
keys: remainingKeys_1,
|
|
44433
|
-
significantCharacters: significantCharacters,
|
|
44434
|
-
});
|
|
44435
|
-
});
|
|
44436
|
-
}
|
|
44437
|
-
else {
|
|
44438
|
-
value = value[key];
|
|
44439
|
-
checkValue({ value: value, index: index });
|
|
44440
|
-
}
|
|
44441
|
-
}
|
|
44442
|
-
};
|
|
44443
|
-
try {
|
|
44444
|
-
for (var _d = __values(keys.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
44445
|
-
var _f = __read(_e.value, 2), index = _f[0], key = _f[1];
|
|
44446
|
-
_loop_1(index, key);
|
|
44447
|
-
}
|
|
44448
|
-
}
|
|
44449
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
44450
|
-
finally {
|
|
44451
|
-
try {
|
|
44452
|
-
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
44453
|
-
}
|
|
44454
|
-
finally { if (e_1) throw e_1.error; }
|
|
44455
|
-
}
|
|
44456
|
-
function checkValue(_a) {
|
|
44457
|
-
var value = _a.value, index = _a.index;
|
|
44458
|
-
if (value &&
|
|
44459
|
-
index === keys.length - 1 &&
|
|
44460
|
-
['string', 'number'].includes(typeof value)) {
|
|
44461
|
-
var extractedValue = significantCharacters
|
|
44462
|
-
? value.slice(0, significantCharacters)
|
|
44463
|
-
: value;
|
|
44464
|
-
extractedValues.push(extractedValue);
|
|
44465
|
-
}
|
|
44466
|
-
}
|
|
44467
|
-
}
|
|
44468
44513
|
}
|
|
44469
44514
|
|
|
44470
44515
|
function getPositionedParticipants(_a) {
|
|
@@ -45256,7 +45301,7 @@ function positionUnseededParticipants(_a) {
|
|
|
45256
45301
|
drawDefinition: drawDefinition,
|
|
45257
45302
|
event: event,
|
|
45258
45303
|
}).appliedPolicies;
|
|
45259
|
-
var avoidance = (appliedPolicies !== null && appliedPolicies !== void 0 ? appliedPolicies : {})
|
|
45304
|
+
var avoidance = (appliedPolicies !== null && appliedPolicies !== void 0 ? appliedPolicies : {})[POLICY_TYPE_AVOIDANCE];
|
|
45260
45305
|
if (structure.stage === PLAY_OFF) {
|
|
45261
45306
|
// generate avoidance policies automatically for Playoffs from Round Robin Groups
|
|
45262
45307
|
var groupings = entries.reduce(function (groupings, entry) {
|
|
@@ -59371,8 +59416,8 @@ function getEntryStatusReports(_a) {
|
|
|
59371
59416
|
return sides === null || sides === void 0 ? void 0 : sides.flatMap(function (side) {
|
|
59372
59417
|
var _a, _b;
|
|
59373
59418
|
return matchUpType === DOUBLES_MATCHUP
|
|
59374
|
-
? (_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds
|
|
59375
|
-
: ((_b = side.participant) === null || _b === void 0 ? void 0 : _b.participantId) || side.participantId;
|
|
59419
|
+
? (_a = side === null || side === void 0 ? void 0 : side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds
|
|
59420
|
+
: ((_b = side === null || side === void 0 ? void 0 : side.participant) === null || _b === void 0 ? void 0 : _b.participantId) || side.participantId;
|
|
59376
59421
|
}).filter(Boolean);
|
|
59377
59422
|
})
|
|
59378
59423
|
.filter(Boolean);
|
|
@@ -59521,7 +59566,7 @@ function getEntryStatusReports(_a) {
|
|
|
59521
59566
|
var _b = _a.participant, participantType = _b.participantType, participantRole = _b.participantRole;
|
|
59522
59567
|
return participantType === INDIVIDUAL && participantRole === COMPETITOR;
|
|
59523
59568
|
});
|
|
59524
|
-
var
|
|
59569
|
+
var nonParticipatingParticipantIds = individualParticipants
|
|
59525
59570
|
.filter(function (_a) {
|
|
59526
59571
|
var participant = _a.participant;
|
|
59527
59572
|
return !nonTeamEnteredParticipantIds.includes(participant.participantId);
|
|
@@ -59531,9 +59576,10 @@ function getEntryStatusReports(_a) {
|
|
|
59531
59576
|
return participant.participantId;
|
|
59532
59577
|
});
|
|
59533
59578
|
var tournamentEntryReport = {
|
|
59534
|
-
nonParticipatingEntriesCount:
|
|
59579
|
+
nonParticipatingEntriesCount: nonParticipatingParticipantIds.length,
|
|
59535
59580
|
individualParticipantsCount: individualParticipants.length,
|
|
59536
59581
|
eventsCount: Object.values(eventReports).length,
|
|
59582
|
+
nonParticipatingParticipantIds: nonParticipatingParticipantIds,
|
|
59537
59583
|
drawDefinitionsCount: drawDefinitionsCount,
|
|
59538
59584
|
tournamentId: tournamentId,
|
|
59539
59585
|
};
|
|
@@ -68606,10 +68652,10 @@ function anonymizeTournamentRecord(_a) {
|
|
|
68606
68652
|
counts[gender] += 1;
|
|
68607
68653
|
}
|
|
68608
68654
|
else {
|
|
68609
|
-
counts[OTHER$
|
|
68655
|
+
counts[OTHER$3] += 1;
|
|
68610
68656
|
}
|
|
68611
68657
|
return counts;
|
|
68612
|
-
}, (_m = {}, _m[MALE] = 0, _m[FEMALE] = 0, _m[OTHER$
|
|
68658
|
+
}, (_m = {}, _m[MALE] = 0, _m[FEMALE] = 0, _m[OTHER$3] = 0, _m));
|
|
68613
68659
|
var genderedPersons = Object.assign.apply(Object, __spreadArray([{}], __read(Object.keys(gendersCount).map(function (gender) {
|
|
68614
68660
|
var _a;
|
|
68615
68661
|
var _b;
|
|
@@ -68624,7 +68670,7 @@ function anonymizeTournamentRecord(_a) {
|
|
|
68624
68670
|
})) === null || _b === void 0 ? void 0 : _b.persons) || [],
|
|
68625
68671
|
_a);
|
|
68626
68672
|
})), false));
|
|
68627
|
-
var genderedIndices = (_o = {}, _o[MALE] = 0, _o[FEMALE] = 0, _o[OTHER$
|
|
68673
|
+
var genderedIndices = (_o = {}, _o[MALE] = 0, _o[FEMALE] = 0, _o[OTHER$3] = 0, _o);
|
|
68628
68674
|
var individualParticipantsCount = individualParticipants.length;
|
|
68629
68675
|
var addressComponents = individualParticipants.reduce(function (components, participant) {
|
|
68630
68676
|
var _a, _b;
|
|
@@ -68657,7 +68703,7 @@ function anonymizeTournamentRecord(_a) {
|
|
|
68657
68703
|
individualParticipants.forEach(function (individualParticipant, participantIndex) {
|
|
68658
68704
|
var _a, _b;
|
|
68659
68705
|
var person = individualParticipant === null || individualParticipant === void 0 ? void 0 : individualParticipant.person;
|
|
68660
|
-
var gender = (person === null || person === void 0 ? void 0 : person.sex) || OTHER$
|
|
68706
|
+
var gender = (person === null || person === void 0 ? void 0 : person.sex) || OTHER$3;
|
|
68661
68707
|
var birthYear = (_a = extractDate(person === null || person === void 0 ? void 0 : person.birthDate)) === null || _a === void 0 ? void 0 : _a.split('-')[0];
|
|
68662
68708
|
var genderedIndex = genderedIndices[gender];
|
|
68663
68709
|
var generatedPerson = genderedPersons[gender][genderedIndex];
|
|
@@ -69221,7 +69267,7 @@ function processTieFormat(_a) {
|
|
|
69221
69267
|
var maxDoublesCount = 0, maxSinglesCount = 0;
|
|
69222
69268
|
var singlesMatchUpTotal = 0, doublesMatchUpTotal = 0;
|
|
69223
69269
|
var categories = {};
|
|
69224
|
-
var genders = (_b = {}, _b[MALE] = 0, _b[FEMALE] = 0, _b[MIXED] = 0, _b[OTHER$
|
|
69270
|
+
var genders = (_b = {}, _b[MALE] = 0, _b[FEMALE] = 0, _b[MIXED] = 0, _b[OTHER$3] = 0, _b[ANY] = 0, _b);
|
|
69225
69271
|
tieFormat =
|
|
69226
69272
|
typeof tieFormat === 'object'
|
|
69227
69273
|
? tieFormat
|
|
@@ -69278,7 +69324,7 @@ function getParticipantsCount(_a) {
|
|
|
69278
69324
|
var gendersCount = (_b = {},
|
|
69279
69325
|
_b[FEMALE] = 0,
|
|
69280
69326
|
_b[MIXED] = 0,
|
|
69281
|
-
_b[OTHER$
|
|
69327
|
+
_b[OTHER$3] = 0,
|
|
69282
69328
|
_b[MALE] = 0,
|
|
69283
69329
|
_b[ANY] = 0,
|
|
69284
69330
|
_b);
|
|
@@ -70955,6 +71001,7 @@ var utilities = {
|
|
|
70955
71001
|
findExtension: findExtension$2,
|
|
70956
71002
|
flattenJSON: flattenJSON,
|
|
70957
71003
|
garman: garman,
|
|
71004
|
+
genderValidityCheck: genderValidityCheck,
|
|
70958
71005
|
generateHashCode: generateHashCode,
|
|
70959
71006
|
generateRange: generateRange,
|
|
70960
71007
|
generateScoreString: generateScoreString,
|
|
@@ -71031,6 +71078,7 @@ exports.scaleEngineAsync = scaleEngineAsync;
|
|
|
71031
71078
|
exports.scoreGovernor = scoreGovernor;
|
|
71032
71079
|
exports.setDeepCopy = setDeepCopy;
|
|
71033
71080
|
exports.setDevContext = setDevContext;
|
|
71081
|
+
exports.setGlobalLog = setGlobalLog;
|
|
71034
71082
|
exports.setStateProvider = setStateProvider;
|
|
71035
71083
|
exports.setSubscriptions = setSubscriptions;
|
|
71036
71084
|
exports.surfaceConstants = surfaceConstants;
|