@typespec/http 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +106 -0
- package/dist/src/content-types.d.ts +15 -0
- package/dist/src/content-types.d.ts.map +1 -0
- package/dist/src/content-types.js +42 -0
- package/dist/src/content-types.js.map +1 -0
- package/dist/src/decorators.d.ts +82 -0
- package/dist/src/decorators.d.ts.map +1 -0
- package/dist/src/decorators.js +513 -0
- package/dist/src/decorators.js.map +1 -0
- package/dist/src/index.d.ts +11 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +11 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/lib.d.ts +294 -0
- package/dist/src/lib.d.ts.map +1 -0
- package/dist/src/lib.js +121 -0
- package/dist/src/lib.js.map +1 -0
- package/dist/src/metadata.d.ts +129 -0
- package/dist/src/metadata.d.ts.map +1 -0
- package/dist/src/metadata.js +323 -0
- package/dist/src/metadata.js.map +1 -0
- package/dist/src/operations.d.ts +31 -0
- package/dist/src/operations.d.ts.map +1 -0
- package/dist/src/operations.js +162 -0
- package/dist/src/operations.js.map +1 -0
- package/dist/src/parameters.d.ts +4 -0
- package/dist/src/parameters.d.ts.map +1 -0
- package/dist/src/parameters.js +142 -0
- package/dist/src/parameters.js.map +1 -0
- package/dist/src/responses.d.ts +7 -0
- package/dist/src/responses.d.ts.map +1 -0
- package/dist/src/responses.js +186 -0
- package/dist/src/responses.js.map +1 -0
- package/dist/src/route.d.ts +23 -0
- package/dist/src/route.d.ts.map +1 -0
- package/dist/src/route.js +149 -0
- package/dist/src/route.js.map +1 -0
- package/dist/src/testing/index.d.ts +3 -0
- package/dist/src/testing/index.d.ts.map +1 -0
- package/dist/src/testing/index.js +8 -0
- package/dist/src/testing/index.js.map +1 -0
- package/dist/src/types.d.ts +254 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils.d.ts +8 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +11 -0
- package/dist/src/utils.js.map +1 -0
- package/dist/src/validate.d.ts +3 -0
- package/dist/src/validate.d.ts.map +1 -0
- package/dist/src/validate.js +9 -0
- package/dist/src/validate.js.map +1 -0
- package/lib/auth.tsp +185 -0
- package/lib/http-decorators.tsp +206 -0
- package/lib/http.tsp +57 -0
- package/package.json +72 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE
|
package/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# TypeSpec HTTP Library
|
|
2
|
+
|
|
3
|
+
This package provides [TypeSpec](https://github.com/microsoft/TypeSpec) decorators, models, and interfaces to describe HTTP APIs. With fundamental models and decorators defined in TypeSpec.Http namespace, you will be able describe basic http level operations.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
In your typespec project root
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @typespec/http
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```TypeSpec
|
|
16
|
+
import "@typespec/http";
|
|
17
|
+
|
|
18
|
+
using TypeSpec.Http;
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For more information, consult the [HTTP and REST](https://microsoft.github.io/typespec/docs/standard-library/http/) section of the TypeSpec guide.
|
|
22
|
+
|
|
23
|
+
## Library Tour
|
|
24
|
+
|
|
25
|
+
`@typespec/http` library defines of the following artifacts:
|
|
26
|
+
|
|
27
|
+
- [TypeSpec HTTP Library](#typespec-http-library)
|
|
28
|
+
- [Install](#install)
|
|
29
|
+
- [Usage](#usage)
|
|
30
|
+
- [Library Tour](#library-tour)
|
|
31
|
+
- [Models](#models)
|
|
32
|
+
- [Decorators](#decorators)
|
|
33
|
+
- [See also](#see-also)
|
|
34
|
+
|
|
35
|
+
## Models
|
|
36
|
+
|
|
37
|
+
| Model | Notes |
|
|
38
|
+
| ---------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
+
| LocationHeader | Location header |
|
|
40
|
+
| Response<Status> | <Status> is numerical status code. |
|
|
41
|
+
| OkResponse<T> | Response<200> with T as the response body model type. |
|
|
42
|
+
| CreatedResponse | Response<201> |
|
|
43
|
+
| AcceptedResponse | Response<202> |
|
|
44
|
+
| NoContentResponse | Response<204> |
|
|
45
|
+
| MovedResponse | Response<301> with LocationHeader for redirected URL |
|
|
46
|
+
| NotModifiedResponse | Response<304> |
|
|
47
|
+
| UnauthorizedResponse | Response<401> |
|
|
48
|
+
| NotFoundResponse | Response<404> |
|
|
49
|
+
| ConflictResponse | Response<409> |
|
|
50
|
+
| PlainData<T> | Produces a new model with the same properties as T, but with @query, @header, @body, and @path decorators removed from all properties. |
|
|
51
|
+
| BasicAuth | Configure `basic` authentication with @useAuth |
|
|
52
|
+
| BearerAuth | Configure `bearer` authentication with @useAuth |
|
|
53
|
+
| ApiKeyAuth<TLocation, TName> | Configure `apiKey` authentication with @useAuth |
|
|
54
|
+
| OAuth2Auth<TFlows> | Configure `oauth2` authentication with @useAuth |
|
|
55
|
+
|
|
56
|
+
## Decorators
|
|
57
|
+
|
|
58
|
+
The `@typespec/http` library defines the following decorators in `TypeSpec.Http` namespace:
|
|
59
|
+
|
|
60
|
+
| Declarator | Scope | Usage |
|
|
61
|
+
| ----------- | ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
62
|
+
| @get | operations | indicating operation uses HTTP `GET` verb. |
|
|
63
|
+
| @put | operations | indicating operation uses HTTP `PUT` verb. |
|
|
64
|
+
| @post | operations | indicating operation uses HTTP `POST` verb. |
|
|
65
|
+
| @patch | operations | indicating operation uses HTTP `PATCH` verb. |
|
|
66
|
+
| @delete | operations | indicating operation uses HTTP `DEL` verb. |
|
|
67
|
+
| @head | operations | indicating operation uses HTTP `HEAD` verb. |
|
|
68
|
+
| @header | model properties and operation parameters | indicating the properties are request or response headers. |
|
|
69
|
+
| @query | model properties and operation parameters | indicating the properties are in the request query string. |
|
|
70
|
+
| @body | model properties and operation parameters | indicating the property is in request or response body. Only one allowed per model and operation. |
|
|
71
|
+
| @path | model properties and operation parameters | indicating the properties are in request path. |
|
|
72
|
+
| @statusCode | model properties and operation parameters | indicating the property is the return status code. Only one allowed per model. |
|
|
73
|
+
| @server | namespace | Configure the server url for the service. |
|
|
74
|
+
| @route | operations, namespaces, interfaces | Syntax:<br> `@route(routeString)`<br><br>Note:<br>`@route` defines the relative route URI for the target operation. The `routeString` argument should be a URI fragment that may contain one or more path parameter fields. If the namespace or interface that contains the operation is also marked with a `@route` decorator, it will be used as a prefix to the route URI of the operation. |
|
|
75
|
+
| @useAuth | namespace | Configure the service authentication. |
|
|
76
|
+
|
|
77
|
+
## How to
|
|
78
|
+
|
|
79
|
+
### Specify content type
|
|
80
|
+
|
|
81
|
+
To specify the content type you can add a `@header contentType: <value>` in the operation parameter(For request content type) or return type(For response content type)
|
|
82
|
+
|
|
83
|
+
Example: return `application/png` byte body
|
|
84
|
+
|
|
85
|
+
```typespec
|
|
86
|
+
op getPng(): {
|
|
87
|
+
@header contentType: "application/png";
|
|
88
|
+
@body _: bytes;
|
|
89
|
+
};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Example: expect `application/png` byte body
|
|
93
|
+
|
|
94
|
+
```typespec
|
|
95
|
+
op getPng(@header contentType: "application/png", @body _: bytes): void;
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## See also
|
|
99
|
+
|
|
100
|
+
- [HTTP example](https://cadlplayground.z22.web.core.windows.net/?c=aW1wb3J0ICJAY2FkbC1sYW5nL3Jlc3QiOwoKQHNlcnZpY2VUaXRsZSgiV2lkZ2V0IFPGFSIpCm5hbWVzcGFjZSBEZW1vxxg7CnVzaW5nIENhZGwuSHR0cDsKCm1vZGVsIMdAewogIEBrZXkgaWQ6IHN0cmluZzsKICB3ZWlnaHQ6IGludDMyxBFjb2xvcjogInJlZCIgfCAiYmx1ZSI7Cn0KCkBlcnJvcsdWRcQMxVVjb2Rly0BtZXNzYWdlymR9CgppbnRlcmbkALLmAI3nALTFP0DkAJ1saXN0KCk6xx9bXSB8xmHEUUByb3V0ZSgid8Uccy97aWR9IinGOHJlYWQoQHBhdGjrANfJSM1GcG9zdCBjcmVhdGUoQGJvZHkgxAXIK9Y0x3pjdXN0b21HZXTId8kR6gC0yjh9Cg%3D%3D):
|
|
101
|
+
- [TypeSpec Getting Started](https://github.com/microsoft/typespec#getting-started)
|
|
102
|
+
- [TypeSpec Website](https://microsoft.github.io/typespec)
|
|
103
|
+
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Diagnostic, ModelProperty, Program } from "@typespec/compiler";
|
|
2
|
+
/**
|
|
3
|
+
* Check if the given model property is the content type header.
|
|
4
|
+
* @param program Program
|
|
5
|
+
* @param property Model property.
|
|
6
|
+
* @returns True if the model property is marked as a header and has the name `content-type`(case insensitive.)
|
|
7
|
+
*/
|
|
8
|
+
export declare function isContentTypeHeader(program: Program, property: ModelProperty): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Resolve the content types from a model property by looking at the value.
|
|
11
|
+
* @property property Model property
|
|
12
|
+
* @returns List of contnet types and any diagnostics if there was an issue.
|
|
13
|
+
*/
|
|
14
|
+
export declare function getContentTypes(property: ModelProperty): [string[], readonly Diagnostic[]];
|
|
15
|
+
//# sourceMappingURL=content-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-types.d.ts","sourceRoot":"","sources":["../../src/content-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAInG;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAGtF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,GAAG,CAAC,MAAM,EAAE,EAAE,SAAS,UAAU,EAAE,CAAC,CAwB1F"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { createDiagnosticCollector } from "@typespec/compiler";
|
|
2
|
+
import { getHeaderFieldName } from "./decorators.js";
|
|
3
|
+
import { createDiagnostic } from "./lib.js";
|
|
4
|
+
/**
|
|
5
|
+
* Check if the given model property is the content type header.
|
|
6
|
+
* @param program Program
|
|
7
|
+
* @param property Model property.
|
|
8
|
+
* @returns True if the model property is marked as a header and has the name `content-type`(case insensitive.)
|
|
9
|
+
*/
|
|
10
|
+
export function isContentTypeHeader(program, property) {
|
|
11
|
+
const headerName = getHeaderFieldName(program, property);
|
|
12
|
+
return Boolean(headerName && headerName.toLowerCase() === "content-type");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the content types from a model property by looking at the value.
|
|
16
|
+
* @property property Model property
|
|
17
|
+
* @returns List of contnet types and any diagnostics if there was an issue.
|
|
18
|
+
*/
|
|
19
|
+
export function getContentTypes(property) {
|
|
20
|
+
const diagnostics = createDiagnosticCollector();
|
|
21
|
+
if (property.type.kind === "String") {
|
|
22
|
+
return [[property.type.value], []];
|
|
23
|
+
}
|
|
24
|
+
else if (property.type.kind === "Union") {
|
|
25
|
+
const contentTypes = [];
|
|
26
|
+
for (const option of property.type.variants.values()) {
|
|
27
|
+
if (option.type.kind === "String") {
|
|
28
|
+
contentTypes.push(option.type.value);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
diagnostics.add(createDiagnostic({
|
|
32
|
+
code: "content-type-string",
|
|
33
|
+
target: property,
|
|
34
|
+
}));
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return diagnostics.wrap(contentTypes);
|
|
39
|
+
}
|
|
40
|
+
return [[], [createDiagnostic({ code: "content-type-string", target: property })]];
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=content-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-types.js","sourceRoot":"","sources":["../../src/content-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAsC,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C;;;;;GAKG;AACH,M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} from "@typespec/compiler";
|
|
2
|
+
import { HeaderFieldOptions, HttpVerb, PathParameterOptions, QueryParameterOptions, ServiceAuthentication } from "./types.js";
|
|
3
|
+
export declare const namespace = "TypeSpec.Http";
|
|
4
|
+
export declare function $header(context: DecoratorContext, entity: ModelProperty, headerNameOrOptions?: string | Model): void;
|
|
5
|
+
export declare function getHeaderFieldOptions(program: Program, entity: Type): HeaderFieldOptions;
|
|
6
|
+
export declare function getHeaderFieldName(program: Program, entity: Type): string;
|
|
7
|
+
export declare function isHeader(program: Program, entity: Type): boolean;
|
|
8
|
+
export declare function $query(context: DecoratorContext, entity: ModelProperty, queryNameOrOptions?: string | Model): void;
|
|
9
|
+
export declare function getQueryParamOptions(program: Program, entity: Type): QueryParameterOptions;
|
|
10
|
+
export declare function getQueryParamName(program: Program, entity: Type): string;
|
|
11
|
+
export declare function isQueryParam(program: Program, entity: Type): boolean;
|
|
12
|
+
export declare function $path(context: DecoratorContext, entity: ModelProperty, paramName?: string): void;
|
|
13
|
+
export declare function getPathParamOptions(program: Program, entity: Type): PathParameterOptions;
|
|
14
|
+
export declare function getPathParamName(program: Program, entity: Type): string;
|
|
15
|
+
export declare function isPathParam(program: Program, entity: Type): boolean;
|
|
16
|
+
export declare function $body(context: DecoratorContext, entity: ModelProperty): void;
|
|
17
|
+
export declare function isBody(program: Program, entity: Type): boolean;
|
|
18
|
+
export declare function $statusCode(context: DecoratorContext, entity: ModelProperty): void;
|
|
19
|
+
export declare function setStatusCode(program: Program, entity: Model | ModelProperty, codes: string[]): void;
|
|
20
|
+
export declare function isStatusCode(program: Program, entity: Type): boolean;
|
|
21
|
+
export declare function getStatusCodes(program: Program, entity: Type): string[];
|
|
22
|
+
export declare function getStatusCodeDescription(statusCode: string): "The request has succeeded." | "The request has succeeded and a new resource has been created as a result." | "The request has been accepted for processing, but processing has not yet completed." | "There is no content to send for this request, but the headers may be useful. " | "The URL of the requested resource has been changed permanently. The new URL is given in the response." | "The client has made a conditional request and the resource has not been modified." | "The server could not understand the request due to invalid syntax." | "Access is unauthorized." | "Access is forbidden" | "The server cannot find the requested resource." | "The request conflicts with the current state of the server." | "Precondition failed." | "Service unavailable." | "Informational" | "Successful" | "Redirection" | "Client Error" | "Server Error" | undefined;
|
|
23
|
+
export declare function getOperationVerb(program: Program, entity: Type): HttpVerb | undefined;
|
|
24
|
+
export declare function $get(context: DecoratorContext, entity: Operation): void;
|
|
25
|
+
export declare function $put(context: DecoratorContext, entity: Operation): void;
|
|
26
|
+
export declare function $post(context: DecoratorContext, entity: Operation): void;
|
|
27
|
+
export declare function $patch(context: DecoratorContext, entity: Operation): void;
|
|
28
|
+
export declare function $delete(context: DecoratorContext, entity: Operation): void;
|
|
29
|
+
export declare function $head(context: DecoratorContext, entity: Operation): void;
|
|
30
|
+
export interface HttpServer {
|
|
31
|
+
url: string;
|
|
32
|
+
description: string;
|
|
33
|
+
parameters: Map<string, ModelProperty>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Configure the server url for the service.
|
|
37
|
+
* @param context Decorator context
|
|
38
|
+
* @param target Decorator target(Must be a namespace)
|
|
39
|
+
* @param description Description for this server.
|
|
40
|
+
* @param parameters @optional Parameters to interpolate in the server url.
|
|
41
|
+
*/
|
|
42
|
+
export declare function $server(context: DecoratorContext, target: Namespace, url: string, description: string, parameters?: Model): void;
|
|
43
|
+
export declare function getServers(program: Program, type: Namespace): HttpServer[] | undefined;
|
|
44
|
+
export declare function $plainData(context: DecoratorContext, entity: Type): void;
|
|
45
|
+
export declare function $useAuth(context: DecoratorContext, serviceNamespace: Namespace, authConfig: Model | Union | Tuple): void;
|
|
46
|
+
export declare function setAuthentication(program: Program, serviceNamespace: Namespace, auth: ServiceAuthentication): void;
|
|
47
|
+
export declare function getAuthentication(program: Program, namespace: Namespace): ServiceAuthentication | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* `@route` defines the relative route URI for the target operation
|
|
50
|
+
*
|
|
51
|
+
* The first argument should be a URI fragment that may contain one or more path parameter fields.
|
|
52
|
+
* If the namespace or interface that contains the operation is also marked with a `@route` decorator,
|
|
53
|
+
* it will be used as a prefix to the route URI of the operation.
|
|
54
|
+
*
|
|
55
|
+
* `@route` can only be applied to operations, namespaces, and interfaces.
|
|
56
|
+
*/
|
|
57
|
+
export declare function $route(context: DecoratorContext, entity: Type, path: string, parameters?: Model): void;
|
|
58
|
+
/**
|
|
59
|
+
* Specifies if inapplicable metadata should be included in the payload for
|
|
60
|
+
* the given entity. This is true by default unless changed by this
|
|
61
|
+
* decorator.
|
|
62
|
+
*
|
|
63
|
+
* @param entity Target model, namespace, or model property. If applied to a
|
|
64
|
+
* model or namespace, applies recursively to child models,
|
|
65
|
+
* namespaces, and model properties unless overridden by
|
|
66
|
+
* applying this decorator to a child.
|
|
67
|
+
*
|
|
68
|
+
* @param value `true` to include inapplicable metadata in payload, false to
|
|
69
|
+
* exclude it.
|
|
70
|
+
*
|
|
71
|
+
* @see isApplicableMetadata
|
|
72
|
+
*/
|
|
73
|
+
export declare function $includeInapplicableMetadataInPayload(context: DecoratorContext, entity: Type, value: boolean): void;
|
|
74
|
+
/**
|
|
75
|
+
* Determines if the given model property should be included in the payload if it is
|
|
76
|
+
* inapplicable metadata.
|
|
77
|
+
*
|
|
78
|
+
* @see isApplicableMetadata
|
|
79
|
+
* @see $includeInapplicableMetadataInPayload
|
|
80
|
+
*/
|
|
81
|
+
export declare function includeInapplicableMetadataInPayload(program: Program, property: ModelProperty): boolean;
|
|
82
|
+
//# sourceMappingURL=decorators.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,gBAAgB,EAIhB,KAAK,EACL,aAAa,EACb,SAAS,EACT,SAAS,EACT,OAAO,EAEP,KAAK,EACL,IAAI,EAEJ,KAAK,EAGN,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAEL,kBAAkB,EAElB,QAAQ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