19 lines
983 B
TypeScript
19 lines
983 B
TypeScript
// 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),
|
|
)
|