Refactor multi-flow mail capability boundaries
This commit is contained in:
@@ -789,6 +789,7 @@ function initPhoneVerificationSectionExpandedState() {
|
||||
}
|
||||
|
||||
function getStepDefinitionsForMode(plusModeEnabled = false, options = {}) {
|
||||
const defaultFlowId = typeof DEFAULT_ACTIVE_FLOW_ID !== 'undefined' ? DEFAULT_ACTIVE_FLOW_ID : 'openai';
|
||||
const defaultMethod = typeof DEFAULT_PLUS_PAYMENT_METHOD !== 'undefined' ? DEFAULT_PLUS_PAYMENT_METHOD : 'paypal';
|
||||
const rawPaymentMethod = typeof options === 'string'
|
||||
? options
|
||||
@@ -796,7 +797,11 @@ function getStepDefinitionsForMode(plusModeEnabled = false, options = {}) {
|
||||
const rawSignupMethod = typeof options === 'string'
|
||||
? currentSignupMethod
|
||||
: (options.signupMethod || currentSignupMethod || DEFAULT_SIGNUP_METHOD);
|
||||
const activeFlowId = typeof options === 'string'
|
||||
? ((typeof latestState !== 'undefined' ? latestState?.activeFlowId : '') || defaultFlowId)
|
||||
: (options.activeFlowId || (typeof latestState !== 'undefined' ? latestState?.activeFlowId : '') || defaultFlowId);
|
||||
return (window.MultiPageStepDefinitions?.getSteps?.({
|
||||
activeFlowId: String(activeFlowId || '').trim().toLowerCase() || defaultFlowId,
|
||||
plusModeEnabled,
|
||||
plusPaymentMethod: normalizePlusPaymentMethod(rawPaymentMethod),
|
||||
signupMethod: normalizeSignupMethod(rawSignupMethod),
|
||||
@@ -830,6 +835,7 @@ function rebuildStepDefinitionState(plusModeEnabled = false, options = {}) {
|
||||
currentPlusPaymentMethod = normalizePlusPaymentMethod(rawPaymentMethod);
|
||||
currentSignupMethod = normalizeSignupMethod(rawSignupMethod);
|
||||
stepDefinitions = getStepDefinitionsForMode(currentPlusModeEnabled, {
|
||||
activeFlowId: options?.activeFlowId,
|
||||
plusPaymentMethod: currentPlusPaymentMethod,
|
||||
signupMethod: currentSignupMethod,
|
||||
});
|
||||
@@ -8524,6 +8530,7 @@ function renderStepsList() {
|
||||
}
|
||||
|
||||
function syncStepDefinitionsForMode(plusModeEnabled = false, plusPaymentMethodOrOptions = {}, maybeOptions = {}) {
|
||||
const defaultFlowId = typeof DEFAULT_ACTIVE_FLOW_ID !== 'undefined' ? DEFAULT_ACTIVE_FLOW_ID : 'openai';
|
||||
const nextPlusModeEnabled = Boolean(plusModeEnabled);
|
||||
const options = typeof plusPaymentMethodOrOptions === 'string'
|
||||
? maybeOptions
|
||||
@@ -8533,9 +8540,15 @@ function syncStepDefinitionsForMode(plusModeEnabled = false, plusPaymentMethodOr
|
||||
: (options.plusPaymentMethod || getSelectedPlusPaymentMethod(latestState));
|
||||
const nextSignupMethod = normalizeSignupMethod(options.signupMethod || currentSignupMethod || DEFAULT_SIGNUP_METHOD);
|
||||
const nextPaymentMethod = normalizePlusPaymentMethod(rawPaymentMethod);
|
||||
const nextActiveFlowId = String(
|
||||
options.activeFlowId
|
||||
|| (typeof latestState !== 'undefined' ? latestState?.activeFlowId : '')
|
||||
|| defaultFlowId
|
||||
).trim().toLowerCase() || defaultFlowId;
|
||||
const rootScope = typeof window !== 'undefined' ? window : globalThis;
|
||||
const currentPaymentStep = stepDefinitions.find((step) => step.key === 'paypal-approve');
|
||||
const nextPaymentTitle = rootScope.MultiPageStepDefinitions?.getPlusPaymentStepTitle?.({
|
||||
activeFlowId: nextActiveFlowId,
|
||||
plusModeEnabled: nextPlusModeEnabled,
|
||||
plusPaymentMethod: nextPaymentMethod,
|
||||
signupMethod: nextSignupMethod,
|
||||
@@ -8551,6 +8564,7 @@ function syncStepDefinitionsForMode(plusModeEnabled = false, plusPaymentMethodOr
|
||||
}
|
||||
|
||||
rebuildStepDefinitionState(nextPlusModeEnabled, {
|
||||
activeFlowId: nextActiveFlowId,
|
||||
plusPaymentMethod: nextPaymentMethod,
|
||||
signupMethod: nextSignupMethod,
|
||||
});
|
||||
@@ -11834,6 +11848,37 @@ async function startAutoRunFromCurrentSettings() {
|
||||
if (typeof persistCurrentSettingsForAction === 'function') {
|
||||
await persistCurrentSettingsForAction();
|
||||
}
|
||||
const autoRunStartValidation = (() => {
|
||||
const rootScope = typeof window !== 'undefined' ? window : globalThis;
|
||||
const registry = rootScope.MultiPageFlowCapabilities?.createFlowCapabilityRegistry?.({
|
||||
defaultFlowId: typeof DEFAULT_ACTIVE_FLOW_ID === 'string' ? DEFAULT_ACTIVE_FLOW_ID : 'openai',
|
||||
}) || null;
|
||||
if (!registry?.validateAutoRunStart) {
|
||||
return { ok: true, errors: [] };
|
||||
}
|
||||
const validationState = {
|
||||
...(latestState || {}),
|
||||
panelMode: typeof getSelectedPanelMode === 'function' ? getSelectedPanelMode() : latestState?.panelMode,
|
||||
signupMethod: typeof getSelectedSignupMethod === 'function' ? getSelectedSignupMethod() : latestState?.signupMethod,
|
||||
phoneVerificationEnabled: typeof inputPhoneVerificationEnabled !== 'undefined' && inputPhoneVerificationEnabled
|
||||
? Boolean(inputPhoneVerificationEnabled.checked)
|
||||
: Boolean(latestState?.phoneVerificationEnabled),
|
||||
plusModeEnabled: typeof inputPlusModeEnabled !== 'undefined' && inputPlusModeEnabled
|
||||
? Boolean(inputPlusModeEnabled.checked)
|
||||
: Boolean(latestState?.plusModeEnabled),
|
||||
contributionMode: Boolean(latestState?.contributionMode),
|
||||
};
|
||||
return registry.validateAutoRunStart({
|
||||
activeFlowId: validationState.activeFlowId,
|
||||
panelMode: validationState.panelMode,
|
||||
signupMethod: validationState.signupMethod,
|
||||
state: validationState,
|
||||
});
|
||||
})();
|
||||
if (autoRunStartValidation?.ok === false) {
|
||||
clearPendingAutoRunStartRunCount();
|
||||
throw new Error(autoRunStartValidation.errors?.[0]?.message || '当前设置不支持启动自动流程。');
|
||||
}
|
||||
if (!(await ensureGpcApiKeyReadyForStart())) {
|
||||
clearPendingAutoRunStartRunCount();
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user