1
- import {
2
- Injectable ,
3
- Param ,
4
- type PipeTransform ,
5
- type Type ,
6
- } from '@nestjs/common' ;
7
- import { CONTROLLER_WATERMARK } from '@nestjs/common/constants.js' ;
8
- import { Context } from '@nestjs/graphql' ;
9
1
import { type DateTime } from 'luxon' ;
10
- import { Identity } from '~/core/authentication' ;
11
2
import { type ScopedRole } from '../components/authorization/dto' ;
12
3
import { type ID } from './id-field' ;
13
4
@@ -30,33 +21,3 @@ export interface Session {
30
21
roles : readonly ScopedRole [ ] ;
31
22
} ;
32
23
}
33
-
34
- @Injectable ( )
35
- export class SessionPipe implements PipeTransform {
36
- constructor ( private readonly identity : Identity ) { }
37
-
38
- transform ( ) {
39
- return this . identity . currentMaybe ;
40
- }
41
- }
42
-
43
- /** @deprecated */
44
- export const LoggedInSession = ( ) => AnonSession ( ) ;
45
-
46
- /** @deprecated */
47
- export const AnonSession =
48
- ( ...pipes : Array < Type < PipeTransform > | PipeTransform > ) : ParameterDecorator =>
49
- ( ...args ) => {
50
- Context ( SessionPipe , ...pipes ) ( ...args ) ;
51
- process . nextTick ( ( ) => {
52
- // Only set this metadata if it's a controller method.
53
- // Waiting for the next tick as class decorators execute after methods.
54
- if ( Reflect . getMetadata ( CONTROLLER_WATERMARK , args [ 0 ] . constructor ) ) {
55
- Param ( SessionPipe , ...pipes ) ( ...args ) ;
56
- SessionWatermark ( ...args ) ;
57
- }
58
- } ) ;
59
- } ;
60
-
61
- const SessionWatermark : ParameterDecorator = ( target , key ) =>
62
- Reflect . defineMetadata ( 'SESSION_WATERMARK' , true , target . constructor , key ! ) ;
0 commit comments