Skip to content

feat(subscriptions): publisher/group-level updates (PR 6/7) - #518

Open
sarthak688 wants to merge 1 commit into
mainfrom
feat/subscriptions-publisher-updates
Open

feat(subscriptions): publisher/group-level updates (PR 6/7)#518
sarthak688 wants to merge 1 commit into
mainfrom
feat/subscriptions-publisher-updates

Conversation

@sarthak688

Copy link
Copy Markdown
Contributor

PR 6/7 in the Notification SDK stack. Stacked on top of #517.

Adds the two broader-scope subscription writes — publisher-level opt-in/out and topic-group entity scoping.

Methods Added

Layer Method Signature
Service subscriptions.updatePublisher() updatePublisher(tenantId: string, subscriptions: PublisherSubscriptionUpdate[]): Promise<SubscriptionUpdatePublisherResponse>
Service subscriptions.updateTopicGroup() updateTopicGroup(tenantId: string, subscriptions: TopicGroupSubscriptionUpdate[]): Promise<SubscriptionUpdateTopicGroupResponse>

Endpoints Called

Method HTTP Endpoint OAuth Scope
updatePublisher() POST notificationservice_/usersubscriptionservice/api/v1/UserSubscription/PublisherSubscription NotificationService
updateTopicGroup() POST notificationservice_/usersubscriptionservice/api/v1/UserSubscription/TopicGroupSubscription NotificationService
  • API spec misspelling preserved: the publisher request body field is publisherID (sic), not publisherId. The SDK's public surface uses the clean spelling; the rename happens at send time inside updatePublisher.
  • Both methods accept arrays of entries — callers can batch many publisher/group updates per request.
  • updatePublisher supports optional entity scoping (e.g. opt in for two specific folders only); updateTopicGroup always scopes a named topic group to a list of entities.

Example Usage

// Opt out of a publisher entirely
await subscriptions.updatePublisher(tenantId, [
  { publisherId: '<publisherId>', isUserOptIn: false },
]);

// Subscribe a topic group to two folders
await subscriptions.updateTopicGroup(tenantId, [
  {
    publisherId: '<publisherId>',
    topicGroupName: 'JobNotifications',
    entities: [
      { id: '<folderId1>', type: 'Folder', isSubscribed: true },
      { id: '<folderId2>', type: 'Folder', isSubscribed: true },
    ],
  },
]);

Verification

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

Integration: updatePublisher round-trip — flip the user's opt-in for the first visible publisher, then restore. updateTopicGroup is unit-only because it needs a configured topic group on the test tenant.

Files

Area Files
Endpoint constants src/utils/constants/endpoints/notification.ts (UPDATE_PUBLISHER, UPDATE_TOPIC_GROUP)
Types src/models/notification/subscriptions.types.ts (PublisherSubscriptionUpdate, TopicGroupSubscriptionUpdate)
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 (+5 tests)
Integration tests tests/integration/shared/notification/subscriptions.integration.test.ts (+1 round-trip test)
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 #517
6 feat/subscriptions-publisher-updates (this PR)
7 feat/subscriptions-mode-reset upcoming

🤖 Generated with Claude Code

@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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

1 similar comment
@claude

claude Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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

Comment thread src/models/notification/subscriptions.models.ts
@deepeshrai-tech

Copy link
Copy Markdown
Contributor

in PR description u mentioned docs/oauth scopes have also changed but i dont see it , is that part of another dependent PR?

Comment thread src/utils/constants/endpoints/notification.ts
@sarthak688
sarthak688 force-pushed the feat/subscriptions-topic-updates branch 3 times, most recently from 41e8fbc to 08dd985 Compare July 21, 2026 08:12
Base automatically changed from feat/subscriptions-topic-updates to main July 21, 2026 10:11
@sarthak688
sarthak688 requested a review from a team July 21, 2026 10:11
…ers, updateTopicGroups) [internal]

Adds publisher-level opt-in/out and topic-group subscription writes. Each method
takes an array of update entries, batching many toggles into one request.

- updatePublishers:  POST notificationservice_/.../UserSubscription/PublisherSubscription
- updateTopicGroups: POST notificationservice_/.../UserSubscription/TopicGroupSubscription

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). Entity scoping uses a dedicated
SubscriptionEntityUpdate input type so callers only supply id/type/isSubscribed
rather than server-resolved discovery fields.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sarthak688
sarthak688 force-pushed the feat/subscriptions-publisher-updates branch from 6544536 to 71115d6 Compare July 22, 2026 06:15
Comment thread src/services/notification/subscriptions.ts
@claude

claude Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review summary: posted 1 new finding — updateTopicGroups passes subscriptions directly without mapping publisherIdpublisherID. Since updatePublishers needed this exact rename (same API controller), the topic-group endpoint likely shares the misspelling. The skipped integration test won''t surface it if wrong. See inline comment at src/services/notification/subscriptions.ts:104-105.

});
});

describe('updateTopicGroups', () => {

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.

unit test lacks entities-scoping coverage

@deepeshrai-tech

Copy link
Copy Markdown
Contributor

plz address claude comment

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