Skip to content

Comments

feat: implement service-feed package with IFeedService contract and system objects#747

Merged
hotlong merged 2 commits intomainfrom
copilot/create-feed-chatter-service
Feb 20, 2026
Merged

feat: implement service-feed package with IFeedService contract and system objects#747
hotlong merged 2 commits intomainfrom
copilot/create-feed-chatter-service

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

Feed/Chatter protocol layer exists (feed.zod.ts, feed-api.zod.ts, subscription.zod.ts) but lacks a service implementation and persistent object definitions. This adds @objectstack/service-feed following the Plugin + Adapter pattern established by service-i18n and service-realtime.

IFeedService Contract (packages/spec/src/contracts/feed-service.ts)

  • Feed CRUD: listFeed, createFeedItem, updateFeedItem, deleteFeedItem, getFeedItem
  • Reactions: addReaction, removeReaction
  • Subscriptions: subscribe, unsubscribe, getSubscription

System Object Metadata (packages/services/service-feed/src/objects/)

  • sys_feed_item — 13 activity types, threading via parent_id/reply_count, visibility levels
  • sys_feed_reaction — Unique constraint on (feed_item_id, emoji, user_id)
  • sys_record_subscription — Event type + channel arrays, unique per (object, record_id, user_id)

All use sys_ prefix per #738 naming convention. Objects live in the service package, not in spec/core.

InMemoryFeedAdapter

  • Cursor-based pagination with stable sort (timestamp + ID tiebreak)
  • Filter modes: all, comments_only, changes_only, tasks_only
  • Thread reply count maintenance on create/delete
  • Reaction aggregation with duplicate detection
  • Subscription upsert semantics

FeedServicePlugin

  • Plugin ID: com.objectstack.service.feed, registers as 'feed' service
const kernel = new ObjectKernel();
kernel.use(new FeedServicePlugin());
await kernel.bootstrap();

const feed = kernel.getService<IFeedService>('feed');
await feed.createFeedItem({
  object: 'account', recordId: 'rec_123', type: 'comment',
  actor: { type: 'user', id: 'user_1', name: 'Alice' },
  body: 'Great progress!',
});

Tests

  • 40 unit tests for InMemoryFeedAdapter (CRUD, filtering, pagination, threading, reactions, subscriptions, edge cases)
  • 4 contract compliance tests for IFeedService

ROADMAP

  • Added to Phase 4c table, implementation tracker (row 15), and package registry
Original prompt

This section details on the original issue you should resolve

<issue_title>实现 Feed/Chatter 核心服务:service-feed 包开发与业务对象定义</issue_title>
<issue_description>### 背景
当前协议层已经定义好 Feed/Chatter 相关的数据协议(feed.zod.ts、feed-api.zod.ts、subscription.zod.ts),但缺少实际可用的服务层实现和持久化支撑。为配合架构最佳实践,需将"Feed/Chatter"相关业务对象(如 feed_item、feed_reaction、record_subscription)与其业务服务实现一并放入新的包 packages/services/service-feed/ 中。

目标

  1. 新建 packages/services/service-feed/ 服务包,实现 Feed/Chatter 相关 API 业务逻辑与持久化适配层。
  2. 将 Feed/Chatter 的业务对象定义(metadata,包括 sys_feed_item、sys_feed_reaction、sys_record_subscription)放在该服务包内,实现"协议分包、对象归属服务"的体系化落地。
  3. 系统对象命名需要参考规范,统一系统内核对象命名前缀为 sys_,对标主流低代码平台最佳实践 #738
  4. 按照协议和 API Contracts 提供真实可用的 Feed/Chatter 接口,支持评论、字段变更历史、回复、Reaction、订阅等功能。

主要任务拆解

Phase 1: 服务骨架与对象定义

  • 新建 packages/services/service-feed/ 目录与基础结构
  • 在 service-feed 包内定义 feed_item、feed_reaction、record_subscription 三大系统业务对象(元数据/metadata)

Phase 2: 核心业务实现

  • 实现 FeedRepository 和 FeedService(含接口契约)
  • 完成 API 层 Zod 校验与持久化 CRUD
  • 路由注册(通过 RestServer/Dispatcher plugin)映射至 /api/v1/data/:object/:recordId/feed 及相关 endpoints

Phase 3: 增值特性与兼容

  • 支持字段变更自动追踪(event-bus 监听 data.afterUpdate)
  • 支持 @mention 理解与通知集成(可选,视是否有 notification/realtime service)
  • 实现 reactions、threading、订阅增强

Phase 4: 测试与文档

  • 单元和集成测试
  • 示例/文档和用法演示

前置条件

  • data service 对象驱动能力可用(已就绪)
  • http.server 服务已安装(如 plugin-hono-server)
  • event-bus 可用性(建议)
  • 已有 Feed 协议层(feed.zod.ts/feed-api.zod.ts)

参考


业务对象(如 feed_item、feed_reaction 等)须在其服务包(service-feed)中定义和分组归属,严禁分散于协议 core/spec 层。
实现完毕需自动校对/运行测试并在 ROADMAP 标记进度。</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link

vercel bot commented Feb 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Feb 19, 2026 7:01pm
spec Ready Ready Preview, Comment Feb 19, 2026 7:01pm

Request Review

…moryFeedAdapter, and system objects

- Add IFeedService contract to @objectstack/spec/contracts
- Create @objectstack/service-feed with InMemoryFeedAdapter
- Define sys_feed_item, sys_feed_reaction, sys_record_subscription objects
- Add FeedServicePlugin for kernel registration
- 40 tests for InMemoryFeedAdapter + 4 contract tests
- Update ROADMAP.md with service-feed progress

Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement Feed/Chatter core service in service-feed package feat: implement service-feed package with IFeedService contract and system objects Feb 19, 2026
Copilot AI requested a review from hotlong February 19, 2026 19:02
@hotlong hotlong marked this pull request as ready for review February 20, 2026 01:25
Copilot AI review requested due to automatic review settings February 20, 2026 01:25
@hotlong hotlong merged commit 0e95686 into main Feb 20, 2026
6 checks passed
Copy link
Contributor

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

This PR implements the @objectstack/service-feed package, providing a complete Feed/Chatter service following the Plugin + Adapter pattern established by other service packages like service-i18n and service-realtime. The implementation includes the IFeedService contract, system object metadata definitions with sys_ prefix per #738, an in-memory adapter with comprehensive features, and extensive test coverage.

Changes:

  • Added IFeedService contract in @objectstack/spec with 9 methods covering feed CRUD, reactions, and subscriptions
  • Implemented 3 system objects (sys_feed_item, sys_feed_reaction, sys_record_subscription) with proper indexes and field definitions
  • Created InMemoryFeedAdapter with cursor-based pagination, filtering modes, threading support, reaction management, and subscription upsert semantics
  • Added FeedServicePlugin following com.objectstack.service.* naming convention
  • Included 44 comprehensive tests (4 contract, 40 adapter unit tests)
  • Updated ROADMAP.md to reflect implementation status

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/spec/src/contracts/feed-service.ts IFeedService contract definition with feed CRUD, reactions, and subscriptions methods
packages/spec/src/contracts/feed-service.test.ts Contract compliance tests verifying interface implementation
packages/spec/src/contracts/index.ts Export for feed-service contract
packages/services/service-feed/src/objects/feed-item.object.ts System object definition for sys_feed_item with 13 activity types and threading support
packages/services/service-feed/src/objects/feed-reaction.object.ts System object definition for sys_feed_reaction with unique constraint per user/emoji
packages/services/service-feed/src/objects/record-subscription.object.ts System object definition for sys_record_subscription with event/channel arrays
packages/services/service-feed/src/objects/index.ts Object metadata exports
packages/services/service-feed/src/in-memory-feed-adapter.ts InMemoryFeedAdapter implementing IFeedService with full feature set
packages/services/service-feed/src/in-memory-feed-adapter.test.ts 40 comprehensive unit tests covering all adapter functionality
packages/services/service-feed/src/feed-service-plugin.ts FeedServicePlugin for kernel integration
packages/services/service-feed/src/index.ts Package exports
packages/services/service-feed/package.json Package configuration with dependencies and scripts
packages/services/service-feed/tsconfig.json TypeScript configuration
pnpm-lock.yaml Dependency lockfile update for new package
ROADMAP.md Updated Phase 4c table, implementation tracker (row 15→576), package registry (row 618), and summary count (14 implemented)
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

* Follows Dependency Inversion Principle - plugins depend on this interface,
* not on concrete feed service implementations.
*
* Aligned with CoreServiceName 'feed' in core-services.zod.ts.
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.

The comment on line 14 states "Aligned with CoreServiceName 'feed' in core-services.zod.ts", but 'feed' is not actually present in the CoreServiceName enum (packages/spec/src/system/core-services.zod.ts). Other similar services like 'realtime' and 'i18n' are included in CoreServiceName. The 'feed' service name should be added to the CoreServiceName enum to maintain consistency with the established pattern and to enable proper service registration validation.

Suggested change
* Aligned with CoreServiceName 'feed' in core-services.zod.ts.
* Service contract for the feed/chatter core service within the ObjectStack runtime.

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.

实现 Feed/Chatter 核心服务:service-feed 包开发与业务对象定义

2 participants