@fern-api/java-dynamic-snippets 3.22.0 → 3.23.0
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 +1 -1
- package/cjs/DynamicSnippetsGenerator.cjs.map +1 -1
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +1 -1
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +1 -1
- package/cjs/index.cjs +1 -1
- package/cjs/index.cjs.map +1 -1
- package/esm/DynamicSnippetsGenerator.js +1 -1
- package/esm/EndpointSnippetGenerator.js +1 -1
- package/esm/{chunk-3GRWXKJQ.js → chunk-C7RK7JUC.js} +2 -2
- package/esm/{chunk-AFF2W4ET.js → chunk-FDN2HGWE.js} +2 -2
- package/esm/{chunk-3RPV4P2N.js → chunk-FNREWPPJ.js} +2 -2
- package/esm/{chunk-BMMM5LLV.js → chunk-JBCRNEMV.js} +2 -2
- package/esm/{chunk-GX6CC3QQ.js → chunk-OHA6X7RF.js} +2 -2
- package/esm/{chunk-RJC322RM.js → chunk-PUKCM72D.js} +2 -2
- package/esm/chunk-PUKCM72D.js.map +1 -0
- package/esm/{chunk-3YTGXHIU.js → chunk-WBDN7N7M.js} +2 -2
- package/esm/{chunk-I6IKEGKL.js → chunk-YVHD2ESF.js} +2 -2
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -1
- package/esm/context/DynamicTypeLiteralMapper.js +1 -1
- package/esm/context/DynamicTypeMapper.js +1 -1
- package/esm/context/FilePropertyMapper.js +1 -1
- package/esm/index.js +1 -1
- package/package.json +1 -1
- package/esm/chunk-RJC322RM.js.map +0 -1
- /package/esm/{chunk-3GRWXKJQ.js.map → chunk-C7RK7JUC.js.map} +0 -0
- /package/esm/{chunk-AFF2W4ET.js.map → chunk-FDN2HGWE.js.map} +0 -0
- /package/esm/{chunk-3RPV4P2N.js.map → chunk-FNREWPPJ.js.map} +0 -0
- /package/esm/{chunk-BMMM5LLV.js.map → chunk-JBCRNEMV.js.map} +0 -0
- /package/esm/{chunk-GX6CC3QQ.js.map → chunk-OHA6X7RF.js.map} +0 -0
- /package/esm/{chunk-3YTGXHIU.js.map → chunk-WBDN7N7M.js.map} +0 -0
- /package/esm/{chunk-I6IKEGKL.js.map → chunk-YVHD2ESF.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-YVHD2ESF.js";import"./chunk-OHA6X7RF.js";import"./chunk-FDN2HGWE.js";import"./chunk-WBDN7N7M.js";import"./chunk-C7RK7JUC.js";import"./chunk-FNREWPPJ.js";import"./chunk-JBCRNEMV.js";import"./chunk-PUKCM72D.js";import"./chunk-2U3YQWRZ.js";export{a as DynamicSnippetsGenerator};
|
|
2
2
|
//# sourceMappingURL=DynamicSnippetsGenerator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-OHA6X7RF.js";import"./chunk-C7RK7JUC.js";import"./chunk-PUKCM72D.js";import"./chunk-2U3YQWRZ.js";export{a as EndpointSnippetGenerator};
|
|
2
2
|
//# sourceMappingURL=EndpointSnippetGenerator.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as m,b as R}from"./chunk-RJC322RM.js";import{a as P,b as S,c as A,d as b,f as u,h as p,i as l}from"./chunk-2U3YQWRZ.js";p();l();p();l();var y=class{constructor(){u(this,"reporter");u(this,"snippet");u(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){u(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 a=await d.generateSnippet({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:a,errors:void 0};n.update({context:s,snippet:a})}catch(a){n.err==null&&(n.err=a)}}return n.getResponseOrThrow({endpoint:e.endpoint})}async generateSnippetAst(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;for(let i of t){let s=this.context.clone(),d=this.createSnippetGenerator(s);try{return await d.generateSnippetAst({endpoint:i,request:e,options:r})}catch(a){n=a}}throw n!=null?n:new Error(`Failed to generate snippet AST for endpoint: ${e.endpoint.method} ${e.endpoint.path}`)}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 a=d.generateSnippetSync({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:a,errors:void 0};n.update({context:s,snippet:a})}catch(a){n.err==null&&(n.err=a)}}return n.getResponseOrThrow({endpoint:e.endpoint})}};p();l();var o={Critical:"CRITICAL",Warning:"WARNING"},g=class c{constructor(){u(this,"errors");u(this,"path");this.errors=[],this.path=[]}add(e){this.errors.push(S(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 c;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 v=class{constructor(){u(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={}}){u(this,"config");u(this,"options");u(this,"errors");u(this,"_ir");u(this,"httpEndpointReferenceParser");this._ir=e,this.config=r,this.options=t,this.errors=new g,this.httpEndpointReferenceParser=new v}associateQueryParametersByWireValue({parameters:e,values:r}){let t=[];for(let[n,i]of Object.entries(r)){this.errors.scope(n);try{let s=e.find(a=>a.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(a=>a.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 T=t,{[n]:d}=T,a=b(T,[A(n)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:a}}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:m(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:m(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:m(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:m(r)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:m(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 x;(function(c){c.Concise="concise",c.Full="full"})(x||(x={}));p();l();var $={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};p();l();export{E as a,o as b,w as c,x as d,$ as e};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as m,b as R}from"./chunk-PUKCM72D.js";import{a as P,b as S,c as A,d as b,f as u,h as p,i as l}from"./chunk-2U3YQWRZ.js";p();l();p();l();var y=class{constructor(){u(this,"reporter");u(this,"snippet");u(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){u(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 a=await d.generateSnippet({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:a,errors:void 0};n.update({context:s,snippet:a})}catch(a){n.err==null&&(n.err=a)}}return n.getResponseOrThrow({endpoint:e.endpoint})}async generateSnippetAst(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;for(let i of t){let s=this.context.clone(),d=this.createSnippetGenerator(s);try{return await d.generateSnippetAst({endpoint:i,request:e,options:r})}catch(a){n=a}}throw n!=null?n:new Error(`Failed to generate snippet AST for endpoint: ${e.endpoint.method} ${e.endpoint.path}`)}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 a=d.generateSnippetSync({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:a,errors:void 0};n.update({context:s,snippet:a})}catch(a){n.err==null&&(n.err=a)}}return n.getResponseOrThrow({endpoint:e.endpoint})}};p();l();var o={Critical:"CRITICAL",Warning:"WARNING"},g=class c{constructor(){u(this,"errors");u(this,"path");this.errors=[],this.path=[]}add(e){this.errors.push(S(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 c;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 v=class{constructor(){u(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={}}){u(this,"config");u(this,"options");u(this,"errors");u(this,"_ir");u(this,"httpEndpointReferenceParser");this._ir=e,this.config=r,this.options=t,this.errors=new g,this.httpEndpointReferenceParser=new v}associateQueryParametersByWireValue({parameters:e,values:r}){let t=[];for(let[n,i]of Object.entries(r)){this.errors.scope(n);try{let s=e.find(a=>a.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(a=>a.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 T=t,{[n]:d}=T,a=b(T,[A(n)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:a}}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:m(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:m(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:m(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:m(r)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:m(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 x;(function(c){c.Concise="concise",c.Full="full"})(x||(x={}));p();l();var $={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};p();l();export{E as a,o as b,w as c,x as d,$ as e};
|
|
2
|
+
//# sourceMappingURL=chunk-C7RK7JUC.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as A}from"./chunk-3YTGXHIU.js";import{c as S}from"./chunk-3GRWXKJQ.js";import{a as P}from"./chunk-3RPV4P2N.js";import{a as O}from"./chunk-BMMM5LLV.js";import{a as N,c as I,d as l}from"./chunk-RJC322RM.js";import{f as c,h as a,i as o}from"./chunk-2U3YQWRZ.js";a();o();a();o();a();o();a();o();a();o();a();o();a();o();var we=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,j=we;var Le=typeof self=="object"&&self&&self.Object===Object&&self,Me=j||Le||Function("return this")(),F=Me;var We=F.Symbol,m=We;a();o();var w=Object.prototype,Ee=w.hasOwnProperty,Ue=w.toString,y=m?m.toStringTag:void 0;function Be(r){var s=Ee.call(r,y),e=r[y];try{r[y]=void 0;var t=!0}catch(i){}var f=Ue.call(r);return t&&(s?r[y]=e:delete r[y]),f}var L=Be;a();o();var ze=Object.prototype,De=ze.toString;function Ve(r){return De.call(r)}var M=Ve;var qe="[object Null]",Ze="[object Undefined]",W=m?m.toStringTag:void 0;function Ge(r){return r==null?r===void 0?Ze:qe:W&&W in Object(r)?L(r):M(r)}var E=Ge;a();o();function Je(r){return r!=null&&typeof r=="object"}var U=Je;var He="[object Symbol]";function _e(r){return typeof r=="symbol"||U(r)&&E(r)==He}var B=_e;a();o();a();o();function Ke(r,s){for(var e=-1,t=r==null?0:r.length,f=Array(t);++e<t;)f[e]=s(r[e],e,r);return f}var z=Ke;a();o();var Ye=Array.isArray,D=Ye;var $e=1/0,V=m?m.prototype:void 0,q=V?V.toString:void 0;function Z(r){if(typeof r=="string")return r;if(D(r))return z(r,Z)+"";if(B(r))return q?q.call(r):"";var s=r+"";return s=="0"&&1/r==-$e?"-0":s}var G=Z;a();o();function Qe(r){return r==null?"":G(r)}var x=Qe;a();o();a();o();a();o();a();o();a();o();a();o();function Xe(r,s,e){var t=-1,f=r.length;s<0&&(s=-s>f?0:f+s),e=e>f?f:e,e<0&&(e+=f),f=s>e?0:e-s>>>0,s>>>=0;for(var i=Array(f);++t<f;)i[t]=r[t+s];return i}var J=Xe;function er(r,s,e){var t=r.length;return e=e===void 0?t:e,!s&&e>=t?r:J(r,s,e)}var H=er;a();o();var rr="\\ud800-\\udfff",tr="\\u0300-\\u036f",ar="\\ufe20-\\ufe2f",or="\\u20d0-\\u20ff",fr=tr+ar+or,sr="\\ufe0e\\ufe0f",ur="\\u200d",nr=RegExp("["+ur+rr+fr+sr+"]");function ir(r){return nr.test(r)}var C=ir;a();o();a();o();function lr(r){return r.split("")}var _=lr;a();o();var K="\\ud800-\\udfff",pr="\\u0300-\\u036f",mr="\\ufe20-\\ufe2f",dr="\\u20d0-\\u20ff",xr=pr+mr+dr,cr="\\ufe0e\\ufe0f",gr="["+K+"]",R="["+xr+"]",v="\\ud83c[\\udffb-\\udfff]",hr="(?:"+R+"|"+v+")",Y="[^"+K+"]",$="(?:\\ud83c[\\udde6-\\uddff]){2}",Q="[\\ud800-\\udbff][\\udc00-\\udfff]",br="\\u200d",X=hr+"?",ee="["+cr+"]?",yr="(?:"+br+"(?:"+[Y,$,Q].join("|")+")"+ee+X+")*",Cr=ee+X+yr,Nr="(?:"+[Y+R+"?",R,$,Q,gr].join("|")+")",Rr=RegExp(v+"(?="+v+")|"+Nr+Cr,"g");function vr(r){return r.match(Rr)||[]}var re=vr;function kr(r){return C(r)?re(r):_(r)}var te=kr;function Tr(r){return function(s){s=x(s);var e=C(s)?te(s):void 0,t=e?e[0]:s.charAt(0),f=e?H(e,1).join(""):s.slice(1);return t[r]()+f}}var ae=Tr;var Sr=ae("toUpperCase"),oe=Sr;function Ir(r){return oe(x(r).toLowerCase())}var fe=Ir;a();o();a();o();function Ar(r,s,e,t){var f=-1,i=r==null?0:r.length;for(t&&i&&(e=r[++f]);++f<i;)e=s(e,r[f],f,r);return e}var se=Ar;a();o();a();o();a();o();function Pr(r){return function(s){return r==null?void 0:r[s]}}var ue=Pr;var Or={\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"},jr=ue(Or),ne=jr;var Fr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,wr="\\u0300-\\u036f",Lr="\\ufe20-\\ufe2f",Mr="\\u20d0-\\u20ff",Wr=wr+Lr+Mr,Er="["+Wr+"]",Ur=RegExp(Er,"g");function Br(r){return r=x(r),r&&r.replace(Fr,ne).replace(Ur,"")}var ie=Br;a();o();a();o();var zr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Dr(r){return r.match(zr)||[]}var le=Dr;a();o();var Vr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function qr(r){return Vr.test(r)}var pe=qr;a();o();var ge="\\ud800-\\udfff",Zr="\\u0300-\\u036f",Gr="\\ufe20-\\ufe2f",Jr="\\u20d0-\\u20ff",Hr=Zr+Gr+Jr,he="\\u2700-\\u27bf",be="a-z\\xdf-\\xf6\\xf8-\\xff",_r="\\xac\\xb1\\xd7\\xf7",Kr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Yr="\\u2000-\\u206f",$r=" \\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",ye="A-Z\\xc0-\\xd6\\xd8-\\xde",Qr="\\ufe0e\\ufe0f",Ce=_r+Kr+Yr+$r,Ne="['\u2019]",me="["+Ce+"]",Xr="["+Hr+"]",Re="\\d+",et="["+he+"]",ve="["+be+"]",ke="[^"+ge+Ce+Re+he+be+ye+"]",rt="\\ud83c[\\udffb-\\udfff]",tt="(?:"+Xr+"|"+rt+")",at="[^"+ge+"]",Te="(?:\\ud83c[\\udde6-\\uddff]){2}",Se="[\\ud800-\\udbff][\\udc00-\\udfff]",g="["+ye+"]",ot="\\u200d",de="(?:"+ve+"|"+ke+")",ft="(?:"+g+"|"+ke+")",xe="(?:"+Ne+"(?:d|ll|m|re|s|t|ve))?",ce="(?:"+Ne+"(?:D|LL|M|RE|S|T|VE))?",Ie=tt+"?",Ae="["+Qr+"]?",st="(?:"+ot+"(?:"+[at,Te,Se].join("|")+")"+Ae+Ie+")*",ut="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",nt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",it=Ae+Ie+st,lt="(?:"+[et,Te,Se].join("|")+")"+it,pt=RegExp([g+"?"+ve+"+"+xe+"(?="+[me,g,"$"].join("|")+")",ft+"+"+ce+"(?="+[me,g+de,"$"].join("|")+")",g+"?"+de+"+"+xe,g+"+"+ce,nt,ut,Re,lt].join("|"),"g");function mt(r){return r.match(pt)||[]}var Pe=mt;function dt(r,s,e){return r=x(r),s=e?void 0:s,s===void 0?pe(r)?Pe(r):le(r):r.match(s)||[]}var Oe=dt;var xt="['\u2019]",ct=RegExp(xt,"g");function gt(r){return function(s){return se(Oe(ie(s).replace(ct,"")),r,"")}}var je=gt;var ht=je(function(r,s,e){return s=s.toLowerCase(),r+(e?fe(s):s)}),k=ht;var bt=new Set(["enum","extends","package","void","short","class","abstract","return","import","for","assert","switch","getClass"]),Fe=class r extends S{constructor({ir:e,config:t,options:f}){var i;super({ir:e,config:t,options:f});c(this,"ir");c(this,"customConfig");c(this,"dynamicTypeMapper");c(this,"dynamicTypeLiteralMapper");c(this,"filePropertyMapper");this.ir=e,this.customConfig=I.parse((i=t.customConfig)!=null?i:{}),this.dynamicTypeMapper=new P({context:this}),this.dynamicTypeLiteralMapper=new A({context:this}),this.filePropertyMapper=new O({context:this})}clone(){return new r({ir:this.ir,config:this.config,options:this.options})}getClassName(e){return this.getName(e.pascalCase.safeName)}getEnumName(e){return this.getName(e.screamingSnakeCase.safeName)}getPropertyName(e){return this.getName(e.camelCase.safeName)}getMethodName(e){return this.getName(e.camelCase.safeName)}getRootClientClassReference(){return l.classReference({name:this.getRootClientClassName(),packageName:this.getRootPackageName()})}getRootClientClassName(){var e,t;return(t=(e=this.customConfig)==null?void 0:e["client-class-name"])!=null?t:`${this.getBaseNamePrefix()}Client`}getEnvironmentClassName(){return"Environment"}getEnvironmentTypeReferenceFromID(e){let t=this.resolveEnvironmentName(e);if(t!=null)return l.codeblock(f=>{f.writeNode(this.getEnvironmentClassReference()),f.write("."),f.write(this.getEnumName(t))})}getEnvironmentClassReference(){return l.classReference({name:this.getEnvironmentClassName(),packageName:this.getCorePackageName()})}getJavaClassReferenceFromDeclaration({declaration:e}){return l.classReference({name:e.name.pascalCase.unsafeName,packageName:this.getTypesPackageName(e.fernFilepath)})}getNullableClassReference(){return l.classReference({name:"Nullable",packageName:this.getCorePackageName()})}getNullableOfNull(){return l.TypeLiteral.reference(l.invokeMethod({on:this.getNullableClassReference(),method:"ofNull",arguments_:[]}))}getOptionalNullableClassReference(){return l.classReference({name:"OptionalNullable",packageName:this.getCorePackageName()})}getOptionalNullableAbsent(){return l.TypeLiteral.reference(l.invokeMethod({on:this.getOptionalNullableClassReference(),method:"absent",arguments_:[]}))}getOptionalNullableOf(e){return l.TypeLiteral.reference(l.invokeMethod({on:this.getOptionalNullableClassReference(),method:"of",arguments_:[e]}))}getFileStreamFromString(e){return l.TypeLiteral.reference(l.codeblock(t=>{t.write("new "),t.writeNode(this.getFileStreamClassReference()),t.write("("),t.writeNode(this.getByteArrayInputStreamClassReference()),t.write("("),t.writeNode(l.TypeLiteral.string(e)),t.write(".getBytes("),t.writeNode(this.getStandardCharsetsClassReference()),t.write(".UTF_8)))")}))}getFileStreamClassReference(){return l.classReference({name:"FileStream",packageName:this.getCorePackageName()})}getByteArrayInputStreamClassReference(){return l.classReference({name:"ByteArrayInputStream",packageName:"java.io"})}getStandardCharsetsClassReference(){return l.classReference({name:"StandardCharsets",packageName:"java.nio.charset"})}isPrimitive(e){switch(e.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(e.value);case"named":{let t=this.resolveNamedType({typeId:e.value});if(t==null)return!1;switch(t.type){case"alias":return this.isPrimitive(t.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:N(t)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:N(e)}}isDirectLiteral(e){return e.type==="literal"}sortTypeInstancesByRequiredFirst(e,t){let f=new Map;t.forEach((p,d)=>{f.set(p.name.wireValue,d)});let i=[],h=[];for(let p of e)this.isOptional(p.typeReference)?h.push(p):i.push(p);return i.sort((p,d)=>{var b,T;return((b=f.get(p.name.wireValue))!=null?b:0)-((T=f.get(d.name.wireValue))!=null?T:0)}),[...i,...h]}associateByWireValue({parameters:e,values:t,ignoreMissingParameters:f}){let i=super.associateByWireValue({parameters:e,values:t,ignoreMissingParameters:f}),h=new Map;for(let d of i)h.set(d.name.wireValue,d);let p=[];for(let d of e){let b=h.get(d.name.wireValue);b!=null&&p.push(b)}return p}getRootPackageName(){let e=this.getPackagePrefixTokens();return this.joinPackageTokens(e)}getCorePackageName(){let e=this.getPackagePrefixTokens();return e.push("core"),this.joinPackageTokens(e)}getTypesPackageName(e){return this.getResourcesPackage(e,"types")}getRequestsPackageName(e){return this.getPackageLayout()==="flat"?this.getTypesPackageName(e):this.getResourcesPackage(e,"requests")}getResourcesPackage(e,t){let f=this.getPackagePrefixTokens();switch(this.getPackageLayout()){case"flat":e!=null&&f.push(...e.packagePath.map(i=>this.getPackageNameSegment(i)));break;case"nested":default:e!=null&&e.allParts.length>0&&f.push("resources"),e!=null&&f.push(...e.allParts.map(i=>this.getPackageNameSegment(i)))}return t!=null&&f.push(t),this.joinPackageTokens(f)}getPackageName(e,t){let f=this.getPackageNameSegments(e);return f=t!=null?[...f,t]:f,[...this.getPackagePrefixTokens(),...f].join(".")}getPackageLayout(){var e,t;return(t=(e=this.customConfig)==null?void 0:e["package-layout"])!=null?t:"nested"}shouldInlinePathParameters(){var e,t;return(t=(e=this.customConfig)==null?void 0:e["inline-path-parameters"])!=null?t:!1}shouldInlineFileProperties(){var e,t;return(t=(e=this.customConfig)==null?void 0:e["inline-file-properties"])!=null?t:!1}getPackageNameSegments(e){return e.packagePath.map(t=>this.getPackageNameSegment(t))}getPackageNameSegment(e){return e.camelCase.safeName.toLowerCase()}getPackagePrefixTokens(){var t;if(((t=this.customConfig)==null?void 0:t["package-prefix"])!=null)return this.customConfig["package-prefix"].split(".");let e=[];return e.push("com"),e.push(...this.splitOnNonAlphaNumericChar(this.config.organization)),e.push(...this.splitOnNonAlphaNumericChar(this.getApiName())),e}getBaseNamePrefix(){return this.convertKebabCaseToUpperCamelCase(this.config.organization)+this.convertKebabCaseToUpperCamelCase(this.getApiName())}getApiName(){return k(this.config.workspaceName)}startsWithNumber(e){return/^\d/.test(e)}splitOnNonAlphaNumericChar(e){return e.split(/[^a-zA-Z0-9]/)}convertKebabCaseToUpperCamelCase(e){return e.replace(/-([a-z])/g,(t,f)=>f.toUpperCase()).replace(/^[a-z]/,t=>t.toUpperCase())}joinPackageTokens(e){return e.map(f=>this.startsWithNumber(f)?"_"+f:f).join(".")}getName(e){return this.isReservedName(e)?"_"+e:e}isReservedName(e){return bt.has(e)}};export{Fe as a};
|
|
1
|
+
import{a as A}from"./chunk-WBDN7N7M.js";import{c as S}from"./chunk-C7RK7JUC.js";import{a as P}from"./chunk-FNREWPPJ.js";import{a as O}from"./chunk-JBCRNEMV.js";import{a as N,c as I,d as l}from"./chunk-PUKCM72D.js";import{f as c,h as a,i as o}from"./chunk-2U3YQWRZ.js";a();o();a();o();a();o();a();o();a();o();a();o();a();o();var we=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,j=we;var Le=typeof self=="object"&&self&&self.Object===Object&&self,Me=j||Le||Function("return this")(),F=Me;var We=F.Symbol,m=We;a();o();var w=Object.prototype,Ee=w.hasOwnProperty,Ue=w.toString,y=m?m.toStringTag:void 0;function Be(r){var s=Ee.call(r,y),e=r[y];try{r[y]=void 0;var t=!0}catch(i){}var f=Ue.call(r);return t&&(s?r[y]=e:delete r[y]),f}var L=Be;a();o();var ze=Object.prototype,De=ze.toString;function Ve(r){return De.call(r)}var M=Ve;var qe="[object Null]",Ze="[object Undefined]",W=m?m.toStringTag:void 0;function Ge(r){return r==null?r===void 0?Ze:qe:W&&W in Object(r)?L(r):M(r)}var E=Ge;a();o();function Je(r){return r!=null&&typeof r=="object"}var U=Je;var He="[object Symbol]";function _e(r){return typeof r=="symbol"||U(r)&&E(r)==He}var B=_e;a();o();a();o();function Ke(r,s){for(var e=-1,t=r==null?0:r.length,f=Array(t);++e<t;)f[e]=s(r[e],e,r);return f}var z=Ke;a();o();var Ye=Array.isArray,D=Ye;var $e=1/0,V=m?m.prototype:void 0,q=V?V.toString:void 0;function Z(r){if(typeof r=="string")return r;if(D(r))return z(r,Z)+"";if(B(r))return q?q.call(r):"";var s=r+"";return s=="0"&&1/r==-$e?"-0":s}var G=Z;a();o();function Qe(r){return r==null?"":G(r)}var x=Qe;a();o();a();o();a();o();a();o();a();o();a();o();function Xe(r,s,e){var t=-1,f=r.length;s<0&&(s=-s>f?0:f+s),e=e>f?f:e,e<0&&(e+=f),f=s>e?0:e-s>>>0,s>>>=0;for(var i=Array(f);++t<f;)i[t]=r[t+s];return i}var J=Xe;function er(r,s,e){var t=r.length;return e=e===void 0?t:e,!s&&e>=t?r:J(r,s,e)}var H=er;a();o();var rr="\\ud800-\\udfff",tr="\\u0300-\\u036f",ar="\\ufe20-\\ufe2f",or="\\u20d0-\\u20ff",fr=tr+ar+or,sr="\\ufe0e\\ufe0f",ur="\\u200d",nr=RegExp("["+ur+rr+fr+sr+"]");function ir(r){return nr.test(r)}var C=ir;a();o();a();o();function lr(r){return r.split("")}var _=lr;a();o();var K="\\ud800-\\udfff",pr="\\u0300-\\u036f",mr="\\ufe20-\\ufe2f",dr="\\u20d0-\\u20ff",xr=pr+mr+dr,cr="\\ufe0e\\ufe0f",gr="["+K+"]",R="["+xr+"]",v="\\ud83c[\\udffb-\\udfff]",hr="(?:"+R+"|"+v+")",Y="[^"+K+"]",$="(?:\\ud83c[\\udde6-\\uddff]){2}",Q="[\\ud800-\\udbff][\\udc00-\\udfff]",br="\\u200d",X=hr+"?",ee="["+cr+"]?",yr="(?:"+br+"(?:"+[Y,$,Q].join("|")+")"+ee+X+")*",Cr=ee+X+yr,Nr="(?:"+[Y+R+"?",R,$,Q,gr].join("|")+")",Rr=RegExp(v+"(?="+v+")|"+Nr+Cr,"g");function vr(r){return r.match(Rr)||[]}var re=vr;function kr(r){return C(r)?re(r):_(r)}var te=kr;function Tr(r){return function(s){s=x(s);var e=C(s)?te(s):void 0,t=e?e[0]:s.charAt(0),f=e?H(e,1).join(""):s.slice(1);return t[r]()+f}}var ae=Tr;var Sr=ae("toUpperCase"),oe=Sr;function Ir(r){return oe(x(r).toLowerCase())}var fe=Ir;a();o();a();o();function Ar(r,s,e,t){var f=-1,i=r==null?0:r.length;for(t&&i&&(e=r[++f]);++f<i;)e=s(e,r[f],f,r);return e}var se=Ar;a();o();a();o();a();o();function Pr(r){return function(s){return r==null?void 0:r[s]}}var ue=Pr;var Or={\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"},jr=ue(Or),ne=jr;var Fr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,wr="\\u0300-\\u036f",Lr="\\ufe20-\\ufe2f",Mr="\\u20d0-\\u20ff",Wr=wr+Lr+Mr,Er="["+Wr+"]",Ur=RegExp(Er,"g");function Br(r){return r=x(r),r&&r.replace(Fr,ne).replace(Ur,"")}var ie=Br;a();o();a();o();var zr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Dr(r){return r.match(zr)||[]}var le=Dr;a();o();var Vr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function qr(r){return Vr.test(r)}var pe=qr;a();o();var ge="\\ud800-\\udfff",Zr="\\u0300-\\u036f",Gr="\\ufe20-\\ufe2f",Jr="\\u20d0-\\u20ff",Hr=Zr+Gr+Jr,he="\\u2700-\\u27bf",be="a-z\\xdf-\\xf6\\xf8-\\xff",_r="\\xac\\xb1\\xd7\\xf7",Kr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Yr="\\u2000-\\u206f",$r=" \\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",ye="A-Z\\xc0-\\xd6\\xd8-\\xde",Qr="\\ufe0e\\ufe0f",Ce=_r+Kr+Yr+$r,Ne="['\u2019]",me="["+Ce+"]",Xr="["+Hr+"]",Re="\\d+",et="["+he+"]",ve="["+be+"]",ke="[^"+ge+Ce+Re+he+be+ye+"]",rt="\\ud83c[\\udffb-\\udfff]",tt="(?:"+Xr+"|"+rt+")",at="[^"+ge+"]",Te="(?:\\ud83c[\\udde6-\\uddff]){2}",Se="[\\ud800-\\udbff][\\udc00-\\udfff]",g="["+ye+"]",ot="\\u200d",de="(?:"+ve+"|"+ke+")",ft="(?:"+g+"|"+ke+")",xe="(?:"+Ne+"(?:d|ll|m|re|s|t|ve))?",ce="(?:"+Ne+"(?:D|LL|M|RE|S|T|VE))?",Ie=tt+"?",Ae="["+Qr+"]?",st="(?:"+ot+"(?:"+[at,Te,Se].join("|")+")"+Ae+Ie+")*",ut="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",nt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",it=Ae+Ie+st,lt="(?:"+[et,Te,Se].join("|")+")"+it,pt=RegExp([g+"?"+ve+"+"+xe+"(?="+[me,g,"$"].join("|")+")",ft+"+"+ce+"(?="+[me,g+de,"$"].join("|")+")",g+"?"+de+"+"+xe,g+"+"+ce,nt,ut,Re,lt].join("|"),"g");function mt(r){return r.match(pt)||[]}var Pe=mt;function dt(r,s,e){return r=x(r),s=e?void 0:s,s===void 0?pe(r)?Pe(r):le(r):r.match(s)||[]}var Oe=dt;var xt="['\u2019]",ct=RegExp(xt,"g");function gt(r){return function(s){return se(Oe(ie(s).replace(ct,"")),r,"")}}var je=gt;var ht=je(function(r,s,e){return s=s.toLowerCase(),r+(e?fe(s):s)}),k=ht;var bt=new Set(["enum","extends","package","void","short","class","abstract","return","import","for","assert","switch","getClass"]),Fe=class r extends S{constructor({ir:e,config:t,options:f}){var i;super({ir:e,config:t,options:f});c(this,"ir");c(this,"customConfig");c(this,"dynamicTypeMapper");c(this,"dynamicTypeLiteralMapper");c(this,"filePropertyMapper");this.ir=e,this.customConfig=I.parse((i=t.customConfig)!=null?i:{}),this.dynamicTypeMapper=new P({context:this}),this.dynamicTypeLiteralMapper=new A({context:this}),this.filePropertyMapper=new O({context:this})}clone(){return new r({ir:this.ir,config:this.config,options:this.options})}getClassName(e){return this.getName(e.pascalCase.safeName)}getEnumName(e){return this.getName(e.screamingSnakeCase.safeName)}getPropertyName(e){return this.getName(e.camelCase.safeName)}getMethodName(e){return this.getName(e.camelCase.safeName)}getRootClientClassReference(){return l.classReference({name:this.getRootClientClassName(),packageName:this.getRootPackageName()})}getRootClientClassName(){var e,t;return(t=(e=this.customConfig)==null?void 0:e["client-class-name"])!=null?t:`${this.getBaseNamePrefix()}Client`}getEnvironmentClassName(){return"Environment"}getEnvironmentTypeReferenceFromID(e){let t=this.resolveEnvironmentName(e);if(t!=null)return l.codeblock(f=>{f.writeNode(this.getEnvironmentClassReference()),f.write("."),f.write(this.getEnumName(t))})}getEnvironmentClassReference(){return l.classReference({name:this.getEnvironmentClassName(),packageName:this.getCorePackageName()})}getJavaClassReferenceFromDeclaration({declaration:e}){return l.classReference({name:e.name.pascalCase.unsafeName,packageName:this.getTypesPackageName(e.fernFilepath)})}getNullableClassReference(){return l.classReference({name:"Nullable",packageName:this.getCorePackageName()})}getNullableOfNull(){return l.TypeLiteral.reference(l.invokeMethod({on:this.getNullableClassReference(),method:"ofNull",arguments_:[]}))}getOptionalNullableClassReference(){return l.classReference({name:"OptionalNullable",packageName:this.getCorePackageName()})}getOptionalNullableAbsent(){return l.TypeLiteral.reference(l.invokeMethod({on:this.getOptionalNullableClassReference(),method:"absent",arguments_:[]}))}getOptionalNullableOf(e){return l.TypeLiteral.reference(l.invokeMethod({on:this.getOptionalNullableClassReference(),method:"of",arguments_:[e]}))}getFileStreamFromString(e){return l.TypeLiteral.reference(l.codeblock(t=>{t.write("new "),t.writeNode(this.getFileStreamClassReference()),t.write("("),t.writeNode(this.getByteArrayInputStreamClassReference()),t.write("("),t.writeNode(l.TypeLiteral.string(e)),t.write(".getBytes("),t.writeNode(this.getStandardCharsetsClassReference()),t.write(".UTF_8)))")}))}getFileStreamClassReference(){return l.classReference({name:"FileStream",packageName:this.getCorePackageName()})}getByteArrayInputStreamClassReference(){return l.classReference({name:"ByteArrayInputStream",packageName:"java.io"})}getStandardCharsetsClassReference(){return l.classReference({name:"StandardCharsets",packageName:"java.nio.charset"})}isPrimitive(e){switch(e.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(e.value);case"named":{let t=this.resolveNamedType({typeId:e.value});if(t==null)return!1;switch(t.type){case"alias":return this.isPrimitive(t.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:N(t)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:N(e)}}isDirectLiteral(e){return e.type==="literal"}sortTypeInstancesByRequiredFirst(e,t){let f=new Map;t.forEach((p,d)=>{f.set(p.name.wireValue,d)});let i=[],h=[];for(let p of e)this.isOptional(p.typeReference)?h.push(p):i.push(p);return i.sort((p,d)=>{var b,T;return((b=f.get(p.name.wireValue))!=null?b:0)-((T=f.get(d.name.wireValue))!=null?T:0)}),[...i,...h]}associateByWireValue({parameters:e,values:t,ignoreMissingParameters:f}){let i=super.associateByWireValue({parameters:e,values:t,ignoreMissingParameters:f}),h=new Map;for(let d of i)h.set(d.name.wireValue,d);let p=[];for(let d of e){let b=h.get(d.name.wireValue);b!=null&&p.push(b)}return p}getRootPackageName(){let e=this.getPackagePrefixTokens();return this.joinPackageTokens(e)}getCorePackageName(){let e=this.getPackagePrefixTokens();return e.push("core"),this.joinPackageTokens(e)}getTypesPackageName(e){return this.getResourcesPackage(e,"types")}getRequestsPackageName(e){return this.getPackageLayout()==="flat"?this.getTypesPackageName(e):this.getResourcesPackage(e,"requests")}getResourcesPackage(e,t){let f=this.getPackagePrefixTokens();switch(this.getPackageLayout()){case"flat":e!=null&&f.push(...e.packagePath.map(i=>this.getPackageNameSegment(i)));break;case"nested":default:e!=null&&e.allParts.length>0&&f.push("resources"),e!=null&&f.push(...e.allParts.map(i=>this.getPackageNameSegment(i)))}return t!=null&&f.push(t),this.joinPackageTokens(f)}getPackageName(e,t){let f=this.getPackageNameSegments(e);return f=t!=null?[...f,t]:f,[...this.getPackagePrefixTokens(),...f].join(".")}getPackageLayout(){var e,t;return(t=(e=this.customConfig)==null?void 0:e["package-layout"])!=null?t:"nested"}shouldInlinePathParameters(){var e,t;return(t=(e=this.customConfig)==null?void 0:e["inline-path-parameters"])!=null?t:!1}shouldInlineFileProperties(){var e,t;return(t=(e=this.customConfig)==null?void 0:e["inline-file-properties"])!=null?t:!1}getPackageNameSegments(e){return e.packagePath.map(t=>this.getPackageNameSegment(t))}getPackageNameSegment(e){return e.camelCase.safeName.toLowerCase()}getPackagePrefixTokens(){var t;if(((t=this.customConfig)==null?void 0:t["package-prefix"])!=null)return this.customConfig["package-prefix"].split(".");let e=[];return e.push("com"),e.push(...this.splitOnNonAlphaNumericChar(this.config.organization)),e.push(...this.splitOnNonAlphaNumericChar(this.getApiName())),e}getBaseNamePrefix(){return this.convertKebabCaseToUpperCamelCase(this.config.organization)+this.convertKebabCaseToUpperCamelCase(this.getApiName())}getApiName(){return k(this.config.workspaceName)}startsWithNumber(e){return/^\d/.test(e)}splitOnNonAlphaNumericChar(e){return e.split(/[^a-zA-Z0-9]/)}convertKebabCaseToUpperCamelCase(e){return e.replace(/-([a-z])/g,(t,f)=>f.toUpperCase()).replace(/^[a-z]/,t=>t.toUpperCase())}joinPackageTokens(e){return e.map(f=>this.startsWithNumber(f)?"_"+f:f).join(".")}getName(e){return this.isReservedName(e)?"_"+e:e}isReservedName(e){return bt.has(e)}};export{Fe 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-
|
|
15
|
+
//# sourceMappingURL=chunk-FDN2HGWE.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as r,d as t}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as r,d as t}from"./chunk-PUKCM72D.js";import{f as a,h as c,i}from"./chunk-2U3YQWRZ.js";c();i();var p=class{constructor({context:e}){a(this,"context");this.context=e}convert(e){switch(e.typeReference.type){case"list":return t.Type.list(this.convert({typeReference:e.typeReference}));case"literal":return this.convertLiteral({literal:e.typeReference.value});case"map":return t.Type.map(this.convert({typeReference:e.typeReference.key}),this.convert({typeReference:e.typeReference.value}));case"named":{let n=this.context.resolveNamedType({typeId:e.typeReference.value});return n==null?this.convertUnknown():this.convertNamed({named:n})}case"optional":case"nullable":return t.Type.optional(this.convert({typeReference:e.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:e.typeReference.value});case"set":return t.Type.set(this.convert({typeReference:e.typeReference}));case"unknown":return this.convertUnknown();default:r(e.typeReference)}}convertNamed({named:e}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference});case"enum":case"discriminatedUnion":case"object":case"undiscriminatedUnion":return t.Type.reference(t.classReference({name:this.context.getClassName(e.declaration.name),packageName:this.context.getTypesPackageName(e.declaration.fernFilepath)}));default:r(e)}}convertLiteral({literal:e}){switch(e.type){case"boolean":return t.Type.boolean();case"string":return t.Type.string()}}convertUnknown(){return t.Type.object()}convertPrimitive({primitive:e}){switch(e){case"INTEGER":return t.Type.integer();case"UINT":return t.Type.integer();case"LONG":return t.Type.long();case"UINT_64":return t.Type.long();case"FLOAT":return t.Type.float();case"DOUBLE":return t.Type.double();case"BOOLEAN":return t.Type.boolean();case"STRING":return t.Type.string();case"DATE":return t.Type.date();case"DATE_TIME":return t.Type.dateTime();case"UUID":return t.Type.uuid();case"BASE_64":return t.Type.bytes();case"BIG_INTEGER":return t.Type.bigInteger();default:r(e)}}};export{p as a};
|
|
2
|
+
//# sourceMappingURL=chunk-FNREWPPJ.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as s,d as n}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as s,d as n}from"./chunk-PUKCM72D.js";import{f as l,h as p,i as y}from"./chunk-2U3YQWRZ.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.getMethodName(t.name),value:this.getSingleFileProperty({property:t,record:i})});break;case"fileArray":e.fileFields.push({name:this.context.getMethodName(t.name),value:this.getArrayFileProperty({property:t,record:i})});break;case"bodyProperty":e.bodyPropertyFields.push({name:this.context.getMethodName(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.reference(this.context.getFileStreamFromString(e))}getArrayFileProperty({property:r,record:o}){let e=this.context.getFileArrayValues({property:r,record:o});if(e==null)return n.TypeLiteral.nop();for(let i of e)return n.TypeLiteral.reference(this.context.getFileStreamFromString(i));return n.TypeLiteral.nop()}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};
|
|
2
|
+
//# sourceMappingURL=chunk-JBCRNEMV.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as m,d as g,e as u}from"./chunk-3GRWXKJQ.js";import{a as y,d as n}from"./chunk-RJC322RM.js";import{f as v,h as A,i as b}from"./chunk-2U3YQWRZ.js";A();b();var q="com.example.usage",L="Example",M="main",S="args",T="client",j={type:"primitive",value:"STRING"};function k(h){if(h.type==="optional"&&h.value.type==="list"){let t=h.value.value;if(t.type==="optional")return{type:"optional",value:{type:"list",value:t.value}}}if(h.type==="list"){let e=h.value;if(e.type==="optional")return{type:"list",value:e.value}}return h}var C=class{constructor({context:e,formatter:t}){v(this,"context");v(this,"formatter");this.context=e,this.formatter=t}async generateSnippet({endpoint:e,request:t,options:r}){var i;let a=this.getConfig(r);return await this.buildCodeBlock({endpoint:e,snippet:t,options:r}).toStringAsync({packageName:(i=a.fullStylePackageName)!=null?i:q,customConfig:this.context.customConfig,formatter:this.formatter})}generateSnippetSync({endpoint:e,request:t,options:r}){var i;let a=this.getConfig(r);return this.buildCodeBlock({endpoint:e,snippet:t,options:r}).toString({packageName:(i=a.fullStylePackageName)!=null?i:q,customConfig:this.context.customConfig,formatter:this.formatter})}async generateSnippetAst({endpoint:e,request:t,options:r}){throw new Error("Unsupported")}buildCodeBlock({endpoint:e,snippet:t,options:r}){let a=n.codeblock(i=>{i.writeNodeStatement(this.constructClient({endpoint:e,snippet:t})),i.newLine(),i.writeNodeStatement(this.callMethod({endpoint:e,snippet:t}))}),s=this.getStyle(r);switch(s){case g.Concise:return a;case g.Full:return this.buildFullCodeBlock({body:a,options:r});default:y(s)}}constructClient({endpoint:e,snippet:t}){return n.codeblock(r=>{r.writeNode(this.context.getRootClientClassReference()),r.write(` ${T} = `),r.writeNode(n.TypeLiteral.builder({classReference:this.context.getRootClientClassReference(),parameters:this.getRootClientBuilderArgs({endpoint:e,snippet:t})}))})}buildFullCodeBlock({body:e,options:t}){var i;let r=this.getConfig(t),a=n.class_({name:(i=r.fullStyleClassName)!=null?i:L,access:n.Access.Public}),s=n.parameter({name:S,type:n.Type.array(n.Type.string())});return a.addMethod(n.method({name:M,access:n.Access.Public,static_:!0,parameters:[s],body:e})),a}getRootClientBuilderArgs({endpoint:e,snippet:t}){var o,p;let r=[];e.auth!=null&&(t.auth!=null?r.push(...this.getRootClientAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:m.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`}));let a=this.getRootClientBaseUrlArg({baseUrl:t.baseURL,environment:t.environment});a!=null&&r.push(a),this.context.errors.scope(u.Headers),this.context.ir.headers!=null&&t.headers!=null&&r.push(...this.getRootClientHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope();let s=new Set;if([...(o=this.context.ir.pathParameters)!=null?o:[],...(p=e.request.pathParameters)!=null?p:[]].forEach(l=>{l.variable!=null&&s.add(l.variable)}),this.context.ir.variables!=null&&this.context.ir.variables.length>0){for(let l of this.context.ir.variables)if(s.has(l.id)){let c=l.name.camelCase.unsafeName;r.push({name:c,value:n.TypeLiteral.string(`YOUR_${l.name.screamingSnakeCase.unsafeName}`)})}}if(this.context.errors.scope(u.PathParameters),this.context.ir.pathParameters!=null&&this.context.ir.pathParameters.length>0){let l=this.context.ir.pathParameters.filter(c=>c.variable==null);l.length>0&&r.push(...this.getPathParameters({namedParameters:l,snippet:t}))}return this.context.errors.unscope(),r}getRootClientBaseUrlArg({baseUrl:e,environment:t}){var r;if(e!=null&&t!=null){this.context.errors.add({severity:m.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(e!=null){if(((r=this.context.ir.environments)==null?void 0:r.environments.type)==="multipleBaseUrls"){this.context.errors.add({severity:m.Critical,message:"The Java SDK doesn't support a baseUrl when multiple URL environments are configured"});return}return{name:"url",value:n.TypeLiteral.string(e)}}if(t!=null){if(this.context.isSingleEnvironmentID(t)){let a=this.context.getEnvironmentTypeReferenceFromID(t);if(a==null){this.context.errors.add({severity:m.Warning,message:`Environment ${JSON.stringify(t)} was not found`});return}return{name:"environment",value:n.TypeLiteral.reference(a)}}if(this.context.isMultiEnvironmentValues(t))return this.context.validateMultiEnvironmentUrlValues(t)?{name:"environment",value:n.TypeLiteral.reference(n.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.values(t).map(a=>this.context.dynamicTypeLiteralMapper.convert({typeReference:j,value:a}))}))}:void 0}}getRootClientAuthArgs({auth:e,values:t}){if(t.type!==e.type)return this.addError(this.context.newAuthMismatchError({auth:e,values:t}).message),[];switch(e.type){case"basic":return t.type==="basic"?this.getRootClientBasicAuthArgs({auth:e,values:t}):[];case"bearer":return t.type==="bearer"?this.getRootClientBearerAuthArgs({auth:e,values:t}):[];case"header":return t.type==="header"?this.getRootClientHeaderAuthArgs({auth:e,values:t}):[];case"oauth":return t.type==="oauth"?this.getRootClientOAuthArgs({auth:e,values:t}):[];case"inferred":return this.addWarning("The Java SDK Generator does not support Inferred auth scheme yet"),[];default:y(e)}}addError(e){this.context.errors.add({severity:m.Critical,message:e})}addWarning(e){this.context.errors.add({severity:m.Warning,message:e})}getRootClientBasicAuthArgs({auth:e,values:t}){return[{name:"credentials",value:n.TypeLiteral.raw(`"${t.username}", "${t.password}"`)}]}getRootClientBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.token),value:n.TypeLiteral.string(t.token)}]}getRootClientHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value})}]}getRootClientOAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.clientId),value:n.TypeLiteral.string(t.clientId)},{name:this.context.getMethodName(e.clientSecret),value:n.TypeLiteral.string(t.clientSecret)}]}getRootClientHeaderArgs({headers:e,values:t}){let r=[];for(let a of e){let s=this.getRootClientHeaderArg({header:a,value:t.value});s!=null&&r.push({name:this.context.getMethodName(a.name.name),value:s})}return r}getRootClientHeaderArg({header:e,value:t}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t});if(!n.TypeLiteral.isNop(r))return r}callMethod({endpoint:e,snippet:t}){return n.invokeMethod({on:n.codeblock(T),method:this.getMethod({endpoint:e}),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:y(e.request)}}getMethodArgsForBodyRequest({request:e,snippet:t}){var i;let r=[];this.context.errors.scope(u.PathParameters);let a=((i=e.pathParameters)!=null?i:[]).filter(o=>o.variable==null);a.length>0&&r.push(...this.getPathParameters({namedParameters:a,snippet:t}).map(o=>o.value)),this.context.errors.unscope(),this.context.errors.scope(u.RequestBody),e.body!=null&&r.push(this.getBodyRequestArg({body:e.body,value:t.requestBody})),this.context.errors.unscope();let s=this.getRequestOptionsArg({request:e,snippet:t});return s!=null&&r.push(s),r}usesOptionalNullable(){var e;return((e=this.context.customConfig)==null?void 0:e["collapse-optional-nullable"])===!0}getBodyRequestArg({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":{if(e.value.type==="optional"){if(t==null)return this.usesOptionalNullable()?this.context.getOptionalNullableAbsent():n.TypeLiteral.reference(n.invokeMethod({on:n.classReference({name:"Optional",packageName:"java.util"}),method:"empty",arguments_:[]}));let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value.value,value:t,as:"request"}),a=r.toString({packageName:"com.example",customConfig:this.context.customConfig});return a.includes("Optional.empty()")||a.includes("OptionalNullable.absent()")?r:this.usesOptionalNullable()?this.context.getOptionalNullableOf(r):n.TypeLiteral.optional({value:r,useOf:!0})}return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t,as:"request"})}default:y(e)}}getBytesBodyRequestArg({value:e}){return e==null?n.TypeLiteral.bytes(""):typeof e!="string"?(this.context.errors.add({severity:m.Critical,message:`Expected bytes value to be a string, got ${typeof e}`}),n.TypeLiteral.nop()):n.TypeLiteral.bytes(e)}getMethodArgsForInlinedRequest({request:e,snippet:t}){var l;let r=[],{inlinePathParameters:a,inlineFileProperties:s}={inlinePathParameters:this.context.shouldInlinePathParameters(),inlineFileProperties:this.context.shouldInlineFileProperties()};this.context.errors.scope(u.PathParameters);let i=[],o=((l=e.pathParameters)!=null?l:[]).filter(c=>c.variable==null);o.length>0&&i.push(...this.getPathParameters({namedParameters:o,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(u.RequestBody);let p=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:a})||r.push(...i.map(c=>c.value)),s||r.push(...p.fileFields.map(c=>c.value)),r.push(this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:a})?i:[],filePropertyInfo:p})),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:a}){var P,R,x,F,I,B;this.context.errors.scope(u.QueryParameters);let i=this.context.associateQueryParametersByWireValue({parameters:(P=e.queryParameters)!=null?P:[],values:(R=t.queryParameters)!=null?R:{}}).filter(d=>!this.context.isDirectLiteral(d.typeReference)),p=this.context.sortTypeInstancesByRequiredFirst(i,(x=e.queryParameters)!=null?x:[]).map(d=>({name:this.context.getMethodName(d.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:k(d.typeReference),value:d.value,as:"request"})}));this.context.errors.unscope(),this.context.errors.scope(u.Headers);let c=this.context.associateByWireValue({parameters:(F=e.headers)!=null?F:[],values:(I=t.headers)!=null?I:{}}).filter(d=>!this.context.isDirectLiteral(d.typeReference)),N=this.context.sortTypeInstancesByRequiredFirst(c,(B=e.headers)!=null?B:[]).map(d=>({name:this.context.getMethodName(d.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:d.typeReference,value:d.value,as:"request"})}));this.context.errors.unscope(),this.context.errors.scope(u.RequestBody);let E=e.body!=null?this.getInlinedRequestBodyBuilderParameters({body:e.body,value:t.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),n.TypeLiteral.builder({classReference:n.classReference({name:this.context.getClassName(e.declaration.name),packageName:this.context.getRequestsPackageName(e.declaration.fernFilepath)}),parameters:[...r,...N,...p,...E]})}getRequestOptionsArg({request:e,snippet:t}){var p,l,c;let r="headers"in e?(p=e.headers)!=null?p:[]:[];if(r.length===0||Object.keys((l=t.headers)!=null?l:{}).length===0)return;this.context.errors.scope(u.Headers);let a=this.context.associateByWireValue({parameters:r,values:(c=t.headers)!=null?c:{}});if(this.context.errors.unscope(),a.length===0)return;let s=n.classReference({name:"RequestOptions",packageName:this.context.getCorePackageName()}),i=n.invokeMethod({on:s,method:"builder",arguments_:[]});for(let f of a)i=n.invokeMethod({on:i,method:"addHeader",arguments_:[n.TypeLiteral.string(f.name.wireValue),this.context.dynamicTypeLiteralMapper.convert(f)]});let o=n.invokeMethod({on:i,method:"build",arguments_:[]});return n.TypeLiteral.reference(o)}getInlinedRequestBodyBuilderParameters({body:e,value:t,filePropertyInfo:r}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyBuilderParameters({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyBuilderParameter({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyBuilderParameters({filePropertyInfo:r});default:y(e)}}getFileUploadRequestBodyBuilderParameters({filePropertyInfo:e}){return this.context.shouldInlineFileProperties()?[...e.fileFields,...e.bodyPropertyFields]:e.bodyPropertyFields}getReferencedRequestBodyPropertyBuilderParameter({body:e,value:t}){return{name:this.context.getMethodName(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,as:"request"});default:y(e)}}getInlinedRequestBodyPropertyBuilderParameters({parameters:e,value:t}){var i;let a=this.context.associateByWireValue({parameters:e,values:(i=this.context.getRecord(t))!=null?i:{}}).filter(o=>!this.context.isDirectLiteral(o.typeReference));return this.context.sortTypeInstancesByRequiredFirst(a,e).map(o=>({name:this.context.getMethodName(o.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:o.typeReference,value:o.value,as:"request"})}))}getPathParameters({namedParameters:e,snippet:t}){var s;let r=[],a=this.context.associateByWireValue({parameters:e,values:(s=t.pathParameters)!=null?s:{}});for(let i of a)r.push({name:this.context.getMethodName(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)}getStyle(e){var t,r;return(r=(t=e.style)!=null?t:this.context.options.style)!=null?r:g.Full}getConfig(e){var t,r;return(r=(t=e.config)!=null?t:this.context.options.config)!=null?r:{}}};export{C as a};
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as m,d as g,e as u}from"./chunk-C7RK7JUC.js";import{a as y,d as n}from"./chunk-PUKCM72D.js";import{f as v,h as A,i as b}from"./chunk-2U3YQWRZ.js";A();b();var q="com.example.usage",L="Example",M="main",S="args",T="client",j={type:"primitive",value:"STRING"};function k(h){if(h.type==="optional"&&h.value.type==="list"){let t=h.value.value;if(t.type==="optional")return{type:"optional",value:{type:"list",value:t.value}}}if(h.type==="list"){let e=h.value;if(e.type==="optional")return{type:"list",value:e.value}}return h}var C=class{constructor({context:e,formatter:t}){v(this,"context");v(this,"formatter");this.context=e,this.formatter=t}async generateSnippet({endpoint:e,request:t,options:r}){var i;let a=this.getConfig(r);return await this.buildCodeBlock({endpoint:e,snippet:t,options:r}).toStringAsync({packageName:(i=a.fullStylePackageName)!=null?i:q,customConfig:this.context.customConfig,formatter:this.formatter})}generateSnippetSync({endpoint:e,request:t,options:r}){var i;let a=this.getConfig(r);return this.buildCodeBlock({endpoint:e,snippet:t,options:r}).toString({packageName:(i=a.fullStylePackageName)!=null?i:q,customConfig:this.context.customConfig,formatter:this.formatter})}async generateSnippetAst({endpoint:e,request:t,options:r}){throw new Error("Unsupported")}buildCodeBlock({endpoint:e,snippet:t,options:r}){let a=n.codeblock(i=>{i.writeNodeStatement(this.constructClient({endpoint:e,snippet:t})),i.newLine(),i.writeNodeStatement(this.callMethod({endpoint:e,snippet:t}))}),s=this.getStyle(r);switch(s){case g.Concise:return a;case g.Full:return this.buildFullCodeBlock({body:a,options:r});default:y(s)}}constructClient({endpoint:e,snippet:t}){return n.codeblock(r=>{r.writeNode(this.context.getRootClientClassReference()),r.write(` ${T} = `),r.writeNode(n.TypeLiteral.builder({classReference:this.context.getRootClientClassReference(),parameters:this.getRootClientBuilderArgs({endpoint:e,snippet:t})}))})}buildFullCodeBlock({body:e,options:t}){var i;let r=this.getConfig(t),a=n.class_({name:(i=r.fullStyleClassName)!=null?i:L,access:n.Access.Public}),s=n.parameter({name:S,type:n.Type.array(n.Type.string())});return a.addMethod(n.method({name:M,access:n.Access.Public,static_:!0,parameters:[s],body:e})),a}getRootClientBuilderArgs({endpoint:e,snippet:t}){var o,p;let r=[];e.auth!=null&&(t.auth!=null?r.push(...this.getRootClientAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:m.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`}));let a=this.getRootClientBaseUrlArg({baseUrl:t.baseURL,environment:t.environment});a!=null&&r.push(a),this.context.errors.scope(u.Headers),this.context.ir.headers!=null&&t.headers!=null&&r.push(...this.getRootClientHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope();let s=new Set;if([...(o=this.context.ir.pathParameters)!=null?o:[],...(p=e.request.pathParameters)!=null?p:[]].forEach(l=>{l.variable!=null&&s.add(l.variable)}),this.context.ir.variables!=null&&this.context.ir.variables.length>0){for(let l of this.context.ir.variables)if(s.has(l.id)){let c=l.name.camelCase.unsafeName;r.push({name:c,value:n.TypeLiteral.string(`YOUR_${l.name.screamingSnakeCase.unsafeName}`)})}}if(this.context.errors.scope(u.PathParameters),this.context.ir.pathParameters!=null&&this.context.ir.pathParameters.length>0){let l=this.context.ir.pathParameters.filter(c=>c.variable==null);l.length>0&&r.push(...this.getPathParameters({namedParameters:l,snippet:t}))}return this.context.errors.unscope(),r}getRootClientBaseUrlArg({baseUrl:e,environment:t}){var r;if(e!=null&&t!=null){this.context.errors.add({severity:m.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(e!=null){if(((r=this.context.ir.environments)==null?void 0:r.environments.type)==="multipleBaseUrls"){this.context.errors.add({severity:m.Critical,message:"The Java SDK doesn't support a baseUrl when multiple URL environments are configured"});return}return{name:"url",value:n.TypeLiteral.string(e)}}if(t!=null){if(this.context.isSingleEnvironmentID(t)){let a=this.context.getEnvironmentTypeReferenceFromID(t);if(a==null){this.context.errors.add({severity:m.Warning,message:`Environment ${JSON.stringify(t)} was not found`});return}return{name:"environment",value:n.TypeLiteral.reference(a)}}if(this.context.isMultiEnvironmentValues(t))return this.context.validateMultiEnvironmentUrlValues(t)?{name:"environment",value:n.TypeLiteral.reference(n.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.values(t).map(a=>this.context.dynamicTypeLiteralMapper.convert({typeReference:j,value:a}))}))}:void 0}}getRootClientAuthArgs({auth:e,values:t}){if(t.type!==e.type)return this.addError(this.context.newAuthMismatchError({auth:e,values:t}).message),[];switch(e.type){case"basic":return t.type==="basic"?this.getRootClientBasicAuthArgs({auth:e,values:t}):[];case"bearer":return t.type==="bearer"?this.getRootClientBearerAuthArgs({auth:e,values:t}):[];case"header":return t.type==="header"?this.getRootClientHeaderAuthArgs({auth:e,values:t}):[];case"oauth":return t.type==="oauth"?this.getRootClientOAuthArgs({auth:e,values:t}):[];case"inferred":return this.addWarning("The Java SDK Generator does not support Inferred auth scheme yet"),[];default:y(e)}}addError(e){this.context.errors.add({severity:m.Critical,message:e})}addWarning(e){this.context.errors.add({severity:m.Warning,message:e})}getRootClientBasicAuthArgs({auth:e,values:t}){return[{name:"credentials",value:n.TypeLiteral.raw(`"${t.username}", "${t.password}"`)}]}getRootClientBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.token),value:n.TypeLiteral.string(t.token)}]}getRootClientHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value})}]}getRootClientOAuthArgs({auth:e,values:t}){return[{name:this.context.getMethodName(e.clientId),value:n.TypeLiteral.string(t.clientId)},{name:this.context.getMethodName(e.clientSecret),value:n.TypeLiteral.string(t.clientSecret)}]}getRootClientHeaderArgs({headers:e,values:t}){let r=[];for(let a of e){let s=this.getRootClientHeaderArg({header:a,value:t.value});s!=null&&r.push({name:this.context.getMethodName(a.name.name),value:s})}return r}getRootClientHeaderArg({header:e,value:t}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t});if(!n.TypeLiteral.isNop(r))return r}callMethod({endpoint:e,snippet:t}){return n.invokeMethod({on:n.codeblock(T),method:this.getMethod({endpoint:e}),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:y(e.request)}}getMethodArgsForBodyRequest({request:e,snippet:t}){var i;let r=[];this.context.errors.scope(u.PathParameters);let a=((i=e.pathParameters)!=null?i:[]).filter(o=>o.variable==null);a.length>0&&r.push(...this.getPathParameters({namedParameters:a,snippet:t}).map(o=>o.value)),this.context.errors.unscope(),this.context.errors.scope(u.RequestBody),e.body!=null&&r.push(this.getBodyRequestArg({body:e.body,value:t.requestBody})),this.context.errors.unscope();let s=this.getRequestOptionsArg({request:e,snippet:t});return s!=null&&r.push(s),r}usesOptionalNullable(){var e;return((e=this.context.customConfig)==null?void 0:e["collapse-optional-nullable"])===!0}getBodyRequestArg({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":{if(e.value.type==="optional"){if(t==null)return this.usesOptionalNullable()?this.context.getOptionalNullableAbsent():n.TypeLiteral.reference(n.invokeMethod({on:n.classReference({name:"Optional",packageName:"java.util"}),method:"empty",arguments_:[]}));let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value.value,value:t,as:"request"}),a=r.toString({packageName:"com.example",customConfig:this.context.customConfig});return a.includes("Optional.empty()")||a.includes("OptionalNullable.absent()")?r:this.usesOptionalNullable()?this.context.getOptionalNullableOf(r):n.TypeLiteral.optional({value:r,useOf:!0})}return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t,as:"request"})}default:y(e)}}getBytesBodyRequestArg({value:e}){return e==null?n.TypeLiteral.bytes(""):typeof e!="string"?(this.context.errors.add({severity:m.Critical,message:`Expected bytes value to be a string, got ${typeof e}`}),n.TypeLiteral.nop()):n.TypeLiteral.bytes(e)}getMethodArgsForInlinedRequest({request:e,snippet:t}){var l;let r=[],{inlinePathParameters:a,inlineFileProperties:s}={inlinePathParameters:this.context.shouldInlinePathParameters(),inlineFileProperties:this.context.shouldInlineFileProperties()};this.context.errors.scope(u.PathParameters);let i=[],o=((l=e.pathParameters)!=null?l:[]).filter(c=>c.variable==null);o.length>0&&i.push(...this.getPathParameters({namedParameters:o,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(u.RequestBody);let p=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:a})||r.push(...i.map(c=>c.value)),s||r.push(...p.fileFields.map(c=>c.value)),r.push(this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:a})?i:[],filePropertyInfo:p})),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:a}){var P,R,x,F,I,B;this.context.errors.scope(u.QueryParameters);let i=this.context.associateQueryParametersByWireValue({parameters:(P=e.queryParameters)!=null?P:[],values:(R=t.queryParameters)!=null?R:{}}).filter(d=>!this.context.isDirectLiteral(d.typeReference)),p=this.context.sortTypeInstancesByRequiredFirst(i,(x=e.queryParameters)!=null?x:[]).map(d=>({name:this.context.getMethodName(d.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:k(d.typeReference),value:d.value,as:"request"})}));this.context.errors.unscope(),this.context.errors.scope(u.Headers);let c=this.context.associateByWireValue({parameters:(F=e.headers)!=null?F:[],values:(I=t.headers)!=null?I:{}}).filter(d=>!this.context.isDirectLiteral(d.typeReference)),N=this.context.sortTypeInstancesByRequiredFirst(c,(B=e.headers)!=null?B:[]).map(d=>({name:this.context.getMethodName(d.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:d.typeReference,value:d.value,as:"request"})}));this.context.errors.unscope(),this.context.errors.scope(u.RequestBody);let E=e.body!=null?this.getInlinedRequestBodyBuilderParameters({body:e.body,value:t.requestBody,filePropertyInfo:a}):[];return this.context.errors.unscope(),n.TypeLiteral.builder({classReference:n.classReference({name:this.context.getClassName(e.declaration.name),packageName:this.context.getRequestsPackageName(e.declaration.fernFilepath)}),parameters:[...r,...N,...p,...E]})}getRequestOptionsArg({request:e,snippet:t}){var p,l,c;let r="headers"in e?(p=e.headers)!=null?p:[]:[];if(r.length===0||Object.keys((l=t.headers)!=null?l:{}).length===0)return;this.context.errors.scope(u.Headers);let a=this.context.associateByWireValue({parameters:r,values:(c=t.headers)!=null?c:{}});if(this.context.errors.unscope(),a.length===0)return;let s=n.classReference({name:"RequestOptions",packageName:this.context.getCorePackageName()}),i=n.invokeMethod({on:s,method:"builder",arguments_:[]});for(let f of a)i=n.invokeMethod({on:i,method:"addHeader",arguments_:[n.TypeLiteral.string(f.name.wireValue),this.context.dynamicTypeLiteralMapper.convert(f)]});let o=n.invokeMethod({on:i,method:"build",arguments_:[]});return n.TypeLiteral.reference(o)}getInlinedRequestBodyBuilderParameters({body:e,value:t,filePropertyInfo:r}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyBuilderParameters({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyBuilderParameter({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyBuilderParameters({filePropertyInfo:r});default:y(e)}}getFileUploadRequestBodyBuilderParameters({filePropertyInfo:e}){return this.context.shouldInlineFileProperties()?[...e.fileFields,...e.bodyPropertyFields]:e.bodyPropertyFields}getReferencedRequestBodyPropertyBuilderParameter({body:e,value:t}){return{name:this.context.getMethodName(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,as:"request"});default:y(e)}}getInlinedRequestBodyPropertyBuilderParameters({parameters:e,value:t}){var i;let a=this.context.associateByWireValue({parameters:e,values:(i=this.context.getRecord(t))!=null?i:{}}).filter(o=>!this.context.isDirectLiteral(o.typeReference));return this.context.sortTypeInstancesByRequiredFirst(a,e).map(o=>({name:this.context.getMethodName(o.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:o.typeReference,value:o.value,as:"request"})}))}getPathParameters({namedParameters:e,snippet:t}){var s;let r=[],a=this.context.associateByWireValue({parameters:e,values:(s=t.pathParameters)!=null?s:{}});for(let i of a)r.push({name:this.context.getMethodName(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)}getStyle(e){var t,r;return(r=(t=e.style)!=null?t:this.context.options.style)!=null?r:g.Full}getConfig(e){var t,r;return(r=(t=e.config)!=null?t:this.context.options.config)!=null?r:{}}};export{C as a};
|
|
2
|
+
//# sourceMappingURL=chunk-OHA6X7RF.js.map
|