feat(feedback): Phase 1.2 - extend repository with screenshot support and blob path generation
This commit is contained in:
parent
acfbd7c9d7
commit
8d2ba9c1cc
@ -34,6 +34,12 @@ export async function createFeedback(
|
|||||||
platform: input.platform ?? null,
|
platform: input.platform ?? null,
|
||||||
status: 'new',
|
status: 'new',
|
||||||
adminNotes: null,
|
adminNotes: null,
|
||||||
|
// Screenshot fields (Phase 1.2)
|
||||||
|
screenshotBlobPath: input.screenshotBlobPath,
|
||||||
|
screenshotContentType: input.screenshotContentType,
|
||||||
|
screenshotSizeBytes: input.screenshotSizeBytes,
|
||||||
|
// Device context (Phase 1.2)
|
||||||
|
deviceContext: input.deviceContext,
|
||||||
createdAt: now,
|
createdAt: now,
|
||||||
updatedAt: now,
|
updatedAt: now,
|
||||||
};
|
};
|
||||||
@ -102,6 +108,46 @@ export async function deleteFeedback(id: string, productId: string): Promise<boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
// Screenshot management (Phase 1.2)
|
||||||
|
// ─────────────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate blob path for feedback screenshot.
|
||||||
|
* Pattern: feedback/{productId}/{feedbackId}/{screenshotId}.png
|
||||||
|
*/
|
||||||
|
export function generateScreenshotBlobPath(
|
||||||
|
productId: string,
|
||||||
|
feedbackId: string,
|
||||||
|
contentType: 'image/png' | 'image/jpeg' | 'image/webp'
|
||||||
|
): string {
|
||||||
|
const screenshotId = `scr_${crypto.randomUUID().split('-')[0]}`;
|
||||||
|
const ext = contentType === 'image/png' ? 'png' : contentType === 'image/jpeg' ? 'jpg' : 'webp';
|
||||||
|
return `feedback/${productId}/${feedbackId}/${screenshotId}.${ext}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get feedback with fresh screenshot URL (placeholder - actual SAS generation in blob module).
|
||||||
|
* This function validates the feedback exists and has a screenshot.
|
||||||
|
*/
|
||||||
|
export async function getFeedbackWithScreenshot(
|
||||||
|
id: string,
|
||||||
|
productId: string
|
||||||
|
): Promise<FeedbackDoc | null> {
|
||||||
|
const feedback = await getFeedback(id, productId);
|
||||||
|
if (!feedback || !feedback.screenshotBlobPath) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return feedback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if feedback has screenshot for quick UI checks.
|
||||||
|
*/
|
||||||
|
export function hasScreenshot(feedback: FeedbackDoc): boolean {
|
||||||
|
return !!feedback.screenshotBlobPath && !!feedback.screenshotContentType;
|
||||||
|
}
|
||||||
|
|
||||||
export async function getFeedbackStats(productId: string): Promise<Record<string, number>> {
|
export async function getFeedbackStats(productId: string): Promise<Record<string, number>> {
|
||||||
const { resources } = await getContainer()
|
const { resources } = await getContainer()
|
||||||
.items.query<{ type: string; cnt: number }>({
|
.items.query<{ type: string; cnt: number }>({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user