@fern-api/csharp-dynamic-snippets 0.0.4 → 0.0.5

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.
Files changed (27) hide show
  1. package/cjs/index.cjs +17 -20
  2. package/cjs/index.cjs.map +1 -1
  3. package/esm/DynamicSnippetsGenerator.js +1 -1
  4. package/esm/EndpointSnippetGenerator.js +1 -1
  5. package/esm/{chunk-SAYITSWL.js → chunk-4O5TI5LE.js} +2 -2
  6. package/esm/{chunk-ZDZZCKFB.js → chunk-7QB2DXDM.js} +3 -3
  7. package/esm/{chunk-ZDZZCKFB.js.map → chunk-7QB2DXDM.js.map} +1 -1
  8. package/esm/{chunk-MM7AFFVF.js → chunk-CQ47NT5H.js} +2 -2
  9. package/esm/{chunk-F3KILROP.js → chunk-GZ2J5EKE.js} +2 -2
  10. package/esm/{chunk-GQKEVSN5.js → chunk-JXQ2W4OZ.js} +2 -2
  11. package/esm/{chunk-CDMZ2O62.js → chunk-PRGD7S35.js} +2 -2
  12. package/esm/{chunk-PBYJXQQK.js → chunk-U2GJA4AT.js} +2 -2
  13. package/esm/{chunk-D2D544ZS.js → chunk-WMO2ROQ4.js} +2 -2
  14. package/esm/context/DynamicSnippetsGeneratorContext.js +1 -1
  15. package/esm/context/DynamicTypeLiteralMapper.js +1 -1
  16. package/esm/context/DynamicTypeMapper.js +1 -1
  17. package/esm/context/FilePropertyMapper.js +1 -1
  18. package/esm/index.js +1 -4
  19. package/esm/index.js.map +1 -1
  20. package/package.json +1 -1
  21. /package/esm/{chunk-SAYITSWL.js.map → chunk-4O5TI5LE.js.map} +0 -0
  22. /package/esm/{chunk-MM7AFFVF.js.map → chunk-CQ47NT5H.js.map} +0 -0
  23. /package/esm/{chunk-F3KILROP.js.map → chunk-GZ2J5EKE.js.map} +0 -0
  24. /package/esm/{chunk-GQKEVSN5.js.map → chunk-JXQ2W4OZ.js.map} +0 -0
  25. /package/esm/{chunk-CDMZ2O62.js.map → chunk-PRGD7S35.js.map} +0 -0
  26. /package/esm/{chunk-PBYJXQQK.js.map → chunk-U2GJA4AT.js.map} +0 -0
  27. /package/esm/{chunk-D2D544ZS.js.map → chunk-WMO2ROQ4.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-GQKEVSN5.js";import"./chunk-SAYITSWL.js";import"./chunk-PBYJXQQK.js";import"./chunk-CDMZ2O62.js";import"./chunk-D2D544ZS.js";import"./chunk-F3KILROP.js";import"./chunk-MM7AFFVF.js";import"./chunk-ZDZZCKFB.js";export{a as DynamicSnippetsGenerator};
1
+ import{a}from"./chunk-JXQ2W4OZ.js";import"./chunk-4O5TI5LE.js";import"./chunk-U2GJA4AT.js";import"./chunk-PRGD7S35.js";import"./chunk-WMO2ROQ4.js";import"./chunk-GZ2J5EKE.js";import"./chunk-CQ47NT5H.js";import"./chunk-7QB2DXDM.js";export{a as DynamicSnippetsGenerator};
2
2
  //# sourceMappingURL=DynamicSnippetsGenerator.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-SAYITSWL.js";import"./chunk-D2D544ZS.js";import"./chunk-ZDZZCKFB.js";export{a as EndpointSnippetGenerator};
1
+ import{a}from"./chunk-4O5TI5LE.js";import"./chunk-WMO2ROQ4.js";import"./chunk-7QB2DXDM.js";export{a as EndpointSnippetGenerator};
2
2
  //# sourceMappingURL=EndpointSnippetGenerator.js.map
@@ -1,4 +1,4 @@
1
- import{b as d,d as R,e as i}from"./chunk-D2D544ZS.js";import{a as b,b as v,h as w,i as m,k as A,l as F,m as q}from"./chunk-ZDZZCKFB.js";var ke=typeof global=="object"&&global&&global.Object===Object&&global,E=ke;var Me=typeof self=="object"&&self&&self.Object===Object&&self,Ue=E||Me||Function("return this")(),k=Ue;var We=k.Symbol,p=We;var M=Object.prototype,je=M.hasOwnProperty,De=M.toString,h=p?p.toStringTag:void 0;function Ve(r){var s=je.call(r,h),e=r[h];try{r[h]=void 0;var t=!0}catch(o){}var a=De.call(r);return t&&(s?r[h]=e:delete r[h]),a}var U=Ve;var ze=Object.prototype,He=ze.toString;function Ge(r){return He.call(r)}var W=Ge;var Ze="[object Null]",Je="[object Undefined]",j=p?p.toStringTag:void 0;function Ke(r){return r==null?r===void 0?Je:Ze:j&&j in Object(r)?U(r):W(r)}var D=Ke;function _e(r){return r!=null&&typeof r=="object"}var V=_e;var $e="[object Symbol]";function Ye(r){return typeof r=="symbol"||V(r)&&D(r)==$e}var z=Ye;function Qe(r,s){for(var e=-1,t=r==null?0:r.length,a=Array(t);++e<t;)a[e]=s(r[e],e,r);return a}var H=Qe;var Xe=Array.isArray,G=Xe;var et=1/0,Z=p?p.prototype:void 0,J=Z?Z.toString:void 0;function K(r){if(typeof r=="string")return r;if(G(r))return H(r,K)+"";if(z(r))return J?J.call(r):"";var s=r+"";return s=="0"&&1/r==-et?"-0":s}var _=K;function tt(r){return r==null?"":_(r)}var l=tt;function rt(r,s,e){var t=-1,a=r.length;s<0&&(s=-s>a?0:a+s),e=e>a?a:e,e<0&&(e+=a),a=s>e?0:e-s>>>0,s>>>=0;for(var o=Array(a);++t<a;)o[t]=r[t+s];return o}var $=rt;function at(r,s,e){var t=r.length;return e=e===void 0?t:e,!s&&e>=t?r:$(r,s,e)}var Y=at;var ot="\\ud800-\\udfff",st="\\u0300-\\u036f",nt="\\ufe20-\\ufe2f",ft="\\u20d0-\\u20ff",ut=st+nt+ft,it="\\ufe0e\\ufe0f",pt="\\u200d",dt=RegExp("["+pt+ot+ut+it+"]");function lt(r){return dt.test(r)}var I=lt;function mt(r){return r.split("")}var Q=mt;var X="\\ud800-\\udfff",ct="\\u0300-\\u036f",xt="\\ufe20-\\ufe2f",ht="\\u20d0-\\u20ff",yt=ct+xt+ht,gt="\\ufe0e\\ufe0f",bt="["+X+"]",S="["+yt+"]",P="\\ud83c[\\udffb-\\udfff]",vt="(?:"+S+"|"+P+")",ee="[^"+X+"]",te="(?:\\ud83c[\\udde6-\\uddff]){2}",re="[\\ud800-\\udbff][\\udc00-\\udfff]",Rt="\\u200d",ae=vt+"?",oe="["+gt+"]?",At="(?:"+Rt+"(?:"+[ee,te,re].join("|")+")"+oe+ae+")*",It=oe+ae+At,Ct="(?:"+[ee+S+"?",S,te,re,bt].join("|")+")",Ft=RegExp(P+"(?="+P+")|"+Ct+It,"g");function St(r){return r.match(Ft)||[]}var se=St;function Pt(r){return I(r)?se(r):Q(r)}var ne=Pt;function Tt(r){return function(s){s=l(s);var e=I(s)?ne(s):void 0,t=e?e[0]:s.charAt(0),a=e?Y(e,1).join(""):s.slice(1);return t[r]()+a}}var fe=Tt;var Bt=fe("toUpperCase"),y=Bt;function Lt(r){return y(l(r).toLowerCase())}var ue=Lt;function Ot(r,s,e,t){var a=-1,o=r==null?0:r.length;for(t&&o&&(e=r[++a]);++a<o;)e=s(e,r[a],a,r);return e}var ie=Ot;function Nt(r){return function(s){return r==null?void 0:r[s]}}var pe=Nt;var wt={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},qt=pe(wt),de=qt;var Et=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,kt="\\u0300-\\u036f",Mt="\\ufe20-\\ufe2f",Ut="\\u20d0-\\u20ff",Wt=kt+Mt+Ut,jt="["+Wt+"]",Dt=RegExp(jt,"g");function Vt(r){return r=l(r),r&&r.replace(Et,de).replace(Dt,"")}var le=Vt;var zt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Ht(r){return r.match(zt)||[]}var me=Ht;var Gt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Zt(r){return Gt.test(r)}var ce=Zt;var be="\\ud800-\\udfff",Jt="\\u0300-\\u036f",Kt="\\ufe20-\\ufe2f",_t="\\u20d0-\\u20ff",$t=Jt+Kt+_t,ve="\\u2700-\\u27bf",Re="a-z\\xdf-\\xf6\\xf8-\\xff",Yt="\\xac\\xb1\\xd7\\xf7",Qt="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Xt="\\u2000-\\u206f",er=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ae="A-Z\\xc0-\\xd6\\xd8-\\xde",tr="\\ufe0e\\ufe0f",Ie=Yt+Qt+Xt+er,Ce="['\u2019]",xe="["+Ie+"]",rr="["+$t+"]",Fe="\\d+",ar="["+ve+"]",Se="["+Re+"]",Pe="[^"+be+Ie+Fe+ve+Re+Ae+"]",or="\\ud83c[\\udffb-\\udfff]",sr="(?:"+rr+"|"+or+")",nr="[^"+be+"]",Te="(?:\\ud83c[\\udde6-\\uddff]){2}",Be="[\\ud800-\\udbff][\\udc00-\\udfff]",x="["+Ae+"]",fr="\\u200d",he="(?:"+Se+"|"+Pe+")",ur="(?:"+x+"|"+Pe+")",ye="(?:"+Ce+"(?:d|ll|m|re|s|t|ve))?",ge="(?:"+Ce+"(?:D|LL|M|RE|S|T|VE))?",Le=sr+"?",Oe="["+tr+"]?",ir="(?:"+fr+"(?:"+[nr,Te,Be].join("|")+")"+Oe+Le+")*",pr="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",dr="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",lr=Oe+Le+ir,mr="(?:"+[ar,Te,Be].join("|")+")"+lr,cr=RegExp([x+"?"+Se+"+"+ye+"(?="+[xe,x,"$"].join("|")+")",ur+"+"+ge+"(?="+[xe,x+he,"$"].join("|")+")",x+"?"+he+"+"+ye,x+"+"+ge,dr,pr,Fe,mr].join("|"),"g");function xr(r){return r.match(cr)||[]}var Ne=xr;function hr(r,s,e){return r=l(r),s=e?void 0:s,s===void 0?ce(r)?Ne(r):me(r):r.match(s)||[]}var we=hr;var yr="['\u2019]",gr=RegExp(yr,"g");function br(r){return function(s){return ie(we(le(s).replace(gr,"")),r,"")}}var qe=br;var vr=qe(function(r,s,e){return s=s.toLowerCase(),r+(e?ue(s):s)}),T=vr;var Ee=class extends q{constructor({context:e}){super(e);w(this,"context");this.context=e}async generateSnippet({endpoint:e,request:t,options:a}){return this.buildCodeBlock({endpoint:e,snippet:t,options:a}).toString({namespace:"Usage",generation:this.generation,allNamespaceSegments:new Set,allTypeClassReferences:new Map})}generateSnippetSync({endpoint:e,request:t,options:a}){return this.buildCodeBlock({endpoint:e,snippet:t,options:a}).toString({namespace:"Usage",generation:this.generation,allNamespaceSegments:new Set,allTypeClassReferences:new Map})}buildCodeBlock({endpoint:e,snippet:t,options:a}){var f;if(e.examples&&!((f=e.examples)!=null&&f.find(u=>A.DynamicIR.EndpointExample(t)&&u.id===t.id)))throw new Error("Endpoint does not have an example that matches the snippet");let o=this.csharp.codeblock(u=>{u.writeNodeStatement(this.constructClient({endpoint:e,snippet:t})),u.newLine(),u.writeNodeStatement(this.callMethod({endpoint:e,snippet:t}))}),n=this.getStyle(a);switch(n){case R.Concise:return o;case R.Full:return this.buildFullCodeBlock({body:o,options:a});default:m(n)}}buildFullCodeBlock({body:e,options:t}){var n;let a=this.getConfig(t),o=this.csharp.class_({name:(n=a.fullStyleClassName)!=null?n:"Example",namespace:"Usage",access:F.Access.Public});return o.addNamespaceReference(this.types.RootClient.namespace),o.addMethod({name:"Do",access:F.Access.Public,isAsync:!0,parameters:[],body:e}),o}constructClient({endpoint:e,snippet:t}){return this.csharp.codeblock(a=>{a.write("var client = "),a.writeNode(this.getRootClientConstructorInvocation(this.getConstructorArgs({endpoint:e,snippet:t})))})}callMethod({endpoint:e,snippet:t}){var n,f;let a=((n=e.response)==null?void 0:n.type)==="streaming"||((f=e.response)==null?void 0:f.type)==="streamParameter",o=this.csharp.invokeMethod({on:this.csharp.codeblock("client"),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t}),async:!0,configureAwait:!0,multiline:!0,isAsyncEnumerable:a});return a?this.csharp.codeblock(u=>{u.write("await foreach (var item in "),u.writeNode(o),u.writeLine(")"),u.pushScope(),u.writeLine("/* consume each item */"),u.popScope()}):o}getConstructorArgs({endpoint:e,snippet:t}){let a=[];e.auth!=null&&(t.auth!=null?a.push(...this.getConstructorAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:d.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`}));let o=[],n=this.getConstructorBaseUrlArgs({baseUrl:t.baseURL,environment:t.environment});n.length>0&&o.push(...n),this.context.errors.scope(i.Headers);let f=[];return this.context.ir.headers!=null&&t.headers!=null&&f.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope(),o.length===0?[...a,...f]:[...a,...f,{name:"clientOptions",assignment:this.csharp.instantiateClass({classReference:this.types.ClientOptions,arguments_:o.map(u=>({name:u.name,assignment:u.assignment})),multiline:!0})}]}getConstructorBaseUrlArgs({baseUrl:e,environment:t}){let a=this.getBaseUrlArg({baseUrl:e,environment:t});return A.TypeLiteral.nop(a)?[]:[{name:this.getBaseUrlOptionName(),assignment:a}]}getBaseUrlArg({baseUrl:e,environment:t}){var a;if(e!=null&&t!=null)return this.context.errors.add({severity:d.Critical,message:"Cannot specify both baseUrl and environment options"}),this.csharp.TypeLiteral.nop();if(e!=null)return((a=this.context.ir.environments)==null?void 0:a.environments.type)==="multipleBaseUrls"?(this.context.errors.add({severity:d.Critical,message:"The C# SDK doesn't support a baseUrl when multiple URL environments are configured"}),this.csharp.TypeLiteral.nop()):this.csharp.TypeLiteral.string(e);if(t!=null){if(this.context.isSingleEnvironmentID(t)){let o=this.context.getEnvironmentTypeReferenceFromID(t);return o==null?(this.context.errors.add({severity:d.Warning,message:`Environment ${JSON.stringify(t)} was not found`}),this.csharp.TypeLiteral.nop()):this.csharp.TypeLiteral.reference(o)}if(this.context.isMultiEnvironmentValues(t))return this.context.validateMultiEnvironmentUrlValues(t)?this.csharp.TypeLiteral.reference(this.csharp.instantiateClass({classReference:this.types.Environments,arguments_:Object.entries(t).map(([o,n])=>({name:y(T(o)),assignment:this.context.dynamicTypeLiteralMapper.convert({typeReference:{type:"primitive",value:"STRING"},value:n})})),multiline:!0})):this.csharp.TypeLiteral.nop()}return this.csharp.TypeLiteral.nop()}getConstructorAuthArgs({auth:e,values:t}){if(t.type!==e.type)return this.addError(this.context.newAuthMismatchError({auth:e,values:t}).message),[];switch(e.type){case"basic":return t.type==="basic"?this.getConstructorBasicAuthArg({auth:e,values:t}):[];case"bearer":return t.type==="bearer"?this.getConstructorBearerAuthArgs({auth:e,values:t}):[];case"header":return t.type==="header"?this.getConstructorHeaderAuthArgs({auth:e,values:t}):[];case"oauth":return t.type==="oauth"?this.getConstructorOAuthArgs({auth:e,values:t}):[];case"inferred":return this.addWarning("The C# SDK Generator does not support Inferred auth scheme yet"),[];default:m(e)}}addError(e){this.context.errors.add({severity:d.Critical,message:e})}addWarning(e){this.context.errors.add({severity:d.Warning,message:e})}getConstructorBasicAuthArg({auth:e,values:t}){return[{name:this.context.getParameterName(e.username),assignment:this.csharp.TypeLiteral.string(t.username)},{name:this.context.getParameterName(e.password),assignment:this.csharp.TypeLiteral.string(t.password)}]}getConstructorBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getParameterName(e.token),assignment:this.csharp.TypeLiteral.string(t.token)}]}getConstructorHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getParameterName(e.header.name.name),assignment:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value,fallbackToDefault:e.header.name.wireValue})}]}getConstructorOAuthArgs({auth:e,values:t}){return[{name:this.context.getParameterName(e.clientId),assignment:this.csharp.TypeLiteral.string(t.clientId)},{name:this.context.getParameterName(e.clientSecret),assignment:this.csharp.TypeLiteral.string(t.clientSecret)}]}getConstructorHeaderArgs({headers:e,values:t}){let a=[];for(let o of e){let n=this.getConstructorHeaderArg({header:o,value:t.value});n!=null&&a.push({name:this.context.getParameterName(o.name.name),assignment:n})}return a}getConstructorHeaderArg({header:e,value:t}){let a=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t,fallbackToDefault:e.name.wireValue});if(!A.TypeLiteral.nop(a))return a}getMethodArgs({endpoint:e,snippet:t}){switch(e.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:e.request,snippet:t});case"body":return this.getMethodArgsForBodyRequest({request:e.request,snippet:t});default:m(e.request)}}getMethodArgsForInlinedRequest({request:e,snippet:t}){var u,g;let a=[];this.context.errors.scope(i.PathParameters);let o=[],n=[...(u=this.context.ir.pathParameters)!=null?u:[],...(g=e.pathParameters)!=null?g:[]];n.length>0&&o.push(...this.getPathParameters({namedParameters:n,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(i.RequestBody);let f=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:this.settings.shouldInlinePathParameters})||a.push(...o.map(C=>C.value)),a.push(this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:this.settings.shouldInlinePathParameters})?o:[],filePropertyInfo:f})),a}getFilePropertyInfo({request:e,snippet:t}){return e.body==null||!this.context.isFileUploadRequestBody(e.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:e.body,value:t.requestBody})}getInlinedRequestArg({request:e,snippet:t,pathParameterFields:a,filePropertyInfo:o}){var B,L,O,N;this.context.errors.scope(i.QueryParameters);let f=this.context.associateQueryParametersByWireValue({parameters:(B=e.queryParameters)!=null?B:[],values:(L=t.queryParameters)!=null?L:{}}).map(c=>({name:this.context.getPropertyName(c.name.name),value:this.context.dynamicTypeLiteralMapper.convert(c)}));this.context.errors.unscope(),this.context.errors.scope(i.Headers);let g=this.context.associateByWireValue({parameters:(O=e.headers)!=null?O:[],values:(N=t.headers)!=null?N:{}}).map(c=>({name:this.context.getPropertyName(c.name.name),value:this.context.dynamicTypeLiteralMapper.convert(v(b({},c),{fallbackToDefault:c.name.wireValue}))}));this.context.errors.unscope(),this.context.errors.scope(i.RequestBody);let C=e.body!=null?this.getInlinedRequestBodyConstructorFields({body:e.body,value:t.requestBody,filePropertyInfo:o}):[];return this.context.errors.unscope(),this.csharp.TypeLiteral.class_({reference:this.csharp.classReference({origin:e.declaration,namespace:this.context.getNamespace(e.declaration.fernFilepath)}),fields:[...a,...f,...g,...C]})}getInlinedRequestBodyConstructorFields({body:e,value:t,filePropertyInfo:a}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyConstructorFields({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyConstructorField({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyConstructorFields({filePropertyInfo:a});default:m(e)}}getInlinedRequestBodyPropertyConstructorFields({parameters:e,value:t}){var n;let a=[],o=this.context.associateByWireValue({parameters:e,values:(n=this.context.getRecord(t))!=null?n:{}});for(let f of o)a.push({name:this.context.getPropertyName(f.name.name),value:this.context.dynamicTypeLiteralMapper.convert(v(b({},f),{fallbackToDefault:f.name.wireValue}))});return a}getFileUploadRequestBodyConstructorFields({filePropertyInfo:e}){return[...e.fileFields,...e.bodyPropertyFields]}getReferencedRequestBodyPropertyConstructorField({body:e,value:t}){return{name:this.context.getPropertyName(e.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:e.bodyType,value:t})}}getReferencedRequestBodyPropertyTypeLiteral({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t,fallbackToDefault:JSON.stringify(e.value)});default:m(e)}}getMethodArgsForBodyRequest({request:e,snippet:t}){var n,f;let a=[];this.context.errors.scope(i.PathParameters);let o=[...(n=this.context.ir.pathParameters)!=null?n:[],...(f=e.pathParameters)!=null?f:[]];return o.length>0&&a.push(...this.getPathParameters({namedParameters:o,snippet:t}).map(u=>u.value)),this.context.errors.unscope(),this.context.errors.scope(i.RequestBody),e.body!=null&&a.push(this.getBodyRequestArg({body:e.body,value:t.requestBody})),this.context.errors.unscope(),a}getBodyRequestArg({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return e.value.type==="optional"&&t==null?this.csharp.TypeLiteral.null():this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t,fallbackToDefault:JSON.stringify(e.value)});default:m(e)}}getBytesBodyRequestArg({value:e}){let t=this.context.getValueAsString({value:e});return t==null&&(this.context.errors.add({severity:d.Critical,message:"The bytes request body must be provided in string format"}),t="[bytes]"),this.csharp.TypeLiteral.reference(this.context.getMemoryStreamForString(t))}getRootClientConstructorInvocation(e){return this.csharp.instantiateClass({classReference:this.types.RootClient,arguments_:e,forceUseConstructor:!0,multiline:!0})}getPathParameters({namedParameters:e,snippet:t}){var n;let a=[],o=this.context.associateByWireValueOrDefault({parameters:e,values:(n=t.pathParameters)!=null?n:{}});for(let f of o)a.push({name:this.context.getPropertyName(f.name.name),value:this.context.dynamicTypeLiteralMapper.convert(v(b({},f),{fallbackToDefault:f.name.wireValue}))});return a}getMethod({endpoint:e}){return e.declaration.fernFilepath.allParts.length>0?`${e.declaration.fernFilepath.allParts.map(t=>this.context.getClassName(t)).join(".")}.${this.context.getMethodName(e.declaration.name)}`:this.context.getMethodName(e.declaration.name)}getBaseUrlOptionName(){var e;return((e=this.context.ir.environments)==null?void 0:e.environments.type)==="multipleBaseUrls"?"Environment":"BaseUrl"}getStyle(e){var t,a;return(a=(t=e.style)!=null?t:this.context.options.style)!=null?a:R.Full}getConfig(e){var t,a;return(a=(t=e.config)!=null?t:this.context.options.config)!=null?a:{}}};export{Ee as a};
1
+ import{b as d,d as R,e as i}from"./chunk-WMO2ROQ4.js";import{a as b,b as v,e as w,f as m,h as A,i as F,j as q}from"./chunk-7QB2DXDM.js";var ke=typeof global=="object"&&global&&global.Object===Object&&global,E=ke;var Me=typeof self=="object"&&self&&self.Object===Object&&self,Ue=E||Me||Function("return this")(),k=Ue;var We=k.Symbol,p=We;var M=Object.prototype,je=M.hasOwnProperty,De=M.toString,h=p?p.toStringTag:void 0;function Ve(r){var s=je.call(r,h),e=r[h];try{r[h]=void 0;var t=!0}catch(o){}var a=De.call(r);return t&&(s?r[h]=e:delete r[h]),a}var U=Ve;var ze=Object.prototype,He=ze.toString;function Ge(r){return He.call(r)}var W=Ge;var Ze="[object Null]",Je="[object Undefined]",j=p?p.toStringTag:void 0;function Ke(r){return r==null?r===void 0?Je:Ze:j&&j in Object(r)?U(r):W(r)}var D=Ke;function _e(r){return r!=null&&typeof r=="object"}var V=_e;var $e="[object Symbol]";function Ye(r){return typeof r=="symbol"||V(r)&&D(r)==$e}var z=Ye;function Qe(r,s){for(var e=-1,t=r==null?0:r.length,a=Array(t);++e<t;)a[e]=s(r[e],e,r);return a}var H=Qe;var Xe=Array.isArray,G=Xe;var et=1/0,Z=p?p.prototype:void 0,J=Z?Z.toString:void 0;function K(r){if(typeof r=="string")return r;if(G(r))return H(r,K)+"";if(z(r))return J?J.call(r):"";var s=r+"";return s=="0"&&1/r==-et?"-0":s}var _=K;function tt(r){return r==null?"":_(r)}var l=tt;function rt(r,s,e){var t=-1,a=r.length;s<0&&(s=-s>a?0:a+s),e=e>a?a:e,e<0&&(e+=a),a=s>e?0:e-s>>>0,s>>>=0;for(var o=Array(a);++t<a;)o[t]=r[t+s];return o}var $=rt;function at(r,s,e){var t=r.length;return e=e===void 0?t:e,!s&&e>=t?r:$(r,s,e)}var Y=at;var ot="\\ud800-\\udfff",st="\\u0300-\\u036f",nt="\\ufe20-\\ufe2f",ft="\\u20d0-\\u20ff",ut=st+nt+ft,it="\\ufe0e\\ufe0f",pt="\\u200d",dt=RegExp("["+pt+ot+ut+it+"]");function lt(r){return dt.test(r)}var I=lt;function mt(r){return r.split("")}var Q=mt;var X="\\ud800-\\udfff",ct="\\u0300-\\u036f",xt="\\ufe20-\\ufe2f",ht="\\u20d0-\\u20ff",yt=ct+xt+ht,gt="\\ufe0e\\ufe0f",bt="["+X+"]",S="["+yt+"]",P="\\ud83c[\\udffb-\\udfff]",vt="(?:"+S+"|"+P+")",ee="[^"+X+"]",te="(?:\\ud83c[\\udde6-\\uddff]){2}",re="[\\ud800-\\udbff][\\udc00-\\udfff]",Rt="\\u200d",ae=vt+"?",oe="["+gt+"]?",At="(?:"+Rt+"(?:"+[ee,te,re].join("|")+")"+oe+ae+")*",It=oe+ae+At,Ct="(?:"+[ee+S+"?",S,te,re,bt].join("|")+")",Ft=RegExp(P+"(?="+P+")|"+Ct+It,"g");function St(r){return r.match(Ft)||[]}var se=St;function Pt(r){return I(r)?se(r):Q(r)}var ne=Pt;function Tt(r){return function(s){s=l(s);var e=I(s)?ne(s):void 0,t=e?e[0]:s.charAt(0),a=e?Y(e,1).join(""):s.slice(1);return t[r]()+a}}var fe=Tt;var Bt=fe("toUpperCase"),y=Bt;function Lt(r){return y(l(r).toLowerCase())}var ue=Lt;function Ot(r,s,e,t){var a=-1,o=r==null?0:r.length;for(t&&o&&(e=r[++a]);++a<o;)e=s(e,r[a],a,r);return e}var ie=Ot;function Nt(r){return function(s){return r==null?void 0:r[s]}}var pe=Nt;var wt={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},qt=pe(wt),de=qt;var Et=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,kt="\\u0300-\\u036f",Mt="\\ufe20-\\ufe2f",Ut="\\u20d0-\\u20ff",Wt=kt+Mt+Ut,jt="["+Wt+"]",Dt=RegExp(jt,"g");function Vt(r){return r=l(r),r&&r.replace(Et,de).replace(Dt,"")}var le=Vt;var zt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Ht(r){return r.match(zt)||[]}var me=Ht;var Gt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Zt(r){return Gt.test(r)}var ce=Zt;var be="\\ud800-\\udfff",Jt="\\u0300-\\u036f",Kt="\\ufe20-\\ufe2f",_t="\\u20d0-\\u20ff",$t=Jt+Kt+_t,ve="\\u2700-\\u27bf",Re="a-z\\xdf-\\xf6\\xf8-\\xff",Yt="\\xac\\xb1\\xd7\\xf7",Qt="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Xt="\\u2000-\\u206f",er=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ae="A-Z\\xc0-\\xd6\\xd8-\\xde",tr="\\ufe0e\\ufe0f",Ie=Yt+Qt+Xt+er,Ce="['\u2019]",xe="["+Ie+"]",rr="["+$t+"]",Fe="\\d+",ar="["+ve+"]",Se="["+Re+"]",Pe="[^"+be+Ie+Fe+ve+Re+Ae+"]",or="\\ud83c[\\udffb-\\udfff]",sr="(?:"+rr+"|"+or+")",nr="[^"+be+"]",Te="(?:\\ud83c[\\udde6-\\uddff]){2}",Be="[\\ud800-\\udbff][\\udc00-\\udfff]",x="["+Ae+"]",fr="\\u200d",he="(?:"+Se+"|"+Pe+")",ur="(?:"+x+"|"+Pe+")",ye="(?:"+Ce+"(?:d|ll|m|re|s|t|ve))?",ge="(?:"+Ce+"(?:D|LL|M|RE|S|T|VE))?",Le=sr+"?",Oe="["+tr+"]?",ir="(?:"+fr+"(?:"+[nr,Te,Be].join("|")+")"+Oe+Le+")*",pr="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",dr="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",lr=Oe+Le+ir,mr="(?:"+[ar,Te,Be].join("|")+")"+lr,cr=RegExp([x+"?"+Se+"+"+ye+"(?="+[xe,x,"$"].join("|")+")",ur+"+"+ge+"(?="+[xe,x+he,"$"].join("|")+")",x+"?"+he+"+"+ye,x+"+"+ge,dr,pr,Fe,mr].join("|"),"g");function xr(r){return r.match(cr)||[]}var Ne=xr;function hr(r,s,e){return r=l(r),s=e?void 0:s,s===void 0?ce(r)?Ne(r):me(r):r.match(s)||[]}var we=hr;var yr="['\u2019]",gr=RegExp(yr,"g");function br(r){return function(s){return ie(we(le(s).replace(gr,"")),r,"")}}var qe=br;var vr=qe(function(r,s,e){return s=s.toLowerCase(),r+(e?ue(s):s)}),T=vr;var Ee=class extends q{constructor({context:e}){super(e);w(this,"context");this.context=e}async generateSnippet({endpoint:e,request:t,options:a}){return this.buildCodeBlock({endpoint:e,snippet:t,options:a}).toString({namespace:"Usage",generation:this.generation,allNamespaceSegments:new Set,allTypeClassReferences:new Map})}generateSnippetSync({endpoint:e,request:t,options:a}){return this.buildCodeBlock({endpoint:e,snippet:t,options:a}).toString({namespace:"Usage",generation:this.generation,allNamespaceSegments:new Set,allTypeClassReferences:new Map})}buildCodeBlock({endpoint:e,snippet:t,options:a}){var f;if(e.examples&&!((f=e.examples)!=null&&f.find(u=>A.DynamicIR.EndpointExample(t)&&u.id===t.id)))throw new Error("Endpoint does not have an example that matches the snippet");let o=this.csharp.codeblock(u=>{u.writeNodeStatement(this.constructClient({endpoint:e,snippet:t})),u.newLine(),u.writeNodeStatement(this.callMethod({endpoint:e,snippet:t}))}),n=this.getStyle(a);switch(n){case R.Concise:return o;case R.Full:return this.buildFullCodeBlock({body:o,options:a});default:m(n)}}buildFullCodeBlock({body:e,options:t}){var n;let a=this.getConfig(t),o=this.csharp.class_({name:(n=a.fullStyleClassName)!=null?n:"Example",namespace:"Usage",access:F.Access.Public});return o.addNamespaceReference(this.types.RootClient.namespace),o.addMethod({name:"Do",access:F.Access.Public,isAsync:!0,parameters:[],body:e}),o}constructClient({endpoint:e,snippet:t}){return this.csharp.codeblock(a=>{a.write("var client = "),a.writeNode(this.getRootClientConstructorInvocation(this.getConstructorArgs({endpoint:e,snippet:t})))})}callMethod({endpoint:e,snippet:t}){var n,f;let a=((n=e.response)==null?void 0:n.type)==="streaming"||((f=e.response)==null?void 0:f.type)==="streamParameter",o=this.csharp.invokeMethod({on:this.csharp.codeblock("client"),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t}),async:!0,configureAwait:!0,multiline:!0,isAsyncEnumerable:a});return a?this.csharp.codeblock(u=>{u.write("await foreach (var item in "),u.writeNode(o),u.writeLine(")"),u.pushScope(),u.writeLine("/* consume each item */"),u.popScope()}):o}getConstructorArgs({endpoint:e,snippet:t}){let a=[];e.auth!=null&&(t.auth!=null?a.push(...this.getConstructorAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:d.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`}));let o=[],n=this.getConstructorBaseUrlArgs({baseUrl:t.baseURL,environment:t.environment});n.length>0&&o.push(...n),this.context.errors.scope(i.Headers);let f=[];return this.context.ir.headers!=null&&t.headers!=null&&f.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope(),o.length===0?[...a,...f]:[...a,...f,{name:"clientOptions",assignment:this.csharp.instantiateClass({classReference:this.types.ClientOptions,arguments_:o.map(u=>({name:u.name,assignment:u.assignment})),multiline:!0})}]}getConstructorBaseUrlArgs({baseUrl:e,environment:t}){let a=this.getBaseUrlArg({baseUrl:e,environment:t});return A.TypeLiteral.nop(a)?[]:[{name:this.getBaseUrlOptionName(),assignment:a}]}getBaseUrlArg({baseUrl:e,environment:t}){var a;if(e!=null&&t!=null)return this.context.errors.add({severity:d.Critical,message:"Cannot specify both baseUrl and environment options"}),this.csharp.TypeLiteral.nop();if(e!=null)return((a=this.context.ir.environments)==null?void 0:a.environments.type)==="multipleBaseUrls"?(this.context.errors.add({severity:d.Critical,message:"The C# SDK doesn't support a baseUrl when multiple URL environments are configured"}),this.csharp.TypeLiteral.nop()):this.csharp.TypeLiteral.string(e);if(t!=null){if(this.context.isSingleEnvironmentID(t)){let o=this.context.getEnvironmentTypeReferenceFromID(t);return o==null?(this.context.errors.add({severity:d.Warning,message:`Environment ${JSON.stringify(t)} was not found`}),this.csharp.TypeLiteral.nop()):this.csharp.TypeLiteral.reference(o)}if(this.context.isMultiEnvironmentValues(t))return this.context.validateMultiEnvironmentUrlValues(t)?this.csharp.TypeLiteral.reference(this.csharp.instantiateClass({classReference:this.types.Environments,arguments_:Object.entries(t).map(([o,n])=>({name:y(T(o)),assignment:this.context.dynamicTypeLiteralMapper.convert({typeReference:{type:"primitive",value:"STRING"},value:n})})),multiline:!0})):this.csharp.TypeLiteral.nop()}return this.csharp.TypeLiteral.nop()}getConstructorAuthArgs({auth:e,values:t}){if(t.type!==e.type)return this.addError(this.context.newAuthMismatchError({auth:e,values:t}).message),[];switch(e.type){case"basic":return t.type==="basic"?this.getConstructorBasicAuthArg({auth:e,values:t}):[];case"bearer":return t.type==="bearer"?this.getConstructorBearerAuthArgs({auth:e,values:t}):[];case"header":return t.type==="header"?this.getConstructorHeaderAuthArgs({auth:e,values:t}):[];case"oauth":return t.type==="oauth"?this.getConstructorOAuthArgs({auth:e,values:t}):[];case"inferred":return this.addWarning("The C# SDK Generator does not support Inferred auth scheme yet"),[];default:m(e)}}addError(e){this.context.errors.add({severity:d.Critical,message:e})}addWarning(e){this.context.errors.add({severity:d.Warning,message:e})}getConstructorBasicAuthArg({auth:e,values:t}){return[{name:this.context.getParameterName(e.username),assignment:this.csharp.TypeLiteral.string(t.username)},{name:this.context.getParameterName(e.password),assignment:this.csharp.TypeLiteral.string(t.password)}]}getConstructorBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getParameterName(e.token),assignment:this.csharp.TypeLiteral.string(t.token)}]}getConstructorHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getParameterName(e.header.name.name),assignment:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value,fallbackToDefault:e.header.name.wireValue})}]}getConstructorOAuthArgs({auth:e,values:t}){return[{name:this.context.getParameterName(e.clientId),assignment:this.csharp.TypeLiteral.string(t.clientId)},{name:this.context.getParameterName(e.clientSecret),assignment:this.csharp.TypeLiteral.string(t.clientSecret)}]}getConstructorHeaderArgs({headers:e,values:t}){let a=[];for(let o of e){let n=this.getConstructorHeaderArg({header:o,value:t.value});n!=null&&a.push({name:this.context.getParameterName(o.name.name),assignment:n})}return a}getConstructorHeaderArg({header:e,value:t}){let a=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t,fallbackToDefault:e.name.wireValue});if(!A.TypeLiteral.nop(a))return a}getMethodArgs({endpoint:e,snippet:t}){switch(e.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:e.request,snippet:t});case"body":return this.getMethodArgsForBodyRequest({request:e.request,snippet:t});default:m(e.request)}}getMethodArgsForInlinedRequest({request:e,snippet:t}){var u,g;let a=[];this.context.errors.scope(i.PathParameters);let o=[],n=[...(u=this.context.ir.pathParameters)!=null?u:[],...(g=e.pathParameters)!=null?g:[]];n.length>0&&o.push(...this.getPathParameters({namedParameters:n,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(i.RequestBody);let f=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:this.settings.shouldInlinePathParameters})||a.push(...o.map(C=>C.value)),a.push(this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:this.settings.shouldInlinePathParameters})?o:[],filePropertyInfo:f})),a}getFilePropertyInfo({request:e,snippet:t}){return e.body==null||!this.context.isFileUploadRequestBody(e.body)?{fileFields:[],bodyPropertyFields:[]}:this.context.filePropertyMapper.getFilePropertyInfo({body:e.body,value:t.requestBody})}getInlinedRequestArg({request:e,snippet:t,pathParameterFields:a,filePropertyInfo:o}){var B,L,O,N;this.context.errors.scope(i.QueryParameters);let f=this.context.associateQueryParametersByWireValue({parameters:(B=e.queryParameters)!=null?B:[],values:(L=t.queryParameters)!=null?L:{}}).map(c=>({name:this.context.getPropertyName(c.name.name),value:this.context.dynamicTypeLiteralMapper.convert(c)}));this.context.errors.unscope(),this.context.errors.scope(i.Headers);let g=this.context.associateByWireValue({parameters:(O=e.headers)!=null?O:[],values:(N=t.headers)!=null?N:{}}).map(c=>({name:this.context.getPropertyName(c.name.name),value:this.context.dynamicTypeLiteralMapper.convert(v(b({},c),{fallbackToDefault:c.name.wireValue}))}));this.context.errors.unscope(),this.context.errors.scope(i.RequestBody);let C=e.body!=null?this.getInlinedRequestBodyConstructorFields({body:e.body,value:t.requestBody,filePropertyInfo:o}):[];return this.context.errors.unscope(),this.csharp.TypeLiteral.class_({reference:this.csharp.classReference({origin:e.declaration,namespace:this.context.getNamespace(e.declaration.fernFilepath)}),fields:[...a,...f,...g,...C]})}getInlinedRequestBodyConstructorFields({body:e,value:t,filePropertyInfo:a}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyConstructorFields({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyConstructorField({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyConstructorFields({filePropertyInfo:a});default:m(e)}}getInlinedRequestBodyPropertyConstructorFields({parameters:e,value:t}){var n;let a=[],o=this.context.associateByWireValue({parameters:e,values:(n=this.context.getRecord(t))!=null?n:{}});for(let f of o)a.push({name:this.context.getPropertyName(f.name.name),value:this.context.dynamicTypeLiteralMapper.convert(v(b({},f),{fallbackToDefault:f.name.wireValue}))});return a}getFileUploadRequestBodyConstructorFields({filePropertyInfo:e}){return[...e.fileFields,...e.bodyPropertyFields]}getReferencedRequestBodyPropertyConstructorField({body:e,value:t}){return{name:this.context.getPropertyName(e.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:e.bodyType,value:t})}}getReferencedRequestBodyPropertyTypeLiteral({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t,fallbackToDefault:JSON.stringify(e.value)});default:m(e)}}getMethodArgsForBodyRequest({request:e,snippet:t}){var n,f;let a=[];this.context.errors.scope(i.PathParameters);let o=[...(n=this.context.ir.pathParameters)!=null?n:[],...(f=e.pathParameters)!=null?f:[]];return o.length>0&&a.push(...this.getPathParameters({namedParameters:o,snippet:t}).map(u=>u.value)),this.context.errors.unscope(),this.context.errors.scope(i.RequestBody),e.body!=null&&a.push(this.getBodyRequestArg({body:e.body,value:t.requestBody})),this.context.errors.unscope(),a}getBodyRequestArg({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return e.value.type==="optional"&&t==null?this.csharp.TypeLiteral.null():this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t,fallbackToDefault:JSON.stringify(e.value)});default:m(e)}}getBytesBodyRequestArg({value:e}){let t=this.context.getValueAsString({value:e});return t==null&&(this.context.errors.add({severity:d.Critical,message:"The bytes request body must be provided in string format"}),t="[bytes]"),this.csharp.TypeLiteral.reference(this.context.getMemoryStreamForString(t))}getRootClientConstructorInvocation(e){return this.csharp.instantiateClass({classReference:this.types.RootClient,arguments_:e,forceUseConstructor:!0,multiline:!0})}getPathParameters({namedParameters:e,snippet:t}){var n;let a=[],o=this.context.associateByWireValueOrDefault({parameters:e,values:(n=t.pathParameters)!=null?n:{}});for(let f of o)a.push({name:this.context.getPropertyName(f.name.name),value:this.context.dynamicTypeLiteralMapper.convert(v(b({},f),{fallbackToDefault:f.name.wireValue}))});return a}getMethod({endpoint:e}){return e.declaration.fernFilepath.allParts.length>0?`${e.declaration.fernFilepath.allParts.map(t=>this.context.getClassName(t)).join(".")}.${this.context.getMethodName(e.declaration.name)}`:this.context.getMethodName(e.declaration.name)}getBaseUrlOptionName(){var e;return((e=this.context.ir.environments)==null?void 0:e.environments.type)==="multipleBaseUrls"?"Environment":"BaseUrl"}getStyle(e){var t,a;return(a=(t=e.style)!=null?t:this.context.options.style)!=null?a:R.Full}getConfig(e){var t,a;return(a=(t=e.config)!=null?t:this.context.options.config)!=null?a:{}}};export{Ee as a};
2
2
  /*! Bundled license information:
3
3
 
4
4
  lodash-es/lodash.js:
@@ -12,4 +12,4 @@ lodash-es/lodash.js:
12
12
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
13
13
  *)
14
14
  */
15
- //# sourceMappingURL=chunk-SAYITSWL.js.map
15
+ //# sourceMappingURL=chunk-4O5TI5LE.js.map