@outbuild-company/schedule-core 1.13.3 → 1.13.5

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
@@ -14867,6 +14867,7 @@ async function dispatchActivitySetProgress(action, options, deps) {
14867
14867
  changes.postProcessors ?? [],
14868
14868
  adapter
14869
14869
  );
14870
+ const autoscheduleFrom = changes.needsAutoSchedule ? ctx.hierarchy.hasChildren(action.activityId) ? AUTOSCHEDULE_SCOPE.ROOTS : action.activityId : null;
14870
14871
  const { scheduledIds } = await runPostMutation(
14871
14872
  {
14872
14873
  adapter,
@@ -14876,7 +14877,7 @@ async function dispatchActivitySetProgress(action, options, deps) {
14876
14877
  },
14877
14878
  {
14878
14879
  action,
14879
- autoscheduleFrom: changes.needsAutoSchedule ? action.activityId : null,
14880
+ autoscheduleFrom,
14880
14881
  recomputeParentsFrom: [],
14881
14882
  collectDirty: (sids) => collectDirtyForInlineEdit(action.activityId, touchedIds, sids),
14882
14883
  now: deps.now,
@@ -15357,7 +15358,7 @@ function parseFiniteNonNegative(value) {
15357
15358
  if (!Number.isFinite(numeric) || numeric < 0) return null;
15358
15359
  return numeric;
15359
15360
  }
15360
- function normalizeBaselinePoint(point, reporter, diagnostic) {
15361
+ function normalizeBaselinePoint(point, reporter, diagnostic, isMilestone = false) {
15361
15362
  const durationDays = parseFiniteNonNegative(point.duration);
15362
15363
  const cost = parseFiniteNonNegative(point.cost);
15363
15364
  const workHours = parseFiniteNonNegative(point.hh_work);
@@ -15373,9 +15374,17 @@ function normalizeBaselinePoint(point, reporter, diagnostic) {
15373
15374
  );
15374
15375
  return null;
15375
15376
  }
15377
+ const startDate = parseBaselineDate(point.start_date);
15378
+ const parsedEndDate = parseBaselineDate(point.end_date);
15379
+ const hasInvertedLegacyMilestone = isMilestone && durationDays === 0 && startDate !== null && parsedEndDate !== null && parsedEndDate < startDate;
15380
+ if (hasInvertedLegacyMilestone) {
15381
+ reporter.warn(
15382
+ "[baseline] normalizing inverted zero-duration milestone to one instant"
15383
+ );
15384
+ }
15376
15385
  return {
15377
- startDate: parseBaselineDate(point.start_date),
15378
- endDate: parseBaselineDate(point.end_date),
15386
+ startDate,
15387
+ endDate: hasInvertedLegacyMilestone ? startDate : parsedEndDate,
15379
15388
  durationDays,
15380
15389
  cost,
15381
15390
  workHours,
@@ -15419,14 +15428,20 @@ function applyBaselinePoints(adapter, points, reporter, recordDiagnostic = noopL
15419
15428
  }
15420
15429
  const changed = [];
15421
15430
  for (const [coreId, group] of grouped) {
15431
+ const isMilestone = adapter.getActivity(coreId)?.type === ACTIVITY_TYPE.MILESTONE;
15422
15432
  adapter.setActivityField(
15423
15433
  coreId,
15424
15434
  "baselinePoints",
15425
15435
  group.map(
15426
- (point) => normalizeBaselinePoint(point, reporter, {
15427
- record: recordDiagnostic,
15428
- sampleId: coreId
15429
- })
15436
+ (point) => normalizeBaselinePoint(
15437
+ point,
15438
+ reporter,
15439
+ {
15440
+ record: recordDiagnostic,
15441
+ sampleId: coreId
15442
+ },
15443
+ isMilestone
15444
+ )
15430
15445
  ).filter((point) => point !== null)
15431
15446
  );
15432
15447
  changed.push(coreId);
@@ -20911,13 +20926,18 @@ function parseCriticality(raw, reporter) {
20911
20926
  );
20912
20927
  return false;
20913
20928
  }
20914
- function parseBaselinePoints(raw, reporter, recordDiagnostic, activityId) {
20929
+ function parseBaselinePoints(raw, reporter, recordDiagnostic, activityId, isMilestone) {
20915
20930
  if (!Array.isArray(raw)) return [];
20916
20931
  return raw.map(
20917
- (point) => normalizeBaselinePoint(point, reporter, {
20918
- record: recordDiagnostic,
20919
- sampleId: activityId
20920
- })
20932
+ (point) => normalizeBaselinePoint(
20933
+ point,
20934
+ reporter,
20935
+ {
20936
+ record: recordDiagnostic,
20937
+ sampleId: activityId
20938
+ },
20939
+ isMilestone
20940
+ )
20921
20941
  ).filter((point) => point !== null);
20922
20942
  }
20923
20943
  function parseActivity(raw, context) {
@@ -20978,7 +20998,8 @@ function parseActivity(raw, context) {
20978
20998
  raw.baseline_points,
20979
20999
  context.reporter,
20980
21000
  context.recordDiagnostic,
20981
- String(raw.unique_id)
21001
+ String(raw.unique_id),
21002
+ isMilestone
20982
21003
  ),
20983
21004
  baselineSnapshot: null,
20984
21005
  recursiveDurationHours: durationToHours(