@letpeoplework/lighthouse-client 0.1.0 → 0.3.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.d.mts CHANGED
@@ -103,6 +103,21 @@ type LighthouseApiResult<TValue> = {
103
103
  readonly error: LighthouseApiError;
104
104
  };
105
105
  type LighthouseWritePayload = Readonly<Record<string, unknown>>;
106
+ type MetricsDateRange = {
107
+ readonly startDate: string;
108
+ readonly endDate: string;
109
+ };
110
+ declare const getDefaultMetricsDateRange: () => MetricsDateRange;
111
+ type ManualForecastInput = {
112
+ readonly remainingItems?: number;
113
+ readonly targetDate?: string;
114
+ };
115
+ type BacktestInput = {
116
+ readonly startDate: string;
117
+ readonly endDate: string;
118
+ readonly historicalStartDate: string;
119
+ readonly historicalEndDate: string;
120
+ };
106
121
  type LighthouseClient = {
107
122
  readonly checkConnectivity: () => Promise<ConnectivityValidationResult>;
108
123
  readonly getVersion: () => Promise<LighthouseApiResult<string>>;
@@ -123,10 +138,22 @@ type LighthouseClient = {
123
138
  readonly updatePortfolio: (portfolioId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
124
139
  readonly deletePortfolio: (portfolioId: number) => Promise<LighthouseApiResult<void>>;
125
140
  readonly refreshPortfolio: (portfolioId: number) => Promise<LighthouseApiResult<void>>;
141
+ readonly getTeamThroughput: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
142
+ readonly getTeamCycleTimePercentiles: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly unknown[]>>;
143
+ readonly getPortfolioThroughput: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
144
+ readonly getFeaturesByIds: (ids: readonly number[]) => Promise<LighthouseApiResult<readonly unknown[]>>;
145
+ readonly getFeaturesByReferences: (refs: readonly string[]) => Promise<LighthouseApiResult<readonly unknown[]>>;
146
+ readonly getFeatureWorkItems: (featureId: number) => Promise<LighthouseApiResult<readonly unknown[]>>;
147
+ readonly listDeliveries: (portfolioId: number) => Promise<LighthouseApiResult<readonly unknown[]>>;
148
+ readonly createDelivery: (portfolioId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
149
+ readonly updateDelivery: (deliveryId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
150
+ readonly deleteDelivery: (deliveryId: number) => Promise<LighthouseApiResult<undefined>>;
151
+ readonly runManualForecast: (teamId: number, payload: ManualForecastInput) => Promise<LighthouseApiResult<unknown>>;
152
+ readonly runBacktest: (teamId: number, payload: BacktestInput) => Promise<LighthouseApiResult<unknown>>;
126
153
  };
127
154
  type LighthouseClientDependencies = {
128
155
  readonly fetch?: (url: string, init?: RequestInit) => Promise<ConnectivityFetchResponse>;
129
156
  };
130
157
  declare const createLighthouseClient: (configuration: LighthouseClientConfiguration, dependencies?: LighthouseClientDependencies) => LighthouseClient;
131
158
 
132
- export { type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, 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 ResolvedLighthouseEndpoint, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, parseStandaloneDiscoveryContract, validateLighthouseConnectivity };
159
+ export { type BacktestInput, type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, 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 ResolvedLighthouseEndpoint, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, parseStandaloneDiscoveryContract, validateLighthouseConnectivity };
package/dist/index.d.ts CHANGED
@@ -103,6 +103,21 @@ type LighthouseApiResult<TValue> = {
103
103
  readonly error: LighthouseApiError;
104
104
  };
105
105
  type LighthouseWritePayload = Readonly<Record<string, unknown>>;
106
+ type MetricsDateRange = {
107
+ readonly startDate: string;
108
+ readonly endDate: string;
109
+ };
110
+ declare const getDefaultMetricsDateRange: () => MetricsDateRange;
111
+ type ManualForecastInput = {
112
+ readonly remainingItems?: number;
113
+ readonly targetDate?: string;
114
+ };
115
+ type BacktestInput = {
116
+ readonly startDate: string;
117
+ readonly endDate: string;
118
+ readonly historicalStartDate: string;
119
+ readonly historicalEndDate: string;
120
+ };
106
121
  type LighthouseClient = {
107
122
  readonly checkConnectivity: () => Promise<ConnectivityValidationResult>;
108
123
  readonly getVersion: () => Promise<LighthouseApiResult<string>>;
@@ -123,10 +138,22 @@ type LighthouseClient = {
123
138
  readonly updatePortfolio: (portfolioId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
124
139
  readonly deletePortfolio: (portfolioId: number) => Promise<LighthouseApiResult<void>>;
125
140
  readonly refreshPortfolio: (portfolioId: number) => Promise<LighthouseApiResult<void>>;
141
+ readonly getTeamThroughput: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
142
+ readonly getTeamCycleTimePercentiles: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly unknown[]>>;
143
+ readonly getPortfolioThroughput: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
144
+ readonly getFeaturesByIds: (ids: readonly number[]) => Promise<LighthouseApiResult<readonly unknown[]>>;
145
+ readonly getFeaturesByReferences: (refs: readonly string[]) => Promise<LighthouseApiResult<readonly unknown[]>>;
146
+ readonly getFeatureWorkItems: (featureId: number) => Promise<LighthouseApiResult<readonly unknown[]>>;
147
+ readonly listDeliveries: (portfolioId: number) => Promise<LighthouseApiResult<readonly unknown[]>>;
148
+ readonly createDelivery: (portfolioId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
149
+ readonly updateDelivery: (deliveryId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
150
+ readonly deleteDelivery: (deliveryId: number) => Promise<LighthouseApiResult<undefined>>;
151
+ readonly runManualForecast: (teamId: number, payload: ManualForecastInput) => Promise<LighthouseApiResult<unknown>>;
152
+ readonly runBacktest: (teamId: number, payload: BacktestInput) => Promise<LighthouseApiResult<unknown>>;
126
153
  };
127
154
  type LighthouseClientDependencies = {
128
155
  readonly fetch?: (url: string, init?: RequestInit) => Promise<ConnectivityFetchResponse>;
129
156
  };
130
157
  declare const createLighthouseClient: (configuration: LighthouseClientConfiguration, dependencies?: LighthouseClientDependencies) => LighthouseClient;
131
158
 
132
- export { type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, 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 ResolvedLighthouseEndpoint, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, parseStandaloneDiscoveryContract, validateLighthouseConnectivity };
159
+ export { type BacktestInput, type ClientCapability, type ClientPackageContract, type ConnectivityCategory, type ConnectivityDependencies, type ConnectivityFetchResponse, type ConnectivityValidationResult, 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 ResolvedLighthouseEndpoint, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, parseStandaloneDiscoveryContract, validateLighthouseConnectivity };
package/dist/index.js CHANGED
@@ -23,6 +23,7 @@ __export(index_exports, {
23
23
  createLighthouseAuthContext: () => createLighthouseAuthContext,
24
24
  createLighthouseClient: () => createLighthouseClient,
25
25
  getClientPackageContract: () => getClientPackageContract,
26
+ getDefaultMetricsDateRange: () => getDefaultMetricsDateRange,
26
27
  parseStandaloneDiscoveryContract: () => parseStandaloneDiscoveryContract,
27
28
  validateLighthouseConnectivity: () => validateLighthouseConnectivity
28
29
  });
@@ -312,6 +313,16 @@ var createLighthouseAuthContext = (store) => ({
312
313
  return getStatusFromAuth({ kind: "none" }, "none");
313
314
  }
314
315
  });
316
+ var getDefaultMetricsDateRange = () => {
317
+ const end = /* @__PURE__ */ new Date();
318
+ const start = /* @__PURE__ */ new Date();
319
+ start.setDate(start.getDate() - 90);
320
+ const toIsoDate = (d) => d.toISOString().split("T")[0];
321
+ return {
322
+ startDate: toIsoDate(start),
323
+ endDate: toIsoDate(end)
324
+ };
325
+ };
315
326
  var getAuthHeaders = (auth) => {
316
327
  if (auth === void 0 || auth.kind === "none") {
317
328
  return {};
@@ -595,6 +606,93 @@ var createLighthouseClient = (configuration, dependencies = {}) => ({
595
606
  {
596
607
  method: "POST"
597
608
  }
609
+ ),
610
+ getTeamThroughput: async (teamId, range) => {
611
+ const r = range ?? getDefaultMetricsDateRange();
612
+ return requestJson(
613
+ configuration,
614
+ dependencies,
615
+ `/v1/teams/${teamId}/metrics/throughput?startDate=${r.startDate}&endDate=${r.endDate}`,
616
+ { method: "GET" }
617
+ );
618
+ },
619
+ getTeamCycleTimePercentiles: async (teamId, range) => {
620
+ const r = range ?? getDefaultMetricsDateRange();
621
+ return requestJson(
622
+ configuration,
623
+ dependencies,
624
+ `/v1/teams/${teamId}/metrics/cycleTimePercentiles?startDate=${r.startDate}&endDate=${r.endDate}`,
625
+ { method: "GET" }
626
+ );
627
+ },
628
+ getPortfolioThroughput: async (portfolioId, range) => {
629
+ const r = range ?? getDefaultMetricsDateRange();
630
+ return requestJson(
631
+ configuration,
632
+ dependencies,
633
+ `/v1/portfolios/${portfolioId}/metrics/throughput?startDate=${r.startDate}&endDate=${r.endDate}`,
634
+ { method: "GET" }
635
+ );
636
+ },
637
+ getFeaturesByIds: async (ids) => {
638
+ const queryString = ids.map((id) => `ids=${encodeURIComponent(id)}`).join("&");
639
+ return requestJson(
640
+ configuration,
641
+ dependencies,
642
+ `/v1/features?${queryString}`,
643
+ { method: "GET" }
644
+ );
645
+ },
646
+ getFeaturesByReferences: async (refs) => {
647
+ const queryString = refs.map((r) => `featureReferences=${encodeURIComponent(r)}`).join("&");
648
+ return requestJson(
649
+ configuration,
650
+ dependencies,
651
+ `/v1/features/references?${queryString}`,
652
+ { method: "GET" }
653
+ );
654
+ },
655
+ getFeatureWorkItems: async (featureId) => requestJson(
656
+ configuration,
657
+ dependencies,
658
+ `/v1/features/${featureId}/workitems`,
659
+ { method: "GET" }
660
+ ),
661
+ listDeliveries: async (portfolioId) => requestJson(
662
+ configuration,
663
+ dependencies,
664
+ `/v1/deliveries/portfolio/${portfolioId}`,
665
+ { method: "GET" }
666
+ ),
667
+ createDelivery: async (portfolioId, payload) => requestJson(
668
+ configuration,
669
+ dependencies,
670
+ `/v1/deliveries/portfolio/${portfolioId}`,
671
+ { method: "POST", body: payload }
672
+ ),
673
+ updateDelivery: async (deliveryId, payload) => requestJson(
674
+ configuration,
675
+ dependencies,
676
+ `/v1/deliveries/${deliveryId}`,
677
+ { method: "PUT", body: payload }
678
+ ),
679
+ deleteDelivery: async (deliveryId) => requestNoContent(
680
+ configuration,
681
+ dependencies,
682
+ `/v1/deliveries/${deliveryId}`,
683
+ { method: "DELETE" }
684
+ ),
685
+ runManualForecast: async (teamId, payload) => requestJson(
686
+ configuration,
687
+ dependencies,
688
+ `/v1/forecast/manual/${teamId}`,
689
+ { method: "POST", body: payload }
690
+ ),
691
+ runBacktest: async (teamId, payload) => requestJson(
692
+ configuration,
693
+ dependencies,
694
+ `/v1/forecast/backtest/${teamId}`,
695
+ { method: "POST", body: payload }
598
696
  )
599
697
  });
600
698
  // Annotate the CommonJS export names for ESM import in node:
@@ -602,6 +700,7 @@ var createLighthouseClient = (configuration, dependencies = {}) => ({
602
700
  createLighthouseAuthContext,
603
701
  createLighthouseClient,
604
702
  getClientPackageContract,
703
+ getDefaultMetricsDateRange,
605
704
  parseStandaloneDiscoveryContract,
606
705
  validateLighthouseConnectivity
607
706
  });
package/dist/index.mjs CHANGED
@@ -284,6 +284,16 @@ var createLighthouseAuthContext = (store) => ({
284
284
  return getStatusFromAuth({ kind: "none" }, "none");
285
285
  }
286
286
  });
287
+ var getDefaultMetricsDateRange = () => {
288
+ const end = /* @__PURE__ */ new Date();
289
+ const start = /* @__PURE__ */ new Date();
290
+ start.setDate(start.getDate() - 90);
291
+ const toIsoDate = (d) => d.toISOString().split("T")[0];
292
+ return {
293
+ startDate: toIsoDate(start),
294
+ endDate: toIsoDate(end)
295
+ };
296
+ };
287
297
  var getAuthHeaders = (auth) => {
288
298
  if (auth === void 0 || auth.kind === "none") {
289
299
  return {};
@@ -567,12 +577,100 @@ var createLighthouseClient = (configuration, dependencies = {}) => ({
567
577
  {
568
578
  method: "POST"
569
579
  }
580
+ ),
581
+ getTeamThroughput: async (teamId, range) => {
582
+ const r = range ?? getDefaultMetricsDateRange();
583
+ return requestJson(
584
+ configuration,
585
+ dependencies,
586
+ `/v1/teams/${teamId}/metrics/throughput?startDate=${r.startDate}&endDate=${r.endDate}`,
587
+ { method: "GET" }
588
+ );
589
+ },
590
+ getTeamCycleTimePercentiles: async (teamId, range) => {
591
+ const r = range ?? getDefaultMetricsDateRange();
592
+ return requestJson(
593
+ configuration,
594
+ dependencies,
595
+ `/v1/teams/${teamId}/metrics/cycleTimePercentiles?startDate=${r.startDate}&endDate=${r.endDate}`,
596
+ { method: "GET" }
597
+ );
598
+ },
599
+ getPortfolioThroughput: async (portfolioId, range) => {
600
+ const r = range ?? getDefaultMetricsDateRange();
601
+ return requestJson(
602
+ configuration,
603
+ dependencies,
604
+ `/v1/portfolios/${portfolioId}/metrics/throughput?startDate=${r.startDate}&endDate=${r.endDate}`,
605
+ { method: "GET" }
606
+ );
607
+ },
608
+ getFeaturesByIds: async (ids) => {
609
+ const queryString = ids.map((id) => `ids=${encodeURIComponent(id)}`).join("&");
610
+ return requestJson(
611
+ configuration,
612
+ dependencies,
613
+ `/v1/features?${queryString}`,
614
+ { method: "GET" }
615
+ );
616
+ },
617
+ getFeaturesByReferences: async (refs) => {
618
+ const queryString = refs.map((r) => `featureReferences=${encodeURIComponent(r)}`).join("&");
619
+ return requestJson(
620
+ configuration,
621
+ dependencies,
622
+ `/v1/features/references?${queryString}`,
623
+ { method: "GET" }
624
+ );
625
+ },
626
+ getFeatureWorkItems: async (featureId) => requestJson(
627
+ configuration,
628
+ dependencies,
629
+ `/v1/features/${featureId}/workitems`,
630
+ { method: "GET" }
631
+ ),
632
+ listDeliveries: async (portfolioId) => requestJson(
633
+ configuration,
634
+ dependencies,
635
+ `/v1/deliveries/portfolio/${portfolioId}`,
636
+ { method: "GET" }
637
+ ),
638
+ createDelivery: async (portfolioId, payload) => requestJson(
639
+ configuration,
640
+ dependencies,
641
+ `/v1/deliveries/portfolio/${portfolioId}`,
642
+ { method: "POST", body: payload }
643
+ ),
644
+ updateDelivery: async (deliveryId, payload) => requestJson(
645
+ configuration,
646
+ dependencies,
647
+ `/v1/deliveries/${deliveryId}`,
648
+ { method: "PUT", body: payload }
649
+ ),
650
+ deleteDelivery: async (deliveryId) => requestNoContent(
651
+ configuration,
652
+ dependencies,
653
+ `/v1/deliveries/${deliveryId}`,
654
+ { method: "DELETE" }
655
+ ),
656
+ runManualForecast: async (teamId, payload) => requestJson(
657
+ configuration,
658
+ dependencies,
659
+ `/v1/forecast/manual/${teamId}`,
660
+ { method: "POST", body: payload }
661
+ ),
662
+ runBacktest: async (teamId, payload) => requestJson(
663
+ configuration,
664
+ dependencies,
665
+ `/v1/forecast/backtest/${teamId}`,
666
+ { method: "POST", body: payload }
570
667
  )
571
668
  });
572
669
  export {
573
670
  createLighthouseAuthContext,
574
671
  createLighthouseClient,
575
672
  getClientPackageContract,
673
+ getDefaultMetricsDateRange,
576
674
  parseStandaloneDiscoveryContract,
577
675
  validateLighthouseConnectivity
578
676
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letpeoplework/lighthouse-client",
3
- "version": "0.1.0",
3
+ "version": "0.3.0",
4
4
  "description": "Shared Lighthouse API client contracts",
5
5
  "repository": "https://github.com/LetPeopleWork/lighthouse-clients",
6
6
  "main": "dist/index.cjs",
@@ -17,7 +17,9 @@
17
17
  "dist"
18
18
  ],
19
19
  "publishConfig": {
20
- "access": "public"
20
+ "access": "public",
21
+ "provenance": true,
22
+ "registry": "https://registry.npmjs.org/"
21
23
  },
22
24
  "scripts": {
23
25
  "build": "tsup src/index.ts --format esm,cjs --dts --clean",