@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.
Files changed (59) hide show
  1. package/dist/index.cjs +37 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +165 -0
  4. package/dist/index.d.ts +165 -0
  5. package/dist/index.js +37 -0
  6. package/dist/index.js.map +1 -0
  7. package/package.json +9 -10
  8. package/cjs/DynamicSnippetsGenerator.cjs +0 -42
  9. package/cjs/DynamicSnippetsGenerator.cjs.map +0 -1
  10. package/cjs/DynamicSnippetsGenerator.d.cts +0 -25
  11. package/cjs/DynamicSnippetsGeneratorContext-4_I0JAlU.d.cts +0 -87
  12. package/cjs/EndpointSnippetGenerator.cjs +0 -31
  13. package/cjs/EndpointSnippetGenerator.cjs.map +0 -1
  14. package/cjs/EndpointSnippetGenerator.d.cts +0 -68
  15. package/cjs/context/DynamicSnippetsGeneratorContext.cjs +0 -42
  16. package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +0 -1
  17. package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +0 -5
  18. package/cjs/context/DynamicTypeLiteralMapper.cjs +0 -31
  19. package/cjs/context/DynamicTypeLiteralMapper.cjs.map +0 -1
  20. package/cjs/context/DynamicTypeLiteralMapper.d.cts +0 -5
  21. package/cjs/context/FilePropertyMapper.cjs +0 -31
  22. package/cjs/context/FilePropertyMapper.cjs.map +0 -1
  23. package/cjs/context/FilePropertyMapper.d.cts +0 -5
  24. package/cjs/index.cjs +0 -42
  25. package/cjs/index.cjs.map +0 -1
  26. package/cjs/index.d.cts +0 -7
  27. package/esm/DynamicSnippetsGenerator.d.ts +0 -25
  28. package/esm/DynamicSnippetsGenerator.js +0 -2
  29. package/esm/DynamicSnippetsGenerator.js.map +0 -1
  30. package/esm/DynamicSnippetsGeneratorContext-4_I0JAlU.d.ts +0 -87
  31. package/esm/EndpointSnippetGenerator.d.ts +0 -68
  32. package/esm/EndpointSnippetGenerator.js +0 -2
  33. package/esm/EndpointSnippetGenerator.js.map +0 -1
  34. package/esm/chunk-2KHLQG2A.js +0 -2
  35. package/esm/chunk-2KHLQG2A.js.map +0 -1
  36. package/esm/chunk-2SPAKVUZ.js +0 -2
  37. package/esm/chunk-2SPAKVUZ.js.map +0 -1
  38. package/esm/chunk-3XEFLXHY.js +0 -2
  39. package/esm/chunk-3XEFLXHY.js.map +0 -1
  40. package/esm/chunk-DP6NTUTQ.js +0 -2
  41. package/esm/chunk-DP6NTUTQ.js.map +0 -1
  42. package/esm/chunk-HGKGDQ5J.js +0 -15
  43. package/esm/chunk-HGKGDQ5J.js.map +0 -1
  44. package/esm/chunk-NHAFJ5OA.js +0 -31
  45. package/esm/chunk-NHAFJ5OA.js.map +0 -1
  46. package/esm/chunk-ULECZXWB.js +0 -2
  47. package/esm/chunk-ULECZXWB.js.map +0 -1
  48. package/esm/context/DynamicSnippetsGeneratorContext.d.ts +0 -5
  49. package/esm/context/DynamicSnippetsGeneratorContext.js +0 -2
  50. package/esm/context/DynamicSnippetsGeneratorContext.js.map +0 -1
  51. package/esm/context/DynamicTypeLiteralMapper.d.ts +0 -5
  52. package/esm/context/DynamicTypeLiteralMapper.js +0 -2
  53. package/esm/context/DynamicTypeLiteralMapper.js.map +0 -1
  54. package/esm/context/FilePropertyMapper.d.ts +0 -5
  55. package/esm/context/FilePropertyMapper.js +0 -2
  56. package/esm/context/FilePropertyMapper.js.map +0 -1
  57. package/esm/index.d.ts +0 -7
  58. package/esm/index.js +0 -2
  59. package/esm/index.js.map +0 -1
@@ -0,0 +1,165 @@
1
+ import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec, AbstractAstNode, AbstractDynamicSnippetsGenerator } 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
+ declare class EndpointSnippetGenerator {
88
+ private context;
89
+ constructor({ context }: {
90
+ context: DynamicSnippetsGeneratorContext;
91
+ });
92
+ generateSnippet({ endpoint, request }: {
93
+ endpoint: FernIr.dynamic.Endpoint;
94
+ request: FernIr.dynamic.EndpointSnippetRequest;
95
+ }): Promise<string>;
96
+ generateSnippetSync({ endpoint, request }: {
97
+ endpoint: FernIr.dynamic.Endpoint;
98
+ request: FernIr.dynamic.EndpointSnippetRequest;
99
+ }): string;
100
+ generateSnippetAst({ endpoint, request }: {
101
+ endpoint: FernIr.dynamic.Endpoint;
102
+ request: FernIr.dynamic.EndpointSnippetRequest;
103
+ }): Promise<AbstractAstNode>;
104
+ /**
105
+ * Generates just the method call AST without the client instantiation.
106
+ * This is useful for wire tests where the client is created separately
107
+ * with test-specific configuration.
108
+ */
109
+ generateMethodCallSnippetAst({ endpoint, request }: {
110
+ endpoint: FernIr.dynamic.Endpoint;
111
+ request: FernIr.dynamic.EndpointSnippetRequest;
112
+ }): python.AstNode;
113
+ private buildPythonFile;
114
+ private constructClient;
115
+ private getConstructorArgs;
116
+ private getConstructorEnvironmentArgs;
117
+ private getEnvironmentValue;
118
+ private getConstructorAuthArgs;
119
+ private addAuthMismatchError;
120
+ private addWarning;
121
+ private getConstructorBasicAuthArg;
122
+ private getConstructorBearerAuthArgs;
123
+ private getConstructorHeaderAuthArgs;
124
+ private getConstructorOAuthArgs;
125
+ private getConstructorHeaderArgs;
126
+ private getConstructorHeaderArg;
127
+ private callMethod;
128
+ private getMethodArgs;
129
+ private getMethodArgsForBodyRequest;
130
+ private getBodyRequestArgs;
131
+ private getBodyRequestArgsForTypeReference;
132
+ private getBodyRequestArgsForNamedTypeReference;
133
+ private resolvesToLiteralType;
134
+ private getBodyRequestArgsForBytes;
135
+ private getBytesBodyRequestTypeInstantiation;
136
+ private getMethodArgsForInlinedRequest;
137
+ private getFilePropertyInfo;
138
+ private getInlinedRequestArgs;
139
+ private getInlinedRequestBodyObjectFields;
140
+ private getFileUploadRequestBodyObjectFields;
141
+ private getReferencedRequestBodyPropertyTypeInstantiation;
142
+ private getInlinedRequestBodyPropertyObjectFields;
143
+ private getPathParameters;
144
+ private getMethod;
145
+ private getEnvironmentOptionName;
146
+ }
147
+
148
+ declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
149
+ constructor({ ir, config }: {
150
+ ir: FernIr.dynamic.DynamicIntermediateRepresentation;
151
+ config: FernGeneratorExec.GeneratorConfig;
152
+ });
153
+ generate(request: FernIr.dynamic.EndpointSnippetRequest): Promise<FernIr.dynamic.EndpointSnippetResponse>;
154
+ generateSync(request: FernIr.dynamic.EndpointSnippetRequest): FernIr.dynamic.EndpointSnippetResponse;
155
+ generateSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): Promise<AbstractAstNode>;
156
+ /**
157
+ * Generates just the method call AST without the client instantiation.
158
+ * This is useful for wire tests where the client is created separately
159
+ * with test-specific configuration.
160
+ */
161
+ generateMethodCallSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): python.AstNode;
162
+ protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
163
+ }
164
+
165
+ export { DynamicSnippetsGenerator };
@@ -0,0 +1,165 @@
1
+ import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec, AbstractAstNode, AbstractDynamicSnippetsGenerator } 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
+ declare class EndpointSnippetGenerator {
88
+ private context;
89
+ constructor({ context }: {
90
+ context: DynamicSnippetsGeneratorContext;
91
+ });
92
+ generateSnippet({ endpoint, request }: {
93
+ endpoint: FernIr.dynamic.Endpoint;
94
+ request: FernIr.dynamic.EndpointSnippetRequest;
95
+ }): Promise<string>;
96
+ generateSnippetSync({ endpoint, request }: {
97
+ endpoint: FernIr.dynamic.Endpoint;
98
+ request: FernIr.dynamic.EndpointSnippetRequest;
99
+ }): string;
100
+ generateSnippetAst({ endpoint, request }: {
101
+ endpoint: FernIr.dynamic.Endpoint;
102
+ request: FernIr.dynamic.EndpointSnippetRequest;
103
+ }): Promise<AbstractAstNode>;
104
+ /**
105
+ * Generates just the method call AST without the client instantiation.
106
+ * This is useful for wire tests where the client is created separately
107
+ * with test-specific configuration.
108
+ */
109
+ generateMethodCallSnippetAst({ endpoint, request }: {
110
+ endpoint: FernIr.dynamic.Endpoint;
111
+ request: FernIr.dynamic.EndpointSnippetRequest;
112
+ }): python.AstNode;
113
+ private buildPythonFile;
114
+ private constructClient;
115
+ private getConstructorArgs;
116
+ private getConstructorEnvironmentArgs;
117
+ private getEnvironmentValue;
118
+ private getConstructorAuthArgs;
119
+ private addAuthMismatchError;
120
+ private addWarning;
121
+ private getConstructorBasicAuthArg;
122
+ private getConstructorBearerAuthArgs;
123
+ private getConstructorHeaderAuthArgs;
124
+ private getConstructorOAuthArgs;
125
+ private getConstructorHeaderArgs;
126
+ private getConstructorHeaderArg;
127
+ private callMethod;
128
+ private getMethodArgs;
129
+ private getMethodArgsForBodyRequest;
130
+ private getBodyRequestArgs;
131
+ private getBodyRequestArgsForTypeReference;
132
+ private getBodyRequestArgsForNamedTypeReference;
133
+ private resolvesToLiteralType;
134
+ private getBodyRequestArgsForBytes;
135
+ private getBytesBodyRequestTypeInstantiation;
136
+ private getMethodArgsForInlinedRequest;
137
+ private getFilePropertyInfo;
138
+ private getInlinedRequestArgs;
139
+ private getInlinedRequestBodyObjectFields;
140
+ private getFileUploadRequestBodyObjectFields;
141
+ private getReferencedRequestBodyPropertyTypeInstantiation;
142
+ private getInlinedRequestBodyPropertyObjectFields;
143
+ private getPathParameters;
144
+ private getMethod;
145
+ private getEnvironmentOptionName;
146
+ }
147
+
148
+ declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
149
+ constructor({ ir, config }: {
150
+ ir: FernIr.dynamic.DynamicIntermediateRepresentation;
151
+ config: FernGeneratorExec.GeneratorConfig;
152
+ });
153
+ generate(request: FernIr.dynamic.EndpointSnippetRequest): Promise<FernIr.dynamic.EndpointSnippetResponse>;
154
+ generateSync(request: FernIr.dynamic.EndpointSnippetRequest): FernIr.dynamic.EndpointSnippetResponse;
155
+ generateSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): Promise<AbstractAstNode>;
156
+ /**
157
+ * Generates just the method call AST without the client instantiation.
158
+ * This is useful for wire tests where the client is created separately
159
+ * with test-specific configuration.
160
+ */
161
+ generateMethodCallSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): python.AstNode;
162
+ protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
163
+ }
164
+
165
+ export { DynamicSnippetsGenerator };