@fern-api/php-dynamic-snippets 0.0.7 → 0.0.8

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.
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-DFQIKN25.js";import"./chunk-CPIHNCS3.js";import"./chunk-XX3MRTVI.js";import"./chunk-EECVWAVT.js";import"./chunk-3LG5WCZI.js";import"./chunk-3QAUV5WT.js";import"./chunk-PYHFKEW4.js";export{a as DynamicSnippetsGenerator};
1
+ import{a}from"./chunk-SGTIIPPK.js";import"./chunk-6HHK4TUF.js";import"./chunk-XX3MRTVI.js";import"./chunk-EECVWAVT.js";import"./chunk-3LG5WCZI.js";import"./chunk-3QAUV5WT.js";import"./chunk-PYHFKEW4.js";export{a as DynamicSnippetsGenerator};
2
2
  //# sourceMappingURL=DynamicSnippetsGenerator.js.map
@@ -32,6 +32,7 @@ declare class EndpointSnippetGenerator {
32
32
  private getBaseUrlArg;
33
33
  private getConstructorBearerAuthArgs;
34
34
  private getConstructorHeaderAuthArgs;
35
+ private getConstructorOAuthArgs;
35
36
  private getConstructorHeaderArgs;
36
37
  private getConstructorHeaderArg;
37
38
  private getMethodArgs;
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-CPIHNCS3.js";import"./chunk-3LG5WCZI.js";import"./chunk-PYHFKEW4.js";export{a as EndpointSnippetGenerator};
1
+ import{a}from"./chunk-6HHK4TUF.js";import"./chunk-3LG5WCZI.js";import"./chunk-PYHFKEW4.js";export{a as EndpointSnippetGenerator};
2
2
  //# sourceMappingURL=EndpointSnippetGenerator.js.map
@@ -0,0 +1,4 @@
1
+ import{b as d,d as l}from"./chunk-3LG5WCZI.js";import{e as F,f as x,g as P,h as m,l as a}from"./chunk-PYHFKEW4.js";x();P();var I="$client",f="Example",A=`<?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 A+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 A+r.toString({namespace:f,rootNamespace:f,customConfig:(s=this.context.customConfig)!=null?s:{}})}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}))})}constructClient({endpoint:e,snippet:t}){return a.codeblock(r=>{r.write(`${I} = `),r.writeNode(this.getRootClientClassInstantiation(this.getConstructorArgs({endpoint:e,snippet:t})))})}callMethod({endpoint:e,snippet:t}){return a.invokeMethod({on:a.codeblock(I),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t}),multiline:!0})}getConstructorArgs({endpoint:e,snippet:t}){var u;let r=[];e.auth!=null&&(t.auth!=null?r.push(...this.getConstructorAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:d.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`}));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(l.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 this.addWarning("The PHP SDK Generator does not support Inferred auth scheme yet"),[];default:m(e)}}addError(e){this.context.errors.add({severity:d.Critical,message:e})}addWarning(e){this.context.errors.add({severity:d.Warning,message:e})}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],p)=>{i.write(`${u}: '${c}'`),p<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)return;let r=t[0];if(r==null)return;let s=e[r];if(s==null)return;if(this.context.isSingleEnvironmentID(s)){let o=this.context.resolveEnvironmentName(s);if(o==null)return;if(t.every(c=>{let p=e[c];return p!=null&&this.context.isSingleEnvironmentID(p)&&p===s}))return{type:"named",name:this.context.getClassName(o)}}let n={},i=!1;for(let o of t){let u=e[o];if(u!=null&&!this.context.isSingleEnvironmentID(u)){i=!0;let c=this.getBaseUrlPropertyName(o);n[c]=u}}if(i&&Object.keys(n).length>0)return{type:"custom",urls:n}}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:d.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:d.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)}]}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(l.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(l.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:d.Critical,message:"The PHP SDK doesn't support bytes requests yet"}),a.TypeLiteral.nop()}getMethodArgsForInlinedRequest({request:e,snippet:t}){var u,c,p,h;let r=[],s=(c=(u=this.context.customConfig)==null?void 0:u.inlinePathParameters)!=null?c:!1;this.context.errors.scope(l.PathParameters);let n=[],i=[...(p=this.context.ir.pathParameters)!=null?p:[],...(h=e.pathParameters)!=null?h:[]];i.length>0&&n.push(...this.getPathParameters({namedParameters:i,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(l.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 p,h,g,v;this.context.errors.scope(l.QueryParameters);let i=this.context.associateQueryParametersByWireValue({parameters:(p=e.queryParameters)!=null?p:[],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(l.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(l.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-6HHK4TUF.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/EndpointSnippetGenerator.ts"],"sourcesContent":["import { NamedArgument, 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 private 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 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 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 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 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 this.addWarning(\"The PHP SDK Generator does not support Inferred auth scheme yet\");\n return [];\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 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 if (this.context.isSingleEnvironmentID(firstBaseUrlValue)) {\n const environmentName = this.context.resolveEnvironmentName(firstBaseUrlValue);\n if (environmentName == null) {\n return undefined;\n }\n\n const allSameEnvironment = baseUrlIds.every((baseUrlId) => {\n const value = environment[baseUrlId];\n return value != null && this.context.isSingleEnvironmentID(value) && value === firstBaseUrlValue;\n });\n\n if (allSameEnvironment) {\n return { type: \"named\", name: this.context.getClassName(environmentName) };\n }\n }\n\n const urls: Record<string, string> = {};\n let hasAnyLiteralUrl = false;\n for (const baseUrlId of baseUrlIds) {\n const value = environment[baseUrlId];\n if (value == null) {\n continue;\n }\n if (!this.context.isSingleEnvironmentID(value)) {\n hasAnyLiteralUrl = true;\n const paramName = this.getBaseUrlPropertyName(baseUrlId);\n urls[paramName] = value;\n }\n }\n\n if (hasAnyLiteralUrl && 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 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,CAC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,CAEQ,kBAAkB,CACtB,gBAAAG,EACA,QAAA5D,CACJ,EAG2B,CA30B/B,IAAAF,EA40BQ,IAAMY,EAA+B,CAAC,EAEhCkC,EAAiB,KAAK,QAAQ,qBAAqB,CACrD,WAAYgB,EACZ,QAAQ9D,EAAAE,EAAQ,iBAAR,KAAAF,EAA0B,CAAC,CACvC,CAAC,EACD,QAAW6D,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,SAAAd,CAAS,EAAkD,CAC3E,OAAIA,EAAS,YAAY,aAAa,SAAS,OAAS,EAC7C,GAAGA,EAAS,YAAY,aAAa,SACvC,IAAKiE,GAAQ,KAAK,QAAQ,gBAAgBA,CAAG,CAAC,EAC9C,KAAK,IAAI,CAAC,KAAK,KAAK,QAAQ,cAAcjE,EAAS,YAAY,IAAI,CAAC,GAEtE,KAAK,QAAQ,cAAcA,EAAS,YAAY,IAAI,CAC/D,CAEQ,gCAAgCkE,EAAqD,CACzF,OAAO7D,EAAI,iBAAiB,CACxB,eAAgBA,EAAI,eAAe,CAC/B,KAAM,KAAK,QAAQ,uBAAuB,EAC1C,UAAW,KAAK,QAAQ,aAC5B,CAAC,EACD,WAAA6D,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","snippet","php_exports","writer","authArgs","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","baseUrlId","value","urls","hasAnyLiteralUrl","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_"]}
@@ -1,2 +1,2 @@
1
- import{a as i}from"./chunk-CPIHNCS3.js";import{a as p}from"./chunk-XX3MRTVI.js";import{a as t}from"./chunk-3LG5WCZI.js";import{f as n,g as r}from"./chunk-PYHFKEW4.js";n();r();var o=class extends t{constructor({ir:e,config:a}){super(new p({ir:e,config:a}))}async generate(e){return super.generate(e)}generateSync(e){return super.generateSync(e)}createSnippetGenerator(e){return new i({context:e})}};export{o as a};
2
- //# sourceMappingURL=chunk-DFQIKN25.js.map
1
+ import{a as i}from"./chunk-6HHK4TUF.js";import{a as p}from"./chunk-XX3MRTVI.js";import{a as t}from"./chunk-3LG5WCZI.js";import{f as n,g as r}from"./chunk-PYHFKEW4.js";n();r();var o=class extends t{constructor({ir:e,config:a}){super(new p({ir:e,config:a}))}async generate(e){return super.generate(e)}generateSync(e){return super.generateSync(e)}createSnippetGenerator(e){return new i({context:e})}};export{o as a};
2
+ //# sourceMappingURL=chunk-SGTIIPPK.js.map
package/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{a as n}from"./chunk-DFQIKN25.js";import"./chunk-CPIHNCS3.js";import"./chunk-XX3MRTVI.js";import"./chunk-EECVWAVT.js";import"./chunk-3LG5WCZI.js";import"./chunk-3QAUV5WT.js";import{f as e,g as r}from"./chunk-PYHFKEW4.js";e();r();export{n as DynamicSnippetsGenerator};
1
+ import{a as n}from"./chunk-SGTIIPPK.js";import"./chunk-6HHK4TUF.js";import"./chunk-XX3MRTVI.js";import"./chunk-EECVWAVT.js";import"./chunk-3LG5WCZI.js";import"./chunk-3QAUV5WT.js";import{f as e,g as r}from"./chunk-PYHFKEW4.js";e();r();export{n as DynamicSnippetsGenerator};
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.7",
3
+ "version": "0.0.8",
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 d,d as l}from"./chunk-3LG5WCZI.js";import{e as F,f as P,g as x,h as m,l as a}from"./chunk-PYHFKEW4.js";P();x();var I="$client",f="Example",R=`<?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 R+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 R+r.toString({namespace:f,rootNamespace:f,customConfig:(s=this.context.customConfig)!=null?s:{}})}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}))})}constructClient({endpoint:e,snippet:t}){return a.codeblock(r=>{r.write(`${I} = `),r.writeNode(this.getRootClientClassInstantiation(this.getConstructorArgs({endpoint:e,snippet:t})))})}callMethod({endpoint:e,snippet:t}){return a.invokeMethod({on:a.codeblock(I),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t}),multiline:!0})}getConstructorArgs({endpoint:e,snippet:t}){var u;let r=[];e.auth!=null&&(t.auth!=null?r.push(...this.getConstructorAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:d.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`}));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(l.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 this.addWarning("The PHP SDK doesn't support OAuth client credentials yet"),[];case"inferred":return this.addWarning("The PHP SDK Generator does not support Inferred auth scheme yet"),[];default:m(e)}}addError(e){this.context.errors.add({severity:d.Critical,message:e})}addWarning(e){this.context.errors.add({severity:d.Warning,message:e})}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],p)=>{i.write(`${u}: '${c}'`),p<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)return;let r=t[0];if(r==null)return;let s=e[r];if(s==null)return;if(this.context.isSingleEnvironmentID(s)){let o=this.context.resolveEnvironmentName(s);if(o==null)return;if(t.every(c=>{let p=e[c];return p!=null&&this.context.isSingleEnvironmentID(p)&&p===s}))return{type:"named",name:this.context.getClassName(o)}}let n={},i=!1;for(let o of t){let u=e[o];if(u!=null&&!this.context.isSingleEnvironmentID(u)){i=!0;let c=this.getBaseUrlPropertyName(o);n[c]=u}}if(i&&Object.keys(n).length>0)return{type:"custom",urls:n}}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:d.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:d.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})}]}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(l.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(l.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:d.Critical,message:"The PHP SDK doesn't support bytes requests yet"}),a.TypeLiteral.nop()}getMethodArgsForInlinedRequest({request:e,snippet:t}){var u,c,p,h;let r=[],s=(c=(u=this.context.customConfig)==null?void 0:u.inlinePathParameters)!=null?c:!1;this.context.errors.scope(l.PathParameters);let n=[],i=[...(p=this.context.ir.pathParameters)!=null?p:[],...(h=e.pathParameters)!=null?h:[]];i.length>0&&n.push(...this.getPathParameters({namedParameters:i,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(l.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 p,h,g,v;this.context.errors.scope(l.QueryParameters);let i=this.context.associateQueryParametersByWireValue({parameters:(p=e.queryParameters)!=null?p:[],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(l.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(l.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-CPIHNCS3.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/EndpointSnippetGenerator.ts"],"sourcesContent":["import { NamedArgument, 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 private 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 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 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 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 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 this.addWarning(\"The PHP SDK doesn't support OAuth client credentials yet\");\n return [];\n case \"inferred\":\n this.addWarning(\"The PHP SDK Generator does not support Inferred auth scheme yet\");\n return [];\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 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 if (this.context.isSingleEnvironmentID(firstBaseUrlValue)) {\n const environmentName = this.context.resolveEnvironmentName(firstBaseUrlValue);\n if (environmentName == null) {\n return undefined;\n }\n\n const allSameEnvironment = baseUrlIds.every((baseUrlId) => {\n const value = environment[baseUrlId];\n return value != null && this.context.isSingleEnvironmentID(value) && value === firstBaseUrlValue;\n });\n\n if (allSameEnvironment) {\n return { type: \"named\", name: this.context.getClassName(environmentName) };\n }\n }\n\n const urls: Record<string, string> = {};\n let hasAnyLiteralUrl = false;\n for (const baseUrlId of baseUrlIds) {\n const value = environment[baseUrlId];\n if (value == null) {\n continue;\n }\n if (!this.context.isSingleEnvironmentID(value)) {\n hasAnyLiteralUrl = true;\n const paramName = this.getBaseUrlPropertyName(baseUrlId);\n urls[paramName] = value;\n }\n }\n\n if (hasAnyLiteralUrl && 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 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,C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AyB,QAAQA,CAAS,CAClE,CAAC,EAGL,OAAOjD,CACX,CAEQ,UAAU,CAAE,SAAAd,CAAS,EAAkD,CAC3E,OAAIA,EAAS,YAAY,aAAa,SAAS,OAAS,EAC7C,GAAGA,EAAS,YAAY,aAAa,SACvC,IAAKiE,GAAQ,KAAK,QAAQ,gBAAgBA,CAAG,CAAC,EAC9C,KAAK,IAAI,CAAC,KAAK,KAAK,QAAQ,cAAcjE,EAAS,YAAY,IAAI,CAAC,GAEtE,KAAK,QAAQ,cAAcA,EAAS,YAAY,IAAI,CAC/D,CAEQ,gCAAgCkE,EAAqD,CACzF,OAAO7D,EAAI,iBAAiB,CACxB,eAAgBA,EAAI,eAAe,CAC/B,KAAM,KAAK,QAAQ,uBAAuB,EAC1C,UAAW,KAAK,QAAQ,aAC5B,CAAC,EACD,WAAA6D,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","snippet","php_exports","writer","authArgs","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","baseUrlId","value","urls","hasAnyLiteralUrl","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_"]}