@remit/mailbox-service 0.0.117 → 0.0.118
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/dist/ownership.d.ts +1 -1
- package/dist/ownership.js +9 -2
- package/package.json +1 -1
package/dist/ownership.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { AccountItem, MailboxItem } from "@remit/data-ports";
|
|
2
2
|
import { type AccessMode, type Refusable } from "./refusal.js";
|
|
3
|
-
export declare const ownedAccount: <A extends Pick<AccountItem, "accountId" | "accountConfigId">>(account: A, accountConfigId: string, mode: AccessMode) => Refusable<A>;
|
|
3
|
+
export declare const ownedAccount: <A extends Pick<AccountItem, "accountId" | "accountConfigId" | "deletedAt">>(account: A, accountConfigId: string, mode: AccessMode) => Refusable<A>;
|
|
4
4
|
export declare const folderInAccount: <M extends Pick<MailboxItem, "mailboxId" | "accountId">>(mailbox: M, accountId: string, mode: AccessMode) => Refusable<M>;
|
|
5
5
|
export declare const settledFolder: <M extends Pick<MailboxItem, "mailboxId" | "fullPath" | "syncStatus">>(target: M) => Refusable<M>;
|
|
6
6
|
export interface MessageOwnershipClient {
|
package/dist/ownership.js
CHANGED
|
@@ -2,9 +2,16 @@ import { MailboxSyncStatus } from "@remit/domain-enums";
|
|
|
2
2
|
import { accept, invalid, refuse, } from "./refusal.js";
|
|
3
3
|
// A read refuses with NotFound so another tenant's account does not leak its
|
|
4
4
|
// existence; an action names the resource already, so it is refused outright.
|
|
5
|
+
// A deleted account keeps its row until the purge finishes, and is gone to its owner.
|
|
5
6
|
export const ownedAccount = (account, accountConfigId, mode) => {
|
|
6
|
-
if (account.accountConfigId === accountConfigId)
|
|
7
|
-
|
|
7
|
+
if (account.accountConfigId === accountConfigId) {
|
|
8
|
+
if (account.deletedAt === undefined)
|
|
9
|
+
return accept(account);
|
|
10
|
+
return refuse({
|
|
11
|
+
kind: "NotFound",
|
|
12
|
+
message: `Account not found: ${account.accountId}`,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
8
15
|
if (mode === "read") {
|
|
9
16
|
return refuse({
|
|
10
17
|
kind: "NotFound",
|