@punks/backend-entity-manager 0.0.114 → 0.0.116

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.
Files changed (50) hide show
  1. package/dist/cjs/index.js +6 -1
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/abstractions/authentication.d.ts +0 -1
  4. package/dist/cjs/types/platforms/nest/__test__/server/app/{setup/setup.controller.d.ts → appAdmin/appAdmin.controller.d.ts} +1 -1
  5. package/dist/cjs/types/platforms/nest/__test__/server/app/appAdmin/appAdmin.module.d.ts +2 -0
  6. package/dist/{esm/types/platforms/nest/__test__/server/app/setup → cjs/types/platforms/nest/__test__/server/app/appAdmin}/templates/index.d.ts +2 -1
  7. package/dist/cjs/types/platforms/nest/__test__/server/app/appAdmin/templates/user-update/index.d.ts +15 -0
  8. package/dist/cjs/types/platforms/nest/__test__/server/app/appAdmin/templates/user-update/models.d.ts +12 -0
  9. package/dist/cjs/types/platforms/nest/__test__/server/index.d.ts +1 -0
  10. package/dist/cjs/types/platforms/nest/__test__/server/infrastructure/authentication/types.d.ts +4 -0
  11. package/dist/cjs/types/platforms/nest/__test__/server/testing/authentication/index.d.ts +10 -0
  12. package/dist/cjs/types/platforms/nest/__test__/server/testing/authentication/types.d.ts +8 -0
  13. package/dist/cjs/types/platforms/nest/extensions/authentication/types/index.d.ts +1 -1
  14. package/dist/esm/index.js +6 -1
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/types/abstractions/authentication.d.ts +0 -1
  17. package/dist/esm/types/platforms/nest/__test__/server/app/{setup/setup.controller.d.ts → appAdmin/appAdmin.controller.d.ts} +1 -1
  18. package/dist/esm/types/platforms/nest/__test__/server/app/appAdmin/appAdmin.module.d.ts +2 -0
  19. package/dist/{cjs/types/platforms/nest/__test__/server/app/setup → esm/types/platforms/nest/__test__/server/app/appAdmin}/templates/index.d.ts +2 -1
  20. package/dist/esm/types/platforms/nest/__test__/server/app/appAdmin/templates/tenant-initialize/tenant-initialize.pipeline.test.d.ts +1 -0
  21. package/dist/esm/types/platforms/nest/__test__/server/app/appAdmin/templates/user-update/index.d.ts +15 -0
  22. package/dist/esm/types/platforms/nest/__test__/server/app/appAdmin/templates/user-update/models.d.ts +12 -0
  23. package/dist/esm/types/platforms/nest/__test__/server/app/appAdmin/templates/user-update/user-update.pipeline.spec.d.ts +1 -0
  24. package/dist/esm/types/platforms/nest/__test__/server/index.d.ts +1 -0
  25. package/dist/esm/types/platforms/nest/__test__/server/infrastructure/authentication/types.d.ts +4 -0
  26. package/dist/esm/types/platforms/nest/__test__/server/testing/authentication/index.d.ts +10 -0
  27. package/dist/esm/types/platforms/nest/__test__/server/testing/authentication/types.d.ts +8 -0
  28. package/dist/esm/types/platforms/nest/extensions/authentication/types/index.d.ts +1 -1
  29. package/dist/index.d.ts +1 -2
  30. package/package.json +2 -1
  31. package/dist/cjs/types/platforms/nest/__test__/server/app/setup/setup.module.d.ts +0 -2
  32. package/dist/esm/types/platforms/nest/__test__/server/app/setup/setup.module.d.ts +0 -2
  33. /package/dist/cjs/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/instance-initialize/index.d.ts +0 -0
  34. /package/dist/cjs/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/instance-initialize/instance-initialize.pipeline.test.d.ts +0 -0
  35. /package/dist/cjs/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/instance-initialize/models.d.ts +0 -0
  36. /package/dist/cjs/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/organization-register/index.d.ts +0 -0
  37. /package/dist/cjs/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/organization-register/models.d.ts +0 -0
  38. /package/dist/cjs/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/organization-register/organization-register.pipeline.test.d.ts +0 -0
  39. /package/dist/cjs/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/tenant-initialize/index.d.ts +0 -0
  40. /package/dist/cjs/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/tenant-initialize/models.d.ts +0 -0
  41. /package/dist/cjs/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/tenant-initialize/tenant-initialize.pipeline.test.d.ts +0 -0
  42. /package/dist/{esm/types/platforms/nest/__test__/server/app/setup/templates/instance-initialize/instance-initialize.pipeline.test.d.ts → cjs/types/platforms/nest/__test__/server/app/appAdmin/templates/user-update/user-update.pipeline.spec.d.ts} +0 -0
  43. /package/dist/esm/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/instance-initialize/index.d.ts +0 -0
  44. /package/dist/esm/types/platforms/nest/__test__/server/app/{setup/templates/organization-register/organization-register.pipeline.test.d.ts → appAdmin/templates/instance-initialize/instance-initialize.pipeline.test.d.ts} +0 -0
  45. /package/dist/esm/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/instance-initialize/models.d.ts +0 -0
  46. /package/dist/esm/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/organization-register/index.d.ts +0 -0
  47. /package/dist/esm/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/organization-register/models.d.ts +0 -0
  48. /package/dist/esm/types/platforms/nest/__test__/server/app/{setup/templates/tenant-initialize/tenant-initialize.pipeline.test.d.ts → appAdmin/templates/organization-register/organization-register.pipeline.test.d.ts} +0 -0
  49. /package/dist/esm/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/tenant-initialize/index.d.ts +0 -0
  50. /package/dist/esm/types/platforms/nest/__test__/server/app/{setup → appAdmin}/templates/tenant-initialize/models.d.ts +0 -0
@@ -1,5 +1,4 @@
1
1
  export interface IAuthenticationUserRole {
2
- id: string;
3
2
  uid: string;
4
3
  }
5
4
  export interface IAuthenticationContext<TUserContextData> {
@@ -3,7 +3,7 @@ import { TenantInitializeTemplate } from "./templates/tenant-initialize";
3
3
  import { InstanceInitializeTemplate } from "./templates/instance-initialize";
4
4
  import { OrganizationInitializeRequest, OrganizationInitializeResponse } from "./templates/organization-register/models";
5
5
  import { OrganizationRegisterTemplate } from "./templates/organization-register";
6
- export declare class SetupController {
6
+ export declare class AppAdminController {
7
7
  private readonly tenantInit;
8
8
  private readonly instanceInit;
9
9
  private readonly organizationInit;
@@ -0,0 +1,2 @@
1
+ export declare class AppAdminAppModule {
2
+ }
@@ -1,4 +1,5 @@
1
1
  import { InstanceInitializeTemplate } from "./instance-initialize";
2
2
  import { OrganizationRegisterTemplate } from "./organization-register";
3
3
  import { TenantInitializeTemplate } from "./tenant-initialize";
4
- export declare const SetupTemplates: (typeof InstanceInitializeTemplate | typeof OrganizationRegisterTemplate | typeof TenantInitializeTemplate)[];
4
+ import { UserUpdateTemplate } from "./user-update";
5
+ export declare const SetupTemplates: (typeof InstanceInitializeTemplate | typeof OrganizationRegisterTemplate | typeof TenantInitializeTemplate | typeof UserUpdateTemplate)[];
@@ -0,0 +1,15 @@
1
+ import { PipelineDefinition } from "../../../../../../../../types";
2
+ import { AuthenticationService } from "../../../../../../extensions";
3
+ import { IPipelineTemplateBuilder, NestPipelineTemplate } from "../../../../../../pipelines";
4
+ import { AppUserProfileEntityManager } from "../../../../entities/appUserProfiles/appUserProfile.manager";
5
+ import { AppUserEntityManager } from "../../../../entities/appUsers/appUser.manager";
6
+ import { AppAuthContext } from "../../../../infrastructure/authentication";
7
+ import { UserUpdatePipelineInput } from "./models";
8
+ export declare class UserUpdateTemplate extends NestPipelineTemplate<UserUpdatePipelineInput, void, AppAuthContext> {
9
+ private readonly auth;
10
+ private readonly users;
11
+ private readonly userProfiles;
12
+ constructor(auth: AuthenticationService, users: AppUserEntityManager, userProfiles: AppUserProfileEntityManager);
13
+ protected isAuthorized(context: AppAuthContext): boolean;
14
+ protected buildTemplate(builder: IPipelineTemplateBuilder<UserUpdatePipelineInput, AppAuthContext>): PipelineDefinition<UserUpdatePipelineInput, void, AppAuthContext>;
15
+ }
@@ -0,0 +1,12 @@
1
+ export declare class UserUpdateRequest {
2
+ email: string;
3
+ userName: string;
4
+ fistName: string;
5
+ lastName: string;
6
+ roleUid: string;
7
+ birthDate?: string;
8
+ }
9
+ export type UserUpdatePipelineInput = {
10
+ userId: string;
11
+ data: UserUpdateRequest;
12
+ };
@@ -6,6 +6,7 @@ export declare const createTestServer: (options?: {
6
6
  useVersioning?: boolean;
7
7
  extraControllers?: any[];
8
8
  extraProviders?: any[];
9
+ extraModules?: any[];
9
10
  enableLogging?: boolean;
10
11
  }) => Promise<{
11
12
  app: import("@nestjs/common").INestApplication<any>;
@@ -10,10 +10,14 @@ export type AppUserContext = {
10
10
  tenantId: string;
11
11
  tenantUid: string;
12
12
  };
13
+ export type AppUserRole = {
14
+ uid: string;
15
+ };
13
16
  export declare class AppAuthContext implements IAuthenticationContext<AppUserContext> {
14
17
  isAuthenticated: boolean;
15
18
  isAnonymous: boolean;
16
19
  userId?: string;
17
20
  userContext?: AppUserContext;
18
21
  userInfo?: AppUserInfo;
22
+ userRoles?: AppUserRole[];
19
23
  }
@@ -0,0 +1,10 @@
1
+ import { INestApplication } from "@nestjs/common";
2
+ import { DataSource } from "typeorm";
3
+ import { ApplicationAuthenticationContext } from "./types";
4
+ import { AppAuthContextProvider } from "../../infrastructure/authentication";
5
+ import { AuthGuard } from "../../../../extensions";
6
+ export declare const mockAuthenticatedUser: (auth: AppAuthContextProvider, guard: AuthGuard) => void;
7
+ export declare const createAuthenticationContext: (app: INestApplication<any>, dataSource: DataSource) => Promise<ApplicationAuthenticationContext>;
8
+ export declare const createUser: (app: INestApplication<any>, context: ApplicationAuthenticationContext, data: {
9
+ roleUid?: string;
10
+ }) => Promise<import("../../../../extensions").IAuthUser>;
@@ -0,0 +1,8 @@
1
+ import { AppDirectoryEntity } from "../../database/core/entities/appDirectory.entity";
2
+ import { AppOrganizationEntity } from "../../database/core/entities/appOrganization.entity";
3
+ import { AppTenantEntity } from "../../database/core/entities/appTenant.entity";
4
+ export type ApplicationAuthenticationContext = {
5
+ tenant: AppTenantEntity;
6
+ organization: AppOrganizationEntity;
7
+ directory: AppDirectoryEntity;
8
+ };
@@ -20,5 +20,5 @@ export type AppRole = {
20
20
  name: string;
21
21
  };
22
22
  export type RolesGuardOptions = {
23
- inheritRoles?: boolean;
23
+ exact?: boolean;
24
24
  };
package/dist/esm/index.js CHANGED
@@ -2363,7 +2363,7 @@ const Public = () => SetMetadata(AuthenticationGuardsSymbols.Public, true);
2363
2363
  const Authenticated = () => SetMetadata(AuthenticationGuardsSymbols.Authenticated, true);
2364
2364
  const Roles = (...roles) => SetMetadata(AuthenticationGuardsSymbols.Roles, roles);
2365
2365
  const MemberOf = (...groups) => SetMetadata(AuthenticationGuardsSymbols.MemberOf, groups);
2366
- const buildRolesGuard = ({ mainRole, inheritedRoles, }, options) => Roles(mainRole.uid, ...(options?.inheritRoles && inheritedRoles
2366
+ const buildRolesGuard = ({ mainRole, inheritedRoles, }, options) => Roles(mainRole.uid, ...(!options?.exact && inheritedRoles
2367
2367
  ? inheritedRoles.map((role) => role.uid)
2368
2368
  : []));
2369
2369
 
@@ -22019,6 +22019,11 @@ class TypeOrmRepository {
22019
22019
  throw new Error("Invalid 'id' parameter.");
22020
22020
  }
22021
22021
  this.logger.debug("Updating entity", { id, entity });
22022
+ // await this.innerRepository.preload(id as any)
22023
+ // await this.innerRepository.save({
22024
+ // id,
22025
+ // ...entity,
22026
+ // } as unknown as TEntity)
22022
22027
  await this.innerRepository.update(id, entity);
22023
22028
  const current = await this.get(id);
22024
22029
  if (!current) {