@remit/drizzle-service 0.0.26 → 0.0.27
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.
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { randomUUID } from "node:crypto";
|
|
3
3
|
import { after, before, describe, test } from "node:test";
|
|
4
|
+
import { MailboxSyncStatus } from "@remit/domain-enums";
|
|
4
5
|
import Database from "better-sqlite3";
|
|
5
6
|
import { drizzle } from "drizzle-orm/better-sqlite3";
|
|
6
7
|
import { mailboxTable } from "../schema.js";
|
|
@@ -66,6 +67,33 @@ describe("MailboxRepo (sqlite)", () => {
|
|
|
66
67
|
const reread = await repo.get(accountId, created.mailboxId);
|
|
67
68
|
assert.equal(reread.highestModseq, "9007199254740993");
|
|
68
69
|
});
|
|
70
|
+
|
|
71
|
+
test("renameChildPaths marks each child pending along with its new path (#290)", async () => {
|
|
72
|
+
// A renamed parent is set pending by the caller; its children's new paths
|
|
73
|
+
// are equally absent from the server until MAILBOX_RENAME lands, so they
|
|
74
|
+
// must be pending too — otherwise a reconcile in that window reaps the
|
|
75
|
+
// child as server-deleted.
|
|
76
|
+
const accountId = randomUUID();
|
|
77
|
+
const parent = await repo.create({
|
|
78
|
+
...makeMailboxInput(accountId, "Work"),
|
|
79
|
+
syncStatus: MailboxSyncStatus.pending,
|
|
80
|
+
});
|
|
81
|
+
const child = await repo.create({
|
|
82
|
+
...makeMailboxInput(accountId, "Work/sub"),
|
|
83
|
+
syncStatus: MailboxSyncStatus.synced,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
await repo.renameChildPaths(accountId, "Work", "Projects", "/");
|
|
87
|
+
|
|
88
|
+
const renamedChild = await repo.get(accountId, child.mailboxId);
|
|
89
|
+
assert.equal(renamedChild.fullPath, "Projects/sub");
|
|
90
|
+
assert.equal(renamedChild.syncStatus, MailboxSyncStatus.pending);
|
|
91
|
+
|
|
92
|
+
// The parent row is untouched by this call (its own path/status is the
|
|
93
|
+
// caller's job).
|
|
94
|
+
const parentRow = await repo.get(accountId, parent.mailboxId);
|
|
95
|
+
assert.equal(parentRow.fullPath, "Work");
|
|
96
|
+
});
|
|
69
97
|
});
|
|
70
98
|
|
|
71
99
|
/**
|
package/src/repos/i4-mailbox.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type {
|
|
|
6
6
|
ResultList,
|
|
7
7
|
UpdateMailboxInput,
|
|
8
8
|
} from "@remit/data-ports";
|
|
9
|
-
import { MailboxCursorState } from "@remit/domain-enums";
|
|
9
|
+
import { MailboxCursorState, MailboxSyncStatus } from "@remit/domain-enums";
|
|
10
10
|
import { and, asc, eq, gt, inArray, or } from "drizzle-orm";
|
|
11
11
|
import type { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
12
12
|
import shortUuid from "short-uuid";
|
|
@@ -341,7 +341,13 @@ export class MailboxRepo implements IMailboxRepository {
|
|
|
341
341
|
const children = await this.findByPathPrefix(accountId, oldPath, delimiter);
|
|
342
342
|
for (const child of children) {
|
|
343
343
|
const newChildPath = child.fullPath.replace(oldPath, newPath);
|
|
344
|
-
|
|
344
|
+
// Mark the child pending, like the renamed parent: its new path is not
|
|
345
|
+
// on the server until MAILBOX_RENAME lands, so a reconcile running in
|
|
346
|
+
// that window must not reap it as server-deleted (#290).
|
|
347
|
+
await this.update(accountId, child.mailboxId, {
|
|
348
|
+
fullPath: newChildPath,
|
|
349
|
+
syncStatus: MailboxSyncStatus.pending,
|
|
350
|
+
});
|
|
345
351
|
}
|
|
346
352
|
}
|
|
347
353
|
}
|