@@ -314,8 +314,8 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
314
314
async ( session , [ providerId , scope , redirect ] ) => {
315
315
return await this . _getUserOAuthConnectionCacheFn ( {
316
316
getUser : async ( ) => await this . _currentUserCache . getOrWait ( [ session ] , "write-only" ) ,
317
- getOrWaitOAuthToken : async ( ) => await this . _currentUserOAuthConnectionAccessTokensCache . getOrWait ( [ session , providerId , scope || "" ] , "write-only" ) ,
318
- useOAuthToken : ( ) => useAsyncCache ( this . _currentUserOAuthConnectionAccessTokensCache , [ session , providerId , scope || "" ] , "useOAuthToken" ) ,
317
+ getOrWaitOAuthToken : async ( ) => await this . _currentUserOAuthConnectionAccessTokensCache . getOrWait ( [ session , providerId , scope || "" ] as const , "write-only" ) ,
318
+ useOAuthToken : ( ) => useAsyncCache ( this . _currentUserOAuthConnectionAccessTokensCache , [ session , providerId , scope || "" ] as const , "useOAuthToken" ) ,
319
319
providerId,
320
320
scope,
321
321
redirect,
@@ -748,7 +748,7 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
748
748
return result . map ( ( crud ) => app . _clientTeamUserFromCrud ( crud ) ) ;
749
749
} ,
750
750
useUsers ( ) {
751
- const result = useAsyncCache ( app . _teamMemberProfilesCache , [ app . _getSession ( ) , crud . id ] , "team.useUsers()" ) ;
751
+ const result = useAsyncCache ( app . _teamMemberProfilesCache , [ app . _getSession ( ) , crud . id ] as const , "team.useUsers()" ) ;
752
752
return result . map ( ( crud ) => app . _clientTeamUserFromCrud ( crud ) ) ;
753
753
} ,
754
754
async update ( data : TeamUpdateOptions ) {
@@ -902,7 +902,7 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
902
902
function useConnectedAccount ( id : ProviderType , options : { or : 'redirect' , scopes ?: string [ ] } ) : OAuthConnection ;
903
903
function useConnectedAccount ( id : ProviderType , options ?: { or ?: 'redirect' , scopes ?: string [ ] } ) : OAuthConnection | null {
904
904
const scopeString = options ?. scopes ?. join ( " " ) ;
905
- return useAsyncCache ( app . _currentUserOAuthConnectionCache , [ session , id , scopeString || "" , options ?. or === 'redirect' ] , "user.useConnectedAccount()" ) ;
905
+ return useAsyncCache ( app . _currentUserOAuthConnectionCache , [ session , id , scopeString || "" , options ?. or === 'redirect' ] as const , "user.useConnectedAccount()" ) ;
906
906
}
907
907
908
908
return {
@@ -954,7 +954,7 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
954
954
} ,
955
955
usePermissions ( scope : Team , options ?: { recursive ?: boolean } ) : TeamPermission [ ] {
956
956
const recursive = options ?. recursive ?? true ;
957
- const permissions = useAsyncCache ( app . _currentUserPermissionsCache , [ session , scope . id , recursive ] , "user.usePermissions()" ) ;
957
+ const permissions = useAsyncCache ( app . _currentUserPermissionsCache , [ session , scope . id , recursive ] as const , "user.usePermissions()" ) ;
958
958
return useMemo ( ( ) => permissions . map ( ( crud ) => app . _clientTeamPermissionFromCrud ( crud ) ) , [ permissions ] ) ;
959
959
} ,
960
960
usePermission ( scope : Team , permissionId : string ) : TeamPermission | null {
@@ -992,7 +992,7 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
992
992
return app . _editableTeamProfileFromCrud ( result ) ;
993
993
} ,
994
994
useTeamProfile ( team : Team ) {
995
- const result = useAsyncCache ( app . _currentUserTeamProfileCache , [ session , team . id ] , "user.useTeamProfile()" ) ;
995
+ const result = useAsyncCache ( app . _currentUserTeamProfileCache , [ session , team . id ] as const , "user.useTeamProfile()" ) ;
996
996
return app . _editableTeamProfileFromCrud ( result ) ;
997
997
} ,
998
998
async delete ( ) {
@@ -1004,7 +1004,7 @@ class _StackClientAppImpl<HasTokenStore extends boolean, ProjectId extends strin
1004
1004
return result . map ( ( crud ) => app . _clientContactChannelFromCrud ( crud ) ) ;
1005
1005
} ,
1006
1006
useContactChannels ( ) {
1007
- const result = useAsyncCache ( app . _clientContactChannelsCache , [ session ] , "user.useContactChannels()" ) ;
1007
+ const result = useAsyncCache ( app . _clientContactChannelsCache , [ session ] as const , "user.useContactChannels()" ) ;
1008
1008
return result . map ( ( crud ) => app . _clientContactChannelFromCrud ( crud ) ) ;
1009
1009
} ,
1010
1010
async createContactChannel ( data : ContactChannelCreateOptions ) {
@@ -1623,8 +1623,8 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
1623
1623
async ( [ userId , providerId , scope , redirect ] ) => {
1624
1624
return await this . _getUserOAuthConnectionCacheFn ( {
1625
1625
getUser : async ( ) => await this . _serverUserCache . getOrWait ( [ userId ] , "write-only" ) ,
1626
- getOrWaitOAuthToken : async ( ) => await this . _serverUserOAuthConnectionAccessTokensCache . getOrWait ( [ userId , providerId , scope || "" ] , "write-only" ) ,
1627
- useOAuthToken : ( ) => useAsyncCache ( this . _serverUserOAuthConnectionAccessTokensCache , [ userId , providerId , scope || "" ] , "user.useConnectedAccount()" ) ,
1626
+ getOrWaitOAuthToken : async ( ) => await this . _serverUserOAuthConnectionAccessTokensCache . getOrWait ( [ userId , providerId , scope || "" ] as const , "write-only" ) ,
1627
+ useOAuthToken : ( ) => useAsyncCache ( this . _serverUserOAuthConnectionAccessTokensCache , [ userId , providerId , scope || "" ] as const , "user.useConnectedAccount()" ) ,
1628
1628
providerId,
1629
1629
scope,
1630
1630
redirect,
@@ -1724,7 +1724,7 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
1724
1724
function useConnectedAccount ( id : ProviderType , options : { or : 'redirect' , scopes ?: string [ ] } ) : OAuthConnection ;
1725
1725
function useConnectedAccount ( id : ProviderType , options ?: { or ?: 'redirect' , scopes ?: string [ ] } ) : OAuthConnection | null {
1726
1726
const scopeString = options ?. scopes ?. join ( " " ) ;
1727
- return useAsyncCache ( app . _serverUserOAuthConnectionCache , [ crud . id , id , scopeString || "" , options ?. or === 'redirect' ] , "user.useConnectedAccount()" ) ;
1727
+ return useAsyncCache ( app . _serverUserOAuthConnectionCache , [ crud . id , id , scopeString || "" , options ?. or === 'redirect' ] as const , "user.useConnectedAccount()" ) ;
1728
1728
}
1729
1729
1730
1730
return {
@@ -1813,7 +1813,7 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
1813
1813
} ,
1814
1814
usePermissions ( scope : Team , options ?: { recursive ?: boolean } ) : AdminTeamPermission [ ] {
1815
1815
const recursive = options ?. recursive ?? true ;
1816
- const permissions = useAsyncCache ( app . _serverTeamUserPermissionsCache , [ scope . id , crud . id , recursive ] , "user.usePermissions()" ) ;
1816
+ const permissions = useAsyncCache ( app . _serverTeamUserPermissionsCache , [ scope . id , crud . id , recursive ] as const , "user.usePermissions()" ) ;
1817
1817
return useMemo ( ( ) => permissions . map ( ( crud ) => app . _serverPermissionFromCrud ( crud ) ) , [ permissions ] ) ;
1818
1818
} ,
1819
1819
async getPermission ( scope : Team , permissionId : string ) : Promise < AdminTeamPermission | null > {
@@ -1848,15 +1848,15 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
1848
1848
return app . _serverEditableTeamProfileFromCrud ( result ) ;
1849
1849
} ,
1850
1850
useTeamProfile ( team : Team ) {
1851
- const result = useAsyncCache ( app . _serverUserTeamProfileCache , [ team . id , crud . id ] , "user.useTeamProfile()" ) ;
1851
+ const result = useAsyncCache ( app . _serverUserTeamProfileCache , [ team . id , crud . id ] as const , "user.useTeamProfile()" ) ;
1852
1852
return useMemo ( ( ) => app . _serverEditableTeamProfileFromCrud ( result ) , [ result ] ) ;
1853
1853
} ,
1854
1854
async listContactChannels ( ) {
1855
1855
const result = await app . _serverContactChannelsCache . getOrWait ( [ crud . id ] , "write-only" ) ;
1856
1856
return result . map ( ( data ) => app . _serverContactChannelFromCrud ( crud . id , data ) ) ;
1857
1857
} ,
1858
1858
useContactChannels ( ) {
1859
- const result = useAsyncCache ( app . _serverContactChannelsCache , [ crud . id ] , "user.useContactChannels()" ) ;
1859
+ const result = useAsyncCache ( app . _serverContactChannelsCache , [ crud . id ] as const , "user.useContactChannels()" ) ;
1860
1860
return useMemo ( ( ) => result . map ( ( data ) => app . _serverContactChannelFromCrud ( crud . id , data ) ) , [ result ] ) ;
1861
1861
} ,
1862
1862
createContactChannel : async ( data : ServerContactChannelCreateOptions ) => {
@@ -1912,7 +1912,7 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
1912
1912
return result . map ( u => app . _serverTeamUserFromCrud ( u ) ) ;
1913
1913
} ,
1914
1914
useUsers ( ) {
1915
- const result = useAsyncCache ( app . _serverTeamMemberProfilesCache , [ crud . id ] , "team.useUsers()" ) ;
1915
+ const result = useAsyncCache ( app . _serverTeamMemberProfilesCache , [ crud . id ] as const , "team.useUsers()" ) ;
1916
1916
return useMemo ( ( ) => result . map ( u => app . _serverTeamUserFromCrud ( u ) ) , [ result ] ) ;
1917
1917
} ,
1918
1918
async addUser ( userId ) {
@@ -2042,7 +2042,7 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
2042
2042
}
2043
2043
2044
2044
useUsers ( options ?: ServerListUsersOptions ) : ServerUser [ ] & { nextCursor : string | null } {
2045
- const crud = useAsyncCache ( this . _serverUsersCache , [ options ?. cursor , options ?. limit , options ?. orderBy , options ?. desc , options ?. query ] , "useServerUsers()" ) ;
2045
+ const crud = useAsyncCache ( this . _serverUsersCache , [ options ?. cursor , options ?. limit , options ?. orderBy , options ?. desc , options ?. query ] as const , "useServerUsers()" ) ;
2046
2046
const result : any = crud . items . map ( ( j ) => this . _serverUserFromCrud ( j ) ) ;
2047
2047
result . nextCursor = crud . pagination ?. next_cursor ?? null ;
2048
2048
return result as any ;
@@ -2102,7 +2102,7 @@ class _StackServerAppImpl<HasTokenStore extends boolean, ProjectId extends strin
2102
2102
protected override async _refreshUsers ( ) {
2103
2103
await Promise . all ( [
2104
2104
super . _refreshUsers ( ) ,
2105
- this . _serverUsersCache . refresh ( [ ] ) ,
2105
+ this . _serverUsersCache . refreshWhere ( ( ) => true ) ,
2106
2106
] ) ;
2107
2107
}
2108
2108
}
0 commit comments