@typespec/http-client-js 0.4.0-dev.7 → 0.4.0-dev.8
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-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 +1 -1
- 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,10 +1,12 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import * as ay from "@alloy-js/core";
|
|
3
|
-
import {
|
|
4
|
-
import { useTransformNamePolicy } from "@typespec/emitter-framework";
|
|
3
|
+
import { useTransformNamePolicy, useTsp } from "@typespec/emitter-framework";
|
|
5
4
|
import { reportDiagnostic } from "../../../lib.js";
|
|
6
5
|
import { HttpPartTransform } from "./part-transform.js";
|
|
7
6
|
export function MultipartTransform(props) {
|
|
7
|
+
const {
|
|
8
|
+
$
|
|
9
|
+
} = useTsp();
|
|
8
10
|
const transportNamer = useTransformNamePolicy();
|
|
9
11
|
const httpParts = props.body.parts;
|
|
10
12
|
if (httpParts.length === 0) {
|
|
@@ -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,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAInD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"simple-part-transform.d.ts","sourceRoot":"","sources":["../../../../../src/components/transforms/multipart/simple-part-transform.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAGrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAInD,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,iBAAiB,CAAC;IACxB,OAAO,EAAE,EAAE,CAAC,QAAQ,CAAC;CACtB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,eAgClE"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import * as ay from "@alloy-js/core";
|
|
3
3
|
import * as ts from "@alloy-js/typescript";
|
|
4
|
-
import {
|
|
4
|
+
import { useTsp } from "@typespec/emitter-framework";
|
|
5
5
|
import { reportDiagnostic } from "../../../lib.js";
|
|
6
6
|
import { JsonTransform } from "../json/json-transform.js";
|
|
7
7
|
export function SimplePartTransform(props) {
|
|
8
|
+
const {
|
|
9
|
+
$
|
|
10
|
+
} = useTsp();
|
|
8
11
|
const namePolicy = ts.useTSNamePolicy();
|
|
9
12
|
const applicationName = namePolicy.getName(props.part.name, "variable");
|
|
10
13
|
const partName = ts.ValueExpression({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operation-transform-expression.d.ts","sourceRoot":"","sources":["../../../../src/components/transforms/operation-transform-expression.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"operation-transform-expression.d.ts","sourceRoot":"","sources":["../../../../src/components/transforms/operation-transform-expression.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,MAAM,WAAW,uCAAuC;IACtD,aAAa,EAAE,aAAa,CAAC;CAC9B;AAED,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,uCAAuC,qCA6B1F"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createComponent as _$createComponent } from "@alloy-js/core/jsx-runtime";
|
|
2
2
|
import * as ts from "@alloy-js/typescript";
|
|
3
|
-
import {
|
|
4
|
-
import { TransformNamePolicyContext } from "@typespec/emitter-framework";
|
|
3
|
+
import { TransformNamePolicyContext, useTsp } from "@typespec/emitter-framework";
|
|
5
4
|
import { reportDiagnostic } from "../../lib.js";
|
|
6
5
|
import { ContentTypeEncodingProvider } from "./content-type-encoding-provider.js";
|
|
7
6
|
import { JsonTransform } from "./json/json-transform.js";
|
|
@@ -43,6 +42,9 @@ export function OperationTransformExpression(props) {
|
|
|
43
42
|
});
|
|
44
43
|
}
|
|
45
44
|
function payloadApplicationNameGetter(type) {
|
|
45
|
+
const {
|
|
46
|
+
$
|
|
47
|
+
} = useTsp();
|
|
46
48
|
if (typeof type.name !== "string") {
|
|
47
49
|
reportDiagnostic($.program, {
|
|
48
50
|
code: "symbol-name-not-supported",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { code } from "@alloy-js/core";
|
|
2
2
|
import { NoTarget } 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.js";
|
|
6
6
|
import { reportDiagnostic } from "../../lib.js";
|
|
@@ -36,6 +36,9 @@ const scalarTransformerMap = defineScalarTransformerMap({
|
|
|
36
36
|
},
|
|
37
37
|
bytes: {
|
|
38
38
|
toTransport: (itemRef, encoding) => {
|
|
39
|
+
const {
|
|
40
|
+
$
|
|
41
|
+
} = useTsp();
|
|
39
42
|
const bytesEncoding = encoding?.encoding ?? useDefaultEncoding("bytes");
|
|
40
43
|
switch (bytesEncoding) {
|
|
41
44
|
case "base64":
|
|
@@ -51,6 +54,9 @@ const scalarTransformerMap = defineScalarTransformerMap({
|
|
|
51
54
|
}
|
|
52
55
|
},
|
|
53
56
|
toApplication: (itemRef, encoding) => {
|
|
57
|
+
const {
|
|
58
|
+
$
|
|
59
|
+
} = useTsp();
|
|
54
60
|
const bytesEncoding = encoding?.encoding ?? useDefaultEncoding("bytes");
|
|
55
61
|
switch (bytesEncoding) {
|
|
56
62
|
case "base64":
|
|
@@ -151,6 +157,9 @@ const scalarTransformerMap = defineScalarTransformerMap({
|
|
|
151
157
|
},
|
|
152
158
|
utcDateTime: {
|
|
153
159
|
toTransport: (itemRef, encoding) => {
|
|
160
|
+
const {
|
|
161
|
+
$
|
|
162
|
+
} = useTsp();
|
|
154
163
|
const dateEncoding = encoding?.encoding ?? useDefaultEncoding("datetime");
|
|
155
164
|
let encodingFnRef = ef.DateRfc3339SerializerRefkey;
|
|
156
165
|
switch (dateEncoding) {
|
|
@@ -172,6 +181,9 @@ const scalarTransformerMap = defineScalarTransformerMap({
|
|
|
172
181
|
return code`${encodingFnRef}(${itemRef})`;
|
|
173
182
|
},
|
|
174
183
|
toApplication: (itemRef, encoding) => {
|
|
184
|
+
const {
|
|
185
|
+
$
|
|
186
|
+
} = useTsp();
|
|
175
187
|
const dateEncoding = encoding?.encoding ?? useDefaultEncoding("datetime");
|
|
176
188
|
let decodingFnRef = ef.DateDeserializerRefkey;
|
|
177
189
|
switch (dateEncoding) {
|
|
@@ -216,82 +228,87 @@ const scalarTransformerMap = defineScalarTransformerMap({
|
|
|
216
228
|
* Tests for determining the scalar transformation key.
|
|
217
229
|
*/
|
|
218
230
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
231
|
+
function getScalarTests() {
|
|
232
|
+
const {
|
|
233
|
+
$
|
|
234
|
+
} = useTsp();
|
|
235
|
+
return [{
|
|
236
|
+
key: "boolean",
|
|
237
|
+
test: t => $.scalar.isBoolean(t) || $.scalar.extendsBoolean(t)
|
|
238
|
+
}, {
|
|
239
|
+
key: "bytes",
|
|
240
|
+
test: t => $.scalar.isBytes(t) || $.scalar.extendsBytes(t)
|
|
241
|
+
}, {
|
|
242
|
+
key: "decimal",
|
|
243
|
+
test: t => $.scalar.isDecimal(t) || $.scalar.extendsDecimal(t)
|
|
244
|
+
}, {
|
|
245
|
+
key: "decimal128",
|
|
246
|
+
test: t => $.scalar.isDecimal128(t) || $.scalar.extendsDecimal128(t)
|
|
247
|
+
}, {
|
|
248
|
+
key: "duration",
|
|
249
|
+
test: t => $.scalar.isDuration(t) || $.scalar.extendsDuration(t)
|
|
250
|
+
}, {
|
|
251
|
+
key: "float",
|
|
252
|
+
test: t => $.scalar.isFloat(t) || $.scalar.extendsFloat(t)
|
|
253
|
+
}, {
|
|
254
|
+
key: "float32",
|
|
255
|
+
test: t => $.scalar.isFloat32(t) || $.scalar.extendsFloat32(t)
|
|
256
|
+
}, {
|
|
257
|
+
key: "float64",
|
|
258
|
+
test: t => $.scalar.isFloat64(t) || $.scalar.extendsFloat64(t)
|
|
259
|
+
}, {
|
|
260
|
+
key: "int16",
|
|
261
|
+
test: t => $.scalar.isInt16(t) || $.scalar.extendsInt16(t)
|
|
262
|
+
}, {
|
|
263
|
+
key: "int32",
|
|
264
|
+
test: t => $.scalar.isInt32(t) || $.scalar.extendsInt32(t)
|
|
265
|
+
}, {
|
|
266
|
+
key: "int64",
|
|
267
|
+
test: t => $.scalar.isInt64(t) || $.scalar.extendsInt64(t)
|
|
268
|
+
}, {
|
|
269
|
+
key: "int8",
|
|
270
|
+
test: t => $.scalar.isInt8(t) || $.scalar.extendsInt8(t)
|
|
271
|
+
}, {
|
|
272
|
+
key: "integer",
|
|
273
|
+
test: t => $.scalar.isInteger(t) || $.scalar.extendsInteger(t)
|
|
274
|
+
}, {
|
|
275
|
+
key: "numeric",
|
|
276
|
+
test: t => $.scalar.isNumeric(t) || $.scalar.extendsNumeric(t)
|
|
277
|
+
}, {
|
|
278
|
+
key: "offsetDateTime",
|
|
279
|
+
test: t => $.scalar.isOffsetDateTime(t) || $.scalar.extendsOffsetDateTime(t)
|
|
280
|
+
}, {
|
|
281
|
+
key: "plainDate",
|
|
282
|
+
test: t => $.scalar.isPlainDate(t) || $.scalar.extendsPlainDate(t)
|
|
283
|
+
}, {
|
|
284
|
+
key: "plainTime",
|
|
285
|
+
test: t => $.scalar.isPlainTime(t) || $.scalar.extendsPlainTime(t)
|
|
286
|
+
}, {
|
|
287
|
+
key: "safeint",
|
|
288
|
+
test: t => $.scalar.isSafeint(t) || $.scalar.extendsSafeint(t)
|
|
289
|
+
}, {
|
|
290
|
+
key: "string",
|
|
291
|
+
test: t => $.scalar.isString(t) || $.scalar.extendsString(t)
|
|
292
|
+
}, {
|
|
293
|
+
key: "uint16",
|
|
294
|
+
test: t => $.scalar.isUint16(t) || $.scalar.extendsUint16(t)
|
|
295
|
+
}, {
|
|
296
|
+
key: "uint32",
|
|
297
|
+
test: t => $.scalar.isUint32(t) || $.scalar.extendsUint32(t)
|
|
298
|
+
}, {
|
|
299
|
+
key: "uint64",
|
|
300
|
+
test: t => $.scalar.isUint64(t) || $.scalar.extendsUint64(t)
|
|
301
|
+
}, {
|
|
302
|
+
key: "uint8",
|
|
303
|
+
test: t => $.scalar.isUint8(t) || $.scalar.extendsUint8(t)
|
|
304
|
+
}, {
|
|
305
|
+
key: "url",
|
|
306
|
+
test: t => $.scalar.isUrl(t) || $.scalar.extendsUrl(t)
|
|
307
|
+
}, {
|
|
308
|
+
key: "utcDateTime",
|
|
309
|
+
test: t => $.scalar.isUtcDateTime(t) || $.scalar.extendsUtcDateTime(t)
|
|
310
|
+
}];
|
|
311
|
+
}
|
|
295
312
|
|
|
296
313
|
/**
|
|
297
314
|
* Determines the key to use in the scalarTransformerMap for the given scalar type.
|
|
@@ -304,7 +321,7 @@ function getScalarTransformKey(type) {
|
|
|
304
321
|
for (const {
|
|
305
322
|
key,
|
|
306
323
|
test
|
|
307
|
-
} of
|
|
324
|
+
} of getScalarTests()) {
|
|
308
325
|
if (test(type)) {
|
|
309
326
|
return key;
|
|
310
327
|
}
|
|
@@ -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,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,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"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as ts from "@alloy-js/typescript";
|
|
2
|
-
import { $ } from "@typespec/compiler/experimental/typekit";
|
|
3
2
|
import * as ef from "@typespec/emitter-framework";
|
|
4
3
|
import { kebabCase } from "change-case";
|
|
5
4
|
import { reportDiagnostic } from "../../lib.js";
|
|
@@ -64,6 +63,9 @@ export function createTransformNamePolicy(namers = {}) {
|
|
|
64
63
|
* @returns The transformed application name as a string.
|
|
65
64
|
*/
|
|
66
65
|
export function defaultApplicationNameGetter(type) {
|
|
66
|
+
const {
|
|
67
|
+
$
|
|
68
|
+
} = ef.useTsp();
|
|
67
69
|
if (!hasStringName(type)) {
|
|
68
70
|
reportDiagnostic($.program, {
|
|
69
71
|
code: "symbol-name-not-supported",
|
|
@@ -85,6 +87,9 @@ export function defaultApplicationNameGetter(type) {
|
|
|
85
87
|
* @returns The transformed transport name as a string.
|
|
86
88
|
*/
|
|
87
89
|
export function defaultTransportNameGetter(type, encoding = "application/json") {
|
|
90
|
+
const {
|
|
91
|
+
$
|
|
92
|
+
} = ef.useTsp();
|
|
88
93
|
if (!hasStringName(type)) {
|
|
89
94
|
reportDiagnostic($.program, {
|
|
90
95
|
code: "symbol-name-not-supported",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unpack-model-property.d.ts","sourceRoot":"","sources":["../../../../src/components/utils/unpack-model-property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAGrE;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"unpack-model-property.d.ts","sourceRoot":"","sources":["../../../../src/components/utils/unpack-model-property.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,aAAa,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAGrE;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,aAAa,GAAG,IAAI,CAkCjE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNullType } 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,9 @@ 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) {
|
|
10
|
+
const {
|
|
11
|
+
$
|
|
12
|
+
} = useTsp();
|
|
10
13
|
const type = $.httpPart.unpack(modelProperty.type) ?? modelProperty.type;
|
|
11
14
|
if ($.modelProperty.is(type)) {
|
|
12
15
|
return unpackProperty(type);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"encoding-context.d.ts","sourceRoot":"","sources":["../../../../src/context/encoding/encoding-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;AAIlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,gBAAgB,CACb,CAAC;AAEnD,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"encoding-context.d.ts","sourceRoot":"","sources":["../../../../src/context/encoding/encoding-context.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAkC,MAAM,gBAAgB,CAAC;AAIlF,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,eAAe,EAAE,gBAAgB,CAAC,gBAAgB,CACb,CAAC;AAEnD,wBAAgB,WAAW,iDAY1B;AAED,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,gBAAgB,GAAG,MAAM,GAAG,SAAS,CAGzF"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { 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
|
export const EncodingContext = createNamedContext("Encoding");
|
|
6
6
|
export function useEncoding() {
|
|
7
7
|
const context = useContext(EncodingContext);
|
|
8
|
+
const {
|
|
9
|
+
$
|
|
10
|
+
} = useTsp();
|
|
8
11
|
if (!context) {
|
|
9
12
|
reportDiagnostic($.program, {
|
|
10
13
|
code: "use-encoding-context-without-provider",
|
package/dist/src/emitter.js
CHANGED
|
@@ -18,6 +18,9 @@ import { RestError } from "./components/static-helpers/rest-error.js";
|
|
|
18
18
|
export async function $onEmit(context) {
|
|
19
19
|
const packageName = context.options["package-name"] ?? "test-package";
|
|
20
20
|
const output = _$createComponent(Output, {
|
|
21
|
+
get program() {
|
|
22
|
+
return context.program;
|
|
23
|
+
},
|
|
21
24
|
get children() {
|
|
22
25
|
return _$createComponent(ts.PackageDirectory, {
|
|
23
26
|
name: packageName,
|
|
@@ -69,5 +72,5 @@ export async function $onEmit(context) {
|
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
74
|
});
|
|
72
|
-
await writeOutput(output, context.emitterOutputDir);
|
|
75
|
+
await writeOutput(context.program, output, context.emitterOutputDir);
|
|
73
76
|
}
|
|
@@ -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;AAI1C,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"multipart.d.ts","sourceRoot":"","sources":["../../../src/utils/multipart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAI1C,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAwB/C"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useTsp } from "@typespec/emitter-framework";
|
|
2
2
|
import { reportDiagnostic } from "../lib.js";
|
|
3
3
|
export function isMultipart(type) {
|
|
4
|
+
const {
|
|
5
|
+
$
|
|
6
|
+
} = useTsp();
|
|
4
7
|
const body = type;
|
|
5
8
|
if (!$.model.is(body)) {
|
|
6
9
|
return false;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { ModelProperty, Operation } from "@typespec/compiler";
|
|
2
2
|
import { unsafe_Mutator as Mutator } from "@typespec/compiler/experimental";
|
|
3
|
+
import type { Typekit } from "@typespec/compiler/experimental/typekit";
|
|
3
4
|
/**
|
|
4
5
|
* Prepares operation for client representation. This includes adding an options bag for optional parameters.
|
|
5
6
|
* @param operation operation to be prepared
|
|
6
7
|
* @returns the prepared operation
|
|
7
8
|
*/
|
|
8
|
-
export declare function prepareOperation(operation: Operation): Operation;
|
|
9
|
+
export declare function prepareOperation($: Typekit, operation: Operation): Operation;
|
|
9
10
|
export declare const anonymousMutator: Mutator;
|
|
10
11
|
/**
|
|
11
12
|
* Mutates the operation so that the parameters model is split into required and optional parameters.
|
|
12
13
|
*/
|
|
13
14
|
export declare const httpParamsMutator: Mutator;
|
|
14
|
-
export declare function isConstantHeader(modelProperty: ModelProperty): boolean;
|
|
15
|
+
export declare function isConstantHeader($: Typekit, modelProperty: ModelProperty): boolean;
|
|
15
16
|
//# sourceMappingURL=operations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../src/utils/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,aAAa,EAAE,SAAS,EAAS,MAAM,oBAAoB,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../../src/utils/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,aAAa,EAAE,SAAS,EAAS,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EAGL,cAAc,IAAI,OAAO,EAG1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAEvE;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,CAE5E;AAgBD,eAAO,MAAM,gBAAgB,EAAE,OAI9B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAwD/B,CAAC;AAEF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,WAUxE"}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { unsafe_mutateSubgraph as mutateSubgraph, unsafe_MutatorFlow as MutatorFlow } from "@typespec/compiler/experimental";
|
|
2
|
-
import { $ } from "@typespec/compiler/experimental/typekit";
|
|
3
|
-
|
|
1
|
+
import { unsafe_$ as $, unsafe_mutateSubgraph as mutateSubgraph, unsafe_MutatorFlow as MutatorFlow } from "@typespec/compiler/experimental";
|
|
4
2
|
/**
|
|
5
3
|
* Prepares operation for client representation. This includes adding an options bag for optional parameters.
|
|
6
4
|
* @param operation operation to be prepared
|
|
7
5
|
* @returns the prepared operation
|
|
8
6
|
*/
|
|
9
|
-
export function prepareOperation(operation) {
|
|
7
|
+
export function prepareOperation($, operation) {
|
|
10
8
|
return mutateSubgraph($.program, [httpParamsMutator], operation).type;
|
|
11
9
|
}
|
|
12
10
|
|
|
@@ -17,9 +15,9 @@ const anonymousMutatorRecord = {
|
|
|
17
15
|
filter(t) {
|
|
18
16
|
return MutatorFlow.MutateAndRecur;
|
|
19
17
|
},
|
|
20
|
-
mutate(t, clone) {
|
|
18
|
+
mutate(t, clone, _program, realm) {
|
|
21
19
|
if (!clone.name) {
|
|
22
|
-
clone.name =
|
|
20
|
+
clone.name = $(realm).type.getPlausibleName(clone);
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
23
|
};
|
|
@@ -39,10 +37,11 @@ export const httpParamsMutator = {
|
|
|
39
37
|
return MutatorFlow.DoNotRecur;
|
|
40
38
|
},
|
|
41
39
|
mutate(o, clone, _program, realm) {
|
|
42
|
-
const
|
|
43
|
-
const
|
|
40
|
+
const tk = $(realm);
|
|
41
|
+
const httpOperation = tk.httpOperation.get(o);
|
|
42
|
+
const returnType = tk.httpOperation.getReturnType(httpOperation);
|
|
44
43
|
clone.returnType = returnType;
|
|
45
|
-
const params =
|
|
44
|
+
const params = tk.httpRequest.getParameters(httpOperation, ["query", "header", "path", "body", "contentType"]);
|
|
46
45
|
if (!params) {
|
|
47
46
|
return;
|
|
48
47
|
}
|
|
@@ -51,16 +50,16 @@ export const httpParamsMutator = {
|
|
|
51
50
|
acc[prop.name] = prop;
|
|
52
51
|
return acc;
|
|
53
52
|
}, {});
|
|
54
|
-
const optionsBag =
|
|
53
|
+
const optionsBag = tk.model.create({
|
|
55
54
|
properties: optionals
|
|
56
55
|
});
|
|
57
|
-
const optionsProp =
|
|
56
|
+
const optionsProp = tk.modelProperty.create({
|
|
58
57
|
name: "options",
|
|
59
58
|
type: optionsBag,
|
|
60
59
|
optional: true
|
|
61
60
|
});
|
|
62
61
|
for (const [key, prop] of clone.parameters.properties) {
|
|
63
|
-
if (prop.optional || isConstantHeader(prop)) {
|
|
62
|
+
if (prop.optional || isConstantHeader(tk, prop)) {
|
|
64
63
|
clone.parameters.properties.delete(key);
|
|
65
64
|
}
|
|
66
65
|
}
|
|
@@ -70,7 +69,7 @@ export const httpParamsMutator = {
|
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
};
|
|
73
|
-
export function isConstantHeader(modelProperty) {
|
|
72
|
+
export function isConstantHeader($, modelProperty) {
|
|
74
73
|
if (!$.modelProperty.isHttpHeader(modelProperty)) {
|
|
75
74
|
return false;
|
|
76
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/utils/parameters.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAS,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EAAY,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI5C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,mBAAmB,EAAE,
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../../src/utils/parameters.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAS,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EAAY,YAAY,EAAkB,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAI5C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,GAAG,EAAE,CAAC,mBAAmB,EAAE,CA8BjF;AA4DD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,OAAO,CAE/D;AAED,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;AAChG,wBAAgB,eAAe,CAAC,QAAQ,EAAE,YAAY,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import * as ay from "@alloy-js/core";
|
|
2
|
-
import {
|
|
2
|
+
import { useTsp } from "@typespec/emitter-framework";
|
|
3
3
|
import { buildParameterDescriptor } from "@typespec/emitter-framework/typescript";
|
|
4
4
|
import { getClientContextOptionsRef } from "../components/client-context/client-context-options.js";
|
|
5
5
|
import { httpRuntimeTemplateLib } from "../components/external-packages/ts-http-runtime.js";
|
|
6
6
|
export function buildClientParameters(client) {
|
|
7
|
+
const {
|
|
8
|
+
$
|
|
9
|
+
} = useTsp();
|
|
7
10
|
const clientConstructor = $.client.getConstructor(client);
|
|
8
11
|
const parameters = $.operation.getClientSignature(client, clientConstructor);
|
|
9
12
|
const params = parameters.flatMap(param => {
|
|
@@ -27,6 +30,9 @@ export function buildClientParameters(client) {
|
|
|
27
30
|
return params;
|
|
28
31
|
}
|
|
29
32
|
function buildClientParameterDescriptor(modelProperty) {
|
|
33
|
+
const {
|
|
34
|
+
$
|
|
35
|
+
} = useTsp();
|
|
30
36
|
const authSchemes = $.modelProperty.getCredentialAuth(modelProperty);
|
|
31
37
|
if (authSchemes) {
|
|
32
38
|
if (authSchemes.length === 1 && authSchemes[0].type === "noAuth") {
|