@@ -64,7 +64,10 @@ export async function resolveKnowledgeAccessAvailability(
6464 throw new Error ( 'Knowledge access requires one resource owner' )
6565 /** A caller that brings its own billing snapshot is answered from that snapshot, uncached. */
6666 if ( context . ownerBilling ) return readKnowledgeAccessAvailability ( context )
67- const key = `${ context . organizationId ?? '' } |${ context . workspaceId ?? '' } |${ context . userId ?? '' } `
67+ /** An organization's answer depends on the organization alone; a workspace's on its viewer too. */
68+ const key = context . organizationId
69+ ? `${ context . organizationId } ||`
70+ : `|${ context . workspaceId ?? '' } |${ context . userId ?? '' } `
6871 const availability = await availabilityCache . fetch ( key , { context } )
6972 if ( ! availability ) throw new Error ( 'Knowledge access availability could not be resolved' )
7073 return availability
@@ -89,14 +92,14 @@ async function readKnowledgeAccessAvailability(
8992 return { sourceMirrored : false , memberScoped : false }
9093 }
9194 if ( context . organizationId ) {
92- return {
93- sourceMirrored :
94- ! isHosted || ( await isOrganizationOnEnterprisePlan ( context . organizationId , 'throw' ) ) ,
95- memberScoped : await isScopedCredentialGroupsAvailable ( {
95+ const [ enterprise , memberScoped ] = await Promise . all ( [
96+ isHosted ? isOrganizationOnEnterprisePlan ( context . organizationId , 'throw' ) : true ,
97+ isScopedCredentialGroupsAvailable ( {
9698 kind : 'organization' ,
9799 organizationId : context . organizationId ,
98100 } ) ,
99- }
101+ ] )
102+ return { sourceMirrored : enterprise , memberScoped }
100103 }
101104 if ( ! context . workspaceId ) throw new Error ( 'Knowledge access requires a resource owner' )
102105 const ownerBilling =
0 commit comments