@letpeoplework/lighthouse-client 0.6.0 → 0.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
@@ -24,6 +24,8 @@ __export(index_exports, {
24
24
  createLighthouseClient: () => createLighthouseClient,
25
25
  getClientPackageContract: () => getClientPackageContract,
26
26
  getDefaultMetricsDateRange: () => getDefaultMetricsDateRange,
27
+ getStandaloneDiscoveryLockfilePath: () => getStandaloneDiscoveryLockfilePath,
28
+ loadStandaloneDiscoveryContract: () => loadStandaloneDiscoveryContract,
27
29
  parseStandaloneDiscoveryContract: () => parseStandaloneDiscoveryContract,
28
30
  pollCliAuthSession: () => pollCliAuthSession,
29
31
  queryServerAuthMode: () => queryServerAuthMode,
@@ -31,6 +33,9 @@ __export(index_exports, {
31
33
  validateLighthouseConnectivity: () => validateLighthouseConnectivity
32
34
  });
33
35
  module.exports = __toCommonJS(index_exports);
36
+ var import_promises = require("fs/promises");
37
+ var import_node_os = require("os");
38
+ var import_node_path = require("path");
34
39
  var getClientPackageContract = () => ({
35
40
  name: "@letpeoplework/lighthouse-client",
36
41
  capabilities: [
@@ -41,6 +46,7 @@ var getClientPackageContract = () => ({
41
46
  ]
42
47
  });
43
48
  var SUPPORTED_DISCOVERY_CONTRACT_VERSION = 1;
49
+ var STANDALONE_DISCOVERY_LOCKFILE_NAME = "standalone.lock.json";
44
50
  var isObjectRecord = (value) => {
45
51
  return typeof value === "object" && value !== null && !Array.isArray(value);
46
52
  };
@@ -155,6 +161,47 @@ var parseStandaloneDiscoveryContract = (serializedContract) => {
155
161
  detectedAtUtc
156
162
  });
157
163
  };
164
+ var getStandaloneDiscoveryLockfilePath = () => {
165
+ if (process.env.LIGHTHOUSE_STANDALONE_LOCKFILE_PATH !== void 0) {
166
+ return process.env.LIGHTHOUSE_STANDALONE_LOCKFILE_PATH;
167
+ }
168
+ if (process.platform === "darwin") {
169
+ return (0, import_node_path.join)(
170
+ (0, import_node_os.homedir)(),
171
+ "Library",
172
+ "Application Support",
173
+ "Lighthouse",
174
+ STANDALONE_DISCOVERY_LOCKFILE_NAME
175
+ );
176
+ }
177
+ if (process.platform === "win32") {
178
+ return (0, import_node_path.join)(
179
+ process.env.APPDATA ?? (0, import_node_path.join)((0, import_node_os.homedir)(), "AppData", "Roaming"),
180
+ "Lighthouse",
181
+ STANDALONE_DISCOVERY_LOCKFILE_NAME
182
+ );
183
+ }
184
+ return (0, import_node_path.join)(
185
+ process.env.XDG_CONFIG_HOME ?? (0, import_node_path.join)((0, import_node_os.homedir)(), ".config"),
186
+ "Lighthouse",
187
+ STANDALONE_DISCOVERY_LOCKFILE_NAME
188
+ );
189
+ };
190
+ var loadStandaloneDiscoveryContract = async () => {
191
+ try {
192
+ const serializedContract = await (0, import_promises.readFile)(
193
+ getStandaloneDiscoveryLockfilePath(),
194
+ "utf8"
195
+ );
196
+ const parsedContract = parseStandaloneDiscoveryContract(serializedContract);
197
+ if (!parsedContract.isValid) {
198
+ return null;
199
+ }
200
+ return parsedContract.contract;
201
+ } catch {
202
+ return null;
203
+ }
204
+ };
158
205
  var getResolvedEndpoint = (mode, lighthouseUrl) => {
159
206
  const apiBaseUrl = getApiBaseUrl(lighthouseUrl);
160
207
  return {
@@ -841,12 +888,12 @@ var createLighthouseClient = (configuration, dependencies = {}) => ({
841
888
  `/v1/teams/${teamId}/metrics/totalWorkItemAge?${getMetricsAsOfDateQuery(asOfDate)}`,
842
889
  { method: "GET" }
843
890
  ),
844
- getTeamTotalWorkItemAgePbc: async (teamId, range) => {
891
+ getTeamTotalWorkItemAgeInfo: async (teamId, range) => {
845
892
  const r = getResolvedMetricsDateRange(range);
846
893
  return requestJson(
847
894
  configuration,
848
895
  dependencies,
849
- `/v1/teams/${teamId}/metrics/totalWorkItemAge/pbc?${getMetricsDateRangeQuery(r)}`,
896
+ `/v1/teams/${teamId}/metrics/totalWorkItemAgeInfo?${getMetricsDateRangeQuery(r)}`,
850
897
  { method: "GET" }
851
898
  );
852
899
  },
@@ -916,12 +963,12 @@ var createLighthouseClient = (configuration, dependencies = {}) => ({
916
963
  `/v1/portfolios/${portfolioId}/metrics/totalWorkItemAge?${getMetricsAsOfDateQuery(asOfDate)}`,
917
964
  { method: "GET" }
918
965
  ),
919
- getPortfolioTotalWorkItemAgePbc: async (portfolioId, range) => {
966
+ getPortfolioTotalWorkItemAgeInfo: async (portfolioId, range) => {
920
967
  const r = getResolvedMetricsDateRange(range);
921
968
  return requestJson(
922
969
  configuration,
923
970
  dependencies,
924
- `/v1/portfolios/${portfolioId}/metrics/totalWorkItemAge/pbc?${getMetricsDateRangeQuery(r)}`,
971
+ `/v1/portfolios/${portfolioId}/metrics/totalWorkItemAgeInfo?${getMetricsDateRangeQuery(r)}`,
925
972
  { method: "GET" }
926
973
  );
927
974
  },
@@ -992,6 +1039,8 @@ var createLighthouseClient = (configuration, dependencies = {}) => ({
992
1039
  createLighthouseClient,
993
1040
  getClientPackageContract,
994
1041
  getDefaultMetricsDateRange,
1042
+ getStandaloneDiscoveryLockfilePath,
1043
+ loadStandaloneDiscoveryContract,
995
1044
  parseStandaloneDiscoveryContract,
996
1045
  pollCliAuthSession,
997
1046
  queryServerAuthMode,
package/dist/index.d.cts CHANGED
@@ -50,6 +50,8 @@ type ConnectivityValidationResult = {
50
50
  readonly endpoint?: ResolvedLighthouseEndpoint;
51
51
  };
52
52
  declare const parseStandaloneDiscoveryContract: (serializedContract: string) => StandaloneDiscoveryContractParseResult;
53
+ declare const getStandaloneDiscoveryLockfilePath: () => string;
54
+ declare const loadStandaloneDiscoveryContract: () => Promise<StandaloneDiscoveryContract | null>;
53
55
  declare const validateLighthouseConnectivity: (configuration: LighthouseConnectionConfiguration, dependencies: ConnectivityDependencies, requestInit?: RequestInit) => Promise<ConnectivityValidationResult>;
54
56
  type LighthouseClientAuth = {
55
57
  readonly kind: "none";
@@ -195,7 +197,7 @@ type LighthouseClient = {
195
197
  readonly getTeamCycleTimeData: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly unknown[]>>;
196
198
  readonly getTeamPredictabilityScore: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
197
199
  readonly getTeamTotalWorkItemAge: (teamId: number, asOfDate: string) => Promise<LighthouseApiResult<number>>;
198
- readonly getTeamTotalWorkItemAgePbc: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
200
+ readonly getTeamTotalWorkItemAgeInfo: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
199
201
  readonly getPortfolioThroughput: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
200
202
  readonly getPortfolioCycleTimePercentiles: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly unknown[]>>;
201
203
  readonly getPortfolioArrivals: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
@@ -204,7 +206,7 @@ type LighthouseClient = {
204
206
  readonly getPortfolioCycleTimeData: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly unknown[]>>;
205
207
  readonly getPortfolioPredictabilityScore: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
206
208
  readonly getPortfolioTotalWorkItemAge: (portfolioId: number, asOfDate: string) => Promise<LighthouseApiResult<number>>;
207
- readonly getPortfolioTotalWorkItemAgePbc: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
209
+ readonly getPortfolioTotalWorkItemAgeInfo: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
208
210
  readonly getFeaturesByIds: (ids: readonly number[]) => Promise<LighthouseApiResult<readonly unknown[]>>;
209
211
  readonly getFeaturesByReferences: (refs: readonly string[]) => Promise<LighthouseApiResult<readonly unknown[]>>;
210
212
  readonly getFeatureWorkItems: (featureId: number) => Promise<LighthouseApiResult<readonly unknown[]>>;
@@ -220,4 +222,4 @@ type LighthouseClientDependencies = {
220
222
  };
221
223
  declare const createLighthouseClient: (configuration: LighthouseClientConfiguration, dependencies?: LighthouseClientDependencies) => LighthouseClient;
222
224
 
223
- export { type BacktestInput, 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 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 ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, validateLighthouseConnectivity };
225
+ export { type BacktestInput, 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 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 ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, getStandaloneDiscoveryLockfilePath, loadStandaloneDiscoveryContract, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, validateLighthouseConnectivity };
package/dist/index.d.ts CHANGED
@@ -50,6 +50,8 @@ type ConnectivityValidationResult = {
50
50
  readonly endpoint?: ResolvedLighthouseEndpoint;
51
51
  };
52
52
  declare const parseStandaloneDiscoveryContract: (serializedContract: string) => StandaloneDiscoveryContractParseResult;
53
+ declare const getStandaloneDiscoveryLockfilePath: () => string;
54
+ declare const loadStandaloneDiscoveryContract: () => Promise<StandaloneDiscoveryContract | null>;
53
55
  declare const validateLighthouseConnectivity: (configuration: LighthouseConnectionConfiguration, dependencies: ConnectivityDependencies, requestInit?: RequestInit) => Promise<ConnectivityValidationResult>;
54
56
  type LighthouseClientAuth = {
55
57
  readonly kind: "none";
@@ -195,7 +197,7 @@ type LighthouseClient = {
195
197
  readonly getTeamCycleTimeData: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly unknown[]>>;
196
198
  readonly getTeamPredictabilityScore: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
197
199
  readonly getTeamTotalWorkItemAge: (teamId: number, asOfDate: string) => Promise<LighthouseApiResult<number>>;
198
- readonly getTeamTotalWorkItemAgePbc: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
200
+ readonly getTeamTotalWorkItemAgeInfo: (teamId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
199
201
  readonly getPortfolioThroughput: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
200
202
  readonly getPortfolioCycleTimePercentiles: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly unknown[]>>;
201
203
  readonly getPortfolioArrivals: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
@@ -204,7 +206,7 @@ type LighthouseClient = {
204
206
  readonly getPortfolioCycleTimeData: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<readonly unknown[]>>;
205
207
  readonly getPortfolioPredictabilityScore: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
206
208
  readonly getPortfolioTotalWorkItemAge: (portfolioId: number, asOfDate: string) => Promise<LighthouseApiResult<number>>;
207
- readonly getPortfolioTotalWorkItemAgePbc: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
209
+ readonly getPortfolioTotalWorkItemAgeInfo: (portfolioId: number, range?: MetricsDateRange) => Promise<LighthouseApiResult<unknown>>;
208
210
  readonly getFeaturesByIds: (ids: readonly number[]) => Promise<LighthouseApiResult<readonly unknown[]>>;
209
211
  readonly getFeaturesByReferences: (refs: readonly string[]) => Promise<LighthouseApiResult<readonly unknown[]>>;
210
212
  readonly getFeatureWorkItems: (featureId: number) => Promise<LighthouseApiResult<readonly unknown[]>>;
@@ -220,4 +222,4 @@ type LighthouseClientDependencies = {
220
222
  };
221
223
  declare const createLighthouseClient: (configuration: LighthouseClientConfiguration, dependencies?: LighthouseClientDependencies) => LighthouseClient;
222
224
 
223
- export { type BacktestInput, 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 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 ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, validateLighthouseConnectivity };
225
+ export { type BacktestInput, 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 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 ServerAuthModeResult, type StandaloneDiscoveryContract, type StandaloneDiscoveryContractParseResult, type StoredLighthouseAuth, createLighthouseAuthContext, createLighthouseClient, getClientPackageContract, getDefaultMetricsDateRange, getStandaloneDiscoveryLockfilePath, loadStandaloneDiscoveryContract, parseStandaloneDiscoveryContract, pollCliAuthSession, queryServerAuthMode, startCliAuthSession, validateLighthouseConnectivity };
package/dist/index.js CHANGED
@@ -1,4 +1,7 @@
1
1
  // src/index.ts
2
+ import { readFile } from "fs/promises";
3
+ import { homedir } from "os";
4
+ import { join } from "path";
2
5
  var getClientPackageContract = () => ({
3
6
  name: "@letpeoplework/lighthouse-client",
4
7
  capabilities: [
@@ -9,6 +12,7 @@ var getClientPackageContract = () => ({
9
12
  ]
10
13
  });
11
14
  var SUPPORTED_DISCOVERY_CONTRACT_VERSION = 1;
15
+ var STANDALONE_DISCOVERY_LOCKFILE_NAME = "standalone.lock.json";
12
16
  var isObjectRecord = (value) => {
13
17
  return typeof value === "object" && value !== null && !Array.isArray(value);
14
18
  };
@@ -123,6 +127,47 @@ var parseStandaloneDiscoveryContract = (serializedContract) => {
123
127
  detectedAtUtc
124
128
  });
125
129
  };
130
+ var getStandaloneDiscoveryLockfilePath = () => {
131
+ if (process.env.LIGHTHOUSE_STANDALONE_LOCKFILE_PATH !== void 0) {
132
+ return process.env.LIGHTHOUSE_STANDALONE_LOCKFILE_PATH;
133
+ }
134
+ if (process.platform === "darwin") {
135
+ return join(
136
+ homedir(),
137
+ "Library",
138
+ "Application Support",
139
+ "Lighthouse",
140
+ STANDALONE_DISCOVERY_LOCKFILE_NAME
141
+ );
142
+ }
143
+ if (process.platform === "win32") {
144
+ return join(
145
+ process.env.APPDATA ?? join(homedir(), "AppData", "Roaming"),
146
+ "Lighthouse",
147
+ STANDALONE_DISCOVERY_LOCKFILE_NAME
148
+ );
149
+ }
150
+ return join(
151
+ process.env.XDG_CONFIG_HOME ?? join(homedir(), ".config"),
152
+ "Lighthouse",
153
+ STANDALONE_DISCOVERY_LOCKFILE_NAME
154
+ );
155
+ };
156
+ var loadStandaloneDiscoveryContract = async () => {
157
+ try {
158
+ const serializedContract = await readFile(
159
+ getStandaloneDiscoveryLockfilePath(),
160
+ "utf8"
161
+ );
162
+ const parsedContract = parseStandaloneDiscoveryContract(serializedContract);
163
+ if (!parsedContract.isValid) {
164
+ return null;
165
+ }
166
+ return parsedContract.contract;
167
+ } catch {
168
+ return null;
169
+ }
170
+ };
126
171
  var getResolvedEndpoint = (mode, lighthouseUrl) => {
127
172
  const apiBaseUrl = getApiBaseUrl(lighthouseUrl);
128
173
  return {
@@ -809,12 +854,12 @@ var createLighthouseClient = (configuration, dependencies = {}) => ({
809
854
  `/v1/teams/${teamId}/metrics/totalWorkItemAge?${getMetricsAsOfDateQuery(asOfDate)}`,
810
855
  { method: "GET" }
811
856
  ),
812
- getTeamTotalWorkItemAgePbc: async (teamId, range) => {
857
+ getTeamTotalWorkItemAgeInfo: async (teamId, range) => {
813
858
  const r = getResolvedMetricsDateRange(range);
814
859
  return requestJson(
815
860
  configuration,
816
861
  dependencies,
817
- `/v1/teams/${teamId}/metrics/totalWorkItemAge/pbc?${getMetricsDateRangeQuery(r)}`,
862
+ `/v1/teams/${teamId}/metrics/totalWorkItemAgeInfo?${getMetricsDateRangeQuery(r)}`,
818
863
  { method: "GET" }
819
864
  );
820
865
  },
@@ -884,12 +929,12 @@ var createLighthouseClient = (configuration, dependencies = {}) => ({
884
929
  `/v1/portfolios/${portfolioId}/metrics/totalWorkItemAge?${getMetricsAsOfDateQuery(asOfDate)}`,
885
930
  { method: "GET" }
886
931
  ),
887
- getPortfolioTotalWorkItemAgePbc: async (portfolioId, range) => {
932
+ getPortfolioTotalWorkItemAgeInfo: async (portfolioId, range) => {
888
933
  const r = getResolvedMetricsDateRange(range);
889
934
  return requestJson(
890
935
  configuration,
891
936
  dependencies,
892
- `/v1/portfolios/${portfolioId}/metrics/totalWorkItemAge/pbc?${getMetricsDateRangeQuery(r)}`,
937
+ `/v1/portfolios/${portfolioId}/metrics/totalWorkItemAgeInfo?${getMetricsDateRangeQuery(r)}`,
893
938
  { method: "GET" }
894
939
  );
895
940
  },
@@ -959,6 +1004,8 @@ export {
959
1004
  createLighthouseClient,
960
1005
  getClientPackageContract,
961
1006
  getDefaultMetricsDateRange,
1007
+ getStandaloneDiscoveryLockfilePath,
1008
+ loadStandaloneDiscoveryContract,
962
1009
  parseStandaloneDiscoveryContract,
963
1010
  pollCliAuthSession,
964
1011
  queryServerAuthMode,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letpeoplework/lighthouse-client",
3
- "version": "0.6.0",
3
+ "version": "0.8.0",
4
4
  "description": "Shared Lighthouse API client contracts",
5
5
  "repository": "https://github.com/LetPeopleWork/lighthouse-clients",
6
6
  "type": "module",