MCPcopy Create free account
hub / github.com/Kilo-Org/cloud / WlClient

Class WlClient

packages/wl-sdk/src/client.ts:157–396  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155}
156
157export class WlClient {
158 readonly #config: WlClientConfig;
159 readonly #upstream: { owner: string; db: string };
160 readonly #fork: { forkOwner: string; forkDb: string };
161 readonly #auth: DoltHubAuth;
162 readonly #hooks: DoltFetchHooks;
163
164 constructor(config: WlClientConfig) {
165 if (!config.upstream) throw new WlError('WlClient: upstream is required', 'internal');
166 if (!config.forkOrg) throw new WlError('WlClient: forkOrg is required', 'internal');
167 if (!config.rigHandle) throw new WlError('WlClient: rigHandle is required', 'internal');
168 if (!config.token) throw new WlError('WlClient: token is required', 'internal');
169
170 this.#config = config;
171 this.#upstream = parseUpstreamRef(config.upstream);
172 this.#fork = { forkOwner: config.forkOrg, forkDb: this.#upstream.db };
173 this.#auth = { token: config.token };
174 this.#hooks = {
175 onRequest: config.onRequest,
176 onError: info => config.onError?.(info),
177 };
178 }
179
180 /** The parsed `{ owner, db }` of the upstream wasteland. */
181 get upstream(): { owner: string; db: string } {
182 return this.#upstream;
183 }
184
185 /** The parsed `{ forkOwner, forkDb }` for the caller's fork. */
186 get fork(): { forkOwner: string; forkDb: string } {
187 return this.#fork;
188 }
189
190 /** The configured rig handle. */
191 get rigHandle(): string {
192 return this.#config.rigHandle;
193 }
194
195 #ctx(): MutationContext {
196 return {
197 auth: this.#auth,
198 upstream: this.#upstream,
199 fork: this.#fork,
200 rigHandle: this.#config.rigHandle,
201 fetch: this.#config.fetch,
202 now: this.#config.now,
203 hooks: this.#hooks,
204 };
205 }
206
207 // ── Lifecycle ──────────────────────────────────────────────────
208
209 async join(input: JoinInput): Promise<JoinResult> {
210 return unwrap(
211 await join({
212 auth: this.#auth,
213 upstream: this.#upstream,
214 dolthubOrg: this.#config.forkOrg,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected