Skip to content

Commit

Permalink
♻️ refactor move repo to shared
Browse files Browse the repository at this point in the history
  • Loading branch information
yaf authored Nov 21, 2024
1 parent 4633b2c commit ad822cb
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion api/lib/domain/usecases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as complementaryCertificationRepository from '../../../src/certificatio
import * as sessionCodeService from '../../../src/certification/enrolment/domain/services/session-code-service.js';
import { getCenterForAdmin } from '../../../src/certification/enrolment/domain/usecases/get-center-for-admin.js';
import * as centerRepository from '../../../src/certification/enrolment/infrastructure/repositories/center-repository.js';
import * as certificationCandidateRepository from '../../../src/certification/enrolment/infrastructure/repositories/certification-candidate-repository.js';
import * as certificationCpfCityRepository from '../../../src/certification/enrolment/infrastructure/repositories/certification-cpf-city-repository.js';
import * as sessionEnrolmentRepository from '../../../src/certification/enrolment/infrastructure/repositories/session-repository.js';
import * as certificationEvaluationCandidateRepository from '../../../src/certification/evaluation/infrastructure/repositories/certification-candidate-repository.js';
Expand All @@ -23,6 +22,7 @@ import * as supervisorAccessRepository from '../../../src/certification/session-
import * as certificationBadgesService from '../../../src/certification/shared/domain/services/certification-badges-service.js';
import * as scoringCertificationService from '../../../src/certification/shared/domain/services/scoring-certification-service.js';
import * as certificationAssessmentRepository from '../../../src/certification/shared/infrastructure/repositories/certification-assessment-repository.js';
import * as certificationCandidateRepository from '../../../src/certification/shared/infrastructure/repositories/certification-candidate-repository.js';
import * as certificationCenterRepository from '../../../src/certification/shared/infrastructure/repositories/certification-center-repository.js';
import * as certificationChallengeLiveAlertRepository from '../../../src/certification/shared/infrastructure/repositories/certification-challenge-live-alert-repository.js';
import * as certificationChallengeRepository from '../../../src/certification/shared/infrastructure/repositories/certification-challenge-repository.js';
Expand Down
4 changes: 2 additions & 2 deletions api/src/certification/enrolment/domain/usecases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import * as temporarySessionsStorageForMassImportService from '../services/tempo
* @typedef {import('../../infrastructure/repositories/index.js').ComplementaryCertificationRepository} ComplementaryCertificationRepository
* @typedef {import('../../infrastructure/repositories/index.js').ComplementaryCertificationBadgeWithOffsetVersionRepository} ComplementaryCertificationBadgeWithOffsetVersionRepository
* @typedef {import('../../infrastructure/repositories/index.js').SessionRepository} SessionRepository
* @typedef {import('../../infrastructure/repositories/index.js').CertificationCandidateRepository} CertificationCandidateRepository
* @typedef {import('../../../../shared/infrastructure/repositories/index.js').CertificationCandidateRepository} CertificationCandidateRepository
* @typedef {import('../../../session-management/infrastructure/repositories/index.js').CertificationCandidateForSupervisingRepository} CertificationCandidateForSupervisingRepository
* @typedef {import('../../infrastructure/repositories/index.js').CertificationCpfCityRepository} CertificationCpfCityRepository
* @typedef {import('../../infrastructure/repositories/index.js').CertificationCpfCountryRepository} CertificationCpfCountryRepository
Expand All @@ -32,7 +32,7 @@ import * as temporarySessionsStorageForMassImportService from '../services/tempo
* @typedef {import('../../infrastructure/repositories/index.js').CountryRepository} CountryRepository
* @typedef {import('../../infrastructure/repositories/index.js').ScoCertificationCandidateRepository} ScoCertificationCandidateRepository
* @typedef {import('../../infrastructure/repositories/index.js').OrganizationLearnerRepository} OrganizationLearnerRepository
* @typedef {import('../../infrastructure/repositories/index.js').UserRepository} UserRepository
* @typedef {import('../../../../shared/infrastructure/repositories/index.js').UserRepository} UserRepository
* @typedef {import('../../../shared/domain/validators/session-validator.js')} SessionValidator
* @typedef {import('../../../shared/domain/services/certification-cpf-service.js')} CertificationCpfService
* @typedef {import('../../infrastructure/utils/pdf/attendance-sheet-pdf.js')} AttendanceSheetPdfUtils
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import * as organizationLearnerRepository from '../../../../../lib/infrastructur
import { injectDependencies } from '../../../../shared/infrastructure/utils/dependency-injection.js';
import * as complementaryCertificationApi from '../../../complementary-certification/application/api/complementary-certification-api.js';
import * as sessionManagementRepository from '../../../session-management/infrastructure/repositories/session-repository.js';
import * as certificationCandidateRepository from '../../../shared/infrastructure/repositories/certification-candidate-repository.js';
import * as certificationCenterRepository from '../../../shared/infrastructure/repositories/certification-center-repository.js';
import * as targetProfileHistoryRepository from '../../../shared/infrastructure/repositories/target-profile-history-repository.js';
import * as userRepository from '../../../shared/infrastructure/repositories/user-repository.js';
import * as candidateRepository from './candidate-repository.js';
import * as centerRepository from './center-repository.js';
import * as certificationCandidateRepository from './certification-candidate-repository.js';
import * as certificationCpfCityRepository from './certification-cpf-city-repository.js';
import * as certificationCpfCountryRepository from './certification-cpf-country-repository.js';
import * as complementaryCertificationBadgeWithOffsetVersionRepository from './complementary-certification-badge-with-offset-version-repository.js';
Expand All @@ -18,7 +19,6 @@ import * as pixCertificationRepository from './pix-certification-repository.js';
import * as scoCertificationCandidateRepository from './sco-certification-candidate-repository.js';
import * as sessionForAttendanceSheetRepository from './session-for-attendance-sheet-repository.js';
import * as sessionRepository from './session-repository.js';
import * as userRepository from './user-repository.js';

/**
* Using {@link https://jsdoc.app/tags-type "Closure Compiler's syntax"} to document injected dependencies
Expand Down
6 changes: 3 additions & 3 deletions api/src/certification/evaluation/domain/usecases/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import * as languageService from '../../../../shared/domain/services/language-se
import * as placementProfileService from '../../../../shared/domain/services/placement-profile-service.js';
import { injectDependencies } from '../../../../shared/infrastructure/utils/dependency-injection.js';
import { importNamedExportsFromDirectory } from '../../../../shared/infrastructure/utils/import-named-exports-from-directory.js';
import * as enrolmentCertificationCandidateRepository from '../../../enrolment/infrastructure/repositories/certification-candidate-repository.js';
import * as userRepository from '../../../enrolment/infrastructure/repositories/user-repository.js';
import * as flashAlgorithmService from '../../../flash-certification/domain/services/algorithm-methods/flash.js';
import {
answerRepository,
Expand All @@ -24,8 +22,10 @@ import {
sharedCompetenceMarkRepository,
} from '../../../session-management/infrastructure/repositories/index.js';
import * as certificationBadgesService from '../../../shared/domain/services/certification-badges-service.js';
import * as sharedCertificationCandidateRepository from '../../../shared/infrastructure/repositories/certification-candidate-repository.js';
import * as certificationCenterRepository from '../../../shared/infrastructure/repositories/certification-center-repository.js';
import * as certificationCourseRepository from '../../../shared/infrastructure/repositories/certification-course-repository.js';
import * as userRepository from '../../../shared/infrastructure/repositories/user-repository.js';
import * as certificationCandidateRepository from '../../infrastructure/repositories/certification-candidate-repository.js';
import * as certificationCompanionAlertRepository from '../../infrastructure/repositories/certification-companion-alert-repository.js';
/**
Expand All @@ -35,7 +35,7 @@ import * as certificationCompanionAlertRepository from '../../infrastructure/rep
const dependencies = {
...sessionRepositories,
assessmentRepository,
enrolmentCertificationCandidateRepository,
sharedCertificationCandidateRepository,
verifyCertificateCodeService,
assessmentResultRepository,
answerRepository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const { features } = config;
* @param {Object} params
* @param {SessionRepository} params.sessionRepository
* @param {AssessmentRepository} params.assessmentRepository
* @param {CertificationCandidateRepository} params.enrolmentCertificationCandidateRepository
* @param {CertificationCandidateRepository} params.sharedCertificationCandidateRepository
* @param {CertificationCourseRepository} params.certificationCourseRepository
* @param {UserRepository} params.userRepository
* @param {PlacementProfileService} params.placementProfileService
Expand All @@ -48,7 +48,7 @@ const retrieveLastOrCreateCertificationCourse = async function ({
userId,
locale,
assessmentRepository,
enrolmentCertificationCandidateRepository,
sharedCertificationCandidateRepository,
certificationCourseRepository,
sessionRepository,
certificationCenterRepository,
Expand All @@ -64,7 +64,7 @@ const retrieveLastOrCreateCertificationCourse = async function ({
_validateSessionAccess(session, accessCode);
_validateSessionIsActive(session);

const certificationCandidate = await enrolmentCertificationCandidateRepository.getBySessionIdAndUserId({
const certificationCandidate = await sharedCertificationCandidateRepository.getBySessionIdAndUserId({
userId,
sessionId,
});
Expand All @@ -81,7 +81,7 @@ const retrieveLastOrCreateCertificationCourse = async function ({

await _blockCandidateFromRestartingWithoutExplicitValidation(
certificationCandidate,
enrolmentCertificationCandidateRepository,
sharedCertificationCandidateRepository,
);

if (existingCertificationCourse) {
Expand Down Expand Up @@ -164,10 +164,10 @@ function _validateCandidateIsAuthorizedToStart(certificationCandidate, existingC

async function _blockCandidateFromRestartingWithoutExplicitValidation(
certificationCandidate,
enrolmentCertificationCandidateRepository,
sharedCertificationCandidateRepository,
) {
certificationCandidate.authorizedToStart = false;
await enrolmentCertificationCandidateRepository.update(certificationCandidate);
await sharedCertificationCandidateRepository.update(certificationCandidate);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { knex } from '../../../../../db/knex-database-connection.js';
import { NotFoundError } from '../../../../shared/domain/errors.js';
import { CertificationCandidate } from '../../../../shared/domain/models/index.js';
import { ComplementaryCertification } from '../../domain/models/ComplementaryCertification.js';
import { Subscription } from '../../domain/models/Subscription.js';
import { ComplementaryCertification } from '../../../enrolment/domain/models/ComplementaryCertification.js';
import { Subscription } from '../../../enrolment/domain/models/Subscription.js';

const getBySessionIdAndUserId = async function ({ sessionId, userId }) {
const candidateData = await _candidateBaseQuery().where({ sessionId, userId }).first();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _ from 'lodash';

import { knex } from '../../../../../db/knex-database-connection.js';
import { DomainTransaction } from '../../../../shared/domain/DomainTransaction.js';
import { User } from '../../domain/models/User.js';
import { User } from '../../../enrolment/domain/models/User.js';

export async function get({ id }) {
const knexConn = DomainTransaction.getConnection();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import _ from 'lodash';

import * as certificationCandidateRepository from '../../../../../../src/certification/enrolment/infrastructure/repositories/certification-candidate-repository.js';
import { ComplementaryCertification } from '../../../../../../src/certification/session-management/domain/models/ComplementaryCertification.js';
import { ComplementaryCertificationKeys } from '../../../../../../src/certification/shared/domain/models/ComplementaryCertificationKeys.js';
import * as certificationCandidateRepository from '../../../../../../src/certification/shared/infrastructure/repositories/certification-candidate-repository.js';
import { NotFoundError } from '../../../../../../src/shared/domain/errors.js';
import { catchErr, databaseBuilder, domainBuilder, expect, knex } from '../../../../../test-helper.js';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as userRepository from '../../../../../../src/certification/enrolment/infrastructure/repositories/user-repository.js';
import * as userRepository from '../../../../../../src/certification/shared/infrastructure/repositories/user-repository.js';
import { databaseBuilder, domainBuilder, expect } from '../../../../../test-helper.js';

describe('Integration | Repository | certification | enrolment | User', function () {
Expand Down
Loading

0 comments on commit ad822cb

Please sign in to comment.