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

Function readWantedRowAt

packages/wl-sdk/src/ops/state.ts:57–85  ·  view source on GitHub ↗
(opts: {
  auth: DoltHubAuth;
  owner: string;
  db: string;
  ref?: string;
  wantedId: string;
  fetch?: typeof fetch;
  hooks?: DoltFetchHooks;
})

Source from the content-addressed store, hash-verified

55
56/** Read the full wanted row at a ref. Returns `null` when the row isn't present. */
57export async function readWantedRowAt(opts: {
58 auth: DoltHubAuth;
59 owner: string;
60 db: string;
61 ref?: string;
62 wantedId: string;
63 fetch?: typeof fetch;
64 hooks?: DoltFetchHooks;
65}): Promise<WantedRow | null> {
66 const sql = `SELECT * FROM wanted WHERE id = '${escapeSqlString(opts.wantedId)}' LIMIT 1`;
67 try {
68 const res = await doltRead({
69 auth: opts.auth,
70 owner: opts.owner,
71 db: opts.db,
72 ref: opts.ref,
73 query: sql,
74 fetch: opts.fetch,
75 hooks: opts.hooks,
76 });
77 if (res.rows.length === 0) return null;
78 const parsed = WantedRowSchema.safeParse(res.rows[0]);
79 if (!parsed.success) return null;
80 return parsed.data;
81 } catch (err) {
82 if (err instanceof WlDoltHubError && err.status === 404) return null;
83 throw new WlError(`Read wanted row at ${opts.ref ?? 'main'} failed`, 'upstream', err);
84 }
85}
86
87/**
88 * Compare two wanted rows for "represents the same state on the wanted-board".

Callers 2

applyMutationFunction · 0.90
publishFunction · 0.90

Calls 2

escapeSqlStringFunction · 0.90
doltReadFunction · 0.90

Tested by

no test coverage detected