@typespec/http 0.66.0-dev.0 → 0.66.0-dev.1
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/experimental/typekit/kits/http-operation.d.ts +7 -2
- package/dist/src/experimental/typekit/kits/http-operation.d.ts.map +1 -1
- package/dist/src/experimental/typekit/kits/http-operation.js +10 -6
- package/dist/src/experimental/typekit/kits/http-operation.js.map +1 -1
- package/dist/src/experimental/typekit/kits/http-part.d.ts +28 -0
- package/dist/src/experimental/typekit/kits/http-part.d.ts.map +1 -0
- package/dist/src/experimental/typekit/kits/http-part.js +20 -0
- package/dist/src/experimental/typekit/kits/http-part.js.map +1 -0
- package/dist/src/experimental/typekit/kits/http-request.d.ts +5 -1
- package/dist/src/experimental/typekit/kits/http-request.d.ts.map +1 -1
- package/dist/src/experimental/typekit/kits/http-request.js +12 -17
- package/dist/src/experimental/typekit/kits/http-request.js.map +1 -1
- package/dist/src/experimental/typekit/kits/http-response.d.ts +3 -2
- package/dist/src/experimental/typekit/kits/http-response.d.ts.map +1 -1
- package/dist/src/experimental/typekit/kits/http-response.js +1 -1
- package/dist/src/experimental/typekit/kits/http-response.js.map +1 -1
- package/dist/src/experimental/typekit/kits/index.d.ts +2 -0
- package/dist/src/experimental/typekit/kits/index.d.ts.map +1 -1
- package/dist/src/experimental/typekit/kits/index.js +2 -0
- package/dist/src/experimental/typekit/kits/index.js.map +1 -1
- package/dist/src/experimental/typekit/kits/model.d.ts +17 -0
- package/dist/src/experimental/typekit/kits/model.d.ts.map +1 -0
- package/dist/src/experimental/typekit/kits/model.js +10 -0
- package/dist/src/experimental/typekit/kits/model.js.map +1 -0
- package/package.json +3 -3
|
@@ -16,12 +16,12 @@ export interface HttpOperationKit {
|
|
|
16
16
|
* Get the responses for the given operation. This function will return an array of responses grouped by status code and content type.
|
|
17
17
|
* @param op operation to extract the HttpResponse from
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
flattenResponses(op: HttpOperation): FlatHttpResponse[];
|
|
20
20
|
/**
|
|
21
21
|
* Get the Http Return type for the given operation. This function will resolve the returnType based on the Http Operation.
|
|
22
22
|
* @param op operation to get the return type for
|
|
23
23
|
*/
|
|
24
|
-
getReturnType(op:
|
|
24
|
+
getReturnType(op: HttpOperation, options?: {
|
|
25
25
|
includeErrors?: boolean;
|
|
26
26
|
}): Type;
|
|
27
27
|
}
|
|
@@ -41,6 +41,11 @@ export interface FlatHttpResponse {
|
|
|
41
41
|
* Response content.
|
|
42
42
|
*/
|
|
43
43
|
responseContent: HttpOperationResponseContent;
|
|
44
|
+
/**
|
|
45
|
+
* Response type.
|
|
46
|
+
*
|
|
47
|
+
*/
|
|
48
|
+
type: Type;
|
|
44
49
|
}
|
|
45
50
|
interface TypekitExtension {
|
|
46
51
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-operation.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,SAAS,EAAiB,IAAI,EAAY,MAAM,oBAAoB,CAAC;AAGjG,OAAO,EACL,aAAa,EACb,4BAA4B,EAC5B,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,GAAG,CAAC,EAAE,EAAE,SAAS,GAAG,aAAa,CAAC;IAClC;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"http-operation.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,SAAS,EAAiB,IAAI,EAAY,MAAM,oBAAoB,CAAC;AAGjG,OAAO,EACL,aAAa,EACb,4BAA4B,EAC5B,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAE3B;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;;;;OAKG;IACH,GAAG,CAAC,EAAE,EAAE,SAAS,GAAG,aAAa,CAAC;IAClC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,EAAE,aAAa,GAAG,gBAAgB,EAAE,CAAC;IACxD;;;OAGG;IACH,aAAa,CAAC,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE;QAAE,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,IAAI,CAAC;CAC/E;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,UAAU,EAAE,oBAAoB,CAAC;IACjC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,EAAE,4BAA4B,CAAC;IAC9C;;;OAGG;IACH,IAAI,EAAE,IAAI,CAAC;CACZ;AAED,UAAU,gBAAgB;IACxB;;;OAGG;IACH,aAAa,EAAE,gBAAgB,CAAC;CACjC;AAED,OAAO,QAAQ,yCAAyC,CAAC;IACvD,UAAU,OAAQ,SAAQ,gBAAgB;KAAG;CAC9C"}
|
|
@@ -6,10 +6,10 @@ defineKit({
|
|
|
6
6
|
get(op) {
|
|
7
7
|
return ignoreDiagnostics(getHttpOperation(this.program, op));
|
|
8
8
|
},
|
|
9
|
-
getReturnType(
|
|
10
|
-
let responses = this.httpOperation.
|
|
9
|
+
getReturnType(httpOperation, options) {
|
|
10
|
+
let responses = this.httpOperation.flattenResponses(httpOperation);
|
|
11
11
|
if (!options?.includeErrors) {
|
|
12
|
-
responses = responses.filter((r) => !this.httpResponse.isErrorResponse(r
|
|
12
|
+
responses = responses.filter((r) => !this.httpResponse.isErrorResponse(r));
|
|
13
13
|
}
|
|
14
14
|
const voidType = { kind: "Intrinsic", name: "void" };
|
|
15
15
|
let httpReturnType = voidType;
|
|
@@ -31,9 +31,8 @@ defineKit({
|
|
|
31
31
|
}
|
|
32
32
|
return httpReturnType;
|
|
33
33
|
},
|
|
34
|
-
|
|
34
|
+
flattenResponses(httpOperation) {
|
|
35
35
|
const responsesMap = [];
|
|
36
|
-
const httpOperation = this.httpOperation.get(operation);
|
|
37
36
|
for (const response of httpOperation.responses) {
|
|
38
37
|
for (const responseContent of response.responses) {
|
|
39
38
|
const contentTypeProperty = responseContent.properties.find((property) => property.kind === "contentType");
|
|
@@ -44,7 +43,12 @@ defineKit({
|
|
|
44
43
|
else if (responseContent.body) {
|
|
45
44
|
contentType = "application/json";
|
|
46
45
|
}
|
|
47
|
-
responsesMap.push({
|
|
46
|
+
responsesMap.push({
|
|
47
|
+
statusCode: response.statusCodes,
|
|
48
|
+
contentType,
|
|
49
|
+
responseContent,
|
|
50
|
+
type: response.type,
|
|
51
|
+
});
|
|
48
52
|
}
|
|
49
53
|
}
|
|
50
54
|
return responsesMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-operation.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA4C,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,SAAS,EAAW,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"http-operation.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-operation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAA4C,MAAM,oBAAoB,CAAC;AACjG,OAAO,EAAE,SAAS,EAAW,MAAM,yCAAyC,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAkE1D,SAAS,CAAmB;IAC1B,aAAa,EAAE;QACb,GAAG,CAAC,EAAE;YACJ,OAAO,iBAAiB,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;QAC/D,CAAC;QACD,aAAa,CAAC,aAAa,EAAE,OAAO;YAClC,IAAI,SAAS,GAAG,IAAI,CAAC,aAAa,CAAC,gBAAgB,CAAC,aA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Aa,CAAC,SAAS,EAAE,CAAC;gBAC/C,KAAK,MAAM,eAAe,IAAI,QAAQ,CAAC,SAAS,EAAE,CAAC;oBACjD,MAAM,mBAAmB,GAAG,eAAe,CAAC,UAAU,CAAC,IAAI,CACzD,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,aAAa,CAC9C,CAAC;oBAEF,IAAI,WAA+B,CAAC;oBAEpC,IAAI,mBAAmB,EAAE,CAAC;wBACxB,WAAW,GAAI,mBAAmB,CAAC,QAAQ,CAAC,IAAsB,CAAC,KAAK,CAAC;oBAC3E,CAAC;yBAAM,IAAI,eAAe,CAAC,IAAI,EAAE,CAAC;wBAChC,WAAW,GAAG,kBAAkB,CAAC;oBACnC,CAAC;oBAED,YAAY,CAAC,IAAI,CAAC;wBAChB,UAAU,EAAE,QAAQ,CAAC,WAAW;wBAChC,WAAW;wBACX,eAAe;wBACf,IAAI,EAAE,QAAQ,CAAC,IAAI;qBACpB,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;YAED,OAAO,YAAY,CAAC;QACtB,CAAC;KACF;CACF,CAAC,CAAC;AAEH,SAAS,gBAAgB,CAAC,OAAgB,EAAE,IAAW;IACrD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,EAAc,CAAC;IACzD,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3B,OAAO,OAAO,CAAC,KAAK,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Type } from "@typespec/compiler";
|
|
2
|
+
import { HttpPart } from "../../../private.decorators.js";
|
|
3
|
+
/**
|
|
4
|
+
* Utilities for working with HTTP Parts.
|
|
5
|
+
* @experimental
|
|
6
|
+
*/
|
|
7
|
+
export interface HttpPartKit {
|
|
8
|
+
/**
|
|
9
|
+
* Check if the model is a HTTP part.
|
|
10
|
+
* @param type model to check
|
|
11
|
+
*/
|
|
12
|
+
is(type: Type): boolean;
|
|
13
|
+
get(type: Type): HttpPart | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Unpacks the wrapped model from the HTTP part or the original model if
|
|
16
|
+
* not an HttpPart.
|
|
17
|
+
* @param type HttpPart model to unpack
|
|
18
|
+
*/
|
|
19
|
+
unpack(type: Type): Type;
|
|
20
|
+
}
|
|
21
|
+
export interface TypekitExtension {
|
|
22
|
+
httpPart: HttpPartKit;
|
|
23
|
+
}
|
|
24
|
+
declare module "@typespec/compiler/experimental/typekit" {
|
|
25
|
+
interface Typekit extends TypekitExtension {
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=http-part.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-part.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-part.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,OAAO,EAAe,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAEvE;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC;IAIxB,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtC;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,WAAW,CAAC;CACvB;AAED,OAAO,QAAQ,yCAAyC,CAAC;IACvD,UAAU,OAAQ,SAAQ,gBAAgB;KAAG;CAC9C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineKit } from "@typespec/compiler/experimental/typekit";
|
|
2
|
+
import { getHttpPart } from "../../../private.decorators.js";
|
|
3
|
+
defineKit({
|
|
4
|
+
httpPart: {
|
|
5
|
+
is(type) {
|
|
6
|
+
return this.model.is(type) && this.httpPart.get(type) !== undefined;
|
|
7
|
+
},
|
|
8
|
+
get(type) {
|
|
9
|
+
return getHttpPart(this.program, type);
|
|
10
|
+
},
|
|
11
|
+
unpack(type) {
|
|
12
|
+
const part = this.httpPart.get(type);
|
|
13
|
+
if (part) {
|
|
14
|
+
return part.type;
|
|
15
|
+
}
|
|
16
|
+
return type;
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=http-part.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-part.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-part.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAY,MAAM,gCAAgC,CAAC;AAgCvE,SAAS,CAAmB;IAC1B,QAAQ,EAAE;QACR,EAAE,CAAC,IAAI;YACL,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,SAAS,CAAC;QACtE,CAAC;QACD,GAAG,CAAC,IAAI;YACN,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;QACD,MAAM,CAAC,IAAI;YACT,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrC,IAAI,IAAI,EAAE,CAAC;gBACT,OAAO,IAAI,CAAC,IAAI,CAAC;YACnB,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF;CACF,CAAC,CAAC"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { Model } from "@typespec/compiler";
|
|
2
2
|
import { HttpOperation } from "../../../types.js";
|
|
3
3
|
export type HttpRequestParameterKind = "query" | "header" | "path" | "contentType" | "body";
|
|
4
|
+
/**
|
|
5
|
+
* Utilities for working with HTTP Requests operations.
|
|
6
|
+
* @experimental
|
|
7
|
+
*/
|
|
4
8
|
interface HttpRequestKit {
|
|
5
9
|
body: {
|
|
6
10
|
/**
|
|
7
|
-
* Checks the body is a property explicitly tagged with @body or @
|
|
11
|
+
* Checks the body is a property explicitly tagged with @body @bodyRoot or @multipartBody
|
|
8
12
|
* @param httpOperation the http operation to check
|
|
9
13
|
*/
|
|
10
14
|
isExplicit(httpOperation: HttpOperation): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-request.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAiB,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;AAE5F,UAAU,cAAc;IACtB,IAAI,EAAE;QACJ;;;WAGG;QACH,UAAU,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC;KACnD,CAAC;IACF;;;OAGG;IACH,iBAAiB,CAAC,aAAa,EAAE,aAAa,GAAG,KAAK,GAAG,SAAS,CAAC;IACnE;;;;OAIG;IACH,aAAa,CACX,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,wBAAwB,EAAE,GAAG,wBAAwB,GAC1D,KAAK,GAAG,SAAS,CAAC;CACtB;AAED,UAAU,gBAAgB;IACxB,WAAW,EAAE,cAAc,CAAC;CAC7B;AAED,OAAO,QAAQ,yCAAyC,CAAC;IACvD,UAAU,OAAQ,SAAQ,gBAAgB;KAAG;CAC9C"}
|
|
1
|
+
{"version":3,"file":"http-request.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAiB,MAAM,oBAAoB,CAAC;AAE1D,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,MAAM,MAAM,wBAAwB,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,aAAa,GAAG,MAAM,CAAC;AAE5F;;;GAGG;AACH,UAAU,cAAc;IACtB,IAAI,EAAE;QACJ;;;WAGG;QACH,UAAU,CAAC,aAAa,EAAE,aAAa,GAAG,OAAO,CAAC;KACnD,CAAC;IACF;;;OAGG;IACH,iBAAiB,CAAC,aAAa,EAAE,aAAa,GAAG,KAAK,GAAG,SAAS,CAAC;IACnE;;;;OAIG;IACH,aAAa,CACX,aAAa,EAAE,aAAa,EAC5B,IAAI,EAAE,wBAAwB,EAAE,GAAG,wBAAwB,GAC1D,KAAK,GAAG,SAAS,CAAC;CACtB;AAED,UAAU,gBAAgB;IACxB,WAAW,EAAE,cAAc,CAAC;CAC7B;AAED,OAAO,QAAQ,yCAAyC,CAAC;IACvD,UAAU,OAAQ,SAAQ,gBAAgB;KAAG;CAC9C"}
|
|
@@ -3,7 +3,7 @@ defineKit({
|
|
|
3
3
|
httpRequest: {
|
|
4
4
|
body: {
|
|
5
5
|
isExplicit(httpOperation) {
|
|
6
|
-
return (httpOperation.parameters.properties.find((p) => p.kind === "body" || p.kind === "bodyRoot") !== undefined);
|
|
6
|
+
return (httpOperation.parameters.properties.find((p) => p.kind === "body" || p.kind === "bodyRoot" || p.kind === "multipartBody") !== undefined);
|
|
7
7
|
},
|
|
8
8
|
},
|
|
9
9
|
getBodyParameters(httpOperation) {
|
|
@@ -25,28 +25,23 @@ defineKit({
|
|
|
25
25
|
},
|
|
26
26
|
getParameters(httpOperation, kind) {
|
|
27
27
|
const kinds = new Set(Array.isArray(kind) ? kind : [kind]);
|
|
28
|
-
const parameterProperties =
|
|
29
|
-
|
|
28
|
+
const parameterProperties = new Map();
|
|
29
|
+
kinds.forEach((kind) => {
|
|
30
30
|
if (kind === "body") {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
parameterProperties.
|
|
34
|
-
}
|
|
31
|
+
this.httpRequest
|
|
32
|
+
.getBodyParameters(httpOperation)
|
|
33
|
+
?.properties.forEach((value, key) => parameterProperties.set(key, value));
|
|
35
34
|
}
|
|
36
35
|
else {
|
|
37
|
-
|
|
38
|
-
.filter((p) => p.kind === kind)
|
|
39
|
-
.
|
|
40
|
-
parameterProperties.push(...params);
|
|
36
|
+
httpOperation.parameters.properties
|
|
37
|
+
.filter((p) => p.kind === kind && p.property)
|
|
38
|
+
.forEach((p) => parameterProperties.set(p.property.name, p.property));
|
|
41
39
|
}
|
|
42
|
-
}
|
|
43
|
-
if (parameterProperties.
|
|
40
|
+
});
|
|
41
|
+
if (parameterProperties.size === 0) {
|
|
44
42
|
return undefined;
|
|
45
43
|
}
|
|
46
|
-
const properties =
|
|
47
|
-
acc[prop.name] = prop;
|
|
48
|
-
return acc;
|
|
49
|
-
}, {});
|
|
44
|
+
const properties = Object.fromEntries(parameterProperties);
|
|
50
45
|
return this.model.create({ properties });
|
|
51
46
|
},
|
|
52
47
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-request.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"http-request.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAyCpE,SAAS,CAAmB;IAC1B,WAAW,EAAE;QACX,IAAI,EAAE;YACJ,UAAU,CAAC,aAA4B;gBACrC,OAAO,CACL,aAAa,CAAC,UAAU,CAAC,UAAU,CAA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,WAAW;yBACb,iBAAiB,CAAC,aAAa,CAAC;wBACjC,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;gBAC9E,CAAC;qBAAM,CAAC;oBACN,aAAa,CAAC,UAAU,CAAC,UAAU;yBAChC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC;yBAC5C,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,CAAC,QAAS,CAAC,IAAI,EAAE,CAAC,CAAC,QAAS,CAAC,CAAC,CAAC;gBAC5E,CAAC;YACH,CAAC,CAAC,CAAC;YAEH,IAAI,mBAAmB,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;gBACnC,OAAO,SAAS,CAAC;YACnB,CAAC;YAED,MAAM,UAAU,GAAG,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;YAE3D,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;QAC3C,CAAC;KACF;CACF,CAAC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { HttpStatusCodeRange, HttpStatusCodesEntry } from "../../../types.js";
|
|
2
|
+
import { FlatHttpResponse } from "./http-operation.js";
|
|
2
3
|
/**
|
|
3
4
|
* Utilities for working with HTTP responses.
|
|
4
5
|
* @experimental
|
|
@@ -7,7 +8,7 @@ export interface HttpResponseKit {
|
|
|
7
8
|
/**
|
|
8
9
|
* Check if the response is an error response.
|
|
9
10
|
*/
|
|
10
|
-
isErrorResponse(response:
|
|
11
|
+
isErrorResponse(response: FlatHttpResponse): boolean;
|
|
11
12
|
/**
|
|
12
13
|
* utilities to perform checks on status codes
|
|
13
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-response.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-response.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"http-response.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-response.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,eAAe,CAAC,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC;IACrD;;OAEG;IACH,UAAU,EAAE;QACV;;;WAGG;QACH,QAAQ,CAAC,UAAU,EAAE,oBAAoB,GAAG,UAAU,IAAI,MAAM,CAAC;QACjE;;;WAGG;QACH,OAAO,CAAC,UAAU,EAAE,oBAAoB,GAAG,UAAU,IAAI,mBAAmB,CAAC;QAC7E;;;WAGG;QACH,SAAS,CAAC,UAAU,EAAE,oBAAoB,GAAG,UAAU,IAAI,GAAG,CAAC;KAChE,CAAC;CACH;AAED,UAAU,gBAAgB;IACxB;;;OAGG;IACH,YAAY,EAAE,eAAe,CAAC;CAC/B;AAED,OAAO,QAAQ,yCAAyC,CAAC;IACvD,UAAU,OAAQ,SAAQ,gBAAgB;KAAG;CAC9C"}
|
|
@@ -3,7 +3,7 @@ import { defineKit } from "@typespec/compiler/experimental/typekit";
|
|
|
3
3
|
defineKit({
|
|
4
4
|
httpResponse: {
|
|
5
5
|
isErrorResponse(response) {
|
|
6
|
-
return response.
|
|
6
|
+
return this.model.is(response.type) ? isErrorModel(this.program, response.type) : false;
|
|
7
7
|
},
|
|
8
8
|
statusCode: {
|
|
9
9
|
isSingle(statusCode) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-response.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;
|
|
1
|
+
{"version":3,"file":"http-response.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/http-response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AA+CpE,SAAS,CAAmB;IAC1B,YAAY,EAAE;QACZ,eAAe,CAAC,QAAQ;YACtB,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1F,CAAC;QACD,UAAU,EAAE;YACV,QAAQ,CAAC,UAAU;gBACjB,OAAO,OAAO,UAAU,KAAK,QAAQ,CAAC;YACxC,CAAC;YACD,OAAO,CAAC,UAAU;gBAChB,OAAO,OAAO,UAAU,KAAK,QAAQ,IAAI,OAAO,IAAI,UAAU,IAAI,KAAK,IAAI,UAAU,CAAC;YACxF,CAAC;YACD,SAAS,CAAC,UAAU;gBAClB,OAAO,UAAU,KAAK,GAAG,CAAC;YAC5B,CAAC;SACF;KACF;CACF,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Model } from "@typespec/compiler";
|
|
2
|
+
/**
|
|
3
|
+
* Utilities for working with Models in the context of Http.
|
|
4
|
+
* @experimental
|
|
5
|
+
*/
|
|
6
|
+
export interface HttpModel {
|
|
7
|
+
/**
|
|
8
|
+
* Check if a model is an Http file.
|
|
9
|
+
* @param model model to check
|
|
10
|
+
*/
|
|
11
|
+
isHttpFile(model: Model): boolean;
|
|
12
|
+
}
|
|
13
|
+
declare module "@typespec/compiler/experimental/typekit" {
|
|
14
|
+
interface ModelKit extends HttpModel {
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/model.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,UAAU,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;CACnC;AAMD,OAAO,QAAQ,yCAAyC,CAAC;IACvD,UAAU,QAAS,SAAQ,SAAS;KAAG;CACxC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineKit } from "@typespec/compiler/experimental/typekit";
|
|
2
|
+
import { isHttpFile } from "../../../private.decorators.js";
|
|
3
|
+
defineKit({
|
|
4
|
+
model: {
|
|
5
|
+
isHttpFile(model) {
|
|
6
|
+
return isHttpFile(this.program, model);
|
|
7
|
+
},
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../../src/experimental/typekit/kits/model.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAsB5D,SAAS,CAAmB;IAC1B,KAAK,EAAE;QACL,UAAU,CAAC,KAAY;YACrB,OAAO,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QACzC,CAAC;KACF;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typespec/http",
|
|
3
|
-
"version": "0.66.0-dev.
|
|
3
|
+
"version": "0.66.0-dev.1",
|
|
4
4
|
"author": "Microsoft Corporation",
|
|
5
5
|
"description": "TypeSpec HTTP protocol binding",
|
|
6
6
|
"homepage": "https://github.com/microsoft/typespec",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"!dist/test/**"
|
|
54
54
|
],
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@typespec/compiler": "~0.65.
|
|
56
|
+
"@typespec/compiler": "~0.65.1 || >=0.66.0-dev <0.66.0",
|
|
57
57
|
"@typespec/streams": "~0.65.0 || >=0.66.0-dev <0.66.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependenciesMeta": {
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/node": "~22.10.10",
|
|
66
|
-
"@typespec/compiler": "~0.65.
|
|
66
|
+
"@typespec/compiler": "~0.65.1 || >=0.66.0-dev <0.66.0",
|
|
67
67
|
"@typespec/library-linter": "~0.65.0 || >=0.66.0-dev <0.66.0",
|
|
68
68
|
"@typespec/streams": "~0.65.0 || >=0.66.0-dev <0.66.0",
|
|
69
69
|
"@vitest/coverage-v8": "^3.0.4",
|