MCPcopy Create free account
hub / github.com/massCodeIO/massCode / walkItems

Function walkItems

src/main/http/import/postman.ts:324–355  ·  view source on GitHub ↗
(
  items: unknown[],
  collection: HttpImportCollection,
  parentId: string | null,
  context: PostmanContext,
  sourcePath: string,
  warnings: HttpImportWarning[],
)

Source from the content-addressed store, hash-verified

322}
323
324function walkItems(
325 items: unknown[],
326 collection: HttpImportCollection,
327 parentId: string | null,
328 context: PostmanContext,
329 sourcePath: string,
330 warnings: HttpImportWarning[],
331): void {
332 for (const [index, item] of items.entries()) {
333 if (!isRecord(item)) {
334 continue
335 }
336
337 const name = normalizeImportName(item.name, `Item ${index + 1}`)
338 const source = `${sourcePath}/${name}`
339 const itemAuth = parseAuth(item.auth, source, warnings)
340 const nextContext = itemAuth ? { auth: itemAuth } : context
341
342 if (Array.isArray(item.item)) {
343 const id = asString(item.id || item._postman_id) || `${source}:${index}`
344 const folder: HttpImportFolder = { id, name, parentId }
345 collection.folders.push(folder)
346 walkItems(item.item, collection, id, nextContext, source, warnings)
347 continue
348 }
349
350 const request = parseRequest(item, parentId, nextContext, source, warnings)
351 if (request) {
352 collection.requests.push(request)
353 }
354 }
355}
356
357function parseCollection(
358 raw: UnknownRecord,

Callers 1

parseCollectionFunction · 0.85

Calls 5

normalizeImportNameFunction · 0.90
isRecordFunction · 0.70
parseAuthFunction · 0.70
asStringFunction · 0.70
parseRequestFunction · 0.70

Tested by

no test coverage detected