@remit/data-ports 0.0.73 → 0.0.75

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/data-ports",
3
- "version": "0.0.73",
3
+ "version": "0.0.75",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -78,5 +78,27 @@ export function accountRepositoryConformance(
78
78
  AccountService.Calendar,
79
79
  ]);
80
80
  });
81
+
82
+ test("the mail sources of a config leave out an account with mail off", async () => {
83
+ const accountConfigId = harness.makeId();
84
+ const mailOnly = await repo.create(accountInput(accountConfigId));
85
+ const both = await repo.create({
86
+ ...accountInput(accountConfigId),
87
+ syncedServices: [AccountService.Mail, AccountService.Calendar],
88
+ });
89
+ await repo.create({
90
+ ...accountInput(accountConfigId),
91
+ syncedServices: [AccountService.Calendar],
92
+ });
93
+ await repo.create(accountInput(harness.makeId()));
94
+
95
+ const sources =
96
+ await repo.listMailSourcesByAccountConfig(accountConfigId);
97
+
98
+ assert.deepEqual(
99
+ sources.map((account) => account.accountId).sort(),
100
+ [mailOnly.accountId, both.accountId].sort(),
101
+ );
102
+ });
81
103
  });
82
104
  }
package/src/errors.ts CHANGED
@@ -212,3 +212,15 @@ export class InternalServerError extends UnhandledError {
212
212
  */
213
213
  export const isNotFoundError = (error: unknown): boolean =>
214
214
  (error as { name?: string })?.name === "NotFoundError";
215
+
216
+ export class MailSyncOffError extends BadRequestError {
217
+ name = "MailSyncOffError";
218
+
219
+ constructor(message: string, accountId: string) {
220
+ super(message);
221
+ this.publicApiError = {
222
+ code: "mail_sync_off",
223
+ details: { accountId },
224
+ };
225
+ }
226
+ }
@@ -24,6 +24,9 @@ export interface IAccountRepository {
24
24
  options?: { limit?: number; continuationToken?: string },
25
25
  ): Promise<ResultList<AccountItem>>;
26
26
  listAllByAccountConfig(accountConfigId: string): Promise<AccountItem[]>;
27
+ listMailSourcesByAccountConfig(
28
+ accountConfigId: string,
29
+ ): Promise<AccountItem[]>;
27
30
  describe(accountId: string): Promise<AccountDescription>;
28
31
  listAll(): Promise<AccountItem[]>;
29
32
  incrementMailboxSynced(accountId: string): Promise<AccountItem>;
package/src/types.ts CHANGED
@@ -379,6 +379,7 @@ export type CreateMailboxInput = Omit<
379
379
  | "cursorState"
380
380
  | "syncStatus"
381
381
  | "pendingPath"
382
+ | "syncFailureReason"
382
383
  > & {
383
384
  namespaceType?: MailboxItem["namespaceType"];
384
385
  parentMailboxId?: MailboxItem["parentMailboxId"];
@@ -428,6 +429,7 @@ export type MailboxStatePredicate = {
428
429
  export type MailboxTransitionWrite = {
429
430
  fullPath?: string;
430
431
  pendingPath?: string | null;
432
+ syncFailureReason?: string;
431
433
  };
432
434
 
433
435
  export type MailboxTransitionIntent = MailboxStatePredicate & {