Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 19x 19x 19x 19x 5x 19x 19x 19x 19x 19x 19x 19x 6x 19x 19x 19x 19x 4x 19x 19x 19x 19x 4x 19x 19x 19x 19x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 97x 22x 22x 21x 21x 1x 1x 97x 64x 64x 64x 9x 9x 9x 9x 9x 9x 9x 9x 9x 64x 1x 1x 1x 1x 1x 1x 1x 64x 2x 64x 64x 9x 9x 9x 64x 13x 13x 13x 64x 64x 3x 3x 3x 3x 3x 3x 3x 64x 1x 64x 1x 1x 1x 1x 1x 1x 64x 64x 4x 4x 4x 4x 4x 4x 64x 64x 14x 64x 64x 64x 4x 64x 2x 64x 1x 64x 64x 97x 97x 97x 39x 39x 39x 39x 39x 39x 64x 64x 63x 63x 63x 63x 64x 56x 56x 56x 56x 56x 56x 39x 97x 97x 16x 16x 16x 16x 97x 97x 97x 97x 118x 118x 97x 118x 112x 112x 118x 118x 133x 133x 128x 128x 133x 100x 118x 118x 97x 97x 100x 100x 100x 97x 97x 125x 97x 97x 97x 97x 97x 97x | export interface RevisionChange {
type: string;
uuid?: string;
node?: string;
subtype?: string;
field?: string;
lang?: string;
}
interface Phrase {
noun: string;
plural: string;
verb: string;
order: number;
noCount?: boolean;
}
const CATEGORY_ORDER = [
'metadata',
'structure',
'content',
'translations',
'notes',
'layout'
];
function categoryFor(change: RevisionChange): string | null {
switch (change.type) {
case 'metadata_changed':
case 'base_language_changed':
return 'metadata';
case 'node_added':
case 'node_removed':
case 'action_added':
case 'action_removed':
case 'action_reordered':
case 'router_updated':
case 'connection_changed':
return 'structure';
case 'action_updated':
return 'content';
case 'translation_added':
case 'translation_updated':
case 'translation_removed':
return 'translations';
case 'sticky_added':
case 'sticky_removed':
case 'sticky_updated':
case 'sticky_moved':
return 'notes';
case 'node_moved':
return 'layout';
default:
return null;
}
}
const ACTION_LABELS: Record<string, { noun: string; plural: string }> = {
send_msg: { noun: 'message', plural: 'messages' },
send_email: { noun: 'email', plural: 'emails' },
send_broadcast: { noun: 'broadcast', plural: 'broadcasts' },
set_contact_field: { noun: 'contact field', plural: 'contact fields' },
set_contact_name: { noun: 'contact name', plural: 'contact name changes' },
set_contact_language: {
noun: 'contact language',
plural: 'contact language changes'
},
set_contact_status: {
noun: 'contact status',
plural: 'contact status changes'
},
set_contact_channel: { noun: 'contact channel', plural: 'contact channels' },
add_contact_groups: { noun: 'group', plural: 'groups' },
remove_contact_groups: { noun: 'group', plural: 'groups' },
add_contact_urn: { noun: 'URN', plural: 'URNs' },
set_run_result: { noun: 'result', plural: 'results' },
call_webhook: { noun: 'webhook', plural: 'webhooks' },
call_classifier: { noun: 'classifier', plural: 'classifiers' },
call_resthook: { noun: 'resthook', plural: 'resthooks' },
call_llm: { noun: 'AI prompt', plural: 'AI prompts' },
enter_flow: { noun: 'subflow', plural: 'subflows' },
start_session: { noun: 'subflow', plural: 'subflows' },
transfer_airtime: { noun: 'airtime transfer', plural: 'airtime transfers' },
play_audio: { noun: 'audio', plural: 'audio clips' },
say_msg: { noun: 'voice message', plural: 'voice messages' },
open_ticket: { noun: 'ticket', plural: 'tickets' },
add_input_labels: { noun: 'label', plural: 'labels' },
remove_input_labels: { noun: 'label', plural: 'labels' },
request_optin: { noun: 'opt-in', plural: 'opt-ins' },
send_optin_msg: { noun: 'opt-in message', plural: 'opt-in messages' }
};
const METADATA_LABELS: Record<string, { noun: string }> = {
name: { noun: 'name' },
type: { noun: 'flow type' },
expire_after_minutes: { noun: 'expiration' }
};
function actionLabel(subtype?: string): { noun: string; plural: string } {
if (subtype && ACTION_LABELS[subtype]) {
return ACTION_LABELS[subtype];
}
return { noun: 'action', plural: 'actions' };
}
function changeToPhrase(change: RevisionChange): Phrase | null {
switch (change.type) {
case 'metadata_changed': {
const label = METADATA_LABELS[change.field || ''] || {
noun: change.field || 'metadata'
};
return {
noun: label.noun,
plural: label.noun,
verb: 'changed',
order: 0,
noCount: true
};
}
case 'base_language_changed':
return {
noun: 'base language',
plural: 'base language',
verb: 'changed',
order: 1,
noCount: true
};
case 'node_added':
return { noun: 'node', plural: 'nodes', verb: 'added', order: 2 };
case 'node_removed':
return { noun: 'node', plural: 'nodes', verb: 'removed', order: 3 };
case 'action_added': {
const label = actionLabel(change.subtype);
return { ...label, verb: 'added', order: 4 };
}
case 'action_updated': {
const label = actionLabel(change.subtype);
return { ...label, verb: 'updated', order: 5 };
}
case 'action_removed': {
const label = actionLabel(change.subtype);
return { ...label, verb: 'removed', order: 6 };
}
case 'action_reordered':
return {
noun: 'actions',
plural: 'actions',
verb: 'reordered',
order: 7,
noCount: true
};
case 'router_updated':
return { noun: 'split', plural: 'splits', verb: 'updated', order: 8 };
case 'connection_changed':
return {
noun: 'connection',
plural: 'connections',
verb: 'changed',
order: 9
};
case 'translation_added':
return {
noun: 'translation',
plural: 'translations',
verb: 'added',
order: 10
};
case 'translation_updated':
return {
noun: 'translation',
plural: 'translations',
verb: 'updated',
order: 11
};
case 'translation_removed':
return {
noun: 'translation',
plural: 'translations',
verb: 'removed',
order: 12
};
case 'sticky_added':
return { noun: 'sticky', plural: 'stickies', verb: 'added', order: 13 };
case 'sticky_updated':
return { noun: 'sticky', plural: 'stickies', verb: 'updated', order: 14 };
case 'sticky_removed':
return { noun: 'sticky', plural: 'stickies', verb: 'removed', order: 15 };
case 'sticky_moved':
return { noun: 'sticky', plural: 'stickies', verb: 'moved', order: 16 };
case 'node_moved':
return { noun: 'node', plural: 'nodes', verb: 'moved', order: 17 };
default:
return null;
}
}
const MAX_PHRASES = 2;
function buildPhraseGroups(
changes: RevisionChange[] | null | undefined
): Map<string, { phrase: Phrase; count: number }> {
const groups = new Map<string, { phrase: Phrase; count: number }>();
for (const change of changes ?? []) {
const phrase = changeToPhrase(change);
if (!phrase) continue;
const key = `${phrase.order}:${phrase.noun}:${phrase.verb}`;
const existing = groups.get(key);
if (existing) {
existing.count++;
} else {
groups.set(key, { phrase, count: 1 });
}
}
return groups;
}
export function isSignificantChange(
changes: RevisionChange[] | null | undefined
): boolean {
return buildPhraseGroups(changes).size > MAX_PHRASES;
}
export function summarizeChanges(
changes: RevisionChange[] | null | undefined
): string {
if (!changes || changes.length === 0) return '';
const groups = buildPhraseGroups(changes);
if (groups.size === 0) return '';
const sorted = Array.from(groups.values()).sort(
(a, b) => a.phrase.order - b.phrase.order
);
const parts = sorted.map(({ phrase, count }) =>
phrase.noCount || count === 1
? `${phrase.verb} ${phrase.noun}`
: `${phrase.verb} ${count} ${phrase.plural}`
);
if (parts.length <= MAX_PHRASES) {
return capitalize(parts.join(' and '));
}
const presentCategories = new Set<string>();
for (const change of changes) {
const cat = categoryFor(change);
if (cat) presentCategories.add(cat);
}
const categories = CATEGORY_ORDER.filter((c) => presentCategories.has(c));
const visibleCategories = categories.slice(0, MAX_PHRASES);
return `Significantly changed ${visibleCategories.join(' and ')}`;
}
function capitalize(text: string): string {
return text.charAt(0).toUpperCase() + text.slice(1);
}
|