tods-competition-factory 1.9.1 → 1.9.3

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
@@ -1360,7 +1360,6 @@ function handleCaughtError$1({
1360
1360
  const globalState = {
1361
1361
  tournamentFactoryVersion: "0.0.0",
1362
1362
  timers: { default: { elapsedTime: 0 } },
1363
- iterators: { makeDeepCopy: 0 },
1364
1363
  deepCopyAttributes: {
1365
1364
  stringify: [],
1366
1365
  ignore: [],
@@ -1437,12 +1436,6 @@ function setGlobalLog(loggingFx) {
1437
1436
  function setDevContext(value) {
1438
1437
  globalState.devContext = value;
1439
1438
  }
1440
- function setDeepCopyIterations(value) {
1441
- globalState.iterators.makeDeepCopy = value;
1442
- }
1443
- function getDeepCopyIterations() {
1444
- return globalState.iterators.makeDeepCopy;
1445
- }
1446
1439
  function disableNotifications() {
1447
1440
  _globalStateProvider.disableNotifications();
1448
1441
  }
@@ -1538,7 +1531,13 @@ function handleCaughtError({
1538
1531
  }
1539
1532
  function globalLog$1(engine, log) {
1540
1533
  if (globalState.globalLog) {
1541
- return globalState.globalLog(engine, log);
1534
+ try {
1535
+ globalState.globalLog(engine, log);
1536
+ } catch (error) {
1537
+ console.log("globalLog error", error);
1538
+ console.log(engine, log);
1539
+ setGlobalLog();
1540
+ }
1542
1541
  } else {
1543
1542
  console.log(engine, log);
1544
1543
  }
@@ -1869,13 +1868,6 @@ function makeDeepCopy(sourceObject, convertExtensions, internalUse, removeExtens
1869
1868
  if (!deepCopy?.enabled && !internalUse || typeof sourceObject !== "object" || typeof sourceObject === "function" || sourceObject === null || typeof deepCopy?.threshold === "number" && iteration >= deepCopy.threshold) {
1870
1869
  return sourceObject;
1871
1870
  }
1872
- const devContext = getDevContext({ makeDeepCopy: true });
1873
- if (devContext) {
1874
- setDeepCopyIterations(iteration);
1875
- if (typeof devContext === "object" && (iteration > (devContext.iterationThreshold || 15) || devContext.firstIteration && iteration === 0) && devContext.log && (!devContext.notInternalUse || devContext.notInternalUse && !internalUse)) {
1876
- console.log({ devContext, iteration, internalUse }, sourceObject);
1877
- }
1878
- }
1879
1871
  const targetObject = Array.isArray(sourceObject) ? [] : {};
1880
1872
  const sourceObjectKeys = Object.keys(sourceObject).filter(
1881
1873
  (key) => !internalUse || !ignore || Array.isArray(ignore) && !ignore.includes(key) || typeof ignore === "function" && !ignore(key)
@@ -2422,7 +2414,7 @@ const matchUpFormatCode = {
2422
2414
  };
2423
2415
 
2424
2416
  function factoryVersion() {
2425
- return "1.9.1";
2417
+ return "1.9.3";
2426
2418
  }
2427
2419
 
2428
2420
  function getObjectTieFormat(obj) {
@@ -10336,11 +10328,10 @@ function modifyMatchUpScore({
10336
10328
  }
10337
10329
  if (Array.isArray(defaultedProcessCodes) && inContextMatchUp && !inContextMatchUp.sides?.every(({ participantId }) => participantId)) {
10338
10330
  if (matchUpStatus === DEFAULTED) {
10339
- if (matchUp.processCodes) {
10340
- matchUp.processCodes.push(...defaultedProcessCodes);
10341
- } else {
10342
- matchUp.processCodes = defaultedProcessCodes;
10343
- }
10331
+ matchUp.processCodes = unique([
10332
+ ...matchUp.processCodes ?? [],
10333
+ ...defaultedProcessCodes
10334
+ ]);
10344
10335
  } else {
10345
10336
  for (const processCode of defaultedProcessCodes || []) {
10346
10337
  const codeIndex = processCode && matchUp?.processCodes?.lastIndexOf(processCode);
@@ -15131,44 +15122,37 @@ const positionActionConstants = {
15131
15122
  SEED_VALUE
15132
15123
  };
15133
15124
 
15134
- const POLICY_POSITION_ACTIONS_DEFAULT = {
15125
+ const POLICY_POSITION_ACTIONS_UNRESTRICTED = {
15135
15126
  [POLICY_TYPE_POSITION_ACTIONS]: {
15136
- policyName: "positionActionsDefault",
15127
+ policyName: "positionActionsUnrestricted",
15128
+ // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [], structureTypes: [] }
15129
+ // enabledStructures: [] => all structures are enabled
15130
+ enabledStructures: [],
15131
+ // enables entries in other flights to be accessed as alternates
15132
+ otherFlightEntries: true,
15133
+ // enables entries with multiple qualifying roundTargets to be placed in any round
15134
+ disableRoundRestrictions: true,
15135
+ // enable specific actions even when there are active positions
15136
+ activePositionOverrides: [SEED_VALUE, REMOVE_SEED]
15137
+ }
15138
+ };
15139
+
15140
+ const POLICY_POSITION_ACTIONS_NO_MOVEMENT = {
15141
+ [POLICY_TYPE_POSITION_ACTIONS]: {
15142
+ policyName: "positionActionsNoMovement",
15137
15143
  // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [] }
15138
15144
  // enabledStructures: [] => all structures are enabled
15139
15145
  enabledStructures: [
15140
- {
15141
- stages: [QUALIFYING, MAIN],
15142
- // stages to which this policy applies
15143
- stageSequences: [1],
15144
- // stageSequences to which this policy applies
15145
- enabledActions: [],
15146
- // enabledActions: [] => all actions are enabled
15147
- disabledActions: []
15148
- // disabledActions: [] => no actions are disabled
15149
- },
15150
15146
  {
15151
15147
  stages: [],
15152
15148
  // stages: [] => applies to all stages
15153
15149
  stageSequences: [],
15154
15150
  // stageSequences: [] => applies to all stageSequences
15155
- enabledActions: [
15156
- ADD_NICKNAME,
15157
- ADD_PENALTY,
15158
- QUALIFYING_PARTICIPANT,
15159
- SEED_VALUE
15160
- ],
15151
+ enabledActions: [SEED_VALUE, ADD_NICKNAME, ADD_PENALTY],
15161
15152
  disabledActions: []
15162
15153
  // disabledActions: [] => no actions are disabled
15163
15154
  }
15164
- ],
15165
- // positionActions will be completely disabled for any structures matching { stages: [], stageSequences: [] }
15166
- // disabledStructures: [] => no structures are disabled
15167
- disbledStructures: [],
15168
- // enables entries in other flights to be accessed as alternates
15169
- otherFlightEntries: false,
15170
- // enable specific actions even when there are active positions
15171
- activePositionOverrides: []
15155
+ ]
15172
15156
  }
15173
15157
  };
15174
15158
 
@@ -15181,115 +15165,44 @@ const POLICY_POSITION_ACTIONS_DISABLED = {
15181
15165
  }
15182
15166
  };
15183
15167
 
15184
- const POLICY_POSITION_ACTIONS_NO_MOVEMENT = {
15168
+ const POLICY_POSITION_ACTIONS_DEFAULT = {
15185
15169
  [POLICY_TYPE_POSITION_ACTIONS]: {
15186
- policyName: "positionActionsNoMovement",
15170
+ policyName: "positionActionsDefault",
15187
15171
  // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [] }
15188
15172
  // enabledStructures: [] => all structures are enabled
15189
15173
  enabledStructures: [
15174
+ {
15175
+ stages: [QUALIFYING, MAIN],
15176
+ // stages to which this policy applies
15177
+ stageSequences: [1],
15178
+ // stageSequences to which this policy applies
15179
+ enabledActions: [],
15180
+ // enabledActions: [] => all actions are enabled
15181
+ disabledActions: []
15182
+ // disabledActions: [] => no actions are disabled
15183
+ },
15190
15184
  {
15191
15185
  stages: [],
15192
15186
  // stages: [] => applies to all stages
15193
15187
  stageSequences: [],
15194
15188
  // stageSequences: [] => applies to all stageSequences
15195
- enabledActions: [SEED_VALUE, ADD_NICKNAME, ADD_PENALTY],
15189
+ enabledActions: [
15190
+ ADD_NICKNAME,
15191
+ ADD_PENALTY,
15192
+ QUALIFYING_PARTICIPANT,
15193
+ SEED_VALUE
15194
+ ],
15196
15195
  disabledActions: []
15197
15196
  // disabledActions: [] => no actions are disabled
15198
15197
  }
15199
- ]
15200
- }
15201
- };
15202
-
15203
- const POLICY_POSITION_ACTIONS_UNRESTRICTED = {
15204
- [POLICY_TYPE_POSITION_ACTIONS]: {
15205
- policyName: "positionActionsUnrestricted",
15206
- // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [], structureTypes: [] }
15207
- // enabledStructures: [] => all structures are enabled
15208
- enabledStructures: [],
15198
+ ],
15199
+ // positionActions will be completely disabled for any structures matching { stages: [], stageSequences: [] }
15200
+ // disabledStructures: [] => no structures are disabled
15201
+ disbledStructures: [],
15209
15202
  // enables entries in other flights to be accessed as alternates
15210
- otherFlightEntries: true,
15211
- // enables entries with multiple qualifying roundTargets to be placed in any round
15212
- disableRoundRestrictions: true,
15203
+ otherFlightEntries: false,
15213
15204
  // enable specific actions even when there are active positions
15214
- activePositionOverrides: [SEED_VALUE, REMOVE_SEED]
15215
- }
15216
- };
15217
-
15218
- const POLICY_PRIVACY_DEFAULT = {
15219
- [POLICY_TYPE_PARTICIPANT]: {
15220
- policyName: "Participant Privacy Policy",
15221
- participant: {
15222
- contacts: false,
15223
- individualParticipants: {
15224
- onlineResources: false,
15225
- participantName: true,
15226
- participantOtherName: true,
15227
- participantId: true,
15228
- participantRole: true,
15229
- participantStatus: true,
15230
- penalties: false,
15231
- representing: true,
15232
- participantRoleResponsibilities: false,
15233
- participantType: true,
15234
- person: {
15235
- addresses: false,
15236
- biographicalInformation: false,
15237
- birthDate: false,
15238
- contacts: false,
15239
- nationalityCode: true,
15240
- nativeFamilyName: false,
15241
- nativeGivenName: false,
15242
- onlineResources: false,
15243
- otherNames: true,
15244
- parentOrganisationId: false,
15245
- passportFamilyName: false,
15246
- passportGivenName: false,
15247
- personId: false,
15248
- personOtherIds: false,
15249
- previousNames: false,
15250
- sex: false,
15251
- standardFamilyName: true,
15252
- standardGivenName: true,
15253
- status: false,
15254
- tennisId: false,
15255
- wheelchair: true
15256
- }
15257
- },
15258
- individualParticipantIds: true,
15259
- onlineResources: false,
15260
- participantName: true,
15261
- participantOtherName: true,
15262
- participantId: true,
15263
- participantRole: true,
15264
- participantStatus: true,
15265
- penalties: false,
15266
- representing: true,
15267
- participantRoleResponsibilities: false,
15268
- participantType: true,
15269
- person: {
15270
- addresses: false,
15271
- biographicalInformation: false,
15272
- birthDate: false,
15273
- contacts: false,
15274
- nationalityCode: true,
15275
- nativeFamilyName: false,
15276
- nativeGivenName: false,
15277
- onlineResources: false,
15278
- otherNames: true,
15279
- parentOrganisationId: false,
15280
- passportFamilyName: false,
15281
- passportGivenName: false,
15282
- personId: false,
15283
- personOtherIds: false,
15284
- previousNames: false,
15285
- sex: false,
15286
- standardFamilyName: true,
15287
- standardGivenName: true,
15288
- status: false,
15289
- tennisId: false,
15290
- wheelchair: true
15291
- }
15292
- }
15205
+ activePositionOverrides: []
15293
15206
  }
15294
15207
  };
15295
15208
 
@@ -15488,6 +15401,107 @@ const POLICY_SCHEDULING_DEFAULT = {
15488
15401
  }
15489
15402
  };
15490
15403
 
15404
+ const POLICY_PRIVACY_DEFAULT = {
15405
+ [POLICY_TYPE_PARTICIPANT]: {
15406
+ policyName: "Participant Privacy Policy",
15407
+ participant: {
15408
+ contacts: false,
15409
+ individualParticipants: {
15410
+ onlineResources: false,
15411
+ participantName: true,
15412
+ participantOtherName: true,
15413
+ participantId: true,
15414
+ participantRole: true,
15415
+ participantStatus: true,
15416
+ penalties: false,
15417
+ representing: true,
15418
+ participantRoleResponsibilities: false,
15419
+ participantType: true,
15420
+ person: {
15421
+ addresses: false,
15422
+ biographicalInformation: false,
15423
+ birthDate: false,
15424
+ contacts: false,
15425
+ nationalityCode: true,
15426
+ nativeFamilyName: false,
15427
+ nativeGivenName: false,
15428
+ onlineResources: false,
15429
+ otherNames: true,
15430
+ parentOrganisationId: false,
15431
+ passportFamilyName: false,
15432
+ passportGivenName: false,
15433
+ personId: false,
15434
+ personOtherIds: false,
15435
+ previousNames: false,
15436
+ sex: false,
15437
+ standardFamilyName: true,
15438
+ standardGivenName: true,
15439
+ status: false,
15440
+ tennisId: false,
15441
+ wheelchair: true
15442
+ }
15443
+ },
15444
+ individualParticipantIds: true,
15445
+ onlineResources: false,
15446
+ participantName: true,
15447
+ participantOtherName: true,
15448
+ participantId: true,
15449
+ participantRole: true,
15450
+ participantStatus: true,
15451
+ penalties: false,
15452
+ representing: true,
15453
+ participantRoleResponsibilities: false,
15454
+ participantType: true,
15455
+ person: {
15456
+ addresses: false,
15457
+ biographicalInformation: false,
15458
+ birthDate: false,
15459
+ contacts: false,
15460
+ nationalityCode: true,
15461
+ nativeFamilyName: false,
15462
+ nativeGivenName: false,
15463
+ onlineResources: false,
15464
+ otherNames: true,
15465
+ parentOrganisationId: false,
15466
+ passportFamilyName: false,
15467
+ passportGivenName: false,
15468
+ personId: false,
15469
+ personOtherIds: false,
15470
+ previousNames: false,
15471
+ sex: false,
15472
+ standardFamilyName: true,
15473
+ standardGivenName: true,
15474
+ status: false,
15475
+ tennisId: false,
15476
+ wheelchair: true
15477
+ }
15478
+ }
15479
+ }
15480
+ };
15481
+
15482
+ const POLICY_SCORING_DEFAULT = {
15483
+ [POLICY_TYPE_SCORING]: {
15484
+ defaultMatchUpFormat: FORMAT_STANDARD,
15485
+ allowDeletionWithScoresPresent: {
15486
+ drawDefinitions: false,
15487
+ structures: false
15488
+ },
15489
+ requireAllPositionsAssigned: false,
15490
+ processCodes: {
15491
+ incompleteAssignmentsOnDefault: ["RANKING.IGNORE"]
15492
+ },
15493
+ stage: {
15494
+ [MAIN]: {
15495
+ stageSequence: {
15496
+ 1: {
15497
+ requireAllPositionsAssigned: true
15498
+ }
15499
+ }
15500
+ }
15501
+ }
15502
+ }
15503
+ };
15504
+
15491
15505
  const POLICY_SCORING_USTA = {
15492
15506
  [POLICY_TYPE_SCORING]: {
15493
15507
  requireAllPositionsAssigned: false,
@@ -15584,66 +15598,43 @@ const POLICY_SCORING_USTA = {
15584
15598
  }
15585
15599
  };
15586
15600
 
15587
- const POLICY_SCORING_DEFAULT = {
15588
- [POLICY_TYPE_SCORING]: {
15589
- defaultMatchUpFormat: FORMAT_STANDARD,
15590
- allowDeletionWithScoresPresent: {
15591
- drawDefinitions: false,
15592
- structures: false
15593
- },
15594
- requireAllPositionsAssigned: false,
15595
- processCodes: {
15596
- incompleteAssignmentsOnDefault: ["RANKING.IGNORE"]
15597
- },
15598
- stage: {
15599
- [MAIN]: {
15600
- stageSequence: {
15601
- 1: {
15602
- requireAllPositionsAssigned: true
15603
- }
15604
- }
15605
- }
15606
- }
15607
- }
15608
- };
15609
-
15610
- const POLICY_SEEDING_ITF = {
15601
+ const POLICY_SEEDING_DEFAULT = {
15611
15602
  [POLICY_TYPE_SEEDING]: {
15612
- seedingProfile: { positioning: CLUSTER },
15613
15603
  validSeedPositions: { ignore: true },
15614
15604
  duplicateSeedNumbers: true,
15615
15605
  drawSizeProgression: true,
15616
- policyName: "ITF SEEDING",
15606
+ seedingProfile: {
15607
+ drawTypes: {
15608
+ [ROUND_ROBIN_WITH_PLAYOFF]: { positioning: WATERFALL },
15609
+ [ROUND_ROBIN]: { positioning: WATERFALL }
15610
+ },
15611
+ positioning: SEPARATE
15612
+ },
15613
+ policyName: "USTA SEEDING",
15617
15614
  seedsCountThresholds: [
15618
15615
  { drawSize: 4, minimumParticipantCount: 3, seedsCount: 2 },
15619
15616
  { drawSize: 16, minimumParticipantCount: 12, seedsCount: 4 },
15620
15617
  { drawSize: 32, minimumParticipantCount: 24, seedsCount: 8 },
15621
15618
  { drawSize: 64, minimumParticipantCount: 48, seedsCount: 16 },
15622
- { drawSize: 128, minimumParticipantCount: 97, seedsCount: 32 },
15619
+ { drawSize: 128, minimumParticipantCount: 96, seedsCount: 32 },
15623
15620
  { drawSize: 256, minimumParticipantCount: 192, seedsCount: 64 }
15624
15621
  ]
15625
15622
  }
15626
15623
  };
15627
15624
 
15628
- const POLICY_SEEDING_USTA = {
15625
+ const POLICY_SEEDING_ITF = {
15629
15626
  [POLICY_TYPE_SEEDING]: {
15627
+ seedingProfile: { positioning: CLUSTER },
15630
15628
  validSeedPositions: { ignore: true },
15631
15629
  duplicateSeedNumbers: true,
15632
15630
  drawSizeProgression: true,
15633
- seedingProfile: {
15634
- drawTypes: {
15635
- [ROUND_ROBIN_WITH_PLAYOFF]: { positioning: WATERFALL },
15636
- [ROUND_ROBIN]: { positioning: WATERFALL }
15637
- },
15638
- positioning: SEPARATE
15639
- },
15640
- policyName: "USTA SEEDING",
15631
+ policyName: "ITF SEEDING",
15641
15632
  seedsCountThresholds: [
15642
15633
  { drawSize: 4, minimumParticipantCount: 3, seedsCount: 2 },
15643
15634
  { drawSize: 16, minimumParticipantCount: 12, seedsCount: 4 },
15644
15635
  { drawSize: 32, minimumParticipantCount: 24, seedsCount: 8 },
15645
15636
  { drawSize: 64, minimumParticipantCount: 48, seedsCount: 16 },
15646
- { drawSize: 128, minimumParticipantCount: 96, seedsCount: 32 },
15637
+ { drawSize: 128, minimumParticipantCount: 97, seedsCount: 32 },
15647
15638
  { drawSize: 256, minimumParticipantCount: 192, seedsCount: 64 }
15648
15639
  ]
15649
15640
  }
@@ -15661,7 +15652,7 @@ const policies = {
15661
15652
  POLICY_SCORING_DEFAULT,
15662
15653
  POLICY_SCORING_USTA,
15663
15654
  POLICY_SEEDING_ITF,
15664
- POLICY_SEEDING_USTA
15655
+ POLICY_SEEDING_DEFAULT
15665
15656
  };
15666
15657
 
15667
15658
  const fixtures = {
@@ -26538,6 +26529,34 @@ function updateFactoryExtension({ tournamentRecord, value }) {
26538
26529
  addExtension$1({ element: tournamentRecord, extension: updatedExtension });
26539
26530
  }
26540
26531
 
26532
+ function engineLogging({
26533
+ methodName,
26534
+ elapsed,
26535
+ engine,
26536
+ params,
26537
+ result
26538
+ }) {
26539
+ const devContext = getDevContext();
26540
+ if (typeof devContext !== "object")
26541
+ return;
26542
+ const log = { method: methodName };
26543
+ const logError = result?.error && (devContext.errors === true || Array.isArray(devContext.errors) && devContext.errors.includes(methodName));
26544
+ const specifiedMethodParams = Array.isArray(devContext.params) && devContext.params?.includes(methodName);
26545
+ const logParams = devContext.params && !Array.isArray(devContext.params) || specifiedMethodParams;
26546
+ const exclude = Array.isArray(devContext.exclude) && devContext.exclude.includes(methodName);
26547
+ if (!exclude && ![void 0, false].includes(devContext.perf) && (isNaN(devContext.perf) || elapsed > devContext.perf)) {
26548
+ log.elapsed = elapsed;
26549
+ }
26550
+ if (!exclude && (logError || logParams)) {
26551
+ log.params = params;
26552
+ }
26553
+ if (!exclude && (logError || devContext.result && !Array.isArray(devContext.result) && (!Array.isArray(devContext.params) || specifiedMethodParams) || Array.isArray(devContext.result) && devContext.result?.includes(methodName))) {
26554
+ log.result = result;
26555
+ }
26556
+ if (Object.keys(log).length > 1)
26557
+ globalLog$1(engine, log);
26558
+ }
26559
+
26541
26560
  function notifySubscribers(params) {
26542
26561
  const { mutationStatus, tournamentId, directives, timeStamp } = params || {};
26543
26562
  const { topics } = getTopics();
@@ -40664,27 +40683,6 @@ function setState$4(records, deepCopyOption = true) {
40664
40683
  return setTournamentRecords(deepCopyOption ? makeDeepCopy(records) : records);
40665
40684
  }
40666
40685
 
40667
- function engineLogging({ result, methodName, elapsed, params, engine }) {
40668
- const devContext = getDevContext();
40669
- const log = { method: methodName };
40670
- const logError = result?.error && (devContext.errors === true || Array.isArray(devContext.errors) && devContext.errors.includes(methodName));
40671
- const specifiedMethodParams = Array.isArray(devContext.params) && devContext.params?.includes(methodName);
40672
- const logParams = devContext.params && !Array.isArray(devContext.params) || specifiedMethodParams;
40673
- const exclude = Array.isArray(devContext.exclude) && devContext.exclude.includes(methodName);
40674
- if (!exclude && ![void 0, false].includes(devContext.perf) && (isNaN(devContext.perf) || elapsed > devContext.perf))
40675
- log.elapsed = elapsed;
40676
- if (!exclude && (logError || logParams)) {
40677
- log.params = params;
40678
- }
40679
- if (!exclude && (logError || devContext.result && !Array.isArray(devContext.result) && (!Array.isArray(devContext.params) || specifiedMethodParams) || Array.isArray(devContext.result) && devContext.result?.includes(methodName))) {
40680
- log.result = result;
40681
- }
40682
- if (Object.keys(log).length > 1)
40683
- globalLog$1(engine, log);
40684
- if (result && devContext.makeDeepCopy)
40685
- result.deepCopyIterations = getDeepCopyIterations();
40686
- }
40687
-
40688
40686
  const competitionEngine = function() {
40689
40687
  const engine = {
40690
40688
  getState: (params) => getState$3({
@@ -40816,6 +40814,7 @@ const competitionEngine = function() {
40816
40814
  return { error: INVALID_VALUES };
40817
40815
  const tournamentRecords = getTournamentRecords();
40818
40816
  const activeTournamentId = getTournamentId();
40817
+ const start = Date.now();
40819
40818
  const snapshot = rollbackOnError && makeDeepCopy(tournamentRecords, false, true);
40820
40819
  let timeStamp;
40821
40820
  const results = [];
@@ -40825,10 +40824,8 @@ const competitionEngine = function() {
40825
40824
  const { method: methodName, params } = directive;
40826
40825
  if (!engine[methodName]) {
40827
40826
  const result3 = { error: METHOD_NOT_FOUND, methodName };
40828
- const devContext = getDevContext();
40829
- if (devContext.result && !Array.isArray(devContext.result) || Array.isArray(devContext.result) && devContext.result?.includes(methodName)) {
40830
- console.log("ce:", result3);
40831
- }
40827
+ const elapsed = Date.now() - start;
40828
+ engineLogging({ result: result3, methodName, elapsed, params, engine: "ce:" });
40832
40829
  return result3;
40833
40830
  }
40834
40831
  const result2 = executeFunction(
@@ -43879,11 +43876,14 @@ function randomUnseededSeparation({
43879
43876
  idCollections,
43880
43877
  participants
43881
43878
  });
43879
+ if (allGroups.error) {
43880
+ return decorateResult({ result: allGroups, stack });
43881
+ }
43882
43882
  const participantIdGroups = Object.assign(
43883
43883
  {},
43884
43884
  ...unseededParticipantIds.map((participantId) => {
43885
43885
  const groups = Object.keys(allGroups).filter(
43886
- (key) => allGroups[key].includes(participantId)
43886
+ (key) => (allGroups[key] ?? []).includes(participantId)
43887
43887
  );
43888
43888
  return { [participantId]: groups };
43889
43889
  })
@@ -44081,7 +44081,7 @@ function positionUnseededParticipants({
44081
44081
  drawDefinition,
44082
44082
  event
44083
44083
  });
44084
- let avoidance = (appliedPolicies ?? {})[POLICY_TYPE_AVOIDANCE];
44084
+ let avoidance = appliedPolicies?.[POLICY_TYPE_AVOIDANCE];
44085
44085
  if (structure.stage === PLAY_OFF) {
44086
44086
  const groupings = entries.reduce((groupings2, entry) => {
44087
44087
  if (!groupings2[entry.groupingValue])
@@ -49476,8 +49476,8 @@ const matchUpGovernor = {
49476
49476
  };
49477
49477
 
49478
49478
  function attachPolicies({
49479
- drawDefinition,
49480
- policyDefinitions
49479
+ policyDefinitions,
49480
+ drawDefinition
49481
49481
  }) {
49482
49482
  if (!drawDefinition) {
49483
49483
  return { error: MISSING_DRAW_DEFINITION };
@@ -56513,11 +56513,12 @@ function replaceTieMatchUpParticipantId(params) {
56513
56513
  }
56514
56514
  if (substitution || side.substitutions?.length === 1) {
56515
56515
  if (substitution) {
56516
- const processCodes = tieMatchUp?.processCodes ?? [];
56517
- if (substitutionProcessCodes)
56518
- processCodes.push(...substitutionProcessCodes);
56519
- if (tieMatchUp)
56520
- tieMatchUp.processCodes = processCodes;
56516
+ if (substitutionProcessCodes && tieMatchUp) {
56517
+ tieMatchUp.processCodes = unique([
56518
+ ...tieMatchUp?.processCodes ?? [],
56519
+ ...substitutionProcessCodes
56520
+ ]);
56521
+ }
56521
56522
  } else {
56522
56523
  for (const substitutionProcessCode of substitutionProcessCodes || []) {
56523
56524
  const codeIndex = tieMatchUp?.processCodes?.lastIndexOf(
@@ -59925,13 +59926,15 @@ function generateDrawDefinition(params) {
59925
59926
  if (params.seedingProfile) {
59926
59927
  if (!policyDefinitions[POLICY_TYPE_SEEDING]) {
59927
59928
  policyDefinitions[POLICY_TYPE_SEEDING] = {
59928
- ...POLICY_SEEDING_USTA[POLICY_TYPE_SEEDING]
59929
+ ...POLICY_SEEDING_DEFAULT[POLICY_TYPE_SEEDING]
59929
59930
  };
59930
59931
  }
59931
59932
  policyDefinitions[POLICY_TYPE_SEEDING].seedingProfile = seedingProfile;
59932
59933
  }
59933
59934
  const { participants, participantMap } = getParticipants$1({
59934
59935
  withIndividualParticipants: true,
59936
+ convertExtensions: true,
59937
+ internalUse: true,
59935
59938
  tournamentRecord
59936
59939
  });
59937
59940
  const enforceGender = params.enforceGender ?? policyDefinitions?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender ?? appliedPolicies?.[POLICY_TYPE_MATCHUP_ACTIONS]?.participants?.enforceGender;
@@ -60042,6 +60045,10 @@ function generateDrawDefinition(params) {
60042
60045
  drawDefinition.matchUpType = matchUpType;
60043
60046
  }
60044
60047
  }
60048
+ const policiesToAttach = {
60049
+ [POLICY_TYPE_AVOIDANCE]: appliedPolicies[POLICY_TYPE_AVOIDANCE],
60050
+ ...POLICY_SEEDING_DEFAULT
60051
+ };
60045
60052
  if (policyDefinitions) {
60046
60053
  if (typeof policyDefinitions !== "object") {
60047
60054
  return decorateResult({
@@ -60050,7 +60057,6 @@ function generateDrawDefinition(params) {
60050
60057
  stack
60051
60058
  });
60052
60059
  } else {
60053
- const policiesToAttach = {};
60054
60060
  for (const key of Object.keys(policyDefinitions)) {
60055
60061
  if (JSON.stringify(appliedPolicies?.[key]) !== JSON.stringify(policyDefinitions[key])) {
60056
60062
  policiesToAttach[key] = policyDefinitions[key];
@@ -60061,10 +60067,11 @@ function generateDrawDefinition(params) {
60061
60067
  Object.assign(appliedPolicies, policiesToAttach);
60062
60068
  }
60063
60069
  }
60070
+ } else if (policiesToAttach.avoidance) {
60071
+ attachPolicies({ drawDefinition, policyDefinitions: policiesToAttach });
60064
60072
  }
60065
60073
  if (!appliedPolicies[POLICY_TYPE_SEEDING] && !policyDefinitions[POLICY_TYPE_SEEDING]) {
60066
- attachPolicies({ drawDefinition, policyDefinitions: POLICY_SEEDING_USTA });
60067
- Object.assign(appliedPolicies, POLICY_SEEDING_USTA);
60074
+ Object.assign(appliedPolicies, POLICY_SEEDING_DEFAULT);
60068
60075
  }
60069
60076
  let structureId = existingDrawDefinition?.structures?.find(
60070
60077
  (structure) => structure.stage === MAIN && structure.stageSequence === 1
@@ -61671,6 +61678,7 @@ const tournamentEngine = (() => {
61671
61678
  function executionQueue(directives, rollbackOnError) {
61672
61679
  if (!Array.isArray(directives))
61673
61680
  return { error: INVALID_VALUES };
61681
+ const start = Date.now();
61674
61682
  const tournamentId = getTournamentId();
61675
61683
  const tournamentRecord = getTournamentRecord(tournamentId);
61676
61684
  const snapshot = rollbackOnError && makeDeepCopy(tournamentRecord, false, true);
@@ -61681,10 +61689,8 @@ const tournamentEngine = (() => {
61681
61689
  const { method: methodName, params } = directive;
61682
61690
  if (!engine[methodName]) {
61683
61691
  const result3 = { error: METHOD_NOT_FOUND, methodName };
61684
- const devContext = getDevContext();
61685
- if (devContext.result && !Array.isArray(devContext.result) || Array.isArray(devContext.result) && devContext.result?.includes(methodName)) {
61686
- console.log("te:", result3);
61687
- }
61692
+ const elapsed = Date.now() - start;
61693
+ engineLogging({ result: result3, methodName, elapsed, params, engine: "te:" });
61688
61694
  return result3;
61689
61695
  }
61690
61696
  const result2 = executeFunction(