@fern-api/python-dynamic-snippets 0.0.9 → 4.41.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/cjs/DynamicSnippetsGenerator.cjs +7 -7
  2. package/cjs/DynamicSnippetsGenerator.cjs.map +1 -1
  3. package/cjs/EndpointSnippetGenerator.cjs +8 -8
  4. package/cjs/EndpointSnippetGenerator.cjs.map +1 -1
  5. package/cjs/EndpointSnippetGenerator.d.cts +1 -0
  6. package/cjs/context/DynamicSnippetsGeneratorContext.cjs +6 -6
  7. package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +1 -1
  8. package/cjs/context/DynamicTypeLiteralMapper.cjs +4 -4
  9. package/cjs/context/DynamicTypeLiteralMapper.cjs.map +1 -1
  10. package/cjs/context/FilePropertyMapper.cjs +4 -4
  11. package/cjs/context/FilePropertyMapper.cjs.map +1 -1
  12. package/cjs/index.cjs +7 -7
  13. package/cjs/index.cjs.map +1 -1
  14. package/esm/DynamicSnippetsGenerator.js +1 -1
  15. package/esm/EndpointSnippetGenerator.d.ts +1 -0
  16. package/esm/EndpointSnippetGenerator.js +1 -1
  17. package/esm/chunk-2KHLQG2A.js +2 -0
  18. package/esm/chunk-2KHLQG2A.js.map +1 -0
  19. package/esm/chunk-2SPAKVUZ.js +2 -0
  20. package/esm/chunk-2SPAKVUZ.js.map +1 -0
  21. package/esm/{chunk-W7SA7MNB.js → chunk-3XEFLXHY.js} +2 -2
  22. package/esm/{chunk-BZ5ZJPTG.js → chunk-DP6NTUTQ.js} +2 -2
  23. package/esm/{chunk-XX42ILF7.js → chunk-HGKGDQ5J.js} +2 -2
  24. package/esm/{chunk-YEXRWSXV.js → chunk-NHAFJ5OA.js} +8 -8
  25. package/esm/chunk-NHAFJ5OA.js.map +1 -0
  26. package/esm/{chunk-AK6ZQDEA.js → chunk-ULECZXWB.js} +2 -2
  27. package/esm/context/DynamicSnippetsGeneratorContext.js +1 -1
  28. package/esm/context/DynamicTypeLiteralMapper.js +1 -1
  29. package/esm/context/FilePropertyMapper.js +1 -1
  30. package/esm/index.js +1 -1
  31. package/package.json +1 -1
  32. package/esm/chunk-2FBSEQ3K.js +0 -2
  33. package/esm/chunk-2FBSEQ3K.js.map +0 -1
  34. package/esm/chunk-6JNSYN57.js +0 -2
  35. package/esm/chunk-6JNSYN57.js.map +0 -1
  36. package/esm/chunk-YEXRWSXV.js.map +0 -1
  37. /package/esm/{chunk-W7SA7MNB.js.map → chunk-3XEFLXHY.js.map} +0 -0
  38. /package/esm/{chunk-BZ5ZJPTG.js.map → chunk-DP6NTUTQ.js.map} +0 -0
  39. /package/esm/{chunk-XX42ILF7.js.map → chunk-HGKGDQ5J.js.map} +0 -0
  40. /package/esm/{chunk-AK6ZQDEA.js.map → chunk-ULECZXWB.js.map} +0 -0
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-BZ5ZJPTG.js";import"./chunk-6JNSYN57.js";import"./chunk-XX42ILF7.js";import"./chunk-W7SA7MNB.js";import"./chunk-AK6ZQDEA.js";import"./chunk-2FBSEQ3K.js";import"./chunk-YEXRWSXV.js";export{a as DynamicSnippetsGenerator};
1
+ import{a}from"./chunk-DP6NTUTQ.js";import"./chunk-2KHLQG2A.js";import"./chunk-HGKGDQ5J.js";import"./chunk-3XEFLXHY.js";import"./chunk-ULECZXWB.js";import"./chunk-2SPAKVUZ.js";import"./chunk-NHAFJ5OA.js";export{a as DynamicSnippetsGenerator};
2
2
  //# sourceMappingURL=DynamicSnippetsGenerator.js.map
@@ -50,6 +50,7 @@ declare class EndpointSnippetGenerator {
50
50
  private getBodyRequestArgs;
51
51
  private getBodyRequestArgsForTypeReference;
52
52
  private getBodyRequestArgsForNamedTypeReference;
53
+ private resolvesToLiteralType;
53
54
  private getBodyRequestArgsForBytes;
54
55
  private getBytesBodyRequestTypeInstantiation;
55
56
  private getMethodArgsForInlinedRequest;
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-6JNSYN57.js";import"./chunk-AK6ZQDEA.js";import"./chunk-YEXRWSXV.js";export{a as EndpointSnippetGenerator};
1
+ import{a}from"./chunk-2KHLQG2A.js";import"./chunk-ULECZXWB.js";import"./chunk-NHAFJ5OA.js";export{a as EndpointSnippetGenerator};
2
2
  //# sourceMappingURL=EndpointSnippetGenerator.js.map
@@ -0,0 +1,2 @@
1
+ import{b as d,d as u}from"./chunk-ULECZXWB.js";import{a as I,b as F,e as P,f as R,g as A,h as c,j as a}from"./chunk-NHAFJ5OA.js";R();A();var T={type:"primitive",value:"STRING"},q=["example"],x="client",h="request",N=class{constructor({context:e}){P(this,"context");this.context=e}async generateSnippet({endpoint:e,request:t}){return this.buildPythonFile({endpoint:e,snippet:t}).toString()}generateSnippetSync({endpoint:e,request:t}){return this.buildPythonFile({endpoint:e,snippet:t}).toString()}async generateSnippetAst({endpoint:e,request:t}){return this.buildPythonFile({endpoint:e,snippet:t})}generateMethodCallSnippetAst({endpoint:e,request:t}){return this.callMethod({endpoint:e,snippet:t})}buildPythonFile({endpoint:e,snippet:t}){return a.file({path:q,statements:[this.constructClient({endpoint:e,snippet:t}),this.callMethod({endpoint:e,snippet:t})]})}constructClient({endpoint:e,snippet:t}){return a.assign({lhs:a.reference({name:x}),rhs:a.instantiateClass({classReference:this.context.getRootClientClassReference(),arguments_:this.getConstructorArgs({endpoint:e,snippet:t}).map(r=>a.methodArgument({name:r.name,value:r.value})),multiline:!0})})}getConstructorArgs({endpoint:e,snippet:t}){let r=[],n=this.getConstructorEnvironmentArgs({baseUrl:t.baseURL,environment:t.environment});return n.length>0&&r.push(...n),e.auth!=null&&(t.auth!=null?r.push(...this.getConstructorAuthArgs({auth:e.auth,values:t.auth})):this.context.errors.add({severity:d.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(u.PathParameters),this.context.ir.pathParameters!=null&&r.push(...this.getPathParameters({namedParameters:this.context.ir.pathParameters,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(u.Headers),this.context.ir.headers!=null&&t.headers!=null&&r.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope(),r}getConstructorEnvironmentArgs({baseUrl:e,environment:t}){let r=this.getEnvironmentValue({baseUrl:e,environment:t});return r==null?[]:t!=null&&this.context.isMultiEnvironmentValues(t)?[{name:"environment",value:r}]:[{name:this.getEnvironmentOptionName({environment:t}),value:r}]}getEnvironmentValue({baseUrl:e,environment:t}){if(e!=null&&t!=null){this.context.errors.add({severity:d.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(e!=null)return a.TypeInstantiation.str(e);if(t!=null){if(this.context.isSingleEnvironmentID(t)){let r=this.context.getEnvironmentTypeReferenceFromID(t);if(r==null){this.context.errors.add({severity:d.Warning,message:`Environment ${JSON.stringify(t)} was not found`});return}return a.TypeInstantiation.reference(r)}if(this.context.isMultiEnvironmentValues(t))return this.context.validateMultiEnvironmentUrlValues(t)?a.TypeInstantiation.reference(a.instantiateClass({classReference:this.context.getEnvironmentClassReference(),arguments_:Object.entries(t).map(([r,n])=>({name:r,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:T,value:n})})).map(r=>a.methodArgument({name:r.name,value:r.value})),multiline:!0})):void 0}}getConstructorAuthArgs({auth:e,values:t}){switch(e.type){case"basic":return t.type!=="basic"?(this.addAuthMismatchError(e,t),[]):this.getConstructorBasicAuthArg({auth:e,values:t});case"bearer":return t.type!=="bearer"?(this.addAuthMismatchError(e,t),[]):this.getConstructorBearerAuthArgs({auth:e,values:t});case"header":return t.type!=="header"?(this.addAuthMismatchError(e,t),[]):this.getConstructorHeaderAuthArgs({auth:e,values:t});case"oauth":return t.type!=="oauth"?(this.addAuthMismatchError(e,t),[]):this.getConstructorOAuthArgs({auth:e,values:t});case"inferred":return t.type!=="inferred"?(this.addAuthMismatchError(e,t),[]):(this.addWarning("The Python SDK Generator does not support Inferred auth scheme yet"),[]);default:c(e)}}addAuthMismatchError(e,t){this.context.errors.add({severity:d.Critical,message:this.context.newAuthMismatchError({auth:e,values:t}).message})}addWarning(e){this.context.errors.add({severity:d.Warning,message:e})}getConstructorBasicAuthArg({auth:e,values:t}){return[{name:this.context.getPropertyName(e.username),value:a.TypeInstantiation.str(t.username)},{name:this.context.getPropertyName(e.password),value:a.TypeInstantiation.str(t.password)}]}getConstructorBearerAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.token),value:a.TypeInstantiation.str(t.token)}]}getConstructorHeaderAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.header.name.name),value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e.header.typeReference,value:t.value})}]}getConstructorOAuthArgs({auth:e,values:t}){return[{name:this.context.getPropertyName(e.clientId),value:a.TypeInstantiation.str(t.clientId)},{name:this.context.getPropertyName(e.clientSecret),value:a.TypeInstantiation.str(t.clientSecret)}]}getConstructorHeaderArgs({headers:e,values:t}){let r=[];for(let n of e){let i=this.getConstructorHeaderArg({header:n,value:t.value});i!=null&&r.push(i)}return r}getConstructorHeaderArg({header:e,value:t}){let r=this.context.dynamicTypeLiteralMapper.convert({typeReference:e.typeReference,value:t});if(!a.TypeInstantiation.isNop(r))return{name:this.context.getPropertyName(e.name.name),value:r}}callMethod({endpoint:e,snippet:t}){return a.invokeMethod({on:a.reference({name:x}),method:this.getMethod({endpoint:e}),arguments_:this.getMethodArgs({endpoint:e,snippet:t}).map(r=>a.methodArgument({name:r.name,value:r.value})),multiline:!0})}getMethodArgs({endpoint:e,snippet:t}){switch(e.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:e.request,snippet:t});case"body":return this.getMethodArgsForBodyRequest({request:e.request,snippet:t});default:c(e.request)}}getMethodArgsForBodyRequest({request:e,snippet:t}){var o,s;let r=[];this.context.errors.scope(u.PathParameters);let n=[...(o=this.context.ir.pathParameters)!=null?o:[],...(s=e.pathParameters)!=null?s:[]],i=new Set;if(e.body!=null){let m=this.getBodyRequestArgs({body:e.body,value:t.requestBody});i=new Set(m.map(y=>y.name))}if(n.length>0){let y=this.getPathParameters({namedParameters:n,snippet:t}).map(p=>i.has(p.name)?F(I({},p),{name:p.name+"_"}):p);r.push(...y)}return this.context.errors.unscope(),this.context.errors.scope(u.RequestBody),e.body!=null&&r.push(...this.getBodyRequestArgs({body:e.body,value:t.requestBody})),this.context.errors.unscope(),r}getBodyRequestArgs({body:e,value:t}){switch(e.type){case"bytes":return[{name:h,value:this.getBytesBodyRequestTypeInstantiation({value:t})}];case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:e.value,value:t});default:c(e)}}getBodyRequestArgsForTypeReference({typeReference:e,value:t}){switch(e.type){case"named":{let r=this.context.resolveNamedType({typeId:e.value});return r==null?[]:this.getBodyRequestArgsForNamedTypeReference({typeReference:e,named:r,value:t})}case"nullable":case"optional":{let r=e.value;if(r.type==="named"){let n=this.context.resolveNamedType({typeId:r.value});if((n==null?void 0:n.type)==="object")return[{name:h,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:r,value:t})}]}return this.getBodyRequestArgsForTypeReference({typeReference:e.value,value:t})}case"list":case"map":case"set":case"literal":case"primitive":case"unknown":return[{name:h,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e,value:t})}];default:c(e)}}getBodyRequestArgsForNamedTypeReference({typeReference:e,named:t,value:r}){var n;switch(t.type){case"alias":return this.getBodyRequestArgsForTypeReference({typeReference:t.typeReference,value:r});case"enum":case"discriminatedUnion":case"undiscriminatedUnion":return[{name:h,value:this.context.dynamicTypeLiteralMapper.convert({typeReference:e,value:r})}];case"object":return this.context.associateByWireValue({parameters:t.properties,values:(n=this.context.getRecord(r))!=null?n:{}}).filter(s=>!this.resolvesToLiteralType(s.typeReference)).map(s=>({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)}));default:c(t)}}resolvesToLiteralType(e){switch(e.type){case"literal":return!0;case"optional":case"nullable":return this.resolvesToLiteralType(e.value);case"named":{let t=this.context.resolveNamedType({typeId:e.value});return t==null?!1:t.type==="alias"?this.resolvesToLiteralType(t.typeReference):!1}case"list":case"map":case"set":case"primitive":case"unknown":return!1;default:c(e)}}getBodyRequestArgsForBytes({body:e,value:t}){let r=this.getBytesBodyRequestTypeInstantiation({value:t});return a.TypeInstantiation.isNop(r)?[]:[{name:this.context.getPropertyName(e.bodyKey),value:r}]}getBytesBodyRequestTypeInstantiation({value:e}){return typeof e!="string"?(this.context.errors.add({severity:d.Critical,message:`Expected bytes value to be a string, got ${typeof e}`}),a.TypeInstantiation.nop()):a.TypeInstantiation.bytes(e)}getMethodArgsForInlinedRequest({request:e,snippet:t}){let r=[],n=this.context.shouldInlinePathParameters();this.context.errors.scope(u.PathParameters);let i=[];e.pathParameters!=null&&i.push(...this.getPathParameters({namedParameters:e.pathParameters,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(u.RequestBody);let o=this.getFilePropertyInfo({request:e,snippet:t});return this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:n})||r.push(...i),this.context.needsRequestParameter({request:e,inlinePathParameters:n,inlineFileProperties:!0})&&r.push(...this.getInlinedRequestArgs({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:n})?i:[],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})}getInlinedRequestArgs({request:e,snippet:t,pathParameterFields:r,filePropertyInfo:n}){var p,g,f,v;this.context.errors.scope(u.QueryParameters);let o=this.context.associateQueryParametersByWireValue({parameters:(p=e.queryParameters)!=null?p:[],values:(g=t.queryParameters)!=null?g:{}}).map(l=>({name:this.context.getPropertyName(l.name.name),value:this.context.dynamicTypeLiteralMapper.convert(l)}));this.context.errors.unscope(),this.context.errors.scope(u.Headers);let m=this.context.associateByWireValue({parameters:(f=e.headers)!=null?f:[],values:(v=t.headers)!=null?v:{}}).map(l=>({name:this.context.getPropertyName(l.name.name),value:this.context.dynamicTypeLiteralMapper.convert(l)}));this.context.errors.unscope(),this.context.errors.scope(u.RequestBody);let y=e.body!=null?this.getInlinedRequestBodyObjectFields({body:e.body,value:t.requestBody,filePropertyInfo:n}):[];return this.context.errors.unscope(),[...r,...o,...m,...y]}getInlinedRequestBodyObjectFields({body:e,value:t,filePropertyInfo:r}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyObjectFields({parameters:e.value,value:t});case"referenced":return this.getReferencedRequestBodyPropertyTypeInstantiation({body:e,value:t});case"fileUpload":return this.getFileUploadRequestBodyObjectFields({filePropertyInfo:r});default:c(e)}}getFileUploadRequestBodyObjectFields({filePropertyInfo:e}){return[...e.fileFields,...e.bodyPropertyFields]}getReferencedRequestBodyPropertyTypeInstantiation({body:e,value:t}){let r=e.bodyType;switch(r.type){case"bytes":return this.getBodyRequestArgsForBytes({body:e,value:t});case"typeReference":return this.getBodyRequestArgsForTypeReference({typeReference:r.value,value:t});default:c(r)}}getInlinedRequestBodyPropertyObjectFields({parameters:e,value:t}){var o;let r=[],i=this.context.associateByWireValue({parameters:e,values:(o=this.context.getRecord(t))!=null?o:{}}).filter(s=>!this.resolvesToLiteralType(s.typeReference));for(let s of i)r.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return r}getPathParameters({namedParameters:e,snippet:t}){var o;let r=[],n=e.filter(s=>!this.resolvesToLiteralType(s.typeReference)),i=this.context.associateByWireValue({parameters:n,values:(o=t.pathParameters)!=null?o:{},ignoreMissingParameters:!0});for(let s of i)r.push({name:this.context.getPropertyName(s.name.name),value:this.context.dynamicTypeLiteralMapper.convert(s)});return r}getMethod({endpoint:e}){return e.declaration.fernFilepath.allParts.length>0?`${e.declaration.fernFilepath.allParts.map(t=>this.context.getMethodName(t)).join(".")}.${this.context.getMethodName(e.declaration.name)}`:this.context.getMethodName(e.declaration.name)}getEnvironmentOptionName({environment:e}){return e!=null?"environment":"base_url"}};export{N as a};
2
+ //# sourceMappingURL=chunk-2KHLQG2A.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/EndpointSnippetGenerator.ts"],"sourcesContent":["import { AbstractAstNode, Scope, Severity } from \"@fern-api/browser-compatible-base-generator\";\nimport { assertNever } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { python } from \"@fern-api/python-ast\";\n\nimport { DynamicSnippetsGeneratorContext } from \"./context/DynamicSnippetsGeneratorContext\";\nimport { FilePropertyInfo } from \"./context/FilePropertyMapper\";\n\nconst STRING_TYPE_REFERENCE: FernIr.dynamic.TypeReference = {\n type: \"primitive\",\n value: \"STRING\"\n};\nconst SNIPPET_MODULE_PATH = [\"example\"];\nconst CLIENT_VAR_NAME = \"client\";\nconst REQUEST_BODY_ARG_NAME = \"request\";\n\nexport class EndpointSnippetGenerator {\n private context: DynamicSnippetsGeneratorContext;\n\n constructor({ context }: { context: DynamicSnippetsGeneratorContext }) {\n this.context = context;\n }\n\n public async generateSnippet({\n endpoint,\n request\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n }): Promise<string> {\n const file = this.buildPythonFile({ endpoint, snippet: request });\n return file.toString();\n }\n\n public generateSnippetSync({\n endpoint,\n request\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n }): string {\n const file = this.buildPythonFile({ endpoint, snippet: request });\n return file.toString();\n }\n\n public async generateSnippetAst({\n endpoint,\n request\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n }): Promise<AbstractAstNode> {\n return this.buildPythonFile({ endpoint, snippet: request });\n }\n\n /**\n * Generates just the method call AST without the client instantiation.\n * This is useful for wire tests where the client is created separately\n * with test-specific configuration.\n */\n public generateMethodCallSnippetAst({\n endpoint,\n request\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n request: FernIr.dynamic.EndpointSnippetRequest;\n }): python.AstNode {\n return this.callMethod({ endpoint, snippet: request });\n }\n\n private buildPythonFile({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.PythonFile {\n return python.file({\n path: SNIPPET_MODULE_PATH,\n statements: [this.constructClient({ endpoint, snippet }), this.callMethod({ endpoint, snippet })]\n });\n }\n\n private constructClient({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.AstNode {\n return python.assign({\n lhs: python.reference({ name: CLIENT_VAR_NAME }),\n rhs: python.instantiateClass({\n classReference: this.context.getRootClientClassReference(),\n arguments_: this.getConstructorArgs({ endpoint, snippet }).map((arg) =>\n python.methodArgument({\n name: arg.name,\n value: arg.value\n })\n ),\n multiline: true\n })\n });\n }\n\n private getConstructorArgs({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.NamedValue[] {\n const fields: python.NamedValue[] = [];\n const environmentArgs = this.getConstructorEnvironmentArgs({\n baseUrl: snippet.baseURL,\n environment: snippet.environment\n });\n if (environmentArgs.length > 0) {\n fields.push(...environmentArgs);\n }\n if (endpoint.auth != null) {\n if (snippet.auth != null) {\n fields.push(...this.getConstructorAuthArgs({ auth: endpoint.auth, values: snippet.auth }));\n } else {\n this.context.errors.add({\n severity: Severity.Warning,\n message: `Auth with ${endpoint.auth.type} configuration is required for this endpoint`\n });\n }\n }\n\n this.context.errors.scope(Scope.PathParameters);\n if (this.context.ir.pathParameters != null) {\n fields.push(...this.getPathParameters({ namedParameters: this.context.ir.pathParameters, snippet }));\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.Headers);\n if (this.context.ir.headers != null && snippet.headers != null) {\n fields.push(\n ...this.getConstructorHeaderArgs({ headers: this.context.ir.headers, values: snippet.headers })\n );\n }\n this.context.errors.unscope();\n return fields;\n }\n\n private getConstructorEnvironmentArgs({\n baseUrl,\n environment\n }: {\n baseUrl: string | undefined;\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): python.NamedValue[] {\n const environmentValue = this.getEnvironmentValue({ baseUrl, environment });\n if (environmentValue == null) {\n return [];\n }\n\n if (environment != null && this.context.isMultiEnvironmentValues(environment)) {\n return [\n {\n name: \"environment\",\n value: environmentValue\n }\n ];\n }\n\n return [\n {\n name: this.getEnvironmentOptionName({ environment }),\n value: environmentValue\n }\n ];\n }\n\n private getEnvironmentValue({\n baseUrl,\n environment\n }: {\n baseUrl: string | undefined;\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): python.TypeInstantiation | undefined {\n if (baseUrl != null && environment != null) {\n this.context.errors.add({\n severity: Severity.Critical,\n message: \"Cannot specify both baseUrl and environment options\"\n });\n return undefined;\n }\n if (baseUrl != null) {\n return python.TypeInstantiation.str(baseUrl);\n }\n if (environment != null) {\n if (this.context.isSingleEnvironmentID(environment)) {\n const environmentTypeReference = this.context.getEnvironmentTypeReferenceFromID(environment);\n if (environmentTypeReference == null) {\n this.context.errors.add({\n severity: Severity.Warning,\n message: `Environment ${JSON.stringify(environment)} was not found`\n });\n return undefined;\n }\n return python.TypeInstantiation.reference(environmentTypeReference);\n }\n if (this.context.isMultiEnvironmentValues(environment)) {\n if (!this.context.validateMultiEnvironmentUrlValues(environment)) {\n return undefined;\n }\n return python.TypeInstantiation.reference(\n python.instantiateClass({\n classReference: this.context.getEnvironmentClassReference(),\n arguments_: Object.entries(environment)\n .map(([key, value]) => ({\n name: key,\n value: this.context.dynamicTypeLiteralMapper.convert({\n typeReference: STRING_TYPE_REFERENCE,\n value\n })\n }))\n .map((arg) =>\n python.methodArgument({\n name: arg.name,\n value: arg.value\n })\n ),\n multiline: true\n })\n );\n }\n }\n return undefined;\n }\n\n private getConstructorAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.Auth;\n values: FernIr.dynamic.AuthValues;\n }): python.NamedValue[] {\n switch (auth.type) {\n case \"basic\":\n if (values.type !== \"basic\") {\n this.addAuthMismatchError(auth, values);\n return [];\n }\n return this.getConstructorBasicAuthArg({ auth, values });\n case \"bearer\":\n if (values.type !== \"bearer\") {\n this.addAuthMismatchError(auth, values);\n return [];\n }\n return this.getConstructorBearerAuthArgs({ auth, values });\n case \"header\":\n if (values.type !== \"header\") {\n this.addAuthMismatchError(auth, values);\n return [];\n }\n return this.getConstructorHeaderAuthArgs({ auth, values });\n case \"oauth\":\n if (values.type !== \"oauth\") {\n this.addAuthMismatchError(auth, values);\n return [];\n }\n return this.getConstructorOAuthArgs({ auth, values });\n case \"inferred\":\n if (values.type !== \"inferred\") {\n this.addAuthMismatchError(auth, values);\n return [];\n }\n this.addWarning(\"The Python SDK Generator does not support Inferred auth scheme yet\");\n return [];\n default:\n assertNever(auth);\n }\n }\n\n private addAuthMismatchError(auth: FernIr.dynamic.Auth, values: FernIr.dynamic.AuthValues): void {\n this.context.errors.add({\n severity: Severity.Critical,\n message: this.context.newAuthMismatchError({ auth, values }).message\n });\n }\n\n private addWarning(message: string): void {\n this.context.errors.add({ severity: Severity.Warning, message });\n }\n\n private getConstructorBasicAuthArg({\n auth,\n values\n }: {\n auth: FernIr.dynamic.BasicAuth;\n values: FernIr.dynamic.BasicAuthValues;\n }): python.NamedValue[] {\n return [\n {\n name: this.context.getPropertyName(auth.username),\n value: python.TypeInstantiation.str(values.username)\n },\n {\n name: this.context.getPropertyName(auth.password),\n value: python.TypeInstantiation.str(values.password)\n }\n ];\n }\n\n private getConstructorBearerAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.BearerAuth;\n values: FernIr.dynamic.BearerAuthValues;\n }): python.NamedValue[] {\n return [\n {\n name: this.context.getPropertyName(auth.token),\n value: python.TypeInstantiation.str(values.token)\n }\n ];\n }\n\n private getConstructorHeaderAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.HeaderAuth;\n values: FernIr.dynamic.HeaderAuthValues;\n }): python.NamedValue[] {\n return [\n {\n name: this.context.getPropertyName(auth.header.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert({\n typeReference: auth.header.typeReference,\n value: values.value\n })\n }\n ];\n }\n\n private getConstructorOAuthArgs({\n auth,\n values\n }: {\n auth: FernIr.dynamic.OAuth;\n values: FernIr.dynamic.OAuthValues;\n }): python.NamedValue[] {\n return [\n {\n name: this.context.getPropertyName(auth.clientId),\n value: python.TypeInstantiation.str(values.clientId)\n },\n {\n name: this.context.getPropertyName(auth.clientSecret),\n value: python.TypeInstantiation.str(values.clientSecret)\n }\n ];\n }\n\n private getConstructorHeaderArgs({\n headers,\n values\n }: {\n headers: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): python.NamedValue[] {\n const fields: python.NamedValue[] = [];\n for (const header of headers) {\n const field = this.getConstructorHeaderArg({ header, value: values.value });\n if (field != null) {\n fields.push(field);\n }\n }\n return fields;\n }\n\n private getConstructorHeaderArg({\n header,\n value\n }: {\n header: FernIr.dynamic.NamedParameter;\n value: unknown;\n }): python.NamedValue | undefined {\n const typeLiteral = this.context.dynamicTypeLiteralMapper.convert({\n typeReference: header.typeReference,\n value\n });\n if (python.TypeInstantiation.isNop(typeLiteral)) {\n // Literal header values (e.g. \"X-API-Version\") should not be included in the\n // client constructor.\n return undefined;\n }\n return {\n name: this.context.getPropertyName(header.name.name),\n value: typeLiteral\n };\n }\n\n private callMethod({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.AstNode {\n return python.invokeMethod({\n on: python.reference({ name: CLIENT_VAR_NAME }),\n method: this.getMethod({ endpoint }),\n arguments_: this.getMethodArgs({ endpoint, snippet }).map((arg) =>\n python.methodArgument({\n name: arg.name,\n value: arg.value\n })\n ),\n multiline: true\n });\n }\n\n private getMethodArgs({\n endpoint,\n snippet\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.NamedValue[] {\n switch (endpoint.request.type) {\n case \"inlined\":\n return this.getMethodArgsForInlinedRequest({ request: endpoint.request, snippet });\n case \"body\":\n return this.getMethodArgsForBodyRequest({ request: endpoint.request, snippet });\n default:\n assertNever(endpoint.request);\n }\n }\n\n private getMethodArgsForBodyRequest({\n request,\n snippet\n }: {\n request: FernIr.dynamic.BodyRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.NamedValue[] {\n const args: python.NamedValue[] = [];\n\n this.context.errors.scope(Scope.PathParameters);\n const pathParameters = [...(this.context.ir.pathParameters ?? []), ...(request.pathParameters ?? [])];\n\n // Get body property names to check for collisions\n let bodyPropertyNames: Set<string> = new Set();\n if (request.body != null) {\n const bodyArgs = this.getBodyRequestArgs({ body: request.body, value: snippet.requestBody });\n bodyPropertyNames = new Set(bodyArgs.map((arg) => arg.name));\n }\n\n // Add path parameters, adding underscore suffix if they collide with body properties\n if (pathParameters.length > 0) {\n const pathArgs = this.getPathParameters({ namedParameters: pathParameters, snippet });\n const disambiguatedPathArgs = pathArgs.map((arg) => {\n // If this path parameter name collides with a body property, add underscore suffix\n if (bodyPropertyNames.has(arg.name)) {\n return { ...arg, name: arg.name + \"_\" };\n }\n return arg;\n });\n args.push(...disambiguatedPathArgs);\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n if (request.body != null) {\n args.push(...this.getBodyRequestArgs({ body: request.body, value: snippet.requestBody }));\n }\n this.context.errors.unscope();\n\n return args;\n }\n\n private getBodyRequestArgs({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBodyType;\n value: unknown;\n }): python.NamedValue[] {\n switch (body.type) {\n case \"bytes\":\n return [\n {\n name: REQUEST_BODY_ARG_NAME,\n value: this.getBytesBodyRequestTypeInstantiation({ value })\n }\n ];\n case \"typeReference\":\n return this.getBodyRequestArgsForTypeReference({ typeReference: body.value, value });\n default:\n assertNever(body);\n }\n }\n\n private getBodyRequestArgsForTypeReference({\n typeReference,\n value\n }: {\n typeReference: FernIr.dynamic.TypeReference;\n value: unknown;\n }): python.NamedValue[] {\n switch (typeReference.type) {\n case \"named\": {\n const named = this.context.resolveNamedType({ typeId: typeReference.value });\n if (named == null) {\n return [];\n }\n return this.getBodyRequestArgsForNamedTypeReference({ typeReference, named, value });\n }\n case \"nullable\":\n case \"optional\": {\n // Check if the inner type is an object - if so, don't flatten it\n const innerType = typeReference.value;\n if (innerType.type === \"named\") {\n const named = this.context.resolveNamedType({ typeId: innerType.value });\n if (named?.type === \"object\") {\n // Optional objects should NOT be flattened - use as single 'request' parameter\n return [\n {\n name: REQUEST_BODY_ARG_NAME,\n value: this.context.dynamicTypeLiteralMapper.convert({\n typeReference: innerType,\n value\n })\n }\n ];\n }\n }\n // For non-object types, continue unwrapping\n return this.getBodyRequestArgsForTypeReference({ typeReference: typeReference.value, value });\n }\n case \"list\":\n case \"map\":\n case \"set\":\n case \"literal\":\n case \"primitive\":\n case \"unknown\":\n return [\n {\n name: REQUEST_BODY_ARG_NAME,\n value: this.context.dynamicTypeLiteralMapper.convert({ typeReference, value })\n }\n ];\n default:\n assertNever(typeReference);\n }\n }\n\n private getBodyRequestArgsForNamedTypeReference({\n typeReference,\n named,\n value\n }: {\n typeReference: FernIr.dynamic.TypeReference;\n named: FernIr.dynamic.NamedType;\n value: unknown;\n }): python.NamedValue[] {\n switch (named.type) {\n case \"alias\":\n return this.getBodyRequestArgsForTypeReference({ typeReference: named.typeReference, value });\n case \"enum\":\n case \"discriminatedUnion\":\n case \"undiscriminatedUnion\":\n return [\n {\n name: REQUEST_BODY_ARG_NAME,\n value: this.context.dynamicTypeLiteralMapper.convert({ typeReference, value })\n }\n ];\n case \"object\": {\n const bodyProperties = this.context.associateByWireValue({\n parameters: named.properties,\n values: this.context.getRecord(value) ?? {}\n });\n\n const nonLiteralBodyProperties = bodyProperties.filter(\n (property) => !this.resolvesToLiteralType(property.typeReference)\n );\n\n return nonLiteralBodyProperties.map((property) => ({\n name: this.context.getPropertyName(property.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(property)\n }));\n }\n default:\n assertNever(named);\n }\n }\n\n private resolvesToLiteralType(typeReference: FernIr.dynamic.TypeReference): boolean {\n switch (typeReference.type) {\n case \"literal\":\n return true;\n case \"optional\":\n case \"nullable\":\n return this.resolvesToLiteralType(typeReference.value);\n case \"named\": {\n const named = this.context.resolveNamedType({ typeId: typeReference.value });\n if (named == null) {\n return false;\n }\n if (named.type === \"alias\") {\n return this.resolvesToLiteralType(named.typeReference);\n }\n return false;\n }\n case \"list\":\n case \"map\":\n case \"set\":\n case \"primitive\":\n case \"unknown\":\n return false;\n default:\n assertNever(typeReference);\n }\n }\n\n private getBodyRequestArgsForBytes({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBody;\n value: unknown;\n }): python.NamedValue[] {\n const typeInstantiation = this.getBytesBodyRequestTypeInstantiation({ value });\n if (python.TypeInstantiation.isNop(typeInstantiation)) {\n return [];\n }\n return [\n {\n name: this.context.getPropertyName(body.bodyKey),\n value: typeInstantiation\n }\n ];\n }\n\n private getBytesBodyRequestTypeInstantiation({ value }: { value: unknown }): python.TypeInstantiation {\n if (typeof value !== \"string\") {\n this.context.errors.add({\n severity: Severity.Critical,\n message: `Expected bytes value to be a string, got ${typeof value}`\n });\n return python.TypeInstantiation.nop();\n }\n return python.TypeInstantiation.bytes(value);\n }\n\n private getMethodArgsForInlinedRequest({\n request,\n snippet\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.NamedValue[] {\n const args: python.NamedValue[] = [];\n\n const inlinePathParameters = this.context.shouldInlinePathParameters();\n\n this.context.errors.scope(Scope.PathParameters);\n const pathParameterFields: python.NamedValue[] = [];\n if (request.pathParameters != null) {\n pathParameterFields.push(...this.getPathParameters({ namedParameters: request.pathParameters, snippet }));\n }\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const filePropertyInfo = this.getFilePropertyInfo({ request, snippet });\n this.context.errors.unscope();\n\n if (\n !this.context.includePathParametersInWrappedRequest({\n request,\n inlinePathParameters\n })\n ) {\n args.push(...pathParameterFields);\n }\n\n if (\n this.context.needsRequestParameter({\n request,\n inlinePathParameters,\n inlineFileProperties: true\n })\n ) {\n args.push(\n ...this.getInlinedRequestArgs({\n request,\n snippet,\n pathParameterFields: this.context.includePathParametersInWrappedRequest({\n request,\n inlinePathParameters\n })\n ? pathParameterFields\n : [],\n filePropertyInfo\n })\n );\n }\n return args;\n }\n\n private getFilePropertyInfo({\n request,\n snippet\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): FilePropertyInfo {\n if (request.body == null || !this.context.isFileUploadRequestBody(request.body)) {\n return {\n fileFields: [],\n bodyPropertyFields: []\n };\n }\n return this.context.filePropertyMapper.getFilePropertyInfo({\n body: request.body,\n value: snippet.requestBody\n });\n }\n\n private getInlinedRequestArgs({\n request,\n snippet,\n pathParameterFields,\n filePropertyInfo\n }: {\n request: FernIr.dynamic.InlinedRequest;\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n pathParameterFields: python.NamedValue[];\n filePropertyInfo: FilePropertyInfo;\n }): python.NamedValue[] {\n this.context.errors.scope(Scope.QueryParameters);\n const queryParameters = this.context.associateQueryParametersByWireValue({\n parameters: request.queryParameters ?? [],\n values: snippet.queryParameters ?? {}\n });\n const queryParameterFields = queryParameters.map((queryParameter) => ({\n name: this.context.getPropertyName(queryParameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(queryParameter)\n }));\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.Headers);\n const headers = this.context.associateByWireValue({\n parameters: request.headers ?? [],\n values: snippet.headers ?? {}\n });\n const headerFields = headers.map((header) => ({\n name: this.context.getPropertyName(header.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(header)\n }));\n this.context.errors.unscope();\n\n this.context.errors.scope(Scope.RequestBody);\n const requestBodyFields =\n request.body != null\n ? this.getInlinedRequestBodyObjectFields({\n body: request.body,\n value: snippet.requestBody,\n filePropertyInfo\n })\n : [];\n this.context.errors.unscope();\n\n return [...pathParameterFields, ...queryParameterFields, ...headerFields, ...requestBodyFields];\n }\n\n private getInlinedRequestBodyObjectFields({\n body,\n value,\n filePropertyInfo\n }: {\n body: FernIr.dynamic.InlinedRequestBody;\n value: unknown;\n filePropertyInfo: FilePropertyInfo;\n }): python.NamedValue[] {\n switch (body.type) {\n case \"properties\":\n return this.getInlinedRequestBodyPropertyObjectFields({ parameters: body.value, value });\n case \"referenced\":\n return this.getReferencedRequestBodyPropertyTypeInstantiation({ body, value });\n case \"fileUpload\":\n return this.getFileUploadRequestBodyObjectFields({ filePropertyInfo });\n default:\n assertNever(body);\n }\n }\n\n private getFileUploadRequestBodyObjectFields({\n filePropertyInfo\n }: {\n filePropertyInfo: FilePropertyInfo;\n }): python.NamedValue[] {\n return [...filePropertyInfo.fileFields, ...filePropertyInfo.bodyPropertyFields];\n }\n\n private getReferencedRequestBodyPropertyTypeInstantiation({\n body,\n value\n }: {\n body: FernIr.dynamic.ReferencedRequestBody;\n value: unknown;\n }): python.NamedValue[] {\n const bodyType = body.bodyType;\n switch (bodyType.type) {\n case \"bytes\":\n return this.getBodyRequestArgsForBytes({ body, value });\n case \"typeReference\":\n return this.getBodyRequestArgsForTypeReference({ typeReference: bodyType.value, value });\n default:\n assertNever(bodyType);\n }\n }\n\n private getInlinedRequestBodyPropertyObjectFields({\n parameters,\n value\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n value: unknown;\n }): python.NamedValue[] {\n const fields: python.NamedValue[] = [];\n\n const bodyProperties = this.context.associateByWireValue({\n parameters,\n values: this.context.getRecord(value) ?? {}\n });\n\n const nonLiteralBodyProperties = bodyProperties.filter(\n (parameter) => !this.resolvesToLiteralType(parameter.typeReference)\n );\n\n for (const parameter of nonLiteralBodyProperties) {\n fields.push({\n name: this.context.getPropertyName(parameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(parameter)\n });\n }\n\n return fields;\n }\n\n private getPathParameters({\n namedParameters,\n snippet\n }: {\n namedParameters: FernIr.dynamic.NamedParameter[];\n snippet: FernIr.dynamic.EndpointSnippetRequest;\n }): python.NamedValue[] {\n const args: python.NamedValue[] = [];\n\n const nonLiteralPathParameters = namedParameters.filter(\n (parameter) => !this.resolvesToLiteralType(parameter.typeReference)\n );\n\n const pathParameters = this.context.associateByWireValue({\n parameters: nonLiteralPathParameters,\n values: snippet.pathParameters ?? {},\n\n // Path parameters are distributed across the client constructor\n // and the request method, so we ignore missing parameters here.\n ignoreMissingParameters: true\n });\n for (const parameter of pathParameters) {\n args.push({\n name: this.context.getPropertyName(parameter.name.name),\n value: this.context.dynamicTypeLiteralMapper.convert(parameter)\n });\n }\n\n return args;\n }\n\n private getMethod({ endpoint }: { endpoint: FernIr.dynamic.Endpoint }): string {\n if (endpoint.declaration.fernFilepath.allParts.length > 0) {\n return `${endpoint.declaration.fernFilepath.allParts\n .map((val) => this.context.getMethodName(val))\n .join(\".\")}.${this.context.getMethodName(endpoint.declaration.name)}`;\n }\n return this.context.getMethodName(endpoint.declaration.name);\n }\n\n private getEnvironmentOptionName({\n environment\n }: {\n environment: FernIr.dynamic.EnvironmentValues | undefined;\n }): string {\n if (environment != null) {\n return \"environment\";\n }\n return \"base_url\";\n }\n}\n"],"mappings":"iIAAAA,IAAAC,IAQA,IAAMC,EAAsD,CACxD,KAAM,YACN,MAAO,QACX,EACMC,EAAsB,CAAC,SAAS,EAChCC,EAAkB,SAClBC,EAAwB,UAEjBC,EAAN,KAA+B,CAGlC,YAAY,CAAE,QAAAC,CAAQ,EAAiD,CAFvEC,EAAA,KAAQ,WAGJ,KAAK,QAAUD,CACnB,CAEA,MAAa,gBAAgB,CACzB,SAAAE,EACA,QAAAC,CACJ,EAGoB,CAEhB,OADa,KAAK,gBAAgB,CAAE,SAAAD,EAA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S,OAAS,EAC7C,GAAGA,EAAS,YAAY,aAAa,SACvC,IAAKqD,GAAQ,KAAK,QAAQ,cAAcA,CAAG,CAAC,EAC5C,KAAK,GAAG,CAAC,IAAI,KAAK,QAAQ,cAAcrD,EAAS,YAAY,IAAI,CAAC,GAEpE,KAAK,QAAQ,cAAcA,EAAS,YAAY,IAAI,CAC/D,CAEQ,yBAAyB,CAC7B,YAAAU,CACJ,EAEW,CACP,OAAIA,GAAe,KACR,cAEJ,UACX,CACJ","names":["init_process","init_buffer","STRING_TYPE_REFERENCE","SNIPPET_MODULE_PATH","CLIENT_VAR_NAME","REQUEST_BODY_ARG_NAME","EndpointSnippetGenerator","context","__publicField","endpoint","request","snippet","python_exports","arg","fields","environmentArgs","Severity","Scope","baseUrl","environment","environmentValue","environmentTypeReference","key","value","auth","values","assertNever","message","headers","header","field","typeLiteral","_a","_b","args","pathParameters","bodyPropertyNames","bodyArgs","disambiguatedPathArgs","__spreadProps","__spreadValues","body","typeReference","named","innerType","property","typeInstantiation","inlinePathParameters","pathParameterFields","filePropertyInfo","_c","_d","queryParameterFields","queryParameter","headerFields","requestBodyFields","bodyType","parameters","nonLiteralBodyProperties","parameter","namedParameters","nonLiteralPathParameters","val"]}
@@ -0,0 +1,2 @@
1
+ import{e as l,f as s,g as y,h as c,j as a}from"./chunk-NHAFJ5OA.js";s();y();var d=class{constructor({context:t}){l(this,"context");this.context=t}getFilePropertyInfo({body:t,value:i}){var p;let e={fileFields:[],bodyPropertyFields:[]},r=(p=this.context.getRecord(i))!=null?p:{};for(let n of t.properties)switch(n.type){case"file":{let o=this.getSingleFileProperty({property:n,record:r});if(a.TypeInstantiation.isNop(o))break;e.fileFields.push({name:this.context.getPropertyName(n.name),value:o});break}case"fileArray":{let o=this.getArrayFileProperty({property:n,record:r});if(a.TypeInstantiation.isNop(o))break;e.fileFields.push({name:this.context.getPropertyName(n.name),value:o});break}case"bodyProperty":{let o=this.getBodyProperty({property:n,record:r});if(a.TypeInstantiation.isNop(o))break;e.bodyPropertyFields.push({name:this.context.getPropertyName(n.name.name),value:o});break}default:c(n)}return e}getSingleFileProperty({property:t,record:i}){var r;let e=this.context.getSingleFileValue({property:t,record:i});return e==null&&(e=`example_${(r=t.wireValue)!=null?r:"file"}`),this.context.getFileFromString(e)}getArrayFileProperty({property:t,record:i}){let e=this.context.getFileArrayValues({property:t,record:i});return e==null?a.TypeInstantiation.nop():a.TypeInstantiation.list(e.map(r=>this.context.getFileFromString(r)))}getBodyProperty({property:t,record:i}){let e=i[t.name.wireValue];return e==null?a.TypeInstantiation.nop():this.context.dynamicTypeLiteralMapper.convert({typeReference:t.typeReference,value:e})}};export{d as a};
2
+ //# sourceMappingURL=chunk-2SPAKVUZ.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/context/FilePropertyMapper.ts"],"sourcesContent":["import { assertNever } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { python } from \"@fern-api/python-ast\";\n\nimport { DynamicSnippetsGeneratorContext } from \"./DynamicSnippetsGeneratorContext\";\n\nexport interface FilePropertyInfo {\n fileFields: python.NamedValue[];\n bodyPropertyFields: python.NamedValue[];\n}\n\nexport class FilePropertyMapper {\n private context: DynamicSnippetsGeneratorContext;\n\n constructor({ context }: { context: DynamicSnippetsGeneratorContext }) {\n this.context = context;\n }\n\n public getFilePropertyInfo({\n body,\n value\n }: {\n body: FernIr.dynamic.FileUploadRequestBody;\n value: unknown;\n }): FilePropertyInfo {\n const result: FilePropertyInfo = {\n fileFields: [],\n bodyPropertyFields: []\n };\n const record = this.context.getRecord(value) ?? {};\n for (const property of body.properties) {\n switch (property.type) {\n case \"file\": {\n const value = this.getSingleFileProperty({ property, record });\n if (python.TypeInstantiation.isNop(value)) {\n break;\n }\n result.fileFields.push({\n name: this.context.getPropertyName(property.name),\n value\n });\n break;\n }\n case \"fileArray\": {\n const value = this.getArrayFileProperty({ property, record });\n if (python.TypeInstantiation.isNop(value)) {\n break;\n }\n result.fileFields.push({\n name: this.context.getPropertyName(property.name),\n value\n });\n break;\n }\n case \"bodyProperty\": {\n const value = this.getBodyProperty({ property, record });\n if (python.TypeInstantiation.isNop(value)) {\n break;\n }\n result.bodyPropertyFields.push({\n name: this.context.getPropertyName(property.name.name),\n value\n });\n break;\n }\n default:\n assertNever(property);\n }\n }\n return result;\n }\n\n private getSingleFileProperty({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.File_;\n record: Record<string, unknown>;\n }): python.TypeInstantiation {\n let fileValue = this.context.getSingleFileValue({ property, record });\n\n if (fileValue == null) {\n fileValue = `example_${property.wireValue ?? \"file\"}`;\n }\n\n return this.context.getFileFromString(fileValue);\n }\n\n private getArrayFileProperty({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.FileArray;\n record: Record<string, unknown>;\n }): python.TypeInstantiation {\n const fileValues = this.context.getFileArrayValues({ property, record });\n if (fileValues == null) {\n return python.TypeInstantiation.nop();\n }\n return python.TypeInstantiation.list(fileValues.map((value) => this.context.getFileFromString(value)));\n }\n\n private getBodyProperty({\n property,\n record\n }: {\n property: FernIr.dynamic.NamedParameter;\n record: Record<string, unknown>;\n }): python.TypeInstantiation {\n const bodyPropertyValue = record[property.name.wireValue];\n if (bodyPropertyValue == null) {\n return python.TypeInstantiation.nop();\n }\n return this.context.dynamicTypeLiteralMapper.convert({\n typeReference: property.typeReference,\n value: bodyPropertyValue\n });\n }\n}\n"],"mappings":"oEAAAA,IAAAC,IAWO,IAAMC,EAAN,KAAyB,CAG5B,YAAY,CAAE,QAAAC,CAAQ,EAAiD,CAFvEC,EAAA,KAAQ,WAGJ,KAAK,QAAUD,CACnB,CAEO,oBAAoB,CACvB,KAAAE,EACA,MAAAC,CACJ,EAGqB,CAxBzB,IAAAC,EAyBQ,IAAMC,EAA2B,CAC7B,WAAY,CAAC,EACb,mBAAoB,CAAC,CACzB,EACMC,GAASF,EAAA,KAAK,QAAQ,UAAUD,CAAK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AK,QAAQ,mBAAmB,CAAE,SAAAJ,EAAU,OAAAD,CAAO,CAAC,EACvE,OAAIK,GAAc,KACPH,EAAO,kBAAkB,IAAI,EAEjCA,EAAO,kBAAkB,KAAKG,EAAW,IAAKR,GAAU,KAAK,QAAQ,kBAAkBA,CAAK,CAAC,CAAC,CACzG,CAEQ,gBAAgB,CACpB,SAAAI,EACA,OAAAD,CACJ,EAG6B,CACzB,IAAMM,EAAoBN,EAAOC,EAAS,KAAK,SAAS,EACxD,OAAIK,GAAqB,KACdJ,EAAO,kBAAkB,IAAI,EAEjC,KAAK,QAAQ,yBAAyB,QAAQ,CACjD,cAAeD,EAAS,cACxB,MAAOK,CACX,CAAC,CACL,CACJ","names":["init_process","init_buffer","FilePropertyMapper","context","__publicField","body","value","_a","result","record","property","python_exports","assertNever","fileValue","fileValues","bodyPropertyValue"]}
@@ -1,2 +1,2 @@
1
- import{b as s}from"./chunk-AK6ZQDEA.js";import{e as p,f as u,g as l,h as c,j as r}from"./chunk-YEXRWSXV.js";u();l();var d="value",y=class{constructor({context:e}){p(this,"context");this.context=e}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?r.TypeInstantiation.none():(this.context.errors.add({severity:s.Critical,message:"Expected non-null value, but got null"}),r.TypeInstantiation.nop());if(e.value===void 0)return r.TypeInstantiation.nop();switch(e.typeReference.type){case"list":return this.convertList({list:e.typeReference.value,value:e.value});case"literal":return this.convertLiteral({literalType:e.typeReference.value,value:e.value});case"map":return this.convertMap({map:e.typeReference,value:e.value});case"named":{let t=this.context.resolveNamedType({typeId:e.typeReference.value});return t==null?r.TypeInstantiation.nop():this.convertNamed({named:t,value:e.value,as:e.as})}case"optional":return this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as});case"nullable":return this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as});case"primitive":return this.convertPrimitive({primitive:e.typeReference.value,value:e.value,as:e.as});case"set":return this.convertSet({set:e.typeReference.value,value:e.value});case"unknown":return r.TypeInstantiation.unknown(e.value);default:c(e.typeReference)}}convertLiteral({literalType:e,value:t}){switch(e.type){case"boolean":{let i=this.context.getValueAsBoolean({value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.bool(i)}case"string":{let i=this.context.getValueAsString({value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.str(i)}default:c(e)}}convertList({list:e,value:t}){return Array.isArray(t)?r.TypeInstantiation.list(t.map((i,n)=>{this.context.errors.scope({index:n});try{return this.convert({typeReference:e,value:i})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:s.Critical,message:`Expected array but got: ${typeof t}`}),r.TypeInstantiation.nop())}convertSet({set:e,value:t}){return Array.isArray(t)?r.TypeInstantiation.list(t.map((i,n)=>{this.context.errors.scope({index:n});try{return this.convert({typeReference:e,value:i})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:s.Critical,message:`Expected array but got: ${typeof t}`}),r.TypeInstantiation.nop())}convertMap({map:e,value:t}){return typeof t!="object"||t==null?(this.context.errors.add({severity:s.Critical,message:`Expected object but got: ${t==null?"null":typeof t}`}),r.TypeInstantiation.nop()):r.TypeInstantiation.dict(Object.entries(t).map(([i,n])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:e.key,value:i,as:"key"}),value:this.convert({typeReference:e.value,value:n})}}finally{this.context.errors.unscope()}}),{multiline:!0})}convertNamed({named:e,value:t,as:i}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference,value:t,as:i});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:e,value:t});case"enum":return this.convertEnum({enum_:e,value:t});case"object":return this.convertObject({object_:e,value:t});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t});default:c(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:t}){let i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t});if(i==null)return r.TypeInstantiation.nop();let n=i.singleDiscriminatedUnionType,a=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:i,unionVariant:n});if(a==null)return r.TypeInstantiation.nop();let o={name:this.context.getPropertyName(e.discriminant.name),value:r.TypeInstantiation.str(n.discriminantValue.wireValue)};return r.TypeInstantiation.typedDict([o,...a],{multiline:!0})}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:e,unionVariant:t}){let i=this.getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t});switch(t.type){case"samePropertiesAsObject":{let n=this.context.resolveNamedType({typeId:t.typeId});if(n==null)return;let a=this.convertNamed({named:n,value:e.value});if(!a.isTypedDict()){this.context.errors.add({severity:s.Critical,message:"Internal error; expected union value to be an object"});return}let o=a.asTypedDictOrThrow();return[...i,...o.entries]}case"singleProperty":try{this.context.errors.scope(t.discriminantValue.wireValue);let n=this.context.getRecord(e.value);return n==null?[...i,{name:d,value:this.convert({typeReference:t.typeReference,value:e.value})}]:[...i,{name:this.context.getPropertyName(t.discriminantValue.name),value:this.convert({typeReference:t.typeReference,value:n[t.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return i;default:c(t)}}getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t}){var n,a;return this.context.associateByWireValue({parameters:(n=t.properties)!=null?n:[],values:(a=this.context.getRecord(e.value))!=null?a:{},ignoreMissingParameters:!0}).map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getPropertyName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})}convertObject({object_:e,value:t}){var n;let i=this.context.associateByWireValue({parameters:e.properties,values:(n=this.context.getRecord(t))!=null?n:{}});return r.TypeInstantiation.typedDict(i.map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getPropertyName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}}),{multiline:!0})}convertEnum({enum_:e,value:t}){let i=this.getEnumValue({enum_:e,value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.str(i)}getEnumValue({enum_:e,value:t}){if(typeof t!="string"){this.context.errors.add({severity:s.Critical,message:`Expected enum value string, got: ${typeof t}`});return}if(e.values.find(n=>n.wireValue===t)==null){this.context.errors.add({severity:s.Critical,message:`An enum value named "${t}" does not exist in this context`});return}return t}convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t});return i==null?r.TypeInstantiation.nop():i}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t}){for(let i of e.types)try{return this.convert({typeReference:i,value:t})}catch(n){continue}this.context.errors.add({severity:s.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof t}" value`})}convertPrimitive({primitive:e,value:t,as:i}){switch(e){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let n=this.getValueAsNumber({value:t,as:i});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.int(n)}case"FLOAT":case"DOUBLE":{let n=this.getValueAsNumber({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.float(n)}case"BOOLEAN":{let n=this.getValueAsBoolean({value:t,as:i});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.bool(n)}case"BASE_64":case"BIG_INTEGER":case"STRING":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.str(n)}case"UUID":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.uuid(n)}case"DATE":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.date(n)}case"DATE_TIME":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.datetime(n)}default:c(e)}}getValueAsNumber({value:e,as:t}){let i=t==="key"&&typeof e=="string"?Number(e):e;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:e,as:t}){let i=t==="key"?typeof e=="string"?e==="true":e==="false"?!1:e:e;return this.context.getValueAsBoolean({value:i})}};export{y as a};
2
- //# sourceMappingURL=chunk-W7SA7MNB.js.map
1
+ import{b as s}from"./chunk-ULECZXWB.js";import{e as p,f as u,g as l,h as c,j as r}from"./chunk-NHAFJ5OA.js";u();l();var d="value",y=class{constructor({context:e}){p(this,"context");this.context=e}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?r.TypeInstantiation.none():(this.context.errors.add({severity:s.Critical,message:"Expected non-null value, but got null"}),r.TypeInstantiation.nop());if(e.value===void 0)return r.TypeInstantiation.nop();switch(e.typeReference.type){case"list":return this.convertList({list:e.typeReference.value,value:e.value});case"literal":return this.convertLiteral({literalType:e.typeReference.value,value:e.value});case"map":return this.convertMap({map:e.typeReference,value:e.value});case"named":{let t=this.context.resolveNamedType({typeId:e.typeReference.value});return t==null?r.TypeInstantiation.nop():this.convertNamed({named:t,value:e.value,as:e.as})}case"optional":return this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as});case"nullable":return this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as});case"primitive":return this.convertPrimitive({primitive:e.typeReference.value,value:e.value,as:e.as});case"set":return this.convertSet({set:e.typeReference.value,value:e.value});case"unknown":return r.TypeInstantiation.unknown(e.value);default:c(e.typeReference)}}convertLiteral({literalType:e,value:t}){switch(e.type){case"boolean":{let i=this.context.getValueAsBoolean({value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.bool(i)}case"string":{let i=this.context.getValueAsString({value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.str(i)}default:c(e)}}convertList({list:e,value:t}){return Array.isArray(t)?r.TypeInstantiation.list(t.map((i,n)=>{this.context.errors.scope({index:n});try{return this.convert({typeReference:e,value:i})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:s.Critical,message:`Expected array but got: ${typeof t}`}),r.TypeInstantiation.nop())}convertSet({set:e,value:t}){return Array.isArray(t)?r.TypeInstantiation.list(t.map((i,n)=>{this.context.errors.scope({index:n});try{return this.convert({typeReference:e,value:i})}finally{this.context.errors.unscope()}}),{multiline:!0}):(this.context.errors.add({severity:s.Critical,message:`Expected array but got: ${typeof t}`}),r.TypeInstantiation.nop())}convertMap({map:e,value:t}){return typeof t!="object"||t==null?(this.context.errors.add({severity:s.Critical,message:`Expected object but got: ${t==null?"null":typeof t}`}),r.TypeInstantiation.nop()):r.TypeInstantiation.dict(Object.entries(t).map(([i,n])=>{this.context.errors.scope(i);try{return{key:this.convert({typeReference:e.key,value:i,as:"key"}),value:this.convert({typeReference:e.value,value:n})}}finally{this.context.errors.unscope()}}),{multiline:!0})}convertNamed({named:e,value:t,as:i}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference,value:t,as:i});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:e,value:t});case"enum":return this.convertEnum({enum_:e,value:t});case"object":return this.convertObject({object_:e,value:t});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t});default:c(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:t}){let i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t});if(i==null)return r.TypeInstantiation.nop();let n=i.singleDiscriminatedUnionType,a=this.convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:i,unionVariant:n});if(a==null)return r.TypeInstantiation.nop();let o={name:this.context.getPropertyName(e.discriminant.name),value:r.TypeInstantiation.str(n.discriminantValue.wireValue)};return r.TypeInstantiation.typedDict([o,...a],{multiline:!0})}convertDiscriminatedUnionProperties({discriminatedUnionTypeInstance:e,unionVariant:t}){let i=this.getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t});switch(t.type){case"samePropertiesAsObject":{let n=this.context.resolveNamedType({typeId:t.typeId});if(n==null)return;let a=this.convertNamed({named:n,value:e.value});if(!a.isTypedDict()){this.context.errors.add({severity:s.Critical,message:"Internal error; expected union value to be an object"});return}let o=a.asTypedDictOrThrow();return[...i,...o.entries]}case"singleProperty":try{this.context.errors.scope(t.discriminantValue.wireValue);let n=this.context.getRecord(e.value);return n==null?[...i,{name:d,value:this.convert({typeReference:t.typeReference,value:e.value})}]:[...i,{name:this.context.getPropertyName(t.discriminantValue.name),value:this.convert({typeReference:t.typeReference,value:n[t.discriminantValue.wireValue]})}]}finally{this.context.errors.unscope()}case"noProperties":return i;default:c(t)}}getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t}){var n,a;return this.context.associateByWireValue({parameters:(n=t.properties)!=null?n:[],values:(a=this.context.getRecord(e.value))!=null?a:{},ignoreMissingParameters:!0}).map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getPropertyName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})}convertObject({object_:e,value:t}){var n;let i=this.context.associateByWireValue({parameters:e.properties,values:(n=this.context.getRecord(t))!=null?n:{}});return r.TypeInstantiation.typedDict(i.map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getPropertyName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}}),{multiline:!0})}convertEnum({enum_:e,value:t}){let i=this.getEnumValue({enum_:e,value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.str(i)}getEnumValue({enum_:e,value:t}){if(typeof t!="string"){this.context.errors.add({severity:s.Critical,message:`Expected enum value string, got: ${typeof t}`});return}if(e.values.find(n=>n.wireValue===t)==null){this.context.errors.add({severity:s.Critical,message:`An enum value named "${t}" does not exist in this context`});return}return t}convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t}){let i=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t});return i==null?r.TypeInstantiation.nop():i}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t}){for(let i of e.types)try{return this.convert({typeReference:i,value:t})}catch(n){continue}this.context.errors.add({severity:s.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof t}" value`})}convertPrimitive({primitive:e,value:t,as:i}){switch(e){case"INTEGER":case"LONG":case"UINT":case"UINT_64":{let n=this.getValueAsNumber({value:t,as:i});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.int(n)}case"FLOAT":case"DOUBLE":{let n=this.getValueAsNumber({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.float(n)}case"BOOLEAN":{let n=this.getValueAsBoolean({value:t,as:i});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.bool(n)}case"BASE_64":case"BIG_INTEGER":case"STRING":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.str(n)}case"UUID":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.uuid(n)}case"DATE":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.date(n)}case"DATE_TIME":{let n=this.context.getValueAsString({value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.datetime(n)}default:c(e)}}getValueAsNumber({value:e,as:t}){let i=t==="key"&&typeof e=="string"?Number(e):e;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:e,as:t}){let i=t==="key"?typeof e=="string"?e==="true":e==="false"?!1:e:e;return this.context.getValueAsBoolean({value:i})}};export{y as a};
2
+ //# sourceMappingURL=chunk-3XEFLXHY.js.map
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-6JNSYN57.js";import{a as i}from"./chunk-XX42ILF7.js";import{a as p}from"./chunk-AK6ZQDEA.js";import{f as r,g as o}from"./chunk-YEXRWSXV.js";r();o();var c=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){return super.generateSnippetAst(e)}generateMethodCallSnippetAst(e){let n=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(n.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let t;for(let s of n){let d=this.context.clone(),m=this.createSnippetGenerator(d);try{return m.generateMethodCallSnippetAst({endpoint:s,request:e})}catch(S){t=S}}throw t!=null?t:new Error(`Failed to generate method call snippet AST for endpoint: ${e.endpoint.method} ${e.endpoint.path}`)}createSnippetGenerator(e){return new a({context:e})}};export{c as a};
2
- //# sourceMappingURL=chunk-BZ5ZJPTG.js.map
1
+ import{a}from"./chunk-2KHLQG2A.js";import{a as i}from"./chunk-HGKGDQ5J.js";import{a as p}from"./chunk-ULECZXWB.js";import{f as r,g as o}from"./chunk-NHAFJ5OA.js";r();o();var c=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){return super.generateSnippetAst(e)}generateMethodCallSnippetAst(e){let n=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(n.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let t;for(let s of n){let d=this.context.clone(),m=this.createSnippetGenerator(d);try{return m.generateMethodCallSnippetAst({endpoint:s,request:e})}catch(S){t=S}}throw t!=null?t:new Error(`Failed to generate method call snippet AST for endpoint: ${e.endpoint.method} ${e.endpoint.path}`)}createSnippetGenerator(e){return new a({context:e})}};export{c as a};
2
+ //# sourceMappingURL=chunk-DP6NTUTQ.js.map
@@ -1,4 +1,4 @@
1
- import{a as A}from"./chunk-W7SA7MNB.js";import{c as S}from"./chunk-AK6ZQDEA.js";import{a as O}from"./chunk-2FBSEQ3K.js";import{e as x,f as t,g as a,h as b,j as i}from"./chunk-YEXRWSXV.js";t();a();t();a();t();a();t();a();t();a();t();a();t();a();var Ie=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,N=Ie;var ke=typeof self=="object"&&self&&self.Object===Object&&self,Ee=N||ke||Function("return this")(),I=Ee;var Te=I.Symbol,p=Te;t();a();var k=Object.prototype,Me=k.hasOwnProperty,we=k.toString,c=p?p.toStringTag:void 0;function je(e){var o=Me.call(e,c),r=e[c];try{e[c]=void 0;var f=!0}catch(m){}var l=we.call(e);return f&&(o?e[c]=r:delete e[c]),l}var E=je;t();a();var Pe=Object.prototype,We=Pe.toString;function Le(e){return We.call(e)}var T=Le;var Ue="[object Null]",ze="[object Undefined]",M=p?p.toStringTag:void 0;function Be(e){return e==null?e===void 0?ze:Ue:M&&M in Object(e)?E(e):T(e)}var w=Be;t();a();function Fe(e){return e!=null&&typeof e=="object"}var j=Fe;var De="[object Symbol]";function _e(e){return typeof e=="symbol"||j(e)&&w(e)==De}var P=_e;t();a();t();a();function Ze(e,o){for(var r=-1,f=e==null?0:e.length,l=Array(f);++r<f;)l[r]=o(e[r],r,e);return l}var W=Ze;t();a();var Ge=Array.isArray,L=Ge;var qe=1/0,U=p?p.prototype:void 0,z=U?U.toString:void 0;function B(e){if(typeof e=="string")return e;if(L(e))return W(e,B)+"";if(P(e))return z?z.call(e):"";var o=e+"";return o=="0"&&1/e==-qe?"-0":o}var F=B;t();a();function He(e){return e==null?"":F(e)}var n=He;t();a();t();a();t();a();t();a();t();a();t();a();function Ve(e,o,r){var f=-1,l=e.length;o<0&&(o=-o>l?0:l+o),r=r>l?l:r,r<0&&(r+=l),l=o>r?0:r-o>>>0,o>>>=0;for(var m=Array(l);++f<l;)m[f]=e[f+o];return m}var D=Ve;function Je(e,o,r){var f=e.length;return r=r===void 0?f:r,!o&&r>=f?e:D(e,o,r)}var _=Je;t();a();var Ke="\\ud800-\\udfff",$e="\\u0300-\\u036f",Ye="\\ufe20-\\ufe2f",Qe="\\u20d0-\\u20ff",Xe=$e+Ye+Qe,er="\\ufe0e\\ufe0f",rr="\\u200d",tr=RegExp("["+rr+Ke+Xe+er+"]");function ar(e){return tr.test(e)}var g=ar;t();a();t();a();function or(e){return e.split("")}var Z=or;t();a();var G="\\ud800-\\udfff",fr="\\u0300-\\u036f",ur="\\ufe20-\\ufe2f",sr="\\u20d0-\\u20ff",lr=fr+ur+sr,pr="\\ufe0e\\ufe0f",nr="["+G+"]",y="["+lr+"]",C="\\ud83c[\\udffb-\\udfff]",mr="(?:"+y+"|"+C+")",q="[^"+G+"]",H="(?:\\ud83c[\\udde6-\\uddff]){2}",V="[\\ud800-\\udbff][\\udc00-\\udfff]",ir="\\u200d",J=mr+"?",K="["+pr+"]?",dr="(?:"+ir+"(?:"+[q,H,V].join("|")+")"+K+J+")*",xr=K+J+dr,cr="(?:"+[q+y+"?",y,H,V,nr].join("|")+")",gr=RegExp(C+"(?="+C+")|"+cr+xr,"g");function hr(e){return e.match(gr)||[]}var $=hr;function br(e){return g(e)?$(e):Z(e)}var Y=br;function yr(e){return function(o){o=n(o);var r=g(o)?Y(o):void 0,f=r?r[0]:o.charAt(0),l=r?_(r,1).join(""):o.slice(1);return f[e]()+l}}var Q=yr;var Cr=Q("toUpperCase"),X=Cr;function Rr(e){return X(n(e).toLowerCase())}var ee=Rr;t();a();t();a();function vr(e,o,r,f){var l=-1,m=e==null?0:e.length;for(f&&m&&(r=e[++l]);++l<m;)r=o(r,e[l],l,e);return r}var re=vr;t();a();t();a();t();a();function Sr(e){return function(o){return e==null?void 0:e[o]}}var te=Sr;var Ar={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Or=te(Ar),ae=Or;var Nr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ir="\\u0300-\\u036f",kr="\\ufe20-\\ufe2f",Er="\\u20d0-\\u20ff",Tr=Ir+kr+Er,Mr="["+Tr+"]",wr=RegExp(Mr,"g");function jr(e){return e=n(e),e&&e.replace(Nr,ae).replace(wr,"")}var oe=jr;t();a();t();a();var Pr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Wr(e){return e.match(Pr)||[]}var fe=Wr;t();a();var Lr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Ur(e){return Lr.test(e)}var ue=Ur;t();a();var me="\\ud800-\\udfff",zr="\\u0300-\\u036f",Br="\\ufe20-\\ufe2f",Fr="\\u20d0-\\u20ff",Dr=zr+Br+Fr,ie="\\u2700-\\u27bf",de="a-z\\xdf-\\xf6\\xf8-\\xff",_r="\\xac\\xb1\\xd7\\xf7",Zr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Gr="\\u2000-\\u206f",qr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",xe="A-Z\\xc0-\\xd6\\xd8-\\xde",Hr="\\ufe0e\\ufe0f",ce=_r+Zr+Gr+qr,ge="['\u2019]",se="["+ce+"]",Vr="["+Dr+"]",he="\\d+",Jr="["+ie+"]",be="["+de+"]",ye="[^"+me+ce+he+ie+de+xe+"]",Kr="\\ud83c[\\udffb-\\udfff]",$r="(?:"+Vr+"|"+Kr+")",Yr="[^"+me+"]",Ce="(?:\\ud83c[\\udde6-\\uddff]){2}",Re="[\\ud800-\\udbff][\\udc00-\\udfff]",d="["+xe+"]",Qr="\\u200d",le="(?:"+be+"|"+ye+")",Xr="(?:"+d+"|"+ye+")",pe="(?:"+ge+"(?:d|ll|m|re|s|t|ve))?",ne="(?:"+ge+"(?:D|LL|M|RE|S|T|VE))?",ve=$r+"?",Se="["+Hr+"]?",et="(?:"+Qr+"(?:"+[Yr,Ce,Re].join("|")+")"+Se+ve+")*",rt="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",tt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",at=Se+ve+et,ot="(?:"+[Jr,Ce,Re].join("|")+")"+at,ft=RegExp([d+"?"+be+"+"+pe+"(?="+[se,d,"$"].join("|")+")",Xr+"+"+ne+"(?="+[se,d+le,"$"].join("|")+")",d+"?"+le+"+"+pe,d+"+"+ne,tt,rt,he,ot].join("|"),"g");function ut(e){return e.match(ft)||[]}var Ae=ut;function st(e,o,r){return e=n(e),o=r?void 0:o,o===void 0?ue(e)?Ae(e):fe(e):e.match(o)||[]}var Oe=st;var lt="['\u2019]",pt=RegExp(lt,"g");function nt(e){return function(o){return re(Oe(oe(o).replace(pt,"")),e,"")}}var h=nt;var mt=h(function(e,o,r){return o=o.toLowerCase(),e+(r?ee(o):o)}),R=mt;t();a();var it=h(function(e,o,r){return e+(r?"_":"")+o.toLowerCase()}),v=it;var dt=["list","set"],Ne=class e extends S{constructor({ir:r,config:f}){var l;super({ir:r,config:f});x(this,"ir");x(this,"customConfig");x(this,"dynamicTypeLiteralMapper");x(this,"filePropertyMapper");this.ir=r,this.customConfig=(l=f.customConfig)!=null?l:{},this.dynamicTypeLiteralMapper=new A({context:this}),this.filePropertyMapper=new O({context:this})}clone(){return new e({ir:this.ir,config:this.config})}getClassName(r){let f=r.pascalCase.safeName,l=this.getRootClientClassName();return f===l?`${l}Model`:f}getTypedDictClassName(r){return`${this.getClassName(r)}Params`}getPropertyName(r){let f=r.snakeCase.safeName;return f.startsWith("_")?"f_"+f.substring(f.lastIndexOf("_")+1):f}getMethodName(r){return dt.includes(r.snakeCase.unsafeName)?r.snakeCase.unsafeName:r.snakeCase.safeName}getRootClientClassReference(){return i.reference({name:this.getRootClientClassName(),modulePath:this.getRootModulePath()})}getRootClientClassName(){var r,f;return((r=this.customConfig.client)==null?void 0:r.exported_class_name)!=null?this.customConfig.client.exported_class_name:this.customConfig.client_class_name!=null?this.customConfig.client_class_name:((f=this.customConfig.client)==null?void 0:f.class_name)!=null?this.customConfig.client.class_name:this.pascalCase(this.config.organization)+this.pascalCase(this.config.workspaceName)}getEnvironmentClassName(){return`${this.getRootClientClassName()}Environment`}getEnvironmentTypeReferenceFromID(r){let f=this.resolveEnvironmentName(r);if(f!=null)return i.accessAttribute({lhs:this.getEnvironmentClassReference(),rhs:i.codeBlock(this.getEnvironmentEnumName(f))})}getEnvironmentClassReference(){return i.reference({name:this.getEnvironmentClassName(),modulePath:this.getEnvironmentModulePath()})}getEnvironmentEnumName(r){return r.screamingSnakeCase.safeName}isPrimitive(r){switch(r.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(r.value);case"named":{let f=this.resolveNamedType({typeId:r.value});if(f==null)return!1;switch(f.type){case"alias":return this.isPrimitive(f.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:b(f)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:b(r)}}getFileFromString(r){return i.TypeInstantiation.str(r)}getRootModulePath(){if(this.customConfig.package_name!=null)return[this.customConfig.package_name];let r=this.cleanOrganizationName();return this.customConfig.use_api_name_in_package?[r,this.getApiName()]:[r]}getCoreModulePath(){return this.getRootModulePath().concat("core")}getEnvironmentModulePath(){return this.getRootModulePath().concat("environment")}shouldInlinePathParameters(){return!0}cleanOrganizationName(){return this.config.organization.replace(/[^a-zA-Z0-9]/g,"_")}getApiName(){return v(this.config.workspaceName)}pascalCase(r){let f=R(r);return f.charAt(0).toUpperCase()+f.slice(1)}};export{Ne as a};
1
+ import{a as A}from"./chunk-3XEFLXHY.js";import{c as S}from"./chunk-ULECZXWB.js";import{a as O}from"./chunk-2SPAKVUZ.js";import{e as x,f as t,g as a,h as b,j as i}from"./chunk-NHAFJ5OA.js";t();a();t();a();t();a();t();a();t();a();t();a();t();a();var Ie=typeof globalThis=="object"&&globalThis&&globalThis.Object===Object&&globalThis,N=Ie;var ke=typeof self=="object"&&self&&self.Object===Object&&self,Ee=N||ke||Function("return this")(),I=Ee;var Te=I.Symbol,p=Te;t();a();var k=Object.prototype,Me=k.hasOwnProperty,we=k.toString,c=p?p.toStringTag:void 0;function je(e){var o=Me.call(e,c),r=e[c];try{e[c]=void 0;var f=!0}catch(m){}var l=we.call(e);return f&&(o?e[c]=r:delete e[c]),l}var E=je;t();a();var Pe=Object.prototype,We=Pe.toString;function Le(e){return We.call(e)}var T=Le;var Ue="[object Null]",ze="[object Undefined]",M=p?p.toStringTag:void 0;function Be(e){return e==null?e===void 0?ze:Ue:M&&M in Object(e)?E(e):T(e)}var w=Be;t();a();function Fe(e){return e!=null&&typeof e=="object"}var j=Fe;var De="[object Symbol]";function _e(e){return typeof e=="symbol"||j(e)&&w(e)==De}var P=_e;t();a();t();a();function Ze(e,o){for(var r=-1,f=e==null?0:e.length,l=Array(f);++r<f;)l[r]=o(e[r],r,e);return l}var W=Ze;t();a();var Ge=Array.isArray,L=Ge;var qe=1/0,U=p?p.prototype:void 0,z=U?U.toString:void 0;function B(e){if(typeof e=="string")return e;if(L(e))return W(e,B)+"";if(P(e))return z?z.call(e):"";var o=e+"";return o=="0"&&1/e==-qe?"-0":o}var F=B;t();a();function He(e){return e==null?"":F(e)}var n=He;t();a();t();a();t();a();t();a();t();a();t();a();function Ve(e,o,r){var f=-1,l=e.length;o<0&&(o=-o>l?0:l+o),r=r>l?l:r,r<0&&(r+=l),l=o>r?0:r-o>>>0,o>>>=0;for(var m=Array(l);++f<l;)m[f]=e[f+o];return m}var D=Ve;function Je(e,o,r){var f=e.length;return r=r===void 0?f:r,!o&&r>=f?e:D(e,o,r)}var _=Je;t();a();var Ke="\\ud800-\\udfff",$e="\\u0300-\\u036f",Ye="\\ufe20-\\ufe2f",Qe="\\u20d0-\\u20ff",Xe=$e+Ye+Qe,er="\\ufe0e\\ufe0f",rr="\\u200d",tr=RegExp("["+rr+Ke+Xe+er+"]");function ar(e){return tr.test(e)}var g=ar;t();a();t();a();function or(e){return e.split("")}var Z=or;t();a();var G="\\ud800-\\udfff",fr="\\u0300-\\u036f",ur="\\ufe20-\\ufe2f",sr="\\u20d0-\\u20ff",lr=fr+ur+sr,pr="\\ufe0e\\ufe0f",nr="["+G+"]",y="["+lr+"]",C="\\ud83c[\\udffb-\\udfff]",mr="(?:"+y+"|"+C+")",q="[^"+G+"]",H="(?:\\ud83c[\\udde6-\\uddff]){2}",V="[\\ud800-\\udbff][\\udc00-\\udfff]",ir="\\u200d",J=mr+"?",K="["+pr+"]?",dr="(?:"+ir+"(?:"+[q,H,V].join("|")+")"+K+J+")*",xr=K+J+dr,cr="(?:"+[q+y+"?",y,H,V,nr].join("|")+")",gr=RegExp(C+"(?="+C+")|"+cr+xr,"g");function hr(e){return e.match(gr)||[]}var $=hr;function br(e){return g(e)?$(e):Z(e)}var Y=br;function yr(e){return function(o){o=n(o);var r=g(o)?Y(o):void 0,f=r?r[0]:o.charAt(0),l=r?_(r,1).join(""):o.slice(1);return f[e]()+l}}var Q=yr;var Cr=Q("toUpperCase"),X=Cr;function Rr(e){return X(n(e).toLowerCase())}var ee=Rr;t();a();t();a();function vr(e,o,r,f){var l=-1,m=e==null?0:e.length;for(f&&m&&(r=e[++l]);++l<m;)r=o(r,e[l],l,e);return r}var re=vr;t();a();t();a();t();a();function Sr(e){return function(o){return e==null?void 0:e[o]}}var te=Sr;var Ar={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Or=te(Ar),ae=Or;var Nr=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Ir="\\u0300-\\u036f",kr="\\ufe20-\\ufe2f",Er="\\u20d0-\\u20ff",Tr=Ir+kr+Er,Mr="["+Tr+"]",wr=RegExp(Mr,"g");function jr(e){return e=n(e),e&&e.replace(Nr,ae).replace(wr,"")}var oe=jr;t();a();t();a();var Pr=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function Wr(e){return e.match(Pr)||[]}var fe=Wr;t();a();var Lr=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function Ur(e){return Lr.test(e)}var ue=Ur;t();a();var me="\\ud800-\\udfff",zr="\\u0300-\\u036f",Br="\\ufe20-\\ufe2f",Fr="\\u20d0-\\u20ff",Dr=zr+Br+Fr,ie="\\u2700-\\u27bf",de="a-z\\xdf-\\xf6\\xf8-\\xff",_r="\\xac\\xb1\\xd7\\xf7",Zr="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Gr="\\u2000-\\u206f",qr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",xe="A-Z\\xc0-\\xd6\\xd8-\\xde",Hr="\\ufe0e\\ufe0f",ce=_r+Zr+Gr+qr,ge="['\u2019]",se="["+ce+"]",Vr="["+Dr+"]",he="\\d+",Jr="["+ie+"]",be="["+de+"]",ye="[^"+me+ce+he+ie+de+xe+"]",Kr="\\ud83c[\\udffb-\\udfff]",$r="(?:"+Vr+"|"+Kr+")",Yr="[^"+me+"]",Ce="(?:\\ud83c[\\udde6-\\uddff]){2}",Re="[\\ud800-\\udbff][\\udc00-\\udfff]",d="["+xe+"]",Qr="\\u200d",le="(?:"+be+"|"+ye+")",Xr="(?:"+d+"|"+ye+")",pe="(?:"+ge+"(?:d|ll|m|re|s|t|ve))?",ne="(?:"+ge+"(?:D|LL|M|RE|S|T|VE))?",ve=$r+"?",Se="["+Hr+"]?",et="(?:"+Qr+"(?:"+[Yr,Ce,Re].join("|")+")"+Se+ve+")*",rt="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",tt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",at=Se+ve+et,ot="(?:"+[Jr,Ce,Re].join("|")+")"+at,ft=RegExp([d+"?"+be+"+"+pe+"(?="+[se,d,"$"].join("|")+")",Xr+"+"+ne+"(?="+[se,d+le,"$"].join("|")+")",d+"?"+le+"+"+pe,d+"+"+ne,tt,rt,he,ot].join("|"),"g");function ut(e){return e.match(ft)||[]}var Ae=ut;function st(e,o,r){return e=n(e),o=r?void 0:o,o===void 0?ue(e)?Ae(e):fe(e):e.match(o)||[]}var Oe=st;var lt="['\u2019]",pt=RegExp(lt,"g");function nt(e){return function(o){return re(Oe(oe(o).replace(pt,"")),e,"")}}var h=nt;var mt=h(function(e,o,r){return o=o.toLowerCase(),e+(r?ee(o):o)}),R=mt;t();a();var it=h(function(e,o,r){return e+(r?"_":"")+o.toLowerCase()}),v=it;var dt=["list","set"],Ne=class e extends S{constructor({ir:r,config:f}){var l;super({ir:r,config:f});x(this,"ir");x(this,"customConfig");x(this,"dynamicTypeLiteralMapper");x(this,"filePropertyMapper");this.ir=r,this.customConfig=(l=f.customConfig)!=null?l:{},this.dynamicTypeLiteralMapper=new A({context:this}),this.filePropertyMapper=new O({context:this})}clone(){return new e({ir:this.ir,config:this.config})}getClassName(r){let f=r.pascalCase.safeName,l=this.getRootClientClassName();return f===l?`${l}Model`:f}getTypedDictClassName(r){return`${this.getClassName(r)}Params`}getPropertyName(r){let f=r.snakeCase.safeName;return f.startsWith("_")?"f_"+f.substring(f.lastIndexOf("_")+1):f}getMethodName(r){return dt.includes(r.snakeCase.unsafeName)?r.snakeCase.unsafeName:r.snakeCase.safeName}getRootClientClassReference(){return i.reference({name:this.getRootClientClassName(),modulePath:this.getRootModulePath()})}getRootClientClassName(){var r,f;return((r=this.customConfig.client)==null?void 0:r.exported_class_name)!=null?this.customConfig.client.exported_class_name:this.customConfig.client_class_name!=null?this.customConfig.client_class_name:((f=this.customConfig.client)==null?void 0:f.class_name)!=null?this.customConfig.client.class_name:this.pascalCase(this.config.organization)+this.pascalCase(this.config.workspaceName)}getEnvironmentClassName(){return`${this.getRootClientClassName()}Environment`}getEnvironmentTypeReferenceFromID(r){let f=this.resolveEnvironmentName(r);if(f!=null)return i.accessAttribute({lhs:this.getEnvironmentClassReference(),rhs:i.codeBlock(this.getEnvironmentEnumName(f))})}getEnvironmentClassReference(){return i.reference({name:this.getEnvironmentClassName(),modulePath:this.getEnvironmentModulePath()})}getEnvironmentEnumName(r){return r.screamingSnakeCase.safeName}isPrimitive(r){switch(r.type){case"primitive":return!0;case"optional":case"nullable":return this.isPrimitive(r.value);case"named":{let f=this.resolveNamedType({typeId:r.value});if(f==null)return!1;switch(f.type){case"alias":return this.isPrimitive(f.typeReference);case"discriminatedUnion":case"undiscriminatedUnion":case"object":case"enum":return!1;default:b(f)}break}case"list":case"set":case"map":case"literal":case"unknown":return!1;default:b(r)}}getFileFromString(r){return i.TypeInstantiation.str(r)}getRootModulePath(){if(this.customConfig.package_name!=null)return[this.customConfig.package_name];let r=this.cleanOrganizationName();return this.customConfig.use_api_name_in_package?[r,this.getApiName()]:[r]}getCoreModulePath(){return this.getRootModulePath().concat("core")}getEnvironmentModulePath(){return this.getRootModulePath().concat("environment")}shouldInlinePathParameters(){return!0}cleanOrganizationName(){return this.config.organization.replace(/[^a-zA-Z0-9]/g,"_")}getApiName(){return v(this.config.workspaceName)}pascalCase(r){let f=R(r);return f.charAt(0).toUpperCase()+f.slice(1)}};export{Ne as a};
2
2
  /*! Bundled license information:
3
3
 
4
4
  lodash-es/lodash.js:
@@ -12,4 +12,4 @@ lodash-es/lodash.js:
12
12
  * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
13
13
  *)
14
14
  */
15
- //# sourceMappingURL=chunk-XX42ILF7.js.map
15
+ //# sourceMappingURL=chunk-HGKGDQ5J.js.map