@fern-api/csharp-dynamic-snippets 0.0.5 → 2.10.0
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/DynamicSnippetsGenerator.cjs +17 -17
- package/cjs/DynamicSnippetsGenerator.cjs.map +1 -1
- package/cjs/DynamicSnippetsGenerator.d.cts +5 -3
- package/cjs/{DynamicSnippetsGeneratorContext-DQDI25Nx.d.cts → DynamicSnippetsGeneratorContext-Dz9RlVgp.d.cts} +133 -85
- package/cjs/EndpointSnippetGenerator.cjs +20 -20
- package/cjs/EndpointSnippetGenerator.cjs.map +1 -1
- package/cjs/EndpointSnippetGenerator.d.cts +10 -4
- package/cjs/context/DynamicLiteralMapper.cjs +2 -0
- package/cjs/context/DynamicLiteralMapper.cjs.map +1 -0
- package/cjs/context/DynamicLiteralMapper.d.cts +7 -0
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs +20 -20
- package/cjs/context/DynamicSnippetsGeneratorContext.cjs.map +1 -1
- package/cjs/context/DynamicSnippetsGeneratorContext.d.cts +3 -2
- package/cjs/context/DynamicTypeMapper.cjs +1 -1
- package/cjs/context/DynamicTypeMapper.cjs.map +1 -1
- package/cjs/context/DynamicTypeMapper.d.cts +3 -2
- package/cjs/context/FilePropertyMapper.cjs +15 -15
- package/cjs/context/FilePropertyMapper.cjs.map +1 -1
- package/cjs/context/FilePropertyMapper.d.cts +3 -2
- package/cjs/index.cjs +17 -17
- package/cjs/index.cjs.map +1 -1
- package/cjs/index.d.cts +3 -2
- package/esm/DynamicSnippetsGenerator.d.ts +5 -3
- package/esm/DynamicSnippetsGenerator.js +1 -1
- package/esm/{DynamicSnippetsGeneratorContext-DQDI25Nx.d.ts → DynamicSnippetsGeneratorContext-Dz9RlVgp.d.ts} +133 -85
- package/esm/EndpointSnippetGenerator.d.ts +10 -4
- package/esm/EndpointSnippetGenerator.js +1 -1
- package/esm/chunk-3AKTWPYH.js +2 -0
- package/esm/chunk-3AKTWPYH.js.map +1 -0
- package/esm/chunk-4A2AR7IK.js +2 -0
- package/esm/chunk-4A2AR7IK.js.map +1 -0
- package/esm/chunk-54PJL32I.js +2 -0
- package/esm/chunk-54PJL32I.js.map +1 -0
- package/esm/chunk-BHXOAZDW.js +2 -0
- package/esm/chunk-BHXOAZDW.js.map +1 -0
- package/esm/chunk-JXSLTUG5.js +2 -0
- package/esm/chunk-JXSLTUG5.js.map +1 -0
- package/esm/chunk-ONI3ZPJV.js +15 -0
- package/esm/chunk-ONI3ZPJV.js.map +1 -0
- package/esm/chunk-RHB5YSP4.js +33 -0
- package/esm/chunk-RHB5YSP4.js.map +1 -0
- package/esm/chunk-VBCDESX3.js +2 -0
- package/esm/chunk-VBCDESX3.js.map +1 -0
- package/esm/context/DynamicLiteralMapper.d.ts +7 -0
- package/esm/context/DynamicLiteralMapper.js +2 -0
- package/esm/context/DynamicSnippetsGeneratorContext.d.ts +3 -2
- package/esm/context/DynamicSnippetsGeneratorContext.js +1 -1
- package/esm/context/DynamicTypeMapper.d.ts +3 -2
- package/esm/context/DynamicTypeMapper.js +1 -1
- package/esm/context/FilePropertyMapper.d.ts +3 -2
- package/esm/context/FilePropertyMapper.js +1 -1
- package/esm/index.d.ts +3 -2
- package/esm/index.js +1 -1
- package/package.json +1 -1
- package/cjs/context/DynamicTypeLiteralMapper.cjs +0 -2
- package/cjs/context/DynamicTypeLiteralMapper.cjs.map +0 -1
- package/cjs/context/DynamicTypeLiteralMapper.d.cts +0 -6
- package/esm/chunk-4O5TI5LE.js +0 -15
- package/esm/chunk-4O5TI5LE.js.map +0 -1
- package/esm/chunk-7QB2DXDM.js +0 -33
- package/esm/chunk-7QB2DXDM.js.map +0 -1
- package/esm/chunk-CQ47NT5H.js +0 -2
- package/esm/chunk-CQ47NT5H.js.map +0 -1
- package/esm/chunk-GZ2J5EKE.js +0 -2
- package/esm/chunk-GZ2J5EKE.js.map +0 -1
- package/esm/chunk-JXQ2W4OZ.js +0 -2
- package/esm/chunk-JXQ2W4OZ.js.map +0 -1
- package/esm/chunk-PRGD7S35.js +0 -2
- package/esm/chunk-PRGD7S35.js.map +0 -1
- package/esm/chunk-U2GJA4AT.js +0 -2
- package/esm/chunk-U2GJA4AT.js.map +0 -1
- package/esm/chunk-WMO2ROQ4.js +0 -2
- package/esm/chunk-WMO2ROQ4.js.map +0 -1
- package/esm/context/DynamicTypeLiteralMapper.d.ts +0 -6
- package/esm/context/DynamicTypeLiteralMapper.js +0 -2
- /package/esm/context/{DynamicTypeLiteralMapper.js.map → DynamicLiteralMapper.js.map} +0 -0
package/cjs/index.d.cts
CHANGED
|
@@ -2,8 +2,9 @@ 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 './DynamicSnippetsGeneratorContext-
|
|
5
|
+
import './DynamicSnippetsGeneratorContext-Dz9RlVgp.cjs';
|
|
6
|
+
import '@fern-api/csharp-codegen/lib/ast';
|
|
7
|
+
import '@fern-api/csharp-codegen/lib/ast/types/Type';
|
|
6
8
|
import '@fern-api/csharp-codegen/lib/context/model-navigator';
|
|
7
|
-
import '@fern-api/csharp-codegen/lib/context/extern';
|
|
8
9
|
import '@fern-api/csharp-codegen';
|
|
9
10
|
import './EndpointSnippetGenerator.cjs';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, Options } from '@fern-api/browser-compatible-base-generator';
|
|
1
|
+
import { AbstractDynamicSnippetsGenerator, FernGeneratorExec, Options, AbstractAstNode } from '@fern-api/browser-compatible-base-generator';
|
|
2
2
|
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
3
|
-
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-
|
|
3
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-Dz9RlVgp.js';
|
|
4
4
|
import { EndpointSnippetGenerator } from './EndpointSnippetGenerator.js';
|
|
5
|
+
import '@fern-api/csharp-codegen/lib/ast';
|
|
6
|
+
import '@fern-api/csharp-codegen/lib/ast/types/Type';
|
|
5
7
|
import '@fern-api/csharp-codegen/lib/context/model-navigator';
|
|
6
|
-
import '@fern-api/csharp-codegen/lib/context/extern';
|
|
7
8
|
import '@fern-api/csharp-codegen';
|
|
8
9
|
|
|
9
10
|
declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<DynamicSnippetsGeneratorContext, EndpointSnippetGenerator> {
|
|
@@ -15,6 +16,7 @@ declare class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<
|
|
|
15
16
|
precalculate(requests: FernIr.dynamic.EndpointSnippetRequest[]): void;
|
|
16
17
|
generate(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): Promise<FernIr.dynamic.EndpointSnippetResponse>;
|
|
17
18
|
generateSync(request: FernIr.dynamic.EndpointSnippetRequest, options?: Options): FernIr.dynamic.EndpointSnippetResponse;
|
|
19
|
+
generateSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): Promise<AbstractAstNode>;
|
|
18
20
|
protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator;
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-4A2AR7IK.js";import"./chunk-ONI3ZPJV.js";import"./chunk-3AKTWPYH.js";import"./chunk-BHXOAZDW.js";import"./chunk-VBCDESX3.js";import"./chunk-JXSLTUG5.js";import"./chunk-54PJL32I.js";import"./chunk-RHB5YSP4.js";export{a as DynamicSnippetsGenerator};
|
|
2
2
|
//# sourceMappingURL=DynamicSnippetsGenerator.js.map
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
+
import * as _fern_api_csharp_codegen_lib_ast from '@fern-api/csharp-codegen/lib/ast';
|
|
2
|
+
import * as _fern_api_csharp_codegen_lib_ast_types_Type from '@fern-api/csharp-codegen/lib/ast/types/Type';
|
|
1
3
|
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
4
|
import * as _fern_api_csharp_codegen from '@fern-api/csharp-codegen';
|
|
4
5
|
import { WithGeneration, ast, Generation } from '@fern-api/csharp-codegen';
|
|
5
6
|
import { AbstractDynamicSnippetsGeneratorContext, FernGeneratorExec, Options } from '@fern-api/browser-compatible-base-generator';
|
|
6
7
|
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
7
8
|
|
|
8
|
-
declare namespace
|
|
9
|
+
declare namespace DynamicLiteralMapper {
|
|
9
10
|
interface Args {
|
|
10
11
|
typeReference: FernIr.dynamic.TypeReference;
|
|
11
12
|
value: unknown;
|
|
@@ -14,12 +15,12 @@ declare namespace DynamicTypeLiteralMapper {
|
|
|
14
15
|
}
|
|
15
16
|
type ConvertedAs = "key";
|
|
16
17
|
}
|
|
17
|
-
declare class
|
|
18
|
+
declare class DynamicLiteralMapper extends WithGeneration {
|
|
18
19
|
private context;
|
|
19
20
|
constructor({ context }: {
|
|
20
21
|
context: DynamicSnippetsGeneratorContext;
|
|
21
22
|
});
|
|
22
|
-
convert(args:
|
|
23
|
+
convert(args: DynamicLiteralMapper.Args): ast.Literal;
|
|
23
24
|
private convertList;
|
|
24
25
|
private convertLiteral;
|
|
25
26
|
private convertSet;
|
|
@@ -78,7 +79,7 @@ declare class FilePropertyMapper extends WithGeneration {
|
|
|
78
79
|
declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGeneratorContext {
|
|
79
80
|
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
80
81
|
dynamicTypeMapper: DynamicTypeMapper;
|
|
81
|
-
|
|
82
|
+
dynamicLiteralMapper: DynamicLiteralMapper;
|
|
82
83
|
filePropertyMapper: FilePropertyMapper;
|
|
83
84
|
readonly generation: Generation;
|
|
84
85
|
get namespaces(): {
|
|
@@ -95,7 +96,6 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
95
96
|
implicit: Set<string>;
|
|
96
97
|
};
|
|
97
98
|
get registry(): _fern_api_csharp_codegen.NameRegistry;
|
|
98
|
-
get extern(): _fern_api_csharp_codegen_lib_context_extern.Extern;
|
|
99
99
|
get settings(): {
|
|
100
100
|
namespace: string;
|
|
101
101
|
readOnlyMemoryTypes: string[];
|
|
@@ -131,6 +131,12 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
131
131
|
extraDependencies: Record<string, string>;
|
|
132
132
|
pascalCaseEnvironments: boolean;
|
|
133
133
|
explicitNamespaces: boolean;
|
|
134
|
+
outputPath: {
|
|
135
|
+
library: string;
|
|
136
|
+
test: string;
|
|
137
|
+
solution: string;
|
|
138
|
+
other: string;
|
|
139
|
+
};
|
|
134
140
|
};
|
|
135
141
|
get constants(): {
|
|
136
142
|
folders: {
|
|
@@ -192,7 +198,14 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
192
198
|
idempotentOptions: string;
|
|
193
199
|
};
|
|
194
200
|
};
|
|
195
|
-
get
|
|
201
|
+
get model(): _fern_api_csharp_codegen_lib_context_model_navigator.ModelNavigator;
|
|
202
|
+
get format(): {
|
|
203
|
+
private: (name: string) => string;
|
|
204
|
+
};
|
|
205
|
+
get csharp(): _fern_api_csharp_codegen.CSharp;
|
|
206
|
+
get Types(): {
|
|
207
|
+
Arbitrary: (name: string) => _fern_api_csharp_codegen_lib_ast_types_Type.Primitive.AribitraryType;
|
|
208
|
+
HttpMethodExtensions: ast.ClassReference;
|
|
196
209
|
FormRequest: ast.ClassReference;
|
|
197
210
|
ClientOptions: ast.ClassReference;
|
|
198
211
|
RawClient: ast.ClassReference;
|
|
@@ -238,140 +251,175 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
238
251
|
CustomPagerClass: (itemType: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
239
252
|
Pager: (itemType: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
240
253
|
OffsetPager: ({ requestType, requestOptionsType, responseType, offsetType, stepType, itemType }: {
|
|
241
|
-
requestType: ast.Type
|
|
242
|
-
requestOptionsType: ast.Type
|
|
243
|
-
responseType: ast.Type
|
|
244
|
-
offsetType: ast.Type
|
|
245
|
-
stepType: ast.Type
|
|
246
|
-
itemType: ast.Type
|
|
254
|
+
requestType: ast.Type;
|
|
255
|
+
requestOptionsType: ast.Type;
|
|
256
|
+
responseType: ast.Type;
|
|
257
|
+
offsetType: ast.Type;
|
|
258
|
+
stepType: ast.Type;
|
|
259
|
+
itemType: ast.Type;
|
|
247
260
|
}) => ast.ClassReference;
|
|
248
261
|
CursorPager: ({ requestType, requestOptionsType, responseType, cursorType, itemType }: {
|
|
249
|
-
requestType: ast.Type
|
|
250
|
-
requestOptionsType: ast.Type
|
|
251
|
-
responseType: ast.Type
|
|
252
|
-
cursorType: ast.Type
|
|
253
|
-
itemType: ast.Type
|
|
262
|
+
requestType: ast.Type;
|
|
263
|
+
requestOptionsType: ast.Type;
|
|
264
|
+
responseType: ast.Type;
|
|
265
|
+
cursorType: ast.Type;
|
|
266
|
+
itemType: ast.Type;
|
|
254
267
|
}) => ast.ClassReference;
|
|
255
268
|
CollectionItemSerializer: (itemType: ast.ClassReference, serializer: ast.ClassReference) => ast.ClassReference;
|
|
256
269
|
OneOfSerializer: (oneof: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
257
270
|
AdditionalProperties: (genericType?: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
258
271
|
ReadOnlyAdditionalProperties: (genericType?: ast.Type | ast.ClassReference) => ast.ClassReference;
|
|
259
272
|
};
|
|
260
|
-
get model(): _fern_api_csharp_codegen_lib_context_model_navigator.ModelNavigator;
|
|
261
|
-
get csharp(): _fern_api_csharp_codegen.CSharp;
|
|
262
273
|
get System(): {
|
|
263
|
-
Action: (typeParameters?:
|
|
264
|
-
Func: (typeParameters?:
|
|
265
|
-
DateOnly:
|
|
266
|
-
DateTime:
|
|
267
|
-
Enum:
|
|
268
|
-
Exception:
|
|
269
|
-
ReadOnlyMemory: (type: ast.Type
|
|
270
|
-
Serializable:
|
|
271
|
-
String:
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
274
|
+
Action: (typeParameters?: ast.Type[]) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
275
|
+
Func: (typeParameters?: ast.Type[], returnType?: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
276
|
+
DateOnly: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
277
|
+
DateTime: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
278
|
+
Enum: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
279
|
+
Exception: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
280
|
+
ReadOnlyMemory: (type: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
281
|
+
Serializable: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
282
|
+
String: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
283
|
+
Type: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
284
|
+
TimeSpan: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
285
|
+
Uri: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
286
|
+
UriBuilder: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
275
287
|
Runtime: {
|
|
276
288
|
Serialization: {
|
|
277
|
-
EnumMember:
|
|
289
|
+
EnumMember: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
278
290
|
};
|
|
279
291
|
};
|
|
280
292
|
Collections: {
|
|
281
293
|
Generic: {
|
|
282
|
-
IAsyncEnumerable: (elementType?: ast.
|
|
283
|
-
IEnumerable: (elementType?: ast.
|
|
284
|
-
KeyValuePair: (keyType?: ast.
|
|
285
|
-
List: (elementType?: ast.
|
|
286
|
-
HashSet: (elementType?: ast.
|
|
287
|
-
Dictionary: (keyType?: ast.
|
|
288
|
-
IDictionary: (keyType: ast.Type
|
|
294
|
+
IAsyncEnumerable: (elementType?: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
295
|
+
IEnumerable: (elementType?: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
296
|
+
KeyValuePair: (keyType?: ast.Type, valueType?: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
297
|
+
List: (elementType?: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
298
|
+
HashSet: (elementType?: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
299
|
+
Dictionary: (keyType?: ast.Type, valueType?: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
300
|
+
IDictionary: (keyType: ast.Type, valueType: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
289
301
|
};
|
|
290
302
|
Linq: {
|
|
291
|
-
Enumerable:
|
|
303
|
+
Enumerable: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
292
304
|
};
|
|
293
305
|
};
|
|
294
306
|
Globalization: {
|
|
295
|
-
DateTimeStyles:
|
|
307
|
+
DateTimeStyles: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
296
308
|
};
|
|
297
309
|
Linq: {
|
|
298
|
-
Enumerable:
|
|
310
|
+
Enumerable: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
299
311
|
};
|
|
300
312
|
Net: {
|
|
301
313
|
Http: {
|
|
302
|
-
HttpClient:
|
|
303
|
-
HttpMethod:
|
|
304
|
-
HttpResponseHeaders:
|
|
314
|
+
HttpClient: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
315
|
+
HttpMethod: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
316
|
+
HttpResponseHeaders: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
305
317
|
};
|
|
306
318
|
ServerSentEvents: {
|
|
307
|
-
SseEvent:
|
|
308
|
-
SseParser:
|
|
319
|
+
SseEvent: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
320
|
+
SseParser: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
309
321
|
};
|
|
310
322
|
WebSockets: {
|
|
311
|
-
ClientWebSocketOptions:
|
|
323
|
+
ClientWebSocketOptions: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
312
324
|
};
|
|
313
325
|
};
|
|
314
326
|
IO: {
|
|
315
|
-
MemoryStream:
|
|
316
|
-
Stream:
|
|
317
|
-
StreamReader:
|
|
327
|
+
MemoryStream: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
328
|
+
Stream: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
329
|
+
StreamReader: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
318
330
|
};
|
|
319
331
|
Text: {
|
|
320
|
-
Encoding:
|
|
321
|
-
Encoding_UTF8:
|
|
332
|
+
Encoding: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
333
|
+
Encoding_UTF8: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
322
334
|
Json: {
|
|
323
|
-
JsonElement:
|
|
324
|
-
JsonDocument:
|
|
325
|
-
JsonException:
|
|
326
|
-
Utf8JsonReader:
|
|
327
|
-
JsonSerializerOptions:
|
|
328
|
-
JsonSerializer:
|
|
329
|
-
Utf8JsonWriter:
|
|
335
|
+
JsonElement: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
336
|
+
JsonDocument: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
337
|
+
JsonException: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
338
|
+
Utf8JsonReader: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
339
|
+
JsonSerializerOptions: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
340
|
+
JsonSerializer: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
341
|
+
Utf8JsonWriter: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
330
342
|
Nodes: {
|
|
331
|
-
JsonNode:
|
|
332
|
-
JsonObject:
|
|
343
|
+
JsonNode: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
344
|
+
JsonObject: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
333
345
|
};
|
|
334
346
|
Serialization: {
|
|
335
|
-
IJsonOnDeserialized:
|
|
336
|
-
IJsonOnSerializing:
|
|
337
|
-
JsonOnDeserializedAttribute:
|
|
338
|
-
JsonExtensionData:
|
|
339
|
-
JsonConverter: (typeToConvert?: ast.
|
|
340
|
-
JsonIgnore:
|
|
341
|
-
JsonPropertyName:
|
|
347
|
+
IJsonOnDeserialized: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
348
|
+
IJsonOnSerializing: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
349
|
+
JsonOnDeserializedAttribute: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
350
|
+
JsonExtensionData: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
351
|
+
JsonConverter: (typeToConvert?: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
352
|
+
JsonIgnore: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
353
|
+
JsonPropertyName: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
342
354
|
};
|
|
343
355
|
};
|
|
344
356
|
};
|
|
345
357
|
Threading: {
|
|
346
|
-
CancellationToken:
|
|
358
|
+
CancellationToken: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
347
359
|
Tasks: {
|
|
348
|
-
Task: (ofType?: ast.
|
|
360
|
+
Task: (ofType?: ast.Type) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
349
361
|
};
|
|
350
362
|
};
|
|
351
363
|
};
|
|
352
364
|
get NUnit(): {
|
|
353
365
|
Framework: {
|
|
354
|
-
TestFixture:
|
|
355
|
-
Test:
|
|
356
|
-
OneTimeTearDown:
|
|
357
|
-
OneTimeSetUp:
|
|
358
|
-
SetUpFixture:
|
|
366
|
+
TestFixture: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
367
|
+
Test: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
368
|
+
OneTimeTearDown: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
369
|
+
OneTimeSetUp: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
370
|
+
SetUpFixture: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
359
371
|
};
|
|
360
372
|
};
|
|
361
373
|
get OneOf(): {
|
|
362
|
-
OneOf: (generics?: ast.
|
|
363
|
-
OneOfBase: (generics?: ast.
|
|
374
|
+
OneOf: (generics?: ast.Type[]) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
375
|
+
OneOfBase: (generics?: ast.Type[]) => _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
364
376
|
};
|
|
365
377
|
get Google(): {
|
|
366
378
|
Protobuf: {
|
|
367
379
|
WellKnownTypes: {
|
|
368
|
-
Struct:
|
|
369
|
-
Value:
|
|
370
|
-
ListValue:
|
|
371
|
-
Timestamp:
|
|
380
|
+
Struct: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
381
|
+
Value: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
382
|
+
ListValue: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
383
|
+
Timestamp: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
372
384
|
};
|
|
373
385
|
};
|
|
374
386
|
};
|
|
387
|
+
get WireMock(): {
|
|
388
|
+
Server: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
389
|
+
WireMockServerSettings: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
390
|
+
WireMockConsoleLogger: _fern_api_csharp_codegen_lib_ast.ClassReference;
|
|
391
|
+
};
|
|
392
|
+
get Primitive(): {
|
|
393
|
+
string: _fern_api_csharp_codegen_lib_ast_types_Type.Primitive.String;
|
|
394
|
+
boolean: _fern_api_csharp_codegen_lib_ast_types_Type.Primitive.Boolean;
|
|
395
|
+
integer: _fern_api_csharp_codegen_lib_ast_types_Type.Primitive.Integer;
|
|
396
|
+
long: _fern_api_csharp_codegen_lib_ast_types_Type.Primitive.Long;
|
|
397
|
+
uint: _fern_api_csharp_codegen_lib_ast_types_Type.Primitive.Uint;
|
|
398
|
+
ulong: _fern_api_csharp_codegen_lib_ast_types_Type.Primitive.ULong;
|
|
399
|
+
float: _fern_api_csharp_codegen_lib_ast_types_Type.Primitive.Float;
|
|
400
|
+
double: _fern_api_csharp_codegen_lib_ast_types_Type.Primitive.Double;
|
|
401
|
+
object: _fern_api_csharp_codegen_lib_ast_types_Type.Primitive.Object;
|
|
402
|
+
};
|
|
403
|
+
get Value(): {
|
|
404
|
+
binary: _fern_api_csharp_codegen_lib_ast_types_Type.Value.Binary;
|
|
405
|
+
dateOnly: _fern_api_csharp_codegen_lib_ast_types_Type.Value.DateOnly;
|
|
406
|
+
dateTime: _fern_api_csharp_codegen_lib_ast_types_Type.Value.DateTime;
|
|
407
|
+
uuid: _fern_api_csharp_codegen_lib_ast_types_Type.Value.Uuid;
|
|
408
|
+
stringEnum: (value: ast.ClassReference) => _fern_api_csharp_codegen_lib_ast_types_Type.Value.StringEnum;
|
|
409
|
+
};
|
|
410
|
+
get Collection(): {
|
|
411
|
+
array: (value: ast.Type) => _fern_api_csharp_codegen_lib_ast_types_Type.Collection.Array;
|
|
412
|
+
listType: (value: ast.Type) => _fern_api_csharp_codegen_lib_ast_types_Type.Collection.ListType;
|
|
413
|
+
list: (value: ast.Type) => _fern_api_csharp_codegen_lib_ast_types_Type.Collection.List;
|
|
414
|
+
set: (value: ast.Type) => _fern_api_csharp_codegen_lib_ast_types_Type.Collection.Set;
|
|
415
|
+
map: (keyType: ast.Type, valueType: ast.Type, options?: {
|
|
416
|
+
dontSimplify?: boolean;
|
|
417
|
+
}) => _fern_api_csharp_codegen_lib_ast_types_Type.Collection.Map;
|
|
418
|
+
idictionary: (keyType: ast.Type, valueType: ast.Type, options?: {
|
|
419
|
+
dontSimplify?: boolean;
|
|
420
|
+
}) => _fern_api_csharp_codegen_lib_ast_types_Type.Collection.IDictionary;
|
|
421
|
+
keyValuePair: (keyType: ast.Type, valueType: ast.Type) => _fern_api_csharp_codegen_lib_ast_types_Type.Collection.KeyValuePair;
|
|
422
|
+
};
|
|
375
423
|
constructor({ ir, config, options, generation }: {
|
|
376
424
|
ir: FernIr.dynamic.DynamicIntermediateRepresentation;
|
|
377
425
|
config: FernGeneratorExec.GeneratorConfig;
|
|
@@ -379,7 +427,7 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
379
427
|
generation?: Generation;
|
|
380
428
|
});
|
|
381
429
|
clone(): DynamicSnippetsGeneratorContext;
|
|
382
|
-
getFileParameterForString(str: string): ast.
|
|
430
|
+
getFileParameterForString(str: string): ast.Literal;
|
|
383
431
|
getMemoryStreamForString(str: string): ast.ClassInstantiation;
|
|
384
432
|
getClassName(name: FernIr.Name): string;
|
|
385
433
|
getParameterName(name: FernIr.Name): string;
|
|
@@ -392,4 +440,4 @@ declare class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGen
|
|
|
392
440
|
precalculate(requests: Partial<FernIr.dynamic.EndpointSnippetRequest>[]): void;
|
|
393
441
|
}
|
|
394
442
|
|
|
395
|
-
export { DynamicSnippetsGeneratorContext as D, type FilePropertyInfo as F,
|
|
443
|
+
export { DynamicSnippetsGeneratorContext as D, type FilePropertyInfo as F, DynamicLiteralMapper as a, DynamicTypeMapper as b, FilePropertyMapper as c };
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { Options } from '@fern-api/browser-compatible-base-generator';
|
|
2
|
-
import { WithGeneration } from '@fern-api/csharp-codegen';
|
|
2
|
+
import { WithGeneration, ast } from '@fern-api/csharp-codegen';
|
|
3
3
|
import { FernIr } from '@fern-api/dynamic-ir-sdk';
|
|
4
|
-
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-
|
|
4
|
+
import { D as DynamicSnippetsGeneratorContext } from './DynamicSnippetsGeneratorContext-Dz9RlVgp.js';
|
|
5
|
+
import '@fern-api/csharp-codegen/lib/ast';
|
|
6
|
+
import '@fern-api/csharp-codegen/lib/ast/types/Type';
|
|
5
7
|
import '@fern-api/csharp-codegen/lib/context/model-navigator';
|
|
6
|
-
import '@fern-api/csharp-codegen/lib/context/extern';
|
|
7
8
|
|
|
8
9
|
declare class EndpointSnippetGenerator extends WithGeneration {
|
|
9
10
|
private context;
|
|
@@ -20,6 +21,11 @@ declare class EndpointSnippetGenerator extends WithGeneration {
|
|
|
20
21
|
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
21
22
|
options: Options;
|
|
22
23
|
}): string;
|
|
24
|
+
generateSnippetAst({ endpoint, request, options }: {
|
|
25
|
+
endpoint: FernIr.dynamic.Endpoint;
|
|
26
|
+
request: FernIr.dynamic.EndpointSnippetRequest;
|
|
27
|
+
options?: Options;
|
|
28
|
+
}): Promise<ast.AstNode>;
|
|
23
29
|
private buildCodeBlock;
|
|
24
30
|
private buildFullCodeBlock;
|
|
25
31
|
private constructClient;
|
|
@@ -44,7 +50,7 @@ declare class EndpointSnippetGenerator extends WithGeneration {
|
|
|
44
50
|
private getInlinedRequestBodyPropertyConstructorFields;
|
|
45
51
|
private getFileUploadRequestBodyConstructorFields;
|
|
46
52
|
private getReferencedRequestBodyPropertyConstructorField;
|
|
47
|
-
private
|
|
53
|
+
private getReferencedRequestBodyPropertyLiteral;
|
|
48
54
|
private getMethodArgsForBodyRequest;
|
|
49
55
|
private getBodyRequestArg;
|
|
50
56
|
private getBytesBodyRequestArg;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-ONI3ZPJV.js";import"./chunk-VBCDESX3.js";import"./chunk-RHB5YSP4.js";export{a as EndpointSnippetGenerator};
|
|
2
2
|
//# sourceMappingURL=EndpointSnippetGenerator.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as c}from"./chunk-BHXOAZDW.js";import{c as a}from"./chunk-VBCDESX3.js";import{a as p}from"./chunk-JXSLTUG5.js";import{a as m}from"./chunk-54PJL32I.js";import{e as r,j as o}from"./chunk-RHB5YSP4.js";var l=class g extends a{constructor({ir:e,config:t,options:n,generation:i}){super({ir:e,config:t,options:n});r(this,"ir");r(this,"dynamicTypeMapper");r(this,"dynamicLiteralMapper");r(this,"filePropertyMapper");r(this,"generation");this.ir=e,this.generation=i!=null?i:new o(e,t.workspaceName,t.customConfig!=null?t.customConfig:{},t),this.dynamicTypeMapper=new p({context:this}),this.dynamicLiteralMapper=new c({context:this}),this.filePropertyMapper=new m({context:this})}get namespaces(){return this.generation.namespaces}get registry(){return this.generation.registry}get settings(){return this.generation.settings}get constants(){return this.generation.constants}get names(){return this.generation.names}get model(){return this.generation.model}get format(){return this.generation.format}get csharp(){return this.generation.csharp}get Types(){return this.generation.Types}get System(){return this.generation.extern.System}get NUnit(){return this.generation.extern.NUnit}get OneOf(){return this.generation.extern.OneOf}get Google(){return this.generation.extern.Google}get WireMock(){return this.generation.extern.WireMock}get Primitive(){return this.generation.Primitive}get Value(){return this.generation.Value}get Collection(){return this.generation.Collection}clone(){return new g({ir:this.ir,config:this.config,options:this.options,generation:this.generation})}getFileParameterForString(e){return this.csharp.Literal.reference(this.csharp.instantiateClass({classReference:this.Types.FileParameter,arguments_:[],properties:[{name:"Stream",value:this.getMemoryStreamForString(e)}],multiline:!0}))}getMemoryStreamForString(e){return this.System.IO.MemoryStream.new({arguments_:[this.csharp.invokeMethod({on:this.System.Text.Encoding_UTF8,method:"GetBytes",arguments_:[this.csharp.Literal.string(e)]})]})}getClassName(e){return e.pascalCase.safeName}getParameterName(e){return e.camelCase.safeName}getPropertyName(e){return e.pascalCase.safeName}getMethodName(e){return`${e.pascalCase.safeName}Async`}getNamespace(e,t){let n=this.getNamespaceSegments(e);return n=t!=null?[...n,t]:n,[this.namespaces.root,...n].join(".")}getEnvironmentTypeReferenceFromID(e){let t=this.resolveEnvironmentName(e);if(t!=null)return this.getEnvironmentClassReferenceForEnumName(t)}getEnvironmentClassReferenceForEnumName(e){return this.csharp.classReference({name:`${this.generation.Types.Environments.name}.${this.getClassName(e)}`,namespace:this.namespaces.root})}getNamespaceSegments(e){return(this.settings.explicitNamespaces?e.allParts:e.packagePath).map(n=>n.pascalCase.safeName)}precalculate(e){this.generation.initialize(),this.System.Collections.Generic.KeyValuePair(),this.System.Collections.Generic.IEnumerable(),this.System.Collections.Generic.IAsyncEnumerable(),this.System.Collections.Generic.HashSet(),this.System.Collections.Generic.List(),this.System.Collections.Generic.Dictionary(),this.System.Threading.Tasks.Task(),Object.entries(this.ir.types).sort((t,n)=>t[0].length-n[0].length).forEach(([t,n])=>{this.dynamicTypeMapper.convertToClassReference(n)});for(let[t,n]of e.entries())if(this.csharp.classReference({origin:this.model.staticExplicit(`Example${t}`),namespace:"Usage"}),n.endpoint){let i=this.resolveEndpointLocation(n.endpoint);for(let s of i)switch(s.request.type){case"inlined":this.csharp.classReference({origin:s.request.declaration.name,namespace:this.getNamespace(s.request.declaration.fernFilepath)});break;case"body":break}}this.generation.Types.ClientOptions,this.generation.Types.RootClient,this.csharp.freezeClassReferences()}};export{l as a};
|
|
2
|
+
//# sourceMappingURL=chunk-3AKTWPYH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/DynamicSnippetsGeneratorContext.ts"],"sourcesContent":["import {\n AbstractDynamicSnippetsGeneratorContext,\n FernGeneratorExec,\n Options\n} from \"@fern-api/browser-compatible-base-generator\";\nimport { ast, CsharpConfigSchema, Generation } from \"@fern-api/csharp-codegen\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { DynamicLiteralMapper } from \"./DynamicLiteralMapper\";\nimport { DynamicTypeMapper } from \"./DynamicTypeMapper\";\nimport { FilePropertyMapper } from \"./FilePropertyMapper\";\n\nexport class DynamicSnippetsGeneratorContext extends AbstractDynamicSnippetsGeneratorContext {\n public ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n public dynamicTypeMapper: DynamicTypeMapper;\n public dynamicLiteralMapper: DynamicLiteralMapper;\n public filePropertyMapper: FilePropertyMapper;\n\n public readonly generation: Generation;\n\n public get namespaces() {\n return this.generation.namespaces;\n }\n public get registry() {\n return this.generation.registry;\n }\n public get settings() {\n return this.generation.settings;\n }\n public get constants() {\n return this.generation.constants;\n }\n public get names() {\n return this.generation.names;\n }\n public get model() {\n return this.generation.model;\n }\n public get format() {\n return this.generation.format;\n }\n public get csharp() {\n return this.generation.csharp;\n }\n public get Types() {\n return this.generation.Types;\n }\n public get System() {\n return this.generation.extern.System;\n }\n public get NUnit() {\n return this.generation.extern.NUnit;\n }\n public get OneOf() {\n return this.generation.extern.OneOf;\n }\n public get Google() {\n return this.generation.extern.Google;\n }\n public get WireMock() {\n return this.generation.extern.WireMock;\n }\n public get Primitive() {\n return this.generation.Primitive;\n }\n public get Value() {\n return this.generation.Value;\n }\n public get Collection() {\n return this.generation.Collection;\n }\n\n constructor({\n ir,\n config,\n options,\n generation\n }: {\n ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n config: FernGeneratorExec.GeneratorConfig;\n options?: Options;\n generation?: Generation;\n }) {\n super({ ir, config, options });\n this.ir = ir;\n\n this.generation =\n generation ??\n new Generation(\n ir,\n config.workspaceName,\n config.customConfig != null ? (config.customConfig as CsharpConfigSchema) : ({} as CsharpConfigSchema),\n config\n );\n\n this.dynamicTypeMapper = new DynamicTypeMapper({ context: this });\n this.dynamicLiteralMapper = new DynamicLiteralMapper({ context: this });\n this.filePropertyMapper = new FilePropertyMapper({ context: this });\n }\n\n public clone(): DynamicSnippetsGeneratorContext {\n return new DynamicSnippetsGeneratorContext({\n ir: this.ir,\n config: this.config,\n options: this.options,\n generation: this.generation\n });\n }\n\n public getFileParameterForString(str: string): ast.Literal {\n return this.csharp.Literal.reference(\n this.csharp.instantiateClass({\n classReference: this.Types.FileParameter,\n arguments_: [],\n properties: [\n {\n name: \"Stream\",\n value: this.getMemoryStreamForString(str)\n }\n ],\n multiline: true\n })\n );\n }\n\n public getMemoryStreamForString(str: string): ast.ClassInstantiation {\n return this.System.IO.MemoryStream.new({\n arguments_: [\n this.csharp.invokeMethod({\n on: this.System.Text.Encoding_UTF8,\n method: \"GetBytes\",\n arguments_: [this.csharp.Literal.string(str)]\n })\n ]\n });\n }\n\n public getClassName(name: FernIr.Name): string {\n return name.pascalCase.safeName;\n }\n\n public getParameterName(name: FernIr.Name): string {\n return name.camelCase.safeName;\n }\n\n public getPropertyName(name: FernIr.Name): string {\n return name.pascalCase.safeName;\n }\n\n public getMethodName(name: FernIr.Name): string {\n return `${name.pascalCase.safeName}Async`;\n }\n\n public getNamespace(fernFilepath: FernIr.dynamic.FernFilepath, suffix?: string): string {\n let parts = this.getNamespaceSegments(fernFilepath);\n parts = suffix != null ? [...parts, suffix] : parts;\n return [this.namespaces.root, ...parts].join(\".\");\n }\n\n public getEnvironmentTypeReferenceFromID(environmentID: string): ast.ClassReference | undefined {\n const environmentName = this.resolveEnvironmentName(environmentID);\n if (environmentName == null) {\n return undefined;\n }\n return this.getEnvironmentClassReferenceForEnumName(environmentName);\n }\n\n private getEnvironmentClassReferenceForEnumName(name: FernIr.Name): ast.ClassReference {\n return this.csharp.classReference({\n name: `${this.generation.Types.Environments.name}.${this.getClassName(name)}`,\n namespace: this.namespaces.root\n });\n }\n\n private getNamespaceSegments(fernFilepath: FernIr.dynamic.FernFilepath): string[] {\n const segments = this.settings.explicitNamespaces ? fernFilepath.allParts : fernFilepath.packagePath;\n return segments.map((segment) => segment.pascalCase.safeName);\n }\n\n public precalculate(requests: Partial<FernIr.dynamic.EndpointSnippetRequest>[]): void {\n this.generation.initialize();\n this.System.Collections.Generic.KeyValuePair();\n this.System.Collections.Generic.IEnumerable();\n this.System.Collections.Generic.IAsyncEnumerable();\n this.System.Collections.Generic.HashSet();\n this.System.Collections.Generic.List();\n this.System.Collections.Generic.Dictionary();\n this.System.Threading.Tasks.Task();\n\n // generate the names for the model types\n Object.entries(this.ir.types)\n .sort((a, b) => {\n // sort by shortest key length\n return a[0].length - b[0].length;\n })\n .forEach(([typeId, type]) => {\n this.dynamicTypeMapper.convertToClassReference(type);\n });\n\n for (const [idx, request] of requests.entries()) {\n // generate the class names for the examples\n\n this.csharp.classReference({\n origin: this.model.staticExplicit(`Example${idx}`),\n namespace: \"Usage\"\n });\n\n if (request.endpoint) {\n const endpoints = this.resolveEndpointLocation(request.endpoint);\n for (const endpoint of endpoints) {\n switch (endpoint.request.type) {\n case \"inlined\":\n this.csharp.classReference({\n origin: endpoint.request.declaration.name,\n namespace: this.getNamespace(endpoint.request.declaration.fernFilepath)\n });\n\n break;\n\n case \"body\":\n break;\n }\n }\n }\n }\n\n this.generation.Types.ClientOptions;\n this.generation.Types.RootClient;\n\n // after generating the names for everything, freeze the class references\n this.csharp.freezeClassReferences();\n }\n}\n"],"mappings":"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","names":["DynamicSnippetsGeneratorContext","_DynamicSnippetsGeneratorContext","AbstractDynamicSnippetsGeneratorContext","ir","config","options","generation","__publicField","Generation","DynamicTypeMapper","DynamicLiteralMapper","FilePropertyMapper","str","name","fernFilepath","suffix","parts","environmentID","environmentName","segment","requests","a","b","typeId","type","idx","request","endpoints","endpoint"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as p}from"./chunk-ONI3ZPJV.js";import{a as r}from"./chunk-3AKTWPYH.js";import{a as t}from"./chunk-VBCDESX3.js";var i=class extends t{constructor({ir:e,config:n,options:o={}}){super(new r({ir:e,config:n,options:o}))}precalculate(e){this.context.precalculate(e)}async generate(e,n={}){return super.generate(e,n)}generateSync(e,n={}){return super.generateSync(e,n)}async generateSnippetAst(e){return super.generateSnippetAst(e)}createSnippetGenerator(e){return new p({context:e})}};export{i as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4A2AR7IK.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/DynamicSnippetsGenerator.ts"],"sourcesContent":["import {\n AbstractAstNode,\n AbstractDynamicSnippetsGenerator,\n FernGeneratorExec,\n Options\n} from \"@fern-api/browser-compatible-base-generator\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\nimport { DynamicSnippetsGeneratorContext } from \"./context/DynamicSnippetsGeneratorContext\";\nimport { EndpointSnippetGenerator } from \"./EndpointSnippetGenerator\";\n\nexport class DynamicSnippetsGenerator extends AbstractDynamicSnippetsGenerator<\n DynamicSnippetsGeneratorContext,\n EndpointSnippetGenerator\n> {\n constructor({\n ir,\n config,\n options = {}\n }: {\n ir: FernIr.dynamic.DynamicIntermediateRepresentation;\n config: FernGeneratorExec.GeneratorConfig;\n options?: Options;\n }) {\n super(new DynamicSnippetsGeneratorContext({ ir, config, options }));\n }\n\n public precalculate(requests: FernIr.dynamic.EndpointSnippetRequest[]): void {\n this.context.precalculate(requests);\n }\n\n public override async generate(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options: Options = {}\n ): Promise<FernIr.dynamic.EndpointSnippetResponse> {\n return super.generate(request, options);\n }\n\n public override generateSync(\n request: FernIr.dynamic.EndpointSnippetRequest,\n options: Options = {}\n ): FernIr.dynamic.EndpointSnippetResponse {\n return super.generateSync(request, options);\n }\n\n public override async generateSnippetAst(request: FernIr.dynamic.EndpointSnippetRequest): Promise<AbstractAstNode> {\n return super.generateSnippetAst(request);\n }\n\n protected createSnippetGenerator(context: DynamicSnippetsGeneratorContext): EndpointSnippetGenerator {\n return new EndpointSnippetGenerator({ context });\n }\n}\n"],"mappings":"wHAUO,IAAMA,EAAN,cAAuCC,CAG5C,CACE,YAAY,CACR,GAAAC,EACA,OAAAC,EACA,QAAAC,EAAU,CAAC,CACf,EAIG,CACC,MAAM,IAAIC,EAAgC,CAAE,GAAAH,EAAI,OAAAC,EAAQ,QAAAC,CAAQ,CAAC,CAAC,CACtE,CAEO,aAAaE,EAAyD,CACzE,KAAK,QAAQ,aAAaA,CAAQ,CACtC,CAEA,MAAsB,SAClBC,EACAH,EAAmB,CAAC,EAC2B,CAC/C,OAAO,MAAM,SAASG,EAASH,CAAO,CAC1C,CAEgB,aACZG,EACAH,EAAmB,CAAC,EACkB,CACtC,OAAO,MAAM,aAAaG,EAASH,CAAO,CAC9C,CAEA,MAAsB,mBAAmBG,EAA0E,CAC/G,OAAO,MAAM,mBAAmBA,CAAO,CAC3C,CAEU,uBAAuBC,EAAoE,CACjG,OAAO,IAAIC,EAAyB,CAAE,QAAAD,CAAQ,CAAC,CACnD,CACJ","names":["DynamicSnippetsGenerator","AbstractDynamicSnippetsGenerator","ir","config","options","DynamicSnippetsGeneratorContext","requests","request","context","EndpointSnippetGenerator"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{e as s,f as l,h as n,k as c}from"./chunk-RHB5YSP4.js";var p=class extends c{constructor({context:a}){super(a.generation);s(this,"context");this.context=a}getFilePropertyInfo({body:a,value:i}){var o;let t={fileFields:[],bodyPropertyFields:[]},r=(o=this.context.getRecord(i))!=null?o:{};for(let e of a.properties)switch(e.type){case"file":n.Record.missingKey(r,e.wireValue)&&(r[e.wireValue]="[bytes]"),t.fileFields.push({name:this.context.getPropertyName(e.name),value:this.getSingleFileProperty({property:e,record:r})});break;case"fileArray":n.Record.missingKey(r,e.wireValue)&&(r[e.wireValue]=["[bytes]"]),t.fileFields.push({name:this.context.getPropertyName(e.name),value:this.getArrayFileProperty({property:e,record:r})});break;case"bodyProperty":if(n.Record.missingKey(r,e.name.wireValue))switch(e.typeReference.type){case"optional":break;case"primitive":{switch(e.typeReference.value.toLowerCase()){case"integer":{r[e.name.wireValue]=123;break}case"string":{r[e.name.wireValue]="[string]";break}case"boolean":{r[e.name.wireValue]=!0;break}case"double":{r[e.name.wireValue]=123.456;break}case"float":{r[e.name.wireValue]=123.456;break}case"long":{r[e.name.wireValue]=123456789;break}case"uint":{r[e.name.wireValue]=123;break}case"uint64":{r[e.name.wireValue]=12345;break}case"date":{r[e.name.wireValue]=new Date(2021,1,1);break}case"datetime":{r[e.name.wireValue]=new Date(2021,1,1,12,0,0);break}case"uuid":{r[e.name.wireValue]="123e4567-e89b-12d3-a456-426614174000";break}case"base64":{r[e.name.wireValue]="SGVsbG8gd29ybGQh";break}case"biginteger":{r[e.name.wireValue]="12345678901234567890";break}}break}default:break}t.bodyPropertyFields.push({name:this.context.getPropertyName(e.name.name),value:this.getBodyProperty({property:e,record:r})});break;default:l(e)}return t}getSingleFileProperty({property:a,record:i}){let t=this.context.getSingleFileValue({property:a,record:i});return t==null?this.csharp.Literal.nop():this.context.getFileParameterForString(t)}getArrayFileProperty({property:a,record:i}){let t=this.context.getFileArrayValues({property:a,record:i});return t==null?this.csharp.Literal.nop():this.csharp.Literal.list({valueType:this.Types.FileParameter,values:t.map(r=>this.context.getFileParameterForString(r))})}getBodyProperty({property:a,record:i}){let t=i[a.name.wireValue];return t==null?this.csharp.Literal.nop():this.context.dynamicLiteralMapper.convert({typeReference:a.typeReference,value:t})}};export{p as a};
|
|
2
|
+
//# sourceMappingURL=chunk-54PJL32I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/context/FilePropertyMapper.ts"],"sourcesContent":["import { assertNever } from \"@fern-api/core-utils\";\nimport { ast, is, WithGeneration } from \"@fern-api/csharp-codegen\";\nimport { FernIr } from \"@fern-api/dynamic-ir-sdk\";\n\nimport { DynamicSnippetsGeneratorContext } from \"./DynamicSnippetsGeneratorContext\";\n\nexport interface FilePropertyInfo {\n fileFields: ast.ConstructorField[];\n bodyPropertyFields: ast.ConstructorField[];\n}\n\nexport class FilePropertyMapper extends WithGeneration {\n private context: DynamicSnippetsGeneratorContext;\n\n constructor({ context }: { context: DynamicSnippetsGeneratorContext }) {\n super(context.generation);\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 // if we don't have a record, we can fake some data for it.\n if (is.Record.missingKey(record, property.wireValue)) {\n record[property.wireValue] = \"[bytes]\";\n }\n result.fileFields.push({\n name: this.context.getPropertyName(property.name),\n value: this.getSingleFileProperty({ property, record })\n });\n break;\n case \"fileArray\":\n // if we don't have a record, we can fake some data for it.\n if (is.Record.missingKey(record, property.wireValue)) {\n record[property.wireValue] = [\"[bytes]\"];\n }\n result.fileFields.push({\n name: this.context.getPropertyName(property.name),\n value: this.getArrayFileProperty({ property, record })\n });\n break;\n case \"bodyProperty\":\n // if we don't have a record, we can try fake some data for it.\n if (is.Record.missingKey(record, property.name.wireValue)) {\n switch (property.typeReference.type) {\n case \"optional\": {\n // ignore missing optional values\n break;\n }\n case \"primitive\": {\n // for primitives, we can return a sample value.\n switch (property.typeReference.value.toLowerCase()) {\n case \"integer\": {\n record[property.name.wireValue] = 123;\n break;\n }\n case \"string\": {\n record[property.name.wireValue] = \"[string]\";\n break;\n }\n case \"boolean\": {\n record[property.name.wireValue] = true;\n break;\n }\n case \"double\": {\n record[property.name.wireValue] = 123.456;\n break;\n }\n case \"float\": {\n record[property.name.wireValue] = 123.456;\n break;\n }\n case \"long\": {\n record[property.name.wireValue] = 123456789;\n break;\n }\n case \"uint\": {\n record[property.name.wireValue] = 123;\n break;\n }\n case \"uint64\": {\n record[property.name.wireValue] = 12345;\n break;\n }\n case \"date\": {\n record[property.name.wireValue] = new Date(2021, 1, 1);\n break;\n }\n case \"datetime\": {\n record[property.name.wireValue] = new Date(2021, 1, 1, 12, 0, 0);\n break;\n }\n case \"uuid\": {\n record[property.name.wireValue] = \"123e4567-e89b-12d3-a456-426614174000\";\n break;\n }\n case \"base64\": {\n record[property.name.wireValue] = \"SGVsbG8gd29ybGQh\";\n break;\n }\n case \"biginteger\": {\n record[property.name.wireValue] = \"12345678901234567890\";\n break;\n }\n }\n break;\n }\n\n default: {\n // todo: optionally synthesize a value for a other types in the future\n break;\n }\n }\n }\n result.bodyPropertyFields.push({\n name: this.context.getPropertyName(property.name.name),\n value: this.getBodyProperty({ property, record })\n });\n break;\n default:\n assertNever(property);\n }\n }\n return result;\n }\n\n private getSingleFileProperty({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.File_;\n record: Record<string, unknown>;\n }): ast.Literal {\n const fileValue = this.context.getSingleFileValue({ property, record });\n if (fileValue == null) {\n return this.csharp.Literal.nop();\n }\n return this.context.getFileParameterForString(fileValue);\n }\n\n private getArrayFileProperty({\n property,\n record\n }: {\n property: FernIr.dynamic.FileUploadRequestBodyProperty.FileArray;\n record: Record<string, unknown>;\n }): ast.Literal {\n const fileValues = this.context.getFileArrayValues({ property, record });\n if (fileValues == null) {\n return this.csharp.Literal.nop();\n }\n return this.csharp.Literal.list({\n valueType: this.Types.FileParameter,\n values: fileValues.map((value) => this.context.getFileParameterForString(value))\n });\n }\n\n private getBodyProperty({\n property,\n record\n }: {\n property: FernIr.dynamic.NamedParameter;\n record: Record<string, unknown>;\n }): ast.Literal {\n const bodyPropertyValue = record[property.name.wireValue];\n if (bodyPropertyValue == null) {\n return this.csharp.Literal.nop();\n }\n return this.context.dynamicLiteralMapper.convert({\n typeReference: property.typeReference,\n value: bodyPropertyValue\n });\n }\n}\n"],"mappings":"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","names":["FilePropertyMapper","WithGeneration","context","__publicField","body","value","_a","result","record","property","is","assertNever","fileValue","fileValues","bodyPropertyValue"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{b as a}from"./chunk-VBCDESX3.js";import{e as u,f as c,k as p}from"./chunk-RHB5YSP4.js";var h=class extends p{constructor({context:e}){super(e.generation);u(this,"context");this.context=e}convert(e){if(e.value===null)return this.context.isNullable(e.typeReference)?this.csharp.Literal.null():(this.context.errors.add({severity:a.Critical,message:"Expected non-null value, but got null"}),this.csharp.Literal.nop());if(e.value===void 0&&!e.fallbackToDefault)return this.csharp.Literal.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.Literal.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.Literal.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.Literal.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.Literal.nop():this.csharp.Literal.boolean(t)}case"string":{let t=this.context.getValueAsString({value:r});return t==null?i?this.Primitive.string.getDeterminsticDefault(i):this.csharp.Literal.nop():this.csharp.Literal.string(t)}default:c(e)}}convertSet({set:e,value:r,fallbackToDefault:i}){return Array.isArray(r)?this.csharp.Literal.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.Literal.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.Literal.nop()):this.csharp.Literal.dictionary({keyType:this.context.dynamicTypeMapper.convert({typeReference:e.key}),valueType:e.value.type==="unknown"?this.context.dynamicTypeMapper.convert({typeReference:e.value}).asOptional():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.Literal.nop();let s=n.singleDiscriminatedUnionType,o=this.getBaseProperties({discriminatedUnionTypeInstance:n,singleDiscriminatedUnionType:s});switch(s.type){case"samePropertiesAsObject":{let l=this.context.resolveNamedType({typeId:s.typeId});return l==null?this.csharp.Literal.nop():this.instantiateUnionWithBaseProperties({classReference:t,baseProperties:o,arguments_:[this.convertNamed({named:l,value:n.value})]})}case"singleProperty":{if(this.context.getRecord(n.value)==null)return this.csharp.Literal.nop();try{let m=["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:o,arguments_:[this.csharp.instantiateClass({classReference:this.csharp.classReference({name:m,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:o,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.Literal.reference(t):this.csharp.Literal.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.Literal.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.Literal.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.Literal.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.Literal.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.Literal.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.Literal.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.Primitive.integer.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.integer(n)}case"LONG":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.Primitive.long.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.long(n)}case"UINT":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.Primitive.uint.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.uint(n)}case"UINT_64":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.Primitive.ulong.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.ulong(n)}case"FLOAT":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.Primitive.float.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.float(n)}case"DOUBLE":{let n=this.getValueAsNumber({value:r,as:i});return n==null?t?this.Primitive.double.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.double(n)}case"BOOLEAN":{let n=this.getValueAsBoolean({value:r,as:i});return n==null?t?this.Primitive.boolean.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.boolean(n)}case"STRING":{let n=this.context.getValueAsString({value:r});return n==null?t?this.Primitive.string.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.string(n)}case"DATE":{let n=this.context.getValueAsString({value:r});return n==null?t?this.Value.dateOnly.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.date(n)}case"DATE_TIME":{let n=this.context.getValueAsString({value:r});return n==null?t?this.Value.dateTime.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.datetime(n)}case"UUID":{let n=this.context.getValueAsString({value:r});return n==null?t?this.Primitive.string.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.string(n)}case"BASE_64":{let n=this.context.getValueAsString({value:r});return n==null?t?this.Primitive.string.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.string(n)}case"BIG_INTEGER":{let n=this.context.getValueAsString({value:r});return n==null?t?this.Primitive.string.getDeterminsticDefault(t):this.csharp.Literal.nop():this.csharp.Literal.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-BHXOAZDW.js.map
|