@remit/drizzle-service 0.0.52 → 0.0.53

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,6 @@
1
1
  {
2
2
  "name": "@remit/drizzle-service",
3
- "version": "0.0.52",
3
+ "version": "0.0.53",
4
4
  "description": "Drizzle ORM service over SQLite",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -14,11 +14,15 @@ import { AccountSettingRepo } from "./i4-account-setting.js";
14
14
  import { MailboxRepo } from "./i4-mailbox.js";
15
15
  import { MailboxSpecialUseRepo } from "./i4-mailbox-special-use.js";
16
16
 
17
- const makeMailboxInput = (accountId: string, fullPath: string) => ({
17
+ const makeMailboxInput = (
18
+ accountId: string,
19
+ fullPath: string,
20
+ hierarchyDelimiter = "/",
21
+ ) => ({
18
22
  accountId,
19
23
  namespaceType: "personal" as const,
20
24
  namespacePrefix: "",
21
- hierarchyDelimiter: "/",
25
+ hierarchyDelimiter,
22
26
  fullPath,
23
27
  uidValidity: 1,
24
28
  uidNext: 1,
@@ -210,6 +214,59 @@ describe("MailboxSpecialUseRepo role lookups (sqlite)", () => {
210
214
  assert.equal(found?.mailboxId, spam.mailboxId);
211
215
  });
212
216
 
217
+ test("resolves an INBOX-nested Trash folder that advertises no special use", async () => {
218
+ // #837: `findTrashMailbox` carried its own copy of the discarded
219
+ // whole-path rule, so `INBOX/Trash` resolved to nothing and a delete
220
+ // refused on an account that plainly has a Trash folder.
221
+ const { accountId } = await makeAccount();
222
+ await mailboxes.create(makeMailboxInput(accountId, "INBOX"));
223
+ const trash = await mailboxes.create(
224
+ makeMailboxInput(accountId, "INBOX/Trash"),
225
+ );
226
+
227
+ assert.equal(
228
+ (await repo.findTrashMailbox(accountId))?.mailboxId,
229
+ trash.mailboxId,
230
+ );
231
+ // Resolving the name widens where a delete FILES mail, never what an
232
+ // Empty Trash may expunge (#846): that still needs the flag or an
233
+ // appointment.
234
+ assert.equal(await repo.findConfirmedTrashMailbox(accountId), null);
235
+ });
236
+
237
+ test("resolves an INBOX-nested Archive folder that advertises no special use", async () => {
238
+ const { accountId } = await makeAccount();
239
+ await mailboxes.create(makeMailboxInput(accountId, "INBOX"));
240
+ const archive = await mailboxes.create(
241
+ makeMailboxInput(accountId, "INBOX/Archive"),
242
+ );
243
+
244
+ assert.equal(
245
+ (await repo.findArchiveMailbox(accountId))?.mailboxId,
246
+ archive.mailboxId,
247
+ );
248
+ });
249
+
250
+ test("splits the leaf on the account's own delimiter, not on a slash", async () => {
251
+ const { accountId } = await makeAccount();
252
+ await mailboxes.create(makeMailboxInput(accountId, "INBOX", "."));
253
+ const trash = await mailboxes.create(
254
+ makeMailboxInput(accountId, "INBOX.Trash", "."),
255
+ );
256
+ const archive = await mailboxes.create(
257
+ makeMailboxInput(accountId, "INBOX.Archive", "."),
258
+ );
259
+
260
+ assert.equal(
261
+ (await repo.findTrashMailbox(accountId))?.mailboxId,
262
+ trash.mailboxId,
263
+ );
264
+ assert.equal(
265
+ (await repo.findArchiveMailbox(accountId))?.mailboxId,
266
+ archive.mailboxId,
267
+ );
268
+ });
269
+
213
270
  test("answers null when the account has no Junk folder at all", async () => {
214
271
  const { accountId } = await makeAccount();
215
272
  await mailboxes.create(makeMailboxInput(accountId, "INBOX"));