@azure/template-dpg 1.0.0-alpha.20230530.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/README.md +107 -0
- package/dist/index.cjs +363 -0
- package/dist/index.cjs.map +1 -0
- package/dist-esm/src/WidgetServiceClient.js +58 -0
- package/dist-esm/src/WidgetServiceClient.js.map +1 -0
- package/dist-esm/src/api/WidgetServiceContext.js +14 -0
- package/dist-esm/src/api/WidgetServiceContext.js.map +1 -0
- package/dist-esm/src/api/foo.js +13 -0
- package/dist-esm/src/api/foo.js.map +1 -0
- package/dist-esm/src/api/index.js +5 -0
- package/dist-esm/src/api/index.js.map +1 -0
- package/dist-esm/src/api/models.js +4 -0
- package/dist-esm/src/api/models.js.map +1 -0
- package/dist-esm/src/api/operations.js +171 -0
- package/dist-esm/src/api/operations.js.map +1 -0
- package/dist-esm/src/common/interfaces.js +4 -0
- package/dist-esm/src/common/interfaces.js.map +1 -0
- package/dist-esm/src/index.js +4 -0
- package/dist-esm/src/index.js.map +1 -0
- package/dist-esm/src/logger.js +12 -0
- package/dist-esm/src/logger.js.map +1 -0
- package/dist-esm/src/rest/clientDefinitions.js +4 -0
- package/dist-esm/src/rest/clientDefinitions.js.map +1 -0
- package/dist-esm/src/rest/index.js +19 -0
- package/dist-esm/src/rest/index.js.map +1 -0
- package/dist-esm/src/rest/isUnexpected.js +75 -0
- package/dist-esm/src/rest/isUnexpected.js.map +1 -0
- package/dist-esm/src/rest/models.js +4 -0
- package/dist-esm/src/rest/models.js.map +1 -0
- package/dist-esm/src/rest/outputModels.js +4 -0
- package/dist-esm/src/rest/outputModels.js.map +1 -0
- package/dist-esm/src/rest/parameters.js +4 -0
- package/dist-esm/src/rest/parameters.js.map +1 -0
- package/dist-esm/src/rest/responses.js +4 -0
- package/dist-esm/src/rest/responses.js.map +1 -0
- package/dist-esm/src/rest/widgetServiceClient.js +46 -0
- package/dist-esm/src/rest/widgetServiceClient.js.map +1 -0
- package/package.json +123 -0
- package/types/latest/template-dpg.d.ts +101 -0
- package/types/latest/tsdoc-metadata.json +11 -0
- package/types/samples-dev/createWidget.d.ts +2 -0
- package/types/samples-dev/createWidget.d.ts.map +1 -0
- package/types/src/WidgetServiceClient.d.ts +41 -0
- package/types/src/WidgetServiceClient.d.ts.map +1 -0
- package/types/src/api/WidgetServiceContext.d.ts +19 -0
- package/types/src/api/WidgetServiceContext.d.ts.map +1 -0
- package/types/src/api/foo.d.ts +9 -0
- package/types/src/api/foo.d.ts.map +1 -0
- package/types/src/api/index.d.ts +11 -0
- package/types/src/api/index.d.ts.map +1 -0
- package/types/src/api/models.d.ts +25 -0
- package/types/src/api/models.d.ts.map +1 -0
- package/types/src/api/operations.d.ts +67 -0
- package/types/src/api/operations.d.ts.map +1 -0
- package/types/src/common/interfaces.d.ts +21 -0
- package/types/src/common/interfaces.d.ts.map +1 -0
- package/types/src/index.d.ts +12 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/logger.d.ts +2 -0
- package/types/src/logger.d.ts.map +1 -0
- package/types/src/rest/clientDefinitions.d.ts +52 -0
- package/types/src/rest/clientDefinitions.d.ts.map +1 -0
- package/types/src/rest/index.d.ts +17 -0
- package/types/src/rest/index.d.ts.map +1 -0
- package/types/src/rest/isUnexpected.d.ts +15 -0
- package/types/src/rest/isUnexpected.d.ts.map +1 -0
- package/types/src/rest/models.d.ts +20 -0
- package/types/src/rest/models.d.ts.map +1 -0
- package/types/src/rest/outputModels.d.ts +25 -0
- package/types/src/rest/outputModels.d.ts.map +1 -0
- package/types/src/rest/parameters.d.ts +22 -0
- package/types/src/rest/parameters.d.ts.map +1 -0
- package/types/src/rest/responses.d.ts +63 -0
- package/types/src/rest/responses.d.ts.map +1 -0
- package/types/src/rest/widgetServiceClient.d.ts +16 -0
- package/types/src/rest/widgetServiceClient.d.ts.map +1 -0
- package/types/test/public/widgetService.spec.d.ts +2 -0
- package/types/test/public/widgetService.spec.d.ts.map +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Microsoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# Azure Template client library for JavaScript
|
|
2
|
+
|
|
3
|
+
<!-- NOTE: This README file is a template. Read through it and replace the instructions (keeping an eye out for package names like "@azure/template") with the ones that pertain to your package. For a complete example based on the real Azure App Configuration SDK, see README-TEMPLATE.md in this directory. -->
|
|
4
|
+
|
|
5
|
+
This project is used as a template package for the Azure SDK for JavaScript. It is intended to help Azure SDK developers bootstrap new packages, and it provides an example of how to organize the code and documentation of a client library for an Azure service.
|
|
6
|
+
|
|
7
|
+
## Getting started
|
|
8
|
+
|
|
9
|
+
### Currently supported environments
|
|
10
|
+
|
|
11
|
+
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule)
|
|
12
|
+
- Latest versions of Safari, Chrome, Edge, and Firefox.
|
|
13
|
+
|
|
14
|
+
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details.
|
|
15
|
+
|
|
16
|
+
### Prerequisites
|
|
17
|
+
|
|
18
|
+
- An [Azure subscription][azure_sub].
|
|
19
|
+
|
|
20
|
+
Usually you'd put a shell command for provisioning the necessary Azure services here.
|
|
21
|
+
|
|
22
|
+
### Install the `@azure/template` package
|
|
23
|
+
|
|
24
|
+
Install the Template client library for JavaScript with `npm`:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install @azure/template
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Browser support
|
|
31
|
+
|
|
32
|
+
#### JavaScript Bundle
|
|
33
|
+
|
|
34
|
+
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling).
|
|
35
|
+
|
|
36
|
+
#### CORS
|
|
37
|
+
|
|
38
|
+
<!--
|
|
39
|
+
|
|
40
|
+
NOTE: if your service supports CORS natively please provide instructions for enabling CORS at the service level (similar to the sample below), otherwise replace this section with guidance such as:
|
|
41
|
+
|
|
42
|
+
Due to Azure template service CORS limitation this library cannot be used to make direct calls to the template service from a browser. Please refer to [this document](https://github.com/Azure/azure-sdk-for-js/blob/main/samples/cors/ts/README.md) for guidance.
|
|
43
|
+
|
|
44
|
+
-->
|
|
45
|
+
|
|
46
|
+
You need to set up [Cross-Origin Resource Sharing (CORS)](https://docs.microsoft.com/rest/api/storageservices/cross-origin-resource-sharing--cors--support-for-the-azure-storage-services) rules for your storage account if you need to develop for browsers. Go to Azure portal and Azure Storage Explorer, find your storage account, create new CORS rules for blob/queue/file/table service(s).
|
|
47
|
+
|
|
48
|
+
For example, you can create the following CORS settings for debugging. But please customize the settings carefully according to your requirements in a production environment.
|
|
49
|
+
|
|
50
|
+
- Allowed origins: \*
|
|
51
|
+
- Allowed verbs: DELETE,GET,HEAD,MERGE,POST,OPTIONS,PUT
|
|
52
|
+
- Allowed headers: \*
|
|
53
|
+
- Exposed headers: \*
|
|
54
|
+
- Maximum age (seconds): 86400
|
|
55
|
+
|
|
56
|
+
### Further examples
|
|
57
|
+
|
|
58
|
+
Top-level examples usually include things like creating and authenticating the main Client. If your service supports multiple means of authenticating (e.g. key-based and Azure Active Directory) you can give a separate example of each.
|
|
59
|
+
|
|
60
|
+
## Key concepts
|
|
61
|
+
|
|
62
|
+
### ConfigurationClient
|
|
63
|
+
|
|
64
|
+
Describe your primary client here. Talk about what operations it can do and when a developer would want to use it.
|
|
65
|
+
|
|
66
|
+
### Additional Examples
|
|
67
|
+
|
|
68
|
+
Create a section for each top-level service concept you want to explain.
|
|
69
|
+
|
|
70
|
+
## Examples
|
|
71
|
+
|
|
72
|
+
### First Example
|
|
73
|
+
|
|
74
|
+
<!-- Examples should showcase the primary, or "champion" scenarios of the client SDK. -->
|
|
75
|
+
|
|
76
|
+
Create several code examples for how someone would use your library to accomplish a common task with the service.
|
|
77
|
+
|
|
78
|
+
## Troubleshooting
|
|
79
|
+
|
|
80
|
+
### Logging
|
|
81
|
+
|
|
82
|
+
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment variable to `info`. Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
const { setLogLevel } = require("@azure/logger");
|
|
86
|
+
|
|
87
|
+
setLogLevel("info");
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
|
|
91
|
+
|
|
92
|
+
## Next steps
|
|
93
|
+
|
|
94
|
+
Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/template/template/samples) directory for detailed examples that demonstrate how to use the client libraries.
|
|
95
|
+
|
|
96
|
+
## Contributing
|
|
97
|
+
|
|
98
|
+
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.
|
|
99
|
+
|
|
100
|
+
## Related projects
|
|
101
|
+
|
|
102
|
+
- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)
|
|
103
|
+
|
|
104
|
+

|
|
105
|
+
|
|
106
|
+
[azure_cli]: https://docs.microsoft.com/cli/azure
|
|
107
|
+
[azure_sub]: https://azure.microsoft.com/free/
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var coreAuth = require('@azure/core-auth');
|
|
6
|
+
var coreClient = require('@azure-rest/core-client');
|
|
7
|
+
var logger$1 = require('@azure/logger');
|
|
8
|
+
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
9
|
+
|
|
10
|
+
// Copyright (c) Microsoft Corporation.
|
|
11
|
+
const logger = logger$1.createClientLogger("widget");
|
|
12
|
+
|
|
13
|
+
// Copyright (c) Microsoft Corporation.
|
|
14
|
+
function createClient(endpoint, credentialOrOptions, options = {}) {
|
|
15
|
+
let credential;
|
|
16
|
+
if (coreAuth.isTokenCredential(credentialOrOptions)) {
|
|
17
|
+
credential = credentialOrOptions;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
options = credentialOrOptions !== null && credentialOrOptions !== void 0 ? credentialOrOptions : {};
|
|
21
|
+
}
|
|
22
|
+
const client = _createClient(endpoint, options);
|
|
23
|
+
coreClient.addCredentialPipelinePolicy(client.pipeline, endpoint, { credential, clientOptions: options });
|
|
24
|
+
return client;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Initialize a new instance of `WidgetServiceContext`
|
|
28
|
+
* @param endpoint - The parameter endpoint
|
|
29
|
+
* @param options - the parameter for all optional parameters
|
|
30
|
+
*/
|
|
31
|
+
function _createClient(endpoint, options = {}) {
|
|
32
|
+
var _a, _b, _c, _d;
|
|
33
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${endpoint}`;
|
|
34
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "1.0.0";
|
|
35
|
+
const userAgentInfo = `azsdk-js-widget-rest/1.0.0-beta.1`;
|
|
36
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
37
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
38
|
+
: `${userAgentInfo}`;
|
|
39
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
40
|
+
userAgentPrefix,
|
|
41
|
+
}, loggingOptions: {
|
|
42
|
+
logger: (_d = (_c = options.loggingOptions) === null || _c === void 0 ? void 0 : _c.logger) !== null && _d !== void 0 ? _d : logger.info,
|
|
43
|
+
} });
|
|
44
|
+
const client = coreClient.getClient(baseUrl, options);
|
|
45
|
+
return client;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Copyright (c) Microsoft Corporation.
|
|
49
|
+
// Licensed under the MIT license.
|
|
50
|
+
const responseMap = {
|
|
51
|
+
"GET /widgets": ["200"],
|
|
52
|
+
"POST /widgets": ["201"],
|
|
53
|
+
"GET /widgets/{id}": ["200"],
|
|
54
|
+
"PATCH /widgets/{id}": ["200"],
|
|
55
|
+
"DELETE /widgets/{id}": ["204"],
|
|
56
|
+
"POST /widgets/{id}/analyze": ["200"],
|
|
57
|
+
};
|
|
58
|
+
function isUnexpected(response) {
|
|
59
|
+
const lroOriginal = response.headers["x-ms-original-url"];
|
|
60
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
61
|
+
const method = response.request.method;
|
|
62
|
+
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
63
|
+
if (!pathDetails) {
|
|
64
|
+
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
65
|
+
}
|
|
66
|
+
return !pathDetails.includes(response.status);
|
|
67
|
+
}
|
|
68
|
+
function getParametrizedPathSuccess(method, path) {
|
|
69
|
+
var _a, _b, _c, _d;
|
|
70
|
+
const pathParts = path.split("/");
|
|
71
|
+
// Traverse list to match the longest candidate
|
|
72
|
+
// matchedLen: the length of candidate path
|
|
73
|
+
// matchedValue: the matched status code array
|
|
74
|
+
let matchedLen = -1, matchedValue = [];
|
|
75
|
+
// Iterate the responseMap to find a match
|
|
76
|
+
for (const [key, value] of Object.entries(responseMap)) {
|
|
77
|
+
// Extracting the path from the map key which is in format
|
|
78
|
+
// GET /path/foo
|
|
79
|
+
if (!key.startsWith(method)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
const candidatePath = getPathFromMapKey(key);
|
|
83
|
+
// Get each part of the url path
|
|
84
|
+
const candidateParts = candidatePath.split("/");
|
|
85
|
+
// track if we have found a match to return the values found.
|
|
86
|
+
let found = true;
|
|
87
|
+
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
88
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
89
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
90
|
+
// If the current part of the candidate is a "template" part
|
|
91
|
+
// Try to use the suffix of pattern to match the path
|
|
92
|
+
// {guid} ==> $
|
|
93
|
+
// {guid}:export ==> :export$
|
|
94
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
95
|
+
if (!isMatched) {
|
|
96
|
+
found = false;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
// If the candidate part is not a template and
|
|
102
|
+
// the parts don't match mark the candidate as not found
|
|
103
|
+
// to move on with the next candidate path.
|
|
104
|
+
if (candidateParts[i] !== pathParts[j]) {
|
|
105
|
+
found = false;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
// We finished evaluating the current candidate parts
|
|
110
|
+
// Update the matched value if and only if we found the longer pattern
|
|
111
|
+
if (found && candidatePath.length > matchedLen) {
|
|
112
|
+
matchedLen = candidatePath.length;
|
|
113
|
+
matchedValue = value;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return matchedValue;
|
|
117
|
+
}
|
|
118
|
+
function getPathFromMapKey(mapKey) {
|
|
119
|
+
const pathStart = mapKey.indexOf("/");
|
|
120
|
+
return mapKey.slice(pathStart);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Copyright (c) Microsoft Corporation.
|
|
124
|
+
// Licensed under the MIT license.
|
|
125
|
+
/**
|
|
126
|
+
* THIS IS AN AUTO-GENERATED FILE - DO NOT EDIT!
|
|
127
|
+
*
|
|
128
|
+
* Any changes you make here may be lost.
|
|
129
|
+
*
|
|
130
|
+
* If you need to make changes, please do so in the original source file, \{project-root\}/sources/custom
|
|
131
|
+
*/
|
|
132
|
+
function foo() {
|
|
133
|
+
console.log("foo");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Copyright (c) Microsoft Corporation.
|
|
137
|
+
function _listWidgetsSend(context, options = { requestOptions: {} }) {
|
|
138
|
+
var _a, _b, _c;
|
|
139
|
+
return context.path("/widgets").get({
|
|
140
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
|
141
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
|
142
|
+
headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
async function _listWidgetsDeserialize(result) {
|
|
146
|
+
var _a;
|
|
147
|
+
if (isUnexpected(result)) {
|
|
148
|
+
throw result.body;
|
|
149
|
+
}
|
|
150
|
+
return ((_a = result.body) !== null && _a !== void 0 ? _a : []).map((p) => ({
|
|
151
|
+
id: p["id"],
|
|
152
|
+
weight: p["weight"],
|
|
153
|
+
color: p["color"],
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* List all widgets in the system. This operation is not paginated, and returns a simple array of widgets.
|
|
158
|
+
*
|
|
159
|
+
* It does not accept any options or parameters.
|
|
160
|
+
*/
|
|
161
|
+
async function listWidgets(context, options = { requestOptions: {} }) {
|
|
162
|
+
const result = await _listWidgetsSend(context, options);
|
|
163
|
+
return _listWidgetsDeserialize(result);
|
|
164
|
+
}
|
|
165
|
+
function _getWidgetSend(context, id, options = { requestOptions: {} }) {
|
|
166
|
+
var _a, _b, _c;
|
|
167
|
+
return context.path("/widgets/{id}", id).get({
|
|
168
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
|
169
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
|
170
|
+
headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
async function _getWidgetDeserialize(result) {
|
|
174
|
+
if (isUnexpected(result)) {
|
|
175
|
+
throw result.body;
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
id: result.body["id"],
|
|
179
|
+
weight: result.body["weight"],
|
|
180
|
+
color: result.body["color"],
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
/** Get a widget by ID. */
|
|
184
|
+
async function getWidget(context, id, options = { requestOptions: {} }) {
|
|
185
|
+
const result = await _getWidgetSend(context, id, options);
|
|
186
|
+
return _getWidgetDeserialize(result);
|
|
187
|
+
}
|
|
188
|
+
function _createWidgetSend(context, weight, color, options = { requestOptions: {} }) {
|
|
189
|
+
var _a, _b, _c;
|
|
190
|
+
return context.path("/widgets").post({
|
|
191
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
|
192
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
|
193
|
+
headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
|
|
194
|
+
body: { weight: weight, color: color },
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
async function _createWidgetDeserialize(result) {
|
|
198
|
+
if (isUnexpected(result)) {
|
|
199
|
+
throw result.body;
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
id: result.body["id"],
|
|
203
|
+
weight: result.body["weight"],
|
|
204
|
+
color: result.body["color"],
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Create a new widget.
|
|
209
|
+
*
|
|
210
|
+
* The widget ID is not required during creation, as it is automatically set by the server. Providing an ID will
|
|
211
|
+
* result in an error.
|
|
212
|
+
*/
|
|
213
|
+
async function createWidget(context, weight, color, options = { requestOptions: {} }) {
|
|
214
|
+
const result = await _createWidgetSend(context, weight, color, options);
|
|
215
|
+
return _createWidgetDeserialize(result);
|
|
216
|
+
}
|
|
217
|
+
function _updateWidgetSend(context, id, options = { requestOptions: {} }) {
|
|
218
|
+
var _a, _b, _c;
|
|
219
|
+
return context.path("/widgets/{id}", id).patch({
|
|
220
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
|
221
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
|
222
|
+
headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
|
|
223
|
+
body: { weight: options === null || options === void 0 ? void 0 : options.weight, color: options === null || options === void 0 ? void 0 : options.color },
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
async function _updateWidgetDeserialize(result) {
|
|
227
|
+
if (isUnexpected(result)) {
|
|
228
|
+
throw result.body;
|
|
229
|
+
}
|
|
230
|
+
return {
|
|
231
|
+
id: result.body["id"],
|
|
232
|
+
weight: result.body["weight"],
|
|
233
|
+
color: result.body["color"],
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Update the contents of the widget. The widget ID is required in the input, but cannot be changed. All other fields
|
|
238
|
+
* are optional and will be updated within the widget if provided.
|
|
239
|
+
*/
|
|
240
|
+
async function updateWidget(context, id, options = { requestOptions: {} }) {
|
|
241
|
+
const result = await _updateWidgetSend(context, id, options);
|
|
242
|
+
return _updateWidgetDeserialize(result);
|
|
243
|
+
}
|
|
244
|
+
function _deleteWidgetSend(context, id, options = { requestOptions: {} }) {
|
|
245
|
+
var _a, _b, _c;
|
|
246
|
+
return context.path("/widgets/{id}", id).delete({
|
|
247
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
|
248
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
|
249
|
+
headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
async function _deleteWidgetDeserialize(result) {
|
|
253
|
+
if (isUnexpected(result)) {
|
|
254
|
+
throw result.body;
|
|
255
|
+
}
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
/** Delete a widget by ID. */
|
|
259
|
+
async function deleteWidget(context, id, options = { requestOptions: {} }) {
|
|
260
|
+
const result = await _deleteWidgetSend(context, id, options);
|
|
261
|
+
return _deleteWidgetDeserialize(result);
|
|
262
|
+
}
|
|
263
|
+
function _analyzeWidgetSend(context, id, options = { requestOptions: {} }) {
|
|
264
|
+
var _a, _b, _c;
|
|
265
|
+
return context.path("/widgets/{id}/analyze", id).post({
|
|
266
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
|
267
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
|
268
|
+
headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
async function _analyzeWidgetDeserialize(result) {
|
|
272
|
+
if (isUnexpected(result)) {
|
|
273
|
+
throw result.body;
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
summary: result.body["summary"],
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* In this customization we will perform the following tasks in addition to the generated:
|
|
281
|
+
* - We are going to add special error handling for demonstration purposes
|
|
282
|
+
*/
|
|
283
|
+
async function analyzeWidget(context, id, options) {
|
|
284
|
+
try {
|
|
285
|
+
foo();
|
|
286
|
+
const result = await _analyzeWidget(context, id, options);
|
|
287
|
+
return result;
|
|
288
|
+
}
|
|
289
|
+
catch (error) {
|
|
290
|
+
console.error("Error occurred while calling analyzeWidget:", error);
|
|
291
|
+
if (error.message && error.statusCode) {
|
|
292
|
+
throw new coreRestPipeline.RestError(error.message, { code: error.statusCode });
|
|
293
|
+
}
|
|
294
|
+
throw new Error(error);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/** Analyze a widget. The only guarantee is that this method will return a string containing the results of the analysis. */
|
|
298
|
+
async function _analyzeWidget(context, id, options = { requestOptions: {} }) {
|
|
299
|
+
const result = await _analyzeWidgetSend(context, id, options);
|
|
300
|
+
return _analyzeWidgetDeserialize(result);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Copyright (c) Microsoft Corporation.
|
|
304
|
+
function createWidgetService(endpoint, credentialOrOptions, options = {}) {
|
|
305
|
+
const baseUrl = endpoint;
|
|
306
|
+
if (coreAuth.isTokenCredential(credentialOrOptions)) {
|
|
307
|
+
return createClient(baseUrl, credentialOrOptions, options);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
return createClient(baseUrl, credentialOrOptions);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// Copyright (c) Microsoft Corporation.
|
|
315
|
+
class WidgetServiceClient {
|
|
316
|
+
constructor(endpoint, credentialOrOptions, options = {}) {
|
|
317
|
+
if (coreAuth.isTokenCredential(credentialOrOptions)) {
|
|
318
|
+
this._client = createWidgetService(endpoint, credentialOrOptions, options);
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
this._client = createWidgetService(endpoint, credentialOrOptions);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* List all widgets in the system. This operation is not paginated, and returns a simple array of widgets.
|
|
326
|
+
*
|
|
327
|
+
* It does not accept any options or parameters.
|
|
328
|
+
*/
|
|
329
|
+
listWidgets(options = { requestOptions: {} }) {
|
|
330
|
+
return listWidgets(this._client, options);
|
|
331
|
+
}
|
|
332
|
+
/** Get a widget by ID. */
|
|
333
|
+
getWidget(id, options = { requestOptions: {} }) {
|
|
334
|
+
return getWidget(this._client, id, options);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Create a new widget.
|
|
338
|
+
*
|
|
339
|
+
* The widget ID is not required during creation, as it is automatically set by the server. Providing an ID will
|
|
340
|
+
* result in an error.
|
|
341
|
+
*/
|
|
342
|
+
createWidget(weight, color, options = { requestOptions: {} }) {
|
|
343
|
+
return createWidget(this._client, weight, color, options);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Update the contents of the widget. The widget ID is required in the input, but cannot be changed. All other fields
|
|
347
|
+
* are optional and will be updated within the widget if provided.
|
|
348
|
+
*/
|
|
349
|
+
updateWidget(id, options = { requestOptions: {} }) {
|
|
350
|
+
return updateWidget(this._client, id, options);
|
|
351
|
+
}
|
|
352
|
+
/** Delete a widget by ID. */
|
|
353
|
+
deleteWidget(id, options = { requestOptions: {} }) {
|
|
354
|
+
return deleteWidget(this._client, id, options);
|
|
355
|
+
}
|
|
356
|
+
/** Analyze a widget. The only guarantee is that this method will return a string containing the results of the analysis. */
|
|
357
|
+
analyzeWidget(id, options = { requestOptions: {} }) {
|
|
358
|
+
return analyzeWidget(this._client, id, options);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
exports.WidgetServiceClient = WidgetServiceClient;
|
|
363
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/logger.ts","../src/rest/widgetServiceClient.ts","../src/rest/isUnexpected.ts","../src/api/foo.ts","../src/api/operations.ts","../src/api/WidgetServiceContext.ts","../src/WidgetServiceClient.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * THIS IS AN AUTO-GENERATED FILE - DO NOT EDIT!\n *\n * Any changes you make here may be lost.\n *\n * If you need to make changes, please do so in the original source file, \\{project-root\\}/sources/custom\n */\n\nimport { createClientLogger } from \"@azure/logger\";\nexport const logger = createClientLogger(\"widget\");\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * THIS IS AN AUTO-GENERATED FILE - DO NOT EDIT!\n *\n * Any changes you make here may be lost.\n *\n * If you need to make changes, please do so in the original source file, \\{project-root\\}/sources/custom\n */\n\nimport { ClientOptions, addCredentialPipelinePolicy, getClient } from \"@azure-rest/core-client\";\nimport { TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { logger } from \"../logger.js\";\nimport { WidgetServiceContext } from \"./clientDefinitions.js\";\n\n/**\n * This customization adds credential support to the client. And overloads for when it is optional\n */\nexport default function createClient(\n endpoint: string,\n credential: TokenCredential,\n options?: ClientOptions\n): WidgetServiceContext;\nexport default function createClient(\n endpoint: string,\n options?: ClientOptions\n): WidgetServiceContext;\nexport default function createClient(\n endpoint: string,\n credentialOrOptions?: TokenCredential | ClientOptions,\n options: ClientOptions = {}\n): WidgetServiceContext {\n let credential: TokenCredential | undefined;\n if (isTokenCredential(credentialOrOptions)) {\n credential = credentialOrOptions;\n } else {\n options = credentialOrOptions ?? {};\n }\n\n const client = _createClient(endpoint, options);\n addCredentialPipelinePolicy(client.pipeline, endpoint, { credential, clientOptions: options });\n return client;\n}\n\n/**\n * Initialize a new instance of `WidgetServiceContext`\n * @param endpoint - The parameter endpoint\n * @param options - the parameter for all optional parameters\n */\nfunction _createClient(endpoint: string, options: ClientOptions = {}): WidgetServiceContext {\n const baseUrl = options.baseUrl ?? `${endpoint}`;\n options.apiVersion = options.apiVersion ?? \"1.0.0\";\n const userAgentInfo = `azsdk-js-widget-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n };\n const client = getClient(baseUrl, options) as WidgetServiceContext;\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * THIS IS AN AUTO-GENERATED FILE - DO NOT EDIT!\n *\n * Any changes you make here may be lost.\n *\n * If you need to make changes, please do so in the original source file, \\{project-root\\}/sources/custom\n */\n\nimport {\n ListWidgets200Response,\n ListWidgetsDefaultResponse,\n CreateWidget201Response,\n CreateWidgetDefaultResponse,\n GetWidget200Response,\n GetWidgetDefaultResponse,\n UpdateWidget200Response,\n UpdateWidgetDefaultResponse,\n DeleteWidget204Response,\n DeleteWidgetDefaultResponse,\n AnalyzeWidget200Response,\n AnalyzeWidgetDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /widgets\": [\"200\"],\n \"POST /widgets\": [\"201\"],\n \"GET /widgets/{id}\": [\"200\"],\n \"PATCH /widgets/{id}\": [\"200\"],\n \"DELETE /widgets/{id}\": [\"204\"],\n \"POST /widgets/{id}/analyze\": [\"200\"],\n};\n\nexport function isUnexpected(\n response: ListWidgets200Response | ListWidgetsDefaultResponse\n): response is ListWidgetsDefaultResponse;\nexport function isUnexpected(\n response: CreateWidget201Response | CreateWidgetDefaultResponse\n): response is CreateWidgetDefaultResponse;\nexport function isUnexpected(\n response: GetWidget200Response | GetWidgetDefaultResponse\n): response is GetWidgetDefaultResponse;\nexport function isUnexpected(\n response: UpdateWidget200Response | UpdateWidgetDefaultResponse\n): response is UpdateWidgetDefaultResponse;\nexport function isUnexpected(\n response: DeleteWidget204Response | DeleteWidgetDefaultResponse\n): response is DeleteWidgetDefaultResponse;\nexport function isUnexpected(\n response: AnalyzeWidget200Response | AnalyzeWidgetDefaultResponse\n): response is AnalyzeWidgetDefaultResponse;\nexport function isUnexpected(\n response:\n | ListWidgets200Response\n | ListWidgetsDefaultResponse\n | CreateWidget201Response\n | CreateWidgetDefaultResponse\n | GetWidget200Response\n | GetWidgetDefaultResponse\n | UpdateWidget200Response\n | UpdateWidgetDefaultResponse\n | DeleteWidget204Response\n | DeleteWidgetDefaultResponse\n | AnalyzeWidget200Response\n | AnalyzeWidgetDefaultResponse\n): response is\n | ListWidgetsDefaultResponse\n | CreateWidgetDefaultResponse\n | GetWidgetDefaultResponse\n | UpdateWidgetDefaultResponse\n | DeleteWidgetDefaultResponse\n | AnalyzeWidgetDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {\n if (candidateParts[i]?.startsWith(\"{\") && candidateParts[i]?.indexOf(\"}\") !== -1) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(\n pathParts[j] || \"\"\n );\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * THIS IS AN AUTO-GENERATED FILE - DO NOT EDIT!\n *\n * Any changes you make here may be lost.\n *\n * If you need to make changes, please do so in the original source file, \\{project-root\\}/sources/custom\n */\nexport function foo(): void {\n console.log(\"foo\");\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * THIS IS AN AUTO-GENERATED FILE - DO NOT EDIT!\n *\n * Any changes you make here may be lost.\n *\n * If you need to make changes, please do so in the original source file, \\{project-root\\}/sources/custom\n */\n\nimport { StreamableMethod } from \"@azure-rest/core-client\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { RequestOptions } from \"../common/interfaces.js\";\nimport {\n AnalyzeWidget200Response,\n AnalyzeWidgetDefaultResponse,\n WidgetServiceContext as Client,\n CreateWidget201Response,\n CreateWidgetDefaultResponse,\n DeleteWidget204Response,\n DeleteWidgetDefaultResponse,\n GetWidget200Response,\n GetWidgetDefaultResponse,\n ListWidgets200Response,\n ListWidgetsDefaultResponse,\n UpdateWidget200Response,\n UpdateWidgetDefaultResponse,\n isUnexpected,\n} from \"../rest/index.js\";\nimport { foo } from \"./foo.js\";\nimport { AnalyzeResult, ColorType, Widget } from \"./models.js\";\n\nexport interface ListWidgetsOptions extends RequestOptions {}\n\nexport interface GetWidgetOptions extends RequestOptions {}\n\nexport interface CreateWidgetOptions extends RequestOptions {}\n\nexport interface UpdateWidgetOptions extends RequestOptions {\n /** The weight of the widget. This is an int32, but must be greater than zero. */\n weight?: number;\n /** The color of the widget. */\n color?: ColorType;\n}\n\nexport interface DeleteWidgetOptions extends RequestOptions {}\n\nexport interface AnalyzeWidgetOptions extends RequestOptions {}\n\nexport function _listWidgetsSend(\n context: Client,\n options: ListWidgetsOptions = { requestOptions: {} }\n): StreamableMethod<ListWidgets200Response | ListWidgetsDefaultResponse> {\n return context.path(\"/widgets\").get({\n allowInsecureConnection: options.requestOptions?.allowInsecureConnection,\n skipUrlEncoding: options.requestOptions?.skipUrlEncoding,\n headers: { ...options.requestOptions?.headers },\n });\n}\n\nexport async function _listWidgetsDeserialize(\n result: ListWidgets200Response | ListWidgetsDefaultResponse\n): Promise<Widget[]> {\n if (isUnexpected(result)) {\n throw result.body;\n }\n\n return (result.body ?? []).map((p) => ({\n id: p[\"id\"],\n weight: p[\"weight\"],\n color: p[\"color\"],\n }));\n}\n\n/**\n * List all widgets in the system. This operation is not paginated, and returns a simple array of widgets.\n *\n * It does not accept any options or parameters.\n */\nexport async function listWidgets(\n context: Client,\n options: ListWidgetsOptions = { requestOptions: {} }\n): Promise<Widget[]> {\n const result = await _listWidgetsSend(context, options);\n return _listWidgetsDeserialize(result);\n}\n\nexport function _getWidgetSend(\n context: Client,\n id: string,\n options: GetWidgetOptions = { requestOptions: {} }\n): StreamableMethod<GetWidget200Response | GetWidgetDefaultResponse> {\n return context.path(\"/widgets/{id}\", id).get({\n allowInsecureConnection: options.requestOptions?.allowInsecureConnection,\n skipUrlEncoding: options.requestOptions?.skipUrlEncoding,\n headers: { ...options.requestOptions?.headers },\n });\n}\n\nexport async function _getWidgetDeserialize(\n result: GetWidget200Response | GetWidgetDefaultResponse\n): Promise<Widget> {\n if (isUnexpected(result)) {\n throw result.body;\n }\n\n return {\n id: result.body[\"id\"],\n weight: result.body[\"weight\"],\n color: result.body[\"color\"],\n };\n}\n\n/** Get a widget by ID. */\nexport async function getWidget(\n context: Client,\n id: string,\n options: GetWidgetOptions = { requestOptions: {} }\n): Promise<Widget> {\n const result = await _getWidgetSend(context, id, options);\n return _getWidgetDeserialize(result);\n}\n\nexport function _createWidgetSend(\n context: Client,\n weight: number,\n color: ColorType,\n options: CreateWidgetOptions = { requestOptions: {} }\n): StreamableMethod<CreateWidget201Response | CreateWidgetDefaultResponse> {\n return context.path(\"/widgets\").post({\n allowInsecureConnection: options.requestOptions?.allowInsecureConnection,\n skipUrlEncoding: options.requestOptions?.skipUrlEncoding,\n headers: { ...options.requestOptions?.headers },\n body: { weight: weight, color: color },\n });\n}\n\nexport async function _createWidgetDeserialize(\n result: CreateWidget201Response | CreateWidgetDefaultResponse\n): Promise<Widget> {\n if (isUnexpected(result)) {\n throw result.body;\n }\n\n return {\n id: result.body[\"id\"],\n weight: result.body[\"weight\"],\n color: result.body[\"color\"],\n };\n}\n\n/**\n * Create a new widget.\n *\n * The widget ID is not required during creation, as it is automatically set by the server. Providing an ID will\n * result in an error.\n */\nexport async function createWidget(\n context: Client,\n weight: number,\n color: ColorType,\n options: CreateWidgetOptions = { requestOptions: {} }\n): Promise<Widget> {\n const result = await _createWidgetSend(context, weight, color, options);\n return _createWidgetDeserialize(result);\n}\n\nexport function _updateWidgetSend(\n context: Client,\n id: string,\n options: UpdateWidgetOptions = { requestOptions: {} }\n): StreamableMethod<UpdateWidget200Response | UpdateWidgetDefaultResponse> {\n return context.path(\"/widgets/{id}\", id).patch({\n allowInsecureConnection: options.requestOptions?.allowInsecureConnection,\n skipUrlEncoding: options.requestOptions?.skipUrlEncoding,\n headers: { ...options.requestOptions?.headers },\n body: { weight: options?.weight, color: options?.color },\n });\n}\n\nexport async function _updateWidgetDeserialize(\n result: UpdateWidget200Response | UpdateWidgetDefaultResponse\n): Promise<Widget> {\n if (isUnexpected(result)) {\n throw result.body;\n }\n\n return {\n id: result.body[\"id\"],\n weight: result.body[\"weight\"],\n color: result.body[\"color\"],\n };\n}\n\n/**\n * Update the contents of the widget. The widget ID is required in the input, but cannot be changed. All other fields\n * are optional and will be updated within the widget if provided.\n */\nexport async function updateWidget(\n context: Client,\n id: string,\n options: UpdateWidgetOptions = { requestOptions: {} }\n): Promise<Widget> {\n const result = await _updateWidgetSend(context, id, options);\n return _updateWidgetDeserialize(result);\n}\n\nexport function _deleteWidgetSend(\n context: Client,\n id: string,\n options: DeleteWidgetOptions = { requestOptions: {} }\n): StreamableMethod<DeleteWidget204Response | DeleteWidgetDefaultResponse> {\n return context.path(\"/widgets/{id}\", id).delete({\n allowInsecureConnection: options.requestOptions?.allowInsecureConnection,\n skipUrlEncoding: options.requestOptions?.skipUrlEncoding,\n headers: { ...options.requestOptions?.headers },\n });\n}\n\nexport async function _deleteWidgetDeserialize(\n result: DeleteWidget204Response | DeleteWidgetDefaultResponse\n): Promise<void> {\n if (isUnexpected(result)) {\n throw result.body;\n }\n\n return;\n}\n\n/** Delete a widget by ID. */\nexport async function deleteWidget(\n context: Client,\n id: string,\n options: DeleteWidgetOptions = { requestOptions: {} }\n): Promise<void> {\n const result = await _deleteWidgetSend(context, id, options);\n return _deleteWidgetDeserialize(result);\n}\n\nexport function _analyzeWidgetSend(\n context: Client,\n id: string,\n options: AnalyzeWidgetOptions = { requestOptions: {} }\n): StreamableMethod<AnalyzeWidget200Response | AnalyzeWidgetDefaultResponse> {\n return context.path(\"/widgets/{id}/analyze\", id).post({\n allowInsecureConnection: options.requestOptions?.allowInsecureConnection,\n skipUrlEncoding: options.requestOptions?.skipUrlEncoding,\n headers: { ...options.requestOptions?.headers },\n });\n}\n\nexport async function _analyzeWidgetDeserialize(\n result: AnalyzeWidget200Response | AnalyzeWidgetDefaultResponse\n): Promise<AnalyzeResult> {\n if (isUnexpected(result)) {\n throw result.body;\n }\n\n return {\n summary: result.body[\"summary\"],\n };\n}\n\n/**\n * In this customization we will perform the following tasks in addition to the generated:\n * - We are going to add special error handling for demonstration purposes\n */\nexport async function analyzeWidget(\n context: Client,\n id: string,\n options?: AnalyzeWidgetOptions\n): Promise<AnalyzeResult> {\n try {\n foo();\n const result = await _analyzeWidget(context, id, options);\n return result;\n } catch (error: any) {\n console.error(\"Error occurred while calling analyzeWidget:\", error);\n if (error.message && error.statusCode) {\n throw new RestError(error.message, { code: error.statusCode });\n }\n\n throw new Error(error);\n }\n}\n\n/** Analyze a widget. The only guarantee is that this method will return a string containing the results of the analysis. */\nasync function _analyzeWidget(\n context: Client,\n id: string,\n options: AnalyzeWidgetOptions = { requestOptions: {} }\n): Promise<AnalyzeResult> {\n const result = await _analyzeWidgetSend(context, id, options);\n return _analyzeWidgetDeserialize(result);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * THIS IS AN AUTO-GENERATED FILE - DO NOT EDIT!\n *\n * Any changes you make here may be lost.\n *\n * If you need to make changes, please do so in the original source file, \\{project-root\\}/sources/custom\n */\n\nimport { ClientOptions } from \"@azure-rest/core-client\";\nimport { TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport getClient, { WidgetServiceContext } from \"../rest/index.js\";\n\nexport { WidgetServiceContext } from \"../rest/index.js\";\n\nexport interface WidgetServiceClientOptions extends ClientOptions {}\n\n/**\n * This customization adds authentication to the client.\n */\nexport function createWidgetService(\n endpoint: string,\n options?: ClientOptions\n): WidgetServiceContext;\nexport function createWidgetService(\n endpoint: string,\n credential: TokenCredential,\n options?: ClientOptions\n): WidgetServiceContext;\nexport function createWidgetService(\n endpoint: string,\n credentialOrOptions?: TokenCredential | ClientOptions,\n options: ClientOptions = {}\n): WidgetServiceContext {\n const baseUrl = endpoint;\n if (isTokenCredential(credentialOrOptions)) {\n return getClient(baseUrl, credentialOrOptions, options);\n } else {\n return getClient(baseUrl, credentialOrOptions);\n }\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * THIS IS AN AUTO-GENERATED FILE - DO NOT EDIT!\n *\n * Any changes you make here may be lost.\n *\n * If you need to make changes, please do so in the original source file, \\{project-root\\}/sources/custom\n */\n\nimport { TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport {\n AnalyzeResult,\n AnalyzeWidgetOptions,\n ColorType,\n CreateWidgetOptions,\n DeleteWidgetOptions,\n GetWidgetOptions,\n ListWidgetsOptions,\n UpdateWidgetOptions,\n Widget,\n WidgetServiceClientOptions,\n WidgetServiceContext,\n analyzeWidget,\n createWidget,\n createWidgetService,\n deleteWidget,\n getWidget,\n listWidgets,\n updateWidget,\n} from \"./api/index.js\";\n\nexport { WidgetServiceClientOptions } from \"./api/WidgetServiceContext.js\";\n\nexport class WidgetServiceClient {\n private _client: WidgetServiceContext;\n\n /** */\n constructor(endpoint: string, options?: WidgetServiceClientOptions);\n constructor(endpoint: string, credential: TokenCredential, options?: WidgetServiceClientOptions);\n constructor(\n endpoint: string,\n credentialOrOptions?: TokenCredential | WidgetServiceClientOptions,\n options: WidgetServiceClientOptions = {}\n ) {\n if (isTokenCredential(credentialOrOptions)) {\n this._client = createWidgetService(endpoint, credentialOrOptions, options);\n } else {\n this._client = createWidgetService(endpoint, credentialOrOptions);\n }\n }\n\n /**\n * List all widgets in the system. This operation is not paginated, and returns a simple array of widgets.\n *\n * It does not accept any options or parameters.\n */\n listWidgets(options: ListWidgetsOptions = { requestOptions: {} }): Promise<Widget[]> {\n return listWidgets(this._client, options);\n }\n\n /** Get a widget by ID. */\n getWidget(id: string, options: GetWidgetOptions = { requestOptions: {} }): Promise<Widget> {\n return getWidget(this._client, id, options);\n }\n\n /**\n * Create a new widget.\n *\n * The widget ID is not required during creation, as it is automatically set by the server. Providing an ID will\n * result in an error.\n */\n createWidget(\n weight: number,\n color: ColorType,\n options: CreateWidgetOptions = { requestOptions: {} }\n ): Promise<Widget> {\n return createWidget(this._client, weight, color, options);\n }\n\n /**\n * Update the contents of the widget. The widget ID is required in the input, but cannot be changed. All other fields\n * are optional and will be updated within the widget if provided.\n */\n updateWidget(id: string, options: UpdateWidgetOptions = { requestOptions: {} }): Promise<Widget> {\n return updateWidget(this._client, id, options);\n }\n\n /** Delete a widget by ID. */\n deleteWidget(id: string, options: DeleteWidgetOptions = { requestOptions: {} }): Promise<void> {\n return deleteWidget(this._client, id, options);\n }\n\n /** Analyze a widget. The only guarantee is that this method will return a string containing the results of the analysis. */\n analyzeWidget(\n id: string,\n options: AnalyzeWidgetOptions = { requestOptions: {} }\n ): Promise<AnalyzeResult> {\n return analyzeWidget(this._client, id, options);\n }\n}\n"],"names":["createClientLogger","isTokenCredential","addCredentialPipelinePolicy","getClient","RestError"],"mappings":";;;;;;;;;AAAA;AAYO,MAAM,MAAM,GAAGA,2BAAkB,CAAC,QAAQ,CAAC;;ACZlD;AA4Bc,SAAU,YAAY,CAClC,QAAgB,EAChB,mBAAqD,EACrD,OAAA,GAAyB,EA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O,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;KAC3D;AAED;;;AAGG;IACH,YAAY,CAAC,EAAU,EAAE,OAAA,GAA+B,EAAE,cAAc,EAAE,EAAE,EAAE,EAAA;QAC5E,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;KAChD;;IAGD,YAAY,CAAC,EAAU,EAAE,OAAA,GAA+B,EAAE,cAAc,EAAE,EAAE,EAAE,EAAA;QAC5E,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;KAChD;;IAGD,aAAa,CACX,EAAU,EACV,OAAA,GAAgC,EAAE,cAAc,EAAE,EAAE,EAAE,EAAA;QAEtD,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;KACjD;AACF;;;;"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
/**
|
|
4
|
+
* THIS IS AN AUTO-GENERATED FILE - DO NOT EDIT!
|
|
5
|
+
*
|
|
6
|
+
* Any changes you make here may be lost.
|
|
7
|
+
*
|
|
8
|
+
* If you need to make changes, please do so in the original source file, \{project-root\}/sources/custom
|
|
9
|
+
*/
|
|
10
|
+
import { isTokenCredential } from "@azure/core-auth";
|
|
11
|
+
import { analyzeWidget, createWidget, createWidgetService, deleteWidget, getWidget, listWidgets, updateWidget, } from "./api/index.js";
|
|
12
|
+
export class WidgetServiceClient {
|
|
13
|
+
constructor(endpoint, credentialOrOptions, options = {}) {
|
|
14
|
+
if (isTokenCredential(credentialOrOptions)) {
|
|
15
|
+
this._client = createWidgetService(endpoint, credentialOrOptions, options);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this._client = createWidgetService(endpoint, credentialOrOptions);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* List all widgets in the system. This operation is not paginated, and returns a simple array of widgets.
|
|
23
|
+
*
|
|
24
|
+
* It does not accept any options or parameters.
|
|
25
|
+
*/
|
|
26
|
+
listWidgets(options = { requestOptions: {} }) {
|
|
27
|
+
return listWidgets(this._client, options);
|
|
28
|
+
}
|
|
29
|
+
/** Get a widget by ID. */
|
|
30
|
+
getWidget(id, options = { requestOptions: {} }) {
|
|
31
|
+
return getWidget(this._client, id, options);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a new widget.
|
|
35
|
+
*
|
|
36
|
+
* The widget ID is not required during creation, as it is automatically set by the server. Providing an ID will
|
|
37
|
+
* result in an error.
|
|
38
|
+
*/
|
|
39
|
+
createWidget(weight, color, options = { requestOptions: {} }) {
|
|
40
|
+
return createWidget(this._client, weight, color, options);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Update the contents of the widget. The widget ID is required in the input, but cannot be changed. All other fields
|
|
44
|
+
* are optional and will be updated within the widget if provided.
|
|
45
|
+
*/
|
|
46
|
+
updateWidget(id, options = { requestOptions: {} }) {
|
|
47
|
+
return updateWidget(this._client, id, options);
|
|
48
|
+
}
|
|
49
|
+
/** Delete a widget by ID. */
|
|
50
|
+
deleteWidget(id, options = { requestOptions: {} }) {
|
|
51
|
+
return deleteWidget(this._client, id, options);
|
|
52
|
+
}
|
|
53
|
+
/** Analyze a widget. The only guarantee is that this method will return a string containing the results of the analysis. */
|
|
54
|
+
analyzeWidget(id, options = { requestOptions: {} }) {
|
|
55
|
+
return analyzeWidget(this._client, id, options);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=WidgetServiceClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WidgetServiceClient.js","sourceRoot":"","sources":["../../src/WidgetServiceClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;;GAMG;AA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UAA+B,EAAE,cAAc,EAAE,EAAE,EAAE;QAC5E,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IACjD,CAAC;IAED,4HAA4H;IAC5H,aAAa,CACX,EAAU,EACV,UAAgC,EAAE,cAAc,EAAE,EAAE,EAAE;QAEtD,OAAO,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAClD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * THIS IS AN AUTO-GENERATED FILE - DO NOT EDIT!\n *\n * Any changes you make here may be lost.\n *\n * If you need to make changes, please do so in the original source file, \\{project-root\\}/sources/custom\n */\n\nimport { TokenCredential, isTokenCredential } from \"@azure/core-auth\";\nimport {\n AnalyzeResult,\n AnalyzeWidgetOptions,\n ColorType,\n CreateWidgetOptions,\n DeleteWidgetOptions,\n GetWidgetOptions,\n ListWidgetsOptions,\n UpdateWidgetOptions,\n Widget,\n WidgetServiceClientOptions,\n WidgetServiceContext,\n analyzeWidget,\n createWidget,\n createWidgetService,\n deleteWidget,\n getWidget,\n listWidgets,\n updateWidget,\n} from \"./api/index.js\";\n\nexport { WidgetServiceClientOptions } from \"./api/WidgetServiceContext.js\";\n\nexport class WidgetServiceClient {\n private _client: WidgetServiceContext;\n\n /** */\n constructor(endpoint: string, options?: WidgetServiceClientOptions);\n constructor(endpoint: string, credential: TokenCredential, options?: WidgetServiceClientOptions);\n constructor(\n endpoint: string,\n credentialOrOptions?: TokenCredential | WidgetServiceClientOptions,\n options: WidgetServiceClientOptions = {}\n ) {\n if (isTokenCredential(credentialOrOptions)) {\n this._client = createWidgetService(endpoint, credentialOrOptions, options);\n } else {\n this._client = createWidgetService(endpoint, credentialOrOptions);\n }\n }\n\n /**\n * List all widgets in the system. This operation is not paginated, and returns a simple array of widgets.\n *\n * It does not accept any options or parameters.\n */\n listWidgets(options: ListWidgetsOptions = { requestOptions: {} }): Promise<Widget[]> {\n return listWidgets(this._client, options);\n }\n\n /** Get a widget by ID. */\n getWidget(id: string, options: GetWidgetOptions = { requestOptions: {} }): Promise<Widget> {\n return getWidget(this._client, id, options);\n }\n\n /**\n * Create a new widget.\n *\n * The widget ID is not required during creation, as it is automatically set by the server. Providing an ID will\n * result in an error.\n */\n createWidget(\n weight: number,\n color: ColorType,\n options: CreateWidgetOptions = { requestOptions: {} }\n ): Promise<Widget> {\n return createWidget(this._client, weight, color, options);\n }\n\n /**\n * Update the contents of the widget. The widget ID is required in the input, but cannot be changed. All other fields\n * are optional and will be updated within the widget if provided.\n */\n updateWidget(id: string, options: UpdateWidgetOptions = { requestOptions: {} }): Promise<Widget> {\n return updateWidget(this._client, id, options);\n }\n\n /** Delete a widget by ID. */\n deleteWidget(id: string, options: DeleteWidgetOptions = { requestOptions: {} }): Promise<void> {\n return deleteWidget(this._client, id, options);\n }\n\n /** Analyze a widget. The only guarantee is that this method will return a string containing the results of the analysis. */\n analyzeWidget(\n id: string,\n options: AnalyzeWidgetOptions = { requestOptions: {} }\n ): Promise<AnalyzeResult> {\n return analyzeWidget(this._client, id, options);\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { isTokenCredential } from "@azure/core-auth";
|
|
4
|
+
import getClient from "../rest/index.js";
|
|
5
|
+
export function createWidgetService(endpoint, credentialOrOptions, options = {}) {
|
|
6
|
+
const baseUrl = endpoint;
|
|
7
|
+
if (isTokenCredential(credentialOrOptions)) {
|
|
8
|
+
return getClient(baseUrl, credentialOrOptions, options);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
return getClient(baseUrl, credentialOrOptions);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=WidgetServiceContext.js.map
|