@yiliang114/social-assist-core
v0.0.1
Published
`@yiliang114/social-assist-core` 是一个纯逻辑包,用来承载 `social-assist` 的可复用部分,不依赖 Nest,也不负责数据库持久化。
Downloads
98
Readme
social-assist-core
@yiliang114/social-assist-core 是一个纯逻辑包,用来承载 social-assist 的可复用部分,不依赖 Nest,也不负责数据库持久化。
适合什么时候用
适合:
- 其他 Node 服务想直接生成 GitHub / X / 小红书草稿
- 想复用 hashtag 归一化、X compose URL、模板库读取
- 不需要直接依赖
nest-api的数据库和 HTTP 层
不适合:
- 你需要历史草稿持久化
- 你需要统一走
nest-api的鉴权和接口 - 你需要热点机会抓取接口
这些场景应该调 nest-api 的 social-assist 接口,而不是直接用这个包。
当前导出
当前主入口:
buildSocialDraftPackrenderDraftPackMarkdownnormalizeHashtagsbuildXComposeUrlbuildXClipboardTextbuildXiaohongshuDraftlistSocialAssistTemplates
最小示例
import { buildSocialDraftPack } from '@yiliang114/social-assist-core'
const pack = buildSocialDraftPack({
authorLogin: 'yiliang114',
repository: 'org/repo',
source: 'github_pr',
tone: 'professional',
title: 'Ship social assist studio',
summary: '前后端已经打通,并支持历史草稿恢复。',
url: 'https://github.com/org/repo/pull/123',
hashtags: ['opensource', 'workflow'],
})
console.log(pack.github.recommendedText)
console.log(pack.x.composeUrl)
console.log(pack.xiaohongshu.draftBody)模板库示例
import { listSocialAssistTemplates } from '@yiliang114/social-assist-core'
const result = await listSocialAssistTemplates({
libraryDir: 'scripts/ts/social-assist/library',
kind: 'x_reply',
limit: 8,
})
console.log(result.items)推荐的复用分层
1. 纯逻辑复用
直接依赖本包。
适合:
- CLI
- worker
- 独立 Node 服务
2. 统一能力复用
调 nest-api 的 social-assist HTTP 接口。
适合:
- 多前端共用同一套行为
- 需要统一鉴权
- 需要历史记录和数据库
3. 同仓库 Nest 模块复用
如果你就在本仓库内,并且需要持久化和模板服务,优先直接复用 SocialAssistModule,不要在 Nest 服务里重复造 HTTP 调用。
