@azure-rest/onlineexperimentation 1.0.0-alpha.20250613.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +98 -0
  4. package/dist/browser/clientDefinitions.d.ts +30 -0
  5. package/dist/browser/clientDefinitions.js +3 -0
  6. package/dist/browser/extensibleEnums.d.ts +99 -0
  7. package/dist/browser/extensibleEnums.js +106 -0
  8. package/dist/browser/index.d.ts +11 -0
  9. package/dist/browser/index.js +13 -0
  10. package/dist/browser/isUnexpected.d.ts +6 -0
  11. package/dist/browser/isUnexpected.js +72 -0
  12. package/dist/browser/logger.d.ts +1 -0
  13. package/dist/browser/logger.js +4 -0
  14. package/dist/browser/models.d.ts +104 -0
  15. package/dist/browser/models.js +3 -0
  16. package/dist/browser/onlineExperimentationClient.d.ts +15 -0
  17. package/dist/browser/onlineExperimentationClient.js +45 -0
  18. package/dist/browser/outputModels.d.ts +137 -0
  19. package/dist/browser/outputModels.js +3 -0
  20. package/dist/browser/package.json +3 -0
  21. package/dist/browser/paginateHelper.d.ts +67 -0
  22. package/dist/browser/paginateHelper.js +136 -0
  23. package/dist/browser/parameters.d.ts +92 -0
  24. package/dist/browser/parameters.js +3 -0
  25. package/dist/browser/responses.d.ts +113 -0
  26. package/dist/browser/responses.js +3 -0
  27. package/dist/commonjs/clientDefinitions.d.ts +30 -0
  28. package/dist/commonjs/clientDefinitions.js +4 -0
  29. package/dist/commonjs/extensibleEnums.d.ts +99 -0
  30. package/dist/commonjs/extensibleEnums.js +109 -0
  31. package/dist/commonjs/index.d.ts +11 -0
  32. package/dist/commonjs/index.js +33 -0
  33. package/dist/commonjs/isUnexpected.d.ts +6 -0
  34. package/dist/commonjs/isUnexpected.js +75 -0
  35. package/dist/commonjs/logger.d.ts +1 -0
  36. package/dist/commonjs/logger.js +7 -0
  37. package/dist/commonjs/models.d.ts +104 -0
  38. package/dist/commonjs/models.js +4 -0
  39. package/dist/commonjs/onlineExperimentationClient.d.ts +15 -0
  40. package/dist/commonjs/onlineExperimentationClient.js +48 -0
  41. package/dist/commonjs/outputModels.d.ts +137 -0
  42. package/dist/commonjs/outputModels.js +4 -0
  43. package/dist/commonjs/package.json +3 -0
  44. package/dist/commonjs/paginateHelper.d.ts +67 -0
  45. package/dist/commonjs/paginateHelper.js +139 -0
  46. package/dist/commonjs/parameters.d.ts +92 -0
  47. package/dist/commonjs/parameters.js +4 -0
  48. package/dist/commonjs/responses.d.ts +113 -0
  49. package/dist/commonjs/responses.js +4 -0
  50. package/dist/commonjs/tsdoc-metadata.json +11 -0
  51. package/dist/esm/clientDefinitions.d.ts +30 -0
  52. package/dist/esm/clientDefinitions.js +3 -0
  53. package/dist/esm/extensibleEnums.d.ts +99 -0
  54. package/dist/esm/extensibleEnums.js +106 -0
  55. package/dist/esm/index.d.ts +11 -0
  56. package/dist/esm/index.js +13 -0
  57. package/dist/esm/isUnexpected.d.ts +6 -0
  58. package/dist/esm/isUnexpected.js +72 -0
  59. package/dist/esm/logger.d.ts +1 -0
  60. package/dist/esm/logger.js +4 -0
  61. package/dist/esm/models.d.ts +104 -0
  62. package/dist/esm/models.js +3 -0
  63. package/dist/esm/onlineExperimentationClient.d.ts +15 -0
  64. package/dist/esm/onlineExperimentationClient.js +45 -0
  65. package/dist/esm/outputModels.d.ts +137 -0
  66. package/dist/esm/outputModels.js +3 -0
  67. package/dist/esm/package.json +3 -0
  68. package/dist/esm/paginateHelper.d.ts +67 -0
  69. package/dist/esm/paginateHelper.js +136 -0
  70. package/dist/esm/parameters.d.ts +92 -0
  71. package/dist/esm/parameters.js +3 -0
  72. package/dist/esm/responses.d.ts +113 -0
  73. package/dist/esm/responses.js +3 -0
  74. package/dist/react-native/clientDefinitions.d.ts +30 -0
  75. package/dist/react-native/clientDefinitions.js +3 -0
  76. package/dist/react-native/extensibleEnums.d.ts +99 -0
  77. package/dist/react-native/extensibleEnums.js +106 -0
  78. package/dist/react-native/index.d.ts +11 -0
  79. package/dist/react-native/index.js +13 -0
  80. package/dist/react-native/isUnexpected.d.ts +6 -0
  81. package/dist/react-native/isUnexpected.js +72 -0
  82. package/dist/react-native/logger.d.ts +1 -0
  83. package/dist/react-native/logger.js +4 -0
  84. package/dist/react-native/models.d.ts +104 -0
  85. package/dist/react-native/models.js +3 -0
  86. package/dist/react-native/onlineExperimentationClient.d.ts +15 -0
  87. package/dist/react-native/onlineExperimentationClient.js +45 -0
  88. package/dist/react-native/outputModels.d.ts +137 -0
  89. package/dist/react-native/outputModels.js +3 -0
  90. package/dist/react-native/package.json +3 -0
  91. package/dist/react-native/paginateHelper.d.ts +67 -0
  92. package/dist/react-native/paginateHelper.js +136 -0
  93. package/dist/react-native/parameters.d.ts +92 -0
  94. package/dist/react-native/parameters.js +3 -0
  95. package/dist/react-native/responses.d.ts +113 -0
  96. package/dist/react-native/responses.js +3 -0
  97. package/package.json +138 -0
  98. package/review/onlineexperimentation.api.md +612 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # Release History
2
+
3
+ ## 1.0.0-beta.1 (2025-06-10)
4
+
5
+ ### Features Added
6
+
7
+ Initial release of the @azure-rest/onlineexperimentation package
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) Microsoft Corporation.
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # Azure OnlineExperimentation REST client library for JavaScript
2
+
3
+ Azure Online Experimentation Service
4
+
5
+ **Please rely heavily on our [REST client docs](https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md) to use this library**
6
+
7
+ Key links:
8
+
9
+ - [Source code](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/onlineexperimentation/onlineexperimentation-rest)
10
+ - [Package (NPM)](https://www.npmjs.com/package/@azure-rest/onlineexperimentation)
11
+
12
+ ## Getting started
13
+
14
+ ### Currently supported environments
15
+
16
+ - LTS versions of Node.js
17
+
18
+ ### Prerequisites
19
+
20
+ - You must have an [Azure subscription](https://azure.microsoft.com/free/) to use this package.
21
+
22
+ ### Install the `@azure-rest/onlineexperimentation` package
23
+
24
+ Install the Azure OnlineExperimentation REST client REST client library for JavaScript with `npm`:
25
+
26
+ ```bash
27
+ npm install @azure-rest/onlineexperimentation
28
+ ```
29
+
30
+ ### Create and authenticate a `OnlineExperimentationClient`
31
+
32
+ The Azure Online Experimentation client library initialization requires two parameters:
33
+
34
+ - The `endpoint` property value from the [`Microsoft.OnlineExperimentation/workspaces`](https://learn.microsoft.com/azure/templates/microsoft.onlineexperimentation/workspaces) resource.
35
+ - A `TokenCredential` for authentication, the simplest approach is to use [`DefaultAzureCredential`](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential) from the `@azure/identity` library.
36
+
37
+ ```ts snippet:InitializeClient
38
+ import { DefaultAzureCredential } from "@azure/identity";
39
+ import { OnlineExperimentationClient } from "@azure-rest/onlineexperimentation";
40
+
41
+ const endpoint = process.env.AZURE_ONLINEEXPERIMENTATION_ENDPOINT || "<endpoint>";
42
+ const credential = new DefaultAzureCredential();
43
+ // Initialize a client with default API version
44
+ const client = OnlineExperimentationClient(endpoint, credential);
45
+ ```
46
+
47
+ ## Examples
48
+
49
+ - Full set of [examples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/onlineexperimentation/onlineexperimentation-rest/EXAMPLES.md) demonstrating individual API operations.
50
+ - Example demonstrating experiment metrics management lifecycle: [TypeScript](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/onlineexperimentation/onlineexperimentation-rest/samples/v1-beta/typescript/README.md) and [JavaScript](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/onlineexperimentation/onlineexperimentation-rest/samples/v1-beta/javascript/README.md).
51
+
52
+ ### Quick Start - Initialize Client and List Experiment Metrics
53
+
54
+ The Azure OnlineExperimentation REST client library initialization requires two parameters:
55
+
56
+ - The `endpoint` property value from the [`Microsoft.OnlineExperimentation/workspaces`](https://learn.microsoft.com/azure/templates/microsoft.onlineexperimentation/workspaces) resource.
57
+ - A `TokenCredential` for authentication, the simplest approach is to use [`DefaultAzureCredential`](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/identity/identity/README.md#defaultazurecredential).
58
+
59
+ ```ts snippet:ListExperimentMetrics
60
+ import { DefaultAzureCredential } from "@azure/identity";
61
+ import {
62
+ OnlineExperimentationClient,
63
+ isUnexpected,
64
+ paginate,
65
+ } from "@azure-rest/onlineexperimentation";
66
+
67
+ const endpoint = process.env.AZURE_ONLINEEXPERIMENTATION_ENDPOINT || "<endpoint>";
68
+ const credential = new DefaultAzureCredential();
69
+ const client = OnlineExperimentationClient(endpoint, credential);
70
+ const listResponse = await client.path("/experiment-metrics").get({
71
+ queryParameters: {
72
+ top: 10,
73
+ skip: 0,
74
+ },
75
+ });
76
+ if (isUnexpected(listResponse)) {
77
+ throw listResponse;
78
+ }
79
+ for await (const metric of paginate(client, listResponse)) {
80
+ // Access metric properties
81
+ const id = metric.id;
82
+ const name = metric.displayName;
83
+ }
84
+ ```
85
+
86
+ ## Troubleshooting
87
+
88
+ ### Logging
89
+
90
+ 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`:
91
+
92
+ ```ts snippet:SetLogLevel
93
+ import { setLogLevel } from "@azure/logger";
94
+
95
+ setLogLevel("info");
96
+ ```
97
+
98
+ 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).
@@ -0,0 +1,30 @@
1
+ import type { GetMetricParameters, CreateOrUpdateMetricParameters, DeleteMetricParameters, ValidateMetricParameters, ListMetricsParameters } from "./parameters.js";
2
+ import type { GetMetric200Response, GetMetricDefaultResponse, CreateOrUpdateMetric200Response, CreateOrUpdateMetric201Response, CreateOrUpdateMetricDefaultResponse, DeleteMetric204Response, DeleteMetricDefaultResponse, ValidateMetric200Response, ValidateMetricDefaultResponse, ListMetrics200Response, ListMetricsDefaultResponse } from "./responses.js";
3
+ import type { Client, StreamableMethod } from "@azure-rest/core-client";
4
+ export interface GetMetric {
5
+ /** Fetches an experiment metric by ID. */
6
+ get(options?: GetMetricParameters): StreamableMethod<GetMetric200Response | GetMetricDefaultResponse>;
7
+ /** Creates or updates an experiment metric. */
8
+ patch(options: CreateOrUpdateMetricParameters): StreamableMethod<CreateOrUpdateMetric200Response | CreateOrUpdateMetric201Response | CreateOrUpdateMetricDefaultResponse>;
9
+ /** Deletes an experiment metric. */
10
+ delete(options?: DeleteMetricParameters): StreamableMethod<DeleteMetric204Response | DeleteMetricDefaultResponse>;
11
+ }
12
+ export interface ValidateMetric {
13
+ /** Validates an experiment metric definition. */
14
+ post(options: ValidateMetricParameters): StreamableMethod<ValidateMetric200Response | ValidateMetricDefaultResponse>;
15
+ }
16
+ export interface ListMetrics {
17
+ /** Lists experiment metrics. */
18
+ get(options?: ListMetricsParameters): StreamableMethod<ListMetrics200Response | ListMetricsDefaultResponse>;
19
+ }
20
+ export interface Routes {
21
+ /** Resource for '/experiment-metrics/\{experimentMetricId\}' has methods for the following verbs: get, patch, delete */
22
+ (path: "/experiment-metrics/{experimentMetricId}", experimentMetricId: string): GetMetric;
23
+ /** Resource for '/experiment-metrics:validate' has methods for the following verbs: post */
24
+ (path: "/experiment-metrics:validate"): ValidateMetric;
25
+ /** Resource for '/experiment-metrics' has methods for the following verbs: get */
26
+ (path: "/experiment-metrics"): ListMetrics;
27
+ }
28
+ export type OnlineExperimentationClient = Client & {
29
+ path: Routes;
30
+ };
@@ -0,0 +1,3 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Desired direction for an experiment metric value.
3
+ */
4
+ export declare enum KnownDesiredDirection {
5
+ /**
6
+ * An increase to the metric value is desired. E.g., Success rate, Total revenue.
7
+ */
8
+ Increase = "Increase",
9
+ /**
10
+ * A decrease to the metric value is desired. E.g., Error rate, Latency.
11
+ */
12
+ Decrease = "Decrease",
13
+ /**
14
+ * Neither an increase nor a decrease to the metric value is desired, or the desired direction depends on other factors. E.g., Number of video play attempts, Number of user feedbacks
15
+ */
16
+ Neutral = "Neutral"
17
+ }
18
+ /**
19
+ * How the metric definition calculates metric values from event data.
20
+ */
21
+ export declare enum KnownExperimentMetricType {
22
+ /**
23
+ * Counts the occurrences of an event. Experiment analysis accounts for unequal traffic allocation.
24
+ */
25
+ EventCount = "EventCount",
26
+ /**
27
+ * Counts the number of unique users who encounter an event. Experiment analysis accounts for unequal traffic allocation.
28
+ */
29
+ UserCount = "UserCount",
30
+ /**
31
+ * Calculates the percentage of events that satisfy a specified condition.
32
+ */
33
+ EventRate = "EventRate",
34
+ /**
35
+ * Calculates the percentage of users who encounter a start event and subsequently encounter an end event. Users must encounter the start event before the end event to be counted.
36
+ */
37
+ UserRate = "UserRate",
38
+ /**
39
+ * Calculates the sum of a specified event property. Experiment analysis accounts for unequal traffic allocation.
40
+ */
41
+ Sum = "Sum",
42
+ /**
43
+ * Calculates the average value of a specified event property.
44
+ */
45
+ Average = "Average",
46
+ /**
47
+ * Calculates a specified percentile of an event property.
48
+ */
49
+ Percentile = "Percentile"
50
+ }
51
+ /**
52
+ * Lifecycle stages of an experiment metric, determining whether the metric is included in experiment analysis.
53
+ */
54
+ export declare enum KnownLifecycleStage {
55
+ /**
56
+ * The metric is included in experiment analysis.
57
+ */
58
+ Active = "Active",
59
+ /**
60
+ * The metric is excluded from experiment analysis but remains available for future use.
61
+ */
62
+ Inactive = "Inactive"
63
+ }
64
+ /**
65
+ * The diagnostic error codes.
66
+ */
67
+ export declare enum KnownDiagnosticCode {
68
+ /**
69
+ * The metric definition does not conform to the JSON schema.
70
+ */
71
+ FailedSchemaValidation = "FailedSchemaValidation",
72
+ /**
73
+ * The event filter condition is invalid.
74
+ */
75
+ InvalidEventCondition = "InvalidEventCondition",
76
+ /**
77
+ * Event filter condition has valid syntax but is not currently supported.
78
+ */
79
+ UnsupportedEventCondition = "UnsupportedEventCondition",
80
+ /**
81
+ * The provided experiment metric definition is invalid.
82
+ * For example, defining a metric to calculate the average of a numeric property but
83
+ * including a filter condition that compares it to a string value creates a type mismatch.
84
+ */
85
+ InvalidExperimentMetricDefinition = "InvalidExperimentMetricDefinition"
86
+ }
87
+ /**
88
+ * The result of validating an experiment metric.
89
+ */
90
+ export declare enum KnownValidationResult {
91
+ /**
92
+ * The experiment metric is valid.
93
+ */
94
+ Valid = "Valid",
95
+ /**
96
+ * The experiment metric is invalid.
97
+ */
98
+ Invalid = "Invalid"
99
+ }
@@ -0,0 +1,106 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ /**
4
+ * Desired direction for an experiment metric value.
5
+ */
6
+ export var KnownDesiredDirection;
7
+ (function (KnownDesiredDirection) {
8
+ /**
9
+ * An increase to the metric value is desired. E.g., Success rate, Total revenue.
10
+ */
11
+ KnownDesiredDirection["Increase"] = "Increase";
12
+ /**
13
+ * A decrease to the metric value is desired. E.g., Error rate, Latency.
14
+ */
15
+ KnownDesiredDirection["Decrease"] = "Decrease";
16
+ /**
17
+ * Neither an increase nor a decrease to the metric value is desired, or the desired direction depends on other factors. E.g., Number of video play attempts, Number of user feedbacks
18
+ */
19
+ KnownDesiredDirection["Neutral"] = "Neutral";
20
+ })(KnownDesiredDirection || (KnownDesiredDirection = {}));
21
+ /**
22
+ * How the metric definition calculates metric values from event data.
23
+ */
24
+ export var KnownExperimentMetricType;
25
+ (function (KnownExperimentMetricType) {
26
+ /**
27
+ * Counts the occurrences of an event. Experiment analysis accounts for unequal traffic allocation.
28
+ */
29
+ KnownExperimentMetricType["EventCount"] = "EventCount";
30
+ /**
31
+ * Counts the number of unique users who encounter an event. Experiment analysis accounts for unequal traffic allocation.
32
+ */
33
+ KnownExperimentMetricType["UserCount"] = "UserCount";
34
+ /**
35
+ * Calculates the percentage of events that satisfy a specified condition.
36
+ */
37
+ KnownExperimentMetricType["EventRate"] = "EventRate";
38
+ /**
39
+ * Calculates the percentage of users who encounter a start event and subsequently encounter an end event. Users must encounter the start event before the end event to be counted.
40
+ */
41
+ KnownExperimentMetricType["UserRate"] = "UserRate";
42
+ /**
43
+ * Calculates the sum of a specified event property. Experiment analysis accounts for unequal traffic allocation.
44
+ */
45
+ KnownExperimentMetricType["Sum"] = "Sum";
46
+ /**
47
+ * Calculates the average value of a specified event property.
48
+ */
49
+ KnownExperimentMetricType["Average"] = "Average";
50
+ /**
51
+ * Calculates a specified percentile of an event property.
52
+ */
53
+ KnownExperimentMetricType["Percentile"] = "Percentile";
54
+ })(KnownExperimentMetricType || (KnownExperimentMetricType = {}));
55
+ /**
56
+ * Lifecycle stages of an experiment metric, determining whether the metric is included in experiment analysis.
57
+ */
58
+ export var KnownLifecycleStage;
59
+ (function (KnownLifecycleStage) {
60
+ /**
61
+ * The metric is included in experiment analysis.
62
+ */
63
+ KnownLifecycleStage["Active"] = "Active";
64
+ /**
65
+ * The metric is excluded from experiment analysis but remains available for future use.
66
+ */
67
+ KnownLifecycleStage["Inactive"] = "Inactive";
68
+ })(KnownLifecycleStage || (KnownLifecycleStage = {}));
69
+ /**
70
+ * The diagnostic error codes.
71
+ */
72
+ export var KnownDiagnosticCode;
73
+ (function (KnownDiagnosticCode) {
74
+ /**
75
+ * The metric definition does not conform to the JSON schema.
76
+ */
77
+ KnownDiagnosticCode["FailedSchemaValidation"] = "FailedSchemaValidation";
78
+ /**
79
+ * The event filter condition is invalid.
80
+ */
81
+ KnownDiagnosticCode["InvalidEventCondition"] = "InvalidEventCondition";
82
+ /**
83
+ * Event filter condition has valid syntax but is not currently supported.
84
+ */
85
+ KnownDiagnosticCode["UnsupportedEventCondition"] = "UnsupportedEventCondition";
86
+ /**
87
+ * The provided experiment metric definition is invalid.
88
+ * For example, defining a metric to calculate the average of a numeric property but
89
+ * including a filter condition that compares it to a string value creates a type mismatch.
90
+ */
91
+ KnownDiagnosticCode["InvalidExperimentMetricDefinition"] = "InvalidExperimentMetricDefinition";
92
+ })(KnownDiagnosticCode || (KnownDiagnosticCode = {}));
93
+ /**
94
+ * The result of validating an experiment metric.
95
+ */
96
+ export var KnownValidationResult;
97
+ (function (KnownValidationResult) {
98
+ /**
99
+ * The experiment metric is valid.
100
+ */
101
+ KnownValidationResult["Valid"] = "Valid";
102
+ /**
103
+ * The experiment metric is invalid.
104
+ */
105
+ KnownValidationResult["Invalid"] = "Invalid";
106
+ })(KnownValidationResult || (KnownValidationResult = {}));
@@ -0,0 +1,11 @@
1
+ import OnlineExperimentationClient from "./onlineExperimentationClient.js";
2
+ export * from "./onlineExperimentationClient.js";
3
+ export * from "./parameters.js";
4
+ export * from "./responses.js";
5
+ export * from "./clientDefinitions.js";
6
+ export * from "./isUnexpected.js";
7
+ export * from "./models.js";
8
+ export * from "./outputModels.js";
9
+ export * from "./paginateHelper.js";
10
+ export * from "./extensibleEnums.js";
11
+ export { OnlineExperimentationClient };
@@ -0,0 +1,13 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import OnlineExperimentationClient from "./onlineExperimentationClient.js";
4
+ export * from "./onlineExperimentationClient.js";
5
+ export * from "./parameters.js";
6
+ export * from "./responses.js";
7
+ export * from "./clientDefinitions.js";
8
+ export * from "./isUnexpected.js";
9
+ export * from "./models.js";
10
+ export * from "./outputModels.js";
11
+ export * from "./paginateHelper.js";
12
+ export * from "./extensibleEnums.js";
13
+ export { OnlineExperimentationClient };
@@ -0,0 +1,6 @@
1
+ import type { GetMetric200Response, GetMetricDefaultResponse, CreateOrUpdateMetric200Response, CreateOrUpdateMetric201Response, CreateOrUpdateMetricDefaultResponse, DeleteMetric204Response, DeleteMetricDefaultResponse, ValidateMetric200Response, ValidateMetricDefaultResponse, ListMetrics200Response, ListMetricsDefaultResponse } from "./responses.js";
2
+ export declare function isUnexpected(response: GetMetric200Response | GetMetricDefaultResponse): response is GetMetricDefaultResponse;
3
+ export declare function isUnexpected(response: CreateOrUpdateMetric200Response | CreateOrUpdateMetric201Response | CreateOrUpdateMetricDefaultResponse): response is CreateOrUpdateMetricDefaultResponse;
4
+ export declare function isUnexpected(response: DeleteMetric204Response | DeleteMetricDefaultResponse): response is DeleteMetricDefaultResponse;
5
+ export declare function isUnexpected(response: ValidateMetric200Response | ValidateMetricDefaultResponse): response is ValidateMetricDefaultResponse;
6
+ export declare function isUnexpected(response: ListMetrics200Response | ListMetricsDefaultResponse): response is ListMetricsDefaultResponse;
@@ -0,0 +1,72 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ const responseMap = {
4
+ "GET /experiment-metrics/{experimentMetricId}": ["200"],
5
+ "PATCH /experiment-metrics/{experimentMetricId}": ["200", "201"],
6
+ "DELETE /experiment-metrics/{experimentMetricId}": ["204"],
7
+ "POST /experiment-metrics:validate": ["200"],
8
+ "GET /experiment-metrics": ["200"],
9
+ };
10
+ export function isUnexpected(response) {
11
+ const lroOriginal = response.headers["x-ms-original-url"];
12
+ const url = new URL(lroOriginal ?? response.request.url);
13
+ const method = response.request.method;
14
+ let pathDetails = responseMap[`${method} ${url.pathname}`];
15
+ if (!pathDetails) {
16
+ pathDetails = getParametrizedPathSuccess(method, url.pathname);
17
+ }
18
+ return !pathDetails.includes(response.status);
19
+ }
20
+ function getParametrizedPathSuccess(method, path) {
21
+ const pathParts = path.split("/");
22
+ // Traverse list to match the longest candidate
23
+ // matchedLen: the length of candidate path
24
+ // matchedValue: the matched status code array
25
+ let matchedLen = -1, matchedValue = [];
26
+ // Iterate the responseMap to find a match
27
+ for (const [key, value] of Object.entries(responseMap)) {
28
+ // Extracting the path from the map key which is in format
29
+ // GET /path/foo
30
+ if (!key.startsWith(method)) {
31
+ continue;
32
+ }
33
+ const candidatePath = getPathFromMapKey(key);
34
+ // Get each part of the url path
35
+ const candidateParts = candidatePath.split("/");
36
+ // track if we have found a match to return the values found.
37
+ let found = true;
38
+ for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
39
+ if (candidateParts[i]?.startsWith("{") && candidateParts[i]?.indexOf("}") !== -1) {
40
+ const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length;
41
+ // If the current part of the candidate is a "template" part
42
+ // Try to use the suffix of pattern to match the path
43
+ // {guid} ==> $
44
+ // {guid}:export ==> :export$
45
+ const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || "");
46
+ if (!isMatched) {
47
+ found = false;
48
+ break;
49
+ }
50
+ continue;
51
+ }
52
+ // If the candidate part is not a template and
53
+ // the parts don't match mark the candidate as not found
54
+ // to move on with the next candidate path.
55
+ if (candidateParts[i] !== pathParts[j]) {
56
+ found = false;
57
+ break;
58
+ }
59
+ }
60
+ // We finished evaluating the current candidate parts
61
+ // Update the matched value if and only if we found the longer pattern
62
+ if (found && candidatePath.length > matchedLen) {
63
+ matchedLen = candidatePath.length;
64
+ matchedValue = value;
65
+ }
66
+ }
67
+ return matchedValue;
68
+ }
69
+ function getPathFromMapKey(mapKey) {
70
+ const pathStart = mapKey.indexOf("/");
71
+ return mapKey.slice(pathStart);
72
+ }
@@ -0,0 +1 @@
1
+ export declare const logger: import("@azure/logger").AzureLogger;
@@ -0,0 +1,4 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { createClientLogger } from "@azure/logger";
4
+ export const logger = createClientLogger("onlineexperimentation");
@@ -0,0 +1,104 @@
1
+ /** Defines experiment metric metadata and computation details. */
2
+ export interface ExperimentMetric {
3
+ /**
4
+ * Determines whether it is included in experiment analysis.
5
+ *
6
+ * Possible values: "Active", "Inactive"
7
+ */
8
+ lifecycle: LifecycleStage;
9
+ /** A user-friendly display name for the experiment metric shown in reports and dashboards. */
10
+ displayName: string;
11
+ /** A detailed description of the experiment metric. */
12
+ description: string;
13
+ /** Categories associated with the experiment metric. Used for organizing and filtering metrics. */
14
+ categories: string[];
15
+ /**
16
+ * The desired direction for changes in the metric value.
17
+ *
18
+ * Possible values: "Increase", "Decrease", "Neutral"
19
+ */
20
+ desiredDirection: DesiredDirection;
21
+ /** The metric definition specifying how the metric value is calculated from event data. */
22
+ definition: ExperimentMetricDefinition;
23
+ }
24
+ /** The metric definition, which determines how the metric value is calculated from event data. */
25
+ export interface ExperimentMetricDefinitionParent {
26
+ type: string;
27
+ }
28
+ /** The definition of an EventCount metric definition. Counts the occurrences of a specified event. */
29
+ export interface EventCountMetricDefinition extends ExperimentMetricDefinitionParent {
30
+ /** The type of metric. */
31
+ type: "EventCount";
32
+ /** Event to observe. */
33
+ event: ObservedEvent;
34
+ }
35
+ /** An event observed by a metric. */
36
+ export interface ObservedEvent {
37
+ /** The name of the event. */
38
+ eventName: string;
39
+ /** [Optional] A condition to filter events. */
40
+ filter?: string;
41
+ }
42
+ /** The definition of a UserCount metric definition. Counts unique users who encounter a specified event. */
43
+ export interface UserCountMetricDefinition extends ExperimentMetricDefinitionParent {
44
+ /** The type of metric. */
45
+ type: "UserCount";
46
+ /** Event to observe. */
47
+ event: ObservedEvent;
48
+ }
49
+ /** The definition of an EventRate metric definition. Calculates the percentage of events satisfying a specified condition. */
50
+ export interface EventRateMetricDefinition extends ExperimentMetricDefinitionParent {
51
+ /** The type of metric. */
52
+ type: "EventRate";
53
+ /** Event to observe as the rate denominator. */
54
+ event: ObservedEvent;
55
+ /** The event contributes to the rate numerator if it satisfies this condition. */
56
+ rateCondition: string;
57
+ }
58
+ /** The definition of a UserRate metric definition. Calculates the percentage of users who encounter a start event and subsequently an end event. Users must encounter events in the specified order. */
59
+ export interface UserRateMetricDefinition extends ExperimentMetricDefinitionParent {
60
+ /** The type of metric. */
61
+ type: "UserRate";
62
+ /** The start event to observe as the rate denominator. */
63
+ startEvent: ObservedEvent;
64
+ /** The end event to observe, which is a condition for the rate numerator. */
65
+ endEvent: ObservedEvent;
66
+ }
67
+ /** The definition of a Sum metric definition. Calculates the sum of a specified event property. Experiment analysis accounts for unequal traffic allocation. */
68
+ export interface SumMetricDefinition extends ExperimentMetricDefinitionParent {
69
+ /** The type of metric. */
70
+ type: "Sum";
71
+ /** The value to aggregate. */
72
+ value: AggregatedValue;
73
+ }
74
+ /** An event property value aggregated by a metric. */
75
+ export interface AggregatedValue {
76
+ /** The name of the event. */
77
+ eventName: string;
78
+ /** [Optional] A condition to filter events. */
79
+ filter?: string;
80
+ /** The key of the event property to aggregate. */
81
+ eventProperty: string;
82
+ }
83
+ /** The definition of an Average metric definition. Calculates the average value of a specified event property. */
84
+ export interface AverageMetricDefinition extends ExperimentMetricDefinitionParent {
85
+ /** The type of metric. */
86
+ type: "Average";
87
+ /** The value to aggregate. */
88
+ value: AggregatedValue;
89
+ }
90
+ /** The definition of a Percentile metric definition. Calculates a specified percentile of an event property. */
91
+ export interface PercentileMetricDefinition extends ExperimentMetricDefinitionParent {
92
+ /** The type of metric. */
93
+ type: "Percentile";
94
+ /** The value to aggregate, including the event name and property to measure. */
95
+ value: AggregatedValue;
96
+ /** The percentile to measure. */
97
+ percentile: number;
98
+ }
99
+ /** The metric definition, which determines how the metric value is calculated from event data. */
100
+ export type ExperimentMetricDefinition = ExperimentMetricDefinitionParent | EventCountMetricDefinition | UserCountMetricDefinition | EventRateMetricDefinition | UserRateMetricDefinition | SumMetricDefinition | AverageMetricDefinition | PercentileMetricDefinition;
101
+ /** Alias for LifecycleStage */
102
+ export type LifecycleStage = string;
103
+ /** Alias for DesiredDirection */
104
+ export type DesiredDirection = string;
@@ -0,0 +1,3 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { ClientOptions } from "@azure-rest/core-client";
2
+ import type { TokenCredential } from "@azure/core-auth";
3
+ import type { OnlineExperimentationClient } from "./clientDefinitions.js";
4
+ /** The optional parameters for the client */
5
+ export interface OnlineExperimentationClientOptions extends ClientOptions {
6
+ /** The api version option of the client */
7
+ apiVersion?: string;
8
+ }
9
+ /**
10
+ * Initialize a new instance of `OnlineExperimentationClient`
11
+ * @param endpointParam - Endpoint URL for the Online Experimentation workspace.
12
+ * @param credentials - uniquely identify client credential
13
+ * @param options - the parameter for all optional parameters
14
+ */
15
+ export default function createClient(endpointParam: string, credentials: TokenCredential, { apiVersion, ...options }?: OnlineExperimentationClientOptions): OnlineExperimentationClient;
@@ -0,0 +1,45 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+ import { getClient } from "@azure-rest/core-client";
4
+ import { logger } from "./logger.js";
5
+ /**
6
+ * Initialize a new instance of `OnlineExperimentationClient`
7
+ * @param endpointParam - Endpoint URL for the Online Experimentation workspace.
8
+ * @param credentials - uniquely identify client credential
9
+ * @param options - the parameter for all optional parameters
10
+ */
11
+ export default function createClient(endpointParam, credentials, { apiVersion = "2025-05-31-preview", ...options } = {}) {
12
+ const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}`;
13
+ const userAgentInfo = `azsdk-js-@azure-rest/onlineexperimentation/1.0.0-beta.1`;
14
+ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
15
+ ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
16
+ : `${userAgentInfo}`;
17
+ const clientOptions = {
18
+ ...options,
19
+ userAgentOptions: {
20
+ userAgentPrefix,
21
+ },
22
+ loggingOptions: {
23
+ logger: options.loggingOptions?.logger ?? logger.info,
24
+ },
25
+ credentials: {
26
+ scopes: options.credentials?.scopes ?? ["https://exp.azure.net/.default"],
27
+ },
28
+ };
29
+ const client = getClient(endpointUrl, credentials, clientOptions);
30
+ client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
31
+ client.pipeline.addPolicy({
32
+ name: "ClientApiVersionPolicy",
33
+ sendRequest: (req, next) => {
34
+ // Use the apiVersion defined in request url directly
35
+ // Append one if there is no apiVersion and we have one at client options
36
+ const url = new URL(req.url);
37
+ if (!url.searchParams.get("api-version") && apiVersion) {
38
+ // eslint-disable-next-line no-param-reassign
39
+ req.url = `${req.url}${Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"}api-version=${apiVersion}`;
40
+ }
41
+ return next(req);
42
+ },
43
+ });
44
+ return client;
45
+ }