@outbuild-company/schedule-core 1.13.3 → 1.13.4

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