@letpeoplework/lighthouse-client 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 LetPeopleWork
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,132 @@
1
+ type ClientCapability = "versioned-api-contracts" | "shared-domain-operations" | "connectivity-and-discovery-contracts" | "automation-auth-contracts";
2
+ type ClientPackageContract = {
3
+ readonly name: "@letpeoplework/lighthouse-client";
4
+ readonly capabilities: readonly ClientCapability[];
5
+ };
6
+ declare const getClientPackageContract: () => ClientPackageContract;
7
+ type ConnectivityCategory = "success" | "unreachable" | "misconfigured" | "unauthorized" | "dependency-failure" | "unexpected";
8
+ type StandaloneDiscoveryContract = {
9
+ readonly contractVersion: 1;
10
+ readonly lighthouseUrl: string;
11
+ readonly detectedAtUtc: string;
12
+ };
13
+ type StandaloneDiscoveryContractParseResult = {
14
+ readonly isValid: true;
15
+ readonly contract: StandaloneDiscoveryContract;
16
+ } | {
17
+ readonly isValid: false;
18
+ readonly reason: string;
19
+ };
20
+ type LighthouseConnectionConfiguration = {
21
+ readonly kind: "explicit";
22
+ readonly lighthouseUrl: string;
23
+ } | {
24
+ readonly kind: "standalone";
25
+ readonly getDiscoveryContract: () => Promise<StandaloneDiscoveryContract | null>;
26
+ };
27
+ type ConnectivityFetchResponse = {
28
+ readonly ok: boolean;
29
+ readonly status: number;
30
+ readonly text: () => Promise<string>;
31
+ readonly json?: () => Promise<unknown>;
32
+ };
33
+ type ConnectivityDependencies = {
34
+ readonly fetch: (url: string, init?: RequestInit) => Promise<ConnectivityFetchResponse>;
35
+ };
36
+ type ResolvedLighthouseEndpoint = {
37
+ readonly mode: "explicit" | "standalone";
38
+ readonly lighthouseUrl: string;
39
+ readonly apiBaseUrl: string;
40
+ readonly healthCheckUrl: string;
41
+ };
42
+ type ConnectivityValidationResult = {
43
+ readonly category: "success";
44
+ readonly endpoint: ResolvedLighthouseEndpoint;
45
+ readonly serverVersion: string;
46
+ } | {
47
+ readonly category: Exclude<ConnectivityCategory, "success">;
48
+ readonly reason: string;
49
+ readonly statusCode?: number;
50
+ readonly endpoint?: ResolvedLighthouseEndpoint;
51
+ };
52
+ declare const parseStandaloneDiscoveryContract: (serializedContract: string) => StandaloneDiscoveryContractParseResult;
53
+ declare const validateLighthouseConnectivity: (configuration: LighthouseConnectionConfiguration, dependencies: ConnectivityDependencies, requestInit?: RequestInit) => Promise<ConnectivityValidationResult>;
54
+ type LighthouseClientAuth = {
55
+ readonly kind: "none";
56
+ } | {
57
+ readonly kind: "api-key";
58
+ readonly value: string;
59
+ readonly headerName?: string;
60
+ } | {
61
+ readonly kind: "bearer-token";
62
+ readonly token: string;
63
+ };
64
+ type StoredLighthouseAuth = Exclude<LighthouseClientAuth, {
65
+ kind: "none";
66
+ }>;
67
+ type LighthouseAuthOverrides = {
68
+ readonly apiKey?: string;
69
+ readonly bearerToken?: string;
70
+ readonly apiKeyHeaderName?: string;
71
+ };
72
+ type LighthouseAuthStatus = {
73
+ readonly isAuthenticated: boolean;
74
+ readonly kind: LighthouseClientAuth["kind"];
75
+ readonly source: "none" | "stored" | "override";
76
+ };
77
+ type LighthouseAuthStore = {
78
+ readonly load: () => Promise<StoredLighthouseAuth | null>;
79
+ readonly save: (auth: StoredLighthouseAuth) => Promise<void>;
80
+ readonly clear: () => Promise<void>;
81
+ };
82
+ type LighthouseAuthContext = {
83
+ readonly resolveAuth: (overrides?: LighthouseAuthOverrides) => Promise<LighthouseClientAuth>;
84
+ readonly login: (overrides: LighthouseAuthOverrides) => Promise<void>;
85
+ readonly logout: () => Promise<void>;
86
+ readonly getStatus: (overrides?: LighthouseAuthOverrides) => Promise<LighthouseAuthStatus>;
87
+ };
88
+ declare const createLighthouseAuthContext: (store: LighthouseAuthStore) => LighthouseAuthContext;
89
+ type LighthouseClientConfiguration = {
90
+ readonly connection: LighthouseConnectionConfiguration;
91
+ readonly auth?: LighthouseClientAuth;
92
+ };
93
+ type LighthouseApiError = {
94
+ readonly category: ConnectivityCategory;
95
+ readonly reason: string;
96
+ readonly statusCode?: number;
97
+ };
98
+ type LighthouseApiResult<TValue> = {
99
+ readonly ok: true;
100
+ readonly value: TValue;
101
+ } | {
102
+ readonly ok: false;
103
+ readonly error: LighthouseApiError;
104
+ };
105
+ type LighthouseWritePayload = Readonly<Record<string, unknown>>;
106
+ type LighthouseClient = {
107
+ readonly checkConnectivity: () => Promise<ConnectivityValidationResult>;
108
+ readonly getVersion: () => Promise<LighthouseApiResult<string>>;
109
+ readonly listWorkTrackingConnections: () => Promise<LighthouseApiResult<readonly unknown[]>>;
110
+ readonly getWorkTrackingConnection: (connectionId: number) => Promise<LighthouseApiResult<unknown>>;
111
+ readonly createWorkTrackingConnection: (payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
112
+ readonly updateWorkTrackingConnection: (connectionId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
113
+ readonly deleteWorkTrackingConnection: (connectionId: number) => Promise<LighthouseApiResult<void>>;
114
+ readonly listTeams: () => Promise<LighthouseApiResult<readonly unknown[]>>;
115
+ readonly getTeam: (teamId: number) => Promise<LighthouseApiResult<unknown>>;
116
+ readonly createTeam: (payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
117
+ readonly updateTeam: (teamId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
118
+ readonly deleteTeam: (teamId: number) => Promise<LighthouseApiResult<void>>;
119
+ readonly refreshTeam: (teamId: number) => Promise<LighthouseApiResult<void>>;
120
+ readonly listPortfolios: () => Promise<LighthouseApiResult<readonly unknown[]>>;
121
+ readonly getPortfolio: (portfolioId: number) => Promise<LighthouseApiResult<unknown>>;
122
+ readonly createPortfolio: (payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
123
+ readonly updatePortfolio: (portfolioId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
124
+ readonly deletePortfolio: (portfolioId: number) => Promise<LighthouseApiResult<void>>;
125
+ readonly refreshPortfolio: (portfolioId: number) => Promise<LighthouseApiResult<void>>;
126
+ };
127
+ type LighthouseClientDependencies = {
128
+ readonly fetch?: (url: string, init?: RequestInit) => Promise<ConnectivityFetchResponse>;
129
+ };
130
+ declare const createLighthouseClient: (configuration: LighthouseClientConfiguration, dependencies?: LighthouseClientDependencies) => LighthouseClient;
131
+
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 };
@@ -0,0 +1,132 @@
1
+ type ClientCapability = "versioned-api-contracts" | "shared-domain-operations" | "connectivity-and-discovery-contracts" | "automation-auth-contracts";
2
+ type ClientPackageContract = {
3
+ readonly name: "@letpeoplework/lighthouse-client";
4
+ readonly capabilities: readonly ClientCapability[];
5
+ };
6
+ declare const getClientPackageContract: () => ClientPackageContract;
7
+ type ConnectivityCategory = "success" | "unreachable" | "misconfigured" | "unauthorized" | "dependency-failure" | "unexpected";
8
+ type StandaloneDiscoveryContract = {
9
+ readonly contractVersion: 1;
10
+ readonly lighthouseUrl: string;
11
+ readonly detectedAtUtc: string;
12
+ };
13
+ type StandaloneDiscoveryContractParseResult = {
14
+ readonly isValid: true;
15
+ readonly contract: StandaloneDiscoveryContract;
16
+ } | {
17
+ readonly isValid: false;
18
+ readonly reason: string;
19
+ };
20
+ type LighthouseConnectionConfiguration = {
21
+ readonly kind: "explicit";
22
+ readonly lighthouseUrl: string;
23
+ } | {
24
+ readonly kind: "standalone";
25
+ readonly getDiscoveryContract: () => Promise<StandaloneDiscoveryContract | null>;
26
+ };
27
+ type ConnectivityFetchResponse = {
28
+ readonly ok: boolean;
29
+ readonly status: number;
30
+ readonly text: () => Promise<string>;
31
+ readonly json?: () => Promise<unknown>;
32
+ };
33
+ type ConnectivityDependencies = {
34
+ readonly fetch: (url: string, init?: RequestInit) => Promise<ConnectivityFetchResponse>;
35
+ };
36
+ type ResolvedLighthouseEndpoint = {
37
+ readonly mode: "explicit" | "standalone";
38
+ readonly lighthouseUrl: string;
39
+ readonly apiBaseUrl: string;
40
+ readonly healthCheckUrl: string;
41
+ };
42
+ type ConnectivityValidationResult = {
43
+ readonly category: "success";
44
+ readonly endpoint: ResolvedLighthouseEndpoint;
45
+ readonly serverVersion: string;
46
+ } | {
47
+ readonly category: Exclude<ConnectivityCategory, "success">;
48
+ readonly reason: string;
49
+ readonly statusCode?: number;
50
+ readonly endpoint?: ResolvedLighthouseEndpoint;
51
+ };
52
+ declare const parseStandaloneDiscoveryContract: (serializedContract: string) => StandaloneDiscoveryContractParseResult;
53
+ declare const validateLighthouseConnectivity: (configuration: LighthouseConnectionConfiguration, dependencies: ConnectivityDependencies, requestInit?: RequestInit) => Promise<ConnectivityValidationResult>;
54
+ type LighthouseClientAuth = {
55
+ readonly kind: "none";
56
+ } | {
57
+ readonly kind: "api-key";
58
+ readonly value: string;
59
+ readonly headerName?: string;
60
+ } | {
61
+ readonly kind: "bearer-token";
62
+ readonly token: string;
63
+ };
64
+ type StoredLighthouseAuth = Exclude<LighthouseClientAuth, {
65
+ kind: "none";
66
+ }>;
67
+ type LighthouseAuthOverrides = {
68
+ readonly apiKey?: string;
69
+ readonly bearerToken?: string;
70
+ readonly apiKeyHeaderName?: string;
71
+ };
72
+ type LighthouseAuthStatus = {
73
+ readonly isAuthenticated: boolean;
74
+ readonly kind: LighthouseClientAuth["kind"];
75
+ readonly source: "none" | "stored" | "override";
76
+ };
77
+ type LighthouseAuthStore = {
78
+ readonly load: () => Promise<StoredLighthouseAuth | null>;
79
+ readonly save: (auth: StoredLighthouseAuth) => Promise<void>;
80
+ readonly clear: () => Promise<void>;
81
+ };
82
+ type LighthouseAuthContext = {
83
+ readonly resolveAuth: (overrides?: LighthouseAuthOverrides) => Promise<LighthouseClientAuth>;
84
+ readonly login: (overrides: LighthouseAuthOverrides) => Promise<void>;
85
+ readonly logout: () => Promise<void>;
86
+ readonly getStatus: (overrides?: LighthouseAuthOverrides) => Promise<LighthouseAuthStatus>;
87
+ };
88
+ declare const createLighthouseAuthContext: (store: LighthouseAuthStore) => LighthouseAuthContext;
89
+ type LighthouseClientConfiguration = {
90
+ readonly connection: LighthouseConnectionConfiguration;
91
+ readonly auth?: LighthouseClientAuth;
92
+ };
93
+ type LighthouseApiError = {
94
+ readonly category: ConnectivityCategory;
95
+ readonly reason: string;
96
+ readonly statusCode?: number;
97
+ };
98
+ type LighthouseApiResult<TValue> = {
99
+ readonly ok: true;
100
+ readonly value: TValue;
101
+ } | {
102
+ readonly ok: false;
103
+ readonly error: LighthouseApiError;
104
+ };
105
+ type LighthouseWritePayload = Readonly<Record<string, unknown>>;
106
+ type LighthouseClient = {
107
+ readonly checkConnectivity: () => Promise<ConnectivityValidationResult>;
108
+ readonly getVersion: () => Promise<LighthouseApiResult<string>>;
109
+ readonly listWorkTrackingConnections: () => Promise<LighthouseApiResult<readonly unknown[]>>;
110
+ readonly getWorkTrackingConnection: (connectionId: number) => Promise<LighthouseApiResult<unknown>>;
111
+ readonly createWorkTrackingConnection: (payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
112
+ readonly updateWorkTrackingConnection: (connectionId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
113
+ readonly deleteWorkTrackingConnection: (connectionId: number) => Promise<LighthouseApiResult<void>>;
114
+ readonly listTeams: () => Promise<LighthouseApiResult<readonly unknown[]>>;
115
+ readonly getTeam: (teamId: number) => Promise<LighthouseApiResult<unknown>>;
116
+ readonly createTeam: (payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
117
+ readonly updateTeam: (teamId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
118
+ readonly deleteTeam: (teamId: number) => Promise<LighthouseApiResult<void>>;
119
+ readonly refreshTeam: (teamId: number) => Promise<LighthouseApiResult<void>>;
120
+ readonly listPortfolios: () => Promise<LighthouseApiResult<readonly unknown[]>>;
121
+ readonly getPortfolio: (portfolioId: number) => Promise<LighthouseApiResult<unknown>>;
122
+ readonly createPortfolio: (payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
123
+ readonly updatePortfolio: (portfolioId: number, payload: LighthouseWritePayload) => Promise<LighthouseApiResult<unknown>>;
124
+ readonly deletePortfolio: (portfolioId: number) => Promise<LighthouseApiResult<void>>;
125
+ readonly refreshPortfolio: (portfolioId: number) => Promise<LighthouseApiResult<void>>;
126
+ };
127
+ type LighthouseClientDependencies = {
128
+ readonly fetch?: (url: string, init?: RequestInit) => Promise<ConnectivityFetchResponse>;
129
+ };
130
+ declare const createLighthouseClient: (configuration: LighthouseClientConfiguration, dependencies?: LighthouseClientDependencies) => LighthouseClient;
131
+
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 };