@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.d.cts CHANGED
@@ -63,8 +63,8 @@ interface BaselineVersion {
63
63
  }
64
64
  /** Backend baseline point accepted at the package boundary. */
65
65
  interface BaselinePoint {
66
- start_date: string;
67
- end_date: string;
66
+ start_date: string | null;
67
+ end_date: string | null;
68
68
  /** Baseline duration in working days. */
69
69
  duration: number;
70
70
  cost: number | string;
package/dist/index.d.ts CHANGED
@@ -63,8 +63,8 @@ interface BaselineVersion {
63
63
  }
64
64
  /** Backend baseline point accepted at the package boundary. */
65
65
  interface BaselinePoint {
66
- start_date: string;
67
- end_date: string;
66
+ start_date: string | null;
67
+ end_date: string | null;
68
68
  /** Baseline duration in working days. */
69
69
  duration: number;
70
70
  cost: number | string;
package/dist/index.js CHANGED
@@ -15355,7 +15355,7 @@ function parseFiniteNonNegative(value) {
15355
15355
  if (!Number.isFinite(numeric) || numeric < 0) return null;
15356
15356
  return numeric;
15357
15357
  }
15358
- function normalizeBaselinePoint(point, reporter, diagnostic) {
15358
+ function normalizeBaselinePoint(point, reporter, diagnostic, isMilestone = false) {
15359
15359
  const durationDays = parseFiniteNonNegative(point.duration);
15360
15360
  const cost = parseFiniteNonNegative(point.cost);
15361
15361
  const workHours = parseFiniteNonNegative(point.hh_work);
@@ -15371,9 +15371,17 @@ function normalizeBaselinePoint(point, reporter, diagnostic) {
15371
15371
  );
15372
15372
  return null;
15373
15373
  }
15374
+ const startDate = parseBaselineDate(point.start_date);
15375
+ const parsedEndDate = parseBaselineDate(point.end_date);
15376
+ const hasInvertedLegacyMilestone = isMilestone && durationDays === 0 && startDate !== null && parsedEndDate !== null && parsedEndDate < startDate;
15377
+ if (hasInvertedLegacyMilestone) {
15378
+ reporter.warn(
15379
+ "[baseline] normalizing inverted zero-duration milestone to one instant"
15380
+ );
15381
+ }
15374
15382
  return {
15375
- startDate: parseBaselineDate(point.start_date),
15376
- endDate: parseBaselineDate(point.end_date),
15383
+ startDate,
15384
+ endDate: hasInvertedLegacyMilestone ? startDate : parsedEndDate,
15377
15385
  durationDays,
15378
15386
  cost,
15379
15387
  workHours,
@@ -15417,14 +15425,20 @@ function applyBaselinePoints(adapter, points, reporter, recordDiagnostic = noopL
15417
15425
  }
15418
15426
  const changed = [];
15419
15427
  for (const [coreId, group] of grouped) {
15428
+ const isMilestone = adapter.getActivity(coreId)?.type === ACTIVITY_TYPE.MILESTONE;
15420
15429
  adapter.setActivityField(
15421
15430
  coreId,
15422
15431
  "baselinePoints",
15423
15432
  group.map(
15424
- (point) => normalizeBaselinePoint(point, reporter, {
15425
- record: recordDiagnostic,
15426
- sampleId: coreId
15427
- })
15433
+ (point) => normalizeBaselinePoint(
15434
+ point,
15435
+ reporter,
15436
+ {
15437
+ record: recordDiagnostic,
15438
+ sampleId: coreId
15439
+ },
15440
+ isMilestone
15441
+ )
15428
15442
  ).filter((point) => point !== null)
15429
15443
  );
15430
15444
  changed.push(coreId);
@@ -20909,13 +20923,18 @@ function parseCriticality(raw, reporter) {
20909
20923
  );
20910
20924
  return false;
20911
20925
  }
20912
- function parseBaselinePoints(raw, reporter, recordDiagnostic, activityId) {
20926
+ function parseBaselinePoints(raw, reporter, recordDiagnostic, activityId, isMilestone) {
20913
20927
  if (!Array.isArray(raw)) return [];
20914
20928
  return raw.map(
20915
- (point) => normalizeBaselinePoint(point, reporter, {
20916
- record: recordDiagnostic,
20917
- sampleId: activityId
20918
- })
20929
+ (point) => normalizeBaselinePoint(
20930
+ point,
20931
+ reporter,
20932
+ {
20933
+ record: recordDiagnostic,
20934
+ sampleId: activityId
20935
+ },
20936
+ isMilestone
20937
+ )
20919
20938
  ).filter((point) => point !== null);
20920
20939
  }
20921
20940
  function parseActivity(raw, context) {
@@ -20976,7 +20995,8 @@ function parseActivity(raw, context) {
20976
20995
  raw.baseline_points,
20977
20996
  context.reporter,
20978
20997
  context.recordDiagnostic,
20979
- String(raw.unique_id)
20998
+ String(raw.unique_id),
20999
+ isMilestone
20980
21000
  ),
20981
21001
  baselineSnapshot: null,
20982
21002
  recursiveDurationHours: durationToHours(