@sunsteel/contracts 0.63.0 → 0.64.0

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.cjs CHANGED
@@ -150,9 +150,12 @@ __export(index_exports, {
150
150
  accountExportFileName: () => accountExportFileName,
151
151
  isWithinQuietHours: () => isWithinQuietHours,
152
152
  matchesDeletionConfirmation: () => matchesDeletionConfirmation,
153
+ resolveActiveTrainingBlock: () => resolveActiveTrainingBlock,
154
+ resolveRoutinePlan: () => resolveRoutinePlan,
153
155
  routineDayLabel: () => routineDayLabel,
154
156
  sessionCorrectionWindow: () => sessionCorrectionWindow,
155
- setLogValuesDiffer: () => setLogValuesDiffer
157
+ setLogValuesDiffer: () => setLogValuesDiffer,
158
+ trainingBlockCovers: () => trainingBlockCovers
156
159
  });
157
160
  module.exports = __toCommonJS(index_exports);
158
161
 
@@ -521,6 +524,40 @@ var ROUTINE_TRAINING_BLOCK_SOURCE_KINDS = [
521
524
  "CURRENT_ROUTINE",
522
525
  "SAVED_VERSION"
523
526
  ];
527
+ function trainingBlockCovers(block, date) {
528
+ return block.startDate <= date && date <= block.endDate;
529
+ }
530
+ function resolveActiveTrainingBlock(blocks, date) {
531
+ return blocks?.find((block) => trainingBlockCovers(block, date)) ?? null;
532
+ }
533
+ function resolveRoutinePlan(routine, date) {
534
+ const block = resolveActiveTrainingBlock(routine.trainingBlocks, date);
535
+ if (block) {
536
+ return {
537
+ block: {
538
+ id: block.id,
539
+ seriesId: block.seriesId,
540
+ revision: block.revision,
541
+ name: block.name,
542
+ startDate: block.startDate,
543
+ endDate: block.endDate
544
+ },
545
+ scheduleMode: block.scheduleMode,
546
+ restDays: block.restDays,
547
+ rotationWeekdays: block.rotationWeekdays,
548
+ nextRotationDayId: block.nextRotationDayId,
549
+ days: block.days
550
+ };
551
+ }
552
+ return {
553
+ block: null,
554
+ scheduleMode: routine.scheduleMode,
555
+ restDays: routine.restDays,
556
+ rotationWeekdays: routine.rotationWeekdays ?? [],
557
+ nextRotationDayId: routine.nextRotationDayId ?? null,
558
+ days: routine.days
559
+ };
560
+ }
524
561
 
525
562
  // src/routine-sharing.ts
526
563
  var ROUTINE_VISIBILITY_VALUES = [
@@ -867,7 +904,10 @@ function accountExportFileName(username, exportedAt) {
867
904
  accountExportFileName,
868
905
  isWithinQuietHours,
869
906
  matchesDeletionConfirmation,
907
+ resolveActiveTrainingBlock,
908
+ resolveRoutinePlan,
870
909
  routineDayLabel,
871
910
  sessionCorrectionWindow,
872
- setLogValuesDiffer
911
+ setLogValuesDiffer,
912
+ trainingBlockCovers
873
913
  });