@remit/data-ports 0.0.78 → 0.0.79
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
|
@@ -170,6 +170,45 @@ export function calendarObjectRepositoryConformance(
|
|
|
170
170
|
);
|
|
171
171
|
});
|
|
172
172
|
|
|
173
|
+
test("listByUidPrefix finds the resources whose UID starts with the prefix, in one collection", async () => {
|
|
174
|
+
const calendarId = harness.makeId();
|
|
175
|
+
const other = harness.makeId();
|
|
176
|
+
const tail = await repo.put(
|
|
177
|
+
objectInput(calendarId, {
|
|
178
|
+
resourceName: "tail.ics",
|
|
179
|
+
icalUid: "root@example.com/following/1",
|
|
180
|
+
}),
|
|
181
|
+
);
|
|
182
|
+
await repo.put(
|
|
183
|
+
objectInput(calendarId, {
|
|
184
|
+
resourceName: "root.ics",
|
|
185
|
+
icalUid: "root@example.com",
|
|
186
|
+
}),
|
|
187
|
+
);
|
|
188
|
+
await repo.put(
|
|
189
|
+
objectInput(calendarId, {
|
|
190
|
+
resourceName: "lookalike.ics",
|
|
191
|
+
icalUid: "root@example.comx/following/2",
|
|
192
|
+
}),
|
|
193
|
+
);
|
|
194
|
+
await repo.put(
|
|
195
|
+
objectInput(other, {
|
|
196
|
+
resourceName: "elsewhere.ics",
|
|
197
|
+
icalUid: "root@example.com/following/3",
|
|
198
|
+
}),
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
const found = await repo.listByUidPrefix(
|
|
202
|
+
calendarId,
|
|
203
|
+
"root@example.com/following/",
|
|
204
|
+
);
|
|
205
|
+
|
|
206
|
+
assert.deepEqual(
|
|
207
|
+
found.map((object) => object.calendarObjectId),
|
|
208
|
+
[tail.calendarObjectId],
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
|
|
173
212
|
test("listByCalendar scopes to the collection", async () => {
|
|
174
213
|
const calendarId = harness.makeId();
|
|
175
214
|
const other = harness.makeId();
|
|
@@ -213,6 +213,56 @@ export function calendarSuggestionRepositoryConformance(
|
|
|
213
213
|
assert.equal(new Set(seen).size, 3);
|
|
214
214
|
});
|
|
215
215
|
|
|
216
|
+
test("listByAcceptedCalendarObjects returns, in one read, the account's suggestions answered into any of the resources", async () => {
|
|
217
|
+
const accountConfigId = harness.makeId();
|
|
218
|
+
const first = await repo.put(
|
|
219
|
+
suggestion(accountConfigId, harness.makeId(), harness.makeId(), "uid"),
|
|
220
|
+
);
|
|
221
|
+
const second = await repo.put(
|
|
222
|
+
suggestion(accountConfigId, harness.makeId(), harness.makeId(), "uid"),
|
|
223
|
+
);
|
|
224
|
+
const elsewhere = await repo.put(
|
|
225
|
+
suggestion(accountConfigId, harness.makeId(), harness.makeId(), "uid"),
|
|
226
|
+
);
|
|
227
|
+
const unasked = await repo.put(
|
|
228
|
+
suggestion(accountConfigId, harness.makeId(), harness.makeId(), "uid"),
|
|
229
|
+
);
|
|
230
|
+
const stranger = harness.makeId();
|
|
231
|
+
const strangers = await repo.put(
|
|
232
|
+
suggestion(stranger, harness.makeId(), harness.makeId(), "uid"),
|
|
233
|
+
);
|
|
234
|
+
for (const [owner, row, objectId] of [
|
|
235
|
+
[accountConfigId, first, "cal-object-1"],
|
|
236
|
+
[accountConfigId, second, "cal-object-1"],
|
|
237
|
+
[accountConfigId, elsewhere, "cal-object-2"],
|
|
238
|
+
[accountConfigId, unasked, "cal-object-3"],
|
|
239
|
+
[stranger, strangers, "cal-object-1"],
|
|
240
|
+
] as const) {
|
|
241
|
+
await repo.settle(owner, row.suggestionId, {
|
|
242
|
+
state: CalendarSuggestionState.Accepted,
|
|
243
|
+
acceptedCalendarObjectId: objectId,
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const rows = await repo.listByAcceptedCalendarObjects(accountConfigId, [
|
|
248
|
+
"cal-object-1",
|
|
249
|
+
"cal-object-2",
|
|
250
|
+
]);
|
|
251
|
+
|
|
252
|
+
assert.deepEqual(
|
|
253
|
+
rows.map((row) => row.suggestionId).sort(),
|
|
254
|
+
[
|
|
255
|
+
first.suggestionId,
|
|
256
|
+
second.suggestionId,
|
|
257
|
+
elsewhere.suggestionId,
|
|
258
|
+
].sort(),
|
|
259
|
+
);
|
|
260
|
+
assert.deepEqual(
|
|
261
|
+
await repo.listByAcceptedCalendarObjects(accountConfigId, []),
|
|
262
|
+
[],
|
|
263
|
+
);
|
|
264
|
+
});
|
|
265
|
+
|
|
216
266
|
test("settle records the accepted resource", async () => {
|
|
217
267
|
const accountConfigId = harness.makeId();
|
|
218
268
|
const written = await repo.put(
|
|
@@ -30,6 +30,10 @@ export interface ICalendarObjectRepository {
|
|
|
30
30
|
calendarId: string,
|
|
31
31
|
icalUid: string,
|
|
32
32
|
): Promise<CalendarObjectItem | null>;
|
|
33
|
+
listByUidPrefix(
|
|
34
|
+
calendarId: string,
|
|
35
|
+
prefix: string,
|
|
36
|
+
): Promise<CalendarObjectItem[]>;
|
|
33
37
|
listByCalendar(calendarId: string): Promise<CalendarObjectItem[]>;
|
|
34
38
|
/**
|
|
35
39
|
* The resources whose occurrence rows stop before `instant` — the series a
|
|
@@ -37,6 +37,10 @@ export interface ICalendarSuggestionRepository {
|
|
|
37
37
|
accountConfigId: string,
|
|
38
38
|
messageId: string,
|
|
39
39
|
): Promise<CalendarSuggestionItem[]>;
|
|
40
|
+
listByAcceptedCalendarObjects(
|
|
41
|
+
accountConfigId: string,
|
|
42
|
+
calendarObjectIds: string[],
|
|
43
|
+
): Promise<CalendarSuggestionItem[]>;
|
|
40
44
|
/**
|
|
41
45
|
* The account's suggestions in one state, newest first. Also how the
|
|
42
46
|
* producer finds the revision a new message supersedes: only a `Pending`
|