UNPKG

@taqueria/protocol

Version:

A TypeScript package which contains types that are to be shared between @taqueria/node-sdk and @taqueria/taqueria.

129 lines (125 loc) 4.69 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; 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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); // SanitizedAbsPath.ts var SanitizedAbsPath_exports = {}; __export(SanitizedAbsPath_exports, { create: () => create2, factory: () => factory, generatedSchemas: () => generatedSchemas, make: () => make, of: () => of, rawSchema: () => rawSchema, schemas: () => schemas }); module.exports = __toCommonJS(SanitizedAbsPath_exports); // TaqError.ts var import_fluture = require("fluture"); var toFutureParseErr = (previous, msg, context) => (0, import_fluture.reject)(toParseErr(previous, msg, context)).pipe((0, import_fluture.map)((val) => val)); var toParseErr = (previous, msg, context) => create({ kind: "E_PARSE", msg, context, previous }); var toParseUnknownErr = (previous, msg, context) => create({ kind: "E_PARSE_UNKNOWN", msg, context, previous }); var toFutureParseUnknownErr = (previous, msg, context) => (0, import_fluture.reject)(toParseUnknownErr(previous, msg, context)).pipe((0, import_fluture.map)((val) => val)); var create = (err) => err; // Base.ts var import_fluture2 = require("fluture"); var import_zod = require("zod"); var createSchema = (params) => { var _a, _b; const { rawSchema: rawSchema2, isStringLike } = params; const internalSchema = (_a = params.internalSchema) != null ? _a : params.rawSchema; const noop = (val) => val; const transformer = (_b = params.transformer) != null ? _b : noop; const schema = isStringLike ? internalSchema.transform( (val) => transformer(val) ) : internalSchema.transform( (val) => transformer(val) ); return { rawSchema: rawSchema2, internalSchema, schema }; }; var createType = (params) => { const schemas2 = createSchema(params); const { parseErrMsg, unknownErrMsg } = params; const internalOf = (input) => { try { return (0, import_fluture2.resolve)(schemas2.schema.parse(input)); } catch (previous) { const parseMsg = typeof parseErrMsg === "string" ? parseErrMsg : parseErrMsg(input, previous); const unknownMsg = typeof unknownErrMsg === "string" ? unknownErrMsg : unknownErrMsg(input); if (previous instanceof import_zod.ZodError) { return toFutureParseErr(previous, parseMsg, input); } return toFutureParseUnknownErr(previous, unknownMsg, input); } }; const of2 = internalOf; const make2 = (input) => internalOf(input); const create3 = (input) => schemas2.schema.parse(input); const from = (input) => schemas2.schema.parse(input); const factory2 = { make: make2, of: of2, create: create3, from }; return { schemas: schemas2, factory: factory2 }; }; var Base_default = createType; // SanitizedAbsPath.ts var path = __toESM(require("path")); var import_zod2 = require("zod"); var rawSchema = import_zod2.z.string({ description: "SanitizedAbsPath" }).min(1); var { schemas: generatedSchemas, factory } = Base_default({ isStringLike: true, rawSchema, transformer: (value) => path.resolve(value), parseErrMsg: (value) => `${value} is an invalid absolute path`, unknownErrMsg: (value) => `Something went wrong trying to parse the absolute path, ${value}` }); var { create: create2, make, of } = factory; var schemas = { ...generatedSchemas, schema: generatedSchemas.schema.transform((val) => val) }; //# sourceMappingURL=SanitizedAbsPath.js.map