Setting the file. One moment.
User Action Effects · Wix Replatform · wix/skills · Skills Docs
ContentsBack to the top of the page (opens in a new tab)
lib/ user-action-effects.js
JavaScript · 48 lines · 3 KB
,
pairForChoice
}
=
require
(
'./destination-choice.js'
);
9
10 async function applyUserActionEffect ( projectDir , request , answer ) {
11 if ( ! request.effect) return ;
12 if (request.effect.kind === 'read-back-omission-ack' ) return require ( './read-back-approval.js' ). acknowledge (projectDir, request, answer);
13 if (request.effect.kind === 'approval' ) return require ( './read-back-approval.js' ). applyApproval (projectDir, request, answer);
14 if (request.effect.kind === 'decision' && request.effect.key === 'notificationMute' ) {
15 const value = request.effect.choices?.[answer.choice];
16 if ( ! value) throw new Error ( 'notification mute answer requires a declared choice' );
17 return require ( './notification-mute.js' ). recordNotificationMute (projectDir, value, { rationale: request.title });
18 }
19 if (request.effect.kind === 'site-locale-answer' ) return require ( './site-regional.js' ). recordSiteRegionalApproval (projectDir, request, answer);
20 const artifacts = await loadArtifacts (projectDir);
21 const decisionsPath = path. join (projectDir, 'orchestration' , 'decisions.json' );
22 const effect = request.effect;
23 if (effect.kind === 'decision' && effect.key === 'managementImportMode' ) {
24 const value = effect.choices?.[answer.choice];
25 if ( ! value) return ;
26 updateDecisionObject (artifacts.decisions, 'managementImportMode' , value, { source: 'user' , rationale: request.title });
27 await writeJsonAtomic (decisionsPath, artifacts.decisions);
28 return ;
29 }
30 if (effect.kind === 'decision' && effect.key === 'targetSiteType' ) {
31 // One choice id → both decisions, one write.
32 applySiteTypePair (artifacts.decisions, pairForChoice (effect, answer.choice), { rationale: request.title });
33 await writeJsonAtomic (decisionsPath, artifacts.decisions);
34 return ;
35 }
36 if (effect.kind === 'decision' && effect.key === 'editorWebsiteDecision' ) {
37 const value = effect.choices?.[answer.choice];
38 if ( ! value) throw new Error ( 'editor website decision requires a declared choice' );
39 updateDecisionObject (artifacts.decisions, 'editorWebsiteDecision' , value, { source: 'user' , rationale: request.title });
40 // "Backend only" is an explicit scope change to management.
41 if (value === 'management_only' ) updateDecisionObject (artifacts.decisions, 'deliveryMode' , 'management' , { source: 'user' , rationale: request.title });
42 await writeJsonAtomic (decisionsPath, artifacts.decisions);
43 return ;
44 }
45 throw new Error ( 'unsupported user-action effect' );
46 }
47
48 module . exports = { applyUserActionEffect };