@remit/drizzle-service 0.0.55 → 0.0.56
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,7 +1,10 @@
|
|
|
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 {
|
|
4
|
+
import {
|
|
5
|
+
composeFolderRoleAppointmentName,
|
|
6
|
+
meetsTrashAssurance,
|
|
7
|
+
} from "@remit/data-ports/folder-role";
|
|
5
8
|
import { CanonicalMailboxRole } from "@remit/domain-enums";
|
|
6
9
|
import {
|
|
7
10
|
accountSettingTable,
|
|
@@ -175,7 +178,9 @@ describe("MailboxSpecialUseRepo role lookups (sqlite)", () => {
|
|
|
175
178
|
makeMailboxInput(accountId, "[Gmail]/Trash"),
|
|
176
179
|
);
|
|
177
180
|
|
|
178
|
-
|
|
181
|
+
const proposal = await repo.resolveTrashRole(accountId);
|
|
182
|
+
assert.equal(proposal.kind, "proposed");
|
|
183
|
+
assert.equal(meetsTrashAssurance(proposal, "confirmed"), false);
|
|
179
184
|
|
|
180
185
|
await appoint(
|
|
181
186
|
accountConfigId,
|
|
@@ -183,9 +188,11 @@ describe("MailboxSpecialUseRepo role lookups (sqlite)", () => {
|
|
|
183
188
|
CanonicalMailboxRole.Trash,
|
|
184
189
|
trash.mailboxId,
|
|
185
190
|
);
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
191
|
+
assert.deepEqual(await repo.resolveTrashRole(accountId), {
|
|
192
|
+
kind: "appointed",
|
|
193
|
+
mailbox: { mailboxId: trash.mailboxId, fullPath: "[Gmail]/Trash" },
|
|
194
|
+
});
|
|
195
|
+
assert.notEqual(trash.mailboxId, keepsakes.mailboxId);
|
|
189
196
|
});
|
|
190
197
|
|
|
191
198
|
test("keeps a stale Trash appointment visible instead of answering the fallback", async () => {
|
|
@@ -214,6 +221,17 @@ describe("MailboxSpecialUseRepo role lookups (sqlite)", () => {
|
|
|
214
221
|
mailbox: { mailboxId: flagged.mailboxId, fullPath: "[Gmail]/Trash" },
|
|
215
222
|
},
|
|
216
223
|
});
|
|
224
|
+
|
|
225
|
+
// The flagged folder is where a delete files mail, and no evidence at all
|
|
226
|
+
// that the user meant it to be emptied.
|
|
227
|
+
assert.equal(
|
|
228
|
+
meetsTrashAssurance(await repo.resolveTrashRole(accountId), "confirmed"),
|
|
229
|
+
false,
|
|
230
|
+
);
|
|
231
|
+
assert.equal(
|
|
232
|
+
(await repo.findTrashMailbox(accountId))?.mailboxId,
|
|
233
|
+
flagged.mailboxId,
|
|
234
|
+
);
|
|
217
235
|
});
|
|
218
236
|
|
|
219
237
|
test("resolves an INBOX-nested Junk folder that advertises \\Junk", async () => {
|
|
@@ -259,7 +277,10 @@ describe("MailboxSpecialUseRepo role lookups (sqlite)", () => {
|
|
|
259
277
|
// Resolving the name widens where a delete FILES mail, never what an
|
|
260
278
|
// Empty Trash may expunge (#846): that still needs the flag or an
|
|
261
279
|
// appointment.
|
|
262
|
-
assert.equal(
|
|
280
|
+
assert.equal(
|
|
281
|
+
meetsTrashAssurance(await repo.resolveTrashRole(accountId), "confirmed"),
|
|
282
|
+
false,
|
|
283
|
+
);
|
|
263
284
|
});
|
|
264
285
|
|
|
265
286
|
test("resolves an INBOX-nested Archive folder that advertises no special use", async () => {
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
composeFolderRoleAppointmentName,
|
|
9
9
|
type RoleMailboxCandidate,
|
|
10
10
|
type RoleResolution,
|
|
11
|
-
resolveConfirmedMailboxForRole,
|
|
12
11
|
resolveMailboxForRole,
|
|
13
12
|
resolveRoleForAccount,
|
|
14
13
|
type UnappointedRoleResolution,
|
|
@@ -144,16 +143,6 @@ export class MailboxSpecialUseRepo implements IMailboxSpecialUseRepository {
|
|
|
144
143
|
return this.findMailboxForRole(accountId, CanonicalMailboxRole.Trash);
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
findConfirmedTrashMailbox(
|
|
148
|
-
accountId: string,
|
|
149
|
-
): Promise<{ mailboxId: string; fullPath: string } | null> {
|
|
150
|
-
return this.findMailboxForRole(
|
|
151
|
-
accountId,
|
|
152
|
-
CanonicalMailboxRole.Trash,
|
|
153
|
-
resolveConfirmedMailboxForRole,
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
146
|
/**
|
|
158
147
|
* Trash with its evidence, for the verbs that weigh it. Reads exactly what
|
|
159
148
|
* `findMailboxForRole` reads — a `null` answer is thrown away there, and this
|
|
@@ -194,13 +183,12 @@ export class MailboxSpecialUseRepo implements IMailboxSpecialUseRepository {
|
|
|
194
183
|
private async findMailboxForRole(
|
|
195
184
|
accountId: string,
|
|
196
185
|
role: CanonicalMailboxRoleValue,
|
|
197
|
-
resolve: typeof resolveMailboxForRole = resolveMailboxForRole,
|
|
198
186
|
): Promise<{ mailboxId: string; fullPath: string } | null> {
|
|
199
187
|
const [candidates, appointedMailboxId] = await Promise.all([
|
|
200
188
|
this.roleCandidates(accountId),
|
|
201
189
|
this.appointedMailboxId(accountId, role),
|
|
202
190
|
]);
|
|
203
|
-
const found =
|
|
191
|
+
const found = resolveMailboxForRole(role, candidates, appointedMailboxId);
|
|
204
192
|
return found
|
|
205
193
|
? { mailboxId: found.mailboxId, fullPath: found.fullPath }
|
|
206
194
|
: null;
|