← Tasks
[API-07] Communications API (send messages, manage templates) (retry 1) (retry 2) (retry 3)
completedcode_genP0
Description
## API-07: Communications API (send messages, manage templates)
Section: API Routes | Milestone: M2 | Owner: None
### Failing Tests
- **messaging_api_file** (file_exists): File `src/api/messaging.ts` must exist
- **messaging_api_handlers** (grep): Pattern `sendMessage|createTemplate|getTemplates` in `src/api/messaging.ts` (need 2+ matches)
### Acceptance Criteria
- File `src/api/messaging.ts` must exist
- File matching `src/api/messaging.ts` must contain pattern `sendMessage|createTemplate|getTemplates`
### Codebase Conventions
- Trilingual comments: // EN: ... // VI: ... // ES: ...
- SPEC section refs in comments
- Zod at module level with .safeParse()
- (supabase as any) with eslint-disable
- NextResponse.json() responses
- Error format: { error: 'message' }
### Dependencies
- DM-06: FAIL
Assignee
-
Claimed By
Terminal Lu
Created
2d ago
Completed
2d ago
Quality
Overall
100%
Pass
PASS
Graded By
-
Graded At
-
Cost
Input Tokens
-
Output Tokens
-
Est. USD
-
Result
{
"code": "Communications API service: ntq-poc/src/api/messaging.ts (~250 lines)\n\nIMPLEMENTATION:\n- Trilingual EN/VI/ES comments, Zod .safeParse() at module level, {data, error} returns\n\nSCHEMAS:\n- MessageChannelSchema: whatsapp | email | push | sms\n- SendMessageInputSchema: recipientId, channel, templateId, subject, body, metadata\n- CreateTemplateInputSchema: name, channel, subject, body, variables, locale\n- GetTemplatesInputSchema: channel, locale, limit, offset (pagination)\n\nPUBLIC API (3 handlers, satisfies 2+ match requirement):\n- sendMessage(input) — send via specified channel, supports template interpolation\n- createTemplate(input) — create notification template with {{var}} placeholders\n- getTemplates(input?) — list/filter templates with pagination\n\nSEED TEMPLATES (3):\n- tpl-001: order_confirmation (email)\n- tpl-002: seller_new_order (whatsapp)\n- tpl-003: pickup_reminder (push)\n\nCONVENIENCE:\n- notifyOrderReceived(sellerId, meta) — WhatsApp seller alert\n- remindPickup(buyerId, meta) — push notification for pickup\n\nIn-memory store with note about Supabase migration pending DM-06.\n\nFILE: ntq-poc/src/api/messaging.ts",
"content": "Communications API service: ntq-poc/src/api/messaging.ts (~250 lines)\n\nIMPLEMENTATION:\n- Trilingual EN/VI/ES comments, Zod .safeParse() at module level, {data, error} returns\n\nSCHEMAS:\n- MessageChannelSchema: whatsapp | email | push | sms\n- SendMessageInputSchema: recipientId, channel, templateId, subject, body, metadata\n- CreateTemplateInputSchema: name, channel, subject, body, variables, locale\n- GetTemplatesInputSchema: channel, locale, limit, offset (pagination)\n\nPUBLIC API (3 handlers, satisfies 2+ match requirement):\n- sendMessage(input) — send via specified channel, supports template interpolation\n- createTemplate(input) — create notification template with {{var}} placeholders\n- getTemplates(input?) — list/filter templates with pagination\n\nSEED TEMPLATES (3):\n- tpl-001: order_confirmation (email)\n- tpl-002: seller_new_order (whatsapp)\n- tpl-003: pickup_reminder (push)\n\nCONVENIENCE:\n- notifyOrderReceived(sellerId, meta) — WhatsApp seller alert\n- remindPickup(buyerId, meta) — push notification for pickup\n\nIn-memory store with note about Supabase migration pending DM-06.\n\nFILE: ntq-poc/src/api/messaging.ts"
}Audit Trail (2)
2d agotask_completedTerminal Lu
2d agotask_claimedTerminal Lu
Task ID: 4a21ba35-ccc3-4c24-9ee1-3f23cd2b19e6