@homedev/objector 1.2.60 → 1.2.61
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/dist/index.js +20 -20
- package/package.json +1 -1
- package/dist/index.d.ts +0 -750
package/dist/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var Ot=Object.create;var{getPrototypeOf:Mt,defineProperty:V,getOwnPropertyNames:nr}=Object;var Se=Object.prototype.hasOwnProperty;function je(e){return this[e]}var F=(e,r,t)=>{var n=nr(r);for(let o of n)if(!Se.call(e,o)&&o!=="default")V(e,o,{get:je.bind(r,o),enumerable:!0});if(t){for(let o of n)if(!Se.call(t,o)&&o!=="default")V(t,o,{get:je.bind(r,o),enumerable:!0});return t}},Et,At,Ft=(e,r,t)=>{var n=e!=null&&typeof e==="object";if(n){var o=r?Et??=new WeakMap:At??=new WeakMap,s=o.get(e);if(s)return s}t=e!=null?Ot(Mt(e)):{};let a=r||!e||!e.__esModule?V(t,"default",{value:e,enumerable:!0}):t;for(let i of nr(e))if(!Se.call(a,i))V(a,i,{get:je.bind(e,i),enumerable:!0});if(n)o.set(e,a);return a};var St=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports);var jt=(e)=>e;function Dt(e,r){this[e]=jt.bind(null,r)}var k=(e,r)=>{for(var t in r)V(e,t,{get:r[t],enumerable:!0,configurable:!0,set:Dt.bind(r,t)})};var dt=St((xi,yt)=>{var{defineProperty:qe,getOwnPropertyNames:Wn,getOwnPropertyDescriptor:Nn}=Object,In=Object.prototype.hasOwnProperty,mt=new WeakMap,Ln=(e)=>{var r=mt.get(e),t;if(r)return r;if(r=qe({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")Wn(e).map((n)=>!In.call(r,n)&&qe(r,n,{get:()=>e[n],enumerable:!(t=Nn(e,n))||t.enumerable}));return mt.set(e,r),r},_n=(e,r)=>{for(var t in r)qe(e,t,{get:r[t],enumerable:!0,configurable:!0,set:(n)=>r[t]=()=>n})},gt={};_n(gt,{splitWithQuotes:()=>Tn,splitNested:()=>Un});yt.exports=Ln(gt);var Un=(e,r,t="(",n=")")=>{let o=0,s="",a=[];for(let i of e){if(s+=i,i===t)o++;if(i===n)o--;if(o===0&&i===r)a.push(s.slice(0,-1)),s=""}if(s)a.push(s);return a},Tn=(e,r=",")=>{let t=[],n=e.length,o=r.length,s=0,a=(i)=>{if(i+o>n)return!1;for(let l=0;l<o;l++)if(e[i+l]!==r[l])return!1;return!0};while(s<n){while(s<n&&e[s]===" ")s++;if(s>=n)break;let i="",l=e[s]==='"'||e[s]==="'";if(l){let m=e[s++];while(s<n&&e[s]!==m)i+=e[s++];if(s<n)s++}else{while(s<n&&!a(s)){let m=e[s];if(m==='"'||m==="'"){i+=m,s++;while(s<n&&e[s]!==m)i+=e[s++];if(s<n)i+=e[s++]}else i+=e[s++]}i=i.trim()}if(i)t.push({value:i,quoted:l});if(a(s))s+=o}return t}});var R={};k(R,{writeOutputs:()=>z,writeOutput:()=>me,writeFormat:()=>ce,variable:()=>vr,tokenize:()=>xe,toObjectWithKey:()=>_e,toObject:()=>ee,toList:()=>U,stripIndent:()=>Ze,sortBy:()=>Be,snake:()=>X,sharedFunction:()=>Or,select:()=>E,section:()=>hr,processFields:()=>j,pascal:()=>Q,padBlock:()=>N,nonNullMap:()=>Ue,navigate:()=>de,mergeAll:()=>Y,merge:()=>W,makeFieldProcessorMap:()=>D,makeFieldProcessorList:()=>Re,makeFieldProcessor:()=>H,macro:()=>wr,locate:()=>_,loadFormat:()=>q,key:()=>br,importList:()=>ge,importGlob:()=>Ie,globMap:()=>J,getProcessor:()=>Z,getArgs:()=>fe,find:()=>Xe,exists:()=>B,encoder:()=>Mr,defined:()=>Te,deepClone:()=>$,decoder:()=>Er,conditionPredicates:()=>C,changeCase:()=>G,capital:()=>oe,camel:()=>se,asyncMap:()=>Ye,ObjectorPlugin:()=>re,Objector:()=>ht,NavigateResult:()=>b,NavigateAction:()=>ye,Logger:()=>Ae,AsyncFunction:()=>Ve});var $e={};k($e,{processFields:()=>j,makeFieldProcessorMap:()=>D,makeFieldProcessorList:()=>Re,makeFieldProcessor:()=>H,getProcessor:()=>Z,getArgs:()=>fe});var kt=Object.create,{getPrototypeOf:Rt,defineProperty:or,getOwnPropertyNames:$t}=Object,Ct=Object.prototype.hasOwnProperty,Wt=(e,r,t)=>{t=e!=null?kt(Rt(e)):{};let n=r||!e||!e.__esModule?or(t,"default",{value:e,enumerable:!0}):t;for(let o of $t(e))if(!Ct.call(n,o))or(n,o,{get:()=>e[o],enumerable:!0});return n},Nt=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),It=Nt((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,s=Object.prototype.hasOwnProperty,a=new WeakMap,i=(u)=>{var c=a.get(u),h;if(c)return c;if(c=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((f)=>!s.call(c,f)&&t(c,f,{get:()=>u[f],enumerable:!(h=o(u,f))||h.enumerable}));return a.set(u,c),c},l=(u,c)=>{for(var h in c)t(u,h,{get:c[h],enumerable:!0,configurable:!0,set:(f)=>c[h]=()=>f})},m={};l(m,{splitWithQuotes:()=>y,splitNested:()=>d}),r.exports=i(m);var d=(u,c,h="(",f=")")=>{let w=0,p="",O=[];for(let g of u){if(p+=g,g===h)w++;if(g===f)w--;if(w===0&&g===c)O.push(p.slice(0,-1)),p=""}if(p)O.push(p);return O},y=(u,c=",")=>{let h=[],f=u.length,w=c.length,p=0,O=(g)=>{if(g+w>f)return!1;for(let M=0;M<w;M++)if(u[g+M]!==c[M])return!1;return!0};while(p<f){while(p<f&&u[p]===" ")p++;if(p>=f)break;let g="",M=u[p]==='"'||u[p]==="'";if(M){let v=u[p++];while(p<f&&u[p]!==v)g+=u[p++];if(p<f)p++}else{while(p<f&&!O(p)){let v=u[p];if(v==='"'||v==="'"){g+=v,p++;while(p<f&&u[p]!==v)g+=u[p++];if(p<f)g+=u[p++]}else g+=u[p++]}g=g.trim()}if(g)h.push({value:g,quoted:M});if(O(p))p+=w}return h}}),Lt=Wt(It(),1),L;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(L||={});class S{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new S(0);static _noExplore=new S(2);static _skipSiblings=new S(1);static _deleteParent=new S(4);static ReplaceParent(e,r){return new S(3,e,void 0,r)}static SkipSiblings(){return S._skipSiblings}static Explore(){return S._explore}static NoExplore(){return S._noExplore}static DeleteParent(){return S._deleteParent}static MergeParent(e){return new S(5,e)}static ReplaceItem(e,r){return new S(6,e,r)}static DeleteItem(e){return new S(7,void 0,e)}}var _t=async(e,r)=>{let t=new WeakSet,n=[],o=[],s=async(i,l,m)=>{let d=i===null,y=d?S.Explore():await r({key:i,value:l,path:n,parent:m,parents:o});if(l&&typeof l==="object"&&y.action===0){if(t.has(l))return y;if(t.add(l),!d)n.push(i),o.push(m);let u=l;while(await a(u,i,m))u=m[i];if(!d)o.pop(),n.pop()}return y},a=async(i,l,m)=>{let d=Object.keys(i),y=d.length;for(let u=0;u<y;u++){let c=d[u],h=i[c],f=await s(c,h,i),w=f.action;if(w===0||w===2)continue;if(w===6){if(i[c]=f.by,f.skipSiblings)return;continue}if(w===7){if(delete i[c],f.skipSiblings)return;continue}if(w===1)return;if(w===3){if(l===null)throw Error("Cannot replace root object");if(m[l]=f.by,f.reexplore)return!0;return}if(w===4){if(l===null)throw Error("Cannot delete root object");delete m[l];return}if(w===5)delete i[c],Object.assign(i,f.by)}};await s(null,e,null)},Ut=Object.create,{getPrototypeOf:Tt,defineProperty:sr,getOwnPropertyNames:Bt}=Object,Yt=Object.prototype.hasOwnProperty,Kt=(e,r,t)=>{t=e!=null?Ut(Tt(e)):{};let n=r||!e||!e.__esModule?sr(t,"default",{value:e,enumerable:!0}):t;for(let o of Bt(e))if(!Yt.call(n,o))sr(n,o,{get:()=>e[o],enumerable:!0});return n},Qt=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Xt=Qt((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,s=Object.prototype.hasOwnProperty,a=new WeakMap,i=(u)=>{var c=a.get(u),h;if(c)return c;if(c=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((f)=>!s.call(c,f)&&t(c,f,{get:()=>u[f],enumerable:!(h=o(u,f))||h.enumerable}));return a.set(u,c),c},l=(u,c)=>{for(var h in c)t(u,h,{get:c[h],enumerable:!0,configurable:!0,set:(f)=>c[h]=()=>f})},m={};l(m,{splitWithQuotes:()=>y,splitNested:()=>d}),r.exports=i(m);var d=(u,c,h="(",f=")")=>{let w=0,p="",O=[];for(let g of u){if(p+=g,g===h)w++;if(g===f)w--;if(w===0&&g===c)O.push(p.slice(0,-1)),p=""}if(p)O.push(p);return O},y=(u,c=",")=>{let h=[],f=u.length,w=c.length,p=0,O=(g)=>{if(g+w>f)return!1;for(let M=0;M<w;M++)if(u[g+M]!==c[M])return!1;return!0};while(p<f){while(p<f&&u[p]===" ")p++;if(p>=f)break;let g="",M=u[p]==='"'||u[p]==="'";if(M){let v=u[p++];while(p<f&&u[p]!==v)g+=u[p++];if(p<f)p++}else{while(p<f&&!O(p)){let v=u[p];if(v==='"'||v==="'"){g+=v,p++;while(p<f&&u[p]!==v)g+=u[p++];if(p<f)g+=u[p++]}else g+=u[p++]}g=g.trim()}if(g)h.push({value:g,quoted:M});if(O(p))p+=w}return h}}),Gt=Kt(Xt(),1),Pt=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,Vt=/^([^[\]]*)\[([^\]]*)]$/,De=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return x(r,o,t)?.toString()}return n?e:void 0},xt=(e,r,t,n)=>{let o=De(r,t,n);if(o)return x(e,o,n);let s=Pt.exec(r);if(s){let[,i,l,m]=s,d=De(i.trim(),t,n,!0),y=De(m.trim(),t,n,!0);if(Array.isArray(e)&&(l==="="||l==="==")&&d)return e.find((u)=>u?.[d]==y)}let a=Vt.exec(r);if(a){let[,i,l]=a;return e?.[i]?.[l]}return e?.[r]},x=(e,r,t)=>{let n=void 0,o=void 0,s=r??"",a=(y)=>{if(!y)return[y,!1];return y.endsWith("?")?[y.substring(0,y.length-1),!0]:[y,!1]},i=(y,u)=>{let[c,h]=a(u.pop());if(!c){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return y}let f=xt(y,c,e,t);if(f===void 0){if(h||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${c}" in "${s}"`)}return n=y,o=c,i(f,u)},l=Gt.splitNested(s,t?.separator??".","{","}"),m=void 0;if(l.length>0&&l[l.length-1].startsWith("?="))m=l.pop()?.substring(2);l.reverse();let d=i(e,l);if(d===void 0)return m??t?.defaultValue;return d},ir=(e,r)=>{if(typeof e.value==="string"){if(e.quoted)return e.value;if(e.value.startsWith("[")&&e.value.endsWith("]")){let t=e.value.slice(1,-1);if(t.trim()==="")return[];return t.split(";").map((n)=>{let o=n.trim();if(!isNaN(+o))return+o;return o})}if(e.value.startsWith("{")&&e.value.endsWith("}")){if(e.value.slice(1,-1).trim()==="")return{}}if(e.value==="null")return null;if(e.value==="undefined")return;if(e.value.startsWith("@"))return e.value.slice(1);if(!isNaN(+e.value))return+e.value}return r(e.value)},pe=(e,r,t,n,o,s)=>{let a=n?.(e)??e,i=o(a);if(i[0])return i[1];if(!r){let l=x(t,e),m=o(l);if(m[0])return m[1]}throw Error(s)},lr=(e,r,t,n,o)=>{let s=typeof e.types==="function"?e.types(n,r.value,o):e.types?.[n];if(!s||s==="ref")return ir(r,(i)=>x(t,i));let a=ir(r,()=>r.value);if(Array.isArray(s)){if(!s.includes(a))throw Error(`Argument ${n.toString()} must be one of [${s.join(", ")}]: ${a}`);return a}if(typeof s==="string"){if(s.endsWith("?")){let i=s.slice(0,-1);if(r.value==="null")return S.ReplaceItem(null);if(r.value==="undefined")return S.ReplaceItem(void 0);if(r.value==="")return"";s=i}switch(s){case"any":return a;case"array":return pe(a,r.quoted,t,null,(i)=>[Array.isArray(i),i],`Argument ${n.toString()} must be an array: ${a}`);case"object":return pe(a,r.quoted,t,null,(i)=>[typeof i==="object"&&i!==null,i],`Argument ${n.toString()} must be an object: ${a}`);case"number":return pe(a,r.quoted,t,(i)=>Number(i),(i)=>[!isNaN(i),i],`Argument ${n.toString()} must be a number: ${a}`);case"boolean":return pe(a,r.quoted,t,null,(i)=>{if([!0,"true","1",1,"yes","on"].includes(i))return[!0,!0];if([!1,"false","0",0,"no","off"].includes(i))return[!0,!1];if([null,"null","undefined",void 0,""].includes(i))return[!0,!1];if(Array.isArray(i))return[!0,i.length>0];return[!1,!1]},`Argument ${n.toString()} must be a boolean: ${a}`);case"string":return a.toString();default:throw Error(`Unknown type for argument ${n.toString()}: ${s}`)}}return s(a,t,n,r.quoted)},Z=(e,r)=>{let t=e?.[r];if(t===void 0)throw Error(`Unhandled field processor type: ${r}`);return typeof t==="function"?{options:{},fn:t}:{options:t,fn:t.fn}},ur=(e)=>!e.quoted&&e.value.startsWith("."),Zt=(e)=>{let r={};for(let t of e){if(!ur(t))continue;let n=t.value.indexOf("="),o=n>-1?t.value.slice(1,n):t.value.slice(1),s=n>-1?t.value.slice(n+1):"";if(s.length>=2){let a=s[0],i=s[s.length-1];if(a==='"'&&i==='"'||a==="'"&&i==="'")s=s.slice(1,-1)}if(!r[o])r[o]=[];r[o].push(s)}return r},fe=(e,r,t)=>{let n=Lt.splitWithQuotes(e??""),o=Zt(n),s=n.filter((i)=>!ur(i)),a=r.options.processArgs===!1?[]:s.map((i,l)=>lr(r.options,i,t,l,s));return{rawArgs:s,parsedArgs:a,tags:o}},Ht=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},qt=(e,r)=>r.keys!==void 0&&e.key.startsWith(".")&&r.keys[e.key.substring(1)]!==void 0,Jt=async(e,r,t,n)=>{let{key:o,parent:s}=e,a=Z(n.keys,o.substring(1));if(a.options.processArgs!==!1&&(typeof a.options.types==="function"||a.options.types?.[0]!==void 0))e.value=lr(a.options,{value:e.value,quoted:!1},t,0,[]);if(typeof e.value!=="string")await j(e.value,{...n,root:{...t,parent:e.parent,parents:e.parents},filters:[...n.filters??[],...a.options.filters??[]]});let i=await a.fn({path:r,root:t,parent:s,key:o,options:n,value:e.value,args:[],rawArgs:[],tags:{}});return Ht(i)?i:S.ReplaceParent(i)},ar=(e)=>{let r=e.split(/\r?\n/),t=r.filter((o)=>o.trim().length>0).map((o)=>/^[ \t]*/.exec(o)?.[0].length??0),n=t.length>0?Math.min(...t):0;if(n===0)return e;return r.map((o)=>o.slice(n)).join(`
|
|
2
|
-
`)},
|
|
3
|
-
`;if(
|
|
4
|
-
`).map((
|
|
5
|
-
`);let
|
|
6
|
-
`))
|
|
7
|
-
`;let
|
|
8
|
-
`,
|
|
9
|
-
(${n})`)}}),e},H=(e,r)=>r?{fn:(t)=>e(...t.args),types:r}:(t)=>e(...t.args),Re=(e,r)=>Object.fromEntries(e.map((t)=>[t.name,H(t,r?.types?.[t.name])])),D=(e,r)=>Object.fromEntries((r?.keys??Object.keys(e)).map((t)=>[t,H(e[t],r?.types?.[t])]));var Le={};k(Le,{writeOutputs:()=>z,writeOutput:()=>me,writeFormat:()=>ce,locate:()=>_,loadFormat:()=>q,importList:()=>ge,importGlob:()=>Ie,globMap:()=>J,exists:()=>B});import mr from"fs/promises";import Ce from"path";import an from"fs/promises";import ln from"path";import un from"fs/promises";import pn from"fs/promises";import dr from"fs/promises";import gr from"path";import fn from"fs/promises";import We from"path";import yr from"path";var B=async(e)=>{try{return await mr.access(e,mr.constants.R_OK),!0}catch{return!1}},_=async(e,r)=>{let t=!Ce.isAbsolute(e)&&r?["",...r]:[""];for(let n of t){let o=Ce.join(n,e);if(await B(o))return Ce.resolve(o)}throw Error(`File not found: "${e}"`)},q=async(e,r)=>{let t=await _(e,r?.dirs),n=await an.readFile(t,"utf-8"),o=ln.dirname(t),s={text:{fn:(i)=>i,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.parse,matching:["\\.json$"]},...r?.parsers},a=r?.format?s[r.format]:Object.values(s).find((i)=>i.matching?.some((l)=>new RegExp(l).test(e)));if(!a)throw Error(`Unsupported format for file "${e}" and no matching parser found`);return{content:await a.fn(n),fullPath:t,folderPath:o}},ce=async(e,r,t)=>{let n={text:{fn:(s)=>s,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.stringify,matching:["\\.json$"]},...t?.encoders},o=t?.format?n[t.format]:Object.values(n).find((s)=>s.matching?.some((a)=>new RegExp(a).test(e)));if(!o)throw Error(`Unsupported format for file "${e}" and no matching encoder found`);await un.writeFile(e,await o.fn(r))},J=async(e,r)=>{if(typeof e==="string"&&!e.includes("*"))return await r.map(e,0,[]);let t=await Array.fromAsync(pn.glob(e,{cwd:r.cwd})),n=r.filter?t.filter(r.filter):t;return await Promise.all(n.map(r.map))},z=async(e,r)=>{if(r?.targetDirectory&&r?.removeFirst)try{await dr.rm(r?.targetDirectory,{recursive:!0,force:!0})}catch(t){throw Error(`Failed to clean the output directory: ${t.message}`)}for(let t of e)await me(t,r)},me=async(e,r)=>{let t=gr.join(r?.targetDirectory??".",e.name),n=gr.dirname(t);if(r?.classes){if(e.class!==void 0&&!r.classes.includes(e.class))return;if(r.classRequired&&e.class===void 0)throw Error(`Output "${e.name}" is missing class field`)}if(r?.writing?.(e)===!1)return;try{await dr.mkdir(n,{recursive:!0})}catch(o){throw Error(`Failed to create target directory "${n}" for output "${t}": ${o.message}`)}try{await ce(t,e.value,{format:e.type??"text"})}catch(o){throw Error(`Failed to write output "${t}": ${o.message}`)}},Ne=(e)=>e?yr.isAbsolute(e)?e:yr.join(process.cwd(),e):process.cwd(),ge=async(e,r)=>{let t=[];for(let n of e)try{let o=!We.isAbsolute(n)?We.join(Ne(r?.cwd),n):n;if(r?.filter?.(o)===!1)continue;let s=await import(o);if(r?.resolveDefault==="only"&&!s.default)throw Error(`Module ${n} does not have a default export`);let a=r?.resolveDefault?s.default??s:s,i=r?.map?await r.map(a,n):a;if(i!==void 0)t.push(i)}catch(o){if(r?.fail?.(n,o)===!1)continue;throw Error(`Failed to import module ${n}: ${o.message??o}`)}return t},Ie=async(e,r)=>{let t=[];for(let n of e){let o=(await Array.fromAsync(fn.glob(n,{cwd:Ne(r?.cwd)}))).map((s)=>We.join(Ne(r?.cwd),s));t.push(...await ge(o,r))}return t};var Ke={};k(Ke,{toObjectWithKey:()=>_e,toObject:()=>ee,toList:()=>U,sortBy:()=>Be,nonNullMap:()=>Ue,defined:()=>Te,deepClone:()=>$,asyncMap:()=>Ye});var U=(e,r="name")=>Object.entries(e).map(([t,n])=>({[r]:t,...n})),_e=(e,r="name")=>Object.fromEntries(e.map((t)=>[t[r],t])),ee=(e,r="name")=>Object.fromEntries(e.map((t)=>{let{[r]:n,...o}=t;return[n,o]})),Ue=(e,r)=>{if(!e)return[];let t=[],n=0;for(let o of e)if(o!==null&&o!==void 0)t.push(r(o,n,e)),n++;return t},Te=(e,r="Value is undefined")=>{if(e===void 0||e===null)throw Error(r);return e},Be=(e,r,t=(n,o)=>n-o)=>e.slice().sort((n,o)=>t(r(n),r(o))),Ye=async(e,r)=>Promise.all(e.map(r)),$=(e)=>{if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};var Qe={};k(Qe,{variable:()=>vr,sharedFunction:()=>Or,section:()=>hr,macro:()=>wr,key:()=>br,encoder:()=>Mr,decoder:()=>Er,ObjectorPlugin:()=>re});class re{o;context;constructor(e){this.o=e}}var wr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.sources({[o]:(s)=>n.apply({...this,context:s},s.args)})})},hr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.sections({[o]:(s)=>{return n.call({...this,context:s},s.section)}})})},br=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.keys({[o]:(s)=>n.call({...this,context:s},s.value)})})},vr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.variables({[o]:n})})},Or=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.functions({[o]:n})})},Mr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.encoders({[o]:{fn:n}})})},Er=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.decoders({[o]:{fn:n}})})};var ft={};k(ft,{defaultProcessors:()=>He});var Ar={};k(Ar,{navigate:()=>de,find:()=>Xe,NavigateResult:()=>b,NavigateAction:()=>ye});var ye;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(ye||={});class b{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new b(0);static _noExplore=new b(2);static _skipSiblings=new b(1);static _deleteParent=new b(4);static ReplaceParent(e,r){return new b(3,e,void 0,r)}static SkipSiblings(){return b._skipSiblings}static Explore(){return b._explore}static NoExplore(){return b._noExplore}static DeleteParent(){return b._deleteParent}static MergeParent(e){return new b(5,e)}static ReplaceItem(e,r){return new b(6,e,r)}static DeleteItem(e){return new b(7,void 0,e)}}var de=async(e,r)=>{let t=new WeakSet,n=[],o=[],s=async(i,l,m)=>{let d=i===null,y=d?b.Explore():await r({key:i,value:l,path:n,parent:m,parents:o});if(l&&typeof l==="object"&&y.action===0){if(t.has(l))return y;if(t.add(l),!d)n.push(i),o.push(m);let u=l;while(await a(u,i,m))u=m[i];if(!d)o.pop(),n.pop()}return y},a=async(i,l,m)=>{let d=Object.keys(i),y=d.length;for(let u=0;u<y;u++){let c=d[u],h=i[c],f=await s(c,h,i),w=f.action;if(w===0||w===2)continue;if(w===6){if(i[c]=f.by,f.skipSiblings)return;continue}if(w===7){if(delete i[c],f.skipSiblings)return;continue}if(w===1)return;if(w===3){if(l===null)throw Error("Cannot replace root object");if(m[l]=f.by,f.reexplore)return!0;return}if(w===4){if(l===null)throw Error("Cannot delete root object");delete m[l];return}if(w===5)delete i[c],Object.assign(i,f.by)}};await s(null,e,null)},Xe=async(e,r)=>{let t=[];return await de(e,(n)=>{if(r([...n.path,n.key].join("."),n.value))t.push(n.value);return b.Explore()}),t};var Fr=(e)=>({output:(r)=>{delete r.parent[r.key];for(let t of Array.isArray(r.value)?r.value:[r.value])if(typeof t==="string")e.output({name:t,value:r.parent});else e.output({...t,value:t.value??r.parent});return b.SkipSiblings()}});import cn from"path";var Sr=(e)=>({load:async(r)=>{let t=r.options.globalContext;for(let{file:n}of Array.isArray(r.value)?r.value:[r.value]){if(!n)throw Error("File reference required");await e.load(n,t.file&&cn.dirname(t.file))}return b.DeleteItem()}});var jr={};k(jr,{mergeAll:()=>Y,merge:()=>W});var W=(e,r,t)=>{for(let n of Object.keys(r)){if(e[n]===void 0)continue;let o=r[n],s=e[n];if(typeof s!==typeof o||Array.isArray(s)!==Array.isArray(o)){let i=t?.mismatch?.(n,s,o,e,r);if(i!==void 0){r[n]=i;continue}throw Error(`Type mismatch: ${n}`)}let a=t?.mode?.(n,s,o,e,r)??r[".merge"]??"merge";switch(a){case"source":r[n]=s;continue;case"target":continue;case"skip":delete r[n],delete e[n];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${a}`)}if(typeof s==="object")if(Array.isArray(s))o.push(...s);else{if(t?.navigate?.(n,s,o,e,r)===!1)continue;W(s,o,t)}else{if(s===o)continue;let i=t?.conflict?.(n,s,o,e,r);r[n]=i===void 0?o:i}}for(let n of Object.keys(e))if(r[n]===void 0)r[n]=e[n]},Y=(e,r)=>{let t={};for(let n of e.toReversed())W(n,t,r);return t};var Dr={};k(Dr,{CacheManager:()=>we});class we{cache=new Map;maxSize;constructor(e=100){this.maxSize=e}get(e){return this.cache.get(e)}set(e,r){this.evictIfNeeded(),this.cache.set(e,r)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}setMaxSize(e){this.maxSize=e}size(){return this.cache.size}evictIfNeeded(){if(this.cache.size>=this.maxSize){let e=null,r=1/0;for(let[t,n]of this.cache.entries())if(n.timestamp<r)r=n.timestamp,e=t;if(e)this.cache.delete(e)}}}var Rr={};k(Rr,{select:()=>E});var mn=Object.create,{getPrototypeOf:gn,defineProperty:kr,getOwnPropertyNames:yn}=Object,dn=Object.prototype.hasOwnProperty,wn=(e,r,t)=>{t=e!=null?mn(gn(e)):{};let n=r||!e||!e.__esModule?kr(t,"default",{value:e,enumerable:!0}):t;for(let o of yn(e))if(!dn.call(n,o))kr(n,o,{get:()=>e[o],enumerable:!0});return n},hn=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),bn=hn((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,s=Object.prototype.hasOwnProperty,a=new WeakMap,i=(u)=>{var c=a.get(u),h;if(c)return c;if(c=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((f)=>!s.call(c,f)&&t(c,f,{get:()=>u[f],enumerable:!(h=o(u,f))||h.enumerable}));return a.set(u,c),c},l=(u,c)=>{for(var h in c)t(u,h,{get:c[h],enumerable:!0,configurable:!0,set:(f)=>c[h]=()=>f})},m={};l(m,{splitWithQuotes:()=>y,splitNested:()=>d}),r.exports=i(m);var d=(u,c,h="(",f=")")=>{let w=0,p="",O=[];for(let g of u){if(p+=g,g===h)w++;if(g===f)w--;if(w===0&&g===c)O.push(p.slice(0,-1)),p=""}if(p)O.push(p);return O},y=(u,c=",")=>{let h=[],f=u.length,w=c.length,p=0,O=(g)=>{if(g+w>f)return!1;for(let M=0;M<w;M++)if(u[g+M]!==c[M])return!1;return!0};while(p<f){while(p<f&&u[p]===" ")p++;if(p>=f)break;let g="",M=u[p]==='"'||u[p]==="'";if(M){let v=u[p++];while(p<f&&u[p]!==v)g+=u[p++];if(p<f)p++}else{while(p<f&&!O(p)){let v=u[p];if(v==='"'||v==="'"){g+=v,p++;while(p<f&&u[p]!==v)g+=u[p++];if(p<f)g+=u[p++]}else g+=u[p++]}g=g.trim()}if(g)h.push({value:g,quoted:M});if(O(p))p+=w}return h}}),vn=wn(bn(),1),On=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,Mn=/^([^[\]]*)\[([^\]]*)]$/,Ge=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return E(r,o,t)?.toString()}return n?e:void 0},En=(e,r,t,n)=>{let o=Ge(r,t,n);if(o)return E(e,o,n);let s=On.exec(r);if(s){let[,i,l,m]=s,d=Ge(i.trim(),t,n,!0),y=Ge(m.trim(),t,n,!0);if(Array.isArray(e)&&(l==="="||l==="==")&&d)return e.find((u)=>u?.[d]==y)}let a=Mn.exec(r);if(a){let[,i,l]=a;return e?.[i]?.[l]}return e?.[r]},E=(e,r,t)=>{let n=void 0,o=void 0,s=r??"",a=(y)=>{if(!y)return[y,!1];return y.endsWith("?")?[y.substring(0,y.length-1),!0]:[y,!1]},i=(y,u)=>{let[c,h]=a(u.pop());if(!c){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return y}let f=En(y,c,e,t);if(f===void 0){if(h||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${c}" in "${s}"`)}return n=y,o=c,i(f,u)},l=vn.splitNested(s,t?.separator??".","{","}"),m=void 0;if(l.length>0&&l[l.length-1].startsWith("?="))m=l.pop()?.substring(2);l.reverse();let d=i(e,l);if(d===void 0)return m??t?.defaultValue;return d};var he=(e)=>{if(typeof e.value==="string")return e.parent;let r=e.value.model;if(!r)return e.parent;if(typeof r==="string")return E(e.root,r);return r};var be=(e)=>{if(typeof e.value==="string")return E(e.root,e.value);if(Array.isArray(e.value))return e.value;let r=e.value;if(typeof r.from==="string")return E(e.root,r.from);return r.from};var ve=async(e,r)=>{let t=e.value;if(t.selector===void 0)return r;if(typeof t.selector!=="string"){let n=JSON.parse(JSON.stringify(t.selector));return await j(n,{...e.options,root:{...e.root,result:r}}),n}return await E({...e.root,result:r},t.selector)};var $r={};k($r,{PathManager:()=>T});import K from"path";class T{constructor(){}static normalize(e){return K.normalize(K.resolve(e))}static resolveInContext(e,r){let t=r??process.cwd(),n=K.isAbsolute(e)?e:K.join(t,e);return this.normalize(n)}static isDirectoryPattern(e){return e.endsWith("/")}static isGlobPattern(e){return e.includes("*")}static toAbsolute(e,r){if(K.isAbsolute(e))return e;return K.join(r??process.cwd(),e)}}var Cr={};k(Cr,{conditionPredicatesTypes:()=>te,conditionPredicates:()=>C});var C={and:(...e)=>e.every((r)=>!!r),or:(...e)=>e.some((r)=>!!r),xor:(...e)=>e.filter((r)=>!!r).length===1,true:(...e)=>e.every((r)=>!!r),false:(...e)=>e.every((r)=>!r),eq:(...e)=>e.every((r)=>r===e[0]),ne:(...e)=>e.some((r)=>r!==e[0]),lt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<r),le:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<=r),gt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>r),ge:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>=r),in:(e,r)=>{if(Array.isArray(r))return r.includes(e);if(typeof e==="string")return e.includes(r);if(Array.isArray(e))return e.includes(r);return!1},notin:(e,r)=>!C.in(e,r),contains:(e,r)=>e.includes(r),notcontains:(e,r)=>!e.includes(r),containsi:(e,r)=>e.toLowerCase().includes(r.toLowerCase()),notcontainsi:(e,r)=>!e.toLowerCase().includes(r.toLowerCase()),null:(...e)=>e.every((r)=>r===null||r===void 0),notnull:(...e)=>e.every((r)=>r!==null&&r!==void 0),empty:(...e)=>e.every((r)=>r===""),notempty:(...e)=>e.every((r)=>r!==""),nullorempty:(...e)=>e.every((r)=>r===null||r===void 0||r===""),notnullorempty:(...e)=>e.every((r)=>r!==null&&r!==void 0&&r!=="")},te={and:()=>"boolean",or:()=>"boolean",xor:()=>"boolean",true:()=>"boolean",false:()=>"boolean",lt:()=>"number",le:()=>"number",gt:()=>"number",ge:()=>"number"};var Wr=()=>({each:{filters:[/select|model/],fn:async(e)=>{let r=e.value;delete e.parent[e.key];let t=await be(e),n=await he(e);if(!Array.isArray(t))throw Error('Key "each" requires a source list');if(n===void 0)throw Error('Key "each" must define a model');if(r.extend?.model)n=Y([r.model,...Array.isArray(r.extend.model)?r.extend.model:[r.extend.model]]);let o=[];for(let s=0;s<t.length;s++){let a=$(n);if(await j(a,{...e.options,root:{...e.root,index:s,item:t[s],instance:a}}),r.extend?.result){let i=r.extend.result;a=Y([a,...Array.isArray(i)?i:[i]])}o.push(await ve(e,a))}return o}}});var Nr=()=>({map:{filters:[/select|model/],fn:async(e)=>{delete e.parent[e.key];let r=await be(e),t=await he(e);if(!Array.isArray(r))throw Error('Key "map" requires a source list');if(t===void 0)throw Error('Key "map" must define a model');let n=[];for(let o=0;o<r.length;o++){let s=$(t);await j(s,{...e.options,root:{...e.root,index:o,item:r[o],instance:s}}),n.push(await ve(e,s))}return n}}});var Ir=()=>({concat:async(e)=>{let r=[];for(let t of Array.isArray(e.value)?e.value:[e.value])r.push(...await E(e.root,t));return r.filter((t)=>t!==void 0)}});var Lr=()=>({extends:async(e)=>{let r=async(t,n)=>{for(let o of Array.isArray(n)?n:[n]){let s=await E(e.root,o),a=$(s);if(a[e.key])await r(a,a[e.key]);await j(a,{...e.options}),W(a,t),delete t[e.key]}};return await r(e.parent,e.value),b.Explore()},group:(e)=>{let r=e.root.parent,t=e.value,{items:n,...o}=t;return t.items.forEach((s)=>r.push({...o,...s})),b.DeleteParent()}});var _r=(e)=>({skip:{types:{0:"boolean"},fn:(r)=>r.value?b.DeleteParent():b.DeleteItem()},metadata:({path:r,value:t})=>{return e.metadata(r,t),b.DeleteItem()},if:{types:{0:"boolean"},fn:async(r)=>{let t=r.parent[".then"],n=r.parent[".else"];if(t!==void 0)delete r.parent[".then"];if(n!==void 0)delete r.parent[".else"];let o=r.value?t:n;if(o===void 0)return b.DeleteItem();if(typeof o==="string")return(await j({value:o},{...r.options,root:{...r.root}})).value;return b.ReplaceParent(o,!0)}},switch:(r)=>{let t=r.value;if(!t.cases)throw Error("Missing cases for switch");if(t.cases[t.from]!==void 0)return b.ReplaceParent(t.cases[t.from],!0);if(t.default!==void 0)return b.ReplaceParent(t.default,!0);return b.DeleteParent()}});var Ur=()=>({from:async({root:e,parent:r,value:t})=>{let n=await E(e,t);if(n===null||n===void 0)throw Error(`Unable to resolve reference: ${t}`);if(r.content){if(Array.isArray(r.content)&&Array.isArray(n))return[...n,...r.content];return W(n,r.content),r.content}return n}});import Tr from"node:vm";var Br=(e)=>({modules:async(r)=>{for(let[t,n]of Object.entries(r.value)){let o=Tr.createContext({console,objector:e,document:r.root}),s=new Tr.SourceTextModule(n,{identifier:t,context:o});await s.link((a)=>{throw Error(`Module ${a} is not allowed`)}),await s.evaluate(),e.sources(Object.fromEntries(Object.entries(s.namespace).map(([a,i])=>[`${t}.${a}`,(l)=>i(l,...l.args)])))}return b.DeleteItem()}});var Yr=()=>({try:{fn:(e)=>{let r=e.parent[".catch"];if(r!==void 0)delete e.parent[".catch"];try{return e.value}catch(t){if(r!==void 0)return r;return b.DeleteItem()}}}});var Kr=()=>({let:{fn:(e)=>{let r=e.value;return Object.assign(e.root,r),b.DeleteItem()}}});var Qr=()=>({tap:{fn:(e)=>{return console.log(`[tap] ${e.path}:`,e.value),e.value}}});var An=(e,r)=>{let t=r.section.config.using,n=e.getFunctions();return t?Object.fromEntries(t.map((o)=>{if(o in n)return[o,n[o]];if(o in r.root)return[o,r.root[o]];throw Error(`Function or variable "${o}" not found for script section`)})):n},Pe=(e,r,t,n,o=[])=>{let s=An(e,t),a=["section","context","config","system",...Object.keys(s),...o],i=[r,t.root,t.section.config,e,...Object.values(s)];return[new Ve(...a,n).bind(t),i]},Fn=(e,r)=>{let t={write:(...n)=>{return r.push(...n),t},writeLine:(...n)=>{return r.push(...n.map((o)=>o+`
|
|
1
|
+
var Ar=Object.create;var{getPrototypeOf:ro,defineProperty:Q,getOwnPropertyNames:Er,getOwnPropertyDescriptor:to}=Object,Qe=Object.prototype.hasOwnProperty;function Xe(e){return this[e]}var R=(e,r,t)=>{var n=Er(r);for(let o of n)if(!Qe.call(e,o)&&o!=="default")Q(e,o,{get:Xe.bind(r,o),enumerable:!0});if(t){for(let o of n)if(!Qe.call(t,o)&&o!=="default")Q(t,o,{get:Xe.bind(r,o),enumerable:!0});return t}},no,oo,io=(e,r,t)=>{var n=e!=null&&typeof e==="object";if(n){var o=r?no??=new WeakMap:oo??=new WeakMap,i=o.get(e);if(i)return i}t=e!=null?Ar(ro(e)):{};let l=r||!e||!e.__esModule?Q(t,"default",{value:e,enumerable:!0}):t;for(let a of Er(e))if(!Qe.call(l,a))Q(l,a,{get:Xe.bind(e,a),enumerable:!0});if(n)o.set(e,l);return l};var so=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),br=(e,r)=>{return Object.defineProperty(e,"name",{value:r,enumerable:!1,configurable:!0}),e},ao=(e)=>e;function lo(e,r){this[e]=ao.bind(null,r)}var W=(e,r)=>{for(var t in r)Q(e,t,{get:r[t],enumerable:!0,configurable:!0,set:lo.bind(r,t)})};var Mr=(e,r)=>(r=Symbol[e])?r:Symbol.for("Symbol."+e),ae=(e)=>{throw TypeError(e)},uo=(e,r,t)=>(r in e)?Q(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t;var Ve=(e,r,t)=>r.has(e)||ae("Cannot "+t),po=(e,r)=>Object(r)!==r?ae('Cannot use the "in" operator on this value'):e.has(r),Or=(e,r,t)=>(Ve(e,r,"read from private field"),t?t.call(e):r.get(e));var vr=(e,r,t,n)=>(Ve(e,r,"write to private field"),n?n.call(e,t):r.set(e,t),t),fo=(e,r,t)=>(Ve(e,r,"access private method"),t),Sr=(e)=>[,,,Ar(e?.[Mr("metadata")]??null)],jr=["class","method","getter","setter","accessor","field","value","get","set"],se=(e)=>e!==void 0&&typeof e!=="function"?ae("Function expected"):e,co=(e,r,t,n,o)=>({kind:jr[e],name:r,metadata:n,addInitializer:(i)=>t._?ae("Already initialized"):o.push(se(i||null))}),Ze=(e,r)=>uo(r,Mr("metadata"),e[3]),kr=(e,r,t,n)=>{for(var o=0,i=e[r>>1],l=i&&i.length;o<l;o++)r&1?i[o].call(t):n=i[o].call(t,n);return n},m=(e,r,t,n,o,i)=>{var l,a,p,h,O,y=r&7,u=!!(r&8),d=!!(r&16),A=y>3?e.length+1:y?u?1:2:0,g=jr[y+5],v=y>3&&(e[A-1]=[]),f=e[A]||(e[A]=[]),j=y&&(!d&&!u&&(o=o.prototype),y<5&&(y>3||!d)&&to(y<4?o:{get[t](){return Or(this,i)},set[t](S){vr(this,i,S)}},t));y?d&&y<4&&br(i,(y>2?"set ":y>1?"get ":"")+t):br(o,t);for(var b=n.length-1;b>=0;b--){if(h=co(y,t,p={},e[3],f),y){if(h.static=u,h.private=d,O=h.access={has:d?(S)=>po(o,S):(S)=>(t in S)},y^3)O.get=d?(S)=>(y^1?Or:fo)(S,o,y^4?i:j.get):(S)=>S[t];if(y>2)O.set=d?(S,k)=>vr(S,o,k,y^4?i:j.set):(S,k)=>S[t]=k}if(a=(0,n[b])(y?y<4?d?i:j[g]:y>4?void 0:{get:j.get,set:j.set}:o,h),p._=1,y^4||a===void 0)se(a)&&(y>4?v.unshift(a):y?d?i=a:j[g]=a:o=a);else if(typeof a!=="object"||a===null)ae("Object expected");else se(l=a.get)&&(j.get=l),se(l=a.set)&&(j.set=l),se(l=a.init)&&v.unshift(l)}return y||Ze(e,o),j&&Q(o,t,j),d?y^4?i:j:o};var Rt=so((pl,Ft)=>{var{defineProperty:hr,getOwnPropertyNames:ci,getOwnPropertyDescriptor:mi}=Object,gi=Object.prototype.hasOwnProperty,kt=new WeakMap,yi=(e)=>{var r=kt.get(e),t;if(r)return r;if(r=hr({},"__esModule",{value:!0}),e&&typeof e==="object"||typeof e==="function")ci(e).map((n)=>!gi.call(r,n)&&hr(r,n,{get:()=>e[n],enumerable:!(t=mi(e,n))||t.enumerable}));return kt.set(e,r),r},di=(e,r)=>{for(var t in r)hr(e,t,{get:r[t],enumerable:!0,configurable:!0,set:(n)=>r[t]=()=>n})},Dt={};di(Dt,{splitWithQuotes:()=>hi,splitNested:()=>wi});Ft.exports=yi(Dt);var wi=(e,r,t="(",n=")")=>{let o=0,i="",l=[];for(let a of e){if(i+=a,a===t)o++;if(a===n)o--;if(o===0&&a===r)l.push(i.slice(0,-1)),i=""}if(i)l.push(i);return l},hi=(e,r=",")=>{let t=[],n=e.length,o=r.length,i=0,l=(a)=>{if(a+o>n)return!1;for(let p=0;p<o;p++)if(e[a+p]!==r[p])return!1;return!0};while(i<n){while(i<n&&e[i]===" ")i++;if(i>=n)break;let a="",p=e[i]==='"'||e[i]==="'";if(p){let h=e[i++];while(i<n&&e[i]!==h)a+=e[i++];if(i<n)i++}else{while(i<n&&!l(i)){let h=e[i];if(h==='"'||h==="'"){a+=h,i++;while(i<n&&e[i]!==h)a+=e[i++];if(i<n)a+=e[i++]}else a+=e[i++]}a=a.trim()}if(a)t.push({value:a,quoted:p});if(l(i))i+=o}return t}});var N={};W(N,{writeOutputs:()=>me,writeOutput:()=>xe,writeFormat:()=>Re,variable:()=>Yr,tokenize:()=>yr,toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,stripIndent:()=>dr,sortBy:()=>ar,snake:()=>re,sharedFunction:()=>Gr,select:()=>D,section:()=>Tr,processFields:()=>C,pascal:()=>ee,padBlock:()=>T,nonNullMap:()=>ir,navigate:()=>We,mergeAll:()=>z,merge:()=>_,makeFieldProcessorMap:()=>K,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>pe,macro:()=>c,locate:()=>V,loadFormat:()=>fe,key:()=>Kr,importList:()=>$e,importGlob:()=>tr,globMap:()=>ce,getProcessor:()=>ue,getArgs:()=>Fe,find:()=>fr,exists:()=>q,encoder:()=>Qr,defined:()=>sr,deepClone:()=>I,decoder:()=>Xr,conditionPredicates:()=>L,changeCase:()=>te,capital:()=>we,camel:()=>he,asyncMap:()=>lr,ObjectorPlugin:()=>H,Objector:()=>$t,NavigateResult:()=>M,NavigateAction:()=>Ce,Logger:()=>Ke,AsyncFunction:()=>gr});var ze={};W(ze,{processFields:()=>C,makeFieldProcessorMap:()=>K,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>pe,getProcessor:()=>ue,getArgs:()=>Fe});var mo=Object.create,{getPrototypeOf:go,defineProperty:Dr,getOwnPropertyNames:yo}=Object,wo=Object.prototype.hasOwnProperty,ho=(e,r,t)=>{t=e!=null?mo(go(e)):{};let n=r||!e||!e.__esModule?Dr(t,"default",{value:e,enumerable:!0}):t;for(let o of yo(e))if(!wo.call(n,o))Dr(n,o,{get:()=>e[o],enumerable:!0});return n},bo=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Oo=bo((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),A;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(A=o(u,g))||A.enumerable}));return l.set(u,d),d},p=(u,d)=>{for(var A in d)t(u,A,{get:d[A],enumerable:!0,configurable:!0,set:(g)=>d[A]=()=>g})},h={};p(h,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(h);var O=(u,d,A="(",g=")")=>{let v=0,f="",j=[];for(let b of u){if(f+=b,b===A)v++;if(b===g)v--;if(v===0&&b===d)j.push(f.slice(0,-1)),f=""}if(f)j.push(f);return j},y=(u,d=",")=>{let A=[],g=u.length,v=d.length,f=0,j=(b)=>{if(b+v>g)return!1;for(let S=0;S<v;S++)if(u[b+S]!==d[S])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",S=u[f]==='"'||u[f]==="'";if(S){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!j(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)A.push({value:b,quoted:S});if(j(f))f+=v}return A}}),vo=ho(Oo(),1),X;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(X||={});class x{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new x(0);static _noExplore=new x(2);static _skipSiblings=new x(1);static _deleteParent=new x(4);static ReplaceParent(e,r){return new x(3,e,void 0,r)}static SkipSiblings(){return x._skipSiblings}static Explore(){return x._explore}static NoExplore(){return x._noExplore}static DeleteParent(){return x._deleteParent}static MergeParent(e){return new x(5,e)}static ReplaceItem(e,r){return new x(6,e,r)}static DeleteItem(e){return new x(7,void 0,e)}}var Ao=async(e,r)=>{let t=new WeakSet,n=[],o=[],i=async(a,p,h)=>{let O=a===null,y=O?x.Explore():await r({key:a,value:p,path:n,parent:h,parents:o});if(p&&typeof p==="object"&&y.action===0){if(t.has(p))return y;if(t.add(p),!O)n.push(a),o.push(h);let u=p;while(await l(u,a,h))u=h[a];if(!O)o.pop(),n.pop()}return y},l=async(a,p,h)=>{let O=Object.keys(a),y=O.length;for(let u=0;u<y;u++){let d=O[u],A=a[d],g=await i(d,A,a),v=g.action;if(v===0||v===2)continue;if(v===6){if(a[d]=g.by,g.skipSiblings)return;continue}if(v===7){if(delete a[d],g.skipSiblings)return;continue}if(v===1)return;if(v===3){if(p===null)throw Error("Cannot replace root object");if(h[p]=g.by,g.reexplore)return!0;return}if(v===4){if(p===null)throw Error("Cannot delete root object");delete h[p];return}if(v===5)delete a[d],Object.assign(a,g.by)}};await i(null,e,null)},Eo=Object.create,{getPrototypeOf:Mo,defineProperty:Fr,getOwnPropertyNames:So}=Object,jo=Object.prototype.hasOwnProperty,ko=(e,r,t)=>{t=e!=null?Eo(Mo(e)):{};let n=r||!e||!e.__esModule?Fr(t,"default",{value:e,enumerable:!0}):t;for(let o of So(e))if(!jo.call(n,o))Fr(n,o,{get:()=>e[o],enumerable:!0});return n},Do=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),Fo=Do((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),A;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(A=o(u,g))||A.enumerable}));return l.set(u,d),d},p=(u,d)=>{for(var A in d)t(u,A,{get:d[A],enumerable:!0,configurable:!0,set:(g)=>d[A]=()=>g})},h={};p(h,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(h);var O=(u,d,A="(",g=")")=>{let v=0,f="",j=[];for(let b of u){if(f+=b,b===A)v++;if(b===g)v--;if(v===0&&b===d)j.push(f.slice(0,-1)),f=""}if(f)j.push(f);return j},y=(u,d=",")=>{let A=[],g=u.length,v=d.length,f=0,j=(b)=>{if(b+v>g)return!1;for(let S=0;S<v;S++)if(u[b+S]!==d[S])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",S=u[f]==='"'||u[f]==="'";if(S){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!j(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)A.push({value:b,quoted:S});if(j(f))f+=v}return A}}),Ro=ko(Fo(),1),xo=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,$o=/^([^[\]]*)\[([^\]]*)]$/,He=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return le(r,o,t)?.toString()}return n?e:void 0},Co=(e,r,t,n)=>{let o=He(r,t,n);if(o)return le(e,o,n);let i=xo.exec(r);if(i){let[,a,p,h]=i,O=He(a.trim(),t,n,!0),y=He(h.trim(),t,n,!0);if(Array.isArray(e)&&(p==="="||p==="==")&&O)return e.find((u)=>u?.[O]==y)}let l=$o.exec(r);if(l){let[,a,p]=l;return e?.[a]?.[p]}return e?.[r]},le=(e,r,t)=>{let n=void 0,o=void 0,i=r??"",l=(y)=>{if(!y)return[y,!1];return y.endsWith("?")?[y.substring(0,y.length-1),!0]:[y,!1]},a=(y,u)=>{let[d,A]=l(u.pop());if(!d){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return y}let g=Co(y,d,e,t);if(g===void 0){if(A||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${d}" in "${i}"`)}return n=y,o=d,a(g,u)},p=Ro.splitNested(i,t?.separator??".","{","}"),h=void 0;if(p.length>0&&p[p.length-1].startsWith("?="))h=p.pop()?.substring(2);p.reverse();let O=a(e,p);if(O===void 0)return h??t?.defaultValue;return O},Rr=(e,r)=>{if(typeof e.value==="string"){if(e.quoted)return e.value;if(e.value.startsWith("[")&&e.value.endsWith("]")){let t=e.value.slice(1,-1);if(t.trim()==="")return[];return t.split(";").map((n)=>{let o=n.trim();if(!isNaN(+o))return+o;return o})}if(e.value.startsWith("{")&&e.value.endsWith("}")){if(e.value.slice(1,-1).trim()==="")return{}}if(e.value==="null")return null;if(e.value==="undefined")return;if(e.value.startsWith("@"))return e.value.slice(1);if(!isNaN(+e.value))return+e.value}return r(e.value)},De=(e,r,t,n,o,i)=>{let l=n?.(e)??e,a=o(l);if(a[0])return a[1];if(!r){let p=le(t,e),h=o(p);if(h[0])return h[1]}throw Error(i)},$r=(e,r,t,n,o)=>{let i=typeof e.types==="function"?e.types(n,r.value,o):e.types?.[n];if(!i||i==="ref")return Rr(r,(a)=>le(t,a));let l=Rr(r,()=>r.value);if(Array.isArray(i)){if(!i.includes(l))throw Error(`Argument ${n.toString()} must be one of [${i.join(", ")}]: ${l}`);return l}if(typeof i==="string"){if(i.endsWith("?")){let a=i.slice(0,-1);if(r.value==="null")return x.ReplaceItem(null);if(r.value==="undefined")return x.ReplaceItem(void 0);if(r.value==="")return"";i=a}switch(i){case"any":return l;case"array":return De(l,r.quoted,t,null,(a)=>[Array.isArray(a),a],`Argument ${n.toString()} must be an array: ${l}`);case"object":return De(l,r.quoted,t,null,(a)=>[typeof a==="object"&&a!==null,a],`Argument ${n.toString()} must be an object: ${l}`);case"number":return De(l,r.quoted,t,(a)=>Number(a),(a)=>[!isNaN(a),a],`Argument ${n.toString()} must be a number: ${l}`);case"boolean":return De(l,r.quoted,t,null,(a)=>{if([!0,"true","1",1,"yes","on"].includes(a))return[!0,!0];if([!1,"false","0",0,"no","off"].includes(a))return[!0,!1];if([null,"null","undefined",void 0,""].includes(a))return[!0,!1];if(Array.isArray(a))return[!0,a.length>0];return[!1,!1]},`Argument ${n.toString()} must be a boolean: ${l}`);case"string":return l.toString();default:throw Error(`Unknown type for argument ${n.toString()}: ${i}`)}}return i(l,t,n,r.quoted)},ue=(e,r)=>{let t=e?.[r];if(t===void 0)throw Error(`Unhandled field processor type: ${r}`);return typeof t==="function"?{options:{},fn:t}:{options:t,fn:t.fn}},Cr=(e)=>!e.quoted&&e.value.startsWith("."),Wo=(e)=>{let r={};for(let t of e){if(!Cr(t))continue;let n=t.value.indexOf("="),o=n>-1?t.value.slice(1,n):t.value.slice(1),i=n>-1?t.value.slice(n+1):"";if(i.length>=2){let l=i[0],a=i[i.length-1];if(l==='"'&&a==='"'||l==="'"&&a==="'")i=i.slice(1,-1)}if(!r[o])r[o]=[];r[o].push(i)}return r},Fe=(e,r,t)=>{let n=vo.splitWithQuotes(e??""),o=Wo(n),i=n.filter((a)=>!Cr(a)),l=r.options.processArgs===!1?[]:i.map((a,p)=>$r(r.options,a,t,p,i));return{rawArgs:i,parsedArgs:l,tags:o}},No=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},Io=(e,r)=>r.keys!==void 0&&e.key.startsWith(".")&&r.keys[e.key.substring(1)]!==void 0,Lo=async(e,r,t,n)=>{let{key:o,parent:i}=e,l=ue(n.keys,o.substring(1));if(l.options.processArgs!==!1&&(typeof l.options.types==="function"||l.options.types?.[0]!==void 0))e.value=$r(l.options,{value:e.value,quoted:!1},t,0,[]);if(typeof e.value!=="string")await C(e.value,{...n,root:{...t,parent:e.parent,parents:e.parents},filters:[...n.filters??[],...l.options.filters??[]]});let a=await l.fn({path:r,root:t,parent:i,key:o,options:n,value:e.value,args:[],rawArgs:[],tags:{}});return No(a)?a:x.ReplaceParent(a)},xr=(e)=>{let r=e.split(/\r?\n/),t=r.filter((o)=>o.trim().length>0).map((o)=>/^[ \t]*/.exec(o)?.[0].length??0),n=t.length>0?Math.min(...t):0;if(n===0)return e;return r.map((o)=>o.slice(n)).join(`
|
|
2
|
+
`)},_o=async(e,r,t,n)=>{if(!r?.onSection&&!r?.onSectionConfig&&!r?.sections)return[e,!1];let o=/<@\s*section(?:\s*:\s*([\w-]+))?\s*@>([\s\S]*?)<@\s*\/\s*section\s*@>/g,i,l=e,a=0,p=!1,h={content:l,root:n,path:t,options:r,section:{}};while((i=o.exec(e))!==null){p=!0;let[O,y,u]=i,d=i.index,A=d+O.length,g=e[A]===`
|
|
3
|
+
`;if(g)A++;let v=d+a,f=A+a,j={},b=u,S=/(^|\r?\n)[ \t]*---[ \t]*(\r?\n|$)/m.exec(u);if(S){let oe=u.slice(0,S.index),Ye=S.index+S[0].length;b=u.slice(Ye);let je=xr(oe).trim();if(je.length>0)try{j=r?.configParser?.(je)??{}}catch(Ge){throw Error(`Failed to parse YAML config for section: ${Ge.message}`)}}else if(/^\r?\n/.test(b))b=b.replace(/^\r?\n/,"");b=xr(b),b=b.replace(/(?:\r?\n[ \t]*)+$/,""),b=b.replace(/[ \t]+$/,"");let k={config:y?{...j,type:y}:j,content:b};if(h.content=l,h.section=k,Object.keys(k.config).length>0){if(await r.onSectionConfig?.(h)!==!1)await C(k.config,{...r,root:n})}let Ae=h.section.config.type?r.sections?.[h.section.config.type]:void 0,G;if(Ae)G=await Ae(h);else if(r.onSection)G=await r.onSection(h);if(k.trim)k.content=k.content.trim();if(k.indent)k.content=k.content.split(`
|
|
4
|
+
`).map((oe)=>" ".repeat(k.indent)+oe).join(`
|
|
5
|
+
`);let B="";if(G===!0||k.show)B=k.content;else if(typeof G==="string")B=G;if(g&&B!==""&&!B.endsWith(`
|
|
6
|
+
`))B+=`
|
|
7
|
+
`;let Ee=l.lastIndexOf(`
|
|
8
|
+
`,v-1),Me=Ee===-1?0:Ee+1,Se=l.slice(Me,v).trim().length===0?Me:v;l=l.slice(0,Se)+B+l.slice(f),a+=B.length-(f-Se),h.content=l}return[l,p]},Wr=(e)=>{let r=[],t=0;while(t<e.length)if(e[t]==="$"&&e[t+1]==="("&&(t===0||e[t-1]!=="\\")){let n=t;t+=2;let o=1;for(;t<e.length;t++)if(e[t]==="(")o++;else if(e[t]===")"){if(o--,o===0){r.push([n,t]);break}}if(o!==0)throw Error(`Unmatched opening $( at position ${n.toString()}`);t++}else t++;return r},Pe=Symbol.for("@homedev/fields:OverrideResult"),Uo=(e)=>({[Pe]:!0,value:e}),Bo=(e)=>{return e!==null&&typeof e==="object"&&Pe in e&&e[Pe]===!0},Nr=async(e,r,t)=>{for(let n=r.length-1;n>=0;n--){let[o,i]=r[n],l=e.slice(o+2,i),a=await Nr(l,Wr(l),t);if(typeof a==="object")return a;let p=await t(a,e);if(Bo(p))return p.value;e=e.slice(0,o)+p+e.slice(i+1)}return e},To=async(e,r)=>Nr(e,Wr(e),r),Ko=(e)=>{return e!==null&&typeof e==="object"&&"action"in e},Yo=/([\w\d.-_/]+):(.+)/,Go=async(e,r,t,n)=>{let o=await(async()=>{let i=Yo.exec(e);if(!i)return await le(r,e);let[l,a,p]=i,h=ue(n.sources,a),O=Fe(p,h,r);return await h.fn({args:O.parsedArgs,rawArgs:O.rawArgs,tags:O.tags,key:a,options:n,root:r,path:t,value:null})})();if(o===null||o===void 0)return"";if(typeof o==="object")return Uo(o);return o},Ir=async(e,r,t,n)=>{let o=await To(r,(i)=>Go(i,t,e,n));if(Ko(o))return o;if(o===r)return x.Explore();if(typeof o==="string"){let i=await Ir(e,o,t,n);if(i.action!==X.Explore)return i;return x.ReplaceItem(o)}return x.ReplaceItem(o)},C=async(e,r)=>{return r??={},await Ao(e,async(t)=>{let n=[...t.path,t.key].join(".");if(r?.filters?.length&&r.filters.some((a)=>a.test(n)))return x.NoExplore();let o=t.path.length===0,i=t.parents.length>0?t.parents.toReversed():[];if(o){if(i.length>0)throw Error("Root object should not have a parent");i=r?.root?.parents?[r.root.parent,...r.root.parents.toReversed()]:[]}let l={...e,...r.root,this:t.parent,parent:i.length>0?i[0]:null,parents:i};try{if(t.key.startsWith("$"))return x.NoExplore();let a=x.Explore();if(typeof t.value==="string"){let p=t.value,h=!1;while(!0){let[O,y]=await _o(p,r,n,l);if(h=h||y,a=await Ir(n,O,l,r),a.action===X.ReplaceItem&&typeof a.by==="string"){p=a.by;continue}if(a.action===X.Explore&&y&&O!==p)a=x.ReplaceItem(O);break}if(a.action===X.Explore&&p!==t.value)a=x.ReplaceItem(p);switch(a.action){case X.Explore:break;case X.ReplaceItem:t.value=a.by;break;default:return a}}if(Io(t,r))a=await Lo(t,n,l,r);return a}catch(a){throw Error(`${a.message}
|
|
9
|
+
(${n})`)}}),e},pe=(e,r)=>r?{fn:(t)=>e(...t.args),types:r}:(t)=>e(...t.args),qe=(e,r)=>Object.fromEntries(e.map((t)=>[t.name,pe(t,r?.types?.[t.name])])),K=(e,r)=>Object.fromEntries((r?.keys??Object.keys(e)).map((t)=>[t,pe(e[t],r?.types?.[t])]));var nr={};W(nr,{writeOutputs:()=>me,writeOutput:()=>xe,writeFormat:()=>Re,locate:()=>V,loadFormat:()=>fe,importList:()=>$e,importGlob:()=>tr,globMap:()=>ce,exists:()=>q});import Lr from"fs/promises";import Je from"path";import Qo from"fs/promises";import Xo from"path";import Vo from"fs/promises";import Zo from"fs/promises";import Br from"fs/promises";import _r from"path";import Ho from"fs/promises";import er from"path";import Ur from"path";var q=async(e)=>{try{return await Lr.access(e,Lr.constants.R_OK),!0}catch{return!1}},V=async(e,r)=>{let t=!Je.isAbsolute(e)&&r?["",...r]:[""];for(let n of t){let o=Je.join(n,e);if(await q(o))return Je.resolve(o)}throw Error(`File not found: "${e}"`)},fe=async(e,r)=>{let t=await V(e,r?.dirs),n=await Qo.readFile(t,"utf-8"),o=Xo.dirname(t),i={text:{fn:(a)=>a,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.parse,matching:["\\.json$"]},...r?.parsers},l=r?.format?i[r.format]:Object.values(i).find((a)=>a.matching?.some((p)=>new RegExp(p).test(e)));if(!l)throw Error(`Unsupported format for file "${e}" and no matching parser found`);return{content:await l.fn(n),fullPath:t,folderPath:o}},Re=async(e,r,t)=>{let n={text:{fn:(i)=>i,matching:["\\.txt$","\\.text$"]},json:{fn:JSON.stringify,matching:["\\.json$"]},...t?.encoders},o=t?.format?n[t.format]:Object.values(n).find((i)=>i.matching?.some((l)=>new RegExp(l).test(e)));if(!o)throw Error(`Unsupported format for file "${e}" and no matching encoder found`);await Vo.writeFile(e,await o.fn(r))},ce=async(e,r)=>{if(typeof e==="string"&&!e.includes("*"))return await r.map(e,0,[]);let t=await Array.fromAsync(Zo.glob(e,{cwd:r.cwd})),n=r.filter?t.filter(r.filter):t;return await Promise.all(n.map(r.map))},me=async(e,r)=>{if(r?.targetDirectory&&r?.removeFirst)try{await Br.rm(r?.targetDirectory,{recursive:!0,force:!0})}catch(t){throw Error(`Failed to clean the output directory: ${t.message}`)}for(let t of e)await xe(t,r)},xe=async(e,r)=>{let t=_r.join(r?.targetDirectory??".",e.name),n=_r.dirname(t);if(r?.classes){if(e.class!==void 0&&!r.classes.includes(e.class))return;if(r.classRequired&&e.class===void 0)throw Error(`Output "${e.name}" is missing class field`)}if(r?.writing?.(e)===!1)return;try{await Br.mkdir(n,{recursive:!0})}catch(o){throw Error(`Failed to create target directory "${n}" for output "${t}": ${o.message}`)}try{await Re(t,e.value,{format:e.type??"text"})}catch(o){throw Error(`Failed to write output "${t}": ${o.message}`)}},rr=(e)=>e?Ur.isAbsolute(e)?e:Ur.join(process.cwd(),e):process.cwd(),$e=async(e,r)=>{let t=[];for(let n of e)try{let o=!er.isAbsolute(n)?er.join(rr(r?.cwd),n):n;if(r?.filter?.(o)===!1)continue;let i=await import(o);if(r?.resolveDefault==="only"&&!i.default)throw Error(`Module ${n} does not have a default export`);let l=r?.resolveDefault?i.default??i:i,a=r?.map?await r.map(l,n):l;if(a!==void 0)t.push(a)}catch(o){if(r?.fail?.(n,o)===!1)continue;throw Error(`Failed to import module ${n}: ${o.message??o}`)}return t},tr=async(e,r)=>{let t=[];for(let n of e){let o=(await Array.fromAsync(Ho.glob(n,{cwd:rr(r?.cwd)}))).map((i)=>er.join(rr(r?.cwd),i));t.push(...await $e(o,r))}return t};var ur={};W(ur,{toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,sortBy:()=>ar,nonNullMap:()=>ir,defined:()=>sr,deepClone:()=>I,asyncMap:()=>lr});var Z=(e,r="name")=>Object.entries(e).map(([t,n])=>({[r]:t,...n})),or=(e,r="name")=>Object.fromEntries(e.map((t)=>[t[r],t])),ge=(e,r="name")=>Object.fromEntries(e.map((t)=>{let{[r]:n,...o}=t;return[n,o]})),ir=(e,r)=>{if(!e)return[];let t=[],n=0;for(let o of e)if(o!==null&&o!==void 0)t.push(r(o,n,e)),n++;return t},sr=(e,r="Value is undefined")=>{if(e===void 0||e===null)throw Error(r);return e},ar=(e,r,t=(n,o)=>n-o)=>e.slice().sort((n,o)=>t(r(n),r(o))),lr=async(e,r)=>Promise.all(e.map(r)),I=(e)=>{if(typeof structuredClone<"u")try{return structuredClone(e)}catch{}return JSON.parse(JSON.stringify(e))};var pr={};W(pr,{variable:()=>Yr,sharedFunction:()=>Gr,section:()=>Tr,macro:()=>c,key:()=>Kr,encoder:()=>Qr,decoder:()=>Xr,ObjectorPlugin:()=>H});class H{o;context;constructor(e){this.o=e}}var c=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.sources({[o]:(i)=>n.apply({...this,context:i},i.args)})})},Tr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.sections({[o]:(i)=>{return n.call({...this,context:i},i.section)}})})},Kr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.keys({[o]:(i)=>n.call({...this,context:i},i.value)})})},Yr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.variables({[o]:n})})},Gr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.functions({[o]:n})})},Qr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.encoders({[o]:{fn:n}})})},Xr=(e)=>(r,t)=>{t.addInitializer(function(){let n=this[t.name],o=e?.name??t.name;this.o.decoders({[o]:{fn:n}})})};var St={};W(St,{defaultProcessors:()=>wr});import{createHash as ne}from"crypto";import Y from"path";var Vr={};W(Vr,{navigate:()=>We,find:()=>fr,NavigateResult:()=>M,NavigateAction:()=>Ce});var Ce;((e)=>{e[e.Explore=0]="Explore",e[e.SkipSiblings=1]="SkipSiblings",e[e.NoExplore=2]="NoExplore",e[e.ReplaceParent=3]="ReplaceParent",e[e.DeleteParent=4]="DeleteParent",e[e.MergeParent=5]="MergeParent",e[e.ReplaceItem=6]="ReplaceItem",e[e.DeleteItem=7]="DeleteItem"})(Ce||={});class M{action;by;skipSiblings;reexplore;constructor(e,r,t,n){this.action=e,this.by=r,this.skipSiblings=t,this.reexplore=n}static _explore=new M(0);static _noExplore=new M(2);static _skipSiblings=new M(1);static _deleteParent=new M(4);static ReplaceParent(e,r){return new M(3,e,void 0,r)}static SkipSiblings(){return M._skipSiblings}static Explore(){return M._explore}static NoExplore(){return M._noExplore}static DeleteParent(){return M._deleteParent}static MergeParent(e){return new M(5,e)}static ReplaceItem(e,r){return new M(6,e,r)}static DeleteItem(e){return new M(7,void 0,e)}}var We=async(e,r)=>{let t=new WeakSet,n=[],o=[],i=async(a,p,h)=>{let O=a===null,y=O?M.Explore():await r({key:a,value:p,path:n,parent:h,parents:o});if(p&&typeof p==="object"&&y.action===0){if(t.has(p))return y;if(t.add(p),!O)n.push(a),o.push(h);let u=p;while(await l(u,a,h))u=h[a];if(!O)o.pop(),n.pop()}return y},l=async(a,p,h)=>{let O=Object.keys(a),y=O.length;for(let u=0;u<y;u++){let d=O[u],A=a[d],g=await i(d,A,a),v=g.action;if(v===0||v===2)continue;if(v===6){if(a[d]=g.by,g.skipSiblings)return;continue}if(v===7){if(delete a[d],g.skipSiblings)return;continue}if(v===1)return;if(v===3){if(p===null)throw Error("Cannot replace root object");if(h[p]=g.by,g.reexplore)return!0;return}if(v===4){if(p===null)throw Error("Cannot delete root object");delete h[p];return}if(v===5)delete a[d],Object.assign(a,g.by)}};await i(null,e,null)},fr=async(e,r)=>{let t=[];return await We(e,(n)=>{if(r([...n.path,n.key].join("."),n.value))t.push(n.value);return M.Explore()}),t};var Zr=(e)=>({output:(r)=>{delete r.parent[r.key];for(let t of Array.isArray(r.value)?r.value:[r.value])if(typeof t==="string")e.output({name:t,value:r.parent});else e.output({...t,value:t.value??r.parent});return M.SkipSiblings()}});import Po from"path";var Hr=(e)=>({load:async(r)=>{let t=r.options.globalContext;for(let{file:n}of Array.isArray(r.value)?r.value:[r.value]){if(!n)throw Error("File reference required");await e.load(n,t.file&&Po.dirname(t.file))}return M.DeleteItem()}});var Pr={};W(Pr,{mergeAll:()=>z,merge:()=>_});var _=(e,r,t)=>{for(let n of Object.keys(r)){if(e[n]===void 0)continue;let o=r[n],i=e[n];if(typeof i!==typeof o||Array.isArray(i)!==Array.isArray(o)){let a=t?.mismatch?.(n,i,o,e,r);if(a!==void 0){r[n]=a;continue}throw Error(`Type mismatch: ${n}`)}let l=t?.mode?.(n,i,o,e,r)??r[".merge"]??"merge";switch(l){case"source":r[n]=i;continue;case"target":continue;case"skip":delete r[n],delete e[n];continue;case"merge":break;default:throw Error(`Unknown merge mode: ${l}`)}if(typeof i==="object")if(Array.isArray(i))o.push(...i);else{if(t?.navigate?.(n,i,o,e,r)===!1)continue;_(i,o,t)}else{if(i===o)continue;let a=t?.conflict?.(n,i,o,e,r);r[n]=a===void 0?o:a}}for(let n of Object.keys(e))if(r[n]===void 0)r[n]=e[n]},z=(e,r)=>{let t={};for(let n of e.toReversed())_(n,t,r);return t};var qr={};W(qr,{CacheManager:()=>Ne});class Ne{cache=new Map;maxSize;constructor(e=100){this.maxSize=e}get(e){return this.cache.get(e)}set(e,r){this.evictIfNeeded(),this.cache.set(e,r)}has(e){return this.cache.has(e)}clear(){this.cache.clear()}setMaxSize(e){this.maxSize=e}size(){return this.cache.size}evictIfNeeded(){if(this.cache.size>=this.maxSize){let e=null,r=1/0;for(let[t,n]of this.cache.entries())if(n.timestamp<r)r=n.timestamp,e=t;if(e)this.cache.delete(e)}}}var Jr={};W(Jr,{select:()=>D});var qo=Object.create,{getPrototypeOf:zo,defineProperty:zr,getOwnPropertyNames:Jo}=Object,ei=Object.prototype.hasOwnProperty,ri=(e,r,t)=>{t=e!=null?qo(zo(e)):{};let n=r||!e||!e.__esModule?zr(t,"default",{value:e,enumerable:!0}):t;for(let o of Jo(e))if(!ei.call(n,o))zr(n,o,{get:()=>e[o],enumerable:!0});return n},ti=(e,r)=>()=>(r||e((r={exports:{}}).exports,r),r.exports),ni=ti((e,r)=>{var{defineProperty:t,getOwnPropertyNames:n,getOwnPropertyDescriptor:o}=Object,i=Object.prototype.hasOwnProperty,l=new WeakMap,a=(u)=>{var d=l.get(u),A;if(d)return d;if(d=t({},"__esModule",{value:!0}),u&&typeof u==="object"||typeof u==="function")n(u).map((g)=>!i.call(d,g)&&t(d,g,{get:()=>u[g],enumerable:!(A=o(u,g))||A.enumerable}));return l.set(u,d),d},p=(u,d)=>{for(var A in d)t(u,A,{get:d[A],enumerable:!0,configurable:!0,set:(g)=>d[A]=()=>g})},h={};p(h,{splitWithQuotes:()=>y,splitNested:()=>O}),r.exports=a(h);var O=(u,d,A="(",g=")")=>{let v=0,f="",j=[];for(let b of u){if(f+=b,b===A)v++;if(b===g)v--;if(v===0&&b===d)j.push(f.slice(0,-1)),f=""}if(f)j.push(f);return j},y=(u,d=",")=>{let A=[],g=u.length,v=d.length,f=0,j=(b)=>{if(b+v>g)return!1;for(let S=0;S<v;S++)if(u[b+S]!==d[S])return!1;return!0};while(f<g){while(f<g&&u[f]===" ")f++;if(f>=g)break;let b="",S=u[f]==='"'||u[f]==="'";if(S){let k=u[f++];while(f<g&&u[f]!==k)b+=u[f++];if(f<g)f++}else{while(f<g&&!j(f)){let k=u[f];if(k==='"'||k==="'"){b+=k,f++;while(f<g&&u[f]!==k)b+=u[f++];if(f<g)b+=u[f++]}else b+=u[f++]}b=b.trim()}if(b)A.push({value:b,quoted:S});if(j(f))f+=v}return A}}),oi=ri(ni(),1),ii=/^\[([^=\]]*)([=]*)([^\]]*)\]$/,si=/^([^[\]]*)\[([^\]]*)]$/,cr=(e,r,t,n)=>{if(e.startsWith("{")&&e.endsWith("}")){let o=e.substring(1,e.length-1);return D(r,o,t)?.toString()}return n?e:void 0},ai=(e,r,t,n)=>{let o=cr(r,t,n);if(o)return D(e,o,n);let i=ii.exec(r);if(i){let[,a,p,h]=i,O=cr(a.trim(),t,n,!0),y=cr(h.trim(),t,n,!0);if(Array.isArray(e)&&(p==="="||p==="==")&&O)return e.find((u)=>u?.[O]==y)}let l=si.exec(r);if(l){let[,a,p]=l;return e?.[a]?.[p]}return e?.[r]},D=(e,r,t)=>{let n=void 0,o=void 0,i=r??"",l=(y)=>{if(!y)return[y,!1];return y.endsWith("?")?[y.substring(0,y.length-1),!0]:[y,!1]},a=(y,u)=>{let[d,A]=l(u.pop());if(!d){if(t?.set!==void 0&&o!==void 0&&n!==void 0)n[o]=t.set;return y}let g=ai(y,d,e,t);if(g===void 0){if(A||t?.optional||t?.defaultValue!==void 0)return;throw Error(`Unknown path element: "${d}" in "${i}"`)}return n=y,o=d,a(g,u)},p=oi.splitNested(i,t?.separator??".","{","}"),h=void 0;if(p.length>0&&p[p.length-1].startsWith("?="))h=p.pop()?.substring(2);p.reverse();let O=a(e,p);if(O===void 0)return h??t?.defaultValue;return O};var Ie=(e)=>{if(typeof e.value==="string")return e.parent;let r=e.value.model;if(!r)return e.parent;if(typeof r==="string")return D(e.root,r);return r};var Le=(e)=>{if(typeof e.value==="string")return D(e.root,e.value);if(Array.isArray(e.value))return e.value;let r=e.value;if(typeof r.from==="string")return D(e.root,r.from);return r.from};var _e=async(e,r)=>{let t=e.value;if(t.selector===void 0)return r;if(typeof t.selector!=="string"){let n=JSON.parse(JSON.stringify(t.selector));return await C(n,{...e.options,root:{...e.root,result:r}}),n}return await D({...e.root,result:r},t.selector)};var et={};W(et,{PathManager:()=>P});import J from"path";class P{constructor(){}static normalize(e){return J.normalize(J.resolve(e))}static resolveInContext(e,r){let t=r??process.cwd(),n=J.isAbsolute(e)?e:J.join(t,e);return this.normalize(n)}static isDirectoryPattern(e){return e.endsWith("/")}static isGlobPattern(e){return e.includes("*")}static toAbsolute(e,r){if(J.isAbsolute(e))return e;return J.join(r??process.cwd(),e)}}var rt={};W(rt,{conditionPredicatesTypes:()=>ye,conditionPredicates:()=>L});var L={and:(...e)=>e.every((r)=>!!r),or:(...e)=>e.some((r)=>!!r),xor:(...e)=>e.filter((r)=>!!r).length===1,true:(...e)=>e.every((r)=>!!r),false:(...e)=>e.every((r)=>!r),eq:(...e)=>e.every((r)=>r===e[0]),ne:(...e)=>e.some((r)=>r!==e[0]),lt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<r),le:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]<=r),gt:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>r),ge:(...e)=>typeof e[0]==="number"&&e.slice(1).every((r)=>typeof r==="number"&&e[0]>=r),in:(e,r)=>{if(Array.isArray(r))return r.includes(e);if(typeof e==="string")return e.includes(r);if(Array.isArray(e))return e.includes(r);return!1},notin:(e,r)=>!L.in(e,r),contains:(e,r)=>e.includes(r),notcontains:(e,r)=>!e.includes(r),containsi:(e,r)=>e.toLowerCase().includes(r.toLowerCase()),notcontainsi:(e,r)=>!e.toLowerCase().includes(r.toLowerCase()),null:(...e)=>e.every((r)=>r===null||r===void 0),notnull:(...e)=>e.every((r)=>r!==null&&r!==void 0),empty:(...e)=>e.every((r)=>r===""),notempty:(...e)=>e.every((r)=>r!==""),nullorempty:(...e)=>e.every((r)=>r===null||r===void 0||r===""),notnullorempty:(...e)=>e.every((r)=>r!==null&&r!==void 0&&r!=="")},ye={and:()=>"boolean",or:()=>"boolean",xor:()=>"boolean",true:()=>"boolean",false:()=>"boolean",lt:()=>"number",le:()=>"number",gt:()=>"number",ge:()=>"number"};var tt=()=>({each:{filters:[/select|model/],fn:async(e)=>{let r=e.value;delete e.parent[e.key];let t=await Le(e),n=await Ie(e);if(!Array.isArray(t))throw Error('Key "each" requires a source list');if(n===void 0)throw Error('Key "each" must define a model');if(r.extend?.model)n=z([r.model,...Array.isArray(r.extend.model)?r.extend.model:[r.extend.model]]);let o=[];for(let i=0;i<t.length;i++){let l=I(n);if(await C(l,{...e.options,root:{...e.root,index:i,item:t[i],instance:l}}),r.extend?.result){let a=r.extend.result;l=z([l,...Array.isArray(a)?a:[a]])}o.push(await _e(e,l))}return o}}});var nt=()=>({map:{filters:[/select|model/],fn:async(e)=>{delete e.parent[e.key];let r=await Le(e),t=await Ie(e);if(!Array.isArray(r))throw Error('Key "map" requires a source list');if(t===void 0)throw Error('Key "map" must define a model');let n=[];for(let o=0;o<r.length;o++){let i=I(t);await C(i,{...e.options,root:{...e.root,index:o,item:r[o],instance:i}}),n.push(await _e(e,i))}return n}}});var ot=()=>({concat:async(e)=>{let r=[];for(let t of Array.isArray(e.value)?e.value:[e.value])r.push(...await D(e.root,t));return r.filter((t)=>t!==void 0)}});var it=()=>({extends:async(e)=>{let r=async(t,n)=>{for(let o of Array.isArray(n)?n:[n]){let i=await D(e.root,o),l=I(i);if(l[e.key])await r(l,l[e.key]);await C(l,{...e.options}),_(l,t),delete t[e.key]}};return await r(e.parent,e.value),M.Explore()},group:(e)=>{let r=e.root.parent,t=e.value,{items:n,...o}=t;return t.items.forEach((i)=>r.push({...o,...i})),M.DeleteParent()}});var st=(e)=>({skip:{types:{0:"boolean"},fn:(r)=>r.value?M.DeleteParent():M.DeleteItem()},metadata:({path:r,value:t})=>{return e.metadata(r,t),M.DeleteItem()},if:{types:{0:"boolean"},fn:async(r)=>{let t=r.parent[".then"],n=r.parent[".else"];if(t!==void 0)delete r.parent[".then"];if(n!==void 0)delete r.parent[".else"];let o=r.value?t:n;if(o===void 0)return M.DeleteItem();if(typeof o==="string")return(await C({value:o},{...r.options,root:{...r.root}})).value;return M.ReplaceParent(o,!0)}},switch:(r)=>{let t=r.value;if(!t.cases)throw Error("Missing cases for switch");if(t.cases[t.from]!==void 0)return M.ReplaceParent(t.cases[t.from],!0);if(t.default!==void 0)return M.ReplaceParent(t.default,!0);return M.DeleteParent()}});var at=()=>({from:async({root:e,parent:r,value:t})=>{let n=await D(e,t);if(n===null||n===void 0)throw Error(`Unable to resolve reference: ${t}`);if(r.content){if(Array.isArray(r.content)&&Array.isArray(n))return[...n,...r.content];return _(n,r.content),r.content}return n}});import lt from"node:vm";var ut=(e)=>({modules:async(r)=>{for(let[t,n]of Object.entries(r.value)){let o=lt.createContext({console,objector:e,document:r.root}),i=new lt.SourceTextModule(n,{identifier:t,context:o});await i.link((l)=>{throw Error(`Module ${l} is not allowed`)}),await i.evaluate(),e.sources(Object.fromEntries(Object.entries(i.namespace).map(([l,a])=>[`${t}.${l}`,(p)=>a(p,...p.args)])))}return M.DeleteItem()}});var pt=()=>({try:{fn:(e)=>{let r=e.parent[".catch"];if(r!==void 0)delete e.parent[".catch"];try{return e.value}catch(t){if(r!==void 0)return r;return M.DeleteItem()}}}});var ft=()=>({let:{fn:(e)=>{let r=e.value;return Object.assign(e.root,r),M.DeleteItem()}}});var ct=()=>({tap:{fn:(e)=>{return console.log(`[tap] ${e.path}:`,e.value),e.value}}});var li=(e,r)=>{let t=r.section.config.using,n=e.getFunctions();return t?Object.fromEntries(t.map((o)=>{if(o in n)return[o,n[o]];if(o in r.root)return[o,r.root[o]];throw Error(`Function or variable "${o}" not found for script section`)})):n},mr=(e,r,t,n,o=[])=>{let i=li(e,t),l=["section","context","config","system",...Object.keys(i),...o],a=[r,t.root,t.section.config,e,...Object.values(i)];return[new gr(...l,n).bind(t),a]},ui=(e,r)=>{let t={write:(...n)=>{return r.push(...n),t},writeLine:(...n)=>{return r.push(...n.map((o)=>o+`
|
|
10
10
|
`)),t},clear:()=>{return r.splice(0,r.length),t},prepend:(...n)=>{return r.unshift(...n),t},prependLine:(...n)=>{return r.unshift(...n.map((o)=>o+`
|
|
11
|
-
`)),t},setOptions:(n)=>{return Object.assign(e.section,n),t},use:(n)=>{return n(t),t},getLines:()=>r};return t},
|
|
12
|
-
`,n=" ")=>{let o=n.repeat(r);return e.split(t).map((
|
|
13
|
-
`)};var
|
|
14
|
-
`,
|
|
15
|
-
${e.map((
|
|
11
|
+
`)),t},setOptions:(n)=>{return Object.assign(e.section,n),t},use:(n)=>{return n(t),t},getLines:()=>r};return t},pi=async(e,r,t)=>{let n=t.section.config.condition;if(n!==void 0){let[o,i]=mr(e,r,t,`return (${n})`);if(!await o(...i))return!1}return!0},mt=(e)=>async(r)=>{let t=[],n=ui(r,t);if(!await pi(e,n,r))return!1;let[o,i]=mr(e,n,r,r.section.content,["item"]),l=r.section.config.each;if(l){let[a,p]=mr(e,n,r,`return (${l})`),h=Array.isArray(l)?l:await a(...p);if(!Array.isArray(h))throw Error('The "each" property of a script section must return an array');for(let O of h){let y=await o(...i,O);if(typeof y<"u")t.push(y)}}else{let a=await o(...i);if(typeof a<"u")return a}if(t.length===0)return!1;return t.join("")};var gt=(e)=>({script:mt(e)});import yt from"fs/promises";import de from"path";var dt=(e)=>({include:async(r)=>{let{file:t}=r.options.globalContext;return await ce(r.args[0],{cwd:de.dirname(t),filter:(n)=>de.basename(t)!==n,map:async(n)=>e.load(n,de.dirname(t),r.root)})},exists:async({args:[r]})=>await q(r),file:async(r)=>await yt.readFile(await V(r.args[0],e.getIncludeDirectories())).then((t)=>t.toString()),scan:async(r)=>{let t=[],o=(()=>{let a=r.args[2]??["**/node_modules/**"],p=typeof a==="string"?a.split(",").map((h)=>h.trim()):a;if(!Array.isArray(p))throw Error("Scan exclusion must be a list");return p})(),{file:i}=r.options.globalContext,l=r.args[1]?await V(r.args[1],e.getIncludeDirectories()):de.dirname(i);for await(let a of yt.glob(r.args[0],{cwd:l,exclude:(p)=>o.some((h)=>de.matchesGlob(p,h))}))t.push(a);return t}});var wt={};W(wt,{tokenize:()=>yr,stripIndent:()=>dr,snake:()=>re,pascal:()=>ee,padBlock:()=>T,changeCase:()=>te,capital:()=>we,camel:()=>he});var ee=(e)=>e.replace(/((?:[_ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()).replace(/[_ ]/g,""),we=(e)=>e.replace(/((?:[ ]+)\w|^\w)/g,(r,t)=>t.toUpperCase()),he=(e)=>{let r=ee(e);return r.charAt(0).toLowerCase()+r.slice(1)},re=(e,r="_")=>e.replace(/([a-z])([A-Z])/g,`$1${r}$2`).replace(/\s+/g,r).toLowerCase(),te=(e,r)=>{switch(r){case"upper":return e.toUpperCase();case"lower":return e.toLowerCase();default:return e}},T=(e,r,t=`
|
|
12
|
+
`,n=" ")=>{let o=n.repeat(r);return e.split(t).map((i)=>o+i).join(t)},yr=(e,r,t=/\${([^}]+)}/g)=>{return e.replace(t,(n,o)=>{let i=r[o];if(i===null||i===void 0)return"";if(typeof i==="string")return i;if(typeof i==="number"||typeof i==="boolean")return String(i);return String(i)})},dr=(e)=>{let r=e.split(/\r?\n/),t=r.filter((o)=>o.trim().length>0).map((o)=>/^[ \t]*/.exec(o)?.[0].length??0),n=t.length>0?Math.min(...t):0;if(n===0)return e;return r.map((o)=>o.slice(n)).join(`
|
|
13
|
+
`)};var ht=(e)=>({substring:{types:{0:"ref",1:"number",2:"number"},fn:(r)=>r.args[0].substring(r.args[1],r.args[2])},repeat:{types:{0:"ref",1:"number"},fn:({args:[r,t]})=>r.repeat(t)},pad:{types:{0:"ref",1:"number",2:"string"},fn:({args:[r,t],tags:n})=>{let o=n.join?.[0]??`
|
|
14
|
+
`,i=n.padChar?.[0]??" ";return T(r,t??2,o,i)}},formatAs:{fn:({args:[r,t],tags:n})=>{let o=e.getEncoder(t);if(!o)throw Error("Unsupported format: "+String(t));let i=[];if(o.options?.includeTags)i=[n];return o.fn(r,...i)}}});var Ue=(e,r=0,t)=>{let n=" ".repeat(r),o=" ".repeat(r+1);if(e===null||e===void 0)return"null";else if(typeof e==="boolean")return String(e);else if(typeof e==="number")return String(e);else if(typeof e==="string")return`"${e.replace(/\\/g,"\\\\").replace(/"/g,"\\\"").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`;else if(Array.isArray(e)){if(e.length===0)return"[]";return`[
|
|
15
|
+
${e.map((l)=>`${o}${Ue(l,r+1)},`).join(`
|
|
16
16
|
`)}
|
|
17
|
-
${n}]`}else if(typeof e==="object"){let
|
|
18
|
-
${
|
|
17
|
+
${n}]`}else if(typeof e==="object"){let i=Object.entries(e).sort((a,p)=>t?.sortKeys?a[0].localeCompare(p[0]):0);if(i.length===0)return"{}";return`{
|
|
18
|
+
${i.map(([a,p])=>`${o}${a} = ${Ue(p,r+1,t)}`).join(`
|
|
19
19
|
`)}
|
|
20
|
-
${n}}`}else return String(e)},
|
|
21
|
-
`).replaceAll("\\$","$").replaceAll("\\t","\t")};var
|
|
22
|
-
`,
|
|
23
|
-
`,p):g}return y}}});var ae=async(e,r,t)=>e.rawArgs[r].quoted?e.rawArgs[r].value:await E(e.root,e.rawArgs[r].value,{defaultValue:t}),zr=()=>({switch:{processArgs:!1,fn:async(e)=>{let r=await ae(e,0,!1),t=await ae(e,1);if(t[r]===void 0){if(e.rawArgs.length>2)return ae(e,2);throw Error(`Unhandled switch case: ${r}`)}return t[r]}}});var et=()=>D({log:console.log});var rt=()=>({if:{types:{0:"boolean"},fn:(e)=>e.args[0]?e.args[1]:e.args[2]},check:{types:{0:Object.keys(C)},fn:(e)=>C[e.args[0]](...e.args.slice(1))},...D(C,{types:te})});var tt=(e)=>({default:{processArgs:!1,fn:async(r)=>{for(let t=0;t<r.rawArgs.length;t++)if(r.rawArgs[t]?.value!==void 0){let o=await ae(r,t,null);if(o!==null)return o}if(r.tags.nullable?.length)return b.DeleteItem();if(r.tags.fail?.length)throw Error(`No valid value found for default (${r.rawArgs.map((t)=>t.value).join(", ")})`);return""}},section:{types:["string","boolean"],fn:(r)=>{let t=r.args[0];if(!(r.args[1]??!0))return null;let o=e.getSection(t);if(!o)throw Error(`Section not found: ${t}`);return o.content}}});var nt=()=>({convert:({args:[e,r,t]})=>{switch(r){case"string":return String(e);case"number":{let n=Number(e);if(!isNaN(n))return b.ReplaceItem(n);break}case"boolean":if(e==="true"||e===!0||e===1||e==="1"||e==="yes"||e==="on")return b.ReplaceItem(!0);else if(e==="false"||e===!1||e===0||e==="0"||e==="no"||e==="off")return b.ReplaceItem(!1);break;default:throw Error(`Unsupported type for convert: ${r}`)}if(t!==void 0)return b.ReplaceItem(t);throw Error(`Failed to convert value to ${r}`)},isType:({args:[e,r]})=>{let n=(()=>{switch(r){case"string":return typeof e==="string";case"number":return typeof e==="number";case"boolean":return typeof e==="boolean";case"object":return e!==null&&typeof e==="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"null":return e===null;case"undefined":return e===void 0;case"function":return typeof e==="function";default:throw Error(`Unknown type for isType: ${r}`)}})();return b.ReplaceItem(n)},typeOf:({args:[e]})=>{if(e===null)return"null";else if(Array.isArray(e))return"array";else return typeof e}});var ot=()=>({...D({add:(...e)=>e.reduce((r,t)=>r+t,0),subtract:(e,r)=>e-r,multiply:(...e)=>e.reduce((r,t)=>r*t,1),divide:(e,r)=>{if(r===0)throw Error("Division by zero");return e/r},modulo:(e,r)=>e%r,power:(e,r)=>Math.pow(e,r),sqrt:(e)=>Math.sqrt(e),abs:(e)=>Math.abs(e),floor:(e)=>Math.floor(e),ceil:(e)=>Math.ceil(e),round:(e,r)=>{let t=Math.pow(10,r??0);return Math.round(e*t)/t},min:(...e)=>Math.min(...e),max:(...e)=>Math.max(...e),clamp:(e,r,t)=>Math.max(r,Math.min(t,e)),random:(e,r)=>{let t=e??0,n=r??1;return Math.random()*(n-t)+t}})});var st=()=>({now:()=>new Date,timestamp:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getTime()},iso:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).toISOString()},utc:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).toUTCString()},format:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=new Date(r),o=n.getFullYear(),s=String(n.getMonth()+1).padStart(2,"0"),a=String(n.getDate()).padStart(2,"0"),i=String(n.getHours()).padStart(2,"0"),l=String(n.getMinutes()).padStart(2,"0"),m=String(n.getSeconds()).padStart(2,"0");return t.replace("YYYY",String(o)).replace("MM",s).replace("DD",a).replace("HH",i).replace("mm",l).replace("ss",m)},parse:(e)=>{let r=e.args?.[0];return new Date(r).getTime()},year:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getFullYear()},month:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getMonth()+1},day:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getDate()},dayOfWeek:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getDay()},hours:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getHours()},minutes:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getMinutes()},seconds:(e)=>{let r=e.args?.[0];return(r?new Date(r):new Date).getSeconds()}});var it=()=>{return{unique:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];if(!Array.isArray(r))return r;let n=new Set;return r.filter((o)=>{let s=typeof t==="function"?t(o):t?o[t]:o;if(n.has(s))return!1;return n.add(s),!0})},groupBy:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];if(!Array.isArray(r))return r;let n={};return r.forEach((o)=>{let s=typeof t==="function"?String(t(o)):String(o[t]);if(!n[s])n[s]=[];n[s].push(o)}),n},partition:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];if(!Array.isArray(r))return[[],[]];if(typeof t!=="function")return[r,[]];let n=[],o=[];return r.forEach((s)=>{(t(s)?n:o).push(s)}),[n,o]},chunk:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1]??1;if(!Array.isArray(r))return[];let n=[];for(let o=0;o<r.length;o+=t)n.push(r.slice(o,o+t));return n},flatten:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1]??1;if(!Array.isArray(r))return[r];let n=[],o=(s,a)=>{for(let i of s)if(Array.isArray(i)&&a>0)o(i,a-1);else n.push(i)};return o(r,t),n},compact:(e)=>{let r=e.args?.[0]??e.value;if(!Array.isArray(r))return r;return r.filter((t)=>t!==null&&t!==void 0)},head:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];if(!Array.isArray(r))return r;return t?r.slice(0,t):r[0]},tail:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];if(!Array.isArray(r))return r;return t?r.slice(-t):r[r.length-1]}}};import{createHash as le}from"crypto";var at=()=>({md5:(e)=>{let r=e.args?.[0]??e.value;return le("md5").update(r).digest("hex")},sha1:(e)=>{let r=e.args?.[0]??e.value;return le("sha1").update(r).digest("hex")},sha256:(e)=>{let r=e.args?.[0]??e.value;return le("sha256").update(r).digest("hex")},sha512:(e)=>{let r=e.args?.[0]??e.value;return le("sha512").update(r).digest("hex")},hash:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1]??"sha256";return le(t).update(r).digest("hex")},base64Encode:(e)=>{let r=e.args?.[0]??e.value,t=typeof r==="string"?r:JSON.stringify(r);return Buffer.from(t).toString("base64")},base64Decode:(e)=>{let r=e.args?.[0]??e.value;return Buffer.from(r,"base64").toString("utf-8")},hexEncode:(e)=>{let r=e.args?.[0]??e.value;return Buffer.from(r).toString("hex")},hexDecode:(e)=>{let r=e.args?.[0]??e.value;return Buffer.from(r,"hex").toString("utf-8")}});var lt=()=>({test:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2];return new RegExp(r,n).test(t)},match:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=new RegExp(r,n);return t.match(o)},matchAll:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=new RegExp(r,n);return Array.from(t.matchAll(o))},replace:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=e.args?.[3],s=new RegExp(r,o);return n.replace(s,t)},replaceAll:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=e.args?.[3]??"g",s=new RegExp(r,o);return n.replace(s,t)},split:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=new RegExp(r,n);return t.split(o)},exec:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2];return new RegExp(r,n).exec(t)},search:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2],o=new RegExp(r,n);return t.search(o)}});import{resolve as jn,dirname as Dn,basename as kn,normalize as Rn,join as $n}from"path";var ut=()=>({...D({pathJoin:(...e)=>$n(...e),resolve:(...e)=>jn(...e),dirname:(e)=>Dn(e),basename:(e,r)=>kn(e,r),normalize:(e)=>Rn(e),extname:(e)=>{let r=/\.[^.]*$/.exec(e);return r?r[0]:""},relative:(e,r)=>{let t=e.split("/"),n=r.split("/"),o=0;while(o<t.length&&o<n.length&&t[o]===n[o])o++;let s=t.length-o,a=n.slice(o);return[...Array(s).fill("..")].concat(a).join("/")},isAbsolute:(e)=>e.startsWith("/"),segments:(e)=>e.split("/").filter(Boolean)})});var pt=()=>({isEmail:(e)=>{let r=e.args?.[0]??e.value;return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)},isUrl:(e)=>{let r=e.args?.[0]??e.value;try{return new URL(r),!0}catch{return!1}},isJson:(e)=>{let r=e.args?.[0]??e.value;try{return JSON.parse(r),!0}catch{return!1}},isUuid:(e)=>{let r=e.args?.[0]??e.value;return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(r)},minLength:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];return r?.length>=t},maxLength:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];return r?.length<=t},length:(e)=>{let r=e.args?.[0]??e.value,t=e.args?.[1];return r?.length===t},isNumber:(e)=>{let r=e.args?.[0]??e.value;return typeof r==="number"&&!isNaN(r)},isString:(e)=>{return typeof(e.args?.[0]??e.value)==="string"},isBoolean:(e)=>{return typeof(e.args?.[0]??e.value)==="boolean"},isArray:(e)=>{let r=e.args?.[0]??e.value;return Array.isArray(r)},isObject:(e)=>{let r=e.args?.[0]??e.value;return r!==null&&typeof r==="object"&&!Array.isArray(r)},isEmpty:(e)=>{let r=e.args?.[0]??e.value;if(r===null||r===void 0)return!0;if(typeof r==="string"||Array.isArray(r))return r.length===0;if(typeof r==="object")return Object.keys(r).length===0;return!1},isTruthy:(e)=>{return!!(e.args?.[0]??e.value)},isFalsy:(e)=>{return!(e.args?.[0]??e.value)},inRange:(e)=>{let r=e.args?.[0],t=e.args?.[1],n=e.args?.[2];return r>=t&&r<=n},matches:(e)=>{let r=e.args?.[0],t=e.args?.[1];return new RegExp(t).test(r)},includes:(e)=>{let r=e.args?.[0],t=e.args?.[1];if(typeof r==="string")return r.includes(String(t));return Array.isArray(r)&&r.includes(t)},startsWith:(e)=>{let r=e.args?.[0],t=e.args?.[1];return r.startsWith(t)},endsWith:(e)=>{let r=e.args?.[0],t=e.args?.[1];return r.endsWith(t)}});var He=(e)=>e.keys({...Fr(e),...Sr(e),...Wr(),...Nr(),...Ur(),...Ir(),...Lr(),..._r(e),...Br(e),...Yr(),...Kr(),...Qr()}).sources({...Vr(e),...xr(),...Hr(e),...nt(),...qr(),...Jr(),...zr(),...et(),...rt(),...tt(e),...ot(),...st(),...it(),...at(),...lt(),...ut(),...pt()}).sections(Gr(e)).fieldOptions({configParser:Bun.YAML.parse,onSection:(r)=>{if(r.section.config.name)e.section(r.section)}}).decoders({yaml:{matching:["\\.yml$","\\.yaml$"],fn:Bun.YAML.parse}}).encoders({json:{fn:(r)=>JSON.stringify(r,null,2)},yaml:{fn:(r)=>Bun.YAML.stringify(r,null,2)},terraform:{options:{includeTags:!0},fn:(r,t)=>Oe(r,0,{sortKeys:!!(t?.sort?.length??t?.sortKeys?.length)})}});var ct={};k(ct,{IncludeManager:()=>Me,DocumentIncludeProcessor:()=>Ee});import Cn from"fs/promises";import ue from"path";class Me{includeDirectories=[];baseIncludeDirectories=[];includes=[];addDirectories(...e){this.includeDirectories.push(...e),this.baseIncludeDirectories.push(...e)}getDirectories(){return this.includeDirectories}reset(){this.includeDirectories=[...this.baseIncludeDirectories]}restore(e){this.includeDirectories=[...e]}snapshot(){return[...this.includeDirectories]}addFiles(...e){this.includes.push(...e)}getPendingAndClear(){let e=[...this.includes];return this.includes.length=0,e}async processPatterns(e,r,t){let n=[];for(let o of e)if(T.isGlobPattern(o)){let s=(await Array.fromAsync(Cn.glob(o,{cwd:r}))).map((a)=>ue.join(r,a));for(let a of s)if(!t.included.includes(a))n.push(a)}else if(T.isDirectoryPattern(o)){let s=ue.isAbsolute(o)?o:ue.join(r,o);if(!this.includeDirectories.includes(s))this.includeDirectories.push(s)}else n.push(o);return n}buildSearchDirs(e){let r=e?[e]:[];return r.push(...this.includeDirectories.map((t)=>ue.isAbsolute(t)?t:ue.join(e??process.cwd(),t))),r}}class Ee{includeManager;loadFn;constructor(e,r){this.includeManager=e;this.loadFn=r}async processIncludes(e,r,t){let n=[];if(e.content.includes)n.push(...e.content.includes),delete e.content.includes;n.push(...this.includeManager.getPendingAndClear());let o=await this.includeManager.processPatterns(n,e.folderPath,t);for(let s of o)W(await this.loadFn(s,e.folderPath,{parent:e.content,...r},!0,t),e.content)}}var A={};k(A,{writeOutputs:()=>z,writeOutput:()=>me,writeFormat:()=>ce,tokenize:()=>xe,toObjectWithKey:()=>_e,toObject:()=>ee,toList:()=>U,stripIndent:()=>Ze,sortBy:()=>Be,snake:()=>X,select:()=>E,processFields:()=>j,pascal:()=>Q,padBlock:()=>N,nonNullMap:()=>Ue,navigate:()=>de,mergeAll:()=>Y,merge:()=>W,makeFieldProcessorMap:()=>D,makeFieldProcessorList:()=>Re,makeFieldProcessor:()=>H,locate:()=>_,loadFormat:()=>q,importList:()=>ge,importGlob:()=>Ie,globMap:()=>J,getProcessor:()=>Z,getArgs:()=>fe,find:()=>Xe,exists:()=>B,defined:()=>Te,deepClone:()=>$,conditionPredicates:()=>C,changeCase:()=>G,capital:()=>oe,camel:()=>se,asyncMap:()=>Ye,NavigateResult:()=>b,NavigateAction:()=>ye,Logger:()=>Ae});F(A,Ft(dt(),1));var wt={};k(wt,{Logger:()=>Ae});class Ae{options;constructor(e){this.options={level:"INFO",showClass:!1,levels:["DEBUG","VERBOSE","INFO","WARN","ERROR"],timeStamp:!1,timeOptions:{second:"2-digit",minute:"2-digit",hour:"2-digit",day:"2-digit",month:"2-digit",year:"2-digit"},logFunction:(r,...t)=>{switch(r){case"ERROR":console.error(...t);break;case"WARN":console.warn(...t);break;case"DEBUG":console.debug(...t);break;case"VERBOSE":console.log(...t);break;default:console.log(...t)}},...e}}write(e,...r){if(this.options.level){let o=this.options.levels.indexOf(this.options.level)??-1,s=this.options.levels.indexOf(e);if(s===-1)throw Error(`Unknown log level: ${e}`);if(s<o)return}let t=[],n=[];if(this.options.timeStamp)n.push(new Date().toLocaleString(this.options.timeLocale,this.options.timeOptions));if(this.options.showClass)n.push(e);if(n.length>0)t.push(`[${n.join(" ")}]`);t.push(...r),this.options.logFunction(e,...t)}info(...e){this.write("INFO",...e)}error(...e){this.write("ERROR",...e)}warn(...e){this.write("WARN",...e)}debug(...e){this.write("DEBUG",...e)}verbose(...e){this.write("VERBOSE",...e)}}F(R,A);var Ve=Object.getPrototypeOf(async function(){}).constructor;class ht{includeManager=new Me;includeProcessor;cacheManager=new we(100);outputs=[];vars={};funcs={};fields={sources:{},keys:{},sections:{}};objectMetadata={};currentContext=null;storedSections={};dataEncoders={};dataDecoders={};constructor(){this.includeProcessor=new Ee(this.includeManager,this.load.bind(this)),this.use(He)}use(e){if(e.prototype instanceof re)new e(this);else e(this);return this}includeDirectory(...e){return this.includeManager.addDirectories(...e),this}getIncludeDirectories(){return this.includeManager.getDirectories()}include(...e){return this.includeManager.addFiles(...e),this}keys(e){return Object.assign(this.fields.keys,{...this.fields.keys,...e}),this}sources(e){return Object.assign(this.fields.sources,{...this.fields.sources,...e}),this}sections(e){return Object.assign(this.fields.sections,{...this.fields.sections,...e}),this}variables(e){return this.vars={...this.vars,...e},this}functions(e){return this.funcs={...this.funcs,...e},this}getFunctions(){return this.funcs}getOutputs(){return this.outputs}output(e){return this.outputs.push(e),this}metadata(e,r){return this.objectMetadata[e]=r,this}getMetadata(e){return this.objectMetadata[e]}getAllMetadata(){return this.objectMetadata}setCacheMaxSize(e){return this.cacheManager.setMaxSize(e),this}clearCache(){return this.cacheManager.clear(),this}getCurrentContext(){return this.currentContext}fieldOptions(e){return this.fields={...this.fields,...e},this}section(e){return this.storedSections[e.config.name]=e,this}getSection(e){return this.storedSections[e]}encoders(e){return this.dataEncoders={...this.dataEncoders,...e},this}decoders(e){return this.dataDecoders={...this.dataDecoders,...e},this}getEncoder(e){return this.dataEncoders[e]}getDecoder(e){return this.dataDecoders[e]}filter(e){return this.fields.filters??=[],this.fields.filters.push(e),this}async loadObject(e,r,t){return j(e,{...this.fields,globalContext:{file:t?.fullPath??"@internal"},root:{...r,...this.fields.root,...this.vars,functions:this.funcs,context:this.currentContext,sections:this.storedSections,$document:{root:{content:e},fileName:t?.fileName??"@internal",folder:t?.folderPath??"@internal",fullPath:t?.fullPath??"@internal"}}})}async load(e,r,t,n,o){let s=this.includeManager.snapshot();try{this.includeManager.reset();let a=this.includeManager.buildSearchDirs(r);if(o)this.currentContext=o;this.currentContext??={included:[],document:null};let i=await q(e,{dirs:a,parsers:this.dataDecoders,format:"yaml"}),l=T.normalize(i.fullPath);if(this.currentContext.included.push(l),!i.content)return null;let m=this.cacheManager.get(l),d;if(m)d=m.raw;else d=i.content,this.cacheManager.set(l,{raw:d,timestamp:Date.now()});let y=$(d);i.content=y,await this.includeProcessor.processIncludes(i,t,this.currentContext);let u;if(n!==!0)u=await this.loadObject(i.content,t,{fileName:i.fullPath,folderPath:i.folderPath,fullPath:i.fullPath});else u=i.content;return this.currentContext.document=u,u}catch(a){throw this.includeManager.restore(s),a}finally{this.includeManager.restore(s)}}async writeAll(e){await z(this.getOutputs(),e)}}export{z as writeOutputs,me as writeOutput,ce as writeFormat,vr as variable,xe as tokenize,_e as toObjectWithKey,ee as toObject,U as toList,Ze as stripIndent,Be as sortBy,X as snake,Or as sharedFunction,E as select,hr as section,j as processFields,Q as pascal,N as padBlock,Ue as nonNullMap,de as navigate,Y as mergeAll,W as merge,D as makeFieldProcessorMap,Re as makeFieldProcessorList,H as makeFieldProcessor,wr as macro,_ as locate,q as loadFormat,br as key,ge as importList,Ie as importGlob,J as globMap,Z as getProcessor,fe as getArgs,Xe as find,B as exists,Mr as encoder,Te as defined,$ as deepClone,Er as decoder,C as conditionPredicates,G as changeCase,oe as capital,se as camel,Ye as asyncMap,re as ObjectorPlugin,ht as Objector,b as NavigateResult,ye as NavigateAction,Ae as Logger,Ve as AsyncFunction};
|
|
20
|
+
${n}}`}else return String(e)},be=(e)=>{if(!e)return e;return e.replaceAll("\\n",`
|
|
21
|
+
`).replaceAll("\\$","$").replaceAll("\\t","\t")};var bt=()=>({...K({merge:(...e)=>e.flatMap((r)=>r)}),join:({args:[e],root:r,tags:t})=>{let n=t.key?.[0],o=t.separator?.[0]??t.sep?.[0],i=t.finalize?.length>0,l=be(o);if(typeof e==="string"){if(i&&e.length&&l)return e+l;return e}if(!Array.isArray(e))throw Error("Object is not a list");let a=((n?.length)?e.map((y)=>D({...r,...y},n)):e).join(l),p=t.pad?.[0]??"0",h=t.padChar?.[0]??" ",O=i&&a.length&&l?a+l:a;return p?T(O,parseInt(p),`
|
|
22
|
+
`,h):O},range:({args:[e,r,t]})=>{let n=parseInt(e),o=parseInt(r),i=parseInt(t)||1;if(isNaN(n))throw Error("Invalid range: start value '"+String(e)+"' is not a number");if(isNaN(o))throw Error("Invalid range: end value '"+String(r)+"' is not a number");if(i===0)throw Error("Invalid range: step cannot be zero");if((o-n)/i<0)throw Error("Invalid range: step "+String(i)+" has wrong direction for range "+String(n)+" to "+String(o));return Array.from({length:Math.floor((o-n)/i)+1},(l,a)=>n+a*i)},filter:{types:(e,r,t)=>{switch(e){case 0:return"array";case 1:return Object.keys(L)}return ye[t[1].value]?.(e-2,r,t.slice(2))},fn:({args:[e,r,t],root:n,tags:o})=>{if(e===null||e===void 0)throw Error("Filter source cannot be null or undefined");if(!Array.isArray(e))throw Error("Filter source must be an array");let i=o.key?.[0],l=L[r];if(i){let p=Array(e.length);for(let O=0;O<e.length;O++)try{p[O]=D({...n,...e[O]},i)}catch{p[O]=Symbol("invalid")}let h=[];for(let O=0;O<e.length;O++){let y=p[O];if(typeof y!=="symbol"&&t===void 0?l(y):l(y,t))h.push(e[O])}return h}let a=[];for(let p of e)if(t===void 0?l(p):l(p,t))a.push(p);return a}}});var Ot=()=>({each:{processArgs:!1,fn:async({rawArgs:[e,r,...t],root:n,options:o,tags:i})=>{let l=async(g)=>g.quoted?be(g.value):await D(n,g.value),a=await D(n,e.value),p=await l(r),h=i.key?.[0],O=Array.isArray(a)?a:Z(a),y=[],u=await Promise.all(t.map(async(g)=>await l(g))),d={...n,item:void 0,index:0,params:u,instance:void 0,parent:n.this,tags:i},A={...o,root:d};for(let g=0;g<O.length;g++){let v=I(p),f={instance:v},j=typeof p==="string"?f:v;if(d.item=O[g],d.index=g,d.instance=v,i?.root?.[0])Object.assign(d,await D(d,i.root[0]));if(await C(j,A),h!==void 0)y.push(await D(f.instance,h));else y.push(f.instance)}if(i.join?.length){if(y.length===0)return"";let g=be(i.join[0]),v=i.pad?.[0]??"0",f=i.padChar?.[0]??" ",j=i.finalize?.length&&g?g:"",b=`${y.join(g)}${j}`;return v?T(b,parseInt(v),`
|
|
23
|
+
`,f):b}return y}}});var Oe=async(e,r,t)=>e.rawArgs[r].quoted?e.rawArgs[r].value:await D(e.root,e.rawArgs[r].value,{defaultValue:t}),vt=()=>({switch:{processArgs:!1,fn:async(e)=>{let r=await Oe(e,0,!1),t=await Oe(e,1);if(t[r]===void 0){if(e.rawArgs.length>2)return Oe(e,2);throw Error(`Unhandled switch case: ${r}`)}return t[r]}}});var At=()=>({if:{types:{0:"boolean"},fn:(e)=>e.args[0]?e.args[1]:e.args[2]},check:{types:{0:Object.keys(L)},fn:(e)=>L[e.args[0]](...e.args.slice(1))},...K(L,{types:ye})});var Et=(e)=>({default:{processArgs:!1,fn:async(r)=>{for(let t=0;t<r.rawArgs.length;t++)if(r.rawArgs[t]?.value!==void 0){let o=await Oe(r,t,null);if(o!==null)return o}if(r.tags.nullable?.length)return M.DeleteItem();if(r.tags.fail?.length)throw Error(`No valid value found for default (${r.rawArgs.map((t)=>t.value).join(", ")})`);return""}},section:{types:["string","boolean"],fn:(r)=>{let t=r.args[0];if(!(r.args[1]??!0))return null;let o=e.getSection(t);if(!o)throw Error(`Section not found: ${t}`);return o.content}}});var Mt=()=>({convert:({args:[e,r,t]})=>{switch(r){case"string":return String(e);case"number":{let n=Number(e);if(!isNaN(n))return M.ReplaceItem(n);break}case"boolean":if(e==="true"||e===!0||e===1||e==="1"||e==="yes"||e==="on")return M.ReplaceItem(!0);else if(e==="false"||e===!1||e===0||e==="0"||e==="no"||e==="off")return M.ReplaceItem(!1);break;default:throw Error(`Unsupported type for convert: ${r}`)}if(t!==void 0)return M.ReplaceItem(t);throw Error(`Failed to convert value to ${r}`)},isType:({args:[e,r]})=>{let n=(()=>{switch(r){case"string":return typeof e==="string";case"number":return typeof e==="number";case"boolean":return typeof e==="boolean";case"object":return e!==null&&typeof e==="object"&&!Array.isArray(e);case"array":return Array.isArray(e);case"null":return e===null;case"undefined":return e===void 0;case"function":return typeof e==="function";default:throw Error(`Unknown type for isType: ${r}`)}})();return M.ReplaceItem(n)},typeOf:({args:[e]})=>{if(e===null)return"null";else if(Array.isArray(e))return"array";else return typeof e}});var wr=(e)=>{var r,t,n,o,i,l,a,p,h,O,y,u,d,A,g,v,f,j,b,S,k,Ae,G,B,Ee,Me,Se,oe,Ye,je,Ge,Ct,Wt,Nt,It,Lt,_t,Ut,Bt,Tt,Kt,Yt,Gt,Qt,Xt,Vt,Zt,Ht,Pt,qt,zt,Jt,en,rn,tn,nn,on,sn,an,ln,un,pn,fn,cn,mn,gn,yn,dn,wn,hn,bn,On,vn,An,En,Mn,Sn,jn,kn,Dn,Fn,Rn,xn,$n,Cn,Wn,Nn,In,Ln,_n,Un,Bn,Tn,Kn,Yn,Gn,Qn,Xn,Vn,Zn,Hn,Pn,qn,zn,o,i,l,a,p,h,O,y,u,d,A,g,v,f,j,b,S,k,Ae,G,B,Ee,Me,Se,oe,Ye,je,Ge,Ct,Wt,Nt,It,Lt,_t,Ut,Bt,Tt,Kt,Yt,Gt,Qt,Xt,Vt,Zt,Ht,Pt,qt,zt,Jt,en,rn,tn,nn,on,sn,an,ln,un,pn,fn,cn,mn,gn,yn,dn,wn,hn,bn,On,vn,An,En,Mn,Sn,jn,kn,Dn,Fn,Rn,xn,$n,Cn,Wn,Nn,In,Ln,_n,Un,Bn,Tn,Kn,Yn,Gn,Qn,Xn,Vn,Zn,Hn,Pn,qn,zn;return e.use((n=H,o=[c()],i=[c()],l=[c()],a=[c()],p=[c()],h=[c()],O=[c()],y=[c()],u=[c()],d=[c()],A=[c()],g=[c()],v=[c()],f=[c()],j=[c()],b=[c()],S=[c()],k=[c()],Ae=[c()],G=[c()],B=[c()],Ee=[c()],Me=[c()],Se=[c()],oe=[c()],Ye=[c()],je=[c()],Ge=[c()],Ct=[c()],Wt=[c()],Nt=[c()],It=[c()],Lt=[c()],_t=[c()],Ut=[c()],Bt=[c()],Tt=[c()],Kt=[c()],Yt=[c()],Gt=[c()],Qt=[c()],Xt=[c()],Vt=[c()],Zt=[c()],Ht=[c()],Pt=[c()],qt=[c()],zt=[c()],Jt=[c()],en=[c()],rn=[c()],tn=[c()],nn=[c()],on=[c()],sn=[c()],an=[c()],ln=[c()],un=[c()],pn=[c()],fn=[c()],cn=[c()],mn=[c()],gn=[c()],yn=[c()],dn=[c()],wn=[c()],hn=[c()],bn=[c()],On=[c()],vn=[c()],An=[c()],En=[c()],Mn=[c()],Sn=[c()],jn=[c()],kn=[c()],Dn=[c()],Fn=[c()],Rn=[c()],xn=[c()],$n=[c()],Cn=[c()],Wn=[c()],Nn=[c()],In=[c()],Ln=[c()],_n=[c()],Un=[c()],Bn=[c()],Tn=[c()],Kn=[c()],Yn=[c()],Gn=[c()],Qn=[c()],Xn=[c()],Vn=[c()],Zn=[c()],Hn=[c()],Pn=[c()],qn=[c()],zn=[c()],t=Sr(n),r=class extends n{constructor(){super(...arguments);kr(t,5,this)}env(s){return process.env[s]}uuid(){return crypto.randomUUID()}pascal(s){return ee(s)}camel(s){return he(s)}capital(s){return we(s)}snake(s,w){return te(re(s,"_"),w)}kebab(s,w){return te(re(s,"-"),w)}len(s){return s.length}reverse(s){return s.split("").reverse().join("")}concat(...s){return s.join("")}trim(s){return s.trim()}ltrim(s){return s.trimStart()}rtrim(s){return s.trimEnd()}lower(s){return s.toLowerCase()}upper(s){return s.toUpperCase()}encode(s,w){return Buffer.from(s).toString(w??"base64")}decode(s,w){return Buffer.from(s,w??"base64").toString()}list(s,w){return Z(s,w)}object(s,w){return ge(s,w)}pathJoin(...s){return Y.join(...s)}resolve(...s){return Y.resolve(...s)}dirname(s){return Y.dirname(s)}basename(s,w){return Y.basename(s,w)}normalize(s){return Y.normalize(s)}extname(s){return Y.extname(s)}relative(s,w){return Y.relative(s,w)}isAbsolute(s){return Y.isAbsolute(s)}segments(s){return s.split("/").filter(Boolean)}log(...s){console.log(...s)}md5(s){return ne("md5").update(s).digest("hex")}sha1(s){return ne("sha1").update(s).digest("hex")}sha256(s){return ne("sha256").update(s).digest("hex")}sha512(s){return ne("sha512").update(s).digest("hex")}hash(s,w="sha256"){return ne(w).update(s).digest("hex")}hmac(s,w,E="sha256"){return ne(E).update(s).digest("hex")}base64Encode(s){return Buffer.from(s).toString("base64")}base64Decode(s){return Buffer.from(s,"base64").toString("utf-8")}hexEncode(s){return Buffer.from(s).toString("hex")}hexDecode(s){return Buffer.from(s,"hex").toString("utf-8")}add(...s){return s.reduce((w,E)=>w+E,0)}subtract(s,w){return s-w}multiply(...s){return s.reduce((w,E)=>w*E,1)}divide(s,w){if(w===0)throw Error("Division by zero");return s/w}modulo(s,w){return s%w}power(s,w){return Math.pow(s,w)}sqrt(s){return Math.sqrt(s)}abs(s){return Math.abs(s)}floor(s){return Math.floor(s)}ceil(s){return Math.ceil(s)}round(s,w){let E=Math.pow(10,w??0);return Math.round(s*E)/E}min(...s){return Math.min(...s)}max(...s){return Math.max(...s)}clamp(s,w,E){return Math.max(w,Math.min(E,s))}random(s,w){let E=s??0,$=w??1;return Math.random()*($-E)+E}timestamp(s){return new Date(s).getTime()}iso(s){return new Date(s).toISOString()}utc(s){return new Date(s).toUTCString()}formatDate(s,w){let E=new Date(s),$=E.getFullYear(),U=String(E.getMonth()+1).padStart(2,"0"),ke=String(E.getDate()).padStart(2,"0"),ie=String(E.getHours()).padStart(2,"0"),Jn=String(E.getMinutes()).padStart(2,"0"),eo=String(E.getSeconds()).padStart(2,"0");return w.replace("YYYY",String($)).replace("MM",U).replace("DD",ke).replace("HH",ie).replace("mm",Jn).replace("ss",eo)}parseDate(s){return new Date(s).getTime()}year(s){return new Date(s).getFullYear()}month(s){return new Date(s).getMonth()+1}day(s){return new Date(s).getDate()}dayOfWeek(s){return new Date(s).getDay()}hours(s){return new Date(s).getHours()}minutes(s){return new Date(s).getMinutes()}seconds(s){return new Date(s).getSeconds()}regexTest(s,w,E){return new RegExp(s,E).test(w)}regexMatch(s,w,E){return new RegExp(s,E).exec(w)}regexMatchAll(s,w,E){return Array.from(w.matchAll(new RegExp(s,E)))}regexReplace(s,w,E,$){return E.replace(new RegExp(s,$),w)}regexReplaceAll(s,w,E,$){return E.replace(new RegExp(s,$??"g"),w)}regexSplit(s,w,E){return w.split(new RegExp(s,E))}regexExec(s,w,E){return new RegExp(s,E).exec(w)}regexSearch(s,w,E){return w.search(new RegExp(s,E))}unique(s,w){if(!Array.isArray(s))return s;let E=new Set;return s.filter(($)=>{let U=w?$[w]:$;if(E.has(U))return!1;return E.add(U),!0})}groupBy(s,w){if(!Array.isArray(s))return s;let E={};return s.forEach(($)=>{let U=String($[w]);if(!E[U])E[U]=[];E[U].push($)}),E}chunk(s,w=1){if(!Array.isArray(s))return[];let E=[];for(let $=0;$<s.length;$+=w)E.push(s.slice($,$+w));return E}flatten(s,w=1){if(!Array.isArray(s))return[s];let E=[],$=(U,ke)=>{for(let ie of U)if(Array.isArray(ie)&&ke>0)$(ie,ke-1);else E.push(ie)};return $(s,w),E}compact(s){if(!Array.isArray(s))return s;return s.filter((w)=>w!==null&&w!==void 0)}head(s,w){if(!Array.isArray(s))return s;return w?s.slice(0,w):s[0]}tail(s,w){if(!Array.isArray(s))return s;return w?s.slice(-w):s[s.length-1]}isEmail(s){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s)}isUrl(s){try{return new URL(s),!0}catch{return!1}}isJson(s){try{return JSON.parse(s),!0}catch{return!1}}isUuid(s){return/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s)}minLength(s,w){return s?.length>=w}maxLength(s,w){return s?.length<=w}lengthEquals(s,w){return s?.length===w}isNumber(s){return typeof s==="number"&&!isNaN(s)}isString(s){return typeof s==="string"}isBoolean(s){return typeof s==="boolean"}isArray(s){return Array.isArray(s)}isObject(s){return s!==null&&typeof s==="object"&&!Array.isArray(s)}isEmpty(s){if(s===null||s===void 0)return!0;if(typeof s==="string"||Array.isArray(s))return s.length===0;if(typeof s==="object")return Object.keys(s).length===0;return!1}isTruthy(s){return!!s}isFalsy(s){return!s}inRange(s,w,E){return s>=w&&s<=E}matchesPattern(s,w){return new RegExp(w).test(s)}includes(s,w){if(typeof s==="string")return s.includes(String(w));return Array.isArray(s)&&s.includes(w)}startsWith(s,w){return s.startsWith(w)}endsWith(s,w){return s.endsWith(w)}},m(t,1,"env",o,r),m(t,1,"uuid",i,r),m(t,1,"pascal",l,r),m(t,1,"camel",a,r),m(t,1,"capital",p,r),m(t,1,"snake",h,r),m(t,1,"kebab",O,r),m(t,1,"len",y,r),m(t,1,"reverse",u,r),m(t,1,"concat",d,r),m(t,1,"trim",A,r),m(t,1,"ltrim",g,r),m(t,1,"rtrim",v,r),m(t,1,"lower",f,r),m(t,1,"upper",j,r),m(t,1,"encode",b,r),m(t,1,"decode",S,r),m(t,1,"list",k,r),m(t,1,"object",Ae,r),m(t,1,"pathJoin",G,r),m(t,1,"resolve",B,r),m(t,1,"dirname",Ee,r),m(t,1,"basename",Me,r),m(t,1,"normalize",Se,r),m(t,1,"extname",oe,r),m(t,1,"relative",Ye,r),m(t,1,"isAbsolute",je,r),m(t,1,"segments",Ge,r),m(t,1,"log",Ct,r),m(t,1,"md5",Wt,r),m(t,1,"sha1",Nt,r),m(t,1,"sha256",It,r),m(t,1,"sha512",Lt,r),m(t,1,"hash",_t,r),m(t,1,"hmac",Ut,r),m(t,1,"base64Encode",Bt,r),m(t,1,"base64Decode",Tt,r),m(t,1,"hexEncode",Kt,r),m(t,1,"hexDecode",Yt,r),m(t,1,"add",Gt,r),m(t,1,"subtract",Qt,r),m(t,1,"multiply",Xt,r),m(t,1,"divide",Vt,r),m(t,1,"modulo",Zt,r),m(t,1,"power",Ht,r),m(t,1,"sqrt",Pt,r),m(t,1,"abs",qt,r),m(t,1,"floor",zt,r),m(t,1,"ceil",Jt,r),m(t,1,"round",en,r),m(t,1,"min",rn,r),m(t,1,"max",tn,r),m(t,1,"clamp",nn,r),m(t,1,"random",on,r),m(t,1,"timestamp",sn,r),m(t,1,"iso",an,r),m(t,1,"utc",ln,r),m(t,1,"formatDate",un,r),m(t,1,"parseDate",pn,r),m(t,1,"year",fn,r),m(t,1,"month",cn,r),m(t,1,"day",mn,r),m(t,1,"dayOfWeek",gn,r),m(t,1,"hours",yn,r),m(t,1,"minutes",dn,r),m(t,1,"seconds",wn,r),m(t,1,"regexTest",hn,r),m(t,1,"regexMatch",bn,r),m(t,1,"regexMatchAll",On,r),m(t,1,"regexReplace",vn,r),m(t,1,"regexReplaceAll",An,r),m(t,1,"regexSplit",En,r),m(t,1,"regexExec",Mn,r),m(t,1,"regexSearch",Sn,r),m(t,1,"unique",jn,r),m(t,1,"groupBy",kn,r),m(t,1,"chunk",Dn,r),m(t,1,"flatten",Fn,r),m(t,1,"compact",Rn,r),m(t,1,"head",xn,r),m(t,1,"tail",$n,r),m(t,1,"isEmail",Cn,r),m(t,1,"isUrl",Wn,r),m(t,1,"isJson",Nn,r),m(t,1,"isUuid",In,r),m(t,1,"minLength",Ln,r),m(t,1,"maxLength",_n,r),m(t,1,"lengthEquals",Un,r),m(t,1,"isNumber",Bn,r),m(t,1,"isString",Tn,r),m(t,1,"isBoolean",Kn,r),m(t,1,"isArray",Yn,r),m(t,1,"isObject",Gn,r),m(t,1,"isEmpty",Qn,r),m(t,1,"isTruthy",Xn,r),m(t,1,"isFalsy",Vn,r),m(t,1,"inRange",Zn,r),m(t,1,"matchesPattern",Hn,r),m(t,1,"includes",Pn,r),m(t,1,"startsWith",qn,r),m(t,1,"endsWith",zn,r),Ze(t,r),r)).keys({...Zr(e),...Hr(e),...tt(),...nt(),...at(),...ot(),...it(),...st(e),...ut(e),...pt(),...ft(),...ct()}).sources({...dt(e),...ht(e),...Mt(),...bt(),...Ot(),...vt(),...At(),...Et(e)}).sections(gt(e)).fieldOptions({configParser:Bun.YAML.parse,onSection:(s)=>{if(s.section.config.name)e.section(s.section)}}).decoders({yaml:{matching:["\\.yml$","\\.yaml$"],fn:Bun.YAML.parse}}).encoders({json:{fn:(s)=>JSON.stringify(s,null,2)},yaml:{fn:(s)=>Bun.YAML.stringify(s,null,2)},terraform:{options:{includeTags:!0},fn:(s,w)=>Ue(s,0,{sortKeys:!!(w?.sort?.length??w?.sortKeys?.length)})}})};var jt={};W(jt,{IncludeManager:()=>Be,DocumentIncludeProcessor:()=>Te});import fi from"fs/promises";import ve from"path";class Be{includeDirectories=[];baseIncludeDirectories=[];includes=[];addDirectories(...e){this.includeDirectories.push(...e),this.baseIncludeDirectories.push(...e)}getDirectories(){return this.includeDirectories}reset(){this.includeDirectories=[...this.baseIncludeDirectories]}restore(e){this.includeDirectories=[...e]}snapshot(){return[...this.includeDirectories]}addFiles(...e){this.includes.push(...e)}getPendingAndClear(){let e=[...this.includes];return this.includes.length=0,e}async processPatterns(e,r,t){let n=[];for(let o of e)if(P.isGlobPattern(o)){let i=(await Array.fromAsync(fi.glob(o,{cwd:r}))).map((l)=>ve.join(r,l));for(let l of i)if(!t.included.includes(l))n.push(l)}else if(P.isDirectoryPattern(o)){let i=ve.isAbsolute(o)?o:ve.join(r,o);if(!this.includeDirectories.includes(i))this.includeDirectories.push(i)}else n.push(o);return n}buildSearchDirs(e){let r=e?[e]:[];return r.push(...this.includeDirectories.map((t)=>ve.isAbsolute(t)?t:ve.join(e??process.cwd(),t))),r}}class Te{includeManager;loadFn;constructor(e,r){this.includeManager=e;this.loadFn=r}async processIncludes(e,r,t){let n=[];if(e.content.includes)n.push(...e.content.includes),delete e.content.includes;n.push(...this.includeManager.getPendingAndClear());let o=await this.includeManager.processPatterns(n,e.folderPath,t);for(let i of o)_(await this.loadFn(i,e.folderPath,{parent:e.content,...r},!0,t),e.content)}}var F={};W(F,{writeOutputs:()=>me,writeOutput:()=>xe,writeFormat:()=>Re,tokenize:()=>yr,toObjectWithKey:()=>or,toObject:()=>ge,toList:()=>Z,stripIndent:()=>dr,sortBy:()=>ar,snake:()=>re,select:()=>D,processFields:()=>C,pascal:()=>ee,padBlock:()=>T,nonNullMap:()=>ir,navigate:()=>We,mergeAll:()=>z,merge:()=>_,makeFieldProcessorMap:()=>K,makeFieldProcessorList:()=>qe,makeFieldProcessor:()=>pe,locate:()=>V,loadFormat:()=>fe,importList:()=>$e,importGlob:()=>tr,globMap:()=>ce,getProcessor:()=>ue,getArgs:()=>Fe,find:()=>fr,exists:()=>q,defined:()=>sr,deepClone:()=>I,conditionPredicates:()=>L,changeCase:()=>te,capital:()=>we,camel:()=>he,asyncMap:()=>lr,NavigateResult:()=>M,NavigateAction:()=>Ce,Logger:()=>Ke});R(F,io(Rt(),1));var xt={};W(xt,{Logger:()=>Ke});class Ke{options;constructor(e){this.options={level:"INFO",showClass:!1,levels:["DEBUG","VERBOSE","INFO","WARN","ERROR"],timeStamp:!1,timeOptions:{second:"2-digit",minute:"2-digit",hour:"2-digit",day:"2-digit",month:"2-digit",year:"2-digit"},logFunction:(r,...t)=>{switch(r){case"ERROR":console.error(...t);break;case"WARN":console.warn(...t);break;case"DEBUG":console.debug(...t);break;case"VERBOSE":console.log(...t);break;default:console.log(...t)}},...e}}write(e,...r){if(this.options.level){let o=this.options.levels.indexOf(this.options.level)??-1,i=this.options.levels.indexOf(e);if(i===-1)throw Error(`Unknown log level: ${e}`);if(i<o)return}let t=[],n=[];if(this.options.timeStamp)n.push(new Date().toLocaleString(this.options.timeLocale,this.options.timeOptions));if(this.options.showClass)n.push(e);if(n.length>0)t.push(`[${n.join(" ")}]`);t.push(...r),this.options.logFunction(e,...t)}info(...e){this.write("INFO",...e)}error(...e){this.write("ERROR",...e)}warn(...e){this.write("WARN",...e)}debug(...e){this.write("DEBUG",...e)}verbose(...e){this.write("VERBOSE",...e)}}R(N,F);var gr=Object.getPrototypeOf(async function(){}).constructor;class $t{includeManager=new Be;includeProcessor;cacheManager=new Ne(100);outputs=[];vars={};funcs={};fields={sources:{},keys:{},sections:{}};objectMetadata={};currentContext=null;storedSections={};dataEncoders={};dataDecoders={};constructor(){this.includeProcessor=new Te(this.includeManager,this.load.bind(this)),this.use(wr)}use(e){if(e.prototype instanceof H)new e(this);else e(this);return this}includeDirectory(...e){return this.includeManager.addDirectories(...e),this}getIncludeDirectories(){return this.includeManager.getDirectories()}include(...e){return this.includeManager.addFiles(...e),this}keys(e){return Object.assign(this.fields.keys,{...this.fields.keys,...e}),this}sources(e){return Object.assign(this.fields.sources,{...this.fields.sources,...e}),this}sections(e){return Object.assign(this.fields.sections,{...this.fields.sections,...e}),this}variables(e){return this.vars={...this.vars,...e},this}functions(e){return this.funcs={...this.funcs,...e},this}getFunctions(){return this.funcs}getOutputs(){return this.outputs}output(e){return this.outputs.push(e),this}metadata(e,r){return this.objectMetadata[e]=r,this}getMetadata(e){return this.objectMetadata[e]}getAllMetadata(){return this.objectMetadata}setCacheMaxSize(e){return this.cacheManager.setMaxSize(e),this}clearCache(){return this.cacheManager.clear(),this}getCurrentContext(){return this.currentContext}fieldOptions(e){return this.fields={...this.fields,...e},this}section(e){return this.storedSections[e.config.name]=e,this}getSection(e){return this.storedSections[e]}encoders(e){return this.dataEncoders={...this.dataEncoders,...e},this}decoders(e){return this.dataDecoders={...this.dataDecoders,...e},this}getEncoder(e){return this.dataEncoders[e]}getDecoder(e){return this.dataDecoders[e]}filter(e){return this.fields.filters??=[],this.fields.filters.push(e),this}async loadObject(e,r,t){return C(e,{...this.fields,globalContext:{file:t?.fullPath??"@internal"},root:{...r,...this.fields.root,...this.vars,functions:this.funcs,context:this.currentContext,sections:this.storedSections,$document:{root:{content:e},fileName:t?.fileName??"@internal",folder:t?.folderPath??"@internal",fullPath:t?.fullPath??"@internal"}}})}async load(e,r,t,n,o){let i=this.includeManager.snapshot();try{this.includeManager.reset();let l=this.includeManager.buildSearchDirs(r);if(o)this.currentContext=o;this.currentContext??={included:[],document:null};let a=await fe(e,{dirs:l,parsers:this.dataDecoders,format:"yaml"}),p=P.normalize(a.fullPath);if(this.currentContext.included.push(p),!a.content)return null;let h=this.cacheManager.get(p),O;if(h)O=h.raw;else O=a.content,this.cacheManager.set(p,{raw:O,timestamp:Date.now()});let y=I(O);a.content=y,await this.includeProcessor.processIncludes(a,t,this.currentContext);let u;if(n!==!0)u=await this.loadObject(a.content,t,{fileName:a.fullPath,folderPath:a.folderPath,fullPath:a.fullPath});else u=a.content;return this.currentContext.document=u,u}catch(l){throw this.includeManager.restore(i),l}finally{this.includeManager.restore(i)}}async writeAll(e){await me(this.getOutputs(),e)}}export{me as writeOutputs,xe as writeOutput,Re as writeFormat,Yr as variable,yr as tokenize,or as toObjectWithKey,ge as toObject,Z as toList,dr as stripIndent,ar as sortBy,re as snake,Gr as sharedFunction,D as select,Tr as section,C as processFields,ee as pascal,T as padBlock,ir as nonNullMap,We as navigate,z as mergeAll,_ as merge,K as makeFieldProcessorMap,qe as makeFieldProcessorList,pe as makeFieldProcessor,c as macro,V as locate,fe as loadFormat,Kr as key,$e as importList,tr as importGlob,ce as globMap,ue as getProcessor,Fe as getArgs,fr as find,q as exists,Qr as encoder,sr as defined,I as deepClone,Xr as decoder,L as conditionPredicates,te as changeCase,we as capital,he as camel,lr as asyncMap,H as ObjectorPlugin,$t as Objector,M as NavigateResult,Ce as NavigateAction,Ke as Logger,gr as AsyncFunction};
|
package/package.json
CHANGED
package/dist/index.d.ts
DELETED
|
@@ -1,750 +0,0 @@
|
|
|
1
|
-
export declare const AsyncFunction: any;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Maps an array asynchronously using Promise.all for parallel execution
|
|
5
|
-
* @typeParam T - Type of input array items
|
|
6
|
-
* @typeParam U - Type of async result items
|
|
7
|
-
* @param arr - Array to map
|
|
8
|
-
* @param fn - Async mapping function
|
|
9
|
-
* @returns Promise of mapped array
|
|
10
|
-
* @public
|
|
11
|
-
*/
|
|
12
|
-
export declare const asyncMap: <T, U>(arr: T[], fn: (item: T, index: number, array: T[]) => Promise<U>) => Promise<U[]>;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Converts a string to camelCase (lowerCamelCase).
|
|
16
|
-
* Handles spaces, underscores, and hyphens as word separators.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* camel('hello_world') // 'helloWorld'
|
|
20
|
-
* camel('hello world') // 'helloWorld'
|
|
21
|
-
* camel('HelloWorld') // 'helloWorld'
|
|
22
|
-
*
|
|
23
|
-
* @param v - The string to convert
|
|
24
|
-
* @returns The string in camelCase
|
|
25
|
-
*/
|
|
26
|
-
export declare const camel: (v: string) => string;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Converts a string to Capital Case (each word capitalized, spaces preserved).
|
|
30
|
-
* Only capitalizes words following spaces.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* capital('hello world') // 'Hello World'
|
|
34
|
-
* capital('hello_world') // 'hello_World'
|
|
35
|
-
*
|
|
36
|
-
* @param v - The string to convert
|
|
37
|
-
* @returns The string with each space-separated word capitalized
|
|
38
|
-
*/
|
|
39
|
-
export declare const capital: (v: string) => string;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Changes the case of a string to uppercase, lowercase, or returns unchanged.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* changeCase('Hello', 'upper') // 'HELLO'
|
|
46
|
-
* changeCase('Hello', 'lower') // 'hello'
|
|
47
|
-
* changeCase('Hello') // 'Hello'
|
|
48
|
-
*
|
|
49
|
-
* @param v - The string to transform
|
|
50
|
-
* @param arg - The case type: 'upper', 'lower', or undefined to return unchanged
|
|
51
|
-
* @returns The transformed string
|
|
52
|
-
*/
|
|
53
|
-
export declare const changeCase: (v: string, arg?: string) => string;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
export declare const conditionPredicates: Record<string, (...args: any[]) => boolean>;
|
|
59
|
-
|
|
60
|
-
export declare const decoder: (options?: DecoderOptions) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (data: string) => unknown>) => void;
|
|
61
|
-
|
|
62
|
-
declare type DecoderOptions = ObjectorDecoratorOptions;
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Deep clones an object using structuredClone (faster) with JSON fallback
|
|
66
|
-
* - Uses structuredClone for better performance and broader type support (Date, RegExp, etc.)
|
|
67
|
-
* - Falls back to JSON serialization if structuredClone fails or is unavailable
|
|
68
|
-
* - Note: Functions, symbols, and undefined values are lost in JSON fallback
|
|
69
|
-
* @typeParam T - Type of object to clone
|
|
70
|
-
* @param model - Object to clone
|
|
71
|
-
* @returns Deep clone of the object
|
|
72
|
-
* @public
|
|
73
|
-
*/
|
|
74
|
-
export declare const deepClone: <T>(model: T) => T;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Asserts that a value is defined, throwing an error if undefined
|
|
78
|
-
* @typeParam T - Type of the value
|
|
79
|
-
* @param value - Value to check
|
|
80
|
-
* @param msg - Error message to throw if value is undefined or null
|
|
81
|
-
* @returns The value if defined
|
|
82
|
-
* @throws Error if value is undefined
|
|
83
|
-
* @public
|
|
84
|
-
*/
|
|
85
|
-
export declare const defined: <T>(value: T | undefined | null, msg?: string) => T;
|
|
86
|
-
|
|
87
|
-
declare interface Encoder {
|
|
88
|
-
fn: (data: unknown, ...args: any[]) => string | Promise<string>;
|
|
89
|
-
options?: EncoderOptions;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export declare const encoder: (options?: EncoderOptions_2) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (data: unknown) => string | Promise<string>>) => void;
|
|
93
|
-
|
|
94
|
-
declare interface EncoderOptions {
|
|
95
|
-
includeTags?: boolean;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
declare type EncoderOptions_2 = ObjectorDecoratorOptions;
|
|
99
|
-
|
|
100
|
-
export declare const exists: (fileName: string) => Promise<boolean>;
|
|
101
|
-
|
|
102
|
-
export declare interface FieldContext {
|
|
103
|
-
path: string;
|
|
104
|
-
root: any;
|
|
105
|
-
options: ProcessFieldsOptions;
|
|
106
|
-
value: string | object | number | NavigateResult | null;
|
|
107
|
-
key: string;
|
|
108
|
-
args: any[];
|
|
109
|
-
rawArgs: {
|
|
110
|
-
value: string;
|
|
111
|
-
quoted: boolean;
|
|
112
|
-
}[];
|
|
113
|
-
tags: Record<string, string[]>;
|
|
114
|
-
parent?: any;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
export declare interface FieldProcessor {
|
|
118
|
-
fn: FieldProcessorFunc;
|
|
119
|
-
options: FieldProcessorOptions;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export declare type FieldProcessorFunc = (context: FieldContext) => any;
|
|
123
|
-
|
|
124
|
-
export declare type FieldProcessorMap = Record<string, FieldProcessorTypedFunc>;
|
|
125
|
-
|
|
126
|
-
export declare interface FieldProcessorOptions {
|
|
127
|
-
filters?: RegExp[];
|
|
128
|
-
processArgs?: boolean;
|
|
129
|
-
types?: Record<number, string | any[] | ((value: string, root: any, index: number, quoted: boolean) => any)> | FieldProcessorTypeChecker;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export declare interface FieldProcessorSection {
|
|
133
|
-
config: Record<string, any>;
|
|
134
|
-
content: string;
|
|
135
|
-
trim?: boolean;
|
|
136
|
-
indent?: number;
|
|
137
|
-
show?: boolean;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
export declare type FieldProcessorSectionConfigFunc = (context: FieldProcessorSectionContext) => Promise<boolean | void> | boolean | void;
|
|
141
|
-
|
|
142
|
-
export declare interface FieldProcessorSectionContext {
|
|
143
|
-
section: FieldProcessorSection;
|
|
144
|
-
content: string;
|
|
145
|
-
path: string;
|
|
146
|
-
root: Record<string, any>;
|
|
147
|
-
options: ProcessFieldsOptions;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export declare type FieldProcessorSectionFunc = (context: FieldProcessorSectionContext) => Promise<void | boolean | string> | void | boolean | string;
|
|
151
|
-
|
|
152
|
-
export declare type FieldProcessorSectionMap = Record<string, FieldProcessorSectionFunc>;
|
|
153
|
-
|
|
154
|
-
export declare type FieldProcessorTypeChecker = (n: number, value: any, args: any[]) => any;
|
|
155
|
-
|
|
156
|
-
export declare type FieldProcessorTypeCheckers<T = unknown> = Record<keyof T, FieldProcessorTypeChecker>;
|
|
157
|
-
|
|
158
|
-
export declare type FieldProcessorTypedFunc = FieldProcessorFunc | (FieldProcessorOptions & {
|
|
159
|
-
fn: FieldProcessorFunc;
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
declare interface FilePatternOptions {
|
|
163
|
-
cwd: string;
|
|
164
|
-
filter?: (fileName: string, index: number, array: string[]) => boolean;
|
|
165
|
-
map: (fileName: string, index: number, array: string[]) => Promise<any>;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Finds values in an object tree that match a predicate function.
|
|
170
|
-
*
|
|
171
|
-
* @public
|
|
172
|
-
* @param from - The object to search through
|
|
173
|
-
* @param cb - Predicate function that receives the path and value, returns true for matches
|
|
174
|
-
* @returns Array of matching values
|
|
175
|
-
*
|
|
176
|
-
* @example
|
|
177
|
-
* ```typescript
|
|
178
|
-
* const obj = { a: { b: 1 }, c: { d: 2 } }
|
|
179
|
-
* const results = await find(obj, (path, value) => value === 2)
|
|
180
|
-
* // results: [2]
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
export declare const find: (from: any, cb: (path: string, value: any) => boolean) => Promise<any[]>;
|
|
184
|
-
|
|
185
|
-
export declare const globMap: <T>(pattern: string | string[], options: FilePatternOptions) => Promise<T[] | T>;
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* @public
|
|
189
|
-
*/
|
|
190
|
-
export declare const importGlob: (patterns: string[], options?: ImportOptions) => Promise<any[]>;
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* @public
|
|
194
|
-
*/
|
|
195
|
-
export declare const importList: (modules: string[], options?: ImportOptions) => Promise<any[]>;
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* @public
|
|
199
|
-
*/
|
|
200
|
-
export declare interface ImportOptions {
|
|
201
|
-
cwd?: string;
|
|
202
|
-
resolveDefault?: boolean | 'only';
|
|
203
|
-
filter?: (name: string) => boolean | undefined;
|
|
204
|
-
fail?: (name: string, error: any) => boolean | undefined;
|
|
205
|
-
map?: (module: any, name: string) => any;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export declare const key: (options?: KeyOptions) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (value: any) => any>) => void;
|
|
209
|
-
|
|
210
|
-
declare type KeyOptions = ObjectorDecoratorOptions;
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* @public
|
|
214
|
-
*/
|
|
215
|
-
export declare interface LoadContext {
|
|
216
|
-
included: string[];
|
|
217
|
-
document: unknown;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* @public
|
|
222
|
-
* @param fileName
|
|
223
|
-
* @param options
|
|
224
|
-
* @returns
|
|
225
|
-
*/
|
|
226
|
-
export declare const loadFormat: <T = any>(fileName: string, options?: LoadOptions) => Promise<LoadResult<T>>;
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* @public
|
|
230
|
-
*/
|
|
231
|
-
export declare interface LoadFormatParser {
|
|
232
|
-
matching?: string[];
|
|
233
|
-
fn: (data: string) => any;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* @public
|
|
238
|
-
*/
|
|
239
|
-
export declare interface LoadObjectOptions {
|
|
240
|
-
fileName: string;
|
|
241
|
-
fullPath: string;
|
|
242
|
-
folderPath: string;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* @public
|
|
247
|
-
*/
|
|
248
|
-
export declare interface LoadOptions {
|
|
249
|
-
dirs?: string[];
|
|
250
|
-
parsers?: Record<string, LoadFormatParser>;
|
|
251
|
-
format?: string;
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
export declare interface LoadResult<T> {
|
|
255
|
-
fullPath: string;
|
|
256
|
-
folderPath: string;
|
|
257
|
-
content: T;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
export declare const locate: (fileName: string, dirs?: string[]) => Promise<string>;
|
|
261
|
-
|
|
262
|
-
export declare type LogFunction = (className: string, ...args: any[]) => void;
|
|
263
|
-
|
|
264
|
-
export declare class Logger {
|
|
265
|
-
options: LoggerOptions;
|
|
266
|
-
constructor(options?: Partial<LoggerOptions>);
|
|
267
|
-
write(className: string, ...args: any[]): void;
|
|
268
|
-
info(...args: any[]): void;
|
|
269
|
-
error(...args: any[]): void;
|
|
270
|
-
warn(...args: any[]): void;
|
|
271
|
-
debug(...args: any[]): void;
|
|
272
|
-
verbose(...args: any[]): void;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
export declare interface LoggerOptions {
|
|
276
|
-
level: string;
|
|
277
|
-
showClass: boolean;
|
|
278
|
-
levels: string[];
|
|
279
|
-
timeStamp: boolean;
|
|
280
|
-
timeLocale?: string;
|
|
281
|
-
timeOptions?: Intl.DateTimeFormatOptions;
|
|
282
|
-
logFunction: LogFunction;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
export declare const macro: (options?: MacroOptions) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (...args: any[]) => any>) => void;
|
|
286
|
-
|
|
287
|
-
declare type MacroOptions = ObjectorDecoratorOptions;
|
|
288
|
-
|
|
289
|
-
export declare const makeFieldProcessor: (fn: SourceFunc, types?: FieldProcessorTypeChecker) => FieldProcessorTypedFunc;
|
|
290
|
-
|
|
291
|
-
export declare const makeFieldProcessorList: <T = unknown>(source: SourceFunc[], options?: {
|
|
292
|
-
types?: FieldProcessorTypeCheckers<T>;
|
|
293
|
-
}) => FieldProcessorMap;
|
|
294
|
-
|
|
295
|
-
export declare const makeFieldProcessorMap: <T = unknown>(source: Record<keyof T, SourceFunc>, options?: {
|
|
296
|
-
types?: FieldProcessorTypeCheckers<T>;
|
|
297
|
-
keys?: (keyof T)[];
|
|
298
|
-
}) => FieldProcessorMap;
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* @public
|
|
302
|
-
* @param source
|
|
303
|
-
* @param target
|
|
304
|
-
* @param options
|
|
305
|
-
*/
|
|
306
|
-
export declare const merge: (source: any, target: any, options?: MergeOptions) => void;
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* @public
|
|
310
|
-
* @param elements
|
|
311
|
-
* @param options
|
|
312
|
-
*/
|
|
313
|
-
export declare const mergeAll: (elements: any[], options?: MergeOptions) => any;
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* @public
|
|
317
|
-
*/
|
|
318
|
-
export declare type MergeMode = 'merge' | 'source' | 'target' | 'skip';
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* @public
|
|
322
|
-
*/
|
|
323
|
-
export declare interface MergeOptions {
|
|
324
|
-
conflict?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => any;
|
|
325
|
-
mismatch?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => any;
|
|
326
|
-
navigate?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => boolean | undefined;
|
|
327
|
-
mode?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => MergeMode | void;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* Recursively navigates through an object tree, invoking a callback for each property.
|
|
332
|
-
* Supports various actions like replacing, deleting, or merging values during traversal.
|
|
333
|
-
* Includes circular reference detection to prevent infinite loops.
|
|
334
|
-
*
|
|
335
|
-
* Performance optimizations:
|
|
336
|
-
* - Caches static NavigateResult instances
|
|
337
|
-
* - Uses WeakSet for O(1) circular reference detection
|
|
338
|
-
* - Avoids Object.entries() to prevent array allocations
|
|
339
|
-
* - Optimizes switch statement order for common cases
|
|
340
|
-
*
|
|
341
|
-
* @public
|
|
342
|
-
* @param o - The object to navigate
|
|
343
|
-
* @param cb - Callback function invoked for each property
|
|
344
|
-
* @throws {Error} When attempting to replace the root object
|
|
345
|
-
*/
|
|
346
|
-
export declare const navigate: (o: any, cb: NavigateCallback) => Promise<void>;
|
|
347
|
-
|
|
348
|
-
/**
|
|
349
|
-
* @public
|
|
350
|
-
*/
|
|
351
|
-
export declare enum NavigateAction {
|
|
352
|
-
Explore = 0,
|
|
353
|
-
SkipSiblings = 1,
|
|
354
|
-
NoExplore = 2,
|
|
355
|
-
ReplaceParent = 3,
|
|
356
|
-
DeleteParent = 4,
|
|
357
|
-
MergeParent = 5,
|
|
358
|
-
ReplaceItem = 6,
|
|
359
|
-
DeleteItem = 7
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* @public
|
|
364
|
-
*/
|
|
365
|
-
export declare type NavigateCallback = (context: NavigateContext) => Promise<NavigateResult> | NavigateResult;
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* @public
|
|
369
|
-
*/
|
|
370
|
-
export declare interface NavigateContext {
|
|
371
|
-
key: string;
|
|
372
|
-
value: any;
|
|
373
|
-
path: string[];
|
|
374
|
-
parent: any;
|
|
375
|
-
parents: any[];
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/**
|
|
379
|
-
* @public
|
|
380
|
-
*/
|
|
381
|
-
export declare class NavigateResult {
|
|
382
|
-
readonly action: NavigateAction;
|
|
383
|
-
by?: any | undefined;
|
|
384
|
-
skipSiblings?: boolean | undefined;
|
|
385
|
-
reexplore?: boolean | undefined;
|
|
386
|
-
constructor(action: NavigateAction, by?: any | undefined, skipSiblings?: boolean | undefined, reexplore?: boolean | undefined);
|
|
387
|
-
private static readonly _explore;
|
|
388
|
-
private static readonly _noExplore;
|
|
389
|
-
private static readonly _skipSiblings;
|
|
390
|
-
private static readonly _deleteParent;
|
|
391
|
-
static ReplaceParent(by: any, reexplore?: boolean): NavigateResult;
|
|
392
|
-
static SkipSiblings(): NavigateResult;
|
|
393
|
-
static Explore(): NavigateResult;
|
|
394
|
-
static NoExplore(): NavigateResult;
|
|
395
|
-
static DeleteParent(): NavigateResult;
|
|
396
|
-
static MergeParent(by: any): NavigateResult;
|
|
397
|
-
static ReplaceItem(by: any, skipSiblings?: boolean): NavigateResult;
|
|
398
|
-
static DeleteItem(skipSiblings?: boolean): NavigateResult;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
/**
|
|
402
|
-
* Maps an array while filtering out null/undefined values (performance optimized)
|
|
403
|
-
* Combines filter and map operations to avoid double iteration
|
|
404
|
-
* @typeParam T - Type of input array items
|
|
405
|
-
* @typeParam U - Type of mapped result items
|
|
406
|
-
* @param arr - Array to map (can be undefined)
|
|
407
|
-
* @param fn - Mapping function
|
|
408
|
-
* @returns Mapped array with nulls/undefined filtered out, or empty array if input is undefined
|
|
409
|
-
* @public
|
|
410
|
-
*/
|
|
411
|
-
export declare const nonNullMap: <T, U>(arr: T[] | undefined, fn: (item: T, index: number, array: T[]) => U) => U[];
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* @public
|
|
415
|
-
*/
|
|
416
|
-
export declare class Objector {
|
|
417
|
-
private includeManager;
|
|
418
|
-
private includeProcessor;
|
|
419
|
-
private cacheManager;
|
|
420
|
-
private outputs;
|
|
421
|
-
private vars;
|
|
422
|
-
private funcs;
|
|
423
|
-
private fields;
|
|
424
|
-
private objectMetadata;
|
|
425
|
-
private currentContext;
|
|
426
|
-
private storedSections;
|
|
427
|
-
private dataEncoders;
|
|
428
|
-
private dataDecoders;
|
|
429
|
-
constructor();
|
|
430
|
-
use(handler: ObjectorPluginConstructor | ObjectorPluginFunction): this;
|
|
431
|
-
includeDirectory(...dirs: string[]): this;
|
|
432
|
-
getIncludeDirectories(): string[];
|
|
433
|
-
include(...files: string[]): this;
|
|
434
|
-
keys(keys: FieldProcessorMap): this;
|
|
435
|
-
sources(sources: FieldProcessorMap): this;
|
|
436
|
-
sections(sections: Record<string, FieldProcessorSectionFunc>): this;
|
|
437
|
-
variables(vars: Record<string, unknown>): this;
|
|
438
|
-
functions(funcs: Record<string, typeof AsyncFunction>): this;
|
|
439
|
-
getFunctions(): Record<string, typeof AsyncFunction>;
|
|
440
|
-
getOutputs(): Output[];
|
|
441
|
-
output(o: Output): this;
|
|
442
|
-
metadata(path: string, o: unknown): this;
|
|
443
|
-
getMetadata(path: string): unknown;
|
|
444
|
-
getAllMetadata(): Record<string, unknown>;
|
|
445
|
-
setCacheMaxSize(size: number): this;
|
|
446
|
-
clearCache(): this;
|
|
447
|
-
getCurrentContext(): LoadContext | null;
|
|
448
|
-
fieldOptions(options: ProcessFieldsOptions): this;
|
|
449
|
-
section(section: FieldProcessorSection): this;
|
|
450
|
-
getSection(name: string): FieldProcessorSection | undefined;
|
|
451
|
-
encoders(encoders: Record<string, Encoder>): this;
|
|
452
|
-
decoders(decoders: Record<string, LoadFormatParser>): this;
|
|
453
|
-
getEncoder(name: string): Encoder | undefined;
|
|
454
|
-
getDecoder(name: string): LoadFormatParser | undefined;
|
|
455
|
-
filter(f: RegExp): this;
|
|
456
|
-
loadObject<T = any>(data: T, container?: any, options?: LoadObjectOptions): Promise<T>;
|
|
457
|
-
load<T = unknown>(fileName: string, cwd?: string, container?: unknown, noProcess?: boolean, ld?: LoadContext): Promise<T | null>;
|
|
458
|
-
writeAll(option?: WriteOutputsOption): Promise<void>;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
declare interface ObjectorDecoratorOptions {
|
|
462
|
-
name?: string;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
export declare class ObjectorPlugin {
|
|
466
|
-
protected readonly o: Objector;
|
|
467
|
-
protected readonly context: {
|
|
468
|
-
path: string;
|
|
469
|
-
root: any;
|
|
470
|
-
options: ProcessFieldsOptions;
|
|
471
|
-
value?: string | object | number | null;
|
|
472
|
-
key?: string;
|
|
473
|
-
args?: any[];
|
|
474
|
-
rawArgs?: {
|
|
475
|
-
value: string;
|
|
476
|
-
quoted: boolean;
|
|
477
|
-
}[];
|
|
478
|
-
tags?: Record<string, string[]>;
|
|
479
|
-
parent?: any;
|
|
480
|
-
config?: Record<string, any>;
|
|
481
|
-
};
|
|
482
|
-
constructor(o: Objector);
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
export declare type ObjectorPluginConstructor = new (o: Objector, ...args: any[]) => ObjectorPlugin;
|
|
486
|
-
|
|
487
|
-
declare type ObjectorPluginFunction = (o: Objector) => void;
|
|
488
|
-
|
|
489
|
-
export declare interface Output {
|
|
490
|
-
name: string;
|
|
491
|
-
type?: 'json' | 'yaml' | 'text';
|
|
492
|
-
value: any;
|
|
493
|
-
class?: string;
|
|
494
|
-
}
|
|
495
|
-
|
|
496
|
-
/**
|
|
497
|
-
* Adds indentation to each line of a string.
|
|
498
|
-
* Useful for formatting multi-line text with consistent indentation.
|
|
499
|
-
*
|
|
500
|
-
* @example
|
|
501
|
-
* padBlock('hello\\nworld', 2) // ' hello\\n world'
|
|
502
|
-
* padBlock('a|b|c', 1, '|', '-') // '-a|-b|-c'
|
|
503
|
-
*
|
|
504
|
-
* @param str - The string to indent
|
|
505
|
-
* @param indent - The number of padding units to add
|
|
506
|
-
* @param separator - The separator between lines (default: '\\n')
|
|
507
|
-
* @param padder - The character to repeat for padding (default: ' ')
|
|
508
|
-
* @returns The indented string
|
|
509
|
-
*/
|
|
510
|
-
export declare const padBlock: (str: string, indent: number, separator?: string, padder?: string) => string;
|
|
511
|
-
|
|
512
|
-
/**
|
|
513
|
-
* Converts a string to PascalCase (UpperCamelCase).
|
|
514
|
-
* Handles spaces, underscores, and hyphens as word separators.
|
|
515
|
-
*
|
|
516
|
-
* @example
|
|
517
|
-
* pascal('hello_world') // 'HelloWorld'
|
|
518
|
-
* pascal('hello world') // 'HelloWorld'
|
|
519
|
-
* pascal('helloWorld') // 'HelloWorld'
|
|
520
|
-
*
|
|
521
|
-
* @param v - The string to convert
|
|
522
|
-
* @returns The string in PascalCase
|
|
523
|
-
*/
|
|
524
|
-
export declare const pascal: (v: string) => string;
|
|
525
|
-
|
|
526
|
-
/**
|
|
527
|
-
* @public
|
|
528
|
-
* @param obj
|
|
529
|
-
* @param options
|
|
530
|
-
* @returns
|
|
531
|
-
*/
|
|
532
|
-
export declare const processFields: (obj: any, options?: ProcessFieldsOptions) => Promise<any>;
|
|
533
|
-
|
|
534
|
-
export declare interface ProcessFieldsOptions {
|
|
535
|
-
sources?: FieldProcessorMap;
|
|
536
|
-
keys?: FieldProcessorMap;
|
|
537
|
-
sections?: FieldProcessorSectionMap;
|
|
538
|
-
filters?: RegExp[];
|
|
539
|
-
root?: Record<any, any>;
|
|
540
|
-
globalContext?: any;
|
|
541
|
-
onSection?: FieldProcessorSectionFunc;
|
|
542
|
-
onSectionConfig?: FieldProcessorSectionConfigFunc;
|
|
543
|
-
configParser?: (configText: string) => any;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
export declare const section: (options?: SectionOptions) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (section: FieldProcessorSection) => any>) => void;
|
|
547
|
-
|
|
548
|
-
declare type SectionOptions = ObjectorDecoratorOptions;
|
|
549
|
-
|
|
550
|
-
/**
|
|
551
|
-
* Selects a value from a nested object using a path string with advanced querying capabilities
|
|
552
|
-
*
|
|
553
|
-
* Supports:
|
|
554
|
-
* - Dot notation: 'user.profile.name'
|
|
555
|
-
* - Array indexing: 'users.0' or 'users[0]'
|
|
556
|
-
* - Array filtering: 'users.[name=John].age'
|
|
557
|
-
* - References: 'users.\{activeUserId\}.name'
|
|
558
|
-
* - Optional paths: 'user.profile?.bio'
|
|
559
|
-
* - Default values: 'config.timeout?=5000'
|
|
560
|
-
*
|
|
561
|
-
* @public
|
|
562
|
-
* @param from - The root object to select from
|
|
563
|
-
* @param path - The path string to navigate
|
|
564
|
-
* @param options - Optional configuration
|
|
565
|
-
* @returns The selected value or undefined
|
|
566
|
-
*
|
|
567
|
-
* @example
|
|
568
|
-
* ```typescript
|
|
569
|
-
* const obj = { user: { name: 'Alice', age: 30 } }
|
|
570
|
-
* select(obj, 'user.name') // 'Alice'
|
|
571
|
-
* select(obj, 'user.email', { defaultValue: 'N/A' }) // 'N/A'
|
|
572
|
-
* ```
|
|
573
|
-
*/
|
|
574
|
-
export declare const select: <T = any>(from: any, path: string, options?: SelectOptions) => T | undefined;
|
|
575
|
-
|
|
576
|
-
/**
|
|
577
|
-
* Options for configuring the select function behavior
|
|
578
|
-
* @public
|
|
579
|
-
*/
|
|
580
|
-
export declare interface SelectOptions {
|
|
581
|
-
/** Value to set at the selected path */
|
|
582
|
-
set?: any;
|
|
583
|
-
/** Alternative key to use (currently unused) */
|
|
584
|
-
key?: string;
|
|
585
|
-
/** Path separator character (default: '.') */
|
|
586
|
-
separator?: string;
|
|
587
|
-
/** Default value to return when path is not found */
|
|
588
|
-
defaultValue?: any;
|
|
589
|
-
/** If true, returns undefined instead of throwing on missing paths */
|
|
590
|
-
optional?: boolean;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
export declare const sharedFunction: (options?: SharedFunctionOptions) => (_: any, ctx: ClassMethodDecoratorContext<ObjectorPlugin, (...args: any[]) => any>) => void;
|
|
594
|
-
|
|
595
|
-
declare type SharedFunctionOptions = ObjectorDecoratorOptions;
|
|
596
|
-
|
|
597
|
-
/**
|
|
598
|
-
* Converts a string to snake_case or custom_case.
|
|
599
|
-
* Inserts the separator between lowercase and uppercase characters.
|
|
600
|
-
*
|
|
601
|
-
* @example
|
|
602
|
-
* snake('helloWorld', '_') // 'hello_world'
|
|
603
|
-
* snake('HelloWorld', '-') // 'hello-world'
|
|
604
|
-
* snake('hello world', '_') // 'hello_world'
|
|
605
|
-
*
|
|
606
|
-
* @param v - The string to convert
|
|
607
|
-
* @param separator - The separator to use between words (default: '_')
|
|
608
|
-
* @returns The string in snake case with the specified separator
|
|
609
|
-
*/
|
|
610
|
-
export declare const snake: (v: string, separator?: string) => string;
|
|
611
|
-
|
|
612
|
-
/**
|
|
613
|
-
* Sorts an array by a selector function with custom comparison
|
|
614
|
-
* Uses a shallow copy to avoid mutating the original array
|
|
615
|
-
* @typeParam T - Type of array items
|
|
616
|
-
* @typeParam U - Type of comparison values
|
|
617
|
-
* @param arr - Array to sort
|
|
618
|
-
* @param selector - Function to extract comparison value from item
|
|
619
|
-
* @param compare - Comparison function (default: numeric comparison)
|
|
620
|
-
* @returns New sorted array
|
|
621
|
-
* @public
|
|
622
|
-
*/
|
|
623
|
-
export declare const sortBy: <T, U>(arr: T[], selector: (item: T) => U, compare?: (a: U, b: U) => number) => T[];
|
|
624
|
-
|
|
625
|
-
declare type SourceFunc = (...args: any[]) => any;
|
|
626
|
-
|
|
627
|
-
export declare const splitNested: (str: string, separator: string, open?: string, close?: string) => string[];
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Splits a string by a separator while respecting quoted values.
|
|
631
|
-
* Quoted values can contain the separator without being split.
|
|
632
|
-
* Supports both single (') and double (") quotes.
|
|
633
|
-
*
|
|
634
|
-
* @param input - The string to split
|
|
635
|
-
* @param separator - Single or multi-character separator (default: ',')
|
|
636
|
-
* @returns Array of objects with value and quoted status
|
|
637
|
-
*
|
|
638
|
-
* @example
|
|
639
|
-
* splitWithQuotes('hello, "world", test')
|
|
640
|
-
* // Returns: [
|
|
641
|
-
* // { value: 'hello', quoted: false },
|
|
642
|
-
* // { value: 'world', quoted: true },
|
|
643
|
-
* // { value: 'test', quoted: false }
|
|
644
|
-
* // ]
|
|
645
|
-
*
|
|
646
|
-
* @example
|
|
647
|
-
* splitWithQuotes('a:: "b:: c":: d', '::')
|
|
648
|
-
* // Returns: [
|
|
649
|
-
* // { value: 'a', quoted: false },
|
|
650
|
-
* // { value: 'b:: c', quoted: true },
|
|
651
|
-
* // { value: 'd', quoted: false }
|
|
652
|
-
* // ]
|
|
653
|
-
*/
|
|
654
|
-
export declare const splitWithQuotes: (input: string, separator?: string) => {
|
|
655
|
-
value: string;
|
|
656
|
-
quoted: boolean;
|
|
657
|
-
}[];
|
|
658
|
-
|
|
659
|
-
export declare const stripIndent: (value: string) => string;
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* Replaces tokens in a string with values from an object.
|
|
663
|
-
* Tokens are in the format `$\{key\}`.
|
|
664
|
-
*
|
|
665
|
-
* @example
|
|
666
|
-
* tokenize('Hello $\{name\}', { name: 'World' }) // 'Hello World'
|
|
667
|
-
* tokenize('$\{greeting\} $\{name\}!', { greeting: 'Hi', name: 'Alice' }) // 'Hi Alice!'
|
|
668
|
-
* tokenize('$\{missing\}', {}) // ''
|
|
669
|
-
*
|
|
670
|
-
* @param str - The string containing tokens
|
|
671
|
-
* @param from - An object with key-value pairs for token replacement
|
|
672
|
-
* @param tokenizer - The regex pattern for token matching (default: `/\$\{([^}]+)\}/g`)
|
|
673
|
-
* @returns The string with tokens replaced by values from the object
|
|
674
|
-
*/
|
|
675
|
-
export declare const tokenize: (str: string, from: Record<string, unknown>, tokenizer?: RegExp) => string;
|
|
676
|
-
|
|
677
|
-
/**
|
|
678
|
-
* Converts an object's entries into an array of objects with a key property
|
|
679
|
-
* @typeParam T - The type of items in the resulting array
|
|
680
|
-
* @param from - Object to convert
|
|
681
|
-
* @param key - Property name to use for keys (default: 'name')
|
|
682
|
-
* @returns Array of objects with key properties
|
|
683
|
-
* @example
|
|
684
|
-
* toList({ a: { value: 1 }, b: { value: 2 } }) // [{ name: 'a', value: 1 }, { name: 'b', value: 2 }]
|
|
685
|
-
* @public
|
|
686
|
-
*/
|
|
687
|
-
export declare const toList: <T>(from: Record<string, unknown>, key?: string) => T[];
|
|
688
|
-
|
|
689
|
-
/**
|
|
690
|
-
* Converts an array into an object indexed by a key property, excluding the key from items
|
|
691
|
-
* @typeParam T - The type of the resulting object values
|
|
692
|
-
* @param from - Array to convert
|
|
693
|
-
* @param key - Property name to use as key (default: 'name')
|
|
694
|
-
* @returns Object indexed by key values, without the key property in values
|
|
695
|
-
* @example
|
|
696
|
-
* toObject([{ name: 'a', value: 1 }]) // { a: { value: 1 } }
|
|
697
|
-
* @public
|
|
698
|
-
*/
|
|
699
|
-
export declare const toObject: <T extends Record<string, unknown>>(from: T[], key?: string) => Record<string, Omit<T, typeof key>>;
|
|
700
|
-
|
|
701
|
-
/**
|
|
702
|
-
* Converts an array into an object indexed by a key property, keeping the full items
|
|
703
|
-
* @typeParam T - The type of the resulting object
|
|
704
|
-
* @param from - Array to convert
|
|
705
|
-
* @param key - Property name to use as key (default: 'name')
|
|
706
|
-
* @returns Object indexed by key values
|
|
707
|
-
* @example
|
|
708
|
-
* toObjectWithKey([{ name: 'a', value: 1 }]) // { a: { name: 'a', value: 1 } }
|
|
709
|
-
* @public
|
|
710
|
-
*/
|
|
711
|
-
export declare const toObjectWithKey: <T extends Record<string, unknown>>(from: T[], key?: string) => Record<string, T>;
|
|
712
|
-
|
|
713
|
-
export declare const variable: (options?: VariableOptions) => (_: any, ctx: ClassFieldDecoratorContext<ObjectorPlugin, any>) => void;
|
|
714
|
-
|
|
715
|
-
declare type VariableOptions = ObjectorDecoratorOptions;
|
|
716
|
-
|
|
717
|
-
export declare const writeFormat: (filePath: string, content: any, options?: WriteFormatOptions) => Promise<void>;
|
|
718
|
-
|
|
719
|
-
/**
|
|
720
|
-
* @public
|
|
721
|
-
*/
|
|
722
|
-
export declare interface WriteFormatEncoder {
|
|
723
|
-
matching?: string[];
|
|
724
|
-
fn: (data: any) => Promise<string> | string;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* @public
|
|
729
|
-
*/
|
|
730
|
-
export declare interface WriteFormatOptions {
|
|
731
|
-
format: string;
|
|
732
|
-
encoders?: Record<string, WriteFormatEncoder>;
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
export declare const writeOutput: (o: Output, options?: WriteOutputOption) => Promise<void>;
|
|
736
|
-
|
|
737
|
-
export declare interface WriteOutputOption {
|
|
738
|
-
targetDirectory?: string;
|
|
739
|
-
writing?: (output: Output) => boolean | undefined | void;
|
|
740
|
-
classes?: string[];
|
|
741
|
-
classRequired?: boolean;
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
export declare const writeOutputs: (outputs: Output[], options?: WriteOutputsOption) => Promise<void>;
|
|
745
|
-
|
|
746
|
-
export declare interface WriteOutputsOption extends WriteOutputOption {
|
|
747
|
-
removeFirst?: boolean;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
export { }
|