@typespec/http-server-csharp 0.58.0-alpha.28-dev.4 → 0.58.0-alpha.29-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cli/cli.js +118 -154
- package/dist/src/cli/cli.js.map +1 -1
- package/dist/src/components/controller-action/controller-action.d.ts +16 -0
- package/dist/src/components/controller-action/controller-action.d.ts.map +1 -0
- package/dist/src/components/controller-action/controller-action.js +251 -0
- package/dist/src/components/controller-action/controller-action.js.map +1 -0
- package/dist/src/components/controller-action/controller-action.test.d.ts +2 -0
- package/dist/src/components/controller-action/controller-action.test.d.ts.map +1 -0
- package/dist/src/components/controller-action/controller-action.test.js +106 -0
- package/dist/src/components/controller-action/controller-action.test.js.map +1 -0
- package/dist/src/components/controller-action/parameter-binding.d.ts +17 -0
- package/dist/src/components/controller-action/parameter-binding.d.ts.map +1 -0
- package/dist/src/components/controller-action/parameter-binding.js +77 -0
- package/dist/src/components/controller-action/parameter-binding.js.map +1 -0
- package/dist/src/components/controller-action/response-analysis.d.ts +10 -0
- package/dist/src/components/controller-action/response-analysis.d.ts.map +1 -0
- package/dist/src/components/controller-action/response-analysis.js +61 -0
- package/dist/src/components/controller-action/response-analysis.js.map +1 -0
- package/dist/src/components/controllers/controllers.d.ts +18 -0
- package/dist/src/components/controllers/controllers.d.ts.map +1 -0
- package/dist/src/components/controllers/controllers.js +64 -0
- package/dist/src/components/controllers/controllers.js.map +1 -0
- package/dist/src/components/controllers/controllers.test.d.ts +2 -0
- package/dist/src/components/controllers/controllers.test.d.ts.map +1 -0
- package/dist/src/components/controllers/controllers.test.js +84 -0
- package/dist/src/components/controllers/controllers.test.js.map +1 -0
- package/dist/src/components/csharp-file.d.ts +15 -0
- package/dist/src/components/csharp-file.d.ts.map +1 -0
- package/dist/src/components/csharp-file.js +28 -0
- package/dist/src/components/csharp-file.js.map +1 -0
- package/dist/src/components/enums/enums.d.ts +28 -0
- package/dist/src/components/enums/enums.d.ts.map +1 -0
- package/dist/src/components/enums/enums.js +158 -0
- package/dist/src/components/enums/enums.js.map +1 -0
- package/dist/src/components/enums/enums.test.d.ts +2 -0
- package/dist/src/components/enums/enums.test.d.ts.map +1 -0
- package/dist/src/components/enums/enums.test.js +112 -0
- package/dist/src/components/enums/enums.test.js.map +1 -0
- package/dist/src/components/interfaces/interfaces.d.ts +17 -0
- package/dist/src/components/interfaces/interfaces.d.ts.map +1 -0
- package/dist/src/components/interfaces/interfaces.js +153 -0
- package/dist/src/components/interfaces/interfaces.js.map +1 -0
- package/dist/src/components/interfaces/interfaces.test.d.ts +2 -0
- package/dist/src/components/interfaces/interfaces.test.d.ts.map +1 -0
- package/dist/src/components/interfaces/interfaces.test.js +76 -0
- package/dist/src/components/interfaces/interfaces.test.js.map +1 -0
- package/dist/src/components/models/anonymous-models.d.ts +9 -0
- package/dist/src/components/models/anonymous-models.d.ts.map +1 -0
- package/dist/src/components/models/anonymous-models.js +37 -0
- package/dist/src/components/models/anonymous-models.js.map +1 -0
- package/dist/src/components/models/error-models.d.ts +5 -0
- package/dist/src/components/models/error-models.d.ts.map +1 -0
- package/dist/src/components/models/error-models.js +84 -0
- package/dist/src/components/models/error-models.js.map +1 -0
- package/dist/src/components/models/model-helpers.d.ts +40 -0
- package/dist/src/components/models/model-helpers.d.ts.map +1 -0
- package/dist/src/components/models/model-helpers.js +239 -0
- package/dist/src/components/models/model-helpers.js.map +1 -0
- package/dist/src/components/models/models.d.ts +15 -0
- package/dist/src/components/models/models.d.ts.map +1 -0
- package/dist/src/components/models/models.js +234 -0
- package/dist/src/components/models/models.js.map +1 -0
- package/dist/src/components/models/models.test.d.ts +2 -0
- package/dist/src/components/models/models.test.d.ts.map +1 -0
- package/dist/src/components/models/models.test.js +151 -0
- package/dist/src/components/models/models.test.js.map +1 -0
- package/dist/src/components/project/csproj.d.ts +12 -0
- package/dist/src/components/project/csproj.d.ts.map +1 -0
- package/dist/src/components/project/csproj.js +35 -0
- package/dist/src/components/project/csproj.js.map +1 -0
- package/dist/src/components/project/csproj.test.d.ts +2 -0
- package/dist/src/components/project/csproj.test.d.ts.map +1 -0
- package/dist/src/components/project/csproj.test.js +42 -0
- package/dist/src/components/project/csproj.test.js.map +1 -0
- package/dist/src/components/project/launch-settings.d.ts +16 -0
- package/dist/src/components/project/launch-settings.d.ts.map +1 -0
- package/dist/src/components/project/launch-settings.js +73 -0
- package/dist/src/components/project/launch-settings.js.map +1 -0
- package/dist/src/components/project/launch-settings.test.d.ts +2 -0
- package/dist/src/components/project/launch-settings.test.d.ts.map +1 -0
- package/dist/src/components/project/launch-settings.test.js +48 -0
- package/dist/src/components/project/launch-settings.test.js.map +1 -0
- package/dist/src/components/project/program.d.ts +14 -0
- package/dist/src/components/project/program.d.ts.map +1 -0
- package/dist/src/components/project/program.js +75 -0
- package/dist/src/components/project/program.js.map +1 -0
- package/dist/src/components/project/program.test.d.ts +2 -0
- package/dist/src/components/project/program.test.d.ts.map +1 -0
- package/dist/src/components/project/program.test.js +50 -0
- package/dist/src/components/project/program.test.js.map +1 -0
- package/dist/src/components/render-root.d.ts +14 -0
- package/dist/src/components/render-root.d.ts.map +1 -0
- package/dist/src/components/render-root.js +122 -0
- package/dist/src/components/render-root.js.map +1 -0
- package/dist/src/components/request-models.d.ts +15 -0
- package/dist/src/components/request-models.d.ts.map +1 -0
- package/dist/src/components/request-models.js +97 -0
- package/dist/src/components/request-models.js.map +1 -0
- package/dist/src/components/scaffolding/documentation.d.ts +12 -0
- package/dist/src/components/scaffolding/documentation.d.ts.map +1 -0
- package/dist/src/{lib/doc.js → components/scaffolding/documentation.js} +56 -46
- package/dist/src/components/scaffolding/documentation.js.map +1 -0
- package/dist/src/components/scaffolding/mock-helpers.d.ts +10 -0
- package/dist/src/components/scaffolding/mock-helpers.d.ts.map +1 -0
- package/dist/src/components/scaffolding/mock-helpers.js +268 -0
- package/dist/src/components/scaffolding/mock-helpers.js.map +1 -0
- package/dist/src/components/scaffolding/mock-implementations.d.ts +14 -0
- package/dist/src/components/scaffolding/mock-implementations.d.ts.map +1 -0
- package/dist/src/components/scaffolding/mock-implementations.js +152 -0
- package/dist/src/components/scaffolding/mock-implementations.js.map +1 -0
- package/dist/src/components/scaffolding/mock-return-utils.d.ts +11 -0
- package/dist/src/components/scaffolding/mock-return-utils.d.ts.map +1 -0
- package/dist/src/components/scaffolding/mock-return-utils.js +62 -0
- package/dist/src/components/scaffolding/mock-return-utils.js.map +1 -0
- package/dist/src/components/scaffolding/mock-scaffolding.d.ts +6 -0
- package/dist/src/components/scaffolding/mock-scaffolding.d.ts.map +1 -0
- package/dist/src/components/scaffolding/mock-scaffolding.js +5 -0
- package/dist/src/components/scaffolding/mock-scaffolding.js.map +1 -0
- package/dist/src/components/scaffolding/mock-scaffolding.test.d.ts +2 -0
- package/dist/src/components/scaffolding/mock-scaffolding.test.d.ts.map +1 -0
- package/dist/src/components/scaffolding/mock-scaffolding.test.js +59 -0
- package/dist/src/components/scaffolding/mock-scaffolding.test.js.map +1 -0
- package/dist/src/components/serialization/base64-url-json-converter.d.ts +7 -0
- package/dist/src/components/serialization/base64-url-json-converter.d.ts.map +1 -0
- package/dist/src/components/serialization/base64-url-json-converter.js +58 -0
- package/dist/src/components/serialization/base64-url-json-converter.js.map +1 -0
- package/dist/src/components/serialization/constraint-attributes.d.ts +7 -0
- package/dist/src/components/serialization/constraint-attributes.d.ts.map +1 -0
- package/dist/src/components/serialization/constraint-attributes.js +556 -0
- package/dist/src/components/serialization/constraint-attributes.js.map +1 -0
- package/dist/src/components/serialization/http-service-exception-filter.d.ts +8 -0
- package/dist/src/components/serialization/http-service-exception-filter.d.ts.map +1 -0
- package/dist/src/components/serialization/http-service-exception-filter.js +71 -0
- package/dist/src/components/serialization/http-service-exception-filter.js.map +1 -0
- package/dist/src/components/serialization/json-converters.d.ts +7 -0
- package/dist/src/components/serialization/json-converters.d.ts.map +1 -0
- package/dist/src/components/serialization/json-converters.js +22 -0
- package/dist/src/components/serialization/json-converters.js.map +1 -0
- package/dist/src/components/serialization/json-converters.test.d.ts +2 -0
- package/dist/src/components/serialization/json-converters.test.d.ts.map +1 -0
- package/dist/src/components/serialization/json-converters.test.js +136 -0
- package/dist/src/components/serialization/json-converters.test.js.map +1 -0
- package/dist/src/components/serialization/json-serialization-provider.d.ts +7 -0
- package/dist/src/components/serialization/json-serialization-provider.d.ts.map +1 -0
- package/dist/src/components/serialization/json-serialization-provider.js +90 -0
- package/dist/src/components/serialization/json-serialization-provider.js.map +1 -0
- package/dist/src/components/serialization/time-span-duration-converter.d.ts +7 -0
- package/dist/src/components/serialization/time-span-duration-converter.d.ts.map +1 -0
- package/dist/src/components/serialization/time-span-duration-converter.js +44 -0
- package/dist/src/components/serialization/time-span-duration-converter.js.map +1 -0
- package/dist/src/components/serialization/unix-epoch-date-time-converter.d.ts +7 -0
- package/dist/src/components/serialization/unix-epoch-date-time-converter.d.ts.map +1 -0
- package/dist/src/components/serialization/unix-epoch-date-time-converter.js +71 -0
- package/dist/src/components/serialization/unix-epoch-date-time-converter.js.map +1 -0
- package/dist/src/components/type-expression/type-expression.d.ts +24 -0
- package/dist/src/components/type-expression/type-expression.d.ts.map +1 -0
- package/dist/src/components/type-expression/type-expression.js +223 -0
- package/dist/src/components/type-expression/type-expression.js.map +1 -0
- package/dist/src/components/type-expression/type-expression.test.d.ts +2 -0
- package/dist/src/components/type-expression/type-expression.test.d.ts.map +1 -0
- package/dist/src/components/type-expression/type-expression.test.js +207 -0
- package/dist/src/components/type-expression/type-expression.test.js.map +1 -0
- package/dist/src/context/emitter-options-context.d.ts +13 -0
- package/dist/src/context/emitter-options-context.d.ts.map +1 -0
- package/dist/src/context/emitter-options-context.js +15 -0
- package/dist/src/context/emitter-options-context.js.map +1 -0
- package/dist/src/diagnostics.d.ts +8 -0
- package/dist/src/diagnostics.d.ts.map +1 -0
- package/dist/src/diagnostics.js +164 -0
- package/dist/src/diagnostics.js.map +1 -0
- package/dist/src/emitter.d.ts +8 -0
- package/dist/src/emitter.d.ts.map +1 -0
- package/dist/src/emitter.js +180 -0
- package/dist/src/emitter.js.map +1 -0
- package/dist/src/{lib/index.d.ts → index.d.ts} +1 -1
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/{lib/index.js → index.js} +1 -1
- package/dist/src/index.js.map +1 -0
- package/dist/src/{lib/lib.d.ts → lib.d.ts} +4 -14
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +133 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/output-writer.d.ts +11 -0
- package/dist/src/output-writer.d.ts.map +1 -0
- package/dist/src/output-writer.js +72 -0
- package/dist/src/output-writer.js.map +1 -0
- package/dist/src/service-discovery.d.ts +13 -0
- package/dist/src/service-discovery.d.ts.map +1 -0
- package/dist/src/service-discovery.js +93 -0
- package/dist/src/service-discovery.js.map +1 -0
- package/dist/src/service-resolution.d.ts +34 -0
- package/dist/src/service-resolution.d.ts.map +1 -0
- package/dist/src/service-resolution.js +244 -0
- package/dist/src/service-resolution.js.map +1 -0
- package/dist/src/testing/index.d.ts +2 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +2 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/utils/attributes.d.ts +8 -0
- package/dist/src/utils/attributes.d.ts.map +1 -0
- package/dist/src/utils/attributes.js +224 -0
- package/dist/src/utils/attributes.js.map +1 -0
- package/dist/src/utils/csharp-libs.d.ts +87 -0
- package/dist/src/utils/csharp-libs.d.ts.map +1 -0
- package/dist/src/utils/csharp-libs.js +90 -0
- package/dist/src/utils/csharp-libs.js.map +1 -0
- package/dist/src/utils/doc-comments.d.ts +2 -0
- package/dist/src/utils/doc-comments.d.ts.map +1 -0
- package/dist/src/utils/doc-comments.js +4 -0
- package/dist/src/utils/doc-comments.js.map +1 -0
- package/dist/src/utils/http-helpers.d.ts +19 -0
- package/dist/src/utils/http-helpers.d.ts.map +1 -0
- package/dist/src/utils/http-helpers.js +70 -0
- package/dist/src/utils/http-helpers.js.map +1 -0
- package/dist/src/utils/http-helpers.test.d.ts +2 -0
- package/dist/src/utils/http-helpers.test.d.ts.map +1 -0
- package/dist/src/utils/http-helpers.test.js +68 -0
- package/dist/src/utils/http-helpers.test.js.map +1 -0
- package/dist/src/utils/namespace-utils.d.ts +13 -0
- package/dist/src/utils/namespace-utils.d.ts.map +1 -0
- package/dist/src/utils/namespace-utils.js +55 -0
- package/dist/src/utils/namespace-utils.js.map +1 -0
- package/dist/src/utils/naming.d.ts +31 -0
- package/dist/src/utils/naming.d.ts.map +1 -0
- package/dist/src/utils/naming.js +87 -0
- package/dist/src/utils/naming.js.map +1 -0
- package/dist/src/utils/naming.test.d.ts +2 -0
- package/dist/src/utils/naming.test.d.ts.map +1 -0
- package/dist/src/utils/naming.test.js +86 -0
- package/dist/src/utils/naming.test.js.map +1 -0
- package/dist/src/utils/port.d.ts +5 -0
- package/dist/src/utils/port.d.ts.map +1 -0
- package/dist/src/utils/port.js +33 -0
- package/dist/src/utils/port.js.map +1 -0
- package/dist/src/utils/return-type-helpers.d.ts +8 -0
- package/dist/src/utils/return-type-helpers.d.ts.map +1 -0
- package/dist/src/utils/return-type-helpers.js +59 -0
- package/dist/src/utils/return-type-helpers.js.map +1 -0
- package/package.json +34 -26
- package/dist/src/lib/attributes.d.ts +0 -43
- package/dist/src/lib/attributes.d.ts.map +0 -1
- package/dist/src/lib/attributes.js +0 -422
- package/dist/src/lib/attributes.js.map +0 -1
- package/dist/src/lib/boilerplate.d.ts +0 -6
- package/dist/src/lib/boilerplate.d.ts.map +0 -1
- package/dist/src/lib/boilerplate.js +0 -792
- package/dist/src/lib/boilerplate.js.map +0 -1
- package/dist/src/lib/doc.d.ts +0 -5
- package/dist/src/lib/doc.d.ts.map +0 -1
- package/dist/src/lib/doc.js.map +0 -1
- package/dist/src/lib/index.d.ts.map +0 -1
- package/dist/src/lib/index.js.map +0 -1
- package/dist/src/lib/interfaces.d.ts +0 -183
- package/dist/src/lib/interfaces.d.ts.map +0 -1
- package/dist/src/lib/interfaces.js +0 -287
- package/dist/src/lib/interfaces.js.map +0 -1
- package/dist/src/lib/lib.d.ts.map +0 -1
- package/dist/src/lib/lib.js +0 -146
- package/dist/src/lib/lib.js.map +0 -1
- package/dist/src/lib/project.d.ts +0 -5
- package/dist/src/lib/project.d.ts.map +0 -1
- package/dist/src/lib/project.js +0 -101
- package/dist/src/lib/project.js.map +0 -1
- package/dist/src/lib/scaffolding.d.ts +0 -22
- package/dist/src/lib/scaffolding.d.ts.map +0 -1
- package/dist/src/lib/scaffolding.js +0 -461
- package/dist/src/lib/scaffolding.js.map +0 -1
- package/dist/src/lib/service.d.ts +0 -4
- package/dist/src/lib/service.d.ts.map +0 -1
- package/dist/src/lib/service.js +0 -1208
- package/dist/src/lib/service.js.map +0 -1
- package/dist/src/lib/type-helpers.d.ts +0 -44
- package/dist/src/lib/type-helpers.d.ts.map +0 -1
- package/dist/src/lib/type-helpers.js +0 -106
- package/dist/src/lib/type-helpers.js.map +0 -1
- package/dist/src/lib/utils.d.ts +0 -120
- package/dist/src/lib/utils.d.ts.map +0 -1
- package/dist/src/lib/utils.js +0 -1580
- package/dist/src/lib/utils.js.map +0 -1
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code, Show, SourceDirectory } from "@alloy-js/core";
|
|
3
|
+
import * as cs from "@alloy-js/csharp";
|
|
4
|
+
import { CSharpFile } from "../csharp-file.js";
|
|
5
|
+
/**
|
|
6
|
+
* Renders the mock helper files: IInitializer, Initializer, MockRegistration.
|
|
7
|
+
* These go under the TypeSpec.Helpers namespace.
|
|
8
|
+
*/
|
|
9
|
+
export function MockHelpers(props) {
|
|
10
|
+
return _$createComponent(cs.Namespace, {
|
|
11
|
+
name: "TypeSpec.Helpers",
|
|
12
|
+
get children() {
|
|
13
|
+
return _$createComponent(SourceDirectory, {
|
|
14
|
+
path: "mocks",
|
|
15
|
+
get children() {
|
|
16
|
+
return [_$createComponent(InitializerInterface, {}), _$createComponent(InitializerImplementation, {}), _$createComponent(Show, {
|
|
17
|
+
get when() {
|
|
18
|
+
return props.interfaceRegistrations.length > 0;
|
|
19
|
+
},
|
|
20
|
+
get children() {
|
|
21
|
+
return _$createComponent(MockRegistration, {
|
|
22
|
+
get interfaceRegistrations() {
|
|
23
|
+
return props.interfaceRegistrations;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
})];
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function InitializerInterface() {
|
|
34
|
+
return _$createComponent(CSharpFile, {
|
|
35
|
+
path: "IInitializer.cs",
|
|
36
|
+
children: code`
|
|
37
|
+
/// <summary>
|
|
38
|
+
/// Interface for object initialization in mocks
|
|
39
|
+
/// </summary>
|
|
40
|
+
public interface IInitializer
|
|
41
|
+
{
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// Initialize an object of the given type
|
|
44
|
+
/// </summary>
|
|
45
|
+
/// <param name="type"> The type to initialize</param>
|
|
46
|
+
/// <returns>An instance of the given type. Or null if initialization was impossible.</returns>
|
|
47
|
+
object? Initialize(System.Type type);
|
|
48
|
+
/// <summary>
|
|
49
|
+
/// Initialize an object of the given type
|
|
50
|
+
/// </summary>
|
|
51
|
+
/// <typeparam name="T">The type to initialize</typeparam>
|
|
52
|
+
/// <returns>An instance of the given type</returns>
|
|
53
|
+
T Initialize<T>() where T : class, new();
|
|
54
|
+
}
|
|
55
|
+
`
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function InitializerImplementation() {
|
|
59
|
+
return _$createComponent(CSharpFile, {
|
|
60
|
+
path: "Initializer.cs",
|
|
61
|
+
children: code`
|
|
62
|
+
/// <summary>
|
|
63
|
+
/// Default initializer for mock implementations of business logic interfaces
|
|
64
|
+
/// </summary>
|
|
65
|
+
public class Initializer : IInitializer
|
|
66
|
+
{
|
|
67
|
+
/// <summary>
|
|
68
|
+
/// Instantiate the initializer. The cache *should* be instantiated using ASP.Net Core's dependency injection
|
|
69
|
+
/// </summary>
|
|
70
|
+
/// <param name="cache"></param>
|
|
71
|
+
public Initializer(IDictionary<Type, object?> cache)
|
|
72
|
+
{
|
|
73
|
+
Cache = cache;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
internal virtual IDictionary<Type, object?> Cache { get; }
|
|
77
|
+
|
|
78
|
+
internal object? CacheAndReturn(Type type, object? instance)
|
|
79
|
+
{
|
|
80
|
+
Cache[type] = instance;
|
|
81
|
+
return instance;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
/// Initialize an object fo the given type
|
|
86
|
+
/// </summary>
|
|
87
|
+
/// <param name="type"> The type to initialize</param>
|
|
88
|
+
/// <returns>An instance of the given type. Or null if initialization was impossible.</returns>
|
|
89
|
+
public object? Initialize(Type type)
|
|
90
|
+
{
|
|
91
|
+
if (Cache.ContainsKey(type))
|
|
92
|
+
{
|
|
93
|
+
return Cache[type];
|
|
94
|
+
}
|
|
95
|
+
if (type == typeof(string))
|
|
96
|
+
{
|
|
97
|
+
return CacheAndReturn(type, string.Empty);
|
|
98
|
+
}
|
|
99
|
+
if (type == typeof(int))
|
|
100
|
+
{
|
|
101
|
+
return CacheAndReturn(type, 0);
|
|
102
|
+
}
|
|
103
|
+
if (type == typeof(long))
|
|
104
|
+
{
|
|
105
|
+
return CacheAndReturn(type, 0L);
|
|
106
|
+
}
|
|
107
|
+
if (type == typeof(float))
|
|
108
|
+
{
|
|
109
|
+
return CacheAndReturn(type, 0.0f);
|
|
110
|
+
}
|
|
111
|
+
if (type == typeof(double))
|
|
112
|
+
{
|
|
113
|
+
return CacheAndReturn(type, 0.0);
|
|
114
|
+
}
|
|
115
|
+
if (type == typeof(decimal))
|
|
116
|
+
{
|
|
117
|
+
return CacheAndReturn(type, 0.0m);
|
|
118
|
+
}
|
|
119
|
+
if (type == typeof(bool))
|
|
120
|
+
{
|
|
121
|
+
return CacheAndReturn(type, false);
|
|
122
|
+
}
|
|
123
|
+
if (type == typeof(byte))
|
|
124
|
+
{
|
|
125
|
+
return CacheAndReturn(type, (byte)0);
|
|
126
|
+
}
|
|
127
|
+
if (type == typeof(char))
|
|
128
|
+
{
|
|
129
|
+
return CacheAndReturn(type, (char)0);
|
|
130
|
+
}
|
|
131
|
+
if (type == typeof(short))
|
|
132
|
+
{
|
|
133
|
+
return CacheAndReturn(type, (short)0);
|
|
134
|
+
}
|
|
135
|
+
if (type == typeof(uint))
|
|
136
|
+
{
|
|
137
|
+
return CacheAndReturn(type, (uint)0);
|
|
138
|
+
}
|
|
139
|
+
if (type == typeof(ulong))
|
|
140
|
+
{
|
|
141
|
+
return CacheAndReturn(type, (ulong)0);
|
|
142
|
+
}
|
|
143
|
+
if (type == typeof(ushort))
|
|
144
|
+
{
|
|
145
|
+
return CacheAndReturn(type, (ushort)0);
|
|
146
|
+
}
|
|
147
|
+
if (type == typeof(sbyte))
|
|
148
|
+
{
|
|
149
|
+
return CacheAndReturn(type, (sbyte)0);
|
|
150
|
+
}
|
|
151
|
+
if (type == typeof(DateTime))
|
|
152
|
+
{
|
|
153
|
+
return CacheAndReturn(type, DateTime.UtcNow);
|
|
154
|
+
}
|
|
155
|
+
if (type == typeof(DateTimeOffset))
|
|
156
|
+
{
|
|
157
|
+
return CacheAndReturn(type, DateTimeOffset.UtcNow);
|
|
158
|
+
}
|
|
159
|
+
if (type == typeof(TimeSpan))
|
|
160
|
+
{
|
|
161
|
+
return CacheAndReturn(type, TimeSpan.Zero);
|
|
162
|
+
}
|
|
163
|
+
if (type.IsArray)
|
|
164
|
+
{
|
|
165
|
+
var element = type.GetElementType();
|
|
166
|
+
if (element == null)
|
|
167
|
+
return null;
|
|
168
|
+
return CacheAndReturn(type, Array.CreateInstance(element, 0));
|
|
169
|
+
}
|
|
170
|
+
if (type.IsGenericType)
|
|
171
|
+
{
|
|
172
|
+
var elementType = type.GetGenericArguments()[0];
|
|
173
|
+
if (elementType == null)
|
|
174
|
+
return null;
|
|
175
|
+
|
|
176
|
+
if (type.GetGenericTypeDefinition() == typeof(IEnumerable<>))
|
|
177
|
+
{
|
|
178
|
+
return CacheAndReturn(type, Activator.CreateInstance(typeof(List<>).MakeGenericType(elementType)));
|
|
179
|
+
}
|
|
180
|
+
if (type.GetGenericTypeDefinition() == typeof(ISet<>))
|
|
181
|
+
{
|
|
182
|
+
return CacheAndReturn(type, Activator.CreateInstance(typeof(HashSet<>).MakeGenericType(elementType)));
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
if (type.IsClass)
|
|
186
|
+
{
|
|
187
|
+
return InitializeClass(type);
|
|
188
|
+
}
|
|
189
|
+
var genericType = Nullable.GetUnderlyingType(type);
|
|
190
|
+
if ((genericType != null))
|
|
191
|
+
{
|
|
192
|
+
return Initialize(genericType);
|
|
193
|
+
}
|
|
194
|
+
if (type.IsEnum)
|
|
195
|
+
{
|
|
196
|
+
return CacheAndReturn(type, Enum.GetValues(type).GetValue(0));
|
|
197
|
+
}
|
|
198
|
+
return new object();
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/// <summary>
|
|
202
|
+
/// Initialize an object of the given type
|
|
203
|
+
/// </summary>
|
|
204
|
+
/// <typeparam name="T">The type to initialize</typeparam>
|
|
205
|
+
/// <returns>An instance of the given type</returns>
|
|
206
|
+
public T Initialize<T>() where T : class, new()
|
|
207
|
+
{
|
|
208
|
+
var result = new T();
|
|
209
|
+
var initialized = InitializeClass(typeof(T), result);
|
|
210
|
+
return initialized as T ?? result;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
private object? InitializeClass(Type type, object? instance = null)
|
|
214
|
+
{
|
|
215
|
+
if (Cache.ContainsKey(type))
|
|
216
|
+
{
|
|
217
|
+
instance = Cache[type];
|
|
218
|
+
return instance;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
var result = instance == null ? Activator.CreateInstance(type) : instance;
|
|
222
|
+
foreach (var property in type.GetProperties())
|
|
223
|
+
{
|
|
224
|
+
if (property.CanWrite)
|
|
225
|
+
{
|
|
226
|
+
var propertyType = property.PropertyType;
|
|
227
|
+
property.SetValue(result, Initialize(propertyType));
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return CacheAndReturn(type, result);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
`
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
function MockRegistration(props) {
|
|
238
|
+
const registrations = props.interfaceRegistrations.map(r => `builder.Services.AddScoped<${r}>();`).join("\n");
|
|
239
|
+
return _$createComponent(CSharpFile, {
|
|
240
|
+
path: "MockRegistration.cs",
|
|
241
|
+
using: ["Microsoft.AspNetCore.Http.Features"],
|
|
242
|
+
children: code`
|
|
243
|
+
/// <summary>
|
|
244
|
+
/// Register Business Logic implementations. Replace with actual implementations when available.
|
|
245
|
+
/// </summary>
|
|
246
|
+
public static class MockRegistration
|
|
247
|
+
{
|
|
248
|
+
public static void Register(WebApplicationBuilder builder)
|
|
249
|
+
{
|
|
250
|
+
builder.Services.AddHttpContextAccessor();
|
|
251
|
+
builder.Services.AddScoped<IJsonSerializationProvider, JsonSerializationProvider>();
|
|
252
|
+
// Used for mock implementation only. Remove once business logic interfaces are implemented.
|
|
253
|
+
builder.Services.AddSingleton<IDictionary<Type, object?>>(new Dictionary<Type, object?>());
|
|
254
|
+
builder.Services.AddScoped<IInitializer, Initializer>();
|
|
255
|
+
// Mock business logic implementations
|
|
256
|
+
${registrations}
|
|
257
|
+
// Included for multipart/form-data support
|
|
258
|
+
builder.Services.Configure<FormOptions>(options =>
|
|
259
|
+
{
|
|
260
|
+
options.MemoryBufferThreshold = int.MaxValue;
|
|
261
|
+
options.MultipartBodyLengthLimit = int.MaxValue;
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
`
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=mock-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["code","Show","SourceDirectory","cs","CSharpFile","MockHelpers","props","_$createComponent","Namespace","name","children","path","InitializerInterface","InitializerImplementation","when","interfaceRegistrations","length","MockRegistration","registrations","map","r","join","using"],"sources":["../../../../src/components/scaffolding/mock-helpers.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,IAAI,EAAEC,IAAI,EAAEC,eAAe,QAAuB,gBAAgB;AAC3E,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AACtC,SAASC,UAAU;AAMnB;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,KAAuB,EAAY;EAC7D,OAAAC,iBAAA,CACGJ,EAAE,CAACK,SAAS;IAACC,IAAI;IAAA,IAAAC,SAAA;MAAA,OAAAH,iBAAA,CACfL,eAAe;QAACS,IAAI;QAAA,IAAAD,SAAA;UAAA,QAAAH,iBAAA,CAClBK,oBAAoB,OAAAL,iBAAA,CACpBM,yBAAyB,OAAAN,iBAAA,CACzBN,IAAI;YAAA,IAACa,IAAIA,CAAA;cAAA,OAAER,KAAK,CAACS,sBAAsB,CAACC,MAAM,GAAG,CAAC;YAAA;YAAA,IAAAN,SAAA;cAAA,OAAAH,iBAAA,CAChDU,gBAAgB;gBAAA,IAACF,sBAAsBA,CAAA;kBAAA,OAAET,KAAK,CAACS,sBAAsB;gBAAA;cAAA;YAAA;UAAA;QAAA;MAAA;IAAA;EAAA;AAKhF;AAEA,SAASH,oBAAoBA,CAAA,EAAa;EACxC,OAAAL,iBAAA,CACGH,UAAU;IAACO,IAAI;IAAAD,QAAA,EACbV,IAAI;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAAO;AAGP;AAEA,SAASa,yBAAyBA,CAAA,EAAa;EAC7C,OAAAN,iBAAA,CACGH,UAAU;IAACO,IAAI;IAAAD,QAAA,EACbV,IAAI;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAAO;AAGP;AAMA,SAASiB,gBAAgBA,CAACX,KAA4B,EAAY;EAChE,MAAMY,aAAa,GAAGZ,KAAK,CAACS,sBAAsB,CAC/CI,GAAG,CAAEC,CAAC,IAAK,8BAA8BA,CAAC,MAAM,CAAC,CACjDC,IAAI,CAAC,IAAI,CAAC;EAEb,OAAAd,iBAAA,CACGH,UAAU;IAACO,IAAI;IAAuBW,KAAK,EAAE,CAAC,oCAAoC,CAAC;IAAAZ,QAAA,EACjFV,IAAI;AACX;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,cAAckB,aAAa;AAC3B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EAAO;AAGP","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
|
+
import type { Interface } from "@typespec/compiler";
|
|
3
|
+
import type { OperationHttpCanonicalization } from "@typespec/http-canonicalization";
|
|
4
|
+
export interface MockImplementationsProps {
|
|
5
|
+
interfaces: Interface[];
|
|
6
|
+
/** Map from interface name to its canonicalized HTTP operations. */
|
|
7
|
+
canonicalOpsMap?: Map<string, OperationHttpCanonicalization[]>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Renders per-interface mock implementation classes.
|
|
11
|
+
* These go under the service namespace.
|
|
12
|
+
*/
|
|
13
|
+
export declare function MockImplementations(props: MockImplementationsProps): Children;
|
|
14
|
+
//# sourceMappingURL=mock-implementations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-implementations.d.ts","sourceRoot":"","sources":["../../../../src/components/scaffolding/mock-implementations.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,KAAK,EAAE,SAAS,EAAsB,MAAM,oBAAoB,CAAC;AAExE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AASrF,MAAM,WAAW,wBAAwB;IACvC,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB,oEAAoE;IACpE,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,6BAA6B,EAAE,CAAC,CAAC;CAChE;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,QAAQ,CAU7E"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code, For, SourceDirectory } from "@alloy-js/core";
|
|
3
|
+
import * as cs from "@alloy-js/csharp";
|
|
4
|
+
import { useTsp } from "@typespec/emitter-framework";
|
|
5
|
+
import { CSharpFile } from "../csharp-file.js";
|
|
6
|
+
import { TypeExpression } from "../type-expression/type-expression.js";
|
|
7
|
+
import { getGetBodyPropNames, getMockReturnStatement, getSuccessReturnType } from "./mock-return-utils.js";
|
|
8
|
+
/**
|
|
9
|
+
* Renders per-interface mock implementation classes.
|
|
10
|
+
* These go under the service namespace.
|
|
11
|
+
*/
|
|
12
|
+
export function MockImplementations(props) {
|
|
13
|
+
return _$createComponent(SourceDirectory, {
|
|
14
|
+
path: "mocks",
|
|
15
|
+
get children() {
|
|
16
|
+
return _$createComponent(For, {
|
|
17
|
+
get each() {
|
|
18
|
+
return props.interfaces;
|
|
19
|
+
},
|
|
20
|
+
children: iface => _$createComponent(MockImplementation, {
|
|
21
|
+
type: iface,
|
|
22
|
+
get canonicalOps() {
|
|
23
|
+
return props.canonicalOpsMap?.get(iface.name);
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Generates a mock implementation class for a business logic interface.
|
|
32
|
+
*/
|
|
33
|
+
function MockImplementation(props) {
|
|
34
|
+
const namePolicy = cs.useCSharpNamePolicy();
|
|
35
|
+
const {
|
|
36
|
+
$
|
|
37
|
+
} = useTsp();
|
|
38
|
+
const interfaceName = `I${namePolicy.getName(props.type.name, "class")}`;
|
|
39
|
+
const className = namePolicy.getName(props.type.name, "class");
|
|
40
|
+
const operations = Array.from(props.type.operations.entries());
|
|
41
|
+
|
|
42
|
+
// Build canonical ops map by name
|
|
43
|
+
const canonicalMap = new Map();
|
|
44
|
+
if (props.canonicalOps) {
|
|
45
|
+
for (const cop of props.canonicalOps) {
|
|
46
|
+
canonicalMap.set(cop.name, cop);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return _$createComponent(CSharpFile, {
|
|
50
|
+
path: `${className}.cs`,
|
|
51
|
+
using: ["System", "System.Net", "System.Text.Json", "System.Text.Json.Serialization", "System.Threading.Tasks", "Microsoft.AspNetCore.Mvc"],
|
|
52
|
+
get children() {
|
|
53
|
+
return code`
|
|
54
|
+
/// <summary>
|
|
55
|
+
/// This is a mock implementation of the business logic interface for
|
|
56
|
+
/// demonstration and early development. Feel free to overwrite this file.
|
|
57
|
+
/// Or replace it with another implementation, and register that implementation
|
|
58
|
+
/// in the dependency injection container
|
|
59
|
+
/// </summary>
|
|
60
|
+
public class ${className} : ${interfaceName}
|
|
61
|
+
{
|
|
62
|
+
/// <summary>
|
|
63
|
+
/// The controller constructor, using the dependency injection container to satisfy the parameters.
|
|
64
|
+
/// </summary>
|
|
65
|
+
/// <param name="initializer">The initializer class, registered with dependency injection</param>
|
|
66
|
+
/// <param name="accessor">The accessor for the HttpContext, allows your implementation to
|
|
67
|
+
/// get properties of the incoming request and to set properties of the outgoing response.</param>
|
|
68
|
+
public ${className}(IInitializer initializer, IHttpContextAccessor accessor)
|
|
69
|
+
{
|
|
70
|
+
_initializer = initializer;
|
|
71
|
+
HttpContextAccessor = accessor;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private IInitializer _initializer;
|
|
75
|
+
|
|
76
|
+
/// <summary>
|
|
77
|
+
/// Use this property in your implementation to access properties of the incoming HttpRequest
|
|
78
|
+
/// and to set properties of the outgoing HttpResponse
|
|
79
|
+
/// </summary>
|
|
80
|
+
public IHttpContextAccessor HttpContextAccessor { get; }
|
|
81
|
+
|
|
82
|
+
${_$createComponent(MockMethods, {
|
|
83
|
+
operations: operations,
|
|
84
|
+
get program() {
|
|
85
|
+
return $.program;
|
|
86
|
+
},
|
|
87
|
+
canonicalMap: canonicalMap
|
|
88
|
+
})}
|
|
89
|
+
}
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function MockMethods(props) {
|
|
95
|
+
const namePolicy = cs.useCSharpNamePolicy();
|
|
96
|
+
return _$createComponent(For, {
|
|
97
|
+
get each() {
|
|
98
|
+
return props.operations;
|
|
99
|
+
},
|
|
100
|
+
doubleHardline: true,
|
|
101
|
+
children: ([name, op]) => {
|
|
102
|
+
const methodName = `${namePolicy.getName(name, "class-method")}Async`;
|
|
103
|
+
const successType = getSuccessReturnType(props.program, op.returnType);
|
|
104
|
+
const returnTypeExpr = successType ? code`Task<${_$createComponent(TypeExpression, {
|
|
105
|
+
type: successType
|
|
106
|
+
})}>` : code`Task`;
|
|
107
|
+
const bodyPropNames = getGetBodyPropNames(name, props.canonicalMap);
|
|
108
|
+
|
|
109
|
+
// Check if this is a multipart operation
|
|
110
|
+
const canonicalOp = props.canonicalMap?.get(name);
|
|
111
|
+
const isMultipart = canonicalOp?.requestParameters.body?.bodyKind === "multipart";
|
|
112
|
+
const multipartBodyPropNames = new Set();
|
|
113
|
+
if (isMultipart && canonicalOp) {
|
|
114
|
+
for (const p of canonicalOp.requestParameters.properties) {
|
|
115
|
+
if (p.kind === "body" || p.kind === "bodyRoot" || p.kind === "bodyProperty" || p.kind === "multipartBody") {
|
|
116
|
+
multipartBodyPropNames.add(p.property.sourceType.name);
|
|
117
|
+
}
|
|
118
|
+
if (p.property.isContentTypeProperty) {
|
|
119
|
+
multipartBodyPropNames.add(p.property.sourceType.name);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const parameters = Array.from(op.parameters.properties.entries()).filter(([pName]) => !bodyPropNames.has(pName)).filter(([pName]) => !multipartBodyPropNames.has(pName)).map(([pName, prop]) => ({
|
|
124
|
+
name: namePolicy.getName(pName, "parameter"),
|
|
125
|
+
type: _$createComponent(TypeExpression, {
|
|
126
|
+
get type() {
|
|
127
|
+
return prop.type;
|
|
128
|
+
}
|
|
129
|
+
}),
|
|
130
|
+
optional: prop.optional
|
|
131
|
+
}))
|
|
132
|
+
// Required parameters must come before optional ones in C#
|
|
133
|
+
.sort((a, b) => a.optional === b.optional ? 0 : a.optional ? 1 : -1);
|
|
134
|
+
|
|
135
|
+
// For multipart requests, add MultipartReader parameter
|
|
136
|
+
if (isMultipart) {
|
|
137
|
+
parameters.push({
|
|
138
|
+
name: "reader",
|
|
139
|
+
type: code`MultipartReader`,
|
|
140
|
+
optional: false
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
const paramList = parameters.map((p, i) => code`${p.type}${p.optional ? "?" : ""} ${p.name}${i < parameters.length - 1 ? ", " : ""}`);
|
|
144
|
+
const returnStatement = getMockReturnStatement(props.program, op.returnType);
|
|
145
|
+
return code`public ${returnTypeExpr} ${methodName}(${paramList})
|
|
146
|
+
{
|
|
147
|
+
${returnStatement}
|
|
148
|
+
}`;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=mock-implementations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["code","For","SourceDirectory","cs","useTsp","CSharpFile","TypeExpression","getGetBodyPropNames","getMockReturnStatement","getSuccessReturnType","MockImplementations","props","_$createComponent","path","children","each","interfaces","iface","MockImplementation","type","canonicalOps","canonicalOpsMap","get","name","namePolicy","useCSharpNamePolicy","$","interfaceName","getName","className","operations","Array","from","entries","canonicalMap","Map","cop","set","using","MockMethods","program","doubleHardline","op","methodName","successType","returnType","returnTypeExpr","bodyPropNames","canonicalOp","isMultipart","requestParameters","body","bodyKind","multipartBodyPropNames","Set","p","properties","kind","add","property","sourceType","isContentTypeProperty","parameters","filter","pName","has","map","prop","optional","sort","a","b","push","paramList","i","length","returnStatement"],"sources":["../../../../src/components/scaffolding/mock-implementations.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,IAAI,EAAEC,GAAG,EAAEC,eAAe,QAAuB,gBAAgB;AAC1E,OAAO,KAAKC,EAAE,MAAM,kBAAkB;AAEtC,SAASC,MAAM,QAAQ,6BAA6B;AAEpD,SAASC,UAAU;AACnB,SAASC,cAAc;AACvB,SACEC,mBAAmB,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AAP,iBAAA,CAAGN,cAAc;UAAA,IAACa,IAAIA,CAAA;YAAA,OAAEgD,IAAI,CAAChD,IAAI;UAAA;QAAA,EAAI;QACzCiD,QAAQ,EAAED,IAAI,CAACC;MACjB,CAAC,CAAC;MACF;MAAA,CACCC,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,KAAMD,CAAC,CAACF,QAAQ,KAAKG,CAAC,CAACH,QAAQ,GAAG,CAAC,GAAGE,CAAC,CAACF,QAAQ,GAAG,CAAC,GAAG,CAAC,CAAE,CAAC;;MAExE;MACA,IAAInB,WAAW,EAAE;QACfa,UAAU,CAACU,IAAI,CAAC;UACdjD,IAAI,EAAE,QAAQ;UACdJ,IAAI,EAAEnB,IAAI,iBAAiB;UAC3BoE,QAAQ,EAAE;QACZ,CAAC,CAAC;MACJ;MAEA,MAAMK,SAAS,GAAGX,UAAU,CAACI,GAAG,CAC9B,CAACX,CAAC,EAAEmB,CAAC,KACH1E,IAAI,GAAGuD,CAAC,CAACpC,IAAI,GAAGoC,CAAC,CAACa,QAAQ,GAAG,GAAG,GAAG,EAAE,IAAIb,CAAC,CAAChC,IAAI,GAAGmD,CAAC,GAAGZ,UAAU,CAACa,MAAM,GAAG,CAAC,GAAG,IAAI,GAAG,EAAE,EAC3F,CAAC;MAED,MAAMC,eAAe,GAAGpE,sBAAsB,CAACG,KAAK,CAAC6B,OAAO,EAAEE,EAAE,CAACG,UAAU,CAAC;MAE5E,OAAO7C,IAAI,UAAU8C,cAAc,IAAIH,UAAU,IAAI8B,SAAS;AACtE;AACA,IAAIG,eAAe;AACnB,EAAE;IACI;EAAC;AAGP","ignoreList":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Children } from "@alloy-js/core";
|
|
2
|
+
import type { Program, Type } from "@typespec/compiler";
|
|
3
|
+
import type { OperationHttpCanonicalization } from "@typespec/http-canonicalization";
|
|
4
|
+
export { getSuccessReturnType } from "../../utils/return-type-helpers.js";
|
|
5
|
+
/**
|
|
6
|
+
* Returns a mock return statement for a method based on its return type.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getMockReturnStatement(program: Program, returnType: Type): Children;
|
|
9
|
+
/** Get body property names to filter for GET operations. */
|
|
10
|
+
export declare function getGetBodyPropNames(opName: string, canonicalMap?: Map<string, OperationHttpCanonicalization>): Set<string>;
|
|
11
|
+
//# sourceMappingURL=mock-return-utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-return-utils.d.ts","sourceRoot":"","sources":["../../../../src/components/scaffolding/mock-return-utils.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAKrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAE1E;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,GAAG,QAAQ,CAuBnF;AAED,4DAA4D;AAC5D,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,6BAA6B,CAAC,GACxD,GAAG,CAAC,MAAM,CAAC,CAoBb"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code } from "@alloy-js/core";
|
|
3
|
+
import { getSuccessReturnType } from "../../utils/return-type-helpers.js";
|
|
4
|
+
import { TypeExpression } from "../type-expression/type-expression.js";
|
|
5
|
+
|
|
6
|
+
// Re-export for convenience
|
|
7
|
+
export { getSuccessReturnType } from "../../utils/return-type-helpers.js";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Returns a mock return statement for a method based on its return type.
|
|
11
|
+
*/
|
|
12
|
+
export function getMockReturnStatement(program, returnType) {
|
|
13
|
+
const successType = getSuccessReturnType(program, returnType);
|
|
14
|
+
if (!successType) {
|
|
15
|
+
return "return Task.CompletedTask;";
|
|
16
|
+
}
|
|
17
|
+
if (successType.kind === "Model" && successType.indexer) {
|
|
18
|
+
return code`return Task.FromResult<${_$createComponent(TypeExpression, {
|
|
19
|
+
type: successType
|
|
20
|
+
})}>([]);`;
|
|
21
|
+
}
|
|
22
|
+
if (successType.kind === "Scalar") {
|
|
23
|
+
if (successType.name === "string") {
|
|
24
|
+
// Empty string is the simplest non-null default for string scalars in mock implementations
|
|
25
|
+
return `return Task.FromResult("");`;
|
|
26
|
+
}
|
|
27
|
+
return code`return Task.FromResult<${_$createComponent(TypeExpression, {
|
|
28
|
+
type: successType
|
|
29
|
+
})}>(default);`;
|
|
30
|
+
}
|
|
31
|
+
if (successType.kind === "Model") {
|
|
32
|
+
return code`return Task.FromResult(_initializer.Initialize<${_$createComponent(TypeExpression, {
|
|
33
|
+
type: successType
|
|
34
|
+
})}>());`;
|
|
35
|
+
}
|
|
36
|
+
return code`return Task.FromResult<${_$createComponent(TypeExpression, {
|
|
37
|
+
type: successType
|
|
38
|
+
})}>(default);`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Get body property names to filter for GET operations. */
|
|
42
|
+
export function getGetBodyPropNames(opName, canonicalMap) {
|
|
43
|
+
const bodyPropNames = new Set();
|
|
44
|
+
const canonicalOp = canonicalMap?.get(opName);
|
|
45
|
+
if (!canonicalOp || canonicalOp.method !== "get") return bodyPropNames;
|
|
46
|
+
const body = canonicalOp.requestParameters.body;
|
|
47
|
+
if (body?.bodyKind === "single" && body.bodies.length > 0) {
|
|
48
|
+
const bodyType = body.bodies[0].type.sourceType;
|
|
49
|
+
if (bodyType.kind === "Model") {
|
|
50
|
+
for (const [name] of bodyType.properties) {
|
|
51
|
+
bodyPropNames.add(name);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
for (const p of canonicalOp.requestParameters.properties) {
|
|
56
|
+
if (p.kind === "body" || p.kind === "bodyRoot" || p.kind === "bodyProperty") {
|
|
57
|
+
bodyPropNames.add(p.property.sourceType.name);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return bodyPropNames;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=mock-return-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["code","getSuccessReturnType","TypeExpression","getMockReturnStatement","program","returnType","successType","kind","indexer","_$createComponent","type","name","getGetBodyPropNames","opName","canonicalMap","bodyPropNames","Set","canonicalOp","get","method","body","requestParameters","bodyKind","bodies","length","bodyType","sourceType","properties","add","p","property"],"sources":["../../../../src/components/scaffolding/mock-return-utils.tsx"],"sourcesContent":[null],"mappings":";AACA,SAASA,IAAI,QAAQ,gBAAgB;AAGrC,SAASC,oBAAoB,QAAQ,oCAAoC;AACzE,SAASC,cAAc;;AAEvB;AACA,SAASD,oBAAoB,QAAQ,oCAAoC;;AAEzE;AACA;AACA;AACA,OAAO,SAASE,sBAAsBA,CAACC,OAAgB,EAAEC,UAAgB,EAAY;EACnF,MAAMC,WAAW,GAAGL,oBAAoB,CAACG,OAAO,EAAEC,UAAU,CAAC;EAC7D,IAAI,CAACC,WAAW,EAAE;IAChB,OAAO,4BAA4B;EACrC;EAEA,IAAIA,WAAW,CAACC,IAAI,KAAK,OAAO,IAAID,WAAW,CAACE,OAAO,EAAE;IACvD,OAAOR,IAAI,0BAAAS,iBAAA,CAA4BP,cAAc;MAACQ,IAAI,EAAEJ;IAAW,UAAa;EACtF;EAEA,IAAIA,WAAW,CAACC,IAAI,KAAK,QAAQ,EAAE;IACjC,IAAID,WAAW,CAACK,IAAI,KAAK,QAAQ,EAAE;MACjC;MACA,OAAO,6BAA6B;IACtC;IACA,OAAOX,IAAI,0BAAAS,iBAAA,CAA4BP,cAAc;MAACQ,IAAI,EAAEJ;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AC;IAC/C;EACF;EACA,OAAOI,aAAa;AACtB","ignoreList":[]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { MockHelpers } from "./mock-helpers.jsx";
|
|
2
|
+
export type { MockHelpersProps } from "./mock-helpers.jsx";
|
|
3
|
+
export { MockImplementations } from "./mock-implementations.jsx";
|
|
4
|
+
export type { MockImplementationsProps } from "./mock-implementations.jsx";
|
|
5
|
+
export { getGetBodyPropNames, getMockReturnStatement, getSuccessReturnType, } from "./mock-return-utils.jsx";
|
|
6
|
+
//# sourceMappingURL=mock-scaffolding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-scaffolding.d.ts","sourceRoot":"","sources":["../../../../src/components/scaffolding/mock-scaffolding.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,YAAY,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EACL,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,GACrB,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Re-export from split modules
|
|
2
|
+
export { MockHelpers } from "./mock-helpers.js";
|
|
3
|
+
export { MockImplementations } from "./mock-implementations.js";
|
|
4
|
+
export { getGetBodyPropNames, getMockReturnStatement, getSuccessReturnType } from "./mock-return-utils.js";
|
|
5
|
+
//# sourceMappingURL=mock-scaffolding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["MockHelpers","MockImplementations","getGetBodyPropNames","getMockReturnStatement","getSuccessReturnType"],"sources":["../../../../src/components/scaffolding/mock-scaffolding.tsx"],"sourcesContent":[null],"mappings":"AAAA;AACA,SAASA,WAAW;AAEpB,SAASC,mBAAmB;AAE5B,SACEC,mBAAmB,EACnBC,sBAAsB,EACtBC,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mock-scaffolding.test.d.ts","sourceRoot":"","sources":["../../../../src/components/scaffolding/mock-scaffolding.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { Output, render } from "@alloy-js/core";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { MockHelpers } from "./mock-scaffolding.js";
|
|
5
|
+
function findFileContent(output, pathSuffix) {
|
|
6
|
+
function search(dir) {
|
|
7
|
+
for (const item of dir.contents) {
|
|
8
|
+
if ("contents" in item && typeof item.contents === "string" && (item.path === pathSuffix || item.path.endsWith("/" + pathSuffix))) {
|
|
9
|
+
return item.contents;
|
|
10
|
+
}
|
|
11
|
+
if ("contents" in item && Array.isArray(item.contents)) {
|
|
12
|
+
const found = search(item);
|
|
13
|
+
if (found) return found;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return undefined;
|
|
17
|
+
}
|
|
18
|
+
return search(output);
|
|
19
|
+
}
|
|
20
|
+
describe("MockHelpers", () => {
|
|
21
|
+
it("renders initializer interface", () => {
|
|
22
|
+
const output = render(_$createComponent(Output, {
|
|
23
|
+
get children() {
|
|
24
|
+
return _$createComponent(MockHelpers, {
|
|
25
|
+
interfaceRegistrations: []
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}));
|
|
29
|
+
const content = findFileContent(output, "IInitializer.cs");
|
|
30
|
+
expect(content).toBeDefined();
|
|
31
|
+
expect(content).toContain("IInitializer");
|
|
32
|
+
});
|
|
33
|
+
it("renders initializer implementation", () => {
|
|
34
|
+
const output = render(_$createComponent(Output, {
|
|
35
|
+
get children() {
|
|
36
|
+
return _$createComponent(MockHelpers, {
|
|
37
|
+
interfaceRegistrations: []
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
const content = findFileContent(output, "Initializer.cs");
|
|
42
|
+
expect(content).toBeDefined();
|
|
43
|
+
expect(content).toContain("class Initializer : IInitializer");
|
|
44
|
+
});
|
|
45
|
+
it("renders mock registration with interface registrations", () => {
|
|
46
|
+
const output = render(_$createComponent(Output, {
|
|
47
|
+
get children() {
|
|
48
|
+
return _$createComponent(MockHelpers, {
|
|
49
|
+
interfaceRegistrations: ["IPetStore, MockPetStore"]
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
const content = findFileContent(output, "MockRegistration.cs");
|
|
54
|
+
expect(content).toBeDefined();
|
|
55
|
+
expect(content).toContain("MockRegistration");
|
|
56
|
+
expect(content).toContain("IPetStore, MockPetStore");
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=mock-scaffolding.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Output","render","describe","expect","it","MockHelpers","findFileContent","output","pathSuffix","search","dir","item","contents","path","endsWith","Array","isArray","found","undefined","_$createComponent","children","interfaceRegistrations","content","toBeDefined","toContain"],"sources":["../../../../src/components/scaffolding/mock-scaffolding.test.tsx"],"sourcesContent":[null],"mappings":";AAAA,SAASA,MAAM,EAAEC,MAAM,QAAQ,gBAAgB;AAC/C,SAASC,QAAQ,EAAEC,MAAM,EAAEC,EAAE,QAAQ,QAAQ;AAC7C,SAASC,WAAW;AAEpB,SAASC,eAAeA,CAACC,MAAW,EAAEC,UAAkB,EAAsB;EAC5E,SAASC,MAAMA,CAACC,GAAQ,EAAsB;IAC5C,KAAK,MAAMC,IAAI,IAAID,GAAG,CAACE,QAAQ,EAAE;MAC/B,IACE,UAAU,IAAID,IAAI,IAClB,OAAOA,IAAI,CAACC,QAAQ,KAAK,QAAQ,KAChCD,IAAI,CAACE,IAAI,KAAKL,UAAU,IAAIG,IAAI,CAACE,IAAI,CAACC,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AE,CAAC,wDAAwD,EAAE,MAAM;IACjE,MAAMG,MAAM,GAAGN,MAAM,CAAAkB,iBAAA,CAClBnB,MAAM;MAAA,IAAAoB,SAAA;QAAA,OAAAD,iBAAA,CACJd,WAAW;UAACgB,sBAAsB,EAAE,CAAC,yBAAyB;QAAC;MAAA;IAAA,EAEpE,CAAC;IACD,MAAMC,OAAO,GAAGhB,eAAe,CAACC,MAAM,EAAE,qBAAqB,CAAC;IAC9DJ,MAAM,CAACmB,OAAO,CAAC,CAACC,WAAW,CAAC,CAAC;IAC7BpB,MAAM,CAACmB,OAAO,CAAC,CAACE,SAAS,CAAC,kBAAkB,CAAC;IAC7CrB,MAAM,CAACmB,OAAO,CAAC,CAACE,SAAS,CAAC,yBAAyB,CAAC;EACtD,CAAC,CAAC;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
|
+
/**
|
|
3
|
+
* Renders the Base64UrlJsonConverter.
|
|
4
|
+
* Converts between base64url-encoded strings and byte arrays.
|
|
5
|
+
*/
|
|
6
|
+
export declare function Base64UrlJsonConverter(): Children;
|
|
7
|
+
//# sourceMappingURL=base64-url-json-converter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base64-url-json-converter.d.ts","sourceRoot":"","sources":["../../../../src/components/serialization/base64-url-json-converter.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAIrD;;;GAGG;AACH,wBAAgB,sBAAsB,IAAI,QAAQ,CA+CjD"}
|