UNPKG

jitar

Version:

Distributed runtime for JavaScript and TypeScript to chop monolithic applications into micros.

2 lines (1 loc) 2.6 kB
import{V as e,H as t,n as a,v as s,L as i,w as r,x as n,o,p}from"./ConfigurationManager-B7adTVpS.js";export{A as ArrayParameter,B as BadRequest,C as ConfigurationManager,F as Forbidden,j as NamedParameter,N as NotFound,k as NotImplemented,O as ObjectParameter,l as PaymentRequired,G as Request,R as Response,m as Segment,S as ServerError,T as Teapot,U as Unauthorized}from"./ConfigurationManager-B7adTVpS.js";import"node:fs";import"node:path";import"glob";import"mime-types";import"dotenv";class c{#e;#t;constructor(e,t){this.#e=e,this.#t=t}get fqn(){return this.#e}get implementation(){return this.#t}}class u{#e;#a=new Map;#s;constructor(e){this.#e=e}get fqn(){return this.#e}get public(){return[...this.#a.values()].some(e=>e.public)}get protected(){return[...this.#a.values()].some(e=>e.protected)}addImplementation(e){return this.#a.set(e.version,e),this.#i(e)&&(this.#s=e),this}#i(e){return void 0===this.#s||e.version.greater(this.#s.version)}getImplementation(e){const t=this.#r(e);return this.#a.get(t)}#r(t){let a=e.DEFAULT;for(const e of this.#a.keys()){if(e.equals(t))return e;e.greater(t)||a.less(e)&&(a=e)}return a}}class h{#n;#o;#l;#p;constructor(e,t,a,s){this.#n=e,this.#o=t,this.#l=a,this.#p=s}get version(){return this.#n}get public(){return this.#o===t.PUBLIC}get protected(){return this.#o===t.PROTECTED}get private(){return this.#o===t.PRIVATE}get parameters(){return this.#l}get executable(){return this.#p}}class g extends Error{constructor(){super("Application not read")}}class f extends Error{constructor(e){super(`Application module not found '${e}'`)}}class d{#m=new a;#c;#u;#h;constructor(e){const t=this.#m.makePathAbsolute(e.source,e.meta.root),a=this.#m.makePathAbsolute(e.target,e.meta.root),n=this.#m.makePathAbsolute(e.resources,e.meta.root),o=this.#m.makePathAbsolute(e.segments,e.meta.root);this.#c=new s(new i(t),new i(a),new i(n),new i(o),e.build.ignore),this.#u=new r(this.#c)}async readApplication(){const e=this.#c.source,t=this.#c.resource,a=this.#c.segment,s=await e.filterWithIgnores(n.MODULE_PATTERN,this.#c.sourceIgnores),i=await t.filter(n.RESOURCE_PATTERN),r=await a.filter(n.SEGMENT_PATTERN);this.#h=await this.#u.read(s,i,r)}generateModuleCode(e,t=[]){if(void 0===this.#h)throw new g;const a=this.#h.repository.get(e);if(void 0===a)throw new f(e);const s=this.#h.resources,i=this.#h.segmentation,r=i.getSegments(e);if(0===r.length){return new o(a,s,i).generate()}if(void 0===r.find(e=>t.includes(e.name))){return new p(a,r).generate()}return new o(a,s,i).generate()}}export{d as BuildHelper,c as Class,h as Implementation,u as Procedure,e as Version};