@remit/drizzle-service 0.0.94 → 0.0.96
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
|
@@ -35,6 +35,16 @@ const filterAtDedupe = sqliteTable("filter", {
|
|
|
35
35
|
updatedAt: integer("updated_at").notNull(),
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
+
const organizeJobAtDedupe = sqliteTable("organize_job_request", {
|
|
39
|
+
organizeJobId: text("organize_job_id").primaryKey(),
|
|
40
|
+
accountConfigId: text("account_config_id").notNull(),
|
|
41
|
+
userId: text("user_id").notNull(),
|
|
42
|
+
actionMailboxId: text("action_mailbox_id").notNull(),
|
|
43
|
+
ttl: integer("ttl").notNull(),
|
|
44
|
+
createdAt: integer("created_at").notNull(),
|
|
45
|
+
updatedAt: integer("updated_at").notNull(),
|
|
46
|
+
});
|
|
47
|
+
|
|
38
48
|
type Handle = { sqlite: Database.Database; db: Db<Record<string, unknown>> };
|
|
39
49
|
|
|
40
50
|
const atPredecessor = (): Handle => {
|
|
@@ -229,7 +239,7 @@ describe("(account_id, full_path) becomes unique", () => {
|
|
|
229
239
|
createdAt: 0,
|
|
230
240
|
updatedAt: 0,
|
|
231
241
|
});
|
|
232
|
-
await handle.db.insert(
|
|
242
|
+
await handle.db.insert(organizeJobAtDedupe).values({
|
|
233
243
|
organizeJobId: "job-1",
|
|
234
244
|
accountConfigId: CONFIG,
|
|
235
245
|
userId: "user",
|
|
@@ -272,7 +282,7 @@ describe("(account_id, full_path) becomes unique", () => {
|
|
|
272
282
|
assert.equal(child?.parent, "with-mail");
|
|
273
283
|
const [filter] = await handle.db.select().from(filterAtDedupe);
|
|
274
284
|
assert.equal(filter?.actionMailboxId, "with-mail");
|
|
275
|
-
const [job] = await handle.db.select().from(
|
|
285
|
+
const [job] = await handle.db.select().from(organizeJobAtDedupe);
|
|
276
286
|
assert.equal(job?.actionMailboxId, "with-mail");
|
|
277
287
|
const [copied] = await handle.db
|
|
278
288
|
.select({ original: entities.messages.originalMailboxId })
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
PutCalendarObjectInput,
|
|
5
5
|
} from "@remit/data-ports";
|
|
6
6
|
import { deriveCalendarObjectId } from "@remit/data-ports/id";
|
|
7
|
-
import { and, asc, eq, gt, lt, ne } from "drizzle-orm";
|
|
7
|
+
import { and, asc, eq, gt, gte, lt, ne } from "drizzle-orm";
|
|
8
8
|
import type { Db } from "../db.js";
|
|
9
9
|
import { NotFoundError } from "../error.js";
|
|
10
10
|
import { calendarObjectTable } from "../schema.js";
|
|
@@ -146,6 +146,23 @@ export class CalendarObjectRepo implements ICalendarObjectRepository {
|
|
|
146
146
|
return row ? rowToCalendarObject(row) : null;
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
+
async listByUidPrefix(
|
|
150
|
+
calendarId: string,
|
|
151
|
+
prefix: string,
|
|
152
|
+
): Promise<CalendarObjectItem[]> {
|
|
153
|
+
const rows = await this.db
|
|
154
|
+
.select()
|
|
155
|
+
.from(calendarObjectTable)
|
|
156
|
+
.where(
|
|
157
|
+
and(
|
|
158
|
+
eq(calendarObjectTable.calendarId, calendarId),
|
|
159
|
+
gte(calendarObjectTable.icalUid, prefix),
|
|
160
|
+
lt(calendarObjectTable.icalUid, `${prefix}\uffff`),
|
|
161
|
+
),
|
|
162
|
+
);
|
|
163
|
+
return rows.map(rowToCalendarObject);
|
|
164
|
+
}
|
|
165
|
+
|
|
149
166
|
async listByCalendar(calendarId: string): Promise<CalendarObjectItem[]> {
|
|
150
167
|
const rows = await this.db
|
|
151
168
|
.select()
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
} from "@remit/data-ports";
|
|
8
8
|
import { deriveCalendarSuggestionId } from "@remit/data-ports/id";
|
|
9
9
|
import { CalendarSuggestionState } from "@remit/domain-enums";
|
|
10
|
-
import { and, asc, desc, eq, lt, or } from "drizzle-orm";
|
|
10
|
+
import { and, asc, desc, eq, inArray, lt, or } from "drizzle-orm";
|
|
11
11
|
import type { Db } from "../db.js";
|
|
12
12
|
import { NotFoundError } from "../error.js";
|
|
13
13
|
import { decodeToken, resultList } from "../pagination.js";
|
|
@@ -99,6 +99,26 @@ export class CalendarSuggestionRepo implements ICalendarSuggestionRepository {
|
|
|
99
99
|
return rowToCalendarSuggestion(row);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
async listByAcceptedCalendarObjects(
|
|
103
|
+
accountConfigId: string,
|
|
104
|
+
calendarObjectIds: string[],
|
|
105
|
+
): Promise<CalendarSuggestionItem[]> {
|
|
106
|
+
if (calendarObjectIds.length === 0) return [];
|
|
107
|
+
const rows = await this.db
|
|
108
|
+
.select()
|
|
109
|
+
.from(calendarSuggestionTable)
|
|
110
|
+
.where(
|
|
111
|
+
and(
|
|
112
|
+
eq(calendarSuggestionTable.accountConfigId, accountConfigId),
|
|
113
|
+
inArray(
|
|
114
|
+
calendarSuggestionTable.acceptedCalendarObjectId,
|
|
115
|
+
calendarObjectIds,
|
|
116
|
+
),
|
|
117
|
+
),
|
|
118
|
+
);
|
|
119
|
+
return rows.map(rowToCalendarSuggestion);
|
|
120
|
+
}
|
|
121
|
+
|
|
102
122
|
async listByMessage(
|
|
103
123
|
accountConfigId: string,
|
|
104
124
|
messageId: string,
|
|
@@ -22,6 +22,7 @@ function rowToItem(
|
|
|
22
22
|
accountConfigId: row.accountConfigId,
|
|
23
23
|
userId: row.userId,
|
|
24
24
|
state: row.state as OrganizeJobRequestItem["state"],
|
|
25
|
+
filterId: row.filterId,
|
|
25
26
|
anchorMessageId: row.anchorMessageId,
|
|
26
27
|
matchOperator: row.matchOperator as OrganizeJobRequestItem["matchOperator"],
|
|
27
28
|
literalClauses:
|
|
@@ -53,6 +54,7 @@ export class OrganizeJobRequestRepo implements IOrganizeJobRequestRepository {
|
|
|
53
54
|
accountConfigId: input.accountConfigId,
|
|
54
55
|
userId: input.userId,
|
|
55
56
|
state: input.state ?? "Pending",
|
|
57
|
+
filterId: input.filterId,
|
|
56
58
|
anchorMessageId: input.anchorMessageId,
|
|
57
59
|
matchOperator: input.matchOperator,
|
|
58
60
|
literalClauses: input.literalClauses,
|
|
@@ -664,6 +664,7 @@ export class DrizzleThreadMessageRepository
|
|
|
664
664
|
limit?: number;
|
|
665
665
|
continuationToken?: string;
|
|
666
666
|
excludeDeleted?: boolean;
|
|
667
|
+
mailboxIds?: readonly string[];
|
|
667
668
|
},
|
|
668
669
|
): Promise<ResultList<ThreadMessageItem>> {
|
|
669
670
|
const order = options?.order ?? "desc";
|
|
@@ -681,6 +682,9 @@ export class DrizzleThreadMessageRepository
|
|
|
681
682
|
options?.excludeDeleted
|
|
682
683
|
? eq(threadMessageTable.isDeleted, false)
|
|
683
684
|
: undefined,
|
|
685
|
+
options?.mailboxIds
|
|
686
|
+
? inArray(threadMessageTable.mailboxId, [...options.mailboxIds])
|
|
687
|
+
: undefined,
|
|
684
688
|
buildFieldTermCondition(terms, options?.operator ?? "and"),
|
|
685
689
|
sentDateCursorCond(order, cursor),
|
|
686
690
|
),
|