Skip to content

feat(subscriptions): topic-level updates (PR 5/7)#517

Open
sarthak688 wants to merge 3 commits into
feat/subscriptions-sdkfrom
feat/subscriptions-topic-updates
Open

feat(subscriptions): topic-level updates (PR 5/7)#517
sarthak688 wants to merge 3 commits into
feat/subscriptions-sdkfrom
feat/subscriptions-topic-updates

Conversation

@sarthak688

Copy link
Copy Markdown

PR 5/7 in the Notification SDK stack. Stacked on top of #516.

Adds the topic-scoped subscription writes. Each method takes an array of update entries, letting callers batch many subscription toggles into one request.

Methods Added

Layer Method Signature
Service subscriptions.updateTopic() updateTopic(tenantId: string, subscriptions: TopicSubscriptionUpdate[]): Promise<SubscriptionUpdateTopicResponse>
Service subscriptions.updateCategory() updateCategory(tenantId: string, subscriptions: CategorySubscriptionUpdate[]): Promise<SubscriptionUpdateCategoryResponse>

Endpoints Called

Method HTTP Endpoint OAuth Scope
updateTopic() POST notificationservice_/usersubscriptionservice/api/v1/UserSubscription NotificationService
updateCategory() POST notificationservice_/usersubscriptionservice/api/v1/UserSubscription/CategorySubscription NotificationService
  • UPDATE_TOPIC reuses the same URL as GET_ALL — POST vs GET differentiates the operation. Documented inline in the endpoint constants.
  • updateTopic sends { userSubscriptions: [...] }; updateCategory sends { categorySubscriptions: [...] }.
  • Each entry is a (topicId|publisherId, isSubscribed, notificationMode) triple.

Example Usage

import { NotificationMode, NotificationCategory } from '@uipath/uipath-typescript/notifications';

// Unsubscribe a single topic from a single channel
await subscriptions.updateTopic(tenantId, [
  { topicId: '<topicId>', isSubscribed: false, notificationMode: NotificationMode.Email },
]);

// Unsubscribe from all Error topics under one publisher via email
await subscriptions.updateCategory(tenantId, [
  {
    publisherId: '<publisherId>',
    category: NotificationCategory.Error,
    isSubscribed: false,
    notificationMode: NotificationMode.Email,
  },
]);

API Response vs SDK Response

Method SDK Response
updateTopic { success: true, data: { subscriptions } } (echoes input)
updateCategory { success: true, data: { subscriptions } } (echoes input)

Verification

Check Status
npm run typecheck ✅ clean
npm run lint ✅ 0 warnings, 0 errors
npm run test:unit ✅ 26 tests in notification suite (4 new)

Integration: updateTopic round-trip — flip a non-mandatory topic's mode, then restore. updateCategory is unit-only because it needs richer tenant fixtures (multi-topic category coverage).

Files

Area Files
Endpoint constants src/utils/constants/endpoints/notification.ts (UPDATE_TOPIC, UPDATE_CATEGORY)
Types src/models/notification/subscriptions.types.ts (TopicSubscriptionUpdate, CategorySubscriptionUpdate)
Models src/models/notification/subscriptions.models.ts (response types + ServiceModel methods)
Service src/services/notification/subscriptions.ts
Unit tests tests/unit/services/notification/subscriptions.test.ts (+4 tests)
Integration tests tests/integration/shared/notification/subscriptions.integration.test.ts (+1 round-trip test)
Test utils tests/utils/constants/notification.ts (ERROR_SUBSCRIPTION_INVALID)
Docs docs/oauth-scopes.md

PR Stack

# Branch Status
1 feat/notifications-sdk #512
2 feat/notifications-mark-read #513
3 feat/notifications-delete #514
4 feat/subscriptions-sdk #516
5 feat/subscriptions-topic-updates (this PR)
6 feat/subscriptions-publisher-updates upcoming
7 feat/subscriptions-mode-reset upcoming

🤖 Generated with Claude Code

…gory)

Adds the two topic/category-scoped subscription writes. Each entry in
the payload sets the subscription state for a single (topic, mode) or
(category, mode) pair.

UPDATE_TOPIC reuses the same URL as GET_ALL — POST vs GET differentiates.

Adds TopicSubscriptionUpdate and CategorySubscriptionUpdate types,
response types, oauth-scopes entries, and unit + integration tests
(updateTopic round-trip; updateCategory unit-only because it needs
richer tenant fixtures).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment on lines +210 to +211
it('should propagate errors', async () => {
mockApiClient.post.mockRejectedValue(createMockError(TEST_CONSTANTS.ERROR_MESSAGE));

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.

The updateCategory error test uses the generic TEST_CONSTANTS.ERROR_MESSAGE while the parallel updateTopic error test (line 174) correctly uses NOTIFICATION_TEST_CONSTANTS.ERROR_SUBSCRIPTION_INVALID. Per conventions, TEST_CONSTANTS.ERROR_MESSAGE is only acceptable for collection methods like getAll — mutation methods should use domain-specific error constants.

Suggested change
it('should propagate errors', async () => {
mockApiClient.post.mockRejectedValue(createMockError(TEST_CONSTANTS.ERROR_MESSAGE));
it('should propagate errors', async () => {
mockApiClient.post.mockRejectedValue(createMockError(NOTIFICATION_TEST_CONSTANTS.ERROR_SUBSCRIPTION_INVALID));

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in a2057e0 — switched to NOTIFICATION_TEST_CONSTANTS.ERROR_SUBSCRIPTION_INVALID.

notificationMode: NotificationMode.InApp,
},
])
).rejects.toThrow(TEST_CONSTANTS.ERROR_MESSAGE);

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.

Suggested change
).rejects.toThrow(TEST_CONSTANTS.ERROR_MESSAGE);
).rejects.toThrow(NOTIFICATION_TEST_CONSTANTS.ERROR_SUBSCRIPTION_INVALID);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in a2057e0 — switched to NOTIFICATION_TEST_CONSTANTS.ERROR_SUBSCRIPTION_INVALID.

@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review findings (1 issue):

New finding posted:

  • tests/unit/services/notification/subscriptions.test.ts lines 210–222 — updateCategory error test uses TEST_CONSTANTS.ERROR_MESSAGE (generic) instead of NOTIFICATION_TEST_CONSTANTS.ERROR_SUBSCRIPTION_INVALID (domain-specific), inconsistent with the parallel updateTopic error test. Per conventions, the generic constant is only acceptable for collection methods like getAll.

…ory test

Matches the parallel updateTopic error test on the same suite.

Addresses review comment on PR #517.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sarthak688

Copy link
Copy Markdown
Author

All findings addressed in the latest commit on this branch. Inline reply threads are resolved with commit references.

…scopes entries

Same internal-scope treatment.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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.

1 participant