@remit/data-ports 0.0.69 → 0.0.71
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
|
@@ -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";
|
|
@@ -58,11 +58,12 @@ export interface IThreadMessageRepository {
|
|
|
58
58
|
},
|
|
59
59
|
): Promise<ResultList<ThreadMessageItem>>;
|
|
60
60
|
/**
|
|
61
|
-
* Search rows for a config across every mailbox in `mailboxIds
|
|
62
|
-
*
|
|
61
|
+
* Search rows for a config across every mailbox in `mailboxIds` — the
|
|
62
|
+
* cross-account, cross-folder counterpart of `searchByMailbox`. A row whose
|
|
63
|
+
* From matches any `query` term ranks above one that only mentions the
|
|
64
|
+
* terms, and each tier runs in date order.
|
|
63
65
|
*
|
|
64
|
-
*
|
|
65
|
-
* supplies the mailbox scope, so a search reaching Archive, Sent, Spam and
|
|
66
|
+
* The caller supplies the mailbox scope, so a search reaching Archive, Sent, Spam and
|
|
66
67
|
* custom folders is a matter of which set is passed. An empty or absent
|
|
67
68
|
* `mailboxIds` means no narrowing (every mailbox of the config), which is why
|
|
68
69
|
* handlers pass an explicitly built set rather than relying on the default.
|
package/src/mutation-events.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
*/
|
|
10
10
|
export const MUTATION_EVENT_SCHEMA_VERSION = 2;
|
|
11
11
|
|
|
12
|
+
export const PATHLESS_MUTATION_EVENT_SCHEMA_VERSION = 3;
|
|
13
|
+
|
|
12
14
|
/**
|
|
13
15
|
* Queue payloads are `JSON.parse`d and cast with no validation, so the declared
|
|
14
16
|
* type is a promise the queue cannot keep. A handler that cannot vouch for an
|
|
@@ -16,5 +18,6 @@ export const MUTATION_EVENT_SCHEMA_VERSION = 2;
|
|
|
16
18
|
* makes the unverified expunge the default for every event we cannot vouch for,
|
|
17
19
|
* including any future producer that forgets the field.
|
|
18
20
|
*/
|
|
19
|
-
export const
|
|
20
|
-
value === MUTATION_EVENT_SCHEMA_VERSION
|
|
21
|
+
export const isAcceptedSchemaVersion = (value: unknown): boolean =>
|
|
22
|
+
value === MUTATION_EVENT_SCHEMA_VERSION ||
|
|
23
|
+
value === PATHLESS_MUTATION_EVENT_SCHEMA_VERSION;
|
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"];
|