@fern-api/typescript-dynamic-snippets 0.0.6 → 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.
- package/cjs/DynamicSnippetsGenerator.cjs +17 -5508
- package/cjs/EndpointSnippetGenerator.cjs +17 -3539
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +17 -4863
- package/cjs/context/DynamicTypeLiteralMapper.cjs +17 -3493
- package/cjs/context/FilePropertyMapper.cjs +17 -3073
- package/cjs/index.cjs +29 -8811
- package/esm/DynamicSnippetsGenerator.js +1 -12
- package/esm/EndpointSnippetGenerator.js +1 -8
- package/esm/chunk-25TNFA5L.js +14 -0
- package/esm/chunk-736FTN3M.js +1 -0
- package/esm/chunk-CQ55KPJT.js +1 -0
- package/esm/chunk-LX5O4JB7.js +1 -0
- package/esm/chunk-SQLJANKO.js +1 -0
- package/esm/chunk-V6G7NZKW.js +1 -0
- package/esm/chunk-YD6EIACZ.js +27 -0
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -10
- package/esm/context/DynamicTypeLiteralMapper.js +1 -8
- package/esm/context/FilePropertyMapper.js +1 -7
- package/esm/index.js +13 -3311
- package/package.json +2 -2
- package/esm/chunk-37WY6L3Q.js +0 -551
- package/esm/chunk-6Y2IOBCK.js +0 -501
- package/esm/chunk-KUITDN45.js +0 -538
- package/esm/chunk-MR7ZAFRL.js +0 -819
- package/esm/chunk-PLZLTFT4.js +0 -90
- package/esm/chunk-TKT54OF7.js +0 -86
- package/esm/chunk-WPDO6IRW.js +0 -3060
|
@@ -1,12 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
DynamicSnippetsGenerator
|
|
3
|
-
} from "./chunk-TKT54OF7.js";
|
|
4
|
-
import "./chunk-KUITDN45.js";
|
|
5
|
-
import "./chunk-MR7ZAFRL.js";
|
|
6
|
-
import "./chunk-6Y2IOBCK.js";
|
|
7
|
-
import "./chunk-37WY6L3Q.js";
|
|
8
|
-
import "./chunk-PLZLTFT4.js";
|
|
9
|
-
import "./chunk-WPDO6IRW.js";
|
|
10
|
-
export {
|
|
11
|
-
DynamicSnippetsGenerator
|
|
12
|
-
};
|
|
1
|
+
import{a}from"./chunk-CQ55KPJT.js";import"./chunk-V6G7NZKW.js";import"./chunk-25TNFA5L.js";import"./chunk-SQLJANKO.js";import"./chunk-736FTN3M.js";import"./chunk-LX5O4JB7.js";import"./chunk-YD6EIACZ.js";export{a as DynamicSnippetsGenerator};
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
EndpointSnippetGenerator
|
|
3
|
-
} from "./chunk-KUITDN45.js";
|
|
4
|
-
import "./chunk-37WY6L3Q.js";
|
|
5
|
-
import "./chunk-WPDO6IRW.js";
|
|
6
|
-
export {
|
|
7
|
-
EndpointSnippetGenerator
|
|
8
|
-
};
|
|
1
|
+
import{a}from"./chunk-V6G7NZKW.js";import"./chunk-736FTN3M.js";import"./chunk-YD6EIACZ.js";export{a as EndpointSnippetGenerator};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{a as I}from"./chunk-SQLJANKO.js";import{c as S}from"./chunk-736FTN3M.js";import{a as N}from"./chunk-LX5O4JB7.js";import{j as l,k as t,m as o,p as C}from"./chunk-YD6EIACZ.js";t();o();t();o();t();o();t();o();t();o();t();o();t();o();var Oe=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,A=Oe;var Te=typeof self=="object"&&self&&self.Object===Object&&self,ke=A||Te||Function("return this")(),O=ke;var we=O.Symbol,d=we;t();o();var T=Object.prototype,Ee=T.hasOwnProperty,je=T.toString,c=d?d.toStringTag:void 0;function Me(e){var a=Ee.call(e,c),r=e[c];try{e[c]=void 0;var f=!0}catch(i){}var p=je.call(e);return f&&(a?e[c]=r:delete e[c]),p}var k=Me;t();o();var We=Object.prototype,Le=We.toString;function Ue(e){return Le.call(e)}var w=Ue;var Fe="[object Null]",Pe="[object Undefined]",E=d?d.toStringTag:void 0;function ze(e){return e==null?e===void 0?Pe:Fe:E&&E in Object(e)?k(e):w(e)}var j=ze;t();o();function Be(e){return e!=null&&typeof e=="object"}var M=Be;var De="[object Symbol]";function Ge(e){return typeof e=="symbol"||M(e)&&j(e)==De}var W=Ge;t();o();t();o();function Ze(e,a){for(var r=-1,f=e==null?0:e.length,p=Array(f);++r<f;)p[r]=a(e[r],r,e);return p}var L=Ze;t();o();var $e=Array.isArray,U=$e;var qe=1/0,F=d?d.prototype:void 0,P=F?F.toString:void 0;function z(e){if(typeof e=="string")return e;if(U(e))return L(e,z)+"";if(W(e))return P?P.call(e):"";var a=e+"";return a=="0"&&1/e==-qe?"-0":a}var B=z;t();o();function Ve(e){return e==null?"":B(e)}var m=Ve;t();o();t();o();t();o();t();o();t();o();t();o();function He(e,a,r){var f=-1,p=e.length;a<0&&(a=-a>p?0:p+a),r=r>p?p:r,r<0&&(r+=p),p=a>r?0:r-a>>>0,a>>>=0;for(var i=Array(p);++f<p;)i[f]=e[f+a];return i}var D=He;function Je(e,a,r){var f=e.length;return r=r===void 0?f:r,!a&&r>=f?e:D(e,a,r)}var G=Je;t();o();var Ke="\\ud800-\\udfff",Ye="\\u0300-\\u036f",_e="\\ufe20-\\ufe2f",Qe="\\u20d0-\\u20ff",Xe=Ye+_e+Qe,er="\\ufe0e\\ufe0f",rr="\\u200d",tr=RegExp("["+rr+Ke+Xe+er+"]");function or(e){return tr.test(e)}var g=or;t();o();t();o();function ar(e){return e.split("")}var Z=ar;t();o();var $="\\ud800-\\udfff",fr="\\u0300-\\u036f",ur="\\ufe20-\\ufe2f",sr="\\u20d0-\\u20ff",pr=fr+ur+sr,dr="\\ufe0e\\ufe0f",mr="["+$+"]",h="["+pr+"]",y="\\ud83c[\\udffb-\\udfff]",lr="(?:"+h+"|"+y+")",q="[^"+$+"]",V="(?:\\ud83c[\\udde6-\\uddff]){2}",H="[\\ud800-\\udbff][\\udc00-\\udfff]",ir="\\u200d",J=lr+"?",K="["+dr+"]?",nr="(?:"+ir+"(?:"+[q,V,H].join("|")+")"+K+J+")*",xr=K+J+nr,cr="(?:"+[q+h+"?",h,V,H,mr].join("|")+")",gr=RegExp(y+"(?="+y+")|"+cr+xr,"g");function br(e){return e.match(gr)||[]}var Y=br;function hr(e){return g(e)?Y(e):Z(e)}var _=hr;function yr(e){return function(a){a=m(a);var r=g(a)?_(a):void 0,f=r?r[0]:a.charAt(0),p=r?G(r,1).join(""):a.slice(1);return f[e]()+p}}var Q=yr;var Rr=Q("toUpperCase"),n=Rr;function vr(e){return n(m(e).toLowerCase())}var X=vr;t();o();t();o();function Sr(e,a,r,f){var p=-1,i=e==null?0:e.length;for(f&&i&&(r=e[++p]);++p<i;)r=a(r,e[p],p,e);return r}var ee=Sr;t();o();t();o();t();o();function Cr(e){return function(a){return e==null?void 0:e[a]}}var re=Cr;var Ir={\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"},Nr=re(Ir),te=Nr;var Ar=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Or="\\u0300-\\u036f",Tr="\\ufe20-\\ufe2f",kr="\\u20d0-\\u20ff",wr=Or+Tr+kr,Er="["+wr+"]",jr=RegExp(Er,"g");function Mr(e){return e=m(e),e&&e.replace(Ar,te).replace(jr,"")}var oe=Mr;t();o();t();o();var Wr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Lr(e){return e.match(Wr)||[]}var ae=Lr;t();o();var Ur=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Fr(e){return Ur.test(e)}var fe=Fr;t();o();var me="\\ud800-\\udfff",Pr="\\u0300-\\u036f",zr="\\ufe20-\\ufe2f",Br="\\u20d0-\\u20ff",Dr=Pr+zr+Br,le="\\u2700-\\u27bf",ie="a-z\\xdf-\\xf6\\xf8-\\xff",Gr="\\xac\\xb1\\xd7\\xf7",Zr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",$r="\\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",ne="A-Z\\xc0-\\xd6\\xd8-\\xde",Vr="\\ufe0e\\ufe0f",xe=Gr+Zr+$r+qr,ce="['\u2019]",ue="["+xe+"]",Hr="["+Dr+"]",ge="\\d+",Jr="["+le+"]",be="["+ie+"]",he="[^"+me+xe+ge+le+ie+ne+"]",Kr="\\ud83c[\\udffb-\\udfff]",Yr="(?:"+Hr+"|"+Kr+")",_r="[^"+me+"]",ye="(?:\\ud83c[\\udde6-\\uddff]){2}",Re="[\\ud800-\\udbff][\\udc00-\\udfff]",x="["+ne+"]",Qr="\\u200d",se="(?:"+be+"|"+he+")",Xr="(?:"+x+"|"+he+")",pe="(?:"+ce+"(?:d|ll|m|re|s|t|ve))?",de="(?:"+ce+"(?:D|LL|M|RE|S|T|VE))?",ve=Yr+"?",Se="["+Vr+"]?",et="(?:"+Qr+"(?:"+[_r,ye,Re].join("|")+")"+Se+ve+")*",rt="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",tt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",ot=Se+ve+et,at="(?:"+[Jr,ye,Re].join("|")+")"+ot,ft=RegExp([x+"?"+be+"+"+pe+"(?="+[ue,x,"$"].join("|")+")",Xr+"+"+de+"(?="+[ue,x+se,"$"].join("|")+")",x+"?"+se+"+"+pe,x+"+"+de,tt,rt,ge,at].join("|"),"g");function ut(e){return e.match(ft)||[]}var Ce=ut;function st(e,a,r){return e=m(e),a=r?void 0:a,a===void 0?fe(e)?Ce(e):ae(e):e.match(a)||[]}var Ie=st;var pt="['\u2019]",dt=RegExp(pt,"g");function mt(e){return function(a){return ee(Ie(oe(a).replace(dt,"")),e,"")}}var Ne=mt;var lt=Ne(function(e,a,r){return a=a.toLowerCase(),e+(r?X(a):a)}),b=lt;t();o();t();o();function R({generatorConfig:e,isPackagePrivate:a}){var f;let r=e.output.mode;switch(r.type){case"downloadFiles":return;case"publish":return{packageName:r.registriesV2.npm.packageName,version:r.version,private:a,publishInfo:{registryUrl:r.registriesV2.npm.registryUrl,token:r.registriesV2.npm.token},license:void 0,repoUrl:void 0};case"github":if(r.publishInfo!=null&&r.publishInfo.type!=="npm")throw new Error(`Expected to receive npm publish info but received ${r.publishInfo.type} instead`);return{packageName:r.publishInfo!=null?r.publishInfo.packageName:"",version:r.version,private:a,publishInfo:void 0,repoUrl:r.repoUrl,license:(f=e.license)==null?void 0:f._visit({basic:p=>p.id,custom:p=>`See ${p.filename}`,_other:()=>{}})};default:throw new Error(`Encountered unknown output mode: ${r}`)}}t();o();function v({organization:e,workspaceName:a,namespaceExport:r}){return r!=null?r:`${n(b(e))}${n(b(a))}`}var Ae=class e extends S{constructor({ir:r,config:f}){var p;super({ir:r,config:f});l(this,"ir");l(this,"customConfig");l(this,"dynamicTypeLiteralMapper");l(this,"filePropertyMapper");l(this,"moduleName");l(this,"namespaceExport");this.ir=r,this.customConfig=f.customConfig!=null?f.customConfig:void 0,this.dynamicTypeLiteralMapper=new I({context:this}),this.filePropertyMapper=new N({context:this}),this.moduleName=it({config:f,customConfig:this.customConfig}),this.namespaceExport=v({organization:f.organization,workspaceName:f.workspaceName,namespaceExport:(p=this.customConfig)==null?void 0:p.namespaceExport})}clone(){return new e({ir:this.ir,config:this.config})}getModuleImport(){return{type:"named",moduleName:this.moduleName}}getRootClientName(){return`${this.namespaceExport}Client`}getPropertyName(r){var f,p;return(f=this.customConfig)!=null&&f.retainOriginalCasing||(p=this.customConfig)!=null&&p.noSerdeLayer?this.formatOriginalPropertyName(r.originalName):r.camelCase.unsafeName}getMethodName(r){return r.camelCase.unsafeName}getTypeName(r){return r.pascalCase.unsafeName}getEnvironmentTypeReferenceFromID(r){let f=this.resolveEnvironmentName(r);if(f!=null)return this.getEnvironmentsTypeReference(f)}getFullyQualifiedReference({declaration:r}){return r.fernFilepath.allParts.length>0?`${r.fernFilepath.allParts.map(f=>f.camelCase.unsafeName).join(".")}.${this.getTypeName(r.name)}`:`${this.getTypeName(r.name)}`}getEnvironmentsTypeReference(r){return C.reference({name:`${this.namespaceExport}Environments`,importFrom:this.getModuleImport(),memberName:this.getTypeName(r)})}formatOriginalPropertyName(r){return r.includes("-")?`"${r}"`:r}};function it({config:e,customConfig:a}){var r,f,p;return(p=(f=R({generatorConfig:e,isPackagePrivate:(r=a==null?void 0:a.private)!=null?r:!1}))==null?void 0:f.packageName)!=null?p:e.organization}export{Ae as a};
|
|
2
|
+
/*! Bundled license information:
|
|
3
|
+
|
|
4
|
+
lodash-es/lodash.js:
|
|
5
|
+
(**
|
|
6
|
+
* @license
|
|
7
|
+
* Lodash (Custom Build) <https://lodash.com/>
|
|
8
|
+
* Build: `lodash modularize exports="es" -o ./`
|
|
9
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
10
|
+
* Released under MIT license <https://lodash.com/license>
|
|
11
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
12
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
13
|
+
*)
|
|
14
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as P,b as T,c as b,d as A,j as o,k as a,m as p,n as f,o as g}from"./chunk-YD6EIACZ.js";a();p();var E=class{constructor(e){o(this,"context");this.context=e}};a();p();var n={Critical:"CRITICAL",Warning:"WARNING"},y=class h{constructor(){o(this,"errors");o(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 h;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}};a();p();a();p();a();p();var v=class{constructor(){o(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH)\s(\/[a-zA-Z0-9\/{}_-]*)$/)}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 R=class{constructor({ir:e,config:r}){o(this,"config");o(this,"errors");o(this,"_ir");o(this,"httpEndpointReferenceParser");this._ir=e,this.config=r,this.errors=new y,this.httpEndpointReferenceParser=new v}associateQueryParametersByWireValue({parameters:e,values:r}){let t=[];for(let[i,s]of Object.entries(r)){this.errors.scope(i);try{let l=e.find(m=>m.name.wireValue===i);if(l==null)throw this.newParameterNotRecognizedError(i);let c=this.isListTypeReference(l.typeReference)&&!Array.isArray(s)?[s]:s;t.push({name:l.name,typeReference:l.typeReference,value:c})}finally{this.errors.unscope()}}return t}associateByWireValue({parameters:e,values:r,ignoreMissingParameters:t}){let i=[];for(let[s,l]of Object.entries(r)){this.errors.scope(s);try{let c=e.find(m=>m.name.wireValue===s);if(c==null){if(t)continue;this.errors.add({severity:n.Critical,message:this.newParameterNotRecognizedError(s).message});continue}i.push({name:c.name,typeReference:c.typeReference,value:l})}finally{this.errors.unscope()}}return i}getSingleFileValue({property:e,record:r}){let t=r[e.wireValue];if(t!=null){if(typeof t!="string"){this.errors.add({severity:n.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:n.Critical,message:`Expected file array value to be an array of strings, got ${typeof t}`});return}let i=[];for(let s of t){if(typeof s!="string"){this.errors.add({severity:n.Critical,message:`Expected file array value to be an array of strings, got ${typeof s}`});return}i.push(s)}return i}getRecord(e){if(typeof e!="object"||Array.isArray(e)){this.errors.add({severity:n.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:n.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 i=e.discriminant.wireValue,s=t[i];if(s==null){this.errors.add({severity:n.Critical,message:this.newParameterNotRecognizedError(i).message});return}if(typeof s!="string"){this.errors.add({severity:n.Critical,message:`Expected discriminant value to be a string but got: ${typeof s}`});return}let l=e.types[s];if(l==null){this.errors.add({severity:n.Critical,message:`No type found for discriminant value "${s}"`});return}let x=t,{[i]:c}=x,m=A(x,[b(i)]);return{singleDiscriminatedUnionType:l,discriminantValue:l.discriminantValue,value:m}}resolveEndpointOrThrow(e){let r=this.httpEndpointReferenceParser.tryParse(e);if(r==null)throw new Error(`Failed to parse endpoint reference "${e}"`);return this.resolveEndpointLocationOrThrow(r)}resolveEndpointLocationOrThrow(e){let r=[];for(let t of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:t,parsedEndpoint:e})&&r.push(t);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 i;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}):!((i=e.metadata)!=null&&i.onlyPathParameters)}includePathParametersInWrappedRequest({request:e,inlinePathParameters:r}){var t,i;return r&&((i=(t=e.metadata)==null?void 0:t.includePathParameters)!=null?i:!1)}isFileUploadRequestBody(e){switch(e.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:f(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(i=>i.id===e);return t==null?void 0:t.name}case"multipleBaseUrls":{let t=r.environments.find(i=>i.id===e);return t==null?void 0:t.name}default:f(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:n.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:n.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:n.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let i=new Set(g(t.urls));for(let s of g(e))i.has(s)&&i.delete(s);return i.size>0?(this.errors.add({severity:n.Critical,message:`The provided environments are invalid; got: [${Object.keys(e).join(", ")}], expected: [${g(t.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:e}){if(typeof e!="number"){this.errors.add({severity:n.Critical,message:this.newTypeMismatchError({expected:"number",value:e}).message});return}return e}getValueAsBoolean({value:e}){if(typeof e!="boolean"){this.errors.add({severity:n.Critical,message:this.newTypeMismatchError({expected:"boolean",value:e}).message});return}return e}getValueAsString({value:e}){if(typeof e!="string"){this.errors.add({severity:n.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:f(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:f(r)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:f(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}};a();p();var w=class{constructor(){o(this,"reporter");o(this,"snippet");o(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:e,snippet:r}){(this.reporter==null||this.reporter.size()>e.errors.size())&&(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}"`)}};a();p();var S={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};a();p();export{E as a,n as b,R as c,w as d,S as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c}from"./chunk-V6G7NZKW.js";import{a as h}from"./chunk-25TNFA5L.js";import{a as m,d as s}from"./chunk-736FTN3M.js";import{k as d,m as a}from"./chunk-YD6EIACZ.js";d();a();var f=class extends m{constructor({ir:n,config:r}){super(new h({ir:n,config:r}))}async generate(n){let r=this.context.resolveEndpointLocationOrThrow(n.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${n.endpoint.method} ${n.endpoint.path}"`);let e=new s;for(let i of r){let o=this.context.clone(),p=new c({context:o});try{let t=await p.generateSnippet({endpoint:i,request:n});if(o.errors.empty())return{snippet:t,errors:void 0};e.update({context:o,snippet:t})}catch(t){e.err==null&&(e.err=t)}}return e.getResponseOrThrow({endpoint:n.endpoint})}generateSync(n){let r=this.context.resolveEndpointLocationOrThrow(n.endpoint);if(r.length===0)throw new Error(`No endpoints found that match "${n.endpoint.method} ${n.endpoint.path}"`);let e=new s;for(let i of r){let o=this.context.clone(),p=new c({context:o});try{let t=p.generateSnippetSync({endpoint:i,request:n});if(o.errors.empty())return{snippet:t,errors:void 0};e.update({context:o,snippet:t})}catch(t){e.err==null&&(e.err=t)}}return e.getResponseOrThrow({endpoint:n.endpoint})}};export{f as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as l,k as p,m as y,n as s,p as n}from"./chunk-YD6EIACZ.js";p();y();var c=class{constructor({context:r}){l(this,"context");this.context=r}getFilePropertyInfo({body:r,value:o}){var a;let e={fileFields:[],bodyPropertyFields:[]},i=(a=this.context.getRecord(o))!=null?a:{};for(let t of r.properties)switch(t.type){case"file":e.fileFields.push({name:this.context.getPropertyName(t.name),value:this.getSingleFileProperty({property:t,record:i})});break;case"fileArray":e.fileFields.push({name:this.context.getPropertyName(t.name),value:this.getArrayFileProperty({property:t,record:i})});break;case"bodyProperty":e.bodyPropertyFields.push({name:this.context.getPropertyName(t.name.name),value:this.getBodyProperty({property:t,record:i})});break;default:s(t)}return e}getSingleFileProperty({property:r,record:o}){let e=this.context.getSingleFileValue({property:r,record:o});return e==null?n.TypeLiteral.nop():n.TypeLiteral.blob(e)}getArrayFileProperty({property:r,record:o}){let e=this.context.getFileArrayValues({property:r,record:o});return e==null?n.TypeLiteral.nop():n.TypeLiteral.array({values:e.map(i=>n.TypeLiteral.blob(i))})}getBodyProperty({property:r,record:o}){let e=o[r.name.wireValue];return e==null?n.TypeLiteral.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:r.typeReference,value:e})}};export{c as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as o}from"./chunk-736FTN3M.js";import{j as u,k as p,m as y,n as c,p as r}from"./chunk-YD6EIACZ.js";p();y();var v="value",d=class{constructor({context:e}){u(this,"context");this.context=e}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?r.TypeLiteral.null():(this.context.errors.add({severity:o.Critical,message:"Expected non-null value, but got null"}),r.TypeLiteral.nop());if(e.value===void 0)return r.TypeLiteral.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.TypeLiteral.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 this.convertUnknown({value:e.value});default:c(e.typeReference)}}convertLiteral({literalType:e,value:t}){switch(e.type){case"boolean":{let n=this.context.getValueAsBoolean({value:t});return n==null?r.TypeLiteral.nop():r.TypeLiteral.boolean(n)}case"string":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeLiteral.nop():r.TypeLiteral.string(n)}default:c(e)}}convertList({list:e,value:t}){return Array.isArray(t)?r.TypeLiteral.array({values:t.map((n,i)=>{this.context.errors.scope({index:i});try{return this.convert({typeReference:e,value:n})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:o.Critical,message:`Expected array but got: ${typeof t}`}),r.TypeLiteral.nop())}convertSet({set:e,value:t}){return Array.isArray(t)?r.TypeLiteral.set({values:t.map((n,i)=>{this.context.errors.scope({index:i});try{return this.convert({typeReference:e,value:n})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:o.Critical,message:`Expected array but got: ${typeof t}`}),r.TypeLiteral.nop())}convertMap({map:e,value:t}){return typeof t!="object"||t==null?(this.context.errors.add({severity:o.Critical,message:`Expected object but got: ${t==null?"null":typeof t}`}),r.TypeLiteral.nop()):r.TypeLiteral.record({entries:Object.entries(t).map(([n,i])=>{this.context.errors.scope(n);try{return{key:this.convert({typeReference:e.key,value:n,as:"key"}),value:this.convert({typeReference:e.value,value:i})}}finally{this.context.errors.unscope()}})})}convertNamed({named:e,value:t,as:n}){var i;switch(e.type){case"alias":return(i=this.context.customConfig)!=null&&i.useBrandedStringAliases?r.TypeLiteral.reference(r.codeblock(a=>{a.writeNode(r.reference({name:this.context.namespaceExport,importFrom:this.context.getModuleImport(),memberName:this.context.getFullyQualifiedReference({declaration:e.declaration})})),a.write("("),a.writeNode(this.convert({typeReference:e.typeReference,value:t,as:n})),a.write(")")})):this.convert({typeReference:e.typeReference,value:t,as:n});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.convertUndicriminatedUnion({undicriminatedUnion:e,value:t});default:c(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:t}){var l;let n=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t});if(n==null)return r.TypeLiteral.nop();let i=n.singleDiscriminatedUnionType,a=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:n,unionVariant:i});if(a==null)return r.TypeLiteral.nop();if((l=this.context.customConfig)!=null&&l.includeUtilsOnUnionMembers)return r.TypeLiteral.reference(r.codeblock(m=>{m.writeNode(r.invokeMethod({on:r.reference({name:this.context.namespaceExport,importFrom:this.context.getModuleImport(),memberName:this.context.getFullyQualifiedReference({declaration:e.declaration})}),method:this.context.getMethodName(i.discriminantValue.name),arguments_:this.convertDiscriminatedUnionUtilsArgs({discriminatedUnionTypeInstance:n,unionVariant:i,unionProperties:a})}))}));let s={name:this.context.getPropertyName(e.discriminant.name),value:r.TypeLiteral.string(i.discriminantValue.wireValue)};return r.TypeLiteral.object({fields:[s,...a]})}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:e,unionVariant:t}){let n=this.getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t});switch(t.type){case"samePropertiesAsObject":{let i=this.context.resolveNamedType({typeId:t.typeId});if(i==null)return;let a=this.convertNamed({named:i,value:e.value});if(!a.isObject()){this.context.errors.add({severity:o.Critical,message:"Internal error; expected union value to be an object"});return}let s=a.asObjectOrThrow();return[...n,...s.fields]}case"singleProperty":try{this.context.errors.scope(t.discriminantValue.wireValue);let i=this.context.getRecord(e.value);return i==null?[...n,{name:v,value:this.convert({typeReference:t.typeReference,value:e.value})}]:[...n,{name:this.context.getPropertyName(t.discriminantValue.name),value:this.convert({typeReference:t.typeReference,value:i[t.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return n;default:c(t)}}convertDiscriminatedUnionUtilsArgs({discriminatedUnionTypeInstance:e,unionVariant:t,unionProperties:n}){return t.type==="singleProperty"&&this.context.getRecord(e.value)==null&&n.length===1?[this.convert({typeReference:t.typeReference,value:e.value})]:n.length>0?[r.TypeLiteral.object({fields:n})]:[]}getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t}){var i,a;return this.context.associateByWireValue({parameters:(i=t.properties)!=null?i:[],values:(a=this.context.getRecord(e.value))!=null?a:{},ignoreMissingParameters:!0}).map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getPropertyName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})}convertObject({object_:e,value:t}){var i;let n=this.context.associateByWireValue({parameters:e.properties,values:(i=this.context.getRecord(t))!=null?i:{}});return r.TypeLiteral.object({fields:n.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()}})})}convertEnum({enum_:e,value:t}){let n=this.getEnumValue({enum_:e,value:t});return n==null?r.TypeLiteral.nop():r.TypeLiteral.string(n)}getEnumValue({enum_:e,value:t}){if(typeof t!="string"){this.context.errors.add({severity:o.Critical,message:`Expected enum value string, got: ${typeof t}`});return}if(e.values.find(i=>i.wireValue===t)==null){this.context.errors.add({severity:o.Critical,message:`An enum value named "${t}" does not exist in this context`});return}return t}convertUndicriminatedUnion({undicriminatedUnion:e,value:t}){let n=this.findMatchingUndiscriminatedUnionType({undicriminatedUnion:e,value:t});return n==null?r.TypeLiteral.nop():n}findMatchingUndiscriminatedUnionType({undicriminatedUnion:e,value:t}){for(let n of e.types)try{return this.convert({typeReference:n,value:t})}catch(i){continue}this.context.errors.add({severity:o.Critical,message:`None of the types in the undicriminated union matched the given "${typeof t}" value`})}convertUnknown({value:e}){return r.TypeLiteral.unknown(e)}convertPrimitive({primitive:e,value:t,as:n}){var i,a;switch(e){case"INTEGER":case"UINT":{let s=this.getValueAsNumber({value:t,as:n});return s==null?r.TypeLiteral.nop():r.TypeLiteral.number(s)}case"LONG":case"UINT_64":{let s=this.getValueAsNumber({value:t,as:n});return s==null?r.TypeLiteral.nop():(i=this.context.customConfig)!=null&&i.useBigInt?r.TypeLiteral.bigint(BigInt(s)):r.TypeLiteral.number(s)}case"FLOAT":case"DOUBLE":{let s=this.getValueAsNumber({value:t});return s==null?r.TypeLiteral.nop():r.TypeLiteral.number(s)}case"BOOLEAN":{let s=this.getValueAsBoolean({value:t,as:n});return s==null?r.TypeLiteral.nop():r.TypeLiteral.boolean(s)}case"BASE_64":case"DATE":case"UUID":case"STRING":{let s=this.context.getValueAsString({value:t});return s==null?r.TypeLiteral.nop():r.TypeLiteral.string(s)}case"DATE_TIME":{let s=this.context.getValueAsString({value:t});return s==null?r.TypeLiteral.nop():r.TypeLiteral.datetime(s)}case"BIG_INTEGER":{let s=this.context.getValueAsString({value:t});return s==null?r.TypeLiteral.nop():(a=this.context.customConfig)!=null&&a.useBigInt?r.TypeLiteral.bigint(BigInt(s)):r.TypeLiteral.string(s)}default:c(e)}}getValueAsNumber({value:e,as:t}){let n=t==="key"&&typeof e=="string"?Number(e):e;return this.context.getValueAsNumber({value:n})}getValueAsBoolean({value:e,as:t}){let n=t==="key"?typeof e=="string"?e==="true":e==="false"?!1:e:e;return this.context.getValueAsBoolean({value:n})}};export{d as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as c,e as o}from"./chunk-736FTN3M.js";import{j as F,k as v,m as P,n as u,p as n}from"./chunk-YD6EIACZ.js";v();P();var x="client",I="main",b={type:"primitive",value:"STRING"},R=class{constructor({context:e}){F(this,"context");this.context=e}async generateSnippet({endpoint:e,request:t}){return await this.buildCodeBlock({endpoint:e,snippet:t}).toStringAsync({customConfig:this.context.customConfig})}generateSnippetSync({endpoint:e,request:t}){return this.buildCodeBlock({endpoint:e,snippet:t}).toString({customConfig:this.context.customConfig})}buildCodeBlock({endpoint:e,snippet:t}){return n.codeblock(r=>{r.writeNode(n.function_({name:I,async:!0,parameters:[],body:n.codeblock(i=>{i.writeNodeStatement(this.constructClient({endpoint:e,snippet:t})),i.writeNodeStatement(this.callMethod({endpoint:e,snippet:t}))})})),r.writeNodeStatement(n.invokeFunction({function_:n.reference({name:I}),arguments_:[]}))})}constructClient({endpoint:e,snippet:t}){return n.variable({name:x,const:!0,initializer:n.instantiateClass({class_:n.reference({name:this.context.getRootClientName(),importFrom:this.context.getModuleImport()}),arguments_:[this.getConstructorArgs({endpoint:e,snippet:t})]})})}getConstructorArgs({endpoint:e,snippet:t}){let r=[],i=this.getConstructorEnvironmentArgs({baseUrl:t.baseURL,environment:t.environment});return i.length>0&&r.push(...i),e.auth!=null&&(t.auth!=null?r.push(...this.getConstructorAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:c.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`})),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.length===0?n.TypeLiteral.nop():n.TypeLiteral.object({fields:r})}getConstructorEnvironmentArgs({baseUrl:e,environment:t}){let r=this.getEnvironmentValue({baseUrl:e,environment:t});return r==null?[]:[{name:"environment",value:r}]}getEnvironmentValue({baseUrl:e,environment:t}){if(e!=null&&t!=null){this.context.errors.add({severity:c.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(e!=null)return n.TypeLiteral.string(e);if(t!=null){if(this.context.isSingleEnvironmentID(t)){let r=this.context.getEnvironmentTypeReferenceFromID(t);if(r==null){this.context.errors.add({severity:c.Warning,message:`Environment ${JSON.stringify(t)} was not found`});return}return n.TypeLiteral.reference(r)}if(this.context.isMultiEnvironmentValues(t))return this.context.validateMultiEnvironmentUrlValues(t)?n.TypeLiteral.object({fields:Object.entries(t).map(([r,i])=>({name:r,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:b,value:i})}))}):void 0}}getConstructorAuthArgs({auth:e,values:t}){switch(e.type){case"basic":return t.type!=="basic"?(this.context.errors.add({severity:c.Critical,message:this.context.newAuthMismatchError({auth:e,values:t}).message}),[]):this.getConstructorBasicAuthArg({auth:e,values:t});case"bearer":return t.type!=="bearer"?(this.context.errors.add({severity:c.Critical,message:this.context.newAuthMismatchError({auth:e,values:t}).message}),[]):this.getConstructorBearerAuthArgs({auth:e,values:t});case"header":return t.type!=="header"?(this.context.errors.add({severity:c.Critical,message:this.context.newAuthMismatchError({auth:e,values:t}).message}),[]):this.getConstructorHeaderAuthArgs({auth:e,values:t});default:u(e)}}getConstructorBasicAuthArg({auth:e,values:t}){return[{name:this.context.getPropertyName(e.username),value:n.TypeLiteral.string(t.username)},{name:this.context.getPropertyName(e.password),value:n.TypeLiteral.string(t.password)}]}getConstructorBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.token),value:n.TypeLiteral.string(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})}]}getConstructorHeaderArgs({headers:e,values:t}){let r=[];for(let i of e){let s=this.getConstructorHeaderArg({header:i,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(!n.TypeLiteral.isNop(r))return{name:this.context.getPropertyName(e.name.name),value:r}}callMethod({endpoint:e,snippet:t}){return n.invokeMethod({on:n.reference({name:x}),method:this.getMethod({endpoint:e}),async:!0,arguments_:this.getMethodArgs({endpoint:e,snippet:t})})}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}){let r=[];if(this.context.errors.scope(o.PathParameters),e.pathParameters!=null){let i=this.getPathParameters({namedParameters:e.pathParameters,snippet:t});r.push(...i.map(s=>s.value))}return this.context.errors.unscope(),this.context.errors.scope(o.RequestBody),e.body!=null&&r.push(this.getBodyRequestArg({body:e.body,value:t.requestBody})),this.context.errors.unscope(),r}getBodyRequestArg({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t});default:u(e)}}getBytesBodyRequestArg({value:e}){return typeof e!="string"?(this.context.errors.add({severity:c.Critical,message:`Expected bytes value to be a string, got ${typeof e}`}),n.TypeLiteral.nop()):n.TypeLiteral.blob(e)}getMethodArgsForInlinedRequest({request:e,snippet:t}){var m,h,p,l;let r=[],{inlinePathParameters:i,inlineFileProperties:s}={inlinePathParameters:(h=(m=this.context.customConfig)==null?void 0:m.inlinePathParameters)!=null?h:!1,inlineFileProperties:(l=(p=this.context.customConfig)==null?void 0:p.inlineFileProperties)!=null?l:!1};this.context.errors.scope(o.PathParameters);let a=[];e.pathParameters!=null&&a.push(...this.getPathParameters({namedParameters:e.pathParameters,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(o.RequestBody);let g=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:i})||r.push(...a.map(d=>d.value)),s||r.push(...g.fileFields.map(d=>d.value)),this.context.needsRequestParameter({request:e,inlinePathParameters:i,inlineFileProperties:s})&&r.push(this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:i})?a:[],filePropertyInfo:g})),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})}getInlinedRequestArg({request:e,snippet:t,pathParameterFields:r,filePropertyInfo:i}){var p,l,d,f;this.context.errors.scope(o.QueryParameters);let a=this.context.associateQueryParametersByWireValue({parameters:(p=e.queryParameters)!=null?p:[],values:(l=t.queryParameters)!=null?l:{}}).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:(d=e.headers)!=null?d:[],values:(f=t.headers)!=null?f:{}}).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 h=e.body!=null?this.getInlinedRequestBodyObjectFields({body:e.body,value:t.requestBody,filePropertyInfo:i}):[];return this.context.errors.unscope(),n.TypeLiteral.object({fields:[...r,...a,...m,...h]})}getInlinedRequestBodyObjectFields({body:e,value:t,filePropertyInfo:r}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyObjectFields({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyObjectField({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyObjectFields({filePropertyInfo:r});default:u(e)}}getFileUploadRequestBodyObjectFields({filePropertyInfo:e}){var t;return(t=this.context.customConfig)!=null&&t.inlineFileProperties?[...e.fileFields,...e.bodyPropertyFields]:e.bodyPropertyFields}getReferencedRequestBodyPropertyObjectField({body:e,value:t}){return{name:this.context.getPropertyName(e.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:e.bodyType,value:t})}}getReferencedRequestBodyPropertyTypeLiteral({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t});default:u(e)}}getInlinedRequestBodyPropertyObjectFields({parameters:e,value:t}){var s;let r=[],i=this.context.associateByWireValue({parameters:e,values:(s=this.context.getRecord(t))!=null?s:{}});for(let a of i)r.push({name:this.context.getPropertyName(a.name.name),value:this.context.dynamicTypeLiteralMapper.convert(a)});return r}getPathParameters({namedParameters:e,snippet:t}){var s;let r=[],i=this.context.associateByWireValue({parameters:e,values:(s=t.pathParameters)!=null?s:{}});for(let a of i)r.push({name:this.context.getPropertyName(a.name.name),value:this.context.dynamicTypeLiteralMapper.convert(a)});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)}};export{R as a};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var jr=Object.create;var Q=Object.defineProperty,Vr=Object.defineProperties,Jr=Object.getOwnPropertyDescriptor,zr=Object.getOwnPropertyDescriptors,Hr=Object.getOwnPropertyNames,rr=Object.getOwnPropertySymbols,Gr=Object.getPrototypeOf,lr=Object.prototype.hasOwnProperty,xr=Object.prototype.propertyIsEnumerable;var fr=(e,t,r)=>t in e?Q(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ce=(e,t)=>{for(var r in t||(t={}))lr.call(t,r)&&fr(e,r,t[r]);if(rr)for(var r of rr(t))xr.call(t,r)&&fr(e,r,t[r]);return e},pe=(e,t)=>Vr(e,zr(t));var me=e=>typeof e=="symbol"?e:e+"",we=(e,t)=>{var r={};for(var n in e)lr.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&rr)for(var n of rr(e))t.indexOf(n)<0&&xr.call(e,n)&&(r[n]=e[n]);return r};var hr=(e,t)=>()=>(e&&(t=e(e=0)),t);var de=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Qr=(e,t)=>{for(var r in t)Q(e,r,{get:t[r],enumerable:!0})},yr=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Hr(t))!lr.call(e,i)&&i!==r&&Q(e,i,{get:()=>t[i],enumerable:!(n=Jr(t,i))||n.enumerable});return e};var xe=(e,t,r)=>(r=e!=null?jr(Gr(e)):{},yr(t||!e||!e.__esModule?Q(r,"default",{value:e,enumerable:!0}):r,e)),ye=e=>yr(Q({},"__esModule",{value:!0}),e);var c=(e,t,r)=>fr(e,typeof t!="symbol"?t+"":t,r);function Ar(){throw new Error("setTimeout has not been defined")}function Tr(){throw new Error("clearTimeout has not been defined")}function Er(e){if(R===setTimeout)return setTimeout(e,0);if((R===Ar||!R)&&setTimeout)return R=setTimeout,setTimeout(e,0);try{return R(e,0)}catch(t){try{return R.call(null,e,0)}catch(r){return R.call(this,e,0)}}}function Xr(e){if(S===clearTimeout)return clearTimeout(e);if((S===Tr||!S)&&clearTimeout)return S=clearTimeout,clearTimeout(e);try{return S(e)}catch(t){try{return S.call(null,e)}catch(r){return S.call(this,e)}}}function Zr(){!O||!U||(O=!1,U.length?N=U.concat(N):tr=-1,N.length&&vr())}function vr(){if(!O){var e=Er(Zr);O=!0;for(var t=N.length;t;){for(U=N,N=[];++tr<t;)U&&U[tr].run();tr=-1,t=N.length}U=null,O=!1,Xr(e)}}function qr(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];N.push(new Ir(e,t)),N.length===1&&!O&&Er(vr)}function Ir(e,t){this.fun=e,this.array=t}function L(){}function wt(e){throw new Error("process.binding is not supported")}function dt(){return"/"}function xt(e){throw new Error("process.chdir is not supported")}function yt(){return 0}function At(e){var t=gt.call($)*.001,r=Math.floor(t),n=Math.floor(t%1*1e9);return e&&(r=r-e[0],n=n-e[1],n<0&&(r--,n+=1e9)),[r,n]}function Et(){var e=new Date,t=e-Tt;return t/1e3}var R,S,N,O,U,tr,Kr,rt,tt,et,nt,it,ot,st,at,ut,ft,lt,ht,ct,pt,mt,$,gt,Tt,d,gr,l=hr(()=>{"use strict";R=Ar,S=Tr;typeof globalThis.setTimeout=="function"&&(R=setTimeout);typeof globalThis.clearTimeout=="function"&&(S=clearTimeout);N=[],O=!1,tr=-1;Ir.prototype.run=function(){this.fun.apply(null,this.array)};Kr="browser",rt="browser",tt=!0,et={},nt=[],it="",ot={},st={},at={};ut=L,ft=L,lt=L,ht=L,ct=L,pt=L,mt=L;$=globalThis.performance||{},gt=$.now||$.mozNow||$.msNow||$.oNow||$.webkitNow||function(){return new Date().getTime()};Tt=new Date;d={nextTick:qr,title:Kr,browser:tt,env:et,argv:nt,version:it,versions:ot,on:ut,addListener:ft,once:lt,off:ht,removeListener:ct,removeAllListeners:pt,emit:mt,binding:wt,cwd:dt,chdir:xt,umask:yt,hrtime:At,platform:rt,release:st,config:at,uptime:Et},gr={};Object.keys(gr).forEach(e=>{let t=e.split("."),r=d;for(let n=0;n<t.length;n++){let i=t[n];n===t.length-1?r[i]=gr[e]:r=r[i]||(r[i]={})}})});function Rr(){pr=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t<r;++t)v[t]=e[t],E[e.charCodeAt(t)]=t;E[45]=62,E[95]=63}function It(e){pr||Rr();var t,r,n,i,o,s,u=e.length;if(u%4>0)throw new Error("Invalid string. Length must be a multiple of 4");o=e[u-2]==="="?2:e[u-1]==="="?1:0,s=new vt(u*3/4-o),n=o>0?u-4:u;var f=0;for(t=0,r=0;t<n;t+=4,r+=3)i=E[e.charCodeAt(t)]<<18|E[e.charCodeAt(t+1)]<<12|E[e.charCodeAt(t+2)]<<6|E[e.charCodeAt(t+3)],s[f++]=i>>16&255,s[f++]=i>>8&255,s[f++]=i&255;return o===2?(i=E[e.charCodeAt(t)]<<2|E[e.charCodeAt(t+1)]>>4,s[f++]=i&255):o===1&&(i=E[e.charCodeAt(t)]<<10|E[e.charCodeAt(t+1)]<<4|E[e.charCodeAt(t+2)]>>2,s[f++]=i>>8&255,s[f++]=i&255),s}function Nt(e){return v[e>>18&63]+v[e>>12&63]+v[e>>6&63]+v[e&63]}function bt(e,t,r){for(var n,i=[],o=t;o<r;o+=3)n=(e[o]<<16)+(e[o+1]<<8)+e[o+2],i.push(Nt(n));return i.join("")}function Nr(e){pr||Rr();for(var t,r=e.length,n=r%3,i="",o=[],s=16383,u=0,f=r-n;u<f;u+=s)o.push(bt(e,u,u+s>f?f:u+s));return n===1?(t=e[r-1],i+=v[t>>2],i+=v[t<<4&63],i+="=="):n===2&&(t=(e[r-2]<<8)+e[r-1],i+=v[t>>10],i+=v[t>>4&63],i+=v[t<<2&63],i+="="),o.push(i),o.join("")}function er(){return a.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function b(e,t){if(er()<t)throw new RangeError("Invalid typed array length");return a.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t),e.__proto__=a.prototype):(e===null&&(e=new a(t)),e.length=t),e}function a(e,t,r){if(!a.TYPED_ARRAY_SUPPORT&&!(this instanceof a))return new a(e,t,r);if(typeof e=="number"){if(typeof t=="string")throw new Error("If encoding is specified then the first argument must be a string");return mr(this,e)}return Sr(this,e,t,r)}function Sr(e,t,r,n){if(typeof t=="number")throw new TypeError('"value" argument must not be a number');return typeof ArrayBuffer!="undefined"&&t instanceof ArrayBuffer?St(e,t,r,n):typeof t=="string"?Rt(e,t,r):_t(e,t)}function _r(e){if(typeof e!="number")throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function kt(e,t,r,n){return _r(t),t<=0?b(e,t):r!==void 0?typeof n=="string"?b(e,t).fill(r,n):b(e,t).fill(r):b(e,t)}function mr(e,t){if(_r(t),e=b(e,t<0?0:wr(t)|0),!a.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function Rt(e,t,r){if((typeof r!="string"||r==="")&&(r="utf8"),!a.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=Br(t,r)|0;e=b(e,n);var i=e.write(t,r);return i!==n&&(e=e.slice(0,i)),e}function cr(e,t){var r=t.length<0?0:wr(t.length)|0;e=b(e,r);for(var n=0;n<r;n+=1)e[n]=t[n]&255;return e}function St(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return r===void 0&&n===void 0?t=new Uint8Array(t):n===void 0?t=new Uint8Array(t,r):t=new Uint8Array(t,r,n),a.TYPED_ARRAY_SUPPORT?(e=t,e.__proto__=a.prototype):e=cr(e,t),e}function _t(e,t){if(I(t)){var r=wr(t.length)|0;return e=b(e,r),e.length===0||t.copy(e,0,0,r),e}if(t){if(typeof ArrayBuffer!="undefined"&&t.buffer instanceof ArrayBuffer||"length"in t)return typeof t.length!="number"||Qt(t.length)?b(e,0):cr(e,t);if(t.type==="Buffer"&&Array.isArray(t.data))return cr(e,t.data)}throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}function wr(e){if(e>=er())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+er().toString(16)+" bytes");return e|0}function I(e){return!!(e!=null&&e._isBuffer)}function Br(e,t){if(I(e))return e.length;if(typeof ArrayBuffer!="undefined"&&typeof ArrayBuffer.isView=="function"&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;typeof e!="string"&&(e=""+e);var r=e.length;if(r===0)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return nr(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return Mr(e).length;default:if(n)return nr(e).length;t=(""+t).toLowerCase(),n=!0}}function Bt(e,t,r){var n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return Ot(this,t,r);case"utf8":case"utf-8":return Fr(this,t,r);case"ascii":return Dt(this,t,r);case"latin1":case"binary":return $t(this,t,r);case"base64":return Yt(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Wt(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function F(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function Ur(e,t,r,n,i){if(e.length===0)return-1;if(typeof r=="string"?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=a.from(t,n)),I(t))return t.length===0?-1:br(e,t,r,n,i);if(typeof t=="number")return t=t&255,a.TYPED_ARRAY_SUPPORT&&typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):br(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function br(e,t,r,n,i){var o=1,s=e.length,u=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;o=2,s/=2,u/=2,r/=2}function f(T,D){return o===1?T[D]:T.readUInt16BE(D*o)}var m;if(i){var w=-1;for(m=r;m<s;m++)if(f(e,m)===f(t,w===-1?0:m-w)){if(w===-1&&(w=m),m-w+1===u)return w*o}else w!==-1&&(m-=m-w),w=-1}else for(r+u>s&&(r=s-u),m=r;m>=0;m--){for(var p=!0,y=0;y<u;y++)if(f(e,m+y)!==f(t,y)){p=!1;break}if(p)return m}return-1}function Ut(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n),n>i&&(n=i)):n=i;var o=t.length;if(o%2!==0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var s=0;s<n;++s){var u=parseInt(t.substr(s*2,2),16);if(isNaN(u))return s;e[r+s]=u}return s}function Lt(e,t,r,n){return sr(nr(t,e.length-r),e,r,n)}function Lr(e,t,r,n){return sr(Ht(t),e,r,n)}function Ft(e,t,r,n){return Lr(e,t,r,n)}function Pt(e,t,r,n){return sr(Mr(t),e,r,n)}function Ct(e,t,r,n){return sr(Gt(t,e.length-r),e,r,n)}function Yt(e,t,r){return t===0&&r===e.length?Nr(e):Nr(e.slice(t,r))}function Fr(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var o=e[i],s=null,u=o>239?4:o>223?3:o>191?2:1;if(i+u<=r){var f,m,w,p;switch(u){case 1:o<128&&(s=o);break;case 2:f=e[i+1],(f&192)===128&&(p=(o&31)<<6|f&63,p>127&&(s=p));break;case 3:f=e[i+1],m=e[i+2],(f&192)===128&&(m&192)===128&&(p=(o&15)<<12|(f&63)<<6|m&63,p>2047&&(p<55296||p>57343)&&(s=p));break;case 4:f=e[i+1],m=e[i+2],w=e[i+3],(f&192)===128&&(m&192)===128&&(w&192)===128&&(p=(o&15)<<18|(f&63)<<12|(m&63)<<6|w&63,p>65535&&p<1114112&&(s=p))}}s===null?(s=65533,u=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=u}return Mt(n)}function Mt(e){var t=e.length;if(t<=kr)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=kr));return r}function Dt(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]&127);return n}function $t(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function Ot(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var i="",o=t;o<r;++o)i+=zt(e[o]);return i}function Wt(e,t,r){for(var n=e.slice(t,r),i="",o=0;o<n.length;o+=2)i+=String.fromCharCode(n[o]+n[o+1]*256);return i}function g(e,t,r){if(e%1!==0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function A(e,t,r,n,i,o){if(!I(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<o)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function ir(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i<o;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>(n?i:1-i)*8}function or(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i<o;++i)e[r+i]=t>>>(n?i:3-i)*8&255}function Pr(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function Cr(e,t,r,n,i){return i||Pr(e,t,r,4,34028234663852886e22,-34028234663852886e22),$r(e,t,r,n,23,4),r+4}function Yr(e,t,r,n,i){return i||Pr(e,t,r,8,17976931348623157e292,-17976931348623157e292),$r(e,t,r,n,52,8),r+8}function Vt(e){if(e=Jt(e).replace(jt,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function Jt(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function zt(e){return e<16?"0"+e.toString(16):e.toString(16)}function nr(e,t){t=t||1/0;for(var r,n=e.length,i=null,o=[],s=0;s<n;++s){if(r=e.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return o}function Ht(e){for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r)&255);return t}function Gt(e,t){for(var r,n,i,o=[],s=0;s<e.length&&!((t-=2)<0);++s)r=e.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}function Mr(e){return It(Vt(e))}function sr(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Qt(e){return e!==e}function Xt(e){return e!=null&&(!!e._isBuffer||Dr(e)||Zt(e))}function Dr(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function Zt(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&Dr(e.slice(0,0))}function ar(e,t,r,n,i){var o,s,u=i*8-n-1,f=(1<<u)-1,m=f>>1,w=-7,p=r?i-1:0,y=r?-1:1,T=e[t+p];for(p+=y,o=T&(1<<-w)-1,T>>=-w,w+=u;w>0;o=o*256+e[t+p],p+=y,w-=8);for(s=o&(1<<-w)-1,o>>=-w,w+=n;w>0;s=s*256+e[t+p],p+=y,w-=8);if(o===0)o=1-m;else{if(o===f)return s?NaN:(T?-1:1)*(1/0);s=s+Math.pow(2,n),o=o-m}return(T?-1:1)*s*Math.pow(2,o-n)}function $r(e,t,r,n,i,o){var s,u,f,m=o*8-i-1,w=(1<<m)-1,p=w>>1,y=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,T=n?0:o-1,D=n?1:-1,Wr=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,s=w):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),s+p>=1?t+=y/f:t+=y*Math.pow(2,1-p),t*f>=2&&(s++,f/=2),s+p>=w?(u=0,s=w):s+p>=1?(u=(t*f-1)*Math.pow(2,i),s=s+p):(u=t*Math.pow(2,p-1)*Math.pow(2,i),s=0));i>=8;e[r+T]=u&255,T+=D,u/=256,i-=8);for(s=s<<i|u,m+=i;m>0;e[r+T]=s&255,T+=D,s/=256,m-=8);e[r+T-D]|=Wr*128}var v,E,vt,pr,kr,jt,Or=hr(()=>{"use strict";l();h();v=[],E=[],vt=typeof Uint8Array!="undefined"?Uint8Array:Array,pr=!1;a.TYPED_ARRAY_SUPPORT=globalThis.TYPED_ARRAY_SUPPORT!==void 0?globalThis.TYPED_ARRAY_SUPPORT:!0;a.poolSize=8192;a._augment=function(e){return e.__proto__=a.prototype,e};a.from=function(e,t,r){return Sr(null,e,t,r)};a.kMaxLength=er();a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,typeof Symbol!="undefined"&&Symbol.species&&a[Symbol.species]);a.alloc=function(e,t,r){return kt(null,e,t,r)};a.allocUnsafe=function(e){return mr(null,e)};a.allocUnsafeSlow=function(e){return mr(null,e)};a.isBuffer=Xt;a.compare=function(t,r){if(!I(t)||!I(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var n=t.length,i=r.length,o=0,s=Math.min(n,i);o<s;++o)if(t[o]!==r[o]){n=t[o],i=r[o];break}return n<i?-1:i<n?1:0};a.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}};a.concat=function(t,r){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(t.length===0)return a.alloc(0);var n;if(r===void 0)for(r=0,n=0;n<t.length;++n)r+=t[n].length;var i=a.allocUnsafe(r),o=0;for(n=0;n<t.length;++n){var s=t[n];if(!I(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(i,o),o+=s.length}return i};a.byteLength=Br;a.prototype._isBuffer=!0;a.prototype.swap16=function(){var t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)F(this,r,r+1);return this};a.prototype.swap32=function(){var t=this.length;if(t%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)F(this,r,r+3),F(this,r+1,r+2);return this};a.prototype.swap64=function(){var t=this.length;if(t%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)F(this,r,r+7),F(this,r+1,r+6),F(this,r+2,r+5),F(this,r+3,r+4);return this};a.prototype.toString=function(){var t=this.length|0;return t===0?"":arguments.length===0?Fr(this,0,t):Bt.apply(this,arguments)};a.prototype.equals=function(t){if(!I(t))throw new TypeError("Argument must be a Buffer");return this===t?!0:a.compare(this,t)===0};a.prototype.compare=function(t,r,n,i,o){if(!I(t))throw new TypeError("Argument must be a Buffer");if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),o===void 0&&(o=this.length),r<0||n>t.length||i<0||o>this.length)throw new RangeError("out of range index");if(i>=o&&r>=n)return 0;if(i>=o)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,o>>>=0,this===t)return 0;for(var s=o-i,u=n-r,f=Math.min(s,u),m=this.slice(i,o),w=t.slice(r,n),p=0;p<f;++p)if(m[p]!==w[p]){s=m[p],u=w[p];break}return s<u?-1:u<s?1:0};a.prototype.includes=function(t,r,n){return this.indexOf(t,r,n)!==-1};a.prototype.indexOf=function(t,r,n){return Ur(this,t,r,n,!0)};a.prototype.lastIndexOf=function(t,r,n){return Ur(this,t,r,n,!1)};a.prototype.write=function(t,r,n,i){if(r===void 0)i="utf8",n=this.length,r=0;else if(n===void 0&&typeof r=="string")i=r,n=this.length,r=0;else if(isFinite(r))r=r|0,isFinite(n)?(n=n|0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var o=this.length-r;if((n===void 0||n>o)&&(n=o),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");for(var s=!1;;)switch(i){case"hex":return Ut(this,t,r,n);case"utf8":case"utf-8":return Lt(this,t,r,n);case"ascii":return Lr(this,t,r,n);case"latin1":case"binary":return Ft(this,t,r,n);case"base64":return Pt(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ct(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};kr=4096;a.prototype.slice=function(t,r){var n=this.length;t=~~t,r=r===void 0?n:~~r,t<0?(t+=n,t<0&&(t=0)):t>n&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),r<t&&(r=t);var i;if(a.TYPED_ARRAY_SUPPORT)i=this.subarray(t,r),i.__proto__=a.prototype;else{var o=r-t;i=new a(o,void 0);for(var s=0;s<o;++s)i[s]=this[s+t]}return i};a.prototype.readUIntLE=function(t,r,n){t=t|0,r=r|0,n||g(t,r,this.length);for(var i=this[t],o=1,s=0;++s<r&&(o*=256);)i+=this[t+s]*o;return i};a.prototype.readUIntBE=function(t,r,n){t=t|0,r=r|0,n||g(t,r,this.length);for(var i=this[t+--r],o=1;r>0&&(o*=256);)i+=this[t+--r]*o;return i};a.prototype.readUInt8=function(t,r){return r||g(t,1,this.length),this[t]};a.prototype.readUInt16LE=function(t,r){return r||g(t,2,this.length),this[t]|this[t+1]<<8};a.prototype.readUInt16BE=function(t,r){return r||g(t,2,this.length),this[t]<<8|this[t+1]};a.prototype.readUInt32LE=function(t,r){return r||g(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};a.prototype.readUInt32BE=function(t,r){return r||g(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};a.prototype.readIntLE=function(t,r,n){t=t|0,r=r|0,n||g(t,r,this.length);for(var i=this[t],o=1,s=0;++s<r&&(o*=256);)i+=this[t+s]*o;return o*=128,i>=o&&(i-=Math.pow(2,8*r)),i};a.prototype.readIntBE=function(t,r,n){t=t|0,r=r|0,n||g(t,r,this.length);for(var i=r,o=1,s=this[t+--i];i>0&&(o*=256);)s+=this[t+--i]*o;return o*=128,s>=o&&(s-=Math.pow(2,8*r)),s};a.prototype.readInt8=function(t,r){return r||g(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};a.prototype.readInt16LE=function(t,r){r||g(t,2,this.length);var n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};a.prototype.readInt16BE=function(t,r){r||g(t,2,this.length);var n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};a.prototype.readInt32LE=function(t,r){return r||g(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};a.prototype.readInt32BE=function(t,r){return r||g(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};a.prototype.readFloatLE=function(t,r){return r||g(t,4,this.length),ar(this,t,!0,23,4)};a.prototype.readFloatBE=function(t,r){return r||g(t,4,this.length),ar(this,t,!1,23,4)};a.prototype.readDoubleLE=function(t,r){return r||g(t,8,this.length),ar(this,t,!0,52,8)};a.prototype.readDoubleBE=function(t,r){return r||g(t,8,this.length),ar(this,t,!1,52,8)};a.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var o=Math.pow(2,8*n)-1;A(this,t,r,n,o,0)}var s=1,u=0;for(this[r]=t&255;++u<n&&(s*=256);)this[r+u]=t/s&255;return r+n};a.prototype.writeUIntBE=function(t,r,n,i){if(t=+t,r=r|0,n=n|0,!i){var o=Math.pow(2,8*n)-1;A(this,t,r,n,o,0)}var s=n-1,u=1;for(this[r+s]=t&255;--s>=0&&(u*=256);)this[r+s]=t/u&255;return r+n};a.prototype.writeUInt8=function(t,r,n){return t=+t,r=r|0,n||A(this,t,r,1,255,0),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=t&255,r+1};a.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r|0,n||A(this,t,r,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):ir(this,t,r,!0),r+2};a.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r|0,n||A(this,t,r,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):ir(this,t,r,!1),r+2};a.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r|0,n||A(this,t,r,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255):or(this,t,r,!0),r+4};a.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r|0,n||A(this,t,r,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):or(this,t,r,!1),r+4};a.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r|0,!i){var o=Math.pow(2,8*n-1);A(this,t,r,n,o-1,-o)}var s=0,u=1,f=0;for(this[r]=t&255;++s<n&&(u*=256);)t<0&&f===0&&this[r+s-1]!==0&&(f=1),this[r+s]=(t/u>>0)-f&255;return r+n};a.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r|0,!i){var o=Math.pow(2,8*n-1);A(this,t,r,n,o-1,-o)}var s=n-1,u=1,f=0;for(this[r+s]=t&255;--s>=0&&(u*=256);)t<0&&f===0&&this[r+s+1]!==0&&(f=1),this[r+s]=(t/u>>0)-f&255;return r+n};a.prototype.writeInt8=function(t,r,n){return t=+t,r=r|0,n||A(this,t,r,1,127,-128),a.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=t&255,r+1};a.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r|0,n||A(this,t,r,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8):ir(this,t,r,!0),r+2};a.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r|0,n||A(this,t,r,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=t&255):ir(this,t,r,!1),r+2};a.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r|0,n||A(this,t,r,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):or(this,t,r,!0),r+4};a.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r|0,n||A(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),a.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255):or(this,t,r,!1),r+4};a.prototype.writeFloatLE=function(t,r,n){return Cr(this,t,r,!0,n)};a.prototype.writeFloatBE=function(t,r,n){return Cr(this,t,r,!1,n)};a.prototype.writeDoubleLE=function(t,r,n){return Yr(this,t,r,!0,n)};a.prototype.writeDoubleBE=function(t,r,n){return Yr(this,t,r,!1,n)};a.prototype.copy=function(t,r,n,i){if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i<n&&(i=n),i===n||t.length===0||this.length===0)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r<i-n&&(i=t.length-r+n);var o=i-n,s;if(this===t&&n<r&&r<i)for(s=o-1;s>=0;--s)t[s+r]=this[s+n];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(s=0;s<o;++s)t[s+r]=this[s+n];else Uint8Array.prototype.set.call(t,this.subarray(n,n+o),r);return o};a.prototype.fill=function(t,r,n,i){if(typeof t=="string"){if(typeof r=="string"?(i=r,r=0,n=this.length):typeof n=="string"&&(i=n,n=this.length),t.length===1){var o=t.charCodeAt(0);o<256&&(t=o)}if(i!==void 0&&typeof i!="string")throw new TypeError("encoding must be a string");if(typeof i=="string"&&!a.isEncoding(i))throw new TypeError("Unknown encoding: "+i)}else typeof t=="number"&&(t=t&255);if(r<0||this.length<r||this.length<n)throw new RangeError("Out of range index");if(n<=r)return this;r=r>>>0,n=n===void 0?this.length:n>>>0,t||(t=0);var s;if(typeof t=="number")for(s=r;s<n;++s)this[s]=t;else{var u=I(t)?t:nr(new a(t,i).toString()),f=u.length;for(s=0;s<n-r;++s)this[s+r]=u[s%f]}return this};jt=/[^+\/0-9A-Za-z-_]/g});var h=hr(()=>{"use strict";Or()});l();h();function X(e){throw new Error("Unexpected value: "+JSON.stringify(e))}l();h();l();h();function qt(e){return Object.keys(e)}var dr={};Qr(dr,{AstNode:()=>x,ClassInstantiation:()=>G,CodeBlock:()=>W,Comment:()=>B,Function:()=>J,FunctionInvocation:()=>z,MethodInvocation:()=>H,Parameter:()=>V,Reference:()=>M,Type:()=>Y,TypeLiteral:()=>k,Types:()=>Y,Variable:()=>j,Writer:()=>C,codeblock:()=>ie,function_:()=>oe,instantiateClass:()=>se,invokeFunction:()=>ae,invokeMethod:()=>ue,parameter:()=>fe,reference:()=>le,variable:()=>he});l();h();l();h();l();h();l();h();l();h();l();h();var P=class{};l();h();l();h();var _=class extends P{constructor(r){super();c(this,"value");this.value=r}write(r){typeof this.value=="string"?r.write(this.value):this.value(r)}};var Kt=4,Z=class{constructor(){c(this,"buffer","");c(this,"indentLevel",0);c(this,"hasWrittenAnything",!1);c(this,"lastCharacterIsNewline",!1)}write(t){let r=t.length>0&&t.endsWith(`
|
|
2
|
+
`),n=r?t.substring(0,t.length-1):t,i=this.getIndentString(),o=n.replaceAll(`
|
|
3
|
+
`,`
|
|
4
|
+
${i}`);this.isAtStartOfLine()&&(o=i+o),r&&(o+=`
|
|
5
|
+
`),this.writeInternal(o)}writeNoIndent(t){let r=this.indentLevel;this.indentLevel=0,this.write(t),this.indentLevel=r}writeNode(t){t.write(this)}writeNodeStatement(t){t.write(this),this.write(";"),this.writeNewLineIfLastLineNot()}writeTextStatement(t){new _(t).write(this),this.write(";"),this.writeNewLineIfLastLineNot()}controlFlow(t,r){new _(t).write(this),this.write(" ("),this.writeNode(r),this.write(") {"),this.writeNewLineIfLastLineNot(),this.indent()}endControlFlow(){this.dedent(),this.writeLine("}")}openBlock(t,r="{",n,i="}"){let o=t.filter(s=>s!==void 0).join(" ");o?this.write(`${o} ${r!=null?r:""}`):this.write(r!=null?r:"");try{this.indent(),n(),this.dedent()}finally{this.write(i!=null?i:"")}}writeLine(t=""){this.write(t),this.writeNewLineIfLastLineNot()}newLine(){this.writeInternal(`
|
|
6
|
+
`)}writeNewLineIfLastLineNot(){this.lastCharacterIsNewline||this.writeInternal(`
|
|
7
|
+
`)}indent(){this.indentLevel++}dedent(){this.indentLevel--}delimit({nodes:t,delimiter:r,writeFunction:n}){if(t.length>0){let i=t[0];i!=null&&n(i);for(let o=1;o<t.length;o++){this.write(r);let s=t[o];s!=null&&n(s)}}}toString(){return this.buffer}writeInternal(t){return t.length>0&&(this.hasWrittenAnything=!0,this.lastCharacterIsNewline=t.endsWith(`
|
|
8
|
+
`)),this.buffer+=t}isAtStartOfLine(){return this.lastCharacterIsNewline||!this.hasWrittenAnything}getIndentString(){return" ".repeat(this.indentLevel*Kt)}};l();h();var ur=class{},q=class extends ur{async format(t){return t}formatSync(t){return t}};l();h();l();h();var C=class extends Z{constructor({customConfig:r,formatter:n}){super();c(this,"customConfig");c(this,"formatter");c(this,"imports",{});c(this,"defaultImports",{});c(this,"starImportAliases",{});c(this,"starImportAliasesInverse",{});this.customConfig=r,this.formatter=n!=null?n:new q}addImport(r){var n,i,o;if(r.importFrom!=null){switch(r.importFrom.type){case"default":{this.validateDefault(r);break}case"named":{this.validateNamed(r);break}case"star":{this.validateStar(r);break}}let s=(o=(n=this.imports)[i=r.importFrom.moduleName])!=null?o:n[i]=[];s.map(f=>f.name).includes(r.name)||s.push(r)}}validateDefault(r){var i,o,s,u;if(((i=r.importFrom)==null?void 0:i.type)!=="default")return;let n=(u=(o=this.defaultImports)[s=r.importFrom.moduleName])!=null?u:o[s]=r;if(n.name!==r.name)throw new Error(`Cannot have multiple default imports for module ${r.importFrom.moduleName}: got ${r.name} but already had ${n.name}`)}validateNamed(r){var s,u,f,m,w;if(((s=r.importFrom)==null?void 0:s.type)!=="named")return;let i=((u=this.imports[r.importFrom.moduleName])!=null?u:[]).filter(p=>{var y;return((y=p.importFrom)==null?void 0:y.type)==="star"});if(i.length>0)throw new Error(`Cannot add named import ${r.name} because non-named imports ${i.map(p=>p.name)} already exist`);let o=[];for(let p of Object.values(this.imports))for(let y of p)((f=y.importFrom)==null?void 0:f.type)==="named"&&y.importFrom.moduleName!==r.importFrom.moduleName&&y.name===r.name&&o.push(y);if(o.length>0)throw new Error(`Cannot add named import from module ${r.importFrom.moduleName} because it is already imported from ${(w=(m=o[0])==null?void 0:m.importFrom)==null?void 0:w.moduleName}`)}validateStar(r){var o,s,u,f,m,w,p;if(((o=r.importFrom)==null?void 0:o.type)!=="star")return;let n=(f=(s=this.starImportAliases)[u=r.importFrom.moduleName])!=null?f:s[u]=r.importFrom.starImportAlias;if(n!==r.importFrom.starImportAlias)throw new Error(`Cannot have more than one alias for non-named imports from a module: got ${r.importFrom.starImportAlias} but already have ${n}.`);if(((p=(m=this.starImportAliasesInverse)[w=r.importFrom.starImportAlias])!=null?p:m[w]=r.importFrom.moduleName)!==r.importFrom.moduleName)throw new Error(`Attempted to use alias ${r.importFrom.starImportAlias} for more than one module in the same file`)}};var K=class extends C{constructor({customConfig:t,formatter:r}){super({customConfig:t,formatter:r})}async toStringAsync(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.format(t)}catch(r){throw new Error(`Failed to format TypeScript file: ${r}
|
|
9
|
+
${t}`)}return t}toString(){let t=this.getContent();if(this.formatter!=null)try{return this.formatter.formatSync(t)}catch(r){throw new Error(`Failed to format TypeScript file: ${r}
|
|
10
|
+
${t}`)}return t}getContent(){let t=this.stringifyImports();return t.length>0?t+`
|
|
11
|
+
`+this.buffer:this.buffer}stringifyImports(){let t="";for(let[r,n]of Object.entries(this.imports)){let i=this.defaultImports[r],o="",s=n.filter(f=>{var m;return((m=f.importFrom)==null?void 0:m.type)==="named"}),u=this.starImportAliases[r];if(s.length>0||i!=null||u!=null){if(t+="import",i!=null&&(t+=` ${i.name}`),s.length>0){for(let m of s.slice(0,-1))o+=`${m.name}, `;let f=s[s.length-1];f!=null&&(o+=`${f.name}`),i!=null&&(t+=","),t+=` { ${o} }`}u!=null&&((i!=null||s.length>0)&&(t+=", "),t+=` * as ${u}`),t+=` from "${r}";
|
|
12
|
+
`}}return t}};var x=class extends P{async toStringAsync({customConfig:t,formatter:r}){let n=new K({customConfig:t,formatter:r});return this.write(n),await n.toStringAsync()}toString({customConfig:t,formatter:r}){let n=new K({customConfig:t,formatter:r});return this.write(n),n.toString()}};l();h();var W=class extends x{constructor(r){super();c(this,"args");this.args=r}write(r){return new _(this.args).write(r)}};l();h();var Y=class extends x{constructor(r){super();c(this,"internalType");this.internalType=r}write(r){switch(this.internalType.type){case"string":r.write("string");break;case"number":r.write("number");break;case"bigint":r.write("bigint");break;case"boolean":r.write("boolean");break;case"array":this.internalType.valueType.write(r),r.write("[]");break;case"map":r.write("Record<"),this.internalType.keyType.write(r),r.write(", "),this.internalType.valueType.write(r),r.write(">");break;case"object":r.write("{"),r.indent();for(let[n,i]of Object.entries(this.internalType.fields))r.write(`${n}: `),i.write(r),r.writeLine(",");r.dedent(),r.write("}");break;case"enum":r.write("enum");break;case"any":r.write("any");break;case"promise":r.write("Promise<"),this.internalType.value.write(r),r.write(">");break;case"unknown":r.write("unknown");break;case"void":r.write("void");break;case"undefined":r.write("undefined");break;case"null":r.write("null");break;case"never":r.write("never");break;case"nop":break;default:X(this.internalType)}}static string(){return new this({type:"string"})}static number(){return new this({type:"number"})}static bigint(){return new this({type:"bigint"})}static boolean(){return new this({type:"boolean"})}static array(r){return new this({type:"array",valueType:r})}static object(r){return new this({type:"object",fields:r})}static enum(r){return new this({type:"enum",values:r})}static any(){return new this({type:"any"})}static promise(r){return r.internalType.type==="promise"?r:new this({type:"promise",value:r})}static unknown(){return new this({type:"unknown"})}static void(){return new this({type:"void"})}static undefined(){return new this({type:"undefined"})}static null(){return new this({type:"null"})}static never(){return new this({type:"never"})}static nop(){return new this({type:"nop"})}};l();h();var k=class e extends x{constructor(r){super();c(this,"internalType");this.internalType=r}write(r){var o,s;let n=!!((o=r.customConfig)!=null&&o.noSerdeLayer),i=!!((s=r.customConfig)!=null&&s.useBigInt);switch(this.internalType.type){case"array":{this.writeIterable({writer:r,iterable:this.internalType});break}case"blob":{if(n){r.writeNode(e.string(this.internalType.value));return}r.write("new Blob(["),r.writeNode(e.string(this.internalType.value)),r.write("])");break}case"boolean":{r.write(this.internalType.value.toString());break}case"bigint":{if(i){r.write(`BigInt(${this.internalType.value.toString()})`);return}r.write(`"${this.internalType.value.toString()}"`);return}case"datetime":{if(n){r.writeNode(e.string(this.internalType.value));return}r.write("new Date("),r.writeNode(e.string(this.internalType.value)),r.write(")");break}case"number":{r.write(this.internalType.value.toString());break}case"object":{this.writeObject({writer:r,object:this.internalType});break}case"record":{this.writeRecord({writer:r,record:this.internalType});break}case"reference":{r.writeNode(this.internalType.value);break}case"set":{if(n||this.isSetOfObjects()){r.writeNode(e.array({values:this.internalType.values}));return}r.write("new Set("),this.writeIterable({writer:r,iterable:this.internalType}),r.write(")");break}case"string":{this.internalType.value.includes(`
|
|
13
|
+
`)?this.writeStringWithBackticks({writer:r,value:this.internalType.value}):r.write(`"${this.internalType.value.replaceAll('"','\\"')}"`);break}case"tuple":{this.writeIterable({writer:r,iterable:this.internalType});break}case"unknown":{this.writeUnknown({writer:r,value:this.internalType.value});break}case"null":{r.write("null");break}case"nop":break;default:X(this.internalType)}}isObject(){return this.internalType.type==="object"}asObjectOrThrow(){if(this.isObject())return this.internalType;throw new Error("Internal error; ts.TypeLiteral is not an object")}isSet(){return this.internalType.type==="set"}asSetOrThrow(){if(this.isSet())return this.internalType;throw new Error("Internal error; ts.TypeLiteral is not a set")}isSetOfObjects(){return this.isSet()&&this.asSetOrThrow().values.every(r=>r.isObject())}writeStringWithBackticks({writer:r,value:n}){r.write("`");let i=n.split(`
|
|
14
|
+
`),o=i[0]+`
|
|
15
|
+
`,s=i.slice(1).join(`
|
|
16
|
+
`);r.write(o.replaceAll("`","\\`")),r.writeNoIndent(s.replaceAll("`","\\`")),r.write("`")}writeIterable({writer:r,iterable:n}){let i=ee({values:n.values});if(i.length===0){r.write("[]");return}r.writeLine("["),r.indent();for(let o of i)o.write(r),r.writeLine(",");r.dedent(),r.write("]")}writeRecord({writer:r,record:n}){let i=te({entries:n.entries});if(i.length===0){r.write("{}");return}r.writeLine("{"),r.indent();for(let o of i)o.key.write(r),r.write(": "),o.value.write(r),r.writeLine(",");r.dedent(),r.write("}")}writeObject({writer:r,object:n}){let i=re({fields:n.fields});if(i.length===0){r.write("{}");return}r.writeLine("{"),r.indent();for(let o of i)r.write(`${o.name}: `),o.value.write(r),r.writeLine(",");r.dedent(),r.write("}")}static array({values:r}){return new this({type:"array",values:r})}static bigint(r){return new this({type:"bigint",value:r})}static blob(r){return new this({type:"blob",value:r})}static boolean(r){return new this({type:"boolean",value:r})}static datetime(r){return new this({type:"datetime",value:r})}static number(r){return new this({type:"number",value:r})}static object({fields:r}){return new this({type:"object",fields:r})}static record({entries:r}){return new this({type:"record",entries:r})}static reference(r){return new this({type:"reference",value:r})}static set({values:r}){return new this({type:"set",values:r})}static string(r){return new this({type:"string",value:r})}static tuple({values:r}){return new this({type:"tuple",values:r})}static unknown(r){return new this({type:"unknown",value:r})}static null(){return new this({type:"null"})}static nop(){return new this({type:"nop"})}static isNop(r){return r.internalType.type==="nop"}writeUnknown({writer:r,value:n}){switch(typeof n){case"boolean":r.write(n.toString());return;case"string":r.write(n.includes('"')?`\`${n}\``:`"${n}"`);return;case"number":r.write(n.toString());return;case"object":if(n==null){r.write("null");return}if(Array.isArray(n)){this.writeUnknownArray({writer:r,value:n});return}this.writeUnknownObject({writer:r,value:n});return;default:throw new Error(`Internal error; unsupported unknown type: ${typeof n}`)}}writeUnknownArray({writer:r,value:n}){if(n.length===0){r.write("[]");return}r.writeLine("["),r.indent();for(let i of n)r.writeNode(e.unknown(i)),r.writeLine(",");r.dedent(),r.write("]")}writeUnknownObject({writer:r,value:n}){let i=Object.entries(n);if(i.length===0){r.write("{}");return}r.writeLine("{"),r.indent();for(let[o,s]of i)r.write(`${o}: `),r.writeNode(e.unknown(s)),r.writeLine(",");r.dedent(),r.write("}")}};function re({fields:e}){return e.filter(t=>!k.isNop(t.value))}function te({entries:e}){return e.filter(t=>!k.isNop(t.key)&&!k.isNop(t.value))}function ee({values:e}){return e.filter(t=>!k.isNop(t))}l();h();var M=class extends x{constructor({name:r,importFrom:n,memberName:i}){super();c(this,"name");c(this,"importFrom");c(this,"memberName");this.name=r,this.importFrom=n,this.memberName=i}write(r){var o;this.importFrom!=null&&r.addImport(this);let n=((o=this.importFrom)==null?void 0:o.type)==="star"?`${this.importFrom.starImportAlias}.`:"",i=this.memberName!=null?`.${this.memberName}`:"";r.write(`${n}${this.name}${i}`)}};l();h();var j=class extends x{constructor(r){super();c(this,"args");this.args=r}write(r){this.args.export&&r.write("export "),this.args.const?r.write("const "):r.write("let "),r.write(`${this.args.name} = `),r.writeNode(this.args.initializer)}};l();h();l();h();var B=class extends x{constructor({docs:r}={docs:void 0}){super();c(this,"docs");this.docs=r}write(r){this.docs!=null&&(r.writeLine("/**"),this.docs.split(`
|
|
17
|
+
`).forEach(n=>{r.writeLine(` * ${n}`)}),r.writeLine("*/"))}};var V=class extends x{constructor({name:r,type:n,docs:i}){super();c(this,"name");c(this,"type");c(this,"docs");this.name=r,this.type=n,this.docs=i}write(r){this.docs!=null&&r.writeNode(new B({docs:this.docs})),r.write(`${this.name}: `),this.type.write(r)}};l();h();var J=class extends x{constructor({name:r,parameters:n,async:i,body:o,return_:s,docs:u}){super();c(this,"name");c(this,"parameters");c(this,"async");c(this,"body");c(this,"return_");c(this,"docs");this.name=r,this.parameters=n,this.async=i!=null?i:!1,this.body=o,this.return_=s,this.docs=u}write(r){var n;r.writeNode(new B({docs:this.docs})),this.async&&r.write("async "),r.write("function "),r.write(`${this.name}`),this.writeParameters(r),this.return_!=null&&(r.write(": "),r.writeNode(this.async?Y.promise(this.return_):this.return_)),r.writeLine(" {"),r.indent(),(n=this.body)==null||n.write(r),r.dedent(),r.writeNewLineIfLastLineNot(),r.writeLine("}")}writeParameters(r){if(this.parameters.length===0){r.write("()");return}r.indent(),r.writeLine("(");for(let n of this.parameters)r.writeNode(n),r.writeLine(",");r.dedent(),r.write(")")}};l();h();var z=class extends x{constructor({function_:r,arguments_:n}){super();c(this,"function_");c(this,"arguments_");this.function_=r,this.arguments_=n}write(r){r.writeNode(this.function_),r.write("("),r.delimit({nodes:this.arguments_,delimiter:", ",writeFunction:n=>n.write(r)}),r.write(")")}};l();h();var H=class extends x{constructor({on:r,method:n,arguments_:i,async:o}){super();c(this,"on");c(this,"method");c(this,"arguments_");c(this,"async");this.on=r,this.method=n,this.arguments_=i,this.async=o}write(r){this.async&&r.write("await "),this.on.write(r),r.write("."),r.write(this.method),r.write("("),r.delimit({nodes:this.arguments_,delimiter:", ",writeFunction:n=>n.write(r)}),r.write(")")}};l();h();var G=class extends x{constructor({class_:r,arguments_:n}){super();c(this,"class_");c(this,"arguments_");this.class_=r,this.arguments_=n}write(r){r.write("new "),r.writeNode(this.class_),r.write("("),r.delimit({nodes:this.arguments_,delimiter:", ",writeFunction:n=>n.write(r)}),r.write(")")}};function ie(e){return new W(e)}function oe(e){return new J(e)}function se(e){return new G(e)}function ae(e){return new z(e)}function ue(e){return new H(e)}function fe(e){return new V(e)}function le(e){return new M(e)}function he(e){return new j(e)}l();h();export{ce as a,pe as b,me as c,we as d,hr as e,de as f,Qr as g,xe as h,ye as i,c as j,l as k,a as l,h as m,X as n,qt as o,dr as p};
|
|
18
|
+
/*! Bundled license information:
|
|
19
|
+
|
|
20
|
+
@esbuild-plugins/node-globals-polyfill/Buffer.js:
|
|
21
|
+
(*!
|
|
22
|
+
* The buffer module from node.js, for the browser.
|
|
23
|
+
*
|
|
24
|
+
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
25
|
+
* @license MIT
|
|
26
|
+
*)
|
|
27
|
+
*/
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
DynamicSnippetsGeneratorContext
|
|
3
|
-
} from "../chunk-MR7ZAFRL.js";
|
|
4
|
-
import "../chunk-6Y2IOBCK.js";
|
|
5
|
-
import "../chunk-37WY6L3Q.js";
|
|
6
|
-
import "../chunk-PLZLTFT4.js";
|
|
7
|
-
import "../chunk-WPDO6IRW.js";
|
|
8
|
-
export {
|
|
9
|
-
DynamicSnippetsGeneratorContext
|
|
10
|
-
};
|
|
1
|
+
import{a}from"../chunk-25TNFA5L.js";import"../chunk-SQLJANKO.js";import"../chunk-736FTN3M.js";import"../chunk-LX5O4JB7.js";import"../chunk-YD6EIACZ.js";export{a as DynamicSnippetsGeneratorContext};
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
DynamicTypeLiteralMapper
|
|
3
|
-
} from "../chunk-6Y2IOBCK.js";
|
|
4
|
-
import "../chunk-37WY6L3Q.js";
|
|
5
|
-
import "../chunk-WPDO6IRW.js";
|
|
6
|
-
export {
|
|
7
|
-
DynamicTypeLiteralMapper
|
|
8
|
-
};
|
|
1
|
+
import{a}from"../chunk-SQLJANKO.js";import"../chunk-736FTN3M.js";import"../chunk-YD6EIACZ.js";export{a as DynamicTypeLiteralMapper};
|