@typespec/http-client-js 0.7.0-dev.2 → 0.7.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.testignore +4 -0
- 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,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,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Children, type Refkey } from "@alloy-js/core";
|
|
2
2
|
import { Discriminator, Model, Union } from "@typespec/compiler";
|
|
3
3
|
export interface JsonTransformDiscriminatorProps {
|
|
4
|
-
itemRef:
|
|
4
|
+
itemRef: Refkey | Children;
|
|
5
5
|
discriminator: Discriminator;
|
|
6
6
|
type: Union | Model;
|
|
7
7
|
target: "application" | "transport";
|
|
8
8
|
}
|
|
9
|
-
export declare function JsonTransformDiscriminator(props: JsonTransformDiscriminatorProps):
|
|
10
|
-
export declare function getJsonTransformDiscriminatorRefkey(type: Union | Model, target: "application" | "transport"):
|
|
9
|
+
export declare function JsonTransformDiscriminator(props: JsonTransformDiscriminatorProps): Children;
|
|
10
|
+
export declare function getJsonTransformDiscriminatorRefkey(type: Union | Model, target: "application" | "transport"): Refkey;
|
|
11
11
|
export interface JsonTransformDiscriminatorDeclarationProps {
|
|
12
12
|
type: Union | Model;
|
|
13
13
|
target: "application" | "transport";
|
|
14
14
|
}
|
|
15
|
-
export declare function JsonTransformDiscriminatorDeclaration(props: JsonTransformDiscriminatorDeclarationProps):
|
|
15
|
+
export declare function JsonTransformDiscriminatorDeclaration(props: JsonTransformDiscriminatorDeclarationProps): Children;
|
|
16
16
|
//# sourceMappingURL=json-transform-discriminator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-transform-discriminator.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-transform-discriminator.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"json-transform-discriminator.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-transform-discriminator.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwC,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAElG,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAIjE,MAAM,WAAW,+BAA+B;IAC9C,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,MAAM,EAAE,aAAa,GAAG,WAAW,CAAC;CACrC;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,+BAA+B,YAmChF;AAED,wBAAgB,mCAAmC,CACjD,IAAI,EAAE,KAAK,GAAG,KAAK,EACnB,MAAM,EAAE,aAAa,GAAG,WAAW,UAGpC;AAED,MAAM,WAAW,0CAA0C;IACzD,IAAI,EAAE,KAAK,GAAG,KAAK,CAAC;IACpB,MAAM,EAAE,aAAa,GAAG,WAAW,CAAC;CACrC;AAED,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,0CAA0C,YA+ClD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createComponent as _$createComponent,
|
|
2
|
-
import
|
|
1
|
+
import { createComponent as _$createComponent, mergeProps as _$mergeProps } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code, mapJoin, refkey, useNamePolicy } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { useTsp } from "@typespec/emitter-framework";
|
|
5
5
|
import { JsonTransform } from "./json-transform.js";
|
|
@@ -10,15 +10,15 @@ export function JsonTransformDiscriminator(props) {
|
|
|
10
10
|
const discriminatedUnion = $.model.is(props.type) ? $.model.getDiscriminatedUnion(props.type) : $.union.getDiscriminatedUnion(props.type);
|
|
11
11
|
const propertyName = props.discriminator.propertyName;
|
|
12
12
|
if (!discriminatedUnion || !propertyName) {
|
|
13
|
-
return
|
|
13
|
+
return code`${props.itemRef}`;
|
|
14
14
|
}
|
|
15
|
-
const discriminatorRef =
|
|
15
|
+
const discriminatorRef = code`${props.itemRef}.${props.discriminator.propertyName}`;
|
|
16
16
|
|
|
17
17
|
// Need to cast to make sure that the general types which usually have a broader
|
|
18
18
|
// type in the discriminator are compatible.
|
|
19
|
-
const itemRef =
|
|
20
|
-
const discriminatingCases =
|
|
21
|
-
return
|
|
19
|
+
const itemRef = code`${props.itemRef} as any`;
|
|
20
|
+
const discriminatingCases = mapJoin(() => discriminatedUnion.variants, (name, variant) => {
|
|
21
|
+
return code`
|
|
22
22
|
if( discriminatorValue === ${JSON.stringify(name)}) {
|
|
23
23
|
return ${_$createComponent(JsonTransform, {
|
|
24
24
|
type: variant,
|
|
@@ -35,7 +35,7 @@ export function JsonTransformDiscriminator(props) {
|
|
|
35
35
|
return ["const discriminatorValue = ", discriminatorRef, ";", discriminatingCases, ["console.warn(`Received unknown kind: ` + discriminatorValue); return ", itemRef]];
|
|
36
36
|
}
|
|
37
37
|
export function getJsonTransformDiscriminatorRefkey(type, target) {
|
|
38
|
-
return
|
|
38
|
+
return refkey(type, "json_transform_discriminator_", target);
|
|
39
39
|
}
|
|
40
40
|
export function JsonTransformDiscriminatorDeclaration(props) {
|
|
41
41
|
const {
|
|
@@ -55,12 +55,12 @@ export function JsonTransformDiscriminatorDeclaration(props) {
|
|
|
55
55
|
if (!discriminator) {
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
|
-
const namePolicy =
|
|
58
|
+
const namePolicy = useNamePolicy();
|
|
59
59
|
const transformName = namePolicy.getName(`json_${props.type.name}_to_${props.target}_discriminator`, "function");
|
|
60
|
-
const typeRef =
|
|
60
|
+
const typeRef = refkey(props.type);
|
|
61
61
|
const returnType = props.target === "transport" ? "any" : typeRef;
|
|
62
62
|
const inputType = props.target === "transport" ? typeRef : "any";
|
|
63
|
-
const inputRef =
|
|
63
|
+
const inputRef = refkey();
|
|
64
64
|
const parameters = [{
|
|
65
65
|
name: "input_",
|
|
66
66
|
type: inputType,
|
|
@@ -76,11 +76,11 @@ export function JsonTransformDiscriminatorDeclaration(props) {
|
|
|
76
76
|
return getJsonTransformDiscriminatorRefkey(props.type, props.target);
|
|
77
77
|
},
|
|
78
78
|
get children() {
|
|
79
|
-
return [
|
|
79
|
+
return [code`
|
|
80
80
|
if(!${inputRef}) {
|
|
81
81
|
return ${inputRef} as any;
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
`, _$createComponent(JsonTransformDiscriminator, _$mergeProps(props, {
|
|
84
84
|
itemRef: inputRef,
|
|
85
85
|
discriminator: discriminator
|
|
86
86
|
}))];
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { Refkey } from "@alloy-js/core";
|
|
2
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
3
|
+
import type { Type } from "@typespec/compiler";
|
|
3
4
|
export interface JsonTransformProps {
|
|
4
|
-
itemRef:
|
|
5
|
+
itemRef: Refkey | Children;
|
|
5
6
|
type: Type;
|
|
6
7
|
target: "transport" | "application";
|
|
7
8
|
}
|
|
8
|
-
export declare function JsonTransform(props: JsonTransformProps):
|
|
9
|
+
export declare function JsonTransform(props: JsonTransformProps): Children;
|
|
9
10
|
export interface JsonTransformDeclarationProps {
|
|
10
11
|
type: Type;
|
|
11
12
|
target: "transport" | "application";
|
|
12
13
|
}
|
|
13
|
-
export declare function JsonTransformDeclaration(props: JsonTransformDeclarationProps):
|
|
14
|
+
export declare function JsonTransformDeclaration(props: JsonTransformDeclarationProps): Children;
|
|
14
15
|
//# sourceMappingURL=json-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"json-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/json-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAyB/C,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC3B,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,YAkCtD;AAED,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,YAqB5E"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { code } from "@alloy-js/core";
|
|
3
3
|
import { useTsp } from "@typespec/emitter-framework";
|
|
4
4
|
import { ScalarDataTransform } from "../data-transform.js";
|
|
5
5
|
import { getJsonArrayTransformRefkey, JsonArrayTransform, JsonArrayTransformDeclaration } from "./json-array-transform.js";
|
|
@@ -14,7 +14,7 @@ export function JsonTransform(props) {
|
|
|
14
14
|
const type = $.httpPart.unpack(props.type) ?? props.type;
|
|
15
15
|
const declaredTransform = getTransformReference(type, props.target);
|
|
16
16
|
if (declaredTransform) {
|
|
17
|
-
return
|
|
17
|
+
return code`${declaredTransform}(${props.itemRef})`;
|
|
18
18
|
}
|
|
19
19
|
switch (type.kind) {
|
|
20
20
|
case "Model":
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Union } from "@typespec/compiler";
|
|
1
|
+
import { Children, Refkey } from "@alloy-js/core";
|
|
2
|
+
import type { Union } from "@typespec/compiler";
|
|
3
3
|
export interface JsonUnionTransformProps {
|
|
4
|
-
itemRef:
|
|
4
|
+
itemRef: Refkey | Children;
|
|
5
5
|
type: Union;
|
|
6
6
|
target: "transport" | "application";
|
|
7
7
|
}
|
|
8
|
-
export declare function JsonUnionTransform(props: JsonUnionTransformProps):
|
|
9
|
-
export declare function getJsonUnionTransformRefkey(type: Union, target: "transport" | "application"):
|
|
8
|
+
export declare function JsonUnionTransform(props: JsonUnionTransformProps): Children;
|
|
9
|
+
export declare function getJsonUnionTransformRefkey(type: Union, target: "transport" | "application"): Refkey;
|
|
10
10
|
export interface JsonUnionTransformDeclarationProps {
|
|
11
11
|
type: Union;
|
|
12
12
|
target: "transport" | "application";
|
|
13
13
|
}
|
|
14
|
-
export declare function JsonUnionTransformDeclaration(props: JsonUnionTransformDeclarationProps):
|
|
14
|
+
export declare function JsonUnionTransformDeclaration(props: JsonUnionTransformDeclarationProps): Children;
|
|
15
15
|
//# sourceMappingURL=union-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/union-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"union-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/json/union-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAgB,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEhE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAQhD,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,YAoBhE;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,WAAW,GAAG,aAAa,GAClC,MAAM,CAER;AACD,MAAM,WAAW,kCAAkC;IACjD,IAAI,EAAE,KAAK,CAAC;IACZ,MAAM,EAAE,WAAW,GAAG,aAAa,CAAC;CACrC;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,kCAAkC,YAoCtF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { memo as _$memo, mergeProps as _$mergeProps, createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { code, refkey } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { useTsp } from "@typespec/emitter-framework";
|
|
5
5
|
import { getJsonTransformDiscriminatorRefkey, JsonTransformDiscriminatorDeclaration } from "./json-transform-discriminator.js";
|
|
@@ -24,15 +24,15 @@ export function JsonUnionTransform(props) {
|
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
26
|
export function getJsonUnionTransformRefkey(type, target) {
|
|
27
|
-
return
|
|
27
|
+
return refkey(type, "json_union_transform", target);
|
|
28
28
|
}
|
|
29
29
|
export function JsonUnionTransformDeclaration(props) {
|
|
30
30
|
const namePolicy = ts.useTSNamePolicy();
|
|
31
31
|
const transformName = namePolicy.getName(`json_${props.type.name}_to_${props.target}_transform`, "function");
|
|
32
|
-
const typeRef =
|
|
32
|
+
const typeRef = refkey(props.type);
|
|
33
33
|
const returnType = props.target === "transport" ? "any" : typeRef;
|
|
34
34
|
const inputType = props.target === "transport" ? [typeRef, " | null"] : "any";
|
|
35
|
-
const inputRef =
|
|
35
|
+
const inputRef = refkey();
|
|
36
36
|
const parameters = [{
|
|
37
37
|
name: "input_",
|
|
38
38
|
type: inputType,
|
|
@@ -54,11 +54,11 @@ export function JsonUnionTransformDeclaration(props) {
|
|
|
54
54
|
parameters: parameters,
|
|
55
55
|
refkey: declarationRefkey,
|
|
56
56
|
get children() {
|
|
57
|
-
return [
|
|
57
|
+
return [code`
|
|
58
58
|
if(!${inputRef}) {
|
|
59
59
|
return ${inputRef} as any;
|
|
60
60
|
}
|
|
61
|
-
|
|
61
|
+
`, "return ", _$createComponent(JsonUnionTransform, _$mergeProps(props, {
|
|
62
62
|
itemRef: inputRef
|
|
63
63
|
}))];
|
|
64
64
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Type } from "@typespec/compiler";
|
|
1
|
+
import type { Type } from "@typespec/compiler";
|
|
2
2
|
import { type Typekit } from "@typespec/compiler/typekit";
|
|
3
3
|
export declare function getJsonTransportName($: Typekit, type: Type): string;
|
|
4
4
|
//# sourceMappingURL=transport-namer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport-namer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/transforms/json/utils/transport-namer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"transport-namer.d.ts","sourceRoot":"","sources":["../../../../../../src/components/transforms/json/utils/transport-namer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAG1D,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,UAO1D"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import { HttpOperationPart } from "@typespec/http";
|
|
3
3
|
export interface ArrayPartTransformProps {
|
|
4
4
|
part: HttpOperationPart;
|
|
5
|
-
itemRef:
|
|
5
|
+
itemRef: Children;
|
|
6
6
|
}
|
|
7
|
-
export declare function ArrayPartTransform(props: ArrayPartTransformProps):
|
|
7
|
+
export declare function ArrayPartTransform(props: ArrayPartTransformProps): Children;
|
|
8
8
|
//# sourceMappingURL=array-part-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-part-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/array-part-transform.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"array-part-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/array-part-transform.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,YAwBhE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
+
import { code } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { HttpPartTransform } from "./part-transform.js";
|
|
5
5
|
export function ArrayPartTransform(props) {
|
|
@@ -14,14 +14,14 @@ export function ArrayPartTransform(props) {
|
|
|
14
14
|
multi: false,
|
|
15
15
|
name: partElementName
|
|
16
16
|
};
|
|
17
|
-
return [inputExpression, ".map(", mapCallbackSignature, " ",
|
|
17
|
+
return [inputExpression, ".map(", mapCallbackSignature, " ", code`=> (${_$createComponent(HttpPartTransform, {
|
|
18
18
|
itemRef: null,
|
|
19
19
|
part: partElement
|
|
20
|
-
})})
|
|
20
|
+
})})`, " )"];
|
|
21
21
|
}
|
|
22
22
|
function getPartRef(itemRef, partName) {
|
|
23
23
|
if (itemRef === null) {
|
|
24
24
|
return partName;
|
|
25
25
|
}
|
|
26
|
-
return
|
|
26
|
+
return code`${itemRef}.${partName}`;
|
|
27
27
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
2
|
import { HttpOperationPart } from "@typespec/http";
|
|
3
3
|
export interface FilePartTransformProps {
|
|
4
4
|
part: HttpOperationPart;
|
|
5
|
-
itemRef:
|
|
5
|
+
itemRef: Children;
|
|
6
6
|
}
|
|
7
|
-
export declare function FilePartTransform(props: FilePartTransformProps):
|
|
7
|
+
export declare function FilePartTransform(props: FilePartTransformProps): Children;
|
|
8
8
|
//# sourceMappingURL=file-part-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-part-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/file-part-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"file-part-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/file-part-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAQ,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGnD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,YAU9D"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { code } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { getCreateFilePartDescriptorReference } from "../../static-helpers/multipart-helpers.js";
|
|
5
5
|
export function FilePartTransform(props) {
|
|
@@ -35,5 +35,5 @@ function getPartRef(itemRef, partName) {
|
|
|
35
35
|
if (itemRef === null) {
|
|
36
36
|
return partName;
|
|
37
37
|
}
|
|
38
|
-
return
|
|
38
|
+
return code`${itemRef}.${partName}`;
|
|
39
39
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import * as ay from "@alloy-js/core";
|
|
2
1
|
import { HttpOperationMultipartBody } from "@typespec/http";
|
|
3
2
|
export interface MultipartTransformProps {
|
|
4
3
|
body: HttpOperationMultipartBody;
|
|
5
4
|
}
|
|
6
|
-
export declare function MultipartTransform(props: MultipartTransformProps):
|
|
5
|
+
export declare function MultipartTransform(props: MultipartTransformProps): import("@alloy-js/core").Children;
|
|
7
6
|
//# sourceMappingURL=multipart-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multipart-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/multipart-transform.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"multipart-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/multipart-transform.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAI5D,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,0BAA0B,CAAC;CAClC;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,qCAmBhE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { For } from "@alloy-js/core";
|
|
3
3
|
import { useTransformNamePolicy, useTsp } from "@typespec/emitter-framework";
|
|
4
4
|
import { reportDiagnostic } from "../../../lib.js";
|
|
5
5
|
import { HttpPartTransform } from "./part-transform.js";
|
|
@@ -17,7 +17,7 @@ export function MultipartTransform(props) {
|
|
|
17
17
|
return ["[]"];
|
|
18
18
|
}
|
|
19
19
|
const itemRef = transportNamer.getApplicationName(props.body.property);
|
|
20
|
-
const partTransform = _$createComponent(
|
|
20
|
+
const partTransform = _$createComponent(For, {
|
|
21
21
|
each: httpParts,
|
|
22
22
|
comma: true,
|
|
23
23
|
line: true,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { type Children } from "@alloy-js/core";
|
|
2
2
|
import { HttpOperationPart } from "@typespec/http";
|
|
3
3
|
export interface HttpPartTransformProps {
|
|
4
4
|
part: HttpOperationPart;
|
|
5
|
-
itemRef:
|
|
5
|
+
itemRef: Children;
|
|
6
6
|
}
|
|
7
|
-
export declare function HttpPartTransform(props: HttpPartTransformProps):
|
|
7
|
+
export declare function HttpPartTransform(props: HttpPartTransformProps): Children;
|
|
8
8
|
//# sourceMappingURL=part-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"part-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/part-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"part-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/part-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAKnD,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,YAU9D"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Children } from "@alloy-js/core";
|
|
2
2
|
import { HttpOperationPart } from "@typespec/http";
|
|
3
3
|
export interface SimplePartTransformProps {
|
|
4
4
|
part: HttpOperationPart;
|
|
5
|
-
itemRef:
|
|
5
|
+
itemRef: Children;
|
|
6
6
|
}
|
|
7
|
-
export declare function SimplePartTransform(props: SimplePartTransformProps):
|
|
7
|
+
export declare function SimplePartTransform(props: SimplePartTransformProps): Children;
|
|
8
8
|
//# sourceMappingURL=simple-part-transform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"simple-part-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/simple-part-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"simple-part-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/simple-part-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAc,MAAM,gBAAgB,CAAC;AAGtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAInD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,YAgClE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { code, List } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { useTsp } from "@typespec/emitter-framework";
|
|
5
5
|
import { reportDiagnostic } from "../../../lib.js";
|
|
@@ -15,9 +15,9 @@ export function SimplePartTransform(props) {
|
|
|
15
15
|
});
|
|
16
16
|
const partContentType = props.part.body.contentTypes[0] ?? "application/json";
|
|
17
17
|
const partRef = getPartRef(props.itemRef, applicationName);
|
|
18
|
-
let bodyRef =
|
|
18
|
+
let bodyRef = code`${partRef}`;
|
|
19
19
|
if (props.part.body.property) {
|
|
20
|
-
bodyRef =
|
|
20
|
+
bodyRef = code`${partRef}.${props.part.body.property.name}`;
|
|
21
21
|
}
|
|
22
22
|
if (!partContentType.startsWith("application/json")) {
|
|
23
23
|
reportDiagnostic($.program, {
|
|
@@ -28,7 +28,7 @@ export function SimplePartTransform(props) {
|
|
|
28
28
|
}
|
|
29
29
|
return _$createComponent(ts.ObjectExpression, {
|
|
30
30
|
get children() {
|
|
31
|
-
return _$createComponent(
|
|
31
|
+
return _$createComponent(List, {
|
|
32
32
|
comma: true,
|
|
33
33
|
line: true,
|
|
34
34
|
get children() {
|
|
@@ -56,5 +56,5 @@ function getPartRef(itemRef, partName) {
|
|
|
56
56
|
if (itemRef === null) {
|
|
57
57
|
return partName;
|
|
58
58
|
}
|
|
59
|
-
return
|
|
59
|
+
return code`${itemRef}.${partName}`;
|
|
60
60
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Refkey } from "@alloy-js/core";
|
|
2
2
|
import { HttpOperationBody } from "@typespec/http";
|
|
3
3
|
import { ClientOperation } from "@typespec/http-client";
|
|
4
4
|
export interface TransformDeclarationProps {
|
|
5
5
|
operation: ClientOperation;
|
|
6
|
-
refkey?:
|
|
6
|
+
refkey?: Refkey;
|
|
7
7
|
}
|
|
8
|
-
export declare function getTransformDeclarationRef(operation: ClientOperation):
|
|
9
|
-
export declare function TransformDeclaration(props: TransformDeclarationProps):
|
|
8
|
+
export declare function getTransformDeclarationRef(operation: ClientOperation): Refkey;
|
|
9
|
+
export declare function TransformDeclaration(props: TransformDeclarationProps): import("@alloy-js/core").Children;
|
|
10
10
|
export interface SingleBodyTransformDeclarationProps {
|
|
11
11
|
name: string;
|
|
12
12
|
operation: ClientOperation;
|
|
13
13
|
payload: HttpOperationBody;
|
|
14
|
-
refkey:
|
|
14
|
+
refkey: Refkey;
|
|
15
15
|
}
|
|
16
|
-
export declare function SingleBodyTransformDeclaration(props: SingleBodyTransformDeclarationProps):
|
|
16
|
+
export declare function SingleBodyTransformDeclaration(props: SingleBodyTransformDeclarationProps): import("@alloy-js/core").Children;
|
|
17
17
|
//# sourceMappingURL=operation-transform-declaration.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-transform-declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/transforms/operation-transform-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"operation-transform-declaration.d.ts","sourceRoot":"","sources":["../../../../src/components/transforms/operation-transform-declaration.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,gBAAgB,CAAC;AAGhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGxD,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,eAAe,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,eAAe,UAEpE;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,yBAAyB,qCAOpE;AAED,MAAM,WAAW,mCAAmC;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,eAAe,CAAC;IAC3B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,mCAAmC,qCAmBxF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { refkey } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import * as ef from "@typespec/emitter-framework/typescript";
|
|
5
5
|
import { JsonTransform } from "./json/json-transform.js";
|
|
6
6
|
export function getTransformDeclarationRef(operation) {
|
|
7
|
-
return
|
|
7
|
+
return refkey(operation, "transform");
|
|
8
8
|
}
|
|
9
9
|
export function TransformDeclaration(props) {
|
|
10
10
|
const refkey = props.refkey ?? getTransformDeclarationRef(props.operation);
|
|
@@ -16,7 +16,7 @@ export function TransformDeclaration(props) {
|
|
|
16
16
|
})];
|
|
17
17
|
}
|
|
18
18
|
export function SingleBodyTransformDeclaration(props) {
|
|
19
|
-
const inputRef =
|
|
19
|
+
const inputRef = refkey(props.payload, "property");
|
|
20
20
|
const payloadParameter = {
|
|
21
21
|
name: "payload",
|
|
22
22
|
type: _$createComponent(ef.TypeExpression, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform-name-policy.d.ts","sourceRoot":"","sources":["../../../../src/components/transforms/transform-name-policy.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"transform-name-policy.d.ts","sourceRoot":"","sources":["../../../../src/components/transforms/transform-name-policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,EAAE,MAAM,6BAA6B,CAAC;AAIlD,wBAAgB,sBAAsB,IAAI,EAAE,CAAC,mBAAmB,CAE/D;AAED;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAExD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAE/D;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,MAAM,CAAC;CAC/C;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,GAAE,eAAoB,GAAG,EAAE,CAAC,mBAAmB,CA2B9F;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAUnE;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,QAAQ,EACd,QAAQ,GAAE,MAA2B,GACpC,MAAM,CAYR;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,cAAc,CAEpE"}
|
package/dist/src/emitter.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
|
-
import
|
|
2
|
+
import { SourceDirectory } from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
4
|
import { writeOutput } from "@typespec/emitter-framework";
|
|
5
5
|
import { OperationsDirectory } from "./components/client-directory.js";
|
|
@@ -33,29 +33,29 @@ export async function $onEmit(context) {
|
|
|
33
33
|
"@types/node": "~18.19.75"
|
|
34
34
|
},
|
|
35
35
|
get children() {
|
|
36
|
-
return _$createComponent(
|
|
36
|
+
return _$createComponent(SourceDirectory, {
|
|
37
37
|
path: "src",
|
|
38
38
|
get children() {
|
|
39
39
|
return [_$createComponent(ts.BarrelFile, {
|
|
40
40
|
"export": "."
|
|
41
|
-
}), _$createComponent(Client, {}), _$createComponent(
|
|
41
|
+
}), _$createComponent(Client, {}), _$createComponent(SourceDirectory, {
|
|
42
42
|
path: "models",
|
|
43
43
|
get children() {
|
|
44
44
|
return [_$createComponent(ts.BarrelFile, {
|
|
45
45
|
"export": "models"
|
|
46
|
-
}), _$createComponent(Models, {}), _$createComponent(
|
|
46
|
+
}), _$createComponent(Models, {}), _$createComponent(SourceDirectory, {
|
|
47
47
|
path: "internal",
|
|
48
48
|
get children() {
|
|
49
49
|
return _$createComponent(ModelSerializers, {});
|
|
50
50
|
}
|
|
51
51
|
})];
|
|
52
52
|
}
|
|
53
|
-
}), _$createComponent(
|
|
53
|
+
}), _$createComponent(SourceDirectory, {
|
|
54
54
|
path: "api",
|
|
55
55
|
get children() {
|
|
56
56
|
return _$createComponent(OperationsDirectory, {});
|
|
57
57
|
}
|
|
58
|
-
}), _$createComponent(
|
|
58
|
+
}), _$createComponent(SourceDirectory, {
|
|
59
59
|
path: "helpers",
|
|
60
60
|
get children() {
|
|
61
61
|
return [_$createComponent(PagingHelpers, {}), _$createComponent(Interfaces, {}), _$createComponent(MultipartHelpers, {}), _$createComponent(ts.SourceFile, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../../src/utils/multipart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../../src/utils/multipart.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAI/C,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAwB/C"}
|