@remit/drizzle-service 0.0.103 → 0.0.105

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.
Files changed (66) hide show
  1. package/package.json +4 -3
  2. package/src/bound-parameters.test.ts +57 -0
  3. package/src/bound-parameters.ts +49 -0
  4. package/src/databases.ts +10 -9
  5. package/src/db.ts +1 -0
  6. package/src/index.ts +4 -0
  7. package/src/repair/junk-only-address.sqlite.test.ts +9 -5
  8. package/src/repos/account.conformance.d1.test.ts +20 -0
  9. package/src/repos/account.conformance.sqlite.test.ts +9 -5
  10. package/src/repos/calendar-collection.conformance.d1.test.ts +20 -0
  11. package/src/repos/calendar-default.d1.test.ts +4 -0
  12. package/src/repos/calendar-default.sqlite.test.ts +3 -76
  13. package/src/repos/calendar-default.suite.ts +68 -0
  14. package/src/repos/calendar-event-index.conformance.d1.test.ts +20 -0
  15. package/src/repos/calendar-event-index.conformance.sqlite.test.ts +3 -1
  16. package/src/repos/calendar-event-index.ts +36 -21
  17. package/src/repos/calendar-feed-token.conformance.d1.test.ts +20 -0
  18. package/src/repos/calendar-object.conformance.d1.test.ts +20 -0
  19. package/src/repos/calendar-put.d1.test.ts +4 -0
  20. package/src/repos/calendar-put.sqlite.test.ts +3 -209
  21. package/src/repos/calendar-put.suite.ts +210 -0
  22. package/src/repos/calendar-store.ts +17 -10
  23. package/src/repos/cascade-delete.test.ts +9 -2
  24. package/src/repos/cascade-delete.ts +3 -2
  25. package/src/repos/envelope.d1.test.ts +66 -0
  26. package/src/repos/envelope.sqlite.test.ts +5 -1
  27. package/src/repos/envelope.test.ts +5 -1
  28. package/src/repos/envelope.ts +40 -31
  29. package/src/repos/filter.d1.test.ts +4 -0
  30. package/src/repos/filter.suite.ts +476 -0
  31. package/src/repos/filter.test.ts +3 -472
  32. package/src/repos/i4-account-config.d1.test.ts +4 -0
  33. package/src/repos/i4-account-config.suite.ts +131 -0
  34. package/src/repos/i4-account-config.test.ts +3 -127
  35. package/src/repos/i4-account-export-request.d1.test.ts +4 -0
  36. package/src/repos/i4-account-export-request.suite.ts +44 -0
  37. package/src/repos/i4-account-export-request.test.ts +3 -40
  38. package/src/repos/i4-account-setting.d1.test.ts +4 -0
  39. package/src/repos/i4-account-setting.suite.ts +100 -0
  40. package/src/repos/i4-account-setting.test.ts +3 -93
  41. package/src/repos/i4-account.test.ts +17 -10
  42. package/src/repos/i4-address-junk-move.sqlite.test.ts +9 -5
  43. package/src/repos/i4-mailbox-special-use.sqlite.test.ts +9 -5
  44. package/src/repos/i4-mailbox.sqlite.test.ts +17 -10
  45. package/src/repos/i4-mailbox.test.ts +17 -10
  46. package/src/repos/i4-outbox-attachment.test.ts +9 -5
  47. package/src/repos/label.conformance.d1.test.ts +20 -0
  48. package/src/repos/message.sqlite.test.ts +59 -1
  49. package/src/repos/message.test.ts +5 -1
  50. package/src/repos/message.ts +66 -0
  51. package/src/repos/sync-warning.ts +35 -22
  52. package/src/repos/thread-message-body-muted.sqlite.test.ts +32 -24
  53. package/src/repos/thread-message-field-terms.sqlite.test.ts +18 -10
  54. package/src/repos/thread-message.sqlite.test.ts +15 -9
  55. package/src/repos/thread-message.test.ts +54 -29
  56. package/src/repos/thread-message.ts +13 -9
  57. package/src/repos/thread-search-predicates.ts +36 -63
  58. package/src/schema/message-data.ts +3 -0
  59. package/src/schema-sets/mail.ts +1 -0
  60. package/src/search/thread-message-search.sqlite.test.ts +62 -14
  61. package/src/search/thread-message-search.ts +27 -21
  62. package/src/sqlite-repositories.ts +6 -3
  63. package/src/test-d1.ts +57 -0
  64. package/src/test-db-sqlite.ts +1 -1
  65. package/src/test-shipped-sqlite-schema.ts +8 -6
  66. package/src/test-stores.ts +43 -0
@@ -1,128 +1,4 @@
1
- import assert from "node:assert";
2
- import { after, before, describe, test } from "node:test";
3
- import { createSqliteRepositories } from "../sqlite-repositories.js";
4
- import { createTestDb, randomId, type TestDb } from "../test-db.js";
5
- import type { AccountConfigRepo } from "./i4-account-config.js";
1
+ import { openSqliteTestStores } from "../test-stores.js";
2
+ import { accountConfigRepoSuite } from "./i4-account-config.suite.js";
6
3
 
7
- describe("AccountConfigRepo", () => {
8
- let db: TestDb;
9
- let close: () => Promise<void>;
10
- let repo: AccountConfigRepo;
11
-
12
- before(async () => {
13
- ({ db, close } = await createTestDb());
14
- repo = createSqliteRepositories({
15
- app: db,
16
- mail: db,
17
- search: db,
18
- }).accountConfig;
19
- });
20
-
21
- after(async () => {
22
- await close();
23
- });
24
-
25
- test("create and get", async () => {
26
- const userId = randomId();
27
- const cfg = await repo.create({ userId, name: "My Config" });
28
-
29
- assert.ok(cfg.accountConfigId);
30
- assert.equal(cfg.userId, userId);
31
- assert.equal(cfg.name, "My Config");
32
- assert.equal(cfg.state, "active");
33
-
34
- const fetched = await repo.get(cfg.accountConfigId);
35
- assert.equal(fetched.accountConfigId, cfg.accountConfigId);
36
-
37
- await repo.delete(cfg.accountConfigId);
38
- });
39
-
40
- test("batchGet: WHERE id = ANY($1)", async () => {
41
- const userId = randomId();
42
- const c1 = await repo.create({ userId });
43
- const c2 = await repo.create({ userId });
44
-
45
- const results = await repo.get([c1.accountConfigId, c2.accountConfigId]);
46
- assert.equal(results.length, 2);
47
-
48
- await repo.deleteMany([c1.accountConfigId, c2.accountConfigId]);
49
- });
50
-
51
- test("batchGet empty array returns []", async () => {
52
- const results = await repo.get([]);
53
- assert.deepEqual(results, []);
54
- });
55
-
56
- test("get throws for missing config", async () => {
57
- await assert.rejects(repo.get(randomId()), /not found/i);
58
- });
59
-
60
- test("describe assembles collection (accountConfig + account + address)", async () => {
61
- const userId = randomId();
62
- const cfg = await repo.create({ userId });
63
-
64
- const repos = createSqliteRepositories({ app: db, mail: db, search: db });
65
- const accountRepo = repos.account;
66
- const addrRepo = repos.address;
67
-
68
- await accountRepo.create({
69
- accountConfigId: cfg.accountConfigId,
70
- username: "u",
71
- email: "u@test.com",
72
- isActive: true,
73
- imapHost: "imap.test.com",
74
- imapPort: 993,
75
- imapTls: true,
76
- imapStartTls: false,
77
- connectionState: "not_authenticated",
78
- });
79
-
80
- await addrRepo.createAddress({
81
- addressId: randomId(),
82
- accountConfigId: cfg.accountConfigId,
83
- localPart: "u",
84
- domain: "test.com",
85
- normalizedEmail: "u@test.com",
86
- normalizedCompound: "u@test.com:u",
87
- });
88
-
89
- const desc = await repo.describe(cfg.accountConfigId);
90
- assert.equal(desc.accountConfig.length, 1);
91
- assert.equal(desc.account.length, 1);
92
- assert.equal(desc.address.length, 1);
93
-
94
- await repo.delete(cfg.accountConfigId);
95
- });
96
-
97
- test("listAll returns all configs", async () => {
98
- const userId = randomId();
99
- const c1 = await repo.create({ userId });
100
- const c2 = await repo.create({ userId });
101
-
102
- const all = await repo.listAll();
103
- const ids = new Set(all.map((c) => c.accountConfigId));
104
- assert.ok(ids.has(c1.accountConfigId));
105
- assert.ok(ids.has(c2.accountConfigId));
106
-
107
- await repo.deleteMany([c1.accountConfigId, c2.accountConfigId]);
108
- });
109
-
110
- describe("continuation token rejection (#172)", () => {
111
- for (const [label, token] of [
112
- ["an unparseable", "not-a-cursor"],
113
- ["a bare number", Buffer.from("123").toString("base64url")],
114
- ["a JSON array", Buffer.from("[1,2]").toString("base64url")],
115
- ] as const) {
116
- test(`${label} token is rejected as a 400`, async () => {
117
- await assert.rejects(
118
- () => repo.listByUser(randomId(), { continuationToken: token }),
119
- (error: unknown) => {
120
- assert.equal((error as { statusCode?: number }).statusCode, 400);
121
- assert.equal((error as Error).name, "BadRequestError");
122
- return true;
123
- },
124
- );
125
- });
126
- }
127
- });
128
- });
4
+ accountConfigRepoSuite(openSqliteTestStores);
@@ -0,0 +1,4 @@
1
+ import { openD1TestStores } from "../test-d1.js";
2
+ import { accountExportRequestRepoSuite } from "./i4-account-export-request.suite.js";
3
+
4
+ accountExportRequestRepoSuite(openD1TestStores);
@@ -0,0 +1,44 @@
1
+ import assert from "node:assert/strict";
2
+ import { after, before, describe, test } from "node:test";
3
+ import { randomId } from "../id.js";
4
+ import type { OpenTestStores } from "../test-stores.js";
5
+ import { AccountExportRequestRepo } from "./i4-account-export-request.js";
6
+
7
+ export const accountExportRequestRepoSuite = (open: OpenTestStores): void => {
8
+ describe("AccountExportRequestRepo", () => {
9
+ let close: () => Promise<void>;
10
+ let repo: AccountExportRequestRepo;
11
+
12
+ before(async () => {
13
+ const opened = await open();
14
+ close = opened.close;
15
+ repo = new AccountExportRequestRepo(opened.stores.app.db);
16
+ });
17
+
18
+ after(async () => {
19
+ await close();
20
+ });
21
+
22
+ describe("continuation token rejection (#172)", () => {
23
+ for (const [label, token] of [
24
+ ["an unparseable", "not-a-cursor"],
25
+ ["a bare number", Buffer.from("123").toString("base64url")],
26
+ ["a JSON array", Buffer.from("[1,2]").toString("base64url")],
27
+ ] as const) {
28
+ test(`${label} token is rejected as a 400`, async () => {
29
+ await assert.rejects(
30
+ () =>
31
+ repo.listByAccountConfig(randomId(), {
32
+ continuationToken: token,
33
+ }),
34
+ (error: unknown) => {
35
+ assert.equal((error as { statusCode?: number }).statusCode, 400);
36
+ assert.equal((error as Error).name, "BadRequestError");
37
+ return true;
38
+ },
39
+ );
40
+ });
41
+ }
42
+ });
43
+ });
44
+ };
@@ -1,41 +1,4 @@
1
- import assert from "node:assert/strict";
2
- import { after, before, describe, test } from "node:test";
3
- import { createTestDb, randomId, type TestDb } from "../test-db.js";
4
- import { AccountExportRequestRepo } from "./i4-account-export-request.js";
1
+ import { openSqliteTestStores } from "../test-stores.js";
2
+ import { accountExportRequestRepoSuite } from "./i4-account-export-request.suite.js";
5
3
 
6
- describe("AccountExportRequestRepo", () => {
7
- let db: TestDb;
8
- let close: () => Promise<void>;
9
- let repo: AccountExportRequestRepo;
10
-
11
- before(async () => {
12
- ({ db, close } = await createTestDb());
13
- repo = new AccountExportRequestRepo(db as never);
14
- });
15
-
16
- after(async () => {
17
- await close();
18
- });
19
-
20
- describe("continuation token rejection (#172)", () => {
21
- for (const [label, token] of [
22
- ["an unparseable", "not-a-cursor"],
23
- ["a bare number", Buffer.from("123").toString("base64url")],
24
- ["a JSON array", Buffer.from("[1,2]").toString("base64url")],
25
- ] as const) {
26
- test(`${label} token is rejected as a 400`, async () => {
27
- await assert.rejects(
28
- () =>
29
- repo.listByAccountConfig(randomId(), {
30
- continuationToken: token,
31
- }),
32
- (error: unknown) => {
33
- assert.equal((error as { statusCode?: number }).statusCode, 400);
34
- assert.equal((error as Error).name, "BadRequestError");
35
- return true;
36
- },
37
- );
38
- });
39
- }
40
- });
41
- });
4
+ accountExportRequestRepoSuite(openSqliteTestStores);
@@ -0,0 +1,4 @@
1
+ import { openD1TestStores } from "../test-d1.js";
2
+ import { accountSettingRepoSuite } from "./i4-account-setting.suite.js";
3
+
4
+ accountSettingRepoSuite(openD1TestStores);
@@ -0,0 +1,100 @@
1
+ import assert from "node:assert";
2
+ import { after, before, describe, test } from "node:test";
3
+ import { randomId } from "../id.js";
4
+ import type { OpenTestStores } from "../test-stores.js";
5
+ import { AccountSettingRepo } from "./i4-account-setting.js";
6
+
7
+ export const accountSettingRepoSuite = (open: OpenTestStores): void => {
8
+ describe("AccountSettingRepo", () => {
9
+ let close: () => Promise<void>;
10
+ let repo: AccountSettingRepo;
11
+
12
+ before(async () => {
13
+ const opened = await open();
14
+ close = opened.close;
15
+ repo = new AccountSettingRepo(opened.stores.app.db);
16
+ });
17
+
18
+ after(async () => {
19
+ await close();
20
+ });
21
+
22
+ test("upsert and get", async () => {
23
+ const accountConfigId = randomId();
24
+ await repo.upsert({
25
+ accountConfigId,
26
+ name: "Theme",
27
+ value: { kind: "String", value: "dark" },
28
+ });
29
+
30
+ const setting = await repo.get(accountConfigId, "Theme");
31
+ assert.ok(setting);
32
+ assert.equal(setting.name, "Theme");
33
+ assert.deepEqual(setting.value, { kind: "String", value: "dark" });
34
+
35
+ await repo.delete(accountConfigId, "Theme");
36
+ });
37
+
38
+ test("upsert is idempotent (overwrites)", async () => {
39
+ const accountConfigId = randomId();
40
+ await repo.upsert({
41
+ accountConfigId,
42
+ name: "Density",
43
+ value: { kind: "String", value: "compact" },
44
+ });
45
+ await repo.upsert({
46
+ accountConfigId,
47
+ name: "Density",
48
+ value: { kind: "String", value: "comfortable" },
49
+ });
50
+
51
+ const setting = await repo.get(accountConfigId, "Density");
52
+ assert.deepEqual(setting?.value, {
53
+ kind: "String",
54
+ value: "comfortable",
55
+ });
56
+
57
+ await repo.delete(accountConfigId, "Density");
58
+ });
59
+
60
+ test("get returns null when setting absent", async () => {
61
+ const setting = await repo.get(randomId(), "Theme");
62
+ assert.equal(setting, null);
63
+ });
64
+
65
+ test("listByAccountConfig returns all settings ordered by name", async () => {
66
+ const accountConfigId = randomId();
67
+ await repo.upsert({
68
+ accountConfigId,
69
+ name: "Theme",
70
+ value: { kind: "String", value: "dark" },
71
+ });
72
+ await repo.upsert({
73
+ accountConfigId,
74
+ name: "Density",
75
+ value: { kind: "String", value: "compact" },
76
+ });
77
+
78
+ const settings = await repo.listByAccountConfig(accountConfigId);
79
+ assert.equal(settings.length, 2);
80
+ assert.equal(settings[0].name, "Density");
81
+ assert.equal(settings[1].name, "Theme");
82
+
83
+ await repo.delete(accountConfigId, "Theme");
84
+ await repo.delete(accountConfigId, "Density");
85
+ });
86
+
87
+ test("delete removes the setting", async () => {
88
+ const accountConfigId = randomId();
89
+ await repo.upsert({
90
+ accountConfigId,
91
+ name: "Theme",
92
+ value: { kind: "Boolean", value: true },
93
+ });
94
+ await repo.delete(accountConfigId, "Theme");
95
+
96
+ const setting = await repo.get(accountConfigId, "Theme");
97
+ assert.equal(setting, null);
98
+ });
99
+ });
100
+ };
@@ -1,94 +1,4 @@
1
- import assert from "node:assert";
2
- import { after, before, describe, test } from "node:test";
3
- import { createTestDb, randomId, type TestDb } from "../test-db.js";
4
- import { AccountSettingRepo } from "./i4-account-setting.js";
1
+ import { openSqliteTestStores } from "../test-stores.js";
2
+ import { accountSettingRepoSuite } from "./i4-account-setting.suite.js";
5
3
 
6
- describe("AccountSettingRepo", () => {
7
- let db: TestDb;
8
- let close: () => Promise<void>;
9
- let repo: AccountSettingRepo;
10
-
11
- before(async () => {
12
- ({ db, close } = await createTestDb());
13
- repo = new AccountSettingRepo(db as never);
14
- });
15
-
16
- after(async () => {
17
- await close();
18
- });
19
-
20
- test("upsert and get", async () => {
21
- const accountConfigId = randomId();
22
- await repo.upsert({
23
- accountConfigId,
24
- name: "Theme",
25
- value: { kind: "String", value: "dark" },
26
- });
27
-
28
- const setting = await repo.get(accountConfigId, "Theme");
29
- assert.ok(setting);
30
- assert.equal(setting.name, "Theme");
31
- assert.deepEqual(setting.value, { kind: "String", value: "dark" });
32
-
33
- await repo.delete(accountConfigId, "Theme");
34
- });
35
-
36
- test("upsert is idempotent (overwrites)", async () => {
37
- const accountConfigId = randomId();
38
- await repo.upsert({
39
- accountConfigId,
40
- name: "Density",
41
- value: { kind: "String", value: "compact" },
42
- });
43
- await repo.upsert({
44
- accountConfigId,
45
- name: "Density",
46
- value: { kind: "String", value: "comfortable" },
47
- });
48
-
49
- const setting = await repo.get(accountConfigId, "Density");
50
- assert.deepEqual(setting?.value, { kind: "String", value: "comfortable" });
51
-
52
- await repo.delete(accountConfigId, "Density");
53
- });
54
-
55
- test("get returns null when setting absent", async () => {
56
- const setting = await repo.get(randomId(), "Theme");
57
- assert.equal(setting, null);
58
- });
59
-
60
- test("listByAccountConfig returns all settings ordered by name", async () => {
61
- const accountConfigId = randomId();
62
- await repo.upsert({
63
- accountConfigId,
64
- name: "Theme",
65
- value: { kind: "String", value: "dark" },
66
- });
67
- await repo.upsert({
68
- accountConfigId,
69
- name: "Density",
70
- value: { kind: "String", value: "compact" },
71
- });
72
-
73
- const settings = await repo.listByAccountConfig(accountConfigId);
74
- assert.equal(settings.length, 2);
75
- assert.equal(settings[0].name, "Density");
76
- assert.equal(settings[1].name, "Theme");
77
-
78
- await repo.delete(accountConfigId, "Theme");
79
- await repo.delete(accountConfigId, "Density");
80
- });
81
-
82
- test("delete removes the setting", async () => {
83
- const accountConfigId = randomId();
84
- await repo.upsert({
85
- accountConfigId,
86
- name: "Theme",
87
- value: { kind: "Boolean", value: true },
88
- });
89
- await repo.delete(accountConfigId, "Theme");
90
-
91
- const setting = await repo.get(accountConfigId, "Theme");
92
- assert.equal(setting, null);
93
- });
94
- });
4
+ accountSettingRepoSuite(openSqliteTestStores);
@@ -1,5 +1,6 @@
1
1
  import assert from "node:assert";
2
2
  import { after, before, describe, test } from "node:test";
3
+ import { BETTER_SQLITE3_LIMITS } from "../bound-parameters.js";
3
4
  import { createSqliteRepositories } from "../sqlite-repositories.js";
4
5
  import { createTestDb, randomId, type TestDb } from "../test-db.js";
5
6
  import type { AccountRepo } from "./i4-account.js";
@@ -26,11 +27,14 @@ describe("AccountRepo", () => {
26
27
 
27
28
  before(async () => {
28
29
  ({ db, close } = await createTestDb());
29
- repo = createSqliteRepositories({
30
- app: db,
31
- mail: db,
32
- search: db,
33
- }).account;
30
+ repo = createSqliteRepositories(
31
+ {
32
+ app: db,
33
+ mail: db,
34
+ search: db,
35
+ },
36
+ BETTER_SQLITE3_LIMITS,
37
+ ).account;
34
38
  });
35
39
 
36
40
  after(async () => {
@@ -164,11 +168,14 @@ describe("AccountRepo", () => {
164
168
  const accountConfigId = randomId();
165
169
  const account = await repo.create(makeAccountInput(accountConfigId));
166
170
 
167
- const mailboxRepo = createSqliteRepositories({
168
- app: db,
169
- mail: db,
170
- search: db,
171
- }).mailbox;
171
+ const mailboxRepo = createSqliteRepositories(
172
+ {
173
+ app: db,
174
+ mail: db,
175
+ search: db,
176
+ },
177
+ BETTER_SQLITE3_LIMITS,
178
+ ).mailbox;
172
179
  mailboxCreated(
173
180
  await mailboxRepo.create({
174
181
  accountId: account.accountId,
@@ -1,6 +1,7 @@
1
1
  import assert from "node:assert/strict";
2
2
  import { after, before, beforeEach, describe, test } from "node:test";
3
3
  import type Database from "better-sqlite3";
4
+ import { BETTER_SQLITE3_LIMITS } from "../bound-parameters.js";
4
5
  import { createSqliteRepositories } from "../sqlite-repositories.js";
5
6
  import { createTestDb, type TestDb } from "../test-db.js";
6
7
  import { AddressRepo } from "./i4-address.js";
@@ -125,11 +126,14 @@ describe("reconciling one message's addresses at the moment it moves", () => {
125
126
  before(async () => {
126
127
  ({ db, sqlite, close } = await createTestDb());
127
128
  repo = new AddressRepo(db as never);
128
- specialUse = createSqliteRepositories({
129
- app: db,
130
- mail: db,
131
- search: db,
132
- }).mailboxSpecialUse;
129
+ specialUse = createSqliteRepositories(
130
+ {
131
+ app: db,
132
+ mail: db,
133
+ search: db,
134
+ },
135
+ BETTER_SQLITE3_LIMITS,
136
+ ).mailboxSpecialUse;
133
137
  });
134
138
 
135
139
  /**
@@ -6,6 +6,7 @@ import {
6
6
  meetsTrashAssurance,
7
7
  } from "@remit/data-ports/folder-role";
8
8
  import { CanonicalMailboxRole } from "@remit/domain-enums";
9
+ import { BETTER_SQLITE3_LIMITS } from "../bound-parameters.js";
9
10
  import {
10
11
  accountSettingTable,
11
12
  accountTable,
@@ -57,11 +58,14 @@ describe("MailboxSpecialUseRepo role lookups (sqlite)", () => {
57
58
  });
58
59
  close = testDb.close;
59
60
  db = testDb.db;
60
- const repos = createSqliteRepositories({
61
- app: testDb.db,
62
- mail: testDb.db,
63
- search: testDb.db,
64
- });
61
+ const repos = createSqliteRepositories(
62
+ {
63
+ app: testDb.db,
64
+ mail: testDb.db,
65
+ search: testDb.db,
66
+ },
67
+ BETTER_SQLITE3_LIMITS,
68
+ );
65
69
  repo = repos.mailboxSpecialUse;
66
70
  mailboxes = repos.mailbox;
67
71
  accountSettings = repos.accountSetting;
@@ -4,6 +4,7 @@ import { after, before, describe, test } from "node:test";
4
4
  import { MailboxSyncStatus } from "@remit/domain-enums";
5
5
  import Database from "better-sqlite3";
6
6
  import { drizzle } from "drizzle-orm/better-sqlite3";
7
+ import { BETTER_SQLITE3_LIMITS } from "../bound-parameters.js";
7
8
  import { mailboxTable } from "../schema.js";
8
9
  import { createSqliteRepositories } from "../sqlite-repositories.js";
9
10
  import { createSqliteTestDb } from "../test-db-sqlite.js";
@@ -41,11 +42,14 @@ describe("MailboxRepo (sqlite)", () => {
41
42
  before(async () => {
42
43
  const testDb = await createSqliteTestDb({ mailbox: mailboxTable });
43
44
  close = testDb.close;
44
- repo = createSqliteRepositories({
45
- app: testDb.db,
46
- mail: testDb.db,
47
- search: testDb.db,
48
- }).mailbox;
45
+ repo = createSqliteRepositories(
46
+ {
47
+ app: testDb.db,
48
+ mail: testDb.db,
49
+ search: testDb.db,
50
+ },
51
+ BETTER_SQLITE3_LIMITS,
52
+ ).mailbox;
49
53
  });
50
54
 
51
55
  after(async () => {
@@ -211,11 +215,14 @@ describe("MailboxRepo (sqlite, shipped migrations)", () => {
211
215
  const sqlite = new Database(":memory:");
212
216
  applyMigrationSet(sqlite, "mail");
213
217
  const db = drizzle(sqlite, { schema: { mailbox: mailboxTable } });
214
- repo = createSqliteRepositories({
215
- app: db,
216
- mail: db,
217
- search: db,
218
- }).mailbox;
218
+ repo = createSqliteRepositories(
219
+ {
220
+ app: db,
221
+ mail: db,
222
+ search: db,
223
+ },
224
+ BETTER_SQLITE3_LIMITS,
225
+ ).mailbox;
219
226
  close = async () => {
220
227
  sqlite.close();
221
228
  };
@@ -3,6 +3,7 @@ import { after, before, describe, test } from "node:test";
3
3
  import { MailboxSyncStatus } from "@remit/domain-enums";
4
4
  import { eq } from "drizzle-orm";
5
5
  import { syncBatch } from "../batch.js";
6
+ import { BETTER_SQLITE3_LIMITS } from "../bound-parameters.js";
6
7
  import {
7
8
  envelopeId as deriveEnvelopeId,
8
9
  rootBodyPartId as deriveRootBodyPartId,
@@ -54,11 +55,14 @@ describe("MailboxRepo", () => {
54
55
 
55
56
  before(async () => {
56
57
  ({ db, close } = await createTestDb());
57
- repo = createSqliteRepositories({
58
- app: db,
59
- mail: db,
60
- search: db,
61
- }).mailbox;
58
+ repo = createSqliteRepositories(
59
+ {
60
+ app: db,
61
+ mail: db,
62
+ search: db,
63
+ },
64
+ BETTER_SQLITE3_LIMITS,
65
+ ).mailbox;
62
66
  });
63
67
 
64
68
  after(async () => {
@@ -543,11 +547,14 @@ describe("MailboxRepo", () => {
543
547
  describe("deleteMailboxWithMail — the folder's mail goes with it (D8)", () => {
544
548
  const seedMessage = async (mailboxId: string, uid: number) => {
545
549
  const messageId = randomId();
546
- await createSqliteRepositories({
547
- app: db,
548
- mail: db,
549
- search: db,
550
- }).message.create({
550
+ await createSqliteRepositories(
551
+ {
552
+ app: db,
553
+ mail: db,
554
+ search: db,
555
+ },
556
+ BETTER_SQLITE3_LIMITS,
557
+ ).message.create({
551
558
  messageId,
552
559
  mailboxId,
553
560
  uid,
@@ -1,5 +1,6 @@
1
1
  import assert from "node:assert";
2
2
  import { after, before, describe, test } from "node:test";
3
+ import { BETTER_SQLITE3_LIMITS } from "../bound-parameters.js";
3
4
  import { createSqliteRepositories } from "../sqlite-repositories.js";
4
5
  import { createTestDb, randomId } from "../test-db.js";
5
6
  import type { OutboxAttachmentRepo } from "./i4-outbox-attachment.js";
@@ -28,11 +29,14 @@ const input = (
28
29
 
29
30
  before(async () => {
30
31
  harness = await createTestDb();
31
- repo = createSqliteRepositories({
32
- app: harness.db,
33
- mail: harness.db,
34
- search: harness.db,
35
- }).outboxAttachment;
32
+ repo = createSqliteRepositories(
33
+ {
34
+ app: harness.db,
35
+ mail: harness.db,
36
+ search: harness.db,
37
+ },
38
+ BETTER_SQLITE3_LIMITS,
39
+ ).outboxAttachment;
36
40
  });
37
41
 
38
42
  after(async () => {
@@ -0,0 +1,20 @@
1
+ import { labelRepositoryConformance } from "@remit/data-ports/conformance";
2
+ import { NotFoundError } from "../error.js";
3
+ import { randomId } from "../id.js";
4
+ import { openD1TestStores } from "../test-d1.js";
5
+ import { LabelRepo } from "./label.js";
6
+
7
+ let close: (() => Promise<void>) | undefined;
8
+
9
+ labelRepositoryConformance({
10
+ async createRepository() {
11
+ const opened = await openD1TestStores();
12
+ close = opened.close;
13
+ return new LabelRepo(opened.stores.app.db);
14
+ },
15
+ teardown: async () => {
16
+ await close?.();
17
+ },
18
+ makeId: () => randomId(),
19
+ isNotFoundError: (error) => error instanceof NotFoundError,
20
+ });