From a7516c31f76787c98f93644c7a1a9876004decfa Mon Sep 17 00:00:00 2001 From: coodos Date: Thu, 16 Jul 2026 23:11:57 +0530 Subject: [PATCH] feat: me by id --- services/awareness-service/README.md | 3 +- .../api/src/controllers/QueryController.ts | 10 +++++ services/awareness-service/api/src/openapi.ts | 37 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/services/awareness-service/README.md b/services/awareness-service/README.md index 417a56904..7f804ff43 100644 --- a/services/awareness-service/README.md +++ b/services/awareness-service/README.md @@ -15,7 +15,8 @@ subscription matching and retrying webhook delivery. 1. **Ingest** — `POST /ingest` receives every awareness packet from evault-core (shared-secret auth) and persists it. 2. **Poll** — `GET /api/packets` lets approved consumers query packet history by - ontology, eVault and time range, with cursor pagination. + ontology, eVault and time range, with cursor pagination. A single packet can + also be fetched directly by its MetaEnvelope id with `GET /api/packets/:id`. 3. **Subscribe** — `/api/subscriptions` registers webhook subscriptions filtered by ontology and eVault. Delivered payloads match the legacy evault-core webhook format exactly. diff --git a/services/awareness-service/api/src/controllers/QueryController.ts b/services/awareness-service/api/src/controllers/QueryController.ts index b9ecc2610..104bb643e 100644 --- a/services/awareness-service/api/src/controllers/QueryController.ts +++ b/services/awareness-service/api/src/controllers/QueryController.ts @@ -111,5 +111,15 @@ export function queryRouter(): Router { }); }); + // GET /api/packets/:id - fetch a single awareness packet (MetaEnvelope) by + // its id. Not consumer-scoped, mirroring the polling endpoint above. + router.get("/api/packets/:id", consumerAuth, async (req, res) => { + const packet = await AppDataSource.getRepository(Packet).findOne({ + where: { id: req.params.id }, + }); + if (!packet) return res.status(404).json({ error: "not found" }); + return res.json({ packet }); + }); + return router; } diff --git a/services/awareness-service/api/src/openapi.ts b/services/awareness-service/api/src/openapi.ts index b7106888d..ada41a1d1 100644 --- a/services/awareness-service/api/src/openapi.ts +++ b/services/awareness-service/api/src/openapi.ts @@ -246,6 +246,43 @@ export const openApiDocument = { }, }, }, + "/api/packets/{id}": { + get: { + tags: ["Query"], + summary: "Get a single awareness packet (MetaEnvelope) by ID", + description: "Fetch one awareness packet by its MetaEnvelope id.", + security: [{ consumerAuth: [] }], + parameters: [ + { + name: "id", + in: "path", + required: true, + schema: { type: "string" }, + description: "MetaEnvelope id", + }, + ], + responses: { + "200": { + description: "The requested packet", + content: { + "application/json": { + schema: { + type: "object", + properties: { + packet: { + $ref: "#/components/schemas/Packet", + }, + }, + }, + }, + }, + }, + "401": { $ref: "#/components/responses/Unauthorized" }, + "403": { $ref: "#/components/responses/Forbidden" }, + "404": { $ref: "#/components/responses/NotFound" }, + }, + }, + }, "/api/subscriptions": { get: { tags: ["Subscriptions"],