Skip to content

Add Queue Explorer page for Staff Portal Tech Admin section - #310

Open
aaron-rabinowitz wants to merge 3 commits into
mainfrom
300-add-queue-explorer-page-for-staff-portal-tech-admin-section
Open

Add Queue Explorer page for Staff Portal Tech Admin section#310
aaron-rabinowitz wants to merge 3 commits into
mainfrom
300-add-queue-explorer-page-for-staff-portal-tech-admin-section

Conversation

@aaron-rabinowitz

@aaron-rabinowitz aaron-rabinowitz commented Aug 4, 2026

Copy link
Copy Markdown

…ade necessary additions to cellix service-queue-storage to support queue explorer functionality

Summary by Sourcery

Introduce a Tech Admin queue explorer feature for staff, backed by new queue storage operations, permissions, and GraphQL/application-service endpoints.

New Features:

  • Add a Tech Admin Queue Explorer page and navigation for staff portal, including UI to inspect queue messages and send operational messages when permitted.
  • Expose a generic sendMessageToRegisteredQueue operation and per-queue poison peek and approximate message count methods from the queue storage layer.
  • Provide centralized Tech Admin queue application services and GraphQL APIs for listing queues, peeking messages, getting message counts, and sending messages.

Enhancements:

  • Extend staff tech-admin permissions, role models, adapters, GraphQL types, and UI forms to support canViewQueues and canSendQueueMessages capabilities.
  • Update queue storage documentation to describe the new registered-queue sender, poison queue peek, and message count helpers.
  • Wire Tech Admin application services into the global application-services factory and add codegen configuration for the Tech Admin staff route GraphQL operations.

Build:

  • Extend GraphQL code generation to cover the Tech Admin staff route and adjust workspace dependency overrides and devDependencies for compatibility.

Tests:

  • Add unit and BDD-style tests for new queue storage behaviors (registered sending options, poison peek, message counts), Tech Admin permissions, queue operations, and GraphQL resolvers.
  • Update existing permission and role default tests to cover the new Tech Admin queue-related capabilities.

…ade necessary additions to cellix service-queue-storage to support queue explorer functionality
@aaron-rabinowitz
aaron-rabinowitz requested a review from a team August 4, 2026 22:37
@aaron-rabinowitz
aaron-rabinowitz requested a review from a team as a code owner August 4, 2026 22:37
@aaron-rabinowitz aaron-rabinowitz linked an issue Aug 4, 2026 that may be closed by this pull request
@sourcery-ai

sourcery-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Implements a staff Tech Admin Queue Explorer feature end-to-end: adds generic registered-queue send/peek/count capabilities to the queue storage service, exposes queue operations through application services and GraphQL, wires permissions, and builds a React UI for staff to inspect and send queue messages to selected queues, plus minor dependency/override updates.

Sequence diagram for Tech Admin sending a queue message from the Queue Explorer

sequenceDiagram
    actor StaffUser
    participant UIQueueExplorerContainer
    participant GraphQLServer
    participant TechAdminQueueService as TechAdmin.Queue
    participant QueueStorageService

    StaffUser->>UIQueueExplorerContainer: Click "Send Message" (payload, reason)
    UIQueueExplorerContainer->>GraphQLServer: techAdminQueueSend(input)
    GraphQLServer->>GraphQLServer: verify verifiedUser
    GraphQLServer->>TechAdminQueueService: sendMessage(command)
    TechAdminQueueService->>TechAdminQueueService: checkCanSendQueueMessages()
    TechAdminQueueService->>TechAdminQueueService: sendMessage(queueName, payload, reason)
    TechAdminQueueService->>QueueStorageService: sendMessageToRegisteredQueue(queueName, payload, options)
    QueueStorageService-->>TechAdminQueueService: Message accepted
    TechAdminQueueService-->>GraphQLServer: { status: { success: true } }
    GraphQLServer-->>UIQueueExplorerContainer: Mutation result
    UIQueueExplorerContainer-->>StaffUser: Show "Queue message sent"
Loading

File-Level Changes

Change Details Files
Add generic send-to-registered-queue API and queue message-count/poison-queue peek capabilities to the queue storage library, with tests and documentation.
  • Extend queue producer/consumer contexts to support poison queue peek and approximate message count methods for primary and poison queues.
  • Implement InternalQueueStorageService.getApproximateMessageCount and expose it via IQueueStorageOperations.
  • Introduce RegisteredQueueSender interface and sendMessageToRegisteredQueue method that resolves logging fields, validates payloads against JSON Schema, and restricts to registered inbound/outbound queues.
  • Update tests to cover registered queue sending (including logging and options passthrough), poison-queue peeking, and message-count retrieval.
  • Document the new registered-queue send, poison peek, and message-count APIs in README and export RegisteredQueueSender from the package.
packages/cellix/service-queue-storage/src/queue-producer.ts
packages/cellix/service-queue-storage/src/queue-consumer.ts
packages/cellix/service-queue-storage/src/internal-queue-storage-service.ts
packages/cellix/service-queue-storage/src/interfaces.ts
packages/cellix/service-queue-storage/src/register-queues.ts
packages/cellix/service-queue-storage/src/register-queues.test.ts
packages/cellix/service-queue-storage/src/internal-queue-storage-service.test.ts
packages/cellix/service-queue-storage/src/queue-producer.test.ts
packages/cellix/service-queue-storage/src/queue-consumer.test.ts
packages/cellix/service-queue-storage/README.md
packages/ocom/service-queue-storage/README.md
packages/cellix/service-queue-storage/src/index.ts
Introduce Tech Admin queue operations in the application-services layer, including listing queues, peeking messages, getting message counts, and sending messages with operator reasons and permission checks.
  • Add TechAdmin context to ApplicationServices and wire it to DataSources and QueueStorageOperations.
  • Define centralized tech admin queue list with peek and message-count functions for primary and poison queues.
  • Implement listQueues, getQueueMessageCount, peekMessages, and sendMessage functions with permission checks and specific error handling for unregistered queues and missing physical queues.
  • Add queue-permissions utilities (including a once-per-process permission check optimization) and corresponding tests.
  • Add application-service tests for queue operations (list, permission checks, get message count error case, send-message logging metadata/required reason).
packages/ocom/application-services/src/index.ts
packages/ocom/application-services/src/contexts/tech-admin/index.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/index.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/queue-list.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/list-queues.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/list-queues.test.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/get-queue-message-count.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/get-queue-message-count.test.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/peek-messages.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/send-message.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/send-message.test.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/queue-permissions.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/queue-permissions.test.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/queue-operations.ts
packages/ocom/application-services/src/contexts/tech-admin/queue/queue-operations.test.ts
Expose Tech Admin queue operations via GraphQL schema and resolvers, and generate client types for the Tech Admin UI route.
  • Add tech-admin GraphQL types for queues, messages, message counts, and send results, plus Query and Mutation entry points.
  • Implement resolvers that enforce authentication, delegate to TechAdmin Queue application service for list/peek/count/send, and encapsulate send errors into MutationStatus.
  • Add resolver tests verifying lazy message-count resolution and proper delegation.
  • Configure GraphQL codegen for the ui-staff-route-tech-admin package and add .graphql operations for listing queues, peeking messages, and sending messages.
packages/ocom/graphql/src/schema/types/tech-admin.graphql
packages/ocom/graphql/src/schema/types/tech-admin.resolvers.ts
packages/ocom/graphql/src/schema/types/tech-admin.resolvers.test.ts
codegen.yml
packages/ocom/ui-staff-route-tech-admin/src/components/queue-explorer.container.graphql
packages/ocom/ui-staff-route-tech-admin/src/generated.tsx
Add a Tech Admin Queue Explorer UI in the staff portal, including routing, permissions gating, queue/message tables, and a send-message modal.
  • Replace the Tech Admin route placeholder with a TechAdminPage that renders vertical tabs and redirects unauthorized users to /unauthorized.
  • Implement QueueExplorer presentational component showing queues with counts, poison queues, and a modal to inspect recent messages and optionally send new messages for non-poison queues.
  • Implement QueueExplorerContainer that wires Apollo queries/mutations, handles JSON parsing, error/success messaging, and passes permission flags to the UI.
  • Add QueueExplorerPage that gates the explorer by canViewQueues and controls whether sending is enabled based on canSendQueueMessages.
  • Register required dependencies (@apollo/client, @graphql-typed-document-node/core, antd) in the Tech Admin route package.
packages/ocom/ui-staff-route-tech-admin/src/index.tsx
packages/ocom/ui-staff-route-tech-admin/src/pages/tech-admin.tsx
packages/ocom/ui-staff-route-tech-admin/src/pages/queue-explorer.tsx
packages/ocom/ui-staff-route-tech-admin/src/components/queue-explorer.tsx
packages/ocom/ui-staff-route-tech-admin/src/components/queue-explorer.container.tsx
packages/ocom/ui-staff-route-tech-admin/src/components/queue-explorer.container.graphql
packages/ocom/ui-staff-route-tech-admin/package.json
Introduce and propagate new Tech Admin permissions (canViewQueues and canSendQueueMessages) through domain, persistence, application-services, GraphQL, and UI.
  • Extend StaffRoleTechAdminPermissions spec, value object, defaults, and aggregate to include canViewQueues and canSendQueueMessages (with manage-staff-roles validation) and update tests and feature files.
  • Update persistence adapters and Mongoose model to store canViewQueues and canSendQueueMessages with defaults.
  • Extend StaffRoleCommandTechAdminPermissions and applyTechAdminPermissions to support the new fields and add tests for setting them.
  • Expose new permissions via GraphQL StaffRoleTechAdminPermissions type and creation input, and include them in current-staff-user query.
  • Propagate permissions into staff UI: StaffAuth, useStaffPermissions hook, staff role create/edit forms and containers, and ensure default tech-admin role has both view/send queue permissions.
packages/ocom/domain/src/domain/contexts/user/staff-role/staff-role-tech-admin-permissions.ts
packages/ocom/domain/src/domain/contexts/user/staff-role/staff-role-tech-admin-permissions.test.ts
packages/ocom/domain/src/domain/contexts/user/staff-role/features/staff-role-tech-admin-permissions.feature
packages/ocom/domain/src/domain/contexts/user/staff-role/staff-role-permissions.ts
packages/ocom/domain/src/domain/contexts/user/staff-role/staff-role-defaults.test.ts
packages/ocom/domain/src/domain/contexts/user/staff-role/staff-role.ts
packages/ocom/persistence/src/datasources/domain/user/staff-role/staff-role.domain-adapter.ts
packages/ocom/data-sources-mongoose-models/src/models/role/staff-role.model.ts
packages/ocom/application-services/src/contexts/user/staff-role/apply-permissions.ts
packages/ocom/application-services/src/contexts/user/staff-role/apply-permissions.test.ts
packages/ocom/graphql/src/schema/types/staff-role.graphql
apps/ui-staff/src/hooks/use-staff-permissions.ts
packages/ocom/ui-staff-shared/src/staff-route-shell.tsx
packages/ocom/ui-staff-route-user-management/src/components/staff-role-create.tsx
packages/ocom/ui-staff-route-user-management/src/components/staff-role-create.container.tsx
packages/ocom/ui-staff-route-user-management/src/components/staff-role-edit.container.tsx
packages/ocom/ui-staff-route-user-management/src/components/staff-role-edit.container.graphql
Adjust workspace and app-level dependencies/overrides to support the new functionality and fix minor versions.
  • Add codegen and dependency overrides for Apollo/protobufjs, nanoid, fast-uri, brace-expansion, and autoprefixer; tweak vitest/vite-plugin-node-polyfills ordering.
  • Update pnpm-workspace overrides and pnpm-lock, and apps/ui-community devDependencies to include autoprefixer and adjust vitest entry ordering.
pnpm-workspace.yaml
pnpm-lock.yaml
apps/ui-community/package.json
knip.json

Assessment against linked issues

Issue Objective Addressed Explanation
#300 Implement a Queue Explorer page in the staff portal Tech Admin section that lists all registered queues (including poison queues), allows viewing messages in a selected queue, and supports sending JSON messages with a required reason via the queue storage service.
#300 Introduce and enforce tech admin permissions canViewQueues and canSendQueueMessages across domain, persistence, GraphQL, and UI so that only authorized staff can access the Queue Explorer page and send queue messages, with invalid JSON payloads being rejected.

Possibly linked issues

  • #0: PR fulfills the Queue Explorer tech-admin page, enforcing canViewQueues/canSendQueueMessages and enabling peek/send with validation.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 2 issues, and left some high level feedback:

Fixed security issues:

  • fast-uri (link)

  • In QueueExplorer you pass destroyOnHidden to Modal, but Ant Design’s Modal uses destroyOnClose; this prop is likely a no-op and should be updated to avoid confusion and ensure the modal content is actually destroyed when closed.

  • The new queue helper modules under contexts/tech-admin/queue (e.g. queue-operations.ts with registeredQueueOperations and ensureCanViewQueues) overlap conceptually with the queue-list/queue-permissions implementations and don’t appear to be wired into the rest of the flow—consider removing or consolidating this older helper to avoid dead or duplicate permission logic.

Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In `QueueExplorer` you pass `destroyOnHidden` to `Modal`, but Ant Design’s Modal uses `destroyOnClose`; this prop is likely a no-op and should be updated to avoid confusion and ensure the modal content is actually destroyed when closed.
- The new queue helper modules under `contexts/tech-admin/queue` (e.g. `queue-operations.ts` with `registeredQueueOperations` and `ensureCanViewQueues`) overlap conceptually with the `queue-list`/`queue-permissions` implementations and don’t appear to be wired into the rest of the flow—consider removing or consolidating this older helper to avoid dead or duplicate permission logic.

## Individual Comments

### Comment 1
<location path="packages/ocom/application-services/src/contexts/tech-admin/queue/queue-permissions.ts" line_range="3" />
<code_context>
+import type { DataSources } from '@ocom/persistence';
+
+// only needed becasue passport for techadmin is not implemented
+export function checkPermissionOnce(checkPermission: () => Promise<void>): () => Promise<void> {
+	let permissionCheck: Promise<void> | undefined;
</code_context>
<issue_to_address>
**nitpick (typo):** Fix typo in the explanatory comment about the temporary permission helper.

Please correct the spelling from "becasue" to "because" in this comment.

```suggestion
 // only needed because passport for techadmin is not implemented
```
</issue_to_address>

### Comment 2
<location path="packages/ocom/service-queue-storage/README.md" line_range="27" />
<code_context>

 `ApiContextSpec` should depend on `QueueStorageOperations`, not `ServiceQueueStorage`. The constructor is for bootstrap; the operations type is for application-service injection.

+`QueueStorageOperations` also exposes `sendMessageToRegisteredQueue(queueName, payload)` for controlled operational flows that select a registered physical queue at runtime. It accepts both inbound and outbound queues, validates the payload against the selected schema, and rejects unregistered names. Prefer generated `sendMessageTo...Queue` methods for normal application behavior.
+
 Example:
</code_context>
<issue_to_address>
**question:** The documented `sendMessageToRegisteredQueue` signature may be incomplete compared to the usage example elsewhere.

Here you document `sendMessageToRegisteredQueue(queueName, payload)`, but another README example shows a third `options` argument. If options are supported, please update this section to include the parameter and its shape so the API description stays consistent.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread packages/ocom/service-queue-storage/README.md Outdated
aaron-rabinowitz and others added 2 commits August 4, 2026 18:44
…ue/queue-permissions.ts

Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Queue Explorer page for Staff Portal Tech Admin section

1 participant