@azure/template-dpg 1.0.0-alpha.20230623.2 → 1.0.0-alpha.20230710.2

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.
Files changed (128) hide show
  1. package/dist/index.cjs +7 -0
  2. package/dist/index.cjs.map +1 -1
  3. package/dist-esm/src/WidgetServiceClient.js +7 -0
  4. package/dist-esm/src/WidgetServiceClient.js.map +1 -1
  5. package/dist-esm/src/api/WidgetServiceContext.js.map +1 -1
  6. package/dist-esm/src/api/foo.js +7 -0
  7. package/dist-esm/src/api/foo.js.map +1 -1
  8. package/dist-esm/src/api/index.js.map +1 -1
  9. package/dist-esm/src/api/models.js.map +1 -1
  10. package/dist-esm/src/api/operations.js.map +1 -1
  11. package/dist-esm/src/common/interfaces.js.map +1 -1
  12. package/dist-esm/src/index.js.map +1 -1
  13. package/dist-esm/src/logger.js +7 -0
  14. package/dist-esm/src/logger.js.map +1 -1
  15. package/dist-esm/src/rest/clientDefinitions.js.map +1 -1
  16. package/dist-esm/src/rest/index.js +7 -0
  17. package/dist-esm/src/rest/index.js.map +1 -1
  18. package/dist-esm/src/rest/isUnexpected.js.map +1 -1
  19. package/dist-esm/src/rest/models.js.map +1 -1
  20. package/dist-esm/src/rest/outputModels.js.map +1 -1
  21. package/dist-esm/src/rest/parameters.js.map +1 -1
  22. package/dist-esm/src/rest/responses.js.map +1 -1
  23. package/dist-esm/src/rest/widgetServiceClient.js +7 -0
  24. package/dist-esm/src/rest/widgetServiceClient.js.map +1 -1
  25. package/dist-esm/src/src/WidgetServiceClient.js +58 -0
  26. package/dist-esm/src/src/WidgetServiceClient.js.map +1 -0
  27. package/dist-esm/src/src/api/WidgetServiceContext.js +14 -0
  28. package/dist-esm/src/src/api/WidgetServiceContext.js.map +1 -0
  29. package/dist-esm/src/src/api/foo.js +13 -0
  30. package/dist-esm/src/src/api/foo.js.map +1 -0
  31. package/dist-esm/src/src/api/index.js +5 -0
  32. package/dist-esm/src/src/api/index.js.map +1 -0
  33. package/dist-esm/src/src/api/models.js +4 -0
  34. package/dist-esm/src/src/api/models.js.map +1 -0
  35. package/dist-esm/src/src/api/operations.js +171 -0
  36. package/dist-esm/src/src/api/operations.js.map +1 -0
  37. package/dist-esm/src/src/common/interfaces.js +4 -0
  38. package/dist-esm/src/src/common/interfaces.js.map +1 -0
  39. package/dist-esm/src/src/index.js +4 -0
  40. package/dist-esm/src/src/index.js.map +1 -0
  41. package/dist-esm/src/src/logger.js +12 -0
  42. package/dist-esm/src/src/logger.js.map +1 -0
  43. package/dist-esm/src/src/rest/clientDefinitions.js +4 -0
  44. package/dist-esm/src/src/rest/clientDefinitions.js.map +1 -0
  45. package/dist-esm/src/src/rest/index.js +19 -0
  46. package/dist-esm/src/src/rest/index.js.map +1 -0
  47. package/dist-esm/src/src/rest/isUnexpected.js +75 -0
  48. package/dist-esm/src/src/rest/isUnexpected.js.map +1 -0
  49. package/dist-esm/src/src/rest/models.js +4 -0
  50. package/dist-esm/src/src/rest/models.js.map +1 -0
  51. package/dist-esm/src/src/rest/outputModels.js +4 -0
  52. package/dist-esm/src/src/rest/outputModels.js.map +1 -0
  53. package/dist-esm/src/src/rest/parameters.js +4 -0
  54. package/dist-esm/src/src/rest/parameters.js.map +1 -0
  55. package/dist-esm/src/src/rest/responses.js +4 -0
  56. package/dist-esm/src/src/rest/responses.js.map +1 -0
  57. package/dist-esm/src/src/rest/widgetServiceClient.js +46 -0
  58. package/dist-esm/src/src/rest/widgetServiceClient.js.map +1 -0
  59. package/package.json +1 -1
  60. package/types/latest/template-dpg.d.ts +7 -0
  61. package/types/latest/tsdoc-metadata.json +1 -1
  62. package/types/src/WidgetServiceClient.d.ts +7 -0
  63. package/types/src/WidgetServiceClient.d.ts.map +1 -1
  64. package/types/src/api/WidgetServiceContext.d.ts +7 -0
  65. package/types/src/api/WidgetServiceContext.d.ts.map +1 -1
  66. package/types/src/api/foo.d.ts +7 -0
  67. package/types/src/api/foo.d.ts.map +1 -1
  68. package/types/src/api/index.d.ts +7 -0
  69. package/types/src/api/index.d.ts.map +1 -1
  70. package/types/src/api/models.d.ts +7 -0
  71. package/types/src/api/models.d.ts.map +1 -1
  72. package/types/src/api/operations.d.ts +7 -0
  73. package/types/src/api/operations.d.ts.map +1 -1
  74. package/types/src/common/interfaces.d.ts +7 -0
  75. package/types/src/common/interfaces.d.ts.map +1 -1
  76. package/types/src/index.d.ts +7 -0
  77. package/types/src/index.d.ts.map +1 -1
  78. package/types/src/logger.d.ts.map +1 -1
  79. package/types/src/rest/clientDefinitions.d.ts +7 -0
  80. package/types/src/rest/clientDefinitions.d.ts.map +1 -1
  81. package/types/src/rest/index.d.ts +7 -0
  82. package/types/src/rest/index.d.ts.map +1 -1
  83. package/types/src/rest/isUnexpected.d.ts +7 -0
  84. package/types/src/rest/isUnexpected.d.ts.map +1 -1
  85. package/types/src/rest/models.d.ts +7 -0
  86. package/types/src/rest/models.d.ts.map +1 -1
  87. package/types/src/rest/outputModels.d.ts +7 -0
  88. package/types/src/rest/outputModels.d.ts.map +1 -1
  89. package/types/src/rest/parameters.d.ts +7 -0
  90. package/types/src/rest/parameters.d.ts.map +1 -1
  91. package/types/src/rest/responses.d.ts +7 -0
  92. package/types/src/rest/responses.d.ts.map +1 -1
  93. package/types/src/rest/widgetServiceClient.d.ts +7 -0
  94. package/types/src/rest/widgetServiceClient.d.ts.map +1 -1
  95. package/types/src/src/WidgetServiceClient.d.ts +41 -0
  96. package/types/src/src/WidgetServiceClient.d.ts.map +1 -0
  97. package/types/src/src/api/WidgetServiceContext.d.ts +19 -0
  98. package/types/src/src/api/WidgetServiceContext.d.ts.map +1 -0
  99. package/types/src/src/api/foo.d.ts +9 -0
  100. package/types/src/src/api/foo.d.ts.map +1 -0
  101. package/types/src/src/api/index.d.ts +11 -0
  102. package/types/src/src/api/index.d.ts.map +1 -0
  103. package/types/src/src/api/models.d.ts +25 -0
  104. package/types/src/src/api/models.d.ts.map +1 -0
  105. package/types/src/src/api/operations.d.ts +67 -0
  106. package/types/src/src/api/operations.d.ts.map +1 -0
  107. package/types/src/src/common/interfaces.d.ts +21 -0
  108. package/types/src/src/common/interfaces.d.ts.map +1 -0
  109. package/types/src/src/index.d.ts +12 -0
  110. package/types/src/src/index.d.ts.map +1 -0
  111. package/types/src/src/logger.d.ts +2 -0
  112. package/types/src/src/logger.d.ts.map +1 -0
  113. package/types/src/src/rest/clientDefinitions.d.ts +52 -0
  114. package/types/src/src/rest/clientDefinitions.d.ts.map +1 -0
  115. package/types/src/src/rest/index.d.ts +17 -0
  116. package/types/src/src/rest/index.d.ts.map +1 -0
  117. package/types/src/src/rest/isUnexpected.d.ts +15 -0
  118. package/types/src/src/rest/isUnexpected.d.ts.map +1 -0
  119. package/types/src/src/rest/models.d.ts +20 -0
  120. package/types/src/src/rest/models.d.ts.map +1 -0
  121. package/types/src/src/rest/outputModels.d.ts +25 -0
  122. package/types/src/src/rest/outputModels.d.ts.map +1 -0
  123. package/types/src/src/rest/parameters.d.ts +22 -0
  124. package/types/src/src/rest/parameters.d.ts.map +1 -0
  125. package/types/src/src/rest/responses.d.ts +63 -0
  126. package/types/src/src/rest/responses.d.ts.map +1 -0
  127. package/types/src/src/rest/widgetServiceClient.d.ts +16 -0
  128. package/types/src/src/rest/widgetServiceClient.d.ts.map +1 -0
@@ -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/src/WidgetServiceClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;;GAMG;AAEH,OAAO,EAAmB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAYL,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,YAAY,EACZ,SAAS,EACT,WAAW,EACX,YAAY,GACb,MAAM,gBAAgB,CAAC;AAIxB,MAAM,OAAO,mBAAmB;IAM9B,YACE,QA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,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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WidgetServiceContext.js","sourceRoot":"","sources":["../../../../src/src/api/WidgetServiceContext.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAWlC,OAAO,EAAmB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,SAAmC,MAAM,kBAAkB,CAAC;AAkBnE,MAAM,UAAU,mBAAmB,CACjC,QAAgB,EAChB,mBAAqD,EACrD,UAAyB,EAAE;IAE3B,MAAM,OAAO,GAAG,QAAQ,CAAC;IACzB,IAAI,iBAAiB,CAAC,mBAAmB,CAAC,EAAE;QAC1C,OAAO,SAAS,CAAC,OAAO,EAAE,mBAAmB,EAAE,OAAO,CAAC,CAAC;KACzD;SAAM;QACL,OAAO,SAAS,CAAC,OAAO,EAAE,mBAAmB,CAAC,CAAC;KAChD;AACH,CAAC","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 { 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"]}
@@ -0,0 +1,13 @@
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
+ export function foo() {
11
+ console.log("foo");
12
+ }
13
+ //# sourceMappingURL=foo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"foo.js","sourceRoot":"","sources":["../../../../src/src/api/foo.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;;GAMG;AACH,MAAM,UAAU,GAAG;IACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACrB,CAAC","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 */\nexport function foo(): void {\n console.log(\"foo\");\n}\n"]}
@@ -0,0 +1,5 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export { listWidgets, getWidget, createWidget, updateWidget, deleteWidget, analyzeWidget, } from "./operations.js";
4
+ export { createWidgetService, } from "./WidgetServiceContext.js";
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/src/api/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAWlC,OAAO,EACL,WAAW,EACX,SAAS,EACT,YAAY,EACZ,YAAY,EACZ,YAAY,EACZ,aAAa,GAOd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,mBAAmB,GAGpB,MAAM,2BAA2B,CAAC","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\nexport { Widget, ColorType, AnalyzeResult } from \"./models.js\";\nexport {\n listWidgets,\n getWidget,\n createWidget,\n updateWidget,\n deleteWidget,\n analyzeWidget,\n ListWidgetsOptions,\n GetWidgetOptions,\n CreateWidgetOptions,\n UpdateWidgetOptions,\n DeleteWidgetOptions,\n AnalyzeWidgetOptions,\n} from \"./operations.js\";\nexport {\n createWidgetService,\n WidgetServiceContext,\n WidgetServiceClientOptions,\n} from \"./WidgetServiceContext.js\";\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/src/api/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","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\n/** */\nexport interface Widget {\n /** The UUID of this widget. This is generated automatically by the service. */\n id: string;\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\n/** Type of ColorType */\n/** */\nexport type ColorType = \"red\" | \"blue\";\n\n/** */\nexport interface AnalyzeResult {\n /** */\n summary: string;\n}\n"]}
@@ -0,0 +1,171 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { RestError } from "@azure/core-rest-pipeline";
4
+ import { isUnexpected, } from "../rest/index.js";
5
+ import { foo } from "./foo.js";
6
+ export function _listWidgetsSend(context, options = { requestOptions: {} }) {
7
+ var _a, _b, _c;
8
+ return context.path("/widgets").get({
9
+ allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
10
+ skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
11
+ headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
12
+ });
13
+ }
14
+ export async function _listWidgetsDeserialize(result) {
15
+ var _a;
16
+ if (isUnexpected(result)) {
17
+ throw result.body;
18
+ }
19
+ return ((_a = result.body) !== null && _a !== void 0 ? _a : []).map((p) => ({
20
+ id: p["id"],
21
+ weight: p["weight"],
22
+ color: p["color"],
23
+ }));
24
+ }
25
+ /**
26
+ * List all widgets in the system. This operation is not paginated, and returns a simple array of widgets.
27
+ *
28
+ * It does not accept any options or parameters.
29
+ */
30
+ export async function listWidgets(context, options = { requestOptions: {} }) {
31
+ const result = await _listWidgetsSend(context, options);
32
+ return _listWidgetsDeserialize(result);
33
+ }
34
+ export function _getWidgetSend(context, id, options = { requestOptions: {} }) {
35
+ var _a, _b, _c;
36
+ return context.path("/widgets/{id}", id).get({
37
+ allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
38
+ skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
39
+ headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
40
+ });
41
+ }
42
+ export async function _getWidgetDeserialize(result) {
43
+ if (isUnexpected(result)) {
44
+ throw result.body;
45
+ }
46
+ return {
47
+ id: result.body["id"],
48
+ weight: result.body["weight"],
49
+ color: result.body["color"],
50
+ };
51
+ }
52
+ /** Get a widget by ID. */
53
+ export async function getWidget(context, id, options = { requestOptions: {} }) {
54
+ const result = await _getWidgetSend(context, id, options);
55
+ return _getWidgetDeserialize(result);
56
+ }
57
+ export function _createWidgetSend(context, weight, color, options = { requestOptions: {} }) {
58
+ var _a, _b, _c;
59
+ return context.path("/widgets").post({
60
+ allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
61
+ skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
62
+ headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
63
+ body: { weight: weight, color: color },
64
+ });
65
+ }
66
+ export async function _createWidgetDeserialize(result) {
67
+ if (isUnexpected(result)) {
68
+ throw result.body;
69
+ }
70
+ return {
71
+ id: result.body["id"],
72
+ weight: result.body["weight"],
73
+ color: result.body["color"],
74
+ };
75
+ }
76
+ /**
77
+ * Create a new widget.
78
+ *
79
+ * The widget ID is not required during creation, as it is automatically set by the server. Providing an ID will
80
+ * result in an error.
81
+ */
82
+ export async function createWidget(context, weight, color, options = { requestOptions: {} }) {
83
+ const result = await _createWidgetSend(context, weight, color, options);
84
+ return _createWidgetDeserialize(result);
85
+ }
86
+ export function _updateWidgetSend(context, id, options = { requestOptions: {} }) {
87
+ var _a, _b, _c;
88
+ return context.path("/widgets/{id}", id).patch({
89
+ allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
90
+ skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
91
+ headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
92
+ body: { weight: options === null || options === void 0 ? void 0 : options.weight, color: options === null || options === void 0 ? void 0 : options.color },
93
+ });
94
+ }
95
+ export async function _updateWidgetDeserialize(result) {
96
+ if (isUnexpected(result)) {
97
+ throw result.body;
98
+ }
99
+ return {
100
+ id: result.body["id"],
101
+ weight: result.body["weight"],
102
+ color: result.body["color"],
103
+ };
104
+ }
105
+ /**
106
+ * Update the contents of the widget. The widget ID is required in the input, but cannot be changed. All other fields
107
+ * are optional and will be updated within the widget if provided.
108
+ */
109
+ export async function updateWidget(context, id, options = { requestOptions: {} }) {
110
+ const result = await _updateWidgetSend(context, id, options);
111
+ return _updateWidgetDeserialize(result);
112
+ }
113
+ export function _deleteWidgetSend(context, id, options = { requestOptions: {} }) {
114
+ var _a, _b, _c;
115
+ return context.path("/widgets/{id}", id).delete({
116
+ allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
117
+ skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
118
+ headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
119
+ });
120
+ }
121
+ export async function _deleteWidgetDeserialize(result) {
122
+ if (isUnexpected(result)) {
123
+ throw result.body;
124
+ }
125
+ return;
126
+ }
127
+ /** Delete a widget by ID. */
128
+ export async function deleteWidget(context, id, options = { requestOptions: {} }) {
129
+ const result = await _deleteWidgetSend(context, id, options);
130
+ return _deleteWidgetDeserialize(result);
131
+ }
132
+ export function _analyzeWidgetSend(context, id, options = { requestOptions: {} }) {
133
+ var _a, _b, _c;
134
+ return context.path("/widgets/{id}/analyze", id).post({
135
+ allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
136
+ skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
137
+ headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
138
+ });
139
+ }
140
+ export async function _analyzeWidgetDeserialize(result) {
141
+ if (isUnexpected(result)) {
142
+ throw result.body;
143
+ }
144
+ return {
145
+ summary: result.body["summary"],
146
+ };
147
+ }
148
+ /**
149
+ * In this customization we will perform the following tasks in addition to the generated:
150
+ * - We are going to add special error handling for demonstration purposes
151
+ */
152
+ export async function analyzeWidget(context, id, options) {
153
+ try {
154
+ foo();
155
+ const result = await _analyzeWidget(context, id, options);
156
+ return result;
157
+ }
158
+ catch (error) {
159
+ console.error("Error occurred while calling analyzeWidget:", error);
160
+ if (error.message && error.statusCode) {
161
+ throw new RestError(error.message, { code: error.statusCode });
162
+ }
163
+ throw new Error(error);
164
+ }
165
+ }
166
+ /** Analyze a widget. The only guarantee is that this method will return a string containing the results of the analysis. */
167
+ async function _analyzeWidget(context, id, options = { requestOptions: {} }) {
168
+ const result = await _analyzeWidgetSend(context, id, options);
169
+ return _analyzeWidgetDeserialize(result);
170
+ }
171
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../../../../src/src/api/operations.ts"],"names":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AM,IAAI,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,UAAU,EAAE,CAAC,CAAC;SAChE;QAED,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;KACxB;AACH,CAAC;AAED,4HAA4H;AAC5H,KAAK,UAAU,cAAc,CAC3B,OAAe,EACf,EAAU,EACV,UAAgC,EAAE,cAAc,EAAE,EAAE,EAAE;IAEtD,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,OAAO,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC;IAC9D,OAAO,yBAAyB,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC","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 { 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"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=interfaces.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../src/src/common/interfaces.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","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 { RawHttpHeadersInput } from \"@azure/core-rest-pipeline\";\n\nexport interface RequestOptions {\n requestOptions?: {\n /**\n * Headers to send along with the request\n */\n headers?: RawHttpHeadersInput;\n /** Set to true if the request is sent over HTTP instead of HTTPS */\n allowInsecureConnection?: boolean;\n /** Set to true if you want to skip encoding the path parameters */\n skipUrlEncoding?: boolean;\n };\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export { WidgetServiceClient } from "./WidgetServiceClient.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/src/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAmBlC,OAAO,EAAE,mBAAmB,EAA8B,MAAM,0BAA0B,CAAC","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\nexport { Widget, ColorType, AnalyzeResult } from \"./api/models.js\";\nexport {\n ListWidgetsOptions,\n GetWidgetOptions,\n CreateWidgetOptions,\n UpdateWidgetOptions,\n DeleteWidgetOptions,\n AnalyzeWidgetOptions,\n} from \"./api/operations.js\";\nexport { WidgetServiceClient, WidgetServiceClientOptions } from \"./WidgetServiceClient.js\";\nexport { RequestOptions } from \"./common/interfaces.js\";\n"]}
@@ -0,0 +1,12 @@
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 { createClientLogger } from "@azure/logger";
11
+ export const logger = createClientLogger("widget");
12
+ //# sourceMappingURL=logger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/src/logger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;;GAMG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,MAAM,CAAC,MAAM,MAAM,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAC","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"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=clientDefinitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clientDefinitions.js","sourceRoot":"","sources":["../../../../src/src/rest/clientDefinitions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","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 {\n ListWidgetsParameters,\n CreateWidgetParameters,\n GetWidgetParameters,\n UpdateWidgetParameters,\n DeleteWidgetParameters,\n AnalyzeWidgetParameters,\n} from \"./parameters.js\";\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\";\nimport { Client, StreamableMethod } from \"@azure-rest/core-client\";\n\nexport interface ListWidgets {\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 get(\n options?: ListWidgetsParameters\n ): StreamableMethod<ListWidgets200Response | ListWidgetsDefaultResponse>;\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 post(\n options?: CreateWidgetParameters\n ): StreamableMethod<CreateWidget201Response | CreateWidgetDefaultResponse>;\n}\n\nexport interface GetWidget {\n /** Get a widget by ID. */\n get(\n options?: GetWidgetParameters\n ): StreamableMethod<GetWidget200Response | GetWidgetDefaultResponse>;\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 patch(\n options?: UpdateWidgetParameters\n ): StreamableMethod<UpdateWidget200Response | UpdateWidgetDefaultResponse>;\n /** Delete a widget by ID. */\n delete(\n options?: DeleteWidgetParameters\n ): StreamableMethod<DeleteWidget204Response | DeleteWidgetDefaultResponse>;\n}\n\nexport interface AnalyzeWidget {\n /** Analyze a widget. The only guarantee is that this method will return a string containing the results of the analysis. */\n post(\n options?: AnalyzeWidgetParameters\n ): StreamableMethod<AnalyzeWidget200Response | AnalyzeWidgetDefaultResponse>;\n}\n\nexport interface Routes {\n /** Resource for '/widgets' has methods for the following verbs: get, post */\n (path: \"/widgets\"): ListWidgets;\n /** Resource for '/widgets/\\{id\\}' has methods for the following verbs: get, patch, delete */\n (path: \"/widgets/{id}\", id: string): GetWidget;\n /** Resource for '/widgets/\\{id\\}/analyze' has methods for the following verbs: post */\n (path: \"/widgets/{id}/analyze\", id: string): AnalyzeWidget;\n}\n\nexport type WidgetServiceContext = Client & {\n path: Routes;\n};\n"]}
@@ -0,0 +1,19 @@
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 WidgetServiceClient from "./widgetServiceClient.js";
11
+ export * from "./widgetServiceClient.js";
12
+ export * from "./parameters.js";
13
+ export * from "./responses.js";
14
+ export * from "./clientDefinitions.js";
15
+ export * from "./isUnexpected.js";
16
+ export * from "./models.js";
17
+ export * from "./outputModels.js";
18
+ export default WidgetServiceClient;
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/src/rest/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC;;;;;;GAMG;AAEH,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAE3D,cAAc,0BAA0B,CAAC;AACzC,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAElC,eAAe,mBAAmB,CAAC","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 WidgetServiceClient from \"./widgetServiceClient.js\";\n\nexport * from \"./widgetServiceClient.js\";\nexport * from \"./parameters.js\";\nexport * from \"./responses.js\";\nexport * from \"./clientDefinitions.js\";\nexport * from \"./isUnexpected.js\";\nexport * from \"./models.js\";\nexport * from \"./outputModels.js\";\n\nexport default WidgetServiceClient;\n"]}
@@ -0,0 +1,75 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ const responseMap = {
4
+ "GET /widgets": ["200"],
5
+ "POST /widgets": ["201"],
6
+ "GET /widgets/{id}": ["200"],
7
+ "PATCH /widgets/{id}": ["200"],
8
+ "DELETE /widgets/{id}": ["204"],
9
+ "POST /widgets/{id}/analyze": ["200"],
10
+ };
11
+ export function isUnexpected(response) {
12
+ const lroOriginal = response.headers["x-ms-original-url"];
13
+ const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
14
+ const method = response.request.method;
15
+ let pathDetails = responseMap[`${method} ${url.pathname}`];
16
+ if (!pathDetails) {
17
+ pathDetails = getParametrizedPathSuccess(method, url.pathname);
18
+ }
19
+ return !pathDetails.includes(response.status);
20
+ }
21
+ function getParametrizedPathSuccess(method, path) {
22
+ var _a, _b, _c, _d;
23
+ const pathParts = path.split("/");
24
+ // Traverse list to match the longest candidate
25
+ // matchedLen: the length of candidate path
26
+ // matchedValue: the matched status code array
27
+ let matchedLen = -1, matchedValue = [];
28
+ // Iterate the responseMap to find a match
29
+ for (const [key, value] of Object.entries(responseMap)) {
30
+ // Extracting the path from the map key which is in format
31
+ // GET /path/foo
32
+ if (!key.startsWith(method)) {
33
+ continue;
34
+ }
35
+ const candidatePath = getPathFromMapKey(key);
36
+ // Get each part of the url path
37
+ const candidateParts = candidatePath.split("/");
38
+ // track if we have found a match to return the values found.
39
+ let found = true;
40
+ for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
41
+ if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
42
+ const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
43
+ // If the current part of the candidate is a "template" part
44
+ // Try to use the suffix of pattern to match the path
45
+ // {guid} ==> $
46
+ // {guid}:export ==> :export$
47
+ const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
48
+ if (!isMatched) {
49
+ found = false;
50
+ break;
51
+ }
52
+ continue;
53
+ }
54
+ // If the candidate part is not a template and
55
+ // the parts don't match mark the candidate as not found
56
+ // to move on with the next candidate path.
57
+ if (candidateParts[i] !== pathParts[j]) {
58
+ found = false;
59
+ break;
60
+ }
61
+ }
62
+ // We finished evaluating the current candidate parts
63
+ // Update the matched value if and only if we found the longer pattern
64
+ if (found && candidatePath.length > matchedLen) {
65
+ matchedLen = candidatePath.length;
66
+ matchedValue = value;
67
+ }
68
+ }
69
+ return matchedValue;
70
+ }
71
+ function getPathFromMapKey(mapKey) {
72
+ const pathStart = mapKey.indexOf("/");
73
+ return mapKey.slice(pathStart);
74
+ }
75
+ //# sourceMappingURL=isUnexpected.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../../src/src/rest/isUnexpected.ts"],"names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CAA2C;YAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE;gBACtC,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM;aACP;SACF;QAED,qDAAqD;QACrD,sEAAsE;QACtE,IAAI,KAAK,IAAI,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE;YAC9C,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,YAAY,GAAG,KAAK,CAAC;SACtB;KACF;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","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 {\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"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../../src/src/rest/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","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\nexport interface CreateWidget {\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: \"red\" | \"blue\";\n}\n\nexport interface UpdateWidget {\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?: \"red\" | \"blue\";\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=outputModels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"outputModels.js","sourceRoot":"","sources":["../../../../src/src/rest/outputModels.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","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\nexport interface WidgetOutput {\n /** The UUID of this widget. This is generated automatically by the service. */\n id: string;\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: \"red\" | \"blue\";\n}\n\nexport interface WidgetErrorOutput {\n /** The HTTP error code. */\n code: number;\n /** A human-readable message describing the error. */\n message: string;\n}\n\nexport interface AnalyzeResultOutput {\n summary: string;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=parameters.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parameters.js","sourceRoot":"","sources":["../../../../src/src/rest/parameters.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","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 { RequestParameters } from \"@azure-rest/core-client\";\nimport { CreateWidget, UpdateWidget } from \"./models.js\";\n\nexport type ListWidgetsParameters = RequestParameters;\nexport type GetWidgetParameters = RequestParameters;\n\nexport interface CreateWidgetBodyParam {\n body?: CreateWidget;\n}\n\nexport type CreateWidgetParameters = CreateWidgetBodyParam & RequestParameters;\n\nexport interface UpdateWidgetBodyParam {\n body?: UpdateWidget;\n}\n\nexport type UpdateWidgetParameters = UpdateWidgetBodyParam & RequestParameters;\nexport type DeleteWidgetParameters = RequestParameters;\nexport type AnalyzeWidgetParameters = RequestParameters;\n"]}
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ export {};
4
+ //# sourceMappingURL=responses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"responses.js","sourceRoot":"","sources":["../../../../src/src/rest/responses.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","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 { HttpResponse } from \"@azure-rest/core-client\";\nimport { WidgetOutput, WidgetErrorOutput, AnalyzeResultOutput } from \"./outputModels.js\";\n\n/** The request has succeeded. */\nexport interface ListWidgets200Response extends HttpResponse {\n status: \"200\";\n body: Array<WidgetOutput>;\n}\n\nexport interface ListWidgetsDefaultResponse extends HttpResponse {\n status: string;\n body: WidgetErrorOutput;\n}\n\n/** The request has succeeded. */\nexport interface GetWidget200Response extends HttpResponse {\n status: \"200\";\n body: WidgetOutput;\n}\n\nexport interface GetWidgetDefaultResponse extends HttpResponse {\n status: string;\n body: WidgetErrorOutput;\n}\n\n/** The request has succeeded and a new resource has been created as a result. */\nexport interface CreateWidget201Response extends HttpResponse {\n status: \"201\";\n body: WidgetOutput;\n}\n\nexport interface CreateWidgetDefaultResponse extends HttpResponse {\n status: string;\n body: WidgetErrorOutput;\n}\n\n/** The request has succeeded. */\nexport interface UpdateWidget200Response extends HttpResponse {\n status: \"200\";\n body: WidgetOutput;\n}\n\nexport interface UpdateWidgetDefaultResponse extends HttpResponse {\n status: string;\n body: WidgetErrorOutput;\n}\n\n/** There is no content to send for this request, but the headers may be useful. */\nexport interface DeleteWidget204Response extends HttpResponse {\n status: \"204\";\n}\n\nexport interface DeleteWidgetDefaultResponse extends HttpResponse {\n status: string;\n body: WidgetErrorOutput;\n}\n\n/** The request has succeeded. */\nexport interface AnalyzeWidget200Response extends HttpResponse {\n status: \"200\";\n body: AnalyzeResultOutput;\n}\n\nexport interface AnalyzeWidgetDefaultResponse extends HttpResponse {\n status: string;\n body: WidgetErrorOutput;\n}\n"]}
@@ -0,0 +1,46 @@
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 { addCredentialPipelinePolicy, getClient } from "@azure-rest/core-client";
11
+ import { isTokenCredential } from "@azure/core-auth";
12
+ import { logger } from "../logger.js";
13
+ export default function createClient(endpoint, credentialOrOptions, options = {}) {
14
+ let credential;
15
+ if (isTokenCredential(credentialOrOptions)) {
16
+ credential = credentialOrOptions;
17
+ }
18
+ else {
19
+ options = credentialOrOptions !== null && credentialOrOptions !== void 0 ? credentialOrOptions : {};
20
+ }
21
+ const client = _createClient(endpoint, options);
22
+ addCredentialPipelinePolicy(client.pipeline, endpoint, { credential, clientOptions: options });
23
+ return client;
24
+ }
25
+ /**
26
+ * Initialize a new instance of `WidgetServiceContext`
27
+ * @param endpoint - The parameter endpoint
28
+ * @param options - the parameter for all optional parameters
29
+ */
30
+ function _createClient(endpoint, options = {}) {
31
+ var _a, _b, _c, _d;
32
+ const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${endpoint}`;
33
+ options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "1.0.0";
34
+ const userAgentInfo = `azsdk-js-widget-rest/1.0.0-beta.1`;
35
+ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
36
+ ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
37
+ : `${userAgentInfo}`;
38
+ options = Object.assign(Object.assign({}, options), { userAgentOptions: {
39
+ userAgentPrefix,
40
+ }, loggingOptions: {
41
+ logger: (_d = (_c = options.loggingOptions) === null || _c === void 0 ? void 0 : _c.logger) !== null && _d !== void 0 ? _d : logger.info,
42
+ } });
43
+ const client = getClient(baseUrl, options);
44
+ return client;
45
+ }
46
+ //# sourceMappingURL=widgetServiceClient.js.map