-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(schema)!: apply v1.0.1 changes (#51)
* feat(schema)!: allow multi email in contact field * feat(schema)!: pipes as contact courriels and websites separator * feat(schema)!: update frais à charge * feat(schema)!: update modalites accompagenment * feat(schema): add RIDET as valid pivot * feat(schema)!: pipes as typologies separator * refactor(schema): order calling codes * feat(schema)!: remove cle ban field * feat(schema)!: add itinerance field * feat(schema)!: update services values and make it otional * feat(schema)!: add moalité acces * feat(schema)!: do not set public access information when access is private * feat(schema)!: split public accueillis field to prises en charge and publics addressés * feat: add new typologies * feat!: split labels nationaux and rename autres labels * feat(schema)!: update modalités accompagnement values * fix: frais à charge values * feat(schema)!: rename field accessibilite to fiche_acces_libre --------- Co-authored-by: Arthur Belkhayat <[email protected]>
- Loading branch information
1 parent
77cef20
commit 59efa7a
Showing
92 changed files
with
2,122 additions
and
873 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
/* eslint-disable @typescript-eslint/naming-convention, camelcase */ | ||
|
||
import { Courriel } from '../courriel'; | ||
import { Url } from '../url'; | ||
import { Contact, ContactToValidate } from './contact'; | ||
import { CourrielError, TelephoneError } from './errors'; | ||
import { TelephoneError } from './errors'; | ||
|
||
describe('contact model', (): void => { | ||
it('should create a valid contact', (): void => { | ||
const contactData: ContactToValidate = { | ||
telephone: '+33145896378', | ||
courriel: '[email protected]', | ||
courriel: [Courriel('[email protected]')], | ||
site_web: [Url('http://www.cartographienationale.fr')] | ||
}; | ||
|
||
|
@@ -29,7 +30,7 @@ describe('contact model', (): void => { | |
|
||
it('should create a valid contact with only courriel property', (): void => { | ||
const contactData: ContactToValidate = { | ||
courriel: '[email protected]' | ||
courriel: [Courriel('[email protected]')] | ||
}; | ||
|
||
const contact: Contact = Contact(contactData); | ||
|
@@ -40,7 +41,7 @@ describe('contact model', (): void => { | |
it('should create a valid contact with a phone from French Guiana', (): void => { | ||
const contactData: ContactToValidate = { | ||
telephone: '+594694020905', | ||
courriel: '[email protected]', | ||
courriel: [Courriel('[email protected]')], | ||
site_web: [Url('https://www.facebook.com/YenkumuLutuPapaichton/')] | ||
}; | ||
|
||
|
@@ -49,16 +50,6 @@ describe('contact model', (): void => { | |
expect(contact).toStrictEqual({ ...contactData } as Contact); | ||
}); | ||
|
||
it('should throw CourrielError when courriel is invalid', (): void => { | ||
const contactData: ContactToValidate = { | ||
courriel: 'error' | ||
}; | ||
|
||
expect((): void => { | ||
Contact(contactData); | ||
}).toThrow(new CourrielError('error')); | ||
}); | ||
|
||
it('should throw TelephoneError when telephone is invalid', (): void => { | ||
const contactData: ContactToValidate = { | ||
telephone: 'error' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
export * from './courriel.error'; | ||
export * from './telephone.error'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Courriel } from './courriel'; | ||
import { CourrielError } from './errors'; | ||
|
||
describe('courriel model', (): void => { | ||
it('should create a valid courriel', (): void => { | ||
const courrielData: string = '[email protected]'; | ||
|
||
const courriel: Courriel = Courriel(courrielData); | ||
|
||
expect(courriel).toStrictEqual(courrielData as Courriel); | ||
}); | ||
|
||
it('should throw CourrielError when email do not have at symbole or domain extension', (): void => { | ||
const courrielData: string = 'test@gmail'; | ||
|
||
expect((): void => { | ||
Courriel(courrielData); | ||
}).toThrow(new CourrielError(courrielData)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Model } from '../model'; | ||
import { CourrielError } from './errors'; | ||
|
||
export type Courriel = Model<'Courriel', string>; | ||
|
||
const COURRIEL_REG_EXP: RegExp = | ||
/^(?:[a-zA-Z0-9_][a-zA-Z0-9.!#$%&'*+\\=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9][a-zA-Z0-9-]{0,61}[a-zA-Z0-9])+(?:;|$))+$/u; | ||
|
||
const throwCourrielError = (courriel: string): Courriel => { | ||
throw new CourrielError(courriel); | ||
}; | ||
|
||
export const isValidCourriel = (courriel: string): courriel is Courriel => COURRIEL_REG_EXP.test(courriel); | ||
|
||
/* eslint-disable-next-line @typescript-eslint/naming-convention */ | ||
export const Courriel = (courriel: string): Courriel => (isValidCourriel(courriel) ? courriel : throwCourrielError(courriel)); |
3 changes: 1 addition & 2 deletions
3
src/models/contact/errors/courriel.error.ts → src/models/courriel/errors/courriel.error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './courriel.error'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './errors'; | ||
export * from './courriel'; |
27 changes: 27 additions & 0 deletions
27
src/models/dispositif-programme-national/dispositif-programme-national.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { DispositifProgrammeNational, DispositifProgrammesNationaux } from './dispositif-programme-national'; | ||
import { DispositifProgrammeNationalError } from './errors'; | ||
|
||
describe('dispositif programme national model', (): void => { | ||
it('should create valid dispositif programmes nationaux', (): void => { | ||
const dispositifProgrammesNationaux: DispositifProgrammesNationaux = DispositifProgrammesNationaux([ | ||
DispositifProgrammeNational.ConseillersNumeriques | ||
]); | ||
|
||
expect(dispositifProgrammesNationaux).toStrictEqual([DispositifProgrammeNational.ConseillersNumeriques]); | ||
}); | ||
|
||
it('should not create invalid dispositif programmes nationaux', (): void => { | ||
expect((): void => { | ||
DispositifProgrammesNationaux(['France Emploi' as DispositifProgrammeNational]); | ||
}).toThrow(new DispositifProgrammeNationalError('France Emploi' as DispositifProgrammeNational)); | ||
}); | ||
|
||
it('should not create invalid dispositif programmes nationaux containing a valid and an invalid value', (): void => { | ||
expect((): void => { | ||
DispositifProgrammesNationaux([ | ||
DispositifProgrammeNational.ConseillersNumeriques, | ||
'France Emploi' as DispositifProgrammeNational | ||
]); | ||
}).toThrow(new DispositifProgrammeNationalError('France Emploi' as DispositifProgrammeNational)); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
src/models/dispositif-programme-national/dispositif-programme-national.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { Model } from '../model'; | ||
import { DispositifProgrammeNationalError } from './errors'; | ||
|
||
export enum DispositifProgrammeNational { | ||
AidantsConnect = 'Aidants Connect', | ||
BibliothequesNumeriqueDeReference = 'Bibliothèques numérique de référence', | ||
CertificationPIX = 'Certification PIX', | ||
ConseillersNumeriques = 'Conseillers numériques', | ||
EmmausConnect = 'Emmaüs Connect', | ||
FranceServices = 'France Services', | ||
GrandeEcoleDuNumerique = 'Grande école du numérique', | ||
LaCroixRouge = 'La Croix Rouge', | ||
PointNumeriqueCAF = "Point d'accès numérique CAF", | ||
PromeneursDuNet = 'Promeneurs du net', | ||
RelaisNumeriqueEmmausConnect = 'Relais numérique (Emmaüs Connect)' | ||
} | ||
|
||
export type DispositifProgrammesNationaux = Model<'DispositifProgrammesNationaux', DispositifProgrammeNational[]>; | ||
|
||
export type DispositifProgrammeNationalIndefini = 'dispositif ou programme national indéfini'; | ||
|
||
const firstInvalidDispositifProgrammeNational = (dispositifProgrammeNational: DispositifProgrammeNational): boolean => | ||
!Object.values(DispositifProgrammeNational).includes(dispositifProgrammeNational); | ||
|
||
const throwDispositifProgrammesNationauxError = ( | ||
dispositifProgrammesNationaux: DispositifProgrammeNational[] | ||
): DispositifProgrammesNationaux => { | ||
throw new DispositifProgrammeNationalError( | ||
dispositifProgrammesNationaux.find(firstInvalidDispositifProgrammeNational) ?? 'dispositif ou programme national indéfini' | ||
); | ||
}; | ||
|
||
const isDispositifProgrammesNationaux = ( | ||
dispositifProgrammesNationaux: DispositifProgrammeNational[] | ||
): dispositifProgrammesNationaux is DispositifProgrammesNationaux => | ||
dispositifProgrammesNationaux.find(firstInvalidDispositifProgrammeNational) == null; | ||
|
||
/* eslint-disable-next-line @typescript-eslint/naming-convention */ | ||
export const DispositifProgrammesNationaux = ( | ||
dispositifProgrammesNationaux: DispositifProgrammeNational[] | ||
): DispositifProgrammesNationaux => | ||
isDispositifProgrammesNationaux(dispositifProgrammesNationaux) | ||
? dispositifProgrammesNationaux | ||
: throwDispositifProgrammesNationauxError(dispositifProgrammesNationaux); |
12 changes: 12 additions & 0 deletions
12
src/models/dispositif-programme-national/errors/dispositif-programme-national.error.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { ModelError } from '../../../errors'; | ||
import { DispositifProgrammeNational, DispositifProgrammeNationalIndefini } from '../dispositif-programme-national'; | ||
import { LieuMediationNumerique } from '../../lieu-mediation-numerique'; | ||
|
||
export class DispositifProgrammeNationalError extends ModelError<LieuMediationNumerique> { | ||
constructor(dispositifProgrammeNational: DispositifProgrammeNational | DispositifProgrammeNationalIndefini) { | ||
super( | ||
'dispositif_programmes_nationaux', | ||
`Le dispositif programmes national '${dispositifProgrammeNational}' n'est pas une valeur admise` | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './dispositif-programme-national.error'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './errors'; | ||
export * from './dispositif-programme-national'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ModelError } from '../../../errors'; | ||
import { FormationLabel, FormationLabelIndefini } from '../formation-label'; | ||
import { LieuMediationNumerique } from '../../lieu-mediation-numerique'; | ||
|
||
export class FormationLabelError extends ModelError<LieuMediationNumerique> { | ||
constructor(formationLabel: FormationLabel | FormationLabelIndefini) { | ||
super('formations_labels', `Le label de formation '${formationLabel}' n'est pas une valeur admise`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './formation-label.error'; |
Oops, something went wrong.