@outbuild-company/schedule-core 1.13.0 → 1.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3587,33 +3587,53 @@ function parseLinkTypeCode(raw) {
3587
3587
  return void 0;
3588
3588
  }
3589
3589
  var LINK_ENTRY_SEPARATOR = ";";
3590
- var ENTRY_RE = /^(\d+)(fs|ss|ff|sf)?(?:([+-]?)(\d+(?:\.\d+)?)d?)?$/i;
3590
+ var LAG_UNIT = {
3591
+ DAY: "d",
3592
+ WEEK: "w",
3593
+ WEEK_DHTMLX: "wk",
3594
+ MONTH: "m",
3595
+ MONTH_DHTMLX: "mon",
3596
+ YEAR: "y"
3597
+ };
3598
+ var ENTRY_RE = /^(\d+)(fs|ss|ff|sf)?(?:([+-]?)(\d+(?:\.\d+)?)(wk|w|mon|m|d|y)?)?$/i;
3591
3599
 
3592
3600
  // src/autoscheduler/links/parse-predecessor-string.ts
3593
- function parsePredecessorString(input) {
3601
+ var DEFAULT_WORKING_DAYS_PER_WEEK = 5;
3602
+ var DAYS_PER_MONTH = 30;
3603
+ var DAYS_PER_YEAR = 365;
3604
+ var FIXED_UNIT_DAYS = {
3605
+ [LAG_UNIT.DAY]: 1,
3606
+ [LAG_UNIT.MONTH]: DAYS_PER_MONTH,
3607
+ [LAG_UNIT.MONTH_DHTMLX]: DAYS_PER_MONTH,
3608
+ [LAG_UNIT.YEAR]: DAYS_PER_YEAR
3609
+ };
3610
+ function parsePredecessorString(input, options = {}) {
3594
3611
  const specs = [];
3595
3612
  const errors = [];
3613
+ const daysPerWeek = options.daysPerWeek !== void 0 && Number.isFinite(options.daysPerWeek) && options.daysPerWeek > 0 ? options.daysPerWeek : DEFAULT_WORKING_DAYS_PER_WEEK;
3596
3614
  const trimmed = input.replace(/\s+/g, "");
3597
3615
  if (trimmed.length === 0) return { specs, errors };
3598
3616
  for (const raw of trimmed.split(LINK_ENTRY_SEPARATOR)) {
3599
3617
  if (raw.length === 0) continue;
3600
- const spec = parseEntry(raw);
3618
+ const spec = parseEntry(raw, daysPerWeek);
3601
3619
  if (spec) specs.push(spec);
3602
3620
  else errors.push(raw);
3603
3621
  }
3604
3622
  return { specs, errors };
3605
3623
  }
3606
- function parseEntry(entry) {
3624
+ function parseEntry(entry, daysPerWeek) {
3607
3625
  const lower = entry.toLowerCase();
3608
3626
  const match = ENTRY_RE.exec(lower);
3609
3627
  if (!match) return null;
3610
- const [, correlativeId, typeStr, sign, magnitude] = match;
3628
+ const [, correlativeId, typeStr, sign, magnitude, unit] = match;
3611
3629
  const type = typeStr ? LINK_CODE_TO_TYPE[typeStr] : LINK_CODE_TO_TYPE[DEFAULT_LINK_CODE];
3612
3630
  let lag = 0;
3613
3631
  if (magnitude !== void 0) {
3614
3632
  const value = Number(magnitude);
3615
3633
  if (Number.isNaN(value)) return null;
3616
- lag = sign === "-" ? -value : value;
3634
+ const unitDays = unit === LAG_UNIT.WEEK || unit === LAG_UNIT.WEEK_DHTMLX ? daysPerWeek : FIXED_UNIT_DAYS[unit ?? LAG_UNIT.DAY];
3635
+ const days = value * unitDays;
3636
+ lag = sign === "-" ? -days : days;
3617
3637
  }
3618
3638
  return {
3619
3639
  correlativeId,
@@ -4513,8 +4533,19 @@ var POST_PROCESSOR = {
4513
4533
  var VALIDATION_REASON = {
4514
4534
  NEGATIVE_DURATION: "negative_duration"};
4515
4535
  var EDIT_DENIAL_REASON = {
4536
+ COMPLETED: "completed",
4516
4537
  SUMMARY: "summary",
4517
- HAS_LOOKAHEAD_TASKS: "has_lookahead_tasks"};
4538
+ HAS_PROGRESS: "has_progress",
4539
+ HAS_LOOKAHEAD_TASKS: "has_lookahead_tasks",
4540
+ SIR_START_AFTER_PROGRESS: "sir_start_after_progress"
4541
+ };
4542
+ var EDIT_ALERT_KEY = {
4543
+ CANT_EDIT_COMPLETED: "cant_edit_completed_activity",
4544
+ SUMMARY_COLUMN_VALUE: "summary_column_value",
4545
+ CANT_EDIT_WITH_PROGRESS: "cant_edit_activity_with_progress",
4546
+ SIR_CANT_MOVE_START_AFTER_PROGRESS: "sir_cant_move_start_after_progress",
4547
+ CANT_EDIT_WITH_TASK: "cant_edit_actvity_with_task"
4548
+ };
4518
4549
 
4519
4550
  // src/columns/shared/constraint-validation.ts
4520
4551
  function checkConstraintViolation2(constraintType, constraintDate, projectedDate) {
@@ -4637,10 +4668,10 @@ var MAX_PROGRESS = PROGRESS_COMPLETE;
4637
4668
  var progressPipeline = {
4638
4669
  targetField: "progress",
4639
4670
  canEdit(activity, hierarchy) {
4640
- if (hasLookaheadTasks(activity))
4641
- return cannotEdit("has_lookahead_tasks", "cant_edit_actvity_with_task");
4642
4671
  if (isSummaryActivity2(activity, hierarchy))
4643
4672
  return cannotEdit("summary", "summary_column_value");
4673
+ if (hasLookaheadTasks(activity))
4674
+ return cannotEdit("has_lookahead_tasks", "cant_edit_actvity_with_task");
4644
4675
  return canEdit();
4645
4676
  },
4646
4677
  parseInput(rawValue) {
@@ -11873,7 +11904,13 @@ async function dispatchInlineEditLinks(action, options, deps) {
11873
11904
  return { ok: false, reason: REJECTION_REASON.ACTIVITY_NOT_FOUND };
11874
11905
  }
11875
11906
  const isPredecessors = action.column === COLUMN.CUSTOM_PREDECESSORS;
11876
- const { specs: specsInDays } = parsePredecessorString(action.newValue);
11907
+ const { specs: specsInDays, errors } = parsePredecessorString(
11908
+ action.newValue,
11909
+ { daysPerWeek: sector.hoursPerWeek / sector.hoursPerDay }
11910
+ );
11911
+ if (errors.length > 0) {
11912
+ return { ok: false, reason: REJECTION_REASON.INVALID_VALUE };
11913
+ }
11877
11914
  const specs = specsInDays.map((spec) => ({
11878
11915
  ...spec,
11879
11916
  lag: lagDaysToHours(roundLagDays(spec.lag), sector.hoursPerDay)
@@ -22765,6 +22802,17 @@ var ScheduleCore = class _ScheduleCore {
22765
22802
  this.assertReady();
22766
22803
  return readActivity(this.coreRuntime.state, id);
22767
22804
  }
22805
+ /** Returns the canonical progress editability decision without mutation. */
22806
+ getProgressEditability(id) {
22807
+ this.assertReady();
22808
+ const activity = readActivity(this.coreRuntime.state, id);
22809
+ if (!activity) return null;
22810
+ const context = buildPipelineContext(this.coreRuntime.state, {
22811
+ hoursPerDay: this.coreRuntime.sector.hoursPerDay,
22812
+ dateFormat: this.coreRuntime.sector.dateFormat
22813
+ });
22814
+ return progressPipeline.canEdit(activity, context.hierarchy);
22815
+ }
22768
22816
  /**
22769
22817
  * Creates a read-only date prediction bound to the current revision.
22770
22818
  *
@@ -23759,6 +23807,8 @@ exports.DISPATCH_ACTION_KIND = DISPATCH_ACTION_KIND;
23759
23807
  exports.DISPATCH_ACTION_KINDS = DISPATCH_ACTION_KINDS;
23760
23808
  exports.DISPATCH_LINK_OPERATION_KIND = DISPATCH_LINK_OPERATION_KIND;
23761
23809
  exports.DISPATCH_TRACK_EVENT = DISPATCH_TRACK_EVENT;
23810
+ exports.EDIT_ALERT_KEY = EDIT_ALERT_KEY;
23811
+ exports.EDIT_DENIAL_REASON = EDIT_DENIAL_REASON;
23762
23812
  exports.ENTITY_CHANGE_KIND = ENTITY_CHANGE_KIND;
23763
23813
  exports.FILTER_FIELD = FILTER_FIELD;
23764
23814
  exports.FILTER_LOGIC = FILTER_LOGIC;