@letpeoplework/lighthouse-client 1.6.0 → 1.8.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
@@ -32,6 +32,7 @@ __export(index_exports, {
32
32
  pollCliAuthSession: () => pollCliAuthSession,
33
33
  queryServerAuthMode: () => queryServerAuthMode,
34
34
  startCliAuthSession: () => startCliAuthSession,
35
+ summariseDeliveryMetricsHistory: () => summariseDeliveryMetricsHistory,
35
36
  validateLighthouseConnectivity: () => validateLighthouseConnectivity
36
37
  });
37
38
  module.exports = __toCommonJS(index_exports);
@@ -531,6 +532,15 @@ var getDefaultMetricsDateRange = () => {
531
532
  endDate: toIsoDate(end)
532
533
  };
533
534
  };
535
+ var summariseDeliveryMetricsHistory = (history) => history.points.map((point) => ({
536
+ date: point.date,
537
+ totalWork: point.totalWork,
538
+ doneWork: point.doneWork,
539
+ remainingWork: point.remainingWork,
540
+ epicCount: point.featureBreakdown.length,
541
+ estimatedItemCount: point.estimatedItemCount,
542
+ likelihoodPercentage: point.likelihoodPercentage
543
+ }));
534
544
  var getAuthHeaders = (auth) => {
535
545
  if (auth === void 0 || auth.kind === "none") {
536
546
  return {};
@@ -734,6 +744,12 @@ var getMetricsAsOfDateQuery = (asOfDate) => `asOfDate=${encodeURIComponent(asOfD
734
744
  var getItemIdsQuerySuffix = (itemIds) => itemIds && itemIds.length > 0 ? itemIds.map((id) => `&itemIds=${encodeURIComponent(id)}`).join("") : "";
735
745
  var getViewQuerySuffix = (view) => view === "filtered" ? "&view=filtered" : "";
736
746
  var getDefinitionIdQuerySuffix = (definitionId) => definitionId !== void 0 ? `&definitionId=${encodeURIComponent(definitionId)}` : "";
747
+ var getPercentilesOverTimeQuerySuffix = (metricType, horizon) => {
748
+ const metricTypePart = metricType === void 0 ? "" : `&metricType=${encodeURIComponent(metricType)}`;
749
+ const horizonPart = horizon === void 0 ? "" : `&horizon=${encodeURIComponent(horizon)}`;
750
+ return `${metricTypePart}${horizonPart}`;
751
+ };
752
+ var getProcessBehaviorTypeQuerySuffix = (metricType) => metricType === void 0 ? "" : `&type=${encodeURIComponent(metricType)}`;
737
753
  var addUtcDays = (dateStr, days) => {
738
754
  const d = /* @__PURE__ */ new Date(`${dateStr}T00:00:00Z`);
739
755
  d.setUTCDate(d.getUTCDate() + days);
@@ -788,7 +804,12 @@ var FEATURE_REQUIRES_SERVER_NEWER_THAN = {
788
804
  recurringBlackoutRules: "v26.5.29.5",
789
805
  workItemAgePercentiles: "v26.6.7.1",
790
806
  mcpOAuthPassThrough: "v26.6.16.14",
791
- blockedCountHistory: "v26.7.3.1"
807
+ blockedCountHistory: "v26.7.3.1",
808
+ percentilesOverTime: "v26.7.11.4",
809
+ processBehaviorOverTime: "v26.7.11.4",
810
+ // The endpoint landed in v26.6.7.1. The per-epic size fields came much later and are optional on
811
+ // the wire, so a server between the two answers fine — it just reports no sizes.
812
+ deliveryMetricsHistory: "v26.5.29.5"
792
813
  };
793
814
  var parseServerVersion = (raw) => {
794
815
  const trimmed = raw.trim().replace(/^v/iu, "");
@@ -1258,6 +1279,58 @@ var createLighthouseClient = (configuration, dependencies = {}) => {
1258
1279
  { method: "GET" }
1259
1280
  );
1260
1281
  },
1282
+ getTeamPercentilesOverTime: async (teamId, range, metricType, horizon) => {
1283
+ const unsupported = await ensureServerSupports("percentilesOverTime");
1284
+ if (unsupported) {
1285
+ return unsupported;
1286
+ }
1287
+ const r = getResolvedMetricsDateRange(range);
1288
+ return requestJson(
1289
+ configuration,
1290
+ dependencies,
1291
+ `/v1/teams/${teamId}/metrics/percentiles-over-time?${getMetricsDateRangeQuery(r)}${getPercentilesOverTimeQuerySuffix(metricType, horizon)}`,
1292
+ { method: "GET" }
1293
+ );
1294
+ },
1295
+ getPortfolioPercentilesOverTime: async (portfolioId, range, metricType, horizon) => {
1296
+ const unsupported = await ensureServerSupports("percentilesOverTime");
1297
+ if (unsupported) {
1298
+ return unsupported;
1299
+ }
1300
+ const r = getResolvedMetricsDateRange(range);
1301
+ return requestJson(
1302
+ configuration,
1303
+ dependencies,
1304
+ `/v1/portfolios/${portfolioId}/metrics/percentiles-over-time?${getMetricsDateRangeQuery(r)}${getPercentilesOverTimeQuerySuffix(metricType, horizon)}`,
1305
+ { method: "GET" }
1306
+ );
1307
+ },
1308
+ getTeamProcessBehaviorOverTime: async (teamId, range, metricType) => {
1309
+ const unsupported = await ensureServerSupports("processBehaviorOverTime");
1310
+ if (unsupported) {
1311
+ return unsupported;
1312
+ }
1313
+ const r = getResolvedMetricsDateRange(range);
1314
+ return requestJson(
1315
+ configuration,
1316
+ dependencies,
1317
+ `/v1/teams/${teamId}/metrics/process-behavior-over-time?${getMetricsDateRangeQuery(r)}${getProcessBehaviorTypeQuerySuffix(metricType)}`,
1318
+ { method: "GET" }
1319
+ );
1320
+ },
1321
+ getPortfolioProcessBehaviorOverTime: async (portfolioId, range, metricType) => {
1322
+ const unsupported = await ensureServerSupports("processBehaviorOverTime");
1323
+ if (unsupported) {
1324
+ return unsupported;
1325
+ }
1326
+ const r = getResolvedMetricsDateRange(range);
1327
+ return requestJson(
1328
+ configuration,
1329
+ dependencies,
1330
+ `/v1/portfolios/${portfolioId}/metrics/process-behavior-over-time?${getMetricsDateRangeQuery(r)}${getProcessBehaviorTypeQuerySuffix(metricType)}`,
1331
+ { method: "GET" }
1332
+ );
1333
+ },
1261
1334
  getTeamCumulativeStateTime: async (teamId, range, itemIds) => {
1262
1335
  const unsupported = await ensureServerSupports("cumulativeStateTime");
1263
1336
  if (unsupported) {
@@ -1384,6 +1457,18 @@ var createLighthouseClient = (configuration, dependencies = {}) => {
1384
1457
  `/v1/deliveries/${deliveryId}`,
1385
1458
  { method: "DELETE" }
1386
1459
  ),
1460
+ getDeliveryMetricsHistory: async (deliveryId) => {
1461
+ const unsupported = await ensureServerSupports("deliveryMetricsHistory");
1462
+ if (unsupported) {
1463
+ return unsupported;
1464
+ }
1465
+ return requestJson(
1466
+ configuration,
1467
+ dependencies,
1468
+ `/v1/deliveries/${deliveryId}/metrics-history`,
1469
+ { method: "GET" }
1470
+ );
1471
+ },
1387
1472
  getRecurringBlackoutRules: async () => {
1388
1473
  const unsupported = await ensureServerSupports("recurringBlackoutRules");
1389
1474
  if (unsupported) {
@@ -1460,5 +1545,6 @@ var createLighthouseClient = (configuration, dependencies = {}) => {
1460
1545
  pollCliAuthSession,
1461
1546
  queryServerAuthMode,
1462
1547
  startCliAuthSession,
1548
+ summariseDeliveryMetricsHistory,
1463
1549
  validateLighthouseConnectivity
1464
1550
  });
package/dist/index.d.cts CHANGED
@@ -233,6 +233,125 @@ type BlockedCountSnapshot = {
233
233
  readonly recordedAt: string;
234
234
  readonly blockedCount: number;
235
235
  };
236
+ /**
237
+ * One epic as it stood on the day a delivery snapshot was taken.
238
+ *
239
+ * `likelihood` is null when the epic cannot be forecast (ADR-112). `totalItems` and
240
+ * `isUsingDefaultSize` are absent from every snapshot recorded before Lighthouse began writing
241
+ * sizes, so both are optional and a missing value means "not recorded", never zero.
242
+ */
243
+ type DeliveryFeatureMetric = {
244
+ readonly referenceId: string;
245
+ readonly name: string;
246
+ readonly completion: number;
247
+ readonly likelihood: number | null;
248
+ readonly totalItems?: number | null;
249
+ readonly isUsingDefaultSize?: boolean | null;
250
+ };
251
+ /** One point on a delivery's forecast distribution: the chance of finishing by a date. */
252
+ type DeliveryWhenDistributionPoint = {
253
+ readonly probability: number;
254
+ readonly expectedDate: string;
255
+ };
256
+ /** A delivery as it stood on one recorded day. Dates are ISO strings. */
257
+ type DeliveryMetricsHistoryPoint = {
258
+ readonly date: string;
259
+ readonly targetDateAtSnapshot: string | null;
260
+ readonly totalWork: number;
261
+ readonly doneWork: number;
262
+ readonly remainingWork: number;
263
+ readonly estimatedItemCount: number | null;
264
+ readonly forecastHowMany: number | null;
265
+ readonly likelihoodPercentage: number | null;
266
+ readonly whenDistribution: readonly DeliveryWhenDistributionPoint[] | null;
267
+ readonly featureBreakdown: readonly DeliveryFeatureMetric[];
268
+ };
269
+ /** The whole recorded trend for one delivery. Forward-only: it starts at the first snapshot. */
270
+ type DeliveryMetricsHistory = {
271
+ readonly deliveryDate: string;
272
+ readonly firstSnapshotDate: string | null;
273
+ readonly points: readonly DeliveryMetricsHistoryPoint[];
274
+ };
275
+ /**
276
+ * One day of a delivery, without the per-epic breakdown or the forecast distribution.
277
+ *
278
+ * A ninety-day window over fifteen epics is well over a thousand breakdown objects plus a
279
+ * distribution per day — more than an assistant should be handed by default (ADR-121), and more
280
+ * than a terminal can show. {@link summariseDeliveryMetricsHistory} projects to this.
281
+ */
282
+ type DeliveryMetricsHistorySummaryRow = {
283
+ readonly date: string;
284
+ readonly totalWork: number;
285
+ readonly doneWork: number;
286
+ readonly remainingWork: number;
287
+ readonly epicCount: number;
288
+ readonly estimatedItemCount: number | null;
289
+ readonly likelihoodPercentage: number | null;
290
+ };
291
+ /**
292
+ * Projects a delivery history to one row per recorded day. Pure.
293
+ *
294
+ * The client itself returns the payload whole: dropping data is the caller's choice, so the CLI and
295
+ * the MCP tool apply this by default and step around it when asked for per-epic detail.
296
+ */
297
+ declare const summariseDeliveryMetricsHistory: (history: DeliveryMetricsHistory) => readonly DeliveryMetricsHistorySummaryRow[];
298
+ /**
299
+ * Percentile family recorded by the percentiles-over-time pipeline. Sent as the
300
+ * `metricType` query parameter, and echoed back on every returned row.
301
+ */
302
+ type PercentilesOverTimeMetricType = "CycleTime" | "WorkItemAge";
303
+ /**
304
+ * One captured day on the percentiles-over-time trend: the percentile quartet
305
+ * recorded for {@link recordedAt} (an ISO date string, one row per calendar day,
306
+ * ascending).
307
+ *
308
+ * Recording is FORWARD-ONLY — Lighthouse starts capturing the day the feature is
309
+ * first deployed and never backfills history it did not observe, so a freshly
310
+ * upgraded server legitimately returns an empty array until the first refresh.
311
+ *
312
+ * `CycleTime` is recorded per horizon (30/60/90 days); `WorkItemAge` is always
313
+ * "as of today" and therefore has no horizon dimension, so a horizon sent
314
+ * alongside it is ignored in favour of the horizon-less series.
315
+ *
316
+ * SHARP EDGE: a `CycleTime` request that omits `horizon` is not filtered to one
317
+ * horizon — it returns every recorded horizon interleaved, and because this row
318
+ * shape carries no horizon field they cannot be told apart. Pass an explicit
319
+ * horizon whenever you ask for `CycleTime`.
320
+ */
321
+ type PercentilesOverTimeSnapshot = {
322
+ readonly recordedAt: string;
323
+ readonly metricType: PercentilesOverTimeMetricType;
324
+ readonly p50: number;
325
+ readonly p70: number;
326
+ readonly p85: number;
327
+ readonly p95: number;
328
+ };
329
+ /**
330
+ * Process-behaviour family recorded by the natural-process-limits over-time
331
+ * pipeline. Sent as the `type` query parameter.
332
+ *
333
+ * `FeatureSize` is PORTFOLIO-ONLY: it has no team-level equivalent, so a team
334
+ * never records it. The server answers a team asking for it with an empty
335
+ * series rather than an error.
336
+ */
337
+ type ProcessBehaviorMetricType = "Throughput" | "WorkItemAge" | "Wip" | "CycleTime" | "Arrivals" | "FeatureSize";
338
+ /**
339
+ * One captured day on the process-behaviour-over-time trend: the natural process
340
+ * limit triple recorded for {@link recordedAt} (an ISO date string, one row per
341
+ * calendar day, ascending). The family is carried by the request's `type`
342
+ * parameter, not repeated per row.
343
+ *
344
+ * Recording is FORWARD-ONLY, and a day is only recorded when the underlying
345
+ * chart had a usable baseline — days where it did not are absent from the
346
+ * series rather than present as a zeroed triple, so an empty array means
347
+ * "nothing recorded yet", never "a process pinned at zero".
348
+ */
349
+ type ProcessBehaviorSnapshot = {
350
+ readonly recordedAt: string;
351
+ readonly unpl: number;
352
+ readonly average: number;
353
+ readonly lnpl: number;
354
+ };
236
355
  type CumulativeStateTimeStateRow = {
237
356
  readonly state: string;
238
357
  readonly workflowOrder: number;
@@ -334,6 +453,10 @@ type LighthouseClient = {
334
453
  readonly getPortfolioTotalWorkItemAgeOverTime: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<TotalWorkItemAgeOverTimeResult>>;
335
454
  readonly getTeamBlockedCountHistory: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly BlockedCountSnapshot[]>>;
336
455
  readonly getPortfolioBlockedCountHistory: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly BlockedCountSnapshot[]>>;
456
+ readonly getTeamPercentilesOverTime: (teamId: number, range?: MetricsDateRange, metricType?: PercentilesOverTimeMetricType, horizon?: number) => Promise<LighthouseApiResult<readonly PercentilesOverTimeSnapshot[]>>;
457
+ readonly getPortfolioPercentilesOverTime: (portfolioId: number, range?: MetricsDateRange, metricType?: PercentilesOverTimeMetricType, horizon?: number) => Promise<LighthouseApiResult<readonly PercentilesOverTimeSnapshot[]>>;
458
+ readonly getTeamProcessBehaviorOverTime: (teamId: number, range?: MetricsDateRange, metricType?: ProcessBehaviorMetricType) => Promise<LighthouseApiResult<readonly ProcessBehaviorSnapshot[]>>;
459
+ readonly getPortfolioProcessBehaviorOverTime: (portfolioId: number, range?: MetricsDateRange, metricType?: ProcessBehaviorMetricType) => Promise<LighthouseApiResult<readonly ProcessBehaviorSnapshot[]>>;
337
460
  readonly getTeamCumulativeStateTime: (teamId: number, range?: MetricsDateRange, itemIds?: readonly number[]) => Promise<LighthouseApiResult<CumulativeStateTimeResult>>;
338
461
  readonly getTeamCumulativeStateTimeItems: (teamId: number, state: string, range?: MetricsDateRange, itemIds?: readonly number[]) => Promise<LighthouseApiResult<CumulativeStateTimeItemsResult>>;
339
462
  readonly getTeamCumulativeStateTimeCandidates: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<CumulativeStateTimeCandidatesResult>>;
@@ -347,6 +470,7 @@ type LighthouseClient = {
347
470
  readonly createDelivery: (portfolioId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
348
471
  readonly updateDelivery: (deliveryId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
349
472
  readonly deleteDelivery: (deliveryId: number) => Promise<LighthouseApiResult<undefined>>;
473
+ readonly getDeliveryMetricsHistory: (deliveryId: number) => Promise<LighthouseApiResult<DeliveryMetricsHistory>>;
350
474
  readonly getRecurringBlackoutRules: () => Promise<LighthouseApiResult<readonly RecurringBlackoutRule[]>>;
351
475
  readonly createRecurringBlackoutRule: (payload: LighthouseWritePayload) => Promise<LighthouseApiResult<RecurringBlackoutRule>>;
352
476
  readonly updateRecurringBlackoutRule: (id: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<RecurringBlackoutRule>>;
@@ -371,6 +495,9 @@ declare const FEATURE_REQUIRES_SERVER_NEWER_THAN: {
371
495
  readonly workItemAgePercentiles: "v26.6.7.1";
372
496
  readonly mcpOAuthPassThrough: "v26.6.16.14";
373
497
  readonly blockedCountHistory: "v26.7.3.1";
498
+ readonly percentilesOverTime: "v26.7.11.4";
499
+ readonly processBehaviorOverTime: "v26.7.11.4";
500
+ readonly deliveryMetricsHistory: "v26.5.29.5";
374
501
  };
375
502
  /**
376
503
  * Returns true when `candidate` is strictly newer than `baseline`, false when
@@ -380,4 +507,4 @@ declare const FEATURE_REQUIRES_SERVER_NEWER_THAN: {
380
507
  declare const isServerVersionNewerThan: (candidate: string, baseline: string) => boolean | null;
381
508
  declare const createLighthouseClient: (configuration: LighthouseClientConfiguration, dependencies?: LighthouseClientDependencies) => LighthouseClient;
382
509
 
383
- export { type BacktestInput, type BlockedCountSnapshot, type CliAuthSessionPollResult, type CliAuthSessionStartError, type CliAuthSessionStartOutcome, type CliAuthSessionStartResult, type CliConnection, type CliServerAuthMode, type CliServerConnection, type CliStandaloneConnection, type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, type CumulativeStateTimeCandidateRow, type CumulativeStateTimeCandidatesResult, type CumulativeStateTimeItemRow, type CumulativeStateTimeItemsResult, type CumulativeStateTimeResult, type CumulativeStateTimeStateRow, type DailyTotalWorkItemAge, type DailyWorkItemAge, type DayOfWeek, FEATURE_REQUIRES_SERVER_NEWER_THAN, type LighthouseApiError, type LighthouseApiResult, type LighthouseAuthContext, type LighthouseAuthOverrides, type LighthouseAuthStatus, type LighthouseAuthStore, type LighthouseClient, type LighthouseClientAuth, type LighthouseClientConfiguration, type LighthouseClientDependencies, type LighthouseConnectionConfiguration, type LighthouseWritePayload, type ManualForecastInput, type MetricsDateRange, type RecurringBlackoutRule, type RecurringBlackoutRuleInput, type ResolvedLighthouseEndpoint, type ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, type ThroughputFilterView, type TotalWorkItemAgeOverTimeResult, type WorkItemAgeEntry, type WorkItemAgeOverTimeResult, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, getStandaloneDiscoveryLockfilePath, isServerVersionNewerThan, loadStandaloneDiscoveryContract, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, validateLighthouseConnectivity };
510
+ export { type BacktestInput, type BlockedCountSnapshot, type CliAuthSessionPollResult, type CliAuthSessionStartError, type CliAuthSessionStartOutcome, type CliAuthSessionStartResult, type CliConnection, type CliServerAuthMode, type CliServerConnection, type CliStandaloneConnection, type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, type CumulativeStateTimeCandidateRow, type CumulativeStateTimeCandidatesResult, type CumulativeStateTimeItemRow, type CumulativeStateTimeItemsResult, type CumulativeStateTimeResult, type CumulativeStateTimeStateRow, type DailyTotalWorkItemAge, type DailyWorkItemAge, type DayOfWeek, type DeliveryFeatureMetric, type DeliveryMetricsHistory, type DeliveryMetricsHistoryPoint, type DeliveryMetricsHistorySummaryRow, type DeliveryWhenDistributionPoint, FEATURE_REQUIRES_SERVER_NEWER_THAN, type LighthouseApiError, type LighthouseApiResult, type LighthouseAuthContext, type LighthouseAuthOverrides, type LighthouseAuthStatus, type LighthouseAuthStore, type LighthouseClient, type LighthouseClientAuth, type LighthouseClientConfiguration, type LighthouseClientDependencies, type LighthouseConnectionConfiguration, type LighthouseWritePayload, type ManualForecastInput, type MetricsDateRange, type PercentilesOverTimeMetricType, type PercentilesOverTimeSnapshot, type ProcessBehaviorMetricType, type ProcessBehaviorSnapshot, type RecurringBlackoutRule, type RecurringBlackoutRuleInput, type ResolvedLighthouseEndpoint, type ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, type ThroughputFilterView, type TotalWorkItemAgeOverTimeResult, type WorkItemAgeEntry, type WorkItemAgeOverTimeResult, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, getStandaloneDiscoveryLockfilePath, isServerVersionNewerThan, loadStandaloneDiscoveryContract, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, summariseDeliveryMetricsHistory, validateLighthouseConnectivity };
package/dist/index.d.ts CHANGED
@@ -233,6 +233,125 @@ type BlockedCountSnapshot = {
233
233
  readonly recordedAt: string;
234
234
  readonly blockedCount: number;
235
235
  };
236
+ /**
237
+ * One epic as it stood on the day a delivery snapshot was taken.
238
+ *
239
+ * `likelihood` is null when the epic cannot be forecast (ADR-112). `totalItems` and
240
+ * `isUsingDefaultSize` are absent from every snapshot recorded before Lighthouse began writing
241
+ * sizes, so both are optional and a missing value means "not recorded", never zero.
242
+ */
243
+ type DeliveryFeatureMetric = {
244
+ readonly referenceId: string;
245
+ readonly name: string;
246
+ readonly completion: number;
247
+ readonly likelihood: number | null;
248
+ readonly totalItems?: number | null;
249
+ readonly isUsingDefaultSize?: boolean | null;
250
+ };
251
+ /** One point on a delivery's forecast distribution: the chance of finishing by a date. */
252
+ type DeliveryWhenDistributionPoint = {
253
+ readonly probability: number;
254
+ readonly expectedDate: string;
255
+ };
256
+ /** A delivery as it stood on one recorded day. Dates are ISO strings. */
257
+ type DeliveryMetricsHistoryPoint = {
258
+ readonly date: string;
259
+ readonly targetDateAtSnapshot: string | null;
260
+ readonly totalWork: number;
261
+ readonly doneWork: number;
262
+ readonly remainingWork: number;
263
+ readonly estimatedItemCount: number | null;
264
+ readonly forecastHowMany: number | null;
265
+ readonly likelihoodPercentage: number | null;
266
+ readonly whenDistribution: readonly DeliveryWhenDistributionPoint[] | null;
267
+ readonly featureBreakdown: readonly DeliveryFeatureMetric[];
268
+ };
269
+ /** The whole recorded trend for one delivery. Forward-only: it starts at the first snapshot. */
270
+ type DeliveryMetricsHistory = {
271
+ readonly deliveryDate: string;
272
+ readonly firstSnapshotDate: string | null;
273
+ readonly points: readonly DeliveryMetricsHistoryPoint[];
274
+ };
275
+ /**
276
+ * One day of a delivery, without the per-epic breakdown or the forecast distribution.
277
+ *
278
+ * A ninety-day window over fifteen epics is well over a thousand breakdown objects plus a
279
+ * distribution per day — more than an assistant should be handed by default (ADR-121), and more
280
+ * than a terminal can show. {@link summariseDeliveryMetricsHistory} projects to this.
281
+ */
282
+ type DeliveryMetricsHistorySummaryRow = {
283
+ readonly date: string;
284
+ readonly totalWork: number;
285
+ readonly doneWork: number;
286
+ readonly remainingWork: number;
287
+ readonly epicCount: number;
288
+ readonly estimatedItemCount: number | null;
289
+ readonly likelihoodPercentage: number | null;
290
+ };
291
+ /**
292
+ * Projects a delivery history to one row per recorded day. Pure.
293
+ *
294
+ * The client itself returns the payload whole: dropping data is the caller's choice, so the CLI and
295
+ * the MCP tool apply this by default and step around it when asked for per-epic detail.
296
+ */
297
+ declare const summariseDeliveryMetricsHistory: (history: DeliveryMetricsHistory) => readonly DeliveryMetricsHistorySummaryRow[];
298
+ /**
299
+ * Percentile family recorded by the percentiles-over-time pipeline. Sent as the
300
+ * `metricType` query parameter, and echoed back on every returned row.
301
+ */
302
+ type PercentilesOverTimeMetricType = "CycleTime" | "WorkItemAge";
303
+ /**
304
+ * One captured day on the percentiles-over-time trend: the percentile quartet
305
+ * recorded for {@link recordedAt} (an ISO date string, one row per calendar day,
306
+ * ascending).
307
+ *
308
+ * Recording is FORWARD-ONLY — Lighthouse starts capturing the day the feature is
309
+ * first deployed and never backfills history it did not observe, so a freshly
310
+ * upgraded server legitimately returns an empty array until the first refresh.
311
+ *
312
+ * `CycleTime` is recorded per horizon (30/60/90 days); `WorkItemAge` is always
313
+ * "as of today" and therefore has no horizon dimension, so a horizon sent
314
+ * alongside it is ignored in favour of the horizon-less series.
315
+ *
316
+ * SHARP EDGE: a `CycleTime` request that omits `horizon` is not filtered to one
317
+ * horizon — it returns every recorded horizon interleaved, and because this row
318
+ * shape carries no horizon field they cannot be told apart. Pass an explicit
319
+ * horizon whenever you ask for `CycleTime`.
320
+ */
321
+ type PercentilesOverTimeSnapshot = {
322
+ readonly recordedAt: string;
323
+ readonly metricType: PercentilesOverTimeMetricType;
324
+ readonly p50: number;
325
+ readonly p70: number;
326
+ readonly p85: number;
327
+ readonly p95: number;
328
+ };
329
+ /**
330
+ * Process-behaviour family recorded by the natural-process-limits over-time
331
+ * pipeline. Sent as the `type` query parameter.
332
+ *
333
+ * `FeatureSize` is PORTFOLIO-ONLY: it has no team-level equivalent, so a team
334
+ * never records it. The server answers a team asking for it with an empty
335
+ * series rather than an error.
336
+ */
337
+ type ProcessBehaviorMetricType = "Throughput" | "WorkItemAge" | "Wip" | "CycleTime" | "Arrivals" | "FeatureSize";
338
+ /**
339
+ * One captured day on the process-behaviour-over-time trend: the natural process
340
+ * limit triple recorded for {@link recordedAt} (an ISO date string, one row per
341
+ * calendar day, ascending). The family is carried by the request's `type`
342
+ * parameter, not repeated per row.
343
+ *
344
+ * Recording is FORWARD-ONLY, and a day is only recorded when the underlying
345
+ * chart had a usable baseline — days where it did not are absent from the
346
+ * series rather than present as a zeroed triple, so an empty array means
347
+ * "nothing recorded yet", never "a process pinned at zero".
348
+ */
349
+ type ProcessBehaviorSnapshot = {
350
+ readonly recordedAt: string;
351
+ readonly unpl: number;
352
+ readonly average: number;
353
+ readonly lnpl: number;
354
+ };
236
355
  type CumulativeStateTimeStateRow = {
237
356
  readonly state: string;
238
357
  readonly workflowOrder: number;
@@ -334,6 +453,10 @@ type LighthouseClient = {
334
453
  readonly getPortfolioTotalWorkItemAgeOverTime: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<TotalWorkItemAgeOverTimeResult>>;
335
454
  readonly getTeamBlockedCountHistory: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly BlockedCountSnapshot[]>>;
336
455
  readonly getPortfolioBlockedCountHistory: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly BlockedCountSnapshot[]>>;
456
+ readonly getTeamPercentilesOverTime: (teamId: number, range?: MetricsDateRange, metricType?: PercentilesOverTimeMetricType, horizon?: number) => Promise<LighthouseApiResult<readonly PercentilesOverTimeSnapshot[]>>;
457
+ readonly getPortfolioPercentilesOverTime: (portfolioId: number, range?: MetricsDateRange, metricType?: PercentilesOverTimeMetricType, horizon?: number) => Promise<LighthouseApiResult<readonly PercentilesOverTimeSnapshot[]>>;
458
+ readonly getTeamProcessBehaviorOverTime: (teamId: number, range?: MetricsDateRange, metricType?: ProcessBehaviorMetricType) => Promise<LighthouseApiResult<readonly ProcessBehaviorSnapshot[]>>;
459
+ readonly getPortfolioProcessBehaviorOverTime: (portfolioId: number, range?: MetricsDateRange, metricType?: ProcessBehaviorMetricType) => Promise<LighthouseApiResult<readonly ProcessBehaviorSnapshot[]>>;
337
460
  readonly getTeamCumulativeStateTime: (teamId: number, range?: MetricsDateRange, itemIds?: readonly number[]) => Promise<LighthouseApiResult<CumulativeStateTimeResult>>;
338
461
  readonly getTeamCumulativeStateTimeItems: (teamId: number, state: string, range?: MetricsDateRange, itemIds?: readonly number[]) => Promise<LighthouseApiResult<CumulativeStateTimeItemsResult>>;
339
462
  readonly getTeamCumulativeStateTimeCandidates: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<CumulativeStateTimeCandidatesResult>>;
@@ -347,6 +470,7 @@ type LighthouseClient = {
347
470
  readonly createDelivery: (portfolioId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
348
471
  readonly updateDelivery: (deliveryId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
349
472
  readonly deleteDelivery: (deliveryId: number) => Promise<LighthouseApiResult<undefined>>;
473
+ readonly getDeliveryMetricsHistory: (deliveryId: number) => Promise<LighthouseApiResult<DeliveryMetricsHistory>>;
350
474
  readonly getRecurringBlackoutRules: () => Promise<LighthouseApiResult<readonly RecurringBlackoutRule[]>>;
351
475
  readonly createRecurringBlackoutRule: (payload: LighthouseWritePayload) => Promise<LighthouseApiResult<RecurringBlackoutRule>>;
352
476
  readonly updateRecurringBlackoutRule: (id: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<RecurringBlackoutRule>>;
@@ -371,6 +495,9 @@ declare const FEATURE_REQUIRES_SERVER_NEWER_THAN: {
371
495
  readonly workItemAgePercentiles: "v26.6.7.1";
372
496
  readonly mcpOAuthPassThrough: "v26.6.16.14";
373
497
  readonly blockedCountHistory: "v26.7.3.1";
498
+ readonly percentilesOverTime: "v26.7.11.4";
499
+ readonly processBehaviorOverTime: "v26.7.11.4";
500
+ readonly deliveryMetricsHistory: "v26.5.29.5";
374
501
  };
375
502
  /**
376
503
  * Returns true when `candidate` is strictly newer than `baseline`, false when
@@ -380,4 +507,4 @@ declare const FEATURE_REQUIRES_SERVER_NEWER_THAN: {
380
507
  declare const isServerVersionNewerThan: (candidate: string, baseline: string) => boolean | null;
381
508
  declare const createLighthouseClient: (configuration: LighthouseClientConfiguration, dependencies?: LighthouseClientDependencies) => LighthouseClient;
382
509
 
383
- export { type BacktestInput, type BlockedCountSnapshot, type CliAuthSessionPollResult, type CliAuthSessionStartError, type CliAuthSessionStartOutcome, type CliAuthSessionStartResult, type CliConnection, type CliServerAuthMode, type CliServerConnection, type CliStandaloneConnection, type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, type CumulativeStateTimeCandidateRow, type CumulativeStateTimeCandidatesResult, type CumulativeStateTimeItemRow, type CumulativeStateTimeItemsResult, type CumulativeStateTimeResult, type CumulativeStateTimeStateRow, type DailyTotalWorkItemAge, type DailyWorkItemAge, type DayOfWeek, FEATURE_REQUIRES_SERVER_NEWER_THAN, type LighthouseApiError, type LighthouseApiResult, type LighthouseAuthContext, type LighthouseAuthOverrides, type LighthouseAuthStatus, type LighthouseAuthStore, type LighthouseClient, type LighthouseClientAuth, type LighthouseClientConfiguration, type LighthouseClientDependencies, type LighthouseConnectionConfiguration, type LighthouseWritePayload, type ManualForecastInput, type MetricsDateRange, type RecurringBlackoutRule, type RecurringBlackoutRuleInput, type ResolvedLighthouseEndpoint, type ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, type ThroughputFilterView, type TotalWorkItemAgeOverTimeResult, type WorkItemAgeEntry, type WorkItemAgeOverTimeResult, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, getStandaloneDiscoveryLockfilePath, isServerVersionNewerThan, loadStandaloneDiscoveryContract, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, validateLighthouseConnectivity };
510
+ export { type BacktestInput, type BlockedCountSnapshot, type CliAuthSessionPollResult, type CliAuthSessionStartError, type CliAuthSessionStartOutcome, type CliAuthSessionStartResult, type CliConnection, type CliServerAuthMode, type CliServerConnection, type CliStandaloneConnection, type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, type CumulativeStateTimeCandidateRow, type CumulativeStateTimeCandidatesResult, type CumulativeStateTimeItemRow, type CumulativeStateTimeItemsResult, type CumulativeStateTimeResult, type CumulativeStateTimeStateRow, type DailyTotalWorkItemAge, type DailyWorkItemAge, type DayOfWeek, type DeliveryFeatureMetric, type DeliveryMetricsHistory, type DeliveryMetricsHistoryPoint, type DeliveryMetricsHistorySummaryRow, type DeliveryWhenDistributionPoint, FEATURE_REQUIRES_SERVER_NEWER_THAN, type LighthouseApiError, type LighthouseApiResult, type LighthouseAuthContext, type LighthouseAuthOverrides, type LighthouseAuthStatus, type LighthouseAuthStore, type LighthouseClient, type LighthouseClientAuth, type LighthouseClientConfiguration, type LighthouseClientDependencies, type LighthouseConnectionConfiguration, type LighthouseWritePayload, type ManualForecastInput, type MetricsDateRange, type PercentilesOverTimeMetricType, type PercentilesOverTimeSnapshot, type ProcessBehaviorMetricType, type ProcessBehaviorSnapshot, type RecurringBlackoutRule, type RecurringBlackoutRuleInput, type ResolvedLighthouseEndpoint, type ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, type ThroughputFilterView, type TotalWorkItemAgeOverTimeResult, type WorkItemAgeEntry, type WorkItemAgeOverTimeResult, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, getStandaloneDiscoveryLockfilePath, isServerVersionNewerThan, loadStandaloneDiscoveryContract, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, summariseDeliveryMetricsHistory, validateLighthouseConnectivity };
package/dist/index.js CHANGED
@@ -495,6 +495,15 @@ var getDefaultMetricsDateRange = () => {
495
495
  endDate: toIsoDate(end)
496
496
  };
497
497
  };
498
+ var summariseDeliveryMetricsHistory = (history) => history.points.map((point) => ({
499
+ date: point.date,
500
+ totalWork: point.totalWork,
501
+ doneWork: point.doneWork,
502
+ remainingWork: point.remainingWork,
503
+ epicCount: point.featureBreakdown.length,
504
+ estimatedItemCount: point.estimatedItemCount,
505
+ likelihoodPercentage: point.likelihoodPercentage
506
+ }));
498
507
  var getAuthHeaders = (auth) => {
499
508
  if (auth === void 0 || auth.kind === "none") {
500
509
  return {};
@@ -698,6 +707,12 @@ var getMetricsAsOfDateQuery = (asOfDate) => `asOfDate=${encodeURIComponent(asOfD
698
707
  var getItemIdsQuerySuffix = (itemIds) => itemIds && itemIds.length > 0 ? itemIds.map((id) => `&itemIds=${encodeURIComponent(id)}`).join("") : "";
699
708
  var getViewQuerySuffix = (view) => view === "filtered" ? "&view=filtered" : "";
700
709
  var getDefinitionIdQuerySuffix = (definitionId) => definitionId !== void 0 ? `&definitionId=${encodeURIComponent(definitionId)}` : "";
710
+ var getPercentilesOverTimeQuerySuffix = (metricType, horizon) => {
711
+ const metricTypePart = metricType === void 0 ? "" : `&metricType=${encodeURIComponent(metricType)}`;
712
+ const horizonPart = horizon === void 0 ? "" : `&horizon=${encodeURIComponent(horizon)}`;
713
+ return `${metricTypePart}${horizonPart}`;
714
+ };
715
+ var getProcessBehaviorTypeQuerySuffix = (metricType) => metricType === void 0 ? "" : `&type=${encodeURIComponent(metricType)}`;
701
716
  var addUtcDays = (dateStr, days) => {
702
717
  const d = /* @__PURE__ */ new Date(`${dateStr}T00:00:00Z`);
703
718
  d.setUTCDate(d.getUTCDate() + days);
@@ -752,7 +767,12 @@ var FEATURE_REQUIRES_SERVER_NEWER_THAN = {
752
767
  recurringBlackoutRules: "v26.5.29.5",
753
768
  workItemAgePercentiles: "v26.6.7.1",
754
769
  mcpOAuthPassThrough: "v26.6.16.14",
755
- blockedCountHistory: "v26.7.3.1"
770
+ blockedCountHistory: "v26.7.3.1",
771
+ percentilesOverTime: "v26.7.11.4",
772
+ processBehaviorOverTime: "v26.7.11.4",
773
+ // The endpoint landed in v26.6.7.1. The per-epic size fields came much later and are optional on
774
+ // the wire, so a server between the two answers fine — it just reports no sizes.
775
+ deliveryMetricsHistory: "v26.5.29.5"
756
776
  };
757
777
  var parseServerVersion = (raw) => {
758
778
  const trimmed = raw.trim().replace(/^v/iu, "");
@@ -1222,6 +1242,58 @@ var createLighthouseClient = (configuration, dependencies = {}) => {
1222
1242
  { method: "GET" }
1223
1243
  );
1224
1244
  },
1245
+ getTeamPercentilesOverTime: async (teamId, range, metricType, horizon) => {
1246
+ const unsupported = await ensureServerSupports("percentilesOverTime");
1247
+ if (unsupported) {
1248
+ return unsupported;
1249
+ }
1250
+ const r = getResolvedMetricsDateRange(range);
1251
+ return requestJson(
1252
+ configuration,
1253
+ dependencies,
1254
+ `/v1/teams/${teamId}/metrics/percentiles-over-time?${getMetricsDateRangeQuery(r)}${getPercentilesOverTimeQuerySuffix(metricType, horizon)}`,
1255
+ { method: "GET" }
1256
+ );
1257
+ },
1258
+ getPortfolioPercentilesOverTime: async (portfolioId, range, metricType, horizon) => {
1259
+ const unsupported = await ensureServerSupports("percentilesOverTime");
1260
+ if (unsupported) {
1261
+ return unsupported;
1262
+ }
1263
+ const r = getResolvedMetricsDateRange(range);
1264
+ return requestJson(
1265
+ configuration,
1266
+ dependencies,
1267
+ `/v1/portfolios/${portfolioId}/metrics/percentiles-over-time?${getMetricsDateRangeQuery(r)}${getPercentilesOverTimeQuerySuffix(metricType, horizon)}`,
1268
+ { method: "GET" }
1269
+ );
1270
+ },
1271
+ getTeamProcessBehaviorOverTime: async (teamId, range, metricType) => {
1272
+ const unsupported = await ensureServerSupports("processBehaviorOverTime");
1273
+ if (unsupported) {
1274
+ return unsupported;
1275
+ }
1276
+ const r = getResolvedMetricsDateRange(range);
1277
+ return requestJson(
1278
+ configuration,
1279
+ dependencies,
1280
+ `/v1/teams/${teamId}/metrics/process-behavior-over-time?${getMetricsDateRangeQuery(r)}${getProcessBehaviorTypeQuerySuffix(metricType)}`,
1281
+ { method: "GET" }
1282
+ );
1283
+ },
1284
+ getPortfolioProcessBehaviorOverTime: async (portfolioId, range, metricType) => {
1285
+ const unsupported = await ensureServerSupports("processBehaviorOverTime");
1286
+ if (unsupported) {
1287
+ return unsupported;
1288
+ }
1289
+ const r = getResolvedMetricsDateRange(range);
1290
+ return requestJson(
1291
+ configuration,
1292
+ dependencies,
1293
+ `/v1/portfolios/${portfolioId}/metrics/process-behavior-over-time?${getMetricsDateRangeQuery(r)}${getProcessBehaviorTypeQuerySuffix(metricType)}`,
1294
+ { method: "GET" }
1295
+ );
1296
+ },
1225
1297
  getTeamCumulativeStateTime: async (teamId, range, itemIds) => {
1226
1298
  const unsupported = await ensureServerSupports("cumulativeStateTime");
1227
1299
  if (unsupported) {
@@ -1348,6 +1420,18 @@ var createLighthouseClient = (configuration, dependencies = {}) => {
1348
1420
  `/v1/deliveries/${deliveryId}`,
1349
1421
  { method: "DELETE" }
1350
1422
  ),
1423
+ getDeliveryMetricsHistory: async (deliveryId) => {
1424
+ const unsupported = await ensureServerSupports("deliveryMetricsHistory");
1425
+ if (unsupported) {
1426
+ return unsupported;
1427
+ }
1428
+ return requestJson(
1429
+ configuration,
1430
+ dependencies,
1431
+ `/v1/deliveries/${deliveryId}/metrics-history`,
1432
+ { method: "GET" }
1433
+ );
1434
+ },
1351
1435
  getRecurringBlackoutRules: async () => {
1352
1436
  const unsupported = await ensureServerSupports("recurringBlackoutRules");
1353
1437
  if (unsupported) {
@@ -1423,5 +1507,6 @@ export {
1423
1507
  pollCliAuthSession,
1424
1508
  queryServerAuthMode,
1425
1509
  startCliAuthSession,
1510
+ summariseDeliveryMetricsHistory,
1426
1511
  validateLighthouseConnectivity
1427
1512
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letpeoplework/lighthouse-client",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "Shared Lighthouse API client contracts",
5
5
  "repository": "https://github.com/LetPeopleWork/lighthouse-clients",
6
6
  "type": "module",