angular-t9n
Version:
A translation tool for Angular i18n
1 lines • 1.32 kB
JavaScript
import {o}from'./chunk-DvU4UsWB.js';import {T}from'./chunk-C1Idjiqb.js';import {g,b0 as DS,A as At,K,B as Ba,b1 as Ga,a as aD,l as ln,b2 as k}from'./main-XWPOM5LO.js';var S=(()=>{class n{constructor(){this._translationService=g(T),this._http=g(DS);}orphan(e){return this._translationService.root.pipe(At(1),K(t=>t._links.orphan.href.replace("{id}",e)),Ba(t=>this._http.get(t)))}orphans(e){let t=o(e);return this._translationService.root.pipe(At(1),K(r=>r._links.orphans.href),Ba(r=>this._http.get(r,{params:t})))}deleteOrphan(e){return this._http.delete(e._links.self.href)}migrateOrphan(e,t){return this._http.request("DELETE",e._links.self.href,{body:t})}autoMigrateOrphans(e){return this._fetchOrphans().pipe(Ba(t=>{let r=t.filter(i=>this._canMigrate(i,e)).map(i=>this.migrateOrphan(i,i._embedded.similar[0]).pipe(Ga(i)));return r.length?aD(r):ln([])}))}_fetchOrphans(e=0){return this.orphans({page:e,entriesPerPage:250}).pipe(Ba(t=>t._links.next?this._fetchOrphans(++e).pipe(K(r=>t._embedded.entries.concat(r))):ln(t._embedded.entries)))}_canMigrate(e,t){let r=e._embedded?.similar;return r&&r[0].distance<=t&&r.filter(i=>i.distance===r[0].distance).length===1}static{this.\u0275fac=function(t){return new(t||n)};}static{this.\u0275prov=k({token:n,factory:n.\u0275fac,providedIn:"root"});}}return n})();export{S};