async delete()

in libs/newsletters-data-client/src/lib/layout-storage/S3LayoutStorage.ts [161:188]


	async delete(
		edition: EditionId,
	): Promise<SuccessfulStorageResponse<Layout> | UnsuccessfulStorageResponse> {
		const key = this.editionIdToKey(edition);

		try {
			const layoutToDelete = await this.fetchLayout(edition);
			if (!layoutToDelete) {
				return {
					ok: false,
					message: `no layout for ${edition} to delete`,
					reason: StorageRequestFailureReason.NotFound,
				};
			}

			await this.deleteObject(key);
			return {
				ok: true,
				data: layoutToDelete,
			};
		} catch (err) {
			return {
				ok: false,
				message: `failed to delete layout for ${edition}`,
				reason: StorageRequestFailureReason.S3Failure,
			};
		}
	}