@sap-ux/generator-odata-downloader 0.3.14 → 0.3.15
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/generators/app/index.js +1 -1
- package/package.json +4 -4
package/generators/app/index.js
CHANGED
|
@@ -730,7 +730,7 @@ specVersion: "2.5"`);return s.setMetadata({name:e}),s.setType("application"),s.a
|
|
|
730
730
|
${i}`);let s=[" getReferentialConstraints: function (navigationProperty) {",`${i}`," return undefined;"," }"].join(`
|
|
731
731
|
`),o=e.lastIndexOf(`
|
|
732
732
|
};`);return o!==-1?`${e.slice(0,o)},
|
|
733
|
-
${s}${e.slice(o)}`:e}var Z8t=require("node:fs/promises"),e4t=require("node:path");var H8t=require("node:crypto"),W8t=Te(F8());var G8t={name:"@sap-ux/generator-odata-downloader",displayName:"Fiori Elements Data Downloader",description:"Yeoman generator that supports download of app data, typically for mock data server use.",version:"0.3.14",repository:{type:"git",url:"https://github.com/SAP/open-ux-tools.git",directory:"packages/generator-odata-downloader"},bugs:{url:"https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aodata-download"},license:"Apache-2.0",main:"generators/app/index.js",keywords:["yeoman-generator"],scripts:{build:"npm-run-all clean bundle:prod",compile:"tsc --build",clean:"rimraf --glob generators prebuilds test/test-output coverage *.tsbuildinfo",watch:"tsc --watch",lint:"eslint","lint:fix":"eslint --fix",test:"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors","test-u":"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",link:"pnpm link --global",unlink:"pnpm unlink --global",bundle:"node esbuild.mjs","bundle:dev":"pnpm clean && node esbuild.mjs --development && pnpm pack","bundle:prod":"node esbuild.mjs --production"},files:["LICENSE","generators","!generators/*.map","!generators/**/*.map","prebuilds","yeoman.png"],devDependencies:{"@jest/globals":"30.3.0"},dependencies:{"@sap-devx/yeoman-ui-types":"1.25.0","@sap-ux/annotation-converter":"0.10.21","@sap-ux/axios-extension":"workspace:*","@sap-ux/btp-utils":"workspace:*","@sap-ux/edmx-parser":"0.10.0","@sap-ux/fiori-generator-shared":"workspace:*","@sap-ux/inquirer-common":"workspace:*","@sap-ux/logger":"workspace:*","@sap-ux/mockserver-config-writer":"workspace:*","@sap-ux/odata-service-inquirer":"workspace:*","@sap-ux/odata-service-writer":"workspace:*","@sap-ux/project-access":"workspace:*","@sap-ux/store":"workspace:*","@sap-ux/telemetry":"workspace:*","@sap-ux/ui5-config":"workspace:*","@sap-ux/vocabularies-types":"0.15.0","@sap/ux-specification":"1.144.0","@types/inquirer":"8.2.6","@types/yeoman-generator":"5.2.14","@vscode-logging/logger":"2.0.9",deepmerge:"4.3.1",i18next:"25.10.10",inquirer:"8.2.7","odata-query":"8.0.5","os-name":"4.0.1","prettify-xml":"1.2.0",rimraf:"6.1.3","yeoman-generator":"5.10.0"},engines:{node:">=22.x"}};var kQn="@sap-ux/odata-download-sub-generator",BQn="0a65e45d-6bf4-421d-b845-61e888c50e9e",ya=class{static _telemetryData;static _sessionId;static async initTelemetrySettings(t){this._sessionId=(0,H8t.randomUUID)(),cr.logger.info(`Telemetry session initialized with ID: ${this._sessionId}`);let r={consumerModule:{name:kQn,version:G8t.version},watchTelemetrySettingStore:!1,internalFeature:!0,resourceId:BQn,...t};try{await bL(r)}catch(n){cr.logger.error(`Error initializing telemetry settings: ${n}`)}}static createTelemetryData(t){if(!this._telemetryData){let r=Nt("telemetry.unknownOs");try{r=(0,W8t.default)()}catch{}this._telemetryData={Platform:jr()?"SBAS":"VSCode",OperatingSystem:r,SessionId:this._sessionId}}return this._telemetryData=Object.assign(this._telemetryData,t),this._telemetryData}static prepareTelemetryEvent(t,r){return{eventName:t,properties:r,measurements:{}}}static async sendTelemetry(t,r){let n=this.createTelemetryData(r),i=this.prepareTelemetryEvent(t,n);await nc.getTelemetryClient().reportEvent(i,Ci.NoSampling)}};var qQn=["eq","ne","gt","ge","lt","le"],w7=["and","or","not"],jQn=["any","all"],VQn=["startswith","endswith","contains","matchespattern"],$Qn=["expand","levels","select","skip","top","count","orderby","filter"],Y8t=/\((.*)\)/,z8t=/(?!indexof)\((\w+)\)/;var im="";function hbe({select:e,search:t,skiptoken:r,format:n,top:i,skip:s,filter:o,transform:a,orderBy:u,key:c,count:l,expand:f,action:p,func:d}={}){let h="",g=[],v={};if(c!=null&&(h+=`(${od(c,g)})`),(o||typeof l=="object")&&(v.$filter=C7(typeof l=="object"?l:o,g)),a&&(v.$apply=X8t(a)),f&&(v.$expand=O7(f)),u&&(v.$orderby=mbe(u)),l&&(typeof l=="boolean"?v.$count=!0:h+="/$count"),typeof i=="number"&&(v.$top=i),typeof s=="number"&&(v.$skip=s),p&&(h+=`/${p}`),d){if(typeof d=="string")h+=`/${d}`;else if(typeof d=="object"){let[S]=Object.keys(d),b=od(d[S],g);h+=`/${S}`,b!==""&&(h+=`(${b})`)}}return g.length>0&&Object.assign(v,g.reduce((S,b)=>Object.assign(S,{[`@${b.name}`]:od(b.value)}),{})),zQn(h,{$select:e,$search:t,$skiptoken:r,$format:n,...v})}function dbe(e,t,r=[]){return`${e} eq ${od(t,r)}`}function C7(e={},t=[],r=""){return(Array.isArray(e)?e:[e]).reduce((s,o)=>{if(o){let a=n(o,t,r);a&&s.push(a)}return s},[]).join(" and ");function n(s={},o=[],a=""){let u="";return typeof s=="string"?u=s:s&&typeof s=="object"&&(u=Object.keys(s).reduce((c,l)=>{let f=s[l];if(f===void 0)return c;let p="";if(a?l===im?p=a:z8t.test(l)?p=l.replace(z8t,(d,h)=>h.trim()===im?`(${a})`:`(${a}/${h.trim()})`):Y8t.test(l)?p=l.replace(Y8t,(d,h)=>h.trim()===im?`(${a})`:`(${a}/${h.trim()})`):p=`${a}/${l}`:p=l,l===im&&Array.isArray(f))return c.concat(f.map(d=>dbe(p,d)));if(["number","string","boolean"].indexOf(typeof f)!==-1||f instanceof Date||f===null)c.push(dbe(p,f,o));else if(Array.isArray(f)){let d=l,h=f.map(g=>C7(g,o,a)).filter(g=>g).map(g=>w7.indexOf(d)!==-1?`(${g})`:g);h.length&&(w7.indexOf(d)!==-1?h.length&&(d==="not"?c.push(K8t(h)):c.push(`(${h.join(` ${d} `)})`)):c.push(h.join(` ${d} `)))}else if(w7.indexOf(p)!==-1){let d=p,h=Object.keys(f).map(g=>n({[g]:f[g]}));h.length&&(d==="not"?c.push(K8t(h)):c.push(`(${h.join(` ${d} `)})`))}else if(typeof f=="object")"type"in f?c.push(dbe(p,f,o)):Object.keys(f).forEach(d=>{if(f[d]!==void 0)if(qQn.indexOf(d)!==-1)c.push(`${p} ${d} ${od(f[d],o)}`);else if(w7.indexOf(d)!==-1)Array.isArray(f[d])?c.push(f[d].map(h=>"("+n(h,o,p)+")").join(` ${d} `)):c.push("("+n(f[d],o,p)+")");else if(jQn.indexOf(d)!==-1){let h=i(l.toLowerCase(),f[d],d,p);h&&c.push(h)}else if(d==="has")c.push(`${p} ${d} ${od(f[d],o)}`);else if(d==="in"){let h=Array.isArray(f[d])?f[d]:f[d].value.map(g=>({type:f[d].type,value:g}));c.push(p+" in ("+h.map(g=>od(g,o)).join(",")+")")}else if(VQn.indexOf(d)!==-1)c.push(`${d}(${p},${od(f[d],o)})`);else{let h=n({[d]:f[d]},o,p);h&&c.push(h)}});else throw new Error(`Unexpected value type: ${f}`);return c},[]).join(" and ")),u}function i(s,o,a,u){let c="";if(typeof o=="string"||o instanceof String)c=GQn(s,o,a,u);else if(o){let l=Array.isArray(o)?o.reduce((p,d)=>d.hasOwnProperty(im)?(p.hasOwnProperty(im)||(p[im]=[]),p[im].push(d[im]),p):{...p,...d},{}):o,f=n(l,t,s);c=`${u}/${a}(${f?`${s}:${f}`:""})`}return c}}function GQn(e,t,r,n){let i=r=="all"?"ne":"eq";return`${n}/${r}(${e}: ${e} ${i} '${t}')`}function HQn(e){return e=e.replace(/%/g,"%25"),e=e.replace(/\+/g,"%2B"),e=e.replace(/\//g,"%2F"),e=e.replace(/\?/g,"%3F"),e=e.replace(/#/g,"%23"),e=e.replace(/&/g,"%26"),e=e.replace(/'/g,"''"),e}function od(e,t){if(typeof e=="string")return`'${HQn(e)}'`;if(e instanceof Date)return e.toISOString();if(typeof e=="number")return e;if(Array.isArray(e))return`[${e.map(r=>od(r)).join(",")}]`;if(e===null)return e;if(typeof e=="object")switch(e.type){case"raw":case"guid":return e.value;case"duration":return`duration'${e.value}'`;case"binary":return`binary'${e.value}'`;case"alias":return Array.isArray(t)&&t.push(e),`@${e.name}`;case"json":return escape(JSON.stringify(e.value));case"decimal":return`${e.value}M`;default:return Object.entries(e).filter(([,r])=>r!==void 0).map(([r,n])=>`${r}=${od(n,t)}`).join(",")}return e}function O7(e){if(typeof e=="number")return e;if(typeof e=="string")return e.indexOf("/")===-1?e:e.split("/").reverse().reduce((t,r,n,i)=>n===0?`$expand=${r}`:n===i.length-1?`${r}(${t})`:`$expand=${r}(${t})`,"");if(Array.isArray(e))return`${e.map(t=>O7(t)).join(",")}`;if(typeof e=="object"){let t=Object.keys(e);return t.some(r=>$Qn.indexOf(r.toLowerCase())!==-1)?t.map(r=>{let n;switch(r){case"filter":n=C7(e[r]);break;case"orderBy":n=mbe(e[r]);break;case"levels":case"count":case"skip":case"top":n=`${e[r]}`;break;default:n=O7(e[r])}return`$${r.toLowerCase()}=${n}`}).join(";"):t.map(r=>{let n=O7(e[r]);return n?`${r}(${n})`:r}).join(",")}return""}function X8t(e){return(Array.isArray(e)?e:[e]).reduce((t,r)=>{for(let n of Object.keys(r))switch(n){case"aggregate":{let i=r[n];i&&t.push(`aggregate(${WQn(i)})`);break}case"filter":{let i=r[n];if(i){let s=C7(i);s&&t.push(`filter(${s})`)}break}case"groupBy":{let i=r[n];i&&t.push(`groupby(${YQn(i)})`);break}default:throw new Error(`Unsupported transform: ${n}`)}return t},[]).join("/")||void 0}function WQn(e){return(Array.isArray(e)?e:[e]).map(t=>typeof t=="string"?t:Object.keys(t).map(r=>{let n=t[r];if(!n.with&&n.as)return`${r} as ${n.as}`;if(!n.with)throw new Error(`'with' property required for '${r}'`);if(!n.as)throw new Error(`'as' property required for '${r}'`);return`${r} with ${n.with} as ${n.as}`})).join(",")}function YQn(e){if(!e.properties)throw new Error("'properties' property required for groupBy");let t=`(${e.properties.join(",")})`;return e.transform&&(t+=`,${X8t(e.transform)}`),t}function mbe(e,t=""){return Array.isArray(e)?e.map(r=>Array.isArray(r)&&r.length===2&&["asc","desc"].indexOf(r[1])!==-1?r.join(" "):r).map(r=>`${t}${String(r)}`).join(","):typeof e=="object"?Object.entries(e).map(([r,n])=>mbe(n,`${r}/`)).map(r=>`${t}${r}`).join(","):`${t}${String(e)}`}function zQn(e,t){let r=Object.getOwnPropertyNames(t).filter(n=>t[n]!==void 0&&t[n]!=="").map(n=>`${n}=${t[n]}`);return r.length?`${e}?${r.join("&")}`:e}function K8t(e){return`not (${e.join(" and ")})`}function KQn(e){let t=[];return{expands:e.reduce((n,{entityPath:i})=>{let s=i.split("/"),o=n;return s.forEach((a,u)=>{o.expand||(o.expand={}),o.expand[a]??=u===s.length-1?{}:{expand:{}},o=o.expand[a],t.includes(a)||t.push(a)}),n},{expand:{}}),entityPathParts:t}}function XQn(e,t,r=1,n){let i=t?.map(d=>({entityPath:d.fullPath,entitySetName:d.entity.entitySetName})),{expands:s,entityPathParts:o}=KQn(i),a=o.map(d=>t.find(g=>d===g.entity.entityPath?g.entity.entitySetName:void 0)?.entity.entitySetName).filter(d=>d!==void 0);cr.logger.info(Nt("info.entityFilesToBeGenerated",{entities:a.join(", ")}));let u=e;if(n){let d=[];u.semanticKeys.forEach(x=>{if(x.value!==void 0&&x.value!=="")if(x.type==="Edm.Boolean")d.push(`${x.name} eq ${x.value}`);else{let N=String(x.value).split(","),F=["Edm.UUID","Edm.Guid"].includes(x.type),D=V=>F?V.trim():`'${V.trim()}'`;if(N.length===1)d.push(`${x.name} eq ${D(N[0])}`);else{let V=N.map(z=>`${x.name} eq ${D(z)}`);d.push(`(${V.join(" or ")})`)}}});let h=d.length>0?`,filter(${d.join(" and ")})`:"",g=`$root/${u.entitySetName},${n.qualifier},${n.nodeProperty}`,v=`com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/${u.entitySetName},HierarchyQualifier='${n.qualifier}',NodeProperty='${n.nodeProperty}')`,S=n.isDraft?`$apply=ancestors(${g}${h},keep start)/${v}`:`$apply=${v}`,b=s?hbe(s):"",A=b?`&${b.substring(1)}`:"",w=`${u.entitySetName}?${S}${A}`;return cr.logger.debug(`Query for odata: ${w}`),{query:w}}let c=[];u.semanticKeys.forEach(d=>{if(d.value!==void 0&&d.value!=="")if(["Edm.UUID","Edm.Guid"].includes(d.type)){let g=String(d.value).split(",").map(v=>({[d.name]:{type:"guid",value:v.trim()}}));c.push(g.length===1?g[0]:{or:g})}else if(d.type==="Edm.Boolean")c.push({[d.name]:String(d.value)==="true"});else if(d.type==="Edm.String"){let h=String(d.value).split(","),g=[];h.forEach(v=>{let S=v.trim().split("-");S.length===1?g.push({[d.name]:v.trim()}):S.length===2&&g.push({[d.name]:{ge:S[0].trim(),le:S[1].trim()}})}),c.push(g.length==1?g[0]:{or:g})}else c.push({[d.name]:d.value})});let l={};s&&Object.assign(l,s),c.length>0?Object.assign(l,{filter:c.length===1?c[0]:c,count:!0}):r&&Object.assign(l,{top:r});let f=hbe(l),p=`${u.entitySetName}${f}`;return cr.logger.debug(`Query for odata: ${p}`),{query:p}}function JQn(e,t,r){let n=new Set(["DraftUUID","IsActiveEntity"]),i=[];for(let f of e.semanticKeys){if(f.value===void 0||f.value===""||n.has(f.name))continue;let p=f.keyName??f.name,d=String(f.value).split(",")[0].trim(),h=["Edm.UUID","Edm.Guid"].includes(f.type),g=f.type==="Edm.Boolean";i.push(`${p}=${h||g?d:`'${d}'`}`)}if(i.length===0){cr.logger.debug(`buildNavPropHierarchyQuery: no key values available for '${e.entitySetName}', skipping nav-prop hierarchy query for '${t}'`);return}let s={DraftUUID:"00000000-0000-0000-0000-000000000000",IsActiveEntity:"true"};e.entityType?.keys?.filter(f=>f.name in s).forEach(f=>i.push(`${f.name}=${s[f.name]}`)),cr.logger.debug(`buildNavPropHierarchyQuery: key segment for '${e.entitySetName}': (${i.join(",")})`);let a=`${`${e.entitySetName}(${i.join(",")})`}/${t}`,c=`com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=${`$root/${a}`},HierarchyQualifier='${r.qualifier}',NodeProperty='${r.nodeProperty}')`,l=`${a}?$apply=${c}`;return cr.logger.debug(`Nav-prop hierarchy query: ${l}`),l}async function Q8t(e,t,r,n,i,s=[]){let o=XQn(e,r,n,i),a=await J8t(t,o.query);for(let u of s){let c=r.find(v=>v.entity.entitySetName===u.entitySetName);if(!c){cr.logger.debug(`fetchData: no selected entity matched hierarchy entity '${u.entitySetName}', skipping`);continue}let l=JQn(e,c.entity.entityPath,u);if(!l){cr.logger.debug(`fetchData: could not build nav-prop hierarchy query for '${u.entitySetName}', skipping`);continue}let f=await J8t(t,l);if(!f.entityData||!a.entityData){cr.logger.debug(`fetchData: no data returned for nav-prop hierarchy query '${u.entitySetName}', skipping merge`);continue}cr.logger.debug(`fetchData: merging ${f.entityData.length} hierarchy records into '${c.entity.entityPath}' expanded items`);let p=c.entity.entityPath,d=u.nodeProperty.split("/")[0],h=f.entityData,g=0;for(let v of a.entityData){let S=v[p];if(Array.isArray(S))for(let b of S){let A=h.find(w=>u.entityTypeKeys.every(x=>w[x]===b[x]));A&&(b[d]=A[d],g++)}}cr.logger.debug(`fetchData: patched '${d}' onto ${g} expanded '${p}' records`)}return{odataResult:a}}async function J8t(e,t){try{cr.logger.info(`OData query request: ${encodeURI(e.defaults.baseURL+t).replaceAll("'","%27")}`),cr.logger.debug(`OData query request headers: ${JSON.stringify(e.defaults.headers)}`);let r=await e.get(t),n=r?.data?.match(/"@odata\.count":(\d+)/)?.[1];return cr.logger.info(`OData query records count: ${n}`),{entityData:r?.odata()}}catch(r){let n=Nt("errors.odataQueryError",{error:r});return cr.logger.error(n),{error:n}}}var xu=class e{static externalServiceRequestCache={};static entityTypeRefFacetCache={};static resetExternalServiceCache(t){if(t){delete e.externalServiceRequestCache[t];return}e.externalServiceRequestCache={}}static resetRefFacetCache(){e.entityTypeRefFacetCache={}}static resetServiceCaches(){e.resetExternalServiceCache(),e.resetRefFacetCache()}};async function t4t(e,t,r){if(e.metadata&&t.appAccess&&e.connectedSystem&&e.servicePath&&t.appAccess&&t.referencedEntities){e.connectedSystem.serviceProvider.log=cr.logger;let n=e.connectedSystem?.serviceProvider.service(e.servicePath);if(n){let i=Date.now();ya.sendTelemetry("ODATA_DOWNLOAD_SEND_QUERY",{time:Date()});let s=t.referencedEntities.hierarchyEntities?.find(u=>u.entitySetName===t.referencedEntities.listEntity.entitySetName),o=t.referencedEntities.hierarchyEntities?.filter(u=>u.entitySetName!==t.referencedEntities.listEntity.entitySetName&&r.some(c=>c.entity.entitySetName===u.entitySetName))??[],{odataResult:a}=await Q8t(t.referencedEntities.listEntity,n,r,s?void 0:1,s,o);if(a.entityData)return ya.sendTelemetry("ODATA_DOWNLOAD_RECEIVED_QUERY_RESULT",{duration:`${Date.now()-i} ms`,resultSize:`${a.entityData.length} rows`}),cr.logger.debug(`Got result rows: ${a.entityData.length}`),{odataQueryResult:a.entityData};if(a.error)return ya.sendTelemetry("ODATA_DOWNLOAD_QUERY_ERRORED",{duration:`${Date.now()-i} ms`}),`${a.error}`}}return Nt("errors.dataNotFetched")}function r4t(e){let t=[];return e.Facets.forEach(r=>{if(r.$Type==="com.sap.vocabularies.UI.v1.ReferenceFacet"&&r.Target.type==="AnnotationPath"){let n=r.Target.value;n.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}else r.$Type==="com.sap.vocabularies.UI.v1.CollectionFacet"&&t.push(...r4t(r))}),t}function QQn(e){if(xu.entityTypeRefFacetCache[e.name])return xu.entityTypeRefFacetCache[e.name];let t=[];return e.annotations?.UI?.Facets?.forEach(r=>{if(r.$Type==="com.sap.vocabularies.UI.v1.ReferenceFacet"&&r.Target?.type==="AnnotationPath"){let n=r.Target.value;n?.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}r.$Type==="com.sap.vocabularies.UI.v1.CollectionFacet"&&t.push(...r4t(r))}),xu.entityTypeRefFacetCache[e.name]=t,t??[]}function n4t(e,t="",r=[],n,i){let s={},o=e.navPropEntities;if(o&&o.length>0){let a=e.entityType?QQn(e.entityType):[];for(let u of o){let c=u.entityPath,l=i??e;if(u.entityType?.name===l?.entityType?.name||t.includes(c))continue;let f=t.concat(`${t?"/":""}${c}`);u.navPropEntities&&u.navPropEntities.length>0&&Object.assign(s,n4t(u,f,r,n,i??e).entitySetsFlat);let p={fullPath:f,entity:{entityPath:u.entityPath,entitySetName:u.entitySetName,defaultSelected:a.includes(u.entityPath)||!!n?.includes(f)}},d=`${f}`;r||(r=[]),r.push({name:d,value:p,checked:p.entity.defaultSelected}),s[f]=u.entitySetName}}return{entitySetsFlat:s,choices:r}}function i4t(e,t){let r=t?.map(n=>{let i=n.page?.contextPath??n.page?.routePattern?.replace(":?query:","").replaceAll(/\(\{[^}]*\}\)/g,"");return i?.startsWith(`/${e.entityPath}/`)?i.replace(`/${e.entityPath}/`,""):i}).filter(n=>n!==void 0);if(e.navPropEntities){let n=n4t(e,void 0,void 0,r);return n.choices.sort((i,s)=>(i.name??"").localeCompare(s.name??"")),n}}async function s4t(e,t){let n=(await Co.newInstance(await(0,Z8t.readFile)((0,e4t.join)(e,vt.Ui5Yaml),"utf-8"))).getBackendConfigsFromFioriToolsProxyMiddleware()[0],i;if(n){let s=n.url;if(n.connectPath){let o=n.connectPath.startsWith("/")?n.connectPath:`/${n.connectPath}`;s=new URL(o,n.url).href}i=jr()?n?.destination:await B8t(s,n?.client)}return{servicePath:t.uri,systemName:i}}async function o4t(e){let t=await fL(e.app.appRoot),r=t.getApiVersion(),n=typeof r?.version=="string"?Number.parseInt(r.version,10):0;return n<24?(cr.logger.debug(`@sap/ux-specification from module cache API version is: ${n}. API version '24' at least is required.`),Nt("prompts.appSelection.validation.specficationApiVersionOutdated",{specApiVersion:n})):t}var a4t,ZQn=(...e)=>new Promise(t=>{clearTimeout(a4t),a4t=setTimeout(async()=>t(await t4t(...e)),1e3)}),Ol={appSelection:"appSelection",toggleSelection:"toggleSelection",relatedEntitySelection:"relatedEntitySelection",skipDataDownload:"skipDataDownload",updateMainServiceMetadata:"updateMainServiceMetadata"},eZn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,u4t=["."];async function c4t(e,t,r){let n=!1;if(!r.referencedEntities?.listEntity.semanticKeys.every((a,u)=>(a.name!=="IsActiveEntity"&&!n&&(n=!!a.value),a.value!==void 0&&a.value!==""||!e[`entityKeyIdx:${u}`]))||!n)return Nt("prompts.skipDataDownload.validation.keyRequired");let s=[];r.relatedEntityChoices?.choices?.length&&(s=e[Ol.relatedEntitySelection]);let o=await ZQn(t,r,s);return o}function tZn(e){return xu.resetServiceCaches(),e.appAccess=void 0,e.referencedEntities=void 0,e.servicePath=void 0,e.systemName&&(e.systemName.value=void 0),e.relatedEntityChoices.choices=[],e.relatedEntityChoices.entitySetsFlat={},e}async function l4t(e){let t=[],r={appAccess:void 0,referencedEntities:void 0,servicePath:void 0,systemName:{value:void 0},connectPath:{value:void 0},relatedEntityChoices:{choices:[],entitySetsFlat:{}}},n=[],i=rZn(r,n,e?.appPath),s=await J$t({datasourceType:{includeNone:!1},systemSelection:{includeCloudFoundryAbapEnvChoice:!1,defaultChoice:r.systemName,connectPath:r.connectPath,hideNewSystem:!0},serviceSelection:{serviceFilter:n,requiredOdataVersion:zn.v4}},Uc()!==un.cli,cr.logger);s.prompts=Ps(s.prompts,()=>!!r.appAccess);let o={odata:[]},a=iZn(r,r.relatedEntityChoices),u=sZn(5,r,s.answers,o),c=nZn(r.relatedEntityChoices,s.answers,r,o);return t.push(i,...s.prompts,aZn(s.answers,r),oZn(s.answers,r),...u,a,c),{questions:t,answers:{application:r,odataQueryResult:o,odataServiceAnswers:s.answers}}}function rZn(e,t,r){return{type:"input",guiType:"folder-browser",name:Ol.appSelection,message:Nt("prompts.appSelection.message"),default:n=>r??n.appSelection??e.appAccess?.app.appRoot,guiOptions:{mandatory:!0,breadcrumb:Nt("prompts.appSelection.breadcrumb")},validate:async n=>{if(!n)return!1;if(n===e.appAccess?.app.appRoot)return!0;t.length=0,tZn(e);let i;try{i=await X5(n)}catch(c){let l=c;return c instanceof Error&&(l=c.message),cr.logger.error(Nt("prompts.appSelection.validation.selectedPathDoesNotContainValidApp",{error:l})),`${Nt("prompts.appSelection.validation.selectedPathDoesNotContainValidApp")}${Nt("texts.seeLogForDetails")}`}let s=i.app.services[i.app.mainService??"mainService"];if(!s?.odataVersion?.startsWith("4."))return Nt("prompts.appSelection.validation.appMainServiceOdataVersionNotSupported",{serviceOdataVersion:s.odataVersion});let o=await o4t(i);if(typeof o=="string")return o;e.appAccess=i,e.specification=o;let{servicePath:a,systemName:u}=await s4t(i.app.appRoot,s);return a&&(e.servicePath=a,t.push(a)),e.systemName&&(e.systemName.value=u),e.connectPath&&(e.connectPath.value=a),!0}}}function nZn(e,t,r,n){let i;return{when:async s=>e.choices.length>0,name:Ol.relatedEntitySelection,type:"checkbox",guiOptions:{applyDefaultWhenDirty:!0},message:Nt("prompts.relatedEntitySelection.message"),choices:()=>e.choices,validate:async(s,o)=>{if(e.choices.forEach(a=>{a.disabled||(a.checked=s.some(u=>u.fullPath===a.value.fullPath))}),o&&!o[Ol.skipDataDownload]?.[0]){if(i=await c4t(o,t,r),typeof i=="string")return i;n.odata=i.odataQueryResult}return!0},additionalMessages:()=>{if(i&&typeof i!="string")return{message:Nt("prompts.skipDataDownload.querySuccess",{count:i.odataQueryResult.length}),severity:gbe.Severity.information}},showOutputTabLink:()=>({show:!!i,linkMessage:Nt("prompts.relatedEntitySelection.openLogs")})}}function iZn(e,t){let r,n,i;return{when:()=>{if((n!==e.systemName?.value||e.servicePath!==r)&&e.referencedEntities?.listEntity){let o=i4t(e.referencedEntities.listEntity,e.referencedEntities.pageObjectEntities);o&&(t.choices=o.choices,Object.assign(t.entitySetsFlat,o.entitySetsFlat)),r=e.servicePath,n=e.systemName?.value}return t.choices.length>0},name:Ol.toggleSelection,type:"confirm",message:Nt("prompts.toggleSelection.message"),labelTrue:Nt("prompts.toggleSelection.labelTrue"),labelFalse:Nt("prompts.toggleSelection.labelFalse"),default:!1,validate:o=>(o!==i&&(t.choices.forEach(a=>{if(a.disabled)return;let u=a.value;a.checked=o===!1?u.entity.defaultSelected:!1}),i=o),!0)}}function sZn(e,t,r,n){let i=[],s,o=0,a=u=>({when:async()=>{let c=t.referencedEntities?.listEntity.semanticKeys[u],l=!!c?.name&&c.name!=="IsActiveEntity";return l&&u>o&&(o=u),l},name:`entityKeyIdx:${u}`,message:()=>Nt("prompts.entityKey.message",{keyName:`${t.referencedEntities?.listEntity.semanticKeys[u]?.name} (${t.referencedEntities?.listEntity.entitySetName})`}),type:"input",guiOptions:{hint:Nt("prompts.entityKey.hint")},validate:async(c,l)=>{let f=t.referencedEntities?.listEntity.semanticKeys[u];if(f&&delete f.value,u4t.includes(c))return Nt("prompts.entityKey.validation.invalidKeyValueChars",{chars:u4t.join()});if(c&&f)if(f.type==="Edm.Boolean")try{f.value=JSON.parse(c)}catch{return Nt("prompts.entityKey.validation.invalidBooleanValue")}else if(["Edm.UUID","Edm.Guid"].includes(f.type)){let d=c.split(",");for(let h of d)if(!eZn.test(h.trim()))return Nt("prompts.entityKey.validation.invalidGuidValue");f.value=c.trim()}else f.value=c.trim();let p=c.split(",");if(f?.type&&!["Edm.UUID","Edm.Guid"].includes(f.type)){for(let d of p)if(d.split("-").length>2)return f&&delete f.value,Nt("prompts.entityKey.validation.invalidRangeSpecified")}if(l&&!t.relatedEntityChoices?.choices?.length&&u===o&&!l[Ol.skipDataDownload]?.[0]&&t.referencedEntities?.listEntity.semanticKeys[u]?.name){if(s=await c4t(l,r,t),typeof s=="string")return s;n.odata=s.odataQueryResult}return!0}});for(let u=0;u<e;u++)i.push(a(u));return i}function oZn(e,t){return{when:()=>!!e.metadata&&!!t.servicePath,name:Ol.skipDataDownload,type:"checkbox",message:Nt("prompts.skipDataDownload.message"),guiOptions:{hint:Nt("prompts.skipDataDownload.hint")},default:!1,choices:[{name:Nt("prompts.skipDataDownload.choiceLabel"),value:"skipDownload",checked:!1}]}}function aZn(e,t){let r;return{when:async()=>t.appAccess&&t.specification&&e?.metadata?(r=await j8t(t.appAccess,t.specification,e.metadata),typeof r=="object"&&(t.referencedEntities=r),!0):!1,name:Ol.updateMainServiceMetadata,type:"confirm",message:Nt("prompts.updateMainServiceMetadata.message"),default:!1,additionalMessages:async()=>{if(typeof r=="string")return{message:r,severity:gbe.Severity.error}}}}function f4t(e){let t=[],r=n=>[{name:`${n.entitySetName}/${n.nodeProperty}/source`,type:"list",message:`Source: ${n.entitySetName} > ${n.missingReferentialConstraints?.navPropName}`,default:!1,choices:n.entityProperties.map(i=>({name:i,value:i}))},{name:`${n.entitySetName}/${n.nodeProperty}/target`,type:"list",message:`Target: ${n.entitySetName} > ${n.missingReferentialConstraints?.navPropName}`,default:!1,choices:n.entityProperties.map(i=>({name:i,value:i}))}];return e.forEach(n=>{!n.parentProperty&&n.missingReferentialConstraints?.navPropName&&t.push(...r(n))}),t}var g4t=Te(Oy()),y4t=Te(Py());var E4t=Te(m4t()),_4t=require("node:path");function v4t(e,t,r){xu.resetExternalServiceCache();let n=bZn(e,t),i=[];return{questions:[{name:"valueHelpSelection",type:"checkbox",message:Nt("prompts.valueHelpSelection.message"),choices:()=>n,validate:async o=>{if(!o||o.length===0)return xu.resetExternalServiceCache(),!0;let a=await TZn(o,r),u=(0,E4t.default)(i,a);return i.length=0,i.push(...u),await SZn(i,r),!0}}],valueHelpData:i}}async function SZn(e,t){let r=[],n={transformResponse:s=>typeof s=="string"?JSON.parse(s):s},i=e.map(async s=>{let o=s,[a]=o.path.split(";");xu.externalServiceRequestCache[a]??=[];let l=(0,g4t.convert)((0,y4t.parse)(s.metadata)).entitySets.map(async f=>{let p=f.name;if(xu.externalServiceRequestCache[a].includes(p))return;xu.externalServiceRequestCache[a].push(p);let d=await t.get((0,_4t.join)(o.path,p),n);o.entityData=o.entityData??[],o.entityData?.push({entitySetName:p,items:d.data.value})});await Promise.allSettled(l),o.entityData&&r.push(o)});return await Promise.allSettled(i),r}async function TZn(e,t){let r=e.flat();return await t.fetchExternalServices(r)}function bZn(e,t){let r=lM(e,t,[]),n={};for(let s of r)if(s.type==="value-list"){if(L8t.includes(s.target))continue;let[o]=s.value.split(";"),a=s.target.split("/").pop();a&&(n[o]??={},n[o][a]??=[],n[o][a].push(s))}else s.type==="code-list"&&(n[s.value]??={},n[s.value]["Code list"]??=[],n[s.value]["Code list"].push(s));let i=[];for(let s of Object.values(n))for(let[o,a]of Object.entries(s)){let u=a.map(c=>{if(c.type==="value-list")return c.target.replace(/\/[^/]*$/,"");if(c.type==="code-list"&&c.collectionPath)return c.collectionPath}).filter(c=>c!==void 0);i.push({name:`${o} (${u.join()})`,value:a})}return i.sort((s,o)=>s.name.localeCompare(o.name))}var cr=class e extends T4t.default{vscode;appWizard;static _logger=f4;generatorVersion=this.rootGeneratorVersion();prompts;setPromptsCallback;state={};constructor(t,r){super(t,{...r,skipInstall:!0},{unique:"namespace"}),p_e(this.env,!0),this.options.force=!0,this.prompts=new P7.Prompts([{description:Nt("steps.odataDownloader.description"),name:Nt("steps.odataDownloader.name")},{description:Nt("steps.valueHelpSelection.description"),name:Nt("steps.valueHelpSelection.name")}]),this.setPromptsCallback=n=>{this.prompts&&this.prompts.setCallback(n)},typeof r.appWizard?.setHeaderTitle=="function"&&r.appWizard.setHeaderTitle(Nt("texts.generatorTitle"),`${this.rootGeneratorName()}@${this.rootGeneratorVersion()}`)}static get logger(){return e._logger}async initializing(){await _ve(),e._logger=this._configureLogging(this.options.logLevel,this.options.logger,this.options.vscode),await ya.initTelemetrySettings(),ya.sendTelemetry("ODATA_DOWNLOADER_STARTED",{startUpTime:Date()})}async prompting(){try{let{answers:{application:t,odataQueryResult:r,odataServiceAnswers:n},questions:i}=await l4t(this.options?.data),s=await this.prompt(i);if(this.state.entityOData=r.odata,this.state.entityPropertyToEntitySet=t.relatedEntityChoices.entitySetsFlat,this.state.appRootPath=t.appAccess?.getAppRoot(),this.state.mainServicePath=n.servicePath,this.state.mainServiceName=t.appAccess?.app.mainService,this.state.appEntities=t.referencedEntities,this.state.appRootPath){this.state.mockServerConfig=await Ax(this.state.appRootPath);let o;this.state.mockServerConfig?.services&&(e.logger.debug(`Mock config: ${JSON.stringify(this.state.mockServerConfig)}`),o=this.state.mockServerConfig.services.find(a=>a.urlPath.replaceAll(/(^\/)|(\/$)/g,"")===this.state.mainServicePath?.replaceAll(/(^\/)|(\/$)/g,""))),this.state.mockDataRootPath=o?.mockdataPath??(0,ZS.join)(oi.Webapp,oi.LocalService,oi.Mockdata)}if(this.state.updateMainServiceMetadata=s[Ol.updateMainServiceMetadata],this.state.mainServiceMetadata=n.metadata,s[Ol.skipDataDownload]?.[0]||await this._promptMissingReferentialConstraints(t,s),n.servicePath&&n.metadata&&n.connectedSystem?.serviceProvider instanceof ja){let{questions:o,valueHelpData:a}=v4t(n.servicePath,n.metadata,n.connectedSystem?.serviceProvider);await this.prompt(o),this.state.valueHelpData=a}}catch(t){e.logger.error(t),this._exitOnError(t)}}async writing(){if(this.state.appRootPath){if(this.state.entityOData&&this.state.entityPropertyToEntitySet&&this.state.appEntities)try{let t=Date.now();ya.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_START",{time:Date()}),this.destinationRoot((0,ZS.join)(this.state.appRootPath));let r=pbe(this.state.entityOData,this.state.entityPropertyToEntitySet,this.state.appEntities.listEntity.entitySetName,this.state.appEntities.hierarchyEntities);e.logger.info(Nt("info.entityFilesToBeGenerated",{entities:Object.keys(r).join(", ")}));let n=Object.entries(r);n.forEach(([i,s])=>{this.writeDestinationJSON((0,ZS.join)(this.state.mockDataRootPath,`${i}.json`),s)}),this.state.appEntities.hierarchyEntities?.filter(i=>i.missingReferentialConstraints&&n.some(([s])=>s===i.entitySetName))?.forEach(i=>{let s=(0,ZS.join)(this.state.mockDataRootPath,`${i.entitySetName}.js`),o=this.destinationPath(s),{navPropName:a,constraints:u}=i.missingReferentialConstraints;if(this.fs.exists(o)){let c=this.fs.read(o),l=$8t(c,a,u);l!==c?(this.writeDestination(s,l),e.logger.info(`Updated referential constraint file: ${i.entitySetName}.js`)):e.logger.debug(`Referential constraint for '${a}' already present in ${i.entitySetName}.js \u2014 skipping`)}else{let c=V8t(a,u);this.writeDestination(s,c),e.logger.info(`Written referential constraint file: ${i.entitySetName}.js`)}}),ya.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_END",{writeFileDuration:`${Date.now()-t} ms`,numberOfFiles:`${n.length}`})}catch(t){e.logger.error(t),ya.sendTelemetry("ODATA_DOWNLOADER_WRITING_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(Nt("info.noServiceEntityData"));if(this.state.valueHelpData?.length)try{let t=Date.now();ya.sendTelemetry("ODATA_DOWNLOADER_WRITE_VALUE_HELP_FILES_START",{time:Date()});let r=(0,ZS.join)(this.state.appRootPath,oi.Webapp);if(await I4(this.fs,r,this.state.valueHelpData,this.state.mainServiceName,this.state.mainServicePath),this.state.mockServerConfig){let n={webappPath:r,packageJsonConfig:{skip:!0},ui5MockYamlConfig:{overwrite:!0}};n.ui5MockYamlConfig&&this.state.mainServiceName&&(n.ui5MockYamlConfig.resolveExternalServiceReferences={[this.state.mainServiceName]:!0},await d4(this.state.appRootPath,n,this.fs))}ya.sendTelemetry("ODATA_DOWNLOADER_WRITE_VALUE_HELP_DATA_FILES_END",{writeFileDuration:`${Date.now()-t} ms`,numberOfExternalServices:`${this.state.valueHelpData.length}`})}catch(t){e.logger.error(t),ya.sendTelemetry("ODATA_DOWNLOADER_WRITING_BALUE_HELP_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(Nt("info.noValueHelpData"));if(this.state.updateMainServiceMetadata&&this.state.mainServiceMetadata&&this.state.mainServiceName){let t=(0,ZS.join)(this.state.appRootPath,oi.Webapp,oi.LocalService,this.state.mainServiceName,"metadata.xml");this.writeDestination(t,(0,S4t.default)(this.state.mainServiceMetadata,{indent:4}))}}}async _promptMissingReferentialConstraints(t,r){let n=t.referencedEntities?.listEntity.entitySetName,i=new Set([...n?[n]:[],...(r[Ol.relatedEntitySelection]??[]).map(o=>o.entity.entitySetName)]),s=t.referencedEntities?.hierarchyEntities?.filter(o=>!o.parentProperty&&o.missingReferentialConstraints&&i.has(o.entitySetName))??[];if(s.length>0){this.prompts.splice(1,0,[{name:Nt("steps.addConstraints.name"),description:Nt("steps.addConstraints.description")}]);let o=f4t(s),a=await this.prompt(o),u=[t.referencedEntities?.listEntity,...t.referencedEntities?.pageObjectEntities??[]];s.forEach(c=>{let l=a[`${c.entitySetName}/${c.nodeProperty}/source`],f=a[`${c.entitySetName}/${c.nodeProperty}/target`];if(l&&f){c.missingReferentialConstraints.constraints=[{sourceProperty:l,targetProperty:f}],c.parentProperty=l;let p=u.find(d=>d?.entitySetName===c.entitySetName)?.entityType;c.parentPropertyType=p?.entityProperties.find(d=>d.name===l)?.type??"Edm.String"}})}}_exitOnError(t){throw Uc()!==un.cli&&this.appWizard?.showError(t,P7.MessageType.notification),new Error(t)}_configureLogging(t,r,n){let i=new l4(this.rootGeneratorName(),this.log,t,r,n);return i.info(Nt("info.loggingInitialised",{logLevel:i.getLogLevel()})),i}};
|
|
733
|
+
${s}${e.slice(o)}`:e}var Z8t=require("node:fs/promises"),e4t=require("node:path");var H8t=require("node:crypto"),W8t=Te(F8());var G8t={name:"@sap-ux/generator-odata-downloader",displayName:"Fiori Elements Data Downloader",description:"Yeoman generator that supports download of app data, typically for mock data server use.",version:"0.3.15",repository:{type:"git",url:"https://github.com/SAP/open-ux-tools.git",directory:"packages/generator-odata-downloader"},bugs:{url:"https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aodata-download"},license:"Apache-2.0",main:"generators/app/index.js",keywords:["yeoman-generator"],scripts:{build:"npm-run-all clean bundle:prod",compile:"tsc --build",clean:"rimraf --glob generators prebuilds test/test-output coverage *.tsbuildinfo",watch:"tsc --watch",lint:"eslint","lint:fix":"eslint --fix",test:"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors","test-u":"cross-env NODE_OPTIONS='--experimental-vm-modules' jest --ci --forceExit --detectOpenHandles --colors -u",link:"pnpm link --global",unlink:"pnpm unlink --global",bundle:"node esbuild.mjs","bundle:dev":"pnpm clean && node esbuild.mjs --development && pnpm pack","bundle:prod":"node esbuild.mjs --production"},files:["LICENSE","generators","!generators/*.map","!generators/**/*.map","prebuilds","yeoman.png"],devDependencies:{"@jest/globals":"30.3.0"},dependencies:{"@sap-devx/yeoman-ui-types":"1.25.0","@sap-ux/annotation-converter":"0.10.21","@sap-ux/axios-extension":"workspace:*","@sap-ux/btp-utils":"workspace:*","@sap-ux/edmx-parser":"0.10.0","@sap-ux/fiori-generator-shared":"workspace:*","@sap-ux/inquirer-common":"workspace:*","@sap-ux/logger":"workspace:*","@sap-ux/mockserver-config-writer":"workspace:*","@sap-ux/odata-service-inquirer":"workspace:*","@sap-ux/odata-service-writer":"workspace:*","@sap-ux/project-access":"workspace:*","@sap-ux/store":"workspace:*","@sap-ux/telemetry":"workspace:*","@sap-ux/ui5-config":"workspace:*","@sap-ux/vocabularies-types":"0.15.0","@sap/ux-specification":"1.144.0","@types/inquirer":"8.2.6","@types/yeoman-generator":"5.2.14","@vscode-logging/logger":"2.0.9",deepmerge:"4.3.1",i18next:"25.10.10",inquirer:"8.2.7","odata-query":"8.0.5","os-name":"4.0.1","prettify-xml":"1.2.0",rimraf:"6.1.3","yeoman-generator":"5.10.0"},engines:{node:">=22.x"}};var kQn="@sap-ux/odata-download-sub-generator",BQn="0a65e45d-6bf4-421d-b845-61e888c50e9e",ya=class{static _telemetryData;static _sessionId;static async initTelemetrySettings(t){this._sessionId=(0,H8t.randomUUID)(),cr.logger.info(`Telemetry session initialized with ID: ${this._sessionId}`);let r={consumerModule:{name:kQn,version:G8t.version},watchTelemetrySettingStore:!1,internalFeature:!0,resourceId:BQn,...t};try{await bL(r)}catch(n){cr.logger.error(`Error initializing telemetry settings: ${n}`)}}static createTelemetryData(t){if(!this._telemetryData){let r=Nt("telemetry.unknownOs");try{r=(0,W8t.default)()}catch{}this._telemetryData={Platform:jr()?"SBAS":"VSCode",OperatingSystem:r,SessionId:this._sessionId}}return this._telemetryData=Object.assign(this._telemetryData,t),this._telemetryData}static prepareTelemetryEvent(t,r){return{eventName:t,properties:r,measurements:{}}}static async sendTelemetry(t,r){let n=this.createTelemetryData(r),i=this.prepareTelemetryEvent(t,n);await nc.getTelemetryClient().reportEvent(i,Ci.NoSampling)}};var qQn=["eq","ne","gt","ge","lt","le"],w7=["and","or","not"],jQn=["any","all"],VQn=["startswith","endswith","contains","matchespattern"],$Qn=["expand","levels","select","skip","top","count","orderby","filter"],Y8t=/\((.*)\)/,z8t=/(?!indexof)\((\w+)\)/;var im="";function hbe({select:e,search:t,skiptoken:r,format:n,top:i,skip:s,filter:o,transform:a,orderBy:u,key:c,count:l,expand:f,action:p,func:d}={}){let h="",g=[],v={};if(c!=null&&(h+=`(${od(c,g)})`),(o||typeof l=="object")&&(v.$filter=C7(typeof l=="object"?l:o,g)),a&&(v.$apply=X8t(a)),f&&(v.$expand=O7(f)),u&&(v.$orderby=mbe(u)),l&&(typeof l=="boolean"?v.$count=!0:h+="/$count"),typeof i=="number"&&(v.$top=i),typeof s=="number"&&(v.$skip=s),p&&(h+=`/${p}`),d){if(typeof d=="string")h+=`/${d}`;else if(typeof d=="object"){let[S]=Object.keys(d),b=od(d[S],g);h+=`/${S}`,b!==""&&(h+=`(${b})`)}}return g.length>0&&Object.assign(v,g.reduce((S,b)=>Object.assign(S,{[`@${b.name}`]:od(b.value)}),{})),zQn(h,{$select:e,$search:t,$skiptoken:r,$format:n,...v})}function dbe(e,t,r=[]){return`${e} eq ${od(t,r)}`}function C7(e={},t=[],r=""){return(Array.isArray(e)?e:[e]).reduce((s,o)=>{if(o){let a=n(o,t,r);a&&s.push(a)}return s},[]).join(" and ");function n(s={},o=[],a=""){let u="";return typeof s=="string"?u=s:s&&typeof s=="object"&&(u=Object.keys(s).reduce((c,l)=>{let f=s[l];if(f===void 0)return c;let p="";if(a?l===im?p=a:z8t.test(l)?p=l.replace(z8t,(d,h)=>h.trim()===im?`(${a})`:`(${a}/${h.trim()})`):Y8t.test(l)?p=l.replace(Y8t,(d,h)=>h.trim()===im?`(${a})`:`(${a}/${h.trim()})`):p=`${a}/${l}`:p=l,l===im&&Array.isArray(f))return c.concat(f.map(d=>dbe(p,d)));if(["number","string","boolean"].indexOf(typeof f)!==-1||f instanceof Date||f===null)c.push(dbe(p,f,o));else if(Array.isArray(f)){let d=l,h=f.map(g=>C7(g,o,a)).filter(g=>g).map(g=>w7.indexOf(d)!==-1?`(${g})`:g);h.length&&(w7.indexOf(d)!==-1?h.length&&(d==="not"?c.push(K8t(h)):c.push(`(${h.join(` ${d} `)})`)):c.push(h.join(` ${d} `)))}else if(w7.indexOf(p)!==-1){let d=p,h=Object.keys(f).map(g=>n({[g]:f[g]}));h.length&&(d==="not"?c.push(K8t(h)):c.push(`(${h.join(` ${d} `)})`))}else if(typeof f=="object")"type"in f?c.push(dbe(p,f,o)):Object.keys(f).forEach(d=>{if(f[d]!==void 0)if(qQn.indexOf(d)!==-1)c.push(`${p} ${d} ${od(f[d],o)}`);else if(w7.indexOf(d)!==-1)Array.isArray(f[d])?c.push(f[d].map(h=>"("+n(h,o,p)+")").join(` ${d} `)):c.push("("+n(f[d],o,p)+")");else if(jQn.indexOf(d)!==-1){let h=i(l.toLowerCase(),f[d],d,p);h&&c.push(h)}else if(d==="has")c.push(`${p} ${d} ${od(f[d],o)}`);else if(d==="in"){let h=Array.isArray(f[d])?f[d]:f[d].value.map(g=>({type:f[d].type,value:g}));c.push(p+" in ("+h.map(g=>od(g,o)).join(",")+")")}else if(VQn.indexOf(d)!==-1)c.push(`${d}(${p},${od(f[d],o)})`);else{let h=n({[d]:f[d]},o,p);h&&c.push(h)}});else throw new Error(`Unexpected value type: ${f}`);return c},[]).join(" and ")),u}function i(s,o,a,u){let c="";if(typeof o=="string"||o instanceof String)c=GQn(s,o,a,u);else if(o){let l=Array.isArray(o)?o.reduce((p,d)=>d.hasOwnProperty(im)?(p.hasOwnProperty(im)||(p[im]=[]),p[im].push(d[im]),p):{...p,...d},{}):o,f=n(l,t,s);c=`${u}/${a}(${f?`${s}:${f}`:""})`}return c}}function GQn(e,t,r,n){let i=r=="all"?"ne":"eq";return`${n}/${r}(${e}: ${e} ${i} '${t}')`}function HQn(e){return e=e.replace(/%/g,"%25"),e=e.replace(/\+/g,"%2B"),e=e.replace(/\//g,"%2F"),e=e.replace(/\?/g,"%3F"),e=e.replace(/#/g,"%23"),e=e.replace(/&/g,"%26"),e=e.replace(/'/g,"''"),e}function od(e,t){if(typeof e=="string")return`'${HQn(e)}'`;if(e instanceof Date)return e.toISOString();if(typeof e=="number")return e;if(Array.isArray(e))return`[${e.map(r=>od(r)).join(",")}]`;if(e===null)return e;if(typeof e=="object")switch(e.type){case"raw":case"guid":return e.value;case"duration":return`duration'${e.value}'`;case"binary":return`binary'${e.value}'`;case"alias":return Array.isArray(t)&&t.push(e),`@${e.name}`;case"json":return escape(JSON.stringify(e.value));case"decimal":return`${e.value}M`;default:return Object.entries(e).filter(([,r])=>r!==void 0).map(([r,n])=>`${r}=${od(n,t)}`).join(",")}return e}function O7(e){if(typeof e=="number")return e;if(typeof e=="string")return e.indexOf("/")===-1?e:e.split("/").reverse().reduce((t,r,n,i)=>n===0?`$expand=${r}`:n===i.length-1?`${r}(${t})`:`$expand=${r}(${t})`,"");if(Array.isArray(e))return`${e.map(t=>O7(t)).join(",")}`;if(typeof e=="object"){let t=Object.keys(e);return t.some(r=>$Qn.indexOf(r.toLowerCase())!==-1)?t.map(r=>{let n;switch(r){case"filter":n=C7(e[r]);break;case"orderBy":n=mbe(e[r]);break;case"levels":case"count":case"skip":case"top":n=`${e[r]}`;break;default:n=O7(e[r])}return`$${r.toLowerCase()}=${n}`}).join(";"):t.map(r=>{let n=O7(e[r]);return n?`${r}(${n})`:r}).join(",")}return""}function X8t(e){return(Array.isArray(e)?e:[e]).reduce((t,r)=>{for(let n of Object.keys(r))switch(n){case"aggregate":{let i=r[n];i&&t.push(`aggregate(${WQn(i)})`);break}case"filter":{let i=r[n];if(i){let s=C7(i);s&&t.push(`filter(${s})`)}break}case"groupBy":{let i=r[n];i&&t.push(`groupby(${YQn(i)})`);break}default:throw new Error(`Unsupported transform: ${n}`)}return t},[]).join("/")||void 0}function WQn(e){return(Array.isArray(e)?e:[e]).map(t=>typeof t=="string"?t:Object.keys(t).map(r=>{let n=t[r];if(!n.with&&n.as)return`${r} as ${n.as}`;if(!n.with)throw new Error(`'with' property required for '${r}'`);if(!n.as)throw new Error(`'as' property required for '${r}'`);return`${r} with ${n.with} as ${n.as}`})).join(",")}function YQn(e){if(!e.properties)throw new Error("'properties' property required for groupBy");let t=`(${e.properties.join(",")})`;return e.transform&&(t+=`,${X8t(e.transform)}`),t}function mbe(e,t=""){return Array.isArray(e)?e.map(r=>Array.isArray(r)&&r.length===2&&["asc","desc"].indexOf(r[1])!==-1?r.join(" "):r).map(r=>`${t}${String(r)}`).join(","):typeof e=="object"?Object.entries(e).map(([r,n])=>mbe(n,`${r}/`)).map(r=>`${t}${r}`).join(","):`${t}${String(e)}`}function zQn(e,t){let r=Object.getOwnPropertyNames(t).filter(n=>t[n]!==void 0&&t[n]!=="").map(n=>`${n}=${t[n]}`);return r.length?`${e}?${r.join("&")}`:e}function K8t(e){return`not (${e.join(" and ")})`}function KQn(e){let t=[];return{expands:e.reduce((n,{entityPath:i})=>{let s=i.split("/"),o=n;return s.forEach((a,u)=>{o.expand||(o.expand={}),o.expand[a]??=u===s.length-1?{}:{expand:{}},o=o.expand[a],t.includes(a)||t.push(a)}),n},{expand:{}}),entityPathParts:t}}function XQn(e,t,r=1,n){let i=t?.map(d=>({entityPath:d.fullPath,entitySetName:d.entity.entitySetName})),{expands:s,entityPathParts:o}=KQn(i),a=o.map(d=>t.find(g=>d===g.entity.entityPath?g.entity.entitySetName:void 0)?.entity.entitySetName).filter(d=>d!==void 0);cr.logger.info(Nt("info.entityFilesToBeGenerated",{entities:a.join(", ")}));let u=e;if(n){let d=[];u.semanticKeys.forEach(x=>{if(x.value!==void 0&&x.value!=="")if(x.type==="Edm.Boolean")d.push(`${x.name} eq ${x.value}`);else{let N=String(x.value).split(","),F=["Edm.UUID","Edm.Guid"].includes(x.type),D=V=>F?V.trim():`'${V.trim()}'`;if(N.length===1)d.push(`${x.name} eq ${D(N[0])}`);else{let V=N.map(z=>`${x.name} eq ${D(z)}`);d.push(`(${V.join(" or ")})`)}}});let h=d.length>0?`,filter(${d.join(" and ")})`:"",g=`$root/${u.entitySetName},${n.qualifier},${n.nodeProperty}`,v=`com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=$root/${u.entitySetName},HierarchyQualifier='${n.qualifier}',NodeProperty='${n.nodeProperty}')`,S=n.isDraft?`$apply=ancestors(${g}${h},keep start)/${v}`:`$apply=${v}`,b=s?hbe(s):"",A=b?`&${b.substring(1)}`:"",w=`${u.entitySetName}?${S}${A}`;return cr.logger.debug(`Query for odata: ${w}`),{query:w}}let c=[];u.semanticKeys.forEach(d=>{if(d.value!==void 0&&d.value!=="")if(["Edm.UUID","Edm.Guid"].includes(d.type)){let g=String(d.value).split(",").map(v=>({[d.name]:{type:"guid",value:v.trim()}}));c.push(g.length===1?g[0]:{or:g})}else if(d.type==="Edm.Boolean")c.push({[d.name]:String(d.value)==="true"});else if(d.type==="Edm.String"){let h=String(d.value).split(","),g=[];h.forEach(v=>{let S=v.trim().split("-");S.length===1?g.push({[d.name]:v.trim()}):S.length===2&&g.push({[d.name]:{ge:S[0].trim(),le:S[1].trim()}})}),c.push(g.length==1?g[0]:{or:g})}else c.push({[d.name]:d.value})});let l={};s&&Object.assign(l,s),c.length>0?Object.assign(l,{filter:c.length===1?c[0]:c,count:!0}):r&&Object.assign(l,{top:r});let f=hbe(l),p=`${u.entitySetName}${f}`;return cr.logger.debug(`Query for odata: ${p}`),{query:p}}function JQn(e,t,r){let n=new Set(["DraftUUID","IsActiveEntity"]),i=[];for(let f of e.semanticKeys){if(f.value===void 0||f.value===""||n.has(f.name))continue;let p=f.keyName??f.name,d=String(f.value).split(",")[0].trim(),h=["Edm.UUID","Edm.Guid"].includes(f.type),g=f.type==="Edm.Boolean";i.push(`${p}=${h||g?d:`'${d}'`}`)}if(i.length===0){cr.logger.debug(`buildNavPropHierarchyQuery: no key values available for '${e.entitySetName}', skipping nav-prop hierarchy query for '${t}'`);return}let s={DraftUUID:"00000000-0000-0000-0000-000000000000",IsActiveEntity:"true"};e.entityType?.keys?.filter(f=>f.name in s).forEach(f=>i.push(`${f.name}=${s[f.name]}`)),cr.logger.debug(`buildNavPropHierarchyQuery: key segment for '${e.entitySetName}': (${i.join(",")})`);let a=`${`${e.entitySetName}(${i.join(",")})`}/${t}`,c=`com.sap.vocabularies.Hierarchy.v1.TopLevels(HierarchyNodes=${`$root/${a}`},HierarchyQualifier='${r.qualifier}',NodeProperty='${r.nodeProperty}')`,l=`${a}?$apply=${c}`;return cr.logger.debug(`Nav-prop hierarchy query: ${l}`),l}async function Q8t(e,t,r,n,i,s=[]){let o=XQn(e,r,n,i),a=await J8t(t,o.query);for(let u of s){let c=r.find(v=>v.entity.entitySetName===u.entitySetName);if(!c){cr.logger.debug(`fetchData: no selected entity matched hierarchy entity '${u.entitySetName}', skipping`);continue}let l=JQn(e,c.entity.entityPath,u);if(!l){cr.logger.debug(`fetchData: could not build nav-prop hierarchy query for '${u.entitySetName}', skipping`);continue}let f=await J8t(t,l);if(!f.entityData||!a.entityData){cr.logger.debug(`fetchData: no data returned for nav-prop hierarchy query '${u.entitySetName}', skipping merge`);continue}cr.logger.debug(`fetchData: merging ${f.entityData.length} hierarchy records into '${c.entity.entityPath}' expanded items`);let p=c.entity.entityPath,d=u.nodeProperty.split("/")[0],h=f.entityData,g=0;for(let v of a.entityData){let S=v[p];if(Array.isArray(S))for(let b of S){let A=h.find(w=>u.entityTypeKeys.every(x=>w[x]===b[x]));A&&(b[d]=A[d],g++)}}cr.logger.debug(`fetchData: patched '${d}' onto ${g} expanded '${p}' records`)}return{odataResult:a}}async function J8t(e,t){try{cr.logger.info(`OData query request: ${encodeURI(e.defaults.baseURL+t).replaceAll("'","%27")}`),cr.logger.debug(`OData query request headers: ${JSON.stringify(e.defaults.headers)}`);let r=await e.get(t),n=r?.data?.match(/"@odata\.count":(\d+)/)?.[1];return cr.logger.info(`OData query records count: ${n}`),{entityData:r?.odata()}}catch(r){let n=Nt("errors.odataQueryError",{error:r});return cr.logger.error(n),{error:n}}}var xu=class e{static externalServiceRequestCache={};static entityTypeRefFacetCache={};static resetExternalServiceCache(t){if(t){delete e.externalServiceRequestCache[t];return}e.externalServiceRequestCache={}}static resetRefFacetCache(){e.entityTypeRefFacetCache={}}static resetServiceCaches(){e.resetExternalServiceCache(),e.resetRefFacetCache()}};async function t4t(e,t,r){if(e.metadata&&t.appAccess&&e.connectedSystem&&e.servicePath&&t.appAccess&&t.referencedEntities){e.connectedSystem.serviceProvider.log=cr.logger;let n=e.connectedSystem?.serviceProvider.service(e.servicePath);if(n){let i=Date.now();ya.sendTelemetry("ODATA_DOWNLOAD_SEND_QUERY",{time:Date()});let s=t.referencedEntities.hierarchyEntities?.find(u=>u.entitySetName===t.referencedEntities.listEntity.entitySetName),o=t.referencedEntities.hierarchyEntities?.filter(u=>u.entitySetName!==t.referencedEntities.listEntity.entitySetName&&r.some(c=>c.entity.entitySetName===u.entitySetName))??[],{odataResult:a}=await Q8t(t.referencedEntities.listEntity,n,r,s?void 0:1,s,o);if(a.entityData)return ya.sendTelemetry("ODATA_DOWNLOAD_RECEIVED_QUERY_RESULT",{duration:`${Date.now()-i} ms`,resultSize:`${a.entityData.length} rows`}),cr.logger.debug(`Got result rows: ${a.entityData.length}`),{odataQueryResult:a.entityData};if(a.error)return ya.sendTelemetry("ODATA_DOWNLOAD_QUERY_ERRORED",{duration:`${Date.now()-i} ms`}),`${a.error}`}}return Nt("errors.dataNotFetched")}function r4t(e){let t=[];return e.Facets.forEach(r=>{if(r.$Type==="com.sap.vocabularies.UI.v1.ReferenceFacet"&&r.Target.type==="AnnotationPath"){let n=r.Target.value;n.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}else r.$Type==="com.sap.vocabularies.UI.v1.CollectionFacet"&&t.push(...r4t(r))}),t}function QQn(e){if(xu.entityTypeRefFacetCache[e.name])return xu.entityTypeRefFacetCache[e.name];let t=[];return e.annotations?.UI?.Facets?.forEach(r=>{if(r.$Type==="com.sap.vocabularies.UI.v1.ReferenceFacet"&&r.Target?.type==="AnnotationPath"){let n=r.Target.value;n?.lastIndexOf("/")>-1&&t.push(n.substring(0,n.lastIndexOf("/")))}r.$Type==="com.sap.vocabularies.UI.v1.CollectionFacet"&&t.push(...r4t(r))}),xu.entityTypeRefFacetCache[e.name]=t,t??[]}function n4t(e,t="",r=[],n,i){let s={},o=e.navPropEntities;if(o&&o.length>0){let a=e.entityType?QQn(e.entityType):[];for(let u of o){let c=u.entityPath,l=i??e;if(u.entityType?.name===l?.entityType?.name||t.includes(c))continue;let f=t.concat(`${t?"/":""}${c}`);u.navPropEntities&&u.navPropEntities.length>0&&Object.assign(s,n4t(u,f,r,n,i??e).entitySetsFlat);let p={fullPath:f,entity:{entityPath:u.entityPath,entitySetName:u.entitySetName,defaultSelected:a.includes(u.entityPath)||!!n?.includes(f)}},d=`${f}`;r||(r=[]),r.push({name:d,value:p,checked:p.entity.defaultSelected}),s[f]=u.entitySetName}}return{entitySetsFlat:s,choices:r}}function i4t(e,t){let r=t?.map(n=>{let i=n.page?.contextPath??n.page?.routePattern?.replace(":?query:","").replaceAll(/\(\{[^}]*\}\)/g,"");return i?.startsWith(`/${e.entityPath}/`)?i.replace(`/${e.entityPath}/`,""):i}).filter(n=>n!==void 0);if(e.navPropEntities){let n=n4t(e,void 0,void 0,r);return n.choices.sort((i,s)=>(i.name??"").localeCompare(s.name??"")),n}}async function s4t(e,t){let n=(await Co.newInstance(await(0,Z8t.readFile)((0,e4t.join)(e,vt.Ui5Yaml),"utf-8"))).getBackendConfigsFromFioriToolsProxyMiddleware()[0],i;if(n){let s=n.url;if(n.connectPath){let o=n.connectPath.startsWith("/")?n.connectPath:`/${n.connectPath}`;s=new URL(o,n.url).href}i=jr()?n?.destination:await B8t(s,n?.client)}return{servicePath:t.uri,systemName:i}}async function o4t(e){let t=await fL(e.app.appRoot),r=t.getApiVersion(),n=typeof r?.version=="string"?Number.parseInt(r.version,10):0;return n<24?(cr.logger.debug(`@sap/ux-specification from module cache API version is: ${n}. API version '24' at least is required.`),Nt("prompts.appSelection.validation.specficationApiVersionOutdated",{specApiVersion:n})):t}var a4t,ZQn=(...e)=>new Promise(t=>{clearTimeout(a4t),a4t=setTimeout(async()=>t(await t4t(...e)),1e3)}),Ol={appSelection:"appSelection",toggleSelection:"toggleSelection",relatedEntitySelection:"relatedEntitySelection",skipDataDownload:"skipDataDownload",updateMainServiceMetadata:"updateMainServiceMetadata"},eZn=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,u4t=["."];async function c4t(e,t,r){let n=!1;if(!r.referencedEntities?.listEntity.semanticKeys.every((a,u)=>(a.name!=="IsActiveEntity"&&!n&&(n=!!a.value),a.value!==void 0&&a.value!==""||!e[`entityKeyIdx:${u}`]))||!n)return Nt("prompts.skipDataDownload.validation.keyRequired");let s=[];r.relatedEntityChoices?.choices?.length&&(s=e[Ol.relatedEntitySelection]);let o=await ZQn(t,r,s);return o}function tZn(e){return xu.resetServiceCaches(),e.appAccess=void 0,e.referencedEntities=void 0,e.servicePath=void 0,e.systemName&&(e.systemName.value=void 0),e.relatedEntityChoices.choices=[],e.relatedEntityChoices.entitySetsFlat={},e}async function l4t(e){let t=[],r={appAccess:void 0,referencedEntities:void 0,servicePath:void 0,systemName:{value:void 0},connectPath:{value:void 0},relatedEntityChoices:{choices:[],entitySetsFlat:{}}},n=[],i=rZn(r,n,e?.appPath),s=await J$t({datasourceType:{includeNone:!1},systemSelection:{includeCloudFoundryAbapEnvChoice:!1,defaultChoice:r.systemName,connectPath:r.connectPath,hideNewSystem:!0},serviceSelection:{serviceFilter:n,requiredOdataVersion:zn.v4}},Uc()!==un.cli,cr.logger);s.prompts=Ps(s.prompts,()=>!!r.appAccess);let o={odata:[]},a=iZn(r,r.relatedEntityChoices),u=sZn(5,r,s.answers,o),c=nZn(r.relatedEntityChoices,s.answers,r,o);return t.push(i,...s.prompts,aZn(s.answers,r),oZn(s.answers,r),...u,a,c),{questions:t,answers:{application:r,odataQueryResult:o,odataServiceAnswers:s.answers}}}function rZn(e,t,r){return{type:"input",guiType:"folder-browser",name:Ol.appSelection,message:Nt("prompts.appSelection.message"),default:n=>r??n.appSelection??e.appAccess?.app.appRoot,guiOptions:{mandatory:!0,breadcrumb:Nt("prompts.appSelection.breadcrumb")},validate:async n=>{if(!n)return!1;if(n===e.appAccess?.app.appRoot)return!0;t.length=0,tZn(e);let i;try{i=await X5(n)}catch(c){let l=c;return c instanceof Error&&(l=c.message),cr.logger.error(Nt("prompts.appSelection.validation.selectedPathDoesNotContainValidApp",{error:l})),`${Nt("prompts.appSelection.validation.selectedPathDoesNotContainValidApp")}${Nt("texts.seeLogForDetails")}`}let s=i.app.services[i.app.mainService??"mainService"];if(!s?.odataVersion?.startsWith("4."))return Nt("prompts.appSelection.validation.appMainServiceOdataVersionNotSupported",{serviceOdataVersion:s.odataVersion});let o=await o4t(i);if(typeof o=="string")return o;e.appAccess=i,e.specification=o;let{servicePath:a,systemName:u}=await s4t(i.app.appRoot,s);return a&&(e.servicePath=a,t.push(a)),e.systemName&&(e.systemName.value=u),e.connectPath&&(e.connectPath.value=a),!0}}}function nZn(e,t,r,n){let i;return{when:async s=>e.choices.length>0,name:Ol.relatedEntitySelection,type:"checkbox",guiOptions:{applyDefaultWhenDirty:!0},message:Nt("prompts.relatedEntitySelection.message"),choices:()=>e.choices,validate:async(s,o)=>{if(e.choices.forEach(a=>{a.disabled||(a.checked=s.some(u=>u.fullPath===a.value.fullPath))}),o&&!o[Ol.skipDataDownload]?.[0]){if(i=await c4t(o,t,r),typeof i=="string")return i;n.odata=i.odataQueryResult}return!0},additionalMessages:()=>{if(i&&typeof i!="string")return{message:Nt("prompts.skipDataDownload.querySuccess",{count:i.odataQueryResult.length}),severity:gbe.Severity.information}},showOutputTabLink:()=>({show:!!i,linkMessage:Nt("prompts.relatedEntitySelection.openLogs")})}}function iZn(e,t){let r,n,i;return{when:()=>{if((n!==e.systemName?.value||e.servicePath!==r)&&e.referencedEntities?.listEntity){let o=i4t(e.referencedEntities.listEntity,e.referencedEntities.pageObjectEntities);o&&(t.choices=o.choices,Object.assign(t.entitySetsFlat,o.entitySetsFlat)),r=e.servicePath,n=e.systemName?.value}return t.choices.length>0},name:Ol.toggleSelection,type:"confirm",message:Nt("prompts.toggleSelection.message"),labelTrue:Nt("prompts.toggleSelection.labelTrue"),labelFalse:Nt("prompts.toggleSelection.labelFalse"),default:!1,validate:o=>(o!==i&&(t.choices.forEach(a=>{if(a.disabled)return;let u=a.value;a.checked=o===!1?u.entity.defaultSelected:!1}),i=o),!0)}}function sZn(e,t,r,n){let i=[],s,o=0,a=u=>({when:async()=>{let c=t.referencedEntities?.listEntity.semanticKeys[u],l=!!c?.name&&c.name!=="IsActiveEntity";return l&&u>o&&(o=u),l},name:`entityKeyIdx:${u}`,message:()=>Nt("prompts.entityKey.message",{keyName:`${t.referencedEntities?.listEntity.semanticKeys[u]?.name} (${t.referencedEntities?.listEntity.entitySetName})`}),type:"input",guiOptions:{hint:Nt("prompts.entityKey.hint")},validate:async(c,l)=>{let f=t.referencedEntities?.listEntity.semanticKeys[u];if(f&&delete f.value,u4t.includes(c))return Nt("prompts.entityKey.validation.invalidKeyValueChars",{chars:u4t.join()});if(c&&f)if(f.type==="Edm.Boolean")try{f.value=JSON.parse(c)}catch{return Nt("prompts.entityKey.validation.invalidBooleanValue")}else if(["Edm.UUID","Edm.Guid"].includes(f.type)){let d=c.split(",");for(let h of d)if(!eZn.test(h.trim()))return Nt("prompts.entityKey.validation.invalidGuidValue");f.value=c.trim()}else f.value=c.trim();let p=c.split(",");if(f?.type&&!["Edm.UUID","Edm.Guid"].includes(f.type)){for(let d of p)if(d.split("-").length>2)return f&&delete f.value,Nt("prompts.entityKey.validation.invalidRangeSpecified")}if(l&&!t.relatedEntityChoices?.choices?.length&&u===o&&!l[Ol.skipDataDownload]?.[0]&&t.referencedEntities?.listEntity.semanticKeys[u]?.name){if(s=await c4t(l,r,t),typeof s=="string")return s;n.odata=s.odataQueryResult}return!0}});for(let u=0;u<e;u++)i.push(a(u));return i}function oZn(e,t){return{when:()=>!!e.metadata&&!!t.servicePath,name:Ol.skipDataDownload,type:"checkbox",message:Nt("prompts.skipDataDownload.message"),guiOptions:{hint:Nt("prompts.skipDataDownload.hint")},default:!1,choices:[{name:Nt("prompts.skipDataDownload.choiceLabel"),value:"skipDownload",checked:!1}]}}function aZn(e,t){let r;return{when:async()=>t.appAccess&&t.specification&&e?.metadata?(r=await j8t(t.appAccess,t.specification,e.metadata),typeof r=="object"&&(t.referencedEntities=r),!0):!1,name:Ol.updateMainServiceMetadata,type:"confirm",message:Nt("prompts.updateMainServiceMetadata.message"),default:!1,additionalMessages:async()=>{if(typeof r=="string")return{message:r,severity:gbe.Severity.error}}}}function f4t(e){let t=[],r=n=>[{name:`${n.entitySetName}/${n.nodeProperty}/source`,type:"list",message:`Source: ${n.entitySetName} > ${n.missingReferentialConstraints?.navPropName}`,default:!1,choices:n.entityProperties.map(i=>({name:i,value:i}))},{name:`${n.entitySetName}/${n.nodeProperty}/target`,type:"list",message:`Target: ${n.entitySetName} > ${n.missingReferentialConstraints?.navPropName}`,default:!1,choices:n.entityProperties.map(i=>({name:i,value:i}))}];return e.forEach(n=>{!n.parentProperty&&n.missingReferentialConstraints?.navPropName&&t.push(...r(n))}),t}var g4t=Te(Oy()),y4t=Te(Py());var E4t=Te(m4t()),_4t=require("node:path");function v4t(e,t,r){xu.resetExternalServiceCache();let n=bZn(e,t),i=[];return{questions:[{name:"valueHelpSelection",type:"checkbox",message:Nt("prompts.valueHelpSelection.message"),choices:()=>n,validate:async o=>{if(!o||o.length===0)return xu.resetExternalServiceCache(),!0;let a=await TZn(o,r),u=(0,E4t.default)(i,a);return i.length=0,i.push(...u),await SZn(i,r),!0}}],valueHelpData:i}}async function SZn(e,t){let r=[],n={transformResponse:s=>typeof s=="string"?JSON.parse(s):s},i=e.map(async s=>{let o=s,[a]=o.path.split(";");xu.externalServiceRequestCache[a]??=[];let l=(0,g4t.convert)((0,y4t.parse)(s.metadata)).entitySets.map(async f=>{let p=f.name;if(xu.externalServiceRequestCache[a].includes(p))return;xu.externalServiceRequestCache[a].push(p);let d=await t.get((0,_4t.join)(o.path,p),n);o.entityData=o.entityData??[],o.entityData?.push({entitySetName:p,items:d.data.value})});await Promise.allSettled(l),o.entityData&&r.push(o)});return await Promise.allSettled(i),r}async function TZn(e,t){let r=e.flat();return await t.fetchExternalServices(r)}function bZn(e,t){let r=lM(e,t,[]),n={};for(let s of r)if(s.type==="value-list"){if(L8t.includes(s.target))continue;let[o]=s.value.split(";"),a=s.target.split("/").pop();a&&(n[o]??={},n[o][a]??=[],n[o][a].push(s))}else s.type==="code-list"&&(n[s.value]??={},n[s.value]["Code list"]??=[],n[s.value]["Code list"].push(s));let i=[];for(let s of Object.values(n))for(let[o,a]of Object.entries(s)){let u=a.map(c=>{if(c.type==="value-list")return c.target.replace(/\/[^/]*$/,"");if(c.type==="code-list"&&c.collectionPath)return c.collectionPath}).filter(c=>c!==void 0);i.push({name:`${o} (${u.join()})`,value:a})}return i.sort((s,o)=>s.name.localeCompare(o.name))}var cr=class e extends T4t.default{vscode;appWizard;static _logger=f4;generatorVersion=this.rootGeneratorVersion();prompts;setPromptsCallback;state={};constructor(t,r){super(t,{...r,skipInstall:!0},{unique:"namespace"}),p_e(this.env,!0),this.options.force=!0,this.prompts=new P7.Prompts([{description:Nt("steps.odataDownloader.description"),name:Nt("steps.odataDownloader.name")},{description:Nt("steps.valueHelpSelection.description"),name:Nt("steps.valueHelpSelection.name")}]),this.setPromptsCallback=n=>{this.prompts&&this.prompts.setCallback(n)},typeof r.appWizard?.setHeaderTitle=="function"&&r.appWizard.setHeaderTitle(Nt("texts.generatorTitle"),`${this.rootGeneratorName()}@${this.rootGeneratorVersion()}`)}static get logger(){return e._logger}async initializing(){await _ve(),e._logger=this._configureLogging(this.options.logLevel,this.options.logger,this.options.vscode),await ya.initTelemetrySettings(),ya.sendTelemetry("ODATA_DOWNLOADER_STARTED",{startUpTime:Date()})}async prompting(){try{let{answers:{application:t,odataQueryResult:r,odataServiceAnswers:n},questions:i}=await l4t(this.options?.data),s=await this.prompt(i);if(this.state.entityOData=r.odata,this.state.entityPropertyToEntitySet=t.relatedEntityChoices.entitySetsFlat,this.state.appRootPath=t.appAccess?.getAppRoot(),this.state.mainServicePath=n.servicePath,this.state.mainServiceName=t.appAccess?.app.mainService,this.state.appEntities=t.referencedEntities,this.state.appRootPath){this.state.mockServerConfig=await Ax(this.state.appRootPath);let o;this.state.mockServerConfig?.services&&(e.logger.debug(`Mock config: ${JSON.stringify(this.state.mockServerConfig)}`),o=this.state.mockServerConfig.services.find(a=>a.urlPath.replaceAll(/(^\/)|(\/$)/g,"")===this.state.mainServicePath?.replaceAll(/(^\/)|(\/$)/g,""))),this.state.mockDataRootPath=o?.mockdataPath??(0,ZS.join)(oi.Webapp,oi.LocalService,oi.Mockdata)}if(this.state.updateMainServiceMetadata=s[Ol.updateMainServiceMetadata],this.state.mainServiceMetadata=n.metadata,s[Ol.skipDataDownload]?.[0]||await this._promptMissingReferentialConstraints(t,s),n.servicePath&&n.metadata&&n.connectedSystem?.serviceProvider instanceof ja){let{questions:o,valueHelpData:a}=v4t(n.servicePath,n.metadata,n.connectedSystem?.serviceProvider);await this.prompt(o),this.state.valueHelpData=a}}catch(t){e.logger.error(t),this._exitOnError(t)}}async writing(){if(this.state.appRootPath){if(this.state.entityOData&&this.state.entityPropertyToEntitySet&&this.state.appEntities)try{let t=Date.now();ya.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_START",{time:Date()}),this.destinationRoot((0,ZS.join)(this.state.appRootPath));let r=pbe(this.state.entityOData,this.state.entityPropertyToEntitySet,this.state.appEntities.listEntity.entitySetName,this.state.appEntities.hierarchyEntities);e.logger.info(Nt("info.entityFilesToBeGenerated",{entities:Object.keys(r).join(", ")}));let n=Object.entries(r);n.forEach(([i,s])=>{this.writeDestinationJSON((0,ZS.join)(this.state.mockDataRootPath,`${i}.json`),s)}),this.state.appEntities.hierarchyEntities?.filter(i=>i.missingReferentialConstraints&&n.some(([s])=>s===i.entitySetName))?.forEach(i=>{let s=(0,ZS.join)(this.state.mockDataRootPath,`${i.entitySetName}.js`),o=this.destinationPath(s),{navPropName:a,constraints:u}=i.missingReferentialConstraints;if(this.fs.exists(o)){let c=this.fs.read(o),l=$8t(c,a,u);l!==c?(this.writeDestination(s,l),e.logger.info(`Updated referential constraint file: ${i.entitySetName}.js`)):e.logger.debug(`Referential constraint for '${a}' already present in ${i.entitySetName}.js \u2014 skipping`)}else{let c=V8t(a,u);this.writeDestination(s,c),e.logger.info(`Written referential constraint file: ${i.entitySetName}.js`)}}),ya.sendTelemetry("ODATA_DOWNLOADER_WRITE_DATA_FILES_END",{writeFileDuration:`${Date.now()-t} ms`,numberOfFiles:`${n.length}`})}catch(t){e.logger.error(t),ya.sendTelemetry("ODATA_DOWNLOADER_WRITING_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(Nt("info.noServiceEntityData"));if(this.state.valueHelpData?.length)try{let t=Date.now();ya.sendTelemetry("ODATA_DOWNLOADER_WRITE_VALUE_HELP_FILES_START",{time:Date()});let r=(0,ZS.join)(this.state.appRootPath,oi.Webapp);if(await I4(this.fs,r,this.state.valueHelpData,this.state.mainServiceName,this.state.mainServicePath),this.state.mockServerConfig){let n={webappPath:r,packageJsonConfig:{skip:!0},ui5MockYamlConfig:{overwrite:!0}};n.ui5MockYamlConfig&&this.state.mainServiceName&&(n.ui5MockYamlConfig.resolveExternalServiceReferences={[this.state.mainServiceName]:!0},await d4(this.state.appRootPath,n,this.fs))}ya.sendTelemetry("ODATA_DOWNLOADER_WRITE_VALUE_HELP_DATA_FILES_END",{writeFileDuration:`${Date.now()-t} ms`,numberOfExternalServices:`${this.state.valueHelpData.length}`})}catch(t){e.logger.error(t),ya.sendTelemetry("ODATA_DOWNLOADER_WRITING_BALUE_HELP_DATA_ERROR",{writeFileErrorTime:Date()})}else e.logger.info(Nt("info.noValueHelpData"));if(this.state.updateMainServiceMetadata&&this.state.mainServiceMetadata&&this.state.mainServiceName){let t=(0,ZS.join)(this.state.appRootPath,oi.Webapp,oi.LocalService,this.state.mainServiceName,"metadata.xml");this.writeDestination(t,(0,S4t.default)(this.state.mainServiceMetadata,{indent:4}))}}}async _promptMissingReferentialConstraints(t,r){let n=t.referencedEntities?.listEntity.entitySetName,i=new Set([...n?[n]:[],...(r[Ol.relatedEntitySelection]??[]).map(o=>o.entity.entitySetName)]),s=t.referencedEntities?.hierarchyEntities?.filter(o=>!o.parentProperty&&o.missingReferentialConstraints&&i.has(o.entitySetName))??[];if(s.length>0){this.prompts.splice(1,0,[{name:Nt("steps.addConstraints.name"),description:Nt("steps.addConstraints.description")}]);let o=f4t(s),a=await this.prompt(o),u=[t.referencedEntities?.listEntity,...t.referencedEntities?.pageObjectEntities??[]];s.forEach(c=>{let l=a[`${c.entitySetName}/${c.nodeProperty}/source`],f=a[`${c.entitySetName}/${c.nodeProperty}/target`];if(l&&f){c.missingReferentialConstraints.constraints=[{sourceProperty:l,targetProperty:f}],c.parentProperty=l;let p=u.find(d=>d?.entitySetName===c.entitySetName)?.entityType;c.parentPropertyType=p?.entityProperties.find(d=>d.name===l)?.type??"Edm.String"}})}}_exitOnError(t){throw Uc()!==un.cli&&this.appWizard?.showError(t,P7.MessageType.notification),new Error(t)}_configureLogging(t,r,n){let i=new l4(this.rootGeneratorName(),this.log,t,r,n);return i.info(Nt("info.loggingInitialised",{logLevel:i.getLogLevel()})),i}};
|
|
734
734
|
/*! Bundled license information:
|
|
735
735
|
|
|
736
736
|
mime-db/index.js:
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@sap-ux/generator-odata-downloader",
|
|
3
3
|
"displayName": "Fiori Elements Data Downloader",
|
|
4
4
|
"description": "Yeoman generator that supports download of app data, typically for mock data server use.",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.15",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"@sap-ux/axios-extension": "2.0.3",
|
|
48
48
|
"@sap-ux/btp-utils": "2.0.2",
|
|
49
49
|
"@sap-ux/fiori-generator-shared": "1.0.11",
|
|
50
|
-
"@sap-ux/inquirer-common": "1.0.
|
|
50
|
+
"@sap-ux/inquirer-common": "1.0.12",
|
|
51
51
|
"@sap-ux/logger": "1.0.1",
|
|
52
52
|
"@sap-ux/mockserver-config-writer": "1.0.6",
|
|
53
|
-
"@sap-ux/odata-service-inquirer": "3.0.
|
|
54
|
-
"@sap-ux/odata-service-writer": "1.0.
|
|
53
|
+
"@sap-ux/odata-service-inquirer": "3.0.12",
|
|
54
|
+
"@sap-ux/odata-service-writer": "1.0.7",
|
|
55
55
|
"@sap-ux/project-access": "2.1.2",
|
|
56
56
|
"@sap-ux/store": "2.0.1",
|
|
57
57
|
"@sap-ux/telemetry": "1.0.9",
|