for await()

in src/backend/inventory/canary.lambda.ts [53:115]


  for await (const key of relevantObjectKeys(bucket)) {
    const [, name, version] = constants.STORAGE_KEY_FORMAT_REGEX.exec(key)!;

    packageNames.add(name);
    const majorVersion = `${name}@${new SemVer(version).major}`;
    packageMajorVersions.add(majorVersion);

    const fullName = `${name}@${version}`;

    // Ensure the package is fully registered for per-language status, even if no doc exists yet.
    for (const language of DocumentationLanguage.ALL) {
      recordPerLanguage(language, PerLanguageStatus.MISSING, name, majorVersion, fullName);
    }

    if (!indexedPackages.has(fullName)) {
      indexedPackages.set(fullName, {});
    }
    const status = indexedPackages.get(fullName)!;

    if (key.endsWith(constants.METADATA_KEY_SUFFIX)) {
      status.metadataPresent = true;
    } else if (key.endsWith(constants.PACKAGE_KEY_SUFFIX)) {
      status.tarballPresent = true;
    } else if (key.endsWith(constants.ASSEMBLY_KEY_SUFFIX)) {
      status.assemblyPresent = true;
    } else if (key.endsWith(constants.UNINSTALLABLE_PACKAGE_SUFFIX)) {
      status.uninstallable = true;
    } else {
      let identified = false;
      for (const language of DocumentationLanguage.ALL) {
        const match = submoduleKeyRegexp(language).exec(key);
        if (match != null) {
          const [, submodule, isUnsupported] = match;
          if (status.submodules == null) {
            status.submodules = new Set();
          }
          status.submodules.add(`${fullName}.${submodule}`);
          recordPerLanguage(
            language,
            isUnsupported ? PerLanguageStatus.UNSUPPORTED : PerLanguageStatus.SUPPORTED,
            name,
            majorVersion,
            fullName,
            submodule,
          );
          identified = true;
        } else if (key.endsWith(constants.docsKeySuffix(language, 'md'))) {
          recordPerLanguage(language, PerLanguageStatus.SUPPORTED, name, majorVersion, fullName);
          identified = true;
        } else if (key.endsWith(constants.notSupportedKeySuffix(language, undefined, 'md'))) {
          recordPerLanguage(language, PerLanguageStatus.UNSUPPORTED, name, majorVersion, fullName);
          identified = true;
        } else if (key.endsWith(constants.corruptAssemblyKeySuffix(language, undefined, 'md'))) {
          recordPerLanguage(language, PerLanguageStatus.CORRUPT_ASSEMBLY, name, majorVersion, fullName);
          identified = true;
        }
      }
      if (!identified) {
        status.unknownObjects = status.unknownObjects ?? [];
        status.unknownObjects.push(key);
      }
    }
  }