MCPcopy
hub / github.com/cita-777/metapi / get

Function get

src/server/db/index.ts:1275–1307  ·  view source on GitHub ↗
(innerTarget, prop, receiver)

Source from the content-addressed store, hash-verified

1273
1274 const proxy = new Proxy(target as Record<string, unknown>, {
1275 get(innerTarget, prop, receiver) {
1276 if (prop === 'then' && typeof innerTarget.then === 'function') {
1277 return innerTarget.then.bind(innerTarget);
1278 }
1279
1280 if (prop === 'all' && typeof innerTarget.all !== 'function' && typeof innerTarget.execute === 'function') {
1281 return async (...args: unknown[]) => normalizeAllResult(await (innerTarget.execute as (...a: unknown[]) => Promise<unknown>)(...args));
1282 }
1283
1284 if (prop === 'get' && typeof innerTarget.get !== 'function' && typeof innerTarget.execute === 'function') {
1285 return async (...args: unknown[]) => {
1286 const rows = normalizeAllResult(await (innerTarget.execute as (...a: unknown[]) => Promise<unknown>)(...args));
1287 return rows[0] ?? undefined;
1288 };
1289 }
1290
1291 if (prop === 'run' && typeof innerTarget.run !== 'function' && typeof innerTarget.execute === 'function') {
1292 return async (...args: unknown[]) => normalizeRunResult(await (innerTarget.execute as (...a: unknown[]) => Promise<unknown>)(...args));
1293 }
1294
1295 const original = Reflect.get(innerTarget, prop, receiver);
1296 if (typeof original !== 'function') {
1297 return original;
1298 }
1299
1300 return (...args: unknown[]) => {
1301 const result = original.apply(innerTarget, args);
1302 if (shouldWrapObject(result)) {
1303 return wrapQueryLike(result);
1304 }
1305 return result;
1306 };
1307 },
1308 });
1309
1310 wrappedObjects.set(target, proxy);

Callers

nothing calls this directly

Calls 6

normalizeAllResultFunction · 0.85
normalizeRunResultFunction · 0.85
shouldWrapObjectFunction · 0.85
wrapQueryLikeFunction · 0.85
wrapDbClientFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected