MCPcopy Index your code
hub / github.com/massCodeIO/massCode / buildCaptureRequest

Function buildCaptureRequest

integrations/clipper/src/api.ts:34–83  ·  view source on GitHub ↗
(
  target: CaptureTarget,
  payload: PageCapturePayload,
  explicitName?: string,
)

Source from the content-addressed store, hash-verified

32}
33
34export function buildCaptureRequest(
35 target: CaptureTarget,
36 payload: PageCapturePayload,
37 explicitName?: string,
38): CaptureRequest {
39 const selectedText = payload.selectedText.trim()
40 const noteMarkdown = payload.selectedMarkdown ?? payload.pageMarkdown
41 const noteText = selectedText || payload.pageText || payload.pageTitle
42 const name = trimToValue(explicitName)
43
44 if (target === 'http') {
45 const url = findFirstUrl(selectedText) ?? payload.url
46
47 return {
48 contextLabel: payload.contextLabel,
49 method: 'GET',
50 name,
51 pageTitle: payload.pageTitle,
52 sourceTitle: payload.sourceTitle,
53 sourceUrl: payload.sourceUrl,
54 source: {
55 capturedAt: Date.now(),
56 title: payload.sourceTitle,
57 url: payload.sourceUrl,
58 },
59 suggestedName: getHttpSuggestedName(url),
60 target,
61 url,
62 }
63 }
64
65 return {
66 contextLabel: payload.contextLabel,
67 language: target === 'code' ? getCodeLanguage(payload) : undefined,
68 markdown: target === 'notes' ? noteMarkdown : undefined,
69 name,
70 pageTitle: payload.pageTitle,
71 sourceTitle: payload.sourceTitle,
72 sourceUrl: payload.sourceUrl,
73 source: {
74 capturedAt: Date.now(),
75 title: payload.sourceTitle,
76 url: payload.sourceUrl,
77 },
78 suggestedName: payload.suggestedName ?? payload.contextLabel,
79 target,
80 text: target === 'notes' ? noteText : selectedText,
81 url: payload.url,
82 }
83}
84
85export function getCaptureNameSuggestion(
86 target: CaptureTarget,

Callers 2

captureFromTabFunction · 0.90
captureCurrentPayloadFunction · 0.90

Calls 4

findFirstUrlFunction · 0.85
getHttpSuggestedNameFunction · 0.85
getCodeLanguageFunction · 0.85
trimToValueFunction · 0.70

Tested by

no test coverage detected