Skip to content

Comments

Remove unused endpoints#832

Open
stephenhand wants to merge 2 commits intomasterfrom
sjh/remove_task_assignment_endpoints
Open

Remove unused endpoints#832
stephenhand wants to merge 2 commits intomasterfrom
sjh/remove_task_assignment_endpoints

Conversation

@stephenhand
Copy link
Collaborator

Description

Remove several endpoints that were either migrated to the Twilio Lambda or just haven't been used for years

  • assignOfflineContact - superseded by assignOfflineContactInit and assignOfflineContactResolve
  • checkTaskAssignment, completeTaskAssignment & getTaskAndReservations - all fully migrated to Twilio Lambda
  • autopilotRedirect & createContactlessTask - not referenced anywhere
  • adjustChatCapacity - removed endpoint but kept logic which is used elsewhere, made module private

Checklist

  • Corresponding issue has been opened
  • New tests added
  • Feature flags / configuration added

Other Related Issues

None

Verification steps

AFTER YOU MERGE

  1. Cut a release tag using the GitHub workflow. Wait for it to complete and the notification to be posted in the #aselo-deploys Slack channel.
  2. Comment on the ticket with the release tag version AND any additional instructions required to configure an environment to test the changes.
  3. Only then move the ticket into the QA column in JIRA

You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes several legacy Twilio Serverless endpoints (and their tests) that are no longer used or have been migrated to Twilio Lambda, while keeping the adjustChatCapacity logic as an internal/private module used by other functions.

Changes:

  • Deleted unused/migrated function endpoints: assignOfflineContact, checkTaskAssignment, completeTaskAssignment, getTaskAndReservations, autopilotRedirect, createContactlessTask.
  • Updated adjustChatCapacity to be logic-only (no HTTP handler) and updated callers/tests to import/use the private module.
  • Removed tests that only covered deleted endpoints and refactored adjustChatCapacity tests to exercise the internal function directly.

Reviewed changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/createContactlessTask.test.ts Removed tests for deleted createContactlessTask endpoint.
tests/autopilotRedirect.test.ts Removed tests for deleted autopilotRedirect endpoint.
tests/assignOfflineContact.test.ts Removed tests for deleted assignOfflineContact endpoint.
tests/adjustChatCapacity.test.ts Updated tests to target adjustChatCapacity.private directly (no serverless callback/response).
functions/transferChatStart.ts Updated type import to reference adjustChatCapacity.private.
functions/taskrouterListeners/adjustCapacityListener.private.ts Updated type import to reference adjustChatCapacity.private.
functions/pullTask.ts Updated AdjustChatCapacityType import path to adjustChatCapacity.private.
functions/getTaskAndReservations.ts Deleted unused/migrated endpoint implementation.
functions/createContactlessTask.ts Deleted unused endpoint implementation.
functions/completeTaskAssignment.ts Deleted unused/migrated endpoint implementation.
functions/checkTaskAssignment.ts Deleted unused/migrated endpoint implementation.
functions/autopilotRedirect.protected.ts Deleted unused endpoint implementation.
functions/assignOfflineContact.ts Deleted superseded endpoint implementation.
functions/adjustChatCapacity.private.ts Removed serverless handler; retained internal adjustChatCapacity function + type export.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

success,
} from '@tech-matters/serverless-helpers';
import { AdjustChatCapacityType } from './adjustChatCapacity';
import { AdjustChatCapacityType } from './adjustChatCapacity.private';
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

AdjustChatCapacityType is only used as a type in this file; consider switching this to a type-only import (import type { ... }) to avoid any chance of a runtime import and to match the pattern used in transferChatStart.ts / adjustCapacityListener.private.ts.

Suggested change
import { AdjustChatCapacityType } from './adjustChatCapacity.private';
import type { AdjustChatCapacityType } from './adjustChatCapacity.private';

Copilot uses AI. Check for mistakes.
Comment on lines +98 to 108
test('Should throw with incomplete data', async () => {
const workerSid = 'worker123';
// const adjustment = 'increase';
const event1 = { request: { cookies: {}, headers: {} } };
const event2 = { ...event1, workerSid };

const events = [event1, event2];

const callback: ServerlessCallback = (err, result) => {
expect(result).toBeDefined();
const response = result as MockedResponse;
expect(response.getStatus()).toBe(400);
};

await Promise.all(events.map((e) => adjustChatCapacity(baseContext, e, callback)));
const event1 = {};
const event2 = { workerSid };
await expect(adjustChatCapacity(baseContext, event1 as Body)).rejects.toThrow();
await expect(adjustChatCapacity(baseContext, event2 as Body)).resolves.toStrictEqual({
status: 400,
message: 'Invalid adjustment argument',
});
});
Copy link

Copilot AI Feb 20, 2026

Choose a reason for hiding this comment

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

This test name says it "Should throw with incomplete data", but the second case expects a resolved { status: 400, ... }. Consider splitting into two tests (missing workerSid vs missing/invalid adjustment) or renaming the test to reflect both behaviors. Also, casting event1/event2 to a Required Body bypasses type-safety in a way that's easy to miss; using a Partial<Body>/unknown cast for the negative cases would make the intent clearer.

Copilot uses AI. Check for mistakes.
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.

1 participant