@fern-api/python-dynamic-snippets 0.0.5 → 0.0.7

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 (42) hide show
  1. package/cjs/DynamicSnippetsGenerator.cjs +14 -11
  2. package/cjs/DynamicSnippetsGenerator.cjs.map +1 -1
  3. package/cjs/EndpointSnippetGenerator.cjs +14 -11
  4. package/cjs/EndpointSnippetGenerator.cjs.map +1 -1
  5. package/cjs/context/DynamicSnippetsGeneratorContext.cjs +15 -12
  6. package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +1 -1
  7. package/cjs/context/DynamicTypeLiteralMapper.cjs +15 -12
  8. package/cjs/context/DynamicTypeLiteralMapper.cjs.map +1 -1
  9. package/cjs/context/FilePropertyMapper.cjs +14 -11
  10. package/cjs/context/FilePropertyMapper.cjs.map +1 -1
  11. package/cjs/index.cjs +17 -26
  12. package/cjs/index.cjs.map +1 -1
  13. package/esm/DynamicSnippetsGenerator.js +1 -1
  14. package/esm/EndpointSnippetGenerator.js +1 -1
  15. package/esm/{chunk-QZ6H2KCF.js → chunk-2FBSEQ3K.js} +2 -2
  16. package/esm/{chunk-A2A6Z7VZ.js → chunk-2NL5Y7CR.js} +2 -2
  17. package/esm/chunk-4OZNKHPQ.js +2 -0
  18. package/esm/chunk-6OLYGRJY.js +2 -0
  19. package/esm/{chunk-RZQMRQM5.js.map → chunk-6OLYGRJY.js.map} +1 -1
  20. package/esm/chunk-EO2BLSPL.js +2 -0
  21. package/esm/chunk-EO2BLSPL.js.map +1 -0
  22. package/esm/chunk-PFARUNGR.js +2 -0
  23. package/esm/chunk-PFARUNGR.js.map +1 -0
  24. package/esm/chunk-YEXRWSXV.js +31 -0
  25. package/esm/chunk-YEXRWSXV.js.map +1 -0
  26. package/esm/context/DynamicSnippetsGeneratorContext.js +1 -1
  27. package/esm/context/DynamicTypeLiteralMapper.js +1 -1
  28. package/esm/context/FilePropertyMapper.js +1 -1
  29. package/esm/index.js +1 -13
  30. package/esm/index.js.map +1 -1
  31. package/package.json +1 -1
  32. package/esm/chunk-3LXSVXLG.js +0 -2
  33. package/esm/chunk-3LXSVXLG.js.map +0 -1
  34. package/esm/chunk-7DC5LAKR.js +0 -28
  35. package/esm/chunk-7DC5LAKR.js.map +0 -1
  36. package/esm/chunk-RZQMRQM5.js +0 -2
  37. package/esm/chunk-UU6KFSXM.js +0 -2
  38. package/esm/chunk-VDFQDR2Q.js +0 -2
  39. package/esm/chunk-VDFQDR2Q.js.map +0 -1
  40. /package/esm/{chunk-QZ6H2KCF.js.map → chunk-2FBSEQ3K.js.map} +0 -0
  41. /package/esm/{chunk-A2A6Z7VZ.js.map → chunk-2NL5Y7CR.js.map} +0 -0
  42. /package/esm/{chunk-UU6KFSXM.js.map → chunk-4OZNKHPQ.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-UU6KFSXM.js";import"./chunk-VDFQDR2Q.js";import"./chunk-A2A6Z7VZ.js";import"./chunk-3LXSVXLG.js";import"./chunk-RZQMRQM5.js";import"./chunk-QZ6H2KCF.js";import"./chunk-7DC5LAKR.js";export{a as DynamicSnippetsGenerator};
1
+ import{a}from"./chunk-4OZNKHPQ.js";import"./chunk-EO2BLSPL.js";import"./chunk-2NL5Y7CR.js";import"./chunk-PFARUNGR.js";import"./chunk-6OLYGRJY.js";import"./chunk-2FBSEQ3K.js";import"./chunk-YEXRWSXV.js";export{a as DynamicSnippetsGenerator};
2
2
  //# sourceMappingURL=DynamicSnippetsGenerator.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-VDFQDR2Q.js";import"./chunk-RZQMRQM5.js";import"./chunk-7DC5LAKR.js";export{a as EndpointSnippetGenerator};
1
+ import{a}from"./chunk-EO2BLSPL.js";import"./chunk-6OLYGRJY.js";import"./chunk-YEXRWSXV.js";export{a as EndpointSnippetGenerator};
2
2
  //# sourceMappingURL=EndpointSnippetGenerator.js.map
@@ -1,2 +1,2 @@
1
- import{j as s,k as y,m as l,n as c,p as o}from"./chunk-7DC5LAKR.js";y();l();var d=class{constructor({context:t}){s(this,"context");this.context=t}getFilePropertyInfo({body:t,value:i}){var p;let e={fileFields:[],bodyPropertyFields:[]},a=(p=this.context.getRecord(i))!=null?p:{};for(let r of t.properties)switch(r.type){case"file":{let n=this.getSingleFileProperty({property:r,record:a});if(o.TypeInstantiation.isNop(n))break;e.fileFields.push({name:this.context.getPropertyName(r.name),value:n});break}case"fileArray":{let n=this.getArrayFileProperty({property:r,record:a});if(o.TypeInstantiation.isNop(n))break;e.fileFields.push({name:this.context.getPropertyName(r.name),value:n});break}case"bodyProperty":{let n=this.getBodyProperty({property:r,record:a});if(o.TypeInstantiation.isNop(n))break;e.bodyPropertyFields.push({name:this.context.getPropertyName(r.name.name),value:n});break}default:c(r)}return e}getSingleFileProperty({property:t,record:i}){let e=this.context.getSingleFileValue({property:t,record:i});return e==null?o.TypeInstantiation.nop():this.context.getFileFromString(e)}getArrayFileProperty({property:t,record:i}){let e=this.context.getFileArrayValues({property:t,record:i});return e==null?o.TypeInstantiation.nop():o.TypeInstantiation.list(e.map(a=>this.context.getFileFromString(a)))}getBodyProperty({property:t,record:i}){let e=i[t.name.wireValue];return e==null?o.TypeInstantiation.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:e})}};export{d as a};
2
- //# sourceMappingURL=chunk-QZ6H2KCF.js.map
1
+ import{e as s,f as y,g as l,h as c,j as o}from"./chunk-YEXRWSXV.js";y();l();var d=class{constructor({context:t}){s(this,"context");this.context=t}getFilePropertyInfo({body:t,value:i}){var p;let e={fileFields:[],bodyPropertyFields:[]},a=(p=this.context.getRecord(i))!=null?p:{};for(let r of t.properties)switch(r.type){case"file":{let n=this.getSingleFileProperty({property:r,record:a});if(o.TypeInstantiation.isNop(n))break;e.fileFields.push({name:this.context.getPropertyName(r.name),value:n});break}case"fileArray":{let n=this.getArrayFileProperty({property:r,record:a});if(o.TypeInstantiation.isNop(n))break;e.fileFields.push({name:this.context.getPropertyName(r.name),value:n});break}case"bodyProperty":{let n=this.getBodyProperty({property:r,record:a});if(o.TypeInstantiation.isNop(n))break;e.bodyPropertyFields.push({name:this.context.getPropertyName(r.name.name),value:n});break}default:c(r)}return e}getSingleFileProperty({property:t,record:i}){let e=this.context.getSingleFileValue({property:t,record:i});return e==null?o.TypeInstantiation.nop():this.context.getFileFromString(e)}getArrayFileProperty({property:t,record:i}){let e=this.context.getFileArrayValues({property:t,record:i});return e==null?o.TypeInstantiation.nop():o.TypeInstantiation.list(e.map(a=>this.context.getFileFromString(a)))}getBodyProperty({property:t,record:i}){let e=i[t.name.wireValue];return e==null?o.TypeInstantiation.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:e})}};export{d as a};
2
+ //# sourceMappingURL=chunk-2FBSEQ3K.js.map
@@ -1,4 +1,4 @@
1
- import{a as A}from"./chunk-3LXSVXLG.js";import{c as S}from"./chunk-RZQMRQM5.js";import{a as O}from"./chunk-QZ6H2KCF.js";import{j as x,k as t,m as a,n as b,p as i}from"./chunk-7DC5LAKR.js";t();a();t();a();t();a();t();a();t();a();t();a();t();a();var Ie=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,N=Ie;var ke=typeof self=="object"&&self&&self.Object===Object&&self,Ee=N||ke||Function("return this")(),I=Ee;var Te=I.Symbol,p=Te;t();a();var k=Object.prototype,Me=k.hasOwnProperty,we=k.toString,c=p?p.toStringTag:void 0;function je(e){var o=Me.call(e,c),r=e[c];try{e[c]=void 0;var f=!0}catch(m){}var l=we.call(e);return f&&(o?e[c]=r:delete e[c]),l}var E=je;t();a();var Pe=Object.prototype,We=Pe.toString;function Le(e){return We.call(e)}var T=Le;var Ue="[object Null]",ze="[object Undefined]",M=p?p.toStringTag:void 0;function Be(e){return e==null?e===void 0?ze:Ue:M&&M in Object(e)?E(e):T(e)}var w=Be;t();a();function Fe(e){return e!=null&&typeof e=="object"}var j=Fe;var De="[object Symbol]";function _e(e){return typeof e=="symbol"||j(e)&&w(e)==De}var P=_e;t();a();t();a();function Ze(e,o){for(var r=-1,f=e==null?0:e.length,l=Array(f);++r<f;)l[r]=o(e[r],r,e);return l}var W=Ze;t();a();var Ge=Array.isArray,L=Ge;var qe=1/0,U=p?p.prototype:void 0,z=U?U.toString:void 0;function B(e){if(typeof e=="string")return e;if(L(e))return W(e,B)+"";if(P(e))return z?z.call(e):"";var o=e+"";return o=="0"&&1/e==-qe?"-0":o}var F=B;t();a();function He(e){return e==null?"":F(e)}var n=He;t();a();t();a();t();a();t();a();t();a();t();a();function Ve(e,o,r){var f=-1,l=e.length;o<0&&(o=-o>l?0:l+o),r=r>l?l:r,r<0&&(r+=l),l=o>r?0:r-o>>>0,o>>>=0;for(var m=Array(l);++f<l;)m[f]=e[f+o];return m}var D=Ve;function Je(e,o,r){var f=e.length;return r=r===void 0?f:r,!o&&r>=f?e:D(e,o,r)}var _=Je;t();a();var Ke="\\ud800-\\udfff",$e="\\u0300-\\u036f",Ye="\\ufe20-\\ufe2f",Qe="\\u20d0-\\u20ff",Xe=$e+Ye+Qe,er="\\ufe0e\\ufe0f",rr="\\u200d",tr=RegExp("["+rr+Ke+Xe+er+"]");function ar(e){return tr.test(e)}var g=ar;t();a();t();a();function or(e){return e.split("")}var Z=or;t();a();var G="\\ud800-\\udfff",fr="\\u0300-\\u036f",ur="\\ufe20-\\ufe2f",sr="\\u20d0-\\u20ff",lr=fr+ur+sr,pr="\\ufe0e\\ufe0f",nr="["+G+"]",y="["+lr+"]",C="\\ud83c[\\udffb-\\udfff]",mr="(?:"+y+"|"+C+")",q="[^"+G+"]",H="(?:\\ud83c[\\udde6-\\uddff]){2}",V="[\\ud800-\\udbff][\\udc00-\\udfff]",ir="\\u200d",J=mr+"?",K="["+pr+"]?",dr="(?:"+ir+"(?:"+[q,H,V].join("|")+")"+K+J+")*",xr=K+J+dr,cr="(?:"+[q+y+"?",y,H,V,nr].join("|")+")",gr=RegExp(C+"(?="+C+")|"+cr+xr,"g");function hr(e){return e.match(gr)||[]}var $=hr;function br(e){return g(e)?$(e):Z(e)}var Y=br;function yr(e){return function(o){o=n(o);var r=g(o)?Y(o):void 0,f=r?r[0]:o.charAt(0),l=r?_(r,1).join(""):o.slice(1);return f[e]()+l}}var Q=yr;var Cr=Q("toUpperCase"),X=Cr;function Rr(e){return X(n(e).toLowerCase())}var ee=Rr;t();a();t();a();function vr(e,o,r,f){var l=-1,m=e==null?0:e.length;for(f&&m&&(r=e[++l]);++l<m;)r=o(r,e[l],l,e);return r}var re=vr;t();a();t();a();t();a();function Sr(e){return function(o){return e==null?void 0:e[o]}}var te=Sr;var Ar={\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"},Or=te(Ar),ae=Or;var Nr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ir="\\u0300-\\u036f",kr="\\ufe20-\\ufe2f",Er="\\u20d0-\\u20ff",Tr=Ir+kr+Er,Mr="["+Tr+"]",wr=RegExp(Mr,"g");function jr(e){return e=n(e),e&&e.replace(Nr,ae).replace(wr,"")}var oe=jr;t();a();t();a();var Pr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Wr(e){return e.match(Pr)||[]}var fe=Wr;t();a();var Lr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Ur(e){return Lr.test(e)}var ue=Ur;t();a();var me="\\ud800-\\udfff",zr="\\u0300-\\u036f",Br="\\ufe20-\\ufe2f",Fr="\\u20d0-\\u20ff",Dr=zr+Br+Fr,ie="\\u2700-\\u27bf",de="a-z\\xdf-\\xf6\\xf8-\\xff",_r="\\xac\\xb1\\xd7\\xf7",Zr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Gr="\\u2000-\\u206f",qr=" \\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",xe="A-Z\\xc0-\\xd6\\xd8-\\xde",Hr="\\ufe0e\\ufe0f",ce=_r+Zr+Gr+qr,ge="['\u2019]",se="["+ce+"]",Vr="["+Dr+"]",he="\\d+",Jr="["+ie+"]",be="["+de+"]",ye="[^"+me+ce+he+ie+de+xe+"]",Kr="\\ud83c[\\udffb-\\udfff]",$r="(?:"+Vr+"|"+Kr+")",Yr="[^"+me+"]",Ce="(?:\\ud83c[\\udde6-\\uddff]){2}",Re="[\\ud800-\\udbff][\\udc00-\\udfff]",d="["+xe+"]",Qr="\\u200d",le="(?:"+be+"|"+ye+")",Xr="(?:"+d+"|"+ye+")",pe="(?:"+ge+"(?:d|ll|m|re|s|t|ve))?",ne="(?:"+ge+"(?:D|LL|M|RE|S|T|VE))?",ve=$r+"?",Se="["+Hr+"]?",et="(?:"+Qr+"(?:"+[Yr,Ce,Re].join("|")+")"+Se+ve+")*",rt="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",tt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",at=Se+ve+et,ot="(?:"+[Jr,Ce,Re].join("|")+")"+at,ft=RegExp([d+"?"+be+"+"+pe+"(?="+[se,d,"$"].join("|")+")",Xr+"+"+ne+"(?="+[se,d+le,"$"].join("|")+")",d+"?"+le+"+"+pe,d+"+"+ne,tt,rt,he,ot].join("|"),"g");function ut(e){return e.match(ft)||[]}var Ae=ut;function st(e,o,r){return e=n(e),o=r?void 0:o,o===void 0?ue(e)?Ae(e):fe(e):e.match(o)||[]}var Oe=st;var lt="['\u2019]",pt=RegExp(lt,"g");function nt(e){return function(o){return re(Oe(oe(o).replace(pt,"")),e,"")}}var h=nt;var mt=h(function(e,o,r){return o=o.toLowerCase(),e+(r?ee(o):o)}),R=mt;t();a();var it=h(function(e,o,r){return e+(r?"_":"")+o.toLowerCase()}),v=it;var dt=["list","set"],Ne=class e extends S{constructor({ir:r,config:f}){var l;super({ir:r,config:f});x(this,"ir");x(this,"customConfig");x(this,"dynamicTypeLiteralMapper");x(this,"filePropertyMapper");this.ir=r,this.customConfig=(l=f.customConfig)!=null?l:{},this.dynamicTypeLiteralMapper=new A({context:this}),this.filePropertyMapper=new O({context:this})}clone(){return new e({ir:this.ir,config:this.config})}getClassName(r){let f=r.pascalCase.safeName,l=this.getRootClientClassName();return f===l?`${l}Model`:f}getTypedDictClassName(r){return`${this.getClassName(r)}Params`}getPropertyName(r){let f=r.snakeCase.safeName;return f.startsWith("_")?"f_"+f.substring(f.lastIndexOf("_")+1):f}getMethodName(r){return dt.includes(r.snakeCase.unsafeName)?r.snakeCase.unsafeName:r.snakeCase.safeName}getRootClientClassReference(){return i.reference({name:this.getRootClientClassName(),modulePath:this.getRootModulePath()})}getRootClientClassName(){var r,f;return((r=this.customConfig.client)==null?void 0:r.exported_class_name)!=null?this.customConfig.client.exported_class_name:this.customConfig.client_class_name!=null?this.customConfig.client_class_name:((f=this.customConfig.client)==null?void 0:f.class_name)!=null?this.customConfig.client.class_name:this.pascalCase(this.config.organization)+this.pascalCase(this.config.workspaceName)}getEnvironmentClassName(){return`${this.getRootClientClassName()}Environment`}getEnvironmentTypeReferenceFromID(r){let f=this.resolveEnvironmentName(r);if(f!=null)return i.accessAttribute({lhs:this.getEnvironmentClassReference(),rhs:i.codeBlock(this.getEnvironmentEnumName(f))})}getEnvironmentClassReference(){return i.reference({name:this.getEnvironmentClassName(),modulePath:this.getEnvironmentModulePath()})}getEnvironmentEnumName(r){return r.screamingSnakeCase.safeName}isPrimitive(r){switch(r.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(r.value);case"named":{let f=this.resolveNamedType({typeId:r.value});if(f==null)return!1;switch(f.type){case"alias":return this.isPrimitive(f.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:b(f)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:b(r)}}getFileFromString(r){return i.TypeInstantiation.str(r)}getRootModulePath(){if(this.customConfig.package_name!=null)return[this.customConfig.package_name];let r=this.cleanOrganizationName();return this.customConfig.use_api_name_in_package?[r,this.getApiName()]:[r]}getCoreModulePath(){return this.getRootModulePath().concat("core")}getEnvironmentModulePath(){return this.getRootModulePath().concat("environment")}shouldInlinePathParameters(){return!0}cleanOrganizationName(){return this.config.organization.replace(/[^a-zA-Z0-9]/g,"_")}getApiName(){return v(this.config.workspaceName)}pascalCase(r){let f=R(r);return f.charAt(0).toUpperCase()+f.slice(1)}};export{Ne as a};
1
+ import{a as A}from"./chunk-PFARUNGR.js";import{c as S}from"./chunk-6OLYGRJY.js";import{a as O}from"./chunk-2FBSEQ3K.js";import{e as x,f as t,g as a,h as b,j as i}from"./chunk-YEXRWSXV.js";t();a();t();a();t();a();t();a();t();a();t();a();t();a();var Ie=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,N=Ie;var ke=typeof self=="object"&&self&&self.Object===Object&&self,Ee=N||ke||Function("return this")(),I=Ee;var Te=I.Symbol,p=Te;t();a();var k=Object.prototype,Me=k.hasOwnProperty,we=k.toString,c=p?p.toStringTag:void 0;function je(e){var o=Me.call(e,c),r=e[c];try{e[c]=void 0;var f=!0}catch(m){}var l=we.call(e);return f&&(o?e[c]=r:delete e[c]),l}var E=je;t();a();var Pe=Object.prototype,We=Pe.toString;function Le(e){return We.call(e)}var T=Le;var Ue="[object Null]",ze="[object Undefined]",M=p?p.toStringTag:void 0;function Be(e){return e==null?e===void 0?ze:Ue:M&&M in Object(e)?E(e):T(e)}var w=Be;t();a();function Fe(e){return e!=null&&typeof e=="object"}var j=Fe;var De="[object Symbol]";function _e(e){return typeof e=="symbol"||j(e)&&w(e)==De}var P=_e;t();a();t();a();function Ze(e,o){for(var r=-1,f=e==null?0:e.length,l=Array(f);++r<f;)l[r]=o(e[r],r,e);return l}var W=Ze;t();a();var Ge=Array.isArray,L=Ge;var qe=1/0,U=p?p.prototype:void 0,z=U?U.toString:void 0;function B(e){if(typeof e=="string")return e;if(L(e))return W(e,B)+"";if(P(e))return z?z.call(e):"";var o=e+"";return o=="0"&&1/e==-qe?"-0":o}var F=B;t();a();function He(e){return e==null?"":F(e)}var n=He;t();a();t();a();t();a();t();a();t();a();t();a();function Ve(e,o,r){var f=-1,l=e.length;o<0&&(o=-o>l?0:l+o),r=r>l?l:r,r<0&&(r+=l),l=o>r?0:r-o>>>0,o>>>=0;for(var m=Array(l);++f<l;)m[f]=e[f+o];return m}var D=Ve;function Je(e,o,r){var f=e.length;return r=r===void 0?f:r,!o&&r>=f?e:D(e,o,r)}var _=Je;t();a();var Ke="\\ud800-\\udfff",$e="\\u0300-\\u036f",Ye="\\ufe20-\\ufe2f",Qe="\\u20d0-\\u20ff",Xe=$e+Ye+Qe,er="\\ufe0e\\ufe0f",rr="\\u200d",tr=RegExp("["+rr+Ke+Xe+er+"]");function ar(e){return tr.test(e)}var g=ar;t();a();t();a();function or(e){return e.split("")}var Z=or;t();a();var G="\\ud800-\\udfff",fr="\\u0300-\\u036f",ur="\\ufe20-\\ufe2f",sr="\\u20d0-\\u20ff",lr=fr+ur+sr,pr="\\ufe0e\\ufe0f",nr="["+G+"]",y="["+lr+"]",C="\\ud83c[\\udffb-\\udfff]",mr="(?:"+y+"|"+C+")",q="[^"+G+"]",H="(?:\\ud83c[\\udde6-\\uddff]){2}",V="[\\ud800-\\udbff][\\udc00-\\udfff]",ir="\\u200d",J=mr+"?",K="["+pr+"]?",dr="(?:"+ir+"(?:"+[q,H,V].join("|")+")"+K+J+")*",xr=K+J+dr,cr="(?:"+[q+y+"?",y,H,V,nr].join("|")+")",gr=RegExp(C+"(?="+C+")|"+cr+xr,"g");function hr(e){return e.match(gr)||[]}var $=hr;function br(e){return g(e)?$(e):Z(e)}var Y=br;function yr(e){return function(o){o=n(o);var r=g(o)?Y(o):void 0,f=r?r[0]:o.charAt(0),l=r?_(r,1).join(""):o.slice(1);return f[e]()+l}}var Q=yr;var Cr=Q("toUpperCase"),X=Cr;function Rr(e){return X(n(e).toLowerCase())}var ee=Rr;t();a();t();a();function vr(e,o,r,f){var l=-1,m=e==null?0:e.length;for(f&&m&&(r=e[++l]);++l<m;)r=o(r,e[l],l,e);return r}var re=vr;t();a();t();a();t();a();function Sr(e){return function(o){return e==null?void 0:e[o]}}var te=Sr;var Ar={\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"},Or=te(Ar),ae=Or;var Nr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ir="\\u0300-\\u036f",kr="\\ufe20-\\ufe2f",Er="\\u20d0-\\u20ff",Tr=Ir+kr+Er,Mr="["+Tr+"]",wr=RegExp(Mr,"g");function jr(e){return e=n(e),e&&e.replace(Nr,ae).replace(wr,"")}var oe=jr;t();a();t();a();var Pr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Wr(e){return e.match(Pr)||[]}var fe=Wr;t();a();var Lr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Ur(e){return Lr.test(e)}var ue=Ur;t();a();var me="\\ud800-\\udfff",zr="\\u0300-\\u036f",Br="\\ufe20-\\ufe2f",Fr="\\u20d0-\\u20ff",Dr=zr+Br+Fr,ie="\\u2700-\\u27bf",de="a-z\\xdf-\\xf6\\xf8-\\xff",_r="\\xac\\xb1\\xd7\\xf7",Zr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Gr="\\u2000-\\u206f",qr=" \\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",xe="A-Z\\xc0-\\xd6\\xd8-\\xde",Hr="\\ufe0e\\ufe0f",ce=_r+Zr+Gr+qr,ge="['\u2019]",se="["+ce+"]",Vr="["+Dr+"]",he="\\d+",Jr="["+ie+"]",be="["+de+"]",ye="[^"+me+ce+he+ie+de+xe+"]",Kr="\\ud83c[\\udffb-\\udfff]",$r="(?:"+Vr+"|"+Kr+")",Yr="[^"+me+"]",Ce="(?:\\ud83c[\\udde6-\\uddff]){2}",Re="[\\ud800-\\udbff][\\udc00-\\udfff]",d="["+xe+"]",Qr="\\u200d",le="(?:"+be+"|"+ye+")",Xr="(?:"+d+"|"+ye+")",pe="(?:"+ge+"(?:d|ll|m|re|s|t|ve))?",ne="(?:"+ge+"(?:D|LL|M|RE|S|T|VE))?",ve=$r+"?",Se="["+Hr+"]?",et="(?:"+Qr+"(?:"+[Yr,Ce,Re].join("|")+")"+Se+ve+")*",rt="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",tt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",at=Se+ve+et,ot="(?:"+[Jr,Ce,Re].join("|")+")"+at,ft=RegExp([d+"?"+be+"+"+pe+"(?="+[se,d,"$"].join("|")+")",Xr+"+"+ne+"(?="+[se,d+le,"$"].join("|")+")",d+"?"+le+"+"+pe,d+"+"+ne,tt,rt,he,ot].join("|"),"g");function ut(e){return e.match(ft)||[]}var Ae=ut;function st(e,o,r){return e=n(e),o=r?void 0:o,o===void 0?ue(e)?Ae(e):fe(e):e.match(o)||[]}var Oe=st;var lt="['\u2019]",pt=RegExp(lt,"g");function nt(e){return function(o){return re(Oe(oe(o).replace(pt,"")),e,"")}}var h=nt;var mt=h(function(e,o,r){return o=o.toLowerCase(),e+(r?ee(o):o)}),R=mt;t();a();var it=h(function(e,o,r){return e+(r?"_":"")+o.toLowerCase()}),v=it;var dt=["list","set"],Ne=class e extends S{constructor({ir:r,config:f}){var l;super({ir:r,config:f});x(this,"ir");x(this,"customConfig");x(this,"dynamicTypeLiteralMapper");x(this,"filePropertyMapper");this.ir=r,this.customConfig=(l=f.customConfig)!=null?l:{},this.dynamicTypeLiteralMapper=new A({context:this}),this.filePropertyMapper=new O({context:this})}clone(){return new e({ir:this.ir,config:this.config})}getClassName(r){let f=r.pascalCase.safeName,l=this.getRootClientClassName();return f===l?`${l}Model`:f}getTypedDictClassName(r){return`${this.getClassName(r)}Params`}getPropertyName(r){let f=r.snakeCase.safeName;return f.startsWith("_")?"f_"+f.substring(f.lastIndexOf("_")+1):f}getMethodName(r){return dt.includes(r.snakeCase.unsafeName)?r.snakeCase.unsafeName:r.snakeCase.safeName}getRootClientClassReference(){return i.reference({name:this.getRootClientClassName(),modulePath:this.getRootModulePath()})}getRootClientClassName(){var r,f;return((r=this.customConfig.client)==null?void 0:r.exported_class_name)!=null?this.customConfig.client.exported_class_name:this.customConfig.client_class_name!=null?this.customConfig.client_class_name:((f=this.customConfig.client)==null?void 0:f.class_name)!=null?this.customConfig.client.class_name:this.pascalCase(this.config.organization)+this.pascalCase(this.config.workspaceName)}getEnvironmentClassName(){return`${this.getRootClientClassName()}Environment`}getEnvironmentTypeReferenceFromID(r){let f=this.resolveEnvironmentName(r);if(f!=null)return i.accessAttribute({lhs:this.getEnvironmentClassReference(),rhs:i.codeBlock(this.getEnvironmentEnumName(f))})}getEnvironmentClassReference(){return i.reference({name:this.getEnvironmentClassName(),modulePath:this.getEnvironmentModulePath()})}getEnvironmentEnumName(r){return r.screamingSnakeCase.safeName}isPrimitive(r){switch(r.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(r.value);case"named":{let f=this.resolveNamedType({typeId:r.value});if(f==null)return!1;switch(f.type){case"alias":return this.isPrimitive(f.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:b(f)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:b(r)}}getFileFromString(r){return i.TypeInstantiation.str(r)}getRootModulePath(){if(this.customConfig.package_name!=null)return[this.customConfig.package_name];let r=this.cleanOrganizationName();return this.customConfig.use_api_name_in_package?[r,this.getApiName()]:[r]}getCoreModulePath(){return this.getRootModulePath().concat("core")}getEnvironmentModulePath(){return this.getRootModulePath().concat("environment")}shouldInlinePathParameters(){return!0}cleanOrganizationName(){return this.config.organization.replace(/[^a-zA-Z0-9]/g,"_")}getApiName(){return v(this.config.workspaceName)}pascalCase(r){let f=R(r);return f.charAt(0).toUpperCase()+f.slice(1)}};export{Ne 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-A2A6Z7VZ.js.map
15
+ //# sourceMappingURL=chunk-2NL5Y7CR.js.map
@@ -0,0 +1,2 @@
1
+ import{a as i}from"./chunk-EO2BLSPL.js";import{a as p}from"./chunk-2NL5Y7CR.js";import{a as t}from"./chunk-6OLYGRJY.js";import{f as n,g as r}from"./chunk-YEXRWSXV.js";n();r();var o=class extends t{constructor({ir:e,config:a}){super(new p({ir:e,config:a}))}async generate(e){return super.generate(e)}generateSync(e){return super.generateSync(e)}createSnippetGenerator(e){return new i({context:e})}};export{o as a};
2
+ //# sourceMappingURL=chunk-4OZNKHPQ.js.map
@@ -0,0 +1,2 @@
1
+ import{a as P,b as T,c as S,d as b,e as a,f as p,g as l,h,i as R}from"./chunk-YEXRWSXV.js";p();l();p();l();var y=class{constructor(){a(this,"reporter");a(this,"snippet");a(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:e,snippet:r}){this.shouldUpdate({snippet:r,reporter:e.errors})&&(this.reporter=e.errors.clone(),this.snippet=r)}getResponseOrThrow({endpoint:e}){var r;if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw(r=this.err)!=null?r:new Error(`Failed to generate snippet for endpoint "${e.method} ${e.path}"`)}shouldUpdate({snippet:e,reporter:r}){var t,n;return this.reporter==null||this.reporter.size()>0&&r.size()===0?!0:e.length>((n=(t=this.snippet)==null?void 0:t.length)!=null?n:0)}};var E=class{constructor(e){a(this,"context");this.context=e}async generate(e,r={}){let t=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(t.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let n=new y;for(let i of t){let s=this.context.clone(),d=this.createSnippetGenerator(s);try{let u=await d.generateSnippet({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:u,errors:void 0};n.update({context:s,snippet:u})}catch(u){n.err==null&&(n.err=u)}}return n.getResponseOrThrow({endpoint:e.endpoint})}generateSync(e,r={}){let t=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(t.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let n=new y;for(let i of t){let s=this.context.clone(),d=this.createSnippetGenerator(s);try{let u=d.generateSnippetSync({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:u,errors:void 0};n.update({context:s,snippet:u})}catch(u){n.err==null&&(n.err=u)}}return n.getResponseOrThrow({endpoint:e.endpoint})}};p();l();var o={Critical:"CRITICAL",Warning:"WARNING"},v=class m{constructor(){a(this,"errors");a(this,"path");this.errors=[],this.path=[]}add(e){this.errors.push(T(P({},e),{path:[...this.path]}))}scope(e){this.path.push(e)}unscope(){this.path.pop()}getBySeverity(e){return this.errors.filter(r=>r.severity===e)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let e=new m;return e.errors=[...this.errors],e.path=[...this.path],e}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(e=>({severity:e.severity,path:e.path!=null?this.pathToStringArray(e.path):void 0,message:e.message}))}pathToStringArray(e){let r=[];for(let t of e){if(typeof t=="string"){r.push(t);continue}r[r.length-1]+=`[${t.index}]`}return r}};p();l();p();l();p();l();var g=class{constructor(){a(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(e){return this.REFERENCE_REGEX.test(e)?{type:"valid"}:{type:"invalid"}}tryParse(e){if(this.validate(e).type==="invalid")return;let t=e.match(this.REFERENCE_REGEX);if(!(t==null||t[1]==null||t[2]==null))return{method:t[1],path:t[2]}}};var w=class{constructor({ir:e,config:r,options:t={}}){a(this,"config");a(this,"options");a(this,"errors");a(this,"_ir");a(this,"httpEndpointReferenceParser");this._ir=e,this.config=r,this.options=t,this.errors=new v,this.httpEndpointReferenceParser=new g}associateQueryParametersByWireValue({parameters:e,values:r}){let t=[];for(let[n,i]of Object.entries(r)){this.errors.scope(n);try{let s=e.find(u=>u.name.wireValue===n);if(s==null)throw this.newParameterNotRecognizedError(n);let d=this.isListTypeReference(s.typeReference)&&!Array.isArray(i)?[i]:i;t.push({name:s.name,typeReference:s.typeReference,value:d})}finally{this.errors.unscope()}}return t}associateByWireValueOrDefault({parameters:e,values:r}){let t=[];for(let n of e){this.errors.scope(n.name.wireValue);try{let i=r[n.name.wireValue];if(i==null)if(n.typeReference.type==="primitive"&&n.typeReference.value==="STRING")i=`<${n.name.wireValue}>`;else{this.errors.add({severity:o.Critical,message:this.newParameterNotRecognizedError(n.name.wireValue).message});continue}t.push({name:n.name,typeReference:n.typeReference,value:i})}finally{this.errors.unscope()}}return t}associateByWireValue({parameters:e,values:r,ignoreMissingParameters:t}){let n=[];for(let[i,s]of Object.entries(r)){this.errors.scope(i);try{let d=e.find(u=>u.name.wireValue===i);if(d==null){if(t)continue;this.errors.add({severity:o.Critical,message:this.newParameterNotRecognizedError(i).message});continue}n.push({name:d.name,typeReference:d.typeReference,value:s})}finally{this.errors.unscope()}}return n}getExampleObjectProperties({parameters:e,snippetObject:r}){let t=typeof r=="object"&&r!==null&&!Array.isArray(r)?r:{},n=[];for(let i of e){let s=t[i.name.wireValue];s==null?i.typeReference.type==="nullable"&&n.push({name:i.name,typeReference:i.typeReference,value:null}):n.push({name:i.name,typeReference:i.typeReference,value:s})}return n}getSingleFileValue({property:e,record:r}){let t=r[e.wireValue];if(t!=null){if(typeof t!="string"){this.errors.add({severity:o.Critical,message:`Expected file value to be a string, got ${typeof t}`});return}return t}}getFileArrayValues({property:e,record:r}){let t=r[e.wireValue];if(t==null)return;if(!Array.isArray(t)){this.errors.add({severity:o.Critical,message:`Expected file array value to be an array of strings, got ${typeof t}`});return}let n=[];for(let i of t){if(typeof i!="string"){this.errors.add({severity:o.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}n.push(i)}return n}getRecord(e){if(typeof e!="object"||Array.isArray(e)){this.errors.add({severity:o.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(e)?"array":typeof e}`});return}return e==null?{}:e}resolveNamedType({typeId:e}){let r=this._ir.types[e];if(r==null){this.errors.add({severity:o.Critical,message:`Type identified by "${e}" could not be found`});return}return r}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:r}){let t=this.getRecord(r);if(t==null)return;let n=e.discriminant.wireValue,i=t[n];if(i==null){this.errors.add({severity:o.Critical,message:this.newParameterNotRecognizedError(n).message});return}if(typeof i!="string"){this.errors.add({severity:o.Critical,message:`Expected discriminant value to be a string but got: ${typeof i}`});return}let s=e.types[i];if(s==null){this.errors.add({severity:o.Critical,message:`No type found for discriminant value "${i}"`});return}let x=t,{[n]:d}=x,u=b(x,[S(n)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:u}}resolveEndpointOrThrow(e){let r=this.httpEndpointReferenceParser.tryParse(e);if(r==null)throw new Error(`Failed to parse endpoint reference "${e}"`);return this.resolveEndpointLocationOrThrow(r)}resolveEndpointLocation(e){let r=[];for(let t of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:t,parsedEndpoint:e})&&r.push(t);return r}resolveEndpointLocationOrThrow(e){let r=this.resolveEndpointLocation(e);if(r.length===0)throw new Error(`Failed to find endpoint identified by "${e.method} ${e.path}"`);return r}needsRequestParameter({request:e,inlinePathParameters:r,inlineFileProperties:t}){var n;return this.includePathParametersInWrappedRequest({request:e,inlinePathParameters:r})||e.queryParameters!=null&&e.queryParameters.length>0||e.headers!=null&&e.headers.length>0?!0:e.body!=null?this.includeRequestBodyInWrappedRequest({body:e.body,inlineFileProperties:t}):!((n=e.metadata)!=null&&n.onlyPathParameters)}includePathParametersInWrappedRequest({request:e,inlinePathParameters:r}){var t,n;return r&&((n=(t=e.metadata)==null?void 0:t.includePathParameters)!=null?n:!1)}isFileUploadRequestBody(e){switch(e.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:h(e)}}resolveEnvironmentName(e){if(this._ir.environments==null)return;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}case"multipleBaseUrls":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}default:h(r)}}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}validateMultiEnvironmentUrlValues(e){if(this._ir.environments==null)return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let t=r.environments[0];if(t==null)return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let n=new Set(R(t.urls));for(let i of R(e))n.has(i)&&n.delete(i);return n.size>0?(this.errors.add({severity:o.Critical,message:`The provided environments are invalid; got: [${Object.keys(e).join(", ")}], expected: [${R(t.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:e}){if(typeof e!="number"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"number",value:e}).message});return}return e}getValueAsBoolean({value:e}){if(typeof e!="boolean"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"boolean",value:e}).message});return}return e}getValueAsString({value:e}){if(typeof e!="string"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"string",value:e}).message});return}return e}isOptional(e){switch(e.type){case"nullable":return this.isOptional(e.value);case"optional":return!0;case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}isNullable(e){switch(e.type){case"nullable":return!0;case"optional":return this.isNullable(e.value);case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}newAuthMismatchError({auth:e,values:r}){return new Error(`Expected auth type ${e.type}, got ${r.type}`)}newParameterNotRecognizedError(e){return new Error(`"${e}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:e,value:r}){return new Error(`Expected ${e}, got ${typeof r}`)}includeRequestBodyInWrappedRequest({body:e,inlineFileProperties:r}){switch(e.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r});default:h(e)}}includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r}){return this.fileUploadHasBodyProperties({fileUpload:e})||r&&this.fileUploadHasFileProperties({fileUpload:e})}fileUploadHasBodyProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:h(r)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:h(r)}})}isListTypeReference(e){return e.type==="optional"?this.isListTypeReference(e.value):e.type==="list"||e.type==="set"}parsedEndpointMatches({endpoint:e,parsedEndpoint:r}){return e.location.method===r.method&&e.location.path===r.path}};p();l();var A={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};p();l();export{E as a,o as b,w as c,A as d};
2
+ //# sourceMappingURL=chunk-6OLYGRJY.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../browser-compatible-base/src/dynamic-snippets/AbstractDynamicSnippetsGenerator.ts","../../../../browser-compatible-base/src/dynamic-snippets/Result.ts","../../../../browser-compatible-base/src/dynamic-snippets/ErrorReporter.ts","../../../../browser-compatible-base/src/dynamic-snippets/AbstractDynamicSnippetsGeneratorContext.ts","../../../../../packages/cli/fern-definition/schema/src/index.ts","../../../../../packages/cli/fern-definition/schema/src/utils/HttpEndpointReferenceParser.ts","../../../../browser-compatible-base/src/dynamic-snippets/Scope.ts","../../../../browser-compatible-base/src/dynamic-snippets/index.ts"],"sourcesContent":["import { FernIr } from \"@fern-api/dynamic-ir-sdk\";\n\nimport { AbstractDynamicSnippetsGeneratorContext } from \"./AbstractDynamicSnippetsGeneratorContext\";\nimport { AbstractEndpointSnippetGenerator } from \"./AbstractEndpointSnippetGenerator\";\nimport { Options } from \"./Options\";\nimport { Result } from \"./Result\";\n\nexport abstract class AbstractDynamicSnippetsGenerator<\n Context extends AbstractDynamicSnippetsGeneratorContext,\n EndpointSnippetGenerator extends AbstractEndpointSnippetGenerator<Context>\n> {\n public constructor(public readonly context: Context) {}\n\n protected abstract createSnippetGenerator(context: Context): EndpointSnippetGenerator;\n\n public async generate(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options: Options = {}\n ): Promise<FernIr.dynamic.EndpointSnippetResponse> {\n const endpoints = this.context.resolveEndpointLocationOrThrow(request.endpoint);\n if (endpoints.length === 0) {\n throw new Error(`No endpoints found that match \"${request.endpoint.method} ${request.endpoint.path}\"`);\n }\n const result = new Result();\n for (const endpoint of endpoints) {\n const context = this.context.clone() as Context;\n const snippetGenerator = this.createSnippetGenerator(context);\n try {\n const snippet = await snippetGenerator.generateSnippet({ endpoint, request, options });\n if (context.errors.empty()) {\n return {\n snippet,\n errors: undefined\n };\n }\n result.update({ context, snippet });\n } catch (error) {\n if (result.err == null) {\n result.err = error as Error;\n }\n }\n }\n return result.getResponseOrThrow({ endpoint: request.endpoint });\n }\n\n public generateSync(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options: Options = {}\n ): FernIr.dynamic.EndpointSnippetResponse {\n const endpoints = this.context.resolveEndpointLocationOrThrow(request.endpoint);\n if (endpoints.length === 0) {\n throw new Error(`No endpoints found that match \"${request.endpoint.method} ${request.endpoint.path}\"`);\n }\n const result = new Result();\n for (const endpoint of endpoints) {\n const context = this.context.clone() as Context;\n const snippetGenerator = this.createSnippetGenerator(context);\n try {\n const snippet = snippetGenerator.generateSnippetSync({ endpoint, request, options });\n if (context.errors.empty()) {\n return {\n snippet,\n errors: undefined\n };\n }\n result.update({ context, snippet });\n } catch (error) {\n if (result.err == null) {\n result.err = error as Error;\n }\n }\n }\n return result.getResponseOrThrow({ endpoint: request.endpoint });\n }\n}\n","import { FernIr } from \"@fern-api/dynamic-ir-sdk\";\n\nimport { AbstractDynamicSnippetsGeneratorContext } from \"./AbstractDynamicSnippetsGeneratorContext\";\nimport { ErrorReporter } from \"./ErrorReporter\";\n\nexport class Result {\n public reporter: ErrorReporter | undefined;\n public snippet: string | undefined;\n public err: Error | undefined;\n\n constructor() {\n this.snippet = undefined;\n this.reporter = undefined;\n this.err = undefined;\n }\n\n public update({ context, snippet }: { context: AbstractDynamicSnippetsGeneratorContext; snippet: string }): void {\n if (this.shouldUpdate({ snippet, reporter: context.errors })) {\n this.reporter = context.errors.clone();\n this.snippet = snippet;\n }\n }\n\n public getResponseOrThrow({\n endpoint\n }: {\n endpoint: FernIr.dynamic.EndpointLocation;\n }): FernIr.dynamic.EndpointSnippetResponse {\n if (this.snippet != null && this.reporter != null) {\n return {\n snippet: this.snippet,\n errors: this.reporter.toDynamicSnippetErrors()\n };\n }\n throw this.err ?? new Error(`Failed to generate snippet for endpoint \"${endpoint.method} ${endpoint.path}\"`);\n }\n\n private shouldUpdate({ snippet, reporter }: { snippet: string; reporter: ErrorReporter }): boolean {\n if (this.reporter == null || (this.reporter.size() > 0 && reporter.size() === 0)) {\n return true;\n }\n return snippet.length > (this.snippet?.length ?? 0);\n }\n}\n","export const Severity = {\n Critical: \"CRITICAL\",\n Warning: \"WARNING\"\n} as const;\n\nexport declare namespace ErrorReporter {\n type Path = readonly PathItem[];\n\n type PathItem = string | ArrayPathItem;\n\n type Severity = (typeof Severity)[keyof typeof Severity];\n\n interface ArrayPathItem {\n index: number;\n }\n\n interface Error {\n path?: Path;\n severity: Severity;\n message: string;\n }\n}\n\ninterface Error_ {\n severity: \"CRITICAL\" | \"WARNING\";\n path: string[] | undefined;\n message: string;\n}\n\nexport class ErrorReporter {\n private errors: ErrorReporter.Error[];\n private path: ErrorReporter.PathItem[];\n\n constructor() {\n this.errors = [];\n this.path = [];\n }\n\n public add(err: Omit<ErrorReporter.Error, \"path\">): void {\n this.errors.push({\n ...err,\n path: [...this.path]\n });\n }\n\n public scope(path: ErrorReporter.PathItem): void {\n this.path.push(path);\n }\n\n public unscope(): void {\n this.path.pop();\n }\n\n public getBySeverity(severity: ErrorReporter.Severity): ErrorReporter.Error[] {\n return this.errors.filter((err) => err.severity === severity);\n }\n\n public empty(): boolean {\n return this.errors.length === 0;\n }\n\n public size(): number {\n return this.errors.length;\n }\n\n public clone(): ErrorReporter {\n const clone = new ErrorReporter();\n clone.errors = [...this.errors];\n clone.path = [...this.path];\n return clone;\n }\n\n public reset(): void {\n this.errors = [];\n this.path = [];\n }\n\n public toDynamicSnippetErrors(): Error_[] {\n return this.errors.map((err) => ({\n severity: err.severity,\n path: err.path != null ? this.pathToStringArray(err.path) : undefined,\n message: err.message\n }));\n }\n\n private pathToStringArray(path: ErrorReporter.Path): string[] {\n const result: string[] = [];\n for (const item of path) {\n if (typeof item === \"string\") {\n result.push(item);\n continue;\n }\n result[result.length - 1] += `[${item.index}]`;\n }\n return result;\n }\n}\n","import { assertNever, keys } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { HttpEndpointReferenceParser } from \"@fern-api/fern-definition-schema\";\n\nimport { FernGeneratorExec } from \"../GeneratorNotificationService\";\nimport { DiscriminatedUnionTypeInstance } from \"./DiscriminatedUnionTypeInstance\";\nimport { ErrorReporter, Severity } from \"./ErrorReporter\";\nimport { Options } from \"./Options\";\nimport { TypeInstance } from \"./TypeInstance\";\n\nexport abstract class AbstractDynamicSnippetsGeneratorContext {\n public config: FernGeneratorExec.GeneratorConfig;\n public options: Options;\n public errors: ErrorReporter;\n\n private _ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n private httpEndpointReferenceParser: HttpEndpointReferenceParser;\n\n constructor({\n ir,\n config,\n options = {}\n }: {\n ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n config: FernGeneratorExec.GeneratorConfig;\n options?: Options;\n }) {\n this._ir = ir;\n this.config = config;\n this.options = options;\n this.errors = new ErrorReporter();\n this.httpEndpointReferenceParser = new HttpEndpointReferenceParser();\n }\n\n public abstract clone(): AbstractDynamicSnippetsGeneratorContext;\n\n public associateQueryParametersByWireValue({\n parameters,\n values\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): TypeInstance[] {\n const instances: TypeInstance[] = [];\n for (const [key, value] of Object.entries(values)) {\n this.errors.scope(key);\n try {\n const parameter = parameters.find((param) => param.name.wireValue === key);\n if (parameter == null) {\n throw this.newParameterNotRecognizedError(key);\n }\n // If this query parameter supports allow-multiple, the user-provided values\n // must be wrapped in an array.\n const typeInstanceValue =\n this.isListTypeReference(parameter.typeReference) && !Array.isArray(value) ? [value] : value;\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value: typeInstanceValue\n });\n } finally {\n this.errors.unscope();\n }\n }\n return instances;\n }\n\n public associateByWireValueOrDefault({\n parameters,\n values\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): TypeInstance[] {\n const instances: TypeInstance[] = [];\n for (const parameter of parameters) {\n this.errors.scope(parameter.name.wireValue);\n try {\n let value = values[parameter.name.wireValue];\n\n if (value == null) {\n if (parameter.typeReference.type === \"primitive\" && parameter.typeReference.value === \"STRING\") {\n // synthesize a parameter value for string parameters that are missing data\n value = `<${parameter.name.wireValue}>`;\n } else {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newParameterNotRecognizedError(parameter.name.wireValue).message\n });\n continue;\n }\n }\n\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value\n });\n } finally {\n this.errors.unscope();\n }\n }\n\n return instances;\n }\n\n public associateByWireValue({\n parameters,\n values,\n ignoreMissingParameters\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n ignoreMissingParameters?: boolean;\n }): TypeInstance[] {\n const instances: TypeInstance[] = [];\n for (const [key, value] of Object.entries(values)) {\n this.errors.scope(key);\n try {\n const parameter = parameters.find((param) => param.name.wireValue === key);\n if (parameter == null) {\n if (ignoreMissingParameters) {\n // Required for request payloads that include more information than\n // just the target parameters (e.g. union base properties).\n continue;\n }\n this.errors.add({\n severity: Severity.Critical,\n message: this.newParameterNotRecognizedError(key).message\n });\n continue;\n }\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value\n });\n } finally {\n this.errors.unscope();\n }\n }\n return instances;\n }\n\n /**\n * Similar to `associateByWireValue` but it builds TypeInstance objects by iterating over schema parameters rather\n * than snippet values. Skips non-nullable parameters that are missing from the snippet object.\n */\n public getExampleObjectProperties({\n parameters,\n snippetObject\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n snippetObject: unknown;\n }): TypeInstance[] {\n const objectRecord = (\n typeof snippetObject === \"object\" && snippetObject !== null && !Array.isArray(snippetObject)\n ? snippetObject\n : {}\n ) as Record<string, unknown>;\n const instances: TypeInstance[] = [];\n for (const parameter of parameters) {\n const value = objectRecord[parameter.name.wireValue];\n if (value == null) {\n if (parameter.typeReference.type === \"nullable\") {\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value: null\n });\n }\n } else {\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value\n });\n }\n }\n return instances;\n }\n\n public getSingleFileValue({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.File_;\n record: Record<string, unknown>;\n }): string | undefined {\n const fileValue = record[property.wireValue];\n if (fileValue == null) {\n return undefined;\n }\n if (typeof fileValue !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected file value to be a string, got ${typeof fileValue}`\n });\n return undefined;\n }\n return fileValue;\n }\n\n public getFileArrayValues({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.FileArray;\n record: Record<string, unknown>;\n }): string[] | undefined {\n const fileArrayValue = record[property.wireValue];\n if (fileArrayValue == null) {\n return undefined;\n }\n if (!Array.isArray(fileArrayValue)) {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected file array value to be an array of strings, got ${typeof fileArrayValue}`\n });\n return undefined;\n }\n const stringValues: string[] = [];\n for (const value of fileArrayValue) {\n if (typeof value !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected file array value to be an array of strings, got ${typeof value}`\n });\n return undefined;\n }\n stringValues.push(value);\n }\n return stringValues;\n }\n\n public getRecord(value: unknown): Record<string, unknown> | undefined {\n if (typeof value !== \"object\" || Array.isArray(value)) {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected object with key, value pairs but got: ${\n Array.isArray(value) ? \"array\" : typeof value\n }`\n });\n return undefined;\n }\n if (value == null) {\n return {};\n }\n return value as Record<string, unknown>;\n }\n\n public resolveNamedType({ typeId }: { typeId: FernIr.dynamic.TypeId }): FernIr.dynamic.NamedType | undefined {\n const namedType = this._ir.types[typeId];\n if (namedType == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: `Type identified by \"${typeId}\" could not be found`\n });\n return undefined;\n }\n return namedType;\n }\n\n public resolveDiscriminatedUnionTypeInstance({\n discriminatedUnion,\n value\n }: {\n discriminatedUnion: FernIr.dynamic.DiscriminatedUnionType;\n value: unknown;\n }): DiscriminatedUnionTypeInstance | undefined {\n const record = this.getRecord(value);\n if (record == null) {\n return undefined;\n }\n\n const discriminantFieldName = discriminatedUnion.discriminant.wireValue;\n const discriminantValue = record[discriminantFieldName];\n if (discriminantValue == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newParameterNotRecognizedError(discriminantFieldName).message\n });\n return undefined;\n }\n if (typeof discriminantValue !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected discriminant value to be a string but got: ${typeof discriminantValue}`\n });\n return undefined;\n }\n\n const singleDiscriminatedUnionType = discriminatedUnion.types[discriminantValue];\n if (singleDiscriminatedUnionType == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: `No type found for discriminant value \"${discriminantValue}\"`\n });\n return undefined;\n }\n\n // Remove the discriminant from the record so that the value is valid for the type.\n const { [discriminantFieldName]: _, ...filtered } = record;\n\n return {\n singleDiscriminatedUnionType,\n discriminantValue: singleDiscriminatedUnionType.discriminantValue,\n value: filtered\n };\n }\n\n public resolveEndpointOrThrow(rawEndpoint: string): FernIr.dynamic.Endpoint[] {\n const parsedEndpoint = this.httpEndpointReferenceParser.tryParse(rawEndpoint);\n if (parsedEndpoint == null) {\n throw new Error(`Failed to parse endpoint reference \"${rawEndpoint}\"`);\n }\n return this.resolveEndpointLocationOrThrow(parsedEndpoint);\n }\n\n public resolveEndpointLocation(location: FernIr.dynamic.EndpointLocation): FernIr.dynamic.Endpoint[] {\n const endpoints: FernIr.dynamic.Endpoint[] = [];\n for (const endpoint of Object.values(this._ir.endpoints)) {\n if (this.parsedEndpointMatches({ endpoint, parsedEndpoint: location })) {\n endpoints.push(endpoint);\n }\n }\n\n return endpoints;\n }\n\n public resolveEndpointLocationOrThrow(location: FernIr.dynamic.EndpointLocation): FernIr.dynamic.Endpoint[] {\n const endpoints = this.resolveEndpointLocation(location);\n if (endpoints.length === 0) {\n throw new Error(`Failed to find endpoint identified by \"${location.method} ${location.path}\"`);\n }\n return endpoints;\n }\n\n public needsRequestParameter({\n request,\n inlinePathParameters,\n inlineFileProperties\n }: {\n request: FernIr.dynamic.InlinedRequest;\n inlinePathParameters: boolean;\n inlineFileProperties: boolean;\n }): boolean {\n if (this.includePathParametersInWrappedRequest({ request, inlinePathParameters })) {\n return true;\n }\n if (request.queryParameters != null && request.queryParameters.length > 0) {\n return true;\n }\n if (request.headers != null && request.headers.length > 0) {\n return true;\n }\n if (request.body != null) {\n return this.includeRequestBodyInWrappedRequest({ body: request.body, inlineFileProperties });\n }\n if (request.metadata?.onlyPathParameters) {\n return false;\n }\n return true;\n }\n\n public includePathParametersInWrappedRequest({\n request,\n inlinePathParameters\n }: {\n request: FernIr.dynamic.InlinedRequest;\n inlinePathParameters: boolean;\n }): boolean {\n return inlinePathParameters && (request.metadata?.includePathParameters ?? false);\n }\n\n public isFileUploadRequestBody(\n body: FernIr.dynamic.InlinedRequestBody\n ): body is FernIr.dynamic.InlinedRequestBody.FileUpload {\n switch (body.type) {\n case \"fileUpload\":\n return true;\n case \"properties\":\n case \"referenced\":\n return false;\n default:\n assertNever(body);\n }\n }\n\n public resolveEnvironmentName(environmentID: string): FernIr.Name | undefined {\n if (this._ir.environments == null) {\n return undefined;\n }\n const environments = this._ir.environments.environments;\n switch (environments.type) {\n case \"singleBaseUrl\": {\n const environment = environments.environments.find((env) => env.id === environmentID);\n if (environment == null) {\n return undefined;\n }\n return environment.name;\n }\n case \"multipleBaseUrls\": {\n const environment = environments.environments.find((env) => env.id === environmentID);\n if (environment == null) {\n return undefined;\n }\n return environment.name;\n }\n default:\n assertNever(environments);\n }\n }\n\n public isSingleEnvironmentID(\n environment: FernIr.dynamic.EnvironmentValues\n ): environment is FernIr.dynamic.EnvironmentId {\n return typeof environment === \"string\";\n }\n\n public isMultiEnvironmentValues(\n environment: FernIr.dynamic.EnvironmentValues\n ): environment is FernIr.dynamic.MultipleEnvironmentUrlValues {\n return typeof environment === \"object\";\n }\n\n public validateMultiEnvironmentUrlValues(\n multiEnvironmentUrlValues: FernIr.dynamic.MultipleEnvironmentUrlValues\n ): boolean {\n if (this._ir.environments == null) {\n this.errors.add({\n severity: Severity.Critical,\n message:\n \"Multiple environments are not supported for single base URL environments; use the baseUrl option instead\"\n });\n return false;\n }\n const environments = this._ir.environments.environments;\n switch (environments.type) {\n case \"singleBaseUrl\": {\n this.errors.add({\n severity: Severity.Critical,\n message:\n \"Multiple environments are not supported for single base URL environments; use the baseUrl option instead\"\n });\n return false;\n }\n case \"multipleBaseUrls\": {\n const firstEnvironment = environments.environments[0];\n if (firstEnvironment == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: \"Multiple environments are not supported; use the baseUrl option instead\"\n });\n return false;\n }\n const expectedKeys = new Set(keys(firstEnvironment.urls));\n for (const key of keys(multiEnvironmentUrlValues)) {\n if (expectedKeys.has(key)) {\n expectedKeys.delete(key);\n }\n }\n if (expectedKeys.size > 0) {\n this.errors.add({\n severity: Severity.Critical,\n message: `The provided environments are invalid; got: [${Object.keys(multiEnvironmentUrlValues).join(\", \")}], expected: [${keys(firstEnvironment.urls).join(\", \")}]`\n });\n return false;\n }\n return true;\n }\n }\n }\n\n public getValueAsNumber({ value }: { value: unknown }): number | undefined {\n if (typeof value !== \"number\") {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newTypeMismatchError({ expected: \"number\", value }).message\n });\n return undefined;\n }\n return value;\n }\n\n public getValueAsBoolean({ value }: { value: unknown }): boolean | undefined {\n if (typeof value !== \"boolean\") {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newTypeMismatchError({ expected: \"boolean\", value }).message\n });\n return undefined;\n }\n return value;\n }\n\n public getValueAsString({ value }: { value: unknown }): string | undefined {\n if (typeof value !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newTypeMismatchError({ expected: \"string\", value }).message\n });\n return undefined;\n }\n return value;\n }\n\n public isOptional(typeReference: FernIr.dynamic.TypeReference): boolean {\n switch (typeReference.type) {\n case \"nullable\":\n return this.isOptional(typeReference.value);\n case \"optional\":\n return true;\n case \"named\": {\n const resolvedType = this.resolveNamedType({ typeId: typeReference.value });\n if (resolvedType == null) {\n return false;\n }\n if (resolvedType.type === \"alias\") {\n return this.isNullable(resolvedType.typeReference);\n }\n return false;\n }\n }\n return false;\n }\n\n public isNullable(typeReference: FernIr.dynamic.TypeReference): boolean {\n switch (typeReference.type) {\n case \"nullable\":\n return true;\n case \"optional\":\n return this.isNullable(typeReference.value);\n case \"named\": {\n const resolvedType = this.resolveNamedType({ typeId: typeReference.value });\n if (resolvedType == null) {\n return false;\n }\n if (resolvedType.type === \"alias\") {\n return this.isNullable(resolvedType.typeReference);\n }\n return false;\n }\n }\n return false;\n }\n\n public newAuthMismatchError({\n auth,\n values\n }: {\n auth: FernIr.dynamic.Auth;\n values: FernIr.dynamic.AuthValues;\n }): Error {\n return new Error(`Expected auth type ${auth.type}, got ${values.type}`);\n }\n\n public newParameterNotRecognizedError(parameterName: string): Error {\n return new Error(`\"${parameterName}\" is not a recognized parameter for this endpoint`);\n }\n\n public newTypeMismatchError({ expected, value }: { expected: string; value: unknown }): Error {\n return new Error(`Expected ${expected}, got ${typeof value}`);\n }\n\n private includeRequestBodyInWrappedRequest({\n body,\n inlineFileProperties\n }: {\n body: FernIr.dynamic.InlinedRequestBody;\n inlineFileProperties: boolean;\n }): boolean {\n switch (body.type) {\n case \"properties\":\n case \"referenced\":\n return true;\n case \"fileUpload\":\n return this.includeFileUploadBodyInWrappedRequest({ fileUpload: body, inlineFileProperties });\n default:\n assertNever(body);\n }\n }\n\n private includeFileUploadBodyInWrappedRequest({\n fileUpload,\n inlineFileProperties\n }: {\n fileUpload: FernIr.dynamic.FileUploadRequestBody;\n inlineFileProperties: boolean;\n }): boolean {\n return (\n this.fileUploadHasBodyProperties({ fileUpload }) ||\n (inlineFileProperties && this.fileUploadHasFileProperties({ fileUpload }))\n );\n }\n\n private fileUploadHasBodyProperties({ fileUpload }: { fileUpload: FernIr.dynamic.FileUploadRequestBody }): boolean {\n return fileUpload.properties.some((property) => {\n switch (property.type) {\n case \"file\":\n case \"fileArray\":\n return false;\n case \"bodyProperty\":\n return true;\n default:\n assertNever(property);\n }\n });\n }\n\n private fileUploadHasFileProperties({ fileUpload }: { fileUpload: FernIr.dynamic.FileUploadRequestBody }): boolean {\n return fileUpload.properties.some((property) => {\n switch (property.type) {\n case \"file\":\n case \"fileArray\":\n return true;\n case \"bodyProperty\":\n return false;\n default:\n assertNever(property);\n }\n });\n }\n\n private isListTypeReference(typeReference: FernIr.dynamic.TypeReference): boolean {\n if (typeReference.type === \"optional\") {\n return this.isListTypeReference(typeReference.value);\n }\n return typeReference.type === \"list\" || typeReference.type === \"set\";\n }\n\n private parsedEndpointMatches({\n endpoint,\n parsedEndpoint\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n parsedEndpoint: HttpEndpointReferenceParser.Parsed;\n }): boolean {\n return endpoint.location.method === parsedEndpoint.method && endpoint.location.path === parsedEndpoint.path;\n }\n}\n","export { EXAMPLE_REFERENCE_PREFIX, YAML_SCHEMA_VERSION } from \"./constants\";\nexport { type NodePath, type NodePathItem } from \"./NodePath\";\nexport * as RawSchemas from \"./schemas\";\nexport { type DefinitionFileSchema, type PackageMarkerFileSchema, type RootApiFileSchema } from \"./schemas\";\nexport * from \"./utils/auth\";\nexport * from \"./utils/generics\";\nexport { getRequestBody } from \"./utils/getRequestBody\";\nexport { getResponseBodyType } from \"./utils/getResponseBodyType\";\nexport { HttpEndpointReferenceParser } from \"./utils/HttpEndpointReferenceParser\";\nexport { isInlineRequestBody } from \"./utils/isInlineRequestBody\";\nexport { isOpenApiSourceSchema } from \"./utils/isOpenApiSourceSchema\";\nexport { isRawProtobufSourceSchema } from \"./utils/isRawProtobufSourceSchema\";\nexport { isRawTextType } from \"./utils/isRawTextType\";\nexport { type BytesRequest, parseBytesRequest } from \"./utils/parseBytesRequest\";\nexport { parseFileUploadRequest, type RawFileUploadRequest } from \"./utils/parseFileUploadRequest\";\nexport { parseRawBytesType, type RawBytesType } from \"./utils/parseRawBytesType\";\nexport { parseRawFileType, type RawFileType } from \"./utils/parseRawFileType\";\nexport { parseRawTextType, type RawTextType } from \"./utils/parseRawTextType\";\nexport { RawPrimitiveType } from \"./utils/RawPrimitiveType\";\nexport { recursivelyVisitRawTypeReference } from \"./utils/recursivelyVisitRawTypeReference\";\nexport { visitExampleCodeSampleSchema } from \"./utils/visitExampleCodeSampleSchema\";\nexport { type ExampleResponseSchemaVisitor, visitExampleResponseSchema } from \"./utils/visitExampleResponseSchema\";\nexport { isAnyAuthSchemes, isSingleAuthScheme, type RawApiAuthVisitor, visitRawApiAuth } from \"./utils/visitRawApiAuth\";\nexport {\n type AuthSchemeDeclarationVisitor,\n isHeaderAuthScheme,\n visitRawAuthSchemeDeclaration\n} from \"./utils/visitRawAuthSchemeDeclaration\";\nexport {\n isRawMultipleBaseUrlsEnvironment,\n isRawSingleBaseUrlEnvironment,\n visitRawEnvironmentDeclaration\n} from \"./utils/visitRawEnvironmentDeclaration\";\nexport {\n isVariablePathParameter,\n type PathParameterDeclarationVisitor,\n visitRawPathParameter\n} from \"./utils/visitRawPathParameter\";\nexport {\n isRawAliasDefinition,\n isRawDiscriminatedUnionDefinition,\n isRawEnumDefinition,\n isRawObjectDefinition,\n isRawUndiscriminatedUnionDefinition,\n type RawTypeDeclarationVisitor,\n visitRawTypeDeclaration\n} from \"./utils/visitRawTypeDeclaration\";\nexport { FernContainerRegex, visitRawTypeReference } from \"./utils/visitRawTypeReference\";\n","export declare namespace HttpEndpointReferenceParser {\n interface Parsed {\n path: string;\n method: Method;\n }\n\n type Method = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\" | \"HEAD\";\n\n export type ValidationResult = Valid | Invalid;\n\n interface Valid {\n type: \"valid\";\n }\n\n interface Invalid {\n type: \"invalid\";\n }\n}\n\n/**\n * Parses an HTTP endpoint reference like `POST /users/get`\n */\nexport class HttpEndpointReferenceParser {\n //eslint-disable-next-line\n private REFERENCE_REGEX = /^(GET|POST|PUT|DELETE|PATCH|HEAD)\\s(\\/\\S*)$/;\n\n public validate(reference: string): HttpEndpointReferenceParser.ValidationResult {\n const validFormat = this.REFERENCE_REGEX.test(reference);\n if (!validFormat) {\n return { type: \"invalid\" };\n }\n return { type: \"valid\" };\n }\n\n public tryParse(reference: string): HttpEndpointReferenceParser.Parsed | undefined {\n const validationResponse = this.validate(reference);\n if (validationResponse.type === \"invalid\") {\n return undefined;\n }\n const match = reference.match(this.REFERENCE_REGEX);\n if (match == null || match[1] == null || match[2] == null) {\n return undefined;\n }\n return {\n method: match[1] as HttpEndpointReferenceParser.Method,\n path: match[2]\n };\n }\n}\n","export const Scope = {\n PathParameters: \"pathParameters\",\n QueryParameters: \"queryParameters\",\n Headers: \"headers\",\n RequestBody: \"requestBody\"\n} as const;\n\nexport type Scope = (typeof Scope)[keyof typeof Scope];\n","export { AbstractDynamicSnippetsGenerator } from \"./AbstractDynamicSnippetsGenerator\";\nexport { AbstractDynamicSnippetsGeneratorContext } from \"./AbstractDynamicSnippetsGeneratorContext\";\nexport { type DiscriminatedUnionTypeInstance } from \"./DiscriminatedUnionTypeInstance\";\nexport { ErrorReporter, Severity } from \"./ErrorReporter\";\nexport { type Options, Style } from \"./Options\";\nexport { Result } from \"./Result\";\nexport { Scope } from \"./Scope\";\nexport { type TypeInstance } from \"./TypeInstance\";\nexport { DynamicSnippetsTestRunner } from \"./test-utils/DynamicSnippetsTestRunner\";\n"],"mappings":"gGAKAA,IAAAC,ICAAC,IAAAC,IAAM,IAAOC,EAAP,KAAa,CAKf,aAAA,CAJOC,EAAA,iBACAA,EAAA,gBACAA,EAAA,YAGH,KAAK,QAAU,OACf,KAAK,SAAW,OAChB,KAAK,IAAM,MACf,CAEO,OAAO,CAAE,QAAAC,EAAS,QAAAC,CAAO,EAAyE,CACjG,KAAK,aAAa,CAAE,QAAAA,EAAS,SAAUD,EAAQ,MAAM,CAAE,IACvD,KAAK,SAAWA,EAAQ,OAAO,MAAK,EACpC,KAAK,QAAUC,EAEvB,CAEO,mBAAmB,CACtB,SAAAC,CAAQ,EAGX,CAtBL,IAAAC,EAuBQ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D,MAAO,GACX,IAAK,aACD,OAAO,KAAK,sCAAsC,CAAE,WAAYA,EAAM,qBAAAF,CAAoB,CAAE,EAChG,QACIG,EAAYD,CAAI,CACxB,CACJ,CAEQ,sCAAsC,CAC1C,WAAAe,EACA,qBAAAjB,CAAoB,EAIvB,CACG,OACI,KAAK,4BAA4B,CAAE,WAAAiB,CAAU,CAAE,GAC9CjB,GAAwB,KAAK,4BAA4B,CAAE,WAAAiB,CAAU,CAAE,CAEhF,CAEQ,4BAA4B,CAAE,WAAAA,CAAU,EAAwD,CACpG,OAAOA,EAAW,WAAW,KAAMxC,GAAY,CAC3C,OAAQA,EAAS,KAAM,CACnB,IAAK,OACL,IAAK,YACD,MAAO,GACX,IAAK,eACD,MAAO,GACX,QACI0B,EAAY1B,CAAQ,CAC5B,CACJ,CAAC,CACL,CAEQ,4BAA4B,CAAE,WAAAwC,CAAU,EAAwD,CACpG,OAAOA,EAAW,WAAW,KAAMxC,GAAY,CAC3C,OAAQA,EAAS,KAAM,CACnB,IAAK,OACL,IAAK,YACD,MAAO,GACX,IAAK,eACD,MAAO,GACX,QACI0B,EAAY1B,CAAQ,CAC5B,CACJ,CAAC,CACL,CAEQ,oBAAoBmC,EAA2C,CACnE,OAAIA,EAAc,OAAS,WAChB,KAAK,oBAAoBA,EAAc,KAAK,EAEhDA,EAAc,OAAS,QAAUA,EAAc,OAAS,KACnE,CAEQ,sBAAsB,CAC1B,SAAAf,EACA,eAAAH,CAAc,EAIjB,CACG,OAAOG,EAAS,SAAS,SAAWH,EAAe,QAAUG,EAAS,SAAS,OAASH,EAAe,IAC3G,GG/nBJwB,IAAAC,IAAO,IAAMC,EAAQ,CACjB,eAAgB,iBAChB,gBAAiB,kBACjB,QAAS,UACT,YAAa,eCJjBC,IAAAC","names":["init_process","init_buffer","init_process","init_buffer","Result","__publicField","context","snippet","endpoint","_a","reporter","_b","AbstractDynamicSnippetsGenerator","context","__publicField","request","options","endpoints","result","Result","endpoint","snippetGenerator","snippet","error","init_process","init_buffer","Severity","ErrorReporter","_ErrorReporter","__publicField","err","__spreadProps","__spreadValues","path","severity","clone","result","item","init_process","init_buffer","init_process","init_buffer","init_process","init_buffer","HttpEndpointReferenceParser","__publicField","reference","match","AbstractDynamicSnippetsGeneratorContext","ir","config","options","__publicField","ErrorReporter","HttpEndpointReferenceParser","parameters","values","instances","key","value","parameter","param","typeInstanceValue","Severity","ignoreMissingParameters","snippetObject","objectRecord","property","record","fileValue","fileArrayValue","stringValues","typeId","namedType","discriminatedUnion","discriminantFieldName","discriminantValue","singleDiscriminatedUnionType","_a","_","filtered","__objRest","__restKey","rawEndpoint","parsedEndpoint","location","endpoints","endpoint","request","inlinePathParameters","inlineFileProperties","_b","body","assertNever","environmentID","environments","environment","env","multiEnvironmentUrlValues","firstEnvironment","expectedKeys","keys","typeReference","resolvedType","auth","parameterName","expected","fileUpload","init_process","init_buffer","Scope","init_process","init_buffer"]}
1
+ {"version":3,"sources":["../../../../browser-compatible-base/src/dynamic-snippets/AbstractDynamicSnippetsGenerator.ts","../../../../browser-compatible-base/src/dynamic-snippets/Result.ts","../../../../browser-compatible-base/src/dynamic-snippets/ErrorReporter.ts","../../../../browser-compatible-base/src/dynamic-snippets/AbstractDynamicSnippetsGeneratorContext.ts","../../../../../packages/cli/fern-definition/schema/src/index.ts","../../../../../packages/cli/fern-definition/schema/src/utils/HttpEndpointReferenceParser.ts","../../../../browser-compatible-base/src/dynamic-snippets/Scope.ts","../../../../browser-compatible-base/src/dynamic-snippets/index.ts"],"sourcesContent":["import { FernIr } from \"@fern-api/dynamic-ir-sdk\";\n\nimport { AbstractDynamicSnippetsGeneratorContext } from \"./AbstractDynamicSnippetsGeneratorContext\";\nimport { AbstractEndpointSnippetGenerator } from \"./AbstractEndpointSnippetGenerator\";\nimport { Options } from \"./Options\";\nimport { Result } from \"./Result\";\n\nexport abstract class AbstractDynamicSnippetsGenerator<\n Context extends AbstractDynamicSnippetsGeneratorContext,\n EndpointSnippetGenerator extends AbstractEndpointSnippetGenerator<Context>\n> {\n public constructor(public readonly context: Context) {}\n\n protected abstract createSnippetGenerator(context: Context): EndpointSnippetGenerator;\n\n public async generate(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options: Options = {}\n ): Promise<FernIr.dynamic.EndpointSnippetResponse> {\n const endpoints = this.context.resolveEndpointLocationOrThrow(request.endpoint);\n if (endpoints.length === 0) {\n throw new Error(`No endpoints found that match \"${request.endpoint.method} ${request.endpoint.path}\"`);\n }\n const result = new Result();\n for (const endpoint of endpoints) {\n const context = this.context.clone() as Context;\n const snippetGenerator = this.createSnippetGenerator(context);\n try {\n const snippet = await snippetGenerator.generateSnippet({ endpoint, request, options });\n if (context.errors.empty()) {\n return {\n snippet,\n errors: undefined\n };\n }\n result.update({ context, snippet });\n } catch (error) {\n if (result.err == null) {\n result.err = error as Error;\n }\n }\n }\n return result.getResponseOrThrow({ endpoint: request.endpoint });\n }\n\n public generateSync(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options: Options = {}\n ): FernIr.dynamic.EndpointSnippetResponse {\n const endpoints = this.context.resolveEndpointLocationOrThrow(request.endpoint);\n if (endpoints.length === 0) {\n throw new Error(`No endpoints found that match \"${request.endpoint.method} ${request.endpoint.path}\"`);\n }\n const result = new Result();\n for (const endpoint of endpoints) {\n const context = this.context.clone() as Context;\n const snippetGenerator = this.createSnippetGenerator(context);\n try {\n const snippet = snippetGenerator.generateSnippetSync({ endpoint, request, options });\n if (context.errors.empty()) {\n return {\n snippet,\n errors: undefined\n };\n }\n result.update({ context, snippet });\n } catch (error) {\n if (result.err == null) {\n result.err = error as Error;\n }\n }\n }\n return result.getResponseOrThrow({ endpoint: request.endpoint });\n }\n}\n","import { FernIr } from \"@fern-api/dynamic-ir-sdk\";\n\nimport { AbstractDynamicSnippetsGeneratorContext } from \"./AbstractDynamicSnippetsGeneratorContext\";\nimport { ErrorReporter } from \"./ErrorReporter\";\n\nexport class Result {\n public reporter: ErrorReporter | undefined;\n public snippet: string | undefined;\n public err: Error | undefined;\n\n constructor() {\n this.snippet = undefined;\n this.reporter = undefined;\n this.err = undefined;\n }\n\n public update({ context, snippet }: { context: AbstractDynamicSnippetsGeneratorContext; snippet: string }): void {\n if (this.shouldUpdate({ snippet, reporter: context.errors })) {\n this.reporter = context.errors.clone();\n this.snippet = snippet;\n }\n }\n\n public getResponseOrThrow({\n endpoint\n }: {\n endpoint: FernIr.dynamic.EndpointLocation;\n }): FernIr.dynamic.EndpointSnippetResponse {\n if (this.snippet != null && this.reporter != null) {\n return {\n snippet: this.snippet,\n errors: this.reporter.toDynamicSnippetErrors()\n };\n }\n throw this.err ?? new Error(`Failed to generate snippet for endpoint \"${endpoint.method} ${endpoint.path}\"`);\n }\n\n private shouldUpdate({ snippet, reporter }: { snippet: string; reporter: ErrorReporter }): boolean {\n if (this.reporter == null || (this.reporter.size() > 0 && reporter.size() === 0)) {\n return true;\n }\n return snippet.length > (this.snippet?.length ?? 0);\n }\n}\n","export const Severity = {\n Critical: \"CRITICAL\",\n Warning: \"WARNING\"\n} as const;\n\nexport declare namespace ErrorReporter {\n type Path = readonly PathItem[];\n\n type PathItem = string | ArrayPathItem;\n\n type Severity = (typeof Severity)[keyof typeof Severity];\n\n interface ArrayPathItem {\n index: number;\n }\n\n interface Error {\n path?: Path;\n severity: Severity;\n message: string;\n }\n}\n\ninterface Error_ {\n severity: \"CRITICAL\" | \"WARNING\";\n path: string[] | undefined;\n message: string;\n}\n\nexport class ErrorReporter {\n private errors: ErrorReporter.Error[];\n private path: ErrorReporter.PathItem[];\n\n constructor() {\n this.errors = [];\n this.path = [];\n }\n\n public add(err: Omit<ErrorReporter.Error, \"path\">): void {\n this.errors.push({\n ...err,\n path: [...this.path]\n });\n }\n\n public scope(path: ErrorReporter.PathItem): void {\n this.path.push(path);\n }\n\n public unscope(): void {\n this.path.pop();\n }\n\n public getBySeverity(severity: ErrorReporter.Severity): ErrorReporter.Error[] {\n return this.errors.filter((err) => err.severity === severity);\n }\n\n public empty(): boolean {\n return this.errors.length === 0;\n }\n\n public size(): number {\n return this.errors.length;\n }\n\n public clone(): ErrorReporter {\n const clone = new ErrorReporter();\n clone.errors = [...this.errors];\n clone.path = [...this.path];\n return clone;\n }\n\n public reset(): void {\n this.errors = [];\n this.path = [];\n }\n\n public toDynamicSnippetErrors(): Error_[] {\n return this.errors.map((err) => ({\n severity: err.severity,\n path: err.path != null ? this.pathToStringArray(err.path) : undefined,\n message: err.message\n }));\n }\n\n private pathToStringArray(path: ErrorReporter.Path): string[] {\n const result: string[] = [];\n for (const item of path) {\n if (typeof item === \"string\") {\n result.push(item);\n continue;\n }\n result[result.length - 1] += `[${item.index}]`;\n }\n return result;\n }\n}\n","import { assertNever, keys } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { HttpEndpointReferenceParser } from \"@fern-api/fern-definition-schema\";\n\nimport { FernGeneratorExec } from \"../GeneratorNotificationService\";\nimport { DiscriminatedUnionTypeInstance } from \"./DiscriminatedUnionTypeInstance\";\nimport { ErrorReporter, Severity } from \"./ErrorReporter\";\nimport { Options } from \"./Options\";\nimport { TypeInstance } from \"./TypeInstance\";\n\nexport abstract class AbstractDynamicSnippetsGeneratorContext {\n public config: FernGeneratorExec.GeneratorConfig;\n public options: Options;\n public errors: ErrorReporter;\n\n private _ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n private httpEndpointReferenceParser: HttpEndpointReferenceParser;\n\n constructor({\n ir,\n config,\n options = {}\n }: {\n ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n config: FernGeneratorExec.GeneratorConfig;\n options?: Options;\n }) {\n this._ir = ir;\n this.config = config;\n this.options = options;\n this.errors = new ErrorReporter();\n this.httpEndpointReferenceParser = new HttpEndpointReferenceParser();\n }\n\n public abstract clone(): AbstractDynamicSnippetsGeneratorContext;\n\n public associateQueryParametersByWireValue({\n parameters,\n values\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): TypeInstance[] {\n const instances: TypeInstance[] = [];\n for (const [key, value] of Object.entries(values)) {\n this.errors.scope(key);\n try {\n const parameter = parameters.find((param) => param.name.wireValue === key);\n if (parameter == null) {\n throw this.newParameterNotRecognizedError(key);\n }\n // If this query parameter supports allow-multiple, the user-provided values\n // must be wrapped in an array.\n const typeInstanceValue =\n this.isListTypeReference(parameter.typeReference) && !Array.isArray(value) ? [value] : value;\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value: typeInstanceValue\n });\n } finally {\n this.errors.unscope();\n }\n }\n return instances;\n }\n\n public associateByWireValueOrDefault({\n parameters,\n values\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): TypeInstance[] {\n const instances: TypeInstance[] = [];\n for (const parameter of parameters) {\n this.errors.scope(parameter.name.wireValue);\n try {\n let value = values[parameter.name.wireValue];\n\n if (value == null) {\n if (parameter.typeReference.type === \"primitive\" && parameter.typeReference.value === \"STRING\") {\n // synthesize a parameter value for string parameters that are missing data\n value = `<${parameter.name.wireValue}>`;\n } else {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newParameterNotRecognizedError(parameter.name.wireValue).message\n });\n continue;\n }\n }\n\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value\n });\n } finally {\n this.errors.unscope();\n }\n }\n\n return instances;\n }\n\n public associateByWireValue({\n parameters,\n values,\n ignoreMissingParameters\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n ignoreMissingParameters?: boolean;\n }): TypeInstance[] {\n const instances: TypeInstance[] = [];\n for (const [key, value] of Object.entries(values)) {\n this.errors.scope(key);\n try {\n const parameter = parameters.find((param) => param.name.wireValue === key);\n if (parameter == null) {\n if (ignoreMissingParameters) {\n // Required for request payloads that include more information than\n // just the target parameters (e.g. union base properties).\n continue;\n }\n this.errors.add({\n severity: Severity.Critical,\n message: this.newParameterNotRecognizedError(key).message\n });\n continue;\n }\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value\n });\n } finally {\n this.errors.unscope();\n }\n }\n return instances;\n }\n\n /**\n * Similar to `associateByWireValue` but it builds TypeInstance objects by iterating over schema parameters rather\n * than snippet values. Skips non-nullable parameters that are missing from the snippet object.\n */\n public getExampleObjectProperties({\n parameters,\n snippetObject\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n snippetObject: unknown;\n }): TypeInstance[] {\n const objectRecord = (\n typeof snippetObject === \"object\" && snippetObject !== null && !Array.isArray(snippetObject)\n ? snippetObject\n : {}\n ) as Record<string, unknown>;\n const instances: TypeInstance[] = [];\n for (const parameter of parameters) {\n const value = objectRecord[parameter.name.wireValue];\n if (value == null) {\n if (parameter.typeReference.type === \"nullable\") {\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value: null\n });\n }\n } else {\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value\n });\n }\n }\n return instances;\n }\n\n public getSingleFileValue({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.File_;\n record: Record<string, unknown>;\n }): string | undefined {\n const fileValue = record[property.wireValue];\n if (fileValue == null) {\n return undefined;\n }\n if (typeof fileValue !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected file value to be a string, got ${typeof fileValue}`\n });\n return undefined;\n }\n return fileValue;\n }\n\n public getFileArrayValues({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.FileArray;\n record: Record<string, unknown>;\n }): string[] | undefined {\n const fileArrayValue = record[property.wireValue];\n if (fileArrayValue == null) {\n return undefined;\n }\n if (!Array.isArray(fileArrayValue)) {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected file array value to be an array of strings, got ${typeof fileArrayValue}`\n });\n return undefined;\n }\n const stringValues: string[] = [];\n for (const value of fileArrayValue) {\n if (typeof value !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected file array value to be an array of strings, got ${typeof value}`\n });\n return undefined;\n }\n stringValues.push(value);\n }\n return stringValues;\n }\n\n public getRecord(value: unknown): Record<string, unknown> | undefined {\n if (typeof value !== \"object\" || Array.isArray(value)) {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected object with key, value pairs but got: ${\n Array.isArray(value) ? \"array\" : typeof value\n }`\n });\n return undefined;\n }\n if (value == null) {\n return {};\n }\n return value as Record<string, unknown>;\n }\n\n public resolveNamedType({ typeId }: { typeId: FernIr.dynamic.TypeId }): FernIr.dynamic.NamedType | undefined {\n const namedType = this._ir.types[typeId];\n if (namedType == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: `Type identified by \"${typeId}\" could not be found`\n });\n return undefined;\n }\n return namedType;\n }\n\n public resolveDiscriminatedUnionTypeInstance({\n discriminatedUnion,\n value\n }: {\n discriminatedUnion: FernIr.dynamic.DiscriminatedUnionType;\n value: unknown;\n }): DiscriminatedUnionTypeInstance | undefined {\n const record = this.getRecord(value);\n if (record == null) {\n return undefined;\n }\n\n const discriminantFieldName = discriminatedUnion.discriminant.wireValue;\n const discriminantValue = record[discriminantFieldName];\n if (discriminantValue == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newParameterNotRecognizedError(discriminantFieldName).message\n });\n return undefined;\n }\n if (typeof discriminantValue !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected discriminant value to be a string but got: ${typeof discriminantValue}`\n });\n return undefined;\n }\n\n const singleDiscriminatedUnionType = discriminatedUnion.types[discriminantValue];\n if (singleDiscriminatedUnionType == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: `No type found for discriminant value \"${discriminantValue}\"`\n });\n return undefined;\n }\n\n // Remove the discriminant from the record so that the value is valid for the type.\n const { [discriminantFieldName]: _, ...filtered } = record;\n\n return {\n singleDiscriminatedUnionType,\n discriminantValue: singleDiscriminatedUnionType.discriminantValue,\n value: filtered\n };\n }\n\n public resolveEndpointOrThrow(rawEndpoint: string): FernIr.dynamic.Endpoint[] {\n const parsedEndpoint = this.httpEndpointReferenceParser.tryParse(rawEndpoint);\n if (parsedEndpoint == null) {\n throw new Error(`Failed to parse endpoint reference \"${rawEndpoint}\"`);\n }\n return this.resolveEndpointLocationOrThrow(parsedEndpoint);\n }\n\n public resolveEndpointLocation(location: FernIr.dynamic.EndpointLocation): FernIr.dynamic.Endpoint[] {\n const endpoints: FernIr.dynamic.Endpoint[] = [];\n for (const endpoint of Object.values(this._ir.endpoints)) {\n if (this.parsedEndpointMatches({ endpoint, parsedEndpoint: location })) {\n endpoints.push(endpoint);\n }\n }\n\n return endpoints;\n }\n\n public resolveEndpointLocationOrThrow(location: FernIr.dynamic.EndpointLocation): FernIr.dynamic.Endpoint[] {\n const endpoints = this.resolveEndpointLocation(location);\n if (endpoints.length === 0) {\n throw new Error(`Failed to find endpoint identified by \"${location.method} ${location.path}\"`);\n }\n return endpoints;\n }\n\n public needsRequestParameter({\n request,\n inlinePathParameters,\n inlineFileProperties\n }: {\n request: FernIr.dynamic.InlinedRequest;\n inlinePathParameters: boolean;\n inlineFileProperties: boolean;\n }): boolean {\n if (this.includePathParametersInWrappedRequest({ request, inlinePathParameters })) {\n return true;\n }\n if (request.queryParameters != null && request.queryParameters.length > 0) {\n return true;\n }\n if (request.headers != null && request.headers.length > 0) {\n return true;\n }\n if (request.body != null) {\n return this.includeRequestBodyInWrappedRequest({ body: request.body, inlineFileProperties });\n }\n if (request.metadata?.onlyPathParameters) {\n return false;\n }\n return true;\n }\n\n public includePathParametersInWrappedRequest({\n request,\n inlinePathParameters\n }: {\n request: FernIr.dynamic.InlinedRequest;\n inlinePathParameters: boolean;\n }): boolean {\n return inlinePathParameters && (request.metadata?.includePathParameters ?? false);\n }\n\n public isFileUploadRequestBody(\n body: FernIr.dynamic.InlinedRequestBody\n ): body is FernIr.dynamic.InlinedRequestBody.FileUpload {\n switch (body.type) {\n case \"fileUpload\":\n return true;\n case \"properties\":\n case \"referenced\":\n return false;\n default:\n assertNever(body);\n }\n }\n\n public resolveEnvironmentName(environmentID: string): FernIr.Name | undefined {\n if (this._ir.environments == null) {\n return undefined;\n }\n const environments = this._ir.environments.environments;\n switch (environments.type) {\n case \"singleBaseUrl\": {\n const environment = environments.environments.find((env) => env.id === environmentID);\n if (environment == null) {\n return undefined;\n }\n return environment.name;\n }\n case \"multipleBaseUrls\": {\n const environment = environments.environments.find((env) => env.id === environmentID);\n if (environment == null) {\n return undefined;\n }\n return environment.name;\n }\n default:\n assertNever(environments);\n }\n }\n\n public isSingleEnvironmentID(\n environment: FernIr.dynamic.EnvironmentValues\n ): environment is FernIr.dynamic.EnvironmentId {\n return typeof environment === \"string\";\n }\n\n public isMultiEnvironmentValues(\n environment: FernIr.dynamic.EnvironmentValues\n ): environment is FernIr.dynamic.MultipleEnvironmentUrlValues {\n return typeof environment === \"object\";\n }\n\n public validateMultiEnvironmentUrlValues(\n multiEnvironmentUrlValues: FernIr.dynamic.MultipleEnvironmentUrlValues\n ): boolean {\n if (this._ir.environments == null) {\n this.errors.add({\n severity: Severity.Critical,\n message:\n \"Multiple environments are not supported for single base URL environments; use the baseUrl option instead\"\n });\n return false;\n }\n const environments = this._ir.environments.environments;\n switch (environments.type) {\n case \"singleBaseUrl\": {\n this.errors.add({\n severity: Severity.Critical,\n message:\n \"Multiple environments are not supported for single base URL environments; use the baseUrl option instead\"\n });\n return false;\n }\n case \"multipleBaseUrls\": {\n const firstEnvironment = environments.environments[0];\n if (firstEnvironment == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: \"Multiple environments are not supported; use the baseUrl option instead\"\n });\n return false;\n }\n const expectedKeys = new Set(keys(firstEnvironment.urls));\n for (const key of keys(multiEnvironmentUrlValues)) {\n if (expectedKeys.has(key)) {\n expectedKeys.delete(key);\n }\n }\n if (expectedKeys.size > 0) {\n this.errors.add({\n severity: Severity.Critical,\n message: `The provided environments are invalid; got: [${Object.keys(multiEnvironmentUrlValues).join(\", \")}], expected: [${keys(firstEnvironment.urls).join(\", \")}]`\n });\n return false;\n }\n return true;\n }\n }\n }\n\n public getValueAsNumber({ value }: { value: unknown }): number | undefined {\n if (typeof value !== \"number\") {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newTypeMismatchError({ expected: \"number\", value }).message\n });\n return undefined;\n }\n return value;\n }\n\n public getValueAsBoolean({ value }: { value: unknown }): boolean | undefined {\n if (typeof value !== \"boolean\") {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newTypeMismatchError({ expected: \"boolean\", value }).message\n });\n return undefined;\n }\n return value;\n }\n\n public getValueAsString({ value }: { value: unknown }): string | undefined {\n if (typeof value !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newTypeMismatchError({ expected: \"string\", value }).message\n });\n return undefined;\n }\n return value;\n }\n\n public isOptional(typeReference: FernIr.dynamic.TypeReference): boolean {\n switch (typeReference.type) {\n case \"nullable\":\n return this.isOptional(typeReference.value);\n case \"optional\":\n return true;\n case \"named\": {\n const resolvedType = this.resolveNamedType({ typeId: typeReference.value });\n if (resolvedType == null) {\n return false;\n }\n if (resolvedType.type === \"alias\") {\n return this.isNullable(resolvedType.typeReference);\n }\n return false;\n }\n }\n return false;\n }\n\n public isNullable(typeReference: FernIr.dynamic.TypeReference): boolean {\n switch (typeReference.type) {\n case \"nullable\":\n return true;\n case \"optional\":\n return this.isNullable(typeReference.value);\n case \"named\": {\n const resolvedType = this.resolveNamedType({ typeId: typeReference.value });\n if (resolvedType == null) {\n return false;\n }\n if (resolvedType.type === \"alias\") {\n return this.isNullable(resolvedType.typeReference);\n }\n return false;\n }\n }\n return false;\n }\n\n public newAuthMismatchError({\n auth,\n values\n }: {\n auth: FernIr.dynamic.Auth;\n values: FernIr.dynamic.AuthValues;\n }): Error {\n return new Error(`Expected auth type ${auth.type}, got ${values.type}`);\n }\n\n public newParameterNotRecognizedError(parameterName: string): Error {\n return new Error(`\"${parameterName}\" is not a recognized parameter for this endpoint`);\n }\n\n public newTypeMismatchError({ expected, value }: { expected: string; value: unknown }): Error {\n return new Error(`Expected ${expected}, got ${typeof value}`);\n }\n\n private includeRequestBodyInWrappedRequest({\n body,\n inlineFileProperties\n }: {\n body: FernIr.dynamic.InlinedRequestBody;\n inlineFileProperties: boolean;\n }): boolean {\n switch (body.type) {\n case \"properties\":\n case \"referenced\":\n return true;\n case \"fileUpload\":\n return this.includeFileUploadBodyInWrappedRequest({ fileUpload: body, inlineFileProperties });\n default:\n assertNever(body);\n }\n }\n\n private includeFileUploadBodyInWrappedRequest({\n fileUpload,\n inlineFileProperties\n }: {\n fileUpload: FernIr.dynamic.FileUploadRequestBody;\n inlineFileProperties: boolean;\n }): boolean {\n return (\n this.fileUploadHasBodyProperties({ fileUpload }) ||\n (inlineFileProperties && this.fileUploadHasFileProperties({ fileUpload }))\n );\n }\n\n private fileUploadHasBodyProperties({ fileUpload }: { fileUpload: FernIr.dynamic.FileUploadRequestBody }): boolean {\n return fileUpload.properties.some((property) => {\n switch (property.type) {\n case \"file\":\n case \"fileArray\":\n return false;\n case \"bodyProperty\":\n return true;\n default:\n assertNever(property);\n }\n });\n }\n\n private fileUploadHasFileProperties({ fileUpload }: { fileUpload: FernIr.dynamic.FileUploadRequestBody }): boolean {\n return fileUpload.properties.some((property) => {\n switch (property.type) {\n case \"file\":\n case \"fileArray\":\n return true;\n case \"bodyProperty\":\n return false;\n default:\n assertNever(property);\n }\n });\n }\n\n private isListTypeReference(typeReference: FernIr.dynamic.TypeReference): boolean {\n if (typeReference.type === \"optional\") {\n return this.isListTypeReference(typeReference.value);\n }\n return typeReference.type === \"list\" || typeReference.type === \"set\";\n }\n\n private parsedEndpointMatches({\n endpoint,\n parsedEndpoint\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n parsedEndpoint: HttpEndpointReferenceParser.Parsed;\n }): boolean {\n return endpoint.location.method === parsedEndpoint.method && endpoint.location.path === parsedEndpoint.path;\n }\n}\n","export { EXAMPLE_REFERENCE_PREFIX, YAML_SCHEMA_VERSION } from \"./constants\";\nexport { type NodePath, type NodePathItem } from \"./NodePath\";\nexport * as RawSchemas from \"./schemas\";\nexport { type DefinitionFileSchema, type PackageMarkerFileSchema, type RootApiFileSchema } from \"./schemas\";\nexport * from \"./utils/auth\";\nexport * from \"./utils/generics\";\nexport { getRequestBody } from \"./utils/getRequestBody\";\nexport { getResponseBodyType } from \"./utils/getResponseBodyType\";\nexport { HttpEndpointReferenceParser } from \"./utils/HttpEndpointReferenceParser\";\nexport { isInlineRequestBody } from \"./utils/isInlineRequestBody\";\nexport { isOpenApiSourceSchema } from \"./utils/isOpenApiSourceSchema\";\nexport { isRawProtobufSourceSchema } from \"./utils/isRawProtobufSourceSchema\";\nexport { isRawTextType } from \"./utils/isRawTextType\";\nexport { type BytesRequest, parseBytesRequest } from \"./utils/parseBytesRequest\";\nexport { parseFileUploadRequest, type RawFileUploadRequest } from \"./utils/parseFileUploadRequest\";\nexport { parseRawBytesType, type RawBytesType } from \"./utils/parseRawBytesType\";\nexport { parseRawFileType, type RawFileType } from \"./utils/parseRawFileType\";\nexport { parseRawTextType, type RawTextType } from \"./utils/parseRawTextType\";\nexport { RawPrimitiveType } from \"./utils/RawPrimitiveType\";\nexport { recursivelyVisitRawTypeReference } from \"./utils/recursivelyVisitRawTypeReference\";\nexport { visitExampleCodeSampleSchema } from \"./utils/visitExampleCodeSampleSchema\";\nexport { type ExampleResponseSchemaVisitor, visitExampleResponseSchema } from \"./utils/visitExampleResponseSchema\";\nexport { isAnyAuthSchemes, isSingleAuthScheme, type RawApiAuthVisitor, visitRawApiAuth } from \"./utils/visitRawApiAuth\";\nexport {\n type AuthSchemeDeclarationVisitor,\n isHeaderAuthScheme,\n visitRawAuthSchemeDeclaration\n} from \"./utils/visitRawAuthSchemeDeclaration\";\nexport {\n isRawMultipleBaseUrlsEnvironment,\n isRawSingleBaseUrlEnvironment,\n visitRawEnvironmentDeclaration\n} from \"./utils/visitRawEnvironmentDeclaration\";\nexport {\n isVariablePathParameter,\n type PathParameterDeclarationVisitor,\n visitRawPathParameter\n} from \"./utils/visitRawPathParameter\";\nexport {\n isRawAliasDefinition,\n isRawDiscriminatedUnionDefinition,\n isRawEnumDefinition,\n isRawObjectDefinition,\n isRawUndiscriminatedUnionDefinition,\n type RawTypeDeclarationVisitor,\n visitRawTypeDeclaration\n} from \"./utils/visitRawTypeDeclaration\";\nexport { FernContainerRegex, visitRawTypeReference } from \"./utils/visitRawTypeReference\";\n","export declare namespace HttpEndpointReferenceParser {\n interface Parsed {\n path: string;\n method: Method;\n }\n\n type Method = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\" | \"HEAD\";\n\n export type ValidationResult = Valid | Invalid;\n\n interface Valid {\n type: \"valid\";\n }\n\n interface Invalid {\n type: \"invalid\";\n }\n}\n\n/**\n * Parses an HTTP endpoint reference like `POST /users/get`\n */\nexport class HttpEndpointReferenceParser {\n //eslint-disable-next-line\n private REFERENCE_REGEX = /^(GET|POST|PUT|DELETE|PATCH|HEAD)\\s(\\/\\S*)$/;\n\n public validate(reference: string): HttpEndpointReferenceParser.ValidationResult {\n const validFormat = this.REFERENCE_REGEX.test(reference);\n if (!validFormat) {\n return { type: \"invalid\" };\n }\n return { type: \"valid\" };\n }\n\n public tryParse(reference: string): HttpEndpointReferenceParser.Parsed | undefined {\n const validationResponse = this.validate(reference);\n if (validationResponse.type === \"invalid\") {\n return undefined;\n }\n const match = reference.match(this.REFERENCE_REGEX);\n if (match == null || match[1] == null || match[2] == null) {\n return undefined;\n }\n return {\n method: match[1] as HttpEndpointReferenceParser.Method,\n path: match[2]\n };\n }\n}\n","export const Scope = {\n PathParameters: \"pathParameters\",\n QueryParameters: \"queryParameters\",\n Headers: \"headers\",\n RequestBody: \"requestBody\"\n} as const;\n\nexport type Scope = (typeof Scope)[keyof typeof Scope];\n","export { AbstractDynamicSnippetsGenerator } from \"./AbstractDynamicSnippetsGenerator\";\nexport { AbstractDynamicSnippetsGeneratorContext } from \"./AbstractDynamicSnippetsGeneratorContext\";\nexport { type DiscriminatedUnionTypeInstance } from \"./DiscriminatedUnionTypeInstance\";\nexport { ErrorReporter, Severity } from \"./ErrorReporter\";\nexport { type Options, Style } from \"./Options\";\nexport { Result } from \"./Result\";\nexport { Scope } from \"./Scope\";\nexport { type TypeInstance } from \"./TypeInstance\";\nexport { DynamicSnippetsTestRunner } from \"./test-utils/DynamicSnippetsTestRunner\";\n"],"mappings":"2FAKAA,IAAAC,ICAAC,IAAAC,IAAM,IAAOC,EAAP,KAAa,CAKf,aAAA,CAJOC,EAAA,iBACAA,EAAA,gBACAA,EAAA,YAGH,KAAK,QAAU,OACf,KAAK,SAAW,OAChB,KAAK,IAAM,MACf,CAEO,OAAO,CAAE,QAAAC,EAAS,QAAAC,CAAO,EAAyE,CACjG,KAAK,aAAa,CAAE,QAAAA,EAAS,SAAUD,EAAQ,MAAM,CAAE,IACvD,KAAK,SAAWA,EAAQ,OAAO,MAAK,EACpC,KAAK,QAAUC,EAEvB,CAEO,mBAAmB,CACtB,SAAAC,CAAQ,EAGX,CAtBL,IAAAC,EAuBQ,GAAI,KAAK,SAAW,MAAQ,KAAK,UAAY,KACzC,MAAO,CACH,QAAS,KAAK,QACd,OAAQ,KAAK,SAAS,uBAAsB,GAGpD,MAAMA,EAAA,KAAK,MAAL,KAAAA,EAAY,IAAI,MAAM,4CAA4CD,EAAS,MAAM,IAAIA,EAAS,IAAI,GAAG,CAC/G,CAEQ,aAAa,CAAE,QAAAD,EAAS,SAAAG,CAAQ,EAAgD,CAhC5F,IAAAD,EAAAE,EAiCQ,OAAI,KAAK,UAAY,MAAS,KAAK,SAAS,KAAI,EAAK,GAAKD,EAAS,KAAI,IAAO,EACnE,GAEJH,EAAQ,SAAUI,GAAAF,EAAA,KAAK,UAAL,YAAAA,EAAc,SAAd,KAAAE,EAAwB,EACrD,GDnCE,IAAgBC,EAAhB,KAAgD,CAIlD,YAAmCC,EAAgB,CAAhBC,EAAA,gBAAA,KAAA,QAAAD,CAAmB,CAI/C,MAAM,SACTE,EACAC,EAAmB,CAAA,EAAE,CAErB,IAAMC,EAAY,KAAK,QAAQ,+B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IAAK,YACD,MAAO,GACX,IAAK,eACD,MAAO,GACX,QACI0B,EAAY1B,CAAQ,CAC5B,CACJ,CAAC,CACL,CAEQ,oBAAoBmC,EAA2C,CACnE,OAAIA,EAAc,OAAS,WAChB,KAAK,oBAAoBA,EAAc,KAAK,EAEhDA,EAAc,OAAS,QAAUA,EAAc,OAAS,KACnE,CAEQ,sBAAsB,CAC1B,SAAAf,EACA,eAAAH,CAAc,EAIjB,CACG,OAAOG,EAAS,SAAS,SAAWH,EAAe,QAAUG,EAAS,SAAS,OAASH,EAAe,IAC3G,GG/nBJwB,IAAAC,IAAO,IAAMC,EAAQ,CACjB,eAAgB,iBAChB,gBAAiB,kBACjB,QAAS,UACT,YAAa,eCJjBC,IAAAC","names":["init_process","init_buffer","init_process","init_buffer","Result","__publicField","context","snippet","endpoint","_a","reporter","_b","AbstractDynamicSnippetsGenerator","context","__publicField","request","options","endpoints","result","Result","endpoint","snippetGenerator","snippet","error","init_process","init_buffer","Severity","ErrorReporter","_ErrorReporter","__publicField","err","__spreadProps","__spreadValues","path","severity","clone","result","item","init_process","init_buffer","init_process","init_buffer","init_process","init_buffer","HttpEndpointReferenceParser","__publicField","reference","match","AbstractDynamicSnippetsGeneratorContext","ir","config","options","__publicField","ErrorReporter","HttpEndpointReferenceParser","parameters","values","instances","key","value","parameter","param","typeInstanceValue","Severity","ignoreMissingParameters","snippetObject","objectRecord","property","record","fileValue","fileArrayValue","stringValues","typeId","namedType","discriminatedUnion","discriminantFieldName","discriminantValue","singleDiscriminatedUnionType","_a","_","filtered","__objRest","__restKey","rawEndpoint","parsedEndpoint","location","endpoints","endpoint","request","inlinePathParameters","inlineFileProperties","_b","body","assertNever","environmentID","environments","environment","env","multiEnvironmentUrlValues","firstEnvironment","expectedKeys","keys","typeReference","resolvedType","auth","parameterName","expected","fileUpload","init_process","init_buffer","Scope","init_process","init_buffer"]}
@@ -0,0 +1,2 @@
1
+ import{b as d,d as o}from"./chunk-6OLYGRJY.js";import{a as I,b as F,e as P,f as R,g as x,h as u,j as a}from"./chunk-YEXRWSXV.js";R();x();var q={type:"primitive",value:"STRING"},B=["example"],A="client",h="request",N=class{constructor({context:e}){P(this,"context");this.context=e}async generateSnippet({endpoint:e,request:t}){return this.buildPythonFile({endpoint:e,snippet:t}).toString()}generateSnippetSync({endpoint:e,request:t}){return this.buildPythonFile({endpoint:e,snippet:t}).toString()}buildPythonFile({endpoint:e,snippet:t}){return a.file({path:B,statements:[this.constructClient({endpoint:e,snippet:t}),this.callMethod({endpoint:e,snippet:t})]})}constructClient({endpoint:e,snippet:t}){return a.assign({lhs:a.reference({name:A}),rhs:a.instantiateClass({classReference:this.context.getRootClientClassReference(),arguments_:this.getConstructorArgs({endpoint:e,snippet:t}).map(r=>a.methodArgument({name:r.name,value:r.value})),multiline:!0})})}getConstructorArgs({endpoint:e,snippet:t}){let r=[],n=this.getConstructorEnvironmentArgs({baseUrl:t.baseURL,environment:t.environment});return n.length>0&&r.push(...n),e.auth!=null&&(t.auth!=null?r.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`})),this.context.errors.scope(o.PathParameters),this.context.ir.pathParameters!=null&&r.push(...this.getPathParameters({namedParameters:this.context.ir.pathParameters,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(o.Headers),this.context.ir.headers!=null&&t.headers!=null&&r.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope(),r}getConstructorEnvironmentArgs({baseUrl:e,environment:t}){let r=this.getEnvironmentValue({baseUrl:e,environment:t});return r==null?[]:t!=null&&this.context.isMultiEnvironmentValues(t)?[{name:"environment",value:r}]:[{name:this.getEnvironmentOptionName({environment:t}),value:r}]}getEnvironmentValue({baseUrl:e,environment:t}){if(e!=null&&t!=null){this.context.errors.add({severity:d.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(e!=null)return a.TypeInstantiation.str(e);if(t!=null){if(this.context.isSingleEnvironmentID(t)){let r=this.context.getEnvironmentTypeReferenceFromID(t);if(r==null){this.context.errors.add({severity:d.Warning,message:`Environment ${JSON.stringify(t)} was not found`});return}return a.TypeInstantiation.reference(r)}if(this.context.isMultiEnvironmentValues(t))return this.context.validateMultiEnvironmentUrlValues(t)?a.TypeInstantiation.reference(a.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.entries(t).map(([r,n])=>({name:r,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:q,value:n})})).map(r=>a.methodArgument({name:r.name,value:r.value})),multiline:!0})):void 0}}getConstructorAuthArgs({auth:e,values:t}){switch(e.type){case"basic":return t.type!=="basic"?(this.addAuthMismatchError(e,t),[]):this.getConstructorBasicAuthArg({auth:e,values:t});case"bearer":return t.type!=="bearer"?(this.addAuthMismatchError(e,t),[]):this.getConstructorBearerAuthArgs({auth:e,values:t});case"header":return t.type!=="header"?(this.addAuthMismatchError(e,t),[]):this.getConstructorHeaderAuthArgs({auth:e,values:t});case"oauth":return t.type!=="oauth"?(this.addAuthMismatchError(e,t),[]):this.getConstructorOAuthArgs({auth:e,values:t});case"inferred":return t.type!=="inferred"?(this.addAuthMismatchError(e,t),[]):(this.addWarning("The Python SDK Generator does not support Inferred auth scheme yet"),[]);default:u(e)}}addAuthMismatchError(e,t){this.context.errors.add({severity:d.Critical,message:this.context.newAuthMismatchError({auth:e,values:t}).message})}addWarning(e){this.context.errors.add({severity:d.Warning,message:e})}getConstructorBasicAuthArg({auth:e,values:t}){return[{name:this.context.getPropertyName(e.username),value:a.TypeInstantiation.str(t.username)},{name:this.context.getPropertyName(e.password),value:a.TypeInstantiation.str(t.password)}]}getConstructorBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.token),value:a.TypeInstantiation.str(t.token)}]}getConstructorHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value})}]}getConstructorOAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.clientId),value:a.TypeInstantiation.str(t.clientId)},{name:this.context.getPropertyName(e.clientSecret),value:a.TypeInstantiation.str(t.clientSecret)}]}getConstructorHeaderArgs({headers:e,values:t}){let r=[];for(let n of e){let s=this.getConstructorHeaderArg({header:n,value:t.value});s!=null&&r.push(s)}return r}getConstructorHeaderArg({header:e,value:t}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t});if(!a.TypeInstantiation.isNop(r))return{name:this.context.getPropertyName(e.name.name),value:r}}callMethod({endpoint:e,snippet:t}){return a.invokeMethod({on:a.reference({name:A}),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t}).map(r=>a.methodArgument({name:r.name,value:r.value})),multiline:!0})}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:u(e.request)}}getMethodArgsForBodyRequest({request:e,snippet:t}){var i,l;let r=[];this.context.errors.scope(o.PathParameters);let n=[...(i=this.context.ir.pathParameters)!=null?i:[],...(l=e.pathParameters)!=null?l:[]],s=new Set;if(e.body!=null){let m=this.getBodyRequestArgs({body:e.body,value:t.requestBody});s=new Set(m.map(p=>p.name))}if(n.length>0){let p=this.getPathParameters({namedParameters:n,snippet:t}).map(c=>s.has(c.name)?F(I({},c),{name:c.name+"_"}):c);r.push(...p)}return this.context.errors.unscope(),this.context.errors.scope(o.RequestBody),e.body!=null&&r.push(...this.getBodyRequestArgs({body:e.body,value:t.requestBody})),this.context.errors.unscope(),r}getBodyRequestArgs({body:e,value:t}){switch(e.type){case"bytes":return[{name:h,value:this.getBytesBodyRequestTypeInstantiation({value:t})}];case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:e.value,value:t});default:u(e)}}getBodyRequestArgsForTypeReference({typeReference:e,value:t}){switch(e.type){case"named":{let r=this.context.resolveNamedType({typeId:e.value});return r==null?[]:this.getBodyRequestArgsForNamedTypeReference({typeReference:e,named:r,value:t})}case"nullable":case"optional":{let r=e.value;if(r.type==="named"){let n=this.context.resolveNamedType({typeId:r.value});if((n==null?void 0:n.type)==="object")return[{name:h,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:r,value:t})}]}return this.getBodyRequestArgsForTypeReference({typeReference:e.value,value:t})}case"list":case"map":case"set":case"literal":case"primitive":case"unknown":return[{name:h,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e,value:t})}];default:u(e)}}getBodyRequestArgsForNamedTypeReference({typeReference:e,named:t,value:r}){var n;switch(t.type){case"alias":return this.getBodyRequestArgsForTypeReference({typeReference:t.typeReference,value:r});case"enum":case"discriminatedUnion":case"undiscriminatedUnion":return[{name:h,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e,value:r})}];case"object":return this.context.associateByWireValue({parameters:t.properties,values:(n=this.context.getRecord(r))!=null?n:{}}).map(i=>({name:this.context.getPropertyName(i.name.name),value:this.context.dynamicTypeLiteralMapper.convert(i)}));default:u(t)}}getBodyRequestArgsForBytes({body:e,value:t}){let r=this.getBytesBodyRequestTypeInstantiation({value:t});return a.TypeInstantiation.isNop(r)?[]:[{name:this.context.getPropertyName(e.bodyKey),value:r}]}getBytesBodyRequestTypeInstantiation({value:e}){return typeof e!="string"?(this.context.errors.add({severity:d.Critical,message:`Expected bytes value to be a string, got ${typeof e}`}),a.TypeInstantiation.nop()):a.TypeInstantiation.bytes(e)}getMethodArgsForInlinedRequest({request:e,snippet:t}){let r=[],n=this.context.shouldInlinePathParameters();this.context.errors.scope(o.PathParameters);let s=[];e.pathParameters!=null&&s.push(...this.getPathParameters({namedParameters:e.pathParameters,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(o.RequestBody);let i=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:n})||r.push(...s),this.context.needsRequestParameter({request:e,inlinePathParameters:n,inlineFileProperties:!0})&&r.push(...this.getInlinedRequestArgs({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:n})?s:[],filePropertyInfo:i})),r}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})}getInlinedRequestArgs({request:e,snippet:t,pathParameterFields:r,filePropertyInfo:n}){var c,g,f,v;this.context.errors.scope(o.QueryParameters);let i=this.context.associateQueryParametersByWireValue({parameters:(c=e.queryParameters)!=null?c:[],values:(g=t.queryParameters)!=null?g:{}}).map(y=>({name:this.context.getPropertyName(y.name.name),value:this.context.dynamicTypeLiteralMapper.convert(y)}));this.context.errors.unscope(),this.context.errors.scope(o.Headers);let m=this.context.associateByWireValue({parameters:(f=e.headers)!=null?f:[],values:(v=t.headers)!=null?v:{}}).map(y=>({name:this.context.getPropertyName(y.name.name),value:this.context.dynamicTypeLiteralMapper.convert(y)}));this.context.errors.unscope(),this.context.errors.scope(o.RequestBody);let p=e.body!=null?this.getInlinedRequestBodyObjectFields({body:e.body,value:t.requestBody,filePropertyInfo:n}):[];return this.context.errors.unscope(),[...r,...i,...m,...p]}getInlinedRequestBodyObjectFields({body:e,value:t,filePropertyInfo:r}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyObjectFields({parameters:e.value,value:t});case"referenced":return this.getReferencedRequestBodyPropertyTypeInstantiation({body:e,value:t});case"fileUpload":return this.getFileUploadRequestBodyObjectFields({filePropertyInfo:r});default:u(e)}}getFileUploadRequestBodyObjectFields({filePropertyInfo:e}){return[...e.fileFields,...e.bodyPropertyFields]}getReferencedRequestBodyPropertyTypeInstantiation({body:e,value:t}){let r=e.bodyType;switch(r.type){case"bytes":return this.getBodyRequestArgsForBytes({body:e,value:t});case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:r.value,value:t});default:u(r)}}getInlinedRequestBodyPropertyObjectFields({parameters:e,value:t}){var s;let r=[],n=this.context.associateByWireValue({parameters:e,values:(s=this.context.getRecord(t))!=null?s:{}});for(let i of n)r.push({name:this.context.getPropertyName(i.name.name),value:this.context.dynamicTypeLiteralMapper.convert(i)});return r}getPathParameters({namedParameters:e,snippet:t}){var s;let r=[],n=this.context.associateByWireValue({parameters:e,values:(s=t.pathParameters)!=null?s:{},ignoreMissingParameters:!0});for(let i of n)r.push({name:this.context.getPropertyName(i.name.name),value:this.context.dynamicTypeLiteralMapper.convert(i)});return r}getMethod({endpoint:e}){return e.declaration.fernFilepath.allParts.length>0?`${e.declaration.fernFilepath.allParts.map(t=>this.context.getMethodName(t)).join(".")}.${this.context.getMethodName(e.declaration.name)}`:this.context.getMethodName(e.declaration.name)}getEnvironmentOptionName({environment:e}){return e!=null?"environment":"base_url"}};export{N as a};
2
+ //# sourceMappingURL=chunk-EO2BLSPL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/EndpointSnippetGenerator.ts"],"sourcesContent":["import { Scope, Severity } from \"@fern-api/browser-compatible-base-generator\";\nimport { assertNever } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { python } from \"@fern-api/python-ast\";\n\nimport { DynamicSnippetsGeneratorContext } from \"./context/DynamicSnippetsGeneratorContext\";\nimport { FilePropertyInfo } from \"./context/FilePropertyMapper\";\n\nconst STRING_TYPE_REFERENCE: FernIr.dynamic.TypeReference = {\n type: \"primitive\",\n value: \"STRING\"\n};\nconst SNIPPET_MODULE_PATH = [\"example\"];\nconst CLIENT_VAR_NAME = \"client\";\nconst REQUEST_BODY_ARG_NAME = \"request\";\n\nexport class EndpointSnippetGenerator {\n private context: DynamicSnippetsGeneratorContext;\n\n constructor({ context }: { context: DynamicSnippetsGeneratorContext }) {\n this.context = context;\n }\n\n public async generateSnippet({\n endpoint,\n request\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n }): Promise<string> {\n const file = this.buildPythonFile({ endpoint, snippet: request });\n return file.toString();\n }\n\n public generateSnippetSync({\n endpoint,\n request\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n }): string {\n const file = this.buildPythonFile({ endpoint, snippet: request });\n return file.toString();\n }\n\n private buildPythonFile({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.PythonFile {\n return python.file({\n path: SNIPPET_MODULE_PATH,\n statements: [this.constructClient({ endpoint, snippet }), this.callMethod({ endpoint, snippet })]\n });\n }\n\n private constructClient({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.AstNode {\n return python.assign({\n lhs: python.reference({ name: CLIENT_VAR_NAME }),\n rhs: python.instantiateClass({\n classReference: this.context.getRootClientClassReference(),\n arguments_: this.getConstructorArgs({ endpoint, snippet }).map((arg) =>\n python.methodArgument({\n name: arg.name,\n value: arg.value\n })\n ),\n multiline: true\n })\n });\n }\n\n private getConstructorArgs({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.NamedValue[] {\n const fields: python.NamedValue[] = [];\n const environmentArgs = this.getConstructorEnvironmentArgs({\n baseUrl: snippet.baseURL,\n environment: snippet.environment\n });\n if (environmentArgs.length > 0) {\n fields.push(...environmentArgs);\n }\n if (endpoint.auth != null) {\n if (snippet.auth != null) {\n fields.push(...this.getConstructorAuthArgs({ auth: endpoint.auth, values: snippet.auth }));\n } else {\n this.context.errors.add({\n severity: Severity.Warning,\n message: `Auth with ${endpoint.auth.type} configuration is required for this endpoint`\n });\n }\n }\n\n this.context.errors.scope(Scope.PathParameters);\n if (this.context.ir.pathParameters != null) {\n fields.push(...this.getPathParameters({ namedParameters: this.context.ir.pathParameters, snippet }));\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.Headers);\n if (this.context.ir.headers != null && snippet.headers != null) {\n fields.push(\n ...this.getConstructorHeaderArgs({ headers: this.context.ir.headers, values: snippet.headers })\n );\n }\n this.context.errors.unscope();\n return fields;\n }\n\n private getConstructorEnvironmentArgs({\n baseUrl,\n environment\n }: {\n baseUrl: string | undefined;\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): python.NamedValue[] {\n const environmentValue = this.getEnvironmentValue({ baseUrl, environment });\n if (environmentValue == null) {\n return [];\n }\n\n if (environment != null && this.context.isMultiEnvironmentValues(environment)) {\n return [\n {\n name: \"environment\",\n value: environmentValue\n }\n ];\n }\n\n return [\n {\n name: this.getEnvironmentOptionName({ environment }),\n value: environmentValue\n }\n ];\n }\n\n private getEnvironmentValue({\n baseUrl,\n environment\n }: {\n baseUrl: string | undefined;\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): python.TypeInstantiation | undefined {\n if (baseUrl != null && environment != null) {\n this.context.errors.add({\n severity: Severity.Critical,\n message: \"Cannot specify both baseUrl and environment options\"\n });\n return undefined;\n }\n if (baseUrl != null) {\n return python.TypeInstantiation.str(baseUrl);\n }\n if (environment != null) {\n if (this.context.isSingleEnvironmentID(environment)) {\n const environmentTypeReference = this.context.getEnvironmentTypeReferenceFromID(environment);\n if (environmentTypeReference == null) {\n this.context.errors.add({\n severity: Severity.Warning,\n message: `Environment ${JSON.stringify(environment)} was not found`\n });\n return undefined;\n }\n return python.TypeInstantiation.reference(environmentTypeReference);\n }\n if (this.context.isMultiEnvironmentValues(environment)) {\n if (!this.context.validateMultiEnvironmentUrlValues(environment)) {\n return undefined;\n }\n return python.TypeInstantiation.reference(\n python.instantiateClass({\n classReference: this.context.getEnvironmentClassReference(),\n arguments_: Object.entries(environment)\n .map(([key, value]) => ({\n name: key,\n value: this.context.dynamicTypeLiteralMapper.convert({\n typeReference: STRING_TYPE_REFERENCE,\n value\n })\n }))\n .map((arg) =>\n python.methodArgument({\n name: arg.name,\n value: arg.value\n })\n ),\n multiline: true\n })\n );\n }\n }\n return undefined;\n }\n\n private getConstructorAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.Auth;\n values: FernIr.dynamic.AuthValues;\n }): python.NamedValue[] {\n switch (auth.type) {\n case \"basic\":\n if (values.type !== \"basic\") {\n this.addAuthMismatchError(auth, values);\n return [];\n }\n return this.getConstructorBasicAuthArg({ auth, values });\n case \"bearer\":\n if (values.type !== \"bearer\") {\n this.addAuthMismatchError(auth, values);\n return [];\n }\n return this.getConstructorBearerAuthArgs({ auth, values });\n case \"header\":\n if (values.type !== \"header\") {\n this.addAuthMismatchError(auth, values);\n return [];\n }\n return this.getConstructorHeaderAuthArgs({ auth, values });\n case \"oauth\":\n if (values.type !== \"oauth\") {\n this.addAuthMismatchError(auth, values);\n return [];\n }\n return this.getConstructorOAuthArgs({ auth, values });\n case \"inferred\":\n if (values.type !== \"inferred\") {\n this.addAuthMismatchError(auth, values);\n return [];\n }\n this.addWarning(\"The Python SDK Generator does not support Inferred auth scheme yet\");\n return [];\n default:\n assertNever(auth);\n }\n }\n\n private addAuthMismatchError(auth: FernIr.dynamic.Auth, values: FernIr.dynamic.AuthValues): void {\n this.context.errors.add({\n severity: Severity.Critical,\n message: this.context.newAuthMismatchError({ auth, values }).message\n });\n }\n\n private addWarning(message: string): void {\n this.context.errors.add({ severity: Severity.Warning, message });\n }\n\n private getConstructorBasicAuthArg({\n auth,\n values\n }: {\n auth: FernIr.dynamic.BasicAuth;\n values: FernIr.dynamic.BasicAuthValues;\n }): python.NamedValue[] {\n return [\n {\n name: this.context.getPropertyName(auth.username),\n value: python.TypeInstantiation.str(values.username)\n },\n {\n name: this.context.getPropertyName(auth.password),\n value: python.TypeInstantiation.str(values.password)\n }\n ];\n }\n\n private getConstructorBearerAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.BearerAuth;\n values: FernIr.dynamic.BearerAuthValues;\n }): python.NamedValue[] {\n return [\n {\n name: this.context.getPropertyName(auth.token),\n value: python.TypeInstantiation.str(values.token)\n }\n ];\n }\n\n private getConstructorHeaderAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.HeaderAuth;\n values: FernIr.dynamic.HeaderAuthValues;\n }): python.NamedValue[] {\n return [\n {\n name: this.context.getPropertyName(auth.header.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert({\n typeReference: auth.header.typeReference,\n value: values.value\n })\n }\n ];\n }\n\n private getConstructorOAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.OAuth;\n values: FernIr.dynamic.OAuthValues;\n }): python.NamedValue[] {\n return [\n {\n name: this.context.getPropertyName(auth.clientId),\n value: python.TypeInstantiation.str(values.clientId)\n },\n {\n name: this.context.getPropertyName(auth.clientSecret),\n value: python.TypeInstantiation.str(values.clientSecret)\n }\n ];\n }\n\n private getConstructorHeaderArgs({\n headers,\n values\n }: {\n headers: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): python.NamedValue[] {\n const fields: python.NamedValue[] = [];\n for (const header of headers) {\n const field = this.getConstructorHeaderArg({ header, value: values.value });\n if (field != null) {\n fields.push(field);\n }\n }\n return fields;\n }\n\n private getConstructorHeaderArg({\n header,\n value\n }: {\n header: FernIr.dynamic.NamedParameter;\n value: unknown;\n }): python.NamedValue | undefined {\n const typeLiteral = this.context.dynamicTypeLiteralMapper.convert({\n typeReference: header.typeReference,\n value\n });\n if (python.TypeInstantiation.isNop(typeLiteral)) {\n // Literal header values (e.g. \"X-API-Version\") should not be included in the\n // client constructor.\n return undefined;\n }\n return {\n name: this.context.getPropertyName(header.name.name),\n value: typeLiteral\n };\n }\n\n private callMethod({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.AstNode {\n return python.invokeMethod({\n on: python.reference({ name: CLIENT_VAR_NAME }),\n method: this.getMethod({ endpoint }),\n arguments_: this.getMethodArgs({ endpoint, snippet }).map((arg) =>\n python.methodArgument({\n name: arg.name,\n value: arg.value\n })\n ),\n multiline: true\n });\n }\n\n private getMethodArgs({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.NamedValue[] {\n switch (endpoint.request.type) {\n case \"inlined\":\n return this.getMethodArgsForInlinedRequest({ request: endpoint.request, snippet });\n case \"body\":\n return this.getMethodArgsForBodyRequest({ request: endpoint.request, snippet });\n default:\n assertNever(endpoint.request);\n }\n }\n\n private getMethodArgsForBodyRequest({\n request,\n snippet\n }: {\n request: FernIr.dynamic.BodyRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.NamedValue[] {\n const args: python.NamedValue[] = [];\n\n this.context.errors.scope(Scope.PathParameters);\n const pathParameters = [...(this.context.ir.pathParameters ?? []), ...(request.pathParameters ?? [])];\n\n // Get body property names to check for collisions\n let bodyPropertyNames: Set<string> = new Set();\n if (request.body != null) {\n const bodyArgs = this.getBodyRequestArgs({ body: request.body, value: snippet.requestBody });\n bodyPropertyNames = new Set(bodyArgs.map((arg) => arg.name));\n }\n\n // Add path parameters, adding underscore suffix if they collide with body properties\n if (pathParameters.length > 0) {\n const pathArgs = this.getPathParameters({ namedParameters: pathParameters, snippet });\n const disambiguatedPathArgs = pathArgs.map((arg) => {\n // If this path parameter name collides with a body property, add underscore suffix\n if (bodyPropertyNames.has(arg.name)) {\n return { ...arg, name: arg.name + \"_\" };\n }\n return arg;\n });\n args.push(...disambiguatedPathArgs);\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n if (request.body != null) {\n args.push(...this.getBodyRequestArgs({ body: request.body, value: snippet.requestBody }));\n }\n this.context.errors.unscope();\n\n return args;\n }\n\n private getBodyRequestArgs({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBodyType;\n value: unknown;\n }): python.NamedValue[] {\n switch (body.type) {\n case \"bytes\":\n return [\n {\n name: REQUEST_BODY_ARG_NAME,\n value: this.getBytesBodyRequestTypeInstantiation({ value })\n }\n ];\n case \"typeReference\":\n return this.getBodyRequestArgsForTypeReference({ typeReference: body.value, value });\n default:\n assertNever(body);\n }\n }\n\n private getBodyRequestArgsForTypeReference({\n typeReference,\n value\n }: {\n typeReference: FernIr.dynamic.TypeReference;\n value: unknown;\n }): python.NamedValue[] {\n switch (typeReference.type) {\n case \"named\": {\n const named = this.context.resolveNamedType({ typeId: typeReference.value });\n if (named == null) {\n return [];\n }\n return this.getBodyRequestArgsForNamedTypeReference({ typeReference, named, value });\n }\n case \"nullable\":\n case \"optional\": {\n // Check if the inner type is an object - if so, don't flatten it\n const innerType = typeReference.value;\n if (innerType.type === \"named\") {\n const named = this.context.resolveNamedType({ typeId: innerType.value });\n if (named?.type === \"object\") {\n // Optional objects should NOT be flattened - use as single 'request' parameter\n return [\n {\n name: REQUEST_BODY_ARG_NAME,\n value: this.context.dynamicTypeLiteralMapper.convert({\n typeReference: innerType,\n value\n })\n }\n ];\n }\n }\n // For non-object types, continue unwrapping\n return this.getBodyRequestArgsForTypeReference({ typeReference: typeReference.value, value });\n }\n case \"list\":\n case \"map\":\n case \"set\":\n case \"literal\":\n case \"primitive\":\n case \"unknown\":\n return [\n {\n name: REQUEST_BODY_ARG_NAME,\n value: this.context.dynamicTypeLiteralMapper.convert({ typeReference, value })\n }\n ];\n default:\n assertNever(typeReference);\n }\n }\n\n private getBodyRequestArgsForNamedTypeReference({\n typeReference,\n named,\n value\n }: {\n typeReference: FernIr.dynamic.TypeReference;\n named: FernIr.dynamic.NamedType;\n value: unknown;\n }): python.NamedValue[] {\n switch (named.type) {\n case \"alias\":\n return this.getBodyRequestArgsForTypeReference({ typeReference: named.typeReference, value });\n case \"enum\":\n case \"discriminatedUnion\":\n case \"undiscriminatedUnion\":\n return [\n {\n name: REQUEST_BODY_ARG_NAME,\n value: this.context.dynamicTypeLiteralMapper.convert({ typeReference, value })\n }\n ];\n case \"object\": {\n const bodyProperties = this.context.associateByWireValue({\n parameters: named.properties,\n values: this.context.getRecord(value) ?? {}\n });\n return bodyProperties.map((property) => ({\n name: this.context.getPropertyName(property.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(property)\n }));\n }\n default:\n assertNever(named);\n }\n }\n\n private getBodyRequestArgsForBytes({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBody;\n value: unknown;\n }): python.NamedValue[] {\n const typeInstantiation = this.getBytesBodyRequestTypeInstantiation({ value });\n if (python.TypeInstantiation.isNop(typeInstantiation)) {\n return [];\n }\n return [\n {\n name: this.context.getPropertyName(body.bodyKey),\n value: typeInstantiation\n }\n ];\n }\n\n private getBytesBodyRequestTypeInstantiation({ value }: { value: unknown }): python.TypeInstantiation {\n if (typeof value !== \"string\") {\n this.context.errors.add({\n severity: Severity.Critical,\n message: `Expected bytes value to be a string, got ${typeof value}`\n });\n return python.TypeInstantiation.nop();\n }\n return python.TypeInstantiation.bytes(value);\n }\n\n private getMethodArgsForInlinedRequest({\n request,\n snippet\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.NamedValue[] {\n const args: python.NamedValue[] = [];\n\n const inlinePathParameters = this.context.shouldInlinePathParameters();\n\n this.context.errors.scope(Scope.PathParameters);\n const pathParameterFields: python.NamedValue[] = [];\n if (request.pathParameters != null) {\n pathParameterFields.push(...this.getPathParameters({ namedParameters: request.pathParameters, snippet }));\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const filePropertyInfo = this.getFilePropertyInfo({ request, snippet });\n this.context.errors.unscope();\n\n if (\n !this.context.includePathParametersInWrappedRequest({\n request,\n inlinePathParameters\n })\n ) {\n args.push(...pathParameterFields);\n }\n\n if (\n this.context.needsRequestParameter({\n request,\n inlinePathParameters,\n inlineFileProperties: true\n })\n ) {\n args.push(\n ...this.getInlinedRequestArgs({\n request,\n snippet,\n pathParameterFields: this.context.includePathParametersInWrappedRequest({\n request,\n inlinePathParameters\n })\n ? pathParameterFields\n : [],\n filePropertyInfo\n })\n );\n }\n return args;\n }\n\n private getFilePropertyInfo({\n request,\n snippet\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): FilePropertyInfo {\n if (request.body == null || !this.context.isFileUploadRequestBody(request.body)) {\n return {\n fileFields: [],\n bodyPropertyFields: []\n };\n }\n return this.context.filePropertyMapper.getFilePropertyInfo({\n body: request.body,\n value: snippet.requestBody\n });\n }\n\n private getInlinedRequestArgs({\n request,\n snippet,\n pathParameterFields,\n filePropertyInfo\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n pathParameterFields: python.NamedValue[];\n filePropertyInfo: FilePropertyInfo;\n }): python.NamedValue[] {\n this.context.errors.scope(Scope.QueryParameters);\n const queryParameters = this.context.associateQueryParametersByWireValue({\n parameters: request.queryParameters ?? [],\n values: snippet.queryParameters ?? {}\n });\n const queryParameterFields = queryParameters.map((queryParameter) => ({\n name: this.context.getPropertyName(queryParameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(queryParameter)\n }));\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.Headers);\n const headers = this.context.associateByWireValue({\n parameters: request.headers ?? [],\n values: snippet.headers ?? {}\n });\n const headerFields = headers.map((header) => ({\n name: this.context.getPropertyName(header.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(header)\n }));\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const requestBodyFields =\n request.body != null\n ? this.getInlinedRequestBodyObjectFields({\n body: request.body,\n value: snippet.requestBody,\n filePropertyInfo\n })\n : [];\n this.context.errors.unscope();\n\n return [...pathParameterFields, ...queryParameterFields, ...headerFields, ...requestBodyFields];\n }\n\n private getInlinedRequestBodyObjectFields({\n body,\n value,\n filePropertyInfo\n }: {\n body: FernIr.dynamic.InlinedRequestBody;\n value: unknown;\n filePropertyInfo: FilePropertyInfo;\n }): python.NamedValue[] {\n switch (body.type) {\n case \"properties\":\n return this.getInlinedRequestBodyPropertyObjectFields({ parameters: body.value, value });\n case \"referenced\":\n return this.getReferencedRequestBodyPropertyTypeInstantiation({ body, value });\n case \"fileUpload\":\n return this.getFileUploadRequestBodyObjectFields({ filePropertyInfo });\n default:\n assertNever(body);\n }\n }\n\n private getFileUploadRequestBodyObjectFields({\n filePropertyInfo\n }: {\n filePropertyInfo: FilePropertyInfo;\n }): python.NamedValue[] {\n return [...filePropertyInfo.fileFields, ...filePropertyInfo.bodyPropertyFields];\n }\n\n private getReferencedRequestBodyPropertyTypeInstantiation({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBody;\n value: unknown;\n }): python.NamedValue[] {\n const bodyType = body.bodyType;\n switch (bodyType.type) {\n case \"bytes\":\n return this.getBodyRequestArgsForBytes({ body, value });\n case \"typeReference\":\n return this.getBodyRequestArgsForTypeReference({ typeReference: bodyType.value, value });\n default:\n assertNever(bodyType);\n }\n }\n\n private getInlinedRequestBodyPropertyObjectFields({\n parameters,\n value\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n value: unknown;\n }): python.NamedValue[] {\n const fields: python.NamedValue[] = [];\n\n const bodyProperties = this.context.associateByWireValue({\n parameters,\n values: this.context.getRecord(value) ?? {}\n });\n for (const parameter of bodyProperties) {\n fields.push({\n name: this.context.getPropertyName(parameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(parameter)\n });\n }\n\n return fields;\n }\n\n private getPathParameters({\n namedParameters,\n snippet\n }: {\n namedParameters: FernIr.dynamic.NamedParameter[];\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.NamedValue[] {\n const args: python.NamedValue[] = [];\n\n const pathParameters = this.context.associateByWireValue({\n parameters: namedParameters,\n values: snippet.pathParameters ?? {},\n\n // Path parameters are distributed across the client constructor\n // and the request method, so we ignore missing parameters here.\n ignoreMissingParameters: true\n });\n for (const parameter of pathParameters) {\n args.push({\n name: this.context.getPropertyName(parameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(parameter)\n });\n }\n\n return args;\n }\n\n private getMethod({ endpoint }: { endpoint: FernIr.dynamic.Endpoint }): string {\n if (endpoint.declaration.fernFilepath.allParts.length > 0) {\n return `${endpoint.declaration.fernFilepath.allParts\n .map((val) => this.context.getMethodName(val))\n .join(\".\")}.${this.context.getMethodName(endpoint.declaration.name)}`;\n }\n return this.context.getMethodName(endpoint.declaration.name);\n }\n\n private getEnvironmentOptionName({\n environment\n }: {\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): string {\n if (environment != null) {\n return \"environment\";\n }\n return \"base_url\";\n }\n}\n"],"mappings":"iIAAAA,IAAAC,IAQA,IAAMC,EAAsD,CACxD,KAAM,YACN,MAAO,QACX,EACMC,EAAsB,CAAC,SAAS,EAChCC,EAAkB,SAClBC,EAAwB,UAEjBC,EAAN,KAA+B,CAGlC,YAAY,CAAE,QAAAC,CAAQ,EAAiD,CAFvEC,EAAA,KAAQ,WAGJ,KAAK,QAAUD,CACnB,CAEA,MAAa,gBAAgB,CACzB,SAAAE,EACA,QAAAC,CACJ,EAGoB,CAEhB,OADa,KAAK,gBAAgB,CAAE,SAAAD,EAAU,QAASC,CAAQ,CAAC,EACpD,SAAS,CACzB,CAEO,oBAAoB,CACvB,SAAAD,EACA,QAAAC,CACJ,EAGW,CAEP,OADa,KAAK,gBAAgB,CAAE,SAAAD,EAAU,QAASC,CAAQ,CAAC,EACpD,SAAS,CACzB,CAEQ,gBAAgB,CACpB,SAAAD,EACA,QAAAE,CACJ,EAGsB,CAClB,OAAOC,EAAO,KAAK,CACf,KAAMT,EACN,WAAY,CAAC,KAAK,gBAAgB,CAAE,SAAAM,EAAU,QAAAE,CAAQ,CAAC,EAAG,KAAK,WAAW,CAAE,SAAAF,EAAU,QAAAE,CAAQ,CAAC,CAAC,CACpG,CAAC,CACL,CAEQ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,KAAK,QAAQ,cAAcA,CAAG,CAAC,EAC5C,KAAK,GAAG,CAAC,IAAI,KAAK,QAAQ,cAAcpD,EAAS,YAAY,IAAI,CAAC,GAEpE,KAAK,QAAQ,cAAcA,EAAS,YAAY,IAAI,CAC/D,CAEQ,yBAAyB,CAC7B,YAAAU,CACJ,EAEW,CACP,OAAIA,GAAe,KACR,cAEJ,UACX,CACJ","names":["init_process","init_buffer","STRING_TYPE_REFERENCE","SNIPPET_MODULE_PATH","CLIENT_VAR_NAME","REQUEST_BODY_ARG_NAME","EndpointSnippetGenerator","context","__publicField","endpoint","request","snippet","python_exports","arg","fields","environmentArgs","Severity","Scope","baseUrl","environment","environmentValue","environmentTypeReference","key","value","auth","values","assertNever","message","headers","header","field","typeLiteral","_a","_b","args","pathParameters","bodyPropertyNames","bodyArgs","disambiguatedPathArgs","__spreadProps","__spreadValues","body","typeReference","named","innerType","property","typeInstantiation","inlinePathParameters","pathParameterFields","filePropertyInfo","_c","_d","queryParameterFields","queryParameter","headerFields","requestBodyFields","bodyType","parameters","bodyProperties","parameter","namedParameters","val"]}
@@ -0,0 +1,2 @@
1
+ import{b as s}from"./chunk-6OLYGRJY.js";import{e as p,f as u,g as l,h as c,j as r}from"./chunk-YEXRWSXV.js";u();l();var d="value",y=class{constructor({context:e}){p(this,"context");this.context=e}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?r.TypeInstantiation.none():(this.context.errors.add({severity:s.Critical,message:"Expected non-null value, but got null"}),r.TypeInstantiation.nop());if(e.value===void 0)return r.TypeInstantiation.nop();switch(e.typeReference.type){case"list":return this.convertList({list:e.typeReference.value,value:e.value});case"literal":return this.convertLiteral({literalType:e.typeReference.value,value:e.value});case"map":return this.convertMap({map:e.typeReference,value:e.value});case"named":{let t=this.context.resolveNamedType({typeId:e.typeReference.value});return t==null?r.TypeInstantiation.nop():this.convertNamed({named:t,value:e.value,as:e.as})}case"optional":return this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as});case"nullable":return this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as});case"primitive":return this.convertPrimitive({primitive:e.typeReference.value,value:e.value,as:e.as});case"set":return this.convertSet({set:e.typeReference.value,value:e.value});case"unknown":return r.TypeInstantiation.unknown(e.value);default:c(e.typeReference)}}convertLiteral({literalType:e,value:t}){switch(e.type){case"boolean":{let i=this.context.getValueAsBoolean({value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.bool(i)}case"string":{let i=this.context.getValueAsString({value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.str(i)}default:c(e)}}convertList({list:e,value:t}){return Array.isArray(t)?r.TypeInstantiation.list(t.map((i,n)=>{this.context.errors.scope({index:n});try{return this.convert({typeReference:e,value:i})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:s.Critical,message:`Expected array but got: ${typeof t}`}),r.TypeInstantiation.nop())}convertSet({set:e,value:t}){return Array.isArray(t)?r.TypeInstantiation.list(t.map((i,n)=>{this.context.errors.scope({index:n});try{return this.convert({typeReference:e,value:i})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:s.Critical,message:`Expected array but got: ${typeof t}`}),r.TypeInstantiation.nop())}convertMap({map:e,value:t}){return typeof t!="object"||t==null?(this.context.errors.add({severity:s.Critical,message:`Expected object but got: ${t==null?"null":typeof t}`}),r.TypeInstantiation.nop()):r.TypeInstantiation.dict(Object.entries(t).map(([i,n])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:e.key,value:i,as:"key"}),value:this.convert({typeReference:e.value,value:n})}}finally{this.context.errors.unscope()}}),{multiline:!0})}convertNamed({named:e,value:t,as:i}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference,value:t,as:i});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:e,value:t});case"enum":return this.convertEnum({enum_:e,value:t});case"object":return this.convertObject({object_:e,value:t});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t});default:c(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:t}){let i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t});if(i==null)return r.TypeInstantiation.nop();let n=i.singleDiscriminatedUnionType,a=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:i,unionVariant:n});if(a==null)return r.TypeInstantiation.nop();let o={name:this.context.getPropertyName(e.discriminant.name),value:r.TypeInstantiation.str(n.discriminantValue.wireValue)};return r.TypeInstantiation.typedDict([o,...a],{multiline:!0})}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:e,unionVariant:t}){let i=this.getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t});switch(t.type){case"samePropertiesAsObject":{let n=this.context.resolveNamedType({typeId:t.typeId});if(n==null)return;let a=this.convertNamed({named:n,value:e.value});if(!a.isTypedDict()){this.context.errors.add({severity:s.Critical,message:"Internal error; expected union value to be an object"});return}let o=a.asTypedDictOrThrow();return[...i,...o.entries]}case"singleProperty":try{this.context.errors.scope(t.discriminantValue.wireValue);let n=this.context.getRecord(e.value);return n==null?[...i,{name:d,value:this.convert({typeReference:t.typeReference,value:e.value})}]:[...i,{name:this.context.getPropertyName(t.discriminantValue.name),value:this.convert({typeReference:t.typeReference,value:n[t.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return i;default:c(t)}}getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t}){var n,a;return this.context.associateByWireValue({parameters:(n=t.properties)!=null?n:[],values:(a=this.context.getRecord(e.value))!=null?a:{},ignoreMissingParameters:!0}).map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getPropertyName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})}convertObject({object_:e,value:t}){var n;let i=this.context.associateByWireValue({parameters:e.properties,values:(n=this.context.getRecord(t))!=null?n:{}});return r.TypeInstantiation.typedDict(i.map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getPropertyName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}}),{multiline:!0})}convertEnum({enum_:e,value:t}){let i=this.getEnumValue({enum_:e,value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.str(i)}getEnumValue({enum_:e,value:t}){if(typeof t!="string"){this.context.errors.add({severity:s.Critical,message:`Expected enum value string, got: ${typeof t}`});return}if(e.values.find(n=>n.wireValue===t)==null){this.context.errors.add({severity:s.Critical,message:`An enum value named "${t}" does not exist in this context`});return}return t}convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t});return i==null?r.TypeInstantiation.nop():i}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t}){for(let i of e.types)try{return this.convert({typeReference:i,value:t})}catch(n){continue}this.context.errors.add({severity:s.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof t}" value`})}convertPrimitive({primitive:e,value:t,as:i}){switch(e){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let n=this.getValueAsNumber({value:t,as:i});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.int(n)}case"FLOAT":case"DOUBLE":{let n=this.getValueAsNumber({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.float(n)}case"BOOLEAN":{let n=this.getValueAsBoolean({value:t,as:i});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.bool(n)}case"BASE_64":case"BIG_INTEGER":case"STRING":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.str(n)}case"UUID":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.uuid(n)}case"DATE":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.date(n)}case"DATE_TIME":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.datetime(n)}default:c(e)}}getValueAsNumber({value:e,as:t}){let i=t==="key"&&typeof e=="string"?Number(e):e;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:e,as:t}){let i=t==="key"?typeof e=="string"?e==="true":e==="false"?!1:e:e;return this.context.getValueAsBoolean({value:i})}};export{y as a};
2
+ //# sourceMappingURL=chunk-PFARUNGR.js.map