@printwithsynergy/artwork-pdf-editor 0.2.0 → 0.4.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.
- package/LICENSE +62 -0
- package/dist/components/AccessibilityHintsPanel.d.ts +142 -0
- package/dist/components/AccessibilityHintsPanel.d.ts.map +1 -0
- package/dist/components/AccessibilityHintsPanel.js +158 -0
- package/dist/components/AccessibilityHintsPanel.js.map +1 -0
- package/dist/components/AnnotationOverlay.d.ts +142 -0
- package/dist/components/AnnotationOverlay.d.ts.map +1 -0
- package/dist/components/AnnotationOverlay.js +141 -0
- package/dist/components/AnnotationOverlay.js.map +1 -0
- package/dist/components/AnnotationsSidebar.d.ts +98 -0
- package/dist/components/AnnotationsSidebar.d.ts.map +1 -0
- package/dist/components/AnnotationsSidebar.js +100 -0
- package/dist/components/AnnotationsSidebar.js.map +1 -0
- package/dist/components/BarcodeGeneratorPanel.d.ts +58 -0
- package/dist/components/BarcodeGeneratorPanel.d.ts.map +1 -0
- package/dist/components/BarcodeGeneratorPanel.js +91 -0
- package/dist/components/BarcodeGeneratorPanel.js.map +1 -0
- package/dist/components/BraillePanel.d.ts +99 -0
- package/dist/components/BraillePanel.d.ts.map +1 -0
- package/dist/components/BraillePanel.js +221 -0
- package/dist/components/BraillePanel.js.map +1 -0
- package/dist/components/BrandAssetsPanel.d.ts +130 -0
- package/dist/components/BrandAssetsPanel.d.ts.map +1 -0
- package/dist/components/BrandAssetsPanel.js +125 -0
- package/dist/components/BrandAssetsPanel.js.map +1 -0
- package/dist/components/BrandConsistencyPanel.d.ts +140 -0
- package/dist/components/BrandConsistencyPanel.d.ts.map +1 -0
- package/dist/components/BrandConsistencyPanel.js +158 -0
- package/dist/components/BrandConsistencyPanel.js.map +1 -0
- package/dist/components/ComplianceFindingsPanel.d.ts +62 -0
- package/dist/components/ComplianceFindingsPanel.d.ts.map +1 -0
- package/dist/components/ComplianceFindingsPanel.js +118 -0
- package/dist/components/ComplianceFindingsPanel.js.map +1 -0
- package/dist/components/DesignSuggestionsPanel.d.ts +148 -0
- package/dist/components/DesignSuggestionsPanel.d.ts.map +1 -0
- package/dist/components/DesignSuggestionsPanel.js +154 -0
- package/dist/components/DesignSuggestionsPanel.js.map +1 -0
- package/dist/components/DielineParametersPanel.d.ts +62 -0
- package/dist/components/DielineParametersPanel.d.ts.map +1 -0
- package/dist/components/DielineParametersPanel.js +170 -0
- package/dist/components/DielineParametersPanel.js.map +1 -0
- package/dist/components/DielinePreview.d.ts +150 -0
- package/dist/components/DielinePreview.d.ts.map +1 -0
- package/dist/components/DielinePreview.js +146 -0
- package/dist/components/DielinePreview.js.map +1 -0
- package/dist/components/EditorApp.d.ts +18 -3
- package/dist/components/EditorApp.d.ts.map +1 -1
- package/dist/components/EditorApp.js +42 -7
- package/dist/components/EditorApp.js.map +1 -1
- package/dist/components/EditorCanvas.d.ts +31 -2
- package/dist/components/EditorCanvas.d.ts.map +1 -1
- package/dist/components/EditorCanvas.js +97 -16
- package/dist/components/EditorCanvas.js.map +1 -1
- package/dist/components/EmailNotifyPanel.d.ts +165 -0
- package/dist/components/EmailNotifyPanel.d.ts.map +1 -0
- package/dist/components/EmailNotifyPanel.js +211 -0
- package/dist/components/EmailNotifyPanel.js.map +1 -0
- package/dist/components/FileDropZone.d.ts +9 -1
- package/dist/components/FileDropZone.d.ts.map +1 -1
- package/dist/components/FileDropZone.js +53 -5
- package/dist/components/FileDropZone.js.map +1 -1
- package/dist/components/FoldEditorPanel.d.ts +68 -0
- package/dist/components/FoldEditorPanel.d.ts.map +1 -0
- package/dist/components/FoldEditorPanel.js +65 -0
- package/dist/components/FoldEditorPanel.js.map +1 -0
- package/dist/components/FoldPreviewOverlay.d.ts +48 -0
- package/dist/components/FoldPreviewOverlay.d.ts.map +1 -0
- package/dist/components/FoldPreviewOverlay.js +182 -0
- package/dist/components/FoldPreviewOverlay.js.map +1 -0
- package/dist/components/Gs1DigitalLinkPanel.d.ts +103 -0
- package/dist/components/Gs1DigitalLinkPanel.d.ts.map +1 -0
- package/dist/components/Gs1DigitalLinkPanel.js +199 -0
- package/dist/components/Gs1DigitalLinkPanel.js.map +1 -0
- package/dist/components/HistoryPanel.d.ts +39 -0
- package/dist/components/HistoryPanel.d.ts.map +1 -0
- package/dist/components/HistoryPanel.js +72 -0
- package/dist/components/HistoryPanel.js.map +1 -0
- package/dist/components/IccSoftProofOverlay.d.ts +67 -0
- package/dist/components/IccSoftProofOverlay.d.ts.map +1 -0
- package/dist/components/IccSoftProofOverlay.js +119 -0
- package/dist/components/IccSoftProofOverlay.js.map +1 -0
- package/dist/components/ImposePanel.d.ts +71 -0
- package/dist/components/ImposePanel.d.ts.map +1 -0
- package/dist/components/ImposePanel.js +127 -0
- package/dist/components/ImposePanel.js.map +1 -0
- package/dist/components/InksPanel.d.ts +61 -0
- package/dist/components/InksPanel.d.ts.map +1 -0
- package/dist/components/InksPanel.js +84 -0
- package/dist/components/InksPanel.js.map +1 -0
- package/dist/components/JobSetupPanel.d.ts +118 -0
- package/dist/components/JobSetupPanel.d.ts.map +1 -0
- package/dist/components/JobSetupPanel.js +169 -0
- package/dist/components/JobSetupPanel.js.map +1 -0
- package/dist/components/LayersPanel.d.ts.map +1 -1
- package/dist/components/LayersPanel.js +1 -0
- package/dist/components/LayersPanel.js.map +1 -1
- package/dist/components/MarkLibraryPanel.d.ts +131 -0
- package/dist/components/MarkLibraryPanel.d.ts.map +1 -0
- package/dist/components/MarkLibraryPanel.js +184 -0
- package/dist/components/MarkLibraryPanel.js.map +1 -0
- package/dist/components/MisEstimateButton.d.ts +73 -0
- package/dist/components/MisEstimateButton.d.ts.map +1 -0
- package/dist/components/MisEstimateButton.js +57 -0
- package/dist/components/MisEstimateButton.js.map +1 -0
- package/dist/components/NutritionPanel.d.ts +118 -0
- package/dist/components/NutritionPanel.d.ts.map +1 -0
- package/dist/components/NutritionPanel.js +169 -0
- package/dist/components/NutritionPanel.js.map +1 -0
- package/dist/components/PageNavigator.d.ts.map +1 -1
- package/dist/components/PageNavigator.js +6 -1
- package/dist/components/PageNavigator.js.map +1 -1
- package/dist/components/PaletteManager.d.ts +32 -0
- package/dist/components/PaletteManager.d.ts.map +1 -0
- package/dist/components/PaletteManager.js +89 -0
- package/dist/components/PaletteManager.js.map +1 -0
- package/dist/components/PaletteToSpotPanel.d.ts +122 -0
- package/dist/components/PaletteToSpotPanel.d.ts.map +1 -0
- package/dist/components/PaletteToSpotPanel.js +160 -0
- package/dist/components/PaletteToSpotPanel.js.map +1 -0
- package/dist/components/PreflightAutoFixPanel.d.ts +110 -0
- package/dist/components/PreflightAutoFixPanel.d.ts.map +1 -0
- package/dist/components/PreflightAutoFixPanel.js +119 -0
- package/dist/components/PreflightAutoFixPanel.js.map +1 -0
- package/dist/components/PreflightDiffPanel.d.ts +127 -0
- package/dist/components/PreflightDiffPanel.d.ts.map +1 -0
- package/dist/components/PreflightDiffPanel.js +0 -0
- package/dist/components/PreflightDiffPanel.js.map +1 -0
- package/dist/components/ProcessRulesPanel.d.ts +81 -0
- package/dist/components/ProcessRulesPanel.d.ts.map +1 -0
- package/dist/components/ProcessRulesPanel.js +143 -0
- package/dist/components/ProcessRulesPanel.js.map +1 -0
- package/dist/components/SlackNotifyPanel.d.ts +139 -0
- package/dist/components/SlackNotifyPanel.d.ts.map +1 -0
- package/dist/components/SlackNotifyPanel.js +133 -0
- package/dist/components/SlackNotifyPanel.js.map +1 -0
- package/dist/components/SmartSpotMatchPanel.d.ts +143 -0
- package/dist/components/SmartSpotMatchPanel.d.ts.map +1 -0
- package/dist/components/SmartSpotMatchPanel.js +159 -0
- package/dist/components/SmartSpotMatchPanel.js.map +1 -0
- package/dist/components/StreamingRenderProgress.d.ts +60 -0
- package/dist/components/StreamingRenderProgress.d.ts.map +1 -0
- package/dist/components/StreamingRenderProgress.js +99 -0
- package/dist/components/StreamingRenderProgress.js.map +1 -0
- package/dist/components/SwatchesPicker.d.ts +83 -0
- package/dist/components/SwatchesPicker.d.ts.map +1 -0
- package/dist/components/SwatchesPicker.js +151 -0
- package/dist/components/SwatchesPicker.js.map +1 -0
- package/dist/components/TacOverlay.d.ts +47 -0
- package/dist/components/TacOverlay.d.ts.map +1 -0
- package/dist/components/TacOverlay.js +116 -0
- package/dist/components/TacOverlay.js.map +1 -0
- package/dist/components/TrapEditorPanel.d.ts +52 -0
- package/dist/components/TrapEditorPanel.d.ts.map +1 -0
- package/dist/components/TrapEditorPanel.js +64 -0
- package/dist/components/TrapEditorPanel.js.map +1 -0
- package/dist/components/TrapPreviewOverlay.d.ts +64 -0
- package/dist/components/TrapPreviewOverlay.d.ts.map +1 -0
- package/dist/components/TrapPreviewOverlay.js +120 -0
- package/dist/components/TrapPreviewOverlay.js.map +1 -0
- package/dist/components/VariantMatrixPanel.d.ts +61 -0
- package/dist/components/VariantMatrixPanel.d.ts.map +1 -0
- package/dist/components/VariantMatrixPanel.js +97 -0
- package/dist/components/VariantMatrixPanel.js.map +1 -0
- package/dist/components/VariantMatrixVersionPanel.d.ts +122 -0
- package/dist/components/VariantMatrixVersionPanel.d.ts.map +1 -0
- package/dist/components/VariantMatrixVersionPanel.js +162 -0
- package/dist/components/VariantMatrixVersionPanel.js.map +1 -0
- package/dist/components/WebhookNotifyPanel.d.ts +160 -0
- package/dist/components/WebhookNotifyPanel.d.ts.map +1 -0
- package/dist/components/WebhookNotifyPanel.js +100 -0
- package/dist/components/WebhookNotifyPanel.js.map +1 -0
- package/dist/components/WhiteUnderbasePanel.d.ts +107 -0
- package/dist/components/WhiteUnderbasePanel.d.ts.map +1 -0
- package/dist/components/WhiteUnderbasePanel.js +104 -0
- package/dist/components/WhiteUnderbasePanel.js.map +1 -0
- package/dist/hooks/useEditorMode.d.ts +25 -5
- package/dist/hooks/useEditorMode.d.ts.map +1 -1
- package/dist/hooks/useEditorMode.js +18 -5
- package/dist/hooks/useEditorMode.js.map +1 -1
- package/dist/index.d.ts +51 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -2
- package/dist/index.js.map +1 -1
- package/dist/lens/preflight-findings.d.ts.map +1 -1
- package/dist/lens/preflight-findings.js.map +1 -1
- package/dist/lib/barcode-scan.d.ts +154 -0
- package/dist/lib/barcode-scan.d.ts.map +1 -0
- package/dist/lib/barcode-scan.js +152 -0
- package/dist/lib/barcode-scan.js.map +1 -0
- package/dist/lib/color-math.d.ts +76 -0
- package/dist/lib/color-math.d.ts.map +1 -0
- package/dist/lib/color-math.js +96 -0
- package/dist/lib/color-math.js.map +1 -0
- package/dist/lib/dieline-template.d.ts +87 -0
- package/dist/lib/dieline-template.d.ts.map +1 -1
- package/dist/lib/dieline-template.js +163 -0
- package/dist/lib/dieline-template.js.map +1 -1
- package/dist/lib/editor-config.d.ts +390 -0
- package/dist/lib/editor-config.d.ts.map +1 -1
- package/dist/lib/editor-config.js +90 -0
- package/dist/lib/editor-config.js.map +1 -1
- package/dist/lib/fold-geometry.d.ts +144 -0
- package/dist/lib/fold-geometry.d.ts.map +1 -0
- package/dist/lib/fold-geometry.js +138 -0
- package/dist/lib/fold-geometry.js.map +1 -0
- package/dist/lib/merge-tokens.d.ts +81 -0
- package/dist/lib/merge-tokens.d.ts.map +1 -0
- package/dist/lib/merge-tokens.js +88 -0
- package/dist/lib/merge-tokens.js.map +1 -0
- package/dist/lib/palette-registry.d.ts +40 -0
- package/dist/lib/palette-registry.d.ts.map +1 -0
- package/dist/lib/palette-registry.js +50 -0
- package/dist/lib/palette-registry.js.map +1 -0
- package/dist/lib/panel-anchor.d.ts +101 -0
- package/dist/lib/panel-anchor.d.ts.map +1 -0
- package/dist/lib/panel-anchor.js +68 -0
- package/dist/lib/panel-anchor.js.map +1 -0
- package/dist/lib/preflight/checks.d.ts.map +1 -1
- package/dist/lib/preflight/checks.js +71 -0
- package/dist/lib/preflight/checks.js.map +1 -1
- package/dist/lib/preflight/types.d.ts.map +1 -1
- package/dist/lib/preflight/types.js +11 -0
- package/dist/lib/preflight/types.js.map +1 -1
- package/dist/lib/rasterize.d.ts +93 -0
- package/dist/lib/rasterize.d.ts.map +1 -0
- package/dist/lib/rasterize.js +117 -0
- package/dist/lib/rasterize.js.map +1 -0
- package/dist/lib/separations-registry.d.ts +99 -0
- package/dist/lib/separations-registry.d.ts.map +1 -0
- package/dist/lib/separations-registry.js +59 -0
- package/dist/lib/separations-registry.js.map +1 -0
- package/dist/lib/streaming-render.d.ts +100 -0
- package/dist/lib/streaming-render.d.ts.map +1 -0
- package/dist/lib/streaming-render.js +132 -0
- package/dist/lib/streaming-render.js.map +1 -0
- package/dist/lib/unwired.d.ts +29 -0
- package/dist/lib/unwired.d.ts.map +1 -0
- package/dist/lib/unwired.js +58 -0
- package/dist/lib/unwired.js.map +1 -0
- package/package.json +20 -11
- package/dist/components/SeparationsPanel.d.ts +0 -9
- package/dist/components/SeparationsPanel.d.ts.map +0 -1
- package/dist/components/SeparationsPanel.js +0 -168
- package/dist/components/SeparationsPanel.js.map +0 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wave 4 V3 — versioned variant matrix viewer.
|
|
3
|
+
*
|
|
4
|
+
* Reads a list of historical {@link VariantMatrixSnapshot}s (typically
|
|
5
|
+
* derived from `DocumentV3.variants.version` paired with snapshots
|
|
6
|
+
* the host persists) and surfaces a "v1.2.0 vs v1.3.0" diff. Hosts
|
|
7
|
+
* that ship variant-aware versioning land this in their MIS chrome
|
|
8
|
+
* so a designer can answer "which row did the brand team add in the
|
|
9
|
+
* last revision?" without a full table re-read.
|
|
10
|
+
*
|
|
11
|
+
* Pure controlled component — host owns history, baselineVersion,
|
|
12
|
+
* and currentVersion. The diff helper {@link diffVariantMatrices}
|
|
13
|
+
* is exported so hosts can drive custom rendering (sparkline,
|
|
14
|
+
* change log, MIS audit row) over the same algorithm.
|
|
15
|
+
*
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
import type { ReactElement } from "react";
|
|
19
|
+
import type { VariantMatrixPanelValue, VariantMatrixPanelVariant } from "./VariantMatrixPanel";
|
|
20
|
+
/**
|
|
21
|
+
* One historical variant-matrix snapshot. Structurally compatible
|
|
22
|
+
* with `{ version, ...VariantMatrix }` from
|
|
23
|
+
* `@artworkpdf/document-model` — hosts that carry their own
|
|
24
|
+
* version-history list construct snapshots by stamping each
|
|
25
|
+
* persisted `variants` payload with the matrix-level `version`.
|
|
26
|
+
*
|
|
27
|
+
* @public
|
|
28
|
+
*/
|
|
29
|
+
export type VariantMatrixSnapshot = {
|
|
30
|
+
version: string;
|
|
31
|
+
matrix: VariantMatrixPanelValue;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Per-variant modification record produced by
|
|
35
|
+
* {@link diffVariantMatrices}.
|
|
36
|
+
*
|
|
37
|
+
* `changedTokens` is the list of token keys whose value differs
|
|
38
|
+
* between baseline and current; `nameChanged` is true when the
|
|
39
|
+
* variant's human-readable `name` changed (with the `id` still
|
|
40
|
+
* matching). Either being non-empty makes the variant "modified".
|
|
41
|
+
*
|
|
42
|
+
* @public
|
|
43
|
+
*/
|
|
44
|
+
export type VariantMatrixModifiedVariant = {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
changedTokens: readonly string[];
|
|
48
|
+
nameChanged: boolean;
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Result of {@link diffVariantMatrices}.
|
|
52
|
+
*
|
|
53
|
+
* - `addedVariants` — present in `current` but not `baseline`.
|
|
54
|
+
* - `removedVariants` — present in `baseline` but not `current`.
|
|
55
|
+
* - `modifiedVariants` — present in both with at least one token
|
|
56
|
+
* override change or a name change.
|
|
57
|
+
* - `addedTokenKeys` / `removedTokenKeys` — the diff of the column
|
|
58
|
+
* set (`matrix.tokenKeys`).
|
|
59
|
+
*
|
|
60
|
+
* @public
|
|
61
|
+
*/
|
|
62
|
+
export type VariantMatrixDiffResult = {
|
|
63
|
+
addedVariants: readonly VariantMatrixPanelVariant[];
|
|
64
|
+
removedVariants: readonly VariantMatrixPanelVariant[];
|
|
65
|
+
modifiedVariants: readonly VariantMatrixModifiedVariant[];
|
|
66
|
+
addedTokenKeys: readonly string[];
|
|
67
|
+
removedTokenKeys: readonly string[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* @public
|
|
71
|
+
*/
|
|
72
|
+
export type VariantMatrixVersionPanelProps = {
|
|
73
|
+
/** Ordered version history, oldest → newest. Typically the host's
|
|
74
|
+
* matrix-snapshot ring buffer. Empty array surfaces a "no
|
|
75
|
+
* history yet" hint. */
|
|
76
|
+
history: readonly VariantMatrixSnapshot[];
|
|
77
|
+
/** Version to compare against. Absent → the second-to-latest
|
|
78
|
+
* snapshot when `history.length >= 2`, else the only snapshot. */
|
|
79
|
+
baselineVersion?: string;
|
|
80
|
+
/** Version to compare as "current". Absent → the most-recent
|
|
81
|
+
* snapshot. */
|
|
82
|
+
currentVersion?: string;
|
|
83
|
+
/** Fires when the user picks a different baseline from the panel's
|
|
84
|
+
* dropdown. */
|
|
85
|
+
onBaselineChange?: (version: string) => void;
|
|
86
|
+
/** Fires when the user picks a different current version. */
|
|
87
|
+
onCurrentChange?: (version: string) => void;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Resolve which snapshot the panel should pull from `history`.
|
|
91
|
+
*
|
|
92
|
+
* Behaviour matches `PreflightDiffPanel.resolveBaselineSnapshot`:
|
|
93
|
+
* an explicit version wins when found, else falls back to the
|
|
94
|
+
* most-recent snapshot. Returns `undefined` only when `history` is
|
|
95
|
+
* empty. Falling back keeps the panel useful after a host trims
|
|
96
|
+
* history below the user's saved selection.
|
|
97
|
+
*
|
|
98
|
+
* Pure function; exposed for hosts that mirror the panel's
|
|
99
|
+
* selection in their own chrome.
|
|
100
|
+
*
|
|
101
|
+
* @public
|
|
102
|
+
*/
|
|
103
|
+
export declare function resolveSnapshot(history: readonly VariantMatrixSnapshot[], version: string | undefined): VariantMatrixSnapshot | undefined;
|
|
104
|
+
/**
|
|
105
|
+
* Compute the variant-row + token-column diff between two matrices.
|
|
106
|
+
*
|
|
107
|
+
* Variants are matched by `id`; the human-readable `name` and token
|
|
108
|
+
* `overrides` are compared per-id. Token keys are diffed as sets
|
|
109
|
+
* (order-insensitive). Pure function — no React, no DOM.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export declare function diffVariantMatrices(baseline: VariantMatrixPanelValue, current: VariantMatrixPanelValue): VariantMatrixDiffResult;
|
|
114
|
+
/**
|
|
115
|
+
* Read-only viewer for a versioned variant matrix history. Picks
|
|
116
|
+
* a baseline + current version (dropdowns) and renders a per-row
|
|
117
|
+
* diff plus a token-column diff.
|
|
118
|
+
*
|
|
119
|
+
* @public
|
|
120
|
+
*/
|
|
121
|
+
export declare function VariantMatrixVersionPanel({ history, baselineVersion, currentVersion, onBaselineChange, onCurrentChange, }: VariantMatrixVersionPanelProps): ReactElement;
|
|
122
|
+
//# sourceMappingURL=VariantMatrixVersionPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VariantMatrixVersionPanel.d.ts","sourceRoot":"","sources":["../../src/components/VariantMatrixVersionPanel.tsx"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,KAAK,EAAE,uBAAuB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAE/F;;;;;;;;GAQG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,uBAAuB,CAAC;CACjC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,WAAW,EAAE,OAAO,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,MAA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+
import { useMemo } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* Resolve which snapshot the panel should pull from `history`.
|
|
7
|
+
*
|
|
8
|
+
* Behaviour matches `PreflightDiffPanel.resolveBaselineSnapshot`:
|
|
9
|
+
* an explicit version wins when found, else falls back to the
|
|
10
|
+
* most-recent snapshot. Returns `undefined` only when `history` is
|
|
11
|
+
* empty. Falling back keeps the panel useful after a host trims
|
|
12
|
+
* history below the user's saved selection.
|
|
13
|
+
*
|
|
14
|
+
* Pure function; exposed for hosts that mirror the panel's
|
|
15
|
+
* selection in their own chrome.
|
|
16
|
+
*
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export function resolveSnapshot(history, version) {
|
|
20
|
+
if (history.length === 0)
|
|
21
|
+
return undefined;
|
|
22
|
+
if (version !== undefined) {
|
|
23
|
+
const explicit = history.find((s) => s.version === version);
|
|
24
|
+
if (explicit)
|
|
25
|
+
return explicit;
|
|
26
|
+
}
|
|
27
|
+
return history[history.length - 1];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Compute the variant-row + token-column diff between two matrices.
|
|
31
|
+
*
|
|
32
|
+
* Variants are matched by `id`; the human-readable `name` and token
|
|
33
|
+
* `overrides` are compared per-id. Token keys are diffed as sets
|
|
34
|
+
* (order-insensitive). Pure function — no React, no DOM.
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export function diffVariantMatrices(baseline, current) {
|
|
39
|
+
const baselineById = new Map(baseline.variants.map((v) => [v.id, v]));
|
|
40
|
+
const currentById = new Map(current.variants.map((v) => [v.id, v]));
|
|
41
|
+
const addedVariants = [];
|
|
42
|
+
const removedVariants = [];
|
|
43
|
+
const modifiedVariants = [];
|
|
44
|
+
for (const v of current.variants) {
|
|
45
|
+
const prior = baselineById.get(v.id);
|
|
46
|
+
if (!prior) {
|
|
47
|
+
addedVariants.push(v);
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const changedTokens = diffOverrideKeys(prior.overrides, v.overrides);
|
|
51
|
+
const nameChanged = prior.name !== v.name;
|
|
52
|
+
if (changedTokens.length > 0 || nameChanged) {
|
|
53
|
+
modifiedVariants.push({
|
|
54
|
+
id: v.id,
|
|
55
|
+
name: v.name,
|
|
56
|
+
changedTokens,
|
|
57
|
+
nameChanged,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (const v of baseline.variants) {
|
|
62
|
+
if (!currentById.has(v.id))
|
|
63
|
+
removedVariants.push(v);
|
|
64
|
+
}
|
|
65
|
+
const baselineTokens = new Set(baseline.tokenKeys);
|
|
66
|
+
const currentTokens = new Set(current.tokenKeys);
|
|
67
|
+
const addedTokenKeys = current.tokenKeys.filter((k) => !baselineTokens.has(k));
|
|
68
|
+
const removedTokenKeys = baseline.tokenKeys.filter((k) => !currentTokens.has(k));
|
|
69
|
+
return { addedVariants, removedVariants, modifiedVariants, addedTokenKeys, removedTokenKeys };
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Diff two override maps and return the set of keys whose value
|
|
73
|
+
* differs. Keys present in only one side count as changed (the
|
|
74
|
+
* other side resolves to undefined). Uses `Object.hasOwn` so
|
|
75
|
+
* inherited properties don't sneak in.
|
|
76
|
+
*/
|
|
77
|
+
function diffOverrideKeys(prior, next) {
|
|
78
|
+
const keys = new Set();
|
|
79
|
+
for (const k of Object.keys(prior))
|
|
80
|
+
keys.add(k);
|
|
81
|
+
for (const k of Object.keys(next))
|
|
82
|
+
keys.add(k);
|
|
83
|
+
const changed = [];
|
|
84
|
+
for (const k of keys) {
|
|
85
|
+
const a = Object.hasOwn(prior, k) ? prior[k] : undefined;
|
|
86
|
+
const b = Object.hasOwn(next, k) ? next[k] : undefined;
|
|
87
|
+
if (a !== b)
|
|
88
|
+
changed.push(k);
|
|
89
|
+
}
|
|
90
|
+
return changed.sort();
|
|
91
|
+
}
|
|
92
|
+
const COLORS = {
|
|
93
|
+
added: "#070",
|
|
94
|
+
removed: "#a00",
|
|
95
|
+
modified: "#a60",
|
|
96
|
+
tokenChange: "#06a",
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Read-only viewer for a versioned variant matrix history. Picks
|
|
100
|
+
* a baseline + current version (dropdowns) and renders a per-row
|
|
101
|
+
* diff plus a token-column diff.
|
|
102
|
+
*
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export function VariantMatrixVersionPanel({ history, baselineVersion, currentVersion, onBaselineChange, onCurrentChange, }) {
|
|
106
|
+
// All hooks must run before any conditional return — toggling
|
|
107
|
+
// `history` between empty and non-empty across renders would
|
|
108
|
+
// otherwise change the hook count and trip
|
|
109
|
+
// "Rendered fewer hooks than expected". The helpers tolerate
|
|
110
|
+
// empty input (`resolveSnapshot` returns undefined,
|
|
111
|
+
// `history[0]?.version` is undefined) so the work is cheap on
|
|
112
|
+
// the empty path.
|
|
113
|
+
const resolvedCurrent = resolveSnapshot(history, currentVersion);
|
|
114
|
+
// Default baseline = the version *before* current; lets the panel
|
|
115
|
+
// open with the most useful comparison ("what changed in the last
|
|
116
|
+
// edit?") without the host wiring two selectors.
|
|
117
|
+
const defaultBaselineVersion = history.length >= 2 ? history[history.length - 2]?.version : history[0]?.version;
|
|
118
|
+
const resolvedBaseline = resolveSnapshot(history, baselineVersion ?? defaultBaselineVersion);
|
|
119
|
+
const diff = useMemo(() => resolvedBaseline && resolvedCurrent
|
|
120
|
+
? diffVariantMatrices(resolvedBaseline.matrix, resolvedCurrent.matrix)
|
|
121
|
+
: null, [resolvedBaseline, resolvedCurrent]);
|
|
122
|
+
if (history.length === 0) {
|
|
123
|
+
return (_jsx("div", { "data-testid": "variant-matrix-version-panel", style: { padding: "0.5rem", opacity: 0.6 }, children: "No matrix history yet \u2014 save the matrix to capture the first version." }));
|
|
124
|
+
}
|
|
125
|
+
return (_jsxs("div", { "data-testid": "variant-matrix-version-panel", style: { padding: "0.5rem" }, children: [_jsxs("header", { style: {
|
|
126
|
+
display: "flex",
|
|
127
|
+
alignItems: "baseline",
|
|
128
|
+
gap: "0.5rem",
|
|
129
|
+
marginBottom: "0.5rem",
|
|
130
|
+
}, children: [_jsx("h3", { style: { margin: 0, fontSize: "0.875rem" }, children: "Variant matrix diff" }), _jsx(VersionPicker, { dataTestId: "variant-matrix-baseline", label: "vs.", value: resolvedBaseline?.version ?? "", history: history, onChange: onBaselineChange }), _jsx(VersionPicker, { dataTestId: "variant-matrix-current", label: "\u2192", value: resolvedCurrent?.version ?? "", history: history, onChange: onCurrentChange })] }), diff && (_jsxs(_Fragment, { children: [_jsx(DiffSection, { label: "Added variants", color: COLORS.added, entries: diff.addedVariants.map((v) => v.name) }), _jsx(DiffSection, { label: "Removed variants", color: COLORS.removed, entries: diff.removedVariants.map((v) => v.name) }), _jsx(DiffSection, { label: "Modified variants", color: COLORS.modified, entries: diff.modifiedVariants.map((v) => v.changedTokens.length > 0
|
|
131
|
+
? `${v.name} (${v.changedTokens.join(", ")}${v.nameChanged ? "; renamed" : ""})`
|
|
132
|
+
: `${v.name} (renamed)`) }), _jsx(DiffSection, { label: "Added token columns", color: COLORS.tokenChange, entries: [...diff.addedTokenKeys] }), _jsx(DiffSection, { label: "Removed token columns", color: COLORS.tokenChange, entries: [...diff.removedTokenKeys] })] }))] }));
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* One-row section of the diff viewer. Renders only when `entries`
|
|
136
|
+
* is non-empty, so an unchanged comparison shows nothing — keeps
|
|
137
|
+
* the panel quiet when there's nothing to say.
|
|
138
|
+
*
|
|
139
|
+
* Intra-package helper.
|
|
140
|
+
*/
|
|
141
|
+
function DiffSection({ label, color, entries, }) {
|
|
142
|
+
if (entries.length === 0)
|
|
143
|
+
return null;
|
|
144
|
+
return (_jsxs("section", { style: { marginBottom: "0.5rem" }, children: [_jsxs("h4", { style: { margin: "0 0 0.25rem 0", fontSize: "0.75rem", color }, children: [label, " (", entries.length, ")"] }), _jsx("ul", { style: { listStyle: "none", padding: 0, margin: 0 }, children: entries.map((entry, i) => (
|
|
145
|
+
// Composite key — two variants can legitimately share a
|
|
146
|
+
// name (the id is what disambiguates), and a token-column
|
|
147
|
+
// name can repeat across kind buckets. Including the index
|
|
148
|
+
// keeps React's reconciliation correct without exposing
|
|
149
|
+
// the internal ids in the rendered output.
|
|
150
|
+
_jsx("li", { style: { padding: "0.125rem 0.5rem", fontSize: "0.8125rem" }, children: entry }, `${label}-${i}-${entry}`))) })] }));
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Version dropdown used twice in the header (baseline + current).
|
|
154
|
+
* Disabled state covers the read-only case where the host hasn't
|
|
155
|
+
* wired a setter.
|
|
156
|
+
*
|
|
157
|
+
* Intra-package helper.
|
|
158
|
+
*/
|
|
159
|
+
function VersionPicker({ dataTestId, label, value, history, onChange, }) {
|
|
160
|
+
return (_jsxs("label", { style: { fontSize: "0.75rem", color: "#666" }, children: [`${label} `, _jsx("select", { "data-testid": dataTestId, value: value, onChange: (e) => onChange?.(e.target.value), disabled: onChange === undefined, style: { fontFamily: "monospace", fontSize: "0.75rem" }, children: history.map((s) => (_jsxs("option", { value: s.version, children: ["v", s.version] }, s.version))) })] }));
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=VariantMatrixVersionPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VariantMatrixVersionPanel.js","sourceRoot":"","sources":["../../src/components/VariantMatrixVersionPanel.tsx"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,YAAY,CAAC;;AAqBb,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AA4EhC;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAyC,EACzC,OAA2B;IAE3B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC3C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,MAAM,QAAQ,GAAG,OA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,CAAC,CAAC,OAAO,CAEb,CACV,CAAC,GACK,IACH,CACT,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wave 4 I1 — Generic webhook notify panel.
|
|
3
|
+
*
|
|
4
|
+
* Companion to the I3 {@link SlackNotifyPanel} (Wave 4 PR-11). Where
|
|
5
|
+
* I3 targets a single integration (Slack incoming webhooks) with a
|
|
6
|
+
* canned message template per event, I1 is the generic catch-all —
|
|
7
|
+
* the host wires any outbound HTTP integration (Zapier, n8n, GitHub
|
|
8
|
+
* Actions repository_dispatch, internal worker queues, custom tenant
|
|
9
|
+
* endpoints) by supplying a {@link WebhookNotifyFn} adapter and the
|
|
10
|
+
* panel emits a typed {@link WebhookNotificationEvent} payload.
|
|
11
|
+
*
|
|
12
|
+
* The wire shape is intentionally structured rather than free-form
|
|
13
|
+
* text: downstream consumers can pattern-match on `kind` and read
|
|
14
|
+
* typed fields off `context`, rather than parsing English. Hosts that
|
|
15
|
+
* want a human-readable rendering on top of the structured payload
|
|
16
|
+
* wrap their own adapter.
|
|
17
|
+
*
|
|
18
|
+
* Pairs with the synergy `webhook.notify` workflow node when one is
|
|
19
|
+
* deployed; hosts running purely client-side `fetch()` calls wire a
|
|
20
|
+
* local adapter in the meantime.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
import type { ReactElement } from "react";
|
|
25
|
+
/**
|
|
26
|
+
* The set of editor events the panel can emit. Mirrors
|
|
27
|
+
* {@link SlackNotificationEventKind} for cross-integration parity —
|
|
28
|
+
* the two panels respond to the same event vocabulary so a host can
|
|
29
|
+
* wire I1 + I3 against the same trigger list.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export type WebhookNotificationEventKind = "preflight-blocked" | "preflight-cleared" | "job-submitted" | "variant-approved" | "approval-requested" | "custom";
|
|
34
|
+
/**
|
|
35
|
+
* Context the host passes in alongside the chosen event. Mirrors
|
|
36
|
+
* {@link SlackNotificationContext} so a single host-side state object
|
|
37
|
+
* can feed both panels; the webhook payload preserves the structured
|
|
38
|
+
* fields rather than rendering them into a single text line.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
*/
|
|
42
|
+
export type WebhookNotificationContext = {
|
|
43
|
+
/** Human-readable document name. */
|
|
44
|
+
documentName?: string;
|
|
45
|
+
/** Stable identifier the host uses to link back to the document. */
|
|
46
|
+
documentId?: string;
|
|
47
|
+
/** Optional clickable URL the downstream consumer can use to jump
|
|
48
|
+
* straight into the editor. */
|
|
49
|
+
documentUrl?: string;
|
|
50
|
+
/** Preflight finding count (errors only for `"preflight-blocked"`,
|
|
51
|
+
* total resolved for `"preflight-cleared"`). */
|
|
52
|
+
findingCount?: number;
|
|
53
|
+
/** Variant id for `"variant-approved"`. */
|
|
54
|
+
variantId?: string;
|
|
55
|
+
/** Reviewer / submitter display name. */
|
|
56
|
+
actor?: string;
|
|
57
|
+
/** Free-form additional text — the panel surfaces an optional note
|
|
58
|
+
* input that populates this; downstream consumers may render it as
|
|
59
|
+
* a description / commit message / etc. */
|
|
60
|
+
text?: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Canonical structured payload the panel POSTs to the host adapter.
|
|
64
|
+
* The `kind` + `context` split keeps the wire shape pattern-matchable
|
|
65
|
+
* (no English-parsing required on the receiver) while leaving the
|
|
66
|
+
* envelope (`integration`, `sentAt`) free for routing.
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
*/
|
|
70
|
+
export type WebhookNotificationEvent = {
|
|
71
|
+
/** Schema version — bump on breaking shape changes. */
|
|
72
|
+
schemaVersion: 1;
|
|
73
|
+
/** Event kind from {@link WebhookNotificationEventKind}. */
|
|
74
|
+
kind: WebhookNotificationEventKind;
|
|
75
|
+
/** Structured context — see {@link WebhookNotificationContext}. */
|
|
76
|
+
context: WebhookNotificationContext;
|
|
77
|
+
/** Optional integration identifier the host can use to route the
|
|
78
|
+
* event to one of many wired endpoints (e.g. `"zapier-main"`,
|
|
79
|
+
* `"github-actions-staging"`). When absent, the host adapter
|
|
80
|
+
* decides the default destination. */
|
|
81
|
+
integration?: string;
|
|
82
|
+
/** ISO 8601 timestamp the panel stamps at send time. */
|
|
83
|
+
sentAt: string;
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Pure helper — composes a {@link WebhookNotificationEvent} from a
|
|
87
|
+
* kind + context + optional integration. Stamps `sentAt` to the
|
|
88
|
+
* passed-in `now()` so tests can pin the timestamp. Pure function;
|
|
89
|
+
* no I/O.
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
export declare function composeWebhookEvent(kind: WebhookNotificationEventKind, context: WebhookNotificationContext, options?: {
|
|
94
|
+
integration?: string;
|
|
95
|
+
now?: () => Date;
|
|
96
|
+
}): WebhookNotificationEvent;
|
|
97
|
+
/**
|
|
98
|
+
* Host adapter — POSTs the composed payload to the wired endpoint
|
|
99
|
+
* (typically via a server-side proxy or the synergy `webhook.notify`
|
|
100
|
+
* node). Resolves on accept; rejects on transport / validation
|
|
101
|
+
* errors and the panel surfaces the message inline.
|
|
102
|
+
*
|
|
103
|
+
* @public
|
|
104
|
+
*/
|
|
105
|
+
export type WebhookNotifyFn = (event: WebhookNotificationEvent) => Promise<void>;
|
|
106
|
+
/**
|
|
107
|
+
* Human-readable labels for each event kind, in the order they appear
|
|
108
|
+
* in the dropdown. Mirrors {@link SlackNotifyPanel}'s label map so the
|
|
109
|
+
* two panels stay in lockstep.
|
|
110
|
+
*
|
|
111
|
+
* @public
|
|
112
|
+
*/
|
|
113
|
+
export declare const WEBHOOK_NOTIFICATION_EVENT_LABELS: Readonly<Record<WebhookNotificationEventKind, string>>;
|
|
114
|
+
/**
|
|
115
|
+
* Configuration for the {@link WebhookNotifyPanel}.
|
|
116
|
+
*
|
|
117
|
+
* The host supplies the {@link WebhookNotifyFn} adapter, the typed
|
|
118
|
+
* {@link WebhookNotificationContext}, and (optionally) a list of
|
|
119
|
+
* integration ids that populate the panel's "Integration" dropdown.
|
|
120
|
+
* The panel handles event-kind selection, the optional free-form
|
|
121
|
+
* note, the send button state machine, and surfaces success / error
|
|
122
|
+
* inline.
|
|
123
|
+
*
|
|
124
|
+
* @public
|
|
125
|
+
*/
|
|
126
|
+
export type WebhookNotifyPanelProps = {
|
|
127
|
+
/** Host adapter — see {@link WebhookNotifyFn}. */
|
|
128
|
+
notify: WebhookNotifyFn;
|
|
129
|
+
/** Typed context to bundle into the outgoing event. The host
|
|
130
|
+
* typically wires this from the active document. */
|
|
131
|
+
context: WebhookNotificationContext;
|
|
132
|
+
/** Optional initial event selection. Defaults to
|
|
133
|
+
* `"job-submitted"` — the most common webhook trigger across
|
|
134
|
+
* CI / queue / chat integrations. */
|
|
135
|
+
defaultEvent?: WebhookNotificationEventKind;
|
|
136
|
+
/** Optional list of integration ids the host has wired. Surfaces as
|
|
137
|
+
* a dropdown; when absent the panel omits the picker and the
|
|
138
|
+
* outgoing event has no `integration` field set. */
|
|
139
|
+
integrations?: readonly string[];
|
|
140
|
+
/** Optional initial integration selection. Must match one of
|
|
141
|
+
* `integrations`; when absent the first entry is selected. */
|
|
142
|
+
defaultIntegration?: string;
|
|
143
|
+
/** Optional mapper that turns a notify error into a user-facing
|
|
144
|
+
* message. The default avoids leaking internal `Error.message`
|
|
145
|
+
* strings; hosts that want richer surfaces pass their own mapper.
|
|
146
|
+
* The original error is still passed in so hosts can log it. */
|
|
147
|
+
errorMessage?: (err: unknown) => string;
|
|
148
|
+
/** Optional callback fired on successful notify so the host can
|
|
149
|
+
* show a confirmation toast / log analytics. */
|
|
150
|
+
onSuccess?: (event: WebhookNotificationEvent) => void;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Stateful panel — picks an event template + integration, lets the
|
|
154
|
+
* user append a custom note, composes the typed event via
|
|
155
|
+
* {@link composeWebhookEvent}, and POSTs through the host adapter.
|
|
156
|
+
*
|
|
157
|
+
* @public
|
|
158
|
+
*/
|
|
159
|
+
export declare function WebhookNotifyPanel({ notify, context, defaultEvent, integrations, defaultIntegration, errorMessage, onSuccess, }: WebhookNotifyPanelProps): ReactElement;
|
|
160
|
+
//# sourceMappingURL=WebhookNotifyPanel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebhookNotifyPanel.d.ts","sourceRoot":"","sources":["../../src/components/WebhookNotifyPanel.tsx"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAG1C;;;;;;;GAOG;AACH,MAAM,MAAM,4BAA4B,GACpC,mBAAmB,GACnB,mBAAmB,GACnB,eAAe,GACf,kBAAkB,GAClB,oBAAoB,GACpB,QAAQ,CAAC;AAEb;;;;;;;GAOG;AACH,MAAM,MAAM,0BAA0B,GAAG;IACvC,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oEAAoE;IACpE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;oCACgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;qDACiD;IACjD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;gDAE4C;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,uDAAuD;IACvD,aAAa,EAAE,CAAC,CAAC;IACjB,4DAA4D;IAC5D,IAAI,EAAE,4BAA4B,CAAC;IACnC,mEAAmE;IACnE,OAAO,EAAE,0BAA0B,CAAC;IACpC;;;2CAGuC;IACvC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wDAAwD;IACxD,MAAM,EAAE,MA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
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
/**
|
|
6
|
+
* Pure helper — composes a {@link WebhookNotificationEvent} from a
|
|
7
|
+
* kind + context + optional integration. Stamps `sentAt` to the
|
|
8
|
+
* passed-in `now()` so tests can pin the timestamp. Pure function;
|
|
9
|
+
* no I/O.
|
|
10
|
+
*
|
|
11
|
+
* @public
|
|
12
|
+
*/
|
|
13
|
+
export function composeWebhookEvent(kind, context, options) {
|
|
14
|
+
const now = options?.now ?? (() => new Date());
|
|
15
|
+
return {
|
|
16
|
+
schemaVersion: 1,
|
|
17
|
+
kind,
|
|
18
|
+
context,
|
|
19
|
+
...(options?.integration && { integration: options.integration }),
|
|
20
|
+
sentAt: now().toISOString(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Human-readable labels for each event kind, in the order they appear
|
|
25
|
+
* in the dropdown. Mirrors {@link SlackNotifyPanel}'s label map so the
|
|
26
|
+
* two panels stay in lockstep.
|
|
27
|
+
*
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
30
|
+
export const WEBHOOK_NOTIFICATION_EVENT_LABELS = {
|
|
31
|
+
"preflight-blocked": "Preflight blocked",
|
|
32
|
+
"preflight-cleared": "Preflight cleared",
|
|
33
|
+
"job-submitted": "Job submitted",
|
|
34
|
+
"variant-approved": "Variant approved",
|
|
35
|
+
"approval-requested": "Approval requested",
|
|
36
|
+
custom: "Custom event",
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Stateful panel — picks an event template + integration, lets the
|
|
40
|
+
* user append a custom note, composes the typed event via
|
|
41
|
+
* {@link composeWebhookEvent}, and POSTs through the host adapter.
|
|
42
|
+
*
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export function WebhookNotifyPanel({ notify, context, defaultEvent, integrations, defaultIntegration, errorMessage, onSuccess, }) {
|
|
46
|
+
const [event, setEvent] = useState(defaultEvent ?? "job-submitted");
|
|
47
|
+
// Validate `defaultIntegration` against the wired list — a host-supplied
|
|
48
|
+
// default that isn't in `integrations` would otherwise quietly ship as
|
|
49
|
+
// the outgoing event's `integration` field even though the user can't
|
|
50
|
+
// see / change it in the dropdown.
|
|
51
|
+
const [integration, setIntegration] = useState(() => {
|
|
52
|
+
if (defaultIntegration && integrations?.includes(defaultIntegration)) {
|
|
53
|
+
return defaultIntegration;
|
|
54
|
+
}
|
|
55
|
+
return integrations?.[0] ?? "";
|
|
56
|
+
});
|
|
57
|
+
const [note, setNote] = useState("");
|
|
58
|
+
const [state, setState] = useState({ kind: "idle" });
|
|
59
|
+
// Clear the success / error chip when the user edits any input —
|
|
60
|
+
// a "Sent" indicator next to an unsent payload reads as a lie.
|
|
61
|
+
const resetOutcome = () => {
|
|
62
|
+
setState((prev) => (prev.kind === "ok" || prev.kind === "error" ? { kind: "idle" } : prev));
|
|
63
|
+
};
|
|
64
|
+
const onClick = async () => {
|
|
65
|
+
setState({ kind: "sending" });
|
|
66
|
+
const payload = composeWebhookEvent(event, {
|
|
67
|
+
...context,
|
|
68
|
+
...(note.trim() && { text: note }),
|
|
69
|
+
}, integration ? { integration } : undefined);
|
|
70
|
+
try {
|
|
71
|
+
await notify(payload);
|
|
72
|
+
setState({ kind: "ok" });
|
|
73
|
+
onSuccess?.(payload);
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
// Guard against a host-supplied errorMessage that throws.
|
|
77
|
+
let message = "Couldn't send webhook notification.";
|
|
78
|
+
if (errorMessage) {
|
|
79
|
+
try {
|
|
80
|
+
message = errorMessage(err);
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
// fall back to the default
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
setState({ kind: "error", message });
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
return (_jsxs("div", { "data-testid": "webhook-notify-panel", style: { padding: "0.5rem" }, children: [_jsx("header", { style: { marginBottom: "0.5rem" }, children: _jsx("h3", { style: { margin: 0, fontSize: "0.875rem" }, children: "Webhook notify" }) }), _jsxs("label", { style: { display: "block", fontSize: "0.75rem", marginBottom: "0.5rem" }, children: ["Event", _jsx("select", { "aria-label": "Event", value: event, onChange: (e) => {
|
|
90
|
+
setEvent(e.target.value);
|
|
91
|
+
resetOutcome();
|
|
92
|
+
}, style: { display: "block", marginTop: "0.125rem", width: "100%" }, children: Object.entries(WEBHOOK_NOTIFICATION_EVENT_LABELS).map(([k, label]) => (_jsx("option", { value: k, children: label }, k))) })] }), integrations && integrations.length > 0 && (_jsxs("label", { style: { display: "block", fontSize: "0.75rem", marginBottom: "0.5rem" }, children: ["Integration", _jsx("select", { "aria-label": "Integration", value: integration, onChange: (e) => {
|
|
93
|
+
setIntegration(e.target.value);
|
|
94
|
+
resetOutcome();
|
|
95
|
+
}, style: { display: "block", marginTop: "0.125rem", width: "100%" }, children: integrations.map((id) => (_jsx("option", { value: id, children: id }, id))) })] })), _jsxs("label", { style: { display: "block", fontSize: "0.75rem", marginBottom: "0.5rem" }, children: ["Note", _jsx("textarea", { "aria-label": "Note", placeholder: "Optional \u2014 included as context.text", value: note, onChange: (e) => {
|
|
96
|
+
setNote(e.target.value);
|
|
97
|
+
resetOutcome();
|
|
98
|
+
}, rows: 2, style: { display: "block", marginTop: "0.125rem", width: "100%" } })] }), _jsxs("div", { style: { display: "flex", gap: "0.5rem", alignItems: "center" }, children: [_jsx("button", { type: "button", onClick: onClick, disabled: state.kind === "sending", "aria-busy": state.kind === "sending", children: state.kind === "sending" ? "Sending…" : "Send webhook" }), state.kind === "ok" && (_jsx("output", { style: { color: "#080", fontSize: "0.75rem" }, children: "Sent" })), state.kind === "error" && (_jsx("span", { role: "alert", style: { color: "#a00", fontSize: "0.75rem" }, children: state.message }))] })] }));
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=WebhookNotifyPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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