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

Function apiGetNote

apps/sim/connectors/evernote/evernote.ts:317–364  ·  view source on GitHub ↗

* Calls NoteStore.getNote to fetch a single note with content. * * Thrift: getNote(1:token, 2:guid, 3:withContent, 4:withResourcesData, * 5:withResourcesRecognition, 6:withResourcesAlternateData) * Note: 1:guid, 2:title, 3:content, 6:created, 7:updated, 11:notebookGuid, 12:tagGui

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

Source from the content-addressed store, hash-verified

315 * Note: 1:guid, 2:title, 3:content, 6:created, 7:updated, 11:notebookGuid, 12:tagGuids
316 */
317async function apiGetNote(
318 token: string,
319 guid: string,
320 retryOptions?: Parameters<typeof fetchWithRetry>[2]
321): Promise<Note> {
322 const w = new ThriftWriter()
323 w.writeMessageBegin('getNote', 0)
324 w.writeStringField(1, token)
325 w.writeStringField(2, guid)
326 w.writeBoolField(3, true) // withContent
327 w.writeBoolField(4, false) // withResourcesData
328 w.writeBoolField(5, false) // withResourcesRecognition
329 w.writeBoolField(6, false) // withResourcesAlternateData
330 w.writeFieldStop()
331
332 const r = await callNoteStore(token, w, retryOptions)
333
334 let noteGuid = ''
335 let title = ''
336 let content = ''
337 let created = 0
338 let updated = 0
339 let notebookGuid = ''
340 const tagGuids: string[] = []
341
342 r.readStruct((r2, fid, ftype) => {
343 if (fid === 0 && ftype === TYPE_STRUCT) {
344 r2.readStruct((r3, fid3, ftype3) => {
345 if (fid3 === 1 && ftype3 === TYPE_STRING) noteGuid = r3.readString()
346 else if (fid3 === 2 && ftype3 === TYPE_STRING) title = r3.readString()
347 else if (fid3 === 3 && ftype3 === TYPE_STRING) content = r3.readString()
348 else if (fid3 === 6 && ftype3 === TYPE_I64) created = Number(r3.readI64())
349 else if (fid3 === 7 && ftype3 === TYPE_I64) updated = Number(r3.readI64())
350 else if (fid3 === 11 && ftype3 === TYPE_STRING) notebookGuid = r3.readString()
351 else if (fid3 === 12 && ftype3 === TYPE_LIST) {
352 const { size } = r3.readListBegin()
353 for (let t = 0; t < size; t++) tagGuids.push(r3.readString())
354 } else {
355 r3.skip(ftype3)
356 }
357 })
358 } else if (!checkException(r2, fid, ftype)) {
359 r2.skip(ftype)
360 }
361 })
362
363 return { guid: noteGuid || guid, title, content, created, updated, notebookGuid, tagGuids }
364}
365
366export const evernoteConnector: ConnectorConfig = {
367 ...evernoteConnectorMeta,

Callers 1

evernote.tsFile · 0.85

Calls 12

writeMessageBeginMethod · 0.95
writeStringFieldMethod · 0.95
writeBoolFieldMethod · 0.95
writeFieldStopMethod · 0.95
checkExceptionFunction · 0.85
readStructMethod · 0.80
readStringMethod · 0.80
readI64Method · 0.80
readListBeginMethod · 0.80
skipMethod · 0.80
callNoteStoreFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected