MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / makeDb

Function makeDb

packages/core/sdk/src/test-config.ts:79–99  ·  view source on GitHub ↗
(context?: ExecutorOwnerPolicyContext)

Source from the content-addressed store, hash-verified

77 ]);
78
79 const makeDb = (context?: ExecutorOwnerPolicyContext): FumaDb =>
80 new Proxy(
81 { internal: context === undefined ? internal : { ...internal, context } },
82 {
83 get(target, prop) {
84 if (prop === "internal") return target.internal;
85 if (prop === "withContext") {
86 return (nextContext: ExecutorOwnerPolicyContext) => makeDb(nextContext);
87 }
88 if (!queryMethods.has(prop)) return undefined;
89
90 return async (...args: unknown[]) => {
91 const actual = await start();
92 const actualDb =
93 context === undefined ? actual.db : withQueryContext(actual.db, context);
94 const method = Reflect.get(actualDb, prop) as (...innerArgs: unknown[]) => unknown;
95 return method.apply(actualDb, args);
96 };
97 },
98 },
99 ) as FumaDb;
100
101 const db = makeDb();
102

Callers 2

getFunction · 0.70
makeLazyTestFumaDbFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected