MCPcopy Index your code
hub / github.com/simstudioai/sim / callNoteStore

Function callNoteStore

apps/sim/connectors/evernote/evernote.ts:64–97  ·  view source on GitHub ↗

* Sends a Thrift RPC call to the Evernote NoteStore via HTTP POST.

(
  token: string,
  writer: ThriftWriter,
  retryOptions?: Parameters<typeof fetchWithRetry>[2]
)

Source from the content-addressed store, hash-verified

62 * Sends a Thrift RPC call to the Evernote NoteStore via HTTP POST.
63 */
64async function callNoteStore(
65 token: string,
66 writer: ThriftWriter,
67 retryOptions?: Parameters<typeof fetchWithRetry>[2]
68): Promise<ThriftReader> {
69 const url = getNoteStoreUrl(token)
70
71 const response = await fetchWithRetry(
72 url,
73 {
74 method: 'POST',
75 headers: {
76 'Content-Type': 'application/x-thrift',
77 Accept: 'application/x-thrift',
78 },
79 body: new Uint8Array(writer.toBuffer()),
80 },
81 retryOptions
82 )
83
84 if (!response.ok) {
85 throw new Error(`Evernote HTTP ${response.status}: ${response.statusText}`)
86 }
87
88 const reader = new ThriftReader(await response.arrayBuffer())
89 const msg = reader.readMessageBegin()
90
91 if (reader.isException(msg.type)) {
92 const ex = reader.readException()
93 throw new Error(`Evernote API error: ${ex.message}`)
94 }
95
96 return reader
97}
98
99/**
100 * Checks for Evernote-specific exceptions in response struct fields 1-3.

Callers 4

apiListNotebooksFunction · 0.70
apiListTagsFunction · 0.70
apiFindNotesMetadataFunction · 0.70
apiGetNoteFunction · 0.70

Calls 6

readMessageBeginMethod · 0.95
isExceptionMethod · 0.95
readExceptionMethod · 0.95
fetchWithRetryFunction · 0.90
getNoteStoreUrlFunction · 0.70
toBufferMethod · 0.45

Tested by

no test coverage detected