diff --git a/packages/@aws-cdk/service-spec-types/src/types/database.ts b/packages/@aws-cdk/service-spec-types/src/types/database.ts index 830009ef2..d55c7ec32 100644 --- a/packages/@aws-cdk/service-spec-types/src/types/database.ts +++ b/packages/@aws-cdk/service-spec-types/src/types/database.ts @@ -1,6 +1,6 @@ import { promises as fs } from 'fs'; import { gunzipSync } from 'zlib'; -import { Database, entityCollection, fieldIndex, stringCmp } from '@cdklabs/tskb'; +import { Database, entityCollection, fieldIndex, fieldIndexWithDefault, stringCmp } from '@cdklabs/tskb'; import { IsAugmentedResource, ResourceAugmentation } from './augmentations'; import { DimensionSet, @@ -21,6 +21,7 @@ import { RegionHasResource, RegionHasService, UsesType, + ResourceScrutinyType, } from './resource'; export function emptyDatabase() { @@ -28,6 +29,7 @@ export function emptyDatabase() { { resource: entityCollection().index({ cloudFormationType: fieldIndex('cloudFormationType', stringCmp), + scrutinizable: fieldIndexWithDefault('scrutinizable', stringCmp, ResourceScrutinyType.None), }), region: entityCollection().index({ name: fieldIndex('name', stringCmp), diff --git a/packages/@cdklabs/tskb/src/entity.ts b/packages/@cdklabs/tskb/src/entity.ts index 130531d04..9755e985a 100644 --- a/packages/@cdklabs/tskb/src/entity.ts +++ b/packages/@cdklabs/tskb/src/entity.ts @@ -127,6 +127,14 @@ export function fieldIndex( return calculatedIndex((x) => x[propName], comparator); } +export function fieldIndexWithDefault( + propName: P, + comparator: sortedMap.Comparator>, + defaultValue: NonNullable, +): EntityIndex { + return calculatedIndex((x) => x[propName] ?? defaultValue!, comparator); +} + /** * An index that is calculated based on a function applied to an entity */