@remit/drizzle-service 0.0.90 → 0.0.92

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.90",
3
+ "version": "0.0.92",
4
4
  "description": "Drizzle ORM service over SQLite",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -28,6 +28,11 @@ function rowToCalendar(
28
28
  source: row.source,
29
29
  timezone: row.timezone,
30
30
  syncSequence: row.syncSequence,
31
+ subscriptionUrl: row.subscriptionUrl,
32
+ subscriptionEnabled: row.subscriptionEnabled,
33
+ subscriptionCheckedAt: row.subscriptionCheckedAt,
34
+ subscriptionFetchedAt: row.subscriptionFetchedAt,
35
+ subscriptionError: row.subscriptionError,
31
36
  createdAt: row.createdAt,
32
37
  updatedAt: row.updatedAt,
33
38
  };
@@ -60,6 +65,8 @@ export class CalendarCollectionRepo implements ICalendarCollectionRepository {
60
65
  componentSet: input.componentSet ?? "VeventOnly",
61
66
  source: input.source ?? "UserCreated",
62
67
  timezone: input.timezone ?? "",
68
+ subscriptionUrl: input.subscriptionUrl ?? "",
69
+ subscriptionEnabled: input.subscriptionEnabled ?? false,
63
70
  syncSequence: 0,
64
71
  createdAt: now,
65
72
  updatedAt: now,
@@ -94,6 +101,8 @@ export class CalendarCollectionRepo implements ICalendarCollectionRepository {
94
101
  componentSet: input.componentSet ?? "VeventOnly",
95
102
  source: input.source ?? "UserCreated",
96
103
  timezone: input.timezone ?? "",
104
+ subscriptionUrl: input.subscriptionUrl ?? "",
105
+ subscriptionEnabled: input.subscriptionEnabled ?? false,
97
106
  syncSequence: 0,
98
107
  createdAt: now,
99
108
  updatedAt: now,
@@ -165,6 +174,20 @@ export class CalendarCollectionRepo implements ICalendarCollectionRepository {
165
174
  return rows.map(rowToCalendar);
166
175
  }
167
176
 
177
+ async listEnabledSubscriptions(): Promise<CalendarCollectionItem[]> {
178
+ const rows = await this.db
179
+ .select()
180
+ .from(calendarTable)
181
+ .where(
182
+ and(
183
+ eq(calendarTable.source, "Subscribed"),
184
+ eq(calendarTable.subscriptionEnabled, true),
185
+ ),
186
+ )
187
+ .orderBy(asc(calendarTable.calendarId));
188
+ return rows.map(rowToCalendar);
189
+ }
190
+
168
191
  async findByUrlSegment(
169
192
  accountConfigId: string,
170
193
  urlSegment: string,
@@ -8,7 +8,7 @@ import type {
8
8
  UpdateAccountInput,
9
9
  } from "@remit/data-ports";
10
10
  import { AccountService, SyncPhase } from "@remit/domain-enums";
11
- import { and, asc, eq, gt, inArray, or, sql } from "drizzle-orm";
11
+ import { and, asc, eq, gt, inArray, like, or, sql } from "drizzle-orm";
12
12
  import type { Db } from "../db.js";
13
13
  import { NotFoundError } from "../error.js";
14
14
  import { randomId } from "../id.js";
@@ -291,6 +291,21 @@ export class AccountRepo implements IAccountRepository {
291
291
  return rows.map(rowToAccount);
292
292
  }
293
293
 
294
+ async listMailSourcesByAccountConfig(
295
+ accountConfigId: string,
296
+ ): Promise<AccountItem[]> {
297
+ const rows = await this.db
298
+ .select()
299
+ .from(accountTable)
300
+ .where(
301
+ and(
302
+ eq(accountTable.accountConfigId, accountConfigId),
303
+ like(accountTable.syncedServices, `%"${AccountService.Mail}"%`),
304
+ ),
305
+ );
306
+ return rows.map(rowToAccount);
307
+ }
308
+
294
309
  async describe(accountId: string): Promise<AccountDescription> {
295
310
  const [accounts, mailboxes] = await Promise.all([
296
311
  this.db