@remit/drizzle-service 0.0.93 → 0.0.94

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.93",
3
+ "version": "0.0.94",
4
4
  "description": "Drizzle ORM service over SQLite",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -37,6 +37,7 @@ function rowToCalendarSuggestion(
37
37
  zoneCertainty: row.zoneCertainty,
38
38
  icalData: row.icalData,
39
39
  acceptedCalendarObjectId: row.acceptedCalendarObjectId,
40
+ supersededByMessageId: row.supersededByMessageId,
40
41
  createdAt: row.createdAt,
41
42
  updatedAt: row.updatedAt,
42
43
  };
@@ -61,6 +62,7 @@ export class CalendarSuggestionRepo implements ICalendarSuggestionRepository {
61
62
  suggestionId,
62
63
  state: CalendarSuggestionState.Pending,
63
64
  acceptedCalendarObjectId: "",
65
+ supersededByMessageId: "",
64
66
  createdAt: now,
65
67
  updatedAt: now,
66
68
  })
@@ -200,12 +202,14 @@ export class CalendarSuggestionRepo implements ICalendarSuggestionRepository {
200
202
  async supersedeIfPending(
201
203
  accountConfigId: string,
202
204
  suggestionId: string,
205
+ supersededByMessageId: string,
203
206
  ): Promise<CalendarSuggestionItem | null> {
204
207
  const [row] = await this.db
205
208
  .update(calendarSuggestionTable)
206
209
  .set({
207
210
  state: CalendarSuggestionState.Superseded,
208
211
  acceptedCalendarObjectId: "",
212
+ supersededByMessageId,
209
213
  updatedAt: Date.now(),
210
214
  })
211
215
  .where(
@@ -220,4 +224,23 @@ export class CalendarSuggestionRepo implements ICalendarSuggestionRepository {
220
224
  .returning();
221
225
  return row ? rowToCalendarSuggestion(row) : null;
222
226
  }
227
+
228
+ async repointSuperseded(
229
+ accountConfigId: string,
230
+ suggestionId: string,
231
+ supersededByMessageId: string,
232
+ ): Promise<CalendarSuggestionItem | null> {
233
+ const [row] = await this.db
234
+ .update(calendarSuggestionTable)
235
+ .set({ supersededByMessageId, updatedAt: Date.now() })
236
+ .where(
237
+ and(
238
+ eq(calendarSuggestionTable.accountConfigId, accountConfigId),
239
+ eq(calendarSuggestionTable.suggestionId, suggestionId),
240
+ eq(calendarSuggestionTable.state, CalendarSuggestionState.Superseded),
241
+ ),
242
+ )
243
+ .returning();
244
+ return row ? rowToCalendarSuggestion(row) : null;
245
+ }
223
246
  }