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