feat(notes): scaffold web backend and mobile foundations

This commit is contained in:
saravanakumardb1 2026-03-10 08:53:25 -07:00
parent db7b9f8ff1
commit 771a7d34a6
12010 changed files with 0 additions and 1380066 deletions

1
backend/node_modules/.bin/esbuild generated vendored
View File

@ -1 +0,0 @@
../esbuild/bin/esbuild

1
backend/node_modules/.bin/nanoid generated vendored
View File

@ -1 +0,0 @@
../nanoid/bin/nanoid.cjs

1
backend/node_modules/.bin/pino generated vendored
View File

@ -1 +0,0 @@
../pino/bin.js

1
backend/node_modules/.bin/rollup generated vendored
View File

@ -1 +0,0 @@
../rollup/dist/bin/rollup

1
backend/node_modules/.bin/semver generated vendored
View File

@ -1 +0,0 @@
../semver/bin/semver.js

1
backend/node_modules/.bin/tsc generated vendored
View File

@ -1 +0,0 @@
../typescript/bin/tsc

1
backend/node_modules/.bin/tsserver generated vendored
View File

@ -1 +0,0 @@
../typescript/bin/tsserver

1
backend/node_modules/.bin/tsx generated vendored
View File

@ -1 +0,0 @@
../tsx/dist/cli.mjs

1
backend/node_modules/.bin/vite generated vendored
View File

@ -1 +0,0 @@
../vite/bin/vite.js

View File

@ -1 +0,0 @@
../vite-node/vite-node.mjs

1
backend/node_modules/.bin/vitest generated vendored
View File

@ -1 +0,0 @@
../vitest/vitest.mjs

View File

@ -1 +0,0 @@
../why-is-node-running/cli.js

1942
backend/node_modules/.package-lock.json generated vendored

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
{"version":"3.2.4","results":[[":src/server.test.ts",{"duration":20.562374999999918,"failed":false}],[":src/mcp/note-tool-contracts.test.ts",{"duration":1.9141250000000127,"failed":false}],[":src/modules/notes/routes.test.ts",{"duration":1.3198750000000246,"failed":false}],[":src/modules/note-agent-actions/routes.test.ts",{"duration":1.4805410000000165,"failed":false}],[":src/modules/note-artifacts/routes.test.ts",{"duration":1.3914579999999432,"failed":false}],[":src/modules/workspaces/routes.test.ts",{"duration":1.3432500000000118,"failed":false}],[":src/modules/note-tasks/routes.test.ts",{"duration":1.3227499999999281,"failed":false}],[":src/modules/note-relationships/routes.test.ts",{"duration":1.3448750000000018,"failed":false}]]}

View File

@ -1,21 +0,0 @@
Copyright (c) Microsoft Corporation.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1,38 +0,0 @@
# Azure Rest Core client library for JavaScript
This library is primarily intended to be used in code generated by [AutoRest](https://github.com/Azure/Autorest) and [`autorest.typescript`](https://github.com/Azure/autorest.typescript). Specifically for rest level clients
## Getting started
### Requirements
### Currently supported environments
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
- Latest versions of Safari, Chrome, Edge, and Firefox.
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
### Installation
This package is primarily used in generated code and not meant to be consumed directly by end users.
## Key concepts
## Examples
Examples can be found in the `samples` folder.
## Next steps
You can build and run the tests locally by executing `npm run test`. Explore the `test` folder to see advanced usage and behavior of the public classes.
Learn more about [AutoRest](https://github.com/Azure/autorest) and the [autorest.typescript extension](https://github.com/Azure/autorest.typescript) for generating a compatible client on top of this package.
## Troubleshooting
If you run into issues while using this library, please feel free to [file an issue](https://github.com/Azure/azure-sdk-for-js/issues/new).
## Contributing
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.

View File

@ -1,10 +0,0 @@
import type { PipelinePolicy } from "@azure/core-rest-pipeline";
import type { ClientOptions } from "./common.js";
export declare const apiVersionPolicyName = "ApiVersionPolicy";
/**
* Creates a policy that sets the apiVersion as a query parameter on every request
* @param options - Client options
* @returns Pipeline policy that sets the apiVersion as a query parameter on every request
*/
export declare function apiVersionPolicy(options: ClientOptions): PipelinePolicy;
//# sourceMappingURL=apiVersionPolicy.d.ts.map

View File

@ -1,23 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export const apiVersionPolicyName = "ApiVersionPolicy";
/**
* Creates a policy that sets the apiVersion as a query parameter on every request
* @param options - Client options
* @returns Pipeline policy that sets the apiVersion as a query parameter on every request
*/
export function apiVersionPolicy(options) {
return {
name: apiVersionPolicyName,
sendRequest: (req, next) => {
// Use the apiVesion defined in request url directly
// Append one if there is no apiVesion and we have one at client options
const url = new URL(req.url);
if (!url.searchParams.get("api-version") && options.apiVersion) {
req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${options.apiVersion}`;
}
return next(req);
},
};
}
//# sourceMappingURL=apiVersionPolicy.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"apiVersionPolicy.js","sourceRoot":"","sources":["../../src/apiVersionPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACrD,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,oDAAoD;YACpD,wEAAwE;YACxE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAC/D,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,OAAO,CAAC,UAAU,EAAE,CAAC;YACtC,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport type { ClientOptions } from \"./common.js\";\n\nexport const apiVersionPolicyName = \"ApiVersionPolicy\";\n\n/**\n * Creates a policy that sets the apiVersion as a query parameter on every request\n * @param options - Client options\n * @returns Pipeline policy that sets the apiVersion as a query parameter on every request\n */\nexport function apiVersionPolicy(options: ClientOptions): PipelinePolicy {\n return {\n name: apiVersionPolicyName,\n sendRequest: (req, next) => {\n // Use the apiVesion defined in request url directly\n // Append one if there is no apiVesion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && options.apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${options.apiVersion}`;\n }\n\n return next(req);\n },\n };\n}\n"]}

View File

@ -1,26 +0,0 @@
import type { HttpClient, Pipeline } from "@azure/core-rest-pipeline";
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
import type { ClientOptions } from "./common.js";
/**
* Optional parameters for adding a credential policy to the pipeline.
*/
export interface AddCredentialPipelinePolicyOptions {
/**
* Options related to the client.
*/
clientOptions?: ClientOptions;
/**
* The credential to use.
*/
credential?: TokenCredential | KeyCredential;
}
/**
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
*/
export declare function addCredentialPipelinePolicy(pipeline: Pipeline, endpoint: string, options?: AddCredentialPipelinePolicyOptions): void;
/**
* Creates a default rest pipeline to re-use accross Rest Level Clients
*/
export declare function createDefaultPipeline(endpoint: string, credential?: TokenCredential | KeyCredential, options?: ClientOptions): Pipeline;
export declare function getCachedDefaultHttpsClient(): HttpClient;
//# sourceMappingURL=clientHelpers.d.ts.map

View File

@ -1,49 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { bearerTokenAuthenticationPolicy, createDefaultHttpClient, createPipelineFromOptions, } from "@azure/core-rest-pipeline";
import { isTokenCredential } from "@azure/core-auth";
import { apiVersionPolicy } from "./apiVersionPolicy.js";
import { keyCredentialAuthenticationPolicy } from "./keyCredentialAuthenticationPolicy.js";
let cachedHttpClient;
/**
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
*/
export function addCredentialPipelinePolicy(pipeline, endpoint, options = {}) {
const { credential, clientOptions } = options;
if (!credential) {
return;
}
if (isTokenCredential(credential)) {
const tokenPolicy = bearerTokenAuthenticationPolicy({
credential,
scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,
});
pipeline.addPolicy(tokenPolicy);
}
else if (isKeyCredential(credential)) {
if (!clientOptions?.credentials?.apiKeyHeaderName) {
throw new Error(`Missing API Key Header Name`);
}
const keyPolicy = keyCredentialAuthenticationPolicy(credential, clientOptions?.credentials?.apiKeyHeaderName);
pipeline.addPolicy(keyPolicy);
}
}
/**
* Creates a default rest pipeline to re-use accross Rest Level Clients
*/
export function createDefaultPipeline(endpoint, credential, options = {}) {
const pipeline = createPipelineFromOptions(options);
pipeline.addPolicy(apiVersionPolicy(options));
addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });
return pipeline;
}
function isKeyCredential(credential) {
return credential.key !== undefined;
}
export function getCachedDefaultHttpsClient() {
if (!cachedHttpClient) {
cachedHttpClient = createDefaultHttpClient();
}
return cachedHttpClient;
}
//# sourceMappingURL=clientHelpers.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../src/clientHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAE3F,IAAI,gBAAwC,CAAC;AAgB7C;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAkB,EAClB,QAAgB,EAChB,UAA8C,EAAE;IAEhD,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,+BAA+B,CAAC;YAClD,UAAU;YACV,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,IAAI,GAAG,QAAQ,WAAW;SACrE,CAAC,CAAC;QACH,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;SAAM,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,SAAS,GAAG,iCAAiC,CACjD,UAAU,EACV,aAAa,EAAE,WAAW,EAAE,gBAAgB,CAC7C,CAAC;QACF,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAgB,EAChB,UAA4C,EAC5C,UAAyB,EAAE;IAE3B,MAAM,QAAQ,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAEpD,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE9C,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;IACxF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,UAAe;IACtC,OAAQ,UAA4B,CAAC,GAAG,KAAK,SAAS,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,uBAAuB,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient, Pipeline } from \"@azure/core-rest-pipeline\";\nimport {\n bearerTokenAuthenticationPolicy,\n createDefaultHttpClient,\n createPipelineFromOptions,\n} from \"@azure/core-rest-pipeline\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\n\nimport type { ClientOptions } from \"./common.js\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy.js\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy.js\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Optional parameters for adding a credential policy to the pipeline.\n */\nexport interface AddCredentialPipelinePolicyOptions {\n /**\n * Options related to the client.\n */\n clientOptions?: ClientOptions;\n /**\n * The credential to use.\n */\n credential?: TokenCredential | KeyCredential;\n}\n\n/**\n * Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.\n */\nexport function addCredentialPipelinePolicy(\n pipeline: Pipeline,\n endpoint: string,\n options: AddCredentialPipelinePolicyOptions = {},\n): void {\n const { credential, clientOptions } = options;\n if (!credential) {\n return;\n }\n\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!clientOptions?.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n clientOptions?.credentials?.apiKeyHeaderName,\n );\n pipeline.addPolicy(keyPolicy);\n }\n}\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n endpoint: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): Pipeline {\n const pipeline = createPipelineFromOptions(options);\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });\n return pipeline;\n}\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential).key !== undefined;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n"]}

View File

@ -1,398 +0,0 @@
import type { HttpClient, LogPolicyOptions, Pipeline, PipelineOptions, PipelinePolicy, PipelineRequest, PipelineResponse, RawHttpHeaders, RequestBodyType, TransferProgressEvent } from "@azure/core-rest-pipeline";
import type { RawHttpHeadersInput } from "@azure/core-rest-pipeline";
import type { AbortSignalLike } from "@azure/abort-controller";
import type { OperationTracingOptions } from "@azure/core-tracing";
/**
* Shape of the default request parameters, this may be overridden by the specific
* request types to provide strong types
*/
export type RequestParameters = {
/**
* Headers to send along with the request
*/
headers?: RawHttpHeadersInput;
/**
* Sets the accept header to send to the service
* defaults to 'application/json'. If also a header "accept" is set
* this property will take precedence.
*/
accept?: string;
/**
* Body to send with the request
*/
body?: unknown;
/**
* Query parameters to send with the request
*/
queryParameters?: Record<string, unknown>;
/**
* Set an explicit content-type to send with the request. If also a header "content-type" is set
* this property will take precedence.
*/
contentType?: string;
/** Set to true if the request is sent over HTTP instead of HTTPS */
allowInsecureConnection?: boolean;
/** Set to true if you want to skip encoding the path parameters */
skipUrlEncoding?: boolean;
/**
* Path parameters for custom the base url
*/
pathParameters?: Record<string, any>;
/**
* The number of milliseconds a request can take before automatically being terminated.
*/
timeout?: number;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/**
* Callback which fires upon download progress.
*/
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
/**
* Options used when tracing is enabled.
*/
tracingOptions?: OperationTracingOptions;
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*/
onResponse?: RawResponseCallback;
};
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*
* This callback will be called with two parameters: the raw response, including headers and response body; and an error
* object which will be provided if an error was thrown while processing the request.
* The third __legacyError parameter is provided for backwards compatability only and will have an identical value to the `error` parameter.
*/
export type RawResponseCallback = (rawResponse: FullOperationResponse, error?: unknown, __legacyError?: unknown) => void;
/**
* Wrapper object for http request and response. Deserialized object is stored in
* the `parsedBody` property when the response body is received in JSON.
*/
export interface FullOperationResponse extends PipelineResponse {
/**
* The raw HTTP response headers.
*/
rawHeaders?: RawHttpHeaders;
/**
* The response body as parsed JSON.
*/
parsedBody?: RequestBodyType;
/**
* The request that generated the response.
*/
request: PipelineRequest;
}
/**
* The base options type for all operations.
*/
export interface OperationOptions {
/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
/**
* Options used when creating and sending HTTP requests for this operation.
*/
requestOptions?: OperationRequestOptions;
/**
* Options used when tracing is enabled.
*/
tracingOptions?: OperationTracingOptions;
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*/
onResponse?: RawResponseCallback;
}
/**
* Options used when creating and sending HTTP requests for this operation.
*/
export interface OperationRequestOptions {
/**
* User defined custom request headers that
* will be applied before the request is sent.
*/
headers?: RawHttpHeadersInput;
/**
* The number of milliseconds a request can take before automatically being terminated.
*/
timeout?: number;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/**
* Callback which fires upon download progress.
*/
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* Set to true if the request is sent over HTTP instead of HTTPS
*/
allowInsecureConnection?: boolean;
/**
* Set to true if you want to skip encoding the path parameters
*/
skipUrlEncoding?: boolean;
}
/**
* Type to use with pathUnchecked, overrides the body type to any to allow flexibility
*/
export type PathUncheckedResponse = HttpResponse & {
body: any;
};
/**
* Shape of a Rest Level Client
*/
export interface Client {
/**
* The pipeline used by this client to make requests
*/
pipeline: Pipeline;
/**
* This method will be used to send request that would check the path to provide
* strong types. When used by the codegen this type gets overridden with the generated
* types. For example:
* ```typescript snippet:PathExample
* import { Client } from "@azure-rest/core-client";
*
* type MyClient = Client & {
* path: Routes;
* };
* ```
*/
path: Function;
/**
* This method allows arbitrary paths and doesn't provide strong types
*/
pathUnchecked: PathUnchecked;
}
/**
* A Node.js Readable stream that also has a `destroy` method.
*/
export interface NodeJSReadableStream extends NodeJS.ReadableStream {
/**
* Destroy the stream. Optionally emit an 'error' event, and emit a
* 'close' event (unless emitClose is set to false). After this call,
* internal resources will be released.
*/
destroy(error?: Error): void;
}
/**
* Http Response which body is a NodeJS stream object
*/
export type HttpNodeStreamResponse = HttpResponse & {
/**
* Streamable body
*/
body?: NodeJSReadableStream;
};
/**
* Http Response which body is a NodeJS stream object
*/
export type HttpBrowserStreamResponse = HttpResponse & {
/**
* Streamable body
*/
body?: ReadableStream<Uint8Array>;
};
/**
* Defines the type for a method that supports getting the response body as
* a raw stream
*/
export type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {
/**
* Returns the response body as a NodeJS stream. Only available in Node-like environments.
*/
asNodeStream: () => Promise<HttpNodeStreamResponse>;
/**
* Returns the response body as a browser (Web) stream. Only available in the browser. If you require a Web Stream of the response in Node, consider using the
* `Readable.toWeb` Node API on the result of `asNodeStream`.
*/
asBrowserStream: () => Promise<HttpBrowserStreamResponse>;
};
/**
* Defines the signature for pathUnchecked.
*/
export type PathUnchecked = <TPath extends string>(path: TPath, ...args: PathParameters<TPath>) => ResourceMethods<StreamableMethod>;
/**
* Defines the methods that can be called on a resource
*/
export interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {
/**
* Definition of the GET HTTP method for a resource
*/
get: (options?: RequestParameters) => TResponse;
/**
* Definition of the POST HTTP method for a resource
*/
post: (options?: RequestParameters) => TResponse;
/**
* Definition of the PUT HTTP method for a resource
*/
put: (options?: RequestParameters) => TResponse;
/**
* Definition of the PATCH HTTP method for a resource
*/
patch: (options?: RequestParameters) => TResponse;
/**
* Definition of the DELETE HTTP method for a resource
*/
delete: (options?: RequestParameters) => TResponse;
/**
* Definition of the HEAD HTTP method for a resource
*/
head: (options?: RequestParameters) => TResponse;
/**
* Definition of the OPTIONS HTTP method for a resource
*/
options: (options?: RequestParameters) => TResponse;
/**
* Definition of the TRACE HTTP method for a resource
*/
trace: (options?: RequestParameters) => TResponse;
}
/**
* Used to configure additional policies added to the pipeline at construction.
*/
export interface AdditionalPolicyConfig {
/**
* A policy to be added.
*/
policy: PipelinePolicy;
/**
* Determines if this policy be applied before or after retry logic.
* Only use `perRetry` if you need to modify the request again
* each time the operation is retried due to retryable service
* issues.
*/
position: "perCall" | "perRetry";
}
/**
* General options that a Rest Level Client can take
*/
export type ClientOptions = PipelineOptions & {
/**
* Credentials information
*/
credentials?: {
/**
* Authentication scopes for AAD
*/
scopes?: string[];
/**
* Heder name for Client Secret authentication
*/
apiKeyHeaderName?: string;
};
/**
* Base url for the client
* @deprecated This property is deprecated and will be removed soon, please use endpoint instead
*/
baseUrl?: string;
/**
* Endpoint for the client
*/
endpoint?: string;
/**
* Options for setting a custom apiVersion.
*/
apiVersion?: string;
/**
* Option to allow calling http (insecure) endpoints
*/
allowInsecureConnection?: boolean;
/**
* Additional policies to include in the HTTP pipeline.
*/
additionalPolicies?: AdditionalPolicyConfig[];
/**
* Specify a custom HttpClient when making requests.
*/
httpClient?: HttpClient;
/**
* Options to configure request/response logging.
*/
loggingOptions?: LogPolicyOptions;
};
/**
* Represents the shape of an HttpResponse
*/
export type HttpResponse = {
/**
* The request that generated this response.
*/
request: PipelineRequest;
/**
* The HTTP response headers.
*/
headers: RawHttpHeaders;
/**
* Parsed body
*/
body: unknown;
/**
* The HTTP status code of the response.
*/
status: string;
};
/**
* Helper type used to detect parameters in a path template
* text surrounded by \{\} will be considered a path parameter
*/
export type PathParameters<TRoute extends string> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}` ? [
pathParameter: string | number | PathParameterWithOptions,
...pathParameters: PathParameters<Tail>
] : [
];
/** A response containing error details. */
export interface ErrorResponse {
/** The error object. */
error: ErrorModel;
}
/** The error object. */
export interface ErrorModel {
/** One of a server-defined set of error codes. */
code: string;
/** A human-readable representation of the error. */
message: string;
/** The target of the error. */
target?: string;
/** An array of details about specific errors that led to this reported error. */
details: Array<ErrorModel>;
/** An object containing more specific information than the current object about the error. */
innererror?: InnerError;
}
/** 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. */
export interface InnerError {
/** One of a server-defined set of error codes. */
code: string;
/** Inner error. */
innererror?: InnerError;
}
/**
* An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.
*/
export interface PathParameterWithOptions {
/**
* The value of the parameter.
*/
value: string | number;
/**
* Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.
* Defaults to false.
*/
allowReserved?: boolean;
}
//# sourceMappingURL=common.d.ts.map

View File

@ -1,4 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export {};
//# sourceMappingURL=common.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,16 +0,0 @@
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
import type { Client, ClientOptions } from "./common.js";
/**
* Creates a client with a default pipeline
* @param endpoint - Base endpoint for the client
* @param options - Client options
*/
export declare function getClient(endpoint: string, options?: ClientOptions): Client;
/**
* Creates a client with a default pipeline
* @param endpoint - Base endpoint for the client
* @param credentials - Credentials to authenticate the requests
* @param options - Client options
*/
export declare function getClient(endpoint: string, credentials?: TokenCredential | KeyCredential, options?: ClientOptions): Client;
//# sourceMappingURL=getClient.d.ts.map

View File

@ -1,72 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { isKeyCredential, isTokenCredential } from "@azure/core-auth";
import { createDefaultPipeline } from "./clientHelpers.js";
import { getClient as tspGetClient, } from "@typespec/ts-http-runtime";
/**
* Function to wrap RequestParameters so that we get the legacy onResponse behavior in core-client-rest
*/
function wrapRequestParameters(parameters) {
if (parameters.onResponse) {
return {
...parameters,
onResponse(rawResponse, error) {
parameters.onResponse?.(rawResponse, error, error);
},
};
}
return parameters;
}
export function getClient(endpoint, credentialsOrPipelineOptions, clientOptions = {}) {
let credentials;
if (credentialsOrPipelineOptions) {
if (isCredential(credentialsOrPipelineOptions)) {
credentials = credentialsOrPipelineOptions;
}
else {
clientOptions = credentialsOrPipelineOptions ?? {};
}
}
const pipeline = createDefaultPipeline(endpoint, credentials, clientOptions);
const tspClient = tspGetClient(endpoint, {
...clientOptions,
pipeline,
});
const client = (path, ...args) => {
return {
get: (requestOptions = {}) => {
return tspClient.path(path, ...args).get(wrapRequestParameters(requestOptions));
},
post: (requestOptions = {}) => {
return tspClient.path(path, ...args).post(wrapRequestParameters(requestOptions));
},
put: (requestOptions = {}) => {
return tspClient.path(path, ...args).put(wrapRequestParameters(requestOptions));
},
patch: (requestOptions = {}) => {
return tspClient.path(path, ...args).patch(wrapRequestParameters(requestOptions));
},
delete: (requestOptions = {}) => {
return tspClient.path(path, ...args).delete(wrapRequestParameters(requestOptions));
},
head: (requestOptions = {}) => {
return tspClient.path(path, ...args).head(wrapRequestParameters(requestOptions));
},
options: (requestOptions = {}) => {
return tspClient.path(path, ...args).options(wrapRequestParameters(requestOptions));
},
trace: (requestOptions = {}) => {
return tspClient.path(path, ...args).trace(wrapRequestParameters(requestOptions));
},
};
};
return {
path: client,
pathUnchecked: client,
pipeline: tspClient.pipeline,
};
}
function isCredential(param) {
return isKeyCredential(param) || isTokenCredential(param);
}
//# sourceMappingURL=getClient.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,10 +0,0 @@
/**
* Azure Rest Core Client library for JavaScript
* @packageDocumentation
*/
export { createRestError } from "./restError.js";
export { addCredentialPipelinePolicy, AddCredentialPipelinePolicyOptions, } from "./clientHelpers.js";
export { operationOptionsToRequestParameters } from "./operationOptionHelpers.js";
export * from "./getClient.js";
export * from "./common.js";
//# sourceMappingURL=index.d.ts.map

View File

@ -1,12 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* Azure Rest Core Client library for JavaScript
* @packageDocumentation
*/
export { createRestError } from "./restError.js";
export { addCredentialPipelinePolicy, } from "./clientHelpers.js";
export { operationOptionsToRequestParameters } from "./operationOptionHelpers.js";
export * from "./getClient.js";
export * from "./common.js";
//# sourceMappingURL=index.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,2BAA2B,GAE5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mCAAmC,EAAE,MAAM,6BAA6B,CAAC;AAClF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Azure Rest Core Client library for JavaScript\n * @packageDocumentation\n */\n\nexport { createRestError } from \"./restError.js\";\nexport {\n addCredentialPipelinePolicy,\n AddCredentialPipelinePolicyOptions,\n} from \"./clientHelpers.js\";\nexport { operationOptionsToRequestParameters } from \"./operationOptionHelpers.js\";\nexport * from \"./getClient.js\";\nexport * from \"./common.js\";\n"]}

View File

@ -1,8 +0,0 @@
import type { KeyCredential } from "@azure/core-auth";
import type { PipelinePolicy } from "@azure/core-rest-pipeline";
/**
* The programmatic identifier of the bearerTokenAuthenticationPolicy.
*/
export declare const keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy";
export declare function keyCredentialAuthenticationPolicy(credential: KeyCredential, apiKeyHeaderName: string): PipelinePolicy;
//# sourceMappingURL=keyCredentialAuthenticationPolicy.d.ts.map

View File

@ -1,16 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* The programmatic identifier of the bearerTokenAuthenticationPolicy.
*/
export const keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy";
export function keyCredentialAuthenticationPolicy(credential, apiKeyHeaderName) {
return {
name: keyCredentialAuthenticationPolicyName,
async sendRequest(request, next) {
request.headers.set(apiKeyHeaderName, credential.key);
return next(request);
},
};
}
//# sourceMappingURL=keyCredentialAuthenticationPolicy.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"keyCredentialAuthenticationPolicy.js","sourceRoot":"","sources":["../../src/keyCredentialAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,mCAAmC,CAAC;AAEzF,MAAM,UAAU,iCAAiC,CAC/C,UAAyB,EACzB,gBAAwB;IAExB,OAAO;QACL,IAAI,EAAE,qCAAqC;QAC3C,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { KeyCredential } from \"@azure/core-auth\";\nimport type {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the bearerTokenAuthenticationPolicy.\n */\nexport const keyCredentialAuthenticationPolicyName = \"keyCredentialAuthenticationPolicy\";\n\nexport function keyCredentialAuthenticationPolicy(\n credential: KeyCredential,\n apiKeyHeaderName: string,\n): PipelinePolicy {\n return {\n name: keyCredentialAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(apiKeyHeaderName, credential.key);\n return next(request);\n },\n };\n}\n"]}

View File

@ -1,8 +0,0 @@
import type { OperationOptions, RequestParameters } from "./common.js";
/**
* Helper function to convert OperationOptions to RequestParameters
* @param options - the options that are used by Modular layer to send the request
* @returns the result of the conversion in RequestParameters of RLC layer
*/
export declare function operationOptionsToRequestParameters(options: OperationOptions): RequestParameters;
//# sourceMappingURL=operationOptionHelpers.d.ts.map

View File

@ -1,12 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { operationOptionsToRequestParameters as tspOperationOptionsToRequestParameters, } from "@typespec/ts-http-runtime";
/**
* Helper function to convert OperationOptions to RequestParameters
* @param options - the options that are used by Modular layer to send the request
* @returns the result of the conversion in RequestParameters of RLC layer
*/
export function operationOptionsToRequestParameters(options) {
return tspOperationOptionsToRequestParameters(options);
}
//# sourceMappingURL=operationOptionHelpers.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"operationOptionHelpers.js","sourceRoot":"","sources":["../../src/operationOptionHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,mCAAmC,IAAI,sCAAsC,GAE9E,MAAM,2BAA2B,CAAC;AAEnC;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CAAC,OAAyB;IAC3E,OAAO,sCAAsC,CAC3C,OAA8B,CACV,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationOptions, RequestParameters } from \"./common.js\";\n\nimport {\n operationOptionsToRequestParameters as tspOperationOptionsToRequestParameters,\n type OperationOptions as TspOperationOptions,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Helper function to convert OperationOptions to RequestParameters\n * @param options - the options that are used by Modular layer to send the request\n * @returns the result of the conversion in RequestParameters of RLC layer\n */\nexport function operationOptionsToRequestParameters(options: OperationOptions): RequestParameters {\n return tspOperationOptionsToRequestParameters(\n options as TspOperationOptions,\n ) as RequestParameters;\n}\n"]}

View File

@ -1,3 +0,0 @@
{
"type": "module"
}

View File

@ -1,11 +0,0 @@
import type { RestError } from "@azure/core-rest-pipeline";
import type { PathUncheckedResponse } from "./common.js";
/**
* Creates a rest error from a PathUnchecked response
*/
export declare function createRestError(response: PathUncheckedResponse): RestError;
/**
* Creates a rest error from an error message and a PathUnchecked response
*/
export declare function createRestError(message: string, response: PathUncheckedResponse): RestError;
//# sourceMappingURL=restError.d.ts.map

View File

@ -1,12 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { createRestError as tspCreateRestError, } from "@typespec/ts-http-runtime";
export function createRestError(messageOrResponse, response) {
if (typeof messageOrResponse === "string") {
return tspCreateRestError(messageOrResponse, response);
}
else {
return tspCreateRestError(messageOrResponse);
}
}
//# sourceMappingURL=restError.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"restError.js","sourceRoot":"","sources":["../../src/restError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EACL,eAAe,IAAI,kBAAkB,GAEtC,MAAM,2BAA2B,CAAC;AAUnC,MAAM,UAAU,eAAe,CAC7B,iBAAiD,EACjD,QAAgC;IAEhC,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,kBAAkB,CAAC,iBAAiB,EAAE,QAAqC,CAAC,CAAC;IACtF,CAAC;SAAM,CAAC;QACN,OAAO,kBAAkB,CAAC,iBAA6C,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RestError } from \"@azure/core-rest-pipeline\";\nimport type { PathUncheckedResponse } from \"./common.js\";\n\nimport {\n createRestError as tspCreateRestError,\n type PathUncheckedResponse as TspPathUncheckedResponse,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Creates a rest error from a PathUnchecked response\n */\nexport function createRestError(response: PathUncheckedResponse): RestError;\n/**\n * Creates a rest error from an error message and a PathUnchecked response\n */\nexport function createRestError(message: string, response: PathUncheckedResponse): RestError;\nexport function createRestError(\n messageOrResponse: string | PathUncheckedResponse,\n response?: PathUncheckedResponse,\n): RestError {\n if (typeof messageOrResponse === \"string\") {\n return tspCreateRestError(messageOrResponse, response! as TspPathUncheckedResponse);\n } else {\n return tspCreateRestError(messageOrResponse as TspPathUncheckedResponse);\n }\n}\n"]}

View File

@ -1,10 +0,0 @@
import type { PipelinePolicy } from "@azure/core-rest-pipeline";
import type { ClientOptions } from "./common.js";
export declare const apiVersionPolicyName = "ApiVersionPolicy";
/**
* Creates a policy that sets the apiVersion as a query parameter on every request
* @param options - Client options
* @returns Pipeline policy that sets the apiVersion as a query parameter on every request
*/
export declare function apiVersionPolicy(options: ClientOptions): PipelinePolicy;
//# sourceMappingURL=apiVersionPolicy.d.ts.map

View File

@ -1,27 +0,0 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.apiVersionPolicyName = void 0;
exports.apiVersionPolicy = apiVersionPolicy;
exports.apiVersionPolicyName = "ApiVersionPolicy";
/**
* Creates a policy that sets the apiVersion as a query parameter on every request
* @param options - Client options
* @returns Pipeline policy that sets the apiVersion as a query parameter on every request
*/
function apiVersionPolicy(options) {
return {
name: exports.apiVersionPolicyName,
sendRequest: (req, next) => {
// Use the apiVesion defined in request url directly
// Append one if there is no apiVesion and we have one at client options
const url = new URL(req.url);
if (!url.searchParams.get("api-version") && options.apiVersion) {
req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${options.apiVersion}`;
}
return next(req);
},
};
}
//# sourceMappingURL=apiVersionPolicy.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"apiVersionPolicy.js","sourceRoot":"","sources":["../../src/apiVersionPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAYlC,4CAgBC;AAvBY,QAAA,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,OAAsB;IACrD,OAAO;QACL,IAAI,EAAE,4BAAoB;QAC1B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,oDAAoD;YACpD,wEAAwE;YACxE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAC/D,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,OAAO,CAAC,UAAU,EAAE,CAAC;YACtC,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport type { ClientOptions } from \"./common.js\";\n\nexport const apiVersionPolicyName = \"ApiVersionPolicy\";\n\n/**\n * Creates a policy that sets the apiVersion as a query parameter on every request\n * @param options - Client options\n * @returns Pipeline policy that sets the apiVersion as a query parameter on every request\n */\nexport function apiVersionPolicy(options: ClientOptions): PipelinePolicy {\n return {\n name: apiVersionPolicyName,\n sendRequest: (req, next) => {\n // Use the apiVesion defined in request url directly\n // Append one if there is no apiVesion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && options.apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${options.apiVersion}`;\n }\n\n return next(req);\n },\n };\n}\n"]}

View File

@ -1,26 +0,0 @@
import type { HttpClient, Pipeline } from "@azure/core-rest-pipeline";
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
import type { ClientOptions } from "./common.js";
/**
* Optional parameters for adding a credential policy to the pipeline.
*/
export interface AddCredentialPipelinePolicyOptions {
/**
* Options related to the client.
*/
clientOptions?: ClientOptions;
/**
* The credential to use.
*/
credential?: TokenCredential | KeyCredential;
}
/**
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
*/
export declare function addCredentialPipelinePolicy(pipeline: Pipeline, endpoint: string, options?: AddCredentialPipelinePolicyOptions): void;
/**
* Creates a default rest pipeline to re-use accross Rest Level Clients
*/
export declare function createDefaultPipeline(endpoint: string, credential?: TokenCredential | KeyCredential, options?: ClientOptions): Pipeline;
export declare function getCachedDefaultHttpsClient(): HttpClient;
//# sourceMappingURL=clientHelpers.d.ts.map

View File

@ -1,54 +0,0 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.addCredentialPipelinePolicy = addCredentialPipelinePolicy;
exports.createDefaultPipeline = createDefaultPipeline;
exports.getCachedDefaultHttpsClient = getCachedDefaultHttpsClient;
const core_rest_pipeline_1 = require("@azure/core-rest-pipeline");
const core_auth_1 = require("@azure/core-auth");
const apiVersionPolicy_js_1 = require("./apiVersionPolicy.js");
const keyCredentialAuthenticationPolicy_js_1 = require("./keyCredentialAuthenticationPolicy.js");
let cachedHttpClient;
/**
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
*/
function addCredentialPipelinePolicy(pipeline, endpoint, options = {}) {
const { credential, clientOptions } = options;
if (!credential) {
return;
}
if ((0, core_auth_1.isTokenCredential)(credential)) {
const tokenPolicy = (0, core_rest_pipeline_1.bearerTokenAuthenticationPolicy)({
credential,
scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,
});
pipeline.addPolicy(tokenPolicy);
}
else if (isKeyCredential(credential)) {
if (!clientOptions?.credentials?.apiKeyHeaderName) {
throw new Error(`Missing API Key Header Name`);
}
const keyPolicy = (0, keyCredentialAuthenticationPolicy_js_1.keyCredentialAuthenticationPolicy)(credential, clientOptions?.credentials?.apiKeyHeaderName);
pipeline.addPolicy(keyPolicy);
}
}
/**
* Creates a default rest pipeline to re-use accross Rest Level Clients
*/
function createDefaultPipeline(endpoint, credential, options = {}) {
const pipeline = (0, core_rest_pipeline_1.createPipelineFromOptions)(options);
pipeline.addPolicy((0, apiVersionPolicy_js_1.apiVersionPolicy)(options));
addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });
return pipeline;
}
function isKeyCredential(credential) {
return credential.key !== undefined;
}
function getCachedDefaultHttpsClient() {
if (!cachedHttpClient) {
cachedHttpClient = (0, core_rest_pipeline_1.createDefaultHttpClient)();
}
return cachedHttpClient;
}
//# sourceMappingURL=clientHelpers.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../src/clientHelpers.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAkClC,kEA0BC;AAKD,sDAWC;AAMD,kEAMC;AArFD,kEAImC;AAEnC,gDAAqD;AAGrD,+DAAyD;AACzD,iGAA2F;AAE3F,IAAI,gBAAwC,CAAC;AAgB7C;;GAEG;AACH,SAAgB,2BAA2B,CACzC,QAAkB,EAClB,QAAgB,EAChB,UAA8C,EAAE;IAEhD,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,IAAI,IAAA,6BAAiB,EAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,IAAA,oDAA+B,EAAC;YAClD,UAAU;YACV,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,IAAI,GAAG,QAAQ,WAAW;SACrE,CAAC,CAAC;QACH,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;SAAM,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,SAAS,GAAG,IAAA,wEAAiC,EACjD,UAAU,EACV,aAAa,EAAE,WAAW,EAAE,gBAAgB,CAC7C,CAAC;QACF,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,qBAAqB,CACnC,QAAgB,EAChB,UAA4C,EAC5C,UAAyB,EAAE;IAE3B,MAAM,QAAQ,GAAG,IAAA,8CAAyB,EAAC,OAAO,CAAC,CAAC;IAEpD,QAAQ,CAAC,SAAS,CAAC,IAAA,sCAAgB,EAAC,OAAO,CAAC,CAAC,CAAC;IAE9C,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;IACxF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,UAAe;IACtC,OAAQ,UAA4B,CAAC,GAAG,KAAK,SAAS,CAAC;AACzD,CAAC;AAED,SAAgB,2BAA2B;IACzC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,IAAA,4CAAuB,GAAE,CAAC;IAC/C,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient, Pipeline } from \"@azure/core-rest-pipeline\";\nimport {\n bearerTokenAuthenticationPolicy,\n createDefaultHttpClient,\n createPipelineFromOptions,\n} from \"@azure/core-rest-pipeline\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\n\nimport type { ClientOptions } from \"./common.js\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy.js\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy.js\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Optional parameters for adding a credential policy to the pipeline.\n */\nexport interface AddCredentialPipelinePolicyOptions {\n /**\n * Options related to the client.\n */\n clientOptions?: ClientOptions;\n /**\n * The credential to use.\n */\n credential?: TokenCredential | KeyCredential;\n}\n\n/**\n * Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.\n */\nexport function addCredentialPipelinePolicy(\n pipeline: Pipeline,\n endpoint: string,\n options: AddCredentialPipelinePolicyOptions = {},\n): void {\n const { credential, clientOptions } = options;\n if (!credential) {\n return;\n }\n\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!clientOptions?.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n clientOptions?.credentials?.apiKeyHeaderName,\n );\n pipeline.addPolicy(keyPolicy);\n }\n}\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n endpoint: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): Pipeline {\n const pipeline = createPipelineFromOptions(options);\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });\n return pipeline;\n}\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential).key !== undefined;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n"]}

View File

@ -1,398 +0,0 @@
import type { HttpClient, LogPolicyOptions, Pipeline, PipelineOptions, PipelinePolicy, PipelineRequest, PipelineResponse, RawHttpHeaders, RequestBodyType, TransferProgressEvent } from "@azure/core-rest-pipeline";
import type { RawHttpHeadersInput } from "@azure/core-rest-pipeline";
import type { AbortSignalLike } from "@azure/abort-controller";
import type { OperationTracingOptions } from "@azure/core-tracing";
/**
* Shape of the default request parameters, this may be overridden by the specific
* request types to provide strong types
*/
export type RequestParameters = {
/**
* Headers to send along with the request
*/
headers?: RawHttpHeadersInput;
/**
* Sets the accept header to send to the service
* defaults to 'application/json'. If also a header "accept" is set
* this property will take precedence.
*/
accept?: string;
/**
* Body to send with the request
*/
body?: unknown;
/**
* Query parameters to send with the request
*/
queryParameters?: Record<string, unknown>;
/**
* Set an explicit content-type to send with the request. If also a header "content-type" is set
* this property will take precedence.
*/
contentType?: string;
/** Set to true if the request is sent over HTTP instead of HTTPS */
allowInsecureConnection?: boolean;
/** Set to true if you want to skip encoding the path parameters */
skipUrlEncoding?: boolean;
/**
* Path parameters for custom the base url
*/
pathParameters?: Record<string, any>;
/**
* The number of milliseconds a request can take before automatically being terminated.
*/
timeout?: number;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/**
* Callback which fires upon download progress.
*/
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
/**
* Options used when tracing is enabled.
*/
tracingOptions?: OperationTracingOptions;
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*/
onResponse?: RawResponseCallback;
};
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*
* This callback will be called with two parameters: the raw response, including headers and response body; and an error
* object which will be provided if an error was thrown while processing the request.
* The third __legacyError parameter is provided for backwards compatability only and will have an identical value to the `error` parameter.
*/
export type RawResponseCallback = (rawResponse: FullOperationResponse, error?: unknown, __legacyError?: unknown) => void;
/**
* Wrapper object for http request and response. Deserialized object is stored in
* the `parsedBody` property when the response body is received in JSON.
*/
export interface FullOperationResponse extends PipelineResponse {
/**
* The raw HTTP response headers.
*/
rawHeaders?: RawHttpHeaders;
/**
* The response body as parsed JSON.
*/
parsedBody?: RequestBodyType;
/**
* The request that generated the response.
*/
request: PipelineRequest;
}
/**
* The base options type for all operations.
*/
export interface OperationOptions {
/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
/**
* Options used when creating and sending HTTP requests for this operation.
*/
requestOptions?: OperationRequestOptions;
/**
* Options used when tracing is enabled.
*/
tracingOptions?: OperationTracingOptions;
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*/
onResponse?: RawResponseCallback;
}
/**
* Options used when creating and sending HTTP requests for this operation.
*/
export interface OperationRequestOptions {
/**
* User defined custom request headers that
* will be applied before the request is sent.
*/
headers?: RawHttpHeadersInput;
/**
* The number of milliseconds a request can take before automatically being terminated.
*/
timeout?: number;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/**
* Callback which fires upon download progress.
*/
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* Set to true if the request is sent over HTTP instead of HTTPS
*/
allowInsecureConnection?: boolean;
/**
* Set to true if you want to skip encoding the path parameters
*/
skipUrlEncoding?: boolean;
}
/**
* Type to use with pathUnchecked, overrides the body type to any to allow flexibility
*/
export type PathUncheckedResponse = HttpResponse & {
body: any;
};
/**
* Shape of a Rest Level Client
*/
export interface Client {
/**
* The pipeline used by this client to make requests
*/
pipeline: Pipeline;
/**
* This method will be used to send request that would check the path to provide
* strong types. When used by the codegen this type gets overridden with the generated
* types. For example:
* ```typescript snippet:PathExample
* import { Client } from "@azure-rest/core-client";
*
* type MyClient = Client & {
* path: Routes;
* };
* ```
*/
path: Function;
/**
* This method allows arbitrary paths and doesn't provide strong types
*/
pathUnchecked: PathUnchecked;
}
/**
* A Node.js Readable stream that also has a `destroy` method.
*/
export interface NodeJSReadableStream extends NodeJS.ReadableStream {
/**
* Destroy the stream. Optionally emit an 'error' event, and emit a
* 'close' event (unless emitClose is set to false). After this call,
* internal resources will be released.
*/
destroy(error?: Error): void;
}
/**
* Http Response which body is a NodeJS stream object
*/
export type HttpNodeStreamResponse = HttpResponse & {
/**
* Streamable body
*/
body?: NodeJSReadableStream;
};
/**
* Http Response which body is a NodeJS stream object
*/
export type HttpBrowserStreamResponse = HttpResponse & {
/**
* Streamable body
*/
body?: ReadableStream<Uint8Array>;
};
/**
* Defines the type for a method that supports getting the response body as
* a raw stream
*/
export type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {
/**
* Returns the response body as a NodeJS stream. Only available in Node-like environments.
*/
asNodeStream: () => Promise<HttpNodeStreamResponse>;
/**
* Returns the response body as a browser (Web) stream. Only available in the browser. If you require a Web Stream of the response in Node, consider using the
* `Readable.toWeb` Node API on the result of `asNodeStream`.
*/
asBrowserStream: () => Promise<HttpBrowserStreamResponse>;
};
/**
* Defines the signature for pathUnchecked.
*/
export type PathUnchecked = <TPath extends string>(path: TPath, ...args: PathParameters<TPath>) => ResourceMethods<StreamableMethod>;
/**
* Defines the methods that can be called on a resource
*/
export interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {
/**
* Definition of the GET HTTP method for a resource
*/
get: (options?: RequestParameters) => TResponse;
/**
* Definition of the POST HTTP method for a resource
*/
post: (options?: RequestParameters) => TResponse;
/**
* Definition of the PUT HTTP method for a resource
*/
put: (options?: RequestParameters) => TResponse;
/**
* Definition of the PATCH HTTP method for a resource
*/
patch: (options?: RequestParameters) => TResponse;
/**
* Definition of the DELETE HTTP method for a resource
*/
delete: (options?: RequestParameters) => TResponse;
/**
* Definition of the HEAD HTTP method for a resource
*/
head: (options?: RequestParameters) => TResponse;
/**
* Definition of the OPTIONS HTTP method for a resource
*/
options: (options?: RequestParameters) => TResponse;
/**
* Definition of the TRACE HTTP method for a resource
*/
trace: (options?: RequestParameters) => TResponse;
}
/**
* Used to configure additional policies added to the pipeline at construction.
*/
export interface AdditionalPolicyConfig {
/**
* A policy to be added.
*/
policy: PipelinePolicy;
/**
* Determines if this policy be applied before or after retry logic.
* Only use `perRetry` if you need to modify the request again
* each time the operation is retried due to retryable service
* issues.
*/
position: "perCall" | "perRetry";
}
/**
* General options that a Rest Level Client can take
*/
export type ClientOptions = PipelineOptions & {
/**
* Credentials information
*/
credentials?: {
/**
* Authentication scopes for AAD
*/
scopes?: string[];
/**
* Heder name for Client Secret authentication
*/
apiKeyHeaderName?: string;
};
/**
* Base url for the client
* @deprecated This property is deprecated and will be removed soon, please use endpoint instead
*/
baseUrl?: string;
/**
* Endpoint for the client
*/
endpoint?: string;
/**
* Options for setting a custom apiVersion.
*/
apiVersion?: string;
/**
* Option to allow calling http (insecure) endpoints
*/
allowInsecureConnection?: boolean;
/**
* Additional policies to include in the HTTP pipeline.
*/
additionalPolicies?: AdditionalPolicyConfig[];
/**
* Specify a custom HttpClient when making requests.
*/
httpClient?: HttpClient;
/**
* Options to configure request/response logging.
*/
loggingOptions?: LogPolicyOptions;
};
/**
* Represents the shape of an HttpResponse
*/
export type HttpResponse = {
/**
* The request that generated this response.
*/
request: PipelineRequest;
/**
* The HTTP response headers.
*/
headers: RawHttpHeaders;
/**
* Parsed body
*/
body: unknown;
/**
* The HTTP status code of the response.
*/
status: string;
};
/**
* Helper type used to detect parameters in a path template
* text surrounded by \{\} will be considered a path parameter
*/
export type PathParameters<TRoute extends string> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}` ? [
pathParameter: string | number | PathParameterWithOptions,
...pathParameters: PathParameters<Tail>
] : [
];
/** A response containing error details. */
export interface ErrorResponse {
/** The error object. */
error: ErrorModel;
}
/** The error object. */
export interface ErrorModel {
/** One of a server-defined set of error codes. */
code: string;
/** A human-readable representation of the error. */
message: string;
/** The target of the error. */
target?: string;
/** An array of details about specific errors that led to this reported error. */
details: Array<ErrorModel>;
/** An object containing more specific information than the current object about the error. */
innererror?: InnerError;
}
/** 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. */
export interface InnerError {
/** One of a server-defined set of error codes. */
code: string;
/** Inner error. */
innererror?: InnerError;
}
/**
* An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.
*/
export interface PathParameterWithOptions {
/**
* The value of the parameter.
*/
value: string | number;
/**
* Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.
* Defaults to false.
*/
allowReserved?: boolean;
}
//# sourceMappingURL=common.d.ts.map

View File

@ -1,5 +0,0 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
//# sourceMappingURL=common.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,16 +0,0 @@
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
import type { Client, ClientOptions } from "./common.js";
/**
* Creates a client with a default pipeline
* @param endpoint - Base endpoint for the client
* @param options - Client options
*/
export declare function getClient(endpoint: string, options?: ClientOptions): Client;
/**
* Creates a client with a default pipeline
* @param endpoint - Base endpoint for the client
* @param credentials - Credentials to authenticate the requests
* @param options - Client options
*/
export declare function getClient(endpoint: string, credentials?: TokenCredential | KeyCredential, options?: ClientOptions): Client;
//# sourceMappingURL=getClient.d.ts.map

View File

@ -1,75 +0,0 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.getClient = getClient;
const core_auth_1 = require("@azure/core-auth");
const clientHelpers_js_1 = require("./clientHelpers.js");
const ts_http_runtime_1 = require("@typespec/ts-http-runtime");
/**
* Function to wrap RequestParameters so that we get the legacy onResponse behavior in core-client-rest
*/
function wrapRequestParameters(parameters) {
if (parameters.onResponse) {
return {
...parameters,
onResponse(rawResponse, error) {
parameters.onResponse?.(rawResponse, error, error);
},
};
}
return parameters;
}
function getClient(endpoint, credentialsOrPipelineOptions, clientOptions = {}) {
let credentials;
if (credentialsOrPipelineOptions) {
if (isCredential(credentialsOrPipelineOptions)) {
credentials = credentialsOrPipelineOptions;
}
else {
clientOptions = credentialsOrPipelineOptions ?? {};
}
}
const pipeline = (0, clientHelpers_js_1.createDefaultPipeline)(endpoint, credentials, clientOptions);
const tspClient = (0, ts_http_runtime_1.getClient)(endpoint, {
...clientOptions,
pipeline,
});
const client = (path, ...args) => {
return {
get: (requestOptions = {}) => {
return tspClient.path(path, ...args).get(wrapRequestParameters(requestOptions));
},
post: (requestOptions = {}) => {
return tspClient.path(path, ...args).post(wrapRequestParameters(requestOptions));
},
put: (requestOptions = {}) => {
return tspClient.path(path, ...args).put(wrapRequestParameters(requestOptions));
},
patch: (requestOptions = {}) => {
return tspClient.path(path, ...args).patch(wrapRequestParameters(requestOptions));
},
delete: (requestOptions = {}) => {
return tspClient.path(path, ...args).delete(wrapRequestParameters(requestOptions));
},
head: (requestOptions = {}) => {
return tspClient.path(path, ...args).head(wrapRequestParameters(requestOptions));
},
options: (requestOptions = {}) => {
return tspClient.path(path, ...args).options(wrapRequestParameters(requestOptions));
},
trace: (requestOptions = {}) => {
return tspClient.path(path, ...args).trace(wrapRequestParameters(requestOptions));
},
};
};
return {
path: client,
pathUnchecked: client,
pipeline: tspClient.pipeline,
};
}
function isCredential(param) {
return (0, core_auth_1.isKeyCredential)(param) || (0, core_auth_1.isTokenCredential)(param);
}
//# sourceMappingURL=getClient.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,10 +0,0 @@
/**
* Azure Rest Core Client library for JavaScript
* @packageDocumentation
*/
export { createRestError } from "./restError.js";
export { addCredentialPipelinePolicy, AddCredentialPipelinePolicyOptions, } from "./clientHelpers.js";
export { operationOptionsToRequestParameters } from "./operationOptionHelpers.js";
export * from "./getClient.js";
export * from "./common.js";
//# sourceMappingURL=index.d.ts.map

View File

@ -1,19 +0,0 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.operationOptionsToRequestParameters = exports.addCredentialPipelinePolicy = exports.createRestError = void 0;
const tslib_1 = require("tslib");
/**
* Azure Rest Core Client library for JavaScript
* @packageDocumentation
*/
var restError_js_1 = require("./restError.js");
Object.defineProperty(exports, "createRestError", { enumerable: true, get: function () { return restError_js_1.createRestError; } });
var clientHelpers_js_1 = require("./clientHelpers.js");
Object.defineProperty(exports, "addCredentialPipelinePolicy", { enumerable: true, get: function () { return clientHelpers_js_1.addCredentialPipelinePolicy; } });
var operationOptionHelpers_js_1 = require("./operationOptionHelpers.js");
Object.defineProperty(exports, "operationOptionsToRequestParameters", { enumerable: true, get: function () { return operationOptionHelpers_js_1.operationOptionsToRequestParameters; } });
tslib_1.__exportStar(require("./getClient.js"), exports);
tslib_1.__exportStar(require("./common.js"), exports);
//# sourceMappingURL=index.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC;;;GAGG;AAEH,+CAAiD;AAAxC,+GAAA,eAAe,OAAA;AACxB,uDAG4B;AAF1B,+HAAA,2BAA2B,OAAA;AAG7B,yEAAkF;AAAzE,gJAAA,mCAAmC,OAAA;AAC5C,yDAA+B;AAC/B,sDAA4B","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Azure Rest Core Client library for JavaScript\n * @packageDocumentation\n */\n\nexport { createRestError } from \"./restError.js\";\nexport {\n addCredentialPipelinePolicy,\n AddCredentialPipelinePolicyOptions,\n} from \"./clientHelpers.js\";\nexport { operationOptionsToRequestParameters } from \"./operationOptionHelpers.js\";\nexport * from \"./getClient.js\";\nexport * from \"./common.js\";\n"]}

View File

@ -1,8 +0,0 @@
import type { KeyCredential } from "@azure/core-auth";
import type { PipelinePolicy } from "@azure/core-rest-pipeline";
/**
* The programmatic identifier of the bearerTokenAuthenticationPolicy.
*/
export declare const keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy";
export declare function keyCredentialAuthenticationPolicy(credential: KeyCredential, apiKeyHeaderName: string): PipelinePolicy;
//# sourceMappingURL=keyCredentialAuthenticationPolicy.d.ts.map

View File

@ -1,20 +0,0 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.keyCredentialAuthenticationPolicyName = void 0;
exports.keyCredentialAuthenticationPolicy = keyCredentialAuthenticationPolicy;
/**
* The programmatic identifier of the bearerTokenAuthenticationPolicy.
*/
exports.keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy";
function keyCredentialAuthenticationPolicy(credential, apiKeyHeaderName) {
return {
name: exports.keyCredentialAuthenticationPolicyName,
async sendRequest(request, next) {
request.headers.set(apiKeyHeaderName, credential.key);
return next(request);
},
};
}
//# sourceMappingURL=keyCredentialAuthenticationPolicy.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"keyCredentialAuthenticationPolicy.js","sourceRoot":"","sources":["../../src/keyCredentialAuthenticationPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAelC,8EAWC;AAhBD;;GAEG;AACU,QAAA,qCAAqC,GAAG,mCAAmC,CAAC;AAEzF,SAAgB,iCAAiC,CAC/C,UAAyB,EACzB,gBAAwB;IAExB,OAAO;QACL,IAAI,EAAE,6CAAqC;QAC3C,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { KeyCredential } from \"@azure/core-auth\";\nimport type {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the bearerTokenAuthenticationPolicy.\n */\nexport const keyCredentialAuthenticationPolicyName = \"keyCredentialAuthenticationPolicy\";\n\nexport function keyCredentialAuthenticationPolicy(\n credential: KeyCredential,\n apiKeyHeaderName: string,\n): PipelinePolicy {\n return {\n name: keyCredentialAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(apiKeyHeaderName, credential.key);\n return next(request);\n },\n };\n}\n"]}

View File

@ -1,8 +0,0 @@
import type { OperationOptions, RequestParameters } from "./common.js";
/**
* Helper function to convert OperationOptions to RequestParameters
* @param options - the options that are used by Modular layer to send the request
* @returns the result of the conversion in RequestParameters of RLC layer
*/
export declare function operationOptionsToRequestParameters(options: OperationOptions): RequestParameters;
//# sourceMappingURL=operationOptionHelpers.d.ts.map

View File

@ -1,15 +0,0 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.operationOptionsToRequestParameters = operationOptionsToRequestParameters;
const ts_http_runtime_1 = require("@typespec/ts-http-runtime");
/**
* Helper function to convert OperationOptions to RequestParameters
* @param options - the options that are used by Modular layer to send the request
* @returns the result of the conversion in RequestParameters of RLC layer
*/
function operationOptionsToRequestParameters(options) {
return (0, ts_http_runtime_1.operationOptionsToRequestParameters)(options);
}
//# sourceMappingURL=operationOptionHelpers.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"operationOptionHelpers.js","sourceRoot":"","sources":["../../src/operationOptionHelpers.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAclC,kFAIC;AAdD,+DAGmC;AAEnC;;;;GAIG;AACH,SAAgB,mCAAmC,CAAC,OAAyB;IAC3E,OAAO,IAAA,qDAAsC,EAC3C,OAA8B,CACV,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationOptions, RequestParameters } from \"./common.js\";\n\nimport {\n operationOptionsToRequestParameters as tspOperationOptionsToRequestParameters,\n type OperationOptions as TspOperationOptions,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Helper function to convert OperationOptions to RequestParameters\n * @param options - the options that are used by Modular layer to send the request\n * @returns the result of the conversion in RequestParameters of RLC layer\n */\nexport function operationOptionsToRequestParameters(options: OperationOptions): RequestParameters {\n return tspOperationOptionsToRequestParameters(\n options as TspOperationOptions,\n ) as RequestParameters;\n}\n"]}

View File

@ -1,3 +0,0 @@
{
"type": "commonjs"
}

View File

@ -1,11 +0,0 @@
import type { RestError } from "@azure/core-rest-pipeline";
import type { PathUncheckedResponse } from "./common.js";
/**
* Creates a rest error from a PathUnchecked response
*/
export declare function createRestError(response: PathUncheckedResponse): RestError;
/**
* Creates a rest error from an error message and a PathUnchecked response
*/
export declare function createRestError(message: string, response: PathUncheckedResponse): RestError;
//# sourceMappingURL=restError.d.ts.map

View File

@ -1,15 +0,0 @@
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.createRestError = createRestError;
const ts_http_runtime_1 = require("@typespec/ts-http-runtime");
function createRestError(messageOrResponse, response) {
if (typeof messageOrResponse === "string") {
return (0, ts_http_runtime_1.createRestError)(messageOrResponse, response);
}
else {
return (0, ts_http_runtime_1.createRestError)(messageOrResponse);
}
}
//# sourceMappingURL=restError.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"restError.js","sourceRoot":"","sources":["../../src/restError.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAkBlC,0CASC;AAtBD,+DAGmC;AAUnC,SAAgB,eAAe,CAC7B,iBAAiD,EACjD,QAAgC;IAEhC,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,IAAA,iCAAkB,EAAC,iBAAiB,EAAE,QAAqC,CAAC,CAAC;IACtF,CAAC;SAAM,CAAC;QACN,OAAO,IAAA,iCAAkB,EAAC,iBAA6C,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RestError } from \"@azure/core-rest-pipeline\";\nimport type { PathUncheckedResponse } from \"./common.js\";\n\nimport {\n createRestError as tspCreateRestError,\n type PathUncheckedResponse as TspPathUncheckedResponse,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Creates a rest error from a PathUnchecked response\n */\nexport function createRestError(response: PathUncheckedResponse): RestError;\n/**\n * Creates a rest error from an error message and a PathUnchecked response\n */\nexport function createRestError(message: string, response: PathUncheckedResponse): RestError;\nexport function createRestError(\n messageOrResponse: string | PathUncheckedResponse,\n response?: PathUncheckedResponse,\n): RestError {\n if (typeof messageOrResponse === \"string\") {\n return tspCreateRestError(messageOrResponse, response! as TspPathUncheckedResponse);\n } else {\n return tspCreateRestError(messageOrResponse as TspPathUncheckedResponse);\n }\n}\n"]}

View File

@ -1,11 +0,0 @@
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
// It should be published with your NPM package. It should not be tracked by Git.
{
"tsdocVersion": "0.12",
"toolPackages": [
{
"packageName": "@microsoft/api-extractor",
"packageVersion": "7.52.11"
}
]
}

View File

@ -1,10 +0,0 @@
import type { PipelinePolicy } from "@azure/core-rest-pipeline";
import type { ClientOptions } from "./common.js";
export declare const apiVersionPolicyName = "ApiVersionPolicy";
/**
* Creates a policy that sets the apiVersion as a query parameter on every request
* @param options - Client options
* @returns Pipeline policy that sets the apiVersion as a query parameter on every request
*/
export declare function apiVersionPolicy(options: ClientOptions): PipelinePolicy;
//# sourceMappingURL=apiVersionPolicy.d.ts.map

View File

@ -1,23 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export const apiVersionPolicyName = "ApiVersionPolicy";
/**
* Creates a policy that sets the apiVersion as a query parameter on every request
* @param options - Client options
* @returns Pipeline policy that sets the apiVersion as a query parameter on every request
*/
export function apiVersionPolicy(options) {
return {
name: apiVersionPolicyName,
sendRequest: (req, next) => {
// Use the apiVesion defined in request url directly
// Append one if there is no apiVesion and we have one at client options
const url = new URL(req.url);
if (!url.searchParams.get("api-version") && options.apiVersion) {
req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${options.apiVersion}`;
}
return next(req);
},
};
}
//# sourceMappingURL=apiVersionPolicy.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"apiVersionPolicy.js","sourceRoot":"","sources":["../../src/apiVersionPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACrD,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,oDAAoD;YACpD,wEAAwE;YACxE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAC/D,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,OAAO,CAAC,UAAU,EAAE,CAAC;YACtC,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport type { ClientOptions } from \"./common.js\";\n\nexport const apiVersionPolicyName = \"ApiVersionPolicy\";\n\n/**\n * Creates a policy that sets the apiVersion as a query parameter on every request\n * @param options - Client options\n * @returns Pipeline policy that sets the apiVersion as a query parameter on every request\n */\nexport function apiVersionPolicy(options: ClientOptions): PipelinePolicy {\n return {\n name: apiVersionPolicyName,\n sendRequest: (req, next) => {\n // Use the apiVesion defined in request url directly\n // Append one if there is no apiVesion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && options.apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${options.apiVersion}`;\n }\n\n return next(req);\n },\n };\n}\n"]}

View File

@ -1,26 +0,0 @@
import type { HttpClient, Pipeline } from "@azure/core-rest-pipeline";
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
import type { ClientOptions } from "./common.js";
/**
* Optional parameters for adding a credential policy to the pipeline.
*/
export interface AddCredentialPipelinePolicyOptions {
/**
* Options related to the client.
*/
clientOptions?: ClientOptions;
/**
* The credential to use.
*/
credential?: TokenCredential | KeyCredential;
}
/**
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
*/
export declare function addCredentialPipelinePolicy(pipeline: Pipeline, endpoint: string, options?: AddCredentialPipelinePolicyOptions): void;
/**
* Creates a default rest pipeline to re-use accross Rest Level Clients
*/
export declare function createDefaultPipeline(endpoint: string, credential?: TokenCredential | KeyCredential, options?: ClientOptions): Pipeline;
export declare function getCachedDefaultHttpsClient(): HttpClient;
//# sourceMappingURL=clientHelpers.d.ts.map

View File

@ -1,49 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { bearerTokenAuthenticationPolicy, createDefaultHttpClient, createPipelineFromOptions, } from "@azure/core-rest-pipeline";
import { isTokenCredential } from "@azure/core-auth";
import { apiVersionPolicy } from "./apiVersionPolicy.js";
import { keyCredentialAuthenticationPolicy } from "./keyCredentialAuthenticationPolicy.js";
let cachedHttpClient;
/**
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
*/
export function addCredentialPipelinePolicy(pipeline, endpoint, options = {}) {
const { credential, clientOptions } = options;
if (!credential) {
return;
}
if (isTokenCredential(credential)) {
const tokenPolicy = bearerTokenAuthenticationPolicy({
credential,
scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,
});
pipeline.addPolicy(tokenPolicy);
}
else if (isKeyCredential(credential)) {
if (!clientOptions?.credentials?.apiKeyHeaderName) {
throw new Error(`Missing API Key Header Name`);
}
const keyPolicy = keyCredentialAuthenticationPolicy(credential, clientOptions?.credentials?.apiKeyHeaderName);
pipeline.addPolicy(keyPolicy);
}
}
/**
* Creates a default rest pipeline to re-use accross Rest Level Clients
*/
export function createDefaultPipeline(endpoint, credential, options = {}) {
const pipeline = createPipelineFromOptions(options);
pipeline.addPolicy(apiVersionPolicy(options));
addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });
return pipeline;
}
function isKeyCredential(credential) {
return credential.key !== undefined;
}
export function getCachedDefaultHttpsClient() {
if (!cachedHttpClient) {
cachedHttpClient = createDefaultHttpClient();
}
return cachedHttpClient;
}
//# sourceMappingURL=clientHelpers.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../src/clientHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAE3F,IAAI,gBAAwC,CAAC;AAgB7C;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAkB,EAClB,QAAgB,EAChB,UAA8C,EAAE;IAEhD,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,+BAA+B,CAAC;YAClD,UAAU;YACV,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,IAAI,GAAG,QAAQ,WAAW;SACrE,CAAC,CAAC;QACH,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;SAAM,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,SAAS,GAAG,iCAAiC,CACjD,UAAU,EACV,aAAa,EAAE,WAAW,EAAE,gBAAgB,CAC7C,CAAC;QACF,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAgB,EAChB,UAA4C,EAC5C,UAAyB,EAAE;IAE3B,MAAM,QAAQ,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAEpD,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE9C,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;IACxF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,UAAe;IACtC,OAAQ,UAA4B,CAAC,GAAG,KAAK,SAAS,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,uBAAuB,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient, Pipeline } from \"@azure/core-rest-pipeline\";\nimport {\n bearerTokenAuthenticationPolicy,\n createDefaultHttpClient,\n createPipelineFromOptions,\n} from \"@azure/core-rest-pipeline\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\n\nimport type { ClientOptions } from \"./common.js\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy.js\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy.js\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Optional parameters for adding a credential policy to the pipeline.\n */\nexport interface AddCredentialPipelinePolicyOptions {\n /**\n * Options related to the client.\n */\n clientOptions?: ClientOptions;\n /**\n * The credential to use.\n */\n credential?: TokenCredential | KeyCredential;\n}\n\n/**\n * Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.\n */\nexport function addCredentialPipelinePolicy(\n pipeline: Pipeline,\n endpoint: string,\n options: AddCredentialPipelinePolicyOptions = {},\n): void {\n const { credential, clientOptions } = options;\n if (!credential) {\n return;\n }\n\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!clientOptions?.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n clientOptions?.credentials?.apiKeyHeaderName,\n );\n pipeline.addPolicy(keyPolicy);\n }\n}\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n endpoint: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): Pipeline {\n const pipeline = createPipelineFromOptions(options);\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });\n return pipeline;\n}\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential).key !== undefined;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n"]}

View File

@ -1,398 +0,0 @@
import type { HttpClient, LogPolicyOptions, Pipeline, PipelineOptions, PipelinePolicy, PipelineRequest, PipelineResponse, RawHttpHeaders, RequestBodyType, TransferProgressEvent } from "@azure/core-rest-pipeline";
import type { RawHttpHeadersInput } from "@azure/core-rest-pipeline";
import type { AbortSignalLike } from "@azure/abort-controller";
import type { OperationTracingOptions } from "@azure/core-tracing";
/**
* Shape of the default request parameters, this may be overridden by the specific
* request types to provide strong types
*/
export type RequestParameters = {
/**
* Headers to send along with the request
*/
headers?: RawHttpHeadersInput;
/**
* Sets the accept header to send to the service
* defaults to 'application/json'. If also a header "accept" is set
* this property will take precedence.
*/
accept?: string;
/**
* Body to send with the request
*/
body?: unknown;
/**
* Query parameters to send with the request
*/
queryParameters?: Record<string, unknown>;
/**
* Set an explicit content-type to send with the request. If also a header "content-type" is set
* this property will take precedence.
*/
contentType?: string;
/** Set to true if the request is sent over HTTP instead of HTTPS */
allowInsecureConnection?: boolean;
/** Set to true if you want to skip encoding the path parameters */
skipUrlEncoding?: boolean;
/**
* Path parameters for custom the base url
*/
pathParameters?: Record<string, any>;
/**
* The number of milliseconds a request can take before automatically being terminated.
*/
timeout?: number;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/**
* Callback which fires upon download progress.
*/
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
/**
* Options used when tracing is enabled.
*/
tracingOptions?: OperationTracingOptions;
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*/
onResponse?: RawResponseCallback;
};
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*
* This callback will be called with two parameters: the raw response, including headers and response body; and an error
* object which will be provided if an error was thrown while processing the request.
* The third __legacyError parameter is provided for backwards compatability only and will have an identical value to the `error` parameter.
*/
export type RawResponseCallback = (rawResponse: FullOperationResponse, error?: unknown, __legacyError?: unknown) => void;
/**
* Wrapper object for http request and response. Deserialized object is stored in
* the `parsedBody` property when the response body is received in JSON.
*/
export interface FullOperationResponse extends PipelineResponse {
/**
* The raw HTTP response headers.
*/
rawHeaders?: RawHttpHeaders;
/**
* The response body as parsed JSON.
*/
parsedBody?: RequestBodyType;
/**
* The request that generated the response.
*/
request: PipelineRequest;
}
/**
* The base options type for all operations.
*/
export interface OperationOptions {
/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
/**
* Options used when creating and sending HTTP requests for this operation.
*/
requestOptions?: OperationRequestOptions;
/**
* Options used when tracing is enabled.
*/
tracingOptions?: OperationTracingOptions;
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*/
onResponse?: RawResponseCallback;
}
/**
* Options used when creating and sending HTTP requests for this operation.
*/
export interface OperationRequestOptions {
/**
* User defined custom request headers that
* will be applied before the request is sent.
*/
headers?: RawHttpHeadersInput;
/**
* The number of milliseconds a request can take before automatically being terminated.
*/
timeout?: number;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/**
* Callback which fires upon download progress.
*/
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* Set to true if the request is sent over HTTP instead of HTTPS
*/
allowInsecureConnection?: boolean;
/**
* Set to true if you want to skip encoding the path parameters
*/
skipUrlEncoding?: boolean;
}
/**
* Type to use with pathUnchecked, overrides the body type to any to allow flexibility
*/
export type PathUncheckedResponse = HttpResponse & {
body: any;
};
/**
* Shape of a Rest Level Client
*/
export interface Client {
/**
* The pipeline used by this client to make requests
*/
pipeline: Pipeline;
/**
* This method will be used to send request that would check the path to provide
* strong types. When used by the codegen this type gets overridden with the generated
* types. For example:
* ```typescript snippet:PathExample
* import { Client } from "@azure-rest/core-client";
*
* type MyClient = Client & {
* path: Routes;
* };
* ```
*/
path: Function;
/**
* This method allows arbitrary paths and doesn't provide strong types
*/
pathUnchecked: PathUnchecked;
}
/**
* A Node.js Readable stream that also has a `destroy` method.
*/
export interface NodeJSReadableStream extends NodeJS.ReadableStream {
/**
* Destroy the stream. Optionally emit an 'error' event, and emit a
* 'close' event (unless emitClose is set to false). After this call,
* internal resources will be released.
*/
destroy(error?: Error): void;
}
/**
* Http Response which body is a NodeJS stream object
*/
export type HttpNodeStreamResponse = HttpResponse & {
/**
* Streamable body
*/
body?: NodeJSReadableStream;
};
/**
* Http Response which body is a NodeJS stream object
*/
export type HttpBrowserStreamResponse = HttpResponse & {
/**
* Streamable body
*/
body?: ReadableStream<Uint8Array>;
};
/**
* Defines the type for a method that supports getting the response body as
* a raw stream
*/
export type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {
/**
* Returns the response body as a NodeJS stream. Only available in Node-like environments.
*/
asNodeStream: () => Promise<HttpNodeStreamResponse>;
/**
* Returns the response body as a browser (Web) stream. Only available in the browser. If you require a Web Stream of the response in Node, consider using the
* `Readable.toWeb` Node API on the result of `asNodeStream`.
*/
asBrowserStream: () => Promise<HttpBrowserStreamResponse>;
};
/**
* Defines the signature for pathUnchecked.
*/
export type PathUnchecked = <TPath extends string>(path: TPath, ...args: PathParameters<TPath>) => ResourceMethods<StreamableMethod>;
/**
* Defines the methods that can be called on a resource
*/
export interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {
/**
* Definition of the GET HTTP method for a resource
*/
get: (options?: RequestParameters) => TResponse;
/**
* Definition of the POST HTTP method for a resource
*/
post: (options?: RequestParameters) => TResponse;
/**
* Definition of the PUT HTTP method for a resource
*/
put: (options?: RequestParameters) => TResponse;
/**
* Definition of the PATCH HTTP method for a resource
*/
patch: (options?: RequestParameters) => TResponse;
/**
* Definition of the DELETE HTTP method for a resource
*/
delete: (options?: RequestParameters) => TResponse;
/**
* Definition of the HEAD HTTP method for a resource
*/
head: (options?: RequestParameters) => TResponse;
/**
* Definition of the OPTIONS HTTP method for a resource
*/
options: (options?: RequestParameters) => TResponse;
/**
* Definition of the TRACE HTTP method for a resource
*/
trace: (options?: RequestParameters) => TResponse;
}
/**
* Used to configure additional policies added to the pipeline at construction.
*/
export interface AdditionalPolicyConfig {
/**
* A policy to be added.
*/
policy: PipelinePolicy;
/**
* Determines if this policy be applied before or after retry logic.
* Only use `perRetry` if you need to modify the request again
* each time the operation is retried due to retryable service
* issues.
*/
position: "perCall" | "perRetry";
}
/**
* General options that a Rest Level Client can take
*/
export type ClientOptions = PipelineOptions & {
/**
* Credentials information
*/
credentials?: {
/**
* Authentication scopes for AAD
*/
scopes?: string[];
/**
* Heder name for Client Secret authentication
*/
apiKeyHeaderName?: string;
};
/**
* Base url for the client
* @deprecated This property is deprecated and will be removed soon, please use endpoint instead
*/
baseUrl?: string;
/**
* Endpoint for the client
*/
endpoint?: string;
/**
* Options for setting a custom apiVersion.
*/
apiVersion?: string;
/**
* Option to allow calling http (insecure) endpoints
*/
allowInsecureConnection?: boolean;
/**
* Additional policies to include in the HTTP pipeline.
*/
additionalPolicies?: AdditionalPolicyConfig[];
/**
* Specify a custom HttpClient when making requests.
*/
httpClient?: HttpClient;
/**
* Options to configure request/response logging.
*/
loggingOptions?: LogPolicyOptions;
};
/**
* Represents the shape of an HttpResponse
*/
export type HttpResponse = {
/**
* The request that generated this response.
*/
request: PipelineRequest;
/**
* The HTTP response headers.
*/
headers: RawHttpHeaders;
/**
* Parsed body
*/
body: unknown;
/**
* The HTTP status code of the response.
*/
status: string;
};
/**
* Helper type used to detect parameters in a path template
* text surrounded by \{\} will be considered a path parameter
*/
export type PathParameters<TRoute extends string> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}` ? [
pathParameter: string | number | PathParameterWithOptions,
...pathParameters: PathParameters<Tail>
] : [
];
/** A response containing error details. */
export interface ErrorResponse {
/** The error object. */
error: ErrorModel;
}
/** The error object. */
export interface ErrorModel {
/** One of a server-defined set of error codes. */
code: string;
/** A human-readable representation of the error. */
message: string;
/** The target of the error. */
target?: string;
/** An array of details about specific errors that led to this reported error. */
details: Array<ErrorModel>;
/** An object containing more specific information than the current object about the error. */
innererror?: InnerError;
}
/** 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. */
export interface InnerError {
/** One of a server-defined set of error codes. */
code: string;
/** Inner error. */
innererror?: InnerError;
}
/**
* An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.
*/
export interface PathParameterWithOptions {
/**
* The value of the parameter.
*/
value: string | number;
/**
* Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.
* Defaults to false.
*/
allowReserved?: boolean;
}
//# sourceMappingURL=common.d.ts.map

View File

@ -1,4 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export {};
//# sourceMappingURL=common.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,16 +0,0 @@
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
import type { Client, ClientOptions } from "./common.js";
/**
* Creates a client with a default pipeline
* @param endpoint - Base endpoint for the client
* @param options - Client options
*/
export declare function getClient(endpoint: string, options?: ClientOptions): Client;
/**
* Creates a client with a default pipeline
* @param endpoint - Base endpoint for the client
* @param credentials - Credentials to authenticate the requests
* @param options - Client options
*/
export declare function getClient(endpoint: string, credentials?: TokenCredential | KeyCredential, options?: ClientOptions): Client;
//# sourceMappingURL=getClient.d.ts.map

View File

@ -1,72 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { isKeyCredential, isTokenCredential } from "@azure/core-auth";
import { createDefaultPipeline } from "./clientHelpers.js";
import { getClient as tspGetClient, } from "@typespec/ts-http-runtime";
/**
* Function to wrap RequestParameters so that we get the legacy onResponse behavior in core-client-rest
*/
function wrapRequestParameters(parameters) {
if (parameters.onResponse) {
return {
...parameters,
onResponse(rawResponse, error) {
parameters.onResponse?.(rawResponse, error, error);
},
};
}
return parameters;
}
export function getClient(endpoint, credentialsOrPipelineOptions, clientOptions = {}) {
let credentials;
if (credentialsOrPipelineOptions) {
if (isCredential(credentialsOrPipelineOptions)) {
credentials = credentialsOrPipelineOptions;
}
else {
clientOptions = credentialsOrPipelineOptions ?? {};
}
}
const pipeline = createDefaultPipeline(endpoint, credentials, clientOptions);
const tspClient = tspGetClient(endpoint, {
...clientOptions,
pipeline,
});
const client = (path, ...args) => {
return {
get: (requestOptions = {}) => {
return tspClient.path(path, ...args).get(wrapRequestParameters(requestOptions));
},
post: (requestOptions = {}) => {
return tspClient.path(path, ...args).post(wrapRequestParameters(requestOptions));
},
put: (requestOptions = {}) => {
return tspClient.path(path, ...args).put(wrapRequestParameters(requestOptions));
},
patch: (requestOptions = {}) => {
return tspClient.path(path, ...args).patch(wrapRequestParameters(requestOptions));
},
delete: (requestOptions = {}) => {
return tspClient.path(path, ...args).delete(wrapRequestParameters(requestOptions));
},
head: (requestOptions = {}) => {
return tspClient.path(path, ...args).head(wrapRequestParameters(requestOptions));
},
options: (requestOptions = {}) => {
return tspClient.path(path, ...args).options(wrapRequestParameters(requestOptions));
},
trace: (requestOptions = {}) => {
return tspClient.path(path, ...args).trace(wrapRequestParameters(requestOptions));
},
};
};
return {
path: client,
pathUnchecked: client,
pipeline: tspClient.pipeline,
};
}
function isCredential(param) {
return isKeyCredential(param) || isTokenCredential(param);
}
//# sourceMappingURL=getClient.js.map

File diff suppressed because one or more lines are too long

View File

@ -1,10 +0,0 @@
/**
* Azure Rest Core Client library for JavaScript
* @packageDocumentation
*/
export { createRestError } from "./restError.js";
export { addCredentialPipelinePolicy, AddCredentialPipelinePolicyOptions, } from "./clientHelpers.js";
export { operationOptionsToRequestParameters } from "./operationOptionHelpers.js";
export * from "./getClient.js";
export * from "./common.js";
//# sourceMappingURL=index.d.ts.map

View File

@ -1,12 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* Azure Rest Core Client library for JavaScript
* @packageDocumentation
*/
export { createRestError } from "./restError.js";
export { addCredentialPipelinePolicy, } from "./clientHelpers.js";
export { operationOptionsToRequestParameters } from "./operationOptionHelpers.js";
export * from "./getClient.js";
export * from "./common.js";
//# sourceMappingURL=index.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EACL,2BAA2B,GAE5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,mCAAmC,EAAE,MAAM,6BAA6B,CAAC;AAClF,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\n/**\n * Azure Rest Core Client library for JavaScript\n * @packageDocumentation\n */\n\nexport { createRestError } from \"./restError.js\";\nexport {\n addCredentialPipelinePolicy,\n AddCredentialPipelinePolicyOptions,\n} from \"./clientHelpers.js\";\nexport { operationOptionsToRequestParameters } from \"./operationOptionHelpers.js\";\nexport * from \"./getClient.js\";\nexport * from \"./common.js\";\n"]}

View File

@ -1,8 +0,0 @@
import type { KeyCredential } from "@azure/core-auth";
import type { PipelinePolicy } from "@azure/core-rest-pipeline";
/**
* The programmatic identifier of the bearerTokenAuthenticationPolicy.
*/
export declare const keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy";
export declare function keyCredentialAuthenticationPolicy(credential: KeyCredential, apiKeyHeaderName: string): PipelinePolicy;
//# sourceMappingURL=keyCredentialAuthenticationPolicy.d.ts.map

View File

@ -1,16 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* The programmatic identifier of the bearerTokenAuthenticationPolicy.
*/
export const keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy";
export function keyCredentialAuthenticationPolicy(credential, apiKeyHeaderName) {
return {
name: keyCredentialAuthenticationPolicyName,
async sendRequest(request, next) {
request.headers.set(apiKeyHeaderName, credential.key);
return next(request);
},
};
}
//# sourceMappingURL=keyCredentialAuthenticationPolicy.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"keyCredentialAuthenticationPolicy.js","sourceRoot":"","sources":["../../src/keyCredentialAuthenticationPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAUlC;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,mCAAmC,CAAC;AAEzF,MAAM,UAAU,iCAAiC,CAC/C,UAAyB,EACzB,gBAAwB;IAExB,OAAO;QACL,IAAI,EAAE,qCAAqC;QAC3C,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC;YACtD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { KeyCredential } from \"@azure/core-auth\";\nimport type {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\n\n/**\n * The programmatic identifier of the bearerTokenAuthenticationPolicy.\n */\nexport const keyCredentialAuthenticationPolicyName = \"keyCredentialAuthenticationPolicy\";\n\nexport function keyCredentialAuthenticationPolicy(\n credential: KeyCredential,\n apiKeyHeaderName: string,\n): PipelinePolicy {\n return {\n name: keyCredentialAuthenticationPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n request.headers.set(apiKeyHeaderName, credential.key);\n return next(request);\n },\n };\n}\n"]}

View File

@ -1,8 +0,0 @@
import type { OperationOptions, RequestParameters } from "./common.js";
/**
* Helper function to convert OperationOptions to RequestParameters
* @param options - the options that are used by Modular layer to send the request
* @returns the result of the conversion in RequestParameters of RLC layer
*/
export declare function operationOptionsToRequestParameters(options: OperationOptions): RequestParameters;
//# sourceMappingURL=operationOptionHelpers.d.ts.map

View File

@ -1,12 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { operationOptionsToRequestParameters as tspOperationOptionsToRequestParameters, } from "@typespec/ts-http-runtime";
/**
* Helper function to convert OperationOptions to RequestParameters
* @param options - the options that are used by Modular layer to send the request
* @returns the result of the conversion in RequestParameters of RLC layer
*/
export function operationOptionsToRequestParameters(options) {
return tspOperationOptionsToRequestParameters(options);
}
//# sourceMappingURL=operationOptionHelpers.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"operationOptionHelpers.js","sourceRoot":"","sources":["../../src/operationOptionHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EACL,mCAAmC,IAAI,sCAAsC,GAE9E,MAAM,2BAA2B,CAAC;AAEnC;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CAAC,OAAyB;IAC3E,OAAO,sCAAsC,CAC3C,OAA8B,CACV,CAAC;AACzB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { OperationOptions, RequestParameters } from \"./common.js\";\n\nimport {\n operationOptionsToRequestParameters as tspOperationOptionsToRequestParameters,\n type OperationOptions as TspOperationOptions,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Helper function to convert OperationOptions to RequestParameters\n * @param options - the options that are used by Modular layer to send the request\n * @returns the result of the conversion in RequestParameters of RLC layer\n */\nexport function operationOptionsToRequestParameters(options: OperationOptions): RequestParameters {\n return tspOperationOptionsToRequestParameters(\n options as TspOperationOptions,\n ) as RequestParameters;\n}\n"]}

View File

@ -1,3 +0,0 @@
{
"type": "module"
}

View File

@ -1,11 +0,0 @@
import type { RestError } from "@azure/core-rest-pipeline";
import type { PathUncheckedResponse } from "./common.js";
/**
* Creates a rest error from a PathUnchecked response
*/
export declare function createRestError(response: PathUncheckedResponse): RestError;
/**
* Creates a rest error from an error message and a PathUnchecked response
*/
export declare function createRestError(message: string, response: PathUncheckedResponse): RestError;
//# sourceMappingURL=restError.d.ts.map

View File

@ -1,12 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { createRestError as tspCreateRestError, } from "@typespec/ts-http-runtime";
export function createRestError(messageOrResponse, response) {
if (typeof messageOrResponse === "string") {
return tspCreateRestError(messageOrResponse, response);
}
else {
return tspCreateRestError(messageOrResponse);
}
}
//# sourceMappingURL=restError.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"restError.js","sourceRoot":"","sources":["../../src/restError.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EACL,eAAe,IAAI,kBAAkB,GAEtC,MAAM,2BAA2B,CAAC;AAUnC,MAAM,UAAU,eAAe,CAC7B,iBAAiD,EACjD,QAAgC;IAEhC,IAAI,OAAO,iBAAiB,KAAK,QAAQ,EAAE,CAAC;QAC1C,OAAO,kBAAkB,CAAC,iBAAiB,EAAE,QAAqC,CAAC,CAAC;IACtF,CAAC;SAAM,CAAC;QACN,OAAO,kBAAkB,CAAC,iBAA6C,CAAC,CAAC;IAC3E,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RestError } from \"@azure/core-rest-pipeline\";\nimport type { PathUncheckedResponse } from \"./common.js\";\n\nimport {\n createRestError as tspCreateRestError,\n type PathUncheckedResponse as TspPathUncheckedResponse,\n} from \"@typespec/ts-http-runtime\";\n\n/**\n * Creates a rest error from a PathUnchecked response\n */\nexport function createRestError(response: PathUncheckedResponse): RestError;\n/**\n * Creates a rest error from an error message and a PathUnchecked response\n */\nexport function createRestError(message: string, response: PathUncheckedResponse): RestError;\nexport function createRestError(\n messageOrResponse: string | PathUncheckedResponse,\n response?: PathUncheckedResponse,\n): RestError {\n if (typeof messageOrResponse === \"string\") {\n return tspCreateRestError(messageOrResponse, response! as TspPathUncheckedResponse);\n } else {\n return tspCreateRestError(messageOrResponse as TspPathUncheckedResponse);\n }\n}\n"]}

View File

@ -1,10 +0,0 @@
import type { PipelinePolicy } from "@azure/core-rest-pipeline";
import type { ClientOptions } from "./common.js";
export declare const apiVersionPolicyName = "ApiVersionPolicy";
/**
* Creates a policy that sets the apiVersion as a query parameter on every request
* @param options - Client options
* @returns Pipeline policy that sets the apiVersion as a query parameter on every request
*/
export declare function apiVersionPolicy(options: ClientOptions): PipelinePolicy;
//# sourceMappingURL=apiVersionPolicy.d.ts.map

View File

@ -1,23 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export const apiVersionPolicyName = "ApiVersionPolicy";
/**
* Creates a policy that sets the apiVersion as a query parameter on every request
* @param options - Client options
* @returns Pipeline policy that sets the apiVersion as a query parameter on every request
*/
export function apiVersionPolicy(options) {
return {
name: apiVersionPolicyName,
sendRequest: (req, next) => {
// Use the apiVesion defined in request url directly
// Append one if there is no apiVesion and we have one at client options
const url = new URL(req.url);
if (!url.searchParams.get("api-version") && options.apiVersion) {
req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${options.apiVersion}`;
}
return next(req);
},
};
}
//# sourceMappingURL=apiVersionPolicy.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"apiVersionPolicy.js","sourceRoot":"","sources":["../../src/apiVersionPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,OAAsB;IACrD,OAAO;QACL,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,oDAAoD;YACpD,wEAAwE;YACxE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBAC/D,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,OAAO,CAAC,UAAU,EAAE,CAAC;YACtC,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport type { ClientOptions } from \"./common.js\";\n\nexport const apiVersionPolicyName = \"ApiVersionPolicy\";\n\n/**\n * Creates a policy that sets the apiVersion as a query parameter on every request\n * @param options - Client options\n * @returns Pipeline policy that sets the apiVersion as a query parameter on every request\n */\nexport function apiVersionPolicy(options: ClientOptions): PipelinePolicy {\n return {\n name: apiVersionPolicyName,\n sendRequest: (req, next) => {\n // Use the apiVesion defined in request url directly\n // Append one if there is no apiVesion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && options.apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${options.apiVersion}`;\n }\n\n return next(req);\n },\n };\n}\n"]}

View File

@ -1,26 +0,0 @@
import type { HttpClient, Pipeline } from "@azure/core-rest-pipeline";
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
import type { ClientOptions } from "./common.js";
/**
* Optional parameters for adding a credential policy to the pipeline.
*/
export interface AddCredentialPipelinePolicyOptions {
/**
* Options related to the client.
*/
clientOptions?: ClientOptions;
/**
* The credential to use.
*/
credential?: TokenCredential | KeyCredential;
}
/**
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
*/
export declare function addCredentialPipelinePolicy(pipeline: Pipeline, endpoint: string, options?: AddCredentialPipelinePolicyOptions): void;
/**
* Creates a default rest pipeline to re-use accross Rest Level Clients
*/
export declare function createDefaultPipeline(endpoint: string, credential?: TokenCredential | KeyCredential, options?: ClientOptions): Pipeline;
export declare function getCachedDefaultHttpsClient(): HttpClient;
//# sourceMappingURL=clientHelpers.d.ts.map

View File

@ -1,49 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
import { bearerTokenAuthenticationPolicy, createDefaultHttpClient, createPipelineFromOptions, } from "@azure/core-rest-pipeline";
import { isTokenCredential } from "@azure/core-auth";
import { apiVersionPolicy } from "./apiVersionPolicy.js";
import { keyCredentialAuthenticationPolicy } from "./keyCredentialAuthenticationPolicy.js";
let cachedHttpClient;
/**
* Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.
*/
export function addCredentialPipelinePolicy(pipeline, endpoint, options = {}) {
const { credential, clientOptions } = options;
if (!credential) {
return;
}
if (isTokenCredential(credential)) {
const tokenPolicy = bearerTokenAuthenticationPolicy({
credential,
scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,
});
pipeline.addPolicy(tokenPolicy);
}
else if (isKeyCredential(credential)) {
if (!clientOptions?.credentials?.apiKeyHeaderName) {
throw new Error(`Missing API Key Header Name`);
}
const keyPolicy = keyCredentialAuthenticationPolicy(credential, clientOptions?.credentials?.apiKeyHeaderName);
pipeline.addPolicy(keyPolicy);
}
}
/**
* Creates a default rest pipeline to re-use accross Rest Level Clients
*/
export function createDefaultPipeline(endpoint, credential, options = {}) {
const pipeline = createPipelineFromOptions(options);
pipeline.addPolicy(apiVersionPolicy(options));
addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });
return pipeline;
}
function isKeyCredential(credential) {
return credential.key !== undefined;
}
export function getCachedDefaultHttpsClient() {
if (!cachedHttpClient) {
cachedHttpClient = createDefaultHttpClient();
}
return cachedHttpClient;
}
//# sourceMappingURL=clientHelpers.js.map

View File

@ -1 +0,0 @@
{"version":3,"file":"clientHelpers.js","sourceRoot":"","sources":["../../src/clientHelpers.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EACL,+BAA+B,EAC/B,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,iCAAiC,EAAE,MAAM,wCAAwC,CAAC;AAE3F,IAAI,gBAAwC,CAAC;AAgB7C;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,QAAkB,EAClB,QAAgB,EAChB,UAA8C,EAAE;IAEhD,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAC9C,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO;IACT,CAAC;IAED,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,+BAA+B,CAAC;YAClD,UAAU;YACV,MAAM,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,IAAI,GAAG,QAAQ,WAAW;SACrE,CAAC,CAAC;QACH,QAAQ,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAClC,CAAC;SAAM,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;QACvC,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,gBAAgB,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACjD,CAAC;QACD,MAAM,SAAS,GAAG,iCAAiC,CACjD,UAAU,EACV,aAAa,EAAE,WAAW,EAAE,gBAAgB,CAC7C,CAAC;QACF,QAAQ,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAAgB,EAChB,UAA4C,EAC5C,UAAyB,EAAE;IAE3B,MAAM,QAAQ,GAAG,yBAAyB,CAAC,OAAO,CAAC,CAAC;IAEpD,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;IAE9C,2BAA2B,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,CAAC;IACxF,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,eAAe,CAAC,UAAe;IACtC,OAAQ,UAA4B,CAAC,GAAG,KAAK,SAAS,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,2BAA2B;IACzC,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,gBAAgB,GAAG,uBAAuB,EAAE,CAAC;IAC/C,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { HttpClient, Pipeline } from \"@azure/core-rest-pipeline\";\nimport {\n bearerTokenAuthenticationPolicy,\n createDefaultHttpClient,\n createPipelineFromOptions,\n} from \"@azure/core-rest-pipeline\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isTokenCredential } from \"@azure/core-auth\";\n\nimport type { ClientOptions } from \"./common.js\";\nimport { apiVersionPolicy } from \"./apiVersionPolicy.js\";\nimport { keyCredentialAuthenticationPolicy } from \"./keyCredentialAuthenticationPolicy.js\";\n\nlet cachedHttpClient: HttpClient | undefined;\n\n/**\n * Optional parameters for adding a credential policy to the pipeline.\n */\nexport interface AddCredentialPipelinePolicyOptions {\n /**\n * Options related to the client.\n */\n clientOptions?: ClientOptions;\n /**\n * The credential to use.\n */\n credential?: TokenCredential | KeyCredential;\n}\n\n/**\n * Adds a credential policy to the pipeline if a credential is provided. If none is provided, no policy is added.\n */\nexport function addCredentialPipelinePolicy(\n pipeline: Pipeline,\n endpoint: string,\n options: AddCredentialPipelinePolicyOptions = {},\n): void {\n const { credential, clientOptions } = options;\n if (!credential) {\n return;\n }\n\n if (isTokenCredential(credential)) {\n const tokenPolicy = bearerTokenAuthenticationPolicy({\n credential,\n scopes: clientOptions?.credentials?.scopes ?? `${endpoint}/.default`,\n });\n pipeline.addPolicy(tokenPolicy);\n } else if (isKeyCredential(credential)) {\n if (!clientOptions?.credentials?.apiKeyHeaderName) {\n throw new Error(`Missing API Key Header Name`);\n }\n const keyPolicy = keyCredentialAuthenticationPolicy(\n credential,\n clientOptions?.credentials?.apiKeyHeaderName,\n );\n pipeline.addPolicy(keyPolicy);\n }\n}\n\n/**\n * Creates a default rest pipeline to re-use accross Rest Level Clients\n */\nexport function createDefaultPipeline(\n endpoint: string,\n credential?: TokenCredential | KeyCredential,\n options: ClientOptions = {},\n): Pipeline {\n const pipeline = createPipelineFromOptions(options);\n\n pipeline.addPolicy(apiVersionPolicy(options));\n\n addCredentialPipelinePolicy(pipeline, endpoint, { credential, clientOptions: options });\n return pipeline;\n}\n\nfunction isKeyCredential(credential: any): credential is KeyCredential {\n return (credential as KeyCredential).key !== undefined;\n}\n\nexport function getCachedDefaultHttpsClient(): HttpClient {\n if (!cachedHttpClient) {\n cachedHttpClient = createDefaultHttpClient();\n }\n\n return cachedHttpClient;\n}\n"]}

View File

@ -1,398 +0,0 @@
import type { HttpClient, LogPolicyOptions, Pipeline, PipelineOptions, PipelinePolicy, PipelineRequest, PipelineResponse, RawHttpHeaders, RequestBodyType, TransferProgressEvent } from "@azure/core-rest-pipeline";
import type { RawHttpHeadersInput } from "@azure/core-rest-pipeline";
import type { AbortSignalLike } from "@azure/abort-controller";
import type { OperationTracingOptions } from "@azure/core-tracing";
/**
* Shape of the default request parameters, this may be overridden by the specific
* request types to provide strong types
*/
export type RequestParameters = {
/**
* Headers to send along with the request
*/
headers?: RawHttpHeadersInput;
/**
* Sets the accept header to send to the service
* defaults to 'application/json'. If also a header "accept" is set
* this property will take precedence.
*/
accept?: string;
/**
* Body to send with the request
*/
body?: unknown;
/**
* Query parameters to send with the request
*/
queryParameters?: Record<string, unknown>;
/**
* Set an explicit content-type to send with the request. If also a header "content-type" is set
* this property will take precedence.
*/
contentType?: string;
/** Set to true if the request is sent over HTTP instead of HTTPS */
allowInsecureConnection?: boolean;
/** Set to true if you want to skip encoding the path parameters */
skipUrlEncoding?: boolean;
/**
* Path parameters for custom the base url
*/
pathParameters?: Record<string, any>;
/**
* The number of milliseconds a request can take before automatically being terminated.
*/
timeout?: number;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/**
* Callback which fires upon download progress.
*/
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
/**
* Options used when tracing is enabled.
*/
tracingOptions?: OperationTracingOptions;
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*/
onResponse?: RawResponseCallback;
};
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*
* This callback will be called with two parameters: the raw response, including headers and response body; and an error
* object which will be provided if an error was thrown while processing the request.
* The third __legacyError parameter is provided for backwards compatability only and will have an identical value to the `error` parameter.
*/
export type RawResponseCallback = (rawResponse: FullOperationResponse, error?: unknown, __legacyError?: unknown) => void;
/**
* Wrapper object for http request and response. Deserialized object is stored in
* the `parsedBody` property when the response body is received in JSON.
*/
export interface FullOperationResponse extends PipelineResponse {
/**
* The raw HTTP response headers.
*/
rawHeaders?: RawHttpHeaders;
/**
* The response body as parsed JSON.
*/
parsedBody?: RequestBodyType;
/**
* The request that generated the response.
*/
request: PipelineRequest;
}
/**
* The base options type for all operations.
*/
export interface OperationOptions {
/**
* The signal which can be used to abort requests.
*/
abortSignal?: AbortSignalLike;
/**
* Options used when creating and sending HTTP requests for this operation.
*/
requestOptions?: OperationRequestOptions;
/**
* Options used when tracing is enabled.
*/
tracingOptions?: OperationTracingOptions;
/**
* A function to be called each time a response is received from the server
* while performing the requested operation.
* May be called multiple times.
*/
onResponse?: RawResponseCallback;
}
/**
* Options used when creating and sending HTTP requests for this operation.
*/
export interface OperationRequestOptions {
/**
* User defined custom request headers that
* will be applied before the request is sent.
*/
headers?: RawHttpHeadersInput;
/**
* The number of milliseconds a request can take before automatically being terminated.
*/
timeout?: number;
/**
* Callback which fires upon upload progress.
*/
onUploadProgress?: (progress: TransferProgressEvent) => void;
/**
* Callback which fires upon download progress.
*/
onDownloadProgress?: (progress: TransferProgressEvent) => void;
/**
* Set to true if the request is sent over HTTP instead of HTTPS
*/
allowInsecureConnection?: boolean;
/**
* Set to true if you want to skip encoding the path parameters
*/
skipUrlEncoding?: boolean;
}
/**
* Type to use with pathUnchecked, overrides the body type to any to allow flexibility
*/
export type PathUncheckedResponse = HttpResponse & {
body: any;
};
/**
* Shape of a Rest Level Client
*/
export interface Client {
/**
* The pipeline used by this client to make requests
*/
pipeline: Pipeline;
/**
* This method will be used to send request that would check the path to provide
* strong types. When used by the codegen this type gets overridden with the generated
* types. For example:
* ```typescript snippet:PathExample
* import { Client } from "@azure-rest/core-client";
*
* type MyClient = Client & {
* path: Routes;
* };
* ```
*/
path: Function;
/**
* This method allows arbitrary paths and doesn't provide strong types
*/
pathUnchecked: PathUnchecked;
}
/**
* A Node.js Readable stream that also has a `destroy` method.
*/
export interface NodeJSReadableStream extends NodeJS.ReadableStream {
/**
* Destroy the stream. Optionally emit an 'error' event, and emit a
* 'close' event (unless emitClose is set to false). After this call,
* internal resources will be released.
*/
destroy(error?: Error): void;
}
/**
* Http Response which body is a NodeJS stream object
*/
export type HttpNodeStreamResponse = HttpResponse & {
/**
* Streamable body
*/
body?: NodeJSReadableStream;
};
/**
* Http Response which body is a NodeJS stream object
*/
export type HttpBrowserStreamResponse = HttpResponse & {
/**
* Streamable body
*/
body?: ReadableStream<Uint8Array>;
};
/**
* Defines the type for a method that supports getting the response body as
* a raw stream
*/
export type StreamableMethod<TResponse = PathUncheckedResponse> = PromiseLike<TResponse> & {
/**
* Returns the response body as a NodeJS stream. Only available in Node-like environments.
*/
asNodeStream: () => Promise<HttpNodeStreamResponse>;
/**
* Returns the response body as a browser (Web) stream. Only available in the browser. If you require a Web Stream of the response in Node, consider using the
* `Readable.toWeb` Node API on the result of `asNodeStream`.
*/
asBrowserStream: () => Promise<HttpBrowserStreamResponse>;
};
/**
* Defines the signature for pathUnchecked.
*/
export type PathUnchecked = <TPath extends string>(path: TPath, ...args: PathParameters<TPath>) => ResourceMethods<StreamableMethod>;
/**
* Defines the methods that can be called on a resource
*/
export interface ResourceMethods<TResponse = PromiseLike<PathUncheckedResponse>> {
/**
* Definition of the GET HTTP method for a resource
*/
get: (options?: RequestParameters) => TResponse;
/**
* Definition of the POST HTTP method for a resource
*/
post: (options?: RequestParameters) => TResponse;
/**
* Definition of the PUT HTTP method for a resource
*/
put: (options?: RequestParameters) => TResponse;
/**
* Definition of the PATCH HTTP method for a resource
*/
patch: (options?: RequestParameters) => TResponse;
/**
* Definition of the DELETE HTTP method for a resource
*/
delete: (options?: RequestParameters) => TResponse;
/**
* Definition of the HEAD HTTP method for a resource
*/
head: (options?: RequestParameters) => TResponse;
/**
* Definition of the OPTIONS HTTP method for a resource
*/
options: (options?: RequestParameters) => TResponse;
/**
* Definition of the TRACE HTTP method for a resource
*/
trace: (options?: RequestParameters) => TResponse;
}
/**
* Used to configure additional policies added to the pipeline at construction.
*/
export interface AdditionalPolicyConfig {
/**
* A policy to be added.
*/
policy: PipelinePolicy;
/**
* Determines if this policy be applied before or after retry logic.
* Only use `perRetry` if you need to modify the request again
* each time the operation is retried due to retryable service
* issues.
*/
position: "perCall" | "perRetry";
}
/**
* General options that a Rest Level Client can take
*/
export type ClientOptions = PipelineOptions & {
/**
* Credentials information
*/
credentials?: {
/**
* Authentication scopes for AAD
*/
scopes?: string[];
/**
* Heder name for Client Secret authentication
*/
apiKeyHeaderName?: string;
};
/**
* Base url for the client
* @deprecated This property is deprecated and will be removed soon, please use endpoint instead
*/
baseUrl?: string;
/**
* Endpoint for the client
*/
endpoint?: string;
/**
* Options for setting a custom apiVersion.
*/
apiVersion?: string;
/**
* Option to allow calling http (insecure) endpoints
*/
allowInsecureConnection?: boolean;
/**
* Additional policies to include in the HTTP pipeline.
*/
additionalPolicies?: AdditionalPolicyConfig[];
/**
* Specify a custom HttpClient when making requests.
*/
httpClient?: HttpClient;
/**
* Options to configure request/response logging.
*/
loggingOptions?: LogPolicyOptions;
};
/**
* Represents the shape of an HttpResponse
*/
export type HttpResponse = {
/**
* The request that generated this response.
*/
request: PipelineRequest;
/**
* The HTTP response headers.
*/
headers: RawHttpHeaders;
/**
* Parsed body
*/
body: unknown;
/**
* The HTTP status code of the response.
*/
status: string;
};
/**
* Helper type used to detect parameters in a path template
* text surrounded by \{\} will be considered a path parameter
*/
export type PathParameters<TRoute extends string> = TRoute extends `${infer _Head}/{${infer _Param}}${infer Tail}` ? [
pathParameter: string | number | PathParameterWithOptions,
...pathParameters: PathParameters<Tail>
] : [
];
/** A response containing error details. */
export interface ErrorResponse {
/** The error object. */
error: ErrorModel;
}
/** The error object. */
export interface ErrorModel {
/** One of a server-defined set of error codes. */
code: string;
/** A human-readable representation of the error. */
message: string;
/** The target of the error. */
target?: string;
/** An array of details about specific errors that led to this reported error. */
details: Array<ErrorModel>;
/** An object containing more specific information than the current object about the error. */
innererror?: InnerError;
}
/** 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. */
export interface InnerError {
/** One of a server-defined set of error codes. */
code: string;
/** Inner error. */
innererror?: InnerError;
}
/**
* An object that can be passed as a path parameter, allowing for additional options to be set relating to how the parameter is encoded.
*/
export interface PathParameterWithOptions {
/**
* The value of the parameter.
*/
value: string | number;
/**
* Whether to allow for reserved characters in the value. If set to true, special characters such as '/' in the parameter's value will not be URL encoded.
* Defaults to false.
*/
allowReserved?: boolean;
}
//# sourceMappingURL=common.d.ts.map

View File

@ -1,4 +0,0 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
export {};
//# sourceMappingURL=common.js.map

Some files were not shown because too many files have changed in this diff Show More