File tree Expand file tree Collapse file tree 4 files changed +58
-3
lines changed Expand file tree Collapse file tree 4 files changed +58
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { Injectable } from '@nestjs/common' ;
2
2
import { CachedByArg } from '@seedcompany/common' ;
3
- import { ID , Role } from '~/common' ;
3
+ import { Role } from '~/common' ;
4
+ import { SystemAgent } from './dto' ;
4
5
5
6
@Injectable ( )
6
7
export abstract class ActorRepository {
@@ -22,5 +23,5 @@ export abstract class ActorRepository {
22
23
protected abstract upsertAgent (
23
24
name : string ,
24
25
roles ?: readonly Role [ ] ,
25
- ) : Promise < { id : ID ; name : string ; roles : readonly Role [ ] } > ;
26
+ ) : Promise < SystemAgent > ;
26
27
}
Original file line number Diff line number Diff line change
1
+ import { InterfaceType , ObjectType } from '@nestjs/graphql' ;
2
+ import { keys as keysOf } from 'ts-transformer-keys' ;
3
+ import {
4
+ DataObject ,
5
+ ID ,
6
+ IdField ,
7
+ NameField ,
8
+ resolveByTypename ,
9
+ Role ,
10
+ SecuredProperty ,
11
+ SecuredProps ,
12
+ } from '~/common' ;
13
+ import { RegisterResource } from '~/core' ;
14
+ import { e } from '~/core/edgedb' ;
15
+
16
+ @RegisterResource ( { db : e . Actor } )
17
+ @InterfaceType ( {
18
+ resolveType : resolveByTypename ( Actor . name ) ,
19
+ } )
20
+ export class Actor extends DataObject {
21
+ static readonly Props : string [ ] = keysOf < Actor > ( ) ;
22
+ static readonly SecuredProps : string [ ] = keysOf < SecuredProps < Actor > > ( ) ;
23
+
24
+ @IdField ( )
25
+ readonly id : ID ;
26
+ }
27
+
28
+ @ObjectType ( {
29
+ implements : [ Actor ] ,
30
+ } )
31
+ export abstract class SystemAgent extends Actor {
32
+ __typename ?: 'SystemAgent' ;
33
+
34
+ @NameField ( )
35
+ readonly name : string ;
36
+
37
+ readonly roles : readonly Role [ ] ;
38
+ }
39
+
40
+ @ObjectType ( {
41
+ description : SecuredProperty . descriptionFor ( 'a actor' ) ,
42
+ } )
43
+ export class SecuredActor extends SecuredProperty ( Actor ) { }
44
+
45
+ declare module '~/core/resources/map' {
46
+ interface ResourceMap {
47
+ Actor : typeof Actor ;
48
+ }
49
+ interface ResourceDBMap {
50
+ Actor : typeof e . Actor ;
51
+ }
52
+ }
Original file line number Diff line number Diff line change
1
+ export * from './actor.dto' ;
1
2
export * from './user.dto' ;
2
3
export * from './list-users.dto' ;
3
4
export * from './create-person.dto' ;
Original file line number Diff line number Diff line change @@ -21,10 +21,11 @@ import { Pinnable } from '../../pin/dto';
21
21
import { IProject as Project } from '../../project/dto' ;
22
22
import { Education } from '../education/dto' ;
23
23
import { Unavailability } from '../unavailability/dto' ;
24
+ import { Actor } from './actor.dto' ;
24
25
import { KnownLanguage } from './known-language.dto' ;
25
26
import { SecuredUserStatus } from './user-status.enum' ;
26
27
27
- const Interfaces = IntersectTypes ( Resource , Pinnable ) ;
28
+ const Interfaces = IntersectTypes ( Resource , Actor , Pinnable ) ;
28
29
29
30
@RegisterResource ( { db : e . User } )
30
31
@ObjectType ( {
You can’t perform that action at this time.
0 commit comments