( items: unknown[], collection: HttpImportCollection, parentId: string | null, context: PostmanContext, sourcePath: string, warnings: HttpImportWarning[], )
| 322 | } |
| 323 | |
| 324 | function 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 | |
| 357 | function parseCollection( |
| 358 | raw: UnknownRecord, |
no test coverage detected