@fern-api/go-dynamic-snippets 0.0.17 → 0.0.19

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 (67) hide show
  1. package/cjs/DynamicSnippetsGenerator.cjs +6 -6
  2. package/cjs/DynamicSnippetsGenerator.cjs.map +1 -1
  3. package/cjs/DynamicSnippetsGenerator.d.cts +3 -2
  4. package/cjs/{DynamicSnippetsGeneratorContext-D8VcLYKk.d.cts → DynamicSnippetsGeneratorContext-X0Mtg6YW.d.cts} +1 -0
  5. package/cjs/EndpointSnippetGenerator.cjs +4 -4
  6. package/cjs/EndpointSnippetGenerator.cjs.map +1 -1
  7. package/cjs/EndpointSnippetGenerator.d.cts +7 -2
  8. package/cjs/context/DynamicSnippetsGeneratorContext.cjs +8 -8
  9. package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +1 -1
  10. package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +1 -1
  11. package/cjs/context/DynamicTypeInstantiationMapper.cjs +1 -1
  12. package/cjs/context/DynamicTypeInstantiationMapper.cjs.map +1 -1
  13. package/cjs/context/DynamicTypeInstantiationMapper.d.cts +1 -1
  14. package/cjs/context/DynamicTypeMapper.cjs +4 -4
  15. package/cjs/context/DynamicTypeMapper.cjs.map +1 -1
  16. package/cjs/context/DynamicTypeMapper.d.cts +1 -1
  17. package/cjs/context/FilePropertyMapper.cjs +7 -7
  18. package/cjs/context/FilePropertyMapper.cjs.map +1 -1
  19. package/cjs/context/FilePropertyMapper.d.cts +1 -1
  20. package/cjs/index.cjs +6 -6
  21. package/cjs/index.cjs.map +1 -1
  22. package/cjs/index.d.cts +1 -1
  23. package/esm/DynamicSnippetsGenerator.d.ts +3 -2
  24. package/esm/DynamicSnippetsGenerator.js +1 -1
  25. package/esm/{DynamicSnippetsGeneratorContext-D8VcLYKk.d.ts → DynamicSnippetsGeneratorContext-X0Mtg6YW.d.ts} +1 -0
  26. package/esm/EndpointSnippetGenerator.d.ts +7 -2
  27. package/esm/EndpointSnippetGenerator.js +1 -1
  28. package/esm/{chunk-ZNTXZ3YV.js → chunk-5X6DU53C.js} +2 -2
  29. package/esm/chunk-EUHLPBOB.js +2 -0
  30. package/esm/chunk-EUHLPBOB.js.map +1 -0
  31. package/esm/chunk-FVPD7ODP.js +2 -0
  32. package/esm/chunk-FVPD7ODP.js.map +1 -0
  33. package/esm/chunk-KGXOPYBU.js +2 -0
  34. package/esm/chunk-KGXOPYBU.js.map +1 -0
  35. package/esm/chunk-NY6N4HP7.js +2 -0
  36. package/esm/chunk-NY6N4HP7.js.map +1 -0
  37. package/esm/chunk-S5R5YTLQ.js +2 -0
  38. package/esm/chunk-S5R5YTLQ.js.map +1 -0
  39. package/esm/chunk-T2DJJZPN.js +2 -0
  40. package/esm/chunk-T2DJJZPN.js.map +1 -0
  41. package/esm/{chunk-JHIUGKJ4.js → chunk-VY2BNRW5.js} +9 -9
  42. package/esm/chunk-VY2BNRW5.js.map +1 -0
  43. package/esm/context/DynamicSnippetsGeneratorContext.d.ts +1 -1
  44. package/esm/context/DynamicSnippetsGeneratorContext.js +1 -1
  45. package/esm/context/DynamicTypeInstantiationMapper.d.ts +1 -1
  46. package/esm/context/DynamicTypeInstantiationMapper.js +1 -1
  47. package/esm/context/DynamicTypeMapper.d.ts +1 -1
  48. package/esm/context/DynamicTypeMapper.js +1 -1
  49. package/esm/context/FilePropertyMapper.d.ts +1 -1
  50. package/esm/context/FilePropertyMapper.js +1 -1
  51. package/esm/index.d.ts +1 -1
  52. package/esm/index.js +1 -1
  53. package/package.json +1 -1
  54. package/esm/chunk-ADZ6FCNI.js +0 -2
  55. package/esm/chunk-ADZ6FCNI.js.map +0 -1
  56. package/esm/chunk-FTDA4363.js +0 -2
  57. package/esm/chunk-FTDA4363.js.map +0 -1
  58. package/esm/chunk-GDQPUUAY.js +0 -2
  59. package/esm/chunk-GDQPUUAY.js.map +0 -1
  60. package/esm/chunk-JHIUGKJ4.js.map +0 -1
  61. package/esm/chunk-PZ73VBNX.js +0 -2
  62. package/esm/chunk-PZ73VBNX.js.map +0 -1
  63. package/esm/chunk-SVPRIX53.js +0 -2
  64. package/esm/chunk-SVPRIX53.js.map +0 -1
  65. package/esm/chunk-VTPICU2V.js +0 -2
  66. package/esm/chunk-VTPICU2V.js.map +0 -1
  67. /package/esm/{chunk-ZNTXZ3YV.js.map → chunk-5X6DU53C.js.map} +0 -0
package/cjs/index.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { DynamicSnippetsGenerator } from './DynamicSnippetsGenerator.cjs';
2
2
  import '@fern-api/browser-compatible-base-generator';
3
3
  import '@fern-api/dynamic-ir-sdk';
4
- import './DynamicSnippetsGeneratorContext-D8VcLYKk.cjs';
4
+ import './DynamicSnippetsGeneratorContext-X0Mtg6YW.cjs';
5
5
  import '@fern-api/go-ast';
6
6
  import './EndpointSnippetGenerator.cjs';
@@ -1,6 +1,6 @@
1
- import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, AbstractFormatter, Options } from '@fern-api/browser-compatible-base-generator';
1
+ import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, AbstractFormatter, Options, AbstractAstNode } from '@fern-api/browser-compatible-base-generator';
2
2
  import { FernIr } from '@fern-api/dynamic-ir-sdk';
3
- import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-D8VcLYKk.js';
3
+ import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-X0Mtg6YW.js';
4
4
  import { EndpointSnippetGenerator } from './EndpointSnippetGenerator.js';
5
5
  import '@fern-api/go-ast';
6
6
 
@@ -13,6 +13,7 @@ declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<
13
13
  });
14
14
  generate(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): Promise<FernIr.dynamic.EndpointSnippetResponse>;
15
15
  generateSync(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): FernIr.dynamic.EndpointSnippetResponse;
16
+ generateSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): Promise<AbstractAstNode>;
16
17
  protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
17
18
  }
18
19
 
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-GDQPUUAY.js";import"./chunk-ADZ6FCNI.js";import"./chunk-PZ73VBNX.js";import"./chunk-VTPICU2V.js";import"./chunk-FTDA4363.js";import"./chunk-ZNTXZ3YV.js";import"./chunk-SVPRIX53.js";import"./chunk-JHIUGKJ4.js";export{a as DynamicSnippetsGenerator};
1
+ import{a}from"./chunk-KGXOPYBU.js";import"./chunk-S5R5YTLQ.js";import"./chunk-T2DJJZPN.js";import"./chunk-NY6N4HP7.js";import"./chunk-EUHLPBOB.js";import"./chunk-5X6DU53C.js";import"./chunk-FVPD7ODP.js";import"./chunk-VY2BNRW5.js";export{a as DynamicSnippetsGenerator};
2
2
  //# sourceMappingURL=DynamicSnippetsGenerator.js.map
@@ -95,6 +95,7 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
95
95
  getMethodName(name: FernIr.Name): string;
96
96
  getTestMethodName(endpoint: FernIr.dynamic.Endpoint): string;
97
97
  getTypeName(name: FernIr.Name): string;
98
+ getFieldName(name: FernIr.Name): string;
98
99
  getImportPath(fernFilepath: FernIr.dynamic.FernFilepath): string;
99
100
  getImportPathForRequest(fernFilepath: FernIr.dynamic.FernFilepath): string;
100
101
  getContextTypeReference(): go.TypeReference;
@@ -1,7 +1,7 @@
1
1
  import { AbstractFormatter, Options } from '@fern-api/browser-compatible-base-generator';
2
2
  import { FernIr } from '@fern-api/dynamic-ir-sdk';
3
- import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-D8VcLYKk.js';
4
- import '@fern-api/go-ast';
3
+ import { go } from '@fern-api/go-ast';
4
+ import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-X0Mtg6YW.js';
5
5
 
6
6
  declare class EndpointSnippetGenerator {
7
7
  private context;
@@ -20,6 +20,11 @@ declare class EndpointSnippetGenerator {
20
20
  request: FernIr.dynamic.EndpointSnippetRequest;
21
21
  options?: Options;
22
22
  }): string;
23
+ generateSnippetAst({ endpoint, request, options }: {
24
+ endpoint: FernIr.dynamic.Endpoint;
25
+ request: FernIr.dynamic.EndpointSnippetRequest;
26
+ options?: Options;
27
+ }): Promise<go.AstNode>;
23
28
  private generateWiremockTest;
24
29
  private buildCodeBlock;
25
30
  private buildWiremockTestCodeBlock;
@@ -1,2 +1,2 @@
1
- import{a}from"./chunk-ADZ6FCNI.js";import"./chunk-FTDA4363.js";import"./chunk-JHIUGKJ4.js";export{a as EndpointSnippetGenerator};
1
+ import{a}from"./chunk-S5R5YTLQ.js";import"./chunk-EUHLPBOB.js";import"./chunk-VY2BNRW5.js";export{a as EndpointSnippetGenerator};
2
2
  //# sourceMappingURL=EndpointSnippetGenerator.js.map
@@ -1,2 +1,2 @@
1
- import{e as c,f as i,g as p,h as n,j as e}from"./chunk-JHIUGKJ4.js";i();p();var a=class{constructor({context:t}){c(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return e.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return e.Type.map(this.convert({typeReference:t.typeReference.key}),this.convert({typeReference:t.typeReference.value}));case"named":{let r=this.context.resolveNamedType({typeId:t.typeReference.value});return r==null?this.convertUnknown():this.convertNamed({named:r})}case"optional":return e.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return e.Type.optional(this.convert({typeReference:t.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return e.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:n(t.typeReference)}}convertLiteral({literal:t}){switch(t.type){case"boolean":return e.Type.bool();case"string":return e.Type.string()}}convertNamed({named:t}){let r=e.Type.reference(e.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}));switch(t.type){case"alias":case"enum":return r;case"discriminatedUnion":case"object":case"undiscriminatedUnion":return e.Type.pointer(r);default:n(t)}}convertUnknown(){return e.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return e.Type.int();case"UINT":return e.Type.int();case"LONG":return e.Type.int64();case"UINT_64":return e.Type.int64();case"FLOAT":return e.Type.float64();case"DOUBLE":return e.Type.float64();case"BOOLEAN":return e.Type.bool();case"STRING":return e.Type.string();case"DATE":return e.Type.date();case"DATE_TIME":return e.Type.dateTime();case"UUID":return e.Type.uuid();case"BASE_64":return e.Type.bytes();case"BIG_INTEGER":return e.Type.string();default:n(t)}}};export{a};
2
- //# sourceMappingURL=chunk-ZNTXZ3YV.js.map
1
+ import{e as c,f as i,g as p,h as n,j as e}from"./chunk-VY2BNRW5.js";i();p();var a=class{constructor({context:t}){c(this,"context");this.context=t}convert(t){switch(t.typeReference.type){case"list":return e.Type.slice(this.convert({typeReference:t.typeReference.value}));case"literal":return this.convertLiteral({literal:t.typeReference.value});case"map":return e.Type.map(this.convert({typeReference:t.typeReference.key}),this.convert({typeReference:t.typeReference.value}));case"named":{let r=this.context.resolveNamedType({typeId:t.typeReference.value});return r==null?this.convertUnknown():this.convertNamed({named:r})}case"optional":return e.Type.optional(this.convert({typeReference:t.typeReference.value}));case"nullable":return e.Type.optional(this.convert({typeReference:t.typeReference.value}));case"primitive":return this.convertPrimitive({primitive:t.typeReference.value});case"set":return e.Type.slice(this.convert({typeReference:t.typeReference}));case"unknown":return this.convertUnknown();default:n(t.typeReference)}}convertLiteral({literal:t}){switch(t.type){case"boolean":return e.Type.bool();case"string":return e.Type.string()}}convertNamed({named:t}){let r=e.Type.reference(e.typeReference({name:this.context.getTypeName(t.declaration.name),importPath:this.context.getImportPath(t.declaration.fernFilepath)}));switch(t.type){case"alias":case"enum":return r;case"discriminatedUnion":case"object":case"undiscriminatedUnion":return e.Type.pointer(r);default:n(t)}}convertUnknown(){return e.Type.any()}convertPrimitive({primitive:t}){switch(t){case"INTEGER":return e.Type.int();case"UINT":return e.Type.int();case"LONG":return e.Type.int64();case"UINT_64":return e.Type.int64();case"FLOAT":return e.Type.float64();case"DOUBLE":return e.Type.float64();case"BOOLEAN":return e.Type.bool();case"STRING":return e.Type.string();case"DATE":return e.Type.date();case"DATE_TIME":return e.Type.dateTime();case"UUID":return e.Type.uuid();case"BASE_64":return e.Type.bytes();case"BIG_INTEGER":return e.Type.string();default:n(t)}}};export{a};
2
+ //# sourceMappingURL=chunk-5X6DU53C.js.map
@@ -0,0 +1,2 @@
1
+ import{a as T,b as P,c as S,d as A,e as p,f as l,g as u,h,i as R}from"./chunk-VY2BNRW5.js";l();u();l();u();var y=class{constructor(){p(this,"reporter");p(this,"snippet");p(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:e,snippet:r}){this.shouldUpdate({snippet:r,reporter:e.errors})&&(this.reporter=e.errors.clone(),this.snippet=r)}getResponseOrThrow({endpoint:e}){var r;if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw(r=this.err)!=null?r:new Error(`Failed to generate snippet for endpoint "${e.method} ${e.path}"`)}shouldUpdate({snippet:e,reporter:r}){var t,n;return this.reporter==null||this.reporter.size()>0&&r.size()===0?!0:e.length>((n=(t=this.snippet)==null?void 0:t.length)!=null?n:0)}};var E=class{constructor(e){p(this,"context");this.context=e}async generate(e,r={}){let t=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(t.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let n=new y;for(let i of t){let s=this.context.clone(),d=this.createSnippetGenerator(s);try{let a=await d.generateSnippet({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:a,errors:void 0};n.update({context:s,snippet:a})}catch(a){n.err==null&&(n.err=a)}}return n.getResponseOrThrow({endpoint:e.endpoint})}async generateSnippetAst(e,r={}){let t=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(t.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let n;for(let i of t){let s=this.context.clone(),d=this.createSnippetGenerator(s);try{return await d.generateSnippetAst({endpoint:i,request:e,options:r})}catch(a){n=a}}throw n!=null?n:new Error(`Failed to generate snippet AST for endpoint: ${e.endpoint.method} ${e.endpoint.path}`)}generateSync(e,r={}){let t=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(t.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let n=new y;for(let i of t){let s=this.context.clone(),d=this.createSnippetGenerator(s);try{let a=d.generateSnippetSync({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:a,errors:void 0};n.update({context:s,snippet:a})}catch(a){n.err==null&&(n.err=a)}}return n.getResponseOrThrow({endpoint:e.endpoint})}};l();u();var o={Critical:"CRITICAL",Warning:"WARNING"},g=class m{constructor(){p(this,"errors");p(this,"path");this.errors=[],this.path=[]}add(e){this.errors.push(P(T({},e),{path:[...this.path]}))}scope(e){this.path.push(e)}unscope(){this.path.pop()}getBySeverity(e){return this.errors.filter(r=>r.severity===e)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let e=new m;return e.errors=[...this.errors],e.path=[...this.path],e}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(e=>({severity:e.severity,path:e.path!=null?this.pathToStringArray(e.path):void 0,message:e.message}))}pathToStringArray(e){let r=[];for(let t of e){if(typeof t=="string"){r.push(t);continue}r[r.length-1]+=`[${t.index}]`}return r}};l();u();l();u();l();u();var v=class{constructor(){p(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(e){return this.REFERENCE_REGEX.test(e)?{type:"valid"}:{type:"invalid"}}tryParse(e){if(this.validate(e).type==="invalid")return;let t=e.match(this.REFERENCE_REGEX);if(!(t==null||t[1]==null||t[2]==null))return{method:t[1],path:t[2]}}};var w=class{constructor({ir:e,config:r,options:t={}}){p(this,"config");p(this,"options");p(this,"errors");p(this,"_ir");p(this,"httpEndpointReferenceParser");this._ir=e,this.config=r,this.options=t,this.errors=new g,this.httpEndpointReferenceParser=new v}associateQueryParametersByWireValue({parameters:e,values:r}){let t=[];for(let[n,i]of Object.entries(r)){this.errors.scope(n);try{let s=e.find(a=>a.name.wireValue===n);if(s==null)throw this.newParameterNotRecognizedError(n);let d=this.isListTypeReference(s.typeReference)&&!Array.isArray(i)?[i]:i;t.push({name:s.name,typeReference:s.typeReference,value:d})}finally{this.errors.unscope()}}return t}associateByWireValueOrDefault({parameters:e,values:r}){let t=[];for(let n of e){this.errors.scope(n.name.wireValue);try{let i=r[n.name.wireValue];if(i==null)if(n.typeReference.type==="primitive"&&n.typeReference.value==="STRING")i=`<${n.name.wireValue}>`;else{this.errors.add({severity:o.Critical,message:this.newParameterNotRecognizedError(n.name.wireValue).message});continue}t.push({name:n.name,typeReference:n.typeReference,value:i})}finally{this.errors.unscope()}}return t}associateByWireValue({parameters:e,values:r,ignoreMissingParameters:t}){let n=[];for(let[i,s]of Object.entries(r)){this.errors.scope(i);try{let d=e.find(a=>a.name.wireValue===i);if(d==null){if(t)continue;this.errors.add({severity:o.Critical,message:this.newParameterNotRecognizedError(i).message});continue}n.push({name:d.name,typeReference:d.typeReference,value:s})}finally{this.errors.unscope()}}return n}getExampleObjectProperties({parameters:e,snippetObject:r}){let t=typeof r=="object"&&r!==null&&!Array.isArray(r)?r:{},n=[];for(let i of e){let s=t[i.name.wireValue];s==null?i.typeReference.type==="nullable"&&n.push({name:i.name,typeReference:i.typeReference,value:null}):n.push({name:i.name,typeReference:i.typeReference,value:s})}return n}getSingleFileValue({property:e,record:r}){let t=r[e.wireValue];if(t!=null){if(typeof t!="string"){this.errors.add({severity:o.Critical,message:`Expected file value to be a string, got ${typeof t}`});return}return t}}getFileArrayValues({property:e,record:r}){let t=r[e.wireValue];if(t==null)return;if(!Array.isArray(t)){this.errors.add({severity:o.Critical,message:`Expected file array value to be an array of strings, got ${typeof t}`});return}let n=[];for(let i of t){if(typeof i!="string"){this.errors.add({severity:o.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}n.push(i)}return n}getRecord(e){if(typeof e!="object"||Array.isArray(e)){this.errors.add({severity:o.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(e)?"array":typeof e}`});return}return e==null?{}:e}resolveNamedType({typeId:e}){let r=this._ir.types[e];if(r==null){this.errors.add({severity:o.Critical,message:`Type identified by "${e}" could not be found`});return}return r}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:r}){let t=this.getRecord(r);if(t==null)return;let n=e.discriminant.wireValue,i=t[n];if(i==null){this.errors.add({severity:o.Critical,message:this.newParameterNotRecognizedError(n).message});return}if(typeof i!="string"){this.errors.add({severity:o.Critical,message:`Expected discriminant value to be a string but got: ${typeof i}`});return}let s=e.types[i];if(s==null){this.errors.add({severity:o.Critical,message:`No type found for discriminant value "${i}"`});return}let x=t,{[n]:d}=x,a=A(x,[S(n)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:a}}resolveEndpointOrThrow(e){let r=this.httpEndpointReferenceParser.tryParse(e);if(r==null)throw new Error(`Failed to parse endpoint reference "${e}"`);return this.resolveEndpointLocationOrThrow(r)}resolveEndpointLocation(e){let r=[];for(let t of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:t,parsedEndpoint:e})&&r.push(t);return r}resolveEndpointLocationOrThrow(e){let r=this.resolveEndpointLocation(e);if(r.length===0)throw new Error(`Failed to find endpoint identified by "${e.method} ${e.path}"`);return r}needsRequestParameter({request:e,inlinePathParameters:r,inlineFileProperties:t}){var n;return this.includePathParametersInWrappedRequest({request:e,inlinePathParameters:r})||e.queryParameters!=null&&e.queryParameters.length>0||e.headers!=null&&e.headers.length>0?!0:e.body!=null?this.includeRequestBodyInWrappedRequest({body:e.body,inlineFileProperties:t}):!((n=e.metadata)!=null&&n.onlyPathParameters)}includePathParametersInWrappedRequest({request:e,inlinePathParameters:r}){var t,n;return r&&((n=(t=e.metadata)==null?void 0:t.includePathParameters)!=null?n:!1)}isFileUploadRequestBody(e){switch(e.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:h(e)}}resolveEnvironmentName(e){if(this._ir.environments==null)return;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}case"multipleBaseUrls":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}default:h(r)}}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}validateMultiEnvironmentUrlValues(e){if(this._ir.environments==null)return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let t=r.environments[0];if(t==null)return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let n=new Set(R(t.urls));for(let i of R(e))n.has(i)&&n.delete(i);return n.size>0?(this.errors.add({severity:o.Critical,message:`The provided environments are invalid; got: [${Object.keys(e).join(", ")}], expected: [${R(t.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:e}){if(typeof e!="number"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"number",value:e}).message});return}return e}getValueAsBoolean({value:e}){if(typeof e!="boolean"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"boolean",value:e}).message});return}return e}getValueAsString({value:e}){if(typeof e!="string"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"string",value:e}).message});return}return e}isOptional(e){switch(e.type){case"nullable":return this.isOptional(e.value);case"optional":return!0;case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}isNullable(e){switch(e.type){case"nullable":return!0;case"optional":return this.isNullable(e.value);case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}newAuthMismatchError({auth:e,values:r}){return new Error(`Expected auth type ${e.type}, got ${r.type}`)}newParameterNotRecognizedError(e){return new Error(`"${e}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:e,value:r}){return new Error(`Expected ${e}, got ${typeof r}`)}includeRequestBodyInWrappedRequest({body:e,inlineFileProperties:r}){switch(e.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r});default:h(e)}}includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r}){return this.fileUploadHasBodyProperties({fileUpload:e})||r&&this.fileUploadHasFileProperties({fileUpload:e})}fileUploadHasBodyProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:h(r)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:h(r)}})}isListTypeReference(e){return e.type==="optional"?this.isListTypeReference(e.value):e.type==="list"||e.type==="set"}parsedEndpointMatches({endpoint:e,parsedEndpoint:r}){return e.location.method===r.method&&e.location.path===r.path}};l();u();var b={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};l();u();export{E as a,o as b,w as c,b as d};
2
+ //# sourceMappingURL=chunk-EUHLPBOB.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../browser-compatible-base/src/dynamic-snippets/AbstractDynamicSnippetsGenerator.ts","../../../../browser-compatible-base/src/dynamic-snippets/Result.ts","../../../../browser-compatible-base/src/dynamic-snippets/ErrorReporter.ts","../../../../browser-compatible-base/src/dynamic-snippets/AbstractDynamicSnippetsGeneratorContext.ts","../../../../../packages/cli/fern-definition/schema/src/index.ts","../../../../../packages/cli/fern-definition/schema/src/utils/HttpEndpointReferenceParser.ts","../../../../browser-compatible-base/src/dynamic-snippets/Scope.ts","../../../../browser-compatible-base/src/dynamic-snippets/index.ts"],"sourcesContent":["import { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { AbstractAstNode } from \"../ast\";\nimport { AbstractDynamicSnippetsGeneratorContext } from \"./AbstractDynamicSnippetsGeneratorContext\";\nimport { AbstractEndpointSnippetGenerator } from \"./AbstractEndpointSnippetGenerator\";\nimport { Options } from \"./Options\";\nimport { Result } from \"./Result\";\n\nexport abstract class AbstractDynamicSnippetsGenerator<\n Context extends AbstractDynamicSnippetsGeneratorContext,\n EndpointSnippetGenerator extends AbstractEndpointSnippetGenerator<Context>\n> {\n public constructor(public readonly context: Context) {}\n\n protected abstract createSnippetGenerator(context: Context): EndpointSnippetGenerator;\n\n public async generate(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options: Options = {}\n ): Promise<FernIr.dynamic.EndpointSnippetResponse> {\n const endpoints = this.context.resolveEndpointLocationOrThrow(request.endpoint);\n if (endpoints.length === 0) {\n throw new Error(`No endpoints found that match \"${request.endpoint.method} ${request.endpoint.path}\"`);\n }\n const result = new Result();\n for (const endpoint of endpoints) {\n const context = this.context.clone() as Context;\n const snippetGenerator = this.createSnippetGenerator(context);\n try {\n const snippet = await snippetGenerator.generateSnippet({ endpoint, request, options });\n if (context.errors.empty()) {\n return {\n snippet,\n errors: undefined\n };\n }\n result.update({ context, snippet });\n } catch (error) {\n if (result.err == null) {\n result.err = error as Error;\n }\n }\n }\n return result.getResponseOrThrow({ endpoint: request.endpoint });\n }\n\n public async generateSnippetAst(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options: Options = {}\n ): Promise<AbstractAstNode> {\n const endpoints = this.context.resolveEndpointLocationOrThrow(request.endpoint);\n if (endpoints.length === 0) {\n throw new Error(`No endpoints found that match \"${request.endpoint.method} ${request.endpoint.path}\"`);\n }\n let lastError: Error | undefined = undefined;\n for (const endpoint of endpoints) {\n const context = this.context.clone() as Context;\n const snippetGenerator = this.createSnippetGenerator(context);\n try {\n const ast = await snippetGenerator.generateSnippetAst({ endpoint, request, options });\n return ast;\n } catch (error) {\n lastError = error as Error;\n }\n }\n if (lastError != null) {\n throw lastError;\n }\n throw new Error(\n `Failed to generate snippet AST for endpoint: ${request.endpoint.method} ${request.endpoint.path}`\n );\n }\n\n public generateSync(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options: Options = {}\n ): FernIr.dynamic.EndpointSnippetResponse {\n const endpoints = this.context.resolveEndpointLocationOrThrow(request.endpoint);\n if (endpoints.length === 0) {\n throw new Error(`No endpoints found that match \"${request.endpoint.method} ${request.endpoint.path}\"`);\n }\n const result = new Result();\n for (const endpoint of endpoints) {\n const context = this.context.clone() as Context;\n const snippetGenerator = this.createSnippetGenerator(context);\n try {\n const snippet = snippetGenerator.generateSnippetSync({ endpoint, request, options });\n if (context.errors.empty()) {\n return {\n snippet,\n errors: undefined\n };\n }\n result.update({ context, snippet });\n } catch (error) {\n if (result.err == null) {\n result.err = error as Error;\n }\n }\n }\n return result.getResponseOrThrow({ endpoint: request.endpoint });\n }\n}\n","import { FernIr } from \"@fern-api/dynamic-ir-sdk\";\n\nimport { AbstractDynamicSnippetsGeneratorContext } from \"./AbstractDynamicSnippetsGeneratorContext\";\nimport { ErrorReporter } from \"./ErrorReporter\";\n\nexport class Result {\n public reporter: ErrorReporter | undefined;\n public snippet: string | undefined;\n public err: Error | undefined;\n\n constructor() {\n this.snippet = undefined;\n this.reporter = undefined;\n this.err = undefined;\n }\n\n public update({ context, snippet }: { context: AbstractDynamicSnippetsGeneratorContext; snippet: string }): void {\n if (this.shouldUpdate({ snippet, reporter: context.errors })) {\n this.reporter = context.errors.clone();\n this.snippet = snippet;\n }\n }\n\n public getResponseOrThrow({\n endpoint\n }: {\n endpoint: FernIr.dynamic.EndpointLocation;\n }): FernIr.dynamic.EndpointSnippetResponse {\n if (this.snippet != null && this.reporter != null) {\n return {\n snippet: this.snippet,\n errors: this.reporter.toDynamicSnippetErrors()\n };\n }\n throw this.err ?? new Error(`Failed to generate snippet for endpoint \"${endpoint.method} ${endpoint.path}\"`);\n }\n\n private shouldUpdate({ snippet, reporter }: { snippet: string; reporter: ErrorReporter }): boolean {\n if (this.reporter == null || (this.reporter.size() > 0 && reporter.size() === 0)) {\n return true;\n }\n return snippet.length > (this.snippet?.length ?? 0);\n }\n}\n","export const Severity = {\n Critical: \"CRITICAL\",\n Warning: \"WARNING\"\n} as const;\n\nexport declare namespace ErrorReporter {\n type Path = readonly PathItem[];\n\n type PathItem = string | ArrayPathItem;\n\n type Severity = (typeof Severity)[keyof typeof Severity];\n\n interface ArrayPathItem {\n index: number;\n }\n\n interface Error {\n path?: Path;\n severity: Severity;\n message: string;\n }\n}\n\ninterface Error_ {\n severity: \"CRITICAL\" | \"WARNING\";\n path: string[] | undefined;\n message: string;\n}\n\nexport class ErrorReporter {\n private errors: ErrorReporter.Error[];\n private path: ErrorReporter.PathItem[];\n\n constructor() {\n this.errors = [];\n this.path = [];\n }\n\n public add(err: Omit<ErrorReporter.Error, \"path\">): void {\n this.errors.push({\n ...err,\n path: [...this.path]\n });\n }\n\n public scope(path: ErrorReporter.PathItem): void {\n this.path.push(path);\n }\n\n public unscope(): void {\n this.path.pop();\n }\n\n public getBySeverity(severity: ErrorReporter.Severity): ErrorReporter.Error[] {\n return this.errors.filter((err) => err.severity === severity);\n }\n\n public empty(): boolean {\n return this.errors.length === 0;\n }\n\n public size(): number {\n return this.errors.length;\n }\n\n public clone(): ErrorReporter {\n const clone = new ErrorReporter();\n clone.errors = [...this.errors];\n clone.path = [...this.path];\n return clone;\n }\n\n public reset(): void {\n this.errors = [];\n this.path = [];\n }\n\n public toDynamicSnippetErrors(): Error_[] {\n return this.errors.map((err) => ({\n severity: err.severity,\n path: err.path != null ? this.pathToStringArray(err.path) : undefined,\n message: err.message\n }));\n }\n\n private pathToStringArray(path: ErrorReporter.Path): string[] {\n const result: string[] = [];\n for (const item of path) {\n if (typeof item === \"string\") {\n result.push(item);\n continue;\n }\n result[result.length - 1] += `[${item.index}]`;\n }\n return result;\n }\n}\n","import { assertNever, keys } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { HttpEndpointReferenceParser } from \"@fern-api/fern-definition-schema\";\n\nimport { FernGeneratorExec } from \"../GeneratorNotificationService\";\nimport { DiscriminatedUnionTypeInstance } from \"./DiscriminatedUnionTypeInstance\";\nimport { ErrorReporter, Severity } from \"./ErrorReporter\";\nimport { Options } from \"./Options\";\nimport { TypeInstance } from \"./TypeInstance\";\n\nexport abstract class AbstractDynamicSnippetsGeneratorContext {\n public config: FernGeneratorExec.GeneratorConfig;\n public options: Options;\n public errors: ErrorReporter;\n\n private _ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n private httpEndpointReferenceParser: HttpEndpointReferenceParser;\n\n constructor({\n ir,\n config,\n options = {}\n }: {\n ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n config: FernGeneratorExec.GeneratorConfig;\n options?: Options;\n }) {\n this._ir = ir;\n this.config = config;\n this.options = options;\n this.errors = new ErrorReporter();\n this.httpEndpointReferenceParser = new HttpEndpointReferenceParser();\n }\n\n public abstract clone(): AbstractDynamicSnippetsGeneratorContext;\n\n public associateQueryParametersByWireValue({\n parameters,\n values\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): TypeInstance[] {\n const instances: TypeInstance[] = [];\n for (const [key, value] of Object.entries(values)) {\n this.errors.scope(key);\n try {\n const parameter = parameters.find((param) => param.name.wireValue === key);\n if (parameter == null) {\n throw this.newParameterNotRecognizedError(key);\n }\n // If this query parameter supports allow-multiple, the user-provided values\n // must be wrapped in an array.\n const typeInstanceValue =\n this.isListTypeReference(parameter.typeReference) && !Array.isArray(value) ? [value] : value;\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value: typeInstanceValue\n });\n } finally {\n this.errors.unscope();\n }\n }\n return instances;\n }\n\n public associateByWireValueOrDefault({\n parameters,\n values\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n }): TypeInstance[] {\n const instances: TypeInstance[] = [];\n for (const parameter of parameters) {\n this.errors.scope(parameter.name.wireValue);\n try {\n let value = values[parameter.name.wireValue];\n\n if (value == null) {\n if (parameter.typeReference.type === \"primitive\" && parameter.typeReference.value === \"STRING\") {\n // synthesize a parameter value for string parameters that are missing data\n value = `<${parameter.name.wireValue}>`;\n } else {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newParameterNotRecognizedError(parameter.name.wireValue).message\n });\n continue;\n }\n }\n\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value\n });\n } finally {\n this.errors.unscope();\n }\n }\n\n return instances;\n }\n\n public associateByWireValue({\n parameters,\n values,\n ignoreMissingParameters\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n values: FernIr.dynamic.Values;\n ignoreMissingParameters?: boolean;\n }): TypeInstance[] {\n const instances: TypeInstance[] = [];\n for (const [key, value] of Object.entries(values)) {\n this.errors.scope(key);\n try {\n const parameter = parameters.find((param) => param.name.wireValue === key);\n if (parameter == null) {\n if (ignoreMissingParameters) {\n // Required for request payloads that include more information than\n // just the target parameters (e.g. union base properties).\n continue;\n }\n this.errors.add({\n severity: Severity.Critical,\n message: this.newParameterNotRecognizedError(key).message\n });\n continue;\n }\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value\n });\n } finally {\n this.errors.unscope();\n }\n }\n return instances;\n }\n\n /**\n * Similar to `associateByWireValue` but it builds TypeInstance objects by iterating over schema parameters rather\n * than snippet values. Skips non-nullable parameters that are missing from the snippet object.\n */\n public getExampleObjectProperties({\n parameters,\n snippetObject\n }: {\n parameters: FernIr.dynamic.NamedParameter[];\n snippetObject: unknown;\n }): TypeInstance[] {\n const objectRecord = (\n typeof snippetObject === \"object\" && snippetObject !== null && !Array.isArray(snippetObject)\n ? snippetObject\n : {}\n ) as Record<string, unknown>;\n const instances: TypeInstance[] = [];\n for (const parameter of parameters) {\n const value = objectRecord[parameter.name.wireValue];\n if (value == null) {\n if (parameter.typeReference.type === \"nullable\") {\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value: null\n });\n }\n } else {\n instances.push({\n name: parameter.name,\n typeReference: parameter.typeReference,\n value\n });\n }\n }\n return instances;\n }\n\n public getSingleFileValue({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.File_;\n record: Record<string, unknown>;\n }): string | undefined {\n const fileValue = record[property.wireValue];\n if (fileValue == null) {\n return undefined;\n }\n if (typeof fileValue !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected file value to be a string, got ${typeof fileValue}`\n });\n return undefined;\n }\n return fileValue;\n }\n\n public getFileArrayValues({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.FileArray;\n record: Record<string, unknown>;\n }): string[] | undefined {\n const fileArrayValue = record[property.wireValue];\n if (fileArrayValue == null) {\n return undefined;\n }\n if (!Array.isArray(fileArrayValue)) {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected file array value to be an array of strings, got ${typeof fileArrayValue}`\n });\n return undefined;\n }\n const stringValues: string[] = [];\n for (const value of fileArrayValue) {\n if (typeof value !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected file array value to be an array of strings, got ${typeof value}`\n });\n return undefined;\n }\n stringValues.push(value);\n }\n return stringValues;\n }\n\n public getRecord(value: unknown): Record<string, unknown> | undefined {\n if (typeof value !== \"object\" || Array.isArray(value)) {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected object with key, value pairs but got: ${\n Array.isArray(value) ? \"array\" : typeof value\n }`\n });\n return undefined;\n }\n if (value == null) {\n return {};\n }\n return value as Record<string, unknown>;\n }\n\n public resolveNamedType({ typeId }: { typeId: FernIr.dynamic.TypeId }): FernIr.dynamic.NamedType | undefined {\n const namedType = this._ir.types[typeId];\n if (namedType == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: `Type identified by \"${typeId}\" could not be found`\n });\n return undefined;\n }\n return namedType;\n }\n\n public resolveDiscriminatedUnionTypeInstance({\n discriminatedUnion,\n value\n }: {\n discriminatedUnion: FernIr.dynamic.DiscriminatedUnionType;\n value: unknown;\n }): DiscriminatedUnionTypeInstance | undefined {\n const record = this.getRecord(value);\n if (record == null) {\n return undefined;\n }\n\n const discriminantFieldName = discriminatedUnion.discriminant.wireValue;\n const discriminantValue = record[discriminantFieldName];\n if (discriminantValue == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newParameterNotRecognizedError(discriminantFieldName).message\n });\n return undefined;\n }\n if (typeof discriminantValue !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: `Expected discriminant value to be a string but got: ${typeof discriminantValue}`\n });\n return undefined;\n }\n\n const singleDiscriminatedUnionType = discriminatedUnion.types[discriminantValue];\n if (singleDiscriminatedUnionType == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: `No type found for discriminant value \"${discriminantValue}\"`\n });\n return undefined;\n }\n\n // Remove the discriminant from the record so that the value is valid for the type.\n const { [discriminantFieldName]: _, ...filtered } = record;\n\n return {\n singleDiscriminatedUnionType,\n discriminantValue: singleDiscriminatedUnionType.discriminantValue,\n value: filtered\n };\n }\n\n public resolveEndpointOrThrow(rawEndpoint: string): FernIr.dynamic.Endpoint[] {\n const parsedEndpoint = this.httpEndpointReferenceParser.tryParse(rawEndpoint);\n if (parsedEndpoint == null) {\n throw new Error(`Failed to parse endpoint reference \"${rawEndpoint}\"`);\n }\n return this.resolveEndpointLocationOrThrow(parsedEndpoint);\n }\n\n public resolveEndpointLocation(location: FernIr.dynamic.EndpointLocation): FernIr.dynamic.Endpoint[] {\n const endpoints: FernIr.dynamic.Endpoint[] = [];\n for (const endpoint of Object.values(this._ir.endpoints)) {\n if (this.parsedEndpointMatches({ endpoint, parsedEndpoint: location })) {\n endpoints.push(endpoint);\n }\n }\n\n return endpoints;\n }\n\n public resolveEndpointLocationOrThrow(location: FernIr.dynamic.EndpointLocation): FernIr.dynamic.Endpoint[] {\n const endpoints = this.resolveEndpointLocation(location);\n if (endpoints.length === 0) {\n throw new Error(`Failed to find endpoint identified by \"${location.method} ${location.path}\"`);\n }\n return endpoints;\n }\n\n public needsRequestParameter({\n request,\n inlinePathParameters,\n inlineFileProperties\n }: {\n request: FernIr.dynamic.InlinedRequest;\n inlinePathParameters: boolean;\n inlineFileProperties: boolean;\n }): boolean {\n if (this.includePathParametersInWrappedRequest({ request, inlinePathParameters })) {\n return true;\n }\n if (request.queryParameters != null && request.queryParameters.length > 0) {\n return true;\n }\n if (request.headers != null && request.headers.length > 0) {\n return true;\n }\n if (request.body != null) {\n return this.includeRequestBodyInWrappedRequest({ body: request.body, inlineFileProperties });\n }\n if (request.metadata?.onlyPathParameters) {\n return false;\n }\n return true;\n }\n\n public includePathParametersInWrappedRequest({\n request,\n inlinePathParameters\n }: {\n request: FernIr.dynamic.InlinedRequest;\n inlinePathParameters: boolean;\n }): boolean {\n return inlinePathParameters && (request.metadata?.includePathParameters ?? false);\n }\n\n public isFileUploadRequestBody(\n body: FernIr.dynamic.InlinedRequestBody\n ): body is FernIr.dynamic.InlinedRequestBody.FileUpload {\n switch (body.type) {\n case \"fileUpload\":\n return true;\n case \"properties\":\n case \"referenced\":\n return false;\n default:\n assertNever(body);\n }\n }\n\n public resolveEnvironmentName(environmentID: string): FernIr.Name | undefined {\n if (this._ir.environments == null) {\n return undefined;\n }\n const environments = this._ir.environments.environments;\n switch (environments.type) {\n case \"singleBaseUrl\": {\n const environment = environments.environments.find((env) => env.id === environmentID);\n if (environment == null) {\n return undefined;\n }\n return environment.name;\n }\n case \"multipleBaseUrls\": {\n const environment = environments.environments.find((env) => env.id === environmentID);\n if (environment == null) {\n return undefined;\n }\n return environment.name;\n }\n default:\n assertNever(environments);\n }\n }\n\n public isSingleEnvironmentID(\n environment: FernIr.dynamic.EnvironmentValues\n ): environment is FernIr.dynamic.EnvironmentId {\n return typeof environment === \"string\";\n }\n\n public isMultiEnvironmentValues(\n environment: FernIr.dynamic.EnvironmentValues\n ): environment is FernIr.dynamic.MultipleEnvironmentUrlValues {\n return typeof environment === \"object\";\n }\n\n public validateMultiEnvironmentUrlValues(\n multiEnvironmentUrlValues: FernIr.dynamic.MultipleEnvironmentUrlValues\n ): boolean {\n if (this._ir.environments == null) {\n this.errors.add({\n severity: Severity.Critical,\n message:\n \"Multiple environments are not supported for single base URL environments; use the baseUrl option instead\"\n });\n return false;\n }\n const environments = this._ir.environments.environments;\n switch (environments.type) {\n case \"singleBaseUrl\": {\n this.errors.add({\n severity: Severity.Critical,\n message:\n \"Multiple environments are not supported for single base URL environments; use the baseUrl option instead\"\n });\n return false;\n }\n case \"multipleBaseUrls\": {\n const firstEnvironment = environments.environments[0];\n if (firstEnvironment == null) {\n this.errors.add({\n severity: Severity.Critical,\n message: \"Multiple environments are not supported; use the baseUrl option instead\"\n });\n return false;\n }\n const expectedKeys = new Set(keys(firstEnvironment.urls));\n for (const key of keys(multiEnvironmentUrlValues)) {\n if (expectedKeys.has(key)) {\n expectedKeys.delete(key);\n }\n }\n if (expectedKeys.size > 0) {\n this.errors.add({\n severity: Severity.Critical,\n message: `The provided environments are invalid; got: [${Object.keys(multiEnvironmentUrlValues).join(\", \")}], expected: [${keys(firstEnvironment.urls).join(\", \")}]`\n });\n return false;\n }\n return true;\n }\n }\n }\n\n public getValueAsNumber({ value }: { value: unknown }): number | undefined {\n if (typeof value !== \"number\") {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newTypeMismatchError({ expected: \"number\", value }).message\n });\n return undefined;\n }\n return value;\n }\n\n public getValueAsBoolean({ value }: { value: unknown }): boolean | undefined {\n if (typeof value !== \"boolean\") {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newTypeMismatchError({ expected: \"boolean\", value }).message\n });\n return undefined;\n }\n return value;\n }\n\n public getValueAsString({ value }: { value: unknown }): string | undefined {\n if (typeof value !== \"string\") {\n this.errors.add({\n severity: Severity.Critical,\n message: this.newTypeMismatchError({ expected: \"string\", value }).message\n });\n return undefined;\n }\n return value;\n }\n\n public isOptional(typeReference: FernIr.dynamic.TypeReference): boolean {\n switch (typeReference.type) {\n case \"nullable\":\n return this.isOptional(typeReference.value);\n case \"optional\":\n return true;\n case \"named\": {\n const resolvedType = this.resolveNamedType({ typeId: typeReference.value });\n if (resolvedType == null) {\n return false;\n }\n if (resolvedType.type === \"alias\") {\n return this.isNullable(resolvedType.typeReference);\n }\n return false;\n }\n }\n return false;\n }\n\n public isNullable(typeReference: FernIr.dynamic.TypeReference): boolean {\n switch (typeReference.type) {\n case \"nullable\":\n return true;\n case \"optional\":\n return this.isNullable(typeReference.value);\n case \"named\": {\n const resolvedType = this.resolveNamedType({ typeId: typeReference.value });\n if (resolvedType == null) {\n return false;\n }\n if (resolvedType.type === \"alias\") {\n return this.isNullable(resolvedType.typeReference);\n }\n return false;\n }\n }\n return false;\n }\n\n public newAuthMismatchError({\n auth,\n values\n }: {\n auth: FernIr.dynamic.Auth;\n values: FernIr.dynamic.AuthValues;\n }): Error {\n return new Error(`Expected auth type ${auth.type}, got ${values.type}`);\n }\n\n public newParameterNotRecognizedError(parameterName: string): Error {\n return new Error(`\"${parameterName}\" is not a recognized parameter for this endpoint`);\n }\n\n public newTypeMismatchError({ expected, value }: { expected: string; value: unknown }): Error {\n return new Error(`Expected ${expected}, got ${typeof value}`);\n }\n\n private includeRequestBodyInWrappedRequest({\n body,\n inlineFileProperties\n }: {\n body: FernIr.dynamic.InlinedRequestBody;\n inlineFileProperties: boolean;\n }): boolean {\n switch (body.type) {\n case \"properties\":\n case \"referenced\":\n return true;\n case \"fileUpload\":\n return this.includeFileUploadBodyInWrappedRequest({ fileUpload: body, inlineFileProperties });\n default:\n assertNever(body);\n }\n }\n\n private includeFileUploadBodyInWrappedRequest({\n fileUpload,\n inlineFileProperties\n }: {\n fileUpload: FernIr.dynamic.FileUploadRequestBody;\n inlineFileProperties: boolean;\n }): boolean {\n return (\n this.fileUploadHasBodyProperties({ fileUpload }) ||\n (inlineFileProperties && this.fileUploadHasFileProperties({ fileUpload }))\n );\n }\n\n private fileUploadHasBodyProperties({ fileUpload }: { fileUpload: FernIr.dynamic.FileUploadRequestBody }): boolean {\n return fileUpload.properties.some((property) => {\n switch (property.type) {\n case \"file\":\n case \"fileArray\":\n return false;\n case \"bodyProperty\":\n return true;\n default:\n assertNever(property);\n }\n });\n }\n\n private fileUploadHasFileProperties({ fileUpload }: { fileUpload: FernIr.dynamic.FileUploadRequestBody }): boolean {\n return fileUpload.properties.some((property) => {\n switch (property.type) {\n case \"file\":\n case \"fileArray\":\n return true;\n case \"bodyProperty\":\n return false;\n default:\n assertNever(property);\n }\n });\n }\n\n private isListTypeReference(typeReference: FernIr.dynamic.TypeReference): boolean {\n if (typeReference.type === \"optional\") {\n return this.isListTypeReference(typeReference.value);\n }\n return typeReference.type === \"list\" || typeReference.type === \"set\";\n }\n\n private parsedEndpointMatches({\n endpoint,\n parsedEndpoint\n }: {\n endpoint: FernIr.dynamic.Endpoint;\n parsedEndpoint: HttpEndpointReferenceParser.Parsed;\n }): boolean {\n return endpoint.location.method === parsedEndpoint.method && endpoint.location.path === parsedEndpoint.path;\n }\n}\n","export { EXAMPLE_REFERENCE_PREFIX, YAML_SCHEMA_VERSION } from \"./constants\";\nexport { type NodePath, type NodePathItem } from \"./NodePath\";\nexport * as RawSchemas from \"./schemas\";\nexport { type DefinitionFileSchema, type PackageMarkerFileSchema, type RootApiFileSchema } from \"./schemas\";\nexport * from \"./utils/auth\";\nexport * from \"./utils/generics\";\nexport { getRequestBody } from \"./utils/getRequestBody\";\nexport { getResponseBodyType } from \"./utils/getResponseBodyType\";\nexport { HttpEndpointReferenceParser } from \"./utils/HttpEndpointReferenceParser\";\nexport { isInlineRequestBody } from \"./utils/isInlineRequestBody\";\nexport { isOpenApiSourceSchema } from \"./utils/isOpenApiSourceSchema\";\nexport { isRawProtobufSourceSchema } from \"./utils/isRawProtobufSourceSchema\";\nexport { isRawTextType } from \"./utils/isRawTextType\";\nexport { type BytesRequest, parseBytesRequest } from \"./utils/parseBytesRequest\";\nexport { parseFileUploadRequest, type RawFileUploadRequest } from \"./utils/parseFileUploadRequest\";\nexport { parseRawBytesType, type RawBytesType } from \"./utils/parseRawBytesType\";\nexport { parseRawFileType, type RawFileType } from \"./utils/parseRawFileType\";\nexport { parseRawTextType, type RawTextType } from \"./utils/parseRawTextType\";\nexport { RawPrimitiveType } from \"./utils/RawPrimitiveType\";\nexport { recursivelyVisitRawTypeReference } from \"./utils/recursivelyVisitRawTypeReference\";\nexport { visitExampleCodeSampleSchema } from \"./utils/visitExampleCodeSampleSchema\";\nexport { type ExampleResponseSchemaVisitor, visitExampleResponseSchema } from \"./utils/visitExampleResponseSchema\";\nexport { isAnyAuthSchemes, isSingleAuthScheme, type RawApiAuthVisitor, visitRawApiAuth } from \"./utils/visitRawApiAuth\";\nexport {\n type AuthSchemeDeclarationVisitor,\n isHeaderAuthScheme,\n visitRawAuthSchemeDeclaration\n} from \"./utils/visitRawAuthSchemeDeclaration\";\nexport {\n isRawMultipleBaseUrlsEnvironment,\n isRawSingleBaseUrlEnvironment,\n visitRawEnvironmentDeclaration\n} from \"./utils/visitRawEnvironmentDeclaration\";\nexport {\n isVariablePathParameter,\n type PathParameterDeclarationVisitor,\n visitRawPathParameter\n} from \"./utils/visitRawPathParameter\";\nexport {\n isRawAliasDefinition,\n isRawDiscriminatedUnionDefinition,\n isRawEnumDefinition,\n isRawObjectDefinition,\n isRawUndiscriminatedUnionDefinition,\n type RawTypeDeclarationVisitor,\n visitRawTypeDeclaration\n} from \"./utils/visitRawTypeDeclaration\";\nexport { FernContainerRegex, visitRawTypeReference } from \"./utils/visitRawTypeReference\";\n","export declare namespace HttpEndpointReferenceParser {\n interface Parsed {\n path: string;\n method: Method;\n }\n\n type Method = \"GET\" | \"POST\" | \"PUT\" | \"DELETE\" | \"PATCH\" | \"HEAD\";\n\n export type ValidationResult = Valid | Invalid;\n\n interface Valid {\n type: \"valid\";\n }\n\n interface Invalid {\n type: \"invalid\";\n }\n}\n\n/**\n * Parses an HTTP endpoint reference like `POST /users/get`\n */\nexport class HttpEndpointReferenceParser {\n //eslint-disable-next-line\n private REFERENCE_REGEX = /^(GET|POST|PUT|DELETE|PATCH|HEAD)\\s(\\/\\S*)$/;\n\n public validate(reference: string): HttpEndpointReferenceParser.ValidationResult {\n const validFormat = this.REFERENCE_REGEX.test(reference);\n if (!validFormat) {\n return { type: \"invalid\" };\n }\n return { type: \"valid\" };\n }\n\n public tryParse(reference: string): HttpEndpointReferenceParser.Parsed | undefined {\n const validationResponse = this.validate(reference);\n if (validationResponse.type === \"invalid\") {\n return undefined;\n }\n const match = reference.match(this.REFERENCE_REGEX);\n if (match == null || match[1] == null || match[2] == null) {\n return undefined;\n }\n return {\n method: match[1] as HttpEndpointReferenceParser.Method,\n path: match[2]\n };\n }\n}\n","export const Scope = {\n PathParameters: \"pathParameters\",\n QueryParameters: \"queryParameters\",\n Headers: \"headers\",\n RequestBody: \"requestBody\"\n} as const;\n\nexport type Scope = (typeof Scope)[keyof typeof Scope];\n","export { AbstractDynamicSnippetsGenerator } from \"./AbstractDynamicSnippetsGenerator\";\nexport { AbstractDynamicSnippetsGeneratorContext } from \"./AbstractDynamicSnippetsGeneratorContext\";\nexport { type DiscriminatedUnionTypeInstance } from \"./DiscriminatedUnionTypeInstance\";\nexport { ErrorReporter, Severity } from \"./ErrorReporter\";\nexport { type Options, Style } from \"./Options\";\nexport { Result } from \"./Result\";\nexport { Scope } from \"./Scope\";\nexport { type TypeInstance } from \"./TypeInstance\";\nexport { DynamicSnippetsTestRunner } from \"./test-utils/DynamicSnippetsTestRunner\";\n"],"mappings":"2FAKAA,IAAAC,ICAAC,IAAAC,IAAM,IAAOC,EAAP,KAAa,CAKf,aAAA,CAJOC,EAAA,iBACAA,EAAA,gBACAA,EAAA,YAGH,KAAK,QAAU,OACf,KA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xC,GAAY,CAC3C,OAAQA,EAAS,KAAM,CACnB,IAAK,OACL,IAAK,YACD,MAAO,GACX,IAAK,eACD,MAAO,GACX,QACI0B,EAAY1B,CAAQ,CAC5B,CACJ,CAAC,CACL,CAEQ,4BAA4B,CAAE,WAAAwC,CAAU,EAAwD,CACpG,OAAOA,EAAW,WAAW,KAAMxC,GAAY,CAC3C,OAAQA,EAAS,KAAM,CACnB,IAAK,OACL,IAAK,YACD,MAAO,GACX,IAAK,eACD,MAAO,GACX,QACI0B,EAAY1B,CAAQ,CAC5B,CACJ,CAAC,CACL,CAEQ,oBAAoBmC,EAA2C,CACnE,OAAIA,EAAc,OAAS,WAChB,KAAK,oBAAoBA,EAAc,KAAK,EAEhDA,EAAc,OAAS,QAAUA,EAAc,OAAS,KACnE,CAEQ,sBAAsB,CAC1B,SAAAf,EACA,eAAAH,CAAc,EAIjB,CACG,OAAOG,EAAS,SAAS,SAAWH,EAAe,QAAUG,EAAS,SAAS,OAASH,EAAe,IAC3G,GG/nBJwB,IAAAC,IAAO,IAAMC,EAAQ,CACjB,eAAgB,iBAChB,gBAAiB,kBACjB,QAAS,UACT,YAAa,eCJjBC,IAAAC","names":["init_process","init_buffer","init_process","init_buffer","Result","__publicField","context","snippet","endpoint","_a","reporter","_b","AbstractDynamicSnippetsGenerator","context","__publicField","request","options","endpoints","result","Result","endpoint","snippetGenerator","snippet","error","lastError","init_process","init_buffer","Severity","ErrorReporter","_ErrorReporter","__publicField","err","__spreadProps","__spreadValues","path","severity","clone","result","item","init_process","init_buffer","init_process","init_buffer","init_process","init_buffer","HttpEndpointReferenceParser","__publicField","reference","match","AbstractDynamicSnippetsGeneratorContext","ir","config","options","__publicField","ErrorReporter","HttpEndpointReferenceParser","parameters","values","instances","key","value","parameter","param","typeInstanceValue","Severity","ignoreMissingParameters","snippetObject","objectRecord","property","record","fileValue","fileArrayValue","stringValues","typeId","namedType","discriminatedUnion","discriminantFieldName","discriminantValue","singleDiscriminatedUnionType","_a","_","filtered","__objRest","__restKey","rawEndpoint","parsedEndpoint","location","endpoints","endpoint","request","inlinePathParameters","inlineFileProperties","_b","body","assertNever","environmentID","environments","environment","env","multiEnvironmentUrlValues","firstEnvironment","expectedKeys","keys","typeReference","resolvedType","auth","parameterName","expected","fileUpload","init_process","init_buffer","Scope","init_process","init_buffer"]}
@@ -0,0 +1,2 @@
1
+ import{e as p,f as s,g as l,h as c,j as o}from"./chunk-VY2BNRW5.js";s();l();var y=class{constructor({context:t}){p(this,"context");this.context=t}getFilePropertyInfo({body:t,value:n}){var a;let e={fileFields:[],bodyPropertyFields:[]},i=(a=this.context.getRecord(n))!=null?a:{};for(let r of t.properties)switch(r.type){case"file":e.fileFields.push({name:this.context.getFieldName(r.name),value:this.getSingleFileProperty({property:r,record:i})});break;case"fileArray":e.fileFields.push({name:this.context.getFieldName(r.name),value:this.getArrayFileProperty({property:r,record:i})});break;case"bodyProperty":e.bodyPropertyFields.push({name:this.context.getFieldName(r.name.name),value:this.getBodyProperty({property:r,record:i})});break;default:c(r)}return e}getSingleFileProperty({property:t,record:n}){let e=this.context.getSingleFileValue({property:t,record:n})||"";return o.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(e))}getArrayFileProperty({property:t,record:n}){let e=this.context.getFileArrayValues({property:t,record:n});return e==null?o.TypeInstantiation.nop():o.TypeInstantiation.slice({valueType:o.Type.reference(this.context.getIoReaderTypeReference()),values:e.map(i=>o.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(i)))})}getBodyProperty({property:t,record:n}){let e=n[t.name.wireValue];return e==null?o.TypeInstantiation.nop():this.context.dynamicTypeInstantiationMapper.convert({typeReference:t.typeReference,value:e})}};export{y as a};
2
+ //# sourceMappingURL=chunk-FVPD7ODP.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 { go } from \"@fern-api/go-ast\";\n\nimport { DynamicSnippetsGeneratorContext } from \"./DynamicSnippetsGeneratorContext\";\n\nexport interface FilePropertyInfo {\n fileFields: go.StructField[];\n bodyPropertyFields: go.StructField[];\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 result.fileFields.push({\n name: this.context.getFieldName(property.name),\n value: this.getSingleFileProperty({ property, record })\n });\n break;\n case \"fileArray\":\n result.fileFields.push({\n name: this.context.getFieldName(property.name),\n value: this.getArrayFileProperty({ property, record })\n });\n break;\n case \"bodyProperty\":\n result.bodyPropertyFields.push({\n name: this.context.getFieldName(property.name.name),\n value: this.getBodyProperty({ property, record })\n });\n break;\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 }): go.TypeInstantiation {\n // fix(williammcadams): always return a string reader even if no example was provided\n const fileValue = this.context.getSingleFileValue({ property, record }) || \"\";\n return go.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(fileValue));\n }\n\n private getArrayFileProperty({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.FileArray;\n record: Record<string, unknown>;\n }): go.TypeInstantiation {\n const fileValues = this.context.getFileArrayValues({ property, record });\n if (fileValues == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.slice({\n valueType: go.Type.reference(this.context.getIoReaderTypeReference()),\n values: fileValues.map((value) =>\n go.TypeInstantiation.reference(this.context.getNewStringsReaderFunctionInvocation(value))\n )\n });\n }\n\n private getBodyProperty({\n property,\n record\n }: {\n property: FernIr.dynamic.NamedParameter;\n record: Record<string, unknown>;\n }): go.TypeInstantiation {\n const bodyPropertyValue = record[property.name.wireValue];\n if (bodyPropertyValue == null) {\n return go.TypeInstantiation.nop();\n }\n return this.context.dynamicTypeInstantiationMapper.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,IAA5B,KAAAC,EAAiC,CAAC,EACjD,QAAWG,KAAYL,EAAK,WACxB,OAAQK,EAAS,KAAM,CACnB,IAAK,OACDF,EAAO,WAAW,KAAK,CACnB,KAAM,KAAK,QAAQ,aAAaE,EAAS,IAAI,EAC7C,MAAO,KAAK,sBAAsB,CAAE,SAAAA,EAAU,OAAAD,CAAO,CAAC,CAC1D,CAAC,EACD,MACJ,IAAK,YACDD,EAAO,WAAW,KAAK,CACnB,KAAM,KAAK,QAAQ,aAAaE,EAAS,IAAI,EAC7C,MAAO,KAAK,qBAAqB,CAAE,SAAAA,EAAU,OAAAD,CAAO,CAAC,CACzD,CAAC,EACD,MACJ,IAAK,eACDD,EAAO,mBAAmB,KAAK,CAC3B,KAAM,KAAK,QAAQ,aAAaE,EAAS,KAAK,IAAI,EAClD,MAAO,KAAK,gBAAgB,CAAE,SAAAA,EAAU,OAAAD,CAAO,CAAC,CACpD,CAAC,EACD,MACJ,QACIE,EAAYD,CAAQ,CAC5B,CAEJ,OAAOF,CACX,CAEQ,sBAAsB,CAC1B,SAAAE,EACA,OAAAD,CACJ,EAGyB,CAErB,IAAMG,EAAY,KAAK,QAAQ,mBAAmB,CAAE,SAAAF,EAAU,OAAAD,CAAO,CAAC,GAAK,GAC3E,OAAOI,EAAG,kBAAkB,UAAU,KAAK,QAAQ,sCAAsCD,CAAS,CAAC,CACvG,CAEQ,qBAAqB,CACzB,SAAAF,EACA,OAAAD,CACJ,EAGyB,CACrB,IAAMK,EAAa,KAAK,QAAQ,mBAAmB,CAAE,SAAAJ,EAAU,OAAAD,CAAO,CAAC,EACvE,OAAIK,GAAc,KACPD,EAAG,kBAAkB,IAAI,EAE7BA,EAAG,kBAAkB,MAAM,CAC9B,UAAWA,EAAG,KAAK,UAAU,KAAK,QAAQ,yBAAyB,CAAC,EACpE,OAAQC,EAAW,IAAKR,GACpBO,EAAG,kBAAkB,UAAU,KAAK,QAAQ,sCAAsCP,CAAK,CAAC,CAC5F,CACJ,CAAC,CACL,CAEQ,gBAAgB,CACpB,SAAAI,EACA,OAAAD,CACJ,EAGyB,CACrB,IAAMM,EAAoBN,EAAOC,EAAS,KAAK,SAAS,EACxD,OAAIK,GAAqB,KACdF,EAAG,kBAAkB,IAAI,EAE7B,KAAK,QAAQ,+BAA+B,QAAQ,CACvD,cAAeH,EAAS,cACxB,MAAOK,CACX,CAAC,CACL,CACJ","names":["init_process","init_buffer","FilePropertyMapper","context","__publicField","body","value","_a","result","record","property","assertNever","fileValue","go_exports","fileValues","bodyPropertyValue"]}
@@ -0,0 +1,2 @@
1
+ import{a}from"./chunk-S5R5YTLQ.js";import{a as o}from"./chunk-T2DJJZPN.js";import{a as i}from"./chunk-EUHLPBOB.js";import{e as r,f as n,g as p}from"./chunk-VY2BNRW5.js";n();p();var s=class extends i{constructor({ir:e,config:t,formatter:c}){super(new o({ir:e,config:t}));r(this,"formatter");this.formatter=c}async generate(e,t){return super.generate(e,t)}generateSync(e,t){return super.generateSync(e,t)}async generateSnippetAst(e){return super.generateSnippetAst(e)}createSnippetGenerator(e){return new a({context:e,formatter:this.formatter})}};export{s as a};
2
+ //# sourceMappingURL=chunk-KGXOPYBU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/DynamicSnippetsGenerator.ts"],"sourcesContent":["import {\n AbstractAstNode,\n AbstractDynamicSnippetsGenerator,\n AbstractFormatter,\n FernGeneratorExec,\n Options\n} from \"@fern-api/browser-compatible-base-generator\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { DynamicSnippetsGeneratorContext } from \"./context/DynamicSnippetsGeneratorContext\";\nimport { EndpointSnippetGenerator } from \"./EndpointSnippetGenerator\";\n\nexport class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<\n DynamicSnippetsGeneratorContext,\n EndpointSnippetGenerator\n> {\n private formatter: AbstractFormatter | undefined;\n\n constructor({\n ir,\n config,\n formatter\n }: {\n ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n config: FernGeneratorExec.GeneratorConfig;\n formatter?: AbstractFormatter;\n }) {\n super(new DynamicSnippetsGeneratorContext({ ir, config }));\n this.formatter = formatter;\n }\n\n public async generate(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options?: Options\n ): Promise<FernIr.dynamic.EndpointSnippetResponse> {\n return super.generate(request, options);\n }\n\n public generateSync(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options?: Options\n ): FernIr.dynamic.EndpointSnippetResponse {\n return super.generateSync(request, options);\n }\n\n public async generateSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): Promise<AbstractAstNode> {\n return super.generateSnippetAst(request);\n }\n\n protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator {\n return new EndpointSnippetGenerator({ context, formatter: this.formatter });\n }\n}\n"],"mappings":"yKAAAA,IAAAC,IAWO,IAAMC,EAAN,cAAuCC,CAG5C,CAGE,YAAY,CACR,GAAAC,EACA,OAAAC,EACA,UAAAC,CACJ,EAIG,CACC,MAAM,IAAIC,EAAgC,CAAE,GAAAH,EAAI,OAAAC,CAAO,CAAC,CAAC,EAX7DG,EAAA,KAAQ,aAYJ,KAAK,UAAYF,CACrB,CAEA,MAAa,SACTG,EACAC,EAC+C,CAC/C,OAAO,MAAM,SAASD,EAASC,CAAO,CAC1C,CAEO,aACHD,EACAC,EACsC,CACtC,OAAO,MAAM,aAAaD,EAASC,CAAO,CAC9C,CAEA,MAAa,mBAAmBD,EAA0E,CACtG,OAAO,MAAM,mBAAmBA,CAAO,CAC3C,CAEU,uBAAuBE,EAAoE,CACjG,OAAO,IAAIC,EAAyB,CAAE,QAAAD,EAAS,UAAW,KAAK,SAAU,CAAC,CAC9E,CACJ","names":["init_process","init_buffer","DynamicSnippetsGenerator","AbstractDynamicSnippetsGenerator","ir","config","formatter","DynamicSnippetsGeneratorContext","__publicField","request","options","context","EndpointSnippetGenerator"]}
@@ -0,0 +1,2 @@
1
+ import{b as p}from"./chunk-EUHLPBOB.js";import{e as u,f as l,g as d,h as c,j as r}from"./chunk-VY2BNRW5.js";l();d();var y=class{constructor({context:e}){u(this,"context");this.context=e}convert(e){if(e.value===null&&!this.context.isNullable(e.typeReference)&&this.context.errors.add({severity:p.Critical,message:"Expected non-null value, but got null"}),e.value==null)return r.TypeInstantiation.nop();switch(e.typeReference.type){case"list":return this.convertList({list:e.typeReference.value,value:e.value});case"literal":return r.TypeInstantiation.nop();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"nullable":{let t=e.typeReference.value;if(t.type==="named"){let n=this.context.resolveNamedType({typeId:t.value});if((n==null?void 0:n.type)==="alias"&&["list","set","map"].includes(n.typeReference.type)){let i=this.convert({typeReference:n.typeReference,value:e.value,as:e.as}),a=this.context.getTypeName(n.declaration.name),o=this.context.getImportPath(n.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:i,aliasName:a,aliasImportPath:o})}}return r.TypeInstantiation.optional(this.convert({typeReference:t,value:e.value,as:e.as}))}case"optional":{let t=e.typeReference.value;if(t.type==="named"){let n=this.context.resolveNamedType({typeId:t.value});if((n==null?void 0:n.type)==="alias"&&["list","set","map"].includes(n.typeReference.type)){let i=this.convert({typeReference:n.typeReference,value:e.value,as:e.as}),a=this.context.getTypeName(n.declaration.name),o=this.context.getImportPath(n.declaration.fernFilepath);return this.reconstructAliasCollectionLiteral({collectionLiteral:i,aliasName:a,aliasImportPath:o})}}return r.TypeInstantiation.optional(this.convert({typeReference:t,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.convertList({list:e.typeReference.value,value:e.value});case"unknown":return this.convertUnknown({value:e.value});default:c(e.typeReference)}}convertToPointerIfPossible(e){let t=this.convert(e);switch(e.typeReference.type){case"named":{let n=this.context.resolveNamedType({typeId:e.typeReference.value});return(n==null?void 0:n.type)==="enum"?r.TypeInstantiation.reference(r.invokeMethod({on:t,method:"Ptr",arguments_:[]})):t}default:return t}}convertList({list:e,value:t}){return Array.isArray(t)?r.TypeInstantiation.slice({valueType:this.context.dynamicTypeMapper.convert({typeReference:e}),values:t.map((n,i)=>{this.context.errors.scope({index:i});try{return this.convert({typeReference:e,value:n})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:p.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:p.Critical,message:`Expected object but got: ${t==null?"null":typeof t}`}),r.TypeInstantiation.nop()):r.TypeInstantiation.map({keyType:this.context.dynamicTypeMapper.convert({typeReference:e.key}),valueType:this.context.dynamicTypeMapper.convert({typeReference:e.value}),entries:Object.entries(t).map(([n,i])=>{this.context.errors.scope(n);try{return{key:this.convert({typeReference:e.key,value:n,as:"key"}),value:this.convert({typeReference:e.value,value:i})}}finally{this.context.errors.unscope()}})})}convertNamed({named:e,value:t,as:n}){switch(e.type){case"alias":return this.convertAlias({aliasType:e,value:t,as:n});case"discriminatedUnion":return this.convertDiscriminatedUnion({discriminatedUnion:e,value:t});case"enum":return this.convertEnum({enum_:e,value:t});case"object":return this.convertObject({object_:e,value:t});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t});default:c(e)}}convertAlias({aliasType:e,value:t,as:n}){switch(e.typeReference.type){case"literal":return r.TypeInstantiation.reference(r.invokeFunc({func:r.typeReference({name:this.context.getTypeName(e.declaration.name),importPath:this.context.getImportPath(e.declaration.fernFilepath)}),arguments_:[this.convertLiteralValue(e.typeReference.value)]}));default:return this.convert({typeReference:e.typeReference,value:t,as:n})}}reconstructAliasCollectionLiteral({collectionLiteral:e,aliasName:t,aliasImportPath:n}){let i=e.internalType;return i.type==="slice"?r.TypeInstantiation.reference(r.codeblock(a=>{a.write("&"),a.writeNode(r.typeReference({name:t,importPath:n}));let o=i.values;if(o.length===0){a.write("{}");return}a.writeLine("{"),a.indent();for(let s of o)a.writeNode(s),a.writeLine(",");a.dedent(),a.write("}")})):i.type==="map"?r.TypeInstantiation.reference(r.codeblock(a=>{a.write("&"),a.writeNode(r.typeReference({name:t,importPath:n}));let o=i.entries;if(o.length===0){a.write("{}");return}a.writeLine("{"),a.indent();for(let s of o)a.writeNode(s.key),a.write(": "),a.writeNode(s.value),a.writeLine(",");a.dedent(),a.write("}")})):r.TypeInstantiation.reference(r.codeblock(a=>{a.write("&"),a.writeNode(e)}))}convertLiteralValue(e){switch(e.type){case"boolean":return r.TypeInstantiation.bool(e.value);case"string":return r.TypeInstantiation.string(e.value);default:c(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:t}){let n=this.context.getGoTypeReferenceFromDeclaration({declaration:e.declaration}),i=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:t});if(i==null)return r.TypeInstantiation.nop();let a=i.singleDiscriminatedUnionType,o=this.getBaseFields({discriminatedUnionTypeInstance:i,singleDiscriminatedUnionType:a});switch(a.type){case"samePropertiesAsObject":{let s=this.context.resolveNamedType({typeId:a.typeId});return s==null?r.TypeInstantiation.nop():r.TypeInstantiation.structPointer({typeReference:n,fields:[{name:this.context.getFieldName(a.discriminantValue.name),value:this.convertNamed({named:s,value:i.value})},...o]})}case"singleProperty":{let s=this.context.getRecord(i.value);if(s==null)return r.TypeInstantiation.nop();try{return this.context.errors.scope(a.discriminantValue.wireValue),r.TypeInstantiation.structPointer({typeReference:n,fields:[{name:this.context.getFieldName(a.discriminantValue.name),value:this.convert({typeReference:a.typeReference,value:s[a.discriminantValue.wireValue]})},...o]})}finally{this.context.errors.unscope()}}case"noProperties":return r.TypeInstantiation.structPointer({typeReference:n,fields:[{name:this.context.getFieldName(i.discriminantValue.name),value:r.TypeInstantiation.string(a.discriminantValue.wireValue)},...o]});default:c(a)}}getBaseFields({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:t}){var i,a;return this.context.associateByWireValue({parameters:(i=t.properties)!=null?i:[],values:(a=this.context.getRecord(e.value))!=null?a:{},ignoreMissingParameters:!0}).map(o=>{this.context.errors.scope(o.name.wireValue);try{return{name:this.context.getFieldName(o.name.name),value:this.convert(o)}}finally{this.context.errors.unscope()}})}convertObject({object_:e,value:t}){var i;let n=this.context.associateByWireValue({parameters:e.properties,values:(i=this.context.getRecord(t))!=null?i:{}});return r.TypeInstantiation.structPointer({typeReference:r.typeReference({name:this.context.getTypeName(e.declaration.name),importPath:this.context.getImportPath(e.declaration.fernFilepath)}),fields:n.map(a=>{this.context.errors.scope(a.name.wireValue);try{return{name:this.context.getFieldName(a.name.name),value:this.convert(a)}}finally{this.context.errors.unscope()}})})}convertEnum({enum_:e,value:t}){let n=this.getEnumValueName({enum_:e,value:t});return n==null?r.TypeInstantiation.nop():r.TypeInstantiation.enum(r.typeReference({name:n,importPath:this.context.getImportPath(e.declaration.fernFilepath)}))}getEnumValueName({enum_:e,value:t}){if(typeof t!="string"){this.context.errors.add({severity:p.Critical,message:`Expected enum value string, got: ${typeof t}`});return}let n=e.values.find(i=>i.wireValue===t);if(n==null){this.context.errors.add({severity:p.Critical,message:`An enum value named "${t}" does not exist in this context`});return}return`${this.context.getTypeName(e.declaration.name)}${this.context.getTypeName(n.name)}`}convertUndiscriminatedUnion({undiscriminatedUnion:e,value:t}){let n=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t});if(n==null)return r.TypeInstantiation.nop();let i=this.getUndiscriminatedUnionFieldName({typeReference:n.valueTypeReference});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.structPointer({typeReference:this.context.getGoTypeReferenceFromDeclaration({declaration:e.declaration}),fields:[{name:i,value:n.typeInstantiation}]})}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:t}){for(let n of e.types)try{let i=this.convert({typeReference:n,value:t});return{valueTypeReference:n,typeInstantiation:i}}catch(i){continue}this.context.errors.add({severity:p.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof t}" value`})}getUndiscriminatedUnionFieldName({typeReference:e}){switch(e.type){case"list":return this.getUndiscriminatedUnionFieldNameForList({list:e});case"literal":return this.getUndiscriminatedUnionFieldNameForLiteral({literal:e.value});case"map":return this.getUndiscriminatedUnionFieldNameForMap({map:e});case"named":{let t=this.context.resolveNamedType({typeId:e.value});return t==null?void 0:this.context.getTypeName(t.declaration.name)}case"optional":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:e});case"nullable":return this.getUndiscriminatedUnionFieldNameForOptional({typeReference:e});case"primitive":return this.getUndiscriminatedUnionFieldNameForPrimitive({primitive:e.value});case"set":return this.getUndiscriminatedUnionFieldNameForSet({set:e});case"unknown":return"Unknown";default:c(e)}}getUndiscriminatedUnionFieldNameForList({list:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`${t}List`}getUndiscriminatedUnionFieldNameForMap({map:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e.key});if(t==null)return;let n=this.getUndiscriminatedUnionFieldName({typeReference:e.value});if(n!=null)return`${t}${n}Map`}getUndiscriminatedUnionFieldNameForOptional({typeReference:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`${t}Optional`}getUndiscriminatedUnionFieldNameForSet({set:e}){let t=this.getUndiscriminatedUnionFieldName({typeReference:e});if(t!=null)return`${t}Set`}getUndiscriminatedUnionFieldNameForLiteral({literal:e}){switch(e.type){case"boolean":return e.value?"TrueLiteral":"FalseLiteral";case"string":return`${e.value}StringLiteral`;default:c(e)}}getUndiscriminatedUnionFieldNameForPrimitive({primitive:e}){switch(e){case"INTEGER":case"UINT":return"Integer";case"LONG":case"UINT_64":return"Long";case"FLOAT":case"DOUBLE":return"Double";case"BOOLEAN":return"Boolean";case"BIG_INTEGER":case"STRING":return"String";case"UUID":return"Uuid";case"DATE":return"Date";case"DATE_TIME":return"DateTime";case"BASE_64":return"Base64";default:c(e)}}convertUnknown({value:e}){return r.TypeInstantiation.any(e)}convertPrimitive({primitive:e,value:t,as:n}){switch(e){case"INTEGER":case"UINT":{let i=this.getValueAsNumber({value:t,as:n});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.int(i)}case"LONG":case"UINT_64":{let i=this.getValueAsNumber({value:t,as:n});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.int64(i)}case"FLOAT":case"DOUBLE":{let i=this.getValueAsNumber({value:t,as:n});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.float64(i)}case"BOOLEAN":{let i=this.getValueAsBoolean({value:t,as:n});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.string(i)}case"DATE":{let i=this.context.getValueAsString({value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.date(i)}case"DATE_TIME":{let i=this.context.getValueAsString({value:t});if(i==null)return r.TypeInstantiation.nop();let a=this.normalizeDateTimeString(i);return r.TypeInstantiation.dateTime(a)}case"UUID":{let i=this.context.getValueAsString({value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.uuid(i)}case"BASE_64":{let i=this.context.getValueAsString({value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.bytes(i)}case"BIG_INTEGER":{let i=this.context.getValueAsString({value:t});return i==null?r.TypeInstantiation.nop():r.TypeInstantiation.string(i)}default:c(e)}}getValueAsNumber({value:e,as:t}){let n=t==="key"&&typeof e=="string"?Number(e):e;return this.context.getValueAsNumber({value:n})}getValueAsBoolean({value:e,as:t}){let n=t==="key"?typeof e=="string"?e==="true":e==="false"?!1:e:e;return this.context.getValueAsBoolean({value:n})}normalizeDateTimeString(e){return/^\d{4}-\d{2}-\d{2}$/.test(e)?`${e}T00:00:00Z`:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$/.test(e)?`${e}Z`:e}};export{y as a};
2
+ //# sourceMappingURL=chunk-NY6N4HP7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/context/DynamicTypeInstantiationMapper.ts"],"sourcesContent":["import { DiscriminatedUnionTypeInstance, Severity } from \"@fern-api/browser-compatible-base-generator\";\nimport { assertNever } from \"@fern-api/core-utils\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { go } from \"@fern-api/go-ast\";\n\nimport { DynamicSnippetsGeneratorContext } from \"./DynamicSnippetsGeneratorContext\";\n\nexport declare namespace DynamicTypeInstantiationMapper {\n interface Args {\n typeReference: FernIr.dynamic.TypeReference;\n value: unknown;\n as?: ConvertedAs;\n }\n\n // Identifies what the type is being converted as, which sometimes influences how\n // the type is instantiated.\n type ConvertedAs = \"key\";\n}\n\nexport class DynamicTypeInstantiationMapper {\n private context: DynamicSnippetsGeneratorContext;\n\n constructor({ context }: { context: DynamicSnippetsGeneratorContext }) {\n this.context = context;\n }\n\n public convert(args: DynamicTypeInstantiationMapper.Args): go.TypeInstantiation {\n // eslint-disable-next-line eqeqeq\n if (args.value === null && !this.context.isNullable(args.typeReference)) {\n this.context.errors.add({\n severity: Severity.Critical,\n message: \"Expected non-null value, but got null\"\n });\n }\n if (args.value == null) {\n return go.TypeInstantiation.nop();\n }\n switch (args.typeReference.type) {\n case \"list\":\n return this.convertList({ list: args.typeReference.value, value: args.value });\n case \"literal\":\n return go.TypeInstantiation.nop();\n case \"map\":\n return this.convertMap({ map: args.typeReference, value: args.value });\n case \"named\": {\n const named = this.context.resolveNamedType({ typeId: args.typeReference.value });\n if (named == null) {\n return go.TypeInstantiation.nop();\n }\n return this.convertNamed({ named, value: args.value, as: args.as });\n }\n case \"nullable\": {\n const inner = args.typeReference.value;\n // Special case: nullable + alias-of-collection\n // For fields like `Services *ServicesUs50` where `type ServicesUs50 = []*ServiceUs50`,\n // we generate `&ServicesUs50{...}` using the alias name in the composite literal.\n // This is more idiomatic and matches the exported API type users see.\n if (inner.type === \"named\") {\n const named = this.context.resolveNamedType({ typeId: inner.value });\n if (named?.type === \"alias\" && [\"list\", \"set\", \"map\"].includes(named.typeReference.type)) {\n // Build the underlying collection literal\n const collectionLiteral = this.convert({\n typeReference: named.typeReference,\n value: args.value,\n as: args.as\n });\n\n // Get the alias type reference\n const aliasName = this.context.getTypeName(named.declaration.name);\n const aliasImportPath = this.context.getImportPath(named.declaration.fernFilepath);\n\n // Reconstruct the composite literal using the alias name\n return this.reconstructAliasCollectionLiteral({\n collectionLiteral,\n aliasName,\n aliasImportPath\n });\n }\n }\n // Default behavior for all other nullables\n return go.TypeInstantiation.optional(\n this.convert({ typeReference: inner, value: args.value, as: args.as })\n );\n }\n case \"optional\": {\n const inner = args.typeReference.value;\n // Special case: optional + alias-of-collection\n // For fields like `Services *ServicesUs50` where `type ServicesUs50 = []*ServiceUs50`,\n // we generate `&ServicesUs50{...}` using the alias name in the composite literal.\n // This is more idiomatic and matches the exported API type users see.\n if (inner.type === \"named\") {\n const named = this.context.resolveNamedType({ typeId: inner.value });\n if (named?.type === \"alias\" && [\"list\", \"set\", \"map\"].includes(named.typeReference.type)) {\n // Build the underlying collection literal\n const collectionLiteral = this.convert({\n typeReference: named.typeReference,\n value: args.value,\n as: args.as\n });\n\n // Get the alias type reference\n const aliasName = this.context.getTypeName(named.declaration.name);\n const aliasImportPath = this.context.getImportPath(named.declaration.fernFilepath);\n\n // Reconstruct the composite literal using the alias name\n return this.reconstructAliasCollectionLiteral({\n collectionLiteral,\n aliasName,\n aliasImportPath\n });\n }\n }\n // Default behavior for all other optionals\n return go.TypeInstantiation.optional(\n this.convert({ typeReference: inner, value: args.value, as: args.as })\n );\n }\n case \"primitive\":\n return this.convertPrimitive({ primitive: args.typeReference.value, value: args.value, as: args.as });\n case \"set\":\n return this.convertList({ list: args.typeReference.value, value: args.value });\n case \"unknown\":\n return this.convertUnknown({ value: args.value });\n default:\n assertNever(args.typeReference);\n }\n }\n\n public convertToPointerIfPossible(args: DynamicTypeInstantiationMapper.Args): go.TypeInstantiation {\n const converted = this.convert(args);\n switch (args.typeReference.type) {\n case \"named\": {\n const named = this.context.resolveNamedType({ typeId: args.typeReference.value });\n if (named?.type === \"enum\") {\n return go.TypeInstantiation.reference(\n go.invokeMethod({\n on: converted,\n method: \"Ptr\",\n arguments_: []\n })\n );\n }\n return converted;\n }\n default:\n return converted;\n }\n }\n\n private convertList({ list, value }: { list: FernIr.dynamic.TypeReference; value: unknown }): go.TypeInstantiation {\n if (!Array.isArray(value)) {\n this.context.errors.add({\n severity: Severity.Critical,\n message: `Expected array but got: ${typeof value}`\n });\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.slice({\n valueType: this.context.dynamicTypeMapper.convert({ typeReference: list }),\n values: value.map((v, index) => {\n this.context.errors.scope({ index });\n try {\n return this.convert({ typeReference: list, value: v });\n } finally {\n this.context.errors.unscope();\n }\n })\n });\n }\n\n private convertMap({ map, value }: { map: FernIr.dynamic.MapType; value: unknown }): go.TypeInstantiation {\n if (typeof value !== \"object\" || value == null) {\n this.context.errors.add({\n severity: Severity.Critical,\n message: `Expected object but got: ${value == null ? \"null\" : typeof value}`\n });\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.map({\n keyType: this.context.dynamicTypeMapper.convert({ typeReference: map.key }),\n valueType: this.context.dynamicTypeMapper.convert({ typeReference: map.value }),\n entries: Object.entries(value).map(([key, value]) => {\n this.context.errors.scope(key);\n try {\n return {\n key: this.convert({ typeReference: map.key, value: key, as: \"key\" }),\n value: this.convert({ typeReference: map.value, value })\n };\n } finally {\n this.context.errors.unscope();\n }\n })\n });\n }\n\n private convertNamed({\n named,\n value,\n as\n }: {\n named: FernIr.dynamic.NamedType;\n value: unknown;\n as?: DynamicTypeInstantiationMapper.ConvertedAs;\n }): go.TypeInstantiation {\n switch (named.type) {\n case \"alias\":\n return this.convertAlias({\n aliasType: named,\n value,\n as\n });\n case \"discriminatedUnion\":\n return this.convertDiscriminatedUnion({\n discriminatedUnion: named,\n value\n });\n case \"enum\":\n return this.convertEnum({ enum_: named, value });\n case \"object\":\n return this.convertObject({ object_: named, value });\n case \"undiscriminatedUnion\":\n return this.convertUndiscriminatedUnion({ undiscriminatedUnion: named, value });\n default:\n assertNever(named);\n }\n }\n\n private convertAlias({\n aliasType,\n value,\n as\n }: {\n aliasType: FernIr.dynamic.NamedType.Alias;\n value: unknown;\n as?: DynamicTypeInstantiationMapper.ConvertedAs;\n }): go.TypeInstantiation {\n switch (aliasType.typeReference.type) {\n case \"literal\":\n return go.TypeInstantiation.reference(\n go.invokeFunc({\n func: go.typeReference({\n name: this.context.getTypeName(aliasType.declaration.name),\n importPath: this.context.getImportPath(aliasType.declaration.fernFilepath)\n }),\n arguments_: [this.convertLiteralValue(aliasType.typeReference.value)]\n })\n );\n default:\n return this.convert({ typeReference: aliasType.typeReference, value, as });\n }\n }\n\n private reconstructAliasCollectionLiteral({\n collectionLiteral,\n aliasName,\n aliasImportPath\n }: {\n collectionLiteral: go.TypeInstantiation;\n aliasName: string;\n aliasImportPath: string;\n }): go.TypeInstantiation {\n // Reconstruct the composite literal using the alias name\n const internal = collectionLiteral.internalType;\n // Note: sets are converted to slices via convertList, so they're handled by the slice case\n if (internal.type === \"slice\") {\n return go.TypeInstantiation.reference(\n go.codeblock((writer) => {\n writer.write(\"&\");\n writer.writeNode(\n go.typeReference({\n name: aliasName,\n importPath: aliasImportPath\n })\n );\n\n const values = internal.values;\n if (values.length === 0) {\n writer.write(\"{}\");\n return;\n }\n\n writer.writeLine(\"{\");\n writer.indent();\n for (const v of values) {\n writer.writeNode(v);\n writer.writeLine(\",\");\n }\n writer.dedent();\n writer.write(\"}\");\n })\n );\n }\n if (internal.type === \"map\") {\n return go.TypeInstantiation.reference(\n go.codeblock((writer) => {\n writer.write(\"&\");\n writer.writeNode(\n go.typeReference({\n name: aliasName,\n importPath: aliasImportPath\n })\n );\n\n const entries = internal.entries;\n if (entries.length === 0) {\n writer.write(\"{}\");\n return;\n }\n\n writer.writeLine(\"{\");\n writer.indent();\n for (const entry of entries) {\n writer.writeNode(entry.key);\n writer.write(\": \");\n writer.writeNode(entry.value);\n writer.writeLine(\",\");\n }\n writer.dedent();\n writer.write(\"}\");\n })\n );\n }\n // Fallback: if not a slice or map, use the underlying type approach\n return go.TypeInstantiation.reference(\n go.codeblock((writer) => {\n writer.write(\"&\");\n writer.writeNode(collectionLiteral);\n })\n );\n }\n\n private convertLiteralValue(literal: FernIr.dynamic.LiteralType): go.TypeInstantiation {\n switch (literal.type) {\n case \"boolean\":\n return go.TypeInstantiation.bool(literal.value);\n case \"string\":\n return go.TypeInstantiation.string(literal.value);\n default:\n assertNever(literal);\n }\n }\n\n private convertDiscriminatedUnion({\n discriminatedUnion,\n value\n }: {\n discriminatedUnion: FernIr.dynamic.DiscriminatedUnionType;\n value: unknown;\n }): go.TypeInstantiation {\n const structTypeReference = this.context.getGoTypeReferenceFromDeclaration({\n declaration: discriminatedUnion.declaration\n });\n const discriminatedUnionTypeInstance = this.context.resolveDiscriminatedUnionTypeInstance({\n discriminatedUnion,\n value\n });\n if (discriminatedUnionTypeInstance == null) {\n return go.TypeInstantiation.nop();\n }\n const unionVariant = discriminatedUnionTypeInstance.singleDiscriminatedUnionType;\n const baseFields = this.getBaseFields({\n discriminatedUnionTypeInstance,\n singleDiscriminatedUnionType: unionVariant\n });\n switch (unionVariant.type) {\n case \"samePropertiesAsObject\": {\n const named = this.context.resolveNamedType({\n typeId: unionVariant.typeId\n });\n if (named == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.structPointer({\n typeReference: structTypeReference,\n fields: [\n {\n name: this.context.getFieldName(unionVariant.discriminantValue.name),\n value: this.convertNamed({ named, value: discriminatedUnionTypeInstance.value })\n },\n ...baseFields\n ]\n });\n }\n case \"singleProperty\": {\n const record = this.context.getRecord(discriminatedUnionTypeInstance.value);\n if (record == null) {\n return go.TypeInstantiation.nop();\n }\n try {\n this.context.errors.scope(unionVariant.discriminantValue.wireValue);\n return go.TypeInstantiation.structPointer({\n typeReference: structTypeReference,\n fields: [\n {\n name: this.context.getFieldName(unionVariant.discriminantValue.name),\n value: this.convert({\n typeReference: unionVariant.typeReference,\n value: record[unionVariant.discriminantValue.wireValue]\n })\n },\n ...baseFields\n ]\n });\n } finally {\n this.context.errors.unscope();\n }\n }\n case \"noProperties\":\n return go.TypeInstantiation.structPointer({\n typeReference: structTypeReference,\n fields: [\n {\n // Unions with no properties require the discriminant property to be set.\n name: this.context.getFieldName(discriminatedUnionTypeInstance.discriminantValue.name),\n value: go.TypeInstantiation.string(unionVariant.discriminantValue.wireValue)\n },\n ...baseFields\n ]\n });\n default:\n assertNever(unionVariant);\n }\n }\n\n private getBaseFields({\n discriminatedUnionTypeInstance,\n singleDiscriminatedUnionType\n }: {\n discriminatedUnionTypeInstance: DiscriminatedUnionTypeInstance;\n singleDiscriminatedUnionType: FernIr.dynamic.SingleDiscriminatedUnionType;\n }): go.StructField[] {\n const properties = this.context.associateByWireValue({\n parameters: singleDiscriminatedUnionType.properties ?? [],\n values: this.context.getRecord(discriminatedUnionTypeInstance.value) ?? {},\n\n // We're only selecting the base properties here. The rest of the properties\n // are handled by the union variant.\n ignoreMissingParameters: true\n });\n return properties.map((property) => {\n this.context.errors.scope(property.name.wireValue);\n try {\n return {\n name: this.context.getFieldName(property.name.name),\n value: this.convert(property)\n };\n } finally {\n this.context.errors.unscope();\n }\n });\n }\n\n private convertObject({\n object_,\n value\n }: {\n object_: FernIr.dynamic.ObjectType;\n value: unknown;\n }): go.TypeInstantiation {\n const properties = this.context.associateByWireValue({\n parameters: object_.properties,\n values: this.context.getRecord(value) ?? {}\n });\n return go.TypeInstantiation.structPointer({\n typeReference: go.typeReference({\n name: this.context.getTypeName(object_.declaration.name),\n importPath: this.context.getImportPath(object_.declaration.fernFilepath)\n }),\n fields: properties.map((property) => {\n this.context.errors.scope(property.name.wireValue);\n try {\n return {\n name: this.context.getFieldName(property.name.name),\n value: this.convert(property)\n };\n } finally {\n this.context.errors.unscope();\n }\n })\n });\n }\n\n private convertEnum({ enum_, value }: { enum_: FernIr.dynamic.EnumType; value: unknown }): go.TypeInstantiation {\n const name = this.getEnumValueName({ enum_, value });\n if (name == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.enum(\n go.typeReference({\n name,\n importPath: this.context.getImportPath(enum_.declaration.fernFilepath)\n })\n );\n }\n\n private getEnumValueName({ enum_, value }: { enum_: FernIr.dynamic.EnumType; value: unknown }): string | undefined {\n if (typeof value !== \"string\") {\n this.context.errors.add({\n severity: Severity.Critical,\n message: `Expected enum value string, got: ${typeof value}`\n });\n return undefined;\n }\n const enumValue = enum_.values.find((v) => v.wireValue === value);\n if (enumValue == null) {\n this.context.errors.add({\n severity: Severity.Critical,\n message: `An enum value named \"${value}\" does not exist in this context`\n });\n return undefined;\n }\n return `${this.context.getTypeName(enum_.declaration.name)}${this.context.getTypeName(enumValue.name)}`;\n }\n\n private convertUndiscriminatedUnion({\n undiscriminatedUnion,\n value\n }: {\n undiscriminatedUnion: FernIr.dynamic.UndiscriminatedUnionType;\n value: unknown;\n }): go.TypeInstantiation {\n const result = this.findMatchingUndiscriminatedUnionType({\n undiscriminatedUnion,\n value\n });\n if (result == null) {\n return go.TypeInstantiation.nop();\n }\n const fieldName = this.getUndiscriminatedUnionFieldName({ typeReference: result.valueTypeReference });\n if (fieldName == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.structPointer({\n typeReference: this.context.getGoTypeReferenceFromDeclaration({\n declaration: undiscriminatedUnion.declaration\n }),\n fields: [\n {\n name: fieldName,\n value: result.typeInstantiation\n }\n ]\n });\n }\n\n private findMatchingUndiscriminatedUnionType({\n undiscriminatedUnion,\n value\n }: {\n undiscriminatedUnion: FernIr.dynamic.UndiscriminatedUnionType;\n value: unknown;\n }): { valueTypeReference: FernIr.dynamic.TypeReference; typeInstantiation: go.TypeInstantiation } | undefined {\n for (const typeReference of undiscriminatedUnion.types) {\n try {\n const typeInstantiation = this.convert({ typeReference, value });\n return { valueTypeReference: typeReference, typeInstantiation };\n } catch (e) {\n continue;\n }\n }\n this.context.errors.add({\n severity: Severity.Critical,\n message: `None of the types in the undiscriminated union matched the given \"${typeof value}\" value`\n });\n return undefined;\n }\n\n private getUndiscriminatedUnionFieldName({\n typeReference\n }: {\n typeReference: FernIr.dynamic.TypeReference;\n }): string | undefined {\n switch (typeReference.type) {\n case \"list\":\n return this.getUndiscriminatedUnionFieldNameForList({ list: typeReference });\n case \"literal\":\n return this.getUndiscriminatedUnionFieldNameForLiteral({ literal: typeReference.value });\n case \"map\":\n return this.getUndiscriminatedUnionFieldNameForMap({ map: typeReference });\n case \"named\": {\n const named = this.context.resolveNamedType({ typeId: typeReference.value });\n if (named == null) {\n return undefined;\n }\n return this.context.getTypeName(named.declaration.name);\n }\n case \"optional\":\n return this.getUndiscriminatedUnionFieldNameForOptional({ typeReference });\n case \"nullable\":\n return this.getUndiscriminatedUnionFieldNameForOptional({ typeReference });\n case \"primitive\":\n return this.getUndiscriminatedUnionFieldNameForPrimitive({ primitive: typeReference.value });\n case \"set\":\n return this.getUndiscriminatedUnionFieldNameForSet({ set: typeReference });\n case \"unknown\":\n return \"Unknown\";\n default:\n assertNever(typeReference);\n }\n }\n\n private getUndiscriminatedUnionFieldNameForList({\n list\n }: {\n list: FernIr.dynamic.TypeReference.List;\n }): string | undefined {\n const fieldName = this.getUndiscriminatedUnionFieldName({ typeReference: list });\n if (fieldName == null) {\n return undefined;\n }\n return `${fieldName}List`;\n }\n\n private getUndiscriminatedUnionFieldNameForMap({ map }: { map: FernIr.dynamic.MapType }): string | undefined {\n const keyFieldName = this.getUndiscriminatedUnionFieldName({ typeReference: map.key });\n if (keyFieldName == null) {\n return undefined;\n }\n const valueFieldName = this.getUndiscriminatedUnionFieldName({ typeReference: map.value });\n if (valueFieldName == null) {\n return undefined;\n }\n return `${keyFieldName}${valueFieldName}Map`;\n }\n\n private getUndiscriminatedUnionFieldNameForOptional({\n typeReference\n }: {\n typeReference: FernIr.dynamic.TypeReference.Optional | FernIr.dynamic.TypeReference.Nullable;\n }): string | undefined {\n const fieldName = this.getUndiscriminatedUnionFieldName({ typeReference });\n if (fieldName == null) {\n return undefined;\n }\n return `${fieldName}Optional`;\n }\n\n private getUndiscriminatedUnionFieldNameForSet({\n set\n }: {\n set: FernIr.dynamic.TypeReference.Set;\n }): string | undefined {\n const fieldName = this.getUndiscriminatedUnionFieldName({ typeReference: set });\n if (fieldName == null) {\n return undefined;\n }\n return `${fieldName}Set`;\n }\n\n private getUndiscriminatedUnionFieldNameForLiteral({\n literal\n }: {\n literal: FernIr.dynamic.LiteralType;\n }): string | undefined {\n switch (literal.type) {\n case \"boolean\":\n if (literal.value) {\n return \"TrueLiteral\";\n }\n return \"FalseLiteral\";\n case \"string\":\n return `${literal.value}StringLiteral`;\n default:\n assertNever(literal);\n }\n }\n\n private getUndiscriminatedUnionFieldNameForPrimitive({\n primitive\n }: {\n primitive: FernIr.dynamic.PrimitiveTypeV1;\n }): string {\n switch (primitive) {\n case \"INTEGER\":\n case \"UINT\":\n return \"Integer\";\n case \"LONG\":\n case \"UINT_64\":\n return \"Long\";\n case \"FLOAT\":\n case \"DOUBLE\":\n return \"Double\";\n case \"BOOLEAN\":\n return \"Boolean\";\n case \"BIG_INTEGER\":\n case \"STRING\":\n return \"String\";\n case \"UUID\":\n return \"Uuid\";\n case \"DATE\":\n return \"Date\";\n case \"DATE_TIME\":\n return \"DateTime\";\n case \"BASE_64\":\n return \"Base64\";\n default:\n assertNever(primitive);\n }\n }\n\n private convertUnknown({ value }: { value: unknown }): go.TypeInstantiation {\n return go.TypeInstantiation.any(value);\n }\n\n private convertPrimitive({\n primitive,\n value,\n as\n }: {\n primitive: FernIr.dynamic.PrimitiveTypeV1;\n value: unknown;\n as?: DynamicTypeInstantiationMapper.ConvertedAs;\n }): go.TypeInstantiation {\n switch (primitive) {\n case \"INTEGER\":\n case \"UINT\": {\n const num = this.getValueAsNumber({ value, as });\n if (num == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.int(num);\n }\n case \"LONG\":\n case \"UINT_64\": {\n const num = this.getValueAsNumber({ value, as });\n if (num == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.int64(num);\n }\n case \"FLOAT\":\n case \"DOUBLE\": {\n const num = this.getValueAsNumber({ value, as });\n if (num == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.float64(num);\n }\n case \"BOOLEAN\": {\n const bool = this.getValueAsBoolean({ value, as });\n if (bool == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.bool(bool);\n }\n case \"STRING\": {\n const str = this.context.getValueAsString({ value });\n if (str == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.string(str);\n }\n case \"DATE\": {\n const date = this.context.getValueAsString({ value });\n if (date == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.date(date);\n }\n case \"DATE_TIME\": {\n const dateTime = this.context.getValueAsString({ value });\n if (dateTime == null) {\n return go.TypeInstantiation.nop();\n }\n const normalizedDateTime = this.normalizeDateTimeString(dateTime);\n return go.TypeInstantiation.dateTime(normalizedDateTime);\n }\n case \"UUID\": {\n const uuid = this.context.getValueAsString({ value });\n if (uuid == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.uuid(uuid);\n }\n case \"BASE_64\": {\n const base64 = this.context.getValueAsString({ value });\n if (base64 == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.bytes(base64);\n }\n case \"BIG_INTEGER\": {\n const bigInt = this.context.getValueAsString({ value });\n if (bigInt == null) {\n return go.TypeInstantiation.nop();\n }\n return go.TypeInstantiation.string(bigInt);\n }\n default:\n assertNever(primitive);\n }\n }\n\n private getValueAsNumber({\n value,\n as\n }: {\n value: unknown;\n as?: DynamicTypeInstantiationMapper.ConvertedAs;\n }): number | undefined {\n const num = as === \"key\" ? (typeof value === \"string\" ? Number(value) : value) : value;\n return this.context.getValueAsNumber({ value: num });\n }\n\n private getValueAsBoolean({\n value,\n as\n }: {\n value: unknown;\n as?: DynamicTypeInstantiationMapper.ConvertedAs;\n }): boolean | undefined {\n const bool =\n as === \"key\" ? (typeof value === \"string\" ? value === \"true\" : value === \"false\" ? false : value) : value;\n return this.context.getValueAsBoolean({ value: bool });\n }\n\n private normalizeDateTimeString(dateTime: string): string {\n if (/^\\d{4}-\\d{2}-\\d{2}$/.test(dateTime)) {\n return `${dateTime}T00:00:00Z`;\n }\n if (/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$/.test(dateTime)) {\n return `${dateTime}Z`;\n }\n return dateTime;\n }\n}\n"],"mappings":"4GAAAA,IAAAC,IAmBO,IAAMC,EAAN,KAAqC,CAGxC,YAAY,CAAE,QAAAC,CAAQ,EAAiD,CAFvEC,EAAA,KAAQ,WAGJ,KAAK,QAAUD,CACnB,CAEO,QAAQE,EAAiE,CAQ5E,GANIA,EAAK,QAAU,MAAQ,CAAC,KAAK,QAAQ,WAAWA,EAAK,aAAa,GAClE,KAAK,QAAQ,OAAO,IAAI,CACpB,SAAUC,EAAS,SACnB,QA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CAAS,CAC7B,CACJ,CAEQ,iBAAiB,CACrB,MAAArC,EACA,GAAAK,CACJ,EAGuB,CACnB,IAAMiC,EAAMjC,IAAO,OAAS,OAAOL,GAAU,SAAW,OAAOA,CAAK,EAAaA,EACjF,OAAO,KAAK,QAAQ,iBAAiB,CAAE,MAAOsC,CAAI,CAAC,CACvD,CAEQ,kBAAkB,CACtB,MAAAtC,EACA,GAAAK,CACJ,EAGwB,CACpB,IAAMkC,EACFlC,IAAO,MAAS,OAAOL,GAAU,SAAWA,IAAU,OAASA,IAAU,QAAU,GAAQA,EAASA,EACxG,OAAO,KAAK,QAAQ,kBAAkB,CAAE,MAAOuC,CAAK,CAAC,CACzD,CAEQ,wBAAwBG,EAA0B,CACtD,MAAI,sBAAsB,KAAKA,CAAQ,EAC5B,GAAGA,CAAQ,aAElB,wCAAwC,KAAKA,CAAQ,EAC9C,GAAGA,CAAQ,IAEfA,CACX,CACJ","names":["init_process","init_buffer","DynamicTypeInstantiationMapper","context","__publicField","args","Severity","go_exports","named","inner","collectionLiteral","aliasName","aliasImportPath","assertNever","converted","list","value","v","index","map","key","as","aliasType","internal","writer","values","entries","entry","literal","discriminatedUnion","structTypeReference","discriminatedUnionTypeInstance","unionVariant","baseFields","record","singleDiscriminatedUnionType","_a","_b","property","object_","properties","enum_","name","enumValue","undiscriminatedUnion","result","fieldName","typeReference","typeInstantiation","e","keyFieldName","valueFieldName","set","primitive","num","bool","str","date","dateTime","normalizedDateTime","uuid","base64","bigInt"]}
@@ -0,0 +1,2 @@
1
+ import{b as p,d}from"./chunk-EUHLPBOB.js";import{e as v,f as R,g as N,h as m,j as r}from"./chunk-VY2BNRW5.js";R();N();var b="example",P="fern",T="do",I="client",l=r.TypeInstantiation,w="WireMockBaseURL",C="WireMockClient",x=class{constructor({context:e,formatter:t}){v(this,"context");v(this,"formatter");this.context=e,this.formatter=t}async generateSnippet({endpoint:e,request:t,options:n}){var s,a,c;return((a=(s=n==null?void 0:n.config)==null?void 0:s.outputWiremockTests)!=null?a:!1)?this.generateWiremockTest({endpoint:e,snippet:t}):await this.buildCodeBlock({endpoint:e,snippet:t}).toStringAsync({packageName:b,importPath:P,rootImportPath:this.context.rootImportPath,customConfig:(c=this.context.customConfig)!=null?c:{},formatter:this.formatter})}generateSnippetSync({endpoint:e,request:t,options:n}){var s,a,c;return((a=(s=n==null?void 0:n.config)==null?void 0:s.outputWiremockTests)!=null?a:!1)?this.generateWiremockTest({endpoint:e,snippet:t}):this.buildCodeBlock({endpoint:e,snippet:t}).toString({packageName:b,importPath:P,rootImportPath:this.context.rootImportPath,customConfig:(c=this.context.customConfig)!=null?c:{},formatter:this.formatter})}async generateSnippetAst({endpoint:e,request:t,options:n}){throw new Error("Unsupported")}generateWiremockTest({endpoint:e,snippet:t}){var o;return this.buildWiremockTestCodeBlock({endpoint:e,snippet:t}).toString({packageName:"wiremock",importPath:P,rootImportPath:this.context.rootImportPath,customConfig:(o=this.context.customConfig)!=null?o:{},formatter:this.formatter})}buildCodeBlock({endpoint:e,snippet:t}){return r.codeblock(n=>{n.writeNode(r.func({name:T,parameters:[],return_:[],body:r.codeblock(o=>{o.writeNode(this.constructClient({endpoint:e,snippet:t})),o.writeLine(),o.writeNode(this.callMethod({endpoint:e,snippet:t}))})})),n.writeNewLineIfLastLineNot()})}buildWiremockTestCodeBlock({endpoint:e,snippet:t}){return r.codeblock(n=>{n.writeNode(r.func({name:"Test"+this.context.getTestMethodName(e)+"WithWireMock",parameters:[r.parameter({name:"t",type:r.Type.pointer(r.Type.reference(this.context.getTestingTypeReference()))})],return_:[],body:r.codeblock(o=>{for(let i of this.buildWiremockTestSetup({endpoint:e}))o.writeNode(i),o.writeLine();o.writeLine(),o.writeNode(this.constructWiremockTestClient({endpoint:e,snippet:t})),o.writeLine(),o.writeNode(this.callClientMethodAndAssert({endpoint:e,snippet:t}))})})),n.writeNewLineIfLastLineNot()})}constructClient({endpoint:e,snippet:t}){return r.codeblock(n=>{n.write(`${I} := `),n.writeNode(this.getRootClientFuncInvocation(this.getConstructorArgs({endpoint:e,snippet:t})))})}constructWiremockTestClient({endpoint:e,snippet:t}){return r.codeblock(n=>{n.write(`${I} := `),n.writeNode(this.getRootClientFuncInvocation(this.getWiremockTestConstructorArgs()))})}writeMethodInvocation({writer:e,endpoint:t,snippet:n}){let{otherArgs:o,requestArg:i}=this.getMethodArgs({endpoint:t,snippet:n});if(i!=null)if(i instanceof r.TypeInstantiation&&r.TypeInstantiation.isNop(i))e.writeNode(r.invokeMethod({on:r.codeblock(I),method:this.getMethod({endpoint:t}),arguments_:[this.context.getContextTodoFunctionInvocation(),...o,r.codeblock("nil")]}));else{e.write("request := "),e.writeNode(i),e.writeLine();let s=r.codeblock("request");e.writeNode(r.invokeMethod({on:r.codeblock(I),method:this.getMethod({endpoint:t}),arguments_:[this.context.getContextTodoFunctionInvocation(),...o,s]}))}else e.writeNode(r.invokeMethod({on:r.codeblock(I),method:this.getMethod({endpoint:t}),arguments_:[this.context.getContextTodoFunctionInvocation(),...o]}))}callMethod({endpoint:e,snippet:t}){return r.codeblock(n=>{this.writeMethodInvocation({writer:n,endpoint:e,snippet:t})})}getConstructorArgs({endpoint:e,snippet:t}){let n=[],o=this.getConstructorBaseUrlArg({baseUrl:t.baseURL,environment:t.environment});return o!=null&&n.push(o),e.auth!=null&&(t.auth!=null?n.push(this.getConstructorAuthArg({auth:e.auth,values:t.auth})):this.context.errors.add({severity:p.Warning,message:`Auth with ${e.auth.type} configuration is required for this endpoint`})),this.context.errors.scope(d.Headers),this.context.ir.headers!=null&&t.headers!=null&&n.push(...this.getConstructorHeaderArgs({headers:this.context.ir.headers,values:t.headers})),this.context.errors.unscope(),n}getWiremockTestConstructorArgs(){return[r.codeblock(e=>{e.writeNode(r.invokeFunc({func:r.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[r.codeblock(w)]}))})]}getConstructorAuthArg({auth:e,values:t}){if(t.type!==e.type)return this.addError(this.context.newAuthMismatchError({auth:e,values:t}).message),l.nop();switch(e.type){case"basic":return t.type==="basic"?this.getConstructorBasicAuthArg({auth:e,values:t}):l.nop();case"bearer":return t.type==="bearer"?this.getConstructorBearerAuthArg({auth:e,values:t}):l.nop();case"header":return t.type==="header"?this.getConstructorHeaderAuthArg({auth:e,values:t}):l.nop();case"oauth":return this.addWarning("The Go SDK doesn't support OAuth client credentials yet"),l.nop();case"inferred":return this.addWarning("The Go SDK Generator does not support Inferred auth scheme yet"),l.nop();default:m(e)}}addError(e){this.context.errors.add({severity:p.Critical,message:e})}addWarning(e){this.context.errors.add({severity:p.Warning,message:e})}getConstructorBasicAuthArg({auth:e,values:t}){return r.codeblock(n=>{n.writeNode(r.invokeFunc({func:r.typeReference({name:"WithBasicAuth",importPath:this.context.getOptionImportPath()}),arguments_:[r.TypeInstantiation.string(t.username),r.TypeInstantiation.string(t.password)]}))})}getConstructorBaseUrlArg({baseUrl:e,environment:t}){let n=this.getBaseUrlArg({baseUrl:e,environment:t});if(n!=null)return r.codeblock(o=>{o.writeNode(r.invokeFunc({func:r.typeReference({name:"WithBaseURL",importPath:this.context.getOptionImportPath()}),arguments_:[n]}))})}getBaseUrlArg({baseUrl:e,environment:t}){if(e!=null&&t!=null){this.context.errors.add({severity:p.Critical,message:"Cannot specify both baseUrl and environment options"});return}if(e!=null)return r.TypeInstantiation.string(e);if(t!=null){if(this.context.isSingleEnvironmentID(t)){let n=this.context.getEnvironmentTypeReferenceFromID(t);if(n==null){this.context.errors.add({severity:p.Warning,message:`Environment ${JSON.stringify(t)} was not found`});return}return r.TypeInstantiation.reference(n)}this.context.isMultiEnvironmentValues(t)&&this.context.errors.add({severity:p.Warning,message:"The Go SDK doesn't support a multi-environment client option yet; use the baseUrl option instead"})}}getConstructorBearerAuthArg({auth:e,values:t}){return r.codeblock(n=>{n.writeNode(r.invokeFunc({func:r.typeReference({name:`With${e.token.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[r.TypeInstantiation.string(t.token)]}))})}getConstructorHeaderAuthArg({auth:e,values:t}){return r.codeblock(n=>{n.writeNode(r.invokeFunc({func:r.typeReference({name:`With${e.header.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[this.context.dynamicTypeInstantiationMapper.convert({typeReference:e.header.typeReference,value:t.value})]}))})}getConstructorHeaderArgs({headers:e,values:t}){let n=[];for(let o of e){let i=this.getConstructorHeaderArg({header:o,value:t.value});i!=null&&n.push(i)}return n}getConstructorHeaderArg({header:e,value:t}){let n=this.context.dynamicTypeInstantiationMapper.convert({typeReference:e.typeReference,value:t});if(!r.TypeInstantiation.isNop(n))return r.codeblock(o=>{o.writeNode(r.invokeFunc({func:r.typeReference({name:`With${e.name.name.pascalCase.unsafeName}`,importPath:this.context.getOptionImportPath()}),arguments_:[n]}))})}getMethodArgs({endpoint:e,snippet:t}){switch(e.request.type){case"inlined":return this.getMethodArgsForInlinedRequest({request:e.request,snippet:t});case"body":return this.getMethodArgsForBodyRequest({request:e.request,snippet:t});default:m(e.request)}}getMethodArgsForBodyRequest({request:e,snippet:t}){var s,a;let n=[];this.context.errors.scope(d.PathParameters);let o=[...(s=this.context.ir.pathParameters)!=null?s:[],...(a=e.pathParameters)!=null?a:[]];o.length>0&&n.push(...this.getPathParameters({namedParameters:o,snippet:t}).map(c=>c.value)),this.context.errors.unscope(),this.context.errors.scope(d.RequestBody);let i=e.body!=null?this.getBodyRequestArg({body:e.body,value:t.requestBody}):void 0;return this.context.errors.unscope(),{otherArgs:n,requestArg:i}}getBodyRequestArg({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:e.value,value:t});default:m(e)}}getBytesBodyRequestArg({value:e}){return typeof e!="string"?(this.context.errors.add({severity:p.Critical,message:`Expected bytes value to be a string, got ${typeof e}`}),r.TypeInstantiation.nop()):r.TypeInstantiation.bytes(e)}getMethodArgsForInlinedRequest({request:e,snippet:t}){var h,g,y,f,u,k;let n=[],{inlinePathParameters:o,inlineFileProperties:i}={inlinePathParameters:(g=(h=this.context.customConfig)==null?void 0:h.inlinePathParameters)!=null?g:!0,inlineFileProperties:(f=(y=this.context.customConfig)==null?void 0:y.inlineFileProperties)!=null?f:!0};this.context.errors.scope(d.PathParameters);let s=[],a=[...(u=this.context.ir.pathParameters)!=null?u:[],...(k=e.pathParameters)!=null?k:[]];a.length>0&&s.push(...this.getPathParameters({namedParameters:a,snippet:t})),this.context.errors.unscope(),this.context.errors.scope(d.RequestBody);let c=this.getFilePropertyInfo({request:e,snippet:t});this.context.errors.unscope(),this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:o})||n.push(...s.map(A=>A.value)),i||n.push(...c.fileFields.map(A=>A.value));let F=this.context.needsRequestParameter({request:e,inlinePathParameters:o,inlineFileProperties:i})?this.getInlinedRequestArg({request:e,snippet:t,pathParameterFields:this.context.includePathParametersInWrappedRequest({request:e,inlinePathParameters:o})?s:[],filePropertyInfo:c}):void 0;return{otherArgs:n,requestArg:F}}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:n,filePropertyInfo:o}){var h,g,y,f;this.context.errors.scope(d.QueryParameters);let s=this.context.associateQueryParametersByWireValue({parameters:(h=e.queryParameters)!=null?h:[],values:(g=t.queryParameters)!=null?g:{}}).map(u=>({name:u.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(u)}));this.context.errors.unscope(),this.context.errors.scope(d.Headers);let c=this.context.associateByWireValue({parameters:(y=e.headers)!=null?y:[],values:(f=t.headers)!=null?f:{}}).map(u=>({name:u.name.name.pascalCase.unsafeName,value:this.context.dynamicTypeInstantiationMapper.convert(u)}));this.context.errors.unscope(),this.context.errors.scope(d.RequestBody);let F=e.body!=null?this.getInlinedRequestBodyStructFields({body:e.body,value:t.requestBody,filePropertyInfo:o}):[];return this.context.errors.unscope(),r.TypeInstantiation.structPointer({typeReference:r.typeReference({name:this.context.getMethodName(e.declaration.name),importPath:this.context.getImportPathForRequest(e.declaration.fernFilepath)}),fields:[...n,...s,...c,...F]})}getInlinedRequestBodyStructFields({body:e,value:t,filePropertyInfo:n}){switch(e.type){case"properties":return this.getInlinedRequestBodyPropertyStructFields({parameters:e.value,value:t});case"referenced":return[this.getReferencedRequestBodyPropertyStructField({body:e,value:t})];case"fileUpload":return this.getFileUploadRequestBodyStructFields({filePropertyInfo:n});default:m(e)}}getFileUploadRequestBodyStructFields({filePropertyInfo:e}){var t;return(t=this.context.customConfig)!=null&&t.inlineFileProperties?[...e.fileFields,...e.bodyPropertyFields]:e.bodyPropertyFields}getReferencedRequestBodyPropertyStructField({body:e,value:t}){return{name:this.context.getTypeName(e.bodyKey),value:this.getReferencedRequestBodyPropertyTypeInstantiation({body:e.bodyType,value:t})}}getReferencedRequestBodyPropertyTypeInstantiation({body:e,value:t}){switch(e.type){case"bytes":return this.getBytesBodyRequestArg({value:t});case"typeReference":return this.context.dynamicTypeInstantiationMapper.convert({typeReference:e.value,value:t});default:m(e)}}getInlinedRequestBodyPropertyStructFields({parameters:e,value:t}){var i;let n=[],o=this.context.associateByWireValue({parameters:e,values:(i=this.context.getRecord(t))!=null?i:{}});for(let s of o)n.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convert(s)});return n}getPathParameters({namedParameters:e,snippet:t}){var i;let n=[],o=this.context.associateByWireValue({parameters:e,values:(i=t.pathParameters)!=null?i:{}});for(let s of o)n.push({name:this.context.getTypeName(s.name.name),value:this.context.dynamicTypeInstantiationMapper.convertToPointerIfPossible(s)});return n}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)}getRootClientFuncInvocation(e){return r.invokeFunc({func:r.typeReference({name:this.context.getClientConstructorName(),importPath:this.context.getClientImportPath()}),arguments_:e})}buildWiremockTestSetup({endpoint:e,errorCase:t}){let n="stub";return[]}callClientMethodAndAssert({endpoint:e,snippet:t}){return r.codeblock(n=>{this.writeMethodInvocation({writer:n,endpoint:e,snippet:t}),n.writeLine(),n.writeLine(),n.write("ok, countErr := "),n.writeNode(r.invokeMethod({on:r.codeblock(C),method:"Verify",arguments_:[r.invokeMethod({on:r.codeblock("stub"),method:"Request",arguments_:[],multiline:!1}),r.codeblock("1")],multiline:!1})),n.writeLine(),n.writeNode(r.invokeFunc({func:r.typeReference({name:"NoError",importPath:"github.com/stretchr/testify/require"}),arguments_:[r.codeblock("t"),r.codeblock("countErr"),r.TypeInstantiation.string("Failed to verify WireMock request was matched")],multiline:!1})),n.writeLine(),n.writeNode(r.invokeFunc({func:r.typeReference({name:"True",importPath:"github.com/stretchr/testify/require"}),arguments_:[r.codeblock("t"),r.codeblock("ok"),r.TypeInstantiation.string("WireMock request was not matched")],multiline:!1})),n.writeLine()})}};export{x as a};
2
+ //# sourceMappingURL=chunk-S5R5YTLQ.js.map