6d935e7180
- Add Redis-backed opportunity cache with background refresh (30s interval) - Fix concurrency bug: use lazy thunks instead of eager promises for batching - Add withCwRetry utility with exponential backoff for transient CW errors - Add adaptive TTL algorithms (primary, sub-resource, products) based on opportunity activity - Add include query param on GET /sales/opportunities/:id (notes,contacts,products) - Add opt-in CW API logger (LOG_CW_API env var) with timestamped files in cw-api-logs/ - Add debug-scripts/analyze-cw-calls.py for API call analysis - Add computeSubResourceCacheTTL and computeProductsCacheTTL algorithms with tests - Increase CW API timeout from 15s to 30s - Unblock cache refresh from startup chain (remove await) - Prioritize recently updated opportunities in refresh cycle - Add CACHING.md documentation - Update API_ROUTES.md with caching details and include param - Update copilot instructions to require CACHING.md sync - Add dev:log script for CW API call logging during development
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { createRoute } from "../../../modules/api-utils/createRoute";
|
|
import { opportunities } from "../../../managers/opportunities";
|
|
import { apiResponse } from "../../../modules/api-utils/apiResponse";
|
|
import { ContentfulStatusCode } from "hono/utils/http-status";
|
|
import { authMiddleware } from "../../middleware/authorization";
|
|
import GenericError from "../../../Errors/GenericError";
|
|
|
|
/* DELETE /v1/sales/opportunities/:identifier/notes/:noteId */
|
|
export default createRoute(
|
|
"delete",
|
|
["/opportunities/:identifier/notes/:noteId"],
|
|
async (c) => {
|
|
const identifier = c.req.param("identifier");
|
|
const noteId = Number(c.req.param("noteId"));
|
|
|
|
if (isNaN(noteId))
|
|
throw new GenericError({
|
|
status: 400,
|
|
name: "InvalidNoteId",
|
|
message: "Note ID must be a number",
|
|
});
|
|
|
|
const item = await opportunities.fetchRecord(identifier);
|
|
await item.deleteNote(noteId);
|
|
|
|
const response = apiResponse.successful(
|
|
"Opportunity note deleted successfully!",
|
|
);
|
|
|
|
return c.json(response, response.status as ContentfulStatusCode);
|
|
},
|
|
authMiddleware({ permissions: ["sales.opportunity.note.delete"] }),
|
|
);
|