@typespec/http-client-js 0.4.0-dev.7 → 0.5.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- 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 -1
- package/dist/src/components/client-operation.d.ts.map +1 -1
- package/dist/src/components/client-operation.js +4 -1
- package/dist/src/components/client.d.ts.map +1 -1
- package/dist/src/components/client.js +13 -1
- package/dist/src/components/http-response.d.ts.map +1 -1
- package/dist/src/components/http-response.js +4 -1
- package/dist/src/components/models.d.ts.map +1 -1
- package/dist/src/components/models.js +4 -1
- package/dist/src/components/operation-handlers/paging/page-item.d.ts.map +1 -1
- package/dist/src/components/operation-handlers/paging/page-item.js +4 -1
- 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 +7 -1
- package/dist/src/components/output.d.ts +2 -0
- package/dist/src/components/output.d.ts.map +1 -1
- package/dist/src/components/output.js +6 -5
- package/dist/src/components/serializers.d.ts.map +1 -1
- package/dist/src/components/serializers.js +7 -4
- package/dist/src/components/transforms/data-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/data-transform.js +4 -1
- package/dist/src/components/transforms/json/json-array-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-array-transform.js +7 -1
- 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 -1
- 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 +4 -1
- package/dist/src/components/transforms/json/json-model-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-model-transform.js +7 -1
- package/dist/src/components/transforms/json/json-record-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-record-transform.js +7 -1
- package/dist/src/components/transforms/json/json-transform-discriminator.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-transform-discriminator.js +7 -1
- package/dist/src/components/transforms/json/json-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/json-transform.js +10 -1
- package/dist/src/components/transforms/json/union-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/json/union-transform.js +4 -1
- package/dist/src/components/transforms/json/utils/transport-namer.d.ts +2 -1
- package/dist/src/components/transforms/json/utils/transport-namer.d.ts.map +1 -1
- package/dist/src/components/transforms/json/utils/transport-namer.js +1 -2
- package/dist/src/components/transforms/multipart/multipart-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/multipart-transform.js +4 -2
- package/dist/src/components/transforms/multipart/simple-part-transform.d.ts.map +1 -1
- package/dist/src/components/transforms/multipart/simple-part-transform.js +4 -1
- package/dist/src/components/transforms/operation-transform-expression.d.ts.map +1 -1
- package/dist/src/components/transforms/operation-transform-expression.js +4 -2
- package/dist/src/components/transforms/scalar-transform.js +95 -78
- package/dist/src/components/transforms/transform-name-policy.d.ts.map +1 -1
- package/dist/src/components/transforms/transform-name-policy.js +6 -1
- package/dist/src/components/utils/unpack-model-property.d.ts.map +1 -1
- package/dist/src/components/utils/unpack-model-property.js +4 -1
- package/dist/src/context/encoding/encoding-context.d.ts.map +1 -1
- package/dist/src/context/encoding/encoding-context.js +4 -1
- package/dist/src/emitter.js +4 -1
- package/dist/src/utils/multipart.d.ts.map +1 -1
- package/dist/src/utils/multipart.js +4 -1
- package/dist/src/utils/operations.d.ts +3 -2
- package/dist/src/utils/operations.d.ts.map +1 -1
- package/dist/src/utils/operations.js +12 -13
- package/dist/src/utils/parameters.d.ts.map +1 -1
- package/dist/src/utils/parameters.js +7 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +10 -10
- package/src/components/client-context/client-context-factory.tsx +4 -1
- package/src/components/client-operation.tsx +2 -1
- package/src/components/client.tsx +5 -1
- package/src/components/http-response.tsx +2 -1
- package/src/components/models.tsx +2 -1
- package/src/components/operation-handlers/paging/page-item.tsx +2 -1
- package/src/components/operation-handlers/paging/paginated-operation-handler.tsx +3 -1
- package/src/components/output.tsx +10 -5
- package/src/components/serializers.tsx +6 -4
- package/src/components/transforms/data-transform.tsx +2 -1
- package/src/components/transforms/json/json-array-transform.tsx +3 -1
- package/src/components/transforms/json/json-model-additional-properties-transform.tsx +2 -1
- package/src/components/transforms/json/json-model-property-transform.tsx +2 -1
- package/src/components/transforms/json/json-model-transform.tsx +3 -1
- package/src/components/transforms/json/json-record-transform.tsx +3 -1
- package/src/components/transforms/json/json-transform-discriminator.tsx +3 -1
- package/src/components/transforms/json/json-transform.tsx +4 -1
- package/src/components/transforms/json/union-transform.tsx +2 -1
- package/src/components/transforms/json/utils/transport-namer.ts +2 -2
- package/src/components/transforms/multipart/multipart-transform.tsx +2 -2
- package/src/components/transforms/multipart/simple-part-transform.tsx +2 -1
- package/src/components/transforms/operation-transform-expression.tsx +2 -2
- package/src/components/transforms/scalar-transform.tsx +42 -32
- package/src/components/transforms/transform-name-policy.ts +2 -1
- package/src/components/utils/unpack-model-property.ts +2 -1
- package/src/context/encoding/encoding-context.tsx +2 -1
- package/src/emitter.tsx +2 -2
- package/src/utils/multipart.ts +2 -1
- package/src/utils/operations.ts +13 -11
- package/src/utils/parameters.tsx +3 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Children, code, Refkey } from "@alloy-js/core";
|
|
2
2
|
import { BytesKnownEncoding, EncodeData, NoTarget, Scalar } from "@typespec/compiler";
|
|
3
|
-
import {
|
|
3
|
+
import { useTsp } from "@typespec/emitter-framework";
|
|
4
4
|
import * as ef from "@typespec/emitter-framework/typescript";
|
|
5
5
|
import { useDefaultEncoding } from "../../context/encoding/encoding-context.jsx";
|
|
6
6
|
import { reportDiagnostic } from "../../lib.js";
|
|
@@ -46,6 +46,7 @@ const scalarTransformerMap = defineScalarTransformerMap({
|
|
|
46
46
|
|
|
47
47
|
bytes: {
|
|
48
48
|
toTransport: (itemRef, encoding) => {
|
|
49
|
+
const { $ } = useTsp();
|
|
49
50
|
const bytesEncoding: BytesKnownEncoding | undefined =
|
|
50
51
|
(encoding?.encoding as BytesKnownEncoding) ??
|
|
51
52
|
(useDefaultEncoding("bytes") as BytesKnownEncoding);
|
|
@@ -63,6 +64,7 @@ const scalarTransformerMap = defineScalarTransformerMap({
|
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
toApplication: (itemRef, encoding) => {
|
|
67
|
+
const { $ } = useTsp();
|
|
66
68
|
const bytesEncoding: BytesKnownEncoding | undefined =
|
|
67
69
|
(encoding?.encoding as BytesKnownEncoding) ??
|
|
68
70
|
(useDefaultEncoding("bytes") as BytesKnownEncoding);
|
|
@@ -169,6 +171,7 @@ const scalarTransformerMap = defineScalarTransformerMap({
|
|
|
169
171
|
},
|
|
170
172
|
utcDateTime: {
|
|
171
173
|
toTransport: (itemRef, encoding) => {
|
|
174
|
+
const { $ } = useTsp();
|
|
172
175
|
const dateEncoding = encoding?.encoding ?? useDefaultEncoding("datetime");
|
|
173
176
|
let encodingFnRef: Refkey = ef.DateRfc3339SerializerRefkey;
|
|
174
177
|
switch (dateEncoding) {
|
|
@@ -190,6 +193,7 @@ const scalarTransformerMap = defineScalarTransformerMap({
|
|
|
190
193
|
return code`${encodingFnRef}(${itemRef})`;
|
|
191
194
|
},
|
|
192
195
|
toApplication: (itemRef, encoding) => {
|
|
196
|
+
const { $ } = useTsp();
|
|
193
197
|
const dateEncoding = encoding?.encoding ?? useDefaultEncoding("datetime");
|
|
194
198
|
let decodingFnRef: Refkey = ef.DateDeserializerRefkey;
|
|
195
199
|
switch (dateEncoding) {
|
|
@@ -237,36 +241,42 @@ const scalarTransformerMap = defineScalarTransformerMap({
|
|
|
237
241
|
*/
|
|
238
242
|
type ScalarTest = (type: Scalar) => boolean;
|
|
239
243
|
|
|
240
|
-
|
|
241
|
-
{
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
key: "
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
244
|
+
function getScalarTests(): { key: keyof typeof scalarTransformerMap; test: ScalarTest }[] {
|
|
245
|
+
const { $ } = useTsp();
|
|
246
|
+
return [
|
|
247
|
+
{ key: "boolean", test: (t) => $.scalar.isBoolean(t) || $.scalar.extendsBoolean(t) },
|
|
248
|
+
{ key: "bytes", test: (t) => $.scalar.isBytes(t) || $.scalar.extendsBytes(t) },
|
|
249
|
+
{ key: "decimal", test: (t) => $.scalar.isDecimal(t) || $.scalar.extendsDecimal(t) },
|
|
250
|
+
{ key: "decimal128", test: (t) => $.scalar.isDecimal128(t) || $.scalar.extendsDecimal128(t) },
|
|
251
|
+
{ key: "duration", test: (t) => $.scalar.isDuration(t) || $.scalar.extendsDuration(t) },
|
|
252
|
+
{ key: "float", test: (t) => $.scalar.isFloat(t) || $.scalar.extendsFloat(t) },
|
|
253
|
+
{ key: "float32", test: (t) => $.scalar.isFloat32(t) || $.scalar.extendsFloat32(t) },
|
|
254
|
+
{ key: "float64", test: (t) => $.scalar.isFloat64(t) || $.scalar.extendsFloat64(t) },
|
|
255
|
+
{ key: "int16", test: (t) => $.scalar.isInt16(t) || $.scalar.extendsInt16(t) },
|
|
256
|
+
{ key: "int32", test: (t) => $.scalar.isInt32(t) || $.scalar.extendsInt32(t) },
|
|
257
|
+
{ key: "int64", test: (t) => $.scalar.isInt64(t) || $.scalar.extendsInt64(t) },
|
|
258
|
+
{ key: "int8", test: (t) => $.scalar.isInt8(t) || $.scalar.extendsInt8(t) },
|
|
259
|
+
{ key: "integer", test: (t) => $.scalar.isInteger(t) || $.scalar.extendsInteger(t) },
|
|
260
|
+
{ key: "numeric", test: (t) => $.scalar.isNumeric(t) || $.scalar.extendsNumeric(t) },
|
|
261
|
+
{
|
|
262
|
+
key: "offsetDateTime",
|
|
263
|
+
test: (t) => $.scalar.isOffsetDateTime(t) || $.scalar.extendsOffsetDateTime(t),
|
|
264
|
+
},
|
|
265
|
+
{ key: "plainDate", test: (t) => $.scalar.isPlainDate(t) || $.scalar.extendsPlainDate(t) },
|
|
266
|
+
{ key: "plainTime", test: (t) => $.scalar.isPlainTime(t) || $.scalar.extendsPlainTime(t) },
|
|
267
|
+
{ key: "safeint", test: (t) => $.scalar.isSafeint(t) || $.scalar.extendsSafeint(t) },
|
|
268
|
+
{ key: "string", test: (t) => $.scalar.isString(t) || $.scalar.extendsString(t) },
|
|
269
|
+
{ key: "uint16", test: (t) => $.scalar.isUint16(t) || $.scalar.extendsUint16(t) },
|
|
270
|
+
{ key: "uint32", test: (t) => $.scalar.isUint32(t) || $.scalar.extendsUint32(t) },
|
|
271
|
+
{ key: "uint64", test: (t) => $.scalar.isUint64(t) || $.scalar.extendsUint64(t) },
|
|
272
|
+
{ key: "uint8", test: (t) => $.scalar.isUint8(t) || $.scalar.extendsUint8(t) },
|
|
273
|
+
{ key: "url", test: (t) => $.scalar.isUrl(t) || $.scalar.extendsUrl(t) },
|
|
274
|
+
{
|
|
275
|
+
key: "utcDateTime",
|
|
276
|
+
test: (t) => $.scalar.isUtcDateTime(t) || $.scalar.extendsUtcDateTime(t),
|
|
277
|
+
},
|
|
278
|
+
];
|
|
279
|
+
}
|
|
270
280
|
|
|
271
281
|
/**
|
|
272
282
|
* Determines the key to use in the scalarTransformerMap for the given scalar type.
|
|
@@ -276,7 +286,7 @@ const scalarTests: { key: keyof typeof scalarTransformerMap; test: ScalarTest }[
|
|
|
276
286
|
* @throws Error if the scalar type is unknown.
|
|
277
287
|
*/
|
|
278
288
|
function getScalarTransformKey(type: Scalar): keyof typeof scalarTransformerMap {
|
|
279
|
-
for (const { key, test } of
|
|
289
|
+
for (const { key, test } of getScalarTests()) {
|
|
280
290
|
if (test(type)) {
|
|
281
291
|
return key;
|
|
282
292
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as ts from "@alloy-js/typescript";
|
|
2
2
|
import { Type } from "@typespec/compiler";
|
|
3
|
-
import { $ } from "@typespec/compiler/experimental/typekit";
|
|
4
3
|
import * as ef from "@typespec/emitter-framework";
|
|
5
4
|
import { kebabCase } from "change-case";
|
|
6
5
|
import { reportDiagnostic } from "../../lib.js";
|
|
@@ -88,6 +87,7 @@ export function createTransformNamePolicy(namers: TransformNamers = {}): ef.Tran
|
|
|
88
87
|
* @returns The transformed application name as a string.
|
|
89
88
|
*/
|
|
90
89
|
export function defaultApplicationNameGetter(type: WithName): string {
|
|
90
|
+
const { $ } = ef.useTsp();
|
|
91
91
|
if (!hasStringName(type)) {
|
|
92
92
|
reportDiagnostic($.program, { code: "symbol-name-not-supported", target: type });
|
|
93
93
|
return "";
|
|
@@ -110,6 +110,7 @@ export function defaultTransportNameGetter(
|
|
|
110
110
|
type: WithName,
|
|
111
111
|
encoding: string = "application/json",
|
|
112
112
|
): string {
|
|
113
|
+
const { $ } = ef.useTsp();
|
|
113
114
|
if (!hasStringName(type)) {
|
|
114
115
|
reportDiagnostic($.program, { code: "symbol-name-not-supported", target: type });
|
|
115
116
|
return "";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNullType, ModelProperty, Type } from "@typespec/compiler";
|
|
2
|
-
import {
|
|
2
|
+
import { useTsp } from "@typespec/emitter-framework";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Sometimes a model property type would be another ModelProperty in this case we need to keep unpacking until we find a non Model Property
|
|
@@ -7,6 +7,7 @@ import { $ } from "@typespec/compiler/experimental/typekit";
|
|
|
7
7
|
* This also handles an HttpPart which needs to be unpacked as well.
|
|
8
8
|
*/
|
|
9
9
|
export function unpackProperty(modelProperty: ModelProperty): Type {
|
|
10
|
+
const { $ } = useTsp();
|
|
10
11
|
const type = $.httpPart.unpack(modelProperty.type) ?? modelProperty.type;
|
|
11
12
|
if ($.modelProperty.is(type)) {
|
|
12
13
|
return unpackProperty(type);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ComponentContext, createNamedContext, useContext } from "@alloy-js/core";
|
|
2
2
|
import { NoTarget } from "@typespec/compiler";
|
|
3
|
-
import {
|
|
3
|
+
import { useTsp } from "@typespec/emitter-framework";
|
|
4
4
|
import { reportDiagnostic } from "../../lib.js";
|
|
5
5
|
import { EncodingDefaults } from "./types.js";
|
|
6
6
|
|
|
@@ -9,6 +9,7 @@ export const EncodingContext: ComponentContext<EncodingDefaults> =
|
|
|
9
9
|
|
|
10
10
|
export function useEncoding() {
|
|
11
11
|
const context = useContext(EncodingContext);
|
|
12
|
+
const { $ } = useTsp();
|
|
12
13
|
|
|
13
14
|
if (!context) {
|
|
14
15
|
reportDiagnostic($.program, {
|
package/src/emitter.tsx
CHANGED
|
@@ -20,7 +20,7 @@ import { JsClientEmitterOptions } from "./lib.js";
|
|
|
20
20
|
export async function $onEmit(context: EmitContext<JsClientEmitterOptions>) {
|
|
21
21
|
const packageName = context.options["package-name"] ?? "test-package";
|
|
22
22
|
const output = (
|
|
23
|
-
<Output>
|
|
23
|
+
<Output program={context.program}>
|
|
24
24
|
<ts.PackageDirectory
|
|
25
25
|
name={packageName}
|
|
26
26
|
version="1.0.0"
|
|
@@ -54,5 +54,5 @@ export async function $onEmit(context: EmitContext<JsClientEmitterOptions>) {
|
|
|
54
54
|
</Output>
|
|
55
55
|
);
|
|
56
56
|
|
|
57
|
-
await writeOutput(output, context.emitterOutputDir);
|
|
57
|
+
await writeOutput(context.program, output, context.emitterOutputDir);
|
|
58
58
|
}
|
package/src/utils/multipart.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Type } from "@typespec/compiler";
|
|
2
|
-
import {
|
|
2
|
+
import { useTsp } from "@typespec/emitter-framework";
|
|
3
3
|
import { reportDiagnostic } from "../lib.js";
|
|
4
4
|
|
|
5
5
|
export function isMultipart(type: Type): boolean {
|
|
6
|
+
const { $ } = useTsp();
|
|
6
7
|
const body = type;
|
|
7
8
|
|
|
8
9
|
if (!$.model.is(body)) {
|
package/src/utils/operations.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { Model, ModelProperty, Operation, Union } from "@typespec/compiler";
|
|
2
2
|
import {
|
|
3
|
+
unsafe_$ as $,
|
|
3
4
|
unsafe_mutateSubgraph as mutateSubgraph,
|
|
4
5
|
unsafe_Mutator as Mutator,
|
|
5
6
|
unsafe_MutatorFlow as MutatorFlow,
|
|
6
7
|
unsafe_MutatorRecord,
|
|
7
8
|
} from "@typespec/compiler/experimental";
|
|
8
|
-
import {
|
|
9
|
+
import type { Typekit } from "@typespec/compiler/experimental/typekit";
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Prepares operation for client representation. This includes adding an options bag for optional parameters.
|
|
12
13
|
* @param operation operation to be prepared
|
|
13
14
|
* @returns the prepared operation
|
|
14
15
|
*/
|
|
15
|
-
export function prepareOperation(operation: Operation): Operation {
|
|
16
|
+
export function prepareOperation($: Typekit, operation: Operation): Operation {
|
|
16
17
|
return mutateSubgraph($.program, [httpParamsMutator], operation).type as Operation;
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -23,9 +24,9 @@ const anonymousMutatorRecord: unsafe_MutatorRecord<Model | Union> = {
|
|
|
23
24
|
filter(t) {
|
|
24
25
|
return MutatorFlow.MutateAndRecur;
|
|
25
26
|
},
|
|
26
|
-
mutate(t, clone) {
|
|
27
|
+
mutate(t, clone, _program, realm) {
|
|
27
28
|
if (!clone.name) {
|
|
28
|
-
clone.name =
|
|
29
|
+
clone.name = $(realm).type.getPlausibleName(clone);
|
|
29
30
|
}
|
|
30
31
|
},
|
|
31
32
|
};
|
|
@@ -46,10 +47,11 @@ export const httpParamsMutator: Mutator = {
|
|
|
46
47
|
return MutatorFlow.DoNotRecur;
|
|
47
48
|
},
|
|
48
49
|
mutate(o, clone, _program, realm) {
|
|
49
|
-
const
|
|
50
|
-
const
|
|
50
|
+
const tk = $(realm);
|
|
51
|
+
const httpOperation = tk.httpOperation.get(o);
|
|
52
|
+
const returnType = tk.httpOperation.getReturnType(httpOperation);
|
|
51
53
|
clone.returnType = returnType;
|
|
52
|
-
const params =
|
|
54
|
+
const params = tk.httpRequest.getParameters(httpOperation, [
|
|
53
55
|
"query",
|
|
54
56
|
"header",
|
|
55
57
|
"path",
|
|
@@ -73,18 +75,18 @@ export const httpParamsMutator: Mutator = {
|
|
|
73
75
|
{} as Record<string, ModelProperty>,
|
|
74
76
|
);
|
|
75
77
|
|
|
76
|
-
const optionsBag =
|
|
78
|
+
const optionsBag = tk.model.create({
|
|
77
79
|
properties: optionals,
|
|
78
80
|
});
|
|
79
81
|
|
|
80
|
-
const optionsProp =
|
|
82
|
+
const optionsProp = tk.modelProperty.create({
|
|
81
83
|
name: "options",
|
|
82
84
|
type: optionsBag,
|
|
83
85
|
optional: true,
|
|
84
86
|
});
|
|
85
87
|
|
|
86
88
|
for (const [key, prop] of clone.parameters.properties) {
|
|
87
|
-
if (prop.optional || isConstantHeader(prop)) {
|
|
89
|
+
if (prop.optional || isConstantHeader(tk, prop)) {
|
|
88
90
|
clone.parameters.properties.delete(key);
|
|
89
91
|
}
|
|
90
92
|
}
|
|
@@ -96,7 +98,7 @@ export const httpParamsMutator: Mutator = {
|
|
|
96
98
|
},
|
|
97
99
|
};
|
|
98
100
|
|
|
99
|
-
export function isConstantHeader(modelProperty: ModelProperty) {
|
|
101
|
+
export function isConstantHeader($: Typekit, modelProperty: ModelProperty) {
|
|
100
102
|
if (!$.modelProperty.isHttpHeader(modelProperty)) {
|
|
101
103
|
return false;
|
|
102
104
|
}
|
package/src/utils/parameters.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ay from "@alloy-js/core";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
3
|
import { ModelProperty, Value } from "@typespec/compiler";
|
|
4
|
-
import {
|
|
4
|
+
import { useTsp } from "@typespec/emitter-framework";
|
|
5
5
|
import { buildParameterDescriptor } from "@typespec/emitter-framework/typescript";
|
|
6
6
|
import { HttpAuth, HttpProperty, OAuth2FlowType } from "@typespec/http";
|
|
7
7
|
import * as cl from "@typespec/http-client";
|
|
@@ -9,6 +9,7 @@ import { getClientContextOptionsRef } from "../components/client-context/client-
|
|
|
9
9
|
import { httpRuntimeTemplateLib } from "../components/external-packages/ts-http-runtime.js";
|
|
10
10
|
|
|
11
11
|
export function buildClientParameters(client: cl.Client): ts.ParameterDescriptor[] {
|
|
12
|
+
const { $ } = useTsp();
|
|
12
13
|
const clientConstructor = $.client.getConstructor(client);
|
|
13
14
|
const parameters = $.operation.getClientSignature(client, clientConstructor);
|
|
14
15
|
const params = parameters.flatMap(
|
|
@@ -42,6 +43,7 @@ export function buildClientParameters(client: cl.Client): ts.ParameterDescriptor
|
|
|
42
43
|
function buildClientParameterDescriptor(
|
|
43
44
|
modelProperty: ModelProperty,
|
|
44
45
|
): ts.ParameterDescriptor | undefined {
|
|
46
|
+
const { $ } = useTsp();
|
|
45
47
|
const authSchemes = $.modelProperty.getCredentialAuth(modelProperty);
|
|
46
48
|
|
|
47
49
|
if (authSchemes) {
|