in libs/newsletters-data-client/src/lib/newsletter-storage/NewsletterStorage.ts [74:118]
abstract delete(
listId: number,
): Promise<
| SuccessfulStorageResponse<NewsletterDataWithoutMeta>
| UnsuccessfulStorageResponse
>;
abstract list(): Promise<
| SuccessfulStorageResponse<NewsletterDataWithoutMeta[]>
| UnsuccessfulStorageResponse
>;
getModificationError(
modifications: Partial<NewsletterData>,
): UnsuccessfulStorageResponse | undefined {
const problems: string[] = [];
const propertiesChanged = Object.keys(modifications);
const forbiddenKeyChanges = propertiesChanged.filter((property) =>
IMMUTABLE_PROPERTIES.includes(property),
);
if (forbiddenKeyChanges.length > 0) {
problems.push(
`Cannot change ${forbiddenKeyChanges
.map((key) => `"${key}"`)
.join(' or ')} on a newsletter.`,
);
}
if (!isPartialNewsletterData(modifications)) {
problems.push(
'Not all fields are of the required type or in the right format.',
);
}
if (problems.length === 0) {
return undefined;
}
return {
ok: false,
message: problems.join(' '),
reason: StorageRequestFailureReason.InvalidDataInput,
};
}