@homedev/objector 0.1.32 → 1.0.3
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 +2 -3
- package/package.json +10 -3
- package/dist/objector.d.ts +0 -222
package/dist/index.js
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
`))},list:(r)=>D(r.args[0],r.args[1]),object:(r)=>R(r.args[0],r.args[1]),each:{processArgs:!1,fn:async(r)=>{let f=(T)=>$(T,{root:r.root,load:(b)=>w.load(b,void 0,r.file&&X.dirname(r.file))}),F=await f(r.rawArgs[0].value),n=await f(r.rawArgs[1].value),g=r.rawArgs[2]?.value,O=Array.isArray(F)?F:D(F),E=[];for(let T=0;T<O.length;T++){let b=JSON.parse(JSON.stringify(n)),C={instance:b};if(await U(C,{...r.options,root:{...r.root,item:O[T],this:b,parent:r.root.this,index:T,params:r.rawArgs.slice(3).map((M)=>M.value)}}),g!==void 0&&g!=="@")E.push(C.instance[g]);else E.push(C.instance)}return E}},log:(r)=>{console.log(...r.args)},default:{processArgs:!1,fn:async(r)=>{let f=r.rawArgs[1]?.value?await q(w,r,1):"";return q(w,r,0,f)}},if:{processArgs:!1,fn:async(r)=>{let f=await q(w,r,0,!1);if(!o(f,r.rawArgs.length>3?r.rawArgs[3].value.split(","):void 0))return r.rawArgs.length>2?q(w,r,2):"";return q(w,r,1)}},switch:{processArgs:!1,fn:async(r)=>{let f=await q(w,r,0,!1),F=await q(w,r,1);if(F[f]===void 0){if(r.rawArgs.length>2)return q(w,r,2);throw new Error(`Unhandled switch case: ${f}`)}return F[f]}}}};class t{options={load:{dirs:[]},merge:{},include:{},fields:{},includeKey:"includes",mergeKey:".merge",includes:[],outputs:[]};cache={};includeDirectory(...w){return this.options.load.dirs??=[],this.options.load.dirs.push(...w),this}include(...w){return this.options.includes??=[],this.options.includes.push(...w),this}keys(w){return this.options.fields.keys={...this.options.fields.keys,...w},this}sources(w){return this.options.fields.sources={...this.options.fields.sources,...w},this}variables(w){return this.options.variables={...this.options.variables,...w},this}output(w){return this.options.outputs??=[],this.options.outputs.push(w),this}defaultProcessors(){return this.sources(v(this)).keys(h(this))}alias(w,r){return this.cache[w]=r,this}getAlias(w){return this.cache[w]}getOutputs(){return this.options.outputs??[]}getIncludeDirectories(){return this.options.load.dirs??[]}use(w){return w(this),this}filter(w){return this.options.fields.filters??=[],this.options.fields.filters?.push(w),this}async load(w,r,f,F,n){if(r&&this.cache[r])return this.cache[r];if(this.cache[w])return this.cache[w];let g=f?[f]:[];this.options.load.dirs&&g.push(...this.options.load.dirs);let O=await B(w,{...this.options.load,dirs:g});if(!O.content)return null;if(r)this.cache[r]=O.content;let E=[];if(this.options.includeKey&&O.content[this.options.includeKey])E.push(...O.content[this.options.includeKey]),delete O.content[this.options.includeKey];if(this.options.includes)E.push(...this.options.includes),this.options.includes.length=0;if(await P(E,{root:O.folderPath,loaded:(T)=>{if(this.options.mergeKey)Z(T,O.content,{mode:(b,C,M)=>M[this.options.mergeKey],...this.options.merge})},load:(T)=>this.load(T,void 0,O.folderPath,{parent:O.content,...F},!0),...this.options.include}),n!==!0)await U(O.content,{...this.options.fields,file:O.fullPath,root:{...this.options.fields.root,...this.options.variables,$document:{root:O,fileName:w,folder:O.folderPath,fullPath:O.fullPath,...F}},load:(T)=>this.load(T,void 0,O.folderPath,{parent:O.content,...F})});return O.content}merge(w,r){Z(w,r,{mode:(f,F,n)=>n[this.options.mergeKey],...this.options.merge})}mergeAll(w){let r={};for(let f of w.toReversed())this.merge(f,r);return r}async writeOutputs(w){if(w?.targetDirectory&&w?.removeFirst)try{await G.rm(w?.targetDirectory,{recursive:!0,force:!0})}catch(r){throw new Error(`Failed to clean the output directory: ${r.message}`)}for(let r of this.getOutputs()){let f=a.join(w?.targetDirectory??".",r.name),F=a.dirname(f);if(w?.writing?.(r)===!1)continue;try{await G.mkdir(F,{recursive:!0})}catch(n){throw new Error(`Failed to create target directory "${F}" for output "${f}": ${n.message}`)}try{switch(r.type){case"yaml":await G.writeFile(f,c.stringify(r.value));break;case"json":await G.writeFile(f,JSON.stringify(r.value));break;default:await G.writeFile(f,r.value.toString())}}catch(n){throw new Error(`Failed to write output "${f}": ${n.message}`)}}}}export{Pr as toObjectWithKey,R as toObject,D as toList,$ as select,P as processIncludes,U as processFields,H as navigate,Z as merge,I as locate,B as load,Yr as find,t as Objector,j as NavigateResult,K as NavigateAction};
|
|
1
|
+
var nr=Object.create;var{getPrototypeOf:ir,defineProperty:g,getOwnPropertyNames:E,getOwnPropertyDescriptor:pr}=Object,S=Object.prototype.hasOwnProperty;var w=(o,r,e)=>{e=o!=null?nr(ir(o)):{};let s=r||!o||!o.__esModule?g(e,"default",{value:o,enumerable:!0}):e;for(let t of E(o))if(!S.call(s,t))g(s,t,{get:()=>o[t],enumerable:!0});return s},h=new WeakMap,lr=(o)=>{var r=h.get(o),e;if(r)return r;if(r=g({},"__esModule",{value:!0}),o&&typeof o==="object"||typeof o==="function")E(o).map((s)=>!S.call(r,s)&&g(r,s,{get:()=>o[s],enumerable:!(e=pr(o,s))||e.enumerable}));return h.set(o,r),r};var mr=(o,r)=>{for(var e in r)g(o,e,{get:r[e],enumerable:!0,configurable:!0,set:(s)=>r[e]=()=>s})};var fr={};mr(fr,{Objector:()=>ar});module.exports=lr(fr);var sr=require("@homedev/fields"),F=require("@homedev/files"),tr=require("@homedev/merge"),P=w(require("path"));var C=(o)=>({output:(r)=>{delete r.parent[r.key];for(let e of Array.isArray(r.value)?r.value:[r.value])if(typeof e==="string")o.output({name:e,value:r.parent});else o.output({...e,value:e.value??r.parent})}});var _=require("@homedev/navigate"),v=w(require("path")),L=(o)=>({load:async(r)=>{let e=r.options.globalContext;for(let{file:s}of Array.isArray(r.value)?r.value:[r.value]){if(!s)throw new Error("File reference required");await o.load(s,e.file&&v.default.dirname(e.file))}return _.NavigateResult.DeleteItem()}});var j=require("@homedev/fields"),A=require("@homedev/merge"),c=require("@homedev/select"),D=(o)=>({each:{filters:[/select|model/],fn:async(r)=>{let e=r.value;delete r.parent[r.key];let s=()=>{let p=e.model;if(typeof r.value==="string"||!p)return r.parent;if(typeof p==="string")return c.select(r.root,p);return p},t=()=>{if(typeof r.value==="string")return c.select(r.root,r.value);if(Array.isArray(r.value))return r.value;if(typeof e.from==="string")return c.select(r.root,e.from);return e.from},a=async(p)=>{if(e.selector===void 0)return p;if(typeof e.selector!=="string"){let f=JSON.parse(JSON.stringify(e.selector));return await j.processFields(f,{...r.options,root:{...r.root,result:p}}),f}return await c.select({...r.root,result:p},e.selector)},n=await t(),i=await s();if(!Array.isArray(n))throw new Error('Key "each" requires a source list');if(i===void 0)throw new Error('Key "each" must define a model');if(e.extend?.model)i=A.mergeAll([e.model,...Array.isArray(e.extend.model)?e.extend.model:[e.extend.model]]);let m=[];for(let p=0;p<n.length;p++){let f=JSON.parse(JSON.stringify(i));if(await j.processFields(f,{...r.options,root:{...r.root,item:n[p],this:f,index:p}}),e.extend?.result)f=A.mergeAll([f,...Array.isArray(e.extend?.result)?e.extend.result:[Array.isArray(e.extend?.result)]]);m.push(await a(f))}return m}}});var I=require("@homedev/select"),q=(o)=>({concat:async(r)=>{let e=[];for(let s of Array.isArray(r.value)?r.value:[r.value])e.push(...await I.select(r.root,s));return e.filter((s)=>s!==void 0)}});var B=require("@homedev/fields"),J=require("@homedev/merge"),R=require("@homedev/select"),U=(o)=>({extends:async(r)=>{let e=async(s,t)=>{for(let a of Array.isArray(t)?t:[t]){let n=await R.select(r.root,a),i=JSON.parse(JSON.stringify(n));if(i[r.key])await e(i,i[r.key]);await B.processFields(i,{...r.options}),J.merge(i,s),delete s[r.key]}};await e(r.parent,r.value)}});var b=require("@homedev/navigate"),N=(o)=>({skip:()=>b.NavigateResult.DeleteParent(),metadata:({path:r,value:e})=>{return o.metadata(r,e),b.NavigateResult.DeleteItem()},if:(r)=>{let e=r.parent[".then"],s=r.parent[".else"];if(e)delete r.parent[".then"];if(s)delete r.parent[".else"];if(r.value===null||r.value===void 0||["0",0,"false",""].includes(r.value)||Array.isArray(r.value)&&r.value.length===0)return s??null;else return e??b.NavigateResult.DeleteItem()},switch:(r)=>{let e=r.value;if(!e.cases)throw new Error("Missing cases for switch");return e.cases[e.from]??e.default??null}});var z=require("@homedev/merge"),G=require("@homedev/select"),T=(o)=>({from:async({root:r,parent:e,value:s})=>{let t=await G.select(r,s);if(e.content){if(Array.isArray(e.content)&&Array.isArray(t))return[...t,...e.content];return z.merge(t,e.content),e.content}return t}});var y=require("@homedev/files"),M=w(require("fs/promises")),u=w(require("path")),V=(o)=>({include:async(r)=>{let{file:e}=r.options.globalContext;return await y.globMap(r.args[0],{cwd:u.default.dirname(e),filter:(s)=>u.default.basename(e)!==s,map:async(s)=>o.load(s,u.default.dirname(e),{parent:r.root})})},file:async(r)=>await M.default.readFile(await y.locate(r.args[0],o.getIncludeDirectories())).then((e)=>e.toString()),scan:async(r)=>{let e=[],t=(()=>{let i=r.args[2]??["**/node_modules/**"],m=typeof i==="string"?i.split(",").map((p)=>p.trim()):i;if(!Array.isArray(m))throw new Error("Scan exclusion must be a list");return m})(),{file:a}=r.options.globalContext,n=r.args[1]?await y.locate(r.args[1],o.getIncludeDirectories()):u.default.dirname(a);for await(let i of M.default.glob(r.args[0],{cwd:n,exclude:(m)=>t.some((p)=>u.default.matchesGlob(m,p))}))e.push(i);return e}});var $=(o)=>({env:(r)=>process.env[r.args[0]]});var l=require("@homedev/string-utils"),H=(o)=>({len:(r)=>r.args[0].length,reverse:(r)=>r.args[0].split("").reverse().join(""),substring:(r)=>r.args[0].substring(+r.args[1],+r.args[2]),concat:(r)=>r.args.join(""),lower:(r)=>r.args[0].toLowerCase(),upper:(r)=>r.args[0].toUpperCase(),pascal:(r)=>l.pascal(r.args[0]),camel:(r)=>l.camel(r.args[0]),capital:(r)=>l.capital(r.args[0]),snake:(r)=>l.changeCase(l.snake(r.args[0],"_"),r.args[1]),kebab:(r)=>l.changeCase(l.snake(r.args[0],"-"),r.args[1]),encode:(r)=>Buffer.from(r.args[0]).toString(r.args[1]??"base64"),decode:(r)=>Buffer.from(r.args[0],r.args[1]??"base64").toString(),uuid:(r)=>crypto.randomUUID()});var O=require("@homedev/object-utils"),K=require("@homedev/select"),Q=(o)=>({merge:(r)=>r.args.flatMap((e)=>e),join:(r)=>{let[e,s,t]=r.args,a=e;if(!Array.isArray(a))throw new Error("Object is not a list");if(s?.length)a=a.map((n)=>K.select({...r.root,...n},s));return a.join(t?.replace("\\n",`
|
|
2
|
+
`))},list:(r)=>O.toList(r.args[0],r.args[1]),object:(r)=>O.toObject(r.args[0],r.args[1]),range:(r)=>{let[e,s,t]=r.args,a=parseInt(e),n=parseInt(s),i=parseInt(t)||1;if(isNaN(a)||isNaN(n))throw new Error("Invalid range");return Array.from({length:Math.floor((n-a)/i)+1},(m,p)=>a+p*i)}});var W=require("@homedev/fields"),X=require("@homedev/object-utils"),k=require("@homedev/select"),Y=(o)=>({each:{processArgs:!1,fn:async(r)=>{let e=await k.select(r.root,r.rawArgs[0].value),s=await k.select(r.root,r.rawArgs[1].value),t=r.rawArgs[2]?.value,a=Array.isArray(e)?e:X.toList(e),n=[];for(let i=0;i<a.length;i++){let m=JSON.parse(JSON.stringify(s)),p={instance:m};if(await W.processFields(p,{...r.options,root:{...r.root,item:a[i],this:m,parent:r.root.this,index:i,params:r.rawArgs.slice(3).map((f)=>f.value)}}),t!==void 0&&t!=="@")n.push(p.instance[t]);else n.push(p.instance)}return n}}});var Z=require("@homedev/select"),d=async(o,r,e)=>o.rawArgs[r].quoted?o.rawArgs[r].value:await Z.select(o.root,o.rawArgs[r].value,{defaultValue:e}),x=(o)=>({default:{processArgs:!1,fn:async(r)=>{let e=r.rawArgs[1]?.value?await d(r,1):"";return d(r,0,e)}},switch:{processArgs:!1,fn:async(r)=>{let e=await d(r,0,!1),s=await d(r,1);if(s[e]===void 0){if(r.rawArgs.length>2)return d(r,2);throw new Error(`Unhandled switch case: ${e}`)}return s[e]}}});var rr=(o)=>({log:(r)=>{console.log(...r.args)}});var or=(o)=>({if:{keywords:{0:["eq","ne","lt","le","gt","ge","in","notin","null","notnull","empty","notempty","nullorempty","notnullorempty"]},fn:(r)=>{let[e,...s]=r.args;switch(e){case"eq":return s.every((t,a,n)=>t===n[0]);case"ne":return s.every((t,a,n)=>t!==n[0]);case"lt":return s[0]<s[1];case"le":return s[0]<=s[1];case"gt":return s[0]>s[1];case"ge":return s[0]>=s[1];case"in":return s[0].includes(s[1]);case"notin":return!s[0].includes(s[1]);case"null":return s.every((t,a,n)=>t===null||t===void 0);case"notnull":return s.every((t,a,n)=>t!==null&&t!==void 0);case"empty":return s.every((t,a,n)=>t==="");case"notempty":return s.every((t,a,n)=>t!=="");case"nullorempty":return s.every((t,a,n)=>t===null||t===void 0||t==="");case"notnullorempty":return s.every((t,a,n)=>t!==null&&t!==void 0&&t!=="")}}}});var er=(o)=>o.keys(C(o)).keys(L(o)).keys(D(o)).keys(T(o)).keys(q(o)).keys(U(o)).keys(N(o)).sources(V(o)).sources($(o)).sources(H(o)).sources(Q(o)).sources(Y(o)).sources(x(o)).sources(rr(o)).sources(or(o));class ar{includeDirectories=[];includes=[];outputs=[];vars={};cache={};fields={};objectMetadata={};constructor(){this.use(er)}use(o){return o(this),this}includeDirectory(...o){return this.includeDirectories.push(...o),this}getIncludeDirectories(){return this.includeDirectories}include(...o){return this.includes.push(...o),this}keys(o){return this.fields.keys={...this.fields.keys,...o},this}sources(o){return this.fields.sources={...this.fields.sources,...o},this}variables(o){return this.vars={...this.vars,...o},this}getOutputs(){return this.outputs}output(o){return this.outputs.push(o),this}metadata(o,r){return this.objectMetadata[o]=r,this}getMetadata(o){return this.objectMetadata[o]}getAllMetadata(){return this.objectMetadata}filter(o){return this.fields.filters??=[],this.fields.filters?.push(o),this}async docIncludes(o,r){let e=[];if(o.content.includes)e.push(...o.content.includes),delete o.content.includes;e.push(...this.includes),this.includes.length=0;for(let s of e)tr.merge(await this.load(s,o.folderPath,{parent:o.content,...r},!0),o.content)}async load(o,r,e,s){if(this.cache[o])return this.cache[o];let t=r?[r]:[];t.push(...this.includeDirectories.map((n)=>P.default.isAbsolute(n)?n:P.default.join(r??process.cwd(),n)));let a=await F.loadFormat(o,{dirs:t});if(!a.content)return null;if(await this.docIncludes(a,e),s!==!0)await sr.processFields(a.content,{...this.fields,globalContext:{file:a.fullPath},root:{...this.fields.root,...this.vars,$document:{root:a,fileName:o,folder:a.folderPath,fullPath:a.fullPath,...e}}});return a.content}async writeOutputs(o){await F.writeOutputs(this.getOutputs(),o)}}
|
package/package.json
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homedev/objector",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "object extensions for YAML/JSON",
|
|
5
5
|
"author": "julzor",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"type": "module",
|
|
9
|
-
"typings": "dist/
|
|
9
|
+
"typings": "dist/index.d.ts",
|
|
10
10
|
"peerDependencies": {
|
|
11
|
-
"
|
|
11
|
+
"@homedev/fields": "^1.0.7",
|
|
12
|
+
"@homedev/files": "^1.0.1",
|
|
13
|
+
"@homedev/merge": "^1.0.1",
|
|
14
|
+
"@homedev/navigate": "^1.0.1",
|
|
15
|
+
"@homedev/object-utils": "^1.0.1",
|
|
16
|
+
"@homedev/select": "^1.0.2",
|
|
17
|
+
"@homedev/string-utils": "^1.0.5",
|
|
18
|
+
"yaml": "^2.8.0"
|
|
12
19
|
}
|
|
13
20
|
}
|
package/dist/objector.d.ts
DELETED
|
@@ -1,222 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @public
|
|
3
|
-
*/
|
|
4
|
-
export declare interface DataFile<T = any> {
|
|
5
|
-
content: T;
|
|
6
|
-
fullPath: string;
|
|
7
|
-
folderPath: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export declare interface FieldContext {
|
|
11
|
-
value: any;
|
|
12
|
-
key: string;
|
|
13
|
-
args: any[];
|
|
14
|
-
rawArgs: {
|
|
15
|
-
value: string;
|
|
16
|
-
quoted: boolean;
|
|
17
|
-
}[];
|
|
18
|
-
groups: Record<string, string>;
|
|
19
|
-
path: string;
|
|
20
|
-
root: any;
|
|
21
|
-
parent?: any;
|
|
22
|
-
file?: string;
|
|
23
|
-
options?: ProcessFieldsOptions;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export declare type FieldProcessorFunc = (context: FieldContext) => MaybePromise<any>;
|
|
27
|
-
|
|
28
|
-
export declare type FieldProcessorMap = Record<string, FieldProcessorFunc | FieldProcessorOptions>;
|
|
29
|
-
|
|
30
|
-
export declare interface FieldProcessorOptions {
|
|
31
|
-
fn: FieldProcessorFunc;
|
|
32
|
-
filters?: RegExp[];
|
|
33
|
-
processArgs?: boolean;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @public
|
|
38
|
-
* @param from
|
|
39
|
-
* @param cb
|
|
40
|
-
* @returns
|
|
41
|
-
*/
|
|
42
|
-
export declare const find: (from: any, cb: (path: string, value: string) => any) => Promise<any[]>;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* @public
|
|
46
|
-
*/
|
|
47
|
-
export declare interface IncludeOptions {
|
|
48
|
-
root?: string;
|
|
49
|
-
loaded?: (data: any) => Promise<void> | void;
|
|
50
|
-
loadOptions?: LoadOptions;
|
|
51
|
-
load?: (from: string) => Promise<any>;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* @public
|
|
56
|
-
* @param fileName
|
|
57
|
-
* @param options
|
|
58
|
-
* @returns
|
|
59
|
-
*/
|
|
60
|
-
export declare const load: <T = any>(fileName: string, options?: LoadOptions) => Promise<DataFile<T>>;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* @public
|
|
64
|
-
*/
|
|
65
|
-
export declare interface LoadOptions {
|
|
66
|
-
dirs?: string[];
|
|
67
|
-
parsers?: Record<string, (data: string) => any>;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export declare const locate: (fileName: string, optDirs?: string[]) => Promise<string>;
|
|
71
|
-
|
|
72
|
-
declare type MaybePromise<T> = T | Promise<T>;
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* @public
|
|
76
|
-
* @param source
|
|
77
|
-
* @param target
|
|
78
|
-
* @param options
|
|
79
|
-
*/
|
|
80
|
-
export declare const merge: (source: any, target: any, options?: MergeOptions) => void;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* @public
|
|
84
|
-
*/
|
|
85
|
-
export declare type MergeMode = 'merge' | 'source' | 'target' | 'skip';
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* @public
|
|
89
|
-
*/
|
|
90
|
-
export declare interface MergeOptions {
|
|
91
|
-
conflict?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => any;
|
|
92
|
-
mismatch?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => any;
|
|
93
|
-
navigate?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => boolean | undefined;
|
|
94
|
-
mode?: (key: string, source: any, target: any, sourceContainer: any, targetContainer: any) => MergeMode | void;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @public
|
|
99
|
-
* @param o
|
|
100
|
-
* @param cb
|
|
101
|
-
*/
|
|
102
|
-
export declare const navigate: (o: any, cb: NavigateCallback) => Promise<void>;
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* @public
|
|
106
|
-
*/
|
|
107
|
-
export declare enum NavigateAction {
|
|
108
|
-
Explore = 0,
|
|
109
|
-
SkipSiblings = 1,
|
|
110
|
-
NoExplore = 2,
|
|
111
|
-
ReplaceItem = 3,
|
|
112
|
-
ReplaceParent = 4,
|
|
113
|
-
DeleteParent = 5
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* @public
|
|
118
|
-
*/
|
|
119
|
-
export declare type NavigateCallback = (context: NavigateContext) => Promise<NavigateResult> | NavigateResult;
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @public
|
|
123
|
-
*/
|
|
124
|
-
export declare interface NavigateContext {
|
|
125
|
-
key: string;
|
|
126
|
-
value: any;
|
|
127
|
-
path: string[];
|
|
128
|
-
parent: any;
|
|
129
|
-
parents: any[];
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* @public
|
|
134
|
-
*/
|
|
135
|
-
export declare class NavigateResult {
|
|
136
|
-
readonly action: NavigateAction;
|
|
137
|
-
by?: any | undefined;
|
|
138
|
-
constructor(action: NavigateAction, by?: any | undefined);
|
|
139
|
-
static ReplaceParent(by: any): NavigateResult;
|
|
140
|
-
static ReplaceItem(by: any): NavigateResult;
|
|
141
|
-
static SkipSiblings(): NavigateResult;
|
|
142
|
-
static Explore(): NavigateResult;
|
|
143
|
-
static NoExplore(): NavigateResult;
|
|
144
|
-
static DeleteParent(): NavigateResult;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* @public
|
|
149
|
-
*/
|
|
150
|
-
export declare class Objector {
|
|
151
|
-
private cache;
|
|
152
|
-
includeDirectory(...dirs: string[]): this;
|
|
153
|
-
include(...files: string[]): this;
|
|
154
|
-
keys(keys: FieldProcessorMap): this;
|
|
155
|
-
sources(sources: FieldProcessorMap): this;
|
|
156
|
-
variables(vars: Record<string, any>): this;
|
|
157
|
-
output(o: ObjectorOutput): this;
|
|
158
|
-
defaultProcessors(): this;
|
|
159
|
-
alias(name: string, o: any): this;
|
|
160
|
-
getAlias(name: string): any;
|
|
161
|
-
getOutputs(): ObjectorOutput[];
|
|
162
|
-
getIncludeDirectories(): string[];
|
|
163
|
-
use(handler: (o: Objector) => void): this;
|
|
164
|
-
filter(f: RegExp): this;
|
|
165
|
-
load<T = any>(fileName: string, alias?: string, cwd?: string, container?: any, noProcess?: boolean): Promise<T | null>;
|
|
166
|
-
merge(source: any, target: any): void;
|
|
167
|
-
mergeAll(elements: any[]): any;
|
|
168
|
-
writeOutputs(options?: WriteOutputsOption): Promise<void>;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
declare interface ObjectorOutput {
|
|
172
|
-
name: string;
|
|
173
|
-
type?: string;
|
|
174
|
-
value: any;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @public
|
|
179
|
-
* @param root
|
|
180
|
-
* @param options
|
|
181
|
-
* @returns
|
|
182
|
-
*/
|
|
183
|
-
export declare const processFields: (root: any, options: ProcessFieldsOptions) => Promise<void>;
|
|
184
|
-
|
|
185
|
-
export declare interface ProcessFieldsOptions {
|
|
186
|
-
sourcesMatcher?: RegExp;
|
|
187
|
-
sources?: FieldProcessorMap;
|
|
188
|
-
keysMatcher?: RegExp;
|
|
189
|
-
keys?: FieldProcessorMap;
|
|
190
|
-
filters?: RegExp[];
|
|
191
|
-
file?: string;
|
|
192
|
-
root?: any;
|
|
193
|
-
load?: (from: string) => Promise<any>;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* @public
|
|
198
|
-
* @param includes
|
|
199
|
-
* @param options
|
|
200
|
-
*/
|
|
201
|
-
export declare const processIncludes: (includes: string[], options?: IncludeOptions) => Promise<void>;
|
|
202
|
-
|
|
203
|
-
export declare const select: (at: string, options: {
|
|
204
|
-
root?: any;
|
|
205
|
-
load?: (from: string) => Promise<any>;
|
|
206
|
-
async?: boolean;
|
|
207
|
-
defaultValue?: any;
|
|
208
|
-
}) => any;
|
|
209
|
-
|
|
210
|
-
export declare const toList: <T>(from: any, key?: string) => T[];
|
|
211
|
-
|
|
212
|
-
export declare const toObject: <T>(from: any[], key?: string) => T;
|
|
213
|
-
|
|
214
|
-
export declare const toObjectWithKey: <T>(from: any[], key?: string) => T;
|
|
215
|
-
|
|
216
|
-
declare interface WriteOutputsOption {
|
|
217
|
-
targetDirectory?: string;
|
|
218
|
-
removeFirst?: boolean;
|
|
219
|
-
writing?: (output: ObjectorOutput) => boolean | undefined | void;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export { }
|