UNPKG

easy-api.ts

Version:

A powerful library to create your own API with ease.

1 lines 1.28 kB
Object.defineProperty(exports,"__esModule",{value:!0}),exports.CompiledFunction=void 0;let Interpreter_1=require("../core/Interpreter"),Compiler_1=require("../core/Compiler"),Util_1=require("./Util");class CompiledFunction{data;metadata;constructor(e,t){this.data=e,this.metadata=t}getData(){return this.data.functions.get(this.metadata.name.toLowerCase())}getAllowedValues(e=0){return this.getData()?.parameters[e].allowedValues??null}getFunctions(e,t){return(new Compiler_1.Compiler).remap(this.data.function.fields[e],this.data.server.rs,!0).filter(e=>(0,Interpreter_1.isFunctionToken)(e)).filter(e=>"string"==typeof t?e.name===t:t.name===e.name)}getFunction(e,t){return this.getFunctions(e,t).at(0)}async resolveTypedFields(){var t=this.fields,a=[],r=this.getData()?.parameters.at(-1)?.rest??!1,i=this.getData()?.parameters.length??0;for(let e=0;e<i;e++){this.getData().parameters[e];var s,n=t[e],n=await Util_1.Util.resolveCode(this.data,n);if(a.push(n),e===i-1&&r)for(s of t.slice(e+1))a.push(s)}return a}get name(){return this.metadata.name}get fields(){return this.metadata.fields}get inside(){return this.metadata.inside}get image(){return this.metadata.name+(0<this.metadata.fields.length?`[${this.metadata.fields.join(";")}]`:"")}}exports.CompiledFunction=CompiledFunction;