@taqueria/protocol
Version:
A TypeScript package which contains types that are to be shared between @taqueria/node-sdk and @taqueria/taqueria.
49 lines (48 loc) • 1.79 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// helpers.ts
var helpers_exports = {};
__export(helpers_exports, {
parsingErrorMessages: () => parsingErrorMessages
});
module.exports = __toCommonJS(helpers_exports);
var import_zod = require("zod");
var parsingErrorMessages = (typeName) => {
const parseErrMsg = (value, previous) => {
const message = ["string", "number", "boolean"].includes(typeof value) ? `${value} is not a valid ${typeName}` : `This is not a valid ${typeName}`;
if (previous instanceof import_zod.ZodError) {
const msgs = previous.errors.reduce(
(retval, issue) => {
const path = issue.path.join(" \u2192 ");
const msg = ` ${path}: ${issue.message}`;
return [...retval, msg];
},
[message]
);
return msgs.join("\n") + "\n";
}
return message;
};
const unknownErrMsg = (value) => "Something went wrong trying to parse an ${typeName}";
return {
parseErrMsg,
unknownErrMsg
};
};
//# sourceMappingURL=helpers.js.map