@typespec/http-client-js 0.7.0-dev.1 → 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 +4 -4
- 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
|
-
import
|
|
2
|
-
import { For } from "@alloy-js/core";
|
|
1
|
+
import { For, refkey } from "@alloy-js/core";
|
|
3
2
|
import * as ts from "@alloy-js/typescript";
|
|
4
3
|
import { useTsp } from "@typespec/emitter-framework";
|
|
5
4
|
import * as ef from "@typespec/emitter-framework/typescript";
|
|
@@ -18,7 +17,7 @@ export function Models(props: ModelsProps) {
|
|
|
18
17
|
<For each={dataTypes} hardline>
|
|
19
18
|
{(type) => {
|
|
20
19
|
return $.array.is(type) || $.record.is(type) ? null : (
|
|
21
|
-
<ef.TypeDeclaration export type={type} refkey={
|
|
20
|
+
<ef.TypeDeclaration export type={type} refkey={refkey(type)} />
|
|
22
21
|
);
|
|
23
22
|
}}
|
|
24
23
|
</For>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { refkey } from "@alloy-js/core";
|
|
2
2
|
import { HttpOperation } from "@typespec/http";
|
|
3
3
|
import { ClientOperation as DefaultOperationComponent } from "../client-operation.jsx";
|
|
4
4
|
import { OperationHandlerPipeline } from "./types.jsx";
|
|
@@ -22,7 +22,7 @@ export function OperationPipeline({ httpOperation, pipeline, internal }: Operati
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
// Default to standard client operation if no handler matched
|
|
25
|
-
const defaultOperationRefkey =
|
|
25
|
+
const defaultOperationRefkey = refkey(httpOperation.operation);
|
|
26
26
|
return (
|
|
27
27
|
<DefaultOperationComponent
|
|
28
28
|
httpOperation={httpOperation}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { For, refkey } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
import { PagingOperation, PagingProperty } from "@typespec/compiler";
|
|
4
4
|
import * as ef from "@typespec/emitter-framework/typescript";
|
|
@@ -9,7 +9,7 @@ export interface PageResponseProps {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function getPageResponseTypeRefkey(operation: HttpOperation) {
|
|
12
|
-
return
|
|
12
|
+
return refkey(operation, "page-response");
|
|
13
13
|
}
|
|
14
14
|
export function PageResponseDeclaration(props: PageResponseProps) {
|
|
15
15
|
const namePolicy = ts.useTSNamePolicy();
|
|
@@ -41,7 +41,7 @@ export function PageResponseDeclaration(props: PageResponseProps) {
|
|
|
41
41
|
name={interfaceName}
|
|
42
42
|
refkey={getPageResponseTypeRefkey(props.operation)}
|
|
43
43
|
>
|
|
44
|
-
<
|
|
44
|
+
<For each={responseProperties} line>
|
|
45
45
|
{(parameter) => (
|
|
46
46
|
<ts.InterfaceMember
|
|
47
47
|
name={parameter.property.name}
|
|
@@ -49,7 +49,7 @@ export function PageResponseDeclaration(props: PageResponseProps) {
|
|
|
49
49
|
type={<ef.TypeExpression type={parameter.property.type} />}
|
|
50
50
|
/>
|
|
51
51
|
)}
|
|
52
|
-
</
|
|
52
|
+
</For>
|
|
53
53
|
</ts.InterfaceDeclaration>
|
|
54
54
|
);
|
|
55
55
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { For, refkey } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
import { PagingOperation, PagingProperty } from "@typespec/compiler";
|
|
4
4
|
import * as ef from "@typespec/emitter-framework/typescript";
|
|
@@ -9,7 +9,7 @@ export interface PageSettingsProps {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export function getPageSettingsTypeRefkey(operation: HttpOperation) {
|
|
12
|
-
return
|
|
12
|
+
return refkey(operation, "page-settings");
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export function getPageSettingProperties(pagingOperation: PagingOperation) {
|
|
@@ -39,7 +39,7 @@ export function PageSettingsDeclaration(props: PageSettingsProps) {
|
|
|
39
39
|
name={interfaceName}
|
|
40
40
|
refkey={getPageSettingsTypeRefkey(props.operation)}
|
|
41
41
|
>
|
|
42
|
-
<
|
|
42
|
+
<For each={settingProperties} line>
|
|
43
43
|
{(parameter) => (
|
|
44
44
|
<ts.InterfaceMember
|
|
45
45
|
name={parameter.property.name}
|
|
@@ -47,7 +47,7 @@ export function PageSettingsDeclaration(props: PageSettingsProps) {
|
|
|
47
47
|
type={<ef.TypeExpression type={parameter.property.type} />}
|
|
48
48
|
/>
|
|
49
49
|
)}
|
|
50
|
-
</
|
|
50
|
+
</For>
|
|
51
51
|
</ts.InterfaceDeclaration>
|
|
52
52
|
);
|
|
53
53
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Children } from "@alloy-js/core";
|
|
1
|
+
import { Children, code, List, refkey } from "@alloy-js/core";
|
|
3
2
|
import * as ts from "@alloy-js/typescript";
|
|
4
3
|
import { useTsp } from "@typespec/emitter-framework";
|
|
5
4
|
import { FunctionDeclaration } from "@typespec/emitter-framework/typescript";
|
|
@@ -47,16 +46,16 @@ export const PaginatedOperationHandler: OperationHandler = {
|
|
|
47
46
|
return;
|
|
48
47
|
}
|
|
49
48
|
const pagingOperation = $.operation.getPagingMetadata(httpOperation.operation)!;
|
|
50
|
-
const responseRefkey =
|
|
51
|
-
const operationRefkey =
|
|
52
|
-
const returnType =
|
|
49
|
+
const responseRefkey = refkey(httpOperation, "http-response");
|
|
50
|
+
const operationRefkey = refkey(httpOperation.operation);
|
|
51
|
+
const returnType = code`${getPagedAsyncIterableIteratorRefkey()}<${getPageItemTypeName(pagingOperation)},${getPageResponseTypeRefkey(httpOperation)},${getPageSettingsTypeRefkey(httpOperation)}>`;
|
|
53
52
|
const clientContextInterfaceRef = getClientcontextDeclarationRef(client);
|
|
54
|
-
const optionsRefkey =
|
|
53
|
+
const optionsRefkey = refkey();
|
|
55
54
|
const signatureParams: ts.ParameterDescriptor[] = [
|
|
56
55
|
{
|
|
57
56
|
name: "client",
|
|
58
57
|
type: clientContextInterfaceRef,
|
|
59
|
-
refkey:
|
|
58
|
+
refkey: refkey(client, "paging-operation-client-param"),
|
|
60
59
|
},
|
|
61
60
|
...getOperationParameters(httpOperation, optionsRefkey),
|
|
62
61
|
];
|
|
@@ -64,7 +63,7 @@ export const PaginatedOperationHandler: OperationHandler = {
|
|
|
64
63
|
// Exclude from operation options and include them into PageSettings
|
|
65
64
|
const excludes = getPageSettingProperties(pagingOperation).map((p) => p.property);
|
|
66
65
|
return (
|
|
67
|
-
<
|
|
66
|
+
<List>
|
|
68
67
|
<OperationOptionsDeclaration operation={httpOperation} excludes={excludes} />
|
|
69
68
|
<PageSettingsDeclaration operation={httpOperation} pagingOperation={pagingOperation} />
|
|
70
69
|
<PageResponseDeclaration operation={httpOperation} pagingOperation={pagingOperation} />
|
|
@@ -78,7 +77,7 @@ export const PaginatedOperationHandler: OperationHandler = {
|
|
|
78
77
|
parametersMode="replace"
|
|
79
78
|
parameters={signatureParams}
|
|
80
79
|
>
|
|
81
|
-
<
|
|
80
|
+
<List>
|
|
82
81
|
<GetElements httpOperation={httpOperation} pageDetail={pagingDetail} />
|
|
83
82
|
<GetPagedResponse
|
|
84
83
|
httpOperation={httpOperation}
|
|
@@ -86,12 +85,12 @@ export const PaginatedOperationHandler: OperationHandler = {
|
|
|
86
85
|
operationParams={signatureParams}
|
|
87
86
|
/>
|
|
88
87
|
<>
|
|
89
|
-
{
|
|
88
|
+
{code`
|
|
90
89
|
return ${getBuildPagedAsyncIteratorRefkey}<${getPageItemTypeName(pagingOperation)}, ${getPageResponseTypeRefkey(httpOperation)}, ${getPageSettingsTypeRefkey(httpOperation)}>({${getElementsRefkey(httpOperation)}, ${getPagedResponseFunctionRefkey(httpOperation)}});`}
|
|
91
90
|
</>
|
|
92
|
-
</
|
|
91
|
+
</List>
|
|
93
92
|
</FunctionDeclaration>
|
|
94
|
-
</
|
|
93
|
+
</List>
|
|
95
94
|
);
|
|
96
95
|
},
|
|
97
96
|
};
|
|
@@ -102,19 +101,19 @@ interface GetPagedResponseProps {
|
|
|
102
101
|
operationParams: ts.ParameterDescriptor[];
|
|
103
102
|
}
|
|
104
103
|
function getPagedResponseFunctionRefkey(httpOperation: HttpOperation) {
|
|
105
|
-
return
|
|
104
|
+
return refkey(httpOperation, "get-paged-response");
|
|
106
105
|
}
|
|
107
106
|
|
|
108
107
|
function GetPagedResponse(props: GetPagedResponseProps) {
|
|
109
108
|
const pagingDetail = props.pageDetail;
|
|
110
109
|
const httpOperation = props.httpOperation;
|
|
111
110
|
const params: ts.ParameterDescriptor[] = [
|
|
112
|
-
{ name: "nextToken", type: "string", optional: true, refkey:
|
|
111
|
+
{ name: "nextToken", type: "string", optional: true, refkey: refkey() },
|
|
113
112
|
{
|
|
114
113
|
name: "settings",
|
|
115
114
|
type: getPageSettingsTypeRefkey(httpOperation),
|
|
116
115
|
optional: true,
|
|
117
|
-
refkey:
|
|
116
|
+
refkey: refkey(),
|
|
118
117
|
},
|
|
119
118
|
];
|
|
120
119
|
// TODO: template can't resolve the ref key so fallback to useTSNamePolicy
|
|
@@ -131,7 +130,7 @@ function GetPagedResponse(props: GetPagedResponseProps) {
|
|
|
131
130
|
refkey={getPagedResponseFunctionRefkey(httpOperation)}
|
|
132
131
|
parameters={params}
|
|
133
132
|
>
|
|
134
|
-
{
|
|
133
|
+
{code`
|
|
135
134
|
${
|
|
136
135
|
props.pageDetail.pattern === "nextLink"
|
|
137
136
|
? `
|
|
@@ -173,7 +172,7 @@ interface GetElementsProps {
|
|
|
173
172
|
pageDetail: PagingDetail;
|
|
174
173
|
}
|
|
175
174
|
function getElementsRefkey(httpOperation: HttpOperation) {
|
|
176
|
-
return
|
|
175
|
+
return refkey(httpOperation, "get-elements");
|
|
177
176
|
}
|
|
178
177
|
function GetElements(props: GetElementsProps) {
|
|
179
178
|
const pagingDetail = props.pageDetail;
|
|
@@ -182,7 +181,7 @@ function GetElements(props: GetElementsProps) {
|
|
|
182
181
|
{
|
|
183
182
|
name: "response",
|
|
184
183
|
type: getPageResponseTypeRefkey(httpOperation),
|
|
185
|
-
refkey:
|
|
184
|
+
refkey: refkey(),
|
|
186
185
|
},
|
|
187
186
|
];
|
|
188
187
|
return (
|
|
@@ -191,7 +190,7 @@ function GetElements(props: GetElementsProps) {
|
|
|
191
190
|
refkey={getElementsRefkey(httpOperation)}
|
|
192
191
|
parameters={params}
|
|
193
192
|
>
|
|
194
|
-
{
|
|
193
|
+
{code`
|
|
195
194
|
return response.${pagingDetail.output.items};
|
|
196
195
|
`}
|
|
197
196
|
</FunctionDeclaration>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as ay from "@alloy-js/core";
|
|
2
1
|
import { List, Refkey, StatementList, code, refkey } from "@alloy-js/core";
|
|
3
2
|
import * as ts from "@alloy-js/typescript";
|
|
4
3
|
import { Reference } from "@alloy-js/typescript";
|
|
@@ -32,7 +31,7 @@ export function getHttpRequestSendParams(httpOperation: HttpOperation) {
|
|
|
32
31
|
{
|
|
33
32
|
name: "client",
|
|
34
33
|
type: clientContextInterfaceRef,
|
|
35
|
-
refkey:
|
|
34
|
+
refkey: refkey(client, "send-client-param"),
|
|
36
35
|
},
|
|
37
36
|
...getOperationParameters(httpOperation, optionsRefkey),
|
|
38
37
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { For, refkey } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
import { ModelProperty } from "@typespec/compiler";
|
|
4
4
|
import * as ef from "@typespec/emitter-framework/typescript";
|
|
@@ -11,7 +11,7 @@ export interface OperationOptionsProps {
|
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function getOperationOptionsTypeRefkey(operation: HttpOperation) {
|
|
14
|
-
return
|
|
14
|
+
return refkey(operation, "operation-options");
|
|
15
15
|
}
|
|
16
16
|
export function OperationOptionsDeclaration(props: OperationOptionsProps) {
|
|
17
17
|
const namePolicy = ts.useTSNamePolicy();
|
|
@@ -28,7 +28,7 @@ export function OperationOptionsDeclaration(props: OperationOptionsProps) {
|
|
|
28
28
|
extends={getOperationOptionsInterfaceRefkey()}
|
|
29
29
|
refkey={getOperationOptionsTypeRefkey(props.operation)}
|
|
30
30
|
>
|
|
31
|
-
<
|
|
31
|
+
<For each={optionalParameters} line>
|
|
32
32
|
{(parameter) => (
|
|
33
33
|
<ts.InterfaceMember
|
|
34
34
|
name={parameter.property.name}
|
|
@@ -36,7 +36,7 @@ export function OperationOptionsDeclaration(props: OperationOptionsProps) {
|
|
|
36
36
|
type={<ef.TypeExpression type={parameter.property.type} />}
|
|
37
37
|
/>
|
|
38
38
|
)}
|
|
39
|
-
</
|
|
39
|
+
</For>
|
|
40
40
|
</ef.InterfaceDeclaration>
|
|
41
41
|
);
|
|
42
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Refkey, refkey } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
import { useTransformNamePolicy } from "@typespec/emitter-framework";
|
|
4
4
|
import * as ef from "@typespec/emitter-framework/typescript";
|
|
@@ -12,7 +12,7 @@ export interface OperationParametersProps {
|
|
|
12
12
|
|
|
13
13
|
export function getOperationParameters(
|
|
14
14
|
operation: HttpOperation,
|
|
15
|
-
optionsRefkey:
|
|
15
|
+
optionsRefkey: Refkey,
|
|
16
16
|
): ts.ParameterDescriptor[] {
|
|
17
17
|
const transformNamer = useTransformNamePolicy();
|
|
18
18
|
const requiredParameters = operation.parameters.properties
|
|
@@ -25,7 +25,7 @@ export function getOperationParameters(
|
|
|
25
25
|
const name = transformNamer.getApplicationName(parameter.property);
|
|
26
26
|
const parameterDescriptor: ts.ParameterDescriptor = {
|
|
27
27
|
name,
|
|
28
|
-
refkey:
|
|
28
|
+
refkey: refkey(),
|
|
29
29
|
type: <ef.TypeExpression type={parameter.property.type} />,
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
import { Program } from "@typespec/compiler";
|
|
4
4
|
import { Output as EFOutput, TransformNamePolicyContext } from "@typespec/emitter-framework";
|
|
@@ -9,7 +9,7 @@ import { uriTemplateLib } from "./external-packages/uri-template.js";
|
|
|
9
9
|
import { createTransformNamePolicy } from "./transforms/transform-name-policy.js";
|
|
10
10
|
|
|
11
11
|
export interface OutputProps {
|
|
12
|
-
children?:
|
|
12
|
+
children?: Children;
|
|
13
13
|
program: Program;
|
|
14
14
|
}
|
|
15
15
|
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { code, Refkey, refkey } from "@alloy-js/core";
|
|
2
|
+
import { Children } from "@alloy-js/core/jsx-runtime";
|
|
2
3
|
import * as ts from "@alloy-js/typescript";
|
|
3
4
|
|
|
4
|
-
export function getEncodeUint8ArrayRef():
|
|
5
|
-
return
|
|
5
|
+
export function getEncodeUint8ArrayRef(): Refkey {
|
|
6
|
+
return refkey("encodeUint8Array");
|
|
6
7
|
}
|
|
7
8
|
|
|
8
|
-
export function EncodeUint8Array():
|
|
9
|
-
const valueRef =
|
|
10
|
-
const encodingRef =
|
|
11
|
-
const
|
|
9
|
+
export function EncodeUint8Array(): Children {
|
|
10
|
+
const valueRef = refkey();
|
|
11
|
+
const encodingRef = refkey();
|
|
12
|
+
const key = getEncodeUint8ArrayRef();
|
|
12
13
|
return (
|
|
13
14
|
<ts.FunctionDeclaration
|
|
14
15
|
export
|
|
15
|
-
refkey={
|
|
16
|
+
refkey={key}
|
|
16
17
|
name="encodeUint8Array"
|
|
17
18
|
parameters={[
|
|
18
19
|
{ name: "value", type: "Uint8Array | undefined | null", refkey: valueRef },
|
|
@@ -20,7 +21,7 @@ export function EncodeUint8Array(): ay.Children {
|
|
|
20
21
|
]}
|
|
21
22
|
returnType="string | undefined"
|
|
22
23
|
>
|
|
23
|
-
{
|
|
24
|
+
{code`
|
|
24
25
|
if (!${valueRef}) {
|
|
25
26
|
return ${valueRef} as any;
|
|
26
27
|
}
|
|
@@ -30,21 +31,21 @@ export function EncodeUint8Array(): ay.Children {
|
|
|
30
31
|
);
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
export function getDecodeUint8ArrayRef():
|
|
34
|
-
return
|
|
34
|
+
export function getDecodeUint8ArrayRef(): Refkey {
|
|
35
|
+
return refkey("decodeUint8Array");
|
|
35
36
|
}
|
|
36
|
-
export function DecodeBase64():
|
|
37
|
-
const
|
|
38
|
-
const valueRef =
|
|
37
|
+
export function DecodeBase64(): Children {
|
|
38
|
+
const key = getDecodeUint8ArrayRef();
|
|
39
|
+
const valueRef = refkey();
|
|
39
40
|
return (
|
|
40
41
|
<ts.FunctionDeclaration
|
|
41
42
|
export
|
|
42
43
|
name="decodeBase64"
|
|
43
44
|
parameters={[{ name: "value", type: "string", refkey: valueRef }]}
|
|
44
45
|
returnType="Uint8Array | undefined"
|
|
45
|
-
refkey={
|
|
46
|
+
refkey={key}
|
|
46
47
|
>
|
|
47
|
-
{
|
|
48
|
+
{code`
|
|
48
49
|
if(!${valueRef}) {
|
|
49
50
|
return ${valueRef} as any;
|
|
50
51
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { code, refkey } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
import { httpRuntimeTemplateLib } from "../external-packages/ts-http-runtime.js";
|
|
4
4
|
|
|
5
5
|
export function getOperationOptionsInterfaceRefkey() {
|
|
6
|
-
return
|
|
6
|
+
return refkey("OperationOptions", "interface");
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function OperationOptionsInterfaceDeclaration() {
|
|
10
10
|
const declarationRefkey = getOperationOptionsInterfaceRefkey();
|
|
11
|
-
const onResponseCallback =
|
|
11
|
+
const onResponseCallback = code`(rawResponse: ${httpRuntimeTemplateLib.PathUncheckedResponse}) => void`;
|
|
12
12
|
|
|
13
13
|
const operationOptions = (
|
|
14
14
|
<ts.InterfaceExpression>
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { code, mapJoin, refkey } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
export interface MultipartHelpersProps {}
|
|
4
4
|
|
|
5
5
|
export function getFileContentsTypeReference() {
|
|
6
|
-
return
|
|
6
|
+
return refkey("FileContents", "type", "static-helpers");
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function getCreateFilePartDescriptorReference() {
|
|
10
|
-
return
|
|
10
|
+
return refkey("createFilePartDescriptor", "function", "static-helpers");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function getFileTypeReference() {
|
|
14
|
-
return
|
|
14
|
+
return refkey("File", "type", "static-helpers");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export function MultipartHelpers(props: MultipartHelpersProps) {
|
|
@@ -26,7 +26,7 @@ export function MultipartHelpers(props: MultipartHelpersProps) {
|
|
|
26
26
|
kind="type"
|
|
27
27
|
refkey={getFileContentsTypeReference()}
|
|
28
28
|
>
|
|
29
|
-
{
|
|
29
|
+
{mapJoin(
|
|
30
30
|
() => [
|
|
31
31
|
"string",
|
|
32
32
|
"NodeJS.ReadableStream",
|
|
@@ -45,7 +45,7 @@ export function MultipartHelpers(props: MultipartHelpersProps) {
|
|
|
45
45
|
returnType="any"
|
|
46
46
|
refkey={getCreateFilePartDescriptorReference()}
|
|
47
47
|
>
|
|
48
|
-
{
|
|
48
|
+
{code`
|
|
49
49
|
if (fileInput.contents) {
|
|
50
50
|
return {
|
|
51
51
|
name: partName,
|
|
@@ -73,7 +73,7 @@ function getCreateFilePartParameters(): ts.ParameterDescriptor[] {
|
|
|
73
73
|
{
|
|
74
74
|
name: "defaultContentType",
|
|
75
75
|
optional: true,
|
|
76
|
-
refkey:
|
|
76
|
+
refkey: refkey(),
|
|
77
77
|
type: "string",
|
|
78
78
|
},
|
|
79
79
|
];
|
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { code, Declaration, refkey } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
|
|
4
4
|
export function getPagedAsyncIterableIteratorRefkey() {
|
|
5
|
-
return
|
|
5
|
+
return refkey("PagedAsyncIterableIterator", "interface");
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export function getBuildPagedAsyncIteratorRefkey() {
|
|
9
|
-
return
|
|
9
|
+
return refkey("buildPagedAsyncIterator", "function");
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
function getPagedResultRefkey() {
|
|
13
|
-
return
|
|
13
|
+
return refkey("PagedResult", "interface");
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
function getBuildPagedAsyncIteratorOptionsRefkey() {
|
|
17
|
-
return
|
|
17
|
+
return refkey("BuildPagedAsyncIteratorOptions", "interface");
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function PagedAsyncIterableIteratorInterfaceDeclaration() {
|
|
21
21
|
return (
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
refkey={getPagedAsyncIterableIteratorRefkey()}
|
|
25
|
-
>
|
|
26
|
-
{ay.code`
|
|
22
|
+
<Declaration name="PagedAsyncIterableIterator" refkey={getPagedAsyncIterableIteratorRefkey()}>
|
|
23
|
+
{code`
|
|
27
24
|
/**
|
|
28
25
|
* An interface that allows async iterable iteration both to completion and by page.
|
|
29
26
|
*/
|
|
@@ -51,14 +48,14 @@ export interface PagedAsyncIterableIterator<
|
|
|
51
48
|
settings?: TPageSettings,
|
|
52
49
|
) => AsyncIterableIterator<TPageResponse>;
|
|
53
50
|
} `}
|
|
54
|
-
</
|
|
51
|
+
</Declaration>
|
|
55
52
|
);
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
function PagedResultInterfaceDeclaration() {
|
|
59
56
|
return (
|
|
60
|
-
<
|
|
61
|
-
{
|
|
57
|
+
<Declaration name="PagedResult" refkey={getPagedResultRefkey()}>
|
|
58
|
+
{code`
|
|
62
59
|
/**
|
|
63
60
|
* An interface that describes how to communicate with the service.
|
|
64
61
|
*/
|
|
@@ -87,17 +84,17 @@ interface PagedResult<
|
|
|
87
84
|
settings?: TPageSettings,
|
|
88
85
|
) => AsyncIterableIterator<TPageResponse>;
|
|
89
86
|
}`}
|
|
90
|
-
</
|
|
87
|
+
</Declaration>
|
|
91
88
|
);
|
|
92
89
|
}
|
|
93
90
|
|
|
94
91
|
function BuildPagedAsyncIteratorOptionsInterfaceDeclaration() {
|
|
95
92
|
return (
|
|
96
|
-
<
|
|
93
|
+
<Declaration
|
|
97
94
|
name="BuildPagedAsyncIteratorOptions"
|
|
98
95
|
refkey={getBuildPagedAsyncIteratorOptionsRefkey()}
|
|
99
96
|
>
|
|
100
|
-
{
|
|
97
|
+
{code`
|
|
101
98
|
/**
|
|
102
99
|
* Options for the paging helper
|
|
103
100
|
*/
|
|
@@ -109,14 +106,14 @@ export interface BuildPagedAsyncIteratorOptions<
|
|
|
109
106
|
getElements: (response: TPageResponse) => TElement[];
|
|
110
107
|
getPagedResponse: (nextToken?: string, settings?: TPageSettings) => Promise<{ pagedResponse: TPageResponse; nextToken?: string } | undefined>;
|
|
111
108
|
}`}
|
|
112
|
-
</
|
|
109
|
+
</Declaration>
|
|
113
110
|
);
|
|
114
111
|
}
|
|
115
112
|
|
|
116
113
|
function BuildPagedAsyncIteratorInterfaceDeclaration() {
|
|
117
114
|
return (
|
|
118
|
-
<
|
|
119
|
-
{
|
|
115
|
+
<Declaration name="buildPagedAsyncIterator" refkey={getBuildPagedAsyncIteratorRefkey()}>
|
|
116
|
+
{code`
|
|
120
117
|
/**
|
|
121
118
|
* Helper to paginate results in a generic way and return a PagedAsyncIterableIterator
|
|
122
119
|
*/
|
|
@@ -179,7 +176,7 @@ async function* getPageAsyncIterator<TElement, TPageResponse, TPageSettings>(
|
|
|
179
176
|
yield results;
|
|
180
177
|
}
|
|
181
178
|
}`}
|
|
182
|
-
</
|
|
179
|
+
</Declaration>
|
|
183
180
|
);
|
|
184
181
|
}
|
|
185
182
|
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { code, List, refkey, StatementList } from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
import { httpRuntimeTemplateLib } from "../external-packages/ts-http-runtime.js";
|
|
4
4
|
|
|
5
5
|
export function getRestErrorRefkey() {
|
|
6
|
-
return
|
|
6
|
+
return refkey("rest-error", "static-helpers", "class");
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
export function getCreateRestErrorRefkey() {
|
|
10
|
-
return
|
|
10
|
+
return refkey("create-rest-error", "static-helpers", "function");
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function RestError() {
|
|
14
|
-
const requestRefkey =
|
|
15
|
-
const responseRefkey =
|
|
16
|
-
const statusRefkey =
|
|
17
|
-
const bodyRefkey =
|
|
18
|
-
const headersRefkey =
|
|
19
|
-
const constructorRefkey =
|
|
20
|
-
const fromHttpResponseRefkey =
|
|
14
|
+
const requestRefkey = refkey("request", "rest-error-class-field");
|
|
15
|
+
const responseRefkey = refkey("response", "rest-error-class-field");
|
|
16
|
+
const statusRefkey = refkey("status", "rest-error-class-field");
|
|
17
|
+
const bodyRefkey = refkey("body", "rest-error-class-field");
|
|
18
|
+
const headersRefkey = refkey("headers", "rest-error-class-field");
|
|
19
|
+
const constructorRefkey = refkey("constructor", "rest-error-class-method");
|
|
20
|
+
const fromHttpResponseRefkey = refkey("from-http-response", "rest-error-class-method");
|
|
21
21
|
|
|
22
22
|
const restErrorClass = (
|
|
23
23
|
<ts.ClassDeclaration export name="RestError" extends="Error" refkey={getRestErrorRefkey()}>
|
|
24
|
-
<
|
|
24
|
+
<StatementList>
|
|
25
25
|
<ts.ClassField
|
|
26
26
|
public
|
|
27
27
|
name="request"
|
|
@@ -42,9 +42,9 @@ export function RestError() {
|
|
|
42
42
|
type={httpRuntimeTemplateLib.RawHttpHeaders}
|
|
43
43
|
refkey={headersRefkey}
|
|
44
44
|
/>
|
|
45
|
-
</
|
|
45
|
+
</StatementList>
|
|
46
46
|
|
|
47
|
-
<
|
|
47
|
+
<List hardline>
|
|
48
48
|
<ts.ClassMethod
|
|
49
49
|
name="constructor"
|
|
50
50
|
parameters={[
|
|
@@ -54,7 +54,7 @@ export function RestError() {
|
|
|
54
54
|
returnType={null}
|
|
55
55
|
refkey={constructorRefkey}
|
|
56
56
|
>
|
|
57
|
-
{
|
|
57
|
+
{code`
|
|
58
58
|
// Create an error message that includes relevant details.
|
|
59
59
|
super(\`$\{message\} - HTTP $\{response.status} received for $\{response.request.method} $\{response.request.url}\`);
|
|
60
60
|
this.name = 'RestError';
|
|
@@ -75,12 +75,12 @@ export function RestError() {
|
|
|
75
75
|
returnType={getRestErrorRefkey()}
|
|
76
76
|
refkey={fromHttpResponseRefkey}
|
|
77
77
|
>
|
|
78
|
-
{
|
|
78
|
+
{code`
|
|
79
79
|
const defaultMessage = \`Unexpected HTTP status code: $\{response.status}\`;
|
|
80
80
|
return new RestError(defaultMessage, response);
|
|
81
81
|
`}
|
|
82
82
|
</ts.ClassMethod>
|
|
83
|
-
</
|
|
83
|
+
</List>
|
|
84
84
|
</ts.ClassDeclaration>
|
|
85
85
|
);
|
|
86
86
|
|
|
@@ -92,7 +92,7 @@ export function RestError() {
|
|
|
92
92
|
returnType={getRestErrorRefkey()}
|
|
93
93
|
refkey={getCreateRestErrorRefkey()}
|
|
94
94
|
>
|
|
95
|
-
{
|
|
95
|
+
{code`
|
|
96
96
|
return ${fromHttpResponseRefkey}(response);
|
|
97
97
|
`}
|
|
98
98
|
</ts.FunctionDeclaration>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Children, code } from "@alloy-js/core";
|
|
2
2
|
|
|
3
3
|
export interface ClientTestOptions {}
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ export function ClientTestOptions(_props: ClientTestOptions) {
|
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
return
|
|
10
|
+
return code`
|
|
11
11
|
allowInsecureConnection: true,
|
|
12
12
|
retryOptions: {
|
|
13
13
|
maxRetries: 1,
|
|
@@ -15,7 +15,7 @@ export function ClientTestOptions(_props: ClientTestOptions) {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export function addClientTestOptions(
|
|
18
|
-
options:
|
|
18
|
+
options: Children[],
|
|
19
19
|
settings: { location?: "front" | "back" } = { location: "front" },
|
|
20
20
|
) {
|
|
21
21
|
if (process.env.TYPESPEC_JS_EMITTER_TESTING === "true") {
|