tods-competition-factory 1.8.11 → 1.8.12

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/index.mjs CHANGED
@@ -2375,7 +2375,7 @@ const matchUpFormatCode = {
2375
2375
  };
2376
2376
 
2377
2377
  function factoryVersion() {
2378
- return "1.8.11";
2378
+ return "1.8.12";
2379
2379
  }
2380
2380
 
2381
2381
  function getObjectTieFormat(obj) {
@@ -17287,6 +17287,43 @@ function removeExtraneousAttributes(matchUps, matchUpFormatMap = {}) {
17287
17287
  }
17288
17288
  }
17289
17289
 
17290
+ function participantScaleItem({
17291
+ requireTimeStamp,
17292
+ scaleAttributes,
17293
+ participant
17294
+ }) {
17295
+ if (!participant)
17296
+ return { error: MISSING_PARTICIPANT };
17297
+ if (typeof scaleAttributes !== "object")
17298
+ return { error: INVALID_VALUES };
17299
+ if (!participant.timeItems)
17300
+ participant.timeItems = [];
17301
+ if (Array.isArray(participant.timeItems)) {
17302
+ const { accessor, scaleType, eventType, scaleName } = scaleAttributes;
17303
+ const filterType = [SCALE$1, scaleType, eventType, scaleName].join(".");
17304
+ const filteredTimeItems = participant.timeItems.filter((timeItem2) => timeItem2?.itemType === filterType).filter((timeItem2) => !requireTimeStamp || timeItem2?.itemDate).sort(
17305
+ (a, b) => (a.createdAt ? new Date(a.createdAt).getTime() : 0) - (b.createdAt ? new Date(b.createdAt).getTime() : 0)
17306
+ );
17307
+ const timeItem = filteredTimeItems.pop();
17308
+ if (timeItem) {
17309
+ const [itemSubject, scaleType2, eventType2, scaleName2] = timeItem.itemType?.split(".") ?? [];
17310
+ if (itemSubject !== SCALE$1)
17311
+ return { error: INVALID_SCALE_ITEM };
17312
+ const accessorValue = accessor && getAccessorValue({ element: timeItem.itemValue, accessor });
17313
+ const scaleValue = accessorValue?.value || timeItem.itemValue;
17314
+ const scaleItem = {
17315
+ eventType: eventType2,
17316
+ scaleDate: timeItem.itemDate,
17317
+ scaleValue,
17318
+ scaleName: scaleName2,
17319
+ scaleType: scaleType2
17320
+ };
17321
+ return { ...SUCCESS, scaleItem };
17322
+ }
17323
+ }
17324
+ return { ...SUCCESS, scaleItem: void 0 };
17325
+ }
17326
+
17290
17327
  function getCourtDateAvailability({ court, date }) {
17291
17328
  const targetDateAvailability = date && court.dateAvailability.find(
17292
17329
  (availability) => sameDay(availability.date, date)
@@ -26684,43 +26721,6 @@ function getEventPublishStatuses({ event }) {
26684
26721
  return void 0;
26685
26722
  }
26686
26723
 
26687
- function participantScaleItem({
26688
- requireTimeStamp,
26689
- scaleAttributes,
26690
- participant
26691
- }) {
26692
- if (!participant)
26693
- return { error: MISSING_PARTICIPANT };
26694
- if (typeof scaleAttributes !== "object")
26695
- return { error: INVALID_VALUES };
26696
- if (!participant.timeItems)
26697
- participant.timeItems = [];
26698
- if (Array.isArray(participant.timeItems)) {
26699
- const { accessor, scaleType, eventType, scaleName } = scaleAttributes;
26700
- const filterType = [SCALE$1, scaleType, eventType, scaleName].join(".");
26701
- const filteredTimeItems = participant.timeItems.filter((timeItem2) => timeItem2?.itemType === filterType).filter((timeItem2) => !requireTimeStamp || timeItem2?.itemDate).sort(
26702
- (a, b) => (a.createdAt ? new Date(a.createdAt).getTime() : 0) - (b.createdAt ? new Date(b.createdAt).getTime() : 0)
26703
- );
26704
- const timeItem = filteredTimeItems.pop();
26705
- if (timeItem) {
26706
- const [itemSubject, scaleType2, eventType2, scaleName2] = timeItem.itemType?.split(".") ?? [];
26707
- if (itemSubject !== SCALE$1)
26708
- return { error: INVALID_SCALE_ITEM };
26709
- const accessorValue = accessor && getAccessorValue({ element: timeItem.itemValue, accessor });
26710
- const scaleValue = accessorValue?.value || timeItem.itemValue;
26711
- const scaleItem = {
26712
- eventType: eventType2,
26713
- scaleDate: timeItem.itemDate,
26714
- scaleValue,
26715
- scaleName: scaleName2,
26716
- scaleType: scaleType2
26717
- };
26718
- return { ...SUCCESS, scaleItem };
26719
- }
26720
- }
26721
- return { ...SUCCESS, scaleItem: void 0 };
26722
- }
26723
-
26724
26724
  function getEventSeedAssignments({
26725
26725
  publishedSeeding,
26726
26726
  usePublishState,
@@ -36515,10 +36515,7 @@ function matchUpActions$2({
36515
36515
  }
36516
36516
  });
36517
36517
  }
36518
- if (
36519
- // isInComplete && // TODO: determine whether removal should be disallowed for completed matchUps => policy consideration?
36520
- existingParticipantIds?.length && (!scoreHasValue(matchUp) || side?.substitutions?.length)
36521
- ) {
36518
+ if (existingParticipantIds?.length && (!scoreHasValue(matchUp) || side?.substitutions?.length)) {
36522
36519
  validActions.push({
36523
36520
  method: REMOVE_TEAM_POSITION_METHOD,
36524
36521
  type: REMOVE_PARTICIPANT,
@@ -37985,6 +37982,27 @@ function setState$4(records, deepCopyOption = true) {
37985
37982
  return setTournamentRecords(deepCopyOption ? makeDeepCopy(records) : records);
37986
37983
  }
37987
37984
 
37985
+ function engineLogging({ result, methodName, elapsed, params, engine }) {
37986
+ const devContext = getDevContext();
37987
+ const log = { method: methodName };
37988
+ const logError = result.error && (devContext.errors === true || Array.isArray(devContext.errors) && devContext.errors.includes(methodName));
37989
+ const specifiedMethodParams = Array.isArray(devContext.params) && devContext.params?.includes(methodName);
37990
+ const logParams = devContext.params && !Array.isArray(devContext.params) || specifiedMethodParams;
37991
+ const exclude = Array.isArray(devContext.exclude) && devContext.exclude.includes(methodName);
37992
+ if (!exclude && ![void 0, false].includes(devContext.perf) && (isNaN(devContext.perf) || elapsed > devContext.perf))
37993
+ log.elapsed = elapsed;
37994
+ if (!exclude && (logError || logParams)) {
37995
+ log.params = params;
37996
+ }
37997
+ if (!exclude && (logError || devContext.result && !Array.isArray(devContext.result) && (!Array.isArray(devContext.params) || specifiedMethodParams) || Array.isArray(devContext.result) && devContext.result?.includes(methodName))) {
37998
+ log.result = result;
37999
+ }
38000
+ if (Object.keys(log).length > 1)
38001
+ console.log(engine, log);
38002
+ if (devContext.makeDeepCopy)
38003
+ result.deepCopyIterations = getDeepCopyIterations();
38004
+ }
38005
+
37988
38006
  const competitionEngine = function() {
37989
38007
  const engine = {
37990
38008
  getState: (params) => getState$3({
@@ -38049,20 +38067,7 @@ const competitionEngine = function() {
38049
38067
  ...params
38050
38068
  });
38051
38069
  const elapsed = Date.now() - start;
38052
- const devContext = getDevContext();
38053
- const log = { method: methodName };
38054
- const logError = result.error && (devContext.errors === true || Array.isArray(devContext.errors) && devContext.errors.includes(methodName));
38055
- const exclude = Array.isArray(devContext.exclude) && devContext.exclude.includes(methodName);
38056
- if (!exclude && ![void 0, false].includes(devContext.perf) && (isNaN(devContext.perf) || elapsed > devContext.perf))
38057
- log.elapsed = elapsed;
38058
- if (!exclude && (logError || devContext.params && !Array.isArray(devContext.params) || Array.isArray(devContext.params) && devContext.params?.includes(methodName))) {
38059
- log.params = params;
38060
- }
38061
- if (!exclude && (logError || devContext.result && !Array.isArray(devContext.result) || Array.isArray(devContext.result) && devContext.result?.includes(methodName))) {
38062
- log.result = result;
38063
- }
38064
- if (Object.keys(log).length > 1)
38065
- console.log("ce:", log);
38070
+ engineLogging({ result, methodName, elapsed, params, engine: "ce:" });
38066
38071
  return result;
38067
38072
  }
38068
38073
  function engineInvoke(method, params, methodName) {
@@ -48035,7 +48040,7 @@ function positionActions$1(params) {
48035
48040
  structure,
48036
48041
  event
48037
48042
  }).appliedPolicies ?? {};
48038
- Object.assign(appliedPolicies, specifiedPolicyDefinitions || {});
48043
+ Object.assign(appliedPolicies, specifiedPolicyDefinitions ?? {});
48039
48044
  const {
48040
48045
  actionsPolicy: positionActionsPolicy,
48041
48046
  enabledStructures,
@@ -48192,7 +48197,7 @@ function positionActions$1(params) {
48192
48197
  });
48193
48198
  const { seedNumber, seedValue } = seedAssignments?.find(
48194
48199
  (assignment) => assignment.participantId === participantId
48195
- ) || {};
48200
+ ) ?? {};
48196
48201
  validActions.push({
48197
48202
  type: SEED_VALUE,
48198
48203
  method: SEED_VALUE_METHOD,
@@ -48218,7 +48223,7 @@ function positionActions$1(params) {
48218
48223
  });
48219
48224
  const { seedNumber } = seedAssignments?.find(
48220
48225
  (assignment) => assignment.participantId === participantId
48221
- ) || {};
48226
+ ) ?? {};
48222
48227
  validActions.push({
48223
48228
  method: REMOVE_SEED_METHOD,
48224
48229
  type: REMOVE_SEED,
@@ -60087,22 +60092,7 @@ const tournamentEngine = (() => {
60087
60092
  tournamentRecord
60088
60093
  });
60089
60094
  const elapsed = Date.now() - start;
60090
- const devContext = getDevContext();
60091
- const log = { method: methodName };
60092
- const logError = result.error && (devContext.errors === true || Array.isArray(devContext.errors) && devContext.errors.includes(methodName));
60093
- const exclude = Array.isArray(devContext.exclude) && devContext.exclude.includes(methodName);
60094
- if (!exclude && ![void 0, false].includes(devContext.perf) && (isNaN(devContext.perf) || elapsed > devContext.perf))
60095
- log.elapsed = elapsed;
60096
- if (!exclude && (logError || devContext.params && !Array.isArray(devContext.params) || Array.isArray(devContext.params) && devContext.params?.includes(methodName))) {
60097
- log.params = params;
60098
- }
60099
- if (!exclude && (logError || devContext.result && !Array.isArray(devContext.result) || Array.isArray(devContext.result) && devContext.result?.includes(methodName))) {
60100
- log.result = result;
60101
- }
60102
- if (Object.keys(log).length > 1)
60103
- console.log("te:", log);
60104
- if (devContext.makeDeepCopy)
60105
- result.deepCopyIterations = getDeepCopyIterations();
60095
+ engineLogging({ result, methodName, elapsed, params, engine: "te:" });
60106
60096
  return result;
60107
60097
  }
60108
60098
  function engineInvoke(method, params, methodName) {
@@ -64365,51 +64355,52 @@ const factoryConstants = {
64365
64355
  };
64366
64356
 
64367
64357
  const utilities = {
64368
- hasAttributeValues,
64369
- extractAttributes,
64370
- structureSort,
64371
- matchUpSort,
64372
- tidyScore,
64373
- createMap,
64374
- generateScoreString,
64375
- calculateWinCriteria,
64376
- compareTieFormats,
64377
- parseScoreString,
64378
- scoreHasValue,
64379
- getScaleValues,
64380
- proConflicts,
64381
64358
  addExtension: addExtension$1,
64359
+ calculateWinCriteria,
64360
+ categoryCanContain,
64382
64361
  chunkArray,
64362
+ compareTieFormats,
64383
64363
  countValues,
64364
+ createMap,
64384
64365
  dateRange,
64385
64366
  dateTime,
64386
- roundRobinGroups,
64387
64367
  definedAttributes,
64388
64368
  dehydrateMatchUps,
64369
+ extractAttributes,
64389
64370
  findExtension: findExtension$2,
64371
+ flattenJSON,
64390
64372
  garman,
64391
- getTimeItem,
64392
64373
  generateHashCode,
64393
64374
  generateRange,
64375
+ generateScoreString,
64394
64376
  generateTimeCode,
64377
+ getCategoryAgeDetails,
64378
+ getScaleValues,
64379
+ getTimeItem,
64380
+ hasAttributeValues,
64395
64381
  instanceCount,
64396
64382
  intersection,
64397
- isNumeric,
64383
+ isAdHoc,
64398
64384
  isConvertableInteger,
64385
+ isNumeric,
64399
64386
  isPowerOf2,
64400
64387
  JSON2CSV,
64401
- flattenJSON,
64402
64388
  makeDeepCopy,
64389
+ matchUpSort,
64403
64390
  nearestPowerOf2,
64404
64391
  nextPowerOf2,
64405
64392
  numericSort,
64406
64393
  overlap,
64407
- getCategoryAgeDetails,
64408
- categoryCanContain,
64394
+ parseScoreString,
64395
+ participantScaleItem,
64396
+ proConflicts,
64409
64397
  randomMember,
64410
64398
  randomPop,
64399
+ roundRobinGroups,
64400
+ scoreHasValue,
64411
64401
  shuffleArray,
64412
- isAdHoc,
64402
+ structureSort,
64403
+ tidyScore,
64413
64404
  unique,
64414
64405
  UUID,
64415
64406
  UUIDS,