@remit/drizzle-service 0.0.25 → 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
|
}
|
|
@@ -122,6 +122,7 @@ function toItem(row: Row): ThreadMessageItem {
|
|
|
122
122
|
...(row.fromName !== null ? { fromName: row.fromName } : {}),
|
|
123
123
|
...(row.subject !== null ? { subject: row.subject } : {}),
|
|
124
124
|
...(row.snippet !== null ? { snippet: row.snippet } : {}),
|
|
125
|
+
...(row.listId !== null ? { listId: row.listId } : {}),
|
|
125
126
|
};
|
|
126
127
|
}
|
|
127
128
|
|
|
@@ -237,6 +238,7 @@ export class DrizzleThreadMessageRepository
|
|
|
237
238
|
fromName: input.fromName ?? null,
|
|
238
239
|
subject: input.subject ?? null,
|
|
239
240
|
snippet: input.snippet ?? null,
|
|
241
|
+
listId: input.listId ?? null,
|
|
240
242
|
createdAt: now,
|
|
241
243
|
updatedAt: now,
|
|
242
244
|
};
|
|
@@ -321,6 +323,7 @@ export class DrizzleThreadMessageRepository
|
|
|
321
323
|
if (input.star !== undefined) set.star = input.star;
|
|
322
324
|
if (input.category !== undefined) set.category = input.category;
|
|
323
325
|
if (input.subject !== undefined) set.subject = input.subject;
|
|
326
|
+
if (input.listId !== undefined) set.listId = input.listId;
|
|
324
327
|
if (input.fromEmail !== undefined) set.fromEmail = input.fromEmail;
|
|
325
328
|
if (input.fromName !== undefined) set.fromName = input.fromName;
|
|
326
329
|
if (input.snippet !== undefined) set.snippet = input.snippet;
|