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

Function parsePostmanFiles

src/main/http/import/postman.ts:378–419  ·  view source on GitHub ↗
(files: HttpImportFile[])

Source from the content-addressed store, hash-verified

376}
377
378export function parsePostmanFiles(files: HttpImportFile[]): HttpImportResult {
379 const warnings: HttpImportWarning[] = []
380 const collections: HttpImportCollection[] = []
381 const environments: HttpImportEnvironment[] = []
382
383 for (const file of files) {
384 if (!isJsonFile(file))
385 continue
386
387 const raw = readJsonFile(file, warnings)
388 if (!raw) {
389 continue
390 }
391
392 if (isPostmanCollection(raw)) {
393 collections.push(parseCollection(raw, file.name, warnings))
394
395 const variables = parseVariables(raw.variable, file.name, warnings)
396 if (Object.keys(variables).length > 0) {
397 const infoName = isRecord(raw.info) ? raw.info.name : undefined
398 environments.push({
399 name: `${normalizeImportName(infoName, file.name.replace(/\.json$/i, ''))} Variables`,
400 variables,
401 })
402 }
403
404 continue
405 }
406
407 if (isPostmanEnvironment(raw)) {
408 environments.push(parseEnvironment(raw, file.name, warnings))
409 continue
410 }
411
412 if (isOpenApiDocument(raw))
413 continue
414
415 addWarning(warnings, file.name, 'Unsupported import file skipped')
416 }
417
418 return { collections, environments, warnings }
419}

Callers 3

parseHttpImportFilesFunction · 0.90
openapi.test.tsFile · 0.90
postman.test.tsFile · 0.90

Calls 11

normalizeImportNameFunction · 0.90
addWarningFunction · 0.90
isJsonFileFunction · 0.85
readJsonFileFunction · 0.85
isPostmanCollectionFunction · 0.85
parseCollectionFunction · 0.85
parseVariablesFunction · 0.85
isPostmanEnvironmentFunction · 0.85
isRecordFunction · 0.70
parseEnvironmentFunction · 0.70
isOpenApiDocumentFunction · 0.70

Tested by

no test coverage detected