UNPKG

@fragment-dev/cli

Version:
1,813 lines (1,740 loc) 55.6 kB
import { z } from "./chunk-5TQBOAE7.js"; import { __commonJS, __require, __toESM, init_cjs_shims } from "./chunk-7GH3YGSC.js"; // ../../node_modules/assert-plus/assert.js var require_assert = __commonJS({ "../../node_modules/assert-plus/assert.js"(exports, module) { init_cjs_shims(); var assert2 = __require("assert"); var Stream = __require("stream").Stream; var util = __require("util"); var UUID_REGEXP = /^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$/; function _capitalize(str) { return str.charAt(0).toUpperCase() + str.slice(1); } function _toss(name, expected, oper, arg, actual) { throw new assert2.AssertionError({ message: util.format("%s (%s) is required", name, expected), actual: actual === void 0 ? typeof arg : actual(arg), expected, operator: oper || "===", stackStartFunction: _toss.caller }); } function _getClass(arg) { return Object.prototype.toString.call(arg).slice(8, -1); } function noop() { } var types = { bool: { check: function(arg) { return typeof arg === "boolean"; } }, func: { check: function(arg) { return typeof arg === "function"; } }, string: { check: function(arg) { return typeof arg === "string"; } }, object: { check: function(arg) { return typeof arg === "object" && arg !== null; } }, number: { check: function(arg) { return typeof arg === "number" && !isNaN(arg); } }, finite: { check: function(arg) { return typeof arg === "number" && !isNaN(arg) && isFinite(arg); } }, buffer: { check: function(arg) { return Buffer.isBuffer(arg); }, operator: "Buffer.isBuffer" }, array: { check: function(arg) { return Array.isArray(arg); }, operator: "Array.isArray" }, stream: { check: function(arg) { return arg instanceof Stream; }, operator: "instanceof", actual: _getClass }, date: { check: function(arg) { return arg instanceof Date; }, operator: "instanceof", actual: _getClass }, regexp: { check: function(arg) { return arg instanceof RegExp; }, operator: "instanceof", actual: _getClass }, uuid: { check: function(arg) { return typeof arg === "string" && UUID_REGEXP.test(arg); }, operator: "isUUID" } }; function _setExports(ndebug) { var keys = Object.keys(types); var out; if (process.env.NODE_NDEBUG) { out = noop; } else { out = function(arg, msg) { if (!arg) { _toss(msg, "true", arg); } }; } keys.forEach(function(k) { if (ndebug) { out[k] = noop; return; } var type = types[k]; out[k] = function(arg, msg) { if (!type.check(arg)) { _toss(msg, k, type.operator, arg, type.actual); } }; }); keys.forEach(function(k) { var name = "optional" + _capitalize(k); if (ndebug) { out[name] = noop; return; } var type = types[k]; out[name] = function(arg, msg) { if (arg === void 0 || arg === null) { return; } if (!type.check(arg)) { _toss(msg, k, type.operator, arg, type.actual); } }; }); keys.forEach(function(k) { var name = "arrayOf" + _capitalize(k); if (ndebug) { out[name] = noop; return; } var type = types[k]; var expected = "[" + k + "]"; out[name] = function(arg, msg) { if (!Array.isArray(arg)) { _toss(msg, expected, type.operator, arg, type.actual); } var i; for (i = 0; i < arg.length; i++) { if (!type.check(arg[i])) { _toss(msg, expected, type.operator, arg, type.actual); } } }; }); keys.forEach(function(k) { var name = "optionalArrayOf" + _capitalize(k); if (ndebug) { out[name] = noop; return; } var type = types[k]; var expected = "[" + k + "]"; out[name] = function(arg, msg) { if (arg === void 0 || arg === null) { return; } if (!Array.isArray(arg)) { _toss(msg, expected, type.operator, arg, type.actual); } var i; for (i = 0; i < arg.length; i++) { if (!type.check(arg[i])) { _toss(msg, expected, type.operator, arg, type.actual); } } }; }); Object.keys(assert2).forEach(function(k) { if (k === "AssertionError") { out[k] = assert2[k]; return; } if (ndebug) { out[k] = noop; return; } out[k] = assert2[k]; }); out._setExports = _setExports; return out; } module.exports = _setExports(process.env.NODE_NDEBUG); } }); // ../../node_modules/extsprintf/lib/extsprintf.js var require_extsprintf = __commonJS({ "../../node_modules/extsprintf/lib/extsprintf.js"(exports) { init_cjs_shims(); var mod_assert = __require("assert"); var mod_util = __require("util"); exports.sprintf = jsSprintf; exports.printf = jsPrintf; exports.fprintf = jsFprintf; function jsSprintf(ofmt) { var regex = [ "([^%]*)", /* normal text */ "%", /* start of format */ "(['\\-+ #0]*?)", /* flags (optional) */ "([1-9]\\d*)?", /* width (optional) */ "(\\.([1-9]\\d*))?", /* precision (optional) */ "[lhjztL]*?", /* length mods (ignored) */ "([diouxXfFeEgGaAcCsSp%jr])" /* conversion */ ].join(""); var re = new RegExp(regex); var args = Array.prototype.slice.call(arguments, 1); var fmt = ofmt; var flags, width, precision, conversion; var left, pad, sign, arg, match; var ret = ""; var argn = 1; var posn = 0; var convposn; var curconv; mod_assert.equal( "string", typeof fmt, "first argument must be a format string" ); while ((match = re.exec(fmt)) !== null) { ret += match[1]; fmt = fmt.substring(match[0].length); curconv = match[0].substring(match[1].length); convposn = posn + match[1].length + 1; posn += match[0].length; flags = match[2] || ""; width = match[3] || 0; precision = match[4] || ""; conversion = match[6]; left = false; sign = false; pad = " "; if (conversion == "%") { ret += "%"; continue; } if (args.length === 0) { throw jsError( ofmt, convposn, curconv, "has no matching argument (too few arguments passed)" ); } arg = args.shift(); argn++; if (flags.match(/[\' #]/)) { throw jsError( ofmt, convposn, curconv, "uses unsupported flags" ); } if (precision.length > 0) { throw jsError( ofmt, convposn, curconv, "uses non-zero precision (not supported)" ); } if (flags.match(/-/)) left = true; if (flags.match(/0/)) pad = "0"; if (flags.match(/\+/)) sign = true; switch (conversion) { case "s": if (arg === void 0 || arg === null) { throw jsError( ofmt, convposn, curconv, "attempted to print undefined or null as a string (argument " + argn + " to sprintf)" ); } ret += doPad(pad, width, left, arg.toString()); break; case "d": arg = Math.floor(arg); case "f": sign = sign && arg > 0 ? "+" : ""; ret += sign + doPad( pad, width, left, arg.toString() ); break; case "x": ret += doPad(pad, width, left, arg.toString(16)); break; case "j": if (width === 0) width = 10; ret += mod_util.inspect(arg, false, width); break; case "r": ret += dumpException(arg); break; default: throw jsError( ofmt, convposn, curconv, "is not supported" ); } } ret += fmt; return ret; } function jsError(fmtstr, convposn, curconv, reason) { mod_assert.equal(typeof fmtstr, "string"); mod_assert.equal(typeof curconv, "string"); mod_assert.equal(typeof convposn, "number"); mod_assert.equal(typeof reason, "string"); return new Error('format string "' + fmtstr + '": conversion specifier "' + curconv + '" at character ' + convposn + " " + reason); } function jsPrintf() { var args = Array.prototype.slice.call(arguments); args.unshift(process.stdout); jsFprintf.apply(null, args); } function jsFprintf(stream) { var args = Array.prototype.slice.call(arguments, 1); return stream.write(jsSprintf.apply(this, args)); } function doPad(chr, width, left, str) { var ret = str; while (ret.length < width) { if (left) ret += chr; else ret = chr + ret; } return ret; } function dumpException(ex) { var ret; if (!(ex instanceof Error)) throw new Error(jsSprintf("invalid type for %%r: %j", ex)); ret = "EXCEPTION: " + ex.constructor.name + ": " + ex.stack; if (ex.cause && typeof ex.cause === "function") { var cex = ex.cause(); if (cex) { ret += "\nCaused by: " + dumpException(cex); } } return ret; } } }); // ../../node_modules/verror/node_modules/core-util-is/lib/util.js var require_util = __commonJS({ "../../node_modules/verror/node_modules/core-util-is/lib/util.js"(exports) { init_cjs_shims(); function isArray(arg) { if (Array.isArray) { return Array.isArray(arg); } return objectToString2(arg) === "[object Array]"; } exports.isArray = isArray; function isBoolean(arg) { return typeof arg === "boolean"; } exports.isBoolean = isBoolean; function isNull(arg) { return arg === null; } exports.isNull = isNull; function isNullOrUndefined(arg) { return arg == null; } exports.isNullOrUndefined = isNullOrUndefined; function isNumber(arg) { return typeof arg === "number"; } exports.isNumber = isNumber; function isString(arg) { return typeof arg === "string"; } exports.isString = isString; function isSymbol(arg) { return typeof arg === "symbol"; } exports.isSymbol = isSymbol; function isUndefined2(arg) { return arg === void 0; } exports.isUndefined = isUndefined2; function isRegExp(re) { return objectToString2(re) === "[object RegExp]"; } exports.isRegExp = isRegExp; function isObject2(arg) { return typeof arg === "object" && arg !== null; } exports.isObject = isObject2; function isDate(d) { return objectToString2(d) === "[object Date]"; } exports.isDate = isDate; function isError(e) { return objectToString2(e) === "[object Error]" || e instanceof Error; } exports.isError = isError; function isFunction2(arg) { return typeof arg === "function"; } exports.isFunction = isFunction2; function isPrimitive(arg) { return arg === null || typeof arg === "boolean" || typeof arg === "number" || typeof arg === "string" || typeof arg === "symbol" || // ES6 symbol typeof arg === "undefined"; } exports.isPrimitive = isPrimitive; exports.isBuffer = Buffer.isBuffer; function objectToString2(o) { return Object.prototype.toString.call(o); } } }); // ../../node_modules/verror/lib/verror.js var require_verror = __commonJS({ "../../node_modules/verror/lib/verror.js"(exports, module) { init_cjs_shims(); var mod_assertplus = require_assert(); var mod_util = __require("util"); var mod_extsprintf = require_extsprintf(); var mod_isError = require_util().isError; var sprintf = mod_extsprintf.sprintf; module.exports = VError; VError.VError = VError; VError.SError = SError; VError.WError = WError; VError.MultiError = MultiError; function parseConstructorArguments(args) { var argv, options, sprintf_args, shortmessage, k; mod_assertplus.object(args, "args"); mod_assertplus.bool(args.strict, "args.strict"); mod_assertplus.array(args.argv, "args.argv"); argv = args.argv; if (argv.length === 0) { options = {}; sprintf_args = []; } else if (mod_isError(argv[0])) { options = { "cause": argv[0] }; sprintf_args = argv.slice(1); } else if (typeof argv[0] === "object") { options = {}; for (k in argv[0]) { options[k] = argv[0][k]; } sprintf_args = argv.slice(1); } else { mod_assertplus.string( argv[0], "first argument to VError, SError, or WError constructor must be a string, object, or Error" ); options = {}; sprintf_args = argv; } mod_assertplus.object(options); if (!options.strict && !args.strict) { sprintf_args = sprintf_args.map(function(a) { return a === null ? "null" : a === void 0 ? "undefined" : a; }); } if (sprintf_args.length === 0) { shortmessage = ""; } else { shortmessage = sprintf.apply(null, sprintf_args); } return { "options": options, "shortmessage": shortmessage }; } function VError() { var args, obj, parsed, cause, ctor, message, k; args = Array.prototype.slice.call(arguments, 0); if (!(this instanceof VError)) { obj = Object.create(VError.prototype); VError.apply(obj, arguments); return obj; } parsed = parseConstructorArguments({ "argv": args, "strict": false }); if (parsed.options.name) { mod_assertplus.string( parsed.options.name, `error's "name" must be a string` ); this.name = parsed.options.name; } this.jse_shortmsg = parsed.shortmessage; message = parsed.shortmessage; cause = parsed.options.cause; if (cause) { mod_assertplus.ok(mod_isError(cause), "cause is not an Error"); this.jse_cause = cause; if (!parsed.options.skipCauseMessage) { message += ": " + cause.message; } } this.jse_info = {}; if (parsed.options.info) { for (k in parsed.options.info) { this.jse_info[k] = parsed.options.info[k]; } } this.message = message; Error.call(this, message); if (Error.captureStackTrace) { ctor = parsed.options.constructorOpt || this.constructor; Error.captureStackTrace(this, ctor); } return this; } mod_util.inherits(VError, Error); VError.prototype.name = "VError"; VError.prototype.toString = function ve_toString() { var str = this.hasOwnProperty("name") && this.name || this.constructor.name || this.constructor.prototype.name; if (this.message) str += ": " + this.message; return str; }; VError.prototype.cause = function ve_cause() { var cause = VError.cause(this); return cause === null ? void 0 : cause; }; VError.cause = function(err) { mod_assertplus.ok(mod_isError(err), "err must be an Error"); return mod_isError(err.jse_cause) ? err.jse_cause : null; }; VError.info = function(err) { var rv, cause, k; mod_assertplus.ok(mod_isError(err), "err must be an Error"); cause = VError.cause(err); if (cause !== null) { rv = VError.info(cause); } else { rv = {}; } if (typeof err.jse_info == "object" && err.jse_info !== null) { for (k in err.jse_info) { rv[k] = err.jse_info[k]; } } return rv; }; VError.findCauseByName = function(err, name) { var cause; mod_assertplus.ok(mod_isError(err), "err must be an Error"); mod_assertplus.string(name, "name"); mod_assertplus.ok(name.length > 0, "name cannot be empty"); for (cause = err; cause !== null; cause = VError.cause(cause)) { mod_assertplus.ok(mod_isError(cause)); if (cause.name == name) { return cause; } } return null; }; VError.hasCauseWithName = function(err, name) { return VError.findCauseByName(err, name) !== null; }; VError.fullStack = function(err) { mod_assertplus.ok(mod_isError(err), "err must be an Error"); var cause = VError.cause(err); if (cause) { return err.stack + "\ncaused by: " + VError.fullStack(cause); } return err.stack; }; VError.errorFromList = function(errors) { mod_assertplus.arrayOfObject(errors, "errors"); if (errors.length === 0) { return null; } errors.forEach(function(e) { mod_assertplus.ok(mod_isError(e)); }); if (errors.length == 1) { return errors[0]; } return new MultiError(errors); }; VError.errorForEach = function(err, func) { mod_assertplus.ok(mod_isError(err), "err must be an Error"); mod_assertplus.func(func, "func"); if (err instanceof MultiError) { err.errors().forEach(function iterError(e) { func(e); }); } else { func(err); } }; function SError() { var args, obj, parsed, options; args = Array.prototype.slice.call(arguments, 0); if (!(this instanceof SError)) { obj = Object.create(SError.prototype); SError.apply(obj, arguments); return obj; } parsed = parseConstructorArguments({ "argv": args, "strict": true }); options = parsed.options; VError.call(this, options, "%s", parsed.shortmessage); return this; } mod_util.inherits(SError, VError); function MultiError(errors) { mod_assertplus.array(errors, "list of errors"); mod_assertplus.ok(errors.length > 0, "must be at least one error"); this.ase_errors = errors; VError.call(this, { "cause": errors[0] }, "first of %d error%s", errors.length, errors.length == 1 ? "" : "s"); } mod_util.inherits(MultiError, VError); MultiError.prototype.name = "MultiError"; MultiError.prototype.errors = function me_errors() { return this.ase_errors.slice(0); }; function WError() { var args, obj, parsed, options; args = Array.prototype.slice.call(arguments, 0); if (!(this instanceof WError)) { obj = Object.create(WError.prototype); WError.apply(obj, args); return obj; } parsed = parseConstructorArguments({ "argv": args, "strict": false }); options = parsed.options; options["skipCauseMessage"] = true; VError.call(this, options, "%s", parsed.shortmessage); return this; } mod_util.inherits(WError, VError); WError.prototype.name = "WError"; WError.prototype.toString = function we_toString() { var str = this.hasOwnProperty("name") && this.name || this.constructor.name || this.constructor.prototype.name; if (this.message) str += ": " + this.message; if (this.jse_cause && this.jse_cause.message) str += "; caused by " + this.jse_cause.toString(); return str; }; WError.prototype.cause = function we_cause(c) { if (mod_isError(c)) this.jse_cause = c; return this.jse_cause; }; } }); // ../../libs/error-utils/errors.ts init_cjs_shims(); // ../../libs/error-utils/HttpError.ts init_cjs_shims(); var import_verror = __toESM(require_verror(), 1); var VErrorConstructor = import_verror.default.VError || import_verror.default; var HttpError = class _HttpError extends VErrorConstructor { constructor(...args) { const parsed = _HttpError.parseArgs(args); const vErrorOptions = {}; if (parsed.cause) { vErrorOptions.cause = parsed.cause; } if (parsed.info && Object.keys(parsed.info).length > 0) { vErrorOptions.info = parsed.info; } super(vErrorOptions); Object.setPrototypeOf(this, new.target.prototype); this.name = this.constructor.name; this.message = parsed.message || ""; this.statusCode = parsed.statusCode || this.constructor.prototype.statusCode || 500; this.code = parsed.code || this.constructor.prototype.code || this.name.replace(/Error$/, ""); const bodyCode = parsed.code || this.name.replace(/Error$/, ""); this.body = { code: bodyCode, message: parsed.message || "" }; } /** * Parse constructor arguments into a normalized format. * Handles variadic signatures similar to restify-errors. */ static parseArgs(args) { if (args.length === 0) { return { message: "" }; } const first = args[0]; const second = args[1]; if (first instanceof Error) { if (typeof second === "object" && second !== null && !Array.isArray(second)) { const opts = second; return { cause: first, info: opts.info, statusCode: opts.statusCode, code: opts.code, message: opts.message || first.message }; } if (typeof second === "string") { return { cause: first, message: second }; } return { cause: first, message: first.message }; } if (typeof first === "object" && first !== null && !Array.isArray(first)) { const opts = first; const message = typeof second === "string" ? second : opts.message || ""; return { cause: opts.cause, info: opts.info, statusCode: opts.statusCode, code: opts.code, message }; } if (typeof first === "string") { return { message: first }; } return { message: "" }; } /** * Serialize error to JSON format. * Compatible with restify-errors toJSON behavior. */ toJSON() { let { message } = this.body; const causeMethod = this.cause; if (causeMethod && typeof causeMethod === "function") { try { const causeError = causeMethod(); if (causeError) { const fullString = this.toString(); const colonIndex = fullString.indexOf(":"); if (colonIndex !== -1) { message = fullString.substring(colonIndex + 1).trim(); } } } catch { } } return { code: this.body.code, message }; } /** * Get context/info object (compatibility with restify-errors) */ get context() { return VErrorConstructor.info(this); } }; HttpError.prototype.name = "HttpError"; HttpError.prototype.statusCode = 500; HttpError.prototype.code = "Error"; // ../../libs/error-utils/errors.ts var InternalError = class extends HttpError { constructor(...args) { super(...args); this.name = "InternalError"; } }; InternalError.prototype.statusCode = 500; InternalError.prototype.code = "Error"; var BadRequestError = class extends HttpError { constructor(...args) { super(...args); this.name = "BadRequestError"; } }; BadRequestError.prototype.statusCode = 400; BadRequestError.prototype.code = "BadRequest"; var NotFoundError = class extends HttpError { constructor(...args) { super(...args); this.name = "NotFoundError"; } }; NotFoundError.prototype.statusCode = 404; NotFoundError.prototype.code = "NotFound"; var NotAuthorizedError = class extends HttpError { constructor(...args) { super(...args); this.name = "NotAuthorizedError"; } }; NotAuthorizedError.prototype.statusCode = 401; NotAuthorizedError.prototype.code = "NotAuthorized"; var RequestThrottledError = class extends HttpError { constructor(...args) { super(...args); this.name = "RequestThrottledError"; } }; RequestThrottledError.prototype.statusCode = 429; RequestThrottledError.prototype.code = "TooManyRequests"; // ../../libs/error-utils/index.ts init_cjs_shims(); // ../../libs/error-utils/serializer.ts init_cjs_shims(); var RestError = class extends HttpError { constructor(...args) { super(...args); this.name = "RestError"; } }; RestError.prototype.statusCode = 500; RestError.prototype.code = "Error"; // ../../libs/error-utils/assert.ts init_cjs_shims(); import assert from "assert"; // ../../node_modules/lodash-es/lodash.js init_cjs_shims(); // ../../node_modules/lodash-es/_baseGetTag.js init_cjs_shims(); // ../../node_modules/lodash-es/_Symbol.js init_cjs_shims(); // ../../node_modules/lodash-es/_root.js init_cjs_shims(); // ../../node_modules/lodash-es/_freeGlobal.js init_cjs_shims(); var freeGlobal = typeof global == "object" && global && global.Object === Object && global; var freeGlobal_default = freeGlobal; // ../../node_modules/lodash-es/_root.js var freeSelf = typeof self == "object" && self && self.Object === Object && self; var root = freeGlobal_default || freeSelf || Function("return this")(); var root_default = root; // ../../node_modules/lodash-es/_Symbol.js var Symbol = root_default.Symbol; var Symbol_default = Symbol; // ../../node_modules/lodash-es/_getRawTag.js init_cjs_shims(); var objectProto = Object.prototype; var hasOwnProperty = objectProto.hasOwnProperty; var nativeObjectToString = objectProto.toString; var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0; function getRawTag(value) { var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; try { value[symToStringTag] = void 0; var unmasked = true; } catch (e) { } var result = nativeObjectToString.call(value); if (unmasked) { if (isOwn) { value[symToStringTag] = tag; } else { delete value[symToStringTag]; } } return result; } var getRawTag_default = getRawTag; // ../../node_modules/lodash-es/_objectToString.js init_cjs_shims(); var objectProto2 = Object.prototype; var nativeObjectToString2 = objectProto2.toString; function objectToString(value) { return nativeObjectToString2.call(value); } var objectToString_default = objectToString; // ../../node_modules/lodash-es/_baseGetTag.js var nullTag = "[object Null]"; var undefinedTag = "[object Undefined]"; var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0; function baseGetTag(value) { if (value == null) { return value === void 0 ? undefinedTag : nullTag; } return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value); } var baseGetTag_default = baseGetTag; // ../../node_modules/lodash-es/isObject.js init_cjs_shims(); function isObject(value) { var type = typeof value; return value != null && (type == "object" || type == "function"); } var isObject_default = isObject; // ../../node_modules/lodash-es/_getNative.js init_cjs_shims(); // ../../node_modules/lodash-es/_baseIsNative.js init_cjs_shims(); // ../../node_modules/lodash-es/isFunction.js init_cjs_shims(); var asyncTag = "[object AsyncFunction]"; var funcTag = "[object Function]"; var genTag = "[object GeneratorFunction]"; var proxyTag = "[object Proxy]"; function isFunction(value) { if (!isObject_default(value)) { return false; } var tag = baseGetTag_default(value); return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag; } var isFunction_default = isFunction; // ../../node_modules/lodash-es/_isMasked.js init_cjs_shims(); // ../../node_modules/lodash-es/_coreJsData.js init_cjs_shims(); var coreJsData = root_default["__core-js_shared__"]; var coreJsData_default = coreJsData; // ../../node_modules/lodash-es/_isMasked.js var maskSrcKey = function() { var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || ""); return uid ? "Symbol(src)_1." + uid : ""; }(); function isMasked(func) { return !!maskSrcKey && maskSrcKey in func; } var isMasked_default = isMasked; // ../../node_modules/lodash-es/_toSource.js init_cjs_shims(); var funcProto = Function.prototype; var funcToString = funcProto.toString; function toSource(func) { if (func != null) { try { return funcToString.call(func); } catch (e) { } try { return func + ""; } catch (e) { } } return ""; } var toSource_default = toSource; // ../../node_modules/lodash-es/_baseIsNative.js var reRegExpChar = /[\\^$.*+?()[\]{}|]/g; var reIsHostCtor = /^\[object .+?Constructor\]$/; var funcProto2 = Function.prototype; var objectProto3 = Object.prototype; var funcToString2 = funcProto2.toString; var hasOwnProperty2 = objectProto3.hasOwnProperty; var reIsNative = RegExp( "^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$" ); function baseIsNative(value) { if (!isObject_default(value) || isMasked_default(value)) { return false; } var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor; return pattern.test(toSource_default(value)); } var baseIsNative_default = baseIsNative; // ../../node_modules/lodash-es/_getValue.js init_cjs_shims(); function getValue(object, key) { return object == null ? void 0 : object[key]; } var getValue_default = getValue; // ../../node_modules/lodash-es/_getNative.js function getNative(object, key) { var value = getValue_default(object, key); return baseIsNative_default(value) ? value : void 0; } var getNative_default = getNative; // ../../node_modules/lodash-es/eq.js init_cjs_shims(); function eq(value, other) { return value === other || value !== value && other !== other; } var eq_default = eq; // ../../node_modules/lodash-es/memoize.js init_cjs_shims(); // ../../node_modules/lodash-es/_MapCache.js init_cjs_shims(); // ../../node_modules/lodash-es/_mapCacheClear.js init_cjs_shims(); // ../../node_modules/lodash-es/_Hash.js init_cjs_shims(); // ../../node_modules/lodash-es/_hashClear.js init_cjs_shims(); // ../../node_modules/lodash-es/_nativeCreate.js init_cjs_shims(); var nativeCreate = getNative_default(Object, "create"); var nativeCreate_default = nativeCreate; // ../../node_modules/lodash-es/_hashClear.js function hashClear() { this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {}; this.size = 0; } var hashClear_default = hashClear; // ../../node_modules/lodash-es/_hashDelete.js init_cjs_shims(); function hashDelete(key) { var result = this.has(key) && delete this.__data__[key]; this.size -= result ? 1 : 0; return result; } var hashDelete_default = hashDelete; // ../../node_modules/lodash-es/_hashGet.js init_cjs_shims(); var HASH_UNDEFINED = "__lodash_hash_undefined__"; var objectProto4 = Object.prototype; var hasOwnProperty3 = objectProto4.hasOwnProperty; function hashGet(key) { var data = this.__data__; if (nativeCreate_default) { var result = data[key]; return result === HASH_UNDEFINED ? void 0 : result; } return hasOwnProperty3.call(data, key) ? data[key] : void 0; } var hashGet_default = hashGet; // ../../node_modules/lodash-es/_hashHas.js init_cjs_shims(); var objectProto5 = Object.prototype; var hasOwnProperty4 = objectProto5.hasOwnProperty; function hashHas(key) { var data = this.__data__; return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty4.call(data, key); } var hashHas_default = hashHas; // ../../node_modules/lodash-es/_hashSet.js init_cjs_shims(); var HASH_UNDEFINED2 = "__lodash_hash_undefined__"; function hashSet(key, value) { var data = this.__data__; this.size += this.has(key) ? 0 : 1; data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value; return this; } var hashSet_default = hashSet; // ../../node_modules/lodash-es/_Hash.js function Hash(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } Hash.prototype.clear = hashClear_default; Hash.prototype["delete"] = hashDelete_default; Hash.prototype.get = hashGet_default; Hash.prototype.has = hashHas_default; Hash.prototype.set = hashSet_default; var Hash_default = Hash; // ../../node_modules/lodash-es/_ListCache.js init_cjs_shims(); // ../../node_modules/lodash-es/_listCacheClear.js init_cjs_shims(); function listCacheClear() { this.__data__ = []; this.size = 0; } var listCacheClear_default = listCacheClear; // ../../node_modules/lodash-es/_listCacheDelete.js init_cjs_shims(); // ../../node_modules/lodash-es/_assocIndexOf.js init_cjs_shims(); function assocIndexOf(array, key) { var length = array.length; while (length--) { if (eq_default(array[length][0], key)) { return length; } } return -1; } var assocIndexOf_default = assocIndexOf; // ../../node_modules/lodash-es/_listCacheDelete.js var arrayProto = Array.prototype; var splice = arrayProto.splice; function listCacheDelete(key) { var data = this.__data__, index = assocIndexOf_default(data, key); if (index < 0) { return false; } var lastIndex = data.length - 1; if (index == lastIndex) { data.pop(); } else { splice.call(data, index, 1); } --this.size; return true; } var listCacheDelete_default = listCacheDelete; // ../../node_modules/lodash-es/_listCacheGet.js init_cjs_shims(); function listCacheGet(key) { var data = this.__data__, index = assocIndexOf_default(data, key); return index < 0 ? void 0 : data[index][1]; } var listCacheGet_default = listCacheGet; // ../../node_modules/lodash-es/_listCacheHas.js init_cjs_shims(); function listCacheHas(key) { return assocIndexOf_default(this.__data__, key) > -1; } var listCacheHas_default = listCacheHas; // ../../node_modules/lodash-es/_listCacheSet.js init_cjs_shims(); function listCacheSet(key, value) { var data = this.__data__, index = assocIndexOf_default(data, key); if (index < 0) { ++this.size; data.push([key, value]); } else { data[index][1] = value; } return this; } var listCacheSet_default = listCacheSet; // ../../node_modules/lodash-es/_ListCache.js function ListCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } ListCache.prototype.clear = listCacheClear_default; ListCache.prototype["delete"] = listCacheDelete_default; ListCache.prototype.get = listCacheGet_default; ListCache.prototype.has = listCacheHas_default; ListCache.prototype.set = listCacheSet_default; var ListCache_default = ListCache; // ../../node_modules/lodash-es/_Map.js init_cjs_shims(); var Map = getNative_default(root_default, "Map"); var Map_default = Map; // ../../node_modules/lodash-es/_mapCacheClear.js function mapCacheClear() { this.size = 0; this.__data__ = { "hash": new Hash_default(), "map": new (Map_default || ListCache_default)(), "string": new Hash_default() }; } var mapCacheClear_default = mapCacheClear; // ../../node_modules/lodash-es/_mapCacheDelete.js init_cjs_shims(); // ../../node_modules/lodash-es/_getMapData.js init_cjs_shims(); // ../../node_modules/lodash-es/_isKeyable.js init_cjs_shims(); function isKeyable(value) { var type = typeof value; return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null; } var isKeyable_default = isKeyable; // ../../node_modules/lodash-es/_getMapData.js function getMapData(map, key) { var data = map.__data__; return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map; } var getMapData_default = getMapData; // ../../node_modules/lodash-es/_mapCacheDelete.js function mapCacheDelete(key) { var result = getMapData_default(this, key)["delete"](key); this.size -= result ? 1 : 0; return result; } var mapCacheDelete_default = mapCacheDelete; // ../../node_modules/lodash-es/_mapCacheGet.js init_cjs_shims(); function mapCacheGet(key) { return getMapData_default(this, key).get(key); } var mapCacheGet_default = mapCacheGet; // ../../node_modules/lodash-es/_mapCacheHas.js init_cjs_shims(); function mapCacheHas(key) { return getMapData_default(this, key).has(key); } var mapCacheHas_default = mapCacheHas; // ../../node_modules/lodash-es/_mapCacheSet.js init_cjs_shims(); function mapCacheSet(key, value) { var data = getMapData_default(this, key), size = data.size; data.set(key, value); this.size += data.size == size ? 0 : 1; return this; } var mapCacheSet_default = mapCacheSet; // ../../node_modules/lodash-es/_MapCache.js function MapCache(entries) { var index = -1, length = entries == null ? 0 : entries.length; this.clear(); while (++index < length) { var entry = entries[index]; this.set(entry[0], entry[1]); } } MapCache.prototype.clear = mapCacheClear_default; MapCache.prototype["delete"] = mapCacheDelete_default; MapCache.prototype.get = mapCacheGet_default; MapCache.prototype.has = mapCacheHas_default; MapCache.prototype.set = mapCacheSet_default; var MapCache_default = MapCache; // ../../node_modules/lodash-es/memoize.js var FUNC_ERROR_TEXT = "Expected a function"; function memoize(func, resolver) { if (typeof func != "function" || resolver != null && typeof resolver != "function") { throw new TypeError(FUNC_ERROR_TEXT); } var memoized = function() { var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache; if (cache.has(key)) { return cache.get(key); } var result = func.apply(this, args); memoized.cache = cache.set(key, result) || cache; return result; }; memoized.cache = new (memoize.Cache || MapCache_default)(); return memoized; } memoize.Cache = MapCache_default; var memoize_default = memoize; // ../../node_modules/lodash-es/isUndefined.js init_cjs_shims(); function isUndefined(value) { return value === void 0; } var isUndefined_default = isUndefined; // ../../libs/types/index.ts init_cjs_shims(); // ../../libs/types/accountTypes.ts init_cjs_shims(); var ledgerAccountTypes = [ "asset", "liability", "income", "expense" ]; var LedgerAccountTypeSchema = z.enum(ledgerAccountTypes); // ../../libs/types/currencyCodes.ts init_cjs_shims(); var nonISOCurrencyCodes = [ // Crypto currencies "ADA", "BTC", "DAI", "ETH", "SOL", "USDC", "USDT", "XLM", "UNI", "BCH", "LTC", "AAVE", "LINK", "MATIC", "PTS" ]; var ISOCurrencyCodes = [ // Fiat currencies "AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BTN", "BWP", "BYR", "BZD", "CAD", "CDF", "CHF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GGP", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "IMP", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLL", "SOS", "SPL", "SRD", "SVC", "SYP", "STN", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TVD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VEF", "VND", "VUV", "WST", "XAF", "XCD", "XOF", "XPF", "YER", "ZAR", "ZMW" ]; var currencyCodes = [ ...nonISOCurrencyCodes, ...ISOCurrencyCodes, "LOGICAL", "CUSTOM" ]; var accountCurrencyCodes = [...currencyCodes, "MULTI"]; var currencyModes = ["single", "multi"]; var CurrencyModeSchema = z.enum(currencyModes); var CurrencyCodeSchema = z.enum(currencyCodes); var AccountCurrencyCodeSchema = z.enum(accountCurrencyCodes); var CurrencyMatchInputSchema = z.object({ customCurrencyId: z.optional(z.string()), code: CurrencyCodeSchema }); // ../../libs/types/strings.ts init_cjs_shims(); var UNSAFE_CHARACTERS = ["#", "/", ":"]; var isUnsafeString = (value) => { return !!UNSAFE_CHARACTERS.find((character) => { return value.includes(character); }); }; var unsafePathCharacters = ["#"]; var SafePathStringSchema = z.string().superRefine((value, ctx) => { if (value === "") { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Path cannot be an empty string. Received ${value}` }); } if (value.startsWith("/") || value.endsWith("/")) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Path cannot start or end with a forward slash. Received ${value}` }); } if (value.includes("//")) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Path cannot contain consecutive forward slashes. Received ${value}` }); } if (unsafePathCharacters.find((character) => value.includes(character))) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Path cannot contain the characters: ${unsafePathCharacters.join( "," )}. Received ${value}` }); } }).brand(); var emailRegex = /^[^\s@+]+@[^\s@/]+\.[^\s@/]+$/; var EmailAddressSchema = z.string().superRefine((value, ctx) => { if (!emailRegex.test(value)) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Invalid email address. Cannot include whitespace, +, more than one @, or @ at the end. Received ${value}` }); } }).brand(); var paramRegex = /{{([^{}]*?)}}/g; var getStringParameters = memoize_default((s) => { return [...s.matchAll(paramRegex)].map((match) => match[1].trim()).filter((param) => { return param !== "__proto__"; }); }); var getStringParametersInternal = (s, params) => { getStringParameters(s).forEach((param) => { params.add(param); }); }; var SafeStringSchema = z.string().refine((s) => !isUnsafeString(s) && getStringParameters(s).length === 0, { message: `String cannot contain '#', '/', ':', or parameters in {{handlebar}} syntax` }).brand(); var DateTimeSchema = z.string().datetime().brand(); var ParameterizedString = z.string().transform((s) => { return s.replace(/\{(\s*)(.*?)\s*\{/g, "{$2{").replace(/\}(\s*)(.*?)\s*\}/g, "}$2}").replace(/\{\{(\s*)(.*?)\s*\}\}/g, "{{$2}}"); }).refine( (s) => { return /^[^{}]*({{[^{}]*}}[^{}]*)*$/m.test(s); }, { message: `Parameterized string must have exactly two left brackets followed by exactly two right brackets.` } ).refine( (s) => { const regex = /{{([^{}]*?)}}/g; const matches = [...s.trim().matchAll(regex)]; return matches.every( ([_, param]) => param !== "" && !param.includes(" ") && param[0].match(/[a-zA-Z]/) ); }, { message: `Parameters (e.g. {{param}}) must be a non-empty string beginning with an alphabetical character and may not include whitespace.` } ); var ParameterizedAmount = ({ optional, errorMessage } = {}) => { const schema = optional ? ParameterizedString.optional() : ParameterizedString; return schema.superRefine((s, ctx) => { if (!s) { return; } const withoutHandlebars = s.replace(/\{\{[^}]*\}\}/g, ""); const mathOperatorsRegex = /[*x×/÷%]/i; const firstMathOperatorMatch = withoutHandlebars.match(mathOperatorsRegex); if (firstMathOperatorMatch) { const operator = firstMathOperatorMatch[0]; ctx.addIssue({ code: z.ZodIssueCode.custom, message: errorMessage ?? `Unsupported operator "${operator}". Only + and - are allowed in expressions.` }); return; } let remaining = s.trim(); const valueRegex = /^(-?\d+|\{\{[^}]*\}*\}\})/; const plusminusRegex = /^[+-]/; let expect = "start"; while (remaining.length > 0) { switch (expect) { case "start": { const m1 = remaining.match(valueRegex); if (m1 && m1[0].length > 0) { expect = "plusminus"; remaining = remaining.slice(m1[0].length).trim(); continue; } const m2 = remaining.match(plusminusRegex); if (m2 && m2[0].length > 0) { expect = "value"; remaining = remaining.slice(m2[0].length).trim(); continue; } ctx.addIssue({ code: z.ZodIssueCode.custom, message: errorMessage ?? `Invalid expression at character "${remaining[0]}". Expressions must start with +, -, a number or {{param}}` }); return; } case "plusminus": { const m1 = remaining.match(plusminusRegex); if (m1 && m1[0].length > 0) { expect = "value"; remaining = remaining.slice(m1[0].length).trim(); continue; } ctx.addIssue({ code: z.ZodIssueCode.custom, message: errorMessage ?? `Invalid expression at character "${remaining[0]}". Expected + or - at this point.` }); return; } case "value": { const m1 = remaining.match(valueRegex); if (m1 && m1[0].length > 0) { expect = "plusminus"; remaining = remaining.slice(m1[0].length).trim(); continue; } ctx.addIssue({ code: z.ZodIssueCode.custom, message: errorMessage ?? `Invalid expression at character "${remaining[0]}". Expected a number or {{param}}` }); return; } default: { return; } } } if (expect !== "plusminus") { ctx.addIssue({ code: z.ZodIssueCode.custom, message: errorMessage ?? "Invalid expression. Unexpected end of string." }); } }); }; var safe = (splits, ...values) => SafeStringSchema.parse( splits.reduce((acc, split, i) => acc + split + (values[i] || ""), "") ); var SfnExecutionNameSchema = SafeStringSchema.superRefine( (val, ctx) => { if (val.length < 1 || val.length > 80) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Name must be between 1 and 80 characters long. Received: ${val.length}.` }); return; } if (val.startsWith("_") || val.endsWith("_")) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Name cannot start or end with an underscore.` }); return; } if (!/^[a-zA-Z0-9_-]+$/.test(val)) { ctx.addIssue({ code: z.ZodIssueCode.custom, message: `Name can only contain alphanumeric characters, hyphens, and underscores.` }); } } ).brand(); var MAX_FREEFORM_TEXT_LENGTH = 1e3; // ../../libs/types/time.ts init_cjs_shims(); var quarterMap = { Q1: ["01", "02", "03"], Q2: ["04", "05", "06"], Q3: ["07", "08", "09"], Q4: ["10", "11", "12"] }; var quarters = Object.keys(quarterMap); // ../../libs/error-utils/assert.ts function assertError(predicate, CustomError, options) { if (isUndefined_default(CustomError)) { throw new InternalError("you must pass in CustomError to assert"); } try { assert(!!predicate); } catch (cause) { const opts = typeof options === "function" ? options() : options; throw new CustomError( { ...opts, cause }, opts.message ); } } var assert_default = assertError; function assertIsError(value, options = {}) { if (!(value instanceof Error)) { throw new InternalError({ ...options, info: { ...options.info, error: value }, message: "value is not an Error" }); } } // ../../libs/error-utils/codes.ts init_cjs_shims(); var codes = { dark_reads: { mismatch: "dark_reads_mismatch", mismatch_count: "dark_reads_mismatch_count" }, request: { incompatible_filters: `incompatible_filters`, no_update_provided: `no_update_provided`, no_txs_provided: `no_txs_provided`, too_many_txs: `too_many_txs`, concurrent_request_conflict: `concurrent_request_conflict`, too_many_items_in_list_filter: `too_many_items_in_list_filter`, invalid_input_provided: `invalid_input_provided`, amount_must_be_integer: `amount_must_be_integer` }, balances: { invalid_duration: `invalid_duration`, invalid_time_range: `invalid_time_range`, unsupported_period_type: