function assignScopesToUnknownReferences()

in generator/generate.ts [112:129]


function assignScopesToUnknownReferences(knownReferences: SchemaReference[], unknownReferences: SchemaReference[], autoGenConfig?: AutoGenConfig) {
    const resourceConfig = (autoGenConfig || {}).resourceConfig || [];

    for (const schemaRef of unknownReferences) {
        const config = resourceConfig.find(c => lowerCaseCompare(c.type, schemaRef.type) === 0);

        if (config && (schemaRef.scope & ScopeType.Unknown)) {
            schemaRef.scope = config.scopes || ScopeType.None;
        } else {
            schemaRef.scope = ScopeType.Tenant | ScopeType.Subscription | ScopeType.ResourceGroup | ScopeType.ManagementGroup | ScopeType.Extension;
        }

        for (const knownReference of knownReferences.filter(r => lowerCaseCompare(r.type, schemaRef.type) === 0)) {
            // remove resources for scopes that have already been declared elsewhere to avoid duplication
            schemaRef.scope &= ~knownReference.scope;
        }
    }
}