feat(integrations): добавить ручной sync с CFDM
Docker / build (push) Failing after 22s

Кнопка в настройках запрашивает полную выгрузку bindings из CFDM.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Denozordec
2026-07-31 23:24:04 +07:00
co-authored by Cursor
parent 5bbf0061cf
commit 033557a859
9 changed files with 215 additions and 17 deletions
+26 -1
View File
@@ -125,7 +125,10 @@ export const vpsDomainsRepository = {
return { updated }
},
syncBindings(items: CfdmBindingSyncItem[]): {
syncBindings(
items: CfdmBindingSyncItem[],
opts?: { fullSync?: boolean },
): {
matched: number
unmatched: number
deleted: number
@@ -139,6 +142,7 @@ export const vpsDomainsRepository = {
let unmatched = 0
let deleted = 0
let upserted = 0
const keptBindingIds = new Set<number>()
for (const item of items) {
if (item.deleted) {
@@ -146,6 +150,8 @@ export const vpsDomainsRepository = {
continue
}
keptBindingIds.add(item.bindingId)
const vpsId = findVpsIdByIps(allVps, item.ips)
const matchStatus = resolveMatchStatus(vpsId)
if (matchStatus === 'matched') matched++
@@ -176,6 +182,25 @@ export const vpsDomainsRepository = {
upserted++
}
if (opts?.fullSync) {
const rows = db
.select()
.from(schema.vpsDomains)
.where(
and(
eq(schema.vpsDomains.spaceId, spaceId),
eq(schema.vpsDomains.source, 'cfdm'),
),
)
.all()
for (const row of rows) {
if (!keptBindingIds.has(row.cfdmBindingId)) {
db.delete(schema.vpsDomains).where(eq(schema.vpsDomains.id, row.id)).run()
deleted++
}
}
}
return { matched, unmatched, deleted, upserted }
},