@microsoft/agents-a365-runtime 0.1.0-preview.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +33 -0
- package/dist/cjs/agentic-authorization-service.d.ts +28 -0
- package/dist/cjs/agentic-authorization-service.d.ts.map +1 -0
- package/dist/cjs/agentic-authorization-service.js +18 -0
- package/dist/cjs/agentic-authorization-service.js.map +1 -0
- package/dist/cjs/configuration/DefaultConfigurationProvider.d.ts +39 -0
- package/dist/cjs/configuration/DefaultConfigurationProvider.d.ts.map +1 -0
- package/dist/cjs/configuration/DefaultConfigurationProvider.js +47 -0
- package/dist/cjs/configuration/DefaultConfigurationProvider.js.map +1 -0
- package/dist/cjs/configuration/IConfigurationProvider.d.ts +8 -0
- package/dist/cjs/configuration/IConfigurationProvider.d.ts.map +1 -0
- package/dist/cjs/configuration/IConfigurationProvider.js +5 -0
- package/dist/cjs/configuration/IConfigurationProvider.js.map +1 -0
- package/dist/cjs/configuration/RuntimeConfiguration.d.ts +35 -0
- package/dist/cjs/configuration/RuntimeConfiguration.d.ts.map +1 -0
- package/dist/cjs/configuration/RuntimeConfiguration.js +71 -0
- package/dist/cjs/configuration/RuntimeConfiguration.js.map +1 -0
- package/dist/cjs/configuration/RuntimeConfigurationOptions.d.ts +35 -0
- package/dist/cjs/configuration/RuntimeConfigurationOptions.d.ts.map +1 -0
- package/dist/cjs/configuration/RuntimeConfigurationOptions.js +5 -0
- package/dist/cjs/configuration/RuntimeConfigurationOptions.js.map +1 -0
- package/dist/cjs/configuration/index.d.ts +5 -0
- package/dist/cjs/configuration/index.d.ts.map +1 -0
- package/dist/cjs/configuration/index.js +23 -0
- package/dist/cjs/configuration/index.js.map +1 -0
- package/dist/cjs/environment-utils.d.ts +98 -0
- package/dist/cjs/environment-utils.d.ts.map +1 -0
- package/dist/cjs/environment-utils.js +121 -0
- package/dist/cjs/environment-utils.js.map +1 -0
- package/dist/cjs/index.d.ts +8 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +26 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/operation-error.d.ts +24 -0
- package/dist/cjs/operation-error.d.ts.map +1 -0
- package/dist/cjs/operation-error.js +35 -0
- package/dist/cjs/operation-error.js.map +1 -0
- package/dist/cjs/operation-result.d.ts +41 -0
- package/dist/cjs/operation-result.d.ts.map +1 -0
- package/dist/cjs/operation-result.js +56 -0
- package/dist/cjs/operation-result.js.map +1 -0
- package/dist/cjs/power-platform-api-discovery.d.ts +30 -0
- package/dist/cjs/power-platform-api-discovery.d.ts.map +1 -0
- package/dist/cjs/power-platform-api-discovery.js +86 -0
- package/dist/cjs/power-platform-api-discovery.js.map +1 -0
- package/dist/cjs/utility.d.ts +73 -0
- package/dist/cjs/utility.d.ts.map +1 -0
- package/dist/cjs/utility.js +187 -0
- package/dist/cjs/utility.js.map +1 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.d.ts.map +1 -0
- package/dist/cjs/version.js +5 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/agentic-authorization-service.d.ts +28 -0
- package/dist/esm/agentic-authorization-service.d.ts.map +1 -0
- package/dist/esm/agentic-authorization-service.js +14 -0
- package/dist/esm/agentic-authorization-service.js.map +1 -0
- package/dist/esm/configuration/DefaultConfigurationProvider.d.ts +39 -0
- package/dist/esm/configuration/DefaultConfigurationProvider.d.ts.map +1 -0
- package/dist/esm/configuration/DefaultConfigurationProvider.js +43 -0
- package/dist/esm/configuration/DefaultConfigurationProvider.js.map +1 -0
- package/dist/esm/configuration/IConfigurationProvider.d.ts +8 -0
- package/dist/esm/configuration/IConfigurationProvider.d.ts.map +1 -0
- package/dist/esm/configuration/IConfigurationProvider.js +4 -0
- package/dist/esm/configuration/IConfigurationProvider.js.map +1 -0
- package/dist/esm/configuration/RuntimeConfiguration.d.ts +35 -0
- package/dist/esm/configuration/RuntimeConfiguration.d.ts.map +1 -0
- package/dist/esm/configuration/RuntimeConfiguration.js +67 -0
- package/dist/esm/configuration/RuntimeConfiguration.js.map +1 -0
- package/dist/esm/configuration/RuntimeConfigurationOptions.d.ts +35 -0
- package/dist/esm/configuration/RuntimeConfigurationOptions.d.ts.map +1 -0
- package/dist/esm/configuration/RuntimeConfigurationOptions.js +4 -0
- package/dist/esm/configuration/RuntimeConfigurationOptions.js.map +1 -0
- package/dist/esm/configuration/index.d.ts +5 -0
- package/dist/esm/configuration/index.d.ts.map +1 -0
- package/dist/esm/configuration/index.js +7 -0
- package/dist/esm/configuration/index.js.map +1 -0
- package/dist/esm/environment-utils.d.ts +98 -0
- package/dist/esm/environment-utils.d.ts.map +1 -0
- package/dist/esm/environment-utils.js +114 -0
- package/dist/esm/environment-utils.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/operation-error.d.ts +24 -0
- package/dist/esm/operation-error.d.ts.map +1 -0
- package/dist/esm/operation-error.js +31 -0
- package/dist/esm/operation-error.js.map +1 -0
- package/dist/esm/operation-result.d.ts +41 -0
- package/dist/esm/operation-result.d.ts.map +1 -0
- package/dist/esm/operation-result.js +52 -0
- package/dist/esm/operation-result.js.map +1 -0
- package/dist/esm/power-platform-api-discovery.d.ts +30 -0
- package/dist/esm/power-platform-api-discovery.d.ts.map +1 -0
- package/dist/esm/power-platform-api-discovery.js +82 -0
- package/dist/esm/power-platform-api-discovery.js.map +1 -0
- package/dist/esm/utility.d.ts +73 -0
- package/dist/esm/utility.d.ts.map +1 -0
- package/dist/esm/utility.js +147 -0
- package/dist/esm/utility.js.map +1 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +2 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +63 -0
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.DEVELOPMENT_ENVIRONMENT_NAME = exports.PRODUCTION_ENVIRONMENT_NAME = exports.PROD_OBSERVABILITY_CLUSTER_CATEGORY = exports.PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE = exports.PROD_OBSERVABILITY_SCOPE = void 0;
|
|
6
|
+
exports.getObservabilityAuthenticationScope = getObservabilityAuthenticationScope;
|
|
7
|
+
exports.getClusterCategory = getClusterCategory;
|
|
8
|
+
exports.isDevelopmentEnvironment = isDevelopmentEnvironment;
|
|
9
|
+
exports.getMcpPlatformAuthenticationScope = getMcpPlatformAuthenticationScope;
|
|
10
|
+
/**
|
|
11
|
+
* Utility logic for environment-related operations.
|
|
12
|
+
*
|
|
13
|
+
* Note: These utility functions are maintained for backward compatibility.
|
|
14
|
+
* For new code, prefer using the configuration classes directly:
|
|
15
|
+
* - RuntimeConfiguration for clusterCategory, isDevelopmentEnvironment, isNodeEnvDevelopment
|
|
16
|
+
* - ToolingConfiguration for mcpPlatformAuthenticationScope
|
|
17
|
+
* - ObservabilityConfiguration for observabilityAuthenticationScopes
|
|
18
|
+
*/
|
|
19
|
+
const configuration_1 = require("./configuration");
|
|
20
|
+
/**
|
|
21
|
+
* Production observability authentication scope.
|
|
22
|
+
* @deprecated This constant is exported for backward compatibility only.
|
|
23
|
+
* For new code, use `ObservabilityConfiguration.observabilityAuthenticationScopes` instead.
|
|
24
|
+
*/
|
|
25
|
+
exports.PROD_OBSERVABILITY_SCOPE = 'https://api.powerplatform.com/.default';
|
|
26
|
+
/**
|
|
27
|
+
* Production MCP platform authentication scope.
|
|
28
|
+
* @deprecated This constant is exported for backward compatibility only.
|
|
29
|
+
* For new code, use `ToolingConfiguration.mcpPlatformAuthenticationScope` instead.
|
|
30
|
+
*/
|
|
31
|
+
exports.PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE = 'ea9ffc3e-8a23-4a7d-836d-234d7c7565c1/.default';
|
|
32
|
+
/**
|
|
33
|
+
* Default cluster category for production environments.
|
|
34
|
+
* @deprecated This constant is exported for backward compatibility only.
|
|
35
|
+
* For new code, use `RuntimeConfiguration.clusterCategory` instead.
|
|
36
|
+
*/
|
|
37
|
+
exports.PROD_OBSERVABILITY_CLUSTER_CATEGORY = 'prod';
|
|
38
|
+
// Default environment names
|
|
39
|
+
exports.PRODUCTION_ENVIRONMENT_NAME = 'production';
|
|
40
|
+
exports.DEVELOPMENT_ENVIRONMENT_NAME = 'Development';
|
|
41
|
+
/**
|
|
42
|
+
* Returns the scope for authenticating to the observability service.
|
|
43
|
+
*
|
|
44
|
+
* @returns The authentication scopes for the current environment.
|
|
45
|
+
* @deprecated Use ObservabilityConfiguration.observabilityAuthenticationScopes instead.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // Before:
|
|
49
|
+
* import { getObservabilityAuthenticationScope } from '@microsoft/agents-a365-runtime';
|
|
50
|
+
* const scopes = getObservabilityAuthenticationScope();
|
|
51
|
+
*
|
|
52
|
+
* // After:
|
|
53
|
+
* import { defaultObservabilityConfigurationProvider } from '@microsoft/agents-a365-observability';
|
|
54
|
+
* const scopes = [...defaultObservabilityConfigurationProvider.getConfiguration().observabilityAuthenticationScopes];
|
|
55
|
+
*/
|
|
56
|
+
function getObservabilityAuthenticationScope() {
|
|
57
|
+
// Returns production default - use ObservabilityConfiguration for proper env var support
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- Intentional: deprecated function using deprecated constant
|
|
59
|
+
return [exports.PROD_OBSERVABILITY_SCOPE];
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Gets the cluster category from environment variables.
|
|
63
|
+
*
|
|
64
|
+
* @param configProvider Optional configuration provider. Defaults to defaultRuntimeConfigurationProvider if not specified.
|
|
65
|
+
* @returns The cluster category from CLUSTER_CATEGORY env var, defaults to 'prod'.
|
|
66
|
+
* @deprecated Use RuntimeConfiguration.clusterCategory instead.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* // Before:
|
|
70
|
+
* import { getClusterCategory } from '@microsoft/agents-a365-runtime';
|
|
71
|
+
* const cluster = getClusterCategory();
|
|
72
|
+
*
|
|
73
|
+
* // After:
|
|
74
|
+
* import { defaultRuntimeConfigurationProvider } from '@microsoft/agents-a365-runtime';
|
|
75
|
+
* const cluster = defaultRuntimeConfigurationProvider.getConfiguration().clusterCategory;
|
|
76
|
+
*/
|
|
77
|
+
function getClusterCategory(configProvider) {
|
|
78
|
+
const provider = configProvider ?? configuration_1.defaultRuntimeConfigurationProvider;
|
|
79
|
+
return provider.getConfiguration().clusterCategory;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Returns true if the current environment is a development environment.
|
|
83
|
+
*
|
|
84
|
+
* @param configProvider Optional configuration provider. Defaults to defaultRuntimeConfigurationProvider if not specified.
|
|
85
|
+
* @returns True if the current environment is development, false otherwise.
|
|
86
|
+
* @deprecated Use RuntimeConfiguration.isDevelopmentEnvironment instead.
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* // Before:
|
|
90
|
+
* import { isDevelopmentEnvironment } from '@microsoft/agents-a365-runtime';
|
|
91
|
+
* if (isDevelopmentEnvironment()) { ... }
|
|
92
|
+
*
|
|
93
|
+
* // After:
|
|
94
|
+
* import { defaultRuntimeConfigurationProvider } from '@microsoft/agents-a365-runtime';
|
|
95
|
+
* if (defaultRuntimeConfigurationProvider.getConfiguration().isDevelopmentEnvironment) { ... }
|
|
96
|
+
*/
|
|
97
|
+
function isDevelopmentEnvironment(configProvider) {
|
|
98
|
+
const provider = configProvider ?? configuration_1.defaultRuntimeConfigurationProvider;
|
|
99
|
+
return provider.getConfiguration().isDevelopmentEnvironment;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Gets the MCP platform authentication scope.
|
|
103
|
+
*
|
|
104
|
+
* @returns The MCP platform authentication scope.
|
|
105
|
+
* @deprecated Use ToolingConfiguration.mcpPlatformAuthenticationScope instead.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* // Before:
|
|
109
|
+
* import { getMcpPlatformAuthenticationScope } from '@microsoft/agents-a365-runtime';
|
|
110
|
+
* const scope = getMcpPlatformAuthenticationScope();
|
|
111
|
+
*
|
|
112
|
+
* // After:
|
|
113
|
+
* import { defaultToolingConfigurationProvider } from '@microsoft/agents-a365-tooling';
|
|
114
|
+
* const scope = defaultToolingConfigurationProvider.getConfiguration().mcpPlatformAuthenticationScope;
|
|
115
|
+
*/
|
|
116
|
+
function getMcpPlatformAuthenticationScope() {
|
|
117
|
+
// Returns production default - use ToolingConfiguration for proper env var support
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated -- Intentional: deprecated function using deprecated constant
|
|
119
|
+
return exports.PROD_MCP_PLATFORM_AUTHENTICATION_SCOPE;
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=environment-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment-utils.js","sourceRoot":"","sources":["../../src/environment-utils.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAuDlC,kFAIC;AAkBD,gDAKC;AAkBD,4DAKC;AAiBD,8EAIC;AA5HD;;;;;;;;GAQG;AAEH,mDAA4F;AAG5F;;;;GAIG;AACU,QAAA,wBAAwB,GAAG,wCAAwC,CAAC;AAEjF;;;;GAIG;AACU,QAAA,sCAAsC,GAAG,+CAA+C,CAAC;AAEtG;;;;GAIG;AACU,QAAA,mCAAmC,GAAG,MAAM,CAAC;AAE1D,4BAA4B;AACf,QAAA,2BAA2B,GAAG,YAAY,CAAC;AAC3C,QAAA,4BAA4B,GAAG,aAAa,CAAC;AAE1D;;;;;;;;;;;;;;GAcG;AACH,SAAgB,mCAAmC;IACjD,yFAAyF;IACzF,0HAA0H;IAC1H,OAAO,CAAC,gCAAwB,CAAC,CAAC;AACpC,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,kBAAkB,CAChC,cAA6D;IAE7D,MAAM,QAAQ,GAAG,cAAc,IAAI,mDAAmC,CAAC;IACvE,OAAO,QAAQ,CAAC,gBAAgB,EAAE,CAAC,eAAe,CAAC;AACrD,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,wBAAwB,CACtC,cAA6D;IAE7D,MAAM,QAAQ,GAAG,cAAc,IAAI,mDAAmC,CAAC;IACvE,OAAO,QAAQ,CAAC,gBAAgB,EAAE,CAAC,wBAAwB,CAAC;AAC9D,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,iCAAiC;IAC/C,mFAAmF;IACnF,0HAA0H;IAC1H,OAAO,8CAAsC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './power-platform-api-discovery';
|
|
2
|
+
export * from './environment-utils';
|
|
3
|
+
export * from './utility';
|
|
4
|
+
export * from './agentic-authorization-service';
|
|
5
|
+
export * from './operation-error';
|
|
6
|
+
export * from './operation-result';
|
|
7
|
+
export * from './configuration';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,iCAAiC,CAAC;AAChD,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
+
if (k2 === undefined) k2 = k;
|
|
6
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
+
}
|
|
10
|
+
Object.defineProperty(o, k2, desc);
|
|
11
|
+
}) : (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
o[k2] = m[k];
|
|
14
|
+
}));
|
|
15
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
16
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
__exportStar(require("./power-platform-api-discovery"), exports);
|
|
20
|
+
__exportStar(require("./environment-utils"), exports);
|
|
21
|
+
__exportStar(require("./utility"), exports);
|
|
22
|
+
__exportStar(require("./agentic-authorization-service"), exports);
|
|
23
|
+
__exportStar(require("./operation-error"), exports);
|
|
24
|
+
__exportStar(require("./operation-result"), exports);
|
|
25
|
+
__exportStar(require("./configuration"), exports);
|
|
26
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;;;;;;;;;AAElC,iEAA+C;AAC/C,sDAAoC;AACpC,4CAA0B;AAC1B,kEAAgD;AAChD,oDAAkC;AAClC,qDAAmC;AACnC,kDAAgC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encapsulates an error from an operation.
|
|
3
|
+
*/
|
|
4
|
+
export declare class OperationError {
|
|
5
|
+
/**
|
|
6
|
+
* Gets the exception associated with the error.
|
|
7
|
+
*/
|
|
8
|
+
readonly exception: Error;
|
|
9
|
+
/**
|
|
10
|
+
* Gets the message associated with the error.
|
|
11
|
+
*/
|
|
12
|
+
get message(): string;
|
|
13
|
+
/**
|
|
14
|
+
* Initializes a new instance of the OperationError class.
|
|
15
|
+
* @param exception The exception associated with the error.
|
|
16
|
+
*/
|
|
17
|
+
constructor(exception: Error);
|
|
18
|
+
/**
|
|
19
|
+
* Returns a string representation of the error.
|
|
20
|
+
* @returns A string representation of the error.
|
|
21
|
+
*/
|
|
22
|
+
toString(): string;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=operation-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-error.d.ts","sourceRoot":"","sources":["../../src/operation-error.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,qBAAa,cAAc;IACzB;;OAEG;IACH,SAAgB,SAAS,EAAE,KAAK,CAAC;IAEjC;;OAEG;IACH,IAAW,OAAO,IAAI,MAAM,CAE3B;IAED;;;OAGG;gBACS,SAAS,EAAE,KAAK;IAO5B;;;OAGG;IACI,QAAQ,IAAI,MAAM;CAG1B"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.OperationError = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Encapsulates an error from an operation.
|
|
8
|
+
*/
|
|
9
|
+
class OperationError {
|
|
10
|
+
/**
|
|
11
|
+
* Gets the message associated with the error.
|
|
12
|
+
*/
|
|
13
|
+
get message() {
|
|
14
|
+
return this.exception.message;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Initializes a new instance of the OperationError class.
|
|
18
|
+
* @param exception The exception associated with the error.
|
|
19
|
+
*/
|
|
20
|
+
constructor(exception) {
|
|
21
|
+
if (!exception) {
|
|
22
|
+
throw new Error('exception is required');
|
|
23
|
+
}
|
|
24
|
+
this.exception = exception;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns a string representation of the error.
|
|
28
|
+
* @returns A string representation of the error.
|
|
29
|
+
*/
|
|
30
|
+
toString() {
|
|
31
|
+
return this.exception.toString();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.OperationError = OperationError;
|
|
35
|
+
//# sourceMappingURL=operation-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-error.js","sourceRoot":"","sources":["../../src/operation-error.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC;;GAEG;AACH,MAAa,cAAc;IAMzB;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,YAAY,SAAgB;QAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACI,QAAQ;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC;IACnC,CAAC;CACF;AA/BD,wCA+BC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { OperationError } from './operation-error';
|
|
2
|
+
/**
|
|
3
|
+
* Represents the result of an operation.
|
|
4
|
+
*/
|
|
5
|
+
export declare class OperationResult {
|
|
6
|
+
private static readonly _success;
|
|
7
|
+
private readonly _errors;
|
|
8
|
+
/**
|
|
9
|
+
* Gets a flag indicating whether the operation succeeded.
|
|
10
|
+
*/
|
|
11
|
+
readonly succeeded: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Gets an array of OperationError instances indicating errors that occurred during the operation.
|
|
14
|
+
*/
|
|
15
|
+
get errors(): OperationError[];
|
|
16
|
+
/**
|
|
17
|
+
* Private constructor for OperationResult.
|
|
18
|
+
* @param succeeded Whether the operation succeeded.
|
|
19
|
+
* @param errors Optional array of errors.
|
|
20
|
+
*/
|
|
21
|
+
private constructor();
|
|
22
|
+
/**
|
|
23
|
+
* Returns an OperationResult indicating a successful operation.
|
|
24
|
+
*/
|
|
25
|
+
static get success(): OperationResult;
|
|
26
|
+
/**
|
|
27
|
+
* Creates an OperationResult indicating a failed operation, with a list of errors if applicable.
|
|
28
|
+
* @param errors An optional array of OperationError which caused the operation to fail.
|
|
29
|
+
* @returns An OperationResult indicating a failed operation, with a list of errors if applicable.
|
|
30
|
+
*/
|
|
31
|
+
static failed(...errors: OperationError[]): OperationResult;
|
|
32
|
+
/**
|
|
33
|
+
* Converts the value of the current OperationResult object to its equivalent string representation.
|
|
34
|
+
* @returns A string representation of the current OperationResult object.
|
|
35
|
+
* @remarks
|
|
36
|
+
* If the operation was successful the toString() will return "Succeeded" otherwise it will return
|
|
37
|
+
* "Failed : " followed by a comma delimited list of error messages from its errors collection, if any.
|
|
38
|
+
*/
|
|
39
|
+
toString(): string;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=operation-result.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-result.d.ts","sourceRoot":"","sources":["../../src/operation-result.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IAC7D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAE3C;;OAEG;IACH,SAAgB,SAAS,EAAE,OAAO,CAAC;IAEnC;;OAEG;IACH,IAAW,MAAM,IAAI,cAAc,EAAE,CAEpC;IAED;;;;OAIG;IACH,OAAO;IAKP;;OAEG;IACH,WAAkB,OAAO,IAAI,eAAe,CAE3C;IAED;;;;OAIG;WACW,MAAM,CAAC,GAAG,MAAM,EAAE,cAAc,EAAE,GAAG,eAAe;IAIlE;;;;;;OAMG;IACI,QAAQ,IAAI,MAAM;CAQ1B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT License.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.OperationResult = void 0;
|
|
6
|
+
/**
|
|
7
|
+
* Represents the result of an operation.
|
|
8
|
+
*/
|
|
9
|
+
class OperationResult {
|
|
10
|
+
/**
|
|
11
|
+
* Gets an array of OperationError instances indicating errors that occurred during the operation.
|
|
12
|
+
*/
|
|
13
|
+
get errors() {
|
|
14
|
+
return this._errors || [];
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Private constructor for OperationResult.
|
|
18
|
+
* @param succeeded Whether the operation succeeded.
|
|
19
|
+
* @param errors Optional array of errors.
|
|
20
|
+
*/
|
|
21
|
+
constructor(succeeded, errors) {
|
|
22
|
+
this.succeeded = succeeded;
|
|
23
|
+
this._errors = errors || [];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Returns an OperationResult indicating a successful operation.
|
|
27
|
+
*/
|
|
28
|
+
static get success() {
|
|
29
|
+
return OperationResult._success;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates an OperationResult indicating a failed operation, with a list of errors if applicable.
|
|
33
|
+
* @param errors An optional array of OperationError which caused the operation to fail.
|
|
34
|
+
* @returns An OperationResult indicating a failed operation, with a list of errors if applicable.
|
|
35
|
+
*/
|
|
36
|
+
static failed(...errors) {
|
|
37
|
+
return new OperationResult(false, errors.length > 0 ? errors : []);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Converts the value of the current OperationResult object to its equivalent string representation.
|
|
41
|
+
* @returns A string representation of the current OperationResult object.
|
|
42
|
+
* @remarks
|
|
43
|
+
* If the operation was successful the toString() will return "Succeeded" otherwise it will return
|
|
44
|
+
* "Failed : " followed by a comma delimited list of error messages from its errors collection, if any.
|
|
45
|
+
*/
|
|
46
|
+
toString() {
|
|
47
|
+
if (this.succeeded) {
|
|
48
|
+
return 'Succeeded';
|
|
49
|
+
}
|
|
50
|
+
const errorMessages = this.errors.map(e => e.message).join(', ');
|
|
51
|
+
return `Failed : ${errorMessages}`;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.OperationResult = OperationResult;
|
|
55
|
+
OperationResult._success = new OperationResult(true);
|
|
56
|
+
//# sourceMappingURL=operation-result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation-result.js","sourceRoot":"","sources":["../../src/operation-result.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAIlC;;GAEG;AACH,MAAa,eAAe;IAS1B;;OAEG;IACH,IAAW,MAAM;QACf,OAAO,IAAI,CAAC,OAAO,IAAI,EAAE,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,YAAoB,SAAkB,EAAE,MAAyB;QAC/D,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,MAAM,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACI,MAAM,KAAK,OAAO;QACvB,OAAO,eAAe,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,MAAM,CAAC,GAAG,MAAwB;QAC9C,OAAO,IAAI,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACrE,CAAC;IAED;;;;;;OAMG;IACI,QAAQ;QACb,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACnB,OAAO,WAAW,CAAC;QACrB,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjE,OAAO,YAAY,aAAa,EAAE,CAAC;IACrC,CAAC;;AAxDH,0CAyDC;AAxDyB,wBAAQ,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cluster categories for Power Platform API discovery.
|
|
3
|
+
* String enum provides both compile-time type safety and runtime validation.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum ClusterCategory {
|
|
6
|
+
local = "local",
|
|
7
|
+
dev = "dev",
|
|
8
|
+
test = "test",
|
|
9
|
+
preprod = "preprod",
|
|
10
|
+
firstrelease = "firstrelease",
|
|
11
|
+
prod = "prod",
|
|
12
|
+
gov = "gov",
|
|
13
|
+
high = "high",
|
|
14
|
+
dod = "dod",
|
|
15
|
+
mooncake = "mooncake",
|
|
16
|
+
ex = "ex",
|
|
17
|
+
rx = "rx"
|
|
18
|
+
}
|
|
19
|
+
export declare class PowerPlatformApiDiscovery {
|
|
20
|
+
readonly clusterCategory: ClusterCategory;
|
|
21
|
+
constructor(clusterCategory: ClusterCategory);
|
|
22
|
+
getTokenAudience(): string;
|
|
23
|
+
getTokenEndpointHost(): string;
|
|
24
|
+
getTenantEndpoint(tenantId: string): string;
|
|
25
|
+
getTenantIslandClusterEndpoint(tenantId: string): string;
|
|
26
|
+
private _generatePowerPlatformApiDomain;
|
|
27
|
+
private _getHexApiSuffixLength;
|
|
28
|
+
private _getEnvironmentApiHostNameSuffix;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=power-platform-api-discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"power-platform-api-discovery.d.ts","sourceRoot":"","sources":["../../src/power-platform-api-discovery.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,eAAe;IACzB,KAAK,UAAU;IACf,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,YAAY,iBAAiB;IAC7B,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,QAAQ,aAAa;IACrB,EAAE,OAAO;IACT,EAAE,OAAO;CACV;AAED,qBAAa,yBAAyB;IACpC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;gBAE9B,eAAe,EAAE,eAAe;IAIrC,gBAAgB,IAAI,MAAM;IAI1B,oBAAoB,IAAI,MAAM;IAI9B,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAI3C,8BAA8B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAI/D,OAAO,CAAC,+BAA+B;IAkCvC,OAAO,CAAC,sBAAsB;IAU9B,OAAO,CAAC,gCAAgC;CAuBzC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PowerPlatformApiDiscovery = exports.ClusterCategory = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Cluster categories for Power Platform API discovery.
|
|
6
|
+
* String enum provides both compile-time type safety and runtime validation.
|
|
7
|
+
*/
|
|
8
|
+
var ClusterCategory;
|
|
9
|
+
(function (ClusterCategory) {
|
|
10
|
+
ClusterCategory["local"] = "local";
|
|
11
|
+
ClusterCategory["dev"] = "dev";
|
|
12
|
+
ClusterCategory["test"] = "test";
|
|
13
|
+
ClusterCategory["preprod"] = "preprod";
|
|
14
|
+
ClusterCategory["firstrelease"] = "firstrelease";
|
|
15
|
+
ClusterCategory["prod"] = "prod";
|
|
16
|
+
ClusterCategory["gov"] = "gov";
|
|
17
|
+
ClusterCategory["high"] = "high";
|
|
18
|
+
ClusterCategory["dod"] = "dod";
|
|
19
|
+
ClusterCategory["mooncake"] = "mooncake";
|
|
20
|
+
ClusterCategory["ex"] = "ex";
|
|
21
|
+
ClusterCategory["rx"] = "rx";
|
|
22
|
+
})(ClusterCategory || (exports.ClusterCategory = ClusterCategory = {}));
|
|
23
|
+
class PowerPlatformApiDiscovery {
|
|
24
|
+
constructor(clusterCategory) {
|
|
25
|
+
this.clusterCategory = clusterCategory;
|
|
26
|
+
}
|
|
27
|
+
getTokenAudience() {
|
|
28
|
+
return `https://${this._getEnvironmentApiHostNameSuffix()}`;
|
|
29
|
+
}
|
|
30
|
+
getTokenEndpointHost() {
|
|
31
|
+
return this._getEnvironmentApiHostNameSuffix();
|
|
32
|
+
}
|
|
33
|
+
getTenantEndpoint(tenantId) {
|
|
34
|
+
return this._generatePowerPlatformApiDomain(tenantId);
|
|
35
|
+
}
|
|
36
|
+
getTenantIslandClusterEndpoint(tenantId) {
|
|
37
|
+
return this._generatePowerPlatformApiDomain(tenantId, 'il-');
|
|
38
|
+
}
|
|
39
|
+
_generatePowerPlatformApiDomain(hostNameIdentifier, hostNamePrefix = '') {
|
|
40
|
+
if (!/^[a-zA-Z0-9-]+$/.test(hostNameIdentifier)) {
|
|
41
|
+
throw new Error(`Cannot generate Power Platform API endpoint because the tenant identifier contains invalid host name characters, only alphanumeric and dash characters are expected: ${hostNameIdentifier}`);
|
|
42
|
+
}
|
|
43
|
+
const hostNameInfix = 'tenant';
|
|
44
|
+
const hexNameSuffixLength = this._getHexApiSuffixLength();
|
|
45
|
+
const hexName = hostNameIdentifier.toLowerCase().replace(/-/g, '');
|
|
46
|
+
if (hexNameSuffixLength >= hexName.length) {
|
|
47
|
+
throw new Error(`Cannot generate Power Platform API endpoint because the normalized tenant identifier must be at least ${hexNameSuffixLength + 1} characters in length: ${hexName}`);
|
|
48
|
+
}
|
|
49
|
+
const hexNameSuffix = hexName.substring(hexName.length - hexNameSuffixLength);
|
|
50
|
+
const hexNamePrefix = hexName.substring(0, hexName.length - hexNameSuffixLength);
|
|
51
|
+
const hostNameSuffix = this._getEnvironmentApiHostNameSuffix();
|
|
52
|
+
return `${hostNamePrefix}${hexNamePrefix}.${hexNameSuffix}.${hostNameInfix}.${hostNameSuffix}`;
|
|
53
|
+
}
|
|
54
|
+
_getHexApiSuffixLength() {
|
|
55
|
+
switch (this.clusterCategory) {
|
|
56
|
+
case ClusterCategory.firstrelease:
|
|
57
|
+
case ClusterCategory.prod:
|
|
58
|
+
return 2;
|
|
59
|
+
default:
|
|
60
|
+
return 1;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
_getEnvironmentApiHostNameSuffix() {
|
|
64
|
+
const apiHostNameSuffixMap = {
|
|
65
|
+
local: 'api.powerplatform.localhost',
|
|
66
|
+
dev: 'api.powerplatform.com', //default to prod
|
|
67
|
+
test: 'api.powerplatform.com', //default to prod
|
|
68
|
+
preprod: 'api.powerplatform.com', //default to prod
|
|
69
|
+
firstrelease: 'api.powerplatform.com',
|
|
70
|
+
prod: 'api.powerplatform.com',
|
|
71
|
+
gov: 'api.gov.powerplatform.microsoft.us',
|
|
72
|
+
high: 'api.high.powerplatform.microsoft.us',
|
|
73
|
+
dod: 'api.appsplatform.us',
|
|
74
|
+
mooncake: 'api.powerplatform.partner.microsoftonline.cn',
|
|
75
|
+
ex: 'api.powerplatform.eaglex.ic.gov',
|
|
76
|
+
rx: 'api.powerplatform.microsoft.scloud',
|
|
77
|
+
};
|
|
78
|
+
const suffix = apiHostNameSuffixMap[this.clusterCategory];
|
|
79
|
+
if (!suffix) {
|
|
80
|
+
throw new Error(`Invalid ClusterCategory value: ${this.clusterCategory}`);
|
|
81
|
+
}
|
|
82
|
+
return suffix;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
exports.PowerPlatformApiDiscovery = PowerPlatformApiDiscovery;
|
|
86
|
+
//# sourceMappingURL=power-platform-api-discovery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"power-platform-api-discovery.js","sourceRoot":"","sources":["../../src/power-platform-api-discovery.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { TurnContext } from '@microsoft/agents-hosting';
|
|
2
|
+
/**
|
|
3
|
+
* Utility class providing helper methods for agent runtime operations.
|
|
4
|
+
*/
|
|
5
|
+
export declare class Utility {
|
|
6
|
+
private static cachedPackageName;
|
|
7
|
+
/**
|
|
8
|
+
* Reads the application name from package.json at module load time.
|
|
9
|
+
* This ensures file I/O happens during initialization, not during requests.
|
|
10
|
+
*
|
|
11
|
+
* Note: Uses process.cwd() which assumes the application is started from its root directory.
|
|
12
|
+
* This is a fallback mechanism - npm_package_name (checked first in getApplicationName) is
|
|
13
|
+
* the preferred source as it's reliably set by npm/pnpm when running package scripts.
|
|
14
|
+
*/
|
|
15
|
+
private static initPackageName;
|
|
16
|
+
/**
|
|
17
|
+
* **WARNING: NO SIGNATURE VERIFICATION** - This method uses jwt.decode() which does NOT
|
|
18
|
+
* verify the token signature. The token claims can be spoofed by malicious actors.
|
|
19
|
+
* This method is ONLY suitable for logging, analytics, and diagnostics purposes.
|
|
20
|
+
* Do NOT use the returned value for authorization, access control, or security decisions.
|
|
21
|
+
*
|
|
22
|
+
* Decodes the current token and retrieves the App ID (appid or azp claim).
|
|
23
|
+
*
|
|
24
|
+
* Note: Returns a default GUID ('00000000-0000-0000-0000-000000000000') for empty tokens
|
|
25
|
+
* for backward compatibility with callers that expect a valid-looking GUID.
|
|
26
|
+
* For agent identification where empty string is preferred, use {@link getAgentIdFromToken}.
|
|
27
|
+
*
|
|
28
|
+
* @param token Token to Decode
|
|
29
|
+
* @returns AppId, or default GUID for empty token, or empty string if decode fails
|
|
30
|
+
*/
|
|
31
|
+
static GetAppIdFromToken(token: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* **WARNING: NO SIGNATURE VERIFICATION** - This method uses jwt.decode() which does NOT
|
|
34
|
+
* verify the token signature. The token claims can be spoofed by malicious actors.
|
|
35
|
+
* This method is ONLY suitable for logging, analytics, and diagnostics purposes.
|
|
36
|
+
* Do NOT use the returned value for authorization, access control, or security decisions.
|
|
37
|
+
*
|
|
38
|
+
* Decodes the token and retrieves the best available agent identifier.
|
|
39
|
+
* Checks claims in priority order: xms_par_app_azp (agent blueprint ID) > appid > azp.
|
|
40
|
+
*
|
|
41
|
+
* Note: Returns empty string for empty/missing tokens (unlike {@link GetAppIdFromToken} which
|
|
42
|
+
* returns a default GUID). This allows callers to omit headers when no identifier is available.
|
|
43
|
+
*
|
|
44
|
+
* @param token JWT token to decode
|
|
45
|
+
* @returns Agent ID (GUID) or empty string if not found or token is empty
|
|
46
|
+
*/
|
|
47
|
+
static getAgentIdFromToken(token: string): string;
|
|
48
|
+
/**
|
|
49
|
+
* Resolves the agent identity from the turn context or auth token.
|
|
50
|
+
* @param context Turn Context of the turn.
|
|
51
|
+
* @param authToken Auth token if available.
|
|
52
|
+
* @returns Agent identity (App ID)
|
|
53
|
+
*/
|
|
54
|
+
static ResolveAgentIdentity(context: TurnContext, authToken: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Generates a User-Agent header string containing SDK version, OS type, Node.js version, and orchestrator.
|
|
57
|
+
* @param orchestrator Optional orchestrator identifier to include in the User-Agent string.
|
|
58
|
+
* @returns Formatted User-Agent header string.
|
|
59
|
+
*/
|
|
60
|
+
static GetUserAgentHeader(orchestrator?: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Gets the application name from npm_package_name environment variable or package.json.
|
|
63
|
+
* The package.json result is cached at module load time to avoid sync I/O during requests.
|
|
64
|
+
* @returns Application name or undefined if not available.
|
|
65
|
+
*/
|
|
66
|
+
static getApplicationName(): string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Resets the cached application name. Used for testing purposes.
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
static resetApplicationNameCache(): void;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=utility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utility.d.ts","sourceRoot":"","sources":["../../src/utility.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAQxD;;GAEG;AACH,qBAAa,OAAO;IAIlB,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAA4C;IAE5E;;;;;;;OAOG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IAW9B;;;;;;;;;;;;;;OAcG;WACW,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAoBtD;;;;;;;;;;;;;;OAcG;WACW,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAmBxD;;;;;OAKG;WACW,oBAAoB,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IASnF;;;;OAIG;WACW,kBAAkB,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM;IAM/D;;;;OAIG;WACW,kBAAkB,IAAI,MAAM,GAAG,SAAS;IAYtD;;;OAGG;WACW,yBAAyB,IAAI,IAAI;CAGhD"}
|