UNPKG

@sap/generator-fiori

Version:

Create an SAPUI5 application using SAP Fiori elements or a freestyle approach

21 lines (17 loc) 48 kB
const __esmImportMetaUrl = require('node:url').pathToFileURL(__filename).href; var pr=Object.create;var fe=Object.defineProperty;var mr=Object.getOwnPropertyDescriptor;var gr=Object.getOwnPropertyNames;var vr=Object.getPrototypeOf,wr=Object.prototype.hasOwnProperty;var a=(r,e)=>fe(r,"name",{value:e,configurable:!0});var gt=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},br=(r,e)=>{for(var t in e)fe(r,t,{get:e[t],enumerable:!0})},vt=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of gr(e))!wr.call(r,s)&&s!==t&&fe(r,s,{get:()=>e[s],enumerable:!(n=mr(e,s))||n.enumerable});return r};var Y=(r,e,t)=>(t=r!=null?pr(vr(r)):{},vt(e||!r||!r.__esModule?fe(t,"default",{value:r,enumerable:!0}):t,r)),Sr=r=>vt(fe({},"__esModule",{value:!0}),r);var St=gt((ze,He)=>{(function(r,e){typeof require=="function"&&typeof ze=="object"&&typeof He=="object"?He.exports=e():typeof define=="function"&&define.amd?define(function(){return e()}):r.pluralize=e()})(ze,function(){var r=[],e=[],t={},n={},s={};function l(p){return typeof p=="string"?new RegExp("^"+p+"$","i"):p}a(l,"sanitizeRule");function m(p,w){return p===w?w:p===p.toLowerCase()?w.toLowerCase():p===p.toUpperCase()?w.toUpperCase():p[0]===p[0].toUpperCase()?w.charAt(0).toUpperCase()+w.substr(1).toLowerCase():w.toLowerCase()}a(m,"restoreCase");function _(p,w){return p.replace(/\$(\d{1,2})/g,function(M,k){return w[k]||""})}a(_,"interpolate");function P(p,w){return p.replace(w[0],function(M,k){var N=_(w[1],arguments);return m(M===""?p[k-1]:M,N)})}a(P,"replace");function K(p,w,M){if(!p.length||t.hasOwnProperty(p))return w;for(var k=M.length;k--;){var N=M[k];if(N[0].test(w))return P(w,N)}return w}a(K,"sanitizeWord");function D(p,w,M){return function(k){var N=k.toLowerCase();return w.hasOwnProperty(N)?m(k,N):p.hasOwnProperty(N)?m(k,p[N]):K(N,k,M)}}a(D,"replaceWord");function B(p,w,M,k){return function(N){var Z=N.toLowerCase();return w.hasOwnProperty(Z)?!0:p.hasOwnProperty(Z)?!1:K(Z,Z,M)===Z}}a(B,"checkWord");function $(p,w,M){var k=w===1?$.singular(p):$.plural(p);return(M?w+" ":"")+k}return a($,"pluralize"),$.plural=D(s,n,r),$.isPlural=B(s,n,r),$.singular=D(n,s,e),$.isSingular=B(n,s,e),$.addPluralRule=function(p,w){r.push([l(p),w])},$.addSingularRule=function(p,w){e.push([l(p),w])},$.addUncountableRule=function(p){if(typeof p=="string"){t[p.toLowerCase()]=!0;return}$.addPluralRule(p,"$0"),$.addSingularRule(p,"$0")},$.addIrregularRule=function(p,w){w=w.toLowerCase(),p=p.toLowerCase(),s[p]=w,n[w]=p},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(p){return $.addIrregularRule(p[0],p[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(p){return $.addPluralRule(p[0],p[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(p){return $.addSingularRule(p[0],p[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach($.addUncountableRule),$})});var It=gt(()=>{var kt;(function(r){(function(e){var t=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:_(),n=s(r);typeof t.Reflect<"u"&&(n=s(t.Reflect,n)),e(n,t),typeof t.Reflect>"u"&&(t.Reflect=r);function s(P,K){return function(D,B){Object.defineProperty(P,D,{configurable:!0,writable:!0,value:B}),K&&K(D,B)}}a(s,"makeExporter");function l(){try{return Function("return this;")()}catch{}}a(l,"functionThis");function m(){try{return(0,eval)("(function() { return this; })()")}catch{}}a(m,"indirectEvalThis");function _(){return l()||m()}a(_,"sloppyModeThis")})(function(e,t){var n=Object.prototype.hasOwnProperty,s=typeof Symbol=="function",l=s&&typeof Symbol.toPrimitive<"u"?Symbol.toPrimitive:"@@toPrimitive",m=s&&typeof Symbol.iterator<"u"?Symbol.iterator:"@@iterator",_=typeof Object.create=="function",P={__proto__:[]}instanceof Array,K=!_&&!P,D={create:_?function(){return Re(Object.create(null))}:P?function(){return Re({__proto__:null})}:function(){return Re({})},has:K?function(i,o){return n.call(i,o)}:function(i,o){return o in i},get:K?function(i,o){return n.call(i,o)?i[o]:void 0}:function(i,o){return i[o]}},B=Object.getPrototypeOf(Function),$=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:lr(),p=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:fr(),w=typeof WeakMap=="function"?WeakMap:dr(),M=s?Symbol.for("@reflect-metadata:registry"):void 0,k=sr(),N=ur(k);function Z(i,o,u,c){if(v(u)){if(!ct(i))throw new TypeError;if(!lt(o))throw new TypeError;return Qt(i,o)}else{if(!ct(i))throw new TypeError;if(!O(o))throw new TypeError;if(!O(c)&&!v(c)&&!te(c))throw new TypeError;return te(c)&&(c=void 0),u=G(u),er(i,o,u,c)}}a(Z,"decorate"),e("decorate",Z);function Bt(i,o){function u(c,g){if(!O(c))throw new TypeError;if(!v(g)&&!ar(g))throw new TypeError;nt(i,o,c,g)}return a(u,"decorator"),u}a(Bt,"metadata"),e("metadata",Bt);function Gt(i,o,u,c){if(!O(u))throw new TypeError;return v(c)||(c=G(c)),nt(i,o,u,c)}a(Gt,"defineMetadata"),e("defineMetadata",Gt);function Vt(i,o,u){if(!O(o))throw new TypeError;return v(u)||(u=G(u)),tt(i,o,u)}a(Vt,"hasMetadata"),e("hasMetadata",Vt);function qt(i,o,u){if(!O(o))throw new TypeError;return v(u)||(u=G(u)),Ie(i,o,u)}a(qt,"hasOwnMetadata"),e("hasOwnMetadata",qt);function Jt(i,o,u){if(!O(o))throw new TypeError;return v(u)||(u=G(u)),rt(i,o,u)}a(Jt,"getMetadata"),e("getMetadata",Jt);function Wt(i,o,u){if(!O(o))throw new TypeError;return v(u)||(u=G(u)),it(i,o,u)}a(Wt,"getOwnMetadata"),e("getOwnMetadata",Wt);function Zt(i,o){if(!O(i))throw new TypeError;return v(o)||(o=G(o)),at(i,o)}a(Zt,"getMetadataKeys"),e("getMetadataKeys",Zt);function Yt(i,o){if(!O(i))throw new TypeError;return v(o)||(o=G(o)),ot(i,o)}a(Yt,"getOwnMetadataKeys"),e("getOwnMetadataKeys",Yt);function Xt(i,o,u){if(!O(o))throw new TypeError;if(v(u)||(u=G(u)),!O(o))throw new TypeError;v(u)||(u=G(u));var c=le(o,u,!1);return v(c)?!1:c.OrdinaryDeleteMetadata(i,o,u)}a(Xt,"deleteMetadata"),e("deleteMetadata",Xt);function Qt(i,o){for(var u=i.length-1;u>=0;--u){var c=i[u],g=c(o);if(!v(g)&&!te(g)){if(!lt(g))throw new TypeError;o=g}}return o}a(Qt,"DecorateConstructor");function er(i,o,u,c){for(var g=i.length-1;g>=0;--g){var E=i[g],I=E(o,u,c);if(!v(I)&&!te(I)){if(!O(I))throw new TypeError;c=I}}return c}a(er,"DecorateProperty");function tt(i,o,u){var c=Ie(i,o,u);if(c)return!0;var g=De(o);return te(g)?!1:tt(i,g,u)}a(tt,"OrdinaryHasMetadata");function Ie(i,o,u){var c=le(o,u,!1);return v(c)?!1:ut(c.OrdinaryHasOwnMetadata(i,o,u))}a(Ie,"OrdinaryHasOwnMetadata");function rt(i,o,u){var c=Ie(i,o,u);if(c)return it(i,o,u);var g=De(o);if(!te(g))return rt(i,g,u)}a(rt,"OrdinaryGetMetadata");function it(i,o,u){var c=le(o,u,!1);if(!v(c))return c.OrdinaryGetOwnMetadata(i,o,u)}a(it,"OrdinaryGetOwnMetadata");function nt(i,o,u,c){var g=le(u,c,!0);g.OrdinaryDefineOwnMetadata(i,o,u,c)}a(nt,"OrdinaryDefineOwnMetadata");function at(i,o){var u=ot(i,o),c=De(i);if(c===null)return u;var g=at(c,o);if(g.length<=0)return u;if(u.length<=0)return g;for(var E=new p,I=[],b=0,f=u;b<f.length;b++){var d=f[b],y=E.has(d);y||(E.add(d),I.push(d))}for(var h=0,S=g;h<S.length;h++){var d=S[h],y=E.has(d);y||(E.add(d),I.push(d))}return I}a(at,"OrdinaryMetadataKeys");function ot(i,o){var u=le(i,o,!1);return u?u.OrdinaryOwnMetadataKeys(i,o):[]}a(ot,"OrdinaryOwnMetadataKeys");function st(i){if(i===null)return 1;switch(typeof i){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return i===null?1:6;default:return 6}}a(st,"Type");function v(i){return i===void 0}a(v,"IsUndefined");function te(i){return i===null}a(te,"IsNull");function tr(i){return typeof i=="symbol"}a(tr,"IsSymbol");function O(i){return typeof i=="object"?i!==null:typeof i=="function"}a(O,"IsObject");function rr(i,o){switch(st(i)){case 0:return i;case 1:return i;case 2:return i;case 3:return i;case 4:return i;case 5:return i}var u=o===3?"string":o===5?"number":"default",c=ft(i,l);if(c!==void 0){var g=c.call(i,u);if(O(g))throw new TypeError;return g}return ir(i,u==="default"?"number":u)}a(rr,"ToPrimitive");function ir(i,o){if(o==="string"){var u=i.toString;if(re(u)){var c=u.call(i);if(!O(c))return c}var g=i.valueOf;if(re(g)){var c=g.call(i);if(!O(c))return c}}else{var g=i.valueOf;if(re(g)){var c=g.call(i);if(!O(c))return c}var E=i.toString;if(re(E)){var c=E.call(i);if(!O(c))return c}}throw new TypeError}a(ir,"OrdinaryToPrimitive");function ut(i){return!!i}a(ut,"ToBoolean");function nr(i){return""+i}a(nr,"ToString");function G(i){var o=rr(i,3);return tr(o)?o:nr(o)}a(G,"ToPropertyKey");function ct(i){return Array.isArray?Array.isArray(i):i instanceof Object?i instanceof Array:Object.prototype.toString.call(i)==="[object Array]"}a(ct,"IsArray");function re(i){return typeof i=="function"}a(re,"IsCallable");function lt(i){return typeof i=="function"}a(lt,"IsConstructor");function ar(i){switch(st(i)){case 3:return!0;case 4:return!0;default:return!1}}a(ar,"IsPropertyKey");function Ne(i,o){return i===o||i!==i&&o!==o}a(Ne,"SameValueZero");function ft(i,o){var u=i[o];if(u!=null){if(!re(u))throw new TypeError;return u}}a(ft,"GetMethod");function dt(i){var o=ft(i,m);if(!re(o))throw new TypeError;var u=o.call(i);if(!O(u))throw new TypeError;return u}a(dt,"GetIterator");function yt(i){return i.value}a(yt,"IteratorValue");function ht(i){var o=i.next();return o.done?!1:o}a(ht,"IteratorStep");function pt(i){var o=i.return;o&&o.call(i)}a(pt,"IteratorClose");function De(i){var o=Object.getPrototypeOf(i);if(typeof i!="function"||i===B||o!==B)return o;var u=i.prototype,c=u&&Object.getPrototypeOf(u);if(c==null||c===Object.prototype)return o;var g=c.constructor;return typeof g!="function"||g===i?o:g}a(De,"OrdinaryGetPrototypeOf");function or(){var i;!v(M)&&typeof t.Reflect<"u"&&!(M in t.Reflect)&&typeof t.Reflect.defineMetadata=="function"&&(i=cr(t.Reflect));var o,u,c,g=new w,E={registerProvider:I,getProvider:f,setProvider:y};return E;function I(h){if(!Object.isExtensible(E))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case i===h:break;case v(o):o=h;break;case o===h:break;case v(u):u=h;break;case u===h:break;default:c===void 0&&(c=new p),c.add(h);break}}function b(h,S){if(!v(o)){if(o.isProviderFor(h,S))return o;if(!v(u)){if(u.isProviderFor(h,S))return o;if(!v(c))for(var T=dt(c);;){var A=ht(T);if(!A)return;var L=yt(A);if(L.isProviderFor(h,S))return pt(T),L}}}if(!v(i)&&i.isProviderFor(h,S))return i}function f(h,S){var T=g.get(h),A;return v(T)||(A=T.get(S)),v(A)&&(A=b(h,S),v(A)||(v(T)&&(T=new $,g.set(h,T)),T.set(S,A))),A}function d(h){if(v(h))throw new TypeError;return o===h||u===h||!v(c)&&c.has(h)}function y(h,S,T){if(!d(T))throw new Error("Metadata provider not registered.");var A=f(h,S);if(A!==T){if(!v(A))return!1;var L=g.get(h);v(L)&&(L=new $,g.set(h,L)),L.set(S,T)}return!0}}a(or,"CreateMetadataRegistry");function sr(){var i;return!v(M)&&O(t.Reflect)&&Object.isExtensible(t.Reflect)&&(i=t.Reflect[M]),v(i)&&(i=or()),!v(M)&&O(t.Reflect)&&Object.isExtensible(t.Reflect)&&Object.defineProperty(t.Reflect,M,{enumerable:!1,configurable:!1,writable:!1,value:i}),i}a(sr,"GetOrCreateMetadataRegistry");function ur(i){var o=new w,u={isProviderFor:a(function(d,y){var h=o.get(d);return v(h)?!1:h.has(y)},"isProviderFor"),OrdinaryDefineOwnMetadata:I,OrdinaryHasOwnMetadata:g,OrdinaryGetOwnMetadata:E,OrdinaryOwnMetadataKeys:b,OrdinaryDeleteMetadata:f};return k.registerProvider(u),u;function c(d,y,h){var S=o.get(d),T=!1;if(v(S)){if(!h)return;S=new $,o.set(d,S),T=!0}var A=S.get(y);if(v(A)){if(!h)return;if(A=new $,S.set(y,A),!i.setProvider(d,y,u))throw S.delete(y),T&&o.delete(d),new Error("Wrong provider for target.")}return A}a(c,"GetOrCreateMetadataMap");function g(d,y,h){var S=c(y,h,!1);return v(S)?!1:ut(S.has(d))}a(g,"OrdinaryHasOwnMetadata");function E(d,y,h){var S=c(y,h,!1);if(!v(S))return S.get(d)}a(E,"OrdinaryGetOwnMetadata");function I(d,y,h,S){var T=c(h,S,!0);T.set(d,y)}a(I,"OrdinaryDefineOwnMetadata");function b(d,y){var h=[],S=c(d,y,!1);if(v(S))return h;for(var T=S.keys(),A=dt(T),L=0;;){var mt=ht(A);if(!mt)return h.length=L,h;var yr=yt(mt);try{h[L]=yr}catch(hr){try{pt(A)}finally{throw hr}}L++}}a(b,"OrdinaryOwnMetadataKeys");function f(d,y,h){var S=c(y,h,!1);if(v(S)||!S.delete(d))return!1;if(S.size===0){var T=o.get(y);v(T)||(T.delete(h),T.size===0&&o.delete(T))}return!0}a(f,"OrdinaryDeleteMetadata")}a(ur,"CreateMetadataProvider");function cr(i){var o=i.defineMetadata,u=i.hasOwnMetadata,c=i.getOwnMetadata,g=i.getOwnMetadataKeys,E=i.deleteMetadata,I=new w,b={isProviderFor:a(function(f,d){var y=I.get(f);return!v(y)&&y.has(d)?!0:g(f,d).length?(v(y)&&(y=new p,I.set(f,y)),y.add(d),!0):!1},"isProviderFor"),OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:u,OrdinaryGetOwnMetadata:c,OrdinaryOwnMetadataKeys:g,OrdinaryDeleteMetadata:E};return b}a(cr,"CreateFallbackProvider");function le(i,o,u){var c=k.getProvider(i,o);if(!v(c))return c;if(u){if(k.setProvider(i,o,N))return N;throw new Error("Illegal state.")}}a(le,"GetMetadataProvider");function lr(){var i={},o=[],u=(function(){function b(f,d,y){this._index=0,this._keys=f,this._values=d,this._selector=y}return a(b,"MapIterator"),b.prototype["@@iterator"]=function(){return this},b.prototype[m]=function(){return this},b.prototype.next=function(){var f=this._index;if(f>=0&&f<this._keys.length){var d=this._selector(this._keys[f],this._values[f]);return f+1>=this._keys.length?(this._index=-1,this._keys=o,this._values=o):this._index++,{value:d,done:!1}}return{value:void 0,done:!0}},b.prototype.throw=function(f){throw this._index>=0&&(this._index=-1,this._keys=o,this._values=o),f},b.prototype.return=function(f){return this._index>=0&&(this._index=-1,this._keys=o,this._values=o),{value:f,done:!0}},b})(),c=(function(){function b(){this._keys=[],this._values=[],this._cacheKey=i,this._cacheIndex=-2}return a(b,"Map"),Object.defineProperty(b.prototype,"size",{get:a(function(){return this._keys.length},"get"),enumerable:!0,configurable:!0}),b.prototype.has=function(f){return this._find(f,!1)>=0},b.prototype.get=function(f){var d=this._find(f,!1);return d>=0?this._values[d]:void 0},b.prototype.set=function(f,d){var y=this._find(f,!0);return this._values[y]=d,this},b.prototype.delete=function(f){var d=this._find(f,!1);if(d>=0){for(var y=this._keys.length,h=d+1;h<y;h++)this._keys[h-1]=this._keys[h],this._values[h-1]=this._values[h];return this._keys.length--,this._values.length--,Ne(f,this._cacheKey)&&(this._cacheKey=i,this._cacheIndex=-2),!0}return!1},b.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=i,this._cacheIndex=-2},b.prototype.keys=function(){return new u(this._keys,this._values,g)},b.prototype.values=function(){return new u(this._keys,this._values,E)},b.prototype.entries=function(){return new u(this._keys,this._values,I)},b.prototype["@@iterator"]=function(){return this.entries()},b.prototype[m]=function(){return this.entries()},b.prototype._find=function(f,d){if(!Ne(this._cacheKey,f)){this._cacheIndex=-1;for(var y=0;y<this._keys.length;y++)if(Ne(this._keys[y],f)){this._cacheIndex=y;break}}return this._cacheIndex<0&&d&&(this._cacheIndex=this._keys.length,this._keys.push(f),this._values.push(void 0)),this._cacheIndex},b})();return c;function g(b,f){return b}function E(b,f){return f}function I(b,f){return[b,f]}}a(lr,"CreateMapPolyfill");function fr(){var i=(function(){function o(){this._map=new $}return a(o,"Set"),Object.defineProperty(o.prototype,"size",{get:a(function(){return this._map.size},"get"),enumerable:!0,configurable:!0}),o.prototype.has=function(u){return this._map.has(u)},o.prototype.add=function(u){return this._map.set(u,u),this},o.prototype.delete=function(u){return this._map.delete(u)},o.prototype.clear=function(){this._map.clear()},o.prototype.keys=function(){return this._map.keys()},o.prototype.values=function(){return this._map.keys()},o.prototype.entries=function(){return this._map.entries()},o.prototype["@@iterator"]=function(){return this.keys()},o.prototype[m]=function(){return this.keys()},o})();return i}a(fr,"CreateSetPolyfill");function dr(){var i=16,o=D.create(),u=c();return(function(){function f(){this._key=c()}return a(f,"WeakMap"),f.prototype.has=function(d){var y=g(d,!1);return y!==void 0?D.has(y,this._key):!1},f.prototype.get=function(d){var y=g(d,!1);return y!==void 0?D.get(y,this._key):void 0},f.prototype.set=function(d,y){var h=g(d,!0);return h[this._key]=y,this},f.prototype.delete=function(d){var y=g(d,!1);return y!==void 0?delete y[this._key]:!1},f.prototype.clear=function(){this._key=c()},f})();function c(){var f;do f="@@WeakMap@@"+b();while(D.has(o,f));return o[f]=!0,f}function g(f,d){if(!n.call(f,u)){if(!d)return;Object.defineProperty(f,u,{value:D.create()})}return f[u]}function E(f,d){for(var y=0;y<d;++y)f[y]=Math.random()*255|0;return f}function I(f){if(typeof Uint8Array=="function"){var d=new Uint8Array(f);return typeof crypto<"u"?crypto.getRandomValues(d):typeof msCrypto<"u"?msCrypto.getRandomValues(d):E(d,f),d}return E(new Array(f),f)}function b(){var f=I(i);f[6]=f[6]&79|64,f[8]=f[8]&191|128;for(var d="",y=0;y<i;++y){var h=f[y];(y===4||y===6||y===8)&&(d+="-"),h<16&&(d+="0"),d+=h.toString(16).toLowerCase()}return d}}a(dr,"CreateWeakMapPolyfill");function Re(i){return i.__=void 0,delete i.__,i}a(Re,"MakeDictionary")})})(kt||(kt={}))});var Dr={};br(Dr,{ApiHubSettings:()=>ce,ApiHubSettingsKey:()=>V,ApiHubSettingsService:()=>ve,AuthenticationType:()=>$t,BackendSystem:()=>x,BackendSystemKey:()=>J,ConnectionType:()=>we,Entity:()=>ie,FioriToolsSettings:()=>de,SapTools:()=>ye,SystemType:()=>ne,TelemetrySetting:()=>Me,TelemetrySettingKey:()=>ue,default:()=>Nr,getBackendSystemType:()=>be,getFilesystemWatcherFor:()=>qe,getFioriToolsDirectory:()=>ae,getSapToolsDirectory:()=>q,getService:()=>Ir});module.exports=Sr(Dr);var ie;(function(r){r.BackendSystem="system",r.TelemetrySetting="telemetrySetting"})(ie||(ie={}));var Ce=Y(require("../../commonlibs/i18next/index.js"),1);var wt={error:{unsupportedEntity:"Unsupported entity - {{entityName}}",systemDoesNotExist:"System does not exist. URL: [{{system.url}}], client: [{{system.client}}]",parsingStore:"Cannot parse store for {{entityName}}",noPropertiesSpecified:"No properties specified for update",systemMigrationFailed:"Migrating systems from secure store failed",systemAlreadyExistsInHybridStore:"System with ID: [{{systemId}}] already exists in hybrid store. Not migrating",couldNotDeleteRefreshToken:"Could not delete refresh token for [{{- url}}]",backendSystemEntityKeyExists:"The 'BackendSystem' entity was not written because a 'BackendSystem' entity key already exists: {{entityKey}}.",systemsJsonMigrationFailed:"The migration of the systems.json file from .fioritools to .saptools failed: {{- error}}"},info:{foundRefreshToken:"Found refresh token for {{- systemId}}",tryingToUpdateAuthType:"Trying to update authentication type for {{- systemId}}",authTypeDetermined:"Authentication type [{{- authenticationType }}] determined for {{- systemId }}",authTypeNotDetermined:"Authentication type could not be determined for {{- systemId }}",updatingRefreshTokenInNewStore:"Update refresh token in new store for {{- systemId}}",deletingRefreshTokenFromOldStore:"Deleting refresh token in old store for {{- systemId}}",legacyApiHubKeyFound:"Legacy format API Hub Key found in secure store",legacyApiHubKeyDeleted:"Legacy format API Hub Key removed from secure store",legacyApiHubKeyMigrated:"Legacy format API Hub Key migrated to new format",legacyApiHubKeyNotMigrated:"Legacy format API Hub Key not migrated, new format already exits",noLegacyApiHubKeyFound:"No legacy format API Hub Key found in secure store"}};var Fe="ux-store",je=Ce.default.createInstance();async function bt(){je=Ce.default.createInstance({resources:{en:{[Fe]:wt}},lng:"en",fallbackLng:"en",defaultNS:Fe,fallbackNS:"default",ns:[Fe],interpolation:{escapeValue:!1},showSupportNotice:!1}),await je.init()}a(bt,"initI18n");function R(r,e){return je.t(r,typeof e=="string"?{defaultValue:e}:e)}a(R,"text");var Q=Y(require("node:path"),1),z=Y(require("node:fs"),1);var Ue=require("node:os"),Ke=require("node:path"),Tt=Y(St(),1);var Le;(function(r){r.PROXY_URL="HTTP_PROXY",r.H2O_URL="H2O_URL"})(Le||(Le={}));function _t(){return!!process.env[Le.H2O_URL]}a(_t,"isAppStudio");var ne={AbapCloud:"AbapCloud",AbapOnPrem:"OnPrem",Generic:"Generic"},$t={Basic:"basic",ReentranceTicket:"reentranceTicket",OAuth2RefreshToken:"oauth2",OAuth2ClientCredential:"oauth2ClientCredential"},we={AbapCatalog:"abap_catalog",GenericHost:"generic_host",ODataService:"odata_service"};function be(r){let e;return r.authenticationType==="reentranceTicket"?e=ne.AbapCloud:r.serviceKeys?e=ne.AbapCloud:(r.authenticationType==="basic"||r.username)&&(e=ne.AbapOnPrem),e}a(be,"getBackendSystemType");var $r=Tt.default.plural,Be=a((r,...e)=>r&&e?.length>0&&e.reduce((t,n)=>(t[n]=r[n],t),{})||void 0,"pick");function he(r,e){return r==null||typeof r!="object"?!1:e.some(t=>{let n=r[t];return n!=null})}a(he,"hasAnyValue");function Se(r){return r instanceof Error?r:new Error(String(r))}a(Se,"errorInstance");function U(r){return r instanceof Error?r.message:String(r)}a(U,"errorString");var de;(function(r){r.dir=".fioritools"})(de||(de={}));var ye;(function(r){r.dir=".saptools"})(ye||(ye={}));var ae=a(()=>(0,Ke.join)((0,Ue.homedir)(),de.dir),"getFioriToolsDirectory"),q=a(()=>(0,Ke.join)((0,Ue.homedir)(),ye.dir),"getSapToolsDirectory");function X(r){let e=r?.trim().toLowerCase();return e&&$r(e)}a(X,"toPersistenceName");function pe(r){return X(r)+".json"}a(pe,"getEntityFileName");function Ge(r,e){return Object.entries(e).every(([t,n])=>Array.isArray(n)?n.includes(r[t]):n&&typeof n=="object"?Ge(r[t],n):r[t]===n)}a(Ge,"isMatch");var xt=Y(require("node:os"),1);var Ot=a(({baseDirectory:r}={})=>r?Q.default.isAbsolute(r)?r:Q.default.join(xt.default.homedir(),r):ae(),"basedir"),Ve=class{static{a(this,"FilesystemStore")}logger;storeDirectory;constructor(e,t={}){this.logger=e,this.storeDirectory=Ot(t)}async read({entityName:e,id:t}){let n=X(e);if(!n){this.logger.debug("read: Entity Type is falsy - "+e);return}let{entities:s,error:l}=this._readAll(n);if(l){if(l.code==="ENOENT")return;throw l}if(!s){this.logger.debug(`read: After parsing, entities is falsy. Entity: ${n}, parsed value: ${s}`);return}return s[t]}async getAll({entityName:e}){let t=X(e);if(!t)return this.logger.debug("read: Entity Type is falsy - "+e),[];let{entities:n,error:s}=this._readAll(t);if(s){if(s.code==="ENOENT")return[];throw s}return n?Object.values(n):(this.logger.debug(`read: After parsing, entities is falsy. Entity: ${t}, parsed value: ${n}`),[])}async readAll({entityName:e}){let t=X(e);if(!t)return this.logger.debug("read: Entity Type is falsy - "+e),{};let{entities:n,error:s}=this._readAll(t);if(s){if(s.code==="ENOENT")return{};throw s}return n||(this.logger.debug(`read: After parsing, entities is falsy. Entity: ${t}, parsed value: ${n}`),{})}async write({entityName:e,id:t,entity:n}){let s=X(e);if(!s){this.logger.debug("write: Entity is falsy - "+s);return}let{entities:l={},error:m}=this._readAll(s);if(m&&m.code!=="ENOENT")throw m;return l[t]=n,this.writeToFile(s,l),n}async partialUpdate({entityName:e,id:t,entity:n}){if(!n||!Object.keys(n).length){this.logger.debug("partialUpdate: No properties specified for update");return}let s=await this.read({entityName:e,id:t});if(!s){this.logger.debug(`partialUpdate: Entity with id ${t} does not exist in ${e}. Cannot update.`);return}let l=this.mergeProperties(n,s);return this.write({entityName:e,id:t,entity:l})}mergeProperties(e,t){return{...{...t,...e}}}async del({entityName:e,id:t}){let n=X(e);if(!n)return this.logger.debug("delete: Entity is falsy - "+n),!1;let{entities:s={},error:l}=this._readAll(n);if(l&&l.code!=="ENOENT")throw l;return s[t]?(this.logger.debug(`delete: entity found for id - ${t}. Deleting`),delete s[t],this.writeToFile(n,s),!0):(this.logger.debug("delete: entity not found"),!1)}_readAll(e){let t;try{let s=Q.default.join(this.storeDirectory,`${e}.json`);(0,z.existsSync)(s)?t=(0,z.readFileSync)(s).toString().trim():t=""}catch(s){let l=Se(s);return this.logger.debug(l.message),{error:l}}if(!t)return{entities:void 0};let n;try{n=JSON.parse(t)?.[e]}catch(s){return{error:Se(s)}}return{entities:n}}writeToFile(e,t){let n=JSON.stringify({[e]:t},null,2),s=pe(e);try{(0,z.writeFileSync)(Q.default.join(this.storeDirectory,s),n)}catch(l){if(Se(l)?.code==="ENOENT")this.logger.debug(`Base directory [${this.storeDirectory}] does not exist, trying to create it`),(0,z.mkdirSync)(this.storeDirectory,{recursive:!0}),(0,z.writeFileSync)(Q.default.join(this.storeDirectory,s),n);else throw l}}};function qe(r,e,t={}){let n=Q.default.join(Ot(t),pe(r));if((0,z.existsSync)(n))return z.default.watch(n,void 0,()=>{e(r)});console.warn(`File Not Found: ${n}`)}a(qe,"getFilesystemWatcherFor");function _e(r,e){return new Ve(r,e)}a(_e,"getFilesystemStore");var me=class{static{a(this,"DummyStore")}log;constructor(e){this.log=e}async save(e,t,n){return this.log.warn(`Dummy store. Trying to save for service: ${e}, key: ${t}`),!0}async retrieve(e,t){this.log.warn(`Dummy store. Trying to retrieve for service: ${e}, key: ${t}`)}async delete(e,t){return this.log.warn(`Dummy store. Trying to delete for service: ${e}, key: ${t}`),!0}async getAll(e){return this.log.warn(`Dummy store. Trying to get all values for service: [${e}]`),{}}};var $e=class{static{a(this,"KeyStoreManager")}log;keyring;constructor(e,t){this.log=e,this.keyring=t}serialize(e){try{return JSON.stringify(e)}catch{throw new Error("Failed to serialize value while storing credentials")}}deserialize(e){try{return JSON.parse(e)}catch{throw new Error("Failed to deserialize value while retrieving credentials")}}validateInput(e,t){return!e||!t?(this.log.error("Invalid input: Service or Key is missing."),!1):!0}async save(e,t,n){if(!this.validateInput(e,t))return!1;try{let s=this.serialize(n);return await this.keyring.setPassword(e,t,s),this.log.info(`Credential saved successfully. Service: [${e}], Key: [${t}]`),!0}catch(s){return this.log.error(`Failed to save credential. Service: [${e}], Key: [${t}]. Error: ${U(s)}`),!1}}async retrieve(e,t){if(this.validateInput(e,t))try{let n=await this.keyring.getPassword(e,t);if(!n){this.log.warn(`No credential found. Service: [${e}], Key: [${t}]`);return}return this.deserialize(n)}catch(n){n instanceof Error?this.log.error(`Deserialization error for Service: [${e}], Key: [${t}]. Error: ${U(n)}`):this.log.error(`Failed to retrieve credential. Service: [${e}], Key: [${t}]. Error: ${U(n)}`);return}}async delete(e,t){if(!this.validateInput(e,t))return!1;try{let n=await this.keyring.deletePassword(e,t);return n?this.log.info(`Credential deleted. Service: [${e}], Key: [${t}]`):this.log.warn(`No credential to delete. Service: [${e}], Key: [${t}]`),n}catch(n){return this.log.error(`Failed to delete credential. Service: [${e}], Key: [${t}]. Error: ${U(n)}`),!1}}async getAll(e){let t={};try{let n=await this.keyring.findCredentials(e);return!n||n.length===0?(this.log.warn(`No credentials found for Service: [${e}]`),t):(n.forEach(({account:s,password:l})=>{if(s)try{let m=this.deserialize(l);t[s]=m}catch(m){this.log.error(`Failed to parse credential for Account: [${s}]. Error: ${U(m)}`)}}),this.log.info(`All credentials retrieved. Service: [${e}], Count: ${Object.keys(t).length}`),t)}catch(n){return this.log.error(`Failed to retrieve credentials for Service: [${e}]. Error: ${U(n)}`),t}}};var oe=require("node:path"),Pt=require("node:os"),Mt=require("node:module"),Te=Y(require("node:fs"),1);var Et=(0,Mt.createRequire)(__esmImportMetaUrl);function At(r){let e=r?".vscode-insiders":".vscode",t=(0,oe.join)((0,Pt.homedir)(),e,"extensions");return Te.default.existsSync(t)?Te.default.readdirSync(t).filter(s=>s.startsWith("sapse.sap-ux-application-modeler-extension")).map(s=>{let l=(0,oe.join)(t,s),m=(0,oe.join)(l,"node_modules/@zowe/secrets-for-zowe-sdk/package.json");return Te.default.existsSync(m)?(0,oe.dirname)(m):""}).filter(s=>s!==""):[]}a(At,"getZoweSdkPaths");function Tr(r){try{return Et("@zowe/secrets-for-zowe-sdk").keyring}catch(e){r.warn(U(e)),r.debug("Attempting to load Zowe secrets SDK from fallback locations.");try{let t=[...At(!1),...At(!0)];r.debug(`Discovered fallback directories: ${JSON.stringify(t)}`);for(let n of t)try{return r.debug(`Attempting to load Zowe secrets SDK from: ${n}`),typeof __non_webpack_require__=="function"?__non_webpack_require__(n):Et(n)}catch(s){r.warn(`Failed to load Zowe secrets SDK from ${n}: ${U(s)}`)}}catch(t){r.warn(`Error while discovering fallback paths: ${U(t)}`)}r.warn("Unable to load Zowe secrets SDK from any location.");return}}a(Tr,"loadZoweSecretSdk");var xe=a(r=>{if(_t()||process.env.FIORI_TOOLS_DISABLE_SECURE_STORE)return r.debug("Secure store disabled, using DummyStore."),new me(r);let e=Tr(r);return e?(r.debug("Using KeyStoreManager for secure storage."),new $e(r,e)):(r.debug("Falling back to DummyStore as secure storage could not be initialized."),new me(r))},"getSecureStore");var pi=Y(It(),1);var Je=Symbol("serializable");function H(r,e){let t=Reflect.getOwnMetadata(Je,r.constructor)||new Set;Reflect.defineMetadata(Je,t.add(e),r.constructor)}a(H,"serializable");function Nt(r){let e=Reflect.getOwnMetadata(Je,r.constructor);return e&&Array.from(e.values())||[]}a(Nt,"getSerializableProperties");var We=Symbol("sensitive");function ee(r,e){let t=Reflect.getOwnMetadata(We,r.constructor)||new Set;Reflect.defineMetadata(We,t.add(e),r.constructor)}a(ee,"sensitiveData");function Oe(r){let e=Reflect.getOwnMetadata(We,r.constructor);return e&&Array.from(e.values())||[]}a(Oe,"getSensitiveDataProperties");var ge=require("node:util");function Ee(r){return"fiori/v2/"+r}a(Ee,"getFullyQualifiedServiceName");var Ze=class{static{a(this,"HybridStore")}logger;filesystem;secureStore;constructor(e,t={}){this.logger=e,this.filesystem=_e(this.logger,t),this.secureStore=xe(this.logger)}async read({entityName:e,id:t}){let n=await this.filesystem.read({entityName:e,id:t});n?this.logger.debug(`hybrid/read - id: [${t}], filesystem: ${(0,ge.inspect)(n)}`):this.logger.debug(`hybrid/read - id: [${t}], nothing on the filesystem`);let s=await this.secureStore.retrieve(Ee(e),t);if(s?this.logger.debug(`hybrid/read - id: [${t}]. Found sensitive data in secure store`):this.logger.debug(`hybrid/read - id: [${t}], nothing in the secure store`),n||s)return{...n,...s}}async getAll({entityName:e,includeSensitiveData:t=!0}){return Object.values(await this.readAll({entityName:e,includeSensitiveData:t}))}async readAll({entityName:e,includeSensitiveData:t=!0}){let n={},s=await this.filesystem.readAll({entityName:e})||{},l=Object.keys(s).length===0;if(!t&&!l)return s;let m=await this.secureStore.getAll(Ee(e))||{};for(let _ of new Set([...Object.keys(s),...Object.keys(m)])){let P={...s[_],...m[_]};n[_]=P}return n}async write({entityName:e,id:t,entity:n}){let s=Nt(n),l=Oe(n);if(s.length>0&&l.length>0)for(let P=0;P<s.length;P=P+1)l.indexOf(s[P])!==-1&&(this.logger.debug(`hybrid/write - [${String(s[P])}] is also marked as sensitive. Not writing to filesystem`),s.splice(P,1));let m=Be(n,...s);he(n,s)?(this.logger.debug(`hybrid/write - writing serializable properties: ${(0,ge.inspect)(m)}`),await this.filesystem.write({entityName:e,id:t,entity:m})):this.logger.debug(`hybrid/write - no serializable properties found in ${(0,ge.inspect)(m)}`);let _=Be(n,...l);return he(_,l)?(this.logger.debug(`hybrid/write - writing sensitive properties to secure store. ID: [${t}]`),await this.secureStore.save(Ee(e),t,_)):this.logger.debug(`hybrid/write - no sensitive properties found in ${(0,ge.inspect)(n)}`),n}async del({entityName:e,id:t}){let n=await this.filesystem.del({entityName:e,id:t});this.logger.debug(`hybrid/del - delete result for id [${t}] on the filesystem: ${n}`);let s=await this.secureStore.delete(Ee(e),t);return this.logger.debug(`hybrid/del - delete result for id [${t}] in the secure store: ${s}`),n||s}async partialUpdate({entityName:e,id:t,entity:n}){return this.filesystem.partialUpdate({entityName:e,id:t,entity:n})}};function Ae(r,e){return new Ze(r,e)}a(Ae,"getHybridStore");var F=function(r,e,t,n){var s=arguments.length,l=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,e,t,n);else for(var _=r.length-1;_>=0;_--)(m=r[_])&&(l=(s<3?m(l):s>3?m(e,t,l):m(e,t))||l);return s>3&&l&&Object.defineProperty(e,t,l),l},j=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},x=class{static{a(this,"BackendSystem")}name;url;client;userDisplayName;systemType;connectionType;authenticationType;hasSensitiveData;systemInfo;serviceKeys;refreshToken;username;password;constructor({name:e,url:t,client:n,systemType:s,serviceKeys:l,refreshToken:m,username:_,password:P,userDisplayName:K,authenticationType:D,connectionType:B,systemInfo:$}){this.name=e,this.url=t,this.client=n,this.systemType=s,this.serviceKeys=l,this.refreshToken=m,this.username=_,this.password=P,this.userDisplayName=K,this.authenticationType=D,this.connectionType=B;let p=Oe(this);this.hasSensitiveData=he(this,p),this.systemInfo=$}};F([H,j("design:type",String)],x.prototype,"name",void 0);F([H,j("design:type",String)],x.prototype,"url",void 0);F([H,j("design:type",String)],x.prototype,"client",void 0);F([H,j("design:type",String)],x.prototype,"userDisplayName",void 0);F([H,j("design:type",String)],x.prototype,"systemType",void 0);F([H,j("design:type",String)],x.prototype,"connectionType",void 0);F([H,j("design:type",String)],x.prototype,"authenticationType",void 0);F([H,j("design:type",Boolean)],x.prototype,"hasSensitiveData",void 0);F([H,j("design:type",Object)],x.prototype,"systemInfo",void 0);F([ee,j("design:type",Object)],x.prototype,"serviceKeys",void 0);F([ee,j("design:type",String)],x.prototype,"refreshToken",void 0);F([ee,j("design:type",String)],x.prototype,"username",void 0);F([ee,j("design:type",String)],x.prototype,"password",void 0);var J=class r{static{a(this,"BackendSystemKey")}url;client;static from(e){return new r({url:e.url,client:e.client})}constructor({url:e,client:t}){this.url=e.trim().replace(/\/$/,""),this.client=t?.trim()}getId(){return this.url+`${this.client?"/"+this.client:""}`}};var W;(function(r){r.BackendSystem="system",r.SystemMigrationStatus="systemMigrationStatus",r.TelemetrySetting="telemetrySetting",r.ApiHub="apiHub"})(W||(W={}));var Ye=require("node:path"),Pe=require("node:fs");var Dt=class{static{a(this,"SystemDataProvider")}dataAccessor;entityName=W.BackendSystem;logger;constructor(r,e={}){this.logger=r,this.dataAccessor=Ae(this.logger,e)}async read(r){return this.dataAccessor.read({entityName:this.entityName,id:r.getId()})}async write(r){let e;return r instanceof x?e=r:e=new x({...r}),this.dataAccessor.write({entityName:this.entityName,id:J.from(r).getId(),entity:e})}async delete(r){return this.dataAccessor.del({entityName:this.entityName,id:J.from(r).getId()})}async getAll(r){let e=this.isMigrationRequired(),{includeSensitiveData:t=!0,backendSystemFilter:n}=r??{},s=await this.dataAccessor.readAll({entityName:this.entityName,includeSensitiveData:e?!0:t});return await this.migrateBackendSystems(s,t)||(s=await this.dataAccessor.readAll({entityName:this.entityName,includeSensitiveData:t})),this.applyFilters(Object.values(s),n)}isMigrationRequired(){let r=(0,Ye.join)(q(),".systemsMigrated");try{let e=(0,Pe.readFileSync)(r,"utf-8");return!JSON.parse(e)?.backendSystemMigrationV1}catch{return!0}}applyFilters(r,e={}){return e.connectionType||(e.connectionType="abap_catalog"),r.filter(t=>Ge(t,e))}async migrateBackendSystems(r,e){let t=!0;for(let[n,s]of Object.entries(r)){if(s?.hasSensitiveData!==void 0&&s?.systemType!==void 0&&s?.connectionType!==void 0)continue;t=!1;let m=await this.buildMigratedSystem(s,e,n);await this.dataAccessor.partialUpdate({entityName:this.entityName,id:n,entity:{hasSensitiveData:m.hasSensitiveData,systemType:m.systemType,connectionType:m.connectionType}})}if(!t){let n=(0,Ye.join)(q(),".systemsMigrated"),s={backendSystemMigrationV1:new Date().toISOString()};(0,Pe.writeFileSync)(n,JSON.stringify(s,null,2))}return t}async buildMigratedSystem(r,e,t){let n=r;e||(n=await this.dataAccessor.read({entityName:this.entityName,id:t}));let s=n.systemType??be(n)??"OnPrem",l=n?.connectionType??we.AbapCatalog;return new x({...n,systemType:s,connectionType:l})}};var C=require("node:fs"),se=require("node:path");var Xe=class{static{a(this,"SystemService")}dataProvider;logger;constructor(e,t={}){this.logger=e,this.dataProvider=new Dt(this.logger,t)}async partialUpdate(e,t){this.validatePartialUpdateInput(t);let n=await this.readOrThrow(e),s=this.mergeProperties(t,n);return this.write(s,{force:!0})}mergeProperties(e,t){let n={...e};delete n.url,delete n.client;let s={...t,...n};return new x({...s})}async readOrThrow(e){let t=await this.read(e);if(!t)throw new Error(R("error.systemDoesNotExist",{system:e}));return t}validatePartialUpdateInput(e){if(!e||!Object.keys(e).length)throw new Error(R("error.noPropertiesSpecified"))}async read(e){return this.dataProvider.read(e)}async write(e,t){let n=J.from(e),s=await this.read(J.from(e));if(!t?.force&&s)throw new Error(R("error.backendSystemEntityKeyExists",{entityKey:n.getId()}));return this.dataProvider.write(e)}async delete(e){return this.dataProvider.delete(e)}async getAll(e){return this.dataProvider.getAll(e)}};function Rt(r,e={}){if(!e.baseDirectory){try{xr()}catch(t){r.error(R("error.systemsJsonMigrationFailed",{error:t.message}))}e.baseDirectory=q()}return new Xe(r,e)}a(Rt,"getInstance");function xr(){let r=pe(ie.BackendSystem),e=(0,se.join)(ae(),r),t=(0,se.join)(q(),r),n=(0,se.join)(q(),".systemsMigrated");if(!(0,C.existsSync)(e))return;let s=JSON.parse((0,C.readFileSync)(e,"utf-8")).systems;(0,C.existsSync)(n)?Or(t,s):((0,C.mkdirSync)((0,se.dirname)(t),{recursive:!0}),(0,C.writeFileSync)(t,JSON.stringify({systems:s},null,2)),(0,C.writeFileSync)(n,new Date().toISOString()));let l={};for(let[m,_]of Object.entries(s))l[m]={..._,_migrated:!0};(0,C.writeFileSync)(e,JSON.stringify({systems:{...l}},null,2))}a(xr,"ensureSystemsJsonMigrated");function Or(r,e){let t=!1,n={};for(let[s,l]of Object.entries(e))l._migrated||(n[s]={...l},t=!0);if(t){let s=JSON.parse((0,C.readFileSync)(r,"utf-8")).systems;(0,C.writeFileSync)(r,JSON.stringify({systems:{...s,...n}},null,2))}}a(Or,"migrateNewLegacyPathEntries");var Er=function(r,e,t,n){var s=arguments.length,l=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,e,t,n);else for(var _=r.length-1;_>=0;_--)(m=r[_])&&(l=(s<3?m(l):s>3?m(e,t,l):m(e,t))||l);return s>3&&l&&Object.defineProperty(e,t,l),l},Ar=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},Me=class{static{a(this,"TelemetrySetting")}enableTelemetry;constructor({enableTelemetry:e}){this.enableTelemetry=e}};Er([H,Ar("design:type",Boolean)],Me.prototype,"enableTelemetry",void 0);var ue=class{static{a(this,"TelemetrySettingKey")}getId(){return"telemetrySetting"}};var Ft=class{static{a(this,"TelemetryDataProvider")}dataAccessor;entityName=W.TelemetrySetting;logger;constructor(r){this.logger=r,this.dataAccessor=_e(this.logger)}read(r){return this.dataAccessor.read({entityName:this.entityName,id:r.getId()})}write(r){return this.dataAccessor.write({entityName:this.entityName,id:new ue().getId(),entity:r})}delete(r){return this.dataAccessor.del({entityName:this.entityName,id:new ue().getId()})}getAll(){return this.dataAccessor.getAll({entityName:this.entityName})}};var Qe=class{static{a(this,"TelemetrySettingService")}dataProvider;logger;constructor(e){this.logger=e,this.dataProvider=new Ft(this.logger)}async partialUpdate(){throw new Error("NOT IMPLEMENTED")}async read(e){return this.dataProvider.read(e)}async write(e){return this.dataProvider.write(e)}async delete(e){return this.dataProvider.delete(e)}async getAll(){return this.dataProvider.getAll()}};function jt(r){return new Qe(r)}a(jt,"getInstance");var Pr=function(r,e,t,n){var s=arguments.length,l=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")l=Reflect.decorate(r,e,t,n);else for(var _=r.length-1;_>=0;_--)(m=r[_])&&(l=(s<3?m(l):s>3?m(e,t,l):m(e,t))||l);return s>3&&l&&Object.defineProperty(e,t,l),l},Mr=function(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)},ce=class{static{a(this,"ApiHubSettings")}apiKey;constructor({apiKey:e}){this.apiKey=e}};Pr([ee,Mr("design:type",String)],ce.prototype,"apiKey",void 0);var V=class r{static{a(this,"ApiHubSettingsKey")}static SINGLETON="API_HUB_API_KEY";getId(){return r.SINGLETON}};var Ct=class{static{a(this,"ApiHubSettingsProvider")}dataAccessor;entityName=W.ApiHub;logger;constructor(r,e={}){this.logger=r,this.dataAccessor=Ae(this.logger,e)}read(r){return this.dataAccessor.read({entityName:this.entityName,id:r.getId()})}write(r){return this.dataAccessor.write({entityName:this.entityName,id:V.SINGLETON,entity:r})}delete(r){return this.dataAccessor.del({entityName:this.entityName,id:V.SINGLETON})}getAll(){return this.dataAccessor.getAll({entityName:this.entityName})}};var zt="fiori/system/apiHub",Ht="API_HUB_API_KEY";async function Lt({dataProvider:r,secureStore:e,logger:t}){let n=await e.retrieve(zt,Ht);if(n)t.info(R("info.legacyApiHubKeyFound"));else{t.debug(R("info.noLegacyApiHubKeyFound"));return}await r.read(new V)?t.info(R("info.legacyApiHubKeyNotMigrated")):(await r.write(new ce({apiKey:n})),t.info(R("info.legacyApiHubKeyMigrated"))),await e.delete(zt,Ht),t.info(R("info.legacyApiHubKeyDeleted"))}a(Lt,"migrateToLatestVersion");var ve=class{static{a(this,"ApiHubSettingsService")}dataProvider;logger;secureStore;migrationDone=!1;key=new V;constructor(e){this.logger=e,this.dataProvider=new Ct(this.logger)}async migrate(){this.migrationDone||(this.secureStore||(this.secureStore=xe(this.logger)),await Lt({logger:this.logger,secureStore:this.secureStore,dataProvider:this.dataProvider}),this.migrationDone=!0)}async partialUpdate(){throw await this.migrate(),new Error("NOT IMPLEMENTED")}async read(){return await this.migrate(),this.dataProvider.read(this.key)}async write(e){return await this.migrate(),this.dataProvider.write(e)}async delete(e){return await this.migrate(),this.dataProvider.delete(e)}async getAll(){return await this.migrate(),this.dataProvider.getAll()}};function Ut(r){return new ve(r)}a(Ut,"getInstance");var ke=require("../../open-ux-shared/logger/index.js");var Kt=a(()=>new ke.ToolsLogger({transports:[new ke.ConsoleTransport]}),"getDefaultLogger");var kr={system:Rt,telemetrySetting:jt,"api-hub":Ut};async function Ir({logger:r=Kt(),entityName:e,options:t={}}){await bt();let n=kr[e];if(n)return n(r,t);throw new Error(R("error.unsupportedEntity",{entityName:e}))}a(Ir,"getService");var Nr=void 0;0&&(module.exports={ApiHubSettings,ApiHubSettingsKey,ApiHubSettingsService,AuthenticationType,BackendSystem,BackendSystemKey,ConnectionType,Entity,FioriToolsSettings,SapTools,SystemType,TelemetrySetting,TelemetrySettingKey,getBackendSystemType,getFilesystemWatcherFor,getFioriToolsDirectory,getSapToolsDirectory,getService}); /*! Bundled license information: reflect-metadata/Reflect.js: (*! ***************************************************************************** Copyright (C) Microsoft. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** *) */