unforgit 0.11.9 → 0.11.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2046,6 +2046,43 @@ var RemoteClient = class {
|
|
|
2046
2046
|
}
|
|
2047
2047
|
return res.json();
|
|
2048
2048
|
}
|
|
2049
|
+
async syncPull(orgId, repoId, since) {
|
|
2050
|
+
const params = new URLSearchParams({ orgId, repoId });
|
|
2051
|
+
if (since) params.set("since", since.toISOString());
|
|
2052
|
+
const res = await this.fetchWithRetry(
|
|
2053
|
+
`${this.baseUrl}/v1/sync/pull?${params.toString()}`,
|
|
2054
|
+
{ method: "GET", headers: this.getHeaders() },
|
|
2055
|
+
"syncPull"
|
|
2056
|
+
);
|
|
2057
|
+
if (!res.ok) {
|
|
2058
|
+
this.handleError(res, "syncPull", await res.text());
|
|
2059
|
+
}
|
|
2060
|
+
const memories = await res.json();
|
|
2061
|
+
return memories.map((memory) => ({
|
|
2062
|
+
...memory,
|
|
2063
|
+
createdAt: new Date(memory.createdAt),
|
|
2064
|
+
updatedAt: new Date(memory.updatedAt),
|
|
2065
|
+
deletedAt: memory.deletedAt ? new Date(memory.deletedAt) : void 0
|
|
2066
|
+
}));
|
|
2067
|
+
}
|
|
2068
|
+
async syncTombstones(orgId, repoId, since) {
|
|
2069
|
+
const params = new URLSearchParams({ orgId, repoId });
|
|
2070
|
+
if (since) params.set("since", since.toISOString());
|
|
2071
|
+
const res = await this.fetchWithRetry(
|
|
2072
|
+
`${this.baseUrl}/v1/sync/tombstones?${params.toString()}`,
|
|
2073
|
+
{ method: "GET", headers: this.getHeaders() },
|
|
2074
|
+
"syncTombstones"
|
|
2075
|
+
);
|
|
2076
|
+
if (!res.ok) {
|
|
2077
|
+
this.handleError(res, "syncTombstones", await res.text());
|
|
2078
|
+
}
|
|
2079
|
+
const tombstones = await res.json();
|
|
2080
|
+
return tombstones.map((tombstone) => ({
|
|
2081
|
+
...tombstone,
|
|
2082
|
+
deletedAt: new Date(tombstone.deletedAt),
|
|
2083
|
+
syncedAt: tombstone.syncedAt ? new Date(tombstone.syncedAt) : void 0
|
|
2084
|
+
}));
|
|
2085
|
+
}
|
|
2049
2086
|
async deprecate(id, reason) {
|
|
2050
2087
|
const res = await this.fetchWithRetry(
|
|
2051
2088
|
`${this.baseUrl}/v1/memory/${pathSegment(id)}/deprecate`,
|
|
@@ -3394,7 +3431,6 @@ var LocalStore = class {
|
|
|
3394
3431
|
}
|
|
3395
3432
|
upsertFromRemote(memory, conflictResolution = "last_write_wins") {
|
|
3396
3433
|
const existing = this.getById(memory.id);
|
|
3397
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3398
3434
|
const normalizedOrgId = memory.orgId.toLowerCase();
|
|
3399
3435
|
const normalizedRepoId = memory.repoId.toLowerCase();
|
|
3400
3436
|
if (!existing) {
|
|
@@ -3425,7 +3461,7 @@ var LocalStore = class {
|
|
|
3425
3461
|
memory.deletedAt?.toISOString() ?? null,
|
|
3426
3462
|
memory.deletedBy ?? null,
|
|
3427
3463
|
memory.createdAt.toISOString(),
|
|
3428
|
-
|
|
3464
|
+
memory.updatedAt.toISOString()
|
|
3429
3465
|
);
|
|
3430
3466
|
return { action: "created", conflict: false };
|
|
3431
3467
|
}
|
|
@@ -3463,10 +3499,10 @@ var LocalStore = class {
|
|
|
3463
3499
|
memory.consolidationVersion ?? null,
|
|
3464
3500
|
memory.authorId ?? null,
|
|
3465
3501
|
memory.authorName ?? null,
|
|
3466
|
-
|
|
3502
|
+
remoteVersion,
|
|
3467
3503
|
memory.deletedAt?.toISOString() ?? null,
|
|
3468
3504
|
memory.deletedBy ?? null,
|
|
3469
|
-
|
|
3505
|
+
memory.updatedAt.toISOString(),
|
|
3470
3506
|
memory.id
|
|
3471
3507
|
);
|
|
3472
3508
|
return { action: "updated", conflict: hasConflict };
|
|
@@ -3571,13 +3607,16 @@ var LocalStore = class {
|
|
|
3571
3607
|
});
|
|
3572
3608
|
return transaction.immediate();
|
|
3573
3609
|
}
|
|
3574
|
-
markAsPulled(memoryId,
|
|
3610
|
+
markAsPulled(memoryId, remoteVersion) {
|
|
3575
3611
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3576
3612
|
this.db.prepare(`
|
|
3577
|
-
UPDATE sync_state
|
|
3578
|
-
SET sync_status = 'synced',
|
|
3613
|
+
UPDATE sync_state
|
|
3614
|
+
SET sync_status = 'synced',
|
|
3615
|
+
local_version = ?,
|
|
3616
|
+
remote_version = ?,
|
|
3617
|
+
last_pulled_at = ?
|
|
3579
3618
|
WHERE memory_id = ?
|
|
3580
|
-
`).run(
|
|
3619
|
+
`).run(remoteVersion, remoteVersion, now, memoryId);
|
|
3581
3620
|
}
|
|
3582
3621
|
markAsConflict(memoryId, remoteVersion) {
|
|
3583
3622
|
this.db.prepare(`
|
|
@@ -4428,4 +4467,4 @@ export {
|
|
|
4428
4467
|
RemoteClient,
|
|
4429
4468
|
LocalStore
|
|
4430
4469
|
};
|
|
4431
|
-
//# sourceMappingURL=chunk-
|
|
4470
|
+
//# sourceMappingURL=chunk-J74YKGDT.js.map
|