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

Function makeDb

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

Source from the content-addressed store, hash-verified

68 ]);
69
70 const makeDb = (context?: ExecutorOwnerPolicyContext): FumaDb =>
71 new Proxy(
72 { internal: context === undefined ? internal : { ...internal, context } },
73 {
74 get(target, prop) {
75 if (prop === "internal") return target.internal;
76 if (prop === "withContext") {
77 return (nextContext: ExecutorOwnerPolicyContext) => makeDb(nextContext);
78 }
79 if (!queryMethods.has(prop)) return undefined;
80
81 return async (...args: unknown[]) => {
82 const actual = await start();
83 const actualDb =
84 context === undefined ? actual.db : withQueryContext(actual.db, context);
85 const method = Reflect.get(actualDb, prop) as (...innerArgs: unknown[]) => unknown;
86 return method.apply(actualDb, args);
87 };
88 },
89 },
90 ) as FumaDb;
91
92 const db = makeDb();
93

Callers 2

getFunction · 0.85
makeLazyTestFumaDbFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected