@remit/data-ports 0.0.68 → 0.0.70
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 +1 -1
- package/src/conformance/account.ts +82 -0
- package/src/conformance/index.ts +1 -0
- package/src/errors.ts +11 -5
- package/src/types.ts +2 -0
package/package.json
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { after, before, describe, test } from "node:test";
|
|
3
|
+
import { AccountService, ConnectionState } from "@remit/domain-enums";
|
|
4
|
+
import type { IAccountRepository } from "../interfaces/account.js";
|
|
5
|
+
import type { CreateAccountInput } from "../types.js";
|
|
6
|
+
import type { RepositoryConformanceHarness } from "./harness.js";
|
|
7
|
+
|
|
8
|
+
const accountInput = (accountConfigId: string): CreateAccountInput => ({
|
|
9
|
+
accountConfigId,
|
|
10
|
+
username: "person@example.com",
|
|
11
|
+
email: "person@example.com",
|
|
12
|
+
imapHost: "imap.example.com",
|
|
13
|
+
imapPort: 993,
|
|
14
|
+
imapTls: true,
|
|
15
|
+
imapStartTls: false,
|
|
16
|
+
isActive: true,
|
|
17
|
+
connectionState: ConnectionState.NotAuthenticated,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export function accountRepositoryConformance(
|
|
21
|
+
harness: RepositoryConformanceHarness<IAccountRepository>,
|
|
22
|
+
): void {
|
|
23
|
+
describe("IAccountRepository conformance", () => {
|
|
24
|
+
let repo: IAccountRepository;
|
|
25
|
+
|
|
26
|
+
before(async () => {
|
|
27
|
+
repo = await harness.createRepository();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
after(() => harness.teardown());
|
|
31
|
+
|
|
32
|
+
test("an account created without a service selection syncs mail", async () => {
|
|
33
|
+
const created = await repo.create(accountInput(harness.makeId()));
|
|
34
|
+
|
|
35
|
+
assert.deepEqual(created.syncedServices, [AccountService.Mail]);
|
|
36
|
+
assert.deepEqual((await repo.get(created.accountId)).syncedServices, [
|
|
37
|
+
AccountService.Mail,
|
|
38
|
+
]);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("an account keeps the selection it was created with", async () => {
|
|
42
|
+
const created = await repo.create({
|
|
43
|
+
...accountInput(harness.makeId()),
|
|
44
|
+
syncedServices: [AccountService.Calendar],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
assert.deepEqual((await repo.get(created.accountId)).syncedServices, [
|
|
48
|
+
AccountService.Calendar,
|
|
49
|
+
]);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("an update replaces the selection outright", async () => {
|
|
53
|
+
const created = await repo.create(accountInput(harness.makeId()));
|
|
54
|
+
|
|
55
|
+
const updated = await repo.update(created.accountId, {
|
|
56
|
+
syncedServices: [AccountService.Mail, AccountService.Calendar],
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
assert.deepEqual(updated.syncedServices, [
|
|
60
|
+
AccountService.Mail,
|
|
61
|
+
AccountService.Calendar,
|
|
62
|
+
]);
|
|
63
|
+
assert.deepEqual((await repo.get(created.accountId)).syncedServices, [
|
|
64
|
+
AccountService.Mail,
|
|
65
|
+
AccountService.Calendar,
|
|
66
|
+
]);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("an update that leaves the selection out keeps it", async () => {
|
|
70
|
+
const created = await repo.create({
|
|
71
|
+
...accountInput(harness.makeId()),
|
|
72
|
+
syncedServices: [AccountService.Calendar],
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
await repo.update(created.accountId, { lastError: "timeout" });
|
|
76
|
+
|
|
77
|
+
assert.deepEqual((await repo.get(created.accountId)).syncedServices, [
|
|
78
|
+
AccountService.Calendar,
|
|
79
|
+
]);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
}
|
package/src/conformance/index.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { accountRepositoryConformance } from "./account.js";
|
|
1
2
|
export { calendarCollectionRepositoryConformance } from "./calendar-collection.js";
|
|
2
3
|
export { calendarEventIndexRepositoryConformance } from "./calendar-event-index.js";
|
|
3
4
|
export { calendarFeedTokenRepositoryConformance } from "./calendar-feed-token.js";
|
package/src/errors.ts
CHANGED
|
@@ -81,13 +81,19 @@ export class FolderRoleUnresolvedError extends ConflictError {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
/**
|
|
84
|
-
* A
|
|
85
|
-
* (imap-mutations R2: wait). Its own
|
|
86
|
-
* the
|
|
87
|
-
* refused this way.
|
|
84
|
+
* A durable reference cannot be bound to a mailbox whose own mutation has not
|
|
85
|
+
* settled (folder-rename-and-delete.md D12, imap-mutations R2: wait). Its own
|
|
86
|
+
* code, because the role is not unresolved — the target is: the client words a
|
|
87
|
+
* wait, not a retry. Clearing a role is never refused this way.
|
|
88
|
+
*
|
|
89
|
+
* **422, not 409** (D4). 409 already means "this folder is being changed right
|
|
90
|
+
* now, refresh"; this means "the folder you are pointing at has not settled
|
|
91
|
+
* yet", which is a different sentence and a different remedy. The status is
|
|
92
|
+
* what separates them for a client that reads no further.
|
|
88
93
|
*/
|
|
89
|
-
export class MailboxNotSettledError extends
|
|
94
|
+
export class MailboxNotSettledError extends HTTPError {
|
|
90
95
|
name = "MailboxNotSettledError";
|
|
96
|
+
public statusCode = 422;
|
|
91
97
|
|
|
92
98
|
constructor(message: string, mailboxId: string, syncStatus: string) {
|
|
93
99
|
super(message);
|
package/src/types.ts
CHANGED
|
@@ -207,9 +207,11 @@ export type CreateAccountInput = Omit<
|
|
|
207
207
|
| "smtpTls"
|
|
208
208
|
| "smtpStartTls"
|
|
209
209
|
| "smtpUsername"
|
|
210
|
+
| "syncedServices"
|
|
210
211
|
> & {
|
|
211
212
|
accountId?: string;
|
|
212
213
|
authType?: AccountItem["authType"];
|
|
214
|
+
syncedServices?: AccountItem["syncedServices"];
|
|
213
215
|
smtpEnabled?: AccountItem["smtpEnabled"];
|
|
214
216
|
smtpHost?: AccountItem["smtpHost"];
|
|
215
217
|
smtpPort?: AccountItem["smtpPort"];
|