Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix server-set types #16

Merged
merged 4 commits into from
Dec 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions src/types/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@ import type { Exact } from "type-fest";
import type { HasAllKeysOfRelated } from "../helpers.ts";
import type {
Email,
EmailCreate,
EmailFilterCondition,
EmailImport,
EmailSubmission,
EmailSubmissionCreate,
EmailSubmissionFilterCondition,
GetValueFromHeaderKey,
HeaderFieldKey,
Identity,
IdentityCreate,
Mailbox,
MailboxCreate,
MailboxFilterCondition,
SearchSnippet,
Thread,
VacationResponse
VacationResponse,
VacationResponseCreate
} from "./jmap-mail.ts";
import type {
BlobCopyArguments,
Expand All @@ -30,6 +35,8 @@ import type {
Request as JMAPRequest,
Response as JMAPResponse,
ProblemDetails,
PushSubscription,
PushSubscriptionCreate,
QueryArguments,
QueryChangesArguments,
QueryChangesResponse,
Expand All @@ -47,7 +54,7 @@ export type Requests = {
// Push Subscription ----------------------
"PushSubscription/get": Omit<GetArguments<PushSubscription>, "accountId">;
"PushSubscription/set": Omit<
SetArguments<PushSubscription>,
SetArguments<PushSubscriptionCreate>,
"accountId" | "ifInState"
>;
// Mailbox --------------------------------
Expand All @@ -61,7 +68,7 @@ export type Requests = {
Mailbox,
MailboxFilterCondition
>;
"Mailbox/set": SetArguments<Mailbox> & {
"Mailbox/set": SetArguments<MailboxCreate> & {
onDestroyRemoveEmails?: boolean;
};
// Thread ---------------------------------
Expand All @@ -76,7 +83,7 @@ export type Requests = {
"Email/queryChanges": QueryChangesArguments<Email, EmailFilterCondition> & {
collapseThreads?: boolean;
};
"Email/set": SetArguments<Omit<Email, "headers">>;
"Email/set": SetArguments<EmailCreate>;
"Email/copy": CopyArguments<
Pick<Email, "id" | "mailboxIds" | "keywords" | "receivedAt">
>;
Expand Down Expand Up @@ -107,7 +114,7 @@ export type Requests = {
// Identity -------------------------------
"Identity/get": GetArguments<Identity>;
"Identity/changes": ChangesArguments;
"Identity/set": SetArguments<Identity>;
"Identity/set": SetArguments<IdentityCreate>;
// Email Submission -----------------------
"EmailSubmission/get": GetArguments<EmailSubmission>;
"EmailSubmission/changes": ChangesArguments;
Expand All @@ -119,13 +126,13 @@ export type Requests = {
EmailSubmission,
EmailSubmissionFilterCondition
>;
"EmailSubmission/set": SetArguments<EmailSubmission> & {
"EmailSubmission/set": SetArguments<EmailSubmissionCreate> & {
onSuccessUpdateEmail?: Record<ID, Partial<Email>> | null;
onSuccessDestroyEmail?: ID[] | null;
};
// Vacation Response ----------------------
"VacationResponse/get": GetArguments<VacationResponse>;
"VacationResponse/set": SetArguments<VacationResponse>;
"VacationResponse/set": SetArguments<VacationResponseCreate>;
};

export type Methods = keyof Requests;
Expand Down
Loading