@typespec/http 0.68.0-dev.6 → 0.68.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/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib.d.ts +77 -12
- package/dist/src/lib.d.ts.map +1 -1
- package/dist/src/lib.js +27 -2
- package/dist/src/lib.js.map +1 -1
- package/dist/src/parameters.d.ts.map +1 -1
- package/dist/src/parameters.js +11 -10
- package/dist/src/parameters.js.map +1 -1
- package/dist/src/payload.d.ts +2 -2
- package/dist/src/payload.d.ts.map +1 -1
- package/dist/src/payload.js +100 -30
- package/dist/src/payload.js.map +1 -1
- package/dist/src/private.decorators.d.ts +5 -4
- package/dist/src/private.decorators.d.ts.map +1 -1
- package/dist/src/private.decorators.js +109 -5
- package/dist/src/private.decorators.js.map +1 -1
- package/dist/src/route.d.ts.map +1 -1
- package/dist/src/route.js +14 -2
- package/dist/src/route.js.map +1 -1
- package/dist/src/types.d.ts +52 -8
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/validate.d.ts.map +1 -1
- package/dist/src/validate.js +45 -6
- package/dist/src/validate.js.map +1 -1
- package/lib/main.tsp +146 -3
- package/package.json +1 -1
package/dist/src/index.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export { getOperationParameters } from "./parameters.js";
|
|
|
11
11
|
export { HttpPart, getHttpFileModel, getHttpPart, isHttpFile, isOrExtendsHttpFile, } from "./private.decorators.js";
|
|
12
12
|
export { getResponsesForOperation } from "./responses.js";
|
|
13
13
|
export { addQueryParamsToUriTemplate, getRouteOptionsForNamespace, getRoutePath, getUriTemplatePathParam, isSharedRoute, joinPathSegments, setRoute, setSharedRoute, } from "./route.js";
|
|
14
|
-
export type { AnyHttpAuthRef, ApiKeyAuth, Authentication, AuthenticationOption, AuthenticationOptionReference, AuthenticationReference, AuthorizationCodeFlow, BasicAuth, BearerAuth, ClientCredentialsFlow, CookieParameterOptions, HeaderFieldOptions, HttpAuth, HttpAuthBase, HttpAuthRef, HttpBody, HttpOperation, HttpOperationBody, HttpOperationBodyBase, HttpOperationCookieParameter, HttpOperationHeaderParameter, HttpOperationMultipartBody, HttpOperationParameter, HttpOperationParameters, HttpOperationPart, HttpOperationPathParameter, HttpOperationQueryParameter, HttpOperationResponse, HttpOperationResponseContent, HttpService, HttpServiceAuthentication, HttpStatusCodeRange, HttpStatusCodes, HttpStatusCodesEntry, HttpVerb, ImplicitFlow, NoAuth, NoHttpAuthRef, OAuth2Flow, OAuth2FlowType, OAuth2HttpAuthRef, OAuth2Scope, Oauth2Auth, OpenIDConnectAuth, OperationContainer, OperationVerbSelector, PasswordFlow, PathParameterOptions, QueryParameterOptions, RoutePath, } from "./types.js";
|
|
14
|
+
export type { AnyHttpAuthRef, ApiKeyAuth, Authentication, AuthenticationOption, AuthenticationOptionReference, AuthenticationReference, AuthorizationCodeFlow, BasicAuth, BearerAuth, ClientCredentialsFlow, CookieParameterOptions, HeaderFieldOptions, HttpAuth, HttpAuthBase, HttpAuthRef, HttpBody, HttpOperation, HttpOperationBody, HttpOperationBodyBase, HttpOperationCookieParameter, HttpOperationFileBody, HttpOperationHeaderParameter, HttpOperationMultipartBody, HttpOperationMultipartPartBody, HttpOperationParameter, HttpOperationParameters, HttpOperationPart, HttpOperationPathParameter, HttpOperationQueryParameter, HttpOperationResponse, HttpOperationResponseContent, HttpPayloadBody, HttpService, HttpServiceAuthentication, HttpStatusCodeRange, HttpStatusCodes, HttpStatusCodesEntry, HttpVerb, ImplicitFlow, NoAuth, NoHttpAuthRef, OAuth2Flow, OAuth2FlowType, OAuth2HttpAuthRef, OAuth2Scope, Oauth2Auth, OpenIDConnectAuth, OperationContainer, OperationVerbSelector, PasswordFlow, PathParameterOptions, QueryParameterOptions, RoutePath, } from "./types.js";
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAClF,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,OAAO,EACP,IAAI,EACJ,KAAK,EACL,OAAO,EACP,cAAc,EACd,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,wBAAwB,EACxB,cAAc,EACd,6BAA6B,EAC7B,MAAM,EACN,YAAY,EACZ,UAAU,EACV,aAAa,EACb,QAAQ,EACR,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,iBAAiB,EACjB,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,UAAU,EACV,SAAS,EACT,wBAAwB,EACxB,KAAK,YAAY,EACjB,KAAK,mBAAmB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,YAAY,EACZ,uBAAuB,EACvB,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACrB,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,4BAA4B,EAC5B,4BAA4B,EAC5B,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,4BAA4B,EAC5B,WAAW,EACX,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,aAAa,EACb,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,GACV,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AA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ACR,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,YAAY,EACZ,uBAAuB,EACvB,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,cAAc,EACd,UAAU,EACV,cAAc,EACd,oBAAoB,EACpB,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACrB,SAAS,EACT,UAAU,EACV,qBAAqB,EACrB,sBAAsB,EACtB,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,aAAa,EACb,iBAAiB,EACjB,qBAAqB,EACrB,4BAA4B,EAC5B,qBAAqB,EACrB,4BAA4B,EAC5B,0BAA0B,EAC1B,8BAA8B,EAC9B,sBAAsB,EACtB,uBAAuB,EACvB,iBAAiB,EACjB,0BAA0B,EAC1B,2BAA2B,EAC3B,qBAAqB,EACrB,4BAA4B,EAC5B,eAAe,EACf,WAAW,EACX,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,EACf,oBAAoB,EACpB,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,aAAa,EACb,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,GACV,MAAM,YAAY,CAAC"}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CA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2BAA2B,EAC3B,YAAY,EACZ,uBAAuB,EACvB,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,cAAc,GACf,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,6BAA6B,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EACL,KAAK,EACL,WAAW,EACX,SAAS,EACT,OAAO,EACP,OAAO,EACP,IAAI,EACJ,KAAK,EACL,OAAO,EACP,cAAc,EACd,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,iBAAiB,EACjB,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,UAAU,EACV,wBAAwB,EACxB,cAAc,EACd,6BAA6B,EAC7B,MAAM,EACN,YAAY,EACZ,UAAU,EACV,aAAa,EACb,QAAQ,EACR,uBAAuB,EACvB,WAAW,EACX,YAAY,EACZ,YAAY,EACZ,iBAAiB,GAElB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,gBAAgB;AAChB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,0BAA0B,EAC1B,UAAU,EACV,SAAS,EACT,wBAAwB,GAGzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAEL,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,wBAAwB,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EACL,2BAA2B,EAC3B,2BAA2B,EAC3B,YAAY,EACZ,uBAAuB,EACvB,aAAa,EACb,gBAAgB,EAChB,QAAQ,EACR,cAAc,GACf,MAAM,YAAY,CAAC;AA0DpB,gBAAgB;AAChB,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/src/lib.d.ts
CHANGED
|
@@ -11,8 +11,8 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
|
11
11
|
"use-uri-template": {
|
|
12
12
|
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
13
13
|
};
|
|
14
|
-
"optional-path-
|
|
15
|
-
readonly default: import("@typespec/compiler").CallableMessage<["paramName"]>;
|
|
14
|
+
"optional-needs-path-expansion": {
|
|
15
|
+
readonly default: import("@typespec/compiler").CallableMessage<["paramName", "paramName", "paramName"]>;
|
|
16
16
|
};
|
|
17
17
|
"missing-server-param": {
|
|
18
18
|
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
@@ -77,11 +77,24 @@ export declare const $lib: import("@typespec/compiler").TypeSpecLibrary<{
|
|
|
77
77
|
"http-file-extra-property": {
|
|
78
78
|
readonly default: import("@typespec/compiler").CallableMessage<["propName"]>;
|
|
79
79
|
};
|
|
80
|
+
"http-file-disallowed-metadata": {
|
|
81
|
+
readonly default: import("@typespec/compiler").CallableMessage<["metadataType", "propName"]>;
|
|
82
|
+
};
|
|
80
83
|
"formdata-no-part-name": {
|
|
81
84
|
readonly default: "Part used in multipart/form-data must have a name.";
|
|
82
85
|
};
|
|
86
|
+
"http-file-structured": {
|
|
87
|
+
readonly default: import("@typespec/compiler").CallableMessage<["contentTypes"]>;
|
|
88
|
+
readonly union: "An HTTP File in a union is serialized as a structured model instead of being treated as the contents of a file. Declare a separate operation using `@sharedRoute` that has only the File model as the body type to treat it as a file, or suppress this warning if you intend to serialize the File as a model.";
|
|
89
|
+
};
|
|
90
|
+
"http-file-content-type-not-string": {
|
|
91
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
92
|
+
};
|
|
93
|
+
"http-file-contents-not-scalar": {
|
|
94
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
95
|
+
};
|
|
83
96
|
}, Record<string, any>, "file" | "path" | "query" | "authentication" | "header" | "cookie" | "body" | "bodyRoot" | "bodyIgnore" | "multipartBody" | "statusCode" | "verbs" | "patchOptions" | "servers" | "includeInapplicableMetadataInPayload" | "externalInterfaces" | "routeProducer" | "routes" | "sharedRoutes" | "routeOptions" | "httpPart">;
|
|
84
|
-
export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missing-uri-param" | "incompatible-uri-param" | "use-uri-template" | "optional-path-
|
|
97
|
+
export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missing-uri-param" | "incompatible-uri-param" | "use-uri-template" | "optional-needs-path-expansion" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "multiple-status-codes" | "status-code-invalid" | "content-type-string" | "content-type-ignored" | "metadata-ignored" | "response-cookie-not-supported" | "no-service-found" | "invalid-type-for-auth" | "shared-inconsistency" | "multipart-invalid-content-type" | "multipart-model" | "no-implicit-multipart" | "multipart-part" | "multipart-nested" | "http-file-extra-property" | "http-file-disallowed-metadata" | "formdata-no-part-name" | "http-file-structured" | "http-file-content-type-not-string" | "http-file-contents-not-scalar", M extends keyof {
|
|
85
98
|
"http-verb-duplicate": {
|
|
86
99
|
readonly default: import("@typespec/compiler").CallableMessage<["entityName"]>;
|
|
87
100
|
};
|
|
@@ -94,8 +107,8 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missi
|
|
|
94
107
|
"use-uri-template": {
|
|
95
108
|
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
96
109
|
};
|
|
97
|
-
"optional-path-
|
|
98
|
-
readonly default: import("@typespec/compiler").CallableMessage<["paramName"]>;
|
|
110
|
+
"optional-needs-path-expansion": {
|
|
111
|
+
readonly default: import("@typespec/compiler").CallableMessage<["paramName", "paramName", "paramName"]>;
|
|
99
112
|
};
|
|
100
113
|
"missing-server-param": {
|
|
101
114
|
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
@@ -160,9 +173,22 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missi
|
|
|
160
173
|
"http-file-extra-property": {
|
|
161
174
|
readonly default: import("@typespec/compiler").CallableMessage<["propName"]>;
|
|
162
175
|
};
|
|
176
|
+
"http-file-disallowed-metadata": {
|
|
177
|
+
readonly default: import("@typespec/compiler").CallableMessage<["metadataType", "propName"]>;
|
|
178
|
+
};
|
|
163
179
|
"formdata-no-part-name": {
|
|
164
180
|
readonly default: "Part used in multipart/form-data must have a name.";
|
|
165
181
|
};
|
|
182
|
+
"http-file-structured": {
|
|
183
|
+
readonly default: import("@typespec/compiler").CallableMessage<["contentTypes"]>;
|
|
184
|
+
readonly union: "An HTTP File in a union is serialized as a structured model instead of being treated as the contents of a file. Declare a separate operation using `@sharedRoute` that has only the File model as the body type to treat it as a file, or suppress this warning if you intend to serialize the File as a model.";
|
|
185
|
+
};
|
|
186
|
+
"http-file-content-type-not-string": {
|
|
187
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
188
|
+
};
|
|
189
|
+
"http-file-contents-not-scalar": {
|
|
190
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
191
|
+
};
|
|
166
192
|
}[C]>(program: import("@typespec/compiler").Program, diag: import("@typespec/compiler").DiagnosticReport<{
|
|
167
193
|
"http-verb-duplicate": {
|
|
168
194
|
readonly default: import("@typespec/compiler").CallableMessage<["entityName"]>;
|
|
@@ -176,8 +202,8 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missi
|
|
|
176
202
|
"use-uri-template": {
|
|
177
203
|
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
178
204
|
};
|
|
179
|
-
"optional-path-
|
|
180
|
-
readonly default: import("@typespec/compiler").CallableMessage<["paramName"]>;
|
|
205
|
+
"optional-needs-path-expansion": {
|
|
206
|
+
readonly default: import("@typespec/compiler").CallableMessage<["paramName", "paramName", "paramName"]>;
|
|
181
207
|
};
|
|
182
208
|
"missing-server-param": {
|
|
183
209
|
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
@@ -242,10 +268,23 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missi
|
|
|
242
268
|
"http-file-extra-property": {
|
|
243
269
|
readonly default: import("@typespec/compiler").CallableMessage<["propName"]>;
|
|
244
270
|
};
|
|
271
|
+
"http-file-disallowed-metadata": {
|
|
272
|
+
readonly default: import("@typespec/compiler").CallableMessage<["metadataType", "propName"]>;
|
|
273
|
+
};
|
|
245
274
|
"formdata-no-part-name": {
|
|
246
275
|
readonly default: "Part used in multipart/form-data must have a name.";
|
|
247
276
|
};
|
|
248
|
-
|
|
277
|
+
"http-file-structured": {
|
|
278
|
+
readonly default: import("@typespec/compiler").CallableMessage<["contentTypes"]>;
|
|
279
|
+
readonly union: "An HTTP File in a union is serialized as a structured model instead of being treated as the contents of a file. Declare a separate operation using `@sharedRoute` that has only the File model as the body type to treat it as a file, or suppress this warning if you intend to serialize the File as a model.";
|
|
280
|
+
};
|
|
281
|
+
"http-file-content-type-not-string": {
|
|
282
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
283
|
+
};
|
|
284
|
+
"http-file-contents-not-scalar": {
|
|
285
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
286
|
+
};
|
|
287
|
+
}, C, M>) => void, createDiagnostic: <C extends "http-verb-duplicate" | "missing-uri-param" | "incompatible-uri-param" | "use-uri-template" | "optional-needs-path-expansion" | "missing-server-param" | "duplicate-body" | "duplicate-route-decorator" | "operation-param-duplicate-type" | "duplicate-operation" | "multiple-status-codes" | "status-code-invalid" | "content-type-string" | "content-type-ignored" | "metadata-ignored" | "response-cookie-not-supported" | "no-service-found" | "invalid-type-for-auth" | "shared-inconsistency" | "multipart-invalid-content-type" | "multipart-model" | "no-implicit-multipart" | "multipart-part" | "multipart-nested" | "http-file-extra-property" | "http-file-disallowed-metadata" | "formdata-no-part-name" | "http-file-structured" | "http-file-content-type-not-string" | "http-file-contents-not-scalar", M extends keyof {
|
|
249
288
|
"http-verb-duplicate": {
|
|
250
289
|
readonly default: import("@typespec/compiler").CallableMessage<["entityName"]>;
|
|
251
290
|
};
|
|
@@ -258,8 +297,8 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missi
|
|
|
258
297
|
"use-uri-template": {
|
|
259
298
|
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
260
299
|
};
|
|
261
|
-
"optional-path-
|
|
262
|
-
readonly default: import("@typespec/compiler").CallableMessage<["paramName"]>;
|
|
300
|
+
"optional-needs-path-expansion": {
|
|
301
|
+
readonly default: import("@typespec/compiler").CallableMessage<["paramName", "paramName", "paramName"]>;
|
|
263
302
|
};
|
|
264
303
|
"missing-server-param": {
|
|
265
304
|
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
@@ -324,9 +363,22 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missi
|
|
|
324
363
|
"http-file-extra-property": {
|
|
325
364
|
readonly default: import("@typespec/compiler").CallableMessage<["propName"]>;
|
|
326
365
|
};
|
|
366
|
+
"http-file-disallowed-metadata": {
|
|
367
|
+
readonly default: import("@typespec/compiler").CallableMessage<["metadataType", "propName"]>;
|
|
368
|
+
};
|
|
327
369
|
"formdata-no-part-name": {
|
|
328
370
|
readonly default: "Part used in multipart/form-data must have a name.";
|
|
329
371
|
};
|
|
372
|
+
"http-file-structured": {
|
|
373
|
+
readonly default: import("@typespec/compiler").CallableMessage<["contentTypes"]>;
|
|
374
|
+
readonly union: "An HTTP File in a union is serialized as a structured model instead of being treated as the contents of a file. Declare a separate operation using `@sharedRoute` that has only the File model as the body type to treat it as a file, or suppress this warning if you intend to serialize the File as a model.";
|
|
375
|
+
};
|
|
376
|
+
"http-file-content-type-not-string": {
|
|
377
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
378
|
+
};
|
|
379
|
+
"http-file-contents-not-scalar": {
|
|
380
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
381
|
+
};
|
|
330
382
|
}[C]>(diag: import("@typespec/compiler").DiagnosticReport<{
|
|
331
383
|
"http-verb-duplicate": {
|
|
332
384
|
readonly default: import("@typespec/compiler").CallableMessage<["entityName"]>;
|
|
@@ -340,8 +392,8 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missi
|
|
|
340
392
|
"use-uri-template": {
|
|
341
393
|
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
342
394
|
};
|
|
343
|
-
"optional-path-
|
|
344
|
-
readonly default: import("@typespec/compiler").CallableMessage<["paramName"]>;
|
|
395
|
+
"optional-needs-path-expansion": {
|
|
396
|
+
readonly default: import("@typespec/compiler").CallableMessage<["paramName", "paramName", "paramName"]>;
|
|
345
397
|
};
|
|
346
398
|
"missing-server-param": {
|
|
347
399
|
readonly default: import("@typespec/compiler").CallableMessage<["param"]>;
|
|
@@ -406,8 +458,21 @@ export declare const reportDiagnostic: <C extends "http-verb-duplicate" | "missi
|
|
|
406
458
|
"http-file-extra-property": {
|
|
407
459
|
readonly default: import("@typespec/compiler").CallableMessage<["propName"]>;
|
|
408
460
|
};
|
|
461
|
+
"http-file-disallowed-metadata": {
|
|
462
|
+
readonly default: import("@typespec/compiler").CallableMessage<["metadataType", "propName"]>;
|
|
463
|
+
};
|
|
409
464
|
"formdata-no-part-name": {
|
|
410
465
|
readonly default: "Part used in multipart/form-data must have a name.";
|
|
411
466
|
};
|
|
467
|
+
"http-file-structured": {
|
|
468
|
+
readonly default: import("@typespec/compiler").CallableMessage<["contentTypes"]>;
|
|
469
|
+
readonly union: "An HTTP File in a union is serialized as a structured model instead of being treated as the contents of a file. Declare a separate operation using `@sharedRoute` that has only the File model as the body type to treat it as a file, or suppress this warning if you intend to serialize the File as a model.";
|
|
470
|
+
};
|
|
471
|
+
"http-file-content-type-not-string": {
|
|
472
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
473
|
+
};
|
|
474
|
+
"http-file-contents-not-scalar": {
|
|
475
|
+
readonly default: import("@typespec/compiler").CallableMessage<["type"]>;
|
|
476
|
+
};
|
|
412
477
|
}, C, M>) => import("@typespec/compiler").Diagnostic, HttpStateKeys: Record<"file" | "path" | "query" | "authentication" | "header" | "cookie" | "body" | "bodyRoot" | "bodyIgnore" | "multipartBody" | "statusCode" | "verbs" | "patchOptions" | "servers" | "includeInapplicableMetadataInPayload" | "externalInterfaces" | "routeProducer" | "routes" | "sharedRoutes" | "routeOptions" | "httpPart", symbol>;
|
|
413
478
|
//# sourceMappingURL=lib.d.ts.map
|
package/dist/src/lib.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oVA+Nf,CAAC;AAEH,eAAO,MAAQ,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAE,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sDAAa,aAAa,6UAAS,CAAC"}
|
package/dist/src/lib.js
CHANGED
|
@@ -26,10 +26,10 @@ export const $lib = createTypeSpecLibrary({
|
|
|
26
26
|
default: paramMessage `Parameter '${"param"}' is already defined in the uri template. Explode, style and allowReserved property must be defined in the uri template as described by RFC 6570.`,
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
|
-
"optional-path-
|
|
29
|
+
"optional-needs-path-expansion": {
|
|
30
30
|
severity: "error",
|
|
31
31
|
messages: {
|
|
32
|
-
default: paramMessage `
|
|
32
|
+
default: paramMessage `Optional path parameter '${"paramName"}' must be declared with a leading '/' in the corresponding route path variable. For example, use '{/${"paramName"}}' instead of '{${"paramName"}}'.`,
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
"missing-server-param": {
|
|
@@ -155,12 +155,37 @@ export const $lib = createTypeSpecLibrary({
|
|
|
155
155
|
default: paramMessage `File model cannot define extra properties. Found '${"propName"}'.`,
|
|
156
156
|
},
|
|
157
157
|
},
|
|
158
|
+
"http-file-disallowed-metadata": {
|
|
159
|
+
severity: "error",
|
|
160
|
+
messages: {
|
|
161
|
+
default: paramMessage `File model cannot define HTTP metadata type '${"metadataType"}' on property '${"propName"}'.`,
|
|
162
|
+
},
|
|
163
|
+
},
|
|
158
164
|
"formdata-no-part-name": {
|
|
159
165
|
severity: "error",
|
|
160
166
|
messages: {
|
|
161
167
|
default: "Part used in multipart/form-data must have a name.",
|
|
162
168
|
},
|
|
163
169
|
},
|
|
170
|
+
"http-file-structured": {
|
|
171
|
+
severity: "warning",
|
|
172
|
+
messages: {
|
|
173
|
+
default: paramMessage `HTTP File body is serialized as a structured model in '${"contentTypes"}' instead of being treated as the contents of a file because an explicit Content-Type header is defined. Override the \`contentType\` property of the file model to declare the internal media type of the file's contents, or suppress this warning if you intend to serialize the File as a model.`,
|
|
174
|
+
union: "An HTTP File in a union is serialized as a structured model instead of being treated as the contents of a file. Declare a separate operation using `@sharedRoute` that has only the File model as the body type to treat it as a file, or suppress this warning if you intend to serialize the File as a model.",
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
"http-file-content-type-not-string": {
|
|
178
|
+
severity: "error",
|
|
179
|
+
messages: {
|
|
180
|
+
default: paramMessage `The 'contentType' property of the file model must be 'TypeSpec.string', a string literal, or a union of string literals. Found '${"type"}'.`,
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
"http-file-contents-not-scalar": {
|
|
184
|
+
severity: "error",
|
|
185
|
+
messages: {
|
|
186
|
+
default: paramMessage `The 'contents' property of the file model must be a scalar type that extends 'string' or 'bytes'. Found '${"type"}'.`,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
164
189
|
},
|
|
165
190
|
state: {
|
|
166
191
|
authentication: { description: "State for the @auth decorator" },
|
package/dist/src/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAC;IACxC,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE;QACX,qBAAqB,EAAE;YACrB,QAAQ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W,EAAE,qCAAqC,EAAE;QAClE,aAAa,EAAE,EAAE,WAAW,EAAE,qCAAqC,EAAE;QACrE,UAAU,EAAE,EAAE,WAAW,EAAE,qCAAqC,EAAE;QAClE,KAAK,EAAE,EAAE,WAAW,EAAE,yDAAyD,EAAE;QACjF,YAAY,EAAE,EAAE,WAAW,EAAE,+CAA+C,EAAE;QAC9E,OAAO,EAAE,EAAE,WAAW,EAAE,iCAAiC,EAAE;QAC3D,oCAAoC,EAAE;YACpC,WAAW,EAAE,+DAA+D;SAC7E;QAED,WAAW;QACX,kBAAkB,EAAE,EAAE;QACtB,aAAa,EAAE,EAAE;QACjB,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,EAAE,WAAW,EAAE,sCAAsC,EAAE;QACrE,YAAY,EAAE,EAAE;QAEhB,UAAU;QACV,IAAI,EAAE,EAAE,WAAW,EAAE,uCAAuC,EAAE;QAC9D,QAAQ,EAAE,EAAE,WAAW,EAAE,2CAA2C,EAAE;KACvE;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,SAAS,EACT,OAAO,EACR,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"parameters.d.ts","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,UAAU,EAEV,SAAS,EACT,OAAO,EACR,MAAM,oBAAoB,CAAC;AAI5B,OAAO,EACL,aAAa,EAEb,uBAAuB,EAEvB,yBAAyB,EAG1B,MAAM,YAAY,CAAC;AAGpB,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,MAAM,EAC1B,YAAY,CAAC,EAAE,aAAa,EAC5B,OAAO,GAAE,yBAA8B,GACtC,CAAC,uBAAuB,EAAE,SAAS,UAAU,EAAE,CAAC,CAkBlD"}
|
package/dist/src/parameters.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createDiagnosticCollector, } from "@typespec/compiler";
|
|
2
|
-
import { getOperationVerb } from "./decorators.js";
|
|
3
|
-
import { createDiagnostic } from "./lib.js";
|
|
2
|
+
import { getOperationVerb, getPathOptions } from "./decorators.js";
|
|
4
3
|
import { resolveRequestVisibility } from "./metadata.js";
|
|
5
4
|
import { HttpPayloadDisposition, resolveHttpPayload } from "./payload.js";
|
|
6
5
|
import { parseUriTemplate } from "./uri-template.js";
|
|
@@ -36,6 +35,16 @@ function getOperationParametersForVerb(program, operation, verb, partialUriTempl
|
|
|
36
35
|
const isTopLevel = param.model === operation.parameters;
|
|
37
36
|
const uriParam = isTopLevel && parsedUriTemplate.parameters.find((x) => x.name === param.name);
|
|
38
37
|
if (!uriParam) {
|
|
38
|
+
const pathOptions = getPathOptions(program, param);
|
|
39
|
+
if (pathOptions && param.optional) {
|
|
40
|
+
return {
|
|
41
|
+
type: "path",
|
|
42
|
+
name: pathOptions.name,
|
|
43
|
+
explode: false,
|
|
44
|
+
allowReserved: false,
|
|
45
|
+
style: operatorToStyle["/"],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
39
48
|
return undefined;
|
|
40
49
|
}
|
|
41
50
|
const explode = uriParam.modifier?.type === "explode";
|
|
@@ -76,14 +85,6 @@ function getOperationParametersForVerb(program, operation, verb, partialUriTempl
|
|
|
76
85
|
});
|
|
77
86
|
break;
|
|
78
87
|
case "path":
|
|
79
|
-
if (item.property.optional) {
|
|
80
|
-
diagnostics.add(createDiagnostic({
|
|
81
|
-
code: "optional-path-param",
|
|
82
|
-
format: { paramName: item.property.name },
|
|
83
|
-
target: item.property,
|
|
84
|
-
}));
|
|
85
|
-
}
|
|
86
|
-
// eslint-disable-next-line no-fallthrough
|
|
87
88
|
case "query":
|
|
88
89
|
case "cookie":
|
|
89
90
|
case "header":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAK1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,
|
|
1
|
+
{"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../src/parameters.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,GAK1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAU1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,UAAU,sBAAsB,CACpC,OAAgB,EAChB,SAAoB,EACpB,kBAA0B,EAC1B,YAA4B,EAC5B,UAAqC,EAAE;IAEvC,MAAM,IAAI,GACR,CAAC,OAAO,EAAE,YAAY,IAAI,OAAO,CAAC,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACnE,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC;QACpC,YAAY,EAAE,IAAI,CAAC;IAErB,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,6BAA6B,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,kBAAkB,CAAC,CAAC;IACrF,CAAC;IAED,wEAAwE;IACxE,kEAAkE;IAClE,0EAA0E;IAC1E,yEAAyE;IACzE,MAAM,IAAI,GAAG,6BAA6B,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC3F,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI;QACj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,MAAM,CAAC;YACZ,KAAK,OAAO,CAAC;YACb,KAAK,QAAQ,CAAC;YACd,KAAK,QAAQ;gBACX,UAAU,CAAC,IAAI,CAAC;oBACd,IAAI,EAAE,IAAI,CAAC,IAAW,EAAE,gCAAgC;oBACxD,GAAG,IAAI,CAAC,OAAO;oBACf,KAAK,EAAE,IAAI,CAAC,QAAQ;iBACrB,CAAC,CAAC;gBACH,MAAM;QACV,CAAC;IACH,CAAC;IAED,MAAM,IAAI,GAAG,YAAY,CAAC;IAE1B,OAAO,WAAW,CAAC,IAAI,CAAC;QACtB,UAAU,EAAE,QAAQ;QACpB,UAAU;QACV,IAAI;QACJ,IAAI;QACJ,IAAI,QAAQ;YACV,OAAO,IAAI,EAAE,IAAI,CAAC;QACpB,CAAC;QACD,IAAI,aAAa;YACf,OAAO,IAAI,EAAE,QAAQ,CAAC;QACxB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
package/dist/src/payload.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { DiagnosticResult, Program, Type } from "@typespec/compiler";
|
|
2
2
|
import { GetHttpPropertyOptions, HttpProperty } from "./http-property.js";
|
|
3
3
|
import { Visibility } from "./metadata.js";
|
|
4
|
-
import {
|
|
4
|
+
import { HttpPayloadBody } from "./types.js";
|
|
5
5
|
export interface HttpPayload {
|
|
6
|
-
readonly body?:
|
|
6
|
+
readonly body?: HttpPayloadBody;
|
|
7
7
|
readonly metadata: HttpProperty[];
|
|
8
8
|
}
|
|
9
9
|
export interface ExtractBodyAndMetadataOptions extends GetHttpPropertyOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/payload.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAIhB,OAAO,
|
|
1
|
+
{"version":3,"file":"payload.d.ts","sourceRoot":"","sources":["../../src/payload.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAIhB,OAAO,EAIP,IAAI,EASL,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EACL,sBAAsB,EAEtB,YAAY,EAEb,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAIL,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,YAAY,EAAE,CAAC;CACnC;AAED,MAAM,WAAW,6BAA8B,SAAQ,sBAAsB;CAAG;AAEhF;;GAEG;AACH,oBAAY,sBAAsB;IAChC;;OAEG;IACH,OAAO,IAAA;IACP;;OAEG;IACH,QAAQ,IAAA;IACR;;OAEG;IACH,SAAS,IAAA;CACV;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,UAAU,EAAE,UAAU,EACtB,WAAW,EAAE,sBAAsB,EACnC,OAAO,GAAE,6BAAkC,GAC1C,gBAAgB,CAAC,WAAW,CAAC,CAyB/B"}
|
package/dist/src/payload.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { createDiagnosticCollector, filterModelProperties, getDiscriminator, getEncode, getMediaTypeHint, isArrayModelType, navigateType, } from "@typespec/compiler";
|
|
2
|
+
import { SyntaxKind } from "@typespec/compiler/ast";
|
|
2
3
|
import { DuplicateTracker } from "@typespec/compiler/utils";
|
|
3
4
|
import { getContentTypes } from "./content-types.js";
|
|
4
5
|
import { isCookieParam, isHeader, isPathParam, isQueryParam, isStatusCode } from "./decorators.js";
|
|
5
6
|
import { resolvePayloadProperties, } from "./http-property.js";
|
|
6
|
-
import { createDiagnostic } from "./lib.js";
|
|
7
|
+
import { createDiagnostic, reportDiagnostic } from "./lib.js";
|
|
7
8
|
import { getHttpFileModel, getHttpPart } from "./private.decorators.js";
|
|
8
9
|
/**
|
|
9
10
|
* The disposition of a payload in an HTTP operation.
|
|
@@ -42,16 +43,22 @@ export function resolveHttpPayload(program, type, visibility, disposition, optio
|
|
|
42
43
|
function resolveBody(program, requestOrResponseType, metadata, visibility, disposition) {
|
|
43
44
|
const diagnostics = createDiagnosticCollector();
|
|
44
45
|
const contentTypeProperty = metadata.find((x) => x.kind === "contentType");
|
|
45
|
-
const file = getHttpFileModel(program, requestOrResponseType);
|
|
46
|
+
const file = getHttpFileModel(program, requestOrResponseType, createHttpFileModelFilter(metadata));
|
|
46
47
|
if (file !== undefined) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
48
|
+
if (!contentTypeProperty) {
|
|
49
|
+
// If no content-type property was specified, then this is a _literal_ file.
|
|
50
|
+
return diagnostics.join(getFileBody(file));
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
const contentTypes = contentTypeProperty && diagnostics.pipe(getContentTypes(contentTypeProperty.property));
|
|
54
|
+
reportDiagnostic(program, {
|
|
55
|
+
code: "http-file-structured",
|
|
56
|
+
format: {
|
|
57
|
+
contentTypes: contentTypes.join(", "),
|
|
58
|
+
},
|
|
59
|
+
target: contentTypeProperty.property,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
55
62
|
}
|
|
56
63
|
// non-model or intrinsic/array model -> response body is response type
|
|
57
64
|
if (requestOrResponseType.kind !== "Model" || isArrayModelType(program, requestOrResponseType)) {
|
|
@@ -133,8 +140,30 @@ function resolveExplicitBodyProperty(program, metadata, contentTypeProperty, vis
|
|
|
133
140
|
const valid = diagnostics.pipe(validateBodyProperty(program, item.property, disposition));
|
|
134
141
|
containsMetadataAnnotations = !valid;
|
|
135
142
|
}
|
|
136
|
-
|
|
137
|
-
|
|
143
|
+
const file = getHttpFileModel(program, item.property.type, createHttpFileModelFilter(metadata));
|
|
144
|
+
const isFile = file !== undefined && !contentTypeProperty;
|
|
145
|
+
if (file && contentTypeProperty) {
|
|
146
|
+
const contentTypes = diagnostics.pipe(getContentTypes(contentTypeProperty.property));
|
|
147
|
+
reportDiagnostic(program, {
|
|
148
|
+
code: "http-file-structured",
|
|
149
|
+
format: {
|
|
150
|
+
contentTypes: contentTypes.join(", "),
|
|
151
|
+
},
|
|
152
|
+
target: contentTypeProperty.property,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
if (item.property.type.kind === "Union" && unionContainsFile(program, item.property.type)) {
|
|
156
|
+
reportDiagnostic(program, {
|
|
157
|
+
code: "http-file-structured",
|
|
158
|
+
messageId: "union",
|
|
159
|
+
target: item.property.node.kind === SyntaxKind.ModelProperty
|
|
160
|
+
? item.property.node.value
|
|
161
|
+
: item.property.node,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
resolvedBody ??= isFile
|
|
165
|
+
? diagnostics.pipe(getFileBody(file, item.property))
|
|
166
|
+
: {
|
|
138
167
|
bodyKind: "single",
|
|
139
168
|
...diagnostics.pipe(resolveContentTypesForBody(program, contentTypeProperty, item.property.type)),
|
|
140
169
|
type: item.property.type,
|
|
@@ -142,7 +171,6 @@ function resolveExplicitBodyProperty(program, metadata, contentTypeProperty, vis
|
|
|
142
171
|
containsMetadataAnnotations,
|
|
143
172
|
property: item.property,
|
|
144
173
|
};
|
|
145
|
-
}
|
|
146
174
|
break;
|
|
147
175
|
case "multipartBody":
|
|
148
176
|
resolvedBody = diagnostics.pipe(resolveMultiPartBody(program, item.property, contentTypeProperty, visibility));
|
|
@@ -159,6 +187,21 @@ function resolveExplicitBodyProperty(program, metadata, contentTypeProperty, vis
|
|
|
159
187
|
}
|
|
160
188
|
return diagnostics.wrap(resolvedBody);
|
|
161
189
|
}
|
|
190
|
+
function unionContainsFile(program, u) {
|
|
191
|
+
return unionContainsFileWorker(u);
|
|
192
|
+
function unionContainsFileWorker(u, visited = new Set()) {
|
|
193
|
+
if (visited.has(u))
|
|
194
|
+
return false;
|
|
195
|
+
visited.add(u);
|
|
196
|
+
for (const { type } of u.variants.values()) {
|
|
197
|
+
if (!!getHttpFileModel(program, type) ||
|
|
198
|
+
(type.kind === "Union" && unionContainsFileWorker(type, visited))) {
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
162
205
|
/** Validate a property marked with `@body` */
|
|
163
206
|
function validateBodyProperty(program, property, disposition) {
|
|
164
207
|
const diagnostics = createDiagnosticCollector();
|
|
@@ -293,10 +336,6 @@ function resolvePart(program, type, visibility, property) {
|
|
|
293
336
|
const diagnostics = createDiagnosticCollector();
|
|
294
337
|
const part = getHttpPart(program, type);
|
|
295
338
|
if (part) {
|
|
296
|
-
const file = getHttpFileModel(program, part.type);
|
|
297
|
-
if (file !== undefined) {
|
|
298
|
-
return getFilePart(part.options.name, file);
|
|
299
|
-
}
|
|
300
339
|
let { body, metadata } = diagnostics.pipe(resolveHttpPayload(program, part.type, visibility, HttpPayloadDisposition.Multipart));
|
|
301
340
|
const contentTypeProperty = metadata.find((x) => x.kind === "contentType");
|
|
302
341
|
if (body === undefined) {
|
|
@@ -319,31 +358,62 @@ function resolvePart(program, type, visibility, property) {
|
|
|
319
358
|
body,
|
|
320
359
|
optional: false,
|
|
321
360
|
headers: metadata.filter((x) => x.kind === "header"),
|
|
361
|
+
filename: body.bodyKind === "file" ? body.filename : undefined,
|
|
322
362
|
});
|
|
323
363
|
}
|
|
324
364
|
diagnostics.add(createDiagnostic({ code: "multipart-part", target: type }));
|
|
325
365
|
return diagnostics.wrap(undefined);
|
|
326
366
|
}
|
|
327
|
-
|
|
367
|
+
/**
|
|
368
|
+
* Creates a filter function to determine if a property is applicable metadata for the purposes
|
|
369
|
+
* of effective File model calculation.
|
|
370
|
+
*/
|
|
371
|
+
function createHttpFileModelFilter(metadata) {
|
|
372
|
+
const metadataPropToMetadata = new Map(metadata.map((x) => [x.property, x]));
|
|
373
|
+
return function isApplicableMetadata(property) {
|
|
374
|
+
const httpProperty = metadataPropToMetadata.get(property);
|
|
375
|
+
if (["filename"].includes(property.name))
|
|
376
|
+
return true;
|
|
377
|
+
if (!httpProperty)
|
|
378
|
+
return true;
|
|
379
|
+
if (httpProperty.kind !== "bodyProperty")
|
|
380
|
+
return false;
|
|
381
|
+
return true;
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
/**
|
|
385
|
+
* Gets a file body from an HttpFileModel.
|
|
386
|
+
*
|
|
387
|
+
* @param file - the resolved file model
|
|
388
|
+
* @param property - the property that references the file model, if any
|
|
389
|
+
*/
|
|
390
|
+
function getFileBody(file, property) {
|
|
328
391
|
const [contentTypes, diagnostics] = getContentTypes(file.contentType);
|
|
392
|
+
const isText = isOrExtendsString(file.contents.type);
|
|
329
393
|
return [
|
|
330
394
|
{
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
bodyKind: "single",
|
|
335
|
-
contentTypeProperty: file.contentType,
|
|
336
|
-
contentTypes: contentTypes,
|
|
337
|
-
type: file.contents.type,
|
|
338
|
-
isExplicit: false,
|
|
339
|
-
containsMetadataAnnotations: false,
|
|
340
|
-
},
|
|
395
|
+
bodyKind: "file",
|
|
396
|
+
type: file.type,
|
|
397
|
+
contents: file.contents,
|
|
341
398
|
filename: file.filename,
|
|
342
|
-
|
|
343
|
-
|
|
399
|
+
isText,
|
|
400
|
+
contentTypeProperty: file.contentType,
|
|
401
|
+
contentTypes,
|
|
402
|
+
property,
|
|
344
403
|
},
|
|
345
404
|
diagnostics,
|
|
346
405
|
];
|
|
406
|
+
function isOrExtendsString(type) {
|
|
407
|
+
return isString(type) || (!!type.baseScalar && isOrExtendsString(type.baseScalar));
|
|
408
|
+
function isString(type) {
|
|
409
|
+
return (type.name === "string" &&
|
|
410
|
+
!!type.namespace &&
|
|
411
|
+
type.namespace.name === "TypeSpec" &&
|
|
412
|
+
!!type.namespace.namespace &&
|
|
413
|
+
type.namespace.namespace.name === "" &&
|
|
414
|
+
!type.namespace.namespace.namespace);
|
|
415
|
+
}
|
|
416
|
+
}
|
|
347
417
|
}
|
|
348
418
|
function getDefaultContentTypeForKind(type) {
|
|
349
419
|
return type.kind === "Scalar" ? "text/plain" : "application/json";
|