@fern-api/csharp-dynamic-snippets 0.0.2 → 0.0.4
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/cjs/Config.cjs +2 -11
- package/cjs/Config.cjs.map +1 -0
- package/cjs/DynamicSnippetsGenerator.cjs +31 -19
- package/cjs/DynamicSnippetsGenerator.cjs.map +1 -0
- package/cjs/DynamicSnippetsGenerator.d.cts +4 -1
- package/cjs/DynamicSnippetsGeneratorContext-DQDI25Nx.d.cts +395 -0
- package/cjs/EndpointSnippetGenerator.cjs +30 -19
- package/cjs/EndpointSnippetGenerator.cjs.map +1 -0
- package/cjs/EndpointSnippetGenerator.d.cts +7 -3
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +31 -32
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +1 -0
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +4 -2
- package/cjs/context/DynamicTypeLiteralMapper.cjs +2 -34
- package/cjs/context/DynamicTypeLiteralMapper.cjs.map +1 -0
- package/cjs/context/DynamicTypeLiteralMapper.d.cts +3 -1
- package/cjs/context/DynamicTypeMapper.cjs +2 -34
- package/cjs/context/DynamicTypeMapper.cjs.map +1 -0
- package/cjs/context/DynamicTypeMapper.d.cts +3 -1
- package/cjs/context/FilePropertyMapper.cjs +26 -32
- package/cjs/context/FilePropertyMapper.cjs.map +1 -0
- package/cjs/context/FilePropertyMapper.d.cts +3 -1
- package/cjs/index.cjs +34 -31
- package/cjs/index.cjs.map +1 -0
- package/cjs/index.d.cts +4 -2
- package/esm/Config.js +2 -1
- package/esm/Config.js.map +1 -0
- package/esm/DynamicSnippetsGenerator.d.ts +4 -1
- package/esm/DynamicSnippetsGenerator.js +2 -1
- package/esm/DynamicSnippetsGenerator.js.map +1 -0
- package/esm/DynamicSnippetsGeneratorContext-DQDI25Nx.d.ts +395 -0
- package/esm/EndpointSnippetGenerator.d.ts +7 -3
- package/esm/EndpointSnippetGenerator.js +2 -1
- package/esm/EndpointSnippetGenerator.js.map +1 -0
- package/esm/chunk-CDMZ2O62.js +2 -0
- package/esm/chunk-CDMZ2O62.js.map +1 -0
- package/esm/chunk-D2D544ZS.js +2 -0
- package/esm/chunk-D2D544ZS.js.map +1 -0
- package/esm/chunk-F3KILROP.js +2 -0
- package/esm/chunk-F3KILROP.js.map +1 -0
- package/esm/chunk-GQKEVSN5.js +2 -0
- package/esm/chunk-GQKEVSN5.js.map +1 -0
- package/esm/chunk-KHCIVF5J.js +1 -0
- package/esm/chunk-KHCIVF5J.js.map +1 -0
- package/esm/chunk-MM7AFFVF.js +2 -0
- package/esm/chunk-MM7AFFVF.js.map +1 -0
- package/esm/chunk-PBYJXQQK.js +2 -0
- package/esm/chunk-PBYJXQQK.js.map +1 -0
- package/esm/chunk-SAYITSWL.js +15 -0
- package/esm/chunk-SAYITSWL.js.map +1 -0
- package/esm/chunk-ZDZZCKFB.js +33 -0
- package/esm/chunk-ZDZZCKFB.js.map +1 -0
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +4 -2
- package/esm/context/DynamicSnippetsGeneratorContext.js +2 -1
- package/esm/context/DynamicSnippetsGeneratorContext.js.map +1 -0
- package/esm/context/DynamicTypeLiteralMapper.d.ts +3 -1
- package/esm/context/DynamicTypeLiteralMapper.js +2 -1
- package/esm/context/DynamicTypeLiteralMapper.js.map +1 -0
- package/esm/context/DynamicTypeMapper.d.ts +3 -1
- package/esm/context/DynamicTypeMapper.js +2 -1
- package/esm/context/DynamicTypeMapper.js.map +1 -0
- package/esm/context/FilePropertyMapper.d.ts +3 -1
- package/esm/context/FilePropertyMapper.js +2 -1
- package/esm/context/FilePropertyMapper.js.map +1 -0
- package/esm/index.d.ts +4 -2
- package/esm/index.js +5 -13
- package/esm/index.js.map +1 -0
- package/package.json +1 -1
- package/cjs/DynamicSnippetsGeneratorContext-DbMhuHoi.d.cts +0 -116
- package/esm/DynamicSnippetsGeneratorContext-DbMhuHoi.d.ts +0 -116
- package/esm/chunk-2AZXIWKY.js +0 -11
- package/esm/chunk-ARC6F6E6.js +0 -1
- package/esm/chunk-CIENX2JS.js +0 -1
- package/esm/chunk-DVOWBIEL.js +0 -1
- package/esm/chunk-HN67B7VQ.js +0 -1
- package/esm/chunk-IIP7VDG4.js +0 -1
- package/esm/chunk-ME2YBVEY.js +0 -1
- package/esm/chunk-PJC2VZIA.js +0 -26
- package/esm/chunk-QKK5PTVJ.js +0 -1
- package/esm/chunk-YL3JFOME.js +0 -1
package/cjs/index.d.cts
CHANGED
|
@@ -2,6 +2,8 @@ export { Config } from './Config.cjs';
|
|
|
2
2
|
export { DynamicSnippetsGenerator } from './DynamicSnippetsGenerator.cjs';
|
|
3
3
|
import '@fern-api/browser-compatible-base-generator';
|
|
4
4
|
import '@fern-api/dynamic-ir-sdk';
|
|
5
|
-
import './
|
|
6
|
-
import '
|
|
5
|
+
import './DynamicSnippetsGeneratorContext-DQDI25Nx.cjs';
|
|
6
|
+
import '@fern-api/csharp-codegen/lib/context/model-navigator';
|
|
7
|
+
import '@fern-api/csharp-codegen/lib/context/extern';
|
|
7
8
|
import '@fern-api/csharp-codegen';
|
|
9
|
+
import './EndpointSnippetGenerator.cjs';
|
package/esm/Config.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-KHCIVF5J.js";
|
|
2
|
+
//# sourceMappingURL=Config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, Options } from '@fern-api/browser-compatible-base-generator';
|
|
2
2
|
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-DQDI25Nx.js';
|
|
3
4
|
import { EndpointSnippetGenerator } from './EndpointSnippetGenerator.js';
|
|
4
|
-
import
|
|
5
|
+
import '@fern-api/csharp-codegen/lib/context/model-navigator';
|
|
6
|
+
import '@fern-api/csharp-codegen/lib/context/extern';
|
|
5
7
|
import '@fern-api/csharp-codegen';
|
|
6
8
|
|
|
7
9
|
declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
|
|
@@ -10,6 +12,7 @@ declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<
|
|
|
10
12
|
config: FernGeneratorExec.GeneratorConfig;
|
|
11
13
|
options?: Options;
|
|
12
14
|
});
|
|
15
|
+
precalculate(requests: FernIr.dynamic.EndpointSnippetRequest[]): void;
|
|
13
16
|
generate(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): Promise<FernIr.dynamic.EndpointSnippetResponse>;
|
|
14
17
|
generateSync(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): FernIr.dynamic.EndpointSnippetResponse;
|
|
15
18
|
protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-GQKEVSN5.js";import"./chunk-SAYITSWL.js";import"./chunk-PBYJXQQK.js";import"./chunk-CDMZ2O62.js";import"./chunk-D2D544ZS.js";import"./chunk-F3KILROP.js";import"./chunk-MM7AFFVF.js";import"./chunk-ZDZZCKFB.js";export{a as DynamicSnippetsGenerator};
|
|
2
|
+
//# sourceMappingURL=DynamicSnippetsGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import * as _fern_api_csharp_codegen_lib_context_model_navigator from '@fern-api/csharp-codegen/lib/context/model-navigator';
|
|
2
|
+
import * as _fern_api_csharp_codegen_lib_context_extern from '@fern-api/csharp-codegen/lib/context/extern';
|
|
3
|
+
import * as _fern_api_csharp_codegen from '@fern-api/csharp-codegen';
|
|
4
|
+
import { WithGeneration, ast, Generation } from '@fern-api/csharp-codegen';
|
|
5
|
+
import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec, Options } from '@fern-api/browser-compatible-base-generator';
|
|
6
|
+
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
7
|
+
|
|
8
|
+
declare namespace DynamicTypeLiteralMapper {
|
|
9
|
+
interface Args {
|
|
10
|
+
typeReference: FernIr.dynamic.TypeReference;
|
|
11
|
+
value: unknown;
|
|
12
|
+
as?: ConvertedAs;
|
|
13
|
+
fallbackToDefault?: string;
|
|
14
|
+
}
|
|
15
|
+
type ConvertedAs = "key";
|
|
16
|
+
}
|
|
17
|
+
declare class DynamicTypeLiteralMapper extends WithGeneration {
|
|
18
|
+
private context;
|
|
19
|
+
constructor({ context }: {
|
|
20
|
+
context: DynamicSnippetsGeneratorContext;
|
|
21
|
+
});
|
|
22
|
+
convert(args: DynamicTypeLiteralMapper.Args): ast.TypeLiteral;
|
|
23
|
+
private convertList;
|
|
24
|
+
private convertLiteral;
|
|
25
|
+
private convertSet;
|
|
26
|
+
private convertMap;
|
|
27
|
+
private convertNamed;
|
|
28
|
+
private convertDiscriminatedUnion;
|
|
29
|
+
private getBaseProperties;
|
|
30
|
+
private instantiateUnionWithBaseProperties;
|
|
31
|
+
private getEnumValue;
|
|
32
|
+
private convertObject;
|
|
33
|
+
private convertUndiscriminatedUnion;
|
|
34
|
+
private findMatchingUndiscriminatedUnionType;
|
|
35
|
+
private convertUnknown;
|
|
36
|
+
private convertPrimitive;
|
|
37
|
+
private getValueAsNumber;
|
|
38
|
+
private getValueAsBoolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare namespace DynamicTypeMapper {
|
|
42
|
+
interface Args {
|
|
43
|
+
typeReference: FernIr.dynamic.TypeReference;
|
|
44
|
+
unboxOptionals?: boolean;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
declare class DynamicTypeMapper extends WithGeneration {
|
|
48
|
+
private context;
|
|
49
|
+
constructor({ context }: {
|
|
50
|
+
context: DynamicSnippetsGeneratorContext;
|
|
51
|
+
});
|
|
52
|
+
convert(args: DynamicTypeMapper.Args): ast.Type;
|
|
53
|
+
convertToClassReference(named: FernIr.dynamic.NamedType): ast.ClassReference;
|
|
54
|
+
private convertNamed;
|
|
55
|
+
private convertLiteral;
|
|
56
|
+
private convertUnknown;
|
|
57
|
+
private convertPrimitive;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
interface FilePropertyInfo {
|
|
61
|
+
fileFields: ast.ConstructorField[];
|
|
62
|
+
bodyPropertyFields: ast.ConstructorField[];
|
|
63
|
+
}
|
|
64
|
+
declare class FilePropertyMapper extends WithGeneration {
|
|
65
|
+
private context;
|
|
66
|
+
constructor({ context }: {
|
|
67
|
+
context: DynamicSnippetsGeneratorContext;
|
|
68
|
+
});
|
|
69
|
+
getFilePropertyInfo({ body, value }: {
|
|
70
|
+
body: FernIr.dynamic.FileUploadRequestBody;
|
|
71
|
+
value: unknown;
|
|
72
|
+
}): FilePropertyInfo;
|
|
73
|
+
private getSingleFileProperty;
|
|
74
|
+
private getArrayFileProperty;
|
|
75
|
+
private getBodyProperty;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGeneratorContext {
|
|
79
|
+
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
80
|
+
dynamicTypeMapper: DynamicTypeMapper;
|
|
81
|
+
dynamicTypeLiteralMapper: DynamicTypeLiteralMapper;
|
|
82
|
+
filePropertyMapper: FilePropertyMapper;
|
|
83
|
+
readonly generation: Generation;
|
|
84
|
+
get namespaces(): {
|
|
85
|
+
root: string;
|
|
86
|
+
core: string;
|
|
87
|
+
test: string;
|
|
88
|
+
testUtils: string;
|
|
89
|
+
mockServerTest: string;
|
|
90
|
+
publicCore: string;
|
|
91
|
+
asyncCore: string;
|
|
92
|
+
publicCoreTest: string;
|
|
93
|
+
asIsTestUtils: string;
|
|
94
|
+
publicCoreClasses: string;
|
|
95
|
+
implicit: Set<string>;
|
|
96
|
+
};
|
|
97
|
+
get registry(): _fern_api_csharp_codegen.NameRegistry;
|
|
98
|
+
get extern(): _fern_api_csharp_codegen_lib_context_extern.Extern;
|
|
99
|
+
get settings(): {
|
|
100
|
+
namespace: string;
|
|
101
|
+
readOnlyMemoryTypes: string[];
|
|
102
|
+
simplifyObjectDictionaries: boolean;
|
|
103
|
+
useFullyQualifiedNamespaces: boolean;
|
|
104
|
+
useDotnetFormat: boolean;
|
|
105
|
+
enableWebsockets: boolean;
|
|
106
|
+
enableReadonlyConstants: boolean;
|
|
107
|
+
temporaryWebsocketEnvironments: Record<string, {
|
|
108
|
+
environments: Record<string, string>;
|
|
109
|
+
"default-environment"?: string | undefined;
|
|
110
|
+
}>;
|
|
111
|
+
baseApiExceptionClassName: string;
|
|
112
|
+
baseExceptionClassName: string;
|
|
113
|
+
shouldGeneratedDiscriminatedUnions: boolean;
|
|
114
|
+
exportedClientClassName: string;
|
|
115
|
+
clientClassName: string;
|
|
116
|
+
rootNamespaceForCoreClasses: boolean;
|
|
117
|
+
packageId: string;
|
|
118
|
+
isForwardCompatibleEnumsEnabled: boolean;
|
|
119
|
+
websocketEnvironments: Record<string, {
|
|
120
|
+
environments: Record<string, string>;
|
|
121
|
+
"default-environment"?: string | undefined;
|
|
122
|
+
}>;
|
|
123
|
+
generateNewAdditionalProperties: boolean;
|
|
124
|
+
customPagerName: string;
|
|
125
|
+
environmentClassName: string;
|
|
126
|
+
generateErrorTypes: boolean;
|
|
127
|
+
shouldInlinePathParameters: boolean;
|
|
128
|
+
includeExceptionHandler: boolean;
|
|
129
|
+
shouldGenerateMockServerTests: boolean;
|
|
130
|
+
rootClientAccess: "public" | "internal";
|
|
131
|
+
extraDependencies: Record<string, string>;
|
|
132
|
+
pascalCaseEnvironments: boolean;
|
|
133
|
+
explicitNamespaces: boolean;
|
|
134
|
+
};
|
|
135
|
+
get constants(): {
|
|
136
|
+
folders: {
|
|
137
|
+
mockServerTests: _fern_api_csharp_codegen.TRelativeFilePath;
|
|
138
|
+
types: string;
|
|
139
|
+
exceptions: string;
|
|
140
|
+
src: string;
|
|
141
|
+
protobuf: string;
|
|
142
|
+
serializationTests: _fern_api_csharp_codegen.TRelativeFilePath;
|
|
143
|
+
project: _fern_api_csharp_codegen.TRelativeFilePath;
|
|
144
|
+
sourceFiles: _fern_api_csharp_codegen.TRelativeFilePath;
|
|
145
|
+
coreFiles: _fern_api_csharp_codegen.TRelativeFilePath;
|
|
146
|
+
publicCoreFiles: _fern_api_csharp_codegen.TRelativeFilePath;
|
|
147
|
+
testFiles: _fern_api_csharp_codegen.TRelativeFilePath;
|
|
148
|
+
};
|
|
149
|
+
formatting: {
|
|
150
|
+
indent: string;
|
|
151
|
+
};
|
|
152
|
+
defaults: {
|
|
153
|
+
core: string;
|
|
154
|
+
publicCore: string;
|
|
155
|
+
version: string;
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
get names(): {
|
|
159
|
+
classes: {
|
|
160
|
+
baseApiException: string;
|
|
161
|
+
baseException: string;
|
|
162
|
+
rootClient: string;
|
|
163
|
+
rootClientForSnippets: string;
|
|
164
|
+
customPager: string;
|
|
165
|
+
environment: string;
|
|
166
|
+
};
|
|
167
|
+
project: {
|
|
168
|
+
client: string;
|
|
169
|
+
clientPrefix: string;
|
|
170
|
+
packageId: string;
|
|
171
|
+
};
|
|
172
|
+
files: {
|
|
173
|
+
project: string;
|
|
174
|
+
testProject: string;
|
|
175
|
+
};
|
|
176
|
+
methods: {
|
|
177
|
+
mockOauth: string;
|
|
178
|
+
getAccessTokenAsync: string;
|
|
179
|
+
};
|
|
180
|
+
variables: {
|
|
181
|
+
client: string;
|
|
182
|
+
response: string;
|
|
183
|
+
httpRequest: string;
|
|
184
|
+
sendRequest: string;
|
|
185
|
+
responseBody: string;
|
|
186
|
+
query: string;
|
|
187
|
+
headers: string;
|
|
188
|
+
};
|
|
189
|
+
parameters: {
|
|
190
|
+
cancellationToken: string;
|
|
191
|
+
requestOptions: string;
|
|
192
|
+
idempotentOptions: string;
|
|
193
|
+
};
|
|
194
|
+
};
|
|
195
|
+
get types(): {
|
|
196
|
+
FormRequest: ast.ClassReference;
|
|
197
|
+
ClientOptions: ast.ClassReference;
|
|
198
|
+
RawClient: ast.ClassReference;
|
|
199
|
+
RequestOptions: ast.ClassReference;
|
|
200
|
+
RequestOptionsInterface: ast.ClassReference;
|
|
201
|
+
JsonRequest: ast.ClassReference;
|
|
202
|
+
Version: ast.ClassReference;
|
|
203
|
+
ValueConvert: ast.ClassReference;
|
|
204
|
+
FileParameter: ast.ClassReference;
|
|
205
|
+
Headers: ast.ClassReference;
|
|
206
|
+
HeaderValue: ast.ClassReference;
|
|
207
|
+
RootClient: ast.ClassReference;
|
|
208
|
+
RootClientForSnippets: ast.ClassReference;
|
|
209
|
+
BaseApiException: ast.ClassReference;
|
|
210
|
+
BaseException: ast.ClassReference;
|
|
211
|
+
ExceptionInterceptor: ast.ClassReference;
|
|
212
|
+
ExceptionHandler: ast.ClassReference;
|
|
213
|
+
ProtoAnyMapper: ast.ClassReference;
|
|
214
|
+
Constants: ast.ClassReference;
|
|
215
|
+
EnumSerializer: ast.ClassReference;
|
|
216
|
+
DateTimeSerializer: ast.ClassReference;
|
|
217
|
+
JsonUtils: ast.ClassReference;
|
|
218
|
+
CustomPagerFactory: ast.ClassReference;
|
|
219
|
+
CustomPagerContext: ast.ClassReference;
|
|
220
|
+
Environments: ast.ClassReference;
|
|
221
|
+
TestClient: ast.ClassReference;
|
|
222
|
+
BaseMockServerTest: ast.ClassReference;
|
|
223
|
+
IdempotentRequestOptions: ast.ClassReference;
|
|
224
|
+
IdempotentRequestOptionsInterface: ast.ClassReference;
|
|
225
|
+
IStringEnum: ast.ClassReference;
|
|
226
|
+
AsyncApiOptions: ast.ClassReference;
|
|
227
|
+
QueryBuilder: ast.ClassReference;
|
|
228
|
+
OAuthTokenProvider: ast.ClassReference;
|
|
229
|
+
ProtoConverter: ast.ClassReference;
|
|
230
|
+
RawGrpcClient: ast.ClassReference;
|
|
231
|
+
Extensions: ast.ClassReference;
|
|
232
|
+
GrpcRequestOptions: ast.ClassReference;
|
|
233
|
+
GrpcChannelOptions: ast.ClassReference;
|
|
234
|
+
StringEnum: (genericType?: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
235
|
+
AsyncApi: (genericType: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
236
|
+
AsyncEvent: (genericType: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
237
|
+
StringEnumSerializer: (enumClassReference: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
238
|
+
CustomPagerClass: (itemType: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
239
|
+
Pager: (itemType: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
240
|
+
OffsetPager: ({ requestType, requestOptionsType, responseType, offsetType, stepType, itemType }: {
|
|
241
|
+
requestType: ast.Type | ast.TypeParameter;
|
|
242
|
+
requestOptionsType: ast.Type | ast.TypeParameter;
|
|
243
|
+
responseType: ast.Type | ast.TypeParameter;
|
|
244
|
+
offsetType: ast.Type | ast.TypeParameter;
|
|
245
|
+
stepType: ast.Type | ast.TypeParameter;
|
|
246
|
+
itemType: ast.Type | ast.TypeParameter;
|
|
247
|
+
}) => ast.ClassReference;
|
|
248
|
+
CursorPager: ({ requestType, requestOptionsType, responseType, cursorType, itemType }: {
|
|
249
|
+
requestType: ast.Type | ast.TypeParameter;
|
|
250
|
+
requestOptionsType: ast.Type | ast.TypeParameter;
|
|
251
|
+
responseType: ast.Type | ast.TypeParameter;
|
|
252
|
+
cursorType: ast.Type | ast.TypeParameter;
|
|
253
|
+
itemType: ast.Type | ast.TypeParameter;
|
|
254
|
+
}) => ast.ClassReference;
|
|
255
|
+
CollectionItemSerializer: (itemType: ast.ClassReference, serializer: ast.ClassReference) => ast.ClassReference;
|
|
256
|
+
OneOfSerializer: (oneof: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
257
|
+
AdditionalProperties: (genericType?: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
258
|
+
ReadOnlyAdditionalProperties: (genericType?: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
259
|
+
};
|
|
260
|
+
get model(): _fern_api_csharp_codegen_lib_context_model_navigator.ModelNavigator;
|
|
261
|
+
get csharp(): _fern_api_csharp_codegen.CSharp;
|
|
262
|
+
get System(): {
|
|
263
|
+
Action: (typeParameters?: (ast.ClassReference | ast.TypeParameter | ast.Type)[]) => ast.ClassReference;
|
|
264
|
+
Func: (typeParameters?: (ast.Type | ast.TypeParameter | ast.ClassReference)[], returnType?: ast.Type | ast.TypeParameter | ast.ClassReference) => ast.ClassReference;
|
|
265
|
+
DateOnly: ast.ClassReference;
|
|
266
|
+
DateTime: ast.ClassReference;
|
|
267
|
+
Enum: ast.ClassReference;
|
|
268
|
+
Exception: ast.ClassReference;
|
|
269
|
+
ReadOnlyMemory: (type: ast.Type | ast.ClassReference | ast.TypeParameter) => ast.ClassReference;
|
|
270
|
+
Serializable: ast.ClassReference;
|
|
271
|
+
String: ast.ClassReference;
|
|
272
|
+
TimeSpan: ast.ClassReference;
|
|
273
|
+
Uri: ast.ClassReference;
|
|
274
|
+
UriBuilder: ast.ClassReference;
|
|
275
|
+
Runtime: {
|
|
276
|
+
Serialization: {
|
|
277
|
+
EnumMember: ast.ClassReference;
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
Collections: {
|
|
281
|
+
Generic: {
|
|
282
|
+
IAsyncEnumerable: (elementType?: ast.ClassReference | ast.TypeParameter | ast.Type) => ast.ClassReference;
|
|
283
|
+
IEnumerable: (elementType?: ast.ClassReference | ast.TypeParameter | ast.Type) => ast.ClassReference;
|
|
284
|
+
KeyValuePair: (keyType?: ast.ClassReference | ast.TypeParameter | ast.Type, valueType?: ast.ClassReference | ast.TypeParameter | ast.Type) => ast.ClassReference;
|
|
285
|
+
List: (elementType?: ast.ClassReference | ast.TypeParameter | ast.Type) => ast.ClassReference;
|
|
286
|
+
HashSet: (elementType?: ast.ClassReference | ast.TypeParameter | ast.Type) => ast.ClassReference;
|
|
287
|
+
Dictionary: (keyType?: ast.ClassReference | ast.TypeParameter | ast.Type, valueType?: ast.ClassReference | ast.TypeParameter | ast.Type) => ast.ClassReference;
|
|
288
|
+
IDictionary: (keyType: ast.Type | ast.ClassReference | ast.TypeParameter, valueType: ast.Type | ast.ClassReference | ast.TypeParameter) => ast.ClassReference;
|
|
289
|
+
};
|
|
290
|
+
Linq: {
|
|
291
|
+
Enumerable: ast.ClassReference;
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
Globalization: {
|
|
295
|
+
DateTimeStyles: ast.ClassReference;
|
|
296
|
+
};
|
|
297
|
+
Linq: {
|
|
298
|
+
Enumerable: ast.ClassReference;
|
|
299
|
+
};
|
|
300
|
+
Net: {
|
|
301
|
+
Http: {
|
|
302
|
+
HttpClient: ast.ClassReference;
|
|
303
|
+
HttpMethod: ast.ClassReference;
|
|
304
|
+
HttpResponseHeaders: ast.ClassReference;
|
|
305
|
+
};
|
|
306
|
+
ServerSentEvents: {
|
|
307
|
+
SseEvent: ast.ClassReference;
|
|
308
|
+
SseParser: ast.ClassReference;
|
|
309
|
+
};
|
|
310
|
+
WebSockets: {
|
|
311
|
+
ClientWebSocketOptions: ast.ClassReference;
|
|
312
|
+
};
|
|
313
|
+
};
|
|
314
|
+
IO: {
|
|
315
|
+
MemoryStream: ast.ClassReference;
|
|
316
|
+
Stream: ast.ClassReference;
|
|
317
|
+
StreamReader: ast.ClassReference;
|
|
318
|
+
};
|
|
319
|
+
Text: {
|
|
320
|
+
Encoding: ast.ClassReference;
|
|
321
|
+
Encoding_UTF8: ast.ClassReference;
|
|
322
|
+
Json: {
|
|
323
|
+
JsonElement: ast.ClassReference;
|
|
324
|
+
JsonDocument: ast.ClassReference;
|
|
325
|
+
JsonException: ast.ClassReference;
|
|
326
|
+
Utf8JsonReader: ast.ClassReference;
|
|
327
|
+
JsonSerializerOptions: ast.ClassReference;
|
|
328
|
+
JsonSerializer: ast.ClassReference;
|
|
329
|
+
Utf8JsonWriter: ast.ClassReference;
|
|
330
|
+
Nodes: {
|
|
331
|
+
JsonNode: ast.ClassReference;
|
|
332
|
+
JsonObject: ast.ClassReference;
|
|
333
|
+
};
|
|
334
|
+
Serialization: {
|
|
335
|
+
IJsonOnDeserialized: ast.ClassReference;
|
|
336
|
+
IJsonOnSerializing: ast.ClassReference;
|
|
337
|
+
JsonOnDeserializedAttribute: ast.ClassReference;
|
|
338
|
+
JsonExtensionData: ast.ClassReference;
|
|
339
|
+
JsonConverter: (typeToConvert?: ast.ClassReference | ast.TypeParameter | ast.Type) => ast.ClassReference;
|
|
340
|
+
JsonIgnore: ast.ClassReference;
|
|
341
|
+
JsonPropertyName: ast.ClassReference;
|
|
342
|
+
};
|
|
343
|
+
};
|
|
344
|
+
};
|
|
345
|
+
Threading: {
|
|
346
|
+
CancellationToken: ast.ClassReference;
|
|
347
|
+
Tasks: {
|
|
348
|
+
Task: (ofType?: ast.ClassReference | ast.TypeParameter | ast.Type) => ast.ClassReference;
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
get NUnit(): {
|
|
353
|
+
Framework: {
|
|
354
|
+
TestFixture: ast.ClassReference;
|
|
355
|
+
Test: ast.ClassReference;
|
|
356
|
+
OneTimeTearDown: ast.ClassReference;
|
|
357
|
+
OneTimeSetUp: ast.ClassReference;
|
|
358
|
+
SetUpFixture: ast.ClassReference;
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
get OneOf(): {
|
|
362
|
+
OneOf: (generics?: ast.ClassReference[] | ast.TypeParameter[] | ast.Type[]) => ast.ClassReference;
|
|
363
|
+
OneOfBase: (generics?: ast.ClassReference[] | ast.TypeParameter[] | ast.Type[]) => ast.ClassReference;
|
|
364
|
+
};
|
|
365
|
+
get Google(): {
|
|
366
|
+
Protobuf: {
|
|
367
|
+
WellKnownTypes: {
|
|
368
|
+
Struct: ast.ClassReference;
|
|
369
|
+
Value: ast.ClassReference;
|
|
370
|
+
ListValue: ast.ClassReference;
|
|
371
|
+
Timestamp: ast.ClassReference;
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
constructor({ ir, config, options, generation }: {
|
|
376
|
+
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
377
|
+
config: FernGeneratorExec.GeneratorConfig;
|
|
378
|
+
options?: Options;
|
|
379
|
+
generation?: Generation;
|
|
380
|
+
});
|
|
381
|
+
clone(): DynamicSnippetsGeneratorContext;
|
|
382
|
+
getFileParameterForString(str: string): ast.TypeLiteral;
|
|
383
|
+
getMemoryStreamForString(str: string): ast.ClassInstantiation;
|
|
384
|
+
getClassName(name: FernIr.Name): string;
|
|
385
|
+
getParameterName(name: FernIr.Name): string;
|
|
386
|
+
getPropertyName(name: FernIr.Name): string;
|
|
387
|
+
getMethodName(name: FernIr.Name): string;
|
|
388
|
+
getNamespace(fernFilepath: FernIr.dynamic.FernFilepath, suffix?: string): string;
|
|
389
|
+
getEnvironmentTypeReferenceFromID(environmentID: string): ast.ClassReference | undefined;
|
|
390
|
+
private getEnvironmentClassReferenceForEnumName;
|
|
391
|
+
private getNamespaceSegments;
|
|
392
|
+
precalculate(requests: Partial<FernIr.dynamic.EndpointSnippetRequest>[]): void;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export { DynamicSnippetsGeneratorContext as D, type FilePropertyInfo as F, DynamicTypeLiteralMapper as a, DynamicTypeMapper as b, FilePropertyMapper as c };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Options } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
+
import { WithGeneration } from '@fern-api/csharp-codegen';
|
|
2
3
|
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
|
-
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-
|
|
4
|
-
import '@fern-api/csharp-codegen';
|
|
4
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-DQDI25Nx.js';
|
|
5
|
+
import '@fern-api/csharp-codegen/lib/context/model-navigator';
|
|
6
|
+
import '@fern-api/csharp-codegen/lib/context/extern';
|
|
5
7
|
|
|
6
|
-
declare class EndpointSnippetGenerator {
|
|
8
|
+
declare class EndpointSnippetGenerator extends WithGeneration {
|
|
7
9
|
private context;
|
|
8
10
|
constructor({ context }: {
|
|
9
11
|
context: DynamicSnippetsGeneratorContext;
|
|
@@ -26,6 +28,8 @@ declare class EndpointSnippetGenerator {
|
|
|
26
28
|
private getConstructorBaseUrlArgs;
|
|
27
29
|
private getBaseUrlArg;
|
|
28
30
|
private getConstructorAuthArgs;
|
|
31
|
+
private addError;
|
|
32
|
+
private addWarning;
|
|
29
33
|
private getConstructorBasicAuthArg;
|
|
30
34
|
private getConstructorBearerAuthArgs;
|
|
31
35
|
private getConstructorHeaderAuthArgs;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-SAYITSWL.js";import"./chunk-D2D544ZS.js";import"./chunk-ZDZZCKFB.js";export{a as EndpointSnippetGenerator};
|
|
2
|
+
//# sourceMappingURL=EndpointSnippetGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as a}from"./chunk-D2D544ZS.js";import{h as l,i as c,m as u}from"./chunk-ZDZZCKFB.js";var h=class extends u{constructor({context:e}){super(e);l(this,"context");this.context=e}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?this.csharp.TypeLiteral.null():(this.context.errors.add({severity:a.Critical,message:"Expected non-null value, but got null"}),this.csharp.TypeLiteral.nop());if(e.value===void 0&&!e.fallbackToDefault)return this.csharp.TypeLiteral.nop();switch(e.typeReference.type){case"list":return this.convertList({list:e.typeReference.value,value:e.value,fallbackToDefault:e.fallbackToDefault});case"literal":return this.convertLiteral({literal:e.typeReference.value,value:e.value});case"map":return this.convertMap({map:e.typeReference,value:e.value,fallbackToDefault:e.fallbackToDefault});case"named":{let r=this.context.resolveNamedType({typeId:e.typeReference.value});return r==null?this.csharp.TypeLiteral.nop():this.convertNamed({named:r,value:e.value,as:e.as,fallbackToDefault:e.fallbackToDefault})}case"nullable":return this.convert({typeReference:e.typeReference.value,value:e.value,as:e.as});case"optional":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,fallbackToDefault:e.fallbackToDefault});case"set":return this.convertSet({set:e.typeReference.value,value:e.value,fallbackToDefault:e.fallbackToDefault});case"unknown":return this.convertUnknown({value:e.value,fallbackToDefault:e.fallbackToDefault});default:c(e.typeReference)}}convertList({list:e,value:r,fallbackToDefault:i}){return Array.isArray(r)?this.csharp.TypeLiteral.list({valueType:this.context.dynamicTypeMapper.convert({typeReference:e,unboxOptionals:!0}),values:r.map((t,n)=>{this.context.errors.scope({index:n});try{return this.convert({typeReference:e,value:t})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:a.Critical,message:`Expected array but got: ${typeof r}`}),this.csharp.TypeLiteral.nop())}convertLiteral({literal:e,value:r,fallbackToDefault:i}){switch(e.type){case"boolean":{let t=this.context.getValueAsBoolean({value:r});return t==null?this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.boolean(t)}case"string":{let t=this.context.getValueAsString({value:r});return t==null?i?this.csharp.Type.string.getDeterminsticDefault(i):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.string(t)}default:c(e)}}convertSet({set:e,value:r,fallbackToDefault:i}){return Array.isArray(r)?this.csharp.TypeLiteral.set({valueType:this.context.dynamicTypeMapper.convert({typeReference:e,unboxOptionals:!0}),values:r.map((t,n)=>{this.context.errors.scope({index:n});try{return this.convert({typeReference:e,value:t})}finally{this.context.errors.unscope()}})}):(this.context.errors.add({severity:a.Critical,message:`Expected array but got: ${typeof r}`}),this.csharp.TypeLiteral.nop())}convertMap({map:e,value:r,fallbackToDefault:i}){return typeof r!="object"||r==null?(this.context.errors.add({severity:a.Critical,message:`Expected object but got: ${r==null?"null":typeof r}`}),this.csharp.TypeLiteral.nop()):this.csharp.TypeLiteral.dictionary({keyType:this.context.dynamicTypeMapper.convert({typeReference:e.key}),valueType:e.value.type==="unknown"?this.context.dynamicTypeMapper.convert({typeReference:e.value}).toOptionalIfNotAlready():this.context.dynamicTypeMapper.convert({typeReference:e.value}),entries:Object.entries(r).map(([t,n])=>{this.context.errors.scope(t);try{return{key:this.convert({typeReference:e.key,value:t,as:"key"}),value:this.convert({typeReference:e.value,value:n})}}finally{this.context.errors.unscope()}})})}convertNamed({named:e,value:r,as:i,fallbackToDefault:t}){switch(e.type){case"alias":return this.convert({typeReference:e.typeReference,value:r,as:i,fallbackToDefault:t});case"discriminatedUnion":return this.settings.shouldGeneratedDiscriminatedUnions?this.convertDiscriminatedUnion({discriminatedUnion:e,value:r,fallbackToDefault:t}):this.convertUnknown({value:r,fallbackToDefault:t});case"enum":return this.getEnumValue(e,r);case"object":return this.convertObject({object_:e,value:r,fallbackToDefault:t});case"undiscriminatedUnion":return this.convertUndiscriminatedUnion({undiscriminatedUnion:e,value:r,fallbackToDefault:t});default:c(e)}}convertDiscriminatedUnion({discriminatedUnion:e,value:r,fallbackToDefault:i}){let t=this.csharp.classReference({origin:e.declaration,namespace:this.context.getNamespace(e.declaration.fernFilepath)}),n=this.context.resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:r});if(n==null)return this.csharp.TypeLiteral.nop();let s=n.singleDiscriminatedUnionType,p=this.getBaseProperties({discriminatedUnionTypeInstance:n,singleDiscriminatedUnionType:s});switch(s.type){case"samePropertiesAsObject":{let o=this.context.resolveNamedType({typeId:s.typeId});return o==null?this.csharp.TypeLiteral.nop():this.instantiateUnionWithBaseProperties({classReference:t,baseProperties:p,arguments_:[this.convertNamed({named:o,value:n.value})]})}case"singleProperty":{if(this.context.getRecord(n.value)==null)return this.csharp.TypeLiteral.nop();try{let y=["Value","Type"].includes(s.discriminantValue.name.pascalCase.safeName)?`${s.discriminantValue.name.pascalCase.safeName}Inner`:s.discriminantValue.name.pascalCase.safeName;return this.context.errors.scope(s.discriminantValue.wireValue),this.instantiateUnionWithBaseProperties({classReference:t,baseProperties:p,arguments_:[this.csharp.instantiateClass({classReference:this.csharp.classReference({name:y,enclosingType:t}),arguments_:[this.convert({typeReference:s.typeReference,value:s.discriminantValue.wireValue})]})]})}finally{this.context.errors.unscope()}}case"noProperties":return this.instantiateUnionWithBaseProperties({classReference:t,baseProperties:p,arguments_:[this.csharp.instantiateClass({classReference:this.csharp.classReference({origin:n.discriminantValue,enclosingType:t}),arguments_:[]})]});default:c(s)}}getBaseProperties({discriminatedUnionTypeInstance:e,singleDiscriminatedUnionType:r}){var t,n;return this.context.associateByWireValue({parameters:(t=r.properties)!=null?t:[],values:(n=this.context.getRecord(e.value))!=null?n:{},ignoreMissingParameters:!0}).map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getPropertyName(s.name.name),assignment:this.convert(s)}}finally{this.context.errors.unscope()}})}instantiateUnionWithBaseProperties({classReference:e,arguments_:r,baseProperties:i}){let t=this.csharp.instantiateClass({classReference:e,arguments_:r,multiline:!0});return i.length===0?this.csharp.TypeLiteral.reference(t):this.csharp.TypeLiteral.reference(this.csharp.codeblock(n=>{n.write(t," "),n.pushScope();for(let s of i)n.write(s.name," = ",s.assignment,",");n.popScope(!1)}))}getEnumValue(e,r){if(typeof r!="string")return this.context.errors.add({severity:a.Critical,message:`Expected enum value string, got: ${typeof r}`}),this.csharp.TypeLiteral.nop();let i=e.values.find(s=>s.wireValue===r);if(i==null)return this.context.errors.add({severity:a.Critical,message:`An enum value named "${r}" does not exist in this context`}),this.csharp.TypeLiteral.nop();let t=this.csharp.classReference({origin:e.declaration,namespace:this.context.getNamespace(e.declaration.fernFilepath)}),n=t.registerField(this.model.getPropertyNameFor(i),i);return this.csharp.TypeLiteral.reference(this.csharp.enumInstantiation({reference:t,value:n}))}convertObject({object_:e,value:r,fallbackToDefault:i}){var n;let t=this.context.associateByWireValue({parameters:e.properties,values:(n=this.context.getRecord(r))!=null?n:{}});return this.csharp.TypeLiteral.class_({reference:this.csharp.classReference({origin:e.declaration,namespace:this.context.getNamespace(e.declaration.fernFilepath)}),fields:t.map(s=>{this.context.errors.scope(s.name.wireValue);try{return{name:this.context.getClassName(s.name.name),value:this.convert(s)}}finally{this.context.errors.unscope()}})})}convertUndiscriminatedUnion({undiscriminatedUnion:e,value:r,fallbackToDefault:i}){let t=this.findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:r});return t==null?this.csharp.TypeLiteral.nop():t.typeLiteral}findMatchingUndiscriminatedUnionType({undiscriminatedUnion:e,value:r}){for(let i of e.types)try{let t=this.convert({typeReference:i,value:r});return{valueTypeReference:i,typeLiteral:t}}catch(t){continue}this.context.errors.add({severity:a.Critical,message:`None of the types in the undiscriminated union matched the given "${typeof r}" value`})}convertUnknown({value:e,fallbackToDefault:r}){return this.csharp.TypeLiteral.unknown(e)}convertPrimitive({primitive:e,value:r,as:i,fallbackToDefault:t}){switch(e){case"INTEGER":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.csharp.Type.integer.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.integer(n)}case"LONG":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.csharp.Type.long.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.long(n)}case"UINT":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.csharp.Type.uint.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.uint(n)}case"UINT_64":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.csharp.Type.ulong.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.ulong(n)}case"FLOAT":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.csharp.Type.float.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.float(n)}case"DOUBLE":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.csharp.Type.double.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.double(n)}case"BOOLEAN":{let n=this.getValueAsBoolean({value:r,as:i});return n==null?t?this.csharp.Type.boolean.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.boolean(n)}case"STRING":{let n=this.context.getValueAsString({value:r});return n==null?t?this.csharp.Type.string.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.string(n)}case"DATE":{let n=this.context.getValueAsString({value:r});return n==null?t?this.csharp.Type.dateOnly.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.date(n)}case"DATE_TIME":{let n=this.context.getValueAsString({value:r});return n==null?t?this.csharp.Type.dateTime.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.datetime(n)}case"UUID":{let n=this.context.getValueAsString({value:r});return n==null?t?this.csharp.Type.string.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.string(n)}case"BASE_64":{let n=this.context.getValueAsString({value:r});return n==null?t?this.csharp.Type.string.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.string(n)}case"BIG_INTEGER":{let n=this.context.getValueAsString({value:r});return n==null?t?this.csharp.Type.string.getDeterminsticDefault(t):this.csharp.TypeLiteral.nop():this.csharp.TypeLiteral.string(n)}default:c(e)}}getValueAsNumber({value:e,as:r}){let i=r==="key"&&typeof e=="string"?Number(e):e;return this.context.getValueAsNumber({value:i})}getValueAsBoolean({value:e,as:r}){let i=r==="key"?typeof e=="string"?e==="true":e==="false"?!1:e:e;return this.context.getValueAsBoolean({value:i})}};export{h as a};
|
|
2
|
+
//# sourceMappingURL=chunk-CDMZ2O62.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/DynamicTypeLiteralMapper.ts"],"sourcesContent":["import { DiscriminatedUnionTypeInstance, NamedArgument, Severity } from \"@fern-api/browser-compatible-base-generator\";\nimport { assertNever } from \"@fern-api/core-utils\";\nimport { ast, WithGeneration } from \"@fern-api/csharp-codegen\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { DynamicSnippetsGeneratorContext } from \"./DynamicSnippetsGeneratorContext\";\n\nexport declare namespace DynamicTypeLiteralMapper {\n interface Args {\n typeReference: FernIr.dynamic.TypeReference;\n value: unknown;\n as?: ConvertedAs;\n fallbackToDefault?: string;\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 extends WithGeneration {\n private context: DynamicSnippetsGeneratorContext;\n\n constructor({ context }: { context: DynamicSnippetsGeneratorContext }) {\n super(context);\n this.context = context;\n }\n\n public convert(args: DynamicTypeLiteralMapper.Args): ast.TypeLiteral {\n // eslint-disable-next-line eqeqeq\n if (args.value === null) {\n if (this.context.isNullable(args.typeReference)) {\n return this.csharp.TypeLiteral.null();\n }\n this.context.errors.add({\n severity: Severity.Critical,\n message: \"Expected non-null value, but got null\"\n });\n return this.csharp.TypeLiteral.nop();\n }\n if (args.value === undefined && !args.fallbackToDefault) {\n return this.csharp.TypeLiteral.nop();\n }\n switch (args.typeReference.type) {\n case \"list\":\n return this.convertList({\n list: args.typeReference.value,\n value: args.value,\n fallbackToDefault: args.fallbackToDefault\n });\n case \"literal\":\n return this.convertLiteral({\n literal: args.typeReference.value,\n value: args.value\n });\n case \"map\":\n return this.convertMap({\n map: args.typeReference,\n value: args.value,\n fallbackToDefault: args.fallbackToDefault\n });\n case \"named\": {\n const named = this.context.resolveNamedType({ typeId: args.typeReference.value });\n if (named == null) {\n return this.csharp.TypeLiteral.nop();\n }\n return this.convertNamed({\n named,\n value: args.value,\n as: args.as,\n fallbackToDefault: args.fallbackToDefault\n });\n }\n case \"nullable\":\n return this.convert({\n typeReference: args.typeReference.value,\n value: args.value,\n as: args.as\n });\n case \"optional\":\n return this.convert({\n typeReference: args.typeReference.value,\n value: args.value,\n as: args.as\n });\n case \"primitive\":\n return this.convertPrimitive({\n primitive: args.typeReference.value,\n value: args.value,\n as: args.as,\n fallbackToDefault: args.fallbackToDefault\n });\n case \"set\":\n return this.convertSet({\n set: args.typeReference.value,\n value: args.value,\n fallbackToDefault: args.fallbackToDefault\n });\n case \"unknown\":\n return this.convertUnknown({ value: args.value, fallbackToDefault: args.fallbackToDefault });\n default:\n assertNever(args.typeReference);\n }\n }\n\n private convertList({\n list,\n value,\n fallbackToDefault\n }: {\n list: FernIr.dynamic.TypeReference;\n value: unknown;\n fallbackToDefault?: string;\n }): ast.TypeLiteral {\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 this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.list({\n valueType: this.context.dynamicTypeMapper.convert({ typeReference: list, unboxOptionals: true }),\n values: value.map((v, index) => {\n this.context.errors.scope({ index });\n try {\n return this.convert({ typeReference: list, value: v });\n } finally {\n this.context.errors.unscope();\n }\n })\n });\n }\n\n private convertLiteral({\n literal,\n value,\n fallbackToDefault\n }: {\n literal: FernIr.dynamic.LiteralType;\n value: unknown;\n fallbackToDefault?: string;\n }): ast.TypeLiteral {\n switch (literal.type) {\n case \"boolean\": {\n const bool = this.context.getValueAsBoolean({ value });\n if (bool == null) {\n return this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.boolean(bool);\n }\n case \"string\": {\n const str = this.context.getValueAsString({ value });\n if (str == null) {\n return fallbackToDefault\n ? this.csharp.Type.string.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.string(str);\n }\n default:\n assertNever(literal);\n }\n }\n\n private convertSet({\n set,\n value,\n fallbackToDefault\n }: {\n set: FernIr.dynamic.TypeReference;\n value: unknown;\n fallbackToDefault?: string;\n }): ast.TypeLiteral {\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 this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.set({\n valueType: this.context.dynamicTypeMapper.convert({ typeReference: set, unboxOptionals: true }),\n values: 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 });\n }\n\n private convertMap({\n map,\n value,\n fallbackToDefault\n }: {\n map: FernIr.dynamic.MapType;\n value: unknown;\n fallbackToDefault?: string;\n }): ast.TypeLiteral {\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 this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.dictionary({\n keyType: this.context.dynamicTypeMapper.convert({ typeReference: map.key }),\n valueType:\n map.value.type === \"unknown\"\n ? this.context.dynamicTypeMapper.convert({ typeReference: map.value }).toOptionalIfNotAlready()\n : this.context.dynamicTypeMapper.convert({ typeReference: map.value }),\n entries: Object.entries(value).map(([key, value]) => {\n this.context.errors.scope(key);\n try {\n return {\n key: this.convert({ typeReference: map.key, value: key, as: \"key\" }),\n value: this.convert({ typeReference: map.value, value })\n };\n } finally {\n this.context.errors.unscope();\n }\n })\n });\n }\n\n private convertNamed({\n named,\n value,\n as,\n fallbackToDefault\n }: {\n named: FernIr.dynamic.NamedType;\n value: unknown;\n as?: DynamicTypeLiteralMapper.ConvertedAs;\n fallbackToDefault?: string;\n }): ast.TypeLiteral {\n switch (named.type) {\n case \"alias\":\n return this.convert({ typeReference: named.typeReference, value, as, fallbackToDefault });\n case \"discriminatedUnion\":\n if (this.settings.shouldGeneratedDiscriminatedUnions) {\n return this.convertDiscriminatedUnion({ discriminatedUnion: named, value, fallbackToDefault });\n }\n return this.convertUnknown({ value, fallbackToDefault });\n case \"enum\":\n return this.getEnumValue(named, value);\n case \"object\":\n return this.convertObject({ object_: named, value, fallbackToDefault });\n case \"undiscriminatedUnion\":\n return this.convertUndiscriminatedUnion({ undiscriminatedUnion: named, value, fallbackToDefault });\n default:\n assertNever(named);\n }\n }\n\n private convertDiscriminatedUnion({\n discriminatedUnion,\n value,\n fallbackToDefault\n }: {\n discriminatedUnion: FernIr.dynamic.DiscriminatedUnionType;\n value: unknown;\n fallbackToDefault?: string;\n }): ast.TypeLiteral {\n const classReference = this.csharp.classReference({\n origin: discriminatedUnion.declaration,\n namespace: this.context.getNamespace(discriminatedUnion.declaration.fernFilepath)\n });\n const discriminatedUnionTypeInstance = this.context.resolveDiscriminatedUnionTypeInstance({\n discriminatedUnion,\n value\n });\n if (discriminatedUnionTypeInstance == null) {\n return this.csharp.TypeLiteral.nop();\n }\n const unionVariant = discriminatedUnionTypeInstance.singleDiscriminatedUnionType;\n const baseProperties = this.getBaseProperties({\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 this.csharp.TypeLiteral.nop();\n }\n return this.instantiateUnionWithBaseProperties({\n classReference,\n baseProperties,\n arguments_: [this.convertNamed({ named, value: discriminatedUnionTypeInstance.value })]\n });\n }\n case \"singleProperty\": {\n const record = this.context.getRecord(discriminatedUnionTypeInstance.value);\n if (record == null) {\n return this.csharp.TypeLiteral.nop();\n }\n try {\n const innerClassName = [\"Value\", \"Type\"].includes(\n unionVariant.discriminantValue.name.pascalCase.safeName\n )\n ? `${unionVariant.discriminantValue.name.pascalCase.safeName}Inner`\n : unionVariant.discriminantValue.name.pascalCase.safeName;\n\n this.context.errors.scope(unionVariant.discriminantValue.wireValue);\n return this.instantiateUnionWithBaseProperties({\n classReference,\n baseProperties,\n arguments_: [\n this.csharp.instantiateClass({\n classReference: this.csharp.classReference({\n // origin: discriminatedUnionTypeInstance.discriminantValue,\n name: innerClassName,\n enclosingType: classReference\n }),\n arguments_: [\n this.convert({\n typeReference: unionVariant.typeReference,\n value: unionVariant.discriminantValue.wireValue\n })\n ]\n })\n ]\n });\n } finally {\n this.context.errors.unscope();\n }\n }\n case \"noProperties\":\n return this.instantiateUnionWithBaseProperties({\n classReference,\n baseProperties,\n arguments_: [\n // Unions with no properties require the discriminant property to be set.\n this.csharp.instantiateClass({\n classReference: this.csharp.classReference({\n origin: discriminatedUnionTypeInstance.discriminantValue,\n enclosingType: classReference\n }),\n arguments_: []\n })\n ]\n });\n default:\n assertNever(unionVariant);\n }\n }\n\n private getBaseProperties({\n discriminatedUnionTypeInstance,\n singleDiscriminatedUnionType\n }: {\n discriminatedUnionTypeInstance: DiscriminatedUnionTypeInstance;\n singleDiscriminatedUnionType: FernIr.dynamic.SingleDiscriminatedUnionType;\n }): NamedArgument[] {\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 assignment: this.convert(property)\n };\n } finally {\n this.context.errors.unscope();\n }\n });\n }\n\n private instantiateUnionWithBaseProperties({\n classReference,\n arguments_,\n baseProperties\n }: {\n classReference: ast.ClassReference;\n arguments_: ast.AstNode[];\n baseProperties: NamedArgument[];\n }): ast.TypeLiteral {\n const instantiation = this.csharp.instantiateClass({\n classReference,\n arguments_,\n multiline: true\n });\n if (baseProperties.length === 0) {\n return this.csharp.TypeLiteral.reference(instantiation);\n }\n return this.csharp.TypeLiteral.reference(\n this.csharp.codeblock((writer) => {\n writer.write(instantiation, \" \");\n writer.pushScope();\n for (const baseProperty of baseProperties) {\n writer.write(baseProperty.name, \" = \", baseProperty.assignment, \",\");\n }\n writer.popScope(false);\n })\n );\n }\n\n private getEnumValue(enum_: FernIr.dynamic.EnumType, wireValue: unknown): ast.TypeLiteral {\n if (typeof wireValue !== \"string\") {\n this.context.errors.add({\n severity: Severity.Critical,\n message: `Expected enum value string, got: ${typeof wireValue}`\n });\n return this.csharp.TypeLiteral.nop();\n }\n const enumValue = enum_.values.find((v) => v.wireValue === wireValue);\n if (enumValue == null) {\n this.context.errors.add({\n severity: Severity.Critical,\n message: `An enum value named \"${wireValue}\" does not exist in this context`\n });\n return this.csharp.TypeLiteral.nop();\n }\n const reference = this.csharp.classReference({\n origin: enum_.declaration,\n namespace: this.context.getNamespace(enum_.declaration.fernFilepath)\n });\n\n const valueName = reference.registerField(this.model.getPropertyNameFor(enumValue), enumValue);\n\n return this.csharp.TypeLiteral.reference(\n this.csharp.enumInstantiation({\n reference,\n value: valueName\n })\n );\n }\n\n private convertObject({\n object_,\n value,\n fallbackToDefault\n }: {\n object_: FernIr.dynamic.ObjectType;\n value: unknown;\n fallbackToDefault?: string;\n }): ast.TypeLiteral {\n const properties = this.context.associateByWireValue({\n parameters: object_.properties,\n values: this.context.getRecord(value) ?? {}\n });\n\n return this.csharp.TypeLiteral.class_({\n reference: this.csharp.classReference({\n origin: object_.declaration,\n namespace: this.context.getNamespace(object_.declaration.fernFilepath)\n }),\n fields: properties.map((property) => {\n this.context.errors.scope(property.name.wireValue);\n try {\n return {\n name: this.context.getClassName(property.name.name),\n value: this.convert(property)\n };\n } finally {\n this.context.errors.unscope();\n }\n })\n });\n }\n\n private convertUndiscriminatedUnion({\n undiscriminatedUnion,\n value,\n fallbackToDefault\n }: {\n undiscriminatedUnion: FernIr.dynamic.UndiscriminatedUnionType;\n value: unknown;\n fallbackToDefault?: string;\n }): ast.TypeLiteral {\n const result = this.findMatchingUndiscriminatedUnionType({\n undiscriminatedUnion,\n value\n });\n if (result == null) {\n return this.csharp.TypeLiteral.nop();\n }\n return result.typeLiteral;\n }\n\n private findMatchingUndiscriminatedUnionType({\n undiscriminatedUnion,\n value\n }: {\n undiscriminatedUnion: FernIr.dynamic.UndiscriminatedUnionType;\n value: unknown;\n }): { valueTypeReference: FernIr.dynamic.TypeReference; typeLiteral: ast.TypeLiteral } | undefined {\n for (const typeReference of undiscriminatedUnion.types) {\n try {\n const typeLiteral = this.convert({ typeReference, value });\n return { valueTypeReference: typeReference, typeLiteral };\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 convertUnknown({\n value,\n fallbackToDefault\n }: {\n value: unknown;\n fallbackToDefault?: string;\n }): ast.TypeLiteral {\n return this.csharp.TypeLiteral.unknown(value);\n }\n\n private convertPrimitive({\n primitive,\n value,\n as,\n fallbackToDefault\n }: {\n primitive: FernIr.dynamic.PrimitiveTypeV1;\n value: unknown;\n as?: DynamicTypeLiteralMapper.ConvertedAs;\n fallbackToDefault?: string;\n }): ast.TypeLiteral {\n switch (primitive) {\n case \"INTEGER\": {\n const num = this.getValueAsNumber({ value, as });\n if (num == null) {\n return fallbackToDefault\n ? this.csharp.Type.integer.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.integer(num);\n }\n case \"LONG\": {\n const num = this.getValueAsNumber({ value, as });\n if (num == null) {\n return fallbackToDefault\n ? this.csharp.Type.long.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.long(num);\n }\n case \"UINT\": {\n const num = this.getValueAsNumber({ value, as });\n if (num == null) {\n return fallbackToDefault\n ? this.csharp.Type.uint.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.uint(num);\n }\n case \"UINT_64\": {\n const num = this.getValueAsNumber({ value, as });\n if (num == null) {\n return fallbackToDefault\n ? this.csharp.Type.ulong.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.ulong(num);\n }\n case \"FLOAT\": {\n const num = this.getValueAsNumber({ value, as });\n if (num == null) {\n return fallbackToDefault\n ? this.csharp.Type.float.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.float(num);\n }\n case \"DOUBLE\": {\n const num = this.getValueAsNumber({ value, as });\n if (num == null) {\n return fallbackToDefault\n ? this.csharp.Type.double.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.double(num);\n }\n case \"BOOLEAN\": {\n const bool = this.getValueAsBoolean({ value, as });\n if (bool == null) {\n return fallbackToDefault\n ? this.csharp.Type.boolean.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.boolean(bool);\n }\n case \"STRING\": {\n const str = this.context.getValueAsString({ value });\n if (str == null) {\n return fallbackToDefault\n ? this.csharp.Type.string.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.string(str);\n }\n case \"DATE\": {\n const date = this.context.getValueAsString({ value });\n if (date == null) {\n return fallbackToDefault\n ? this.csharp.Type.dateOnly.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.date(date);\n }\n case \"DATE_TIME\": {\n const dateTime = this.context.getValueAsString({ value });\n if (dateTime == null) {\n return fallbackToDefault\n ? this.csharp.Type.dateTime.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.datetime(dateTime);\n }\n case \"UUID\": {\n const uuid = this.context.getValueAsString({ value });\n if (uuid == null) {\n return fallbackToDefault\n ? this.csharp.Type.string.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.string(uuid);\n }\n case \"BASE_64\": {\n const base64 = this.context.getValueAsString({ value });\n if (base64 == null) {\n return fallbackToDefault\n ? this.csharp.Type.string.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.string(base64);\n }\n case \"BIG_INTEGER\": {\n const bigInt = this.context.getValueAsString({ value });\n if (bigInt == null) {\n return fallbackToDefault\n ? this.csharp.Type.string.getDeterminsticDefault(fallbackToDefault)\n : this.csharp.TypeLiteral.nop();\n }\n return this.csharp.TypeLiteral.string(bigInt);\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":"8FAmBO,IAAMA,EAAN,cAAuCC,CAAe,CAGzD,YAAY,CAAE,QAAAC,CAAQ,EAAiD,CACnE,MAAMA,CAAO,EAHjBC,EAAA,KAAQ,WAIJ,KAAK,QAAUD,CACnB,CAEO,QAAQE,EAAsD,CAEjE,GAAIA,EAAK,QAAU,KACf,OAAI,KAAK,QAAQ,WAAWA,EAAK,aAAa,EACnC,KAAK,OAAO,YAAY,KAAK,GAExC,KAAK,QAAQ,OAAO,I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AAQ,iBAAiB,CAAE,MAAA3C,CAAM,CAAC,EACtD,OAAI2C,GAAU,KACH1C,EACD,KAAK,OAAO,KAAK,OAAO,uBAAuBA,CAAiB,EAChE,KAAK,OAAO,YAAY,IAAI,EAE/B,KAAK,OAAO,YAAY,OAAO0C,CAAM,CAChD,CACA,QACI7C,EAAYuC,CAAS,CAC7B,CACJ,CAEQ,iBAAiB,CACrB,MAAArC,EACA,GAAAU,CACJ,EAGuB,CACnB,IAAM4B,EAAM5B,IAAO,OAAS,OAAOV,GAAU,SAAW,OAAOA,CAAK,EAAaA,EACjF,OAAO,KAAK,QAAQ,iBAAiB,CAAE,MAAOsC,CAAI,CAAC,CACvD,CAEQ,kBAAkB,CACtB,MAAAtC,EACA,GAAAU,CACJ,EAGwB,CACpB,IAAML,EACFK,IAAO,MAAS,OAAOV,GAAU,SAAWA,IAAU,OAASA,IAAU,QAAU,GAAQA,EAASA,EACxG,OAAO,KAAK,QAAQ,kBAAkB,CAAE,MAAOK,CAAK,CAAC,CACzD,CACJ","names":["DynamicTypeLiteralMapper","WithGeneration","context","__publicField","args","Severity","named","assertNever","list","value","fallbackToDefault","v","index","literal","bool","str","set","map","key","as","discriminatedUnion","classReference","discriminatedUnionTypeInstance","unionVariant","baseProperties","innerClassName","singleDiscriminatedUnionType","_a","_b","property","arguments_","instantiation","writer","baseProperty","enum_","wireValue","enumValue","reference","valueName","object_","properties","undiscriminatedUnion","result","typeReference","typeLiteral","e","primitive","num","date","dateTime","uuid","base64","bigInt"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as E,b as w,d as x,e as P,h as a,i as d,j as m}from"./chunk-ZDZZCKFB.js";var c=class{constructor(){a(this,"reporter");a(this,"snippet");a(this,"err");this.snippet=void 0,this.reporter=void 0,this.err=void 0}update({context:e,snippet:r}){this.shouldUpdate({snippet:r,reporter:e.errors})&&(this.reporter=e.errors.clone(),this.snippet=r)}getResponseOrThrow({endpoint:e}){var r;if(this.snippet!=null&&this.reporter!=null)return{snippet:this.snippet,errors:this.reporter.toDynamicSnippetErrors()};throw(r=this.err)!=null?r:new Error(`Failed to generate snippet for endpoint "${e.method} ${e.path}"`)}shouldUpdate({snippet:e,reporter:r}){var t,n;return this.reporter==null||this.reporter.size()>0&&r.size()===0?!0:e.length>((n=(t=this.snippet)==null?void 0:t.length)!=null?n:0)}};var y=class{constructor(e){a(this,"context");this.context=e}async generate(e,r={}){let t=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(t.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let n=new c;for(let i of t){let s=this.context.clone(),l=this.createSnippetGenerator(s);try{let p=await l.generateSnippet({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:p,errors:void 0};n.update({context:s,snippet:p})}catch(p){n.err==null&&(n.err=p)}}return n.getResponseOrThrow({endpoint:e.endpoint})}generateSync(e,r={}){let t=this.context.resolveEndpointLocationOrThrow(e.endpoint);if(t.length===0)throw new Error(`No endpoints found that match "${e.endpoint.method} ${e.endpoint.path}"`);let n=new c;for(let i of t){let s=this.context.clone(),l=this.createSnippetGenerator(s);try{let p=l.generateSnippetSync({endpoint:i,request:e,options:r});if(s.errors.empty())return{snippet:p,errors:void 0};n.update({context:s,snippet:p})}catch(p){n.err==null&&(n.err=p)}}return n.getResponseOrThrow({endpoint:e.endpoint})}};var o={Critical:"CRITICAL",Warning:"WARNING"},f=class u{constructor(){a(this,"errors");a(this,"path");this.errors=[],this.path=[]}add(e){this.errors.push(w(E({},e),{path:[...this.path]}))}scope(e){this.path.push(e)}unscope(){this.path.pop()}getBySeverity(e){return this.errors.filter(r=>r.severity===e)}empty(){return this.errors.length===0}size(){return this.errors.length}clone(){let e=new u;return e.errors=[...this.errors],e.path=[...this.path],e}reset(){this.errors=[],this.path=[]}toDynamicSnippetErrors(){return this.errors.map(e=>({severity:e.severity,path:e.path!=null?this.pathToStringArray(e.path):void 0,message:e.message}))}pathToStringArray(e){let r=[];for(let t of e){if(typeof t=="string"){r.push(t);continue}r[r.length-1]+=`[${t.index}]`}return r}};var h=class{constructor(){a(this,"REFERENCE_REGEX",/^(GET|POST|PUT|DELETE|PATCH|HEAD)\s(\/\S*)$/)}validate(e){return this.REFERENCE_REGEX.test(e)?{type:"valid"}:{type:"invalid"}}tryParse(e){if(this.validate(e).type==="invalid")return;let t=e.match(this.REFERENCE_REGEX);if(!(t==null||t[1]==null||t[2]==null))return{method:t[1],path:t[2]}}};var v=class{constructor({ir:e,config:r,options:t={}}){a(this,"config");a(this,"options");a(this,"errors");a(this,"_ir");a(this,"httpEndpointReferenceParser");this._ir=e,this.config=r,this.options=t,this.errors=new f,this.httpEndpointReferenceParser=new h}associateQueryParametersByWireValue({parameters:e,values:r}){let t=[];for(let[n,i]of Object.entries(r)){this.errors.scope(n);try{let s=e.find(p=>p.name.wireValue===n);if(s==null)throw this.newParameterNotRecognizedError(n);let l=this.isListTypeReference(s.typeReference)&&!Array.isArray(i)?[i]:i;t.push({name:s.name,typeReference:s.typeReference,value:l})}finally{this.errors.unscope()}}return t}associateByWireValueOrDefault({parameters:e,values:r}){let t=[];for(let n of e){this.errors.scope(n.name.wireValue);try{let i=r[n.name.wireValue];if(i==null)if(n.typeReference.type==="primitive"&&n.typeReference.value==="STRING")i=`<${n.name.wireValue}>`;else{this.errors.add({severity:o.Critical,message:this.newParameterNotRecognizedError(n.name.wireValue).message});continue}t.push({name:n.name,typeReference:n.typeReference,value:i})}finally{this.errors.unscope()}}return t}associateByWireValue({parameters:e,values:r,ignoreMissingParameters:t}){let n=[];for(let[i,s]of Object.entries(r)){this.errors.scope(i);try{let l=e.find(p=>p.name.wireValue===i);if(l==null){if(t)continue;this.errors.add({severity:o.Critical,message:this.newParameterNotRecognizedError(i).message});continue}n.push({name:l.name,typeReference:l.typeReference,value:s})}finally{this.errors.unscope()}}return n}getExampleObjectProperties({parameters:e,snippetObject:r}){let t=typeof r=="object"&&r!==null&&!Array.isArray(r)?r:{},n=[];for(let i of e){let s=t[i.name.wireValue];s==null?i.typeReference.type==="nullable"&&n.push({name:i.name,typeReference:i.typeReference,value:null}):n.push({name:i.name,typeReference:i.typeReference,value:s})}return n}getSingleFileValue({property:e,record:r}){let t=r[e.wireValue];if(t!=null){if(typeof t!="string"){this.errors.add({severity:o.Critical,message:`Expected file value to be a string, got ${typeof t}`});return}return t}}getFileArrayValues({property:e,record:r}){let t=r[e.wireValue];if(t==null)return;if(!Array.isArray(t)){this.errors.add({severity:o.Critical,message:`Expected file array value to be an array of strings, got ${typeof t}`});return}let n=[];for(let i of t){if(typeof i!="string"){this.errors.add({severity:o.Critical,message:`Expected file array value to be an array of strings, got ${typeof i}`});return}n.push(i)}return n}getRecord(e){if(typeof e!="object"||Array.isArray(e)){this.errors.add({severity:o.Critical,message:`Expected object with key, value pairs but got: ${Array.isArray(e)?"array":typeof e}`});return}return e==null?{}:e}resolveNamedType({typeId:e}){let r=this._ir.types[e];if(r==null){this.errors.add({severity:o.Critical,message:`Type identified by "${e}" could not be found`});return}return r}resolveDiscriminatedUnionTypeInstance({discriminatedUnion:e,value:r}){let t=this.getRecord(r);if(t==null)return;let n=e.discriminant.wireValue,i=t[n];if(i==null){this.errors.add({severity:o.Critical,message:this.newParameterNotRecognizedError(n).message});return}if(typeof i!="string"){this.errors.add({severity:o.Critical,message:`Expected discriminant value to be a string but got: ${typeof i}`});return}let s=e.types[i];if(s==null){this.errors.add({severity:o.Critical,message:`No type found for discriminant value "${i}"`});return}let R=t,{[n]:l}=R,p=P(R,[x(n)]);return{singleDiscriminatedUnionType:s,discriminantValue:s.discriminantValue,value:p}}resolveEndpointOrThrow(e){let r=this.httpEndpointReferenceParser.tryParse(e);if(r==null)throw new Error(`Failed to parse endpoint reference "${e}"`);return this.resolveEndpointLocationOrThrow(r)}resolveEndpointLocation(e){let r=[];for(let t of Object.values(this._ir.endpoints))this.parsedEndpointMatches({endpoint:t,parsedEndpoint:e})&&r.push(t);return r}resolveEndpointLocationOrThrow(e){let r=this.resolveEndpointLocation(e);if(r.length===0)throw new Error(`Failed to find endpoint identified by "${e.method} ${e.path}"`);return r}needsRequestParameter({request:e,inlinePathParameters:r,inlineFileProperties:t}){var n;return this.includePathParametersInWrappedRequest({request:e,inlinePathParameters:r})||e.queryParameters!=null&&e.queryParameters.length>0||e.headers!=null&&e.headers.length>0?!0:e.body!=null?this.includeRequestBodyInWrappedRequest({body:e.body,inlineFileProperties:t}):!((n=e.metadata)!=null&&n.onlyPathParameters)}includePathParametersInWrappedRequest({request:e,inlinePathParameters:r}){var t,n;return r&&((n=(t=e.metadata)==null?void 0:t.includePathParameters)!=null?n:!1)}isFileUploadRequestBody(e){switch(e.type){case"fileUpload":return!0;case"properties":case"referenced":return!1;default:d(e)}}resolveEnvironmentName(e){if(this._ir.environments==null)return;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}case"multipleBaseUrls":{let t=r.environments.find(n=>n.id===e);return t==null?void 0:t.name}default:d(r)}}isSingleEnvironmentID(e){return typeof e=="string"}isMultiEnvironmentValues(e){return typeof e=="object"}validateMultiEnvironmentUrlValues(e){if(this._ir.environments==null)return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;let r=this._ir.environments.environments;switch(r.type){case"singleBaseUrl":return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported for single base URL environments; use the baseUrl option instead"}),!1;case"multipleBaseUrls":{let t=r.environments[0];if(t==null)return this.errors.add({severity:o.Critical,message:"Multiple environments are not supported; use the baseUrl option instead"}),!1;let n=new Set(m(t.urls));for(let i of m(e))n.has(i)&&n.delete(i);return n.size>0?(this.errors.add({severity:o.Critical,message:`The provided environments are invalid; got: [${Object.keys(e).join(", ")}], expected: [${m(t.urls).join(", ")}]`}),!1):!0}}}getValueAsNumber({value:e}){if(typeof e!="number"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"number",value:e}).message});return}return e}getValueAsBoolean({value:e}){if(typeof e!="boolean"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"boolean",value:e}).message});return}return e}getValueAsString({value:e}){if(typeof e!="string"){this.errors.add({severity:o.Critical,message:this.newTypeMismatchError({expected:"string",value:e}).message});return}return e}isOptional(e){switch(e.type){case"nullable":return this.isOptional(e.value);case"optional":return!0;case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}isNullable(e){switch(e.type){case"nullable":return!0;case"optional":return this.isNullable(e.value);case"named":{let r=this.resolveNamedType({typeId:e.value});return r==null?!1:r.type==="alias"?this.isNullable(r.typeReference):!1}}return!1}newAuthMismatchError({auth:e,values:r}){return new Error(`Expected auth type ${e.type}, got ${r.type}`)}newParameterNotRecognizedError(e){return new Error(`"${e}" is not a recognized parameter for this endpoint`)}newTypeMismatchError({expected:e,value:r}){return new Error(`Expected ${e}, got ${typeof r}`)}includeRequestBodyInWrappedRequest({body:e,inlineFileProperties:r}){switch(e.type){case"properties":case"referenced":return!0;case"fileUpload":return this.includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r});default:d(e)}}includeFileUploadBodyInWrappedRequest({fileUpload:e,inlineFileProperties:r}){return this.fileUploadHasBodyProperties({fileUpload:e})||r&&this.fileUploadHasFileProperties({fileUpload:e})}fileUploadHasBodyProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!1;case"bodyProperty":return!0;default:d(r)}})}fileUploadHasFileProperties({fileUpload:e}){return e.properties.some(r=>{switch(r.type){case"file":case"fileArray":return!0;case"bodyProperty":return!1;default:d(r)}})}isListTypeReference(e){return e.type==="optional"?this.isListTypeReference(e.value):e.type==="list"||e.type==="set"}parsedEndpointMatches({endpoint:e,parsedEndpoint:r}){return e.location.method===r.method&&e.location.path===r.path}};var g;(function(u){u.Concise="concise",u.Full="full"})(g||(g={}));var T={PathParameters:"pathParameters",QueryParameters:"queryParameters",Headers:"headers",RequestBody:"requestBody"};export{y as a,o as b,v as c,g as d,T as e};
|
|
2
|
+
//# sourceMappingURL=chunk-D2D544ZS.js.map
|