@uipath/apollo-react 6.54.0 → 6.56.0

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 (50) hide show
  1. package/dist/canvas/components/Guardrails/centralized-guardrail-details.cjs +139 -0
  2. package/dist/canvas/components/Guardrails/centralized-guardrail-details.d.ts +14 -0
  3. package/dist/canvas/components/Guardrails/centralized-guardrail-details.d.ts.map +1 -0
  4. package/dist/canvas/components/Guardrails/centralized-guardrail-details.js +105 -0
  5. package/dist/canvas/components/Guardrails/centralized-guardrail-utils.cjs +233 -0
  6. package/dist/canvas/components/Guardrails/centralized-guardrail-utils.d.ts +33 -0
  7. package/dist/canvas/components/Guardrails/centralized-guardrail-utils.d.ts.map +1 -0
  8. package/dist/canvas/components/Guardrails/centralized-guardrail-utils.js +172 -0
  9. package/dist/canvas/components/Guardrails/centralized-guardrails-section.cjs +142 -0
  10. package/dist/canvas/components/Guardrails/centralized-guardrails-section.d.ts +19 -0
  11. package/dist/canvas/components/Guardrails/centralized-guardrails-section.d.ts.map +1 -0
  12. package/dist/canvas/components/Guardrails/centralized-guardrails-section.js +108 -0
  13. package/dist/canvas/components/Guardrails/centralized-types.cjs +18 -0
  14. package/dist/canvas/components/Guardrails/centralized-types.d.ts +51 -0
  15. package/dist/canvas/components/Guardrails/centralized-types.d.ts.map +1 -0
  16. package/dist/canvas/components/Guardrails/centralized-types.js +0 -0
  17. package/dist/canvas/components/Guardrails/components/centralized-detail-field.cjs +52 -0
  18. package/dist/canvas/components/Guardrails/components/centralized-detail-field.d.ts +8 -0
  19. package/dist/canvas/components/Guardrails/components/centralized-detail-field.d.ts.map +1 -0
  20. package/dist/canvas/components/Guardrails/components/centralized-detail-field.js +18 -0
  21. package/dist/canvas/components/Guardrails/components/centralized-guardrail-origin-chip.cjs +48 -0
  22. package/dist/canvas/components/Guardrails/components/centralized-guardrail-origin-chip.d.ts +7 -0
  23. package/dist/canvas/components/Guardrails/components/centralized-guardrail-origin-chip.d.ts.map +1 -0
  24. package/dist/canvas/components/Guardrails/components/centralized-guardrail-origin-chip.js +14 -0
  25. package/dist/canvas/components/Guardrails/components/centralized-guardrail-parameters.cjs +77 -0
  26. package/dist/canvas/components/Guardrails/components/centralized-guardrail-parameters.d.ts +7 -0
  27. package/dist/canvas/components/Guardrails/components/centralized-guardrail-parameters.d.ts.map +1 -0
  28. package/dist/canvas/components/Guardrails/components/centralized-guardrail-parameters.js +43 -0
  29. package/dist/canvas/components/Guardrails/components/centralized-guardrail-row.cjs +137 -0
  30. package/dist/canvas/components/Guardrails/components/centralized-guardrail-row.d.ts +14 -0
  31. package/dist/canvas/components/Guardrails/components/centralized-guardrail-row.d.ts.map +1 -0
  32. package/dist/canvas/components/Guardrails/components/centralized-guardrail-row.js +103 -0
  33. package/dist/canvas/components/Guardrails/i18n.cjs +180 -1
  34. package/dist/canvas/components/Guardrails/i18n.d.ts +41 -0
  35. package/dist/canvas/components/Guardrails/i18n.d.ts.map +1 -1
  36. package/dist/canvas/components/Guardrails/i18n.js +169 -2
  37. package/dist/canvas/components/Guardrails/index.cjs +56 -5
  38. package/dist/canvas/components/Guardrails/index.d.ts +9 -2
  39. package/dist/canvas/components/Guardrails/index.d.ts.map +1 -1
  40. package/dist/canvas/components/Guardrails/index.js +5 -2
  41. package/dist/canvas/locales/en.cjs +1 -1
  42. package/dist/canvas/locales/en.d.ts.map +1 -1
  43. package/dist/canvas/locales/en.js +1 -1
  44. package/dist/canvas/styles/tailwind.canvas.css +1 -1
  45. package/dist/core/tokens/css/theme-variables.css +8 -8
  46. package/dist/core/tokens/css/variables.css +8 -8
  47. package/dist/core/tokens/less/_variables.less +8 -8
  48. package/dist/core/tokens/scss/_css-variables.scss +8 -8
  49. package/dist/core/tokens/scss/_variables.scss +8 -8
  50. package/package.json +3 -3
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ CentralizedGuardrailDetails: ()=>CentralizedGuardrailDetails
28
+ });
29
+ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
+ const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
31
+ const external_lucide_react_namespaceObject = require("lucide-react");
32
+ const external_centralized_guardrail_utils_cjs_namespaceObject = require("./centralized-guardrail-utils.cjs");
33
+ const centralized_detail_field_cjs_namespaceObject = require("./components/centralized-detail-field.cjs");
34
+ const centralized_guardrail_origin_chip_cjs_namespaceObject = require("./components/centralized-guardrail-origin-chip.cjs");
35
+ const centralized_guardrail_parameters_cjs_namespaceObject = require("./components/centralized-guardrail-parameters.cjs");
36
+ const guardrail_status_banner_cjs_namespaceObject = require("./components/guardrail-status-banner.cjs");
37
+ const external_definitions_copy_cjs_namespaceObject = require("./definitions-copy.cjs");
38
+ const external_i18n_cjs_namespaceObject = require("./i18n.cjs");
39
+ function CentralizedGuardrailDetails({ guardrail, policyName, definitions, formatScope, formatAction, labels: labelOverrides, className }) {
40
+ const labels = (0, external_i18n_cjs_namespaceObject.useCentralizedGuardrailsLabels)(labelOverrides);
41
+ const copy = (0, external_definitions_copy_cjs_namespaceObject.useGuardrailDefinitionCopy)();
42
+ const byoDefinition = (0, external_centralized_guardrail_utils_cjs_namespaceObject.findCentralizedByoDefinition)(guardrail, definitions);
43
+ const definition = guardrail.isByo ? byoDefinition : (0, external_centralized_guardrail_utils_cjs_namespaceObject.findCentralizedBuiltInDefinition)(guardrail, definitions);
44
+ const { name, description } = (0, external_centralized_guardrail_utils_cjs_namespaceObject.getCentralizedGuardrailDisplay)(guardrail, {
45
+ definition: byoDefinition,
46
+ copy
47
+ });
48
+ const isConfigMissing = (0, external_centralized_guardrail_utils_cjs_namespaceObject.isCentralizedGuardrailConfigMissing)(guardrail, definitions);
49
+ const isConfigDisabled = byoDefinition?.status === 'Disabled';
50
+ const parameterRows = (0, external_centralized_guardrail_utils_cjs_namespaceObject.resolveCentralizedGuardrailParameters)(guardrail, {
51
+ definition,
52
+ labels: {
53
+ enabled: labels.parameterEnabled,
54
+ disabled: labels.parameterDisabled,
55
+ entities: labels.entitiesFallback,
56
+ thresholds: labels.thresholdsFallback
57
+ }
58
+ });
59
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
60
+ "data-slot": "centralized-guardrail-details",
61
+ className: (0, apollo_wind_namespaceObject.cn)('space-y-4', className),
62
+ children: [
63
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Alert, {
64
+ role: "note",
65
+ children: [
66
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_lucide_react_namespaceObject.Info, {}),
67
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(apollo_wind_namespaceObject.AlertDescription, {
68
+ className: "mt-0",
69
+ children: labels.managedMessage
70
+ })
71
+ ]
72
+ }),
73
+ isConfigMissing && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(guardrail_status_banner_cjs_namespaceObject.GuardrailStatusBanner, {
74
+ tone: "error",
75
+ message: labels.missingConfigMessage
76
+ }),
77
+ isConfigDisabled && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(guardrail_status_banner_cjs_namespaceObject.GuardrailStatusBanner, {
78
+ tone: "error",
79
+ message: labels.disabledConfigMessage
80
+ }),
81
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("dl", {
82
+ className: "space-y-3",
83
+ children: [
84
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(centralized_detail_field_cjs_namespaceObject.CentralizedDetailField, {
85
+ label: labels.guardrailType,
86
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("span", {
87
+ className: "flex items-center gap-1.5",
88
+ children: [
89
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
90
+ className: "min-w-0 truncate text-foreground",
91
+ children: name
92
+ }),
93
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(centralized_guardrail_origin_chip_cjs_namespaceObject.CentralizedGuardrailOriginChip, {
94
+ isByo: guardrail.isByo,
95
+ labels: labels
96
+ })
97
+ ]
98
+ })
99
+ }),
100
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(centralized_detail_field_cjs_namespaceObject.CentralizedDetailField, {
101
+ label: labels.policyField,
102
+ children: policyName
103
+ }),
104
+ byoDefinition?.byoConnectorName !== void 0 && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(centralized_detail_field_cjs_namespaceObject.CentralizedDetailField, {
105
+ label: labels.provider,
106
+ children: byoDefinition.byoConnectorName
107
+ }),
108
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(centralized_detail_field_cjs_namespaceObject.CentralizedDetailField, {
109
+ label: labels.description,
110
+ children: description ?? labels.noDescription
111
+ }),
112
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(centralized_detail_field_cjs_namespaceObject.CentralizedDetailField, {
113
+ label: labels.executionStage,
114
+ children: (0, external_centralized_guardrail_utils_cjs_namespaceObject.formatCentralizedExecutionStage)(guardrail.executionStage, labels)
115
+ }),
116
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(centralized_detail_field_cjs_namespaceObject.CentralizedDetailField, {
117
+ label: labels.scopes,
118
+ children: guardrail.scopes.map((scope)=>formatScope?.(scope) ?? (0, external_centralized_guardrail_utils_cjs_namespaceObject.formatCentralizedScope)(scope, labels)).join(', ')
119
+ }),
120
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(centralized_detail_field_cjs_namespaceObject.CentralizedDetailField, {
121
+ label: labels.action,
122
+ children: formatAction?.(guardrail.action) ?? (0, external_centralized_guardrail_utils_cjs_namespaceObject.formatCentralizedAction)(guardrail.action, labels)
123
+ })
124
+ ]
125
+ }),
126
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(centralized_guardrail_parameters_cjs_namespaceObject.CentralizedGuardrailParameters, {
127
+ rows: parameterRows,
128
+ heading: labels.configuration
129
+ })
130
+ ]
131
+ });
132
+ }
133
+ exports.CentralizedGuardrailDetails = __webpack_exports__.CentralizedGuardrailDetails;
134
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
135
+ "CentralizedGuardrailDetails"
136
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
137
+ Object.defineProperty(exports, '__esModule', {
138
+ value: true
139
+ });
@@ -0,0 +1,14 @@
1
+ import type { GuardrailScope } from './builder-types';
2
+ import type { CentralizedGuardrail, CentralizedGuardrailActionType, CentralizedGuardrailDefinition } from './centralized-types';
3
+ import type { CentralizedGuardrailsLabels } from './i18n';
4
+ export interface CentralizedGuardrailDetailsProps<TDefinition extends CentralizedGuardrailDefinition = CentralizedGuardrailDefinition> {
5
+ guardrail: CentralizedGuardrail;
6
+ policyName: string;
7
+ definitions?: TDefinition[];
8
+ formatScope?: (scope: GuardrailScope) => string;
9
+ formatAction?: (action: CentralizedGuardrailActionType) => string;
10
+ labels?: Partial<CentralizedGuardrailsLabels>;
11
+ className?: string;
12
+ }
13
+ export declare function CentralizedGuardrailDetails<TDefinition extends CentralizedGuardrailDefinition = CentralizedGuardrailDefinition>({ guardrail, policyName, definitions, formatScope, formatAction, labels: labelOverrides, className, }: CentralizedGuardrailDetailsProps<TDefinition>): import("react/jsx-runtime").JSX.Element;
14
+ //# sourceMappingURL=centralized-guardrail-details.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"centralized-guardrail-details.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Guardrails/centralized-guardrail-details.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAWtD,OAAO,KAAK,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,8BAA8B,EAC/B,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAG1D,MAAM,WAAW,gCAAgC,CAC/C,WAAW,SAAS,8BAA8B,GAAG,8BAA8B;IAEnF,SAAS,EAAE,oBAAoB,CAAC;IAEhC,UAAU,EAAE,MAAM,CAAC;IAEnB,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;IAE5B,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,MAAM,CAAC;IAEhD,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,8BAA8B,KAAK,MAAM,CAAC;IAClE,MAAM,CAAC,EAAE,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAGD,wBAAgB,2BAA2B,CACzC,WAAW,SAAS,8BAA8B,GAAG,8BAA8B,EACnF,EACA,SAAS,EACT,UAAU,EACV,WAAW,EACX,WAAW,EACX,YAAY,EACZ,MAAM,EAAE,cAAc,EACtB,SAAS,GACV,EAAE,gCAAgC,CAAC,WAAW,CAAC,2CAwE/C"}
@@ -0,0 +1,105 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Alert, AlertDescription, cn } from "@uipath/apollo-wind";
3
+ import { Info } from "lucide-react";
4
+ import { findCentralizedBuiltInDefinition, findCentralizedByoDefinition, formatCentralizedAction, formatCentralizedExecutionStage, formatCentralizedScope, getCentralizedGuardrailDisplay, isCentralizedGuardrailConfigMissing, resolveCentralizedGuardrailParameters } from "./centralized-guardrail-utils.js";
5
+ import { CentralizedDetailField } from "./components/centralized-detail-field.js";
6
+ import { CentralizedGuardrailOriginChip } from "./components/centralized-guardrail-origin-chip.js";
7
+ import { CentralizedGuardrailParameters } from "./components/centralized-guardrail-parameters.js";
8
+ import { GuardrailStatusBanner } from "./components/guardrail-status-banner.js";
9
+ import { useGuardrailDefinitionCopy } from "./definitions-copy.js";
10
+ import { useCentralizedGuardrailsLabels } from "./i18n.js";
11
+ function CentralizedGuardrailDetails({ guardrail, policyName, definitions, formatScope, formatAction, labels: labelOverrides, className }) {
12
+ const labels = useCentralizedGuardrailsLabels(labelOverrides);
13
+ const copy = useGuardrailDefinitionCopy();
14
+ const byoDefinition = findCentralizedByoDefinition(guardrail, definitions);
15
+ const definition = guardrail.isByo ? byoDefinition : findCentralizedBuiltInDefinition(guardrail, definitions);
16
+ const { name, description } = getCentralizedGuardrailDisplay(guardrail, {
17
+ definition: byoDefinition,
18
+ copy
19
+ });
20
+ const isConfigMissing = isCentralizedGuardrailConfigMissing(guardrail, definitions);
21
+ const isConfigDisabled = byoDefinition?.status === 'Disabled';
22
+ const parameterRows = resolveCentralizedGuardrailParameters(guardrail, {
23
+ definition,
24
+ labels: {
25
+ enabled: labels.parameterEnabled,
26
+ disabled: labels.parameterDisabled,
27
+ entities: labels.entitiesFallback,
28
+ thresholds: labels.thresholdsFallback
29
+ }
30
+ });
31
+ return /*#__PURE__*/ jsxs("div", {
32
+ "data-slot": "centralized-guardrail-details",
33
+ className: cn('space-y-4', className),
34
+ children: [
35
+ /*#__PURE__*/ jsxs(Alert, {
36
+ role: "note",
37
+ children: [
38
+ /*#__PURE__*/ jsx(Info, {}),
39
+ /*#__PURE__*/ jsx(AlertDescription, {
40
+ className: "mt-0",
41
+ children: labels.managedMessage
42
+ })
43
+ ]
44
+ }),
45
+ isConfigMissing && /*#__PURE__*/ jsx(GuardrailStatusBanner, {
46
+ tone: "error",
47
+ message: labels.missingConfigMessage
48
+ }),
49
+ isConfigDisabled && /*#__PURE__*/ jsx(GuardrailStatusBanner, {
50
+ tone: "error",
51
+ message: labels.disabledConfigMessage
52
+ }),
53
+ /*#__PURE__*/ jsxs("dl", {
54
+ className: "space-y-3",
55
+ children: [
56
+ /*#__PURE__*/ jsx(CentralizedDetailField, {
57
+ label: labels.guardrailType,
58
+ children: /*#__PURE__*/ jsxs("span", {
59
+ className: "flex items-center gap-1.5",
60
+ children: [
61
+ /*#__PURE__*/ jsx("span", {
62
+ className: "min-w-0 truncate text-foreground",
63
+ children: name
64
+ }),
65
+ /*#__PURE__*/ jsx(CentralizedGuardrailOriginChip, {
66
+ isByo: guardrail.isByo,
67
+ labels: labels
68
+ })
69
+ ]
70
+ })
71
+ }),
72
+ /*#__PURE__*/ jsx(CentralizedDetailField, {
73
+ label: labels.policyField,
74
+ children: policyName
75
+ }),
76
+ byoDefinition?.byoConnectorName !== void 0 && /*#__PURE__*/ jsx(CentralizedDetailField, {
77
+ label: labels.provider,
78
+ children: byoDefinition.byoConnectorName
79
+ }),
80
+ /*#__PURE__*/ jsx(CentralizedDetailField, {
81
+ label: labels.description,
82
+ children: description ?? labels.noDescription
83
+ }),
84
+ /*#__PURE__*/ jsx(CentralizedDetailField, {
85
+ label: labels.executionStage,
86
+ children: formatCentralizedExecutionStage(guardrail.executionStage, labels)
87
+ }),
88
+ /*#__PURE__*/ jsx(CentralizedDetailField, {
89
+ label: labels.scopes,
90
+ children: guardrail.scopes.map((scope)=>formatScope?.(scope) ?? formatCentralizedScope(scope, labels)).join(', ')
91
+ }),
92
+ /*#__PURE__*/ jsx(CentralizedDetailField, {
93
+ label: labels.action,
94
+ children: formatAction?.(guardrail.action) ?? formatCentralizedAction(guardrail.action, labels)
95
+ })
96
+ ]
97
+ }),
98
+ /*#__PURE__*/ jsx(CentralizedGuardrailParameters, {
99
+ rows: parameterRows,
100
+ heading: labels.configuration
101
+ })
102
+ ]
103
+ });
104
+ }
105
+ export { CentralizedGuardrailDetails };
@@ -0,0 +1,233 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ findCentralizedBuiltInDefinition: ()=>findCentralizedBuiltInDefinition,
28
+ findCentralizedByoDefinition: ()=>findCentralizedByoDefinition,
29
+ formatCentralizedAction: ()=>formatCentralizedAction,
30
+ formatCentralizedExecutionStage: ()=>formatCentralizedExecutionStage,
31
+ formatCentralizedScope: ()=>formatCentralizedScope,
32
+ getApplicableCentralizedGuardrails: ()=>getApplicableCentralizedGuardrails,
33
+ getCentralizedGuardrailDisplay: ()=>getCentralizedGuardrailDisplay,
34
+ getCentralizedGuardrailItemId: ()=>getCentralizedGuardrailItemId,
35
+ isCentralizedGuardrailConfigMissing: ()=>isCentralizedGuardrailConfigMissing,
36
+ resolveCentralizedGuardrailParameters: ()=>resolveCentralizedGuardrailParameters
37
+ });
38
+ function getApplicableCentralizedGuardrails(guardrails, { isConversational }) {
39
+ return guardrails.filter((guardrail)=>isConversational ? guardrail.appliesToConversationalAgents : guardrail.appliesToAutonomousAgents);
40
+ }
41
+ function getCentralizedGuardrailItemId(guardrail) {
42
+ return JSON.stringify([
43
+ guardrail.validator,
44
+ guardrail.executionStage,
45
+ guardrail.isByo ? guardrail.name ?? null : false
46
+ ]);
47
+ }
48
+ function findCentralizedByoDefinition(guardrail, definitions) {
49
+ if (!guardrail.isByo || null == guardrail.name) return;
50
+ return definitions?.find((definition)=>definition.byoValidatorName === guardrail.name && definition.validator === guardrail.validator);
51
+ }
52
+ function findCentralizedBuiltInDefinition(guardrail, definitions) {
53
+ if (guardrail.isByo) return;
54
+ return definitions?.find((definition)=>definition.validator === guardrail.validator && void 0 === definition.byoValidatorName);
55
+ }
56
+ function isCentralizedGuardrailConfigMissing(guardrail, definitions) {
57
+ if (!guardrail.isByo || void 0 === definitions) return false;
58
+ return void 0 === findCentralizedByoDefinition(guardrail, definitions);
59
+ }
60
+ function getCentralizedGuardrailDisplay(guardrail, { definition, copy } = {}) {
61
+ const curated = guardrail.isByo ? void 0 : copy?.[guardrail.validator];
62
+ const description = guardrail.isByo ? definition?.description : curated?.description;
63
+ return {
64
+ name: guardrail.name ?? curated?.displayName ?? guardrail.validator,
65
+ description: void 0 === description || '' === description ? void 0 : description
66
+ };
67
+ }
68
+ const isPlainObject = (value)=>null !== value && 'object' == typeof value && !Array.isArray(value);
69
+ const asStringArray = (value)=>Array.isArray(value) ? value.filter((item)=>'string' == typeof item) : [];
70
+ const asNumberRecord = (value)=>isPlainObject(value) ? Object.fromEntries(Object.entries(value).filter((entry)=>'number' == typeof entry[1])) : {};
71
+ function liftBuiltInConfiguration(guardrail, definition, labels) {
72
+ const declared = definition?.parameters ?? [];
73
+ const thresholdsDefinition = declared.find((parameter)=>'map-enum' === parameter.type);
74
+ const entitiesDefinition = thresholdsDefinition?.keySource ? declared.find((parameter)=>parameter.id === thresholdsDefinition.keySource) : declared.find((parameter)=>'enum-list' === parameter.type);
75
+ const entitiesId = entitiesDefinition?.id ?? 'entities';
76
+ const thresholdsId = thresholdsDefinition?.id ?? 'entityThresholds';
77
+ const parameters = [];
78
+ if (null != guardrail.entities) parameters.push({
79
+ id: entitiesId,
80
+ value: guardrail.entities
81
+ });
82
+ if (null != guardrail.entityThresholds) parameters.push({
83
+ id: thresholdsId,
84
+ value: guardrail.entityThresholds
85
+ });
86
+ const definitions = declared.length > 0 ? declared : [
87
+ {
88
+ id: entitiesId,
89
+ type: 'enum-list',
90
+ label: labels.entities
91
+ },
92
+ {
93
+ id: thresholdsId,
94
+ type: 'map-enum',
95
+ label: labels.thresholds,
96
+ keySource: entitiesId
97
+ }
98
+ ];
99
+ return {
100
+ parameters,
101
+ definitions
102
+ };
103
+ }
104
+ function resolveCentralizedGuardrailParameters(guardrail, { definition, labels }) {
105
+ const { parameters, definitions } = guardrail.isByo ? {
106
+ parameters: guardrail.parameters ?? [],
107
+ definitions: definition?.parameters ?? []
108
+ } : liftBuiltInConfiguration(guardrail, definition, labels);
109
+ const valuesById = new Map(parameters.map((parameter)=>[
110
+ parameter.id,
111
+ parameter.value
112
+ ]));
113
+ const definitionsById = new Map(definitions.map((parameterDefinition)=>[
114
+ parameterDefinition.id,
115
+ parameterDefinition
116
+ ]));
117
+ const rendersAsThresholds = (id)=>isPlainObject(valuesById.get(id));
118
+ const optionLabel = (parameterDefinition, option)=>{
119
+ const optionLabels = parameterDefinition?.optionLabels;
120
+ const label = void 0 !== optionLabels && Object.hasOwn(optionLabels, option) ? optionLabels[option] : void 0;
121
+ return 'string' == typeof label ? label : option;
122
+ };
123
+ const formatValue = (parameterDefinition, value)=>{
124
+ if ('boolean' == typeof value) return value ? labels.enabled : labels.disabled;
125
+ if (Array.isArray(value)) return asStringArray(value).map((item)=>optionLabel(parameterDefinition, item)).join(', ');
126
+ if (null == value) return '';
127
+ return 'string' == typeof value ? optionLabel(parameterDefinition, value) : String(value);
128
+ };
129
+ const consumedIds = new Set();
130
+ for (const parameterDefinition of definitions)if (void 0 !== parameterDefinition.keySource && rendersAsThresholds(parameterDefinition.id)) consumedIds.add(parameterDefinition.keySource);
131
+ const toThresholdRow = (id, parameterDefinition)=>{
132
+ const thresholds = asNumberRecord(valuesById.get(id));
133
+ const keySourceDefinition = parameterDefinition?.keySource !== void 0 ? definitionsById.get(parameterDefinition.keySource) : void 0;
134
+ const keySourceList = keySourceDefinition?.type === 'enum-list' ? keySourceDefinition : void 0;
135
+ const selectedKeys = keySourceList ? asStringArray(valuesById.get(keySourceList.id)) : [];
136
+ const keys = Array.from(new Set([
137
+ ...Object.keys(thresholds),
138
+ ...selectedKeys
139
+ ]));
140
+ if (0 === keys.length) return;
141
+ return {
142
+ id,
143
+ kind: 'thresholds',
144
+ label: parameterDefinition?.label ?? labels.thresholds,
145
+ thresholds: keys.map((key)=>({
146
+ key,
147
+ label: optionLabel(keySourceList, key),
148
+ value: Object.hasOwn(thresholds, key) ? thresholds[key] : void 0
149
+ }))
150
+ };
151
+ };
152
+ const toValueRow = (id, parameterDefinition)=>{
153
+ const value = formatValue(parameterDefinition, valuesById.get(id));
154
+ if ('' === value) return;
155
+ return {
156
+ id,
157
+ kind: 'value',
158
+ label: parameterDefinition?.label ?? id,
159
+ value
160
+ };
161
+ };
162
+ const orderedIds = Array.from(new Set([
163
+ ...definitions.map((parameterDefinition)=>parameterDefinition.id),
164
+ ...parameters.map((parameter)=>parameter.id)
165
+ ]));
166
+ return orderedIds.filter((id)=>!consumedIds.has(id) && valuesById.has(id)).map((id)=>{
167
+ const parameterDefinition = definitionsById.get(id);
168
+ return rendersAsThresholds(id) ? toThresholdRow(id, parameterDefinition) : toValueRow(id, parameterDefinition);
169
+ }).filter((row)=>void 0 !== row);
170
+ }
171
+ function formatCentralizedExecutionStage(executionStage, labels) {
172
+ switch(executionStage){
173
+ case 'Pre':
174
+ return labels.stagePre;
175
+ case 'Post':
176
+ return labels.stagePost;
177
+ case 'Both':
178
+ return labels.stageBoth;
179
+ default:
180
+ return executionStage;
181
+ }
182
+ }
183
+ function formatCentralizedScope(scope, labels) {
184
+ switch(scope){
185
+ case 'Agent':
186
+ return labels.scopeAgent;
187
+ case 'Llm':
188
+ return labels.scopeLlm;
189
+ case 'Tool':
190
+ return labels.scopeTool;
191
+ default:
192
+ return scope;
193
+ }
194
+ }
195
+ function formatCentralizedAction(action, labels) {
196
+ switch(action){
197
+ case 'block':
198
+ return labels.actionBlock;
199
+ case 'escalate':
200
+ return labels.actionEscalate;
201
+ case 'filter':
202
+ return labels.actionFilter;
203
+ case 'log':
204
+ return labels.actionLog;
205
+ default:
206
+ return action;
207
+ }
208
+ }
209
+ exports.findCentralizedBuiltInDefinition = __webpack_exports__.findCentralizedBuiltInDefinition;
210
+ exports.findCentralizedByoDefinition = __webpack_exports__.findCentralizedByoDefinition;
211
+ exports.formatCentralizedAction = __webpack_exports__.formatCentralizedAction;
212
+ exports.formatCentralizedExecutionStage = __webpack_exports__.formatCentralizedExecutionStage;
213
+ exports.formatCentralizedScope = __webpack_exports__.formatCentralizedScope;
214
+ exports.getApplicableCentralizedGuardrails = __webpack_exports__.getApplicableCentralizedGuardrails;
215
+ exports.getCentralizedGuardrailDisplay = __webpack_exports__.getCentralizedGuardrailDisplay;
216
+ exports.getCentralizedGuardrailItemId = __webpack_exports__.getCentralizedGuardrailItemId;
217
+ exports.isCentralizedGuardrailConfigMissing = __webpack_exports__.isCentralizedGuardrailConfigMissing;
218
+ exports.resolveCentralizedGuardrailParameters = __webpack_exports__.resolveCentralizedGuardrailParameters;
219
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
220
+ "findCentralizedBuiltInDefinition",
221
+ "findCentralizedByoDefinition",
222
+ "formatCentralizedAction",
223
+ "formatCentralizedExecutionStage",
224
+ "formatCentralizedScope",
225
+ "getApplicableCentralizedGuardrails",
226
+ "getCentralizedGuardrailDisplay",
227
+ "getCentralizedGuardrailItemId",
228
+ "isCentralizedGuardrailConfigMissing",
229
+ "resolveCentralizedGuardrailParameters"
230
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
231
+ Object.defineProperty(exports, '__esModule', {
232
+ value: true
233
+ });
@@ -0,0 +1,33 @@
1
+ import type { GuardrailScope } from './builder-types';
2
+ import type { CentralizedGuardrail, CentralizedGuardrailActionType, CentralizedGuardrailDefinition, CentralizedGuardrailParameterRow } from './centralized-types';
3
+ import type { GuardrailCopyTable } from './definitions-copy';
4
+ import type { CentralizedGuardrailsLabels } from './i18n';
5
+ export type CentralizedGuardrailIdentity = Pick<CentralizedGuardrail, 'validator' | 'name' | 'isByo'>;
6
+ export declare function getApplicableCentralizedGuardrails<T extends CentralizedGuardrail>(guardrails: readonly T[], { isConversational }: {
7
+ isConversational?: boolean;
8
+ }): T[];
9
+ export declare function getCentralizedGuardrailItemId(guardrail: CentralizedGuardrail): string;
10
+ export declare function findCentralizedByoDefinition<T extends CentralizedGuardrailDefinition>(guardrail: CentralizedGuardrailIdentity, definitions: readonly T[] | undefined): T | undefined;
11
+ export declare function findCentralizedBuiltInDefinition<T extends CentralizedGuardrailDefinition>(guardrail: CentralizedGuardrailIdentity, definitions: readonly T[] | undefined): T | undefined;
12
+ export declare function isCentralizedGuardrailConfigMissing(guardrail: CentralizedGuardrailIdentity, definitions: readonly CentralizedGuardrailDefinition[] | undefined): boolean;
13
+ export declare function getCentralizedGuardrailDisplay(guardrail: CentralizedGuardrailIdentity, { definition, copy, }?: {
14
+ definition?: CentralizedGuardrailDefinition;
15
+ copy?: GuardrailCopyTable;
16
+ }): {
17
+ name: string;
18
+ description?: string;
19
+ };
20
+ export interface CentralizedParameterFallbackLabels {
21
+ enabled: string;
22
+ disabled: string;
23
+ entities: string;
24
+ thresholds: string;
25
+ }
26
+ export declare function resolveCentralizedGuardrailParameters(guardrail: CentralizedGuardrail, { definition, labels, }: {
27
+ definition?: CentralizedGuardrailDefinition;
28
+ labels: CentralizedParameterFallbackLabels;
29
+ }): CentralizedGuardrailParameterRow[];
30
+ export declare function formatCentralizedExecutionStage(executionStage: string, labels: CentralizedGuardrailsLabels): string;
31
+ export declare function formatCentralizedScope(scope: GuardrailScope, labels: CentralizedGuardrailsLabels): string;
32
+ export declare function formatCentralizedAction(action: CentralizedGuardrailActionType, labels: CentralizedGuardrailsLabels): string;
33
+ //# sourceMappingURL=centralized-guardrail-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"centralized-guardrail-utils.d.ts","sourceRoot":"","sources":["../../../../src/canvas/components/Guardrails/centralized-guardrail-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,8BAA8B,EAG9B,gCAAgC,EACjC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,QAAQ,CAAC;AAG1D,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAC7C,oBAAoB,EACpB,WAAW,GAAG,MAAM,GAAG,OAAO,CAC/B,CAAC;AAGF,wBAAgB,kCAAkC,CAAC,CAAC,SAAS,oBAAoB,EAC/E,UAAU,EAAE,SAAS,CAAC,EAAE,EACxB,EAAE,gBAAgB,EAAE,EAAE;IAAE,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAAE,GACnD,CAAC,EAAE,CAIL;AAGD,wBAAgB,6BAA6B,CAAC,SAAS,EAAE,oBAAoB,GAAG,MAAM,CAOrF;AAGD,wBAAgB,4BAA4B,CAAC,CAAC,SAAS,8BAA8B,EACnF,SAAS,EAAE,4BAA4B,EACvC,WAAW,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,GACpC,CAAC,GAAG,SAAS,CAMf;AAGD,wBAAgB,gCAAgC,CAAC,CAAC,SAAS,8BAA8B,EACvF,SAAS,EAAE,4BAA4B,EACvC,WAAW,EAAE,SAAS,CAAC,EAAE,GAAG,SAAS,GACpC,CAAC,GAAG,SAAS,CAMf;AAGD,wBAAgB,mCAAmC,CACjD,SAAS,EAAE,4BAA4B,EACvC,WAAW,EAAE,SAAS,8BAA8B,EAAE,GAAG,SAAS,GACjE,OAAO,CAGT;AAMD,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,4BAA4B,EACvC,EACE,UAAU,EACV,IAAI,GACL,GAAE;IAAE,UAAU,CAAC,EAAE,8BAA8B,CAAC;IAAC,IAAI,CAAC,EAAE,kBAAkB,CAAA;CAAO,GACjF;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAOxC;AAGD,MAAM,WAAW,kCAAkC;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACpB;AA0DD,wBAAgB,qCAAqC,CACnD,SAAS,EAAE,oBAAoB,EAC/B,EACE,UAAU,EACV,MAAM,GACP,EAAE;IAAE,UAAU,CAAC,EAAE,8BAA8B,CAAC;IAAC,MAAM,EAAE,kCAAkC,CAAA;CAAE,GAC7F,gCAAgC,EAAE,CAwGpC;AAGD,wBAAgB,+BAA+B,CAC7C,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,2BAA2B,GAClC,MAAM,CAWR;AAGD,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,cAAc,EACrB,MAAM,EAAE,2BAA2B,GAClC,MAAM,CAWR;AAGD,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,8BAA8B,EACtC,MAAM,EAAE,2BAA2B,GAClC,MAAM,CAaR"}