This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
// SPDX-License-Identifier: LicenseRef-ConusAI-Template-1.0
|
||||
// The tenant function builders the generated wrappers are built with (spec §5.4: convex-helpers
|
||||
// custom functions + the repository predicate are the tenant wall). Each adds `ctx.run`, which
|
||||
// runs a procedure of the registry inside this function's transaction (lib/runtime.ts) or, in an
|
||||
// action, an effect procedure through the action composition (lib/effects.ts).
|
||||
|
||||
import { makeTenantFunctions } from "@conusai-kit/data-convex/runtime"
|
||||
import { action, mutation, query } from "../_generated/server"
|
||||
import { callEffectProcedure, type EffectActionCtx } from "./effects"
|
||||
import { callProcedure } from "./runtime"
|
||||
|
||||
export const { tenantQuery, tenantMutation, tenantAction } = makeTenantFunctions(
|
||||
{ query, mutation, action },
|
||||
(ctx) => (name, input, options) =>
|
||||
"db" in ctx
|
||||
? callProcedure(ctx, name, input, options)
|
||||
: callEffectProcedure(ctx as unknown as EffectActionCtx, name, input, options),
|
||||
)
|
||||
Reference in New Issue
Block a user