@typespec/http-client-js 0.7.0-dev.2 → 0.7.0-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/components/client-context/client-context-declaration.d.ts +2 -3
- package/dist/src/components/client-context/client-context-declaration.d.ts.map +1 -1
- package/dist/src/components/client-context/client-context-declaration.js +2 -2
- package/dist/src/components/client-context/client-context-factory.d.ts +3 -3
- package/dist/src/components/client-context/client-context-factory.d.ts.map +1 -1
- package/dist/src/components/client-context/client-context-factory.js +10 -10
- package/dist/src/components/client-context/client-context-options.d.ts +3 -3
- package/dist/src/components/client-context/client-context-options.d.ts.map +1 -1
- package/dist/src/components/client-context/client-context-options.js +3 -3
- package/dist/src/components/client-context/client-context.d.ts +3 -3
- package/dist/src/components/client-context/client-context.d.ts.map +1 -1
- package/dist/src/components/client-context/parametrized-endpoint.d.ts +3 -3
- package/dist/src/components/client-context/parametrized-endpoint.d.ts.map +1 -1
- package/dist/src/components/client-context/parametrized-endpoint.js +5 -5
- package/dist/src/components/client-directory.d.ts +4 -4
- package/dist/src/components/client-directory.d.ts.map +1 -1
- package/dist/src/components/client-directory.js +5 -5
- package/dist/src/components/client-operation.d.ts +4 -4
- package/dist/src/components/client-operation.d.ts.map +1 -1
- package/dist/src/components/client-operation.js +6 -6
- package/dist/src/components/client.d.ts +5 -5
- package/dist/src/components/client.d.ts.map +1 -1
- package/dist/src/components/client.js +14 -14
- package/dist/src/components/encoding-provider.d.ts +1 -1
- package/dist/src/components/encoding-provider.d.ts.map +1 -1
- package/dist/src/components/http-request-parameters-expression.d.ts +4 -4
- package/dist/src/components/http-request-parameters-expression.d.ts.map +1 -1
- package/dist/src/components/http-request-parameters-expression.js +10 -10
- package/dist/src/components/models.d.ts +1 -2
- package/dist/src/components/models.d.ts.map +1 -1
- package/dist/src/components/models.js +2 -3
- package/dist/src/components/operation-handlers/operation-pipeline.d.ts +1 -2
- package/dist/src/components/operation-handlers/operation-pipeline.d.ts.map +1 -1
- package/dist/src/components/operation-handlers/operation-pipeline.js +2 -2
- package/dist/src/components/operation-handlers/paging/page-response.d.ts +2 -3
- package/dist/src/components/operation-handlers/paging/page-response.d.ts.map +1 -1
- package/dist/src/components/operation-handlers/paging/page-response.js +3 -3
- package/dist/src/components/operation-handlers/paging/page-settings.d.ts +2 -3
- package/dist/src/components/operation-handlers/paging/page-settings.d.ts.map +1 -1
- package/dist/src/components/operation-handlers/paging/page-settings.js +3 -3
- package/dist/src/components/operation-handlers/paging/paginated-operation-handler.d.ts.map +1 -1
- package/dist/src/components/operation-handlers/paging/paginated-operation-handler.js +16 -16
- package/dist/src/components/operation-handlers/paging/request-send.d.ts +2 -3
- package/dist/src/components/operation-handlers/paging/request-send.d.ts.map +1 -1
- package/dist/src/components/operation-handlers/paging/request-send.js +1 -2
- package/dist/src/components/operation-handlers/types.d.ts +1 -1
- package/dist/src/components/operation-handlers/types.d.ts.map +1 -1
- package/dist/src/components/operation-options.d.ts +2 -3
- package/dist/src/components/operation-options.d.ts.map +1 -1
- package/dist/src/components/operation-options.js +3 -3
- package/dist/src/components/operation-parameters.d.ts +2 -2
- package/dist/src/components/operation-parameters.d.ts.map +1 -1
- package/dist/src/components/operation-parameters.js +2 -2
- package/dist/src/components/output.d.ts +3 -3
- package/dist/src/components/output.d.ts.map +1 -1
- package/dist/src/components/static-helpers/bytes-encoding.d.ts +6 -5
- package/dist/src/components/static-helpers/bytes-encoding.d.ts.map +1 -1
- package/dist/src/components/static-helpers/bytes-encoding.js +15 -19
- package/dist/src/components/static-helpers/interfaces.d.ts +3 -4
- package/dist/src/components/static-helpers/interfaces.d.ts.map +1 -1
- package/dist/src/components/static-helpers/interfaces.js +3 -3
- package/dist/src/components/static-helpers/multipart-helpers.d.ts +4 -5
- package/dist/src/components/static-helpers/multipart-helpers.d.ts.map +1 -1
- package/dist/src/components/static-helpers/multipart-helpers.js +8 -10
- package/dist/src/components/static-helpers/paging-helper.d.ts +3 -4
- package/dist/src/components/static-helpers/paging-helper.d.ts.map +1 -1
- package/dist/src/components/static-helpers/paging-helper.js +17 -23
- package/dist/src/components/static-helpers/rest-error.d.ts +3 -4
- package/dist/src/components/static-helpers/rest-error.d.ts.map +1 -1
- package/dist/src/components/static-helpers/rest-error.js +19 -25
- package/dist/src/components/testing/client-options.d.ts +3 -3
- package/dist/src/components/testing/client-options.d.ts.map +1 -1
- package/dist/src/components/testing/client-options.js +2 -2
- package/dist/src/components/transforms/content-type-encoding-provider.d.ts +1 -1
- package/dist/src/components/transforms/content-type-encoding-provider.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-array-transform.d.ts +6 -6
- package/dist/src/components/transforms/json/json-array-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-array-transform.js +5 -5
- package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts +4 -4
- package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-model-additional-properties-transform.js +4 -4
- package/dist/src/components/transforms/json/json-model-base-transform.d.ts +4 -4
- package/dist/src/components/transforms/json/json-model-base-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-model-property-transform.d.ts +3 -3
- package/dist/src/components/transforms/json/json-model-property-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-model-property-transform.js +3 -3
- package/dist/src/components/transforms/json/json-model-transform.d.ts +6 -6
- package/dist/src/components/transforms/json/json-model-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-model-transform.js +8 -8
- package/dist/src/components/transforms/json/json-record-transform.d.ts +6 -6
- package/dist/src/components/transforms/json/json-record-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-record-transform.js +5 -5
- package/dist/src/components/transforms/json/json-transform-discriminator.d.ts +5 -5
- package/dist/src/components/transforms/json/json-transform-discriminator.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-transform-discriminator.js +13 -13
- package/dist/src/components/transforms/json/json-transform.d.ts +6 -5
- package/dist/src/components/transforms/json/json-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-transform.js +2 -2
- package/dist/src/components/transforms/json/union-transform.d.ts +6 -6
- package/dist/src/components/transforms/json/union-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/union-transform.js +6 -6
- package/dist/src/components/transforms/json/utils/transport-namer.d.ts +1 -1
- package/dist/src/components/transforms/json/utils/transport-namer.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/array-part-transform.d.ts +3 -3
- package/dist/src/components/transforms/multipart/array-part-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/array-part-transform.js +5 -5
- package/dist/src/components/transforms/multipart/file-part-transform.d.ts +3 -3
- package/dist/src/components/transforms/multipart/file-part-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/file-part-transform.js +2 -2
- package/dist/src/components/transforms/multipart/multipart-transform.d.ts +1 -2
- package/dist/src/components/transforms/multipart/multipart-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/multipart-transform.js +2 -2
- package/dist/src/components/transforms/multipart/part-transform.d.ts +3 -3
- package/dist/src/components/transforms/multipart/part-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/simple-part-transform.d.ts +3 -3
- package/dist/src/components/transforms/multipart/simple-part-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/simple-part-transform.js +5 -5
- package/dist/src/components/transforms/operation-transform-declaration.d.ts +6 -6
- package/dist/src/components/transforms/operation-transform-declaration.d.ts.map +1 -1
- package/dist/src/components/transforms/operation-transform-declaration.js +3 -3
- package/dist/src/components/transforms/transform-name-policy.d.ts +1 -1
- package/dist/src/components/transforms/transform-name-policy.d.ts.map +1 -1
- package/dist/src/emitter.js +6 -6
- package/dist/src/utils/multipart.d.ts +1 -1
- package/dist/src/utils/multipart.d.ts.map +1 -1
- package/dist/src/utils/parameters.d.ts +2 -2
- package/dist/src/utils/parameters.d.ts.map +1 -1
- package/dist/src/utils/parameters.js +6 -6
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/client-context/client-context-declaration.tsx +2 -2
- package/src/components/client-context/client-context-factory.tsx +19 -19
- package/src/components/client-context/client-context-options.tsx +5 -5
- package/src/components/client-context/client-context.tsx +2 -2
- package/src/components/client-context/parametrized-endpoint.tsx +8 -8
- package/src/components/client-directory.tsx +10 -10
- package/src/components/client-operation.tsx +11 -11
- package/src/components/client.tsx +21 -21
- package/src/components/encoding-provider.tsx +1 -1
- package/src/components/http-request-parameters-expression.tsx +19 -19
- package/src/components/models.tsx +2 -3
- package/src/components/operation-handlers/operation-pipeline.tsx +2 -2
- package/src/components/operation-handlers/paging/page-response.tsx +4 -4
- package/src/components/operation-handlers/paging/page-settings.tsx +4 -4
- package/src/components/operation-handlers/paging/paginated-operation-handler.tsx +18 -19
- package/src/components/operation-handlers/paging/request-send.tsx +1 -2
- package/src/components/operation-handlers/types.tsx +1 -1
- package/src/components/operation-options.tsx +4 -4
- package/src/components/operation-parameters.tsx +3 -3
- package/src/components/output.tsx +2 -2
- package/src/components/serializers.tsx +1 -1
- package/src/components/static-helpers/bytes-encoding.tsx +17 -16
- package/src/components/static-helpers/interfaces.tsx +3 -3
- package/src/components/static-helpers/multipart-helpers.tsx +7 -7
- package/src/components/static-helpers/paging-helper.tsx +17 -20
- package/src/components/static-helpers/rest-error.tsx +17 -17
- package/src/components/testing/client-options.tsx +3 -3
- package/src/components/transforms/content-type-encoding-provider.tsx +1 -1
- package/src/components/transforms/json/json-array-transform.tsx +8 -8
- package/src/components/transforms/json/json-model-additional-properties-transform.tsx +6 -6
- package/src/components/transforms/json/json-model-base-transform.tsx +3 -3
- package/src/components/transforms/json/json-model-property-transform.tsx +6 -6
- package/src/components/transforms/json/json-model-transform.tsx +12 -14
- package/src/components/transforms/json/json-record-transform.tsx +8 -8
- package/src/components/transforms/json/json-transform-discriminator.tsx +12 -12
- package/src/components/transforms/json/json-transform.tsx +6 -5
- package/src/components/transforms/json/union-transform.tsx +8 -8
- package/src/components/transforms/json/utils/transport-namer.ts +1 -1
- package/src/components/transforms/multipart/array-part-transform.tsx +6 -5
- package/src/components/transforms/multipart/file-part-transform.tsx +5 -5
- package/src/components/transforms/multipart/multipart-transform.tsx +3 -3
- package/src/components/transforms/multipart/part-transform.tsx +2 -2
- package/src/components/transforms/multipart/simple-part-transform.tsx +8 -8
- package/src/components/transforms/operation-transform-declaration.tsx +7 -6
- package/src/components/transforms/operation-transform-expression.tsx +1 -1
- package/src/components/transforms/transform-name-policy.ts +1 -1
- package/src/emitter.tsx +11 -11
- package/src/utils/multipart.ts +1 -1
- package/src/utils/parameters.tsx +9 -9
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function PagingHelpers(): ay.Children;
|
|
1
|
+
export declare function getPagedAsyncIterableIteratorRefkey(): import("@alloy-js/core").Refkey;
|
|
2
|
+
export declare function getBuildPagedAsyncIteratorRefkey(): import("@alloy-js/core").Refkey;
|
|
3
|
+
export declare function PagingHelpers(): import("@alloy-js/core").Children;
|
|
5
4
|
//# sourceMappingURL=paging-helper.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paging-helper.d.ts","sourceRoot":"","sources":["../../../../src/components/static-helpers/paging-helper.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"paging-helper.d.ts","sourceRoot":"","sources":["../../../../src/components/static-helpers/paging-helper.tsx"],"names":[],"mappings":"AAGA,wBAAgB,mCAAmC,oCAElD;AAED,wBAAgB,gCAAgC,oCAE/C;AA6KD,wBAAgB,aAAa,sCAS5B"}
|
|
@@ -1,26 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code, Declaration, refkey } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
export function getPagedAsyncIterableIteratorRefkey() {
|
|
5
|
-
return
|
|
5
|
+
return refkey("PagedAsyncIterableIterator", "interface");
|
|
6
6
|
}
|
|
7
7
|
export function getBuildPagedAsyncIteratorRefkey() {
|
|
8
|
-
return
|
|
8
|
+
return refkey("buildPagedAsyncIterator", "function");
|
|
9
9
|
}
|
|
10
10
|
function getPagedResultRefkey() {
|
|
11
|
-
return
|
|
11
|
+
return refkey("PagedResult", "interface");
|
|
12
12
|
}
|
|
13
13
|
function getBuildPagedAsyncIteratorOptionsRefkey() {
|
|
14
|
-
return
|
|
14
|
+
return refkey("BuildPagedAsyncIteratorOptions", "interface");
|
|
15
15
|
}
|
|
16
16
|
function PagedAsyncIterableIteratorInterfaceDeclaration() {
|
|
17
|
-
return _$createComponent(
|
|
17
|
+
return _$createComponent(Declaration, {
|
|
18
18
|
name: "PagedAsyncIterableIterator",
|
|
19
19
|
get refkey() {
|
|
20
20
|
return getPagedAsyncIterableIteratorRefkey();
|
|
21
21
|
},
|
|
22
|
-
|
|
23
|
-
return ay.code`
|
|
22
|
+
children: code`
|
|
24
23
|
/**
|
|
25
24
|
* An interface that allows async iterable iteration both to completion and by page.
|
|
26
25
|
*/
|
|
@@ -47,18 +46,16 @@ export interface PagedAsyncIterableIterator<
|
|
|
47
46
|
byPage: (
|
|
48
47
|
settings?: TPageSettings,
|
|
49
48
|
) => AsyncIterableIterator<TPageResponse>;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
49
|
+
} `
|
|
52
50
|
});
|
|
53
51
|
}
|
|
54
52
|
function PagedResultInterfaceDeclaration() {
|
|
55
|
-
return _$createComponent(
|
|
53
|
+
return _$createComponent(Declaration, {
|
|
56
54
|
name: "PagedResult",
|
|
57
55
|
get refkey() {
|
|
58
56
|
return getPagedResultRefkey();
|
|
59
57
|
},
|
|
60
|
-
|
|
61
|
-
return ay.code`
|
|
58
|
+
children: code`
|
|
62
59
|
/**
|
|
63
60
|
* An interface that describes how to communicate with the service.
|
|
64
61
|
*/
|
|
@@ -86,18 +83,16 @@ interface PagedResult<
|
|
|
86
83
|
byPage: (
|
|
87
84
|
settings?: TPageSettings,
|
|
88
85
|
) => AsyncIterableIterator<TPageResponse>;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
86
|
+
}`
|
|
91
87
|
});
|
|
92
88
|
}
|
|
93
89
|
function BuildPagedAsyncIteratorOptionsInterfaceDeclaration() {
|
|
94
|
-
return _$createComponent(
|
|
90
|
+
return _$createComponent(Declaration, {
|
|
95
91
|
name: "BuildPagedAsyncIteratorOptions",
|
|
96
92
|
get refkey() {
|
|
97
93
|
return getBuildPagedAsyncIteratorOptionsRefkey();
|
|
98
94
|
},
|
|
99
|
-
|
|
100
|
-
return ay.code`
|
|
95
|
+
children: code`
|
|
101
96
|
/**
|
|
102
97
|
* Options for the paging helper
|
|
103
98
|
*/
|
|
@@ -108,18 +103,17 @@ export interface BuildPagedAsyncIteratorOptions<
|
|
|
108
103
|
> {
|
|
109
104
|
getElements: (response: TPageResponse) => TElement[];
|
|
110
105
|
getPagedResponse: (nextToken?: string, settings?: TPageSettings) => Promise<{ pagedResponse: TPageResponse; nextToken?: string } | undefined>;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
106
|
+
}`
|
|
113
107
|
});
|
|
114
108
|
}
|
|
115
109
|
function BuildPagedAsyncIteratorInterfaceDeclaration() {
|
|
116
|
-
return _$createComponent(
|
|
110
|
+
return _$createComponent(Declaration, {
|
|
117
111
|
name: "buildPagedAsyncIterator",
|
|
118
112
|
get refkey() {
|
|
119
113
|
return getBuildPagedAsyncIteratorRefkey();
|
|
120
114
|
},
|
|
121
115
|
get children() {
|
|
122
|
-
return
|
|
116
|
+
return code`
|
|
123
117
|
/**
|
|
124
118
|
* Helper to paginate results in a generic way and return a PagedAsyncIterableIterator
|
|
125
119
|
*/
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function
|
|
3
|
-
export declare function
|
|
4
|
-
export declare function RestError(): ay.Children[];
|
|
1
|
+
export declare function getRestErrorRefkey(): import("@alloy-js/core").Refkey;
|
|
2
|
+
export declare function getCreateRestErrorRefkey(): import("@alloy-js/core").Refkey;
|
|
3
|
+
export declare function RestError(): import("@alloy-js/core").Children[];
|
|
5
4
|
//# sourceMappingURL=rest-error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rest-error.d.ts","sourceRoot":"","sources":["../../../../src/components/static-helpers/rest-error.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rest-error.d.ts","sourceRoot":"","sources":["../../../../src/components/static-helpers/rest-error.tsx"],"names":[],"mappings":"AAIA,wBAAgB,kBAAkB,oCAEjC;AAED,wBAAgB,wBAAwB,oCAEvC;AAED,wBAAgB,SAAS,wCAyFxB"}
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { createComponent as _$createComponent
|
|
2
|
-
import
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code, List, refkey, StatementList } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { httpRuntimeTemplateLib } from "../external-packages/ts-http-runtime.js";
|
|
5
5
|
export function getRestErrorRefkey() {
|
|
6
|
-
return
|
|
6
|
+
return refkey("rest-error", "static-helpers", "class");
|
|
7
7
|
}
|
|
8
8
|
export function getCreateRestErrorRefkey() {
|
|
9
|
-
return
|
|
9
|
+
return refkey("create-rest-error", "static-helpers", "function");
|
|
10
10
|
}
|
|
11
11
|
export function RestError() {
|
|
12
|
-
const requestRefkey =
|
|
13
|
-
const responseRefkey =
|
|
14
|
-
const statusRefkey =
|
|
15
|
-
const bodyRefkey =
|
|
16
|
-
const headersRefkey =
|
|
17
|
-
const constructorRefkey =
|
|
18
|
-
const fromHttpResponseRefkey =
|
|
12
|
+
const requestRefkey = refkey("request", "rest-error-class-field");
|
|
13
|
+
const responseRefkey = refkey("response", "rest-error-class-field");
|
|
14
|
+
const statusRefkey = refkey("status", "rest-error-class-field");
|
|
15
|
+
const bodyRefkey = refkey("body", "rest-error-class-field");
|
|
16
|
+
const headersRefkey = refkey("headers", "rest-error-class-field");
|
|
17
|
+
const constructorRefkey = refkey("constructor", "rest-error-class-method");
|
|
18
|
+
const fromHttpResponseRefkey = refkey("from-http-response", "rest-error-class-method");
|
|
19
19
|
const restErrorClass = _$createComponent(ts.ClassDeclaration, {
|
|
20
20
|
"export": true,
|
|
21
21
|
name: "RestError",
|
|
@@ -24,7 +24,7 @@ export function RestError() {
|
|
|
24
24
|
return getRestErrorRefkey();
|
|
25
25
|
},
|
|
26
26
|
get children() {
|
|
27
|
-
return [_$createComponent(
|
|
27
|
+
return [_$createComponent(StatementList, {
|
|
28
28
|
get children() {
|
|
29
29
|
return [_$createComponent(ts.ClassField, {
|
|
30
30
|
"public": true,
|
|
@@ -59,7 +59,7 @@ export function RestError() {
|
|
|
59
59
|
refkey: headersRefkey
|
|
60
60
|
})];
|
|
61
61
|
}
|
|
62
|
-
}), _$createComponent(
|
|
62
|
+
}), _$createComponent(List, {
|
|
63
63
|
hardline: true,
|
|
64
64
|
get children() {
|
|
65
65
|
return [_$createComponent(ts.ClassMethod, {
|
|
@@ -75,8 +75,7 @@ export function RestError() {
|
|
|
75
75
|
},
|
|
76
76
|
returnType: null,
|
|
77
77
|
refkey: constructorRefkey,
|
|
78
|
-
|
|
79
|
-
return ay.code`
|
|
78
|
+
children: code`
|
|
80
79
|
// Create an error message that includes relevant details.
|
|
81
80
|
super(\`$\{message\} - HTTP $\{response.status} received for $\{response.request.method} $\{response.request.url}\`);
|
|
82
81
|
this.name = 'RestError';
|
|
@@ -88,8 +87,7 @@ export function RestError() {
|
|
|
88
87
|
|
|
89
88
|
// Set the prototype explicitly.
|
|
90
89
|
Object.setPrototypeOf(this, RestError.prototype);
|
|
91
|
-
|
|
92
|
-
}
|
|
90
|
+
`
|
|
93
91
|
}), _$createComponent(ts.ClassMethod, {
|
|
94
92
|
"static": true,
|
|
95
93
|
name: "fromHttpResponse",
|
|
@@ -103,12 +101,10 @@ export function RestError() {
|
|
|
103
101
|
return getRestErrorRefkey();
|
|
104
102
|
},
|
|
105
103
|
refkey: fromHttpResponseRefkey,
|
|
106
|
-
|
|
107
|
-
return ay.code`
|
|
104
|
+
children: code`
|
|
108
105
|
const defaultMessage = \`Unexpected HTTP status code: $\{response.status}\`;
|
|
109
106
|
return new RestError(defaultMessage, response);
|
|
110
|
-
|
|
111
|
-
}
|
|
107
|
+
`
|
|
112
108
|
})];
|
|
113
109
|
}
|
|
114
110
|
})];
|
|
@@ -129,11 +125,9 @@ export function RestError() {
|
|
|
129
125
|
get refkey() {
|
|
130
126
|
return getCreateRestErrorRefkey();
|
|
131
127
|
},
|
|
132
|
-
|
|
133
|
-
return ay.code`
|
|
128
|
+
children: code`
|
|
134
129
|
return ${fromHttpResponseRefkey}(response);
|
|
135
|
-
|
|
136
|
-
}
|
|
130
|
+
`
|
|
137
131
|
});
|
|
138
132
|
return [restErrorClass, "\n\n", createRestError];
|
|
139
133
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
2
|
export interface ClientTestOptions {
|
|
3
3
|
}
|
|
4
|
-
export declare function ClientTestOptions(_props: ClientTestOptions):
|
|
5
|
-
export declare function addClientTestOptions(options:
|
|
4
|
+
export declare function ClientTestOptions(_props: ClientTestOptions): Children;
|
|
5
|
+
export declare function addClientTestOptions(options: Children[], settings?: {
|
|
6
6
|
location?: "front" | "back";
|
|
7
7
|
}): void;
|
|
8
8
|
//# sourceMappingURL=client-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-options.d.ts","sourceRoot":"","sources":["../../../../src/components/testing/client-options.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client-options.d.ts","sourceRoot":"","sources":["../../../../src/components/testing/client-options.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AAEhD,MAAM,WAAW,iBAAiB;CAAG;AAErC,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,YAU1D;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,QAAQ,EAAE,EACnB,QAAQ,GAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;CAA0B,QAUlE"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { code } from "@alloy-js/core";
|
|
3
3
|
export function ClientTestOptions(_props) {
|
|
4
4
|
if (process.env.TYPESPEC_JS_EMITTER_TESTING !== "true") {
|
|
5
5
|
return null;
|
|
6
6
|
}
|
|
7
|
-
return
|
|
7
|
+
return code`
|
|
8
8
|
allowInsecureConnection: true,
|
|
9
9
|
retryOptions: {
|
|
10
10
|
maxRetries: 1,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-type-encoding-provider.d.ts","sourceRoot":"","sources":["../../../../src/components/transforms/content-type-encoding-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"content-type-encoding-provider.d.ts","sourceRoot":"","sources":["../../../../src/components/transforms/content-type-encoding-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI/C,MAAM,WAAW,gCAAgC;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,gCAAgC,YAgBlF"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Model } from "@typespec/compiler";
|
|
1
|
+
import { type Children, type Refkey } from "@alloy-js/core";
|
|
2
|
+
import type { Model } from "@typespec/compiler";
|
|
3
3
|
export interface JsonArrayTransformProps {
|
|
4
|
-
itemRef:
|
|
4
|
+
itemRef: Refkey | Children;
|
|
5
5
|
type: Model;
|
|
6
6
|
target: "transport" | "application";
|
|
7
7
|
}
|
|
8
|
-
export declare function JsonArrayTransform(props: JsonArrayTransformProps):
|
|
9
|
-
export declare function getJsonArrayTransformRefkey(type: Model, target: "transport" | "application"):
|
|
8
|
+
export declare function JsonArrayTransform(props: JsonArrayTransformProps): Children;
|
|
9
|
+
export declare function getJsonArrayTransformRefkey(type: Model, target: "transport" | "application"): Refkey;
|
|
10
10
|
export interface JsonArrayTransformDeclarationProps {
|
|
11
11
|
type: Model;
|
|
12
12
|
target: "transport" | "application";
|
|
13
13
|
}
|
|
14
|
-
export declare function JsonArrayTransformDeclaration(props: JsonArrayTransformDeclarationProps):
|
|
14
|
+
export declare function JsonArrayTransformDeclaration(props: JsonArrayTransformDeclarationProps): Children;
|
|
15
15
|
//# sourceMappingURL=json-array-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-array-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-array-transform.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-array-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-array-transform.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAIhD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,YAqBhE;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,WAAW,GAAG,aAAa,GAClC,MAAM,CAER;AAED,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kCAAkC,YAqCtF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import * as ay from "@alloy-js/core";
|
|
3
2
|
import * as ts from "@alloy-js/typescript";
|
|
4
3
|
import * as ef from "@typespec/emitter-framework/typescript";
|
|
4
|
+
import { code, refkey } from "@alloy-js/core";
|
|
5
5
|
import { useTsp } from "@typespec/emitter-framework";
|
|
6
6
|
import { JsonTransform } from "./json-transform.js";
|
|
7
7
|
export function JsonArrayTransform(props) {
|
|
@@ -12,7 +12,7 @@ export function JsonArrayTransform(props) {
|
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
const elementType = $.array.getElementType(props.type);
|
|
15
|
-
return
|
|
15
|
+
return code`
|
|
16
16
|
if(!${props.itemRef}) {
|
|
17
17
|
return ${props.itemRef} as any;
|
|
18
18
|
}
|
|
@@ -33,7 +33,7 @@ export function JsonArrayTransform(props) {
|
|
|
33
33
|
`;
|
|
34
34
|
}
|
|
35
35
|
export function getJsonArrayTransformRefkey(type, target) {
|
|
36
|
-
return
|
|
36
|
+
return refkey(type, "json_array_transform", target);
|
|
37
37
|
}
|
|
38
38
|
export function JsonArrayTransformDeclaration(props) {
|
|
39
39
|
const {
|
|
@@ -46,12 +46,12 @@ export function JsonArrayTransformDeclaration(props) {
|
|
|
46
46
|
const elementName = "name" in elementType && typeof elementType.name === "string" ? elementType.name : "element";
|
|
47
47
|
const namePolicy = ts.useTSNamePolicy();
|
|
48
48
|
const transformName = namePolicy.getName(`json_Array_${elementName}_to_${props.target}_transform`, "function");
|
|
49
|
-
const itemType =
|
|
49
|
+
const itemType = code`Array<${_$createComponent(ef.TypeExpression, {
|
|
50
50
|
type: elementType
|
|
51
51
|
})}>`;
|
|
52
52
|
const returnType = props.target === "transport" ? "any" : itemType;
|
|
53
53
|
const inputType = props.target === "transport" ? [itemType, " | null"] : "any";
|
|
54
|
-
const inputRef =
|
|
54
|
+
const inputRef = refkey();
|
|
55
55
|
const parameters = [{
|
|
56
56
|
name: "items_",
|
|
57
57
|
type: inputType,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Model } from "@typespec/compiler";
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
|
+
import type { Model } from "@typespec/compiler";
|
|
3
3
|
export interface JsonAdditionalPropertiesTransformProps {
|
|
4
|
-
itemRef:
|
|
4
|
+
itemRef: Children;
|
|
5
5
|
type: Model;
|
|
6
6
|
target: "transport" | "application";
|
|
7
7
|
}
|
|
8
|
-
export declare function JsonAdditionalPropertiesTransform(props: JsonAdditionalPropertiesTransformProps):
|
|
8
|
+
export declare function JsonAdditionalPropertiesTransform(props: JsonAdditionalPropertiesTransformProps): Children;
|
|
9
9
|
//# sourceMappingURL=json-model-additional-properties-transform.d.ts.map
|
package/dist/src/components/transforms/json/json-model-additional-properties-transform.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-model-additional-properties-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-model-additional-properties-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"json-model-additional-properties-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-model-additional-properties-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAiB,MAAM,gBAAgB,CAAC;AAEzD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAIhD,MAAM,WAAW,sCAAsC;IACrD,OAAO,EAAE,QAAQ,CAAC;IAClB,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,iCAAiC,CAAC,KAAK,EAAE,sCAAsC,YAwC9F"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, memo as _$memo } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { code, mapJoin } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { useTsp } from "@typespec/emitter-framework";
|
|
5
5
|
import { getJsonRecordTransformRefkey } from "./json-record-transform.js";
|
|
@@ -15,13 +15,13 @@ export function JsonAdditionalPropertiesTransform(props) {
|
|
|
15
15
|
const properties = $.model.getProperties(props.type, {
|
|
16
16
|
includeExtended: true
|
|
17
17
|
});
|
|
18
|
-
const destructuredProperties =
|
|
18
|
+
const destructuredProperties = mapJoin(() => properties, name => name, {
|
|
19
19
|
joiner: ",",
|
|
20
20
|
ender: ","
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
// Inline destructuring that extracts the properties and passes the rest to jsonRecordUnknownToApplicationTransform_2
|
|
24
|
-
const inlineDestructure =
|
|
24
|
+
const inlineDestructure = code`
|
|
25
25
|
${getJsonRecordTransformRefkey(additionalProperties, props.target)}(
|
|
26
26
|
(({ ${destructuredProperties} ...rest }) => rest)(${props.itemRef})
|
|
27
27
|
),
|
|
@@ -31,6 +31,6 @@ export function JsonAdditionalPropertiesTransform(props) {
|
|
|
31
31
|
children: inlineDestructure
|
|
32
32
|
})];
|
|
33
33
|
}
|
|
34
|
-
const itemRef =
|
|
34
|
+
const itemRef = code`${props.itemRef}.additionalProperties`;
|
|
35
35
|
return ["...(", _$memo(() => getJsonRecordTransformRefkey(additionalProperties, props.target)), "(", itemRef, ") ),"];
|
|
36
36
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Model } from "@typespec/compiler";
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
|
+
import type { Model } from "@typespec/compiler";
|
|
3
3
|
export interface JsonModelBaseTransformProps {
|
|
4
|
-
itemRef:
|
|
4
|
+
itemRef: Children;
|
|
5
5
|
type: Model;
|
|
6
6
|
target: "transport" | "application";
|
|
7
7
|
}
|
|
8
|
-
export declare function JsonModelBaseTransform(props: JsonModelBaseTransformProps):
|
|
8
|
+
export declare function JsonModelBaseTransform(props: JsonModelBaseTransformProps): Children;
|
|
9
9
|
//# sourceMappingURL=json-model-base-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-model-base-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-model-base-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"json-model-base-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-model-base-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAGhD,MAAM,WAAW,2BAA2B;IAC1C,OAAO,EAAE,QAAQ,CAAC;IAClB,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,2BAA2B,YAaxE"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Children, Refkey } from "@alloy-js/core";
|
|
2
2
|
import { ModelProperty } from "@typespec/compiler";
|
|
3
3
|
export interface JsonModelPropertyTransformProps {
|
|
4
|
-
itemRef:
|
|
4
|
+
itemRef: Refkey | Children;
|
|
5
5
|
type: ModelProperty;
|
|
6
6
|
target: "transport" | "application";
|
|
7
7
|
}
|
|
8
|
-
export declare function JsonModelPropertyTransform(props: JsonModelPropertyTransformProps):
|
|
8
|
+
export declare function JsonModelPropertyTransform(props: JsonModelPropertyTransformProps): Children;
|
|
9
9
|
//# sourceMappingURL=json-model-property-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-model-property-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-model-property-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"json-model-property-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-model-property-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAA2B,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAE3E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAOnD,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,IAAI,EAAE,aAAa,CAAC;IACpB,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,YAoChF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { code, NamePolicyContext } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { useTsp } from "@typespec/emitter-framework";
|
|
5
5
|
import { unpackProperty } from "../../utils/unpack-model-property.js";
|
|
@@ -16,7 +16,7 @@ export function JsonModelPropertyTransform(props) {
|
|
|
16
16
|
const applicationName = transformNamer.getApplicationName(props.type);
|
|
17
17
|
const targetName = props.target === "transport" ? transportName : applicationName;
|
|
18
18
|
const sourceName = props.target === "transport" ? applicationName : transportName;
|
|
19
|
-
const propertyValueRef = props.itemRef ?
|
|
19
|
+
const propertyValueRef = props.itemRef ? code`${props.itemRef}.${sourceName}` : sourceName;
|
|
20
20
|
let propertyValue;
|
|
21
21
|
if ($.scalar.is(propertyValueType)) {
|
|
22
22
|
propertyValue = _$createComponent(ScalarDataTransform, {
|
|
@@ -38,7 +38,7 @@ export function JsonModelPropertyTransform(props) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
if (props.target === "transport") {
|
|
41
|
-
return _$createComponent(
|
|
41
|
+
return _$createComponent(NamePolicyContext.Provider, {
|
|
42
42
|
value: {
|
|
43
43
|
getName: n => n
|
|
44
44
|
},
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Model } from "@typespec/compiler";
|
|
1
|
+
import { type Children, type Refkey } from "@alloy-js/core";
|
|
2
|
+
import type { Model } from "@typespec/compiler";
|
|
3
3
|
export interface JsonModelTransformProps {
|
|
4
|
-
itemRef:
|
|
4
|
+
itemRef: Refkey | Children;
|
|
5
5
|
type: Model;
|
|
6
6
|
target: "transport" | "application";
|
|
7
7
|
}
|
|
8
|
-
export declare function JsonModelTransform(props: JsonModelTransformProps):
|
|
9
|
-
export declare function getJsonModelTransformRefkey(type: Model, target: "transport" | "application"):
|
|
8
|
+
export declare function JsonModelTransform(props: JsonModelTransformProps): Children;
|
|
9
|
+
export declare function getJsonModelTransformRefkey(type: Model, target: "transport" | "application"): Refkey;
|
|
10
10
|
export interface JsonModelTransformDeclarationProps {
|
|
11
11
|
type: Model;
|
|
12
12
|
target: "transport" | "application";
|
|
13
13
|
}
|
|
14
|
-
export declare function JsonModelTransformDeclaration(props: JsonModelTransformDeclarationProps):
|
|
14
|
+
export declare function JsonModelTransformDeclaration(props: JsonModelTransformDeclarationProps): Children;
|
|
15
15
|
//# sourceMappingURL=json-model-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-model-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-model-transform.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-model-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-model-transform.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAa,KAAK,MAAM,EAAU,MAAM,gBAAgB,CAAC;AAC/E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAUhD,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,YAoChE;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,WAAW,GAAG,aAAa,GAClC,MAAM,CAER;AAED,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kCAAkC,GAAG,QAAQ,CA6CjG"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, memo as _$memo, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import * as ay from "@alloy-js/core";
|
|
3
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
|
+
import { code, For, refkey } from "@alloy-js/core";
|
|
4
4
|
import { useTsp } from "@typespec/emitter-framework";
|
|
5
5
|
import { JsonAdditionalPropertiesTransform } from "./json-model-additional-properties-transform.js";
|
|
6
6
|
import { JsonModelPropertyTransform } from "./json-model-property-transform.js";
|
|
@@ -28,7 +28,7 @@ export function JsonModelTransform(props) {
|
|
|
28
28
|
get type() {
|
|
29
29
|
return props.type;
|
|
30
30
|
}
|
|
31
|
-
}), _$memo(() => discriminator ? ["...", discriminate, "(", _$memo(() => props.itemRef), "),"] : null), _$createComponent(
|
|
31
|
+
}), _$memo(() => discriminator ? ["...", discriminate, "(", _$memo(() => props.itemRef), "),"] : null), _$createComponent(For, {
|
|
32
32
|
each: properties,
|
|
33
33
|
joiner: ",",
|
|
34
34
|
line: true,
|
|
@@ -48,7 +48,7 @@ export function JsonModelTransform(props) {
|
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
export function getJsonModelTransformRefkey(type, target) {
|
|
51
|
-
return
|
|
51
|
+
return refkey(type, "json_model_transform", target);
|
|
52
52
|
}
|
|
53
53
|
export function JsonModelTransformDeclaration(props) {
|
|
54
54
|
const {
|
|
@@ -56,9 +56,9 @@ export function JsonModelTransformDeclaration(props) {
|
|
|
56
56
|
} = useTsp();
|
|
57
57
|
const namePolicy = ts.useTSNamePolicy();
|
|
58
58
|
const transformName = namePolicy.getName(`json_${props.type.name}_to_${props.target}_transform`, "function");
|
|
59
|
-
const returnType = props.target === "transport" ? "any" :
|
|
60
|
-
const inputType = props.target === "transport" ? [_$memo(() =>
|
|
61
|
-
const inputRef =
|
|
59
|
+
const returnType = props.target === "transport" ? "any" : refkey(props.type);
|
|
60
|
+
const inputType = props.target === "transport" ? [_$memo(() => refkey(props.type)), " | null"] : "any";
|
|
61
|
+
const inputRef = refkey();
|
|
62
62
|
const parameters = [
|
|
63
63
|
// Make the input optional to make the transform more robust and check against null and undefined
|
|
64
64
|
{
|
|
@@ -89,12 +89,12 @@ export function JsonModelTransformDeclaration(props) {
|
|
|
89
89
|
parameters: parameters,
|
|
90
90
|
refkey: declarationRefkey,
|
|
91
91
|
get children() {
|
|
92
|
-
return [
|
|
92
|
+
return [code`
|
|
93
93
|
if(!${inputRef}) {
|
|
94
94
|
return ${inputRef} as any;
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
|
|
97
|
+
`, "return ", _$createComponent(JsonModelTransform, _$mergeProps(props, {
|
|
98
98
|
itemRef: inputRef
|
|
99
99
|
})), "!;"];
|
|
100
100
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Model } from "@typespec/compiler";
|
|
1
|
+
import { type Children, type Refkey } from "@alloy-js/core";
|
|
2
|
+
import type { Model } from "@typespec/compiler";
|
|
3
3
|
export interface JsonRecordTransformProps {
|
|
4
|
-
itemRef:
|
|
4
|
+
itemRef: Refkey | Children;
|
|
5
5
|
type: Model;
|
|
6
6
|
target: "transport" | "application";
|
|
7
7
|
}
|
|
8
|
-
export declare function JsonRecordTransform(props: JsonRecordTransformProps):
|
|
9
|
-
export declare function getJsonRecordTransformRefkey(type: Model, target: "transport" | "application"):
|
|
8
|
+
export declare function JsonRecordTransform(props: JsonRecordTransformProps): Children;
|
|
9
|
+
export declare function getJsonRecordTransformRefkey(type: Model, target: "transport" | "application"): Refkey;
|
|
10
10
|
export interface JsonRecordTransformDeclarationProps {
|
|
11
11
|
type: Model;
|
|
12
12
|
target: "transport" | "application";
|
|
13
13
|
}
|
|
14
|
-
export declare function JsonRecordTransformDeclaration(props: JsonRecordTransformDeclarationProps):
|
|
14
|
+
export declare function JsonRecordTransformDeclaration(props: JsonRecordTransformDeclarationProps): Children;
|
|
15
15
|
//# sourceMappingURL=json-record-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-record-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-record-transform.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"json-record-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-record-transform.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AAC1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAIhD,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,YAuBlE;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,WAAW,GAAG,aAAa,GAClC,MAAM,CAER;AAED,MAAM,WAAW,mCAAmC;IAClD,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,mCAAmC,YAqCxF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import * as ay from "@alloy-js/core";
|
|
3
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
|
+
import { code, refkey } from "@alloy-js/core";
|
|
4
4
|
import { useTsp } from "@typespec/emitter-framework";
|
|
5
5
|
import { JsonTransform } from "./json-transform.js";
|
|
6
6
|
export function JsonRecordTransform(props) {
|
|
@@ -13,7 +13,7 @@ export function JsonRecordTransform(props) {
|
|
|
13
13
|
const elementType = $.record.getElementType(props.type);
|
|
14
14
|
|
|
15
15
|
// TODO: Do we need to cast?
|
|
16
|
-
return
|
|
16
|
+
return code`
|
|
17
17
|
if(!${props.itemRef}) {
|
|
18
18
|
return ${props.itemRef} as any;
|
|
19
19
|
}
|
|
@@ -35,7 +35,7 @@ export function JsonRecordTransform(props) {
|
|
|
35
35
|
`;
|
|
36
36
|
}
|
|
37
37
|
export function getJsonRecordTransformRefkey(type, target) {
|
|
38
|
-
return
|
|
38
|
+
return refkey(type, "json_record_transform", target);
|
|
39
39
|
}
|
|
40
40
|
export function JsonRecordTransformDeclaration(props) {
|
|
41
41
|
const {
|
|
@@ -48,10 +48,10 @@ export function JsonRecordTransformDeclaration(props) {
|
|
|
48
48
|
const elementName = "name" in elementType && typeof elementType.name === "string" ? elementType.name : "element";
|
|
49
49
|
const namePolicy = ts.useTSNamePolicy();
|
|
50
50
|
const transformName = namePolicy.getName(`json_Record_${elementName}_to_${props.target}_transform`, "function");
|
|
51
|
-
const itemType =
|
|
51
|
+
const itemType = code`Record<string, any>`;
|
|
52
52
|
const returnType = props.target === "transport" ? "any" : itemType;
|
|
53
53
|
const inputType = props.target === "transport" ? [itemType, " | null"] : "any";
|
|
54
|
-
const inputRef =
|
|
54
|
+
const inputRef = refkey();
|
|
55
55
|
const parameters = [{
|
|
56
56
|
name: "items_",
|
|
57
57
|
type: inputType,
|