@letpeoplework/lighthouse-client 0.7.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 +49 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +47 -0
- package/package.json +1 -1
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 {
|
|
@@ -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";
|
|
@@ -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";
|
|
@@ -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 {
|
|
@@ -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