@letpeoplework/lighthouse-client 0.1.0 → 0.3.1

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.
@@ -1,4 +1,33 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
1
20
  // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ createLighthouseAuthContext: () => createLighthouseAuthContext,
24
+ createLighthouseClient: () => createLighthouseClient,
25
+ getClientPackageContract: () => getClientPackageContract,
26
+ getDefaultMetricsDateRange: () => getDefaultMetricsDateRange,
27
+ parseStandaloneDiscoveryContract: () => parseStandaloneDiscoveryContract,
28
+ validateLighthouseConnectivity: () => validateLighthouseConnectivity
29
+ });
30
+ module.exports = __toCommonJS(index_exports);
2
31
  var getClientPackageContract = () => ({
3
32
  name: "@letpeoplework/lighthouse-client",
4
33
  capabilities: [
@@ -284,6 +313,16 @@ var createLighthouseAuthContext = (store) => ({
284
313
  return getStatusFromAuth({ kind: "none" }, "none");
285
314
  }
286
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
+ };
287
326
  var getAuthHeaders = (auth) => {
288
327
  if (auth === void 0 || auth.kind === "none") {
289
328
  return {};
@@ -567,12 +606,101 @@ var createLighthouseClient = (configuration, dependencies = {}) => ({
567
606
  {
568
607
  method: "POST"
569
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 }
570
696
  )
571
697
  });
572
- export {
698
+ // Annotate the CommonJS export names for ESM import in node:
699
+ 0 && (module.exports = {
573
700
  createLighthouseAuthContext,
574
701
  createLighthouseClient,
575
702
  getClientPackageContract,
703
+ getDefaultMetricsDateRange,
576
704
  parseStandaloneDiscoveryContract,
577
705
  validateLighthouseConnectivity
578
- };
706
+ });
@@ -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
@@ -1,32 +1,4 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
1
  // src/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- createLighthouseAuthContext: () => createLighthouseAuthContext,
24
- createLighthouseClient: () => createLighthouseClient,
25
- getClientPackageContract: () => getClientPackageContract,
26
- parseStandaloneDiscoveryContract: () => parseStandaloneDiscoveryContract,
27
- validateLighthouseConnectivity: () => validateLighthouseConnectivity
28
- });
29
- module.exports = __toCommonJS(index_exports);
30
2
  var getClientPackageContract = () => ({
31
3
  name: "@letpeoplework/lighthouse-client",
32
4
  capabilities: [
@@ -312,6 +284,16 @@ var createLighthouseAuthContext = (store) => ({
312
284
  return getStatusFromAuth({ kind: "none" }, "none");
313
285
  }
314
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
+ };
315
297
  var getAuthHeaders = (auth) => {
316
298
  if (auth === void 0 || auth.kind === "none") {
317
299
  return {};
@@ -595,13 +577,100 @@ var createLighthouseClient = (configuration, dependencies = {}) => ({
595
577
  {
596
578
  method: "POST"
597
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 }
598
667
  )
599
668
  });
600
- // Annotate the CommonJS export names for ESM import in node:
601
- 0 && (module.exports = {
669
+ export {
602
670
  createLighthouseAuthContext,
603
671
  createLighthouseClient,
604
672
  getClientPackageContract,
673
+ getDefaultMetricsDateRange,
605
674
  parseStandaloneDiscoveryContract,
606
675
  validateLighthouseConnectivity
607
- });
676
+ };
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@letpeoplework/lighthouse-client",
3
- "version": "0.1.0",
3
+ "version": "0.3.1",
4
4
  "description": "Shared Lighthouse API client contracts",
5
5
  "repository": "https://github.com/LetPeopleWork/lighthouse-clients",
6
+ "type": "module",
6
7
  "main": "dist/index.cjs",
7
8
  "module": "dist/index.js",
8
9
  "types": "dist/index.d.ts",
@@ -17,7 +18,9 @@
17
18
  "dist"
18
19
  ],
19
20
  "publishConfig": {
20
- "access": "public"
21
+ "access": "public",
22
+ "provenance": true,
23
+ "registry": "https://registry.npmjs.org/"
21
24
  },
22
25
  "scripts": {
23
26
  "build": "tsup src/index.ts --format esm,cjs --dts --clean",