Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
173 lines
5.1 KiB
TypeScript
173 lines
5.1 KiB
TypeScript
import api from './api'
|
|
|
|
/** Response shape for cursor-based feed endpoints */
|
|
interface CursorFeedResponse<T> {
|
|
posts: T[]
|
|
nextCursor: string | null
|
|
}
|
|
|
|
export const postService = {
|
|
getFeed: async (page = 1, limit = 10) => {
|
|
const { data } = await api.get('/posts/feed', { params: { page, limit } })
|
|
return data
|
|
},
|
|
|
|
/**
|
|
* Cursor-based feed — prevents duplicate / missing posts when new content
|
|
* is published between page fetches. Pass the `nextCursor` value from the
|
|
* previous response to get the next page; omit `cursor` for the first page.
|
|
*/
|
|
getFeedCursor: async (cursor?: string, limit: number = 10): Promise<CursorFeedResponse<Record<string, unknown>>> => {
|
|
const params: Record<string, string | number> = { limit }
|
|
if (cursor) {
|
|
params.cursor = cursor
|
|
}
|
|
const { data } = await api.get('/posts/feed', { params })
|
|
return data as CursorFeedResponse<Record<string, unknown>>
|
|
},
|
|
|
|
getPost: async (id: string) => {
|
|
const { data } = await api.get(`/posts/${id}`)
|
|
return data
|
|
},
|
|
|
|
createPost: async (formData: FormData) => {
|
|
const { data } = await api.post('/posts', formData, {
|
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
})
|
|
return data
|
|
},
|
|
|
|
updatePost: async (id: string, updates: { content?: string; visibility?: string; hashtags?: string[] }) => {
|
|
const { data } = await api.put(`/posts/${id}`, updates)
|
|
return data
|
|
},
|
|
|
|
deletePost: async (id: string) => {
|
|
await api.delete(`/posts/${id}`)
|
|
},
|
|
|
|
likePost: async (id: string) => {
|
|
const { data } = await api.post(`/posts/${id}/like`)
|
|
return data
|
|
},
|
|
|
|
unlikePost: async (id: string) => {
|
|
await api.delete(`/posts/${id}/like`)
|
|
},
|
|
|
|
getComments: async (postId: string) => {
|
|
const { data } = await api.get(`/posts/${postId}/comments`)
|
|
return data
|
|
},
|
|
|
|
addComment: async (postId: string, content: string) => {
|
|
const { data } = await api.post(`/posts/${postId}/comments`, { content })
|
|
return data
|
|
},
|
|
|
|
deleteComment: async (postId: string, commentId: string) => {
|
|
await api.delete(`/posts/${postId}/comments/${commentId}`)
|
|
},
|
|
|
|
// Comment actions
|
|
likeComment: async (postId: string, commentId: string) => {
|
|
const { data } = await api.post(`/v1/posts/${postId}/comments/${commentId}/like`)
|
|
return data
|
|
},
|
|
|
|
getCommentLikes: async (postId: string, commentId: string) => {
|
|
const { data } = await api.get(`/v1/posts/${postId}/comments/${commentId}/likes`)
|
|
return data
|
|
},
|
|
|
|
updateComment: async (postId: string, commentId: string, content: string) => {
|
|
const { data } = await api.put(`/v1/posts/${postId}/comments/${commentId}`, { content })
|
|
return data
|
|
},
|
|
|
|
savePost: async (id: string) => {
|
|
const { data } = await api.post(`/post-actions/save/${id}`)
|
|
return data
|
|
},
|
|
|
|
unsavePost: async (id: string) => {
|
|
await api.delete(`/post-actions/save/${id}`)
|
|
},
|
|
|
|
sharePost: async (id: string) => {
|
|
const { data } = await api.post(`/post-actions/share/${id}`)
|
|
return data
|
|
},
|
|
|
|
reportPost: async (id: string, reason: string) => {
|
|
const { data } = await api.post(`/post-actions/report/${id}`, { reason })
|
|
return data
|
|
},
|
|
|
|
retweetPost: async (id: string, comment?: string) => {
|
|
const { data } = await api.post(`/posts/${id}/retweet`, { comment })
|
|
return data
|
|
},
|
|
|
|
searchPosts: async (query: string) => {
|
|
const { data } = await api.get('/search/posts', { params: { q: query } })
|
|
return data
|
|
},
|
|
|
|
getSavedPosts: async () => {
|
|
const { data } = await api.get('/post-actions/saved')
|
|
return data
|
|
},
|
|
|
|
/**
|
|
* Create a post with optional AITM checkpoint linkage.
|
|
* Attaches checkpoint metadata to the FormData before sending.
|
|
*/
|
|
createPostWithCheckpoint: async (
|
|
formData: FormData,
|
|
checkpoint: {
|
|
checkpointId: string
|
|
projectId: string
|
|
fromCheckpointId?: string
|
|
diffSummary?: { added: number; removed: number; modified: number }
|
|
changedFiles?: string[]
|
|
changeStoryTitle?: string
|
|
}
|
|
) => {
|
|
formData.append('checkpointId', checkpoint.checkpointId)
|
|
formData.append('aitmProjectId', checkpoint.projectId)
|
|
if (checkpoint.fromCheckpointId) {
|
|
formData.append('fromCheckpointId', checkpoint.fromCheckpointId)
|
|
}
|
|
if (checkpoint.diffSummary) {
|
|
formData.append('diffSummary', JSON.stringify(checkpoint.diffSummary))
|
|
}
|
|
if (checkpoint.changedFiles) {
|
|
formData.append('changedFiles', JSON.stringify(checkpoint.changedFiles))
|
|
}
|
|
if (checkpoint.changeStoryTitle) {
|
|
formData.append('changeStoryTitle', checkpoint.changeStoryTitle)
|
|
}
|
|
const { data } = await api.post('/posts', formData, {
|
|
headers: { 'Content-Type': 'multipart/form-data' },
|
|
})
|
|
return data
|
|
},
|
|
|
|
/**
|
|
* Create a post directly from an AITM checkpoint.
|
|
* Uses the dedicated `/posts/from-checkpoint` endpoint.
|
|
*/
|
|
createPostFromCheckpoint: async (params: {
|
|
checkpointId: string
|
|
projectId: string
|
|
message?: string
|
|
visibility?: 'public' | 'followers' | 'private'
|
|
}) => {
|
|
const { data } = await api.post('/posts/from-checkpoint', params)
|
|
return data
|
|
},
|
|
}
|
|
|