@remit/drizzle-service 0.0.94 → 0.0.95

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/drizzle-service",
3
- "version": "0.0.94",
3
+ "version": "0.0.95",
4
4
  "description": "Drizzle ORM service over SQLite",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -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,