MCPcopy
hub / github.com/di-sukharev/opencommit / _parse

Method _parse

out/cli.cjs:32091–32165  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

32089 this.validate = this.implement;
32090 }
32091 _parse(input) {
32092 const { ctx } = this._processInputParams(input);
32093 if (ctx.parsedType !== util_1.ZodParsedType.function) {
32094 (0, parseUtil_1.addIssueToContext)(ctx, {
32095 code: ZodError_1.ZodIssueCode.invalid_type,
32096 expected: util_1.ZodParsedType.function,
32097 received: ctx.parsedType
32098 });
32099 return parseUtil_1.INVALID;
32100 }
32101 function makeArgsIssue(args, error) {
32102 return (0, parseUtil_1.makeIssue)({
32103 data: args,
32104 path: ctx.path,
32105 errorMaps: [
32106 ctx.common.contextualErrorMap,
32107 ctx.schemaErrorMap,
32108 (0, errors_1.getErrorMap)(),
32109 errors_1.defaultErrorMap
32110 ].filter((x5) => !!x5),
32111 issueData: {
32112 code: ZodError_1.ZodIssueCode.invalid_arguments,
32113 argumentsError: error
32114 }
32115 });
32116 }
32117 function makeReturnsIssue(returns, error) {
32118 return (0, parseUtil_1.makeIssue)({
32119 data: returns,
32120 path: ctx.path,
32121 errorMaps: [
32122 ctx.common.contextualErrorMap,
32123 ctx.schemaErrorMap,
32124 (0, errors_1.getErrorMap)(),
32125 errors_1.defaultErrorMap
32126 ].filter((x5) => !!x5),
32127 issueData: {
32128 code: ZodError_1.ZodIssueCode.invalid_return_type,
32129 returnTypeError: error
32130 }
32131 });
32132 }
32133 const params = { errorMap: ctx.common.contextualErrorMap };
32134 const fn = ctx.data;
32135 if (this._def.returns instanceof ZodPromise) {
32136 const me2 = this;
32137 return (0, parseUtil_1.OK)(async function(...args) {
32138 const error = new ZodError_1.ZodError([]);
32139 const parsedArgs = await me2._def.args.parseAsync(args, params).catch((e3) => {
32140 error.addIssue(makeArgsIssue(args, e3));
32141 throw error;
32142 });
32143 const result = await Reflect.apply(fn, this, parsedArgs);
32144 const parsedReturns = await me2._def.returns._def.type.parseAsync(result, params).catch((e3) => {
32145 error.addIssue(makeReturnsIssue(result, e3));
32146 throw error;
32147 });
32148 return parsedReturns;

Callers

nothing calls this directly

Calls 4

_processInputParamsMethod · 0.80
parseAsyncMethod · 0.80
safeParseMethod · 0.80
catchMethod · 0.45

Tested by

no test coverage detected