Files
shopify-ai-backup/android-app/capacitor-bridge.js

46 lines
1.2 KiB
JavaScript

import { Preferences } from '@capacitor/preferences';
import { Http } from '@capacitor/http';
const BACKEND_BASE_URL = window.BACKEND_BASE_URL || 'https://api.example.com';
export { Preferences };
export async function syncApp(appId) {
if (!appId || appId.trim() === '') {
throw new Error('appId is required');
}
const { value } = await Preferences.get({ key: `app_${appId}` });
if (!value) {
throw new Error(`App not found: ${appId}`);
}
const appData = JSON.parse(value);
const response = await Http.request({
method: 'POST',
url: `${BACKEND_BASE_URL}/desktop/apps/sync`,
headers: {
'Content-Type': 'application/json',
},
data: appData,
});
if (response.status < 200 || response.status >= 300) {
throw new Error(`Sync failed: ${response.status}`);
}
return response.data;
}
export async function runOpencodeTask(appId, taskName, args = []) {
if (!appId || appId.trim() === '') {
throw new Error('appId is required');
}
if (!taskName || taskName.trim() === '') {
throw new Error('taskName is required');
}
throw new Error('OpenCode execution is not supported on mobile devices. Please use the desktop app for this feature.');
}