@typespec/ts-http-runtime 1.0.0-alpha.20240924.1 → 1.0.0-alpha.20240926.5
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/README.md +16 -8
- package/dist/browser/abort-controller/AbortError.d.ts +11 -3
- package/dist/browser/abort-controller/AbortError.d.ts.map +1 -1
- package/dist/browser/abort-controller/AbortError.js +11 -3
- package/dist/browser/abort-controller/AbortError.js.map +1 -1
- package/dist/browser/client/common.d.ts +5 -3
- package/dist/browser/client/common.d.ts.map +1 -1
- package/dist/browser/client/common.js.map +1 -1
- package/dist/browser/tracing/instrumenter.d.ts +1 -1
- package/dist/browser/tracing/instrumenter.d.ts.map +1 -1
- package/dist/browser/tracing/instrumenter.js +6 -7
- package/dist/browser/tracing/instrumenter.js.map +1 -1
- package/dist/browser/tracing/interfaces.d.ts +17 -2
- package/dist/browser/tracing/interfaces.d.ts.map +1 -1
- package/dist/browser/tracing/interfaces.js.map +1 -1
- package/dist/browser/tracing/state-browser.d.mts.map +1 -0
- package/dist/browser/tracing/state-browser.mjs.map +1 -0
- package/dist/browser/tracing/state.d.ts +8 -0
- package/dist/browser/tracing/state.js +9 -0
- package/dist/commonjs/abort-controller/AbortError.d.ts +11 -3
- package/dist/commonjs/abort-controller/AbortError.d.ts.map +1 -1
- package/dist/commonjs/abort-controller/AbortError.js +11 -3
- package/dist/commonjs/abort-controller/AbortError.js.map +1 -1
- package/dist/commonjs/client/common.d.ts +5 -3
- package/dist/commonjs/client/common.d.ts.map +1 -1
- package/dist/commonjs/client/common.js.map +1 -1
- package/dist/commonjs/tracing/instrumenter.d.ts +1 -1
- package/dist/commonjs/tracing/instrumenter.d.ts.map +1 -1
- package/dist/commonjs/tracing/instrumenter.js +6 -7
- package/dist/commonjs/tracing/instrumenter.js.map +1 -1
- package/dist/commonjs/tracing/interfaces.d.ts +17 -2
- package/dist/commonjs/tracing/interfaces.d.ts.map +1 -1
- package/dist/commonjs/tracing/interfaces.js.map +1 -1
- package/dist/commonjs/tracing/state-cjs.cjs.map +1 -0
- package/dist/commonjs/tracing/state-cjs.d.cts.map +1 -0
- package/dist/commonjs/tracing/state.d.ts +9 -0
- package/dist/commonjs/tracing/state.js +14 -0
- package/dist/esm/abort-controller/AbortError.d.ts +11 -3
- package/dist/esm/abort-controller/AbortError.d.ts.map +1 -1
- package/dist/esm/abort-controller/AbortError.js +11 -3
- package/dist/esm/abort-controller/AbortError.js.map +1 -1
- package/dist/esm/client/common.d.ts +5 -3
- package/dist/esm/client/common.d.ts.map +1 -1
- package/dist/esm/client/common.js.map +1 -1
- package/dist/esm/tracing/instrumenter.d.ts +1 -1
- package/dist/esm/tracing/instrumenter.d.ts.map +1 -1
- package/dist/esm/tracing/instrumenter.js +6 -7
- package/dist/esm/tracing/instrumenter.js.map +1 -1
- package/dist/esm/tracing/interfaces.d.ts +17 -2
- package/dist/esm/tracing/interfaces.d.ts.map +1 -1
- package/dist/esm/tracing/interfaces.js.map +1 -1
- package/dist/esm/tracing/state.d.ts +8 -0
- package/dist/esm/tracing/state.d.ts.map +1 -0
- package/dist/esm/tracing/state.js +10 -0
- package/dist/esm/tracing/state.js.map +1 -0
- package/dist/react-native/abort-controller/AbortError.d.ts +11 -3
- package/dist/react-native/abort-controller/AbortError.d.ts.map +1 -1
- package/dist/react-native/abort-controller/AbortError.js +11 -3
- package/dist/react-native/abort-controller/AbortError.js.map +1 -1
- package/dist/react-native/client/common.d.ts +5 -3
- package/dist/react-native/client/common.d.ts.map +1 -1
- package/dist/react-native/client/common.js.map +1 -1
- package/dist/react-native/tracing/instrumenter.d.ts +1 -1
- package/dist/react-native/tracing/instrumenter.d.ts.map +1 -1
- package/dist/react-native/tracing/instrumenter.js +6 -7
- package/dist/react-native/tracing/instrumenter.js.map +1 -1
- package/dist/react-native/tracing/interfaces.d.ts +17 -2
- package/dist/react-native/tracing/interfaces.d.ts.map +1 -1
- package/dist/react-native/tracing/interfaces.js.map +1 -1
- package/dist/react-native/tracing/state.d.ts +8 -0
- package/dist/react-native/tracing/state.d.ts.map +1 -0
- package/dist/react-native/tracing/state.js +10 -0
- package/dist/react-native/tracing/state.js.map +1 -0
- package/dist/ts-http-runtime.d.ts +34 -9
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -31,7 +31,9 @@ A `PipelineResponse` describes the HTTP response (body, headers, and status code
|
|
|
31
31
|
|
|
32
32
|
A `SendRequest` method is a method that given a `PipelineRequest` can asynchronously return a `PipelineResponse`.
|
|
33
33
|
|
|
34
|
-
```ts
|
|
34
|
+
```ts snippet:send_request
|
|
35
|
+
import { PipelineResponse } from "@typespec/ts-http-runtime";
|
|
36
|
+
|
|
35
37
|
export type SendRequest = (request: PipelineRequest) => Promise<PipelineResponse>;
|
|
36
38
|
```
|
|
37
39
|
|
|
@@ -39,7 +41,7 @@ export type SendRequest = (request: PipelineRequest) => Promise<PipelineResponse
|
|
|
39
41
|
|
|
40
42
|
An `HttpClient` is any object that satisfies the following interface to implement a `SendRequest` method:
|
|
41
43
|
|
|
42
|
-
```ts
|
|
44
|
+
```ts snippet:http_request
|
|
43
45
|
export interface HttpClient {
|
|
44
46
|
/**
|
|
45
47
|
* The method that makes the request and returns a response.
|
|
@@ -54,7 +56,9 @@ export interface HttpClient {
|
|
|
54
56
|
|
|
55
57
|
A `PipelinePolicy` is a simple object that implements the following interface:
|
|
56
58
|
|
|
57
|
-
```ts
|
|
59
|
+
```ts snippet:pipeline_policy
|
|
60
|
+
import { PipelineResponse } from "@typespec/ts-http-runtime";
|
|
61
|
+
|
|
58
62
|
export interface PipelinePolicy {
|
|
59
63
|
/**
|
|
60
64
|
* The policy name. Must be a unique string in the pipeline.
|
|
@@ -62,8 +66,8 @@ export interface PipelinePolicy {
|
|
|
62
66
|
name: string;
|
|
63
67
|
/**
|
|
64
68
|
* The main method to implement that manipulates a request/response.
|
|
65
|
-
* @param request The request being performed.
|
|
66
|
-
* @param next The next policy in the pipeline. Must be called to continue the pipeline.
|
|
69
|
+
* @param request - The request being performed.
|
|
70
|
+
* @param next - The next policy in the pipeline. Must be called to continue the pipeline.
|
|
67
71
|
*/
|
|
68
72
|
sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse>;
|
|
69
73
|
}
|
|
@@ -75,7 +79,9 @@ One can view the role of policies as that of `middleware`, a concept that is fam
|
|
|
75
79
|
|
|
76
80
|
The `sendRequest` implementation can both transform the outgoing request as well as the incoming response:
|
|
77
81
|
|
|
78
|
-
```ts
|
|
82
|
+
```ts snippet:custom_policy
|
|
83
|
+
import { PipelineResponse } from "@typespec/ts-http-runtime";
|
|
84
|
+
|
|
79
85
|
const customPolicy = {
|
|
80
86
|
name: "My wonderful policy",
|
|
81
87
|
async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {
|
|
@@ -100,7 +106,9 @@ You can think of policies being applied like a stack (first-in/last-out.) The fi
|
|
|
100
106
|
|
|
101
107
|
A `Pipeline` satisfies the following interface:
|
|
102
108
|
|
|
103
|
-
```ts
|
|
109
|
+
```ts snippet:pipeline
|
|
110
|
+
import { PipelineResponse } from "@typespec/ts-http-runtime";
|
|
111
|
+
|
|
104
112
|
export interface Pipeline {
|
|
105
113
|
addPolicy(policy: PipelinePolicy, options?: AddPolicyOptions): void;
|
|
106
114
|
removePolicy(options: { name?: string; phase?: PipelinePhase }): PipelinePolicy[];
|
|
@@ -123,7 +131,7 @@ Phases occur in the above order, with serialization policies being applied first
|
|
|
123
131
|
|
|
124
132
|
When adding a policy to the pipeline you can specify not only what phase a policy is in, but also if it has any dependencies:
|
|
125
133
|
|
|
126
|
-
```ts
|
|
134
|
+
```ts snippet:add_policy_options
|
|
127
135
|
export interface AddPolicyOptions {
|
|
128
136
|
beforePolicies?: string[];
|
|
129
137
|
afterPolicies?: string[];
|
|
@@ -4,13 +4,21 @@
|
|
|
4
4
|
* error matches `"AbortError"`.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
|
-
* ```ts
|
|
7
|
+
* ```ts snippet:abort_error
|
|
8
|
+
* import { AbortError } from "@typespec/ts-http-runtime";
|
|
9
|
+
*
|
|
10
|
+
* async function doAsyncWork(options: { abortSignal: AbortSignal }): Promise<void> {
|
|
11
|
+
* if (options.abortSignal.aborted) {
|
|
12
|
+
* throw new AbortError();
|
|
13
|
+
* }
|
|
14
|
+
* // do async work
|
|
15
|
+
* }
|
|
8
16
|
* const controller = new AbortController();
|
|
9
17
|
* controller.abort();
|
|
10
18
|
* try {
|
|
11
|
-
* doAsyncWork(controller.signal)
|
|
19
|
+
* doAsyncWork({ abortSignal: controller.signal });
|
|
12
20
|
* } catch (e) {
|
|
13
|
-
* if (e.name ===
|
|
21
|
+
* if (e.name === "AbortError") {
|
|
14
22
|
* // handle abort error here.
|
|
15
23
|
* }
|
|
16
24
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbortError.d.ts","sourceRoot":"","sources":["../../../src/abort-controller/AbortError.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"AbortError.d.ts","sourceRoot":"","sources":["../../../src/abort-controller/AbortError.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,CAAC,EAAE,MAAM;CAI7B"}
|
|
@@ -6,13 +6,21 @@
|
|
|
6
6
|
* error matches `"AbortError"`.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
|
-
* ```ts
|
|
9
|
+
* ```ts snippet:abort_error
|
|
10
|
+
* import { AbortError } from "@typespec/ts-http-runtime";
|
|
11
|
+
*
|
|
12
|
+
* async function doAsyncWork(options: { abortSignal: AbortSignal }): Promise<void> {
|
|
13
|
+
* if (options.abortSignal.aborted) {
|
|
14
|
+
* throw new AbortError();
|
|
15
|
+
* }
|
|
16
|
+
* // do async work
|
|
17
|
+
* }
|
|
10
18
|
* const controller = new AbortController();
|
|
11
19
|
* controller.abort();
|
|
12
20
|
* try {
|
|
13
|
-
* doAsyncWork(controller.signal)
|
|
21
|
+
* doAsyncWork({ abortSignal: controller.signal });
|
|
14
22
|
* } catch (e) {
|
|
15
|
-
* if (e.name ===
|
|
23
|
+
* if (e.name === "AbortError") {
|
|
16
24
|
* // handle abort error here.
|
|
17
25
|
* }
|
|
18
26
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbortError.js","sourceRoot":"","sources":["../../../src/abort-controller/AbortError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC
|
|
1
|
+
{"version":3,"file":"AbortError.js","sourceRoot":"","sources":["../../../src/abort-controller/AbortError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * This error is thrown when an asynchronous operation has been aborted.\n * Check for this error by testing the `name` that the name property of the\n * error matches `\"AbortError\"`.\n *\n * @example\n * ```ts snippet:abort_error\n * import { AbortError } from \"@typespec/ts-http-runtime\";\n *\n * async function doAsyncWork(options: { abortSignal: AbortSignal }): Promise<void> {\n * if (options.abortSignal.aborted) {\n * throw new AbortError();\n * }\n * // do async work\n * }\n * const controller = new AbortController();\n * controller.abort();\n * try {\n * doAsyncWork({ abortSignal: controller.signal });\n * } catch (e) {\n * if (e.name === \"AbortError\") {\n * // handle abort error here.\n * }\n * }\n * ```\n */\nexport class AbortError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"AbortError\";\n }\n}\n"]}
|
|
@@ -162,10 +162,12 @@ export interface Client {
|
|
|
162
162
|
* This method will be used to send request that would check the path to provide
|
|
163
163
|
* strong types. When used by the codegen this type gets overriden wit the generated
|
|
164
164
|
* types. For example:
|
|
165
|
-
* ```typescript
|
|
165
|
+
* ```typescript snippet:path_example
|
|
166
|
+
* import { Client, Routes } from "@typespec/ts-http-runtime";
|
|
167
|
+
*
|
|
166
168
|
* export type MyClient = Client & {
|
|
167
|
-
*
|
|
168
|
-
* }
|
|
169
|
+
* path: Routes;
|
|
170
|
+
* };
|
|
169
171
|
* ```
|
|
170
172
|
*/
|
|
171
173
|
path: Function;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/client/common.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;OAEG;IACH,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC1C;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oEAAoE;IACpE,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,mEAAmE;IACnE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;OAEG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}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/client/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n HttpClient,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n TransferProgressEvent,\n RawHttpHeadersInput,\n} from \"../interfaces.js\";\nimport { Pipeline, PipelinePolicy } from \"../pipeline.js\";\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\nimport { OperationTracingOptions } from \"../tracing/interfaces.js\";\nimport { PipelineOptions } from \"../createPipelineFromOptions.js\";\nimport { LogPolicyOptions } from \"../policies/logPolicy.js\";\n\n/**\n * Shape of the default request parameters, this may be overriden by the specific\n * request types to provide strong types\n */\nexport type RequestParameters = {\n /**\n * Headers to send along with the request\n */\n headers?: RawHttpHeadersInput;\n /**\n * Sets the accept header to send to the service\n * defaults to 'application/json'. If also a header \"accept\" is set\n * this property will take precedence.\n */\n accept?: string;\n /**\n * Body to send with the request\n */\n body?: unknown;\n /**\n * Query parameters to send with the request\n */\n queryParameters?: Record<string, unknown>;\n /**\n * Set an explicit content-type to send with the request. If also a header \"content-type\" is set\n * this property will take precedence.\n */\n contentType?: string;\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n /** Set to true if you want to skip encoding the path parameters */\n skipUrlEncoding?: boolean;\n /**\n * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n};\n\n/**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\nexport type RawResponseCallback = (rawResponse: FullOperationResponse, error?: unknown) => void;\n\n/**\n * Wrapper object for http request and response. Deserialized object is stored in\n * the `parsedBody` property when the response body is received in JSON.\n */\nexport interface FullOperationResponse extends PipelineResponse {\n /**\n * The raw HTTP response headers.\n */\n rawHeaders?: RawHttpHeaders;\n\n /**\n * The response body as parsed JSON.\n */\n parsedBody?: RequestBodyType;\n\n /**\n * The request that generated the response.\n */\n request: PipelineRequest;\n}\n\n/**\n * The base options type for all operations.\n */\nexport interface OperationOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: OperationRequestOptions;\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n}\n\n/**\n * Options used when creating and sending HTTP requests for this operation.\n */\nexport interface OperationRequestOptions {\n /**\n * User defined custom request headers that\n * will be applied before the request is sent.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n allowInsecureConnection?: boolean;\n\n /**\n * Set to true if you want to skip encoding the path parameters\n */\n skipUrlEncoding?: boolean;\n}\n\n/**\n * Type to use with pathUnchecked, overrides the body type to any to allow flexibility\n */\nexport type PathUncheckedResponse = HttpResponse & { body: any };\n\n/**\n * Shape of a Rest Level Client\n */\nexport interface Client {\n /**\n * The pipeline used by this client to make requests\n */\n pipeline: Pipeline;\n /**\n * This method will be used to send request that would check the path to provide\n * strong types. When used by the codegen this type gets overriden wit the generated\n * types. For example:\n * ```typescript\n * export type MyClient = Client & {\n * path: Routes;\n * }\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpNodeStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: NodeJS.ReadableStream;\n};\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpBrowserStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: ReadableStream<Uint8Array>;\n};\n\n/**\n * Defines the type for a method that supports getting the response body as\n * a raw stream\n */\nexport type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {\n asNodeStream: () => Promise<HttpNodeStreamResponse>;\n asBrowserStream: () => Promise<HttpBrowserStreamResponse>;\n};\n\n/**\n * Defines the signature for pathUnchecked.\n */\nexport type PathUnchecked = <TPath extends string>(\n path: TPath,\n ...args: PathParameters<TPath>\n) => ResourceMethods<StreamableMethod>;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => TResponse;\n}\n\n/**\n * Used to configure additional policies added to the pipeline at construction.\n */\nexport interface AdditionalPolicyConfig {\n /**\n * A policy to be added.\n */\n policy: PipelinePolicy;\n /**\n * Determines if this policy be applied before or after retry logic.\n * Only use `perRetry` if you need to modify the request again\n * each time the operation is retried due to retryable service\n * issues.\n */\n position: \"perCall\" | \"perRetry\";\n}\n\n/**\n * General options that a Rest Level Client can take\n */\nexport type ClientOptions = PipelineOptions & {\n /**\n * Credentials information\n */\n credentials?: {\n /**\n * Authentication scopes for AAD\n */\n scopes?: string[];\n /**\n * Heder name for Client Secret authentication\n */\n apiKeyHeaderName?: string;\n };\n /**\n * Base url for the client\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUrl?: string;\n /**\n * Endpoint for the client\n */\n endpoint?: string;\n /**\n * Options for setting a custom apiVersion.\n */\n apiVersion?: string;\n /**\n * Option to allow calling http (insecure) endpoints\n */\n allowInsecureConnection?: boolean;\n /**\n * Additional policies to include in the HTTP pipeline.\n */\n additionalPolicies?: AdditionalPolicyConfig[];\n /**\n * Specify a custom HttpClient when making requests.\n */\n httpClient?: HttpClient;\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\n};\n\n/**\n * Represents the shape of an HttpResponse\n */\nexport type HttpResponse = {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP response headers.\n */\n headers: RawHttpHeaders;\n /**\n * Parsed body\n */\n body: unknown;\n /**\n * The HTTP status code of the response.\n */\n status: string;\n};\n\n/**\n * Helper type used to detect parameters in a path template\n * text surrounded by \\{\\} will be considered a path parameter\n */\nexport type PathParameters<\n TRoute extends string,\n // This is trying to match the string in TRoute with a template where HEAD/{PARAM}/TAIL\n // for example in the followint path: /foo/{fooId}/bar/{barId}/baz the template will infer\n // HEAD: /foo\n // Param: fooId\n // Tail: /bar/{barId}/baz\n // The above sample path would return [pathParam: string, pathParam: string]\n> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}`\n ? // In case we have a match for the template above we know for sure\n // that we have at least one pathParameter, that's why we set the first pathParam\n // in the tuple. At this point we have only matched up until param, if we want to identify\n // additional parameters we can call RouteParameters recursively on the Tail to match the remaining parts,\n // in case the Tail has more parameters, it will return a tuple with the parameters found in tail.\n // We spread the second path params to end up with a single dimension tuple at the end.\n [pathParameter: string, ...pathParameters: PathParameters<Tail>]\n : // When the path doesn't match the template, it means that we have no path parameters so we return\n // an empty tuple.\n [];\n\n/** A response containing error details. */\nexport interface ErrorResponse {\n /** The error object. */\n error: ErrorModel;\n}\n\n/** The error object. */\nexport interface ErrorModel {\n /** One of a server-defined set of error codes. */\n code: string;\n /** A human-readable representation of the error. */\n message: string;\n /** The target of the error. */\n target?: string;\n /** An array of details about specific errors that led to this reported error. */\n details: Array<ErrorModel>;\n /** An object containing more specific information than the current object about the error. */\n innererror?: InnerError;\n}\n\n/** An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. */\nexport interface InnerError {\n /** One of a server-defined set of error codes. */\n code: string;\n /** Inner error. */\n innererror?: InnerError;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/client/common.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n HttpClient,\n PipelineRequest,\n PipelineResponse,\n RawHttpHeaders,\n RequestBodyType,\n TransferProgressEvent,\n RawHttpHeadersInput,\n} from \"../interfaces.js\";\nimport { Pipeline, PipelinePolicy } from \"../pipeline.js\";\nimport { AbortSignalLike } from \"../abort-controller/AbortSignalLike.js\";\nimport { OperationTracingOptions } from \"../tracing/interfaces.js\";\nimport { PipelineOptions } from \"../createPipelineFromOptions.js\";\nimport { LogPolicyOptions } from \"../policies/logPolicy.js\";\n\n/**\n * Shape of the default request parameters, this may be overriden by the specific\n * request types to provide strong types\n */\nexport type RequestParameters = {\n /**\n * Headers to send along with the request\n */\n headers?: RawHttpHeadersInput;\n /**\n * Sets the accept header to send to the service\n * defaults to 'application/json'. If also a header \"accept\" is set\n * this property will take precedence.\n */\n accept?: string;\n /**\n * Body to send with the request\n */\n body?: unknown;\n /**\n * Query parameters to send with the request\n */\n queryParameters?: Record<string, unknown>;\n /**\n * Set an explicit content-type to send with the request. If also a header \"content-type\" is set\n * this property will take precedence.\n */\n contentType?: string;\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n /** Set to true if you want to skip encoding the path parameters */\n skipUrlEncoding?: boolean;\n /**\n * Path parameters for custom the base url\n */\n pathParameters?: Record<string, any>;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n};\n\n/**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\nexport type RawResponseCallback = (rawResponse: FullOperationResponse, error?: unknown) => void;\n\n/**\n * Wrapper object for http request and response. Deserialized object is stored in\n * the `parsedBody` property when the response body is received in JSON.\n */\nexport interface FullOperationResponse extends PipelineResponse {\n /**\n * The raw HTTP response headers.\n */\n rawHeaders?: RawHttpHeaders;\n\n /**\n * The response body as parsed JSON.\n */\n parsedBody?: RequestBodyType;\n\n /**\n * The request that generated the response.\n */\n request: PipelineRequest;\n}\n\n/**\n * The base options type for all operations.\n */\nexport interface OperationOptions {\n /**\n * The signal which can be used to abort requests.\n */\n abortSignal?: AbortSignalLike;\n /**\n * Options used when creating and sending HTTP requests for this operation.\n */\n requestOptions?: OperationRequestOptions;\n /**\n * Options used when tracing is enabled.\n */\n tracingOptions?: OperationTracingOptions;\n\n /**\n * A function to be called each time a response is received from the server\n * while performing the requested operation.\n * May be called multiple times.\n */\n onResponse?: RawResponseCallback;\n}\n\n/**\n * Options used when creating and sending HTTP requests for this operation.\n */\nexport interface OperationRequestOptions {\n /**\n * User defined custom request headers that\n * will be applied before the request is sent.\n */\n headers?: RawHttpHeadersInput;\n\n /**\n * The number of milliseconds a request can take before automatically being terminated.\n */\n timeout?: number;\n\n /**\n * Callback which fires upon upload progress.\n */\n onUploadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Callback which fires upon download progress.\n */\n onDownloadProgress?: (progress: TransferProgressEvent) => void;\n\n /**\n * Set to true if the request is sent over HTTP instead of HTTPS\n */\n allowInsecureConnection?: boolean;\n\n /**\n * Set to true if you want to skip encoding the path parameters\n */\n skipUrlEncoding?: boolean;\n}\n\n/**\n * Type to use with pathUnchecked, overrides the body type to any to allow flexibility\n */\nexport type PathUncheckedResponse = HttpResponse & { body: any };\n\n/**\n * Shape of a Rest Level Client\n */\nexport interface Client {\n /**\n * The pipeline used by this client to make requests\n */\n pipeline: Pipeline;\n /**\n * This method will be used to send request that would check the path to provide\n * strong types. When used by the codegen this type gets overriden wit the generated\n * types. For example:\n * ```typescript snippet:path_example\n * import { Client, Routes } from \"@typespec/ts-http-runtime\";\n *\n * export type MyClient = Client & {\n * path: Routes;\n * };\n * ```\n */\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n path: Function;\n /**\n * This method allows arbitrary paths and doesn't provide strong types\n */\n pathUnchecked: PathUnchecked;\n}\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpNodeStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: NodeJS.ReadableStream;\n};\n\n/**\n * Http Response which body is a NodeJS stream object\n */\nexport type HttpBrowserStreamResponse = HttpResponse & {\n /**\n * Streamable body\n */\n body?: ReadableStream<Uint8Array>;\n};\n\n/**\n * Defines the type for a method that supports getting the response body as\n * a raw stream\n */\nexport type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {\n asNodeStream: () => Promise<HttpNodeStreamResponse>;\n asBrowserStream: () => Promise<HttpBrowserStreamResponse>;\n};\n\n/**\n * Defines the signature for pathUnchecked.\n */\nexport type PathUnchecked = <TPath extends string>(\n path: TPath,\n ...args: PathParameters<TPath>\n) => ResourceMethods<StreamableMethod>;\n\n/**\n * Defines the methods that can be called on a resource\n */\nexport interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {\n /**\n * Definition of the GET HTTP method for a resource\n */\n get: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the POST HTTP method for a resource\n */\n post: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PUT HTTP method for a resource\n */\n put: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the PATCH HTTP method for a resource\n */\n patch: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the DELETE HTTP method for a resource\n */\n delete: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the HEAD HTTP method for a resource\n */\n head: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the OPTIONS HTTP method for a resource\n */\n options: (options?: RequestParameters) => TResponse;\n /**\n * Definition of the TRACE HTTP method for a resource\n */\n trace: (options?: RequestParameters) => TResponse;\n}\n\n/**\n * Used to configure additional policies added to the pipeline at construction.\n */\nexport interface AdditionalPolicyConfig {\n /**\n * A policy to be added.\n */\n policy: PipelinePolicy;\n /**\n * Determines if this policy be applied before or after retry logic.\n * Only use `perRetry` if you need to modify the request again\n * each time the operation is retried due to retryable service\n * issues.\n */\n position: \"perCall\" | \"perRetry\";\n}\n\n/**\n * General options that a Rest Level Client can take\n */\nexport type ClientOptions = PipelineOptions & {\n /**\n * Credentials information\n */\n credentials?: {\n /**\n * Authentication scopes for AAD\n */\n scopes?: string[];\n /**\n * Heder name for Client Secret authentication\n */\n apiKeyHeaderName?: string;\n };\n /**\n * Base url for the client\n * @deprecated This property is deprecated and will be removed soon, please use endpoint instead\n */\n baseUrl?: string;\n /**\n * Endpoint for the client\n */\n endpoint?: string;\n /**\n * Options for setting a custom apiVersion.\n */\n apiVersion?: string;\n /**\n * Option to allow calling http (insecure) endpoints\n */\n allowInsecureConnection?: boolean;\n /**\n * Additional policies to include in the HTTP pipeline.\n */\n additionalPolicies?: AdditionalPolicyConfig[];\n /**\n * Specify a custom HttpClient when making requests.\n */\n httpClient?: HttpClient;\n /**\n * Options to configure request/response logging.\n */\n loggingOptions?: LogPolicyOptions;\n};\n\n/**\n * Represents the shape of an HttpResponse\n */\nexport type HttpResponse = {\n /**\n * The request that generated this response.\n */\n request: PipelineRequest;\n /**\n * The HTTP response headers.\n */\n headers: RawHttpHeaders;\n /**\n * Parsed body\n */\n body: unknown;\n /**\n * The HTTP status code of the response.\n */\n status: string;\n};\n\n/**\n * Helper type used to detect parameters in a path template\n * text surrounded by \\{\\} will be considered a path parameter\n */\nexport type PathParameters<\n TRoute extends string,\n // This is trying to match the string in TRoute with a template where HEAD/{PARAM}/TAIL\n // for example in the followint path: /foo/{fooId}/bar/{barId}/baz the template will infer\n // HEAD: /foo\n // Param: fooId\n // Tail: /bar/{barId}/baz\n // The above sample path would return [pathParam: string, pathParam: string]\n> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}`\n ? // In case we have a match for the template above we know for sure\n // that we have at least one pathParameter, that's why we set the first pathParam\n // in the tuple. At this point we have only matched up until param, if we want to identify\n // additional parameters we can call RouteParameters recursively on the Tail to match the remaining parts,\n // in case the Tail has more parameters, it will return a tuple with the parameters found in tail.\n // We spread the second path params to end up with a single dimension tuple at the end.\n [pathParameter: string, ...pathParameters: PathParameters<Tail>]\n : // When the path doesn't match the template, it means that we have no path parameters so we return\n // an empty tuple.\n [];\n\n/** A response containing error details. */\nexport interface ErrorResponse {\n /** The error object. */\n error: ErrorModel;\n}\n\n/** The error object. */\nexport interface ErrorModel {\n /** One of a server-defined set of error codes. */\n code: string;\n /** A human-readable representation of the error. */\n message: string;\n /** The target of the error. */\n target?: string;\n /** An array of details about specific errors that led to this reported error. */\n details: Array<ErrorModel>;\n /** An object containing more specific information than the current object about the error. */\n innererror?: InnerError;\n}\n\n/** An object containing more specific information about the error. As per Microsoft One API guidelines - https://github.com/Microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses. */\nexport interface InnerError {\n /** One of a server-defined set of error codes. */\n code: string;\n /** Inner error. */\n innererror?: InnerError;\n}\n"]}
|
|
@@ -2,7 +2,7 @@ import { Instrumenter, TracingSpan } from "./interfaces.js";
|
|
|
2
2
|
export declare function createDefaultTracingSpan(): TracingSpan;
|
|
3
3
|
export declare function createDefaultInstrumenter(): Instrumenter;
|
|
4
4
|
/**
|
|
5
|
-
* Extends the SDK with support for a given instrumenter implementation.
|
|
5
|
+
* Extends the Azure SDK with support for a given instrumenter implementation.
|
|
6
6
|
*
|
|
7
7
|
* @param instrumenter - The instrumenter implementation to use.
|
|
8
8
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../../src/tracing/instrumenter.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EAGZ,WAAW,EACZ,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"instrumenter.d.ts","sourceRoot":"","sources":["../../../src/tracing/instrumenter.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EAGZ,WAAW,EACZ,MAAM,iBAAiB,CAAC;AAKzB,wBAAgB,wBAAwB,IAAI,WAAW,CAmBtD;AAED,wBAAgB,yBAAyB,IAAI,YAAY,CA4BxD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAK9C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
3
|
import { createTracingContext } from "./tracingContext.js";
|
|
4
|
+
import { state } from "./state.js";
|
|
4
5
|
export function createDefaultTracingSpan() {
|
|
5
6
|
return {
|
|
6
7
|
end: () => {
|
|
@@ -40,15 +41,13 @@ export function createDefaultInstrumenter() {
|
|
|
40
41
|
},
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
|
-
/** @internal */
|
|
44
|
-
let instrumenterImplementation;
|
|
45
44
|
/**
|
|
46
|
-
* Extends the SDK with support for a given instrumenter implementation.
|
|
45
|
+
* Extends the Azure SDK with support for a given instrumenter implementation.
|
|
47
46
|
*
|
|
48
47
|
* @param instrumenter - The instrumenter implementation to use.
|
|
49
48
|
*/
|
|
50
49
|
export function useInstrumenter(instrumenter) {
|
|
51
|
-
instrumenterImplementation = instrumenter;
|
|
50
|
+
state.instrumenterImplementation = instrumenter;
|
|
52
51
|
}
|
|
53
52
|
/**
|
|
54
53
|
* Gets the currently set instrumenter, a No-Op instrumenter by default.
|
|
@@ -56,9 +55,9 @@ export function useInstrumenter(instrumenter) {
|
|
|
56
55
|
* @returns The currently set instrumenter
|
|
57
56
|
*/
|
|
58
57
|
export function getInstrumenter() {
|
|
59
|
-
if (!instrumenterImplementation) {
|
|
60
|
-
instrumenterImplementation = createDefaultInstrumenter();
|
|
58
|
+
if (!state.instrumenterImplementation) {
|
|
59
|
+
state.instrumenterImplementation = createDefaultInstrumenter();
|
|
61
60
|
}
|
|
62
|
-
return instrumenterImplementation;
|
|
61
|
+
return state.instrumenterImplementation;
|
|
63
62
|
}
|
|
64
63
|
//# sourceMappingURL=instrumenter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"instrumenter.js","sourceRoot":"","sources":["../../../src/tracing/instrumenter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;
|
|
1
|
+
{"version":3,"file":"instrumenter.js","sourceRoot":"","sources":["../../../src/tracing/instrumenter.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AASlC,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,UAAU,wBAAwB;IACtC,OAAO;QACL,GAAG,EAAE,GAAG,EAAE;YACR,OAAO;QACT,CAAC;QACD,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;QACxB,eAAe,EAAE,GAAG,EAAE;YACpB,OAAO;QACT,CAAC;QACD,YAAY,EAAE,GAAG,EAAE;YACjB,OAAO;QACT,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACd,OAAO;QACT,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE;YACb,OAAO;QACT,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB;IACvC,OAAO;QACL,oBAAoB,EAAE,GAA2B,EAAE;YACjD,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,sBAAsB,EAAE,GAA+B,EAAE;YACvD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,SAAS,EAAE,CACT,KAAa,EACb,WAAoC,EACmB,EAAE;YACzD,OAAO;gBACL,IAAI,EAAE,wBAAwB,EAAE;gBAChC,cAAc,EAAE,oBAAoB,CAAC,EAAE,aAAa,EAAE,WAAW,CAAC,cAAc,EAAE,CAAC;aACpF,CAAC;QACJ,CAAC;QACD,WAAW,CAIT,QAAwB,EACxB,QAAkB,EAClB,GAAG,YAA0B;YAE7B,OAAO,QAAQ,CAAC,GAAG,YAAY,CAAC,CAAC;QACnC,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,YAA0B;IACxD,KAAK,CAAC,0BAA0B,GAAG,YAAY,CAAC;AAClD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe;IAC7B,IAAI,CAAC,KAAK,CAAC,0BAA0B,EAAE,CAAC;QACtC,KAAK,CAAC,0BAA0B,GAAG,yBAAyB,EAAE,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC,0BAA0B,CAAC;AAC1C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n Instrumenter,\n InstrumenterSpanOptions,\n TracingContext,\n TracingSpan,\n} from \"./interfaces.js\";\n\nimport { createTracingContext } from \"./tracingContext.js\";\nimport { state } from \"./state.js\";\n\nexport function createDefaultTracingSpan(): TracingSpan {\n return {\n end: () => {\n // noop\n },\n isRecording: () => false,\n recordException: () => {\n // noop\n },\n setAttribute: () => {\n // noop\n },\n setStatus: () => {\n // noop\n },\n addEvent: () => {\n // noop\n },\n };\n}\n\nexport function createDefaultInstrumenter(): Instrumenter {\n return {\n createRequestHeaders: (): Record<string, string> => {\n return {};\n },\n parseTraceparentHeader: (): TracingContext | undefined => {\n return undefined;\n },\n startSpan: (\n _name: string,\n spanOptions: InstrumenterSpanOptions,\n ): { span: TracingSpan; tracingContext: TracingContext } => {\n return {\n span: createDefaultTracingSpan(),\n tracingContext: createTracingContext({ parentContext: spanOptions.tracingContext }),\n };\n },\n withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n _context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback> {\n return callback(...callbackArgs);\n },\n };\n}\n\n/**\n * Extends the Azure SDK with support for a given instrumenter implementation.\n *\n * @param instrumenter - The instrumenter implementation to use.\n */\nexport function useInstrumenter(instrumenter: Instrumenter): void {\n state.instrumenterImplementation = instrumenter;\n}\n\n/**\n * Gets the currently set instrumenter, a No-Op instrumenter by default.\n *\n * @returns The currently set instrumenter\n */\nexport function getInstrumenter(): Instrumenter {\n if (!state.instrumenterImplementation) {\n state.instrumenterImplementation = createDefaultInstrumenter();\n }\n return state.instrumenterImplementation;\n}\n"]}
|
|
@@ -20,8 +20,23 @@ export interface TracingClient {
|
|
|
20
20
|
*
|
|
21
21
|
* Example:
|
|
22
22
|
*
|
|
23
|
-
* ```ts
|
|
24
|
-
*
|
|
23
|
+
* ```ts snippet:with_span_example
|
|
24
|
+
* import { createTracingClient } from "@typespec/ts-http-runtime";
|
|
25
|
+
*
|
|
26
|
+
* const tracingClient = createTracingClient({
|
|
27
|
+
* namespace: "test.namespace",
|
|
28
|
+
* packageName: "test-package",
|
|
29
|
+
* packageVersion: "1.0.0",
|
|
30
|
+
* });
|
|
31
|
+
* const options = {};
|
|
32
|
+
* const myOperationResult = await tracingClient.withSpan(
|
|
33
|
+
* "myClassName.myOperationName",
|
|
34
|
+
* options,
|
|
35
|
+
* (updatedOptions) => {
|
|
36
|
+
* // Do something with the updated options.
|
|
37
|
+
* return "myOperationResult";
|
|
38
|
+
* },
|
|
39
|
+
* );
|
|
25
40
|
* ```
|
|
26
41
|
* @param name - The name of the span. By convention this should be `${className}.${methodName}`.
|
|
27
42
|
* @param operationOptions - The original options passed to the method. The callback will receive these options with the newly created {@link TracingContext}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../src/tracing/interfaces.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS;IAAE,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,GAAG,GAAG,CAAA;CAAE,GACnE,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,GAC/B,QAAQ,CAAC,CAAC,CAAC,GACX,KAAK,GACP,CAAC,CAAC;AAEN;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B
|
|
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AAM,EAAE,UAAU,GAAG,IAAI,CAAC;IAEpC;;;;;OAKG;IACH,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAEjD;;OAEG;IACH,GAAG,IAAI,IAAI,CAAC;IAEZ;;;;;;;OAOG;IACH,eAAe,CAAC,SAAS,EAAE,KAAK,GAAG,MAAM,GAAG,IAAI,CAAC;IAEjD;;;;OAIG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;OAEG;IACH,QAAQ,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;CAC1D;AAED,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc,CAAC;IACtD;;;;;OAKG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAC/B;;;OAGG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,oDAAoD;IACpD,cAAc,CAAC,EAAE,cAAc,CAAC;CACjC;AAED;;;GAGG;AACH,MAAM,MAAM,yBAAyB,CACnC,OAAO,SAAS;IAAE,cAAc,CAAC,EAAE,uBAAuB,CAAA;CAAE,IAC1D,OAAO,GAAG;IACZ,cAAc,EAAE;QACd,cAAc,EAAE,cAAc,CAAC;KAChC,CAAC;CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/tracing/interfaces.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * A narrower version of TypeScript 4.5's Awaited type which Recursively\n * unwraps the \"awaited type\", emulating the behavior of `await`.\n */\nexport type Resolved<T> = T extends { then(onfulfilled: infer F): any } // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped\n ? F extends (value: infer V) => any // if the argument to `then` is callable, extracts the first argument\n ? Resolved<V> // recursively unwrap the value\n : never // the argument to `then` was not callable\n : T; // non-object or non-thenable\n\n/**\n * Represents a client that can integrate with the currently configured {@link Instrumenter}.\n *\n * Create an instance using {@link createTracingClient}.\n */\nexport interface TracingClient {\n /**\n * Wraps a callback in a tracing span, calls the callback, and closes the span.\n *\n * This is the primary interface for using Tracing and will handle error recording as well as setting the status on the span.\n *\n * Both synchronous and asynchronous functions will be awaited in order to reflect the result of the callback on the span.\n *\n * Example:\n *\n * ```ts\n * const myOperationResult = await tracingClient.withSpan(\"myClassName.myOperationName\", options, (updatedOptions) => myOperation(updatedOptions));\n * ```\n * @param name - The name of the span. By convention this should be `${className}.${methodName}`.\n * @param operationOptions - The original options passed to the method. The callback will receive these options with the newly created {@link TracingContext}.\n * @param callback - The callback to be invoked with the updated options and newly created {@link TracingSpan}.\n */\n withSpan<\n Options extends { tracingOptions?: OperationTracingOptions },\n Callback extends (\n updatedOptions: Options,\n span: Omit<TracingSpan, \"end\">,\n ) => ReturnType<Callback>,\n >(\n name: string,\n operationOptions: Options,\n callback: Callback,\n spanOptions?: TracingSpanOptions,\n ): Promise<Resolved<ReturnType<Callback>>>;\n /**\n * Starts a given span but does not set it as the active span.\n *\n * You must end the span using {@link TracingSpan.end}.\n *\n * Most of the time you will want to use {@link withSpan} instead.\n *\n * @param name - The name of the span. By convention this should be `${className}.${methodName}`.\n * @param operationOptions - The original operation options.\n * @param spanOptions - The options to use when creating the span.\n *\n * @returns A {@link TracingSpan} and the updated operation options.\n */\n startSpan<Options extends { tracingOptions?: OperationTracingOptions }>(\n name: string,\n operationOptions?: Options,\n spanOptions?: TracingSpanOptions,\n ): {\n span: TracingSpan;\n updatedOptions: OptionsWithTracingContext<Options>;\n };\n /**\n * Wraps a callback with an active context and calls the callback.\n * Depending on the implementation, this may set the globally available active context.\n *\n * Useful when you want to leave the boundaries of the SDK (make a request or callback to user code) and are unable to use the {@link withSpan} API.\n *\n * @param context - The {@link TracingContext} to use as the active context in the scope of the callback.\n * @param callback - The callback to be invoked with the given context set as the globally active context.\n * @param callbackArgs - The callback arguments.\n */\n withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback>;\n\n /**\n * Parses a traceparent header value into a {@link TracingSpanContext}.\n *\n * @param traceparentHeader - The traceparent header to parse.\n * @returns An implementation-specific identifier for the span.\n */\n parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;\n\n /**\n * Creates a set of request headers to propagate tracing information to a backend.\n *\n * @param tracingContext - The context containing the span to propagate.\n * @returns The set of headers to add to a request.\n */\n createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;\n}\n\n/**\n * Options that can be passed to {@link createTracingClient}\n */\nexport interface TracingClientOptions {\n /** The value of the az.namespace tracing attribute on newly created spans. */\n namespace: string;\n /** The name of the package invoking this trace. */\n packageName: string;\n /** An optional version of the package invoking this trace. */\n packageVersion?: string;\n}\n\n/** The kind of span. */\nexport type TracingSpanKind = \"client\" | \"server\" | \"producer\" | \"consumer\" | \"internal\";\n\n/** Options used to configure the newly created span. */\nexport interface TracingSpanOptions {\n /** The kind of span. Implementations should default this to \"client\". */\n spanKind?: TracingSpanKind;\n /** A collection of {@link TracingSpanLink} to link to this span. */\n spanLinks?: TracingSpanLink[];\n /** Initial set of attributes to set on a span. */\n spanAttributes?: { [key: string]: unknown };\n}\n\n/** A pointer from the current {@link TracingSpan} to another span in the same or a different trace. */\nexport interface TracingSpanLink {\n /** The {@link TracingContext} containing the span context to link to. */\n tracingContext: TracingContext;\n /** A set of attributes on the link. */\n attributes?: { [key: string]: unknown };\n}\n\n/**\n * Represents an implementation agnostic instrumenter.\n */\nexport interface Instrumenter {\n /**\n * Creates a new {@link TracingSpan} with the given name and options and sets it on a new context.\n * @param name - The name of the span. By convention this should be `${className}.${methodName}`.\n * @param spanOptions - The options to use when creating the span.\n *\n * @returns A {@link TracingSpan} that can be used to end the span, and the context this span has been set on.\n */\n startSpan(\n name: string,\n spanOptions: InstrumenterSpanOptions,\n ): { span: TracingSpan; tracingContext: TracingContext };\n /**\n * Wraps a callback with an active context and calls the callback.\n * Depending on the implementation, this may set the globally available active context.\n *\n * @param context - The {@link TracingContext} to use as the active context in the scope of the callback.\n * @param callback - The callback to be invoked with the given context set as the globally active context.\n * @param callbackArgs - The callback arguments.\n */\n withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback>;\n\n /**\n * Provides an implementation-specific method to parse a {@link https://www.w3.org/TR/trace-context/#traceparent-header}\n * into a {@link TracingSpanContext} which can be used to link non-parented spans together.\n */\n parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;\n /**\n * Provides an implementation-specific method to serialize a {@link TracingSpan} to a set of headers.\n * @param tracingContext - The context containing the span to serialize.\n */\n createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;\n}\n\n/**\n * Options passed to {@link Instrumenter.startSpan} as a superset of {@link TracingSpanOptions}.\n */\nexport interface InstrumenterSpanOptions extends TracingSpanOptions {\n /** The name of the package invoking this trace. */\n packageName: string;\n /** The version of the package invoking this trace. */\n packageVersion?: string;\n /** The current tracing context. Defaults to an implementation-specific \"active\" context. */\n tracingContext?: TracingContext;\n}\n\n/**\n * Status representing a successful operation that can be sent to {@link TracingSpan.setStatus}\n */\nexport type SpanStatusSuccess = { status: \"success\" };\n\n/**\n * Status representing an error that can be sent to {@link TracingSpan.setStatus}\n */\nexport type SpanStatusError = { status: \"error\"; error?: Error | string };\n\n/**\n * Represents the statuses that can be passed to {@link TracingSpan.setStatus}.\n *\n * By default, all spans will be created with status \"unset\".\n */\nexport type SpanStatus = SpanStatusSuccess | SpanStatusError;\n\n/**\n * Represents options you can pass to {@link TracingSpan.addEvent}.\n */\nexport interface AddEventOptions {\n /**\n * A set of attributes to attach to the event.\n */\n attributes?: Record<string, unknown>;\n /**\n * The start time of the event.\n */\n startTime?: Date;\n}\n\n/**\n * Represents an implementation agnostic tracing span.\n */\nexport interface TracingSpan {\n /**\n * Sets the status of the span. When an error is provided, it will be recorded on the span as well.\n *\n * @param status - The {@link SpanStatus} to set on the span.\n */\n setStatus(status: SpanStatus): void;\n\n /**\n * Sets a given attribute on a span.\n *\n * @param name - The attribute's name.\n * @param value - The attribute's value to set. May be any non-nullish value.\n */\n setAttribute(name: string, value: unknown): void;\n\n /**\n * Ends the span.\n */\n end(): void;\n\n /**\n * Records an exception on a {@link TracingSpan} without modifying its status.\n *\n * When recording an unhandled exception that should fail the span, please use {@link TracingSpan.setStatus} instead.\n *\n * @param exception - The exception to record on the span.\n *\n */\n recordException(exception: Error | string): void;\n\n /**\n * Returns true if this {@link TracingSpan} is recording information.\n *\n * Depending on the span implementation, this may return false if the span is not being sampled.\n */\n isRecording(): boolean;\n\n /**\n * Adds an event to the span.\n */\n addEvent?(name: string, options?: AddEventOptions): void;\n}\n\n/** An immutable context bag of tracing values for the current operation. */\nexport interface TracingContext {\n /**\n * Sets a given object on a context.\n * @param key - The key of the given context value.\n * @param value - The value to set on the context.\n *\n * @returns - A new context with the given value set.\n */\n setValue(key: symbol, value: unknown): TracingContext;\n /**\n * Gets an object from the context if it exists.\n * @param key - The key of the given context value.\n *\n * @returns - The value of the given context value if it exists, otherwise `undefined`.\n */\n getValue(key: symbol): unknown;\n /**\n * Deletes an object from the context if it exists.\n * @param key - The key of the given context value to delete.\n */\n deleteValue(key: symbol): TracingContext;\n}\n\n/**\n * Tracing options to set on an operation.\n */\nexport interface OperationTracingOptions {\n /** The context to use for created Tracing Spans. */\n tracingContext?: TracingContext;\n}\n\n/**\n * A utility type for when we know a TracingContext has been set\n * as part of an operation's options.\n */\nexport type OptionsWithTracingContext<\n Options extends { tracingOptions?: OperationTracingOptions },\n> = Options & {\n tracingOptions: {\n tracingContext: TracingContext;\n };\n};\n"]}
|
|
1
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../src/tracing/interfaces.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * A narrower version of TypeScript 4.5's Awaited type which Recursively\n * unwraps the \"awaited type\", emulating the behavior of `await`.\n */\nexport type Resolved<T> = T extends { then(onfulfilled: infer F): any } // `await` only unwraps object types with a callable `then`. Non-object types are not unwrapped\n ? F extends (value: infer V) => any // if the argument to `then` is callable, extracts the first argument\n ? Resolved<V> // recursively unwrap the value\n : never // the argument to `then` was not callable\n : T; // non-object or non-thenable\n\n/**\n * Represents a client that can integrate with the currently configured {@link Instrumenter}.\n *\n * Create an instance using {@link createTracingClient}.\n */\nexport interface TracingClient {\n /**\n * Wraps a callback in a tracing span, calls the callback, and closes the span.\n *\n * This is the primary interface for using Tracing and will handle error recording as well as setting the status on the span.\n *\n * Both synchronous and asynchronous functions will be awaited in order to reflect the result of the callback on the span.\n *\n * Example:\n *\n * ```ts snippet:with_span_example\n * import { createTracingClient } from \"@typespec/ts-http-runtime\";\n *\n * const tracingClient = createTracingClient({\n * namespace: \"test.namespace\",\n * packageName: \"test-package\",\n * packageVersion: \"1.0.0\",\n * });\n * const options = {};\n * const myOperationResult = await tracingClient.withSpan(\n * \"myClassName.myOperationName\",\n * options,\n * (updatedOptions) => {\n * // Do something with the updated options.\n * return \"myOperationResult\";\n * },\n * );\n * ```\n * @param name - The name of the span. By convention this should be `${className}.${methodName}`.\n * @param operationOptions - The original options passed to the method. The callback will receive these options with the newly created {@link TracingContext}.\n * @param callback - The callback to be invoked with the updated options and newly created {@link TracingSpan}.\n */\n withSpan<\n Options extends { tracingOptions?: OperationTracingOptions },\n Callback extends (\n updatedOptions: Options,\n span: Omit<TracingSpan, \"end\">,\n ) => ReturnType<Callback>,\n >(\n name: string,\n operationOptions: Options,\n callback: Callback,\n spanOptions?: TracingSpanOptions,\n ): Promise<Resolved<ReturnType<Callback>>>;\n /**\n * Starts a given span but does not set it as the active span.\n *\n * You must end the span using {@link TracingSpan.end}.\n *\n * Most of the time you will want to use {@link withSpan} instead.\n *\n * @param name - The name of the span. By convention this should be `${className}.${methodName}`.\n * @param operationOptions - The original operation options.\n * @param spanOptions - The options to use when creating the span.\n *\n * @returns A {@link TracingSpan} and the updated operation options.\n */\n startSpan<Options extends { tracingOptions?: OperationTracingOptions }>(\n name: string,\n operationOptions?: Options,\n spanOptions?: TracingSpanOptions,\n ): {\n span: TracingSpan;\n updatedOptions: OptionsWithTracingContext<Options>;\n };\n /**\n * Wraps a callback with an active context and calls the callback.\n * Depending on the implementation, this may set the globally available active context.\n *\n * Useful when you want to leave the boundaries of the SDK (make a request or callback to user code) and are unable to use the {@link withSpan} API.\n *\n * @param context - The {@link TracingContext} to use as the active context in the scope of the callback.\n * @param callback - The callback to be invoked with the given context set as the globally active context.\n * @param callbackArgs - The callback arguments.\n */\n withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback>;\n\n /**\n * Parses a traceparent header value into a {@link TracingSpanContext}.\n *\n * @param traceparentHeader - The traceparent header to parse.\n * @returns An implementation-specific identifier for the span.\n */\n parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;\n\n /**\n * Creates a set of request headers to propagate tracing information to a backend.\n *\n * @param tracingContext - The context containing the span to propagate.\n * @returns The set of headers to add to a request.\n */\n createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;\n}\n\n/**\n * Options that can be passed to {@link createTracingClient}\n */\nexport interface TracingClientOptions {\n /** The value of the az.namespace tracing attribute on newly created spans. */\n namespace: string;\n /** The name of the package invoking this trace. */\n packageName: string;\n /** An optional version of the package invoking this trace. */\n packageVersion?: string;\n}\n\n/** The kind of span. */\nexport type TracingSpanKind = \"client\" | \"server\" | \"producer\" | \"consumer\" | \"internal\";\n\n/** Options used to configure the newly created span. */\nexport interface TracingSpanOptions {\n /** The kind of span. Implementations should default this to \"client\". */\n spanKind?: TracingSpanKind;\n /** A collection of {@link TracingSpanLink} to link to this span. */\n spanLinks?: TracingSpanLink[];\n /** Initial set of attributes to set on a span. */\n spanAttributes?: { [key: string]: unknown };\n}\n\n/** A pointer from the current {@link TracingSpan} to another span in the same or a different trace. */\nexport interface TracingSpanLink {\n /** The {@link TracingContext} containing the span context to link to. */\n tracingContext: TracingContext;\n /** A set of attributes on the link. */\n attributes?: { [key: string]: unknown };\n}\n\n/**\n * Represents an implementation agnostic instrumenter.\n */\nexport interface Instrumenter {\n /**\n * Creates a new {@link TracingSpan} with the given name and options and sets it on a new context.\n * @param name - The name of the span. By convention this should be `${className}.${methodName}`.\n * @param spanOptions - The options to use when creating the span.\n *\n * @returns A {@link TracingSpan} that can be used to end the span, and the context this span has been set on.\n */\n startSpan(\n name: string,\n spanOptions: InstrumenterSpanOptions,\n ): { span: TracingSpan; tracingContext: TracingContext };\n /**\n * Wraps a callback with an active context and calls the callback.\n * Depending on the implementation, this may set the globally available active context.\n *\n * @param context - The {@link TracingContext} to use as the active context in the scope of the callback.\n * @param callback - The callback to be invoked with the given context set as the globally active context.\n * @param callbackArgs - The callback arguments.\n */\n withContext<\n CallbackArgs extends unknown[],\n Callback extends (...args: CallbackArgs) => ReturnType<Callback>,\n >(\n context: TracingContext,\n callback: Callback,\n ...callbackArgs: CallbackArgs\n ): ReturnType<Callback>;\n\n /**\n * Provides an implementation-specific method to parse a {@link https://www.w3.org/TR/trace-context/#traceparent-header}\n * into a {@link TracingSpanContext} which can be used to link non-parented spans together.\n */\n parseTraceparentHeader(traceparentHeader: string): TracingContext | undefined;\n /**\n * Provides an implementation-specific method to serialize a {@link TracingSpan} to a set of headers.\n * @param tracingContext - The context containing the span to serialize.\n */\n createRequestHeaders(tracingContext?: TracingContext): Record<string, string>;\n}\n\n/**\n * Options passed to {@link Instrumenter.startSpan} as a superset of {@link TracingSpanOptions}.\n */\nexport interface InstrumenterSpanOptions extends TracingSpanOptions {\n /** The name of the package invoking this trace. */\n packageName: string;\n /** The version of the package invoking this trace. */\n packageVersion?: string;\n /** The current tracing context. Defaults to an implementation-specific \"active\" context. */\n tracingContext?: TracingContext;\n}\n\n/**\n * Status representing a successful operation that can be sent to {@link TracingSpan.setStatus}\n */\nexport type SpanStatusSuccess = { status: \"success\" };\n\n/**\n * Status representing an error that can be sent to {@link TracingSpan.setStatus}\n */\nexport type SpanStatusError = { status: \"error\"; error?: Error | string };\n\n/**\n * Represents the statuses that can be passed to {@link TracingSpan.setStatus}.\n *\n * By default, all spans will be created with status \"unset\".\n */\nexport type SpanStatus = SpanStatusSuccess | SpanStatusError;\n\n/**\n * Represents options you can pass to {@link TracingSpan.addEvent}.\n */\nexport interface AddEventOptions {\n /**\n * A set of attributes to attach to the event.\n */\n attributes?: Record<string, unknown>;\n /**\n * The start time of the event.\n */\n startTime?: Date;\n}\n\n/**\n * Represents an implementation agnostic tracing span.\n */\nexport interface TracingSpan {\n /**\n * Sets the status of the span. When an error is provided, it will be recorded on the span as well.\n *\n * @param status - The {@link SpanStatus} to set on the span.\n */\n setStatus(status: SpanStatus): void;\n\n /**\n * Sets a given attribute on a span.\n *\n * @param name - The attribute's name.\n * @param value - The attribute's value to set. May be any non-nullish value.\n */\n setAttribute(name: string, value: unknown): void;\n\n /**\n * Ends the span.\n */\n end(): void;\n\n /**\n * Records an exception on a {@link TracingSpan} without modifying its status.\n *\n * When recording an unhandled exception that should fail the span, please use {@link TracingSpan.setStatus} instead.\n *\n * @param exception - The exception to record on the span.\n *\n */\n recordException(exception: Error | string): void;\n\n /**\n * Returns true if this {@link TracingSpan} is recording information.\n *\n * Depending on the span implementation, this may return false if the span is not being sampled.\n */\n isRecording(): boolean;\n\n /**\n * Adds an event to the span.\n */\n addEvent?(name: string, options?: AddEventOptions): void;\n}\n\n/** An immutable context bag of tracing values for the current operation. */\nexport interface TracingContext {\n /**\n * Sets a given object on a context.\n * @param key - The key of the given context value.\n * @param value - The value to set on the context.\n *\n * @returns - A new context with the given value set.\n */\n setValue(key: symbol, value: unknown): TracingContext;\n /**\n * Gets an object from the context if it exists.\n * @param key - The key of the given context value.\n *\n * @returns - The value of the given context value if it exists, otherwise `undefined`.\n */\n getValue(key: symbol): unknown;\n /**\n * Deletes an object from the context if it exists.\n * @param key - The key of the given context value to delete.\n */\n deleteValue(key: symbol): TracingContext;\n}\n\n/**\n * Tracing options to set on an operation.\n */\nexport interface OperationTracingOptions {\n /** The context to use for created Tracing Spans. */\n tracingContext?: TracingContext;\n}\n\n/**\n * A utility type for when we know a TracingContext has been set\n * as part of an operation's options.\n */\nexport type OptionsWithTracingContext<\n Options extends { tracingOptions?: OperationTracingOptions },\n> = Options & {\n tracingOptions: {\n tracingContext: TracingContext;\n };\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-browser.d.mts","sourceRoot":"","sources":["../../../src/tracing/state-browser.mts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C;;GAEG;AACH,eAAO,MAAM,KAAK;gCACyB,YAAY,GAAG,SAAS;CAClE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-browser.mjs","sourceRoot":"","sources":["../../../src/tracing/state-browser.mts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC;;GAEG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,0BAA0B,EAAE,SAAqC;CAClE,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { Instrumenter } from \"./interfaces.js\";\n\n/**\n * Browser-only implementation of the module's state. The browser esm variant will not load the commonjs state, so we do not need to share state between the two.\n */\nexport const state = {\n instrumenterImplementation: undefined as Instrumenter | undefined,\n};\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Instrumenter } from "./interfaces.js";
|
|
2
|
+
/**
|
|
3
|
+
* Browser-only implementation of the module's state. The browser esm variant will not load the commonjs state, so we do not need to share state between the two.
|
|
4
|
+
*/
|
|
5
|
+
export declare const state: {
|
|
6
|
+
instrumenterImplementation: Instrumenter | undefined;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=state-browser.d.mts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
/**
|
|
4
|
+
* Browser-only implementation of the module's state. The browser esm variant will not load the commonjs state, so we do not need to share state between the two.
|
|
5
|
+
*/
|
|
6
|
+
export const state = {
|
|
7
|
+
instrumenterImplementation: undefined,
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=state-browser.mjs.map
|
|
@@ -4,13 +4,21 @@
|
|
|
4
4
|
* error matches `"AbortError"`.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
|
-
* ```ts
|
|
7
|
+
* ```ts snippet:abort_error
|
|
8
|
+
* import { AbortError } from "@typespec/ts-http-runtime";
|
|
9
|
+
*
|
|
10
|
+
* async function doAsyncWork(options: { abortSignal: AbortSignal }): Promise<void> {
|
|
11
|
+
* if (options.abortSignal.aborted) {
|
|
12
|
+
* throw new AbortError();
|
|
13
|
+
* }
|
|
14
|
+
* // do async work
|
|
15
|
+
* }
|
|
8
16
|
* const controller = new AbortController();
|
|
9
17
|
* controller.abort();
|
|
10
18
|
* try {
|
|
11
|
-
* doAsyncWork(controller.signal)
|
|
19
|
+
* doAsyncWork({ abortSignal: controller.signal });
|
|
12
20
|
* } catch (e) {
|
|
13
|
-
* if (e.name ===
|
|
21
|
+
* if (e.name === "AbortError") {
|
|
14
22
|
* // handle abort error here.
|
|
15
23
|
* }
|
|
16
24
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbortError.d.ts","sourceRoot":"","sources":["../../../src/abort-controller/AbortError.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"AbortError.d.ts","sourceRoot":"","sources":["../../../src/abort-controller/AbortError.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,UAAW,SAAQ,KAAK;gBACvB,OAAO,CAAC,EAAE,MAAM;CAI7B"}
|
|
@@ -9,13 +9,21 @@ exports.AbortError = void 0;
|
|
|
9
9
|
* error matches `"AbortError"`.
|
|
10
10
|
*
|
|
11
11
|
* @example
|
|
12
|
-
* ```ts
|
|
12
|
+
* ```ts snippet:abort_error
|
|
13
|
+
* import { AbortError } from "@typespec/ts-http-runtime";
|
|
14
|
+
*
|
|
15
|
+
* async function doAsyncWork(options: { abortSignal: AbortSignal }): Promise<void> {
|
|
16
|
+
* if (options.abortSignal.aborted) {
|
|
17
|
+
* throw new AbortError();
|
|
18
|
+
* }
|
|
19
|
+
* // do async work
|
|
20
|
+
* }
|
|
13
21
|
* const controller = new AbortController();
|
|
14
22
|
* controller.abort();
|
|
15
23
|
* try {
|
|
16
|
-
* doAsyncWork(controller.signal)
|
|
24
|
+
* doAsyncWork({ abortSignal: controller.signal });
|
|
17
25
|
* } catch (e) {
|
|
18
|
-
* if (e.name ===
|
|
26
|
+
* if (e.name === "AbortError") {
|
|
19
27
|
* // handle abort error here.
|
|
20
28
|
* }
|
|
21
29
|
* }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbortError.js","sourceRoot":"","sources":["../../../src/abort-controller/AbortError.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC
|
|
1
|
+
{"version":3,"file":"AbortError.js","sourceRoot":"","sources":["../../../src/abort-controller/AbortError.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAa,UAAW,SAAQ,KAAK;IACnC,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;IAC3B,CAAC;CACF;AALD,gCAKC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * This error is thrown when an asynchronous operation has been aborted.\n * Check for this error by testing the `name` that the name property of the\n * error matches `\"AbortError\"`.\n *\n * @example\n * ```ts snippet:abort_error\n * import { AbortError } from \"@typespec/ts-http-runtime\";\n *\n * async function doAsyncWork(options: { abortSignal: AbortSignal }): Promise<void> {\n * if (options.abortSignal.aborted) {\n * throw new AbortError();\n * }\n * // do async work\n * }\n * const controller = new AbortController();\n * controller.abort();\n * try {\n * doAsyncWork({ abortSignal: controller.signal });\n * } catch (e) {\n * if (e.name === \"AbortError\") {\n * // handle abort error here.\n * }\n * }\n * ```\n */\nexport class AbortError extends Error {\n constructor(message?: string) {\n super(message);\n this.name = \"AbortError\";\n }\n}\n"]}
|
|
@@ -162,10 +162,12 @@ export interface Client {
|
|
|
162
162
|
* This method will be used to send request that would check the path to provide
|
|
163
163
|
* strong types. When used by the codegen this type gets overriden wit the generated
|
|
164
164
|
* types. For example:
|
|
165
|
-
* ```typescript
|
|
165
|
+
* ```typescript snippet:path_example
|
|
166
|
+
* import { Client, Routes } from "@typespec/ts-http-runtime";
|
|
167
|
+
*
|
|
166
168
|
* export type MyClient = Client & {
|
|
167
|
-
*
|
|
168
|
-
* }
|
|
169
|
+
* path: Routes;
|
|
170
|
+
* };
|
|
169
171
|
* ```
|
|
170
172
|
*/
|
|
171
173
|
path: Function;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/client/common.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,UAAU,EACV,eA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