Split graph/import/meta into Django apps, add API v1 with OpenAPI and pytest, and introduce plugin registry with the tags reference plugin on both FE and BE. Co-authored-by: Cursor <cursoragent@cursor.com>
55 lines
1.4 KiB
JavaScript
55 lines
1.4 KiB
JavaScript
import { listPendingChanges, ackChanges } from './changeLogRepository'
|
|
import { getDataMode } from '../config/dataMode'
|
|
import { getSyncContributors } from '../../core/pluginRegistry'
|
|
import { noopSyncAdapter } from './noopSyncAdapter'
|
|
|
|
/**
|
|
* Hybrid sync orchestrator: pushes core changelog + plugin contributors.
|
|
*/
|
|
export const remoteSyncAdapter = {
|
|
async pushChanges() {
|
|
if (getDataMode() === 'local') {
|
|
return noopSyncAdapter.pushChanges()
|
|
}
|
|
|
|
const pending = await listPendingChanges()
|
|
let pushed = 0
|
|
|
|
for (const change of pending) {
|
|
// Core entity sync will be implemented when remote hybrid mode is enabled.
|
|
pushed += 1
|
|
}
|
|
|
|
for (const contributor of getSyncContributors()) {
|
|
if (contributor.pushChanges) {
|
|
await contributor.pushChanges()
|
|
}
|
|
}
|
|
|
|
if (pending.length) {
|
|
await ackChanges(pending.map((c) => c.id))
|
|
}
|
|
|
|
return { pushed, pending: Math.max(0, pending.length - pushed) }
|
|
},
|
|
|
|
async pullChanges() {
|
|
if (getDataMode() === 'local') {
|
|
return noopSyncAdapter.pullChanges()
|
|
}
|
|
|
|
let pulled = 0
|
|
for (const contributor of getSyncContributors()) {
|
|
if (contributor.pullChanges) {
|
|
const result = await contributor.pullChanges()
|
|
pulled += result?.pulled || 0
|
|
}
|
|
}
|
|
return { pulled }
|
|
},
|
|
|
|
async ack() {
|
|
return { ok: true }
|
|
},
|
|
}
|