cvx-kit 0.1.23 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -5
- package/dist/auth.d.mts +6 -2
- package/dist/auth.mjs +1 -1
- package/dist/auth.mjs.map +1 -1
- package/dist/querying/planner.d.mts +18 -1
- package/dist/querying/planner.mjs +1 -1
- package/dist/querying/planner.mjs.map +1 -1
- package/dist/querying/relationships.mjs +1 -1
- package/dist/querying/relationships.mjs.map +1 -1
- package/dist/querying/schema-snapshot.d.mts +18 -0
- package/dist/querying/schema-snapshot.mjs +1 -1
- package/dist/querying/schema-snapshot.mjs.map +1 -1
- package/dist/querying/shared/filters.d.mts +7 -0
- package/dist/querying/shared/filters.mjs +1 -1
- package/dist/querying/shared/filters.mjs.map +1 -1
- package/dist/querying.mjs +1 -1
- package/dist/querying.mjs.map +1 -1
- package/dist/relations-public.d.mts +2 -2
- package/dist/relations-public.mjs +1 -1
- package/dist/relations.d.mts +9 -2
- package/dist/relations.mjs +1 -1
- package/dist/relations.mjs.map +1 -1
- package/dist/zod-registration.mjs +1 -1
- package/dist/zod-registration.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{zodToConvex as e}from"./zod-convex.mjs";import{compactArgumentBoundary as t}from"./querying/filter-boundary.mjs";import{zodOutputToConvex as n}from"convex-helpers/server/zod4";import{ConvexError as r}from"convex/values";import{pick as i}from"convex-helpers";import{NoOp as a}from"convex-helpers/server/customFunctions";import{addFieldsToValidator as o}from"convex-helpers/validators";import*as s from"zod/v4";import*as c from"zod/v4/core";function l(e,t){return f(e,t)}function u(e,t){return f(e,t)}function d(e,t){return f(e,t)}function f(l,u){let d=u.input??a.input,f=u.args??a.args;return function(a){let{args:u,handler:p=a,skipConvexValidation:m=!1,returns:h,...g}=a,_=h&&!(h instanceof c.$ZodType)?s.object(h):h,v=_&&!m?{returns:n(_)}:null;if(u){let n=u;if(n instanceof c.$ZodType){if(n instanceof c.$ZodObject)n=n._zod.def.shape;else throw Error(`Unsupported zod type as args validator: `+n.constructor.name)}let a=m?void 0:t(
|
|
1
|
+
import{zodToConvex as e}from"./zod-convex.mjs";import{compactArgumentBoundary as t}from"./querying/filter-boundary.mjs";import{zodOutputToConvex as n}from"convex-helpers/server/zod4";import{ConvexError as r}from"convex/values";import{pick as i}from"convex-helpers";import{NoOp as a}from"convex-helpers/server/customFunctions";import{addFieldsToValidator as o}from"convex-helpers/validators";import*as s from"zod/v4";import*as c from"zod/v4/core";function l(e,t){return f(e,t)}function u(e,t){return f(e,t)}function d(e,t){return f(e,t)}function f(l,u){let d=u.input??a.input,f=u.args??a.args;return function(a){let{args:u,handler:p=a,skipConvexValidation:m=!1,returns:h,...g}=a,_=h&&!(h instanceof c.$ZodType)?s.object(h):h,v=_&&!m?{returns:n(_)}:null;if(u){let n=u;if(n instanceof c.$ZodType){if(n instanceof c.$ZodObject)n=n._zod.def.shape;else throw Error(`Unsupported zod type as args validator: `+n.constructor.name)}let a=s.object({...n}),h=Object.keys(a.shape),y=m?void 0:t(a),b=y?.validator??e(a);return l({args:m?void 0:o(b,f),...v,handler:async(e,t)=>{y?.preflight(t);let n=await d(e,i(t,Object.keys(f)),g),o=i(t,h),s=await a.safeParseAsync(o);if(!s.success)throw new r({ZodError:JSON.parse(JSON.stringify(s.error.issues,null,2))});let c=s.data,l={...e,...n.ctx},u={...c,...n.args},m=await p(l,u),v=_?await _.parseAsync(m===void 0?null:m):m;return n.onSuccess&&await n.onSuccess({ctx:e,args:c,result:v}),v}})}if(m&&Object.keys(f).length>0)throw Error(`If you're using a custom function with arguments for the input customization, you cannot skip convex validation.`);return l({...v,handler:async(e,t)=>{let n=await d(e,t,g),r={...e,...n.ctx},i={...t,...n.args},a=await p(r,i),o=_?await _.parseAsync(a===void 0?null:a):a;return n.onSuccess&&await n.onSuccess({ctx:e,args:t,result:o}),o}})}}export{d as zCustomAction,u as zCustomMutation,l as zCustomQuery};
|
|
2
2
|
//# sourceMappingURL=zod-registration.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-registration.mjs","names":["zodToConvex","zodToConvex$1","z","zCore","zCustomQuery","customFnBuilder","query","customization","zCustomMutation","mutation","zCustomAction","action","customInput","NoOp","inputArgs","fn","maybeObject","extra","returns","returnValidator","skipConvexValidation","zodOutputToConvex","args","argsValidator","boundary","compactArgumentBoundary","convexValidator","builder","addFieldsToValidator","allArgs","added","ctx","pick","rawArgs","parsed","ConvexError","finalCtx","finalArgs","ret","handler","result"],"sources":["../src/zod-registration.ts"],"sourcesContent":["// Internal auth registration seam. Public wrapper contracts match convex-helpers zod4.\n// Keep the installed helper's registration branches; only argument conversion differs.\nimport { pick } from 'convex-helpers'\nimport { NoOp, type Customization } from 'convex-helpers/server/customFunctions'\nimport { zodOutputToConvex, type CustomBuilder } from 'convex-helpers/server/zod4'\nimport { addFieldsToValidator } from 'convex-helpers/validators'\nimport type {\n\tActionBuilder,\n\tFunctionVisibility,\n\tGenericActionCtx,\n\tGenericDataModel,\n\tGenericMutationCtx,\n\tGenericQueryCtx,\n\tMutationBuilder,\n\tQueryBuilder,\n} from 'convex/server'\nimport { ConvexError, type PropertyValidators, type Value } from 'convex/values'\nimport * as z from 'zod/v4'\nimport * as zCore from 'zod/v4/core'\nimport { zodToConvex } from './zod-convex'\nimport { compactArgumentBoundary } from './querying/filter-boundary'\n\nexport function zCustomQuery<\n\tCustomArgsValidator extends PropertyValidators,\n\tCustomCtx extends Record<string, any>,\n\tCustomMadeArgs extends Record<string, any>,\n\tVisibility extends FunctionVisibility,\n\tDataModel extends GenericDataModel,\n\tExtraArgs extends Record<string, any> = object,\n>(\n\tquery: QueryBuilder<DataModel, Visibility>,\n\tcustomization: Customization<\n\t\tGenericQueryCtx<DataModel>,\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tExtraArgs\n\t>,\n) {\n\t// SAFETY: the private adapter preserves helper registration semantics; this is\n\t// the same generic boundary assertion used by the public helper wrappers.\n\treturn customFnBuilder(query, customization) as CustomBuilder<\n\t\t'query',\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tGenericQueryCtx<DataModel>,\n\t\tVisibility,\n\t\tExtraArgs\n\t>\n}\n\nexport function zCustomMutation<\n\tCustomArgsValidator extends PropertyValidators,\n\tCustomCtx extends Record<string, any>,\n\tCustomMadeArgs extends Record<string, any>,\n\tVisibility extends FunctionVisibility,\n\tDataModel extends GenericDataModel,\n\tExtraArgs extends Record<string, any> = object,\n>(\n\tmutation: MutationBuilder<DataModel, Visibility>,\n\tcustomization: Customization<\n\t\tGenericMutationCtx<DataModel>,\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tExtraArgs\n\t>,\n) {\n\t// SAFETY: the private adapter preserves helper registration semantics; this is\n\t// the same generic boundary assertion used by the public helper wrappers.\n\treturn customFnBuilder(mutation, customization) as CustomBuilder<\n\t\t'mutation',\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tGenericMutationCtx<DataModel>,\n\t\tVisibility,\n\t\tExtraArgs\n\t>\n}\n\nexport function zCustomAction<\n\tCustomArgsValidator extends PropertyValidators,\n\tCustomCtx extends Record<string, any>,\n\tCustomMadeArgs extends Record<string, any>,\n\tVisibility extends FunctionVisibility,\n\tDataModel extends GenericDataModel,\n\tExtraArgs extends Record<string, any> = object,\n>(\n\taction: ActionBuilder<DataModel, Visibility>,\n\tcustomization: Customization<\n\t\tGenericActionCtx<DataModel>,\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tExtraArgs\n\t>,\n) {\n\t// SAFETY: the private adapter preserves helper registration semantics; this is\n\t// the same generic boundary assertion used by the public helper wrappers.\n\treturn customFnBuilder(action, customization) as CustomBuilder<\n\t\t'action',\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tGenericActionCtx<DataModel>,\n\t\tVisibility,\n\t\tExtraArgs\n\t>\n}\n\nfunction customFnBuilder(\n\tbuilder: (args: any) => any,\n\tcustomization: Customization<any, any, any, any, any>,\n) {\n\t// Looking forward to when input / args / ... are optional\n\tconst customInput: Customization<any, any, any, any, any>['input'] =\n\t\tcustomization.input ?? NoOp.input\n\tconst inputArgs = customization.args ?? NoOp.args\n\treturn function customBuilder(fn: any): any {\n\t\tconst { args, handler = fn, skipConvexValidation = false, returns: maybeObject, ...extra } = fn\n\n\t\tconst returns =\n\t\t\tmaybeObject && !(maybeObject instanceof zCore.$ZodType) ? z.object(maybeObject) : maybeObject\n\n\t\tconst returnValidator =\n\t\t\treturns && !skipConvexValidation ? { returns: zodOutputToConvex(returns) } : null\n\n\t\tif (args) {\n\t\t\tlet argsValidator = args\n\t\t\tif (argsValidator instanceof zCore.$ZodType) {\n\t\t\t\tif (argsValidator instanceof zCore.$ZodObject) {\n\t\t\t\t\targsValidator = argsValidator._zod.def.shape\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Unsupported zod type as args validator: ' + argsValidator.constructor.name,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// One conversion preserves graph sharing across all user argument fields.\n\t\t\tconst boundary = skipConvexValidation\n\t\t\t\t? undefined\n\t\t\t\t: compactArgumentBoundary(z.object(argsValidator))\n\t\t\tconst convexValidator = boundary?.validator ?? zodToConvex(z.object(argsValidator))\n\t\t\treturn builder({\n\t\t\t\targs: skipConvexValidation ? undefined : addFieldsToValidator(convexValidator, inputArgs),\n\t\t\t\t...returnValidator,\n\t\t\t\thandler: async (ctx: any, allArgs: any) => {\n\t\t\t\t\tboundary?.preflight(allArgs)\n\t\t\t\t\tconst added = await customInput(ctx, pick(allArgs, Object.keys(inputArgs)), extra)\n\t\t\t\t\tconst rawArgs = pick(allArgs, Object.keys(argsValidator))\n\t\t\t\t\tconst parsed = await z.object(argsValidator).safeParseAsync(rawArgs)\n\t\t\t\t\tif (!parsed.success) {\n\t\t\t\t\t\tthrow new ConvexError({\n\t\t\t\t\t\t\t// SAFETY: serialized Zod issues are the helper's existing Convex Value[] error payload.\n\t\t\t\t\t\t\tZodError: JSON.parse(JSON.stringify(parsed.error.issues, null, 2)) as Value[],\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tconst args = parsed.data\n\t\t\t\t\tconst finalCtx = { ...ctx, ...added.ctx }\n\t\t\t\t\tconst finalArgs = { ...args, ...added.args }\n\t\t\t\t\tconst ret = await handler(finalCtx, finalArgs)\n\t\t\t\t\t// We don't catch the error here. It's a developer error and we\n\t\t\t\t\t// don't want to risk exposing the unexpected value to the client.\n\t\t\t\t\tconst result = returns ? await returns.parseAsync(ret === undefined ? null : ret) : ret\n\t\t\t\t\tif (added.onSuccess) {\n\t\t\t\t\t\tawait added.onSuccess({ ctx, args, result })\n\t\t\t\t\t}\n\t\t\t\t\treturn result\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tif (skipConvexValidation && Object.keys(inputArgs).length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t\"If you're using a custom function with arguments for the input \" +\n\t\t\t\t\t'customization, you cannot skip convex validation.',\n\t\t\t)\n\t\t}\n\t\treturn builder({\n\t\t\t...returnValidator,\n\t\t\thandler: async (ctx: any, args: any) => {\n\t\t\t\tconst added = await customInput(ctx, args, extra)\n\t\t\t\tconst finalCtx = { ...ctx, ...added.ctx }\n\t\t\t\tconst finalArgs = { ...args, ...added.args }\n\t\t\t\tconst ret = await handler(finalCtx, finalArgs)\n\t\t\t\t// We don't catch the error here. It's a developer error and we\n\t\t\t\t// don't want to risk exposing the unexpected value to the client.\n\t\t\t\tconst result = returns ? await returns.parseAsync(ret === undefined ? null : ret) : ret\n\t\t\t\tif (added.onSuccess) {\n\t\t\t\t\tawait added.onSuccess({ ctx, args, result })\n\t\t\t\t}\n\t\t\t\treturn result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KN,CAAa,CAAC,EAClDW,EAAS,MAAMhC,EAAE,OAAOqB,CAAa,CAAC,CAAC,eAAeU,CAAO,EACnE,GAAI,CAACC,EAAO,QACX,MAAM,IAAIC,EAAY,CAErB,SAAU,KAAK,MAAM,KAAK,UAAUD,EAAO,MAAM,OAAQ,KAAM,CAAC,CAAC,CAClE,CAAC,EAEF,IAAMZ,EAAOY,EAAO,KACdE,EAAW,CAAE,GAAGL,EAAK,GAAGD,EAAM,GAAI,EAClCO,EAAY,CAAE,GAAGf,EAAM,GAAGQ,EAAM,IAAK,EACrCQ,EAAM,MAAMC,EAAQH,EAAUC,CAAS,EAGvCG,EAAStB,EAAU,MAAMA,EAAQ,WAAWoB,IAAQ,IAAA,GAAY,KAAOA,CAAG,EAAIA,EAIpF,OAHIR,EAAM,WACT,MAAMA,EAAM,UAAU,CAAE,MAAK,OAAM,QAAO,CAAC,EAErCU,CACR,CACD,CAAC,CACF,CACA,GAAIpB,GAAwB,OAAO,KAAKN,CAAS,CAAC,CAAC,OAAS,EAC3D,MAAU,MACT,kHAED,EAED,OAAOa,EAAQ,CACd,GAAGR,EACH,QAAS,MAAO,EAAU,IAAc,CACvC,IAAMW,EAAQ,MAAMlB,EAAYmB,EAAKT,EAAML,CAAK,EAC1CmB,EAAW,CAAE,GAAGL,EAAK,GAAGD,EAAM,GAAI,EAClCO,EAAY,CAAE,GAAGf,EAAM,GAAGQ,EAAM,IAAK,EACrCQ,EAAM,MAAMC,EAAQH,EAAUC,CAAS,EAGvCG,EAAStB,EAAU,MAAMA,EAAQ,WAAWoB,IAAQ,IAAA,GAAY,KAAOA,CAAG,EAAIA,EAIpF,OAHIR,EAAM,WACT,MAAMA,EAAM,UAAU,CAAE,MAAK,OAAM,QAAO,CAAC,EAErCU,CACR,CACD,CAAC,CACF,CACD"}
|
|
1
|
+
{"version":3,"file":"zod-registration.mjs","names":["zodToConvex","zodToConvex$1","z","zCore","zCustomQuery","customFnBuilder","query","customization","zCustomMutation","mutation","zCustomAction","action","customInput","NoOp","inputArgs","fn","maybeObject","extra","returns","returnValidator","skipConvexValidation","zodOutputToConvex","args","argsValidator","argsSchema","argsKeys","boundary","compactArgumentBoundary","convexValidator","builder","addFieldsToValidator","allArgs","added","ctx","pick","rawArgs","parsed","ConvexError","finalCtx","finalArgs","ret","handler","result"],"sources":["../src/zod-registration.ts"],"sourcesContent":["// Internal auth registration seam. Public wrapper contracts match convex-helpers zod4.\n// Keep the installed helper's registration branches; only argument conversion differs.\nimport { pick } from 'convex-helpers'\nimport { NoOp, type Customization } from 'convex-helpers/server/customFunctions'\nimport { zodOutputToConvex, type CustomBuilder } from 'convex-helpers/server/zod4'\nimport { addFieldsToValidator } from 'convex-helpers/validators'\nimport type {\n\tActionBuilder,\n\tFunctionVisibility,\n\tGenericActionCtx,\n\tGenericDataModel,\n\tGenericMutationCtx,\n\tGenericQueryCtx,\n\tMutationBuilder,\n\tQueryBuilder,\n} from 'convex/server'\nimport { ConvexError, type PropertyValidators, type Value } from 'convex/values'\nimport * as z from 'zod/v4'\nimport * as zCore from 'zod/v4/core'\nimport { zodToConvex } from './zod-convex'\nimport { compactArgumentBoundary } from './querying/filter-boundary'\n\nexport function zCustomQuery<\n\tCustomArgsValidator extends PropertyValidators,\n\tCustomCtx extends Record<string, any>,\n\tCustomMadeArgs extends Record<string, any>,\n\tVisibility extends FunctionVisibility,\n\tDataModel extends GenericDataModel,\n\tExtraArgs extends Record<string, any> = object,\n>(\n\tquery: QueryBuilder<DataModel, Visibility>,\n\tcustomization: Customization<\n\t\tGenericQueryCtx<DataModel>,\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tExtraArgs\n\t>,\n) {\n\t// SAFETY: the private adapter preserves helper registration semantics; this is\n\t// the same generic boundary assertion used by the public helper wrappers.\n\treturn customFnBuilder(query, customization) as CustomBuilder<\n\t\t'query',\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tGenericQueryCtx<DataModel>,\n\t\tVisibility,\n\t\tExtraArgs\n\t>\n}\n\nexport function zCustomMutation<\n\tCustomArgsValidator extends PropertyValidators,\n\tCustomCtx extends Record<string, any>,\n\tCustomMadeArgs extends Record<string, any>,\n\tVisibility extends FunctionVisibility,\n\tDataModel extends GenericDataModel,\n\tExtraArgs extends Record<string, any> = object,\n>(\n\tmutation: MutationBuilder<DataModel, Visibility>,\n\tcustomization: Customization<\n\t\tGenericMutationCtx<DataModel>,\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tExtraArgs\n\t>,\n) {\n\t// SAFETY: the private adapter preserves helper registration semantics; this is\n\t// the same generic boundary assertion used by the public helper wrappers.\n\treturn customFnBuilder(mutation, customization) as CustomBuilder<\n\t\t'mutation',\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tGenericMutationCtx<DataModel>,\n\t\tVisibility,\n\t\tExtraArgs\n\t>\n}\n\nexport function zCustomAction<\n\tCustomArgsValidator extends PropertyValidators,\n\tCustomCtx extends Record<string, any>,\n\tCustomMadeArgs extends Record<string, any>,\n\tVisibility extends FunctionVisibility,\n\tDataModel extends GenericDataModel,\n\tExtraArgs extends Record<string, any> = object,\n>(\n\taction: ActionBuilder<DataModel, Visibility>,\n\tcustomization: Customization<\n\t\tGenericActionCtx<DataModel>,\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tExtraArgs\n\t>,\n) {\n\t// SAFETY: the private adapter preserves helper registration semantics; this is\n\t// the same generic boundary assertion used by the public helper wrappers.\n\treturn customFnBuilder(action, customization) as CustomBuilder<\n\t\t'action',\n\t\tCustomArgsValidator,\n\t\tCustomCtx,\n\t\tCustomMadeArgs,\n\t\tGenericActionCtx<DataModel>,\n\t\tVisibility,\n\t\tExtraArgs\n\t>\n}\n\nfunction customFnBuilder(\n\tbuilder: (args: any) => any,\n\tcustomization: Customization<any, any, any, any, any>,\n) {\n\t// Looking forward to when input / args / ... are optional\n\tconst customInput: Customization<any, any, any, any, any>['input'] =\n\t\tcustomization.input ?? NoOp.input\n\tconst inputArgs = customization.args ?? NoOp.args\n\treturn function customBuilder(fn: any): any {\n\t\tconst { args, handler = fn, skipConvexValidation = false, returns: maybeObject, ...extra } = fn\n\n\t\tconst returns =\n\t\t\tmaybeObject && !(maybeObject instanceof zCore.$ZodType) ? z.object(maybeObject) : maybeObject\n\n\t\tconst returnValidator =\n\t\t\treturns && !skipConvexValidation ? { returns: zodOutputToConvex(returns) } : null\n\n\t\tif (args) {\n\t\t\tlet argsValidator = args\n\t\t\tif (argsValidator instanceof zCore.$ZodType) {\n\t\t\t\tif (argsValidator instanceof zCore.$ZodObject) {\n\t\t\t\t\targsValidator = argsValidator._zod.def.shape\n\t\t\t\t} else {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t'Unsupported zod type as args validator: ' + argsValidator.constructor.name,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Capture top-level fields once, matching the native validator's registration lifetime.\n\t\t\t// Nested schemas retain their identity; parsing and callbacks still run per invocation.\n\t\t\tconst argsSchema = z.object({ ...argsValidator })\n\t\t\tconst argsKeys = Object.keys(argsSchema.shape)\n\t\t\t// One conversion preserves graph sharing across all user argument fields.\n\t\t\tconst boundary = skipConvexValidation ? undefined : compactArgumentBoundary(argsSchema)\n\t\t\tconst convexValidator = boundary?.validator ?? zodToConvex(argsSchema)\n\t\t\treturn builder({\n\t\t\t\targs: skipConvexValidation ? undefined : addFieldsToValidator(convexValidator, inputArgs),\n\t\t\t\t...returnValidator,\n\t\t\t\thandler: async (ctx: any, allArgs: any) => {\n\t\t\t\t\tboundary?.preflight(allArgs)\n\t\t\t\t\tconst added = await customInput(ctx, pick(allArgs, Object.keys(inputArgs)), extra)\n\t\t\t\t\tconst rawArgs = pick(allArgs, argsKeys)\n\t\t\t\t\tconst parsed = await argsSchema.safeParseAsync(rawArgs)\n\t\t\t\t\tif (!parsed.success) {\n\t\t\t\t\t\tthrow new ConvexError({\n\t\t\t\t\t\t\t// SAFETY: serialized Zod issues are the helper's existing Convex Value[] error payload.\n\t\t\t\t\t\t\tZodError: JSON.parse(JSON.stringify(parsed.error.issues, null, 2)) as Value[],\n\t\t\t\t\t\t})\n\t\t\t\t\t}\n\t\t\t\t\tconst args = parsed.data\n\t\t\t\t\tconst finalCtx = { ...ctx, ...added.ctx }\n\t\t\t\t\tconst finalArgs = { ...args, ...added.args }\n\t\t\t\t\tconst ret = await handler(finalCtx, finalArgs)\n\t\t\t\t\t// We don't catch the error here. It's a developer error and we\n\t\t\t\t\t// don't want to risk exposing the unexpected value to the client.\n\t\t\t\t\tconst result = returns ? await returns.parseAsync(ret === undefined ? null : ret) : ret\n\t\t\t\t\tif (added.onSuccess) {\n\t\t\t\t\t\tawait added.onSuccess({ ctx, args, result })\n\t\t\t\t\t}\n\t\t\t\t\treturn result\n\t\t\t\t},\n\t\t\t})\n\t\t}\n\t\tif (skipConvexValidation && Object.keys(inputArgs).length > 0) {\n\t\t\tthrow new Error(\n\t\t\t\t\"If you're using a custom function with arguments for the input \" +\n\t\t\t\t\t'customization, you cannot skip convex validation.',\n\t\t\t)\n\t\t}\n\t\treturn builder({\n\t\t\t...returnValidator,\n\t\t\thandler: async (ctx: any, args: any) => {\n\t\t\t\tconst added = await customInput(ctx, args, extra)\n\t\t\t\tconst finalCtx = { ...ctx, ...added.ctx }\n\t\t\t\tconst finalArgs = { ...args, ...added.args }\n\t\t\t\tconst ret = await handler(finalCtx, finalArgs)\n\t\t\t\t// We don't catch the error here. It's a developer error and we\n\t\t\t\t// don't want to risk exposing the unexpected value to the client.\n\t\t\t\tconst result = returns ? await returns.parseAsync(ret === undefined ? null : ret) : ret\n\t\t\t\tif (added.onSuccess) {\n\t\t\t\t\tawait added.onSuccess({ ctx, args, result })\n\t\t\t\t}\n\t\t\t\treturn result\n\t\t\t},\n\t\t})\n\t}\n}\n"],"mappings":"8bAsBA,SA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: foundation kernels, approvals component, zod table boundaries, WorkOS-backed auth function constructors, and audited command protocol.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"component",
|