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

Function parseRequest

src/main/http/import/opencollection.ts:355–407  ·  view source on GitHub ↗
(
  file: HttpImportFile,
  raw: UnknownRecord,
  folderId: string | null,
  warnings: HttpImportWarning[],
)

Source from the content-addressed store, hash-verified

353}
354
355function parseRequest(
356 file: HttpImportFile,
357 raw: UnknownRecord,
358 folderId: string | null,
359 warnings: HttpImportWarning[],
360): HttpImportRequest | null {
361 const info = getInfo(raw)
362 const http = isRecord(raw.http) ? raw.http : {}
363 const source = file.name
364 const method = normalizeHttpMethod(http.method, source, warnings)
365 if (!method)
366 return null
367
368 const params = parseParams(http.params)
369 const parsedUrl = splitUrlAndQuery(
370 applyPathParams(asString(http.url), params.pathParams),
371 )
372 const auth = parseAuth(http.auth, source, warnings)
373 const headers = normalizeEntries(
374 [...parseHeaders(http.headers), ...auth.headers],
375 source,
376 warnings,
377 )
378 const query = normalizeEntries(
379 [...mergeQueryEntries(parsedUrl.query, params.query), ...auth.query],
380 source,
381 warnings,
382 )
383 const body = parseBody(http.body, source, warnings)
384 const parts = createEmptyRequestParts()
385
386 if (isRecord(raw.runtime)) {
387 if (Array.isArray(raw.runtime.scripts)) {
388 addWarning(warnings, source, 'Runtime scripts skipped')
389 }
390 if (Array.isArray(raw.runtime.assertions)) {
391 addWarning(warnings, source, 'Assertions skipped')
392 }
393 }
394
395 return {
396 ...parts,
397 ...body,
398 auth: resolveAuthConflict(headers, auth.auth, source, warnings),
399 description: asString(raw.docs),
400 folderId,
401 headers,
402 method,
403 name: normalizeImportName(info.name, basename(file.name)),
404 query,
405 url: parsedUrl.url,
406 }
407}
408
409function ensureFolder(
410 collection: HttpImportCollection,

Callers 2

parseBundledItemsFunction · 0.70
parseOpenCollectionFilesFunction · 0.70

Calls 15

normalizeHttpMethodFunction · 0.90
splitUrlAndQueryFunction · 0.90
normalizeEntriesFunction · 0.90
createEmptyRequestPartsFunction · 0.90
addWarningFunction · 0.90
resolveAuthConflictFunction · 0.90
normalizeImportNameFunction · 0.90
parseParamsFunction · 0.85
applyPathParamsFunction · 0.85
getInfoFunction · 0.70
isRecordFunction · 0.70
asStringFunction · 0.70

Tested by

no test coverage detected