CustomCtx + ents not inferring wrapper for custom ctx.runMutations()
I'm a little lost.
I took my code from the action session wrapping for doing custom ctx.runMutation() and tried to do that since we now have ctx.runMutation available in mutations.
Goal
customMutation
withTriggerCtx doesn't throw (avoiding the ent wrapper)
but newCtx gets errors: tried casting it to several things
places i use
i get
I took my code from the action session wrapping for doing custom ctx.runMutation() and tried to do that since we now have ctx.runMutation available in mutations.
Goal
export const replayInputRaw = sessionMutation({
args: {
input: v.any(),
eventType: vEventType,
},
handler: async (ctx, args) => {
const fnRef = makeEventFunctionRef(args.eventType)
const returnValue = await ctx.runSessionMutation(fnRef, {
//sessionId: args.sessionId, <-- gets included
...args.input,
})
return returnValue
},
})export const replayInputRaw = sessionMutation({
args: {
input: v.any(),
eventType: vEventType,
},
handler: async (ctx, args) => {
const fnRef = makeEventFunctionRef(args.eventType)
const returnValue = await ctx.runSessionMutation(fnRef, {
//sessionId: args.sessionId, <-- gets included
...args.input,
})
return returnValue
},
})customMutation
withTriggerCtx doesn't throw (avoiding the ent wrapper)
but newCtx gets errors: tried casting it to several things
export const sessionMutation = customMutation(rawMutation, {
args: { sessionId: v.optional(v.union(v.string(), v.null())) },
input: async (baseCtx, { sessionId }) => {
const withTriggersCtx = await triggers.wrapDB(baseCtx)
const newCtx = await mutationCtx(withTriggersCtx, sessionId)
return {
ctx: {
...newCtx,
...runSessionMutationFunctions(withTriggersCtx, sessionId),
},
args: { sessionId },
}
},
})export const sessionMutation = customMutation(rawMutation, {
args: { sessionId: v.optional(v.union(v.string(), v.null())) },
input: async (baseCtx, { sessionId }) => {
const withTriggersCtx = await triggers.wrapDB(baseCtx)
const newCtx = await mutationCtx(withTriggersCtx, sessionId)
return {
ctx: {
...newCtx,
...runSessionMutationFunctions(withTriggersCtx, sessionId),
},
args: { sessionId },
}
},
})places i use
export type SessionMutationCtx = CustomCtx<typeof sessionMutation>export type SessionMutationCtx = CustomCtx<typeof sessionMutation>i get
const newEvent = await tsCall(ctx, {
Type 'Omit<GenericMutationCtx<{ engines: { document: { _id: Id<"engines">; _creationTime: number; currentTime?: number | undefined; lastStepTs?: number | undefined; processedTime?: number | undefined; sphereId: string; running: boolean; generationNumber: number; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { .....' runSessionMutationts(2345)
is missing the following properties from type :
'{ runSessionQuery<Query extends SessionFunctionMutation<"query">>(query: Query, ...args: SessionArgsArrayMutation<Query>): Promise<FunctionReturnType<Query>>; ... 14 more ...; skipRules: { ...; }; }':
:
runSessionQuery
runSessionMutation const newEvent = await tsCall(ctx, {
Type 'Omit<GenericMutationCtx<{ engines: { document: { _id: Id<"engines">; _creationTime: number; currentTime?: number | undefined; lastStepTs?: number | undefined; processedTime?: number | undefined; sphereId: string; running: boolean; generationNumber: number; }; fieldPaths: ExtractFieldPaths<...> | "_id"; indexes: { .....' runSessionMutationts(2345)
is missing the following properties from type :
'{ runSessionQuery<Query extends SessionFunctionMutation<"query">>(query: Query, ...args: SessionArgsArrayMutation<Query>): Promise<FunctionReturnType<Query>>; ... 14 more ...; skipRules: { ...; }; }':
:
runSessionQuery
runSessionMutation