@lusc/fastmail-masked-email
Version:
A library for creating, deleting, and updating Fastmail masked emails
57 lines • 2.17 kB
JavaScript
import { array as zArray, boolean as zBoolean, enum as zEnum, number as zNumber, object as zObject, record as zRecord, string as zString, unknown as zUnknown, } from 'zod';
export const sessionResponseSchema = zObject({
state: zString(),
apiUrl: zString(),
capabilities: zObject({
'urn:ietf:params:jmap:core': zObject({
maxConcurrentUpload: zNumber(),
maxConcurrentRequests: zNumber(),
maxSizeRequest: zNumber(),
maxObjectsInGet: zNumber(),
maxCallsInRequest: zNumber(),
maxSizeUpload: zNumber(),
maxObjectsInSet: zNumber(),
collationAlgorithms: zArray(zString()),
}),
'https://www.fastmail.com/dev/maskedemail': zRecord(zUnknown()),
}),
accounts: zRecord(zObject({
name: zString(),
isPersonal: zBoolean(),
accountCapabilities: zObject({
'urn:ietf:params:jmap:core': zRecord(zUnknown()),
'https://www.fastmail.com/dev/maskedemail': zRecord(zUnknown()),
}),
isReadOnly: zBoolean(),
})),
eventSourceUrl: zString(),
downloadUrl: zString(),
uploadUrl: zString(),
username: zString(),
primaryAccounts: zRecord(zString()),
});
export const maskedEmailStateSchema = zEnum([
'enabled',
'disabled',
'pending',
'deleted',
]);
export const optionsSchema = zObject({
/** The description to set fpr the masked email */
description: zString().optional(),
/** The domain to be associated with the masked email */
forDomain: zString().optional(),
/**
* The state to set for the masked email
* @defaultValue 'enabled'
* @see {@link MaskedEmailState} for valid values
* */
state: maskedEmailStateSchema.default('enabled'),
}).refine(options => Object.keys(options).length > 0, {
message: 'options must contain at least one of `description`, `forDomain`, `state`',
});
export const createOptionsSchema = optionsSchema.and(zObject({
/** If supplied, the server-assigned email will start with the given prefix. */
emailPrefix: zString().optional(),
}));
//# sourceMappingURL=schemas.js.map