| Name | Size | Mode | Actions |
|---|---|---|---|
| acf-json\.gitkeep | 0 | 0644 | editdlrm |
| assets\css\admin.css | 12113 | 0644 | editdlrm |
| assets\js\admin.js | 52894 | 0644 | editdlrm |
| includes\class-ad-admin.php | 10358 | 0644 | editdlrm |
| includes\class-ad-ai-client.php | 10724 | 0644 | editdlrm |
| includes\class-ad-auth.php | 9189 | 0644 | editdlrm |
| includes\class-ad-cli.php | 8671 | 0644 | editdlrm |
| includes\class-ad-extractor.php | 17237 | 0644 | editdlrm |
| includes\class-ad-mcp.php | 6429 | 0644 | editdlrm |
| includes\class-ad-plugin-core.php | 10252 | 0644 | editdlrm |
| includes\class-ad-progress.php | 8022 | 0644 | editdlrm |
| includes\class-ad-rest.php | 43443 | 0644 | editdlrm |
| includes\class-ad-uninstall.php | 1966 | 0644 | editdlrm |
| includes\class-ad-webhook.php | 24172 | 0644 | editdlrm |
| languages\.gitkeep | 0 | 0644 | editdlrm |
| package.json | 220 | 0644 | editdlrm |
| readme.txt | 8174 | 0644 | editdlrm |
| templates\admin\wizard.php | 29414 | 0644 | editdlrm |
| uninstall.php | 365 | 0644 | editdlrm |
| wp-to-sanity-migration.php | 4418 | 0644 | editdlrm |
/home/altere25/.trash/wp-to-sanity-migration.1/assets\js\admin.js (52894B)
| Item | Qty | Price | Total |
|---|---|---|---|
| ' + (item.label || item.key) + ' | ' + item.quantity + ' | ' + centsToUsd(item.unit_price_cents) + ' | ' + centsToUsd(item.total_cents) + ' |
Subtotal: ' + centsToUsd(quote.subtotal_cents) + '
'; html += 'Total: ' + centsToUsd(quote.total_cents) + '
'; html += 'Upfront (50%): ' + centsToUsd(quote.upfront_50_cents) + ' · Final (50%): ' + centsToUsd(quote.final_50_cents) + '
'; if (quote.estimated_days) { html += 'Estimated time: ' + quote.estimated_days + ' days
'; } if (data.deterministic) { html += 'Note: using estimated pricing (AI pricing model unavailable).
'; } var quoteId = data.quote_id || ''; // T&C checkbox — checkout disabled until the customer agrees. html += ''; html += ''; $('#ad-quote-body').html(html); // Enable checkout only when T&C checkbox is checked. var $tcBox = $('#ad-tc-agree'); var $cbtn0 = $('#ad-checkout-trigger'); $tcBox.on('change', function() { $cbtn0.prop('disabled', !$tcBox.prop('checked') || !quoteId); }); // Wire checkout button → /checkout → redirect to Stripe. $('#ad-checkout-trigger').on('click', function() { if (!$tcBox.prop('checked')) { return; } var $cbtn = $(this).prop('disabled', true).text('Redirecting…'); $.ajax({ url: W.restUrl + 'checkout', method: 'POST', headers: { 'X-WP-Nonce': W.restNonce }, data: { quote_id: quoteId }, success: function(cresp) { if (cresp && cresp.success && cresp.data && cresp.data.checkout_url) { window.location.href = cresp.data.checkout_url; } else { var msg = (cresp && cresp.data && cresp.data.error) ? cresp.data.error : 'Checkout failed.'; $cbtn.prop('disabled', false).text('Continue to payment'); alert(msg); } }, error: function(xhr) { var msg = 'Checkout failed'; try { var body = JSON.parse(xhr.responseText); if (body && body.data && body.data.error) { msg = body.data.error; } else if (body && body.error) { msg = body.error; } } catch (ex) { if (xhr.status) { msg += ' (HTTP ' + xhr.status + ')'; } } $cbtn.prop('disabled', false).text('Continue to payment'); alert(msg); } }); }); } // ----------------------------------------------------------------- // Step 6: Connect Sanity (POST /connect/v2) // ----------------------------------------------------------------- function initConnectSanityStep() { $('#ad-connect-sanity-form').on('submit', function(e) { e.preventDefault(); var $status = $('#ad-connect-sanity-status').removeAttr('hidden') .text('Connecting…').css('color', '#555'); var $btn = $('#ad-connect-sanity-btn').prop('disabled', true); // Extract account_id from the Supabase JWT (sub claim). var accountId = ''; try { // AD_Auth stores the access token server-side; we read it // from the wizard state if present, otherwise leave blank. // The Worker can resolve account_id from the JWT itself. accountId = wizardState.account_id || ''; } catch (ex) { /* leave blank */ } $.ajax({ url: W.restUrl + 'connect/v2', method: 'POST', headers: { 'X-WP-Nonce': W.restNonce }, data: { service_url: '', // pre-configured by network admin; Worker reads from settings admin_token: '', // same account_id: accountId, sanity_project_id: $('#ad-sanity-project-id').val(), sanity_api_token: $('#ad-sanity-api-token').val(), sanity_dataset: $('#ad-sanity-dataset').val() || 'production' }, success: function(resp) { $btn.prop('disabled', false); if (resp && resp.success) { $status.text('Connected! Webhook URL: ' + (resp.data && resp.data.webhook_url ? resp.data.webhook_url : 'configured')) .css('color', '#00a32a'); saveWizardState({ sanity_connected: true }); wizardState.sanity_connected = true; setTimeout(function() { showPanel(7); }, 1200); } else { var msg = (resp && resp.data && resp.data.error) ? resp.data.error : 'Connection failed.'; $status.text(msg).css('color', '#d63638'); } }, error: function(xhr) { $btn.prop('disabled', false); var msg = 'Connection failed'; try { var body = JSON.parse(xhr.responseText); if (body && body.data && body.data.error) { msg = body.data.error; } else if (body && body.error) { msg = body.error; } } catch (ex) { if (xhr.status) { msg += ' (HTTP ' + xhr.status + ')'; } } $status.text(msg).css('color', '#d63638'); } }); }); } // ----------------------------------------------------------------- // Step 7: Content settings (POST /settings) // ----------------------------------------------------------------- function initContentSettingsStep() { $('#ad-save-settings-btn').on('click', function() { var $btn = $(this).prop('disabled', true).text('Saving…'); var $status = $('#ad-save-settings-status').text(''); var postTypes = []; $('input[name="ad_content_post_types[]"]:checked').each(function() { postTypes.push($(this).val()); }); var taxonomies = []; $('input[name="ad_content_taxonomies[]"]:checked').each(function() { taxonomies.push($(this).val()); }); var includeDrafts = $('#ad-include-drafts').is(':checked'); var autoSync = $('#ad-auto-sync').is(':checked'); $.ajax({ url: W.restUrl + 'settings', method: 'POST', headers: { 'X-WP-Nonce': W.restNonce, 'Content-Type': 'application/json' }, data: JSON.stringify({ post_types: postTypes, taxonomies: taxonomies, include_drafts: includeDrafts, auto_sync: autoSync }), success: function(resp) { $btn.prop('disabled', false).text('Save & Continue'); if (resp && resp.success) { $status.text('Saved!').css('color', '#00a32a'); saveWizardState({ content_configured: true }); wizardState.content_configured = true; setTimeout(function() { showPanel(8); }, 800); } else { var msg = (resp && resp.data && resp.data.error) ? resp.data.error : 'Save failed.'; $status.text(msg).css('color', '#d63638'); } }, error: function(xhr) { $btn.prop('disabled', false).text('Save & Continue'); var msg = 'Save failed'; try { var body = JSON.parse(xhr.responseText); if (body && body.data && body.data.error) { msg = body.data.error; } } catch (ex) { if (xhr.status) { msg += ' (HTTP ' + xhr.status + ')'; } } $status.text(msg).css('color', '#d63638'); } }); }); } // ----------------------------------------------------------------- // Step 8: Migration (POST /export/full → ADProgress polling) // ----------------------------------------------------------------- function initMigrationStep() { $('#ad-start-migration-btn').on('click', function() { var $btn = $(this).prop('disabled', true).text('Starting…'); var $status = $('#ad-migration-status').text(''); $.ajax({ url: W.restUrl + 'export/full', method: 'POST', headers: { 'X-WP-Nonce': W.restNonce }, success: function(resp) { if (resp && resp.success) { var queued = (resp.data && resp.data.queued) ? resp.data.queued : 0; $status.text(queued + ' items queued.').css('color', '#00a32a'); saveWizardState({ migration_started: true }); wizardState.migration_started = true; $btn.text('Migration Started').prop('disabled', true); ensureProgressPolling(); // Show continue-to-approval button. $('#ad-continue-approval-wrap').removeAttr('hidden'); } else { var msg = (resp && resp.data && resp.data.error) ? resp.data.error : 'Failed to start.'; $status.text(msg).css('color', '#d63638'); $btn.prop('disabled', false).text('Start Full Migration'); } }, error: function(xhr) { var msg = 'Failed to start migration'; try { var body = JSON.parse(xhr.responseText); if (body && body.data && body.data.error) { msg = body.data.error; } } catch (ex) { if (xhr.status) { msg += ' (HTTP ' + xhr.status + ')'; } } $status.text(msg).css('color', '#d63638'); $btn.prop('disabled', false).text('Start Full Migration'); } }); }); // Continue to approval button. $('#ad-continue-approval-btn').on('click', function() { showPanel(9); }); } // ----------------------------------------------------------------- // Step 9: Approve (POST /approve) // ----------------------------------------------------------------- function initApproveStep() { $('#ad-approve-btn').on('click', function() { var $btn = $(this).prop('disabled', true).text('Processing…'); var $status = $('#ad-approve-status').text(''); var quoteId = wizardState.quote_id || ''; $.ajax({ url: W.restUrl + 'approve', method: 'POST', headers: { 'X-WP-Nonce': W.restNonce }, data: { quote_id: quoteId }, success: function(resp) { if (resp && resp.success && resp.data) { // QA gate: the AI service returns passed=false on QA // failure with an HTTP 200. Check it before treating // this as a true approval. if (resp.data.passed === false) { var failed = resp.data.failed_checks || []; var lines = ['QA checks failed:']; for (var i = 0; i < failed.length; i++) { lines.push('• ' + failed[i].name + (failed[i].detail ? ' — ' + failed[i].detail : '')); } $status.html($('' + (r.sanity_id || '') + '' + $('').text(p).html() + '');
});
$('#ad-cc-prompts').removeClass('ad-cc-hidden');
}
$('#ad-cc-mint').addClass('ad-cc-hidden');
$('#ad-cc-config').removeClass('ad-cc-hidden');
},
setError: function(msg) {
$('#ad-cc-error .ad-cc-error-text').text(msg || 'Something went wrong.');
$('#ad-cc-error').removeClass('ad-cc-hidden');
},
fallbackCopy: function(text, done) {
var ta = document.createElement('textarea');
ta.value = text;
ta.style.position = 'fixed';
ta.style.opacity = '0';
document.body.appendChild(ta);
ta.select();
try { document.execCommand('copy'); done(); } catch (e) { /* noop */ }
document.body.removeChild(ta);
}
};
// -----------------------------------------------------------------
// SchemaPreview module (merged from schema-preview.php inline script)
// -----------------------------------------------------------------
var SchemaPreview = {
initialized: false,
init: function() {
if (this.initialized) { return; }
this.initialized = true;
var btn = document.getElementById('ad-schema-generate');
if (!btn) { return; }
var self = this;
btn.addEventListener('click', function() {
btn.disabled = true;
self.setStatus('Generating…');
$('#ad-schema-rationale').addClass('ad-hidden');
document.getElementById('ad-schema-files').innerHTML = '';
$.ajax({
url: W.restUrl + 'schema-generate',
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-WP-Nonce': W.restNonce
},
data: JSON.stringify({}),
success: function(json) {
btn.disabled = false;
if (!json || !json.success) {
self.setStatus((json && json.data && json.data.error) ? json.data.error : 'Generation failed', true);
return;
}
var data = (json && json.data) || {};
self.setStatus(data.deterministic ? 'AI unavailable — generated deterministic scaffold.' : 'Generated.');
if (data.rationale) {
$('#ad-schema-rationale').text(data.rationale).removeClass('ad-hidden');
}
self.renderFiles(data.schemas || []);
},
error: function(xhr) {
btn.disabled = false;
var msg = 'Request failed';
try {
var body = JSON.parse(xhr.responseText);
if (body && body.data && body.data.error) { msg = body.data.error; }
} catch (e) { if (xhr.status) { msg += ' (HTTP ' + xhr.status + ')'; } }
self.setStatus(msg, true);
}
});
});
},
setStatus: function(msg, err) {
var $s = $('#ad-schema-status');
$s.text(msg);
$s.toggleClass('ad-err', !!err);
},
renderFiles: function(schemas) {
var filesEl = document.getElementById('ad-schema-files');
var tmpl = document.getElementById('ad-schema-file-tmpl');
if (!filesEl || !tmpl) { return; }
var self = this;
schemas.forEach(function(schema) {
var node = tmpl.content.cloneNode(true);
node.querySelector('.ad-schema-filename').textContent = schema.filename;
node.querySelector('.ad-schema-code code').textContent = schema.code;
node.querySelector('.ad-schema-copy').addEventListener('click', function() {
navigator.clipboard.writeText(schema.code).then(function() {
self.setStatus('Copied ' + schema.filename);
}).catch(function() { self.setStatus('Copy failed', true); });
});
node.querySelector('.ad-schema-download').addEventListener('click', function() {
var blob = new Blob([schema.code], { type: 'text/plain' });
var url = URL.createObjectURL(blob);
var a = document.createElement('a');
a.href = url;
a.download = schema.filename;
document.body.appendChild(a);
a.click();
a.remove();
URL.revokeObjectURL(url);
});
filesEl.appendChild(node);
});
}
};
// -----------------------------------------------------------------
// MigrationLog module (new — GET /logs with pagination)
// -----------------------------------------------------------------
var MigrationLog = {
initialized: false,
currentPaged: 1,
init: function() {
if (this.initialized) { return; }
this.initialized = true;
var self = this;
$('#ad-log-refresh').on('click', function() {
self.load(1);
});
$('#ad-log-status-filter').on('change', function() {
self.load(1);
});
// Lazy-load on first tab activation is handled by initNextSteps.
// Also load immediately in case the log tab is the default.
self.load(1);
},
load: function(paged) {
this.currentPaged = paged || 1;
var status = $('#ad-log-status-filter').val() || 'all';
var self = this;
$.ajax({
url: W.restUrl + 'logs',
method: 'GET',
headers: { 'X-WP-Nonce': W.restNonce },
data: { paged: this.currentPaged, status: status },
success: function(resp) {
if (resp && resp.success && resp.data) {
self.render(resp.data);
}
},
error: function() { /* leave loading state */ }
});
},
render: function(data) {
var $tbody = $('#ad-log-table tbody');
if (!$tbody.length) { return; }
var logs = data.logs || [];
if (!logs.length) {
$tbody.html('No logs found. ');
} else {
var rows = '';
for (var i = 0; i < logs.length; i++) {
var log = logs[i];
rows += '' +
'' + (log.id || '') + ' ' +
'' + (log.post_id || '') + ' ' +
'' + (log.action || '') + ' ' +
'' + (log.status || '') + ' ' +
'' + (log.sanity_id || '') + ' ' +
'' + (log.created_at || '') + ' ' +
' ';
}
$tbody.html(rows);
}
// Pagination controls.
var $pag = $('#ad-log-pagination').empty();
var totalPages = parseInt(data.total_pages || 1, 10);
var current = parseInt(data.paged || 1, 10);
if (totalPages > 1) {
var self = this;
if (current > 1) {
$pag.append(' ');
}
$pag.append('Page ' + current + ' of ' + totalPages + '');
if (current < totalPages) {
$pag.append(' ');
}
$pag.find('button').on('click', function() {
self.load(parseInt($(this).data('paged'), 10));
});
}
}
};
// -----------------------------------------------------------------
// Init
// -----------------------------------------------------------------
$(function() {
if (!$('.ad-wizard-wrap').length) { return; }
initLoginStep();
initAnalyzeStep();
initConnectSanityStep();
initContentSettingsStep();
initMigrationStep();
initApproveStep();
loadWizardState();
});
})(jQuery);