MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / invokeWithClient

Method invokeWithClient

packages/orm/src/client/client-impl.ts:340–366  ·  view source on GitHub ↗
(client: any, _input: unknown)

Source from the content-addressed store, hash-verified

338 const handler = procOptions[name] as Function;
339
340 const invokeWithClient = async (client: any, _input: unknown) => {
341 let proceed = async (nextInput: unknown) => {
342 const sanitizedNextInput =
343 nextInput && typeof nextInput === 'object' && !Array.isArray(nextInput) ? nextInput : {};
344
345 return handler({ client, ...sanitizedNextInput });
346 };
347
348 // apply plugins
349 const plugins = [...(client.$options?.plugins ?? [])];
350 for (const plugin of plugins) {
351 const onProcedure = plugin.onProcedure;
352 if (onProcedure) {
353 const _proceed = proceed;
354 proceed = (nextInput: unknown) =>
355 onProcedure({
356 client,
357 name,
358 mutation: !!procDef.mutation,
359 input: nextInput,
360 proceed: (finalInput: unknown) => _proceed(finalInput),
361 }) as Promise<unknown>;
362 }
363 }
364
365 return proceed(_input);
366 };
367
368 return invokeWithClient(this as any, validatedInput);
369 }

Callers

nothing calls this directly

Calls 1

proceedFunction · 0.85

Tested by

no test coverage detected