construct-hub 0.3.337 → 0.3.340
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +2 -2
- package/changelog.md +1 -1
- package/lib/backend/inventory/canary.lambda.bundle/index.js +208 -97
- package/lib/backend/inventory/canary.lambda.bundle/index.js.map +2 -2
- package/lib/backend/inventory/canary.lambda.d.ts +58 -2
- package/lib/backend/inventory/canary.lambda.js +209 -94
- package/lib/backend/inventory/index.d.ts +3 -3
- package/lib/backend/inventory/index.js +47 -12
- package/lib/backend/transliterator/transliterator.ecs-entrypoint.bundle/index.js +3 -3
- package/lib/construct-hub.js +1 -1
- package/lib/package-sources/code-artifact.js +1 -1
- package/lib/package-sources/npmjs.js +1 -1
- package/lib/package-tag/index.js +3 -3
- package/lib/package-tag-group/index.js +2 -2
- package/lib/preload-file/index.js +1 -1
- package/lib/s3/storage.js +1 -1
- package/lib/spdx-license.js +1 -1
- package/package.json +3 -3
- package/releasetag.txt +1 -1
- package/version.txt +1 -1
package/.jsii
CHANGED
@@ -15450,6 +15450,6 @@
|
|
15450
15450
|
"symbolId": "src/package-sources/npmjs:NpmJsProps"
|
15451
15451
|
}
|
15452
15452
|
},
|
15453
|
-
"version": "0.3.
|
15454
|
-
"fingerprint": "
|
15453
|
+
"version": "0.3.340",
|
15454
|
+
"fingerprint": "S0Q8aQnP/TyHexqnVHykEwOLUKH5iJiWWTDTJwjrQq4="
|
15455
15455
|
}
|
package/changelog.md
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
|
2
|
-
### [0.3.
|
2
|
+
### [0.3.340](https://github.com/cdklabs/construct-hub/compare/v0.3.339...v0.3.340) (2022-05-02)
|
@@ -9577,9 +9577,14 @@ var require_lib2 = __commonJS({
|
|
9577
9577
|
// src/backend/inventory/canary.lambda.ts
|
9578
9578
|
var canary_lambda_exports = {};
|
9579
9579
|
__export(canary_lambda_exports, {
|
9580
|
-
|
9580
|
+
DocumentationStatus: () => DocumentationStatus,
|
9581
|
+
Grain: () => Grain,
|
9582
|
+
deserialize: () => deserialize,
|
9583
|
+
handler: () => handler,
|
9584
|
+
serialize: () => serialize
|
9581
9585
|
});
|
9582
9586
|
module.exports = __toCommonJS(canary_lambda_exports);
|
9587
|
+
var import_zlib2 = require("zlib");
|
9583
9588
|
var import_aws_embedded_metrics = __toESM(require_lib());
|
9584
9589
|
var import_semver = __toESM(require_semver2());
|
9585
9590
|
|
@@ -9707,83 +9712,140 @@ var LANGUAGE_DIMENSION = "Language";
|
|
9707
9712
|
import_aws_embedded_metrics.Configuration.namespace = METRICS_NAMESPACE;
|
9708
9713
|
async function handler(event, context) {
|
9709
9714
|
console.log("Event:", JSON.stringify(event, null, 2));
|
9710
|
-
const
|
9711
|
-
const packageNames =
|
9712
|
-
|
9713
|
-
|
9715
|
+
const scratchworkBucket = requireEnv("SCRATCHWORK_BUCKET_NAME");
|
9716
|
+
const { continuationToken, indexedPackages, packageNames, packageMajorVersions, perLanguage } = event.continuationObjectKey ? await loadProgress(event.continuationObjectKey) : {
|
9717
|
+
continuationToken: void 0,
|
9718
|
+
indexedPackages: /* @__PURE__ */ new Map(),
|
9719
|
+
packageNames: /* @__PURE__ */ new Set(),
|
9720
|
+
packageMajorVersions: /* @__PURE__ */ new Set(),
|
9721
|
+
perLanguage: /* @__PURE__ */ new Map()
|
9722
|
+
};
|
9723
|
+
async function loadProgress(continuationObjectKey) {
|
9724
|
+
console.log("Found a continuation object key, retrieving data from the existing run...");
|
9725
|
+
let { Body, ContentEncoding } = await s3().getObject({
|
9726
|
+
Bucket: scratchworkBucket,
|
9727
|
+
Key: continuationObjectKey
|
9728
|
+
}).promise();
|
9729
|
+
if (ContentEncoding === "gzip") {
|
9730
|
+
Body = (0, import_zlib2.gunzipSync)(Buffer.from(Body));
|
9731
|
+
}
|
9732
|
+
if (!Body) {
|
9733
|
+
throw new Error(`Object key "${event.continuationObjectKey}" not found in bucket "${scratchworkBucket}".`);
|
9734
|
+
}
|
9735
|
+
console.log("Deserializing data...");
|
9736
|
+
const serializedState = Body.toString("utf-8");
|
9737
|
+
const state = deserialize(serializedState);
|
9738
|
+
console.log("Deserializing finished.");
|
9739
|
+
return state;
|
9740
|
+
}
|
9714
9741
|
function recordPerLanguage(language, status, pkgName, pkgMajor, pkgVersion, submodule) {
|
9715
9742
|
for (const lang of DocumentationLanguage.ALL) {
|
9716
|
-
doRecordPerLanguage(perLanguage, lang, lang === language ? status :
|
9717
|
-
}
|
9718
|
-
}
|
9719
|
-
|
9720
|
-
|
9721
|
-
const
|
9722
|
-
|
9723
|
-
|
9724
|
-
|
9725
|
-
|
9726
|
-
|
9727
|
-
|
9728
|
-
|
9729
|
-
|
9730
|
-
|
9731
|
-
|
9732
|
-
|
9733
|
-
|
9734
|
-
|
9735
|
-
|
9736
|
-
|
9737
|
-
|
9738
|
-
|
9739
|
-
|
9740
|
-
|
9741
|
-
|
9742
|
-
|
9743
|
+
doRecordPerLanguage(perLanguage, lang, lang === language ? status : DocumentationStatus.MISSING, pkgName, pkgMajor, pkgVersion, submodule);
|
9744
|
+
}
|
9745
|
+
}
|
9746
|
+
async function saveProgress(latestContinuationToken) {
|
9747
|
+
console.log("Serializing data...");
|
9748
|
+
const serializedState = serialize({
|
9749
|
+
continuationToken: latestContinuationToken,
|
9750
|
+
packageNames,
|
9751
|
+
packageMajorVersions,
|
9752
|
+
indexedPackages,
|
9753
|
+
perLanguage
|
9754
|
+
});
|
9755
|
+
console.log("Serializing finished.");
|
9756
|
+
const { buffer, contentEncoding } = compressContent(Buffer.from(serializedState));
|
9757
|
+
const keyName = `inventory-canary-progress-${Date.now()}`;
|
9758
|
+
await s3().putObject({
|
9759
|
+
Bucket: scratchworkBucket,
|
9760
|
+
Key: keyName,
|
9761
|
+
Body: buffer,
|
9762
|
+
ContentType: "application/json",
|
9763
|
+
ContentEncoding: contentEncoding,
|
9764
|
+
Metadata: {
|
9765
|
+
"Lambda-Log-Group": context.logGroupName,
|
9766
|
+
"Lambda-Log-Stream": context.logStreamName,
|
9767
|
+
"Lambda-Run-Id": context.awsRequestId
|
9768
|
+
}
|
9769
|
+
}).promise();
|
9770
|
+
return {
|
9771
|
+
continuationObjectKey: keyName
|
9772
|
+
};
|
9773
|
+
}
|
9774
|
+
const maxMetricProcessingTime = 6e4;
|
9775
|
+
const packageDataBucket = requireEnv("PACKAGE_DATA_BUCKET_NAME");
|
9776
|
+
for await (const [keys, latestContinuationToken] of relevantObjectKeys(packageDataBucket, continuationToken)) {
|
9777
|
+
for (const key of keys) {
|
9778
|
+
const [, name, version] = STORAGE_KEY_FORMAT_REGEX.exec(key);
|
9779
|
+
packageNames.add(name);
|
9780
|
+
const majorVersion = `${name}@${new import_semver.SemVer(version).major}`;
|
9781
|
+
packageMajorVersions.add(majorVersion);
|
9782
|
+
const fullName = `${name}@${version}`;
|
9743
9783
|
for (const language of DocumentationLanguage.ALL) {
|
9744
|
-
|
9745
|
-
|
9746
|
-
|
9747
|
-
|
9748
|
-
|
9749
|
-
|
9750
|
-
|
9751
|
-
|
9752
|
-
|
9753
|
-
|
9754
|
-
|
9755
|
-
|
9756
|
-
|
9757
|
-
|
9758
|
-
|
9759
|
-
|
9760
|
-
|
9761
|
-
|
9762
|
-
|
9763
|
-
|
9764
|
-
|
9765
|
-
|
9766
|
-
|
9767
|
-
|
9768
|
-
|
9769
|
-
|
9770
|
-
|
9771
|
-
|
9772
|
-
|
9773
|
-
|
9774
|
-
|
9775
|
-
|
9776
|
-
|
9784
|
+
recordPerLanguage(language, DocumentationStatus.MISSING, name, majorVersion, fullName);
|
9785
|
+
}
|
9786
|
+
if (!indexedPackages.has(fullName)) {
|
9787
|
+
indexedPackages.set(fullName, {});
|
9788
|
+
}
|
9789
|
+
const status = indexedPackages.get(fullName);
|
9790
|
+
if (key.endsWith(METADATA_KEY_SUFFIX)) {
|
9791
|
+
status.metadataPresent = true;
|
9792
|
+
} else if (key.endsWith(PACKAGE_KEY_SUFFIX)) {
|
9793
|
+
status.tarballPresent = true;
|
9794
|
+
} else if (key.endsWith(ASSEMBLY_KEY_SUFFIX)) {
|
9795
|
+
status.assemblyPresent = true;
|
9796
|
+
} else if (key.endsWith(UNINSTALLABLE_PACKAGE_SUFFIX)) {
|
9797
|
+
status.uninstallable = true;
|
9798
|
+
} else {
|
9799
|
+
let identified = false;
|
9800
|
+
for (const language of DocumentationLanguage.ALL) {
|
9801
|
+
const matchJson = submoduleKeyRegexp(language, "json").exec(key);
|
9802
|
+
const matchMd = submoduleKeyRegexp(language, "md").exec(key);
|
9803
|
+
if (matchJson != null) {
|
9804
|
+
const [, submodule, isUnsupported] = matchJson;
|
9805
|
+
if (status.submodules == null) {
|
9806
|
+
status.submodules = /* @__PURE__ */ new Set();
|
9807
|
+
}
|
9808
|
+
status.submodules.add(`${fullName}.${submodule}`);
|
9809
|
+
recordPerLanguage(language, isUnsupported ? DocumentationStatus.UNSUPPORTED : DocumentationStatus.SUPPORTED, name, majorVersion, fullName, submodule);
|
9810
|
+
identified = true;
|
9811
|
+
} else if (key.endsWith(docsKeySuffix(language, void 0, "json"))) {
|
9812
|
+
recordPerLanguage(language, DocumentationStatus.SUPPORTED, name, majorVersion, fullName);
|
9813
|
+
identified = true;
|
9814
|
+
} else if (key.endsWith(notSupportedKeySuffix(language, void 0, "json"))) {
|
9815
|
+
recordPerLanguage(language, DocumentationStatus.UNSUPPORTED, name, majorVersion, fullName);
|
9816
|
+
identified = true;
|
9817
|
+
} else if (key.endsWith(corruptAssemblyKeySuffix(language, void 0, "json"))) {
|
9818
|
+
recordPerLanguage(language, DocumentationStatus.CORRUPT_ASSEMBLY, name, majorVersion, fullName);
|
9819
|
+
identified = true;
|
9820
|
+
} else if (matchMd != null) {
|
9821
|
+
identified = true;
|
9822
|
+
} else if (key.endsWith(docsKeySuffix(language, void 0, "md"))) {
|
9823
|
+
identified = true;
|
9824
|
+
} else if (key.endsWith(notSupportedKeySuffix(language, void 0, "md"))) {
|
9825
|
+
identified = true;
|
9826
|
+
} else if (key.endsWith(corruptAssemblyKeySuffix(language, void 0, "md"))) {
|
9827
|
+
identified = true;
|
9828
|
+
}
|
9829
|
+
}
|
9830
|
+
if (!identified) {
|
9831
|
+
status.unknownObjects = status.unknownObjects ?? [];
|
9832
|
+
status.unknownObjects.push(key);
|
9833
|
+
}
|
9834
|
+
}
|
9835
|
+
}
|
9836
|
+
if (latestContinuationToken && context.getRemainingTimeInMillis() <= maxMetricProcessingTime) {
|
9837
|
+
console.log("Running up to the Lambda time limit and there are still items to process. Saving our current progress...");
|
9838
|
+
return saveProgress(latestContinuationToken);
|
9777
9839
|
}
|
9778
9840
|
}
|
9779
9841
|
const reports = [];
|
9780
9842
|
function createReport(reportKey, packageVersions) {
|
9781
9843
|
const report = JSON.stringify(packageVersions, null, 2);
|
9782
9844
|
const { buffer, contentEncoding } = compressContent(Buffer.from(report));
|
9783
|
-
console.log(`Uploading list to s3://${
|
9845
|
+
console.log(`Uploading list to s3://${packageDataBucket}/${reportKey}`);
|
9784
9846
|
reports.push(s3().putObject({
|
9785
9847
|
Body: buffer,
|
9786
|
-
Bucket:
|
9848
|
+
Bucket: packageDataBucket,
|
9787
9849
|
ContentEncoding: contentEncoding,
|
9788
9850
|
ContentType: "application/json",
|
9789
9851
|
Expires: new Date(Date.now() + 3e5),
|
@@ -9843,16 +9905,17 @@ async function handler(event, context) {
|
|
9843
9905
|
console.log(`### Start of data for ${language}`);
|
9844
9906
|
metrics.setDimensions({ [LANGUAGE_DIMENSION]: language.toString() });
|
9845
9907
|
for (const forStatus of [
|
9846
|
-
|
9847
|
-
|
9848
|
-
|
9849
|
-
|
9908
|
+
DocumentationStatus.SUPPORTED,
|
9909
|
+
DocumentationStatus.UNSUPPORTED,
|
9910
|
+
DocumentationStatus.MISSING,
|
9911
|
+
DocumentationStatus.CORRUPT_ASSEMBLY
|
9850
9912
|
]) {
|
9851
|
-
for (const [key, statuses] of
|
9913
|
+
for (const [key, statuses] of data.entries()) {
|
9852
9914
|
let filtered = Array.from(statuses.entries()).filter(([, status]) => forStatus === status);
|
9853
9915
|
let metricName = METRIC_NAME_BY_STATUS_AND_GRAIN[forStatus][key];
|
9854
|
-
if (forStatus ===
|
9855
|
-
const
|
9916
|
+
if (forStatus === DocumentationStatus.MISSING && metricName === "MissingPackageVersionCount" /* PER_LANGUAGE_MISSING_VERSIONS */ || forStatus === DocumentationStatus.CORRUPT_ASSEMBLY && metricName === "CorruptAssemblyPackageVersionCount" /* PER_LANGUAGE_CORRUPT_ASSEMBLY_VERSIONS */) {
|
9917
|
+
const lang = DocumentationLanguage.fromString(language);
|
9918
|
+
const reportKey = forStatus === DocumentationStatus.MISSING ? missingDocumentationReport(lang) : corruptAssemblyReport(lang);
|
9856
9919
|
createReport(reportKey, filtered.map(([name]) => name).sort());
|
9857
9920
|
}
|
9858
9921
|
console.log(`${forStatus} ${key} for ${language}: ${filtered.length} entries`);
|
@@ -9867,20 +9930,25 @@ async function handler(event, context) {
|
|
9867
9930
|
for (const report of reports) {
|
9868
9931
|
await report;
|
9869
9932
|
}
|
9933
|
+
return {};
|
9870
9934
|
}
|
9871
|
-
async function* relevantObjectKeys(bucket) {
|
9935
|
+
async function* relevantObjectKeys(bucket, continuationToken) {
|
9872
9936
|
const request = {
|
9873
9937
|
Bucket: bucket,
|
9874
9938
|
Prefix: STORAGE_KEY_PREFIX
|
9875
9939
|
};
|
9940
|
+
if (continuationToken)
|
9941
|
+
request.ContinuationToken = continuationToken;
|
9876
9942
|
do {
|
9877
9943
|
const response = await s3().listObjectsV2(request).promise();
|
9944
|
+
const keys = [];
|
9878
9945
|
for (const { Key } of response.Contents ?? []) {
|
9879
9946
|
if (Key == null) {
|
9880
9947
|
continue;
|
9881
9948
|
}
|
9882
|
-
|
9949
|
+
keys.push(Key);
|
9883
9950
|
}
|
9951
|
+
yield [keys, response.ContinuationToken];
|
9884
9952
|
request.ContinuationToken = response.NextContinuationToken;
|
9885
9953
|
} while (request.ContinuationToken != null);
|
9886
9954
|
}
|
@@ -9892,13 +9960,20 @@ function submoduleKeyRegexp(language, fileExt) {
|
|
9892
9960
|
return str.replace(/([+*.()?$[\]])/g, "\\$1");
|
9893
9961
|
}
|
9894
9962
|
}
|
9895
|
-
var
|
9896
|
-
|
9897
|
-
|
9898
|
-
|
9899
|
-
|
9900
|
-
return
|
9901
|
-
})(
|
9963
|
+
var Grain = /* @__PURE__ */ ((Grain2) => {
|
9964
|
+
Grain2["PACKAGE_MAJOR_VERSIONS"] = "package major versions";
|
9965
|
+
Grain2["PACKAGE_VERSION_SUBMODULES"] = "package version submodules";
|
9966
|
+
Grain2["PACKAGE_VERSIONS"] = "package versions";
|
9967
|
+
Grain2["PACKAGES"] = "packages";
|
9968
|
+
return Grain2;
|
9969
|
+
})(Grain || {});
|
9970
|
+
var DocumentationStatus = /* @__PURE__ */ ((DocumentationStatus2) => {
|
9971
|
+
DocumentationStatus2["MISSING"] = "Missing";
|
9972
|
+
DocumentationStatus2["UNSUPPORTED"] = "Unsupported";
|
9973
|
+
DocumentationStatus2["CORRUPT_ASSEMBLY"] = "CorruptAssembly";
|
9974
|
+
DocumentationStatus2["SUPPORTED"] = "Supported";
|
9975
|
+
return DocumentationStatus2;
|
9976
|
+
})(DocumentationStatus || {});
|
9902
9977
|
var METRIC_NAME_BY_STATUS_AND_GRAIN = {
|
9903
9978
|
["Missing" /* MISSING */]: {
|
9904
9979
|
["packages" /* PACKAGES */]: "MissingPackageCount" /* PER_LANGUAGE_MISSING_PACKAGES */,
|
@@ -9926,21 +10001,21 @@ var METRIC_NAME_BY_STATUS_AND_GRAIN = {
|
|
9926
10001
|
}
|
9927
10002
|
};
|
9928
10003
|
function doRecordPerLanguage(perLanguage, language, status, pkgName, pkgMajor, pkgVersion, submodule) {
|
9929
|
-
if (!perLanguage.has(language)) {
|
9930
|
-
|
9931
|
-
|
9932
|
-
|
9933
|
-
|
9934
|
-
|
9935
|
-
|
9936
|
-
}
|
9937
|
-
const data = perLanguage.get(language);
|
10004
|
+
if (!perLanguage.has(language.name)) {
|
10005
|
+
const perGrainData = /* @__PURE__ */ new Map();
|
10006
|
+
perGrainData.set("package major versions" /* PACKAGE_MAJOR_VERSIONS */, /* @__PURE__ */ new Map());
|
10007
|
+
perGrainData.set("packages" /* PACKAGES */, /* @__PURE__ */ new Map());
|
10008
|
+
perGrainData.set("package version submodules" /* PACKAGE_VERSION_SUBMODULES */, /* @__PURE__ */ new Map());
|
10009
|
+
perGrainData.set("package versions" /* PACKAGE_VERSIONS */, /* @__PURE__ */ new Map());
|
10010
|
+
perLanguage.set(language.name, perGrainData);
|
10011
|
+
}
|
10012
|
+
const data = perLanguage.get(language.name);
|
9938
10013
|
const outputDomains = submodule ? [
|
9939
|
-
[data
|
10014
|
+
[data.get("package version submodules" /* PACKAGE_VERSION_SUBMODULES */), `${pkgVersion}.${submodule}`]
|
9940
10015
|
] : [
|
9941
|
-
[data
|
9942
|
-
[data
|
9943
|
-
[data
|
10016
|
+
[data.get("package major versions" /* PACKAGE_MAJOR_VERSIONS */), pkgMajor],
|
10017
|
+
[data.get("package versions" /* PACKAGE_VERSIONS */), pkgVersion],
|
10018
|
+
[data.get("packages" /* PACKAGES */), pkgName]
|
9944
10019
|
];
|
9945
10020
|
for (const [map, name] of outputDomains) {
|
9946
10021
|
switch (status) {
|
@@ -9961,8 +10036,44 @@ function doRecordPerLanguage(perLanguage, language, status, pkgName, pkgMajor, p
|
|
9961
10036
|
}
|
9962
10037
|
}
|
9963
10038
|
}
|
10039
|
+
function safeReplacer(_key, value) {
|
10040
|
+
if (value instanceof Map) {
|
10041
|
+
return {
|
10042
|
+
_type: "Map",
|
10043
|
+
value: Array.from(value.entries())
|
10044
|
+
};
|
10045
|
+
} else if (value instanceof Set) {
|
10046
|
+
return {
|
10047
|
+
_type: "Set",
|
10048
|
+
value: Array.from([...value])
|
10049
|
+
};
|
10050
|
+
} else {
|
10051
|
+
return value;
|
10052
|
+
}
|
10053
|
+
}
|
10054
|
+
function safeReviver(_key, value) {
|
10055
|
+
if (typeof value === "object" && value !== null) {
|
10056
|
+
if (value._type === "Map") {
|
10057
|
+
return new Map(value.value);
|
10058
|
+
}
|
10059
|
+
if (value._type === "Set") {
|
10060
|
+
return new Set(value.value);
|
10061
|
+
}
|
10062
|
+
}
|
10063
|
+
return value;
|
10064
|
+
}
|
10065
|
+
function serialize(value) {
|
10066
|
+
return JSON.stringify(value, safeReplacer, 2);
|
10067
|
+
}
|
10068
|
+
function deserialize(value) {
|
10069
|
+
return JSON.parse(value, safeReviver);
|
10070
|
+
}
|
9964
10071
|
// Annotate the CommonJS export names for ESM import in node:
|
9965
10072
|
0 && (module.exports = {
|
9966
|
-
|
10073
|
+
DocumentationStatus,
|
10074
|
+
Grain,
|
10075
|
+
deserialize,
|
10076
|
+
handler,
|
10077
|
+
serialize
|
9967
10078
|
});
|
9968
10079
|
//# sourceMappingURL=index.js.map
|