@fern-api/php-dynamic-snippets 0.0.13 → 1.25.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.
Files changed (38) hide show
  1. package/cjs/DynamicSnippetsGenerator.cjs +11 -11
  2. package/cjs/DynamicSnippetsGenerator.cjs.map +1 -1
  3. package/cjs/EndpointSnippetGenerator.cjs +9 -9
  4. package/cjs/EndpointSnippetGenerator.cjs.map +1 -1
  5. package/cjs/EndpointSnippetGenerator.d.cts +7 -0
  6. package/cjs/context/DynamicSnippetsGeneratorContext.cjs +6 -6
  7. package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +1 -1
  8. package/cjs/context/DynamicTypeLiteralMapper.cjs +6 -6
  9. package/cjs/context/DynamicTypeLiteralMapper.cjs.map +1 -1
  10. package/cjs/context/FilePropertyMapper.cjs +7 -7
  11. package/cjs/context/FilePropertyMapper.cjs.map +1 -1
  12. package/cjs/index.cjs +11 -11
  13. package/cjs/index.cjs.map +1 -1
  14. package/esm/DynamicSnippetsGenerator.js +1 -1
  15. package/esm/EndpointSnippetGenerator.d.ts +7 -0
  16. package/esm/EndpointSnippetGenerator.js +1 -1
  17. package/esm/{chunk-PYHFKEW4.js → chunk-34WVNBJS.js} +7 -7
  18. package/esm/chunk-34WVNBJS.js.map +1 -0
  19. package/esm/{chunk-RC5VUNGI.js → chunk-BN32SYGE.js} +2 -2
  20. package/esm/{chunk-3QAUV5WT.js → chunk-F7LTKJMT.js} +2 -2
  21. package/esm/{chunk-E5GKCY37.js → chunk-MZ7AWQF7.js} +2 -2
  22. package/esm/chunk-P7HYTUQU.js +4 -0
  23. package/esm/chunk-P7HYTUQU.js.map +1 -0
  24. package/esm/{chunk-WWRNGEPJ.js → chunk-Q7QB5SA5.js} +2 -2
  25. package/esm/{chunk-EBGZVRNQ.js → chunk-U6JJRNQH.js} +2 -2
  26. package/esm/context/DynamicSnippetsGeneratorContext.js +1 -1
  27. package/esm/context/DynamicTypeLiteralMapper.js +1 -1
  28. package/esm/context/FilePropertyMapper.js +1 -1
  29. package/esm/index.js +1 -1
  30. package/package.json +1 -1
  31. package/esm/chunk-7RBMVIRH.js +0 -4
  32. package/esm/chunk-7RBMVIRH.js.map +0 -1
  33. package/esm/chunk-PYHFKEW4.js.map +0 -1
  34. /package/esm/{chunk-RC5VUNGI.js.map → chunk-BN32SYGE.js.map} +0 -0
  35. /package/esm/{chunk-3QAUV5WT.js.map → chunk-F7LTKJMT.js.map} +0 -0
  36. /package/esm/{chunk-E5GKCY37.js.map → chunk-MZ7AWQF7.js.map} +0 -0
  37. /package/esm/{chunk-WWRNGEPJ.js.map → chunk-Q7QB5SA5.js.map} +0 -0
  38. /package/esm/{chunk-EBGZVRNQ.js.map → chunk-U6JJRNQH.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{a as T,b as P,c as S,d as A,e as p,f as l,g as u,h,k as R}from"./chunk-PYHFKEW4.js";l();u();l();u();var y=class{constructor(){p(this,"reporter");p(this,"snippet");p(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){p(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})}};l();u();var o={Critical:"CRITICAL",Warning:"WARNING"},g=class m{constructor(){p(this,"errors");p(this,"path");this.errors=[],this.path=[]}add(e){this.errors.push(P(T({},e),{path:[...this.path]}))}scope(e){this.path.push(e)}unscope(){this.path.pop()}getBySeverity(e){return this.errors.filter(r=>r.severity===e)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let e=new m;return e.errors=[...this.errors],e.path=[...this.path],e}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(e=>({severity:e.severity,path:e.path!=null?this.pathToStringArray(e.path):void 0,message:e.message}))}pathToStringArray(e){let r=[];for(let t of e){if(typeof t=="string"){r.push(t);continue}r[r.length-1]+=`[${t.index}]`}return r}};l();u();l();u();l();u();var v=class{constructor(){p(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={}}){p(this,"config");p(this,"options");p(this,"errors");p(this,"_ir");p(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 x=t,{[n]:d}=x,a=A(x,[S(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:h(e)}}resolveEnvironmentName(e){if(this._ir.environments==null)return;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}case"multipleBaseUrls":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}default:h(r)}}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}validateMultiEnvironmentUrlValues(e){if(this._ir.environments==null)return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let t=r.environments[0];if(t==null)return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let n=new Set(R(t.urls));for(let i of R(e))n.has(i)&&n.delete(i);return n.size>0?(this.errors.add({severity:o.Critical,message:`The provided environments are invalid; got: [${Object.keys(e).join(", ")}], expected: [${R(t.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:e}){if(typeof e!="number"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"number",value:e}).message});return}return e}getValueAsBoolean({value:e}){if(typeof e!="boolean"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"boolean",value:e}).message});return}return e}getValueAsString({value:e}){if(typeof e!="string"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"string",value:e}).message});return}return e}isOptional(e){switch(e.type){case"nullable":return this.isOptional(e.value);case"optional":return!0;case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}isNullable(e){switch(e.type){case"nullable":return!0;case"optional":return this.isNullable(e.value);case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}newAuthMismatchError({auth:e,values:r}){return new Error(`Expected auth type ${e.type}, got ${r.type}`)}newParameterNotRecognizedError(e){return new Error(`"${e}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:e,value:r}){return new Error(`Expected ${e}, got ${typeof r}`)}includeRequestBodyInWrappedRequest({body:e,inlineFileProperties:r}){switch(e.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r});default:h(e)}}includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r}){return this.fileUploadHasBodyProperties({fileUpload:e})||r&&this.fileUploadHasFileProperties({fileUpload:e})}fileUploadHasBodyProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:h(r)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:h(r)}})}isListTypeReference(e){return e.type==="optional"?this.isListTypeReference(e.value):e.type==="list"||e.type==="set"}parsedEndpointMatches({endpoint:e,parsedEndpoint:r}){return e.location.method===r.method&&e.location.path===r.path}};l();u();var b={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};l();u();export{E as a,o as b,w as c,b as d};
2
- //# sourceMappingURL=chunk-RC5VUNGI.js.map
1
+ import{a as T,b as P,c as S,d as A,e as p,f as l,g as u,h,k as R}from"./chunk-34WVNBJS.js";l();u();l();u();var y=class{constructor(){p(this,"reporter");p(this,"snippet");p(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){p(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})}};l();u();var o={Critical:"CRITICAL",Warning:"WARNING"},g=class m{constructor(){p(this,"errors");p(this,"path");this.errors=[],this.path=[]}add(e){this.errors.push(P(T({},e),{path:[...this.path]}))}scope(e){this.path.push(e)}unscope(){this.path.pop()}getBySeverity(e){return this.errors.filter(r=>r.severity===e)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let e=new m;return e.errors=[...this.errors],e.path=[...this.path],e}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(e=>({severity:e.severity,path:e.path!=null?this.pathToStringArray(e.path):void 0,message:e.message}))}pathToStringArray(e){let r=[];for(let t of e){if(typeof t=="string"){r.push(t);continue}r[r.length-1]+=`[${t.index}]`}return r}};l();u();l();u();l();u();var v=class{constructor(){p(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={}}){p(this,"config");p(this,"options");p(this,"errors");p(this,"_ir");p(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 x=t,{[n]:d}=x,a=A(x,[S(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:h(e)}}resolveEnvironmentName(e){if(this._ir.environments==null)return;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}case"multipleBaseUrls":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}default:h(r)}}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}validateMultiEnvironmentUrlValues(e){if(this._ir.environments==null)return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let t=r.environments[0];if(t==null)return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let n=new Set(R(t.urls));for(let i of R(e))n.has(i)&&n.delete(i);return n.size>0?(this.errors.add({severity:o.Critical,message:`The provided environments are invalid; got: [${Object.keys(e).join(", ")}], expected: [${R(t.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:e}){if(typeof e!="number"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"number",value:e}).message});return}return e}getValueAsBoolean({value:e}){if(typeof e!="boolean"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"boolean",value:e}).message});return}return e}getValueAsString({value:e}){if(typeof e!="string"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"string",value:e}).message});return}return e}isOptional(e){switch(e.type){case"nullable":return this.isOptional(e.value);case"optional":return!0;case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}isNullable(e){switch(e.type){case"nullable":return!0;case"optional":return this.isNullable(e.value);case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}newAuthMismatchError({auth:e,values:r}){return new Error(`Expected auth type ${e.type}, got ${r.type}`)}newParameterNotRecognizedError(e){return new Error(`"${e}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:e,value:r}){return new Error(`Expected ${e}, got ${typeof r}`)}includeRequestBodyInWrappedRequest({body:e,inlineFileProperties:r}){switch(e.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r});default:h(e)}}includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r}){return this.fileUploadHasBodyProperties({fileUpload:e})||r&&this.fileUploadHasFileProperties({fileUpload:e})}fileUploadHasBodyProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:h(r)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:h(r)}})}isListTypeReference(e){return e.type==="optional"?this.isListTypeReference(e.value):e.type==="list"||e.type==="set"}parsedEndpointMatches({endpoint:e,parsedEndpoint:r}){return e.location.method===r.method&&e.location.path===r.path}};l();u();var b={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};l();u();export{E as a,o as b,w as c,b as d};
2
+ //# sourceMappingURL=chunk-BN32SYGE.js.map
@@ -1,2 +1,2 @@
1
- import{e as l,f as a,g as y,h as s,l as i}from"./chunk-PYHFKEW4.js";a();y();var c=class{constructor({context:r}){l(this,"context");this.context=r}getFilePropertyInfo({body:r,value:o}){var p;let e={fileFields:[],bodyPropertyFields:[]},n=(p=this.context.getRecord(o))!=null?p:{};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:n})});break;case"fileArray":e.fileFields.push({name:this.context.getPropertyName(t.name),value:this.getArrayFileProperty({property:t,record:n})});break;case"bodyProperty":e.bodyPropertyFields.push({name:this.context.getPropertyName(t.name.name),value:this.getBodyProperty({property:t,record:n})});break;default:s(t)}return e}getSingleFileProperty({property:r,record:o}){let e=this.context.getSingleFileValue({property:r,record:o});return e==null?i.TypeLiteral.nop():i.TypeLiteral.file(e)}getArrayFileProperty({property:r,record:o}){let e=this.context.getFileArrayValues({property:r,record:o});return e==null?i.TypeLiteral.nop():i.TypeLiteral.list({values:e.map(n=>i.TypeLiteral.file(n))})}getBodyProperty({property:r,record:o}){let e=o[r.name.wireValue];return e==null?i.TypeLiteral.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:r.typeReference,value:e})}};export{c as a};
2
- //# sourceMappingURL=chunk-3QAUV5WT.js.map
1
+ import{e as l,f as a,g as y,h as s,l as i}from"./chunk-34WVNBJS.js";a();y();var c=class{constructor({context:r}){l(this,"context");this.context=r}getFilePropertyInfo({body:r,value:o}){var p;let e={fileFields:[],bodyPropertyFields:[]},n=(p=this.context.getRecord(o))!=null?p:{};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:n})});break;case"fileArray":e.fileFields.push({name:this.context.getPropertyName(t.name),value:this.getArrayFileProperty({property:t,record:n})});break;case"bodyProperty":e.bodyPropertyFields.push({name:this.context.getPropertyName(t.name.name),value:this.getBodyProperty({property:t,record:n})});break;default:s(t)}return e}getSingleFileProperty({property:r,record:o}){let e=this.context.getSingleFileValue({property:r,record:o});return e==null?i.TypeLiteral.nop():i.TypeLiteral.file(e)}getArrayFileProperty({property:r,record:o}){let e=this.context.getFileArrayValues({property:r,record:o});return e==null?i.TypeLiteral.nop():i.TypeLiteral.list({values:e.map(n=>i.TypeLiteral.file(n))})}getBodyProperty({property:r,record:o}){let e=o[r.name.wireValue];return e==null?i.TypeLiteral.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:r.typeReference,value:e})}};export{c as a};
2
+ //# sourceMappingURL=chunk-F7LTKJMT.js.map
@@ -1,2 +1,2 @@
1
- import{a as g}from"./chunk-WWRNGEPJ.js";import{c as l}from"./chunk-RC5VUNGI.js";import{a as f}from"./chunk-3QAUV5WT.js";import{e as r,f as m,g as p,i as o,j as c,l as s,m as u}from"./chunk-PYHFKEW4.js";m();p();var h=["use","clone","list"],d="Requests",y="Types",C=class i extends l{constructor({ir:e,config:t}){var n;super({ir:e,config:t});r(this,"ir");r(this,"customConfig");r(this,"dynamicTypeLiteralMapper");r(this,"filePropertyMapper");r(this,"rootNamespace");this.ir=e,this.customConfig=t.customConfig!=null?t.customConfig:void 0,this.dynamicTypeLiteralMapper=new g({context:this}),this.filePropertyMapper=new f({context:this}),this.rootNamespace=F({organization:t.organization,namespaceOverride:(n=this.customConfig)==null?void 0:n.namespace})}clone(){return new i({ir:this.ir,config:this.config})}getParameterName(e){return this.prependUnderscoreIfNeeded(e.camelCase.unsafeName)}getPropertyName(e){return this.prependUnderscoreIfNeeded(e.camelCase.unsafeName)}getMethodName(e){let t=e.camelCase.unsafeName;return h.includes(t)?t:e.camelCase.safeName}getClassName(e){return u(e.pascalCase.safeName)}getRootClientClassName(){var e,t,n;return((e=this.customConfig)==null?void 0:e.clientName)!=null?this.customConfig.clientName:((t=this.customConfig)==null?void 0:t["client-class-name"])!=null?(n=this.customConfig)==null?void 0:n["client-class-name"]:this.getComputedClientName()}getEnvironmentsClassReference(){return s.classReference({name:"Environments",namespace:this.rootNamespace})}getRequestNamespace(e){return this.getNamespace(e,d)}getTypesNamespace(e){return this.getNamespace(e,y)}getNamespace(e,t){let n=e.allParts.map(N=>N.pascalCase.safeName);return n=t!=null?[...n,t]:n,[this.rootNamespace,...n].join("\\")}getEnvironmentClassAccessFromID(e){let t=this.resolveEnvironmentName(e);if(t!=null)return s.codeblock(n=>{n.writeNode(this.getEnvironmentClassReference(t)),n.write("::"),n.write(this.getClassName(t))})}getEnvironmentClassReference(e){return s.classReference({name:"Environments",namespace:this.rootNamespace})}prependUnderscoreIfNeeded(e){return/^[a-zA-Z_]/.test(e)?e:`_${e}`}getComputedClientName(){return`${this.getOrganizationPascalCase()}Client`}getOrganizationPascalCase(){return`${o(c(this.config.organization))}`}};function F({organization:i,namespaceOverride:a}){return a!=null?a:`${o(c(i))}`}export{C as a};
2
- //# sourceMappingURL=chunk-E5GKCY37.js.map
1
+ import{a as g}from"./chunk-Q7QB5SA5.js";import{c as l}from"./chunk-BN32SYGE.js";import{a as f}from"./chunk-F7LTKJMT.js";import{e as r,f as m,g as p,i as o,j as c,l as s,m as u}from"./chunk-34WVNBJS.js";m();p();var h=["use","clone","list"],d="Requests",y="Types",C=class i extends l{constructor({ir:e,config:t}){var n;super({ir:e,config:t});r(this,"ir");r(this,"customConfig");r(this,"dynamicTypeLiteralMapper");r(this,"filePropertyMapper");r(this,"rootNamespace");this.ir=e,this.customConfig=t.customConfig!=null?t.customConfig:void 0,this.dynamicTypeLiteralMapper=new g({context:this}),this.filePropertyMapper=new f({context:this}),this.rootNamespace=F({organization:t.organization,namespaceOverride:(n=this.customConfig)==null?void 0:n.namespace})}clone(){return new i({ir:this.ir,config:this.config})}getParameterName(e){return this.prependUnderscoreIfNeeded(e.camelCase.unsafeName)}getPropertyName(e){return this.prependUnderscoreIfNeeded(e.camelCase.unsafeName)}getMethodName(e){let t=e.camelCase.unsafeName;return h.includes(t)?t:e.camelCase.safeName}getClassName(e){return u(e.pascalCase.safeName)}getRootClientClassName(){var e,t,n;return((e=this.customConfig)==null?void 0:e.clientName)!=null?this.customConfig.clientName:((t=this.customConfig)==null?void 0:t["client-class-name"])!=null?(n=this.customConfig)==null?void 0:n["client-class-name"]:this.getComputedClientName()}getEnvironmentsClassReference(){return s.classReference({name:"Environments",namespace:this.rootNamespace})}getRequestNamespace(e){return this.getNamespace(e,d)}getTypesNamespace(e){return this.getNamespace(e,y)}getNamespace(e,t){let n=e.allParts.map(N=>N.pascalCase.safeName);return n=t!=null?[...n,t]:n,[this.rootNamespace,...n].join("\\")}getEnvironmentClassAccessFromID(e){let t=this.resolveEnvironmentName(e);if(t!=null)return s.codeblock(n=>{n.writeNode(this.getEnvironmentClassReference(t)),n.write("::"),n.write(this.getClassName(t))})}getEnvironmentClassReference(e){return s.classReference({name:"Environments",namespace:this.rootNamespace})}prependUnderscoreIfNeeded(e){return/^[a-zA-Z_]/.test(e)?e:`_${e}`}getComputedClientName(){return`${this.getOrganizationPascalCase()}Client`}getOrganizationPascalCase(){return`${o(c(this.config.organization))}`}};function F({organization:i,namespaceOverride:a}){return a!=null?a:`${o(c(i))}`}export{C as a};
2
+ //# sourceMappingURL=chunk-MZ7AWQF7.js.map
@@ -0,0 +1,4 @@
1
+ import{b as l,d as p}from"./chunk-BN32SYGE.js";import{e as F,f as I,g as x,h as m,l as i}from"./chunk-34WVNBJS.js";I();x();var A="$client",f="Example",C=`<?php
2
+
3
+ `,P=class{constructor({context:e}){F(this,"context");this.context=e}async generateSnippet({endpoint:e,request:t}){var n;let r=this.buildCodeBlock({endpoint:e,snippet:t});return C+await r.toStringAsync({namespace:f,rootNamespace:f,customConfig:(n=this.context.customConfig)!=null?n:{}})}generateSnippetSync({endpoint:e,request:t}){var n;let r=this.buildCodeBlock({endpoint:e,snippet:t});return C+r.toString({namespace:f,rootNamespace:f,customConfig:(n=this.context.customConfig)!=null?n:{}})}async generateSnippetAst({endpoint:e,request:t,options:r}){return r!=null&&r.skipClientInstantiation?this.buildCodeBlockWithoutClient({endpoint:e,snippet:t}):this.buildCodeBlock({endpoint:e,snippet:t})}buildCodeBlock({endpoint:e,snippet:t}){return i.codeblock(r=>{r.writeNodeStatement(this.constructClient({endpoint:e,snippet:t})),r.writeNodeStatement(this.callMethod({endpoint:e,snippet:t}))})}buildCodeBlockWithoutClient({endpoint:e,snippet:t}){return i.codeblock(r=>{r.writeNodeStatement(this.callMethodOnExistingClient({endpoint:e,snippet:t}))})}constructClient({endpoint:e,snippet:t}){return i.codeblock(r=>{r.write(`${A} = `),r.writeNode(this.getRootClientClassInstantiation(this.getConstructorArgs({endpoint:e,snippet:t})))})}callMethod({endpoint:e,snippet:t}){return i.invokeMethod({on:i.codeblock(A),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t}),multiline:!0})}callMethodOnExistingClient({endpoint:e,snippet:t}){let r=this.getMethodArgs({endpoint:e,snippet:t}),n=this.getRequestOptions({endpoint:e,snippet:t});return i.TypeLiteral.isNop(n)||r.push(n),i.invokeMethod({on:i.codeblock("$this->client"),method:this.getMethod({endpoint:e}),arguments_:r,multiline:!0})}getRequestOptions({endpoint:e,snippet:t}){var o;let r=(o=t.headers)!=null?o:{},n=Object.entries(r);if(n.length===0)return i.TypeLiteral.nop();let s=new Set;if(this.context.ir.headers!=null)for(let c of this.context.ir.headers)s.add(c.name.wireValue.toLowerCase());if(e.request.type==="inlined"&&e.request.headers!=null)for(let c of e.request.headers)s.add(c.name.wireValue.toLowerCase());let a=n.filter(([c])=>!s.has(c.toLowerCase()));return a.length===0?i.TypeLiteral.nop():i.TypeLiteral.map({entries:[{key:i.TypeLiteral.string("headers"),value:i.TypeLiteral.map({entries:a.map(([c,u])=>({key:i.TypeLiteral.string(c),value:i.TypeLiteral.string(String(u))}))})}]})}getConstructorArgs({endpoint:e,snippet:t}){var c;let r=[];if(e.auth!=null)if(t.auth!=null)r.push(...this.getConstructorAuthArgs({auth:e.auth,values:t.auth}));else if(e.auth.type==="inferred"){let u={type:"inferred"};r.push(...this.getConstructorInferredAuthArgs({auth:e.auth,values:u}))}else this.context.errors.add({severity:l.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`});let n=((c=this.context.ir.environments)==null?void 0:c.environments.type)==="multipleBaseUrls",s=this.getConstructorEnvironmentArg({environment:t.environment,hasMultiUrlEnvironments:n}),a=[];if(!n){let u=this.getConstructorBaseUrlArgs({baseUrl:t.baseURL,environment:t.environment});u.length>0&&a.push(...u)}this.context.errors.scope(p.Headers),this.context.ir.headers!=null&&t.headers!=null&&a.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope();let o=[...r];return s!=null&&o.push(s),a.length>0&&o.push({name:"options",assignment:i.TypeLiteral.map({entries:a.map(u=>({key:i.TypeLiteral.string(u.name),value:u.value}))})}),o}getConstructorAuthArgs({auth:e,values:t}){if(t.type!==e.type)return this.addError(this.context.newAuthMismatchError({auth:e,values:t}).message),[];switch(e.type){case"basic":return t.type==="basic"?this.getConstructorBasicAuthArgs({auth:e,values:t}):[];case"bearer":return t.type==="bearer"?this.getConstructorBearerAuthArgs({auth:e,values:t}):[];case"header":return t.type==="header"?this.getConstructorHeaderAuthArgs({auth:e,values:t}):[];case"oauth":return t.type==="oauth"?this.getConstructorOAuthArgs({auth:e,values:t}):[];case"inferred":return t.type==="inferred"?this.getConstructorInferredAuthArgs({auth:e,values:t}):[];default:m(e)}}addError(e){this.context.errors.add({severity:l.Critical,message:e})}addWarning(e){this.context.errors.add({severity:l.Warning,message:e})}getConstructorBasicAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.username),assignment:i.TypeLiteral.string(t.username)},{name:this.context.getPropertyName(e.password),assignment:i.TypeLiteral.string(t.password)}]}getConstructorEnvironmentArg({environment:e,hasMultiUrlEnvironments:t}){if(!t)return;let r=this.context.getEnvironmentsClassReference();if(e!=null){if(this.context.isSingleEnvironmentID(e)){let s=this.context.resolveEnvironmentName(e);if(s==null){this.addWarning(`Environment "${e}" was not found`);return}let a=this.context.getClassName(s);return{name:"environment",assignment:i.TypeLiteral.reference(i.codeblock(o=>{o.writeNode(r),o.write("::"),o.write(a),o.write("()")}))}}if(this.context.isMultiEnvironmentValues(e)){let s=this.resolveMultiEnvironmentName(e);if(s==null){this.addWarning("Invalid multi url environment");return}return s.type==="named"?{name:"environment",assignment:i.TypeLiteral.reference(i.codeblock(a=>{a.writeNode(r),a.write("::"),a.write(s.name),a.write("()")}))}:{name:"environment",assignment:i.TypeLiteral.reference(i.codeblock(a=>{a.writeNode(r),a.write("::custom(");let o=Object.entries(s.urls);o.forEach(([c,u],d)=>{a.write(`${c}: '${u}'`),d<o.length-1&&a.write(", ")}),a.write(")")}))}}}let n=this.getDefaultEnvironmentName();if(n!=null)return{name:"environment",assignment:i.TypeLiteral.reference(i.codeblock(s=>{s.writeNode(r),s.write("::"),s.write(n),s.write("()")}))}}getDefaultEnvironmentName(){var n;if(((n=this.context.ir.environments)==null?void 0:n.environments.type)!=="multipleBaseUrls")return;let e=this.context.ir.environments.environments;if(e.type!=="multipleBaseUrls")return;let t=e.environments;if(t.length===0)return;for(let s of t){let a=this.context.getClassName(s.name);if(a==="Production")return a}let r=t[0];if(r!=null)return this.context.getClassName(r.name)}resolveMultiEnvironmentName(e){let t=Object.keys(e);if(t.length===0||!this.context.validateMultiEnvironmentUrlValues(e))return;let r=t[0];if(r==null)return;let n=e[r];if(n==null)return;let s=this.context.resolveEnvironmentName(n);if(s!=null&&t.every(c=>{let u=e[c];return u==null?!1:this.context.resolveEnvironmentName(u)!=null&&u===n}))return{type:"named",name:this.context.getClassName(s)};let a={};for(let o of t){let c=e[o];if(c==null)continue;let u=this.getBaseUrlPropertyName(o);a[u]=c}if(Object.keys(a).length>0)return{type:"custom",urls:a}}getBaseUrlPropertyName(e){var n;if(((n=this.context.ir.environments)==null?void 0:n.environments.type)!=="multipleBaseUrls")return e;let t=this.context.ir.environments.environments;if(t.type!=="multipleBaseUrls")return e;let r=t.baseUrls.find(s=>s.id===e);return r==null?e:r.name.camelCase.safeName}getConstructorBaseUrlArgs({baseUrl:e,environment:t}){let r=this.getBaseUrlArg({baseUrl:e,environment:t});return i.TypeLiteral.isNop(r)?[]:[{name:"baseUrl",value:r}]}getBaseUrlArg({baseUrl:e,environment:t}){var r;if(e!=null&&t!=null)return this.context.errors.add({severity:l.Critical,message:"Cannot specify both baseUrl and environment options"}),i.TypeLiteral.nop();if(e!=null)return i.TypeLiteral.string(e);if(t!=null){if(this.context.isSingleEnvironmentID(t)){let n=this.context.getEnvironmentClassAccessFromID(t);return n==null?(this.context.errors.add({severity:l.Warning,message:`Environment ${JSON.stringify(t)} was not found`}),i.TypeLiteral.nop()):i.TypeLiteral.reference(i.codeblock(s=>{s.writeNode(n),s.write("->value")}))}if(((r=this.context.ir.environments)==null?void 0:r.environments.type)==="multipleBaseUrls")return i.TypeLiteral.nop()}return i.TypeLiteral.nop()}getConstructorBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.token),assignment:i.TypeLiteral.string(t.token)}]}getConstructorHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.header.name.name),assignment:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value})}]}getConstructorOAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.clientId),assignment:i.TypeLiteral.string(t.clientId)},{name:this.context.getPropertyName(e.clientSecret),assignment:i.TypeLiteral.string(t.clientSecret)}]}getConstructorInferredAuthArgs({auth:e,values:t}){return[]}getConstructorHeaderArgs({headers:e,values:t}){let r=[];for(let n of e){let s=this.getConstructorHeaderArg({header:n,value:t.value});s!=null&&r.push({name:this.context.getPropertyName(n.name.name),value:s})}return r}getConstructorHeaderArg({header:e,value:t}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t});if(!i.TypeLiteral.isNop(r))return r}getMethodArgs({endpoint:e,snippet:t}){switch(e.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:e.request,snippet:t});case"body":return this.getMethodArgsForBodyRequest({request:e.request,snippet:t});default:m(e.request)}}getMethodArgsForBodyRequest({request:e,snippet:t}){var s,a;let r=[];this.context.errors.scope(p.PathParameters);let n=[...(s=this.context.ir.pathParameters)!=null?s:[],...(a=e.pathParameters)!=null?a:[]];return n.length>0&&r.push(...this.getPathParameters({namedParameters:n,snippet:t}).map(o=>o.value)),this.context.errors.unscope(),this.context.errors.scope(p.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:m(e)}}getBytesBodyRequestArg({value:e}){return this.context.errors.add({severity:l.Critical,message:"The PHP SDK doesn't support bytes requests yet"}),i.TypeLiteral.nop()}getMethodArgsForInlinedRequest({request:e,snippet:t}){var c,u,d,h;let r=[],n=(u=(c=this.context.customConfig)==null?void 0:c.inlinePathParameters)!=null?u:!1;this.context.errors.scope(p.PathParameters);let s=[],a=[...(d=this.context.ir.pathParameters)!=null?d:[],...(h=e.pathParameters)!=null?h:[]];a.length>0&&s.push(...this.getPathParameters({namedParameters:a,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(p.RequestBody);let o=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:n})||r.push(...s.map(g=>g.value)),this.context.needsRequestParameter({request:e,inlinePathParameters:n,inlineFileProperties:!0})&&r.push(this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:n})?s:[],filePropertyInfo:o})),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:n}){var d,h,g,v;this.context.errors.scope(p.QueryParameters);let a=this.context.associateQueryParametersByWireValue({parameters:(d=e.queryParameters)!=null?d:[],values:(h=t.queryParameters)!=null?h:{}}).map(y=>({name:this.context.getPropertyName(y.name.name),value:this.context.dynamicTypeLiteralMapper.convert(y)}));this.context.errors.unscope(),this.context.errors.scope(p.Headers);let c=this.context.associateByWireValue({parameters:(g=e.headers)!=null?g:[],values:(v=t.headers)!=null?v:{}}).map(y=>({name:this.context.getPropertyName(y.name.name),value:this.context.dynamicTypeLiteralMapper.convert(y)}));this.context.errors.unscope(),this.context.errors.scope(p.RequestBody);let u=e.body!=null?this.getInlinedRequestBodyConstructorFields({body:e.body,value:t.requestBody,filePropertyInfo:n}):[];return this.context.errors.unscope(),i.TypeLiteral.class_({reference:i.classReference({name:this.context.getClassName(e.declaration.name),namespace:this.context.getRequestNamespace(e.declaration.fernFilepath)}),fields:[...r,...a,...c,...u]})}getInlinedRequestBodyConstructorFields({body:e,value:t,filePropertyInfo:r}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyConstructorFields({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyConstructorField({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyConstructorFields({filePropertyInfo:r});default:m(e)}}getFileUploadRequestBodyConstructorFields({filePropertyInfo:e}){return[...e.fileFields,...e.bodyPropertyFields]}getReferencedRequestBodyPropertyConstructorField({body:e,value:t}){return{name:this.context.getPropertyName(e.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:e.bodyType,value:t})}}getReferencedRequestBodyPropertyTypeLiteral({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t});default:m(e)}}getInlinedRequestBodyPropertyConstructorFields({parameters:e,value:t}){var s;let r=[],n=this.context.associateByWireValue({parameters:e,values:(s=this.context.getRecord(t))!=null?s:{}});for(let a of n)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=[],n=this.context.associateByWireValue({parameters:e,values:(s=t.pathParameters)!=null?s:{}});for(let a of n)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.getPropertyName(t)).join("->")}->${this.context.getMethodName(e.declaration.name)}`:this.context.getMethodName(e.declaration.name)}getRootClientClassInstantiation(e){return i.instantiateClass({classReference:i.classReference({name:this.context.getRootClientClassName(),namespace:this.context.rootNamespace}),arguments_:e,multiline:!0})}};export{P as a};
4
+ //# sourceMappingURL=chunk-P7HYTUQU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/EndpointSnippetGenerator.ts"],"sourcesContent":["import { AbstractAstNode, NamedArgument, Options, Scope, Severity } from \"@fern-api/browser-compatible-base-generator\";\nimport { assertNever } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { php } from \"@fern-api/php-codegen\";\n\nimport { DynamicSnippetsGeneratorContext } from \"./context/DynamicSnippetsGeneratorContext\";\nimport { FilePropertyInfo } from \"./context/FilePropertyMapper\";\n\nconst CLIENT_VAR_NAME = \"$client\";\nconst SNIPPET_NAMESPACE = \"Example\";\nconst PHP_PREFIX = \"<?php\\n\\n\";\n\nexport class EndpointSnippetGenerator {\n private context: DynamicSnippetsGeneratorContext;\n\n constructor({ context }: { context: DynamicSnippetsGeneratorContext }) {\n this.context = context;\n }\n\n public async generateSnippet({\n endpoint,\n request\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n }): Promise<string> {\n const code = this.buildCodeBlock({ endpoint, snippet: request });\n return (\n PHP_PREFIX +\n (await code.toStringAsync({\n namespace: SNIPPET_NAMESPACE,\n rootNamespace: SNIPPET_NAMESPACE,\n customConfig: this.context.customConfig ?? {}\n }))\n );\n }\n\n public generateSnippetSync({\n endpoint,\n request\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n }): string {\n const code = this.buildCodeBlock({ endpoint, snippet: request });\n return (\n PHP_PREFIX +\n code.toString({\n namespace: SNIPPET_NAMESPACE,\n rootNamespace: SNIPPET_NAMESPACE,\n customConfig: this.context.customConfig ?? {}\n })\n );\n }\n\n public async generateSnippetAst({\n endpoint,\n request,\n options\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n options?: Options;\n }): Promise<AbstractAstNode> {\n if (options?.skipClientInstantiation) {\n return this.buildCodeBlockWithoutClient({ endpoint, snippet: request });\n }\n return this.buildCodeBlock({ endpoint, snippet: request });\n }\n\n public buildCodeBlock({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.AstNode {\n return php.codeblock((writer) => {\n writer.writeNodeStatement(this.constructClient({ endpoint, snippet }));\n writer.writeNodeStatement(this.callMethod({ endpoint, snippet }));\n });\n }\n\n public buildCodeBlockWithoutClient({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.AstNode {\n return php.codeblock((writer) => {\n // Skip client instantiation - assume client is already available as $this->client\n writer.writeNodeStatement(this.callMethodOnExistingClient({ endpoint, snippet }));\n });\n }\n\n private constructClient({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.CodeBlock {\n return php.codeblock((writer) => {\n writer.write(`${CLIENT_VAR_NAME} = `);\n writer.writeNode(this.getRootClientClassInstantiation(this.getConstructorArgs({ endpoint, snippet })));\n });\n }\n\n private callMethod({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.MethodInvocation {\n return php.invokeMethod({\n on: php.codeblock(CLIENT_VAR_NAME),\n method: this.getMethod({ endpoint }),\n arguments_: this.getMethodArgs({ endpoint, snippet }),\n multiline: true\n });\n }\n\n private callMethodOnExistingClient({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.MethodInvocation {\n const args = this.getMethodArgs({ endpoint, snippet });\n const requestOptions = this.getRequestOptions({ endpoint, snippet });\n if (!php.TypeLiteral.isNop(requestOptions)) {\n args.push(requestOptions);\n }\n return php.invokeMethod({\n on: php.codeblock(\"$this->client\"),\n method: this.getMethod({ endpoint }),\n arguments_: args,\n multiline: true\n });\n }\n\n /**\n * Builds request options from snippet headers for per-request options.\n * This is used when generating snippets for existing clients (e.g., wire tests)\n * where headers should be passed as method call options rather than client constructor options.\n * Only includes headers that are NOT already mapped to the request directly (i.e., not defined in the IR).\n */\n private getRequestOptions({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.TypeLiteral {\n const headers = snippet.headers ?? {};\n const entries = Object.entries(headers);\n if (entries.length === 0) {\n return php.TypeLiteral.nop();\n }\n\n // Build a set of header names that are already mapped to the request directly\n const mappedHeaderNames = new Set<string>();\n\n // Add global headers from IR\n if (this.context.ir.headers != null) {\n for (const header of this.context.ir.headers) {\n mappedHeaderNames.add(header.name.wireValue.toLowerCase());\n }\n }\n\n // Add endpoint-level headers from inlined request\n if (endpoint.request.type === \"inlined\" && endpoint.request.headers != null) {\n for (const header of endpoint.request.headers) {\n mappedHeaderNames.add(header.name.wireValue.toLowerCase());\n }\n }\n\n // Filter out headers that are already mapped to the request\n const unmappedEntries = entries.filter(([name]) => !mappedHeaderNames.has(name.toLowerCase()));\n if (unmappedEntries.length === 0) {\n return php.TypeLiteral.nop();\n }\n\n return php.TypeLiteral.map({\n entries: [\n {\n key: php.TypeLiteral.string(\"headers\"),\n value: php.TypeLiteral.map({\n entries: unmappedEntries.map(([name, value]) => ({\n key: php.TypeLiteral.string(name),\n value: php.TypeLiteral.string(String(value))\n }))\n })\n }\n ]\n });\n }\n\n private getConstructorArgs({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): NamedArgument[] {\n const authArgs: NamedArgument[] = [];\n if (endpoint.auth != null) {\n if (snippet.auth != null) {\n authArgs.push(...this.getConstructorAuthArgs({ auth: endpoint.auth, values: snippet.auth }));\n } else {\n // Provide default auth values for endpoints that require authentication\n if (endpoint.auth.type === \"inferred\") {\n // For inferred auth, provide default test values\n const defaultInferredAuthValues: FernIr.dynamic.InferredAuthValues = {\n type: \"inferred\"\n };\n authArgs.push(\n ...this.getConstructorInferredAuthArgs({\n auth: endpoint.auth,\n values: defaultInferredAuthValues\n })\n );\n } else {\n this.context.errors.add({\n severity: Severity.Warning,\n message: `Auth with ${endpoint.auth.type} configuration is required for this endpoint`\n });\n }\n }\n }\n\n const hasMultiUrlEnvironments = this.context.ir.environments?.environments.type === \"multipleBaseUrls\";\n const environmentArg = this.getConstructorEnvironmentArg({\n environment: snippet.environment,\n hasMultiUrlEnvironments\n });\n\n const optionArgs: php.ConstructorField[] = [];\n\n if (!hasMultiUrlEnvironments) {\n const baseUrlArgs = this.getConstructorBaseUrlArgs({\n baseUrl: snippet.baseURL,\n environment: snippet.environment\n });\n if (baseUrlArgs.length > 0) {\n optionArgs.push(...baseUrlArgs);\n }\n }\n\n this.context.errors.scope(Scope.Headers);\n if (this.context.ir.headers != null && snippet.headers != null) {\n optionArgs.push(\n ...this.getConstructorHeaderArgs({ headers: this.context.ir.headers, values: snippet.headers })\n );\n }\n this.context.errors.unscope();\n\n const args: NamedArgument[] = [...authArgs];\n\n if (environmentArg != null) {\n args.push(environmentArg);\n }\n\n if (optionArgs.length > 0) {\n args.push({\n name: \"options\",\n assignment: php.TypeLiteral.map({\n entries: optionArgs.map((arg) => ({\n key: php.TypeLiteral.string(arg.name),\n value: arg.value\n }))\n })\n });\n }\n\n return args;\n }\n\n private getConstructorAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.Auth;\n values: FernIr.dynamic.AuthValues;\n }): NamedArgument[] {\n if (values.type !== auth.type) {\n this.addError(this.context.newAuthMismatchError({ auth, values }).message);\n return [];\n }\n switch (auth.type) {\n case \"basic\":\n return values.type === \"basic\" ? this.getConstructorBasicAuthArgs({ auth, values }) : [];\n case \"bearer\":\n return values.type === \"bearer\" ? this.getConstructorBearerAuthArgs({ auth, values }) : [];\n case \"header\":\n return values.type === \"header\" ? this.getConstructorHeaderAuthArgs({ auth, values }) : [];\n case \"oauth\":\n return values.type === \"oauth\" ? this.getConstructorOAuthArgs({ auth, values }) : [];\n case \"inferred\":\n return values.type === \"inferred\" ? this.getConstructorInferredAuthArgs({ auth, values }) : [];\n default:\n assertNever(auth);\n }\n }\n\n private addError(message: string): void {\n this.context.errors.add({ severity: Severity.Critical, message });\n }\n\n private addWarning(message: string): void {\n this.context.errors.add({ severity: Severity.Warning, message });\n }\n\n private getConstructorBasicAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.BasicAuth;\n values: FernIr.dynamic.BasicAuthValues;\n }): NamedArgument[] {\n return [\n {\n name: this.context.getPropertyName(auth.username),\n assignment: php.TypeLiteral.string(values.username)\n },\n {\n name: this.context.getPropertyName(auth.password),\n assignment: php.TypeLiteral.string(values.password)\n }\n ];\n }\n\n private getConstructorEnvironmentArg({\n environment,\n hasMultiUrlEnvironments\n }: {\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n hasMultiUrlEnvironments: boolean;\n }): NamedArgument | undefined {\n if (!hasMultiUrlEnvironments) {\n return undefined;\n }\n\n const environmentClassRef = this.context.getEnvironmentsClassReference();\n\n if (environment != null) {\n if (this.context.isSingleEnvironmentID(environment)) {\n const environmentName = this.context.resolveEnvironmentName(environment);\n if (environmentName == null) {\n this.addWarning(`Environment \"${environment}\" was not found`);\n return undefined;\n }\n const className = this.context.getClassName(environmentName);\n return {\n name: \"environment\",\n assignment: php.TypeLiteral.reference(\n php.codeblock((writer) => {\n writer.writeNode(environmentClassRef);\n writer.write(`::`);\n writer.write(className);\n writer.write(`()`);\n })\n )\n };\n }\n\n if (this.context.isMultiEnvironmentValues(environment)) {\n const result = this.resolveMultiEnvironmentName(environment);\n if (result == null) {\n this.addWarning(\"Invalid multi url environment\");\n return undefined;\n }\n if (result.type === \"named\") {\n return {\n name: \"environment\",\n assignment: php.TypeLiteral.reference(\n php.codeblock((writer) => {\n writer.writeNode(environmentClassRef);\n writer.write(`::`);\n writer.write(result.name);\n writer.write(`()`);\n })\n )\n };\n } else {\n return {\n name: \"environment\",\n assignment: php.TypeLiteral.reference(\n php.codeblock((writer) => {\n writer.writeNode(environmentClassRef);\n writer.write(`::custom(`);\n const entries = Object.entries(result.urls);\n entries.forEach(([paramName, url], index) => {\n writer.write(`${paramName}: '${url}'`);\n if (index < entries.length - 1) {\n writer.write(`, `);\n }\n });\n writer.write(`)`);\n })\n )\n };\n }\n }\n }\n\n const defaultName = this.getDefaultEnvironmentName();\n if (defaultName == null) {\n return undefined;\n }\n\n return {\n name: \"environment\",\n assignment: php.TypeLiteral.reference(\n php.codeblock((writer) => {\n writer.writeNode(environmentClassRef);\n writer.write(`::`);\n writer.write(defaultName);\n writer.write(`()`);\n })\n )\n };\n }\n\n private getDefaultEnvironmentName(): string | undefined {\n if (this.context.ir.environments?.environments.type !== \"multipleBaseUrls\") {\n return undefined;\n }\n\n const environmentsConfig = this.context.ir.environments.environments;\n if (environmentsConfig.type !== \"multipleBaseUrls\") {\n return undefined;\n }\n\n const environments = environmentsConfig.environments;\n if (environments.length === 0) {\n return undefined;\n }\n\n for (const env of environments) {\n const className = this.context.getClassName(env.name);\n if (className === \"Production\") {\n return className;\n }\n }\n\n const firstEnv = environments[0];\n if (firstEnv == null) {\n return undefined;\n }\n return this.context.getClassName(firstEnv.name);\n }\n\n private resolveMultiEnvironmentName(\n environment: FernIr.dynamic.MultipleEnvironmentUrlValues\n ): { type: \"named\"; name: string } | { type: \"custom\"; urls: Record<string, string> } | undefined {\n const baseUrlIds = Object.keys(environment);\n if (baseUrlIds.length === 0) {\n return undefined;\n }\n\n // Validate that all required base URLs are provided\n if (!this.context.validateMultiEnvironmentUrlValues(environment)) {\n return undefined;\n }\n\n const firstBaseUrlId = baseUrlIds[0];\n if (firstBaseUrlId == null) {\n return undefined;\n }\n\n const firstBaseUrlValue = environment[firstBaseUrlId];\n if (firstBaseUrlValue == null) {\n return undefined;\n }\n\n // Check if the first value is a valid environment ID (not just any string)\n const firstEnvironmentName = this.context.resolveEnvironmentName(firstBaseUrlValue);\n if (firstEnvironmentName != null) {\n // Check if all values point to the same environment\n const allSameEnvironment = baseUrlIds.every((baseUrlId) => {\n const value = environment[baseUrlId];\n if (value == null) {\n return false;\n }\n const envName = this.context.resolveEnvironmentName(value);\n return envName != null && value === firstBaseUrlValue;\n });\n\n if (allSameEnvironment) {\n return { type: \"named\", name: this.context.getClassName(firstEnvironmentName) };\n }\n }\n\n // Treat all values as custom URLs\n const urls: Record<string, string> = {};\n for (const baseUrlId of baseUrlIds) {\n const value = environment[baseUrlId];\n if (value == null) {\n continue;\n }\n const paramName = this.getBaseUrlPropertyName(baseUrlId);\n urls[paramName] = value;\n }\n\n if (Object.keys(urls).length > 0) {\n return { type: \"custom\", urls };\n }\n\n return undefined;\n }\n\n private getBaseUrlPropertyName(baseUrlId: string): string {\n if (this.context.ir.environments?.environments.type !== \"multipleBaseUrls\") {\n return baseUrlId;\n }\n\n const environmentsConfig = this.context.ir.environments.environments;\n if (environmentsConfig.type !== \"multipleBaseUrls\") {\n return baseUrlId;\n }\n\n const baseUrl = environmentsConfig.baseUrls.find((url) => url.id === baseUrlId);\n if (baseUrl == null) {\n return baseUrlId;\n }\n\n return baseUrl.name.camelCase.safeName;\n }\n\n private getConstructorBaseUrlArgs({\n baseUrl,\n environment\n }: {\n baseUrl: string | undefined;\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): php.ConstructorField[] {\n const baseUrlArg = this.getBaseUrlArg({ baseUrl, environment });\n if (php.TypeLiteral.isNop(baseUrlArg)) {\n return [];\n }\n return [\n {\n name: \"baseUrl\",\n value: baseUrlArg\n }\n ];\n }\n\n private getBaseUrlArg({\n baseUrl,\n environment\n }: {\n baseUrl: string | undefined;\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): php.TypeLiteral {\n if (baseUrl != null && environment != null) {\n this.context.errors.add({\n severity: Severity.Critical,\n message: \"Cannot specify both baseUrl and environment options\"\n });\n return php.TypeLiteral.nop();\n }\n if (baseUrl != null) {\n return php.TypeLiteral.string(baseUrl);\n }\n if (environment != null) {\n if (this.context.isSingleEnvironmentID(environment)) {\n const classReference = this.context.getEnvironmentClassAccessFromID(environment);\n if (classReference == null) {\n this.context.errors.add({\n severity: Severity.Warning,\n message: `Environment ${JSON.stringify(environment)} was not found`\n });\n return php.TypeLiteral.nop();\n }\n return php.TypeLiteral.reference(\n php.codeblock((writer) => {\n writer.writeNode(classReference);\n writer.write(\"->value\");\n })\n );\n }\n if (this.context.ir.environments?.environments.type === \"multipleBaseUrls\") {\n return php.TypeLiteral.nop();\n }\n }\n return php.TypeLiteral.nop();\n }\n\n private getConstructorBearerAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.BearerAuth;\n values: FernIr.dynamic.BearerAuthValues;\n }): NamedArgument[] {\n return [\n {\n name: this.context.getPropertyName(auth.token),\n assignment: php.TypeLiteral.string(values.token)\n }\n ];\n }\n\n private getConstructorHeaderAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.HeaderAuth;\n values: FernIr.dynamic.HeaderAuthValues;\n }): NamedArgument[] {\n return [\n {\n name: this.context.getPropertyName(auth.header.name.name),\n assignment: this.context.dynamicTypeLiteralMapper.convert({\n typeReference: auth.header.typeReference,\n value: values.value\n })\n }\n ];\n }\n\n private getConstructorOAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.OAuth;\n values: FernIr.dynamic.OAuthValues;\n }): NamedArgument[] {\n return [\n {\n name: this.context.getPropertyName(auth.clientId),\n assignment: php.TypeLiteral.string(values.clientId)\n },\n {\n name: this.context.getPropertyName(auth.clientSecret),\n assignment: php.TypeLiteral.string(values.clientSecret)\n }\n ];\n }\n\n private getConstructorInferredAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.InferredAuth;\n values: FernIr.dynamic.InferredAuthValues;\n }): NamedArgument[] {\n // For now, return empty array to avoid the RangeError issue\n // The inferred auth parameters should be extracted from the normal IR,\n // not the dynamic IR which doesn't contain the detailed endpoint information\n return [];\n }\n\n private getConstructorHeaderArgs({\n headers,\n values\n }: {\n headers: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): php.ConstructorField[] {\n const args: php.ConstructorField[] = [];\n for (const header of headers) {\n const arg = this.getConstructorHeaderArg({ header, value: values.value });\n if (arg != null) {\n args.push({\n name: this.context.getPropertyName(header.name.name),\n value: arg\n });\n }\n }\n return args;\n }\n\n private getConstructorHeaderArg({\n header,\n value\n }: {\n header: FernIr.dynamic.NamedParameter;\n value: unknown;\n }): php.TypeLiteral | undefined {\n const typeLiteral = this.context.dynamicTypeLiteralMapper.convert({\n typeReference: header.typeReference,\n value\n });\n if (php.TypeLiteral.isNop(typeLiteral)) {\n // Literal header values (e.g. \"X-API-Version\") should not be included in the\n // client constructor.\n return undefined;\n }\n return typeLiteral;\n }\n\n private getMethodArgs({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.TypeLiteral[] {\n switch (endpoint.request.type) {\n case \"inlined\":\n return this.getMethodArgsForInlinedRequest({ request: endpoint.request, snippet });\n case \"body\":\n return this.getMethodArgsForBodyRequest({ request: endpoint.request, snippet });\n default:\n assertNever(endpoint.request);\n }\n }\n\n private getMethodArgsForBodyRequest({\n request,\n snippet\n }: {\n request: FernIr.dynamic.BodyRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.TypeLiteral[] {\n const args: php.TypeLiteral[] = [];\n\n this.context.errors.scope(Scope.PathParameters);\n const pathParameters = [...(this.context.ir.pathParameters ?? []), ...(request.pathParameters ?? [])];\n if (pathParameters.length > 0) {\n args.push(\n ...this.getPathParameters({ namedParameters: pathParameters, snippet }).map((field) => field.value)\n );\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n if (request.body != null) {\n args.push(this.getBodyRequestArg({ body: request.body, value: snippet.requestBody }));\n }\n this.context.errors.unscope();\n\n return args;\n }\n\n private getBodyRequestArg({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBodyType;\n value: unknown;\n }): php.TypeLiteral {\n switch (body.type) {\n case \"bytes\": {\n return this.getBytesBodyRequestArg({ value });\n }\n case \"typeReference\":\n return this.context.dynamicTypeLiteralMapper.convert({ typeReference: body.value, value });\n default:\n assertNever(body);\n }\n }\n\n private getBytesBodyRequestArg({ value }: { value: unknown }): php.TypeLiteral {\n this.context.errors.add({\n severity: Severity.Critical,\n message: \"The PHP SDK doesn't support bytes requests yet\"\n });\n return php.TypeLiteral.nop();\n }\n\n private getMethodArgsForInlinedRequest({\n request,\n snippet\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.TypeLiteral[] {\n const args: php.TypeLiteral[] = [];\n\n const inlinePathParameters = this.context.customConfig?.inlinePathParameters ?? false;\n\n this.context.errors.scope(Scope.PathParameters);\n const pathParameterFields: php.ConstructorField[] = [];\n const pathParameters = [...(this.context.ir.pathParameters ?? []), ...(request.pathParameters ?? [])];\n if (pathParameters.length > 0) {\n pathParameterFields.push(...this.getPathParameters({ namedParameters: pathParameters, snippet }));\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const filePropertyInfo = this.getFilePropertyInfo({ request, snippet });\n this.context.errors.unscope();\n\n if (!this.context.includePathParametersInWrappedRequest({ request, inlinePathParameters })) {\n args.push(...pathParameterFields.map((field) => field.value));\n }\n\n if (\n this.context.needsRequestParameter({\n request,\n inlinePathParameters,\n inlineFileProperties: true // The PHP SDK requires inlineFileProperties.\n })\n ) {\n args.push(\n this.getInlinedRequestArg({\n request,\n snippet,\n pathParameterFields: this.context.includePathParametersInWrappedRequest({\n request,\n inlinePathParameters\n })\n ? pathParameterFields\n : [],\n filePropertyInfo\n })\n );\n }\n return args;\n }\n\n private getFilePropertyInfo({\n request,\n snippet\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): FilePropertyInfo {\n if (request.body == null || !this.context.isFileUploadRequestBody(request.body)) {\n return {\n fileFields: [],\n bodyPropertyFields: []\n };\n }\n return this.context.filePropertyMapper.getFilePropertyInfo({\n body: request.body,\n value: snippet.requestBody\n });\n }\n\n private getInlinedRequestArg({\n request,\n snippet,\n pathParameterFields,\n filePropertyInfo\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n pathParameterFields: php.ConstructorField[];\n filePropertyInfo: FilePropertyInfo;\n }): php.TypeLiteral {\n this.context.errors.scope(Scope.QueryParameters);\n const queryParameters = this.context.associateQueryParametersByWireValue({\n parameters: request.queryParameters ?? [],\n values: snippet.queryParameters ?? {}\n });\n const queryParameterFields = queryParameters.map((queryParameter) => ({\n name: this.context.getPropertyName(queryParameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(queryParameter)\n }));\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.Headers);\n const headers = this.context.associateByWireValue({\n parameters: request.headers ?? [],\n values: snippet.headers ?? {}\n });\n const headerFields = headers.map((header) => ({\n name: this.context.getPropertyName(header.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(header)\n }));\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const requestBodyFields =\n request.body != null\n ? this.getInlinedRequestBodyConstructorFields({\n body: request.body,\n value: snippet.requestBody,\n filePropertyInfo\n })\n : [];\n this.context.errors.unscope();\n\n return php.TypeLiteral.class_({\n reference: php.classReference({\n name: this.context.getClassName(request.declaration.name),\n namespace: this.context.getRequestNamespace(request.declaration.fernFilepath)\n }),\n fields: [...pathParameterFields, ...queryParameterFields, ...headerFields, ...requestBodyFields]\n });\n }\n\n private getInlinedRequestBodyConstructorFields({\n body,\n value,\n filePropertyInfo\n }: {\n body: FernIr.dynamic.InlinedRequestBody;\n value: unknown;\n filePropertyInfo: FilePropertyInfo;\n }): php.ConstructorField[] {\n switch (body.type) {\n case \"properties\":\n return this.getInlinedRequestBodyPropertyConstructorFields({ parameters: body.value, value });\n case \"referenced\":\n return [this.getReferencedRequestBodyPropertyConstructorField({ body, value })];\n case \"fileUpload\":\n return this.getFileUploadRequestBodyConstructorFields({ filePropertyInfo });\n default:\n assertNever(body);\n }\n }\n\n private getFileUploadRequestBodyConstructorFields({\n filePropertyInfo\n }: {\n filePropertyInfo: FilePropertyInfo;\n }): php.ConstructorField[] {\n return [...filePropertyInfo.fileFields, ...filePropertyInfo.bodyPropertyFields];\n }\n\n private getReferencedRequestBodyPropertyConstructorField({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBody;\n value: unknown;\n }): php.ConstructorField {\n return {\n name: this.context.getPropertyName(body.bodyKey),\n value: this.getReferencedRequestBodyPropertyTypeLiteral({ body: body.bodyType, value })\n };\n }\n\n private getReferencedRequestBodyPropertyTypeLiteral({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBodyType;\n value: unknown;\n }): php.TypeLiteral {\n switch (body.type) {\n case \"bytes\":\n return this.getBytesBodyRequestArg({ value });\n case \"typeReference\":\n return this.context.dynamicTypeLiteralMapper.convert({ typeReference: body.value, value });\n default:\n assertNever(body);\n }\n }\n\n private getInlinedRequestBodyPropertyConstructorFields({\n parameters,\n value\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n value: unknown;\n }): php.ConstructorField[] {\n const fields: php.ConstructorField[] = [];\n\n const bodyProperties = this.context.associateByWireValue({\n parameters,\n values: this.context.getRecord(value) ?? {}\n });\n for (const parameter of bodyProperties) {\n fields.push({\n name: this.context.getPropertyName(parameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(parameter)\n });\n }\n\n return fields;\n }\n\n private getPathParameters({\n namedParameters,\n snippet\n }: {\n namedParameters: FernIr.dynamic.NamedParameter[];\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.ConstructorField[] {\n const args: php.ConstructorField[] = [];\n\n const pathParameters = this.context.associateByWireValue({\n parameters: namedParameters,\n values: snippet.pathParameters ?? {}\n });\n for (const parameter of pathParameters) {\n args.push({\n name: this.context.getPropertyName(parameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(parameter)\n });\n }\n\n return args;\n }\n\n private getMethod({ endpoint }: { endpoint: FernIr.dynamic.Endpoint }): string {\n if (endpoint.declaration.fernFilepath.allParts.length > 0) {\n return `${endpoint.declaration.fernFilepath.allParts\n .map((val) => this.context.getPropertyName(val))\n .join(\"->\")}->${this.context.getMethodName(endpoint.declaration.name)}`;\n }\n return this.context.getMethodName(endpoint.declaration.name);\n }\n\n private getRootClientClassInstantiation(arguments_: NamedArgument[]): php.ClassInstantiation {\n return php.instantiateClass({\n classReference: php.classReference({\n name: this.context.getRootClientClassName(),\n namespace: this.context.rootNamespace\n }),\n arguments_,\n multiline: true\n });\n }\n}\n"],"mappings":"mHAAAA,IAAAC,IAQA,IAAMC,EAAkB,UAClBC,EAAoB,UACpBC,EAAa;AAAA;AAAA,EAENC,EAAN,KAA+B,CAGlC,YAAY,CAAE,QAAAC,CAAQ,EAAiD,CAFvEC,EAAA,KAAQ,WAGJ,KAAK,QAAUD,CACnB,CAEA,MAAa,gBAAgB,CACzB,SAAAE,EACA,QAAAC,CACJ,EAGoB,CAzBxB,IAAAC,EA0BQ,IAAMC,EAAO,KAAK,eAAe,CAAE,SAAAH,EAAU,QAASC,CAAQ,CAAC,EAC/D,OACIL,EACC,MAAMO,EAAK,cAAc,CACtB,UAAWR,EACX,cAAeA,EACf,cAAcO,EAAA,KAAK,QAAQ,eAAb,KAAAA,EAA6B,CAAC,CAChD,CAAC,CAET,CAEO,oBAAoB,CACvB,SAAAF,EACA,QAAAC,CACJ,EAGW,CA3Cf,IAAAC,EA4CQ,IAAMC,EAAO,KAAK,eAAe,CAAE,SAAAH,EAAU,QAASC,CAAQ,CAAC,EAC/D,OACIL,EACAO,EAAK,SAAS,CACV,UAAWR,EACX,cAAeA,EACf,cAAcO,EAAA,KAAK,QAAQ,eAAb,KAAAA,EAA6B,CAAC,CAChD,CAAC,CAET,CAEA,MAAa,mBAAmB,CAC5B,SAAAF,EACA,QAAAC,EACA,QAAAG,CACJ,EAI6B,CACzB,OAAIA,GAAA,MAAAA,EAAS,wBACF,KAAK,4BAA4B,CAAE,SAAAJ,EAAU,QAASC,CAAQ,CAAC,EAEnE,KAAK,eAAe,CAAE,S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AuB,EAC1C,UAAW,KAAK,QAAQ,aAC5B,CAAC,EACD,WAAAkE,EACA,UAAW,EACf,CAAC,CACL,CACJ","names":["init_process","init_buffer","CLIENT_VAR_NAME","SNIPPET_NAMESPACE","PHP_PREFIX","EndpointSnippetGenerator","context","__publicField","endpoint","request","_a","code","options","snippet","php_exports","writer","args","requestOptions","headers","entries","mappedHeaderNames","header","unmappedEntries","name","value","authArgs","defaultInferredAuthValues","Severity","hasMultiUrlEnvironments","environmentArg","optionArgs","baseUrlArgs","Scope","arg","auth","values","assertNever","message","environment","environmentClassRef","environmentName","className","result","paramName","url","index","defaultName","environmentsConfig","environments","env","firstEnv","baseUrlIds","firstBaseUrlId","firstBaseUrlValue","firstEnvironmentName","baseUrlId","urls","baseUrl","baseUrlArg","classReference","typeLiteral","_b","pathParameters","field","body","_c","_d","inlinePathParameters","pathParameterFields","filePropertyInfo","queryParameterFields","queryParameter","headerFields","requestBodyFields","parameters","fields","bodyProperties","parameter","namedParameters","val","arguments_"]}
@@ -1,2 +1,2 @@
1
- import{b as s}from"./chunk-RC5VUNGI.js";import{e as p,f as l,g as u,h as c,l as i}from"./chunk-PYHFKEW4.js";l();u();var y=class{constructor({context:e}){p(this,"context");this.context=e}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?i.TypeLiteral.null():(this.context.errors.add({severity:s.Critical,message:"Expected non-null value, but got null"}),i.TypeLiteral.nop());if(e.value===void 0)return i.TypeLiteral.nop();switch(e.typeReference.type){case"list":case"set":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?i.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"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?i.TypeLiteral.nop():i.TypeLiteral.boolean(n)}case"string":{let n=this.context.getValueAsString({value:t});return n==null?i.TypeLiteral.nop():i.TypeLiteral.string(n)}default:c(e)}}convertList({list:e,value:t}){return Array.isArray(t)?i.TypeLiteral.list({values:t.map((n,r)=>{this.context.errors.scope({index:r});try{return this.convert({typeReference:e,value:n})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:s.Critical,message:`Expected array but got: ${typeof t}`}),i.TypeLiteral.nop())}convertMap({map:e,value:t}){return typeof t!="object"||t==null?(this.context.errors.add({severity:s.Critical,message:`Expected object but got: ${t==null?"null":typeof t}`}),i.TypeLiteral.nop()):i.TypeLiteral.map({entries:Object.entries(t).map(([n,r])=>{this.context.errors.scope(n);try{return{key:this.convert({typeReference:e.key,value:n,as:"key"}),value:this.convert({typeReference:e.value,value:r})}}finally{this.context.errors.unscope()}})})}convertNamed({named:e,value:t,as:n}){switch(e.type){case"alias":return 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.convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t});default:c(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:t}){let n=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t});if(n==null)return i.TypeLiteral.nop();let r=n.singleDiscriminatedUnionType,a=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:n,unionVariant:r});return a==null?i.TypeLiteral.nop():i.TypeLiteral.reference(i.codeblock(o=>{o.writeNode(i.invokeMethod({on:i.classReference({name:this.context.getClassName(e.declaration.name),namespace:this.context.getTypesNamespace(e.declaration.fernFilepath)}),method:this.context.getMethodName(r.discriminantValue.name),arguments_:this.convertDiscriminatedUnionVariantArgs({discriminatedUnionTypeInstance:n,unionVariant:r,unionProperties:a}),static_:!0}))}))}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:e,unionVariant:t}){switch(t.type){case"samePropertiesAsObject":{let n=this.context.resolveNamedType({typeId:t.typeId});if(n==null)return;let r=this.convertNamed({named:n,value:e.value});if(!r.isClass()){this.context.errors.add({severity:s.Critical,message:"Internal error; expected union value to be an object"});return}return r.asClassOrThrow().fields}case"singleProperty":try{this.context.errors.scope(t.discriminantValue.wireValue);let n=this.context.getRecord(e.value);return n==null?[{name:this.context.getPropertyName(t.discriminantValue.name),value:this.convert({typeReference:t.typeReference,value:e.value})}]:[{name:this.context.getPropertyName(t.discriminantValue.name),value:this.convert({typeReference:t.typeReference,value:n[t.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return[];default:c(t)}}convertDiscriminatedUnionVariantArgs({discriminatedUnionTypeInstance:e,unionVariant:t,unionProperties:n}){let r=this.getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t});if(t.type==="singleProperty"&&this.context.getRecord(e.value)==null&&n.length===1)return[...r,this.convert({typeReference:t.typeReference,value:e.value})];if(t.type==="samePropertiesAsObject"){let a=this.context.resolveNamedType({typeId:t.typeId});return a==null?[]:[...r,i.TypeLiteral.class_({reference:i.classReference({name:this.context.getClassName(a.declaration.name),namespace:this.context.getTypesNamespace(a.declaration.fernFilepath)}),fields:n})]}return r}getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t}){var r,a;return this.context.associateByWireValue({parameters:(r=t.properties)!=null?r:[],values:(a=this.context.getRecord(e.value))!=null?a:{},ignoreMissingParameters:!0}).map(o=>{this.context.errors.scope(o.name.wireValue);try{return this.convert(o)}finally{this.context.errors.unscope()}})}convertObject({object_:e,value:t}){var r;let n=this.context.associateByWireValue({parameters:e.properties,values:(r=this.context.getRecord(t))!=null?r:{}});return i.TypeLiteral.class_({reference:i.classReference({name:this.context.getClassName(e.declaration.name),namespace:this.context.getTypesNamespace(e.declaration.fernFilepath)}),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.getEnumValueName({enum_:e,value:t});return n==null?i.TypeLiteral.nop():i.TypeLiteral.reference(i.codeblock(r=>{r.writeNode(i.classReference({name:this.context.getClassName(e.declaration.name),namespace:this.context.getTypesNamespace(e.declaration.fernFilepath)})),r.write("::"),r.write(n),r.write("->value")}))}getEnumValueName({enum_:e,value:t}){if(typeof t!="string"){this.context.errors.add({severity:s.Critical,message:`Expected enum value string, got: ${typeof t}`});return}let n=e.values.find(r=>r.wireValue===t);if(n==null){this.context.errors.add({severity:s.Critical,message:`An enum value named "${t}" does not exist in this context`});return}return this.context.getClassName(n.name)}convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t}){let n=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t});return n==null?i.TypeLiteral.nop():n}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t}){for(let n of e.types)try{return this.convert({typeReference:n,value:t})}catch(r){continue}this.context.errors.add({severity:s.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof t}" value`})}convertUnknown({value:e}){return i.TypeLiteral.unknown(e)}convertPrimitive({primitive:e,value:t,as:n}){switch(e){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let r=this.getValueAsNumber({value:t,as:n});return r==null?i.TypeLiteral.nop():i.TypeLiteral.number(r)}case"FLOAT":case"DOUBLE":{let r=this.getValueAsNumber({value:t});return r==null?i.TypeLiteral.nop():i.TypeLiteral.float(r)}case"BOOLEAN":{let r=this.getValueAsBoolean({value:t,as:n});return r==null?i.TypeLiteral.nop():i.TypeLiteral.boolean(r)}case"DATE":case"DATE_TIME":{let r=this.context.getValueAsString({value:t});return r==null?i.TypeLiteral.nop():i.TypeLiteral.datetime(r)}case"BASE_64":case"UUID":case"BIG_INTEGER":case"STRING":{let r=this.context.getValueAsString({value:t});return r==null?i.TypeLiteral.nop():i.TypeLiteral.string(r)}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{y as a};
2
- //# sourceMappingURL=chunk-WWRNGEPJ.js.map
1
+ import{b as s}from"./chunk-BN32SYGE.js";import{e as p,f as l,g as u,h as c,l as i}from"./chunk-34WVNBJS.js";l();u();var y=class{constructor({context:e}){p(this,"context");this.context=e}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?i.TypeLiteral.null():(this.context.errors.add({severity:s.Critical,message:"Expected non-null value, but got null"}),i.TypeLiteral.nop());if(e.value===void 0)return i.TypeLiteral.nop();switch(e.typeReference.type){case"list":case"set":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?i.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"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?i.TypeLiteral.nop():i.TypeLiteral.boolean(n)}case"string":{let n=this.context.getValueAsString({value:t});return n==null?i.TypeLiteral.nop():i.TypeLiteral.string(n)}default:c(e)}}convertList({list:e,value:t}){return Array.isArray(t)?i.TypeLiteral.list({values:t.map((n,r)=>{this.context.errors.scope({index:r});try{return this.convert({typeReference:e,value:n})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:s.Critical,message:`Expected array but got: ${typeof t}`}),i.TypeLiteral.nop())}convertMap({map:e,value:t}){return typeof t!="object"||t==null?(this.context.errors.add({severity:s.Critical,message:`Expected object but got: ${t==null?"null":typeof t}`}),i.TypeLiteral.nop()):i.TypeLiteral.map({entries:Object.entries(t).map(([n,r])=>{this.context.errors.scope(n);try{return{key:this.convert({typeReference:e.key,value:n,as:"key"}),value:this.convert({typeReference:e.value,value:r})}}finally{this.context.errors.unscope()}})})}convertNamed({named:e,value:t,as:n}){switch(e.type){case"alias":return 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.convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t});default:c(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:t}){let n=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t});if(n==null)return i.TypeLiteral.nop();let r=n.singleDiscriminatedUnionType,a=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:n,unionVariant:r});return a==null?i.TypeLiteral.nop():i.TypeLiteral.reference(i.codeblock(o=>{o.writeNode(i.invokeMethod({on:i.classReference({name:this.context.getClassName(e.declaration.name),namespace:this.context.getTypesNamespace(e.declaration.fernFilepath)}),method:this.context.getMethodName(r.discriminantValue.name),arguments_:this.convertDiscriminatedUnionVariantArgs({discriminatedUnionTypeInstance:n,unionVariant:r,unionProperties:a}),static_:!0}))}))}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:e,unionVariant:t}){switch(t.type){case"samePropertiesAsObject":{let n=this.context.resolveNamedType({typeId:t.typeId});if(n==null)return;let r=this.convertNamed({named:n,value:e.value});if(!r.isClass()){this.context.errors.add({severity:s.Critical,message:"Internal error; expected union value to be an object"});return}return r.asClassOrThrow().fields}case"singleProperty":try{this.context.errors.scope(t.discriminantValue.wireValue);let n=this.context.getRecord(e.value);return n==null?[{name:this.context.getPropertyName(t.discriminantValue.name),value:this.convert({typeReference:t.typeReference,value:e.value})}]:[{name:this.context.getPropertyName(t.discriminantValue.name),value:this.convert({typeReference:t.typeReference,value:n[t.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return[];default:c(t)}}convertDiscriminatedUnionVariantArgs({discriminatedUnionTypeInstance:e,unionVariant:t,unionProperties:n}){let r=this.getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t});if(t.type==="singleProperty"&&this.context.getRecord(e.value)==null&&n.length===1)return[...r,this.convert({typeReference:t.typeReference,value:e.value})];if(t.type==="samePropertiesAsObject"){let a=this.context.resolveNamedType({typeId:t.typeId});return a==null?[]:[...r,i.TypeLiteral.class_({reference:i.classReference({name:this.context.getClassName(a.declaration.name),namespace:this.context.getTypesNamespace(a.declaration.fernFilepath)}),fields:n})]}return r}getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t}){var r,a;return this.context.associateByWireValue({parameters:(r=t.properties)!=null?r:[],values:(a=this.context.getRecord(e.value))!=null?a:{},ignoreMissingParameters:!0}).map(o=>{this.context.errors.scope(o.name.wireValue);try{return this.convert(o)}finally{this.context.errors.unscope()}})}convertObject({object_:e,value:t}){var r;let n=this.context.associateByWireValue({parameters:e.properties,values:(r=this.context.getRecord(t))!=null?r:{}});return i.TypeLiteral.class_({reference:i.classReference({name:this.context.getClassName(e.declaration.name),namespace:this.context.getTypesNamespace(e.declaration.fernFilepath)}),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.getEnumValueName({enum_:e,value:t});return n==null?i.TypeLiteral.nop():i.TypeLiteral.reference(i.codeblock(r=>{r.writeNode(i.classReference({name:this.context.getClassName(e.declaration.name),namespace:this.context.getTypesNamespace(e.declaration.fernFilepath)})),r.write("::"),r.write(n),r.write("->value")}))}getEnumValueName({enum_:e,value:t}){if(typeof t!="string"){this.context.errors.add({severity:s.Critical,message:`Expected enum value string, got: ${typeof t}`});return}let n=e.values.find(r=>r.wireValue===t);if(n==null){this.context.errors.add({severity:s.Critical,message:`An enum value named "${t}" does not exist in this context`});return}return this.context.getClassName(n.name)}convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t}){let n=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t});return n==null?i.TypeLiteral.nop():n}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t}){for(let n of e.types)try{return this.convert({typeReference:n,value:t})}catch(r){continue}this.context.errors.add({severity:s.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof t}" value`})}convertUnknown({value:e}){return i.TypeLiteral.unknown(e)}convertPrimitive({primitive:e,value:t,as:n}){switch(e){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let r=this.getValueAsNumber({value:t,as:n});return r==null?i.TypeLiteral.nop():i.TypeLiteral.number(r)}case"FLOAT":case"DOUBLE":{let r=this.getValueAsNumber({value:t});return r==null?i.TypeLiteral.nop():i.TypeLiteral.float(r)}case"BOOLEAN":{let r=this.getValueAsBoolean({value:t,as:n});return r==null?i.TypeLiteral.nop():i.TypeLiteral.boolean(r)}case"DATE":case"DATE_TIME":{let r=this.context.getValueAsString({value:t});return r==null?i.TypeLiteral.nop():i.TypeLiteral.datetime(r)}case"BASE_64":case"UUID":case"BIG_INTEGER":case"STRING":{let r=this.context.getValueAsString({value:t});return r==null?i.TypeLiteral.nop():i.TypeLiteral.string(r)}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{y as a};
2
+ //# sourceMappingURL=chunk-Q7QB5SA5.js.map
@@ -1,2 +1,2 @@
1
- import{a as o}from"./chunk-7RBMVIRH.js";import{a as i}from"./chunk-E5GKCY37.js";import{a as p}from"./chunk-RC5VUNGI.js";import{f as t,g as r}from"./chunk-PYHFKEW4.js";t();r();var a=class extends p{constructor({ir:e,config:n}){super(new i({ir:e,config:n}))}async generate(e){return super.generate(e)}generateSync(e){return super.generateSync(e)}async generateSnippetAst(e,n){return await super.generateSnippetAst(e,n)}createSnippetGenerator(e){return new o({context:e})}};export{a};
2
- //# sourceMappingURL=chunk-EBGZVRNQ.js.map
1
+ import{a as o}from"./chunk-P7HYTUQU.js";import{a as i}from"./chunk-MZ7AWQF7.js";import{a as p}from"./chunk-BN32SYGE.js";import{f as t,g as r}from"./chunk-34WVNBJS.js";t();r();var a=class extends p{constructor({ir:e,config:n}){super(new i({ir:e,config:n}))}async generate(e){return super.generate(e)}generateSync(e){return super.generateSync(e)}async generateSnippetAst(e,n){return await super.generateSnippetAst(e,n)}createSnippetGenerator(e){return new o({context:e})}};export{a};
2
+ //# sourceMappingURL=chunk-U6JJRNQH.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-E5GKCY37.js";import"../chunk-WWRNGEPJ.js";import"../chunk-RC5VUNGI.js";import"../chunk-3QAUV5WT.js";import"../chunk-PYHFKEW4.js";export{a as DynamicSnippetsGeneratorContext};
1
+ import{a}from"../chunk-MZ7AWQF7.js";import"../chunk-Q7QB5SA5.js";import"../chunk-BN32SYGE.js";import"../chunk-F7LTKJMT.js";import"../chunk-34WVNBJS.js";export{a as DynamicSnippetsGeneratorContext};
2
2
  //# sourceMappingURL=DynamicSnippetsGeneratorContext.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-WWRNGEPJ.js";import"../chunk-RC5VUNGI.js";import"../chunk-PYHFKEW4.js";export{a as DynamicTypeLiteralMapper};
1
+ import{a}from"../chunk-Q7QB5SA5.js";import"../chunk-BN32SYGE.js";import"../chunk-34WVNBJS.js";export{a as DynamicTypeLiteralMapper};
2
2
  //# sourceMappingURL=DynamicTypeLiteralMapper.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"../chunk-3QAUV5WT.js";import"../chunk-PYHFKEW4.js";export{a as FilePropertyMapper};
1
+ import{a}from"../chunk-F7LTKJMT.js";import"../chunk-34WVNBJS.js";export{a as FilePropertyMapper};
2
2
  //# sourceMappingURL=FilePropertyMapper.js.map
package/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as o}from"./chunk-EBGZVRNQ.js";import{a as n}from"./chunk-7RBMVIRH.js";import"./chunk-E5GKCY37.js";import"./chunk-WWRNGEPJ.js";import"./chunk-RC5VUNGI.js";import"./chunk-3QAUV5WT.js";import{f as e,g as r}from"./chunk-PYHFKEW4.js";e();r();export{o as DynamicSnippetsGenerator,n as EndpointSnippetGenerator};
1
+ import{a as o}from"./chunk-U6JJRNQH.js";import{a as n}from"./chunk-P7HYTUQU.js";import"./chunk-MZ7AWQF7.js";import"./chunk-Q7QB5SA5.js";import"./chunk-BN32SYGE.js";import"./chunk-F7LTKJMT.js";import{f as e,g as r}from"./chunk-34WVNBJS.js";e();r();export{o as DynamicSnippetsGenerator,n as EndpointSnippetGenerator};
2
2
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fern-api/php-dynamic-snippets",
3
- "version": "0.0.13",
3
+ "version": "1.25.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/fern-api/fern.git",
@@ -1,4 +0,0 @@
1
- import{b as l,d as p}from"./chunk-RC5VUNGI.js";import{e as F,f as I,g as A,h as m,l as a}from"./chunk-PYHFKEW4.js";I();A();var x="$client",f="Example",P=`<?php
2
-
3
- `,C=class{constructor({context:e}){F(this,"context");this.context=e}async generateSnippet({endpoint:e,request:t}){var s;let r=this.buildCodeBlock({endpoint:e,snippet:t});return P+await r.toStringAsync({namespace:f,rootNamespace:f,customConfig:(s=this.context.customConfig)!=null?s:{}})}generateSnippetSync({endpoint:e,request:t}){var s;let r=this.buildCodeBlock({endpoint:e,snippet:t});return P+r.toString({namespace:f,rootNamespace:f,customConfig:(s=this.context.customConfig)!=null?s:{}})}async generateSnippetAst({endpoint:e,request:t,options:r}){return r!=null&&r.skipClientInstantiation?this.buildCodeBlockWithoutClient({endpoint:e,snippet:t}):this.buildCodeBlock({endpoint:e,snippet:t})}buildCodeBlock({endpoint:e,snippet:t}){return a.codeblock(r=>{r.writeNodeStatement(this.constructClient({endpoint:e,snippet:t})),r.writeNodeStatement(this.callMethod({endpoint:e,snippet:t}))})}buildCodeBlockWithoutClient({endpoint:e,snippet:t}){return a.codeblock(r=>{r.writeNodeStatement(this.callMethodOnExistingClient({endpoint:e,snippet:t}))})}constructClient({endpoint:e,snippet:t}){return a.codeblock(r=>{r.write(`${x} = `),r.writeNode(this.getRootClientClassInstantiation(this.getConstructorArgs({endpoint:e,snippet:t})))})}callMethod({endpoint:e,snippet:t}){return a.invokeMethod({on:a.codeblock(x),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t}),multiline:!0})}callMethodOnExistingClient({endpoint:e,snippet:t}){return a.invokeMethod({on:a.codeblock("$this->client"),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t}),multiline:!0})}getConstructorArgs({endpoint:e,snippet:t}){var u;let r=[];if(e.auth!=null)if(t.auth!=null)r.push(...this.getConstructorAuthArgs({auth:e.auth,values:t.auth}));else if(e.auth.type==="inferred"){let c={type:"inferred"};r.push(...this.getConstructorInferredAuthArgs({auth:e.auth,values:c}))}else this.context.errors.add({severity:l.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`});let s=((u=this.context.ir.environments)==null?void 0:u.environments.type)==="multipleBaseUrls",n=this.getConstructorEnvironmentArg({environment:t.environment,hasMultiUrlEnvironments:s}),i=[];if(!s){let c=this.getConstructorBaseUrlArgs({baseUrl:t.baseURL,environment:t.environment});c.length>0&&i.push(...c)}this.context.errors.scope(p.Headers),this.context.ir.headers!=null&&t.headers!=null&&i.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope();let o=[...r];return n!=null&&o.push(n),i.length>0&&o.push({name:"options",assignment:a.TypeLiteral.map({entries:i.map(c=>({key:a.TypeLiteral.string(c.name),value:c.value}))})}),o}getConstructorAuthArgs({auth:e,values:t}){if(t.type!==e.type)return this.addError(this.context.newAuthMismatchError({auth:e,values:t}).message),[];switch(e.type){case"basic":return t.type==="basic"?this.getConstructorBasicAuthArgs({auth:e,values:t}):[];case"bearer":return t.type==="bearer"?this.getConstructorBearerAuthArgs({auth:e,values:t}):[];case"header":return t.type==="header"?this.getConstructorHeaderAuthArgs({auth:e,values:t}):[];case"oauth":return t.type==="oauth"?this.getConstructorOAuthArgs({auth:e,values:t}):[];case"inferred":return t.type==="inferred"?this.getConstructorInferredAuthArgs({auth:e,values:t}):[];default:m(e)}}addError(e){this.context.errors.add({severity:l.Critical,message:e})}addWarning(e){this.context.errors.add({severity:l.Warning,message:e})}getConstructorBasicAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.username),assignment:a.TypeLiteral.string(t.username)},{name:this.context.getPropertyName(e.password),assignment:a.TypeLiteral.string(t.password)}]}getConstructorEnvironmentArg({environment:e,hasMultiUrlEnvironments:t}){if(!t)return;let r=this.context.getEnvironmentsClassReference();if(e!=null){if(this.context.isSingleEnvironmentID(e)){let n=this.context.resolveEnvironmentName(e);if(n==null){this.addWarning(`Environment "${e}" was not found`);return}let i=this.context.getClassName(n);return{name:"environment",assignment:a.TypeLiteral.reference(a.codeblock(o=>{o.writeNode(r),o.write("::"),o.write(i),o.write("()")}))}}if(this.context.isMultiEnvironmentValues(e)){let n=this.resolveMultiEnvironmentName(e);if(n==null){this.addWarning("Invalid multi url environment");return}return n.type==="named"?{name:"environment",assignment:a.TypeLiteral.reference(a.codeblock(i=>{i.writeNode(r),i.write("::"),i.write(n.name),i.write("()")}))}:{name:"environment",assignment:a.TypeLiteral.reference(a.codeblock(i=>{i.writeNode(r),i.write("::custom(");let o=Object.entries(n.urls);o.forEach(([u,c],d)=>{i.write(`${u}: '${c}'`),d<o.length-1&&i.write(", ")}),i.write(")")}))}}}let s=this.getDefaultEnvironmentName();if(s!=null)return{name:"environment",assignment:a.TypeLiteral.reference(a.codeblock(n=>{n.writeNode(r),n.write("::"),n.write(s),n.write("()")}))}}getDefaultEnvironmentName(){var s;if(((s=this.context.ir.environments)==null?void 0:s.environments.type)!=="multipleBaseUrls")return;let e=this.context.ir.environments.environments;if(e.type!=="multipleBaseUrls")return;let t=e.environments;if(t.length===0)return;for(let n of t){let i=this.context.getClassName(n.name);if(i==="Production")return i}let r=t[0];if(r!=null)return this.context.getClassName(r.name)}resolveMultiEnvironmentName(e){let t=Object.keys(e);if(t.length===0||!this.context.validateMultiEnvironmentUrlValues(e))return;let r=t[0];if(r==null)return;let s=e[r];if(s==null)return;let n=this.context.resolveEnvironmentName(s);if(n!=null&&t.every(u=>{let c=e[u];return c==null?!1:this.context.resolveEnvironmentName(c)!=null&&c===s}))return{type:"named",name:this.context.getClassName(n)};let i={};for(let o of t){let u=e[o];if(u==null)continue;let c=this.getBaseUrlPropertyName(o);i[c]=u}if(Object.keys(i).length>0)return{type:"custom",urls:i}}getBaseUrlPropertyName(e){var s;if(((s=this.context.ir.environments)==null?void 0:s.environments.type)!=="multipleBaseUrls")return e;let t=this.context.ir.environments.environments;if(t.type!=="multipleBaseUrls")return e;let r=t.baseUrls.find(n=>n.id===e);return r==null?e:r.name.camelCase.safeName}getConstructorBaseUrlArgs({baseUrl:e,environment:t}){let r=this.getBaseUrlArg({baseUrl:e,environment:t});return a.TypeLiteral.isNop(r)?[]:[{name:"baseUrl",value:r}]}getBaseUrlArg({baseUrl:e,environment:t}){var r;if(e!=null&&t!=null)return this.context.errors.add({severity:l.Critical,message:"Cannot specify both baseUrl and environment options"}),a.TypeLiteral.nop();if(e!=null)return a.TypeLiteral.string(e);if(t!=null){if(this.context.isSingleEnvironmentID(t)){let s=this.context.getEnvironmentClassAccessFromID(t);return s==null?(this.context.errors.add({severity:l.Warning,message:`Environment ${JSON.stringify(t)} was not found`}),a.TypeLiteral.nop()):a.TypeLiteral.reference(a.codeblock(n=>{n.writeNode(s),n.write("->value")}))}if(((r=this.context.ir.environments)==null?void 0:r.environments.type)==="multipleBaseUrls")return a.TypeLiteral.nop()}return a.TypeLiteral.nop()}getConstructorBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.token),assignment:a.TypeLiteral.string(t.token)}]}getConstructorHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.header.name.name),assignment:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value})}]}getConstructorOAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.clientId),assignment:a.TypeLiteral.string(t.clientId)},{name:this.context.getPropertyName(e.clientSecret),assignment:a.TypeLiteral.string(t.clientSecret)}]}getConstructorInferredAuthArgs({auth:e,values:t}){return[]}getConstructorHeaderArgs({headers:e,values:t}){let r=[];for(let s of e){let n=this.getConstructorHeaderArg({header:s,value:t.value});n!=null&&r.push({name:this.context.getPropertyName(s.name.name),value:n})}return r}getConstructorHeaderArg({header:e,value:t}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t});if(!a.TypeLiteral.isNop(r))return r}getMethodArgs({endpoint:e,snippet:t}){switch(e.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:e.request,snippet:t});case"body":return this.getMethodArgsForBodyRequest({request:e.request,snippet:t});default:m(e.request)}}getMethodArgsForBodyRequest({request:e,snippet:t}){var n,i;let r=[];this.context.errors.scope(p.PathParameters);let s=[...(n=this.context.ir.pathParameters)!=null?n:[],...(i=e.pathParameters)!=null?i:[]];return s.length>0&&r.push(...this.getPathParameters({namedParameters:s,snippet:t}).map(o=>o.value)),this.context.errors.unscope(),this.context.errors.scope(p.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:m(e)}}getBytesBodyRequestArg({value:e}){return this.context.errors.add({severity:l.Critical,message:"The PHP SDK doesn't support bytes requests yet"}),a.TypeLiteral.nop()}getMethodArgsForInlinedRequest({request:e,snippet:t}){var u,c,d,h;let r=[],s=(c=(u=this.context.customConfig)==null?void 0:u.inlinePathParameters)!=null?c:!1;this.context.errors.scope(p.PathParameters);let n=[],i=[...(d=this.context.ir.pathParameters)!=null?d:[],...(h=e.pathParameters)!=null?h:[]];i.length>0&&n.push(...this.getPathParameters({namedParameters:i,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(p.RequestBody);let o=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:s})||r.push(...n.map(g=>g.value)),this.context.needsRequestParameter({request:e,inlinePathParameters:s,inlineFileProperties:!0})&&r.push(this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:s})?n:[],filePropertyInfo:o})),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:s}){var d,h,g,v;this.context.errors.scope(p.QueryParameters);let i=this.context.associateQueryParametersByWireValue({parameters:(d=e.queryParameters)!=null?d:[],values:(h=t.queryParameters)!=null?h:{}}).map(y=>({name:this.context.getPropertyName(y.name.name),value:this.context.dynamicTypeLiteralMapper.convert(y)}));this.context.errors.unscope(),this.context.errors.scope(p.Headers);let u=this.context.associateByWireValue({parameters:(g=e.headers)!=null?g:[],values:(v=t.headers)!=null?v:{}}).map(y=>({name:this.context.getPropertyName(y.name.name),value:this.context.dynamicTypeLiteralMapper.convert(y)}));this.context.errors.unscope(),this.context.errors.scope(p.RequestBody);let c=e.body!=null?this.getInlinedRequestBodyConstructorFields({body:e.body,value:t.requestBody,filePropertyInfo:s}):[];return this.context.errors.unscope(),a.TypeLiteral.class_({reference:a.classReference({name:this.context.getClassName(e.declaration.name),namespace:this.context.getRequestNamespace(e.declaration.fernFilepath)}),fields:[...r,...i,...u,...c]})}getInlinedRequestBodyConstructorFields({body:e,value:t,filePropertyInfo:r}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyConstructorFields({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyConstructorField({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyConstructorFields({filePropertyInfo:r});default:m(e)}}getFileUploadRequestBodyConstructorFields({filePropertyInfo:e}){return[...e.fileFields,...e.bodyPropertyFields]}getReferencedRequestBodyPropertyConstructorField({body:e,value:t}){return{name:this.context.getPropertyName(e.bodyKey),value:this.getReferencedRequestBodyPropertyTypeLiteral({body:e.bodyType,value:t})}}getReferencedRequestBodyPropertyTypeLiteral({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeLiteralMapper.convert({typeReference:e.value,value:t});default:m(e)}}getInlinedRequestBodyPropertyConstructorFields({parameters:e,value:t}){var n;let r=[],s=this.context.associateByWireValue({parameters:e,values:(n=this.context.getRecord(t))!=null?n:{}});for(let i of s)r.push({name:this.context.getPropertyName(i.name.name),value:this.context.dynamicTypeLiteralMapper.convert(i)});return r}getPathParameters({namedParameters:e,snippet:t}){var n;let r=[],s=this.context.associateByWireValue({parameters:e,values:(n=t.pathParameters)!=null?n:{}});for(let i of s)r.push({name:this.context.getPropertyName(i.name.name),value:this.context.dynamicTypeLiteralMapper.convert(i)});return r}getMethod({endpoint:e}){return e.declaration.fernFilepath.allParts.length>0?`${e.declaration.fernFilepath.allParts.map(t=>this.context.getPropertyName(t)).join("->")}->${this.context.getMethodName(e.declaration.name)}`:this.context.getMethodName(e.declaration.name)}getRootClientClassInstantiation(e){return a.instantiateClass({classReference:a.classReference({name:this.context.getRootClientClassName(),namespace:this.context.rootNamespace}),arguments_:e,multiline:!0})}};export{C as a};
4
- //# sourceMappingURL=chunk-7RBMVIRH.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/EndpointSnippetGenerator.ts"],"sourcesContent":["import { AbstractAstNode, NamedArgument, Options, Scope, Severity } from \"@fern-api/browser-compatible-base-generator\";\nimport { assertNever } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { php } from \"@fern-api/php-codegen\";\n\nimport { DynamicSnippetsGeneratorContext } from \"./context/DynamicSnippetsGeneratorContext\";\nimport { FilePropertyInfo } from \"./context/FilePropertyMapper\";\n\nconst CLIENT_VAR_NAME = \"$client\";\nconst SNIPPET_NAMESPACE = \"Example\";\nconst PHP_PREFIX = \"<?php\\n\\n\";\n\nexport class EndpointSnippetGenerator {\n private context: DynamicSnippetsGeneratorContext;\n\n constructor({ context }: { context: DynamicSnippetsGeneratorContext }) {\n this.context = context;\n }\n\n public async generateSnippet({\n endpoint,\n request\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n }): Promise<string> {\n const code = this.buildCodeBlock({ endpoint, snippet: request });\n return (\n PHP_PREFIX +\n (await code.toStringAsync({\n namespace: SNIPPET_NAMESPACE,\n rootNamespace: SNIPPET_NAMESPACE,\n customConfig: this.context.customConfig ?? {}\n }))\n );\n }\n\n public generateSnippetSync({\n endpoint,\n request\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n }): string {\n const code = this.buildCodeBlock({ endpoint, snippet: request });\n return (\n PHP_PREFIX +\n code.toString({\n namespace: SNIPPET_NAMESPACE,\n rootNamespace: SNIPPET_NAMESPACE,\n customConfig: this.context.customConfig ?? {}\n })\n );\n }\n\n public async generateSnippetAst({\n endpoint,\n request,\n options\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n options?: Options;\n }): Promise<AbstractAstNode> {\n if (options?.skipClientInstantiation) {\n return this.buildCodeBlockWithoutClient({ endpoint, snippet: request });\n }\n return this.buildCodeBlock({ endpoint, snippet: request });\n }\n\n public buildCodeBlock({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.AstNode {\n return php.codeblock((writer) => {\n writer.writeNodeStatement(this.constructClient({ endpoint, snippet }));\n writer.writeNodeStatement(this.callMethod({ endpoint, snippet }));\n });\n }\n\n public buildCodeBlockWithoutClient({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.AstNode {\n return php.codeblock((writer) => {\n // Skip client instantiation - assume client is already available as $this->client\n writer.writeNodeStatement(this.callMethodOnExistingClient({ endpoint, snippet }));\n });\n }\n\n private constructClient({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.CodeBlock {\n return php.codeblock((writer) => {\n writer.write(`${CLIENT_VAR_NAME} = `);\n writer.writeNode(this.getRootClientClassInstantiation(this.getConstructorArgs({ endpoint, snippet })));\n });\n }\n\n private callMethod({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.MethodInvocation {\n return php.invokeMethod({\n on: php.codeblock(CLIENT_VAR_NAME),\n method: this.getMethod({ endpoint }),\n arguments_: this.getMethodArgs({ endpoint, snippet }),\n multiline: true\n });\n }\n\n private callMethodOnExistingClient({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.MethodInvocation {\n return php.invokeMethod({\n on: php.codeblock(\"$this->client\"),\n method: this.getMethod({ endpoint }),\n arguments_: this.getMethodArgs({ endpoint, snippet }),\n multiline: true\n });\n }\n\n private getConstructorArgs({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): NamedArgument[] {\n const authArgs: NamedArgument[] = [];\n if (endpoint.auth != null) {\n if (snippet.auth != null) {\n authArgs.push(...this.getConstructorAuthArgs({ auth: endpoint.auth, values: snippet.auth }));\n } else {\n // Provide default auth values for endpoints that require authentication\n if (endpoint.auth.type === \"inferred\") {\n // For inferred auth, provide default test values\n const defaultInferredAuthValues: FernIr.dynamic.InferredAuthValues = {\n type: \"inferred\"\n };\n authArgs.push(\n ...this.getConstructorInferredAuthArgs({\n auth: endpoint.auth,\n values: defaultInferredAuthValues\n })\n );\n } else {\n this.context.errors.add({\n severity: Severity.Warning,\n message: `Auth with ${endpoint.auth.type} configuration is required for this endpoint`\n });\n }\n }\n }\n\n const hasMultiUrlEnvironments = this.context.ir.environments?.environments.type === \"multipleBaseUrls\";\n const environmentArg = this.getConstructorEnvironmentArg({\n environment: snippet.environment,\n hasMultiUrlEnvironments\n });\n\n const optionArgs: php.ConstructorField[] = [];\n\n if (!hasMultiUrlEnvironments) {\n const baseUrlArgs = this.getConstructorBaseUrlArgs({\n baseUrl: snippet.baseURL,\n environment: snippet.environment\n });\n if (baseUrlArgs.length > 0) {\n optionArgs.push(...baseUrlArgs);\n }\n }\n\n this.context.errors.scope(Scope.Headers);\n if (this.context.ir.headers != null && snippet.headers != null) {\n optionArgs.push(\n ...this.getConstructorHeaderArgs({ headers: this.context.ir.headers, values: snippet.headers })\n );\n }\n this.context.errors.unscope();\n\n const args: NamedArgument[] = [...authArgs];\n\n if (environmentArg != null) {\n args.push(environmentArg);\n }\n\n if (optionArgs.length > 0) {\n args.push({\n name: \"options\",\n assignment: php.TypeLiteral.map({\n entries: optionArgs.map((arg) => ({\n key: php.TypeLiteral.string(arg.name),\n value: arg.value\n }))\n })\n });\n }\n\n return args;\n }\n\n private getConstructorAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.Auth;\n values: FernIr.dynamic.AuthValues;\n }): NamedArgument[] {\n if (values.type !== auth.type) {\n this.addError(this.context.newAuthMismatchError({ auth, values }).message);\n return [];\n }\n switch (auth.type) {\n case \"basic\":\n return values.type === \"basic\" ? this.getConstructorBasicAuthArgs({ auth, values }) : [];\n case \"bearer\":\n return values.type === \"bearer\" ? this.getConstructorBearerAuthArgs({ auth, values }) : [];\n case \"header\":\n return values.type === \"header\" ? this.getConstructorHeaderAuthArgs({ auth, values }) : [];\n case \"oauth\":\n return values.type === \"oauth\" ? this.getConstructorOAuthArgs({ auth, values }) : [];\n case \"inferred\":\n return values.type === \"inferred\" ? this.getConstructorInferredAuthArgs({ auth, values }) : [];\n default:\n assertNever(auth);\n }\n }\n\n private addError(message: string): void {\n this.context.errors.add({ severity: Severity.Critical, message });\n }\n\n private addWarning(message: string): void {\n this.context.errors.add({ severity: Severity.Warning, message });\n }\n\n private getConstructorBasicAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.BasicAuth;\n values: FernIr.dynamic.BasicAuthValues;\n }): NamedArgument[] {\n return [\n {\n name: this.context.getPropertyName(auth.username),\n assignment: php.TypeLiteral.string(values.username)\n },\n {\n name: this.context.getPropertyName(auth.password),\n assignment: php.TypeLiteral.string(values.password)\n }\n ];\n }\n\n private getConstructorEnvironmentArg({\n environment,\n hasMultiUrlEnvironments\n }: {\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n hasMultiUrlEnvironments: boolean;\n }): NamedArgument | undefined {\n if (!hasMultiUrlEnvironments) {\n return undefined;\n }\n\n const environmentClassRef = this.context.getEnvironmentsClassReference();\n\n if (environment != null) {\n if (this.context.isSingleEnvironmentID(environment)) {\n const environmentName = this.context.resolveEnvironmentName(environment);\n if (environmentName == null) {\n this.addWarning(`Environment \"${environment}\" was not found`);\n return undefined;\n }\n const className = this.context.getClassName(environmentName);\n return {\n name: \"environment\",\n assignment: php.TypeLiteral.reference(\n php.codeblock((writer) => {\n writer.writeNode(environmentClassRef);\n writer.write(`::`);\n writer.write(className);\n writer.write(`()`);\n })\n )\n };\n }\n\n if (this.context.isMultiEnvironmentValues(environment)) {\n const result = this.resolveMultiEnvironmentName(environment);\n if (result == null) {\n this.addWarning(\"Invalid multi url environment\");\n return undefined;\n }\n if (result.type === \"named\") {\n return {\n name: \"environment\",\n assignment: php.TypeLiteral.reference(\n php.codeblock((writer) => {\n writer.writeNode(environmentClassRef);\n writer.write(`::`);\n writer.write(result.name);\n writer.write(`()`);\n })\n )\n };\n } else {\n return {\n name: \"environment\",\n assignment: php.TypeLiteral.reference(\n php.codeblock((writer) => {\n writer.writeNode(environmentClassRef);\n writer.write(`::custom(`);\n const entries = Object.entries(result.urls);\n entries.forEach(([paramName, url], index) => {\n writer.write(`${paramName}: '${url}'`);\n if (index < entries.length - 1) {\n writer.write(`, `);\n }\n });\n writer.write(`)`);\n })\n )\n };\n }\n }\n }\n\n const defaultName = this.getDefaultEnvironmentName();\n if (defaultName == null) {\n return undefined;\n }\n\n return {\n name: \"environment\",\n assignment: php.TypeLiteral.reference(\n php.codeblock((writer) => {\n writer.writeNode(environmentClassRef);\n writer.write(`::`);\n writer.write(defaultName);\n writer.write(`()`);\n })\n )\n };\n }\n\n private getDefaultEnvironmentName(): string | undefined {\n if (this.context.ir.environments?.environments.type !== \"multipleBaseUrls\") {\n return undefined;\n }\n\n const environmentsConfig = this.context.ir.environments.environments;\n if (environmentsConfig.type !== \"multipleBaseUrls\") {\n return undefined;\n }\n\n const environments = environmentsConfig.environments;\n if (environments.length === 0) {\n return undefined;\n }\n\n for (const env of environments) {\n const className = this.context.getClassName(env.name);\n if (className === \"Production\") {\n return className;\n }\n }\n\n const firstEnv = environments[0];\n if (firstEnv == null) {\n return undefined;\n }\n return this.context.getClassName(firstEnv.name);\n }\n\n private resolveMultiEnvironmentName(\n environment: FernIr.dynamic.MultipleEnvironmentUrlValues\n ): { type: \"named\"; name: string } | { type: \"custom\"; urls: Record<string, string> } | undefined {\n const baseUrlIds = Object.keys(environment);\n if (baseUrlIds.length === 0) {\n return undefined;\n }\n\n // Validate that all required base URLs are provided\n if (!this.context.validateMultiEnvironmentUrlValues(environment)) {\n return undefined;\n }\n\n const firstBaseUrlId = baseUrlIds[0];\n if (firstBaseUrlId == null) {\n return undefined;\n }\n\n const firstBaseUrlValue = environment[firstBaseUrlId];\n if (firstBaseUrlValue == null) {\n return undefined;\n }\n\n // Check if the first value is a valid environment ID (not just any string)\n const firstEnvironmentName = this.context.resolveEnvironmentName(firstBaseUrlValue);\n if (firstEnvironmentName != null) {\n // Check if all values point to the same environment\n const allSameEnvironment = baseUrlIds.every((baseUrlId) => {\n const value = environment[baseUrlId];\n if (value == null) {\n return false;\n }\n const envName = this.context.resolveEnvironmentName(value);\n return envName != null && value === firstBaseUrlValue;\n });\n\n if (allSameEnvironment) {\n return { type: \"named\", name: this.context.getClassName(firstEnvironmentName) };\n }\n }\n\n // Treat all values as custom URLs\n const urls: Record<string, string> = {};\n for (const baseUrlId of baseUrlIds) {\n const value = environment[baseUrlId];\n if (value == null) {\n continue;\n }\n const paramName = this.getBaseUrlPropertyName(baseUrlId);\n urls[paramName] = value;\n }\n\n if (Object.keys(urls).length > 0) {\n return { type: \"custom\", urls };\n }\n\n return undefined;\n }\n\n private getBaseUrlPropertyName(baseUrlId: string): string {\n if (this.context.ir.environments?.environments.type !== \"multipleBaseUrls\") {\n return baseUrlId;\n }\n\n const environmentsConfig = this.context.ir.environments.environments;\n if (environmentsConfig.type !== \"multipleBaseUrls\") {\n return baseUrlId;\n }\n\n const baseUrl = environmentsConfig.baseUrls.find((url) => url.id === baseUrlId);\n if (baseUrl == null) {\n return baseUrlId;\n }\n\n return baseUrl.name.camelCase.safeName;\n }\n\n private getConstructorBaseUrlArgs({\n baseUrl,\n environment\n }: {\n baseUrl: string | undefined;\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): php.ConstructorField[] {\n const baseUrlArg = this.getBaseUrlArg({ baseUrl, environment });\n if (php.TypeLiteral.isNop(baseUrlArg)) {\n return [];\n }\n return [\n {\n name: \"baseUrl\",\n value: baseUrlArg\n }\n ];\n }\n\n private getBaseUrlArg({\n baseUrl,\n environment\n }: {\n baseUrl: string | undefined;\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): php.TypeLiteral {\n if (baseUrl != null && environment != null) {\n this.context.errors.add({\n severity: Severity.Critical,\n message: \"Cannot specify both baseUrl and environment options\"\n });\n return php.TypeLiteral.nop();\n }\n if (baseUrl != null) {\n return php.TypeLiteral.string(baseUrl);\n }\n if (environment != null) {\n if (this.context.isSingleEnvironmentID(environment)) {\n const classReference = this.context.getEnvironmentClassAccessFromID(environment);\n if (classReference == null) {\n this.context.errors.add({\n severity: Severity.Warning,\n message: `Environment ${JSON.stringify(environment)} was not found`\n });\n return php.TypeLiteral.nop();\n }\n return php.TypeLiteral.reference(\n php.codeblock((writer) => {\n writer.writeNode(classReference);\n writer.write(\"->value\");\n })\n );\n }\n if (this.context.ir.environments?.environments.type === \"multipleBaseUrls\") {\n return php.TypeLiteral.nop();\n }\n }\n return php.TypeLiteral.nop();\n }\n\n private getConstructorBearerAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.BearerAuth;\n values: FernIr.dynamic.BearerAuthValues;\n }): NamedArgument[] {\n return [\n {\n name: this.context.getPropertyName(auth.token),\n assignment: php.TypeLiteral.string(values.token)\n }\n ];\n }\n\n private getConstructorHeaderAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.HeaderAuth;\n values: FernIr.dynamic.HeaderAuthValues;\n }): NamedArgument[] {\n return [\n {\n name: this.context.getPropertyName(auth.header.name.name),\n assignment: this.context.dynamicTypeLiteralMapper.convert({\n typeReference: auth.header.typeReference,\n value: values.value\n })\n }\n ];\n }\n\n private getConstructorOAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.OAuth;\n values: FernIr.dynamic.OAuthValues;\n }): NamedArgument[] {\n return [\n {\n name: this.context.getPropertyName(auth.clientId),\n assignment: php.TypeLiteral.string(values.clientId)\n },\n {\n name: this.context.getPropertyName(auth.clientSecret),\n assignment: php.TypeLiteral.string(values.clientSecret)\n }\n ];\n }\n\n private getConstructorInferredAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.InferredAuth;\n values: FernIr.dynamic.InferredAuthValues;\n }): NamedArgument[] {\n // For now, return empty array to avoid the RangeError issue\n // The inferred auth parameters should be extracted from the normal IR,\n // not the dynamic IR which doesn't contain the detailed endpoint information\n return [];\n }\n\n private getConstructorHeaderArgs({\n headers,\n values\n }: {\n headers: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): php.ConstructorField[] {\n const args: php.ConstructorField[] = [];\n for (const header of headers) {\n const arg = this.getConstructorHeaderArg({ header, value: values.value });\n if (arg != null) {\n args.push({\n name: this.context.getPropertyName(header.name.name),\n value: arg\n });\n }\n }\n return args;\n }\n\n private getConstructorHeaderArg({\n header,\n value\n }: {\n header: FernIr.dynamic.NamedParameter;\n value: unknown;\n }): php.TypeLiteral | undefined {\n const typeLiteral = this.context.dynamicTypeLiteralMapper.convert({\n typeReference: header.typeReference,\n value\n });\n if (php.TypeLiteral.isNop(typeLiteral)) {\n // Literal header values (e.g. \"X-API-Version\") should not be included in the\n // client constructor.\n return undefined;\n }\n return typeLiteral;\n }\n\n private getMethodArgs({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.TypeLiteral[] {\n switch (endpoint.request.type) {\n case \"inlined\":\n return this.getMethodArgsForInlinedRequest({ request: endpoint.request, snippet });\n case \"body\":\n return this.getMethodArgsForBodyRequest({ request: endpoint.request, snippet });\n default:\n assertNever(endpoint.request);\n }\n }\n\n private getMethodArgsForBodyRequest({\n request,\n snippet\n }: {\n request: FernIr.dynamic.BodyRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.TypeLiteral[] {\n const args: php.TypeLiteral[] = [];\n\n this.context.errors.scope(Scope.PathParameters);\n const pathParameters = [...(this.context.ir.pathParameters ?? []), ...(request.pathParameters ?? [])];\n if (pathParameters.length > 0) {\n args.push(\n ...this.getPathParameters({ namedParameters: pathParameters, snippet }).map((field) => field.value)\n );\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n if (request.body != null) {\n args.push(this.getBodyRequestArg({ body: request.body, value: snippet.requestBody }));\n }\n this.context.errors.unscope();\n\n return args;\n }\n\n private getBodyRequestArg({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBodyType;\n value: unknown;\n }): php.TypeLiteral {\n switch (body.type) {\n case \"bytes\": {\n return this.getBytesBodyRequestArg({ value });\n }\n case \"typeReference\":\n return this.context.dynamicTypeLiteralMapper.convert({ typeReference: body.value, value });\n default:\n assertNever(body);\n }\n }\n\n private getBytesBodyRequestArg({ value }: { value: unknown }): php.TypeLiteral {\n this.context.errors.add({\n severity: Severity.Critical,\n message: \"The PHP SDK doesn't support bytes requests yet\"\n });\n return php.TypeLiteral.nop();\n }\n\n private getMethodArgsForInlinedRequest({\n request,\n snippet\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.TypeLiteral[] {\n const args: php.TypeLiteral[] = [];\n\n const inlinePathParameters = this.context.customConfig?.inlinePathParameters ?? false;\n\n this.context.errors.scope(Scope.PathParameters);\n const pathParameterFields: php.ConstructorField[] = [];\n const pathParameters = [...(this.context.ir.pathParameters ?? []), ...(request.pathParameters ?? [])];\n if (pathParameters.length > 0) {\n pathParameterFields.push(...this.getPathParameters({ namedParameters: pathParameters, snippet }));\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const filePropertyInfo = this.getFilePropertyInfo({ request, snippet });\n this.context.errors.unscope();\n\n if (!this.context.includePathParametersInWrappedRequest({ request, inlinePathParameters })) {\n args.push(...pathParameterFields.map((field) => field.value));\n }\n\n if (\n this.context.needsRequestParameter({\n request,\n inlinePathParameters,\n inlineFileProperties: true // The PHP SDK requires inlineFileProperties.\n })\n ) {\n args.push(\n this.getInlinedRequestArg({\n request,\n snippet,\n pathParameterFields: this.context.includePathParametersInWrappedRequest({\n request,\n inlinePathParameters\n })\n ? pathParameterFields\n : [],\n filePropertyInfo\n })\n );\n }\n return args;\n }\n\n private getFilePropertyInfo({\n request,\n snippet\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): FilePropertyInfo {\n if (request.body == null || !this.context.isFileUploadRequestBody(request.body)) {\n return {\n fileFields: [],\n bodyPropertyFields: []\n };\n }\n return this.context.filePropertyMapper.getFilePropertyInfo({\n body: request.body,\n value: snippet.requestBody\n });\n }\n\n private getInlinedRequestArg({\n request,\n snippet,\n pathParameterFields,\n filePropertyInfo\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n pathParameterFields: php.ConstructorField[];\n filePropertyInfo: FilePropertyInfo;\n }): php.TypeLiteral {\n this.context.errors.scope(Scope.QueryParameters);\n const queryParameters = this.context.associateQueryParametersByWireValue({\n parameters: request.queryParameters ?? [],\n values: snippet.queryParameters ?? {}\n });\n const queryParameterFields = queryParameters.map((queryParameter) => ({\n name: this.context.getPropertyName(queryParameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(queryParameter)\n }));\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.Headers);\n const headers = this.context.associateByWireValue({\n parameters: request.headers ?? [],\n values: snippet.headers ?? {}\n });\n const headerFields = headers.map((header) => ({\n name: this.context.getPropertyName(header.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(header)\n }));\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const requestBodyFields =\n request.body != null\n ? this.getInlinedRequestBodyConstructorFields({\n body: request.body,\n value: snippet.requestBody,\n filePropertyInfo\n })\n : [];\n this.context.errors.unscope();\n\n return php.TypeLiteral.class_({\n reference: php.classReference({\n name: this.context.getClassName(request.declaration.name),\n namespace: this.context.getRequestNamespace(request.declaration.fernFilepath)\n }),\n fields: [...pathParameterFields, ...queryParameterFields, ...headerFields, ...requestBodyFields]\n });\n }\n\n private getInlinedRequestBodyConstructorFields({\n body,\n value,\n filePropertyInfo\n }: {\n body: FernIr.dynamic.InlinedRequestBody;\n value: unknown;\n filePropertyInfo: FilePropertyInfo;\n }): php.ConstructorField[] {\n switch (body.type) {\n case \"properties\":\n return this.getInlinedRequestBodyPropertyConstructorFields({ parameters: body.value, value });\n case \"referenced\":\n return [this.getReferencedRequestBodyPropertyConstructorField({ body, value })];\n case \"fileUpload\":\n return this.getFileUploadRequestBodyConstructorFields({ filePropertyInfo });\n default:\n assertNever(body);\n }\n }\n\n private getFileUploadRequestBodyConstructorFields({\n filePropertyInfo\n }: {\n filePropertyInfo: FilePropertyInfo;\n }): php.ConstructorField[] {\n return [...filePropertyInfo.fileFields, ...filePropertyInfo.bodyPropertyFields];\n }\n\n private getReferencedRequestBodyPropertyConstructorField({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBody;\n value: unknown;\n }): php.ConstructorField {\n return {\n name: this.context.getPropertyName(body.bodyKey),\n value: this.getReferencedRequestBodyPropertyTypeLiteral({ body: body.bodyType, value })\n };\n }\n\n private getReferencedRequestBodyPropertyTypeLiteral({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBodyType;\n value: unknown;\n }): php.TypeLiteral {\n switch (body.type) {\n case \"bytes\":\n return this.getBytesBodyRequestArg({ value });\n case \"typeReference\":\n return this.context.dynamicTypeLiteralMapper.convert({ typeReference: body.value, value });\n default:\n assertNever(body);\n }\n }\n\n private getInlinedRequestBodyPropertyConstructorFields({\n parameters,\n value\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n value: unknown;\n }): php.ConstructorField[] {\n const fields: php.ConstructorField[] = [];\n\n const bodyProperties = this.context.associateByWireValue({\n parameters,\n values: this.context.getRecord(value) ?? {}\n });\n for (const parameter of bodyProperties) {\n fields.push({\n name: this.context.getPropertyName(parameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(parameter)\n });\n }\n\n return fields;\n }\n\n private getPathParameters({\n namedParameters,\n snippet\n }: {\n namedParameters: FernIr.dynamic.NamedParameter[];\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): php.ConstructorField[] {\n const args: php.ConstructorField[] = [];\n\n const pathParameters = this.context.associateByWireValue({\n parameters: namedParameters,\n values: snippet.pathParameters ?? {}\n });\n for (const parameter of pathParameters) {\n args.push({\n name: this.context.getPropertyName(parameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(parameter)\n });\n }\n\n return args;\n }\n\n private getMethod({ endpoint }: { endpoint: FernIr.dynamic.Endpoint }): string {\n if (endpoint.declaration.fernFilepath.allParts.length > 0) {\n return `${endpoint.declaration.fernFilepath.allParts\n .map((val) => this.context.getPropertyName(val))\n .join(\"->\")}->${this.context.getMethodName(endpoint.declaration.name)}`;\n }\n return this.context.getMethodName(endpoint.declaration.name);\n }\n\n private getRootClientClassInstantiation(arguments_: NamedArgument[]): php.ClassInstantiation {\n return php.instantiateClass({\n classReference: php.classReference({\n name: this.context.getRootClientClassName(),\n namespace: this.context.rootNamespace\n }),\n arguments_,\n multiline: true\n });\n }\n}\n"],"mappings":"mHAAAA,IAAAC,IAQA,IAAMC,EAAkB,UAClBC,EAAoB,UACpBC,EAAa;AAAA;AAAA,EAENC,EAAN,KAA+B,CAGlC,YAAY,CAAE,QAAAC,CAAQ,EAAiD,CAFvEC,EAA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EQ,kBAAkB,CACtB,gBAAAG,EACA,QAAA7D,CACJ,EAG2B,CAp5B/B,IAAAH,EAq5BQ,IAAMc,EAA+B,CAAC,EAEhCkC,EAAiB,KAAK,QAAQ,qBAAqB,CACrD,WAAYgB,EACZ,QAAQhE,EAAAG,EAAQ,iBAAR,KAAAH,EAA0B,CAAC,CACvC,CAAC,EACD,QAAW+D,KAAaf,EACpBlC,EAAK,KAAK,CACN,KAAM,KAAK,QAAQ,gBAAgBiD,EAAU,KAAK,IAAI,EACtD,MAAO,KAAK,QAAQ,yBAAyB,QAAQA,CAAS,CAClE,CAAC,EAGL,OAAOjD,CACX,CAEQ,UAAU,CAAE,SAAAhB,CAAS,EAAkD,CAC3E,OAAIA,EAAS,YAAY,aAAa,SAAS,OAAS,EAC7C,GAAGA,EAAS,YAAY,aAAa,SACvC,IAAKmE,GAAQ,KAAK,QAAQ,gBAAgBA,CAAG,CAAC,EAC9C,KAAK,IAAI,CAAC,KAAK,KAAK,QAAQ,cAAcnE,EAAS,YAAY,IAAI,CAAC,GAEtE,KAAK,QAAQ,cAAcA,EAAS,YAAY,IAAI,CAC/D,CAEQ,gCAAgCoE,EAAqD,CACzF,OAAO9D,EAAI,iBAAiB,CACxB,eAAgBA,EAAI,eAAe,CAC/B,KAAM,KAAK,QAAQ,uBAAuB,EAC1C,UAAW,KAAK,QAAQ,aAC5B,CAAC,EACD,WAAA8D,EACA,UAAW,EACf,CAAC,CACL,CACJ","names":["init_process","init_buffer","CLIENT_VAR_NAME","SNIPPET_NAMESPACE","PHP_PREFIX","EndpointSnippetGenerator","context","__publicField","endpoint","request","_a","code","options","snippet","php_exports","writer","authArgs","defaultInferredAuthValues","Severity","hasMultiUrlEnvironments","environmentArg","optionArgs","baseUrlArgs","Scope","args","arg","auth","values","assertNever","message","environment","environmentClassRef","environmentName","className","result","entries","paramName","url","index","defaultName","environmentsConfig","environments","env","firstEnv","baseUrlIds","firstBaseUrlId","firstBaseUrlValue","firstEnvironmentName","baseUrlId","value","urls","baseUrl","baseUrlArg","classReference","headers","header","typeLiteral","_b","pathParameters","field","body","_c","_d","inlinePathParameters","pathParameterFields","filePropertyInfo","queryParameterFields","queryParameter","headerFields","requestBodyFields","parameters","fields","bodyProperties","parameter","namedParameters","val","arguments_"]}