@remit/drizzle-service 0.0.17 → 0.0.19
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/repos/filter.test.ts +22 -0
- package/src/repos/i4-account-config.test.ts +19 -0
- package/src/repos/i4-account-export-request.test.ts +41 -0
- package/src/repos/i4-account.test.ts +30 -0
- package/src/repos/i4-address.test.ts +23 -0
- package/src/repos/i4-mailbox.test.ts +19 -0
- package/src/repos/i4-organize-job-request.test.ts +41 -0
- package/src/repos/i4-outbox-message.test.ts +19 -0
- package/src/repos/message.test.ts +22 -0
- package/src/vps-migrations-drift.sqlite.test.ts +1 -0
package/package.json
CHANGED
package/src/repos/filter.test.ts
CHANGED
|
@@ -276,4 +276,26 @@ describe("FilterRepo", () => {
|
|
|
276
276
|
"every filter is paged exactly once",
|
|
277
277
|
);
|
|
278
278
|
});
|
|
279
|
+
|
|
280
|
+
describe("continuation token rejection (#172)", () => {
|
|
281
|
+
for (const [label, token] of [
|
|
282
|
+
["an unparseable", "not-a-cursor"],
|
|
283
|
+
["a bare number", Buffer.from("123").toString("base64url")],
|
|
284
|
+
["a JSON array", Buffer.from("[1,2]").toString("base64url")],
|
|
285
|
+
] as const) {
|
|
286
|
+
test(`${label} token is rejected as a 400`, async () => {
|
|
287
|
+
await assert.rejects(
|
|
288
|
+
() =>
|
|
289
|
+
repo.listPageByAccountConfig(randomId(), {
|
|
290
|
+
continuationToken: token,
|
|
291
|
+
}),
|
|
292
|
+
(error: unknown) => {
|
|
293
|
+
assert.equal((error as { statusCode?: number }).statusCode, 400);
|
|
294
|
+
assert.equal((error as Error).name, "BadRequestError");
|
|
295
|
+
return true;
|
|
296
|
+
},
|
|
297
|
+
);
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
});
|
|
279
301
|
});
|
|
@@ -102,4 +102,23 @@ describe("AccountConfigRepo", () => {
|
|
|
102
102
|
|
|
103
103
|
await repo.deleteMany([c1.accountConfigId, c2.accountConfigId]);
|
|
104
104
|
});
|
|
105
|
+
|
|
106
|
+
describe("continuation token rejection (#172)", () => {
|
|
107
|
+
for (const [label, token] of [
|
|
108
|
+
["an unparseable", "not-a-cursor"],
|
|
109
|
+
["a bare number", Buffer.from("123").toString("base64url")],
|
|
110
|
+
["a JSON array", Buffer.from("[1,2]").toString("base64url")],
|
|
111
|
+
] as const) {
|
|
112
|
+
test(`${label} token is rejected as a 400`, async () => {
|
|
113
|
+
await assert.rejects(
|
|
114
|
+
() => repo.listByUser(randomId(), { continuationToken: token }),
|
|
115
|
+
(error: unknown) => {
|
|
116
|
+
assert.equal((error as { statusCode?: number }).statusCode, 400);
|
|
117
|
+
assert.equal((error as Error).name, "BadRequestError");
|
|
118
|
+
return true;
|
|
119
|
+
},
|
|
120
|
+
);
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
});
|
|
105
124
|
});
|
|
@@ -0,0 +1,41 @@
|
|
|
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";
|
|
5
|
+
|
|
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
|
+
});
|
|
@@ -220,4 +220,34 @@ describe("AccountRepo", () => {
|
|
|
220
220
|
|
|
221
221
|
await repo.deleteMany(created);
|
|
222
222
|
});
|
|
223
|
+
|
|
224
|
+
describe("continuation token rejection (#172)", () => {
|
|
225
|
+
for (const [label, token] of [
|
|
226
|
+
["an unparseable", "not-a-cursor"],
|
|
227
|
+
["a bare number", Buffer.from("123").toString("base64url")],
|
|
228
|
+
["a JSON array", Buffer.from("[1,2]").toString("base64url")],
|
|
229
|
+
] as const) {
|
|
230
|
+
test(`list() rejects ${label} token as a 400`, async () => {
|
|
231
|
+
await assert.rejects(
|
|
232
|
+
() => repo.list(randomId(), { continuationToken: token }),
|
|
233
|
+
(error: unknown) => {
|
|
234
|
+
assert.equal((error as { statusCode?: number }).statusCode, 400);
|
|
235
|
+
assert.equal((error as Error).name, "BadRequestError");
|
|
236
|
+
return true;
|
|
237
|
+
},
|
|
238
|
+
);
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
test(`listAllAccountsPage() rejects ${label} cursor as a 400`, async () => {
|
|
242
|
+
await assert.rejects(
|
|
243
|
+
() => repo.listAllAccountsPage({ cursor: token }),
|
|
244
|
+
(error: unknown) => {
|
|
245
|
+
assert.equal((error as { statusCode?: number }).statusCode, 400);
|
|
246
|
+
assert.equal((error as Error).name, "BadRequestError");
|
|
247
|
+
return true;
|
|
248
|
+
},
|
|
249
|
+
);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
});
|
|
223
253
|
});
|
|
@@ -406,4 +406,27 @@ describe("AddressRepo", () => {
|
|
|
406
406
|
|
|
407
407
|
await repo.deleteAddress(configB, b.addressId);
|
|
408
408
|
});
|
|
409
|
+
|
|
410
|
+
describe("continuation token rejection (#172)", () => {
|
|
411
|
+
for (const [label, token] of [
|
|
412
|
+
["an unparseable", "not-a-cursor"],
|
|
413
|
+
["a bare number", Buffer.from("123").toString("base64url")],
|
|
414
|
+
["a JSON array", Buffer.from("[1,2]").toString("base64url")],
|
|
415
|
+
] as const) {
|
|
416
|
+
test(`${label} cursor is rejected as a 400`, async () => {
|
|
417
|
+
await assert.rejects(
|
|
418
|
+
() =>
|
|
419
|
+
repo.listByAccountConfig({
|
|
420
|
+
accountConfigId: randomId(),
|
|
421
|
+
cursor: token,
|
|
422
|
+
}),
|
|
423
|
+
(error: unknown) => {
|
|
424
|
+
assert.equal((error as { statusCode?: number }).statusCode, 400);
|
|
425
|
+
assert.equal((error as Error).name, "BadRequestError");
|
|
426
|
+
return true;
|
|
427
|
+
},
|
|
428
|
+
);
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
});
|
|
409
432
|
});
|
|
@@ -208,4 +208,23 @@ describe("MailboxRepo", () => {
|
|
|
208
208
|
|
|
209
209
|
await repo.delete(accountB, b.mailboxId);
|
|
210
210
|
});
|
|
211
|
+
|
|
212
|
+
describe("continuation token rejection (#172)", () => {
|
|
213
|
+
for (const [label, token] of [
|
|
214
|
+
["an unparseable", "not-a-cursor"],
|
|
215
|
+
["a bare number", Buffer.from("123").toString("base64url")],
|
|
216
|
+
["a JSON array", Buffer.from("[1,2]").toString("base64url")],
|
|
217
|
+
] as const) {
|
|
218
|
+
test(`${label} token is rejected as a 400`, async () => {
|
|
219
|
+
await assert.rejects(
|
|
220
|
+
() => repo.listByAccount(randomId(), { continuationToken: token }),
|
|
221
|
+
(error: unknown) => {
|
|
222
|
+
assert.equal((error as { statusCode?: number }).statusCode, 400);
|
|
223
|
+
assert.equal((error as Error).name, "BadRequestError");
|
|
224
|
+
return true;
|
|
225
|
+
},
|
|
226
|
+
);
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
});
|
|
211
230
|
});
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { OrganizeJobRequestRepo } from "./i4-organize-job-request.js";
|
|
5
|
+
|
|
6
|
+
describe("OrganizeJobRequestRepo", () => {
|
|
7
|
+
let db: TestDb;
|
|
8
|
+
let close: () => Promise<void>;
|
|
9
|
+
let repo: OrganizeJobRequestRepo;
|
|
10
|
+
|
|
11
|
+
before(async () => {
|
|
12
|
+
({ db, close } = await createTestDb());
|
|
13
|
+
repo = new OrganizeJobRequestRepo(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
|
+
});
|
|
@@ -295,4 +295,23 @@ describe("OutboxMessageRepo", () => {
|
|
|
295
295
|
|
|
296
296
|
await repo.delete(accountConfigId, msg.outboxMessageId);
|
|
297
297
|
});
|
|
298
|
+
|
|
299
|
+
describe("continuation token rejection (#172)", () => {
|
|
300
|
+
for (const [label, token] of [
|
|
301
|
+
["an unparseable", "not-a-cursor"],
|
|
302
|
+
["a bare number", Buffer.from("123").toString("base64url")],
|
|
303
|
+
["a JSON array", Buffer.from("[1,2]").toString("base64url")],
|
|
304
|
+
] as const) {
|
|
305
|
+
test(`${label} token is rejected as a 400`, async () => {
|
|
306
|
+
await assert.rejects(
|
|
307
|
+
() => repo.listByAccount(randomId(), { continuationToken: token }),
|
|
308
|
+
(error: unknown) => {
|
|
309
|
+
assert.equal((error as { statusCode?: number }).statusCode, 400);
|
|
310
|
+
assert.equal((error as Error).name, "BadRequestError");
|
|
311
|
+
return true;
|
|
312
|
+
},
|
|
313
|
+
);
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
});
|
|
298
317
|
});
|
|
@@ -485,4 +485,26 @@ describe("DrizzleMessageRepository", () => {
|
|
|
485
485
|
await messageRepo.deleteMany([]);
|
|
486
486
|
});
|
|
487
487
|
});
|
|
488
|
+
|
|
489
|
+
describe("continuation token rejection (#172)", () => {
|
|
490
|
+
for (const [label, token] of [
|
|
491
|
+
["an unparseable", "not-a-cursor"],
|
|
492
|
+
["a bare number", Buffer.from("123").toString("base64url")],
|
|
493
|
+
["a JSON array", Buffer.from("[1,2]").toString("base64url")],
|
|
494
|
+
] as const) {
|
|
495
|
+
test(`${label} token is rejected as a 400`, async () => {
|
|
496
|
+
await assert.rejects(
|
|
497
|
+
() =>
|
|
498
|
+
messageRepo.listByMailbox("mailbox-172", {
|
|
499
|
+
continuationToken: token,
|
|
500
|
+
}),
|
|
501
|
+
(error: unknown) => {
|
|
502
|
+
assert.equal((error as { statusCode?: number }).statusCode, 400);
|
|
503
|
+
assert.equal((error as Error).name, "BadRequestError");
|
|
504
|
+
return true;
|
|
505
|
+
},
|
|
506
|
+
);
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
});
|
|
488
510
|
});
|
|
@@ -34,6 +34,7 @@ const REPO_ROOT = new URL("../../../", import.meta.url);
|
|
|
34
34
|
const CONFIGS = [
|
|
35
35
|
"deploy/vps/migrate/drizzle.entities.sqlite.config.ts",
|
|
36
36
|
"deploy/vps/migrate/drizzle.auth.sqlite.config.ts",
|
|
37
|
+
"deploy/vps/migrate/drizzle.meta.sqlite.config.ts",
|
|
37
38
|
];
|
|
38
39
|
|
|
39
40
|
type DrizzleConfig = { schema: string; out: string };
|