UNPKG

@sap/generator-fiori

Version:

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

1 lines 5.68 kB
"use strict";exports.id=307,exports.ids=[307,2688],exports.modules={3082(t,e,n){e.rangeAt=e.getLineOffsets=e.TextEdit=e.Range=void 0;var a=n(22395);Object.defineProperty(e,"Range",{enumerable:!0,get:function(){return a.Range}}),Object.defineProperty(e,"TextEdit",{enumerable:!0,get:function(){return a.TextEdit}});var o=n(79811);Object.defineProperty(e,"getLineOffsets",{enumerable:!0,get:function(){return o.getLineOffsets}});var r=n(7479);var s=n(56447);Object.defineProperty(e,"rangeAt",{enumerable:!0,get:function(){return s.rangeAt}});var i=n(59423)},69308(t,e,n){n.d(e,{e:()=>AnnotationsWriter});var a=n(76760),o=n(63011),r=n(81001);class AnnotationsWriter{fs;projectPath;templatesPath;constructor(t,e,n){this.fs=t,this.projectPath=e,this.templatesPath=n}constructContent(t){const{variant:{layer:e},annotation:{dataSource:n,fileName:a}}=t,r=a?.toLocaleLowerCase().replace(".xml",""),s=e===o.$m.CUSTOMER_BASE?`customer.annotation.${r}`:`annotation.${r}`;return{dataSourceId:`${n}`,annotations:[s],annotationsInsertPosition:"END",dataSource:{[s]:{uri:`annotations/${a}`,type:"ODataAnnotation"}}}}getAnnotationFileName({annotation:t}){return t.filePath?a.basename(t.filePath):`annotation_${Date.now()}.xml`}async write(t){const{variant:e,annotation:n}=t;n.fileName=n.fileName??this.getAnnotationFileName(t),n.filePath&&(n.filePath=(0,a.isAbsolute)(n.filePath)?n.filePath:a.join(this.projectPath,n.filePath));const s=this.constructContent(t),i=Date.now();let c;t.isCommand&&(c=(0,r.VV)(e,i,s,o.JQ.ADD_ANNOTATIONS_TO_ODATA)),await(0,r.TD)(this.projectPath,i,t.annotation,c,this.fs,this.templatesPath)}}},67559(t,e,n){n.d(e,{p:()=>ComponentUsagesWriter});var a=n(63011),o=n(81001);class ComponentUsagesWriter{fs;projectPath;constructor(t,e){this.fs=t,this.projectPath=e}constructContent({component:t}){const{data:e,usageId:n,settings:a,isLazy:r,name:s}=t;return{componentUsages:{[n]:{name:s,lazy:"true"===r,settings:(0,o.bG)(a),componentData:(0,o.bG)(e)}}}}constructLibContent({library:t}){const{reference:e,referenceIsLazy:n}=t;return{libraries:{[e]:{lazy:"true"===n}}}}async write(t){const e=this.constructContent(t),n=Date.now(),r=(0,o.VV)(t.variant,n,e,a.JQ.ADD_COMPONENT_USAGES);if(await(0,o.LR)(this.projectPath,r,this.fs),!("library"in t))return;const s=this.constructLibContent(t),i=n+1,c=(0,o.VV)(t.variant,i,s,a.JQ.ADD_LIBRARY_REFERENCE);await(0,o.LR)(this.projectPath,c,this.fs)}}},89471(t,e,n){n.d(e,{L:()=>DataSourceWriter});var a=n(63011),o=n(81001);class DataSourceWriter{fs;projectPath;constructor(t,e){this.fs=t,this.projectPath=e}constructContent(t,e,n){const a={dataSourceId:t,entityPropertyChange:[{propertyPath:"uri",operation:"UPDATE",propertyValue:e}]};return n&&a.entityPropertyChange.push({propertyPath:"settings/maxAge",operation:"UPSERT",propertyValue:Number(n)}),a}async write(t){const{variant:e,dataSources:n,service:r}=t,{id:s,uri:i,maxAge:c,annotationUri:h}=r,u=n[s].settings?.annotations?.[0],p=Date.now(),l=this.constructContent(s,i,c),d=(0,o.VV)(e,p,l,a.JQ.CHANGE_DATA_SOURCE);if(await(0,o.LR)(this.projectPath,d,this.fs),u&&h){const t=this.constructContent(u,h),n=p+1,r=(0,o.VV)(e,n,t,a.JQ.CHANGE_DATA_SOURCE);await(0,o.LR)(this.projectPath,r,this.fs)}}}},93494(t,e,n){n.d(e,{h:()=>InboundWriter});var a=n(63011),o=n(81001);class InboundWriter{fs;projectPath;constructor(t,e){this.fs=t,this.projectPath=e}constructContent(t){const e={inboundId:t.inboundId,entityPropertyChange:[]};return this.getEnhancedContent(t,e),e}getEnhancedContent(t,e){const{icon:n,title:a,subtitle:r}=t.flp;a&&e.entityPropertyChange.push({propertyPath:"title",operation:"UPSERT",propertyValue:(0,o.qQ)(a)}),r&&e.entityPropertyChange.push({propertyPath:"subTitle",operation:"UPSERT",propertyValue:(0,o.qQ)(r)}),n&&e.entityPropertyChange.push({propertyPath:"icon",operation:"UPSERT",propertyValue:(0,o.qQ)(n)})}async write(t){const{changeWithInboundId:e,filePath:n}=await(0,o.ev)(this.projectPath,t.inboundId,this.fs),r=Date.now();if(e)e.content&&this.getEnhancedContent(t,e.content),(0,o.FF)(n,e,this.fs);else{const e=this.constructContent(t),n=(0,o.VV)(t.variant,r,e,a.JQ.CHANGE_INBOUND);await(0,o.LR)(this.projectPath,n,this.fs)}}}},32743(t,e,n){n.d(e,{h:()=>NewModelWriter});var a=n(76760),o=n(19563),r=n(63011),s=n(81001),i=n(18201),c=n(61869);class NewModelWriter{fs;projectPath;constructor(t,e){this.fs=t,this.projectPath=e}constructContent(t){const{service:e,isCloudFoundry:n,serviceType:a}=t,o=a===r.C0.HTTP,i={uri:n?`${e.name.replaceAll(".","/")}${e.uri}`:e.uri,type:o?"http":"OData",settings:{}};e.version&&(i.settings.odataVersion=e.version);const c={dataSource:{[e.name]:i}};if(!o&&e.modelName&&(c.model={[e.modelName]:{dataSource:e.name,...e.modelSettings?.length?{settings:(0,s.bG)(e.modelSettings)}:{}}}),"annotation"in t){const{annotation:n}=t;c.dataSource[e.name].settings.annotations=[`${n.dataSourceName}`],c.dataSource[n.dataSourceName]={uri:n.dataSourceURI,type:"ODataAnnotation"},n.settings&&0!==n.settings.length&&(c.dataSource[n.dataSourceName].settings=(0,s.bG)(n.settings))}return c}async write(t){const e=Date.now(),n=t.serviceType===r.C0.HTTP,h=this.constructContent(t),u=(0,s.VV)(t.variant,e,h,n?r.JQ.ADD_NEW_DATA_SOURCE:r.JQ.ADD_NEW_MODEL);await(0,s.LR)(this.projectPath,u,this.fs),t.isCloudFoundry&&this.writeXsAppRoute(t),t.isOnPremiseDestination&&(await(0,i.Vs)((0,a.dirname)(this.projectPath),this.fs),await(0,c.Ep)(c.vt,t.logger??new o.ToolsLogger))}writeXsAppRoute(t){const e=(0,a.join)(this.projectPath,"webapp","xs-app.json"),n={source:`^/${t.service.name.replaceAll(".","/")}${t.service.uri}(.*)`,target:`${t.service.uri}$1`,destination:t.destinationName},o=this.fs.readJSON(e,{routes:[]});o.routes.push(n),this.fs.writeJSON(e,o)}}}};