@forklaunch/implementation-iam-base 0.8.21 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { OrganizationDto, CreateOrganizationDto, UpdateOrganizationDto, PermissionDto, CreatePermissionDto, UpdatePermissionDto, UpdateRoleDto, RoleDto, CreateRoleDto, UserDto, CreateUserDto, UpdateUserDto } from '@forklaunch/interfaces-iam/types';
2
- import { MapNestedDtoArraysToCollections } from '@forklaunch/core/services';
3
- import { EntityManager } from '@mikro-orm/core';
2
+ import * as _mikro_orm_core from '@mikro-orm/core';
3
+ import { InferEntity, EntityManager } from '@mikro-orm/core';
4
4
 
5
5
  type OrganizationDtos<OrganizationStatus> = {
6
6
  OrganizationMapper: OrganizationDto<OrganizationStatus>;
@@ -24,76 +24,234 @@ type UserDtos = {
24
24
  UpdateUserMapper: UpdateUserDto;
25
25
  };
26
26
 
27
+ declare const Organization: _mikro_orm_core.EntitySchemaWithMeta<"Organization", string, _mikro_orm_core.InferEntityFromProperties<{
28
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
29
+ primary: true;
30
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
31
+ readonly status: _mikro_orm_core.UniversalPropertyOptionsBuilder<any, _mikro_orm_core.EmptyOptions, "name" | "serializedPrimaryKey" | "comment" | "array" | "fieldName" | "fieldNames" | "columnType" | "columnTypes" | "type" | "runtimeType" | "length" | "precision" | "scale" | "autoincrement" | "returning" | "onCreate" | "onUpdate" | "default" | "defaultRaw" | "formula" | "generated" | "nullable" | "unsigned" | "persist" | "hydrate" | "ref" | "hidden" | "version" | "concurrencyCheck" | "index" | "unique" | "check" | "lazy" | "primary" | "setter" | "getter" | "getterName" | "accessor" | "serializer" | "serializedName" | "groups" | "customOrder" | "extra" | "ignoreSchemaChanges" | ("~options" | "~type" | "$type" | "strictNullable") | "nativeEnumName">;
32
+ }, undefined, never, never, false>, never, {
33
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
34
+ primary: true;
35
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
36
+ readonly status: _mikro_orm_core.UniversalPropertyOptionsBuilder<any, _mikro_orm_core.EmptyOptions, "name" | "serializedPrimaryKey" | "comment" | "array" | "fieldName" | "fieldNames" | "columnType" | "columnTypes" | "type" | "runtimeType" | "length" | "precision" | "scale" | "autoincrement" | "returning" | "onCreate" | "onUpdate" | "default" | "defaultRaw" | "formula" | "generated" | "nullable" | "unsigned" | "persist" | "hydrate" | "ref" | "hidden" | "version" | "concurrencyCheck" | "index" | "unique" | "check" | "lazy" | "primary" | "setter" | "getter" | "getterName" | "accessor" | "serializer" | "serializedName" | "groups" | "customOrder" | "extra" | "ignoreSchemaChanges" | ("~options" | "~type" | "$type" | "strictNullable") | "nativeEnumName">;
37
+ }, _mikro_orm_core.EntityCtor<_mikro_orm_core.InferEntityFromProperties<{
38
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
39
+ primary: true;
40
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
41
+ readonly status: _mikro_orm_core.UniversalPropertyOptionsBuilder<any, _mikro_orm_core.EmptyOptions, "name" | "serializedPrimaryKey" | "comment" | "array" | "fieldName" | "fieldNames" | "columnType" | "columnTypes" | "type" | "runtimeType" | "length" | "precision" | "scale" | "autoincrement" | "returning" | "onCreate" | "onUpdate" | "default" | "defaultRaw" | "formula" | "generated" | "nullable" | "unsigned" | "persist" | "hydrate" | "ref" | "hidden" | "version" | "concurrencyCheck" | "index" | "unique" | "check" | "lazy" | "primary" | "setter" | "getter" | "getterName" | "accessor" | "serializer" | "serializedName" | "groups" | "customOrder" | "extra" | "ignoreSchemaChanges" | ("~options" | "~type" | "$type" | "strictNullable") | "nativeEnumName">;
42
+ }, undefined, never, never, false>>>;
43
+ declare const Role: _mikro_orm_core.EntitySchemaWithMeta<"Role", string, _mikro_orm_core.InferEntityFromProperties<{
44
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
45
+ primary: true;
46
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
47
+ readonly permissions: () => _mikro_orm_core.PropertyChain<_mikro_orm_core.InferEntityFromProperties<{
48
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
49
+ primary: true;
50
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
51
+ readonly slug: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
52
+ }, undefined, never, never, false>, _mikro_orm_core.EmptyOptions & {
53
+ kind: "m:n";
54
+ }>;
55
+ }, undefined, never, never, false>, never, {
56
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
57
+ primary: true;
58
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
59
+ readonly permissions: () => _mikro_orm_core.PropertyChain<_mikro_orm_core.InferEntityFromProperties<{
60
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
61
+ primary: true;
62
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
63
+ readonly slug: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
64
+ }, undefined, never, never, false>, _mikro_orm_core.EmptyOptions & {
65
+ kind: "m:n";
66
+ }>;
67
+ }, _mikro_orm_core.EntityCtor<_mikro_orm_core.InferEntityFromProperties<{
68
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
69
+ primary: true;
70
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
71
+ readonly permissions: () => _mikro_orm_core.PropertyChain<_mikro_orm_core.InferEntityFromProperties<{
72
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
73
+ primary: true;
74
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
75
+ readonly slug: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
76
+ }, undefined, never, never, false>, _mikro_orm_core.EmptyOptions & {
77
+ kind: "m:n";
78
+ }>;
79
+ }, undefined, never, never, false>>>;
80
+ declare const Permission: _mikro_orm_core.EntitySchemaWithMeta<"Permission", string, _mikro_orm_core.InferEntityFromProperties<{
81
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
82
+ primary: true;
83
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
84
+ readonly slug: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
85
+ }, undefined, never, never, false>, never, {
86
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
87
+ primary: true;
88
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
89
+ readonly slug: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
90
+ }, _mikro_orm_core.EntityCtor<_mikro_orm_core.InferEntityFromProperties<{
91
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
92
+ primary: true;
93
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
94
+ readonly slug: _mikro_orm_core.UniversalPropertyOptionsBuilder<string, _mikro_orm_core.EmptyOptions, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
95
+ }, undefined, never, never, false>>>;
96
+ declare const User: _mikro_orm_core.EntitySchemaWithMeta<"User", string, _mikro_orm_core.InferEntityFromProperties<{
97
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
98
+ primary: true;
99
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
100
+ readonly organization: () => _mikro_orm_core.PropertyChain<_mikro_orm_core.InferEntityFromProperties<{
101
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
102
+ primary: true;
103
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
104
+ readonly status: _mikro_orm_core.UniversalPropertyOptionsBuilder<any, _mikro_orm_core.EmptyOptions, "name" | "serializedPrimaryKey" | "comment" | "array" | "fieldName" | "fieldNames" | "columnType" | "columnTypes" | "type" | "runtimeType" | "length" | "precision" | "scale" | "autoincrement" | "returning" | "onCreate" | "onUpdate" | "default" | "defaultRaw" | "formula" | "generated" | "nullable" | "unsigned" | "persist" | "hydrate" | "ref" | "hidden" | "version" | "concurrencyCheck" | "index" | "unique" | "check" | "lazy" | "primary" | "setter" | "getter" | "getterName" | "accessor" | "serializer" | "serializedName" | "groups" | "customOrder" | "extra" | "ignoreSchemaChanges" | ("~options" | "~type" | "$type" | "strictNullable") | "nativeEnumName">;
105
+ }, undefined, never, never, false>, Omit<_mikro_orm_core.EmptyOptions & {
106
+ kind: "m:1";
107
+ }, "nullable"> & {
108
+ nullable: true;
109
+ }>;
110
+ }, undefined, never, never, false>, never, {
111
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
112
+ primary: true;
113
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
114
+ readonly organization: () => _mikro_orm_core.PropertyChain<_mikro_orm_core.InferEntityFromProperties<{
115
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
116
+ primary: true;
117
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
118
+ readonly status: _mikro_orm_core.UniversalPropertyOptionsBuilder<any, _mikro_orm_core.EmptyOptions, "name" | "serializedPrimaryKey" | "comment" | "array" | "fieldName" | "fieldNames" | "columnType" | "columnTypes" | "type" | "runtimeType" | "length" | "precision" | "scale" | "autoincrement" | "returning" | "onCreate" | "onUpdate" | "default" | "defaultRaw" | "formula" | "generated" | "nullable" | "unsigned" | "persist" | "hydrate" | "ref" | "hidden" | "version" | "concurrencyCheck" | "index" | "unique" | "check" | "lazy" | "primary" | "setter" | "getter" | "getterName" | "accessor" | "serializer" | "serializedName" | "groups" | "customOrder" | "extra" | "ignoreSchemaChanges" | ("~options" | "~type" | "$type" | "strictNullable") | "nativeEnumName">;
119
+ }, undefined, never, never, false>, Omit<_mikro_orm_core.EmptyOptions & {
120
+ kind: "m:1";
121
+ }, "nullable"> & {
122
+ nullable: true;
123
+ }>;
124
+ }, _mikro_orm_core.EntityCtor<_mikro_orm_core.InferEntityFromProperties<{
125
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
126
+ primary: true;
127
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
128
+ readonly organization: () => _mikro_orm_core.PropertyChain<_mikro_orm_core.InferEntityFromProperties<{
129
+ readonly id: Pick<_mikro_orm_core.UniversalPropertyOptionsBuilder<string, Omit<_mikro_orm_core.EmptyOptions, "primary"> & {
130
+ primary: true;
131
+ }, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>, keyof _mikro_orm_core.PropertyOptions<any> | ("~options" | "~type" | "$type" | "strictNullable")>;
132
+ readonly status: _mikro_orm_core.UniversalPropertyOptionsBuilder<any, _mikro_orm_core.EmptyOptions, "name" | "serializedPrimaryKey" | "comment" | "array" | "fieldName" | "fieldNames" | "columnType" | "columnTypes" | "type" | "runtimeType" | "length" | "precision" | "scale" | "autoincrement" | "returning" | "onCreate" | "onUpdate" | "default" | "defaultRaw" | "formula" | "generated" | "nullable" | "unsigned" | "persist" | "hydrate" | "ref" | "hidden" | "version" | "concurrencyCheck" | "index" | "unique" | "check" | "lazy" | "primary" | "setter" | "getter" | "getterName" | "accessor" | "serializer" | "serializedName" | "groups" | "customOrder" | "extra" | "ignoreSchemaChanges" | ("~options" | "~type" | "$type" | "strictNullable") | "nativeEnumName">;
133
+ }, undefined, never, never, false>, Omit<_mikro_orm_core.EmptyOptions & {
134
+ kind: "m:1";
135
+ }, "nullable"> & {
136
+ nullable: true;
137
+ }>;
138
+ }, undefined, never, never, false>>>;
139
+
27
140
  type OrganizationEntities<OrganizationStatus> = {
28
- OrganizationMapper: MapNestedDtoArraysToCollections<OrganizationDto<OrganizationStatus>, 'users'>;
29
- CreateOrganizationMapper: MapNestedDtoArraysToCollections<OrganizationDto<OrganizationStatus>, 'users'>;
30
- UpdateOrganizationMapper: MapNestedDtoArraysToCollections<OrganizationDto<OrganizationStatus>, 'users'>;
141
+ OrganizationMapper: {
142
+ '~entity': (typeof Organization)['~entity'] & {
143
+ status: OrganizationStatus[keyof OrganizationStatus];
144
+ };
145
+ };
146
+ CreateOrganizationMapper: {
147
+ '~entity': (typeof Organization)['~entity'] & {
148
+ status: OrganizationStatus[keyof OrganizationStatus];
149
+ };
150
+ };
151
+ UpdateOrganizationMapper: {
152
+ '~entity': (typeof Organization)['~entity'] & {
153
+ status: OrganizationStatus[keyof OrganizationStatus];
154
+ };
155
+ };
31
156
  };
32
157
  type PermissionEntities = {
33
- PermissionMapper: PermissionDto;
34
- CreatePermissionMapper: PermissionDto;
35
- UpdatePermissionMapper: PermissionDto;
36
- RoleEntityMapper: MapNestedDtoArraysToCollections<UpdateRoleDto, 'permissions'>;
158
+ PermissionMapper: {
159
+ '~entity': (typeof Permission)['~entity'];
160
+ };
161
+ CreatePermissionMapper: {
162
+ '~entity': (typeof Permission)['~entity'];
163
+ };
164
+ UpdatePermissionMapper: {
165
+ '~entity': (typeof Permission)['~entity'];
166
+ };
167
+ RoleEntityMapper: {
168
+ '~entity': (typeof Role)['~entity'];
169
+ };
37
170
  };
38
171
  type RoleEntities = {
39
- RoleMapper: MapNestedDtoArraysToCollections<RoleDto, 'permissions'>;
40
- CreateRoleMapper: MapNestedDtoArraysToCollections<RoleDto, 'permissions'>;
41
- UpdateRoleMapper: MapNestedDtoArraysToCollections<RoleDto, 'permissions'>;
172
+ RoleMapper: {
173
+ '~entity': (typeof Role)['~entity'];
174
+ };
175
+ CreateRoleMapper: {
176
+ '~entity': (typeof Role)['~entity'];
177
+ };
178
+ UpdateRoleMapper: {
179
+ '~entity': (typeof Role)['~entity'];
180
+ };
42
181
  };
43
182
  type UserEntities = {
44
- UserMapper: MapNestedDtoArraysToCollections<UserDto, 'roles'>;
45
- CreateUserMapper: MapNestedDtoArraysToCollections<UserDto, 'roles'>;
46
- UpdateUserMapper: MapNestedDtoArraysToCollections<UserDto, 'roles'>;
183
+ UserMapper: {
184
+ '~entity': (typeof User)['~entity'];
185
+ };
186
+ CreateUserMapper: {
187
+ '~entity': (typeof User)['~entity'];
188
+ };
189
+ UpdateUserMapper: {
190
+ '~entity': (typeof User)['~entity'];
191
+ };
47
192
  };
48
193
 
49
194
  type OrganizationMappers<OrganizationStatus, MapperEntities extends OrganizationEntities<OrganizationStatus>, MapperDomains extends OrganizationDtos<OrganizationStatus>> = {
50
195
  OrganizationMapper: {
51
- toDto: (entity: MapperEntities['OrganizationMapper']) => Promise<MapperDomains['OrganizationMapper']>;
196
+ entity: MapperEntities['OrganizationMapper'];
197
+ toDto: (entity: InferEntity<MapperEntities['OrganizationMapper']>) => Promise<MapperDomains['OrganizationMapper']>;
52
198
  };
53
199
  CreateOrganizationMapper: {
54
- toEntity: (dto: MapperDomains['CreateOrganizationMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperEntities['CreateOrganizationMapper']>;
200
+ entity: MapperEntities['CreateOrganizationMapper'];
201
+ toEntity: (dto: MapperDomains['CreateOrganizationMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['CreateOrganizationMapper']>>;
55
202
  };
56
203
  UpdateOrganizationMapper: {
57
- toEntity: (dto: MapperDomains['UpdateOrganizationMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperEntities['UpdateOrganizationMapper']>;
204
+ entity: MapperEntities['UpdateOrganizationMapper'];
205
+ toEntity: (dto: MapperDomains['UpdateOrganizationMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['UpdateOrganizationMapper']>>;
58
206
  };
59
207
  };
60
208
 
61
209
  type PermissionMappers<MapperEntities extends PermissionEntities, MapperDomains extends PermissionDtos> = {
62
210
  PermissionMapper: {
63
- toDto: (entity: MapperEntities['PermissionMapper']) => Promise<MapperDomains['PermissionMapper']>;
211
+ entity: MapperEntities['PermissionMapper'];
212
+ toDto: (entity: InferEntity<MapperEntities['PermissionMapper']>) => Promise<MapperDomains['PermissionMapper']>;
64
213
  };
65
214
  CreatePermissionMapper: {
66
- toEntity: (dto: MapperDomains['CreatePermissionMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperEntities['CreatePermissionMapper']>;
215
+ entity: MapperEntities['CreatePermissionMapper'];
216
+ toEntity: (dto: MapperDomains['CreatePermissionMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['CreatePermissionMapper']>>;
67
217
  };
68
218
  UpdatePermissionMapper: {
69
- toEntity: (dto: MapperDomains['UpdatePermissionMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperEntities['UpdatePermissionMapper']>;
219
+ entity: MapperEntities['UpdatePermissionMapper'];
220
+ toEntity: (dto: MapperDomains['UpdatePermissionMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['UpdatePermissionMapper']>>;
70
221
  };
71
222
  RoleEntityMapper: {
72
- toEntity: (dto: MapperDomains['RoleEntityMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperEntities['RoleEntityMapper']>;
223
+ entity: MapperEntities['RoleEntityMapper'];
224
+ toEntity: (dto: MapperDomains['RoleEntityMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['RoleEntityMapper']>>;
73
225
  };
74
226
  };
75
227
 
76
228
  type RoleMappers<MapperEntities extends RoleEntities, MapperDomains extends RoleDtos> = {
77
229
  RoleMapper: {
78
- toDto: (entity: MapperEntities['RoleMapper']) => Promise<MapperDomains['RoleMapper']>;
230
+ entity: MapperEntities['RoleMapper'];
231
+ toDto: (entity: InferEntity<MapperEntities['RoleMapper']>) => Promise<MapperDomains['RoleMapper']>;
79
232
  };
80
233
  CreateRoleMapper: {
81
- toEntity: (dto: MapperDomains['CreateRoleMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperEntities['CreateRoleMapper']>;
234
+ entity: MapperEntities['CreateRoleMapper'];
235
+ toEntity: (dto: MapperDomains['CreateRoleMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['CreateRoleMapper']>>;
82
236
  };
83
237
  UpdateRoleMapper: {
84
- toEntity: (dto: MapperDomains['UpdateRoleMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperEntities['UpdateRoleMapper']>;
238
+ entity: MapperEntities['UpdateRoleMapper'];
239
+ toEntity: (dto: MapperDomains['UpdateRoleMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['UpdateRoleMapper']>>;
85
240
  };
86
241
  };
87
242
 
88
243
  type UserMappers<MapperEntities extends UserEntities, MapperDomains extends UserDtos> = {
89
244
  UserMapper: {
90
- toDto: (entity: MapperEntities['UserMapper']) => Promise<MapperDomains['UserMapper']>;
245
+ entity: MapperEntities['UserMapper'];
246
+ toDto: (entity: InferEntity<MapperEntities['UserMapper']>) => Promise<MapperDomains['UserMapper']>;
91
247
  };
92
248
  CreateUserMapper: {
93
- toEntity: (dto: MapperDomains['CreateUserMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperEntities['CreateUserMapper']>;
249
+ entity: MapperEntities['CreateUserMapper'];
250
+ toEntity: (dto: MapperDomains['CreateUserMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['CreateUserMapper']>>;
94
251
  };
95
252
  UpdateUserMapper: {
96
- toEntity: (dto: MapperDomains['UpdateUserMapper'], em: EntityManager, ...args: unknown[]) => Promise<MapperEntities['UpdateUserMapper']>;
253
+ entity: MapperEntities['UpdateUserMapper'];
254
+ toEntity: (dto: MapperDomains['UpdateUserMapper'], em: EntityManager, ...args: unknown[]) => Promise<InferEntity<MapperEntities['UpdateUserMapper']>>;
97
255
  };
98
256
  };
99
257
 
@@ -14,7 +14,7 @@ export const CreateUserSchema = {
14
14
  password: string,
15
15
  firstName: string,
16
16
  lastName: string,
17
- organization: string,
17
+ organization: optional(string),
18
18
  roles: array(string),
19
19
  phoneNumber: optional(string),
20
20
  subscription: optional(string),
@@ -38,6 +38,7 @@ export const UserSchema = ({ uuidId }: { uuidId: boolean }) => ({
38
38
  email: email,
39
39
  firstName: string,
40
40
  lastName: string,
41
+ organization: optional(string),
41
42
  roles: array(RoleSchema({ uuidId })),
42
43
  phoneNumber: optional(string),
43
44
  subscription: optional(string),
@@ -1,49 +1,67 @@
1
- import { MapNestedDtoArraysToCollections } from '@forklaunch/core/services';
2
1
  import {
3
- OrganizationDto,
4
- PermissionDto,
5
- RoleDto,
6
- UpdateRoleDto,
7
- UserDto
8
- } from '@forklaunch/interfaces-iam/types';
2
+ Organization,
3
+ Permission,
4
+ Role,
5
+ User
6
+ } from '../../persistence/entities';
9
7
 
10
- // organization
8
+ // organization entity mapper types
11
9
  export type OrganizationEntities<OrganizationStatus> = {
12
- OrganizationMapper: MapNestedDtoArraysToCollections<
13
- OrganizationDto<OrganizationStatus>,
14
- 'users'
15
- >;
16
- CreateOrganizationMapper: MapNestedDtoArraysToCollections<
17
- OrganizationDto<OrganizationStatus>,
18
- 'users'
19
- >;
20
- UpdateOrganizationMapper: MapNestedDtoArraysToCollections<
21
- OrganizationDto<OrganizationStatus>,
22
- 'users'
23
- >;
10
+ OrganizationMapper: {
11
+ '~entity': (typeof Organization)['~entity'] & {
12
+ status: OrganizationStatus[keyof OrganizationStatus];
13
+ };
14
+ };
15
+ CreateOrganizationMapper: {
16
+ '~entity': (typeof Organization)['~entity'] & {
17
+ status: OrganizationStatus[keyof OrganizationStatus];
18
+ };
19
+ };
20
+ UpdateOrganizationMapper: {
21
+ '~entity': (typeof Organization)['~entity'] & {
22
+ status: OrganizationStatus[keyof OrganizationStatus];
23
+ };
24
+ };
24
25
  };
25
26
 
26
- // permission
27
+ // permission entity mapper types
27
28
  export type PermissionEntities = {
28
- PermissionMapper: PermissionDto;
29
- CreatePermissionMapper: PermissionDto;
30
- UpdatePermissionMapper: PermissionDto;
31
- RoleEntityMapper: MapNestedDtoArraysToCollections<
32
- UpdateRoleDto,
33
- 'permissions'
34
- >;
29
+ PermissionMapper: {
30
+ '~entity': (typeof Permission)['~entity'];
31
+ };
32
+ CreatePermissionMapper: {
33
+ '~entity': (typeof Permission)['~entity'];
34
+ };
35
+ UpdatePermissionMapper: {
36
+ '~entity': (typeof Permission)['~entity'];
37
+ };
38
+ RoleEntityMapper: {
39
+ '~entity': (typeof Role)['~entity'];
40
+ };
35
41
  };
36
42
 
37
- // role
43
+ // role entity mapper types
38
44
  export type RoleEntities = {
39
- RoleMapper: MapNestedDtoArraysToCollections<RoleDto, 'permissions'>;
40
- CreateRoleMapper: MapNestedDtoArraysToCollections<RoleDto, 'permissions'>;
41
- UpdateRoleMapper: MapNestedDtoArraysToCollections<RoleDto, 'permissions'>;
45
+ RoleMapper: {
46
+ '~entity': (typeof Role)['~entity'];
47
+ };
48
+ CreateRoleMapper: {
49
+ '~entity': (typeof Role)['~entity'];
50
+ };
51
+ UpdateRoleMapper: {
52
+ '~entity': (typeof Role)['~entity'];
53
+ };
42
54
  };
43
55
 
44
- // user
56
+ // user entity mapper types
45
57
  export type UserEntities = {
46
- UserMapper: MapNestedDtoArraysToCollections<UserDto, 'roles'>;
47
- CreateUserMapper: MapNestedDtoArraysToCollections<UserDto, 'roles'>;
48
- UpdateUserMapper: MapNestedDtoArraysToCollections<UserDto, 'roles'>;
58
+ UserMapper: {
59
+ '~entity': (typeof User)['~entity'];
60
+ };
61
+ CreateUserMapper: {
62
+ '~entity': (typeof User)['~entity'];
63
+ };
64
+ UpdateUserMapper: {
65
+ '~entity': (typeof User)['~entity'];
66
+ };
49
67
  };
@@ -1,4 +1,4 @@
1
- import { EntityManager } from '@mikro-orm/core';
1
+ import { EntityManager, InferEntity } from '@mikro-orm/core';
2
2
  import { OrganizationDtos } from './iamDto.types';
3
3
  import { OrganizationEntities } from './iamEntities.types';
4
4
 
@@ -8,22 +8,25 @@ export type OrganizationMappers<
8
8
  MapperDomains extends OrganizationDtos<OrganizationStatus>
9
9
  > = {
10
10
  OrganizationMapper: {
11
+ entity: MapperEntities['OrganizationMapper'];
11
12
  toDto: (
12
- entity: MapperEntities['OrganizationMapper']
13
+ entity: InferEntity<MapperEntities['OrganizationMapper']>
13
14
  ) => Promise<MapperDomains['OrganizationMapper']>;
14
15
  };
15
16
  CreateOrganizationMapper: {
17
+ entity: MapperEntities['CreateOrganizationMapper'];
16
18
  toEntity: (
17
19
  dto: MapperDomains['CreateOrganizationMapper'],
18
20
  em: EntityManager,
19
21
  ...args: unknown[]
20
- ) => Promise<MapperEntities['CreateOrganizationMapper']>;
22
+ ) => Promise<InferEntity<MapperEntities['CreateOrganizationMapper']>>;
21
23
  };
22
24
  UpdateOrganizationMapper: {
25
+ entity: MapperEntities['UpdateOrganizationMapper'];
23
26
  toEntity: (
24
27
  dto: MapperDomains['UpdateOrganizationMapper'],
25
28
  em: EntityManager,
26
29
  ...args: unknown[]
27
- ) => Promise<MapperEntities['UpdateOrganizationMapper']>;
30
+ ) => Promise<InferEntity<MapperEntities['UpdateOrganizationMapper']>>;
28
31
  };
29
32
  };
@@ -1,4 +1,4 @@
1
- import { EntityManager } from '@mikro-orm/core';
1
+ import { EntityManager, InferEntity } from '@mikro-orm/core';
2
2
  import { PermissionDtos } from './iamDto.types';
3
3
  import { PermissionEntities } from './iamEntities.types';
4
4
 
@@ -7,29 +7,33 @@ export type PermissionMappers<
7
7
  MapperDomains extends PermissionDtos
8
8
  > = {
9
9
  PermissionMapper: {
10
+ entity: MapperEntities['PermissionMapper'];
10
11
  toDto: (
11
- entity: MapperEntities['PermissionMapper']
12
+ entity: InferEntity<MapperEntities['PermissionMapper']>
12
13
  ) => Promise<MapperDomains['PermissionMapper']>;
13
14
  };
14
15
  CreatePermissionMapper: {
16
+ entity: MapperEntities['CreatePermissionMapper'];
15
17
  toEntity: (
16
18
  dto: MapperDomains['CreatePermissionMapper'],
17
19
  em: EntityManager,
18
20
  ...args: unknown[]
19
- ) => Promise<MapperEntities['CreatePermissionMapper']>;
21
+ ) => Promise<InferEntity<MapperEntities['CreatePermissionMapper']>>;
20
22
  };
21
23
  UpdatePermissionMapper: {
24
+ entity: MapperEntities['UpdatePermissionMapper'];
22
25
  toEntity: (
23
26
  dto: MapperDomains['UpdatePermissionMapper'],
24
27
  em: EntityManager,
25
28
  ...args: unknown[]
26
- ) => Promise<MapperEntities['UpdatePermissionMapper']>;
29
+ ) => Promise<InferEntity<MapperEntities['UpdatePermissionMapper']>>;
27
30
  };
28
31
  RoleEntityMapper: {
32
+ entity: MapperEntities['RoleEntityMapper'];
29
33
  toEntity: (
30
34
  dto: MapperDomains['RoleEntityMapper'],
31
35
  em: EntityManager,
32
36
  ...args: unknown[]
33
- ) => Promise<MapperEntities['RoleEntityMapper']>;
37
+ ) => Promise<InferEntity<MapperEntities['RoleEntityMapper']>>;
34
38
  };
35
39
  };
@@ -1,4 +1,4 @@
1
- import { EntityManager } from '@mikro-orm/core';
1
+ import { EntityManager, InferEntity } from '@mikro-orm/core';
2
2
  import { RoleDtos } from './iamDto.types';
3
3
  import { RoleEntities } from './iamEntities.types';
4
4
 
@@ -7,22 +7,25 @@ export type RoleMappers<
7
7
  MapperDomains extends RoleDtos
8
8
  > = {
9
9
  RoleMapper: {
10
+ entity: MapperEntities['RoleMapper'];
10
11
  toDto: (
11
- entity: MapperEntities['RoleMapper']
12
+ entity: InferEntity<MapperEntities['RoleMapper']>
12
13
  ) => Promise<MapperDomains['RoleMapper']>;
13
14
  };
14
15
  CreateRoleMapper: {
16
+ entity: MapperEntities['CreateRoleMapper'];
15
17
  toEntity: (
16
18
  dto: MapperDomains['CreateRoleMapper'],
17
19
  em: EntityManager,
18
20
  ...args: unknown[]
19
- ) => Promise<MapperEntities['CreateRoleMapper']>;
21
+ ) => Promise<InferEntity<MapperEntities['CreateRoleMapper']>>;
20
22
  };
21
23
  UpdateRoleMapper: {
24
+ entity: MapperEntities['UpdateRoleMapper'];
22
25
  toEntity: (
23
26
  dto: MapperDomains['UpdateRoleMapper'],
24
27
  em: EntityManager,
25
28
  ...args: unknown[]
26
- ) => Promise<MapperEntities['UpdateRoleMapper']>;
29
+ ) => Promise<InferEntity<MapperEntities['UpdateRoleMapper']>>;
27
30
  };
28
31
  };
@@ -1,4 +1,4 @@
1
- import { EntityManager } from '@mikro-orm/core';
1
+ import { EntityManager, InferEntity } from '@mikro-orm/core';
2
2
  import { UserDtos } from './iamDto.types';
3
3
  import { UserEntities } from './iamEntities.types';
4
4
 
@@ -7,22 +7,25 @@ export type UserMappers<
7
7
  MapperDomains extends UserDtos
8
8
  > = {
9
9
  UserMapper: {
10
+ entity: MapperEntities['UserMapper'];
10
11
  toDto: (
11
- entity: MapperEntities['UserMapper']
12
+ entity: InferEntity<MapperEntities['UserMapper']>
12
13
  ) => Promise<MapperDomains['UserMapper']>;
13
14
  };
14
15
  CreateUserMapper: {
16
+ entity: MapperEntities['CreateUserMapper'];
15
17
  toEntity: (
16
18
  dto: MapperDomains['CreateUserMapper'],
17
19
  em: EntityManager,
18
20
  ...args: unknown[]
19
- ) => Promise<MapperEntities['CreateUserMapper']>;
21
+ ) => Promise<InferEntity<MapperEntities['CreateUserMapper']>>;
20
22
  };
21
23
  UpdateUserMapper: {
24
+ entity: MapperEntities['UpdateUserMapper'];
22
25
  toEntity: (
23
26
  dto: MapperDomains['UpdateUserMapper'],
24
27
  em: EntityManager,
25
28
  ...args: unknown[]
26
- ) => Promise<MapperEntities['UpdateUserMapper']>;
29
+ ) => Promise<InferEntity<MapperEntities['UpdateUserMapper']>>;
27
30
  };
28
31
  };