MCPcopy Index your code
hub / github.com/codeaashu/claude-code / fetchTeamMemoryOnce

Function fetchTeamMemoryOnce

src/services/teamMemorySync/index.ts:188–306  ·  view source on GitHub ↗
(
  state: SyncState,
  repoSlug: string,
  etag?: string | null,
)

Source from the content-addressed store, hash-verified

186// ─── Fetch (pull) ────────────────────────────────────────────
187
188async function fetchTeamMemoryOnce(
189 state: SyncState,
190 repoSlug: string,
191 etag?: string | null,
192): Promise<TeamMemorySyncFetchResult> {
193 try {
194 await checkAndRefreshOAuthTokenIfNeeded()
195
196 const auth = getAuthHeaders()
197 if (auth.error) {
198 return {
199 success: false,
200 error: auth.error,
201 skipRetry: true,
202 errorType: 'auth',
203 }
204 }
205
206 const headers: Record<string, string> = { ...auth.headers }
207 if (etag) {
208 headers['If-None-Match'] = `"${etag.replace(/"/g, '')}"`
209 }
210
211 const endpoint = getTeamMemorySyncEndpoint(repoSlug)
212 const response = await axios.get(endpoint, {
213 headers,
214 timeout: TEAM_MEMORY_SYNC_TIMEOUT_MS,
215 validateStatus: status =>
216 status === 200 || status === 304 || status === 404,
217 })
218
219 if (response.status === 304) {
220 logForDebugging('team-memory-sync: not modified (304)', {
221 level: 'debug',
222 })
223 return { success: true, notModified: true, checksum: etag ?? undefined }
224 }
225
226 if (response.status === 404) {
227 logForDebugging('team-memory-sync: no remote data (404)', {
228 level: 'debug',
229 })
230 state.lastKnownChecksum = null
231 return { success: true, isEmpty: true }
232 }
233
234 const parsed = TeamMemoryDataSchema().safeParse(response.data)
235 if (!parsed.success) {
236 logForDebugging('team-memory-sync: invalid response format', {
237 level: 'warn',
238 })
239 return {
240 success: false,
241 error: 'Invalid team memory response format',
242 skipRetry: true,
243 errorType: 'parse',
244 }
245 }

Callers 1

fetchTeamMemoryFunction · 0.85

Calls 6

logForDebuggingFunction · 0.85
classifyAxiosErrorFunction · 0.85
getAuthHeadersFunction · 0.70
getMethod · 0.65

Tested by

no test coverage detected