Skip to content

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

Merged
sarthak688 merged 1 commit into
mainfrom
feat/subscriptions-topic-updates
Jul 21, 2026
Merged

feat(subscriptions): topic-level updates (PR 5/7)#517
sarthak688 merged 1 commit into
mainfrom
feat/subscriptions-topic-updates

Conversation

@sarthak688

@sarthak688 sarthak688 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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.updateTopics() updateTopics(tenantId: string, subscriptions: TopicSubscriptionUpdate[]): Promise<SubscriptionUpdateTopicsResponse>
Service subscriptions.updateCategories() updateCategories(tenantId: string, subscriptions: CategorySubscriptionUpdate[]): Promise<SubscriptionUpdateCategoriesResponse>

Endpoints Called

Method HTTP Endpoint OAuth Scope
updateTopics() POST notificationservice_/usersubscriptionservice/api/v1/UserSubscription NotificationService
updateCategories() 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.
  • updateTopics sends { userSubscriptions: [...] }; updateCategories sends { categorySubscriptions: [...] }.
  • Each entry is a (topicId|publisherId, isSubscribed, notificationMode) triple.
  • Both methods are plural — they take an array of updates (batch), per the SDK singular/plural cardinality convention.

Example Usage

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

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

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

API Response vs SDK Response

Method SDK Response
updateTopics { success: true, data: { subscriptions } } (echoes input)
updateCategories { success: true, data: { subscriptions } } (echoes input)

Verification

Check Status
npm run typecheck ✅ clean
npm run lint ✅ 0 warnings, 0 errors
npm run test:unit ✅ notification suite (updateTopics/updateCategories covered)

Integration: both updateTopics and updateCategories have round-trip tests (flip → restore) in the describe.skip block — ready to run once OAuth is wired into the integration harness (the subscription API rejects PAT auth).

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
Integration tests tests/integration/shared/notification/subscriptions.integration.test.ts
Test utils tests/utils/constants/notification.ts (ERROR_SUBSCRIPTION_INVALID)

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

Comment thread tests/unit/services/notification/subscriptions.test.ts Outdated
Comment thread tests/unit/services/notification/subscriptions.test.ts Outdated
@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.

sarthak688 added a commit that referenced this pull request Jun 12, 2026
…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
Contributor Author

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

@sarthak688
sarthak688 force-pushed the feat/subscriptions-sdk branch 3 times, most recently from 1d382c9 to 18c7fcb Compare July 9, 2026 07:15
@sarthak688
sarthak688 force-pushed the feat/subscriptions-sdk branch from f344546 to fa43848 Compare July 17, 2026 06:38
@Sarath1018
Sarath1018 force-pushed the feat/subscriptions-sdk branch from fa43848 to 12ea27d Compare July 17, 2026 07:38
Base automatically changed from feat/subscriptions-sdk to main July 17, 2026 07:47
@Sarath1018
Sarath1018 requested a review from a team July 17, 2026 07:47
@sarthak688
sarthak688 force-pushed the feat/subscriptions-topic-updates branch from 3987cc2 to 67e4d40 Compare July 20, 2026 05:03
Comment thread tests/integration/shared/notification/subscriptions.integration.test.ts Outdated
@claude

claude Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Review finding (1 new):

New finding posted:

  • tests/integration/shared/notification/subscriptions.integration.test.ts line 136 — updateCategory has no integration test body. Convention requires every new method to have one, even in a describe.skip file — the body should be written as if it will eventually run. A suggested round-trip block is in the inline comment.

Comment thread src/models/notification/subscriptions.models.ts Outdated
@Sarath1018

Copy link
Copy Markdown
Collaborator

Remove this from PR description: Docs | docs/oauth-scopes.md

@Sarath1018

Copy link
Copy Markdown
Collaborator

for PR gate check-samples to run I think you need to push something or close and open this PR

@sarthak688
sarthak688 force-pushed the feat/subscriptions-topic-updates branch from 67e4d40 to 41e8fbc Compare July 21, 2026 07:55
Comment thread tests/integration/shared/notification/subscriptions.integration.test.ts Outdated
@claude

claude Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review finding (1 new):

New finding posted:

  • tests/integration/shared/notification/subscriptions.integration.test.ts line 152 — updateCategories restore step hardcodes isSubscribed: true instead of snapshotting the original state before the flip. If the tenant's Error–Email category was originally unsubscribed, the test leaves it subscribed. The sibling updateTopics test (line 119) correctly reads mode.isSubscribed and restores to that exact value. Suggested fix: snapshot the original state from getAll() before flipping, same pattern as updateTopics.

…egories) [internal]

Adds topic- and category-scoped subscription writes. Each method takes an
array of update entries, batching many subscription toggles into one request.

- updateTopics:     POST notificationservice_/.../UserSubscription
- updateCategories: POST notificationservice_/.../UserSubscription/CategorySubscription

Both methods are @internal (NotificationService is an internal scope), so no
oauth-scopes.md entries. Response types live in subscriptions.types.ts and
JSDoc lives only on the ServiceModel interface (inherited by the service class
via `implements`, per the repo convention).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sarthak688
sarthak688 force-pushed the feat/subscriptions-topic-updates branch from 41e8fbc to 08dd985 Compare July 21, 2026 08:12
@claude

claude Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

✅ No issues found. Checked for bugs and CLAUDE.md compliance.

@sonarqubecloud

Copy link
Copy Markdown

@sarthak688
sarthak688 requested a review from Sarath1018 July 21, 2026 08:24
@sarthak688
sarthak688 merged commit fcc1c29 into main Jul 21, 2026
15 checks passed
@sarthak688
sarthak688 deleted the feat/subscriptions-topic-updates branch July 21, 2026 10:11
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.

3 participants