@ethisyscore/plugin-ui 1.100.5 → 1.101.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.
@@ -320,9 +320,14 @@ interface IConnectorMappingService {
320
320
  * member. Callers must pass the COMPLETE translation; `useConnectorMappingMutations` is where
321
321
  * that is guaranteed.
322
322
  *
323
- * @returns the replacement row version, or `null` when the host returned none.
323
+ * @returns the replacement row version (or `null` when the host returned none), together with
324
+ * whatever the save-time gate established about the mapping that was stored.
325
+ *
326
+ * The findings are the point of the return type changing: they ride on a SUCCESS response, and
327
+ * returning the row version alone discarded them at this layer — so warnings the host composed
328
+ * were never seen by anyone.
324
329
  */
325
- updateMapping(connectorId: string, moduleKey: string, operationKey: string, toolName: string, rowVersion: string, requestFieldMap: Record<string, string> | null, responseFieldPaths: Record<string, string> | null, staticRequestFields: Record<string, string> | null): Promise<string | null>;
330
+ updateMapping(connectorId: string, moduleKey: string, operationKey: string, toolName: string, rowVersion: string, requestFieldMap: Record<string, string> | null, responseFieldPaths: Record<string, string> | null, staticRequestFields: Record<string, string> | null): Promise<MappingSaveOutcome>;
326
331
  /**
327
332
  * `connectors:mappings:delete`
328
333
  *
@@ -405,6 +410,28 @@ interface IConnectorEnumerationService {
405
410
  listConnectorTools(connectorId: string): Promise<ConnectorToolSummary[]>;
406
411
  }
407
412
 
413
+ /**
414
+ * What the save-time verification gate could establish about the mapping that was stored.
415
+ *
416
+ * Rides on a SUCCESS response: the gate refuses only what the invocation path refuses on every
417
+ * call, and everything else it establishes is true and worth an operator seeing without standing
418
+ * in the way of a save.
419
+ */
420
+ interface MappingVerificationFinding {
421
+ /** Stable code, e.g. `CON_MAP_020`. */
422
+ code: string;
423
+ /** `Warning`, or `Refusal` for one the caller acknowledged. */
424
+ severity: string;
425
+ /** Short operator-facing summary. */
426
+ message: string;
427
+ /** The longer explanation, when there is one. */
428
+ detail?: string | null;
429
+ }
430
+ /** What a mapping save returns: the refreshed token, and anything the gate had to say. */
431
+ interface MappingSaveOutcome {
432
+ rowVersion: string | null;
433
+ findings: MappingVerificationFinding[];
434
+ }
408
435
  /**
409
436
  * The connector tool-mapping surface, served entirely by the host's `connectors:mappings:*` tools.
410
437
  *
@@ -455,7 +482,7 @@ declare class ConnectorMappingService implements IConnectorMappingService, IConn
455
482
  /** Single seam every method goes through, so a subclass can wrap logging or retries in one place. */
456
483
  protected tool<TRes>(name: string, args?: unknown): Promise<TRes>;
457
484
  getMappings(connectorId: string, moduleKey: string): Promise<ConnectorMappingItem[]>;
458
- updateMapping(connectorId: string, moduleKey: string, operationKey: string, toolName: string, rowVersion: string, requestFieldMap: Record<string, string> | null, responseFieldPaths: Record<string, string> | null, staticRequestFields: Record<string, string> | null): Promise<string | null>;
485
+ updateMapping(connectorId: string, moduleKey: string, operationKey: string, toolName: string, rowVersion: string, requestFieldMap: Record<string, string> | null, responseFieldPaths: Record<string, string> | null, staticRequestFields: Record<string, string> | null): Promise<MappingSaveOutcome>;
459
486
  deleteMapping(connectorId: string, moduleKey: string, operationKey: string, rowVersion: string): Promise<void>;
460
487
  autoMatch(connectorId: string, moduleKey: string): Promise<AutoMatchResponse>;
461
488
  getMappingCompleteness(connectorId: string, moduleKey: string): Promise<MappingCompletenessResult>;
@@ -600,6 +627,12 @@ interface UseConnectorMappingMutationsOptions extends ConnectorMappingScope {
600
627
  * ultimately reached the same host event.
601
628
  */
602
629
  showSuccessToast?: (title: string, description?: string) => void;
630
+ /**
631
+ * Warning-toast sink, for the save-time gate's findings. Same defaulting and same reason as
632
+ * {@link showSuccessToast}; separate because a finding reported through the SUCCESS sink reads as
633
+ * part of "saved successfully", which is a warning nobody acts on.
634
+ */
635
+ showWarningToast?: (title: string, description?: string) => void;
603
636
  }
604
637
  /** Return shape of {@link useConnectorMappingMutations}. */
605
638
  interface UseConnectorMappingMutationsResult {
@@ -637,7 +670,7 @@ interface UseConnectorMappingMutationsResult {
637
670
  * See {@link resolveTranslationMember}: it was present in all three repos and was found by this
638
671
  * module's tests rather than in production.
639
672
  */
640
- declare function useConnectorMappingMutations({ service, connectorId, moduleKey, onMappingSaved, showSuccessToast, }: UseConnectorMappingMutationsOptions): UseConnectorMappingMutationsResult;
673
+ declare function useConnectorMappingMutations({ service, connectorId, moduleKey, onMappingSaved, showSuccessToast, showWarningToast, }: UseConnectorMappingMutationsOptions): UseConnectorMappingMutationsResult;
641
674
 
642
675
  /** Variables for one suggest-translation call. */
643
676
  interface SuggestMappingTranslationVars {
@@ -320,9 +320,14 @@ interface IConnectorMappingService {
320
320
  * member. Callers must pass the COMPLETE translation; `useConnectorMappingMutations` is where
321
321
  * that is guaranteed.
322
322
  *
323
- * @returns the replacement row version, or `null` when the host returned none.
323
+ * @returns the replacement row version (or `null` when the host returned none), together with
324
+ * whatever the save-time gate established about the mapping that was stored.
325
+ *
326
+ * The findings are the point of the return type changing: they ride on a SUCCESS response, and
327
+ * returning the row version alone discarded them at this layer — so warnings the host composed
328
+ * were never seen by anyone.
324
329
  */
325
- updateMapping(connectorId: string, moduleKey: string, operationKey: string, toolName: string, rowVersion: string, requestFieldMap: Record<string, string> | null, responseFieldPaths: Record<string, string> | null, staticRequestFields: Record<string, string> | null): Promise<string | null>;
330
+ updateMapping(connectorId: string, moduleKey: string, operationKey: string, toolName: string, rowVersion: string, requestFieldMap: Record<string, string> | null, responseFieldPaths: Record<string, string> | null, staticRequestFields: Record<string, string> | null): Promise<MappingSaveOutcome>;
326
331
  /**
327
332
  * `connectors:mappings:delete`
328
333
  *
@@ -405,6 +410,28 @@ interface IConnectorEnumerationService {
405
410
  listConnectorTools(connectorId: string): Promise<ConnectorToolSummary[]>;
406
411
  }
407
412
 
413
+ /**
414
+ * What the save-time verification gate could establish about the mapping that was stored.
415
+ *
416
+ * Rides on a SUCCESS response: the gate refuses only what the invocation path refuses on every
417
+ * call, and everything else it establishes is true and worth an operator seeing without standing
418
+ * in the way of a save.
419
+ */
420
+ interface MappingVerificationFinding {
421
+ /** Stable code, e.g. `CON_MAP_020`. */
422
+ code: string;
423
+ /** `Warning`, or `Refusal` for one the caller acknowledged. */
424
+ severity: string;
425
+ /** Short operator-facing summary. */
426
+ message: string;
427
+ /** The longer explanation, when there is one. */
428
+ detail?: string | null;
429
+ }
430
+ /** What a mapping save returns: the refreshed token, and anything the gate had to say. */
431
+ interface MappingSaveOutcome {
432
+ rowVersion: string | null;
433
+ findings: MappingVerificationFinding[];
434
+ }
408
435
  /**
409
436
  * The connector tool-mapping surface, served entirely by the host's `connectors:mappings:*` tools.
410
437
  *
@@ -455,7 +482,7 @@ declare class ConnectorMappingService implements IConnectorMappingService, IConn
455
482
  /** Single seam every method goes through, so a subclass can wrap logging or retries in one place. */
456
483
  protected tool<TRes>(name: string, args?: unknown): Promise<TRes>;
457
484
  getMappings(connectorId: string, moduleKey: string): Promise<ConnectorMappingItem[]>;
458
- updateMapping(connectorId: string, moduleKey: string, operationKey: string, toolName: string, rowVersion: string, requestFieldMap: Record<string, string> | null, responseFieldPaths: Record<string, string> | null, staticRequestFields: Record<string, string> | null): Promise<string | null>;
485
+ updateMapping(connectorId: string, moduleKey: string, operationKey: string, toolName: string, rowVersion: string, requestFieldMap: Record<string, string> | null, responseFieldPaths: Record<string, string> | null, staticRequestFields: Record<string, string> | null): Promise<MappingSaveOutcome>;
459
486
  deleteMapping(connectorId: string, moduleKey: string, operationKey: string, rowVersion: string): Promise<void>;
460
487
  autoMatch(connectorId: string, moduleKey: string): Promise<AutoMatchResponse>;
461
488
  getMappingCompleteness(connectorId: string, moduleKey: string): Promise<MappingCompletenessResult>;
@@ -600,6 +627,12 @@ interface UseConnectorMappingMutationsOptions extends ConnectorMappingScope {
600
627
  * ultimately reached the same host event.
601
628
  */
602
629
  showSuccessToast?: (title: string, description?: string) => void;
630
+ /**
631
+ * Warning-toast sink, for the save-time gate's findings. Same defaulting and same reason as
632
+ * {@link showSuccessToast}; separate because a finding reported through the SUCCESS sink reads as
633
+ * part of "saved successfully", which is a warning nobody acts on.
634
+ */
635
+ showWarningToast?: (title: string, description?: string) => void;
603
636
  }
604
637
  /** Return shape of {@link useConnectorMappingMutations}. */
605
638
  interface UseConnectorMappingMutationsResult {
@@ -637,7 +670,7 @@ interface UseConnectorMappingMutationsResult {
637
670
  * See {@link resolveTranslationMember}: it was present in all three repos and was found by this
638
671
  * module's tests rather than in production.
639
672
  */
640
- declare function useConnectorMappingMutations({ service, connectorId, moduleKey, onMappingSaved, showSuccessToast, }: UseConnectorMappingMutationsOptions): UseConnectorMappingMutationsResult;
673
+ declare function useConnectorMappingMutations({ service, connectorId, moduleKey, onMappingSaved, showSuccessToast, showWarningToast, }: UseConnectorMappingMutationsOptions): UseConnectorMappingMutationsResult;
641
674
 
642
675
  /** Variables for one suggest-translation call. */
643
676
  interface SuggestMappingTranslationVars {
@@ -37,7 +37,10 @@ var ConnectorMappingService = class {
37
37
  responseFieldPaths: responseFieldPaths ?? null,
38
38
  staticRequestFields: staticRequestFields ?? null
39
39
  });
40
- return response?.rowVersion ?? null;
40
+ return {
41
+ rowVersion: response?.rowVersion ?? null,
42
+ findings: response?.findings ?? []
43
+ };
41
44
  }
42
45
  async deleteMapping(connectorId, moduleKey, operationKey, rowVersion) {
43
46
  await this.tool("connectors:mappings:delete", {
@@ -319,6 +322,9 @@ function dispatchToast(title, description, variant) {
319
322
  function showSuccessToast(title, description) {
320
323
  dispatchToast(title, description, "success");
321
324
  }
325
+ function showWarningToast(title, description) {
326
+ dispatchToast(title, description, "warning");
327
+ }
322
328
 
323
329
  // src/connector-mappings/types.ts
324
330
  var MAPPING_SOURCE = {
@@ -370,7 +376,8 @@ function useConnectorMappingMutations({
370
376
  connectorId,
371
377
  moduleKey,
372
378
  onMappingSaved,
373
- showSuccessToast: showSuccessToast2 = showSuccessToast
379
+ showSuccessToast: showSuccessToast2 = showSuccessToast,
380
+ showWarningToast: showWarningToast2 = showWarningToast
374
381
  }) {
375
382
  const queryClient = useQueryClient();
376
383
  const [autoMatchSummary, setAutoMatchSummary] = useState(null);
@@ -413,12 +420,20 @@ function useConnectorMappingMutations({
413
420
  args.staticRequestFields
414
421
  ),
415
422
  meta: { errorTitle: "Update failed" },
416
- onSuccess: () => {
423
+ onSuccess: (outcome) => {
417
424
  invalidateMappingsAndCompleteness();
418
425
  if (connectorId) {
419
426
  onMappingSaved?.(connectorId, moduleKey);
420
427
  }
421
- showSuccessToast2("Mapping updated", "The tool mapping was saved.");
428
+ const findings = outcome?.findings ?? [];
429
+ if (findings.length === 0) {
430
+ showSuccessToast2("Mapping updated", "The tool mapping was saved.");
431
+ return;
432
+ }
433
+ showWarningToast2(
434
+ findings.length === 1 ? "Mapping saved, with a warning" : `Mapping saved, with ${findings.length} warnings`,
435
+ findings.map((f) => `${f.message}${f.detail ? ` ${f.detail}` : ""} (${f.code})`).join(" ")
436
+ );
422
437
  }
423
438
  });
424
439
  const deleteMapping = useMutation({