@ethisyscore/plugin-ui 1.131.1 → 1.133.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.
@@ -1,5 +1,5 @@
1
- import { C as ConnectorCanonicalField } from '../../mappingQueryKeys-DsZJn1sk.cjs';
2
- export { a as CONNECTOR_CONTROL_LABEL, b as ConnectorCanonicalFieldKind, c as ConnectorMappingSuggestionResult, d as ConnectorMappingTranslationEditorProps, e as ConnectorMappingTranslationEditorView, f as ConnectorMappingTranslationExtras, M as MappingCompletenessBanner, g as MappingCompletenessBannerProps, h as MappingCompletenessItem, i as MappingCompletenessResult, j as MappingReadiness, P as PLUGIN_PROVIDER_CONTROL_LABEL, k as PROVIDER_CONTROL_LABEL, l as PROVIDER_OPTION_LABEL, S as SUPPRESS_REQUEST_FIELD_VALUE, T as TestToolMappingExtractedField, m as TestToolMappingRequest, n as TestToolMappingResult, o as connectorMappingCompletenessQueryKey, p as connectorMappingsQueryKey, q as connectorMappingsRootQueryKey, r as pluginTargetMappingsQueryKey, s as selectIncompleteOperations, t as selectMappingReadiness, u as selectOptionalIncompleteOperations, v as selectRequiredIncompleteOperations, w as selectRequiredUnmappedOperations } from '../../mappingQueryKeys-DsZJn1sk.cjs';
1
+ import { C as ConnectorCanonicalField } from '../../mappingQueryKeys-_hEc0heh.cjs';
2
+ export { a as CONNECTOR_CONTROL_LABEL, b as ConnectorCanonicalFieldKind, c as ConnectorMappingSuggestionResult, d as ConnectorMappingTranslationEditorProps, e as ConnectorMappingTranslationEditorView, f as ConnectorMappingTranslationExtras, M as MappingCompletenessBanner, g as MappingCompletenessBannerProps, h as MappingCompletenessItem, i as MappingCompletenessResult, j as MappingReadiness, P as PLUGIN_PROVIDER_CONTROL_LABEL, k as PROVIDER_CONTROL_LABEL, l as PROVIDER_OPTION_LABEL, S as SUPPRESS_REQUEST_FIELD_VALUE, T as TestToolMappingExtractedField, m as TestToolMappingRequest, n as TestToolMappingResult, o as connectorMappingCompletenessQueryKey, p as connectorMappingsQueryKey, q as connectorMappingsRootQueryKey, r as pluginTargetMappingsQueryKey, s as selectIncompleteOperations, t as selectMappingReadiness, u as selectOptionalIncompleteOperations, v as selectRequiredIncompleteOperations, w as selectRequiredUnmappedOperations } from '../../mappingQueryKeys-_hEc0heh.cjs';
3
3
  import * as react from 'react';
4
4
  import { ReactNode } from 'react';
5
5
 
@@ -1,5 +1,5 @@
1
- import { C as ConnectorCanonicalField } from '../../mappingQueryKeys-DsZJn1sk.js';
2
- export { a as CONNECTOR_CONTROL_LABEL, b as ConnectorCanonicalFieldKind, c as ConnectorMappingSuggestionResult, d as ConnectorMappingTranslationEditorProps, e as ConnectorMappingTranslationEditorView, f as ConnectorMappingTranslationExtras, M as MappingCompletenessBanner, g as MappingCompletenessBannerProps, h as MappingCompletenessItem, i as MappingCompletenessResult, j as MappingReadiness, P as PLUGIN_PROVIDER_CONTROL_LABEL, k as PROVIDER_CONTROL_LABEL, l as PROVIDER_OPTION_LABEL, S as SUPPRESS_REQUEST_FIELD_VALUE, T as TestToolMappingExtractedField, m as TestToolMappingRequest, n as TestToolMappingResult, o as connectorMappingCompletenessQueryKey, p as connectorMappingsQueryKey, q as connectorMappingsRootQueryKey, r as pluginTargetMappingsQueryKey, s as selectIncompleteOperations, t as selectMappingReadiness, u as selectOptionalIncompleteOperations, v as selectRequiredIncompleteOperations, w as selectRequiredUnmappedOperations } from '../../mappingQueryKeys-DsZJn1sk.js';
1
+ import { C as ConnectorCanonicalField } from '../../mappingQueryKeys-_hEc0heh.js';
2
+ export { a as CONNECTOR_CONTROL_LABEL, b as ConnectorCanonicalFieldKind, c as ConnectorMappingSuggestionResult, d as ConnectorMappingTranslationEditorProps, e as ConnectorMappingTranslationEditorView, f as ConnectorMappingTranslationExtras, M as MappingCompletenessBanner, g as MappingCompletenessBannerProps, h as MappingCompletenessItem, i as MappingCompletenessResult, j as MappingReadiness, P as PLUGIN_PROVIDER_CONTROL_LABEL, k as PROVIDER_CONTROL_LABEL, l as PROVIDER_OPTION_LABEL, S as SUPPRESS_REQUEST_FIELD_VALUE, T as TestToolMappingExtractedField, m as TestToolMappingRequest, n as TestToolMappingResult, o as connectorMappingCompletenessQueryKey, p as connectorMappingsQueryKey, q as connectorMappingsRootQueryKey, r as pluginTargetMappingsQueryKey, s as selectIncompleteOperations, t as selectMappingReadiness, u as selectOptionalIncompleteOperations, v as selectRequiredIncompleteOperations, w as selectRequiredUnmappedOperations } from '../../mappingQueryKeys-_hEc0heh.js';
3
3
  import * as react from 'react';
4
4
  import { ReactNode } from 'react';
5
5
 
@@ -1654,6 +1654,18 @@ function rowFieldPathError(path) {
1654
1654
  if (trimmed.length > MAX_ROW_FIELD_TEXT_LENGTH) return `A path can be at most ${MAX_ROW_FIELD_TEXT_LENGTH} characters.`;
1655
1655
  return null;
1656
1656
  }
1657
+ var DUPLICATE_ROW_FIELD_KEY_ERROR = "This key is already used";
1658
+ function duplicateRowFieldKeyIndexes(rows) {
1659
+ const seen = /* @__PURE__ */ new Set();
1660
+ const duplicates = /* @__PURE__ */ new Set();
1661
+ rows.forEach(({ key }, index) => {
1662
+ const trimmed = key.trim();
1663
+ if (trimmed.length === 0) return;
1664
+ if (seen.has(trimmed)) duplicates.add(index);
1665
+ else seen.add(trimmed);
1666
+ });
1667
+ return duplicates;
1668
+ }
1657
1669
  var REQUEST_TEMPLATES_CAPTION = "The first template whose placeholders all have values is sent as the request. Leave empty to use the field map.";
1658
1670
  function RequestTemplatesSection({
1659
1671
  rows,
@@ -1742,6 +1754,7 @@ function RequestTemplatesSection({
1742
1754
  function RowFieldsSection({ objectFields, rows, onChange, onAdd, onRemove }) {
1743
1755
  return /* @__PURE__ */ jsx(Fragment, { children: objectFields.map((field) => {
1744
1756
  const fieldRows = rows[field.name] ?? [];
1757
+ const duplicateKeys = duplicateRowFieldKeyIndexes(fieldRows);
1745
1758
  return /* @__PURE__ */ jsxs(Box, { className: "flex flex-col gap-2 mb-3", children: [
1746
1759
  /* @__PURE__ */ jsx(Typography, { variant: "h6", component: "h2", children: `Row fields \u2014 ${field.name}` }),
1747
1760
  /* @__PURE__ */ jsxs(Typography, { variant: "caption", className: "text-text-secondary block", children: [
@@ -1759,9 +1772,11 @@ function RowFieldsSection({ objectFields, rows, onChange, onAdd, onRemove }) {
1759
1772
  value: row.key,
1760
1773
  onChange: (e) => onChange(field.name, index, { key: e.target.value }),
1761
1774
  inputProps: { "aria-label": `Row field name ${index + 1} for ${field.name}`, maxLength: MAX_ROW_FIELD_TEXT_LENGTH },
1775
+ error: duplicateKeys.has(index),
1762
1776
  placeholder: "e.g. domain"
1763
1777
  }
1764
- )
1778
+ ),
1779
+ duplicateKeys.has(index) && /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "error", role: "alert", children: DUPLICATE_ROW_FIELD_KEY_ERROR })
1765
1780
  ] }),
1766
1781
  /* @__PURE__ */ jsxs(FormControl, { variant: "filled", size: "medium", className: "surface mb-0 flex-1", children: [
1767
1782
  /* @__PURE__ */ jsx(InputLabel, { children: "JSON path in the row" }),
@@ -1875,7 +1890,9 @@ function ConnectorMappingTranslationEditorView({
1875
1890
  ])
1876
1891
  )
1877
1892
  );
1878
- const hasInvalidTemplate = showTemplates && templateRows.some((row) => row.text.trim().length > 0 && parseRequestTemplate(row.text).error !== null) || showRowFields && objectResponseFields.some((field) => (rowFieldRows[field.name] ?? []).some((row) => rowFieldPathError(row.path) !== null));
1893
+ const hasInvalidTemplate = showTemplates && templateRows.some((row) => row.text.trim().length > 0 && parseRequestTemplate(row.text).error !== null) || showRowFields && objectResponseFields.some(
1894
+ (field) => (rowFieldRows[field.name] ?? []).some((row) => rowFieldPathError(row.path) !== null) || duplicateRowFieldKeyIndexes(rowFieldRows[field.name] ?? []).size > 0
1895
+ );
1879
1896
  const handleTemplateChange = (index, text) => setTemplateRows((prev) => prev.map((row, i) => i === index ? { ...row, text } : row));
1880
1897
  const handleAddTemplate = () => setTemplateRows(
1881
1898
  (prev) => prev.length >= MAX_REQUEST_TEMPLATES ? prev : [...prev, { id: templateRowIdRef.current++, text: "" }]
@@ -1918,6 +1935,13 @@ function ConnectorMappingTranslationEditorView({
1918
1935
  const handleRemoveStaticRow = (index) => {
1919
1936
  setStaticRows((prev) => prev.filter((_, i) => i !== index));
1920
1937
  };
1938
+ const buildExtras = () => {
1939
+ if (!showTemplates && !showRowFields) return void 0;
1940
+ const extras = {};
1941
+ if (showTemplates) extras.requestTemplates = templateRowsToWire(templateRows);
1942
+ if (showRowFields) extras.responseItemFieldPaths = rowFieldRowsToWire(rowFieldRows, objectResponseFields);
1943
+ return extras;
1944
+ };
1921
1945
  const handleSave = () => {
1922
1946
  const requestMap = stripEmpty(requestValues);
1923
1947
  const responseMap = stripEmpty(responseValues);
@@ -1925,13 +1949,11 @@ function ConnectorMappingTranslationEditorView({
1925
1949
  const request = Object.keys(requestMap).length === 0 ? null : requestMap;
1926
1950
  const response = Object.keys(responseMap).length === 0 ? null : responseMap;
1927
1951
  const statics = Object.keys(staticMap).length === 0 ? null : staticMap;
1928
- if (!showTemplates && !showRowFields) {
1952
+ const extras = buildExtras();
1953
+ if (extras === void 0) {
1929
1954
  onSave(request, response, statics);
1930
1955
  return;
1931
1956
  }
1932
- const extras = {};
1933
- if (showTemplates) extras.requestTemplates = templateRowsToWire(templateRows);
1934
- if (showRowFields) extras.responseItemFieldPaths = rowFieldRowsToWire(rowFieldRows, objectResponseFields);
1935
1957
  onSave(request, response, statics, extras);
1936
1958
  };
1937
1959
  const handleTest = async () => {
@@ -1950,7 +1972,8 @@ function ConnectorMappingTranslationEditorView({
1950
1972
  responseFieldPaths: Object.keys(responseMap).length === 0 ? null : responseMap,
1951
1973
  staticRequestFields: Object.keys(staticMap).length === 0 ? null : staticMap
1952
1974
  };
1953
- const result = await onTestMapping(request);
1975
+ const extras = buildExtras();
1976
+ const result = extras === void 0 ? await onTestMapping(request) : await onTestMapping(request, extras);
1954
1977
  setTestResult(result);
1955
1978
  } catch {
1956
1979
  setTestResult({
@@ -2252,6 +2275,22 @@ function ConnectorMappingTranslationEditorView({
2252
2275
  },
2253
2276
  ef.canonicalField
2254
2277
  )) }),
2278
+ testResult.requestArgumentsJson && /* @__PURE__ */ jsxs(Box, { className: "mt-2", "data-testid": "test-request-sent", children: [
2279
+ /* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: "Request sent" }),
2280
+ /* @__PURE__ */ jsx(
2281
+ Box,
2282
+ {
2283
+ component: "pre",
2284
+ className: "mt-1 overflow-auto rounded p-3 text-xs",
2285
+ sx: {
2286
+ maxHeight: 240,
2287
+ backgroundColor: "action.hover",
2288
+ fontFamily: "monospace"
2289
+ },
2290
+ children: testResult.requestArgumentsJson
2291
+ }
2292
+ )
2293
+ ] }),
2255
2294
  testResult.rawResponseJson && /* @__PURE__ */ jsxs(Box, { className: "mt-2", children: [
2256
2295
  /* @__PURE__ */ jsx(
2257
2296
  Button,