Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 1708-feat-instruction-ajoute-la-possibilite-de-voir-les-prochaines-etapes
  • a11y-ci
  • chore-image-snap
  • master
  • notifications
  • preprod
  • prod
  • prolong-proc-ouvertes
  • prs-exploitant
  • sonar
  • try-better-perfs
  • upgrade-keycloak
  • vpn_rie
  • v0.1.0
  • v0.10.0
  • v0.100.0
  • v0.101.0
  • v0.102.0
  • v0.103.0
  • v0.104.0
  • v0.105.0
  • v0.106.0
  • v0.107.0
  • v0.108.0
  • v0.109.0
  • v0.11.0
  • v0.110.0
  • v0.111.0
  • v0.112.0
  • v0.113.0
  • v0.114.0
  • v0.115.0
  • v0.116.0
  • v0.117.0
  • v0.118.0
  • v0.119.0
  • v0.12.0
  • v0.12.1
  • v0.120.0
  • v0.121.0
  • v0.13.0
  • v0.14.0
  • v0.15.0
  • v0.16.0
  • v0.17.0
  • v0.18.0
  • v0.19.0
  • v0.2.0
  • v0.2.1
  • v0.20.0
  • v0.21.0
  • v0.22.0
  • v0.23.0
  • v0.24.0
  • v0.24.1
  • v0.24.10
  • v0.24.11
  • v0.24.12
  • v0.24.13
  • v0.24.14
  • v0.24.15
  • v0.24.16
  • v0.24.17
  • v0.24.18
  • v0.24.19
  • v0.24.2
  • v0.24.20
  • v0.24.21
  • v0.24.22
  • v0.24.23
  • v0.24.24
  • v0.24.25
  • v0.24.26
  • v0.24.27
  • v0.24.28
  • v0.24.29
  • v0.24.3
  • v0.24.30
  • v0.24.31
  • v0.24.32
  • v0.24.33
  • v0.24.34
  • v0.24.35
  • v0.24.36
  • v0.24.37
  • v0.24.38
  • v0.24.39
  • v0.24.4
  • v0.24.40
  • v0.24.41
  • v0.24.42
  • v0.24.43
  • v0.24.44
  • v0.24.45
  • v0.24.46
  • v0.24.47
  • v0.24.48
  • v0.24.49
  • v0.24.5
  • v0.24.50
  • v0.24.51
  • v0.24.52
  • v0.24.53
  • v0.24.54
  • v0.24.55
  • v0.24.56
  • v0.24.57
  • v0.24.58
  • v0.24.59
  • v0.24.6
  • v0.24.60
  • v0.24.61
  • v0.24.62
113 results

Target

Select target project
  • pub/pnm-public/camino
1 result
Select Git revision
  • 1708-feat-instruction-ajoute-la-possibilite-de-voir-les-prochaines-etapes
  • a11y-ci
  • chore-image-snap
  • master
  • notifications
  • preprod
  • prod
  • prolong-proc-ouvertes
  • prs-exploitant
  • sonar
  • try-better-perfs
  • upgrade-keycloak
  • vpn_rie
  • v0.1.0
  • v0.10.0
  • v0.100.0
  • v0.101.0
  • v0.102.0
  • v0.103.0
  • v0.104.0
  • v0.105.0
  • v0.106.0
  • v0.107.0
  • v0.108.0
  • v0.109.0
  • v0.11.0
  • v0.110.0
  • v0.111.0
  • v0.112.0
  • v0.113.0
  • v0.114.0
  • v0.115.0
  • v0.116.0
  • v0.117.0
  • v0.118.0
  • v0.119.0
  • v0.12.0
  • v0.12.1
  • v0.120.0
  • v0.121.0
  • v0.13.0
  • v0.14.0
  • v0.15.0
  • v0.16.0
  • v0.17.0
  • v0.18.0
  • v0.19.0
  • v0.2.0
  • v0.2.1
  • v0.20.0
  • v0.21.0
  • v0.22.0
  • v0.23.0
  • v0.24.0
  • v0.24.1
  • v0.24.10
  • v0.24.11
  • v0.24.12
  • v0.24.13
  • v0.24.14
  • v0.24.15
  • v0.24.16
  • v0.24.17
  • v0.24.18
  • v0.24.19
  • v0.24.2
  • v0.24.20
  • v0.24.21
  • v0.24.22
  • v0.24.23
  • v0.24.24
  • v0.24.25
  • v0.24.26
  • v0.24.27
  • v0.24.28
  • v0.24.29
  • v0.24.3
  • v0.24.30
  • v0.24.31
  • v0.24.32
  • v0.24.33
  • v0.24.34
  • v0.24.35
  • v0.24.36
  • v0.24.37
  • v0.24.38
  • v0.24.39
  • v0.24.4
  • v0.24.40
  • v0.24.41
  • v0.24.42
  • v0.24.43
  • v0.24.44
  • v0.24.45
  • v0.24.46
  • v0.24.47
  • v0.24.48
  • v0.24.49
  • v0.24.5
  • v0.24.50
  • v0.24.51
  • v0.24.52
  • v0.24.53
  • v0.24.54
  • v0.24.55
  • v0.24.56
  • v0.24.57
  • v0.24.58
  • v0.24.59
  • v0.24.6
  • v0.24.60
  • v0.24.61
  • v0.24.62
113 results
Show changes
Commits on Source (2)
Showing
with 475 additions and 438 deletions
...@@ -80,27 +80,18 @@ const titreEtapesPubliques: ITitreInsert = { ...@@ -80,27 +80,18 @@ const titreEtapesPubliques: ITitreInsert = {
{ {
id: newEtapeId('titre-id-demarche-id-asc'), id: newEtapeId('titre-id-demarche-id-asc'),
typeId: 'asc', typeId: 'asc',
ordre: 8,
titreDemarcheId: newDemarcheId('titre-id-demarche-id'),
statutId: 'fai',
date: toCaminoDate('2020-02-02'),
isBrouillon: ETAPE_IS_NOT_BROUILLON,
},
{
id: newEtapeId('titre-id-demarche-id-edm'),
typeId: 'edm',
ordre: 6, ordre: 6,
titreDemarcheId: newDemarcheId('titre-id-demarche-id'), titreDemarcheId: newDemarcheId('titre-id-demarche-id'),
statutId: 'acc', statutId: 'fai',
date: toCaminoDate('2020-02-02'), date: toCaminoDate('2020-02-02'),
isBrouillon: ETAPE_IS_NOT_BROUILLON, isBrouillon: ETAPE_IS_NOT_BROUILLON,
}, },
{ {
id: newEtapeId('titre-id-demarche-id-ede'), id: newEtapeId('titre-id-demarche-id-exp'),
typeId: 'ede', typeId: 'exp',
ordre: 5, ordre: 5,
titreDemarcheId: newDemarcheId('titre-id-demarche-id'), titreDemarcheId: newDemarcheId('titre-id-demarche-id'),
statutId: 'acc', statutId: 'fav',
date: toCaminoDate('2020-02-02'), date: toCaminoDate('2020-02-02'),
isBrouillon: ETAPE_IS_NOT_BROUILLON, isBrouillon: ETAPE_IS_NOT_BROUILLON,
}, },
...@@ -217,7 +208,7 @@ describe('titre', () => { ...@@ -217,7 +208,7 @@ describe('titre', () => {
const res = await graphQLCall(dbPool, titreQuery, { id: 'titre-id' }, { role: 'admin', administrationId: ADMINISTRATION_IDS['DGTM - GUYANE'] }) const res = await graphQLCall(dbPool, titreQuery, { id: 'titre-id' }, { role: 'admin', administrationId: ADMINISTRATION_IDS['DGTM - GUYANE'] })
expect(res.body.errors).toBe(undefined) expect(res.body.errors).toBe(undefined)
expect(res.body.data.titres.elements[0].demarches[0].etapes).toHaveLength(8) expect(res.body.data.titres.elements[0].demarches[0].etapes).toHaveLength(7)
expect( expect(
res.body.data.titres.elements[0].demarches[0].etapes.map(({ id }: { id: string }) => ({ res.body.data.titres.elements[0].demarches[0].etapes.map(({ id }: { id: string }) => ({
id, id,
...@@ -226,8 +217,7 @@ describe('titre', () => { ...@@ -226,8 +217,7 @@ describe('titre', () => {
expect.arrayContaining([ expect.arrayContaining([
{ id: 'titre-id-demarche-id-asc' }, { id: 'titre-id-demarche-id-asc' },
{ id: 'titre-id-demarche-id-dpu' }, { id: 'titre-id-demarche-id-dpu' },
{ id: 'titre-id-demarche-id-ede' }, { id: 'titre-id-demarche-id-exp' },
{ id: 'titre-id-demarche-id-edm' },
{ id: 'titre-id-demarche-id-pfc' }, { id: 'titre-id-demarche-id-pfc' },
{ id: 'titre-id-demarche-id-pfd' }, { id: 'titre-id-demarche-id-pfd' },
{ id: 'titre-id-demarche-id-vfc' }, { id: 'titre-id-demarche-id-vfc' },
......
...@@ -291,7 +291,7 @@ describe('etapeCreer', () => { ...@@ -291,7 +291,7 @@ describe('etapeCreer', () => {
expect(res.statusCode, JSON.stringify(res.body)).toBe(HTTP_STATUS.OK) expect(res.statusCode, JSON.stringify(res.body)).toBe(HTTP_STATUS.OK)
}) })
test('ne peut pas créer une étape EDE sur un titre ARM en tant que DGTM (utilisateur admin)', async () => { test('ne peut pas créer une étape Expertises sur un titre ARM en tant que ONF (utilisateur admin)', async () => {
const titreDemarcheId = await demarcheCreate() const titreDemarcheId = await demarcheCreate()
const res = await restNewPostCall( const res = await restNewPostCall(
...@@ -300,11 +300,11 @@ describe('etapeCreer', () => { ...@@ -300,11 +300,11 @@ describe('etapeCreer', () => {
{}, {},
{ {
role: 'admin', role: 'admin',
administrationId: ADMINISTRATION_IDS['DGTM - GUYANE'], administrationId: ADMINISTRATION_IDS['OFFICE NATIONAL DES FORÊTS'],
}, },
{ {
typeId: 'ede', typeId: ETAPES_TYPES.expertises,
statutId: 'fai', statutId: ETAPES_STATUTS.FAVORABLE,
titreDemarcheId, titreDemarcheId,
date: toCaminoDate('2018-01-01'), date: toCaminoDate('2018-01-01'),
...blankEtapeProps, ...blankEtapeProps,
...@@ -317,12 +317,12 @@ describe('etapeCreer', () => { ...@@ -317,12 +317,12 @@ describe('etapeCreer', () => {
} }
) )
expect(res.statusCode).toBe(HTTP_STATUS.BAD_REQUEST) expect(res.statusCode).toBe(HTTP_STATUS.NOT_FOUND)
expect(res.body).toMatchInlineSnapshot(` expect(res.body).toMatchInlineSnapshot(`
{ {
"detail": "les étapes de la démarche TDE ne sont pas valides", "detail": "L'utilisateur n'a pas accès à la démarche",
"message": "l'étape n'est pas valide", "message": "la démarche n'existe pas",
"status": 400, "status": 404,
} }
`) `)
}) })
...@@ -331,8 +331,8 @@ describe('etapeCreer', () => { ...@@ -331,8 +331,8 @@ describe('etapeCreer', () => {
const titreDemarcheId = await demarcheCreate() const titreDemarcheId = await demarcheCreate()
const res = await restNewPostCall(dbPool, '/rest/etapes', {}, userSuper, { const res = await restNewPostCall(dbPool, '/rest/etapes', {}, userSuper, {
typeId: 'ede', typeId: ETAPES_TYPES.expertises,
statutId: 'fav', statutId: ETAPES_STATUTS.FAVORABLE,
titreDemarcheId, titreDemarcheId,
date: toCaminoDate('2018-01-01'), date: toCaminoDate('2018-01-01'),
...blankEtapeProps, ...blankEtapeProps,
......
...@@ -21,6 +21,7 @@ import { etapeCreate } from './rest-test-utils' ...@@ -21,6 +21,7 @@ import { etapeCreate } from './rest-test-utils'
import { insertTitreGraph, ITitreInsert, multiPolygonWith4Points } from '../../../tests/integration-test-helper' import { insertTitreGraph, ITitreInsert, multiPolygonWith4Points } from '../../../tests/integration-test-helper'
import { ETAPES_TYPES } from 'camino-common/src/static/etapesTypes' import { ETAPES_TYPES } from 'camino-common/src/static/etapesTypes'
import { DOCUMENTS_TYPES_IDS } from 'camino-common/src/static/documentsTypes' import { DOCUMENTS_TYPES_IDS } from 'camino-common/src/static/documentsTypes'
import { ETAPES_STATUTS } from 'camino-common/src/static/etapesStatuts'
vi.mock('../../tools/dir-create', () => ({ vi.mock('../../tools/dir-create', () => ({
__esModule: true, __esModule: true,
...@@ -546,8 +547,8 @@ describe('etapeModifier', () => { ...@@ -546,8 +547,8 @@ describe('etapeModifier', () => {
expect(putRes.statusCode, JSON.stringify(putRes.body)).toBe(HTTP_STATUS.OK) expect(putRes.statusCode, JSON.stringify(putRes.body)).toBe(HTTP_STATUS.OK)
}) })
test('ne peut pas modifier une étape EDE sur un titre ARM en tant que PTMG (utilisateur admin)', async () => { test('ne peut pas modifier une étape Expertises sur un titre ARM en tant que PTMG (utilisateur admin)', async () => {
const { titreDemarcheId, titreEtapeId } = await etapeCreate('ede') const { titreDemarcheId, titreEtapeId } = await etapeCreate(ETAPES_TYPES.expertises)
const res = await restNewPutCall( const res = await restNewPutCall(
dbPool, dbPool,
'/rest/etapes', '/rest/etapes',
...@@ -558,8 +559,8 @@ describe('etapeModifier', () => { ...@@ -558,8 +559,8 @@ describe('etapeModifier', () => {
}, },
{ {
id: titreEtapeId, id: titreEtapeId,
typeId: 'ede', typeId: ETAPES_TYPES.expertises,
statutId: 'fai', statutId: ETAPES_STATUTS.FAVORABLE,
titreDemarcheId, titreDemarcheId,
date: caminoDateValidator.parse('2018-01-01'), date: caminoDateValidator.parse('2018-01-01'),
duree: null, duree: null,
......
...@@ -165,7 +165,7 @@ C;Point éç;-52.55;4.24113309117193` ...@@ -165,7 +165,7 @@ C;Point éç;-52.55;4.24113309117193`
mkdirSync(dir, { recursive: true }) mkdirSync(dir, { recursive: true })
writeFileSync( writeFileSync(
`${dir}/${fileName}`, `${dir}/${fileName}`,
`nom;description;longitude;latitude ` nom ;description;longitude;latitude
A;;-52,54;4,22269896902571 A;;-52,54;4,22269896902571
B;;-52,55;4,22438936251509 B;;-52,55;4,22438936251509
C;Point éç;-52,55;4,24113309117193` C;Point éç;-52,55;4,24113309117193`
...@@ -178,9 +178,54 @@ C;Point éç;-52,55;4,24113309117193` ...@@ -178,9 +178,54 @@ C;Point éç;-52,55;4,24113309117193`
} }
const tested = await restNewPostCall(dbPool, '/rest/geojson/import/:geoSystemeId', { geoSystemeId: GEO_SYSTEME_IDS.WGS84 }, userSuper, body) const tested = await restNewPostCall(dbPool, '/rest/geojson/import/:geoSystemeId', { geoSystemeId: GEO_SYSTEME_IDS.WGS84 }, userSuper, body)
expect(tested.statusCode).toBe(HTTP_STATUS.OK) expect(tested.statusCode, JSON.stringify(tested.body)).toBe(HTTP_STATUS.OK)
expect(tested.body).toMatchSnapshot() expect(tested.body).toMatchSnapshot()
}) })
test('csv valide avec des virgules', async () => {
const fileName = `existing_temp_file_${idGenerate()}.csv`
mkdirSync(dir, { recursive: true })
writeFileSync(
`${dir}/${fileName}`,
`nom,description,longitude,latitude
A,,-52.54,4.22269896902571
B,,-52.55,4.22438936251509
C,Point éç,-52.55,4.24113309117193`
)
const body: GeojsonImportBody = {
titreSlug: titreSlugValidator.parse('titre-slug'),
titreTypeId: 'arm',
tempDocumentName: tempDocumentNameValidator.parse(fileName),
fileType: 'csv',
}
const tested = await restNewPostCall(dbPool, '/rest/geojson/import/:geoSystemeId', { geoSystemeId: GEO_SYSTEME_IDS.WGS84 }, userSuper, body)
expect(tested.body).toMatchInlineSnapshot(`
{
"detail": "Seuls les séparateurs ';' sont acceptés",
"message": "Le séparateur est probablement incorrect",
"status": 400,
}
`)
})
test('csv valide mais sans contenu', async () => {
const fileName = `existing_temp_file_${idGenerate()}.csv`
mkdirSync(dir, { recursive: true })
writeFileSync(`${dir}/${fileName}`, `nom,description,longitude,latitude`)
const body: GeojsonImportBody = {
titreSlug: titreSlugValidator.parse('titre-slug'),
titreTypeId: 'arm',
tempDocumentName: tempDocumentNameValidator.parse(fileName),
fileType: 'csv',
}
const tested = await restNewPostCall(dbPool, '/rest/geojson/import/:geoSystemeId', { geoSystemeId: GEO_SYSTEME_IDS.WGS84 }, userSuper, body)
expect(tested.body).toMatchInlineSnapshot(`
{
"message": "Le CSV ne contient aucun élément",
"status": 400,
}
`)
})
test('fichier valide geojson polygon', async () => { test('fichier valide geojson polygon', async () => {
const feature: FeatureCollectionPolygon = { const feature: FeatureCollectionPolygon = {
type: 'FeatureCollection', type: 'FeatureCollection',
...@@ -1474,7 +1519,7 @@ B;Point B;1063526.397924559889361;6867885.978687250986695;12,12;captage` ...@@ -1474,7 +1519,7 @@ B;Point B;1063526.397924559889361;6867885.978687250986695;12,12;captage`
} }
const tested = await restNewPostCall(dbPool, '/rest/geojson_forages/import/:geoSystemeId', { geoSystemeId: GEO_SYSTEME_IDS['RGFG95 / UTM zone 22N'] }, userSuper, body) const tested = await restNewPostCall(dbPool, '/rest/geojson_forages/import/:geoSystemeId', { geoSystemeId: GEO_SYSTEME_IDS['RGFG95 / UTM zone 22N'] }, userSuper, body)
expect(tested.statusCode).toBe(HTTP_STATUS.OK) expect(tested.statusCode, JSON.stringify(tested.body)).toBe(HTTP_STATUS.OK)
expect(tested.body).toMatchSnapshot() expect(tested.body).toMatchSnapshot()
const testedWithError = await restNewPostCall(dbPool, '/rest/geojson_forages/import/:geoSystemeId', { geoSystemeId: GEO_SYSTEME_IDS.WGS84 }, userSuper, body) const testedWithError = await restNewPostCall(dbPool, '/rest/geojson_forages/import/:geoSystemeId', { geoSystemeId: GEO_SYSTEME_IDS.WGS84 }, userSuper, body)
......
...@@ -41,7 +41,7 @@ import { ...@@ -41,7 +41,7 @@ import {
import { join } from 'node:path' import { join } from 'node:path'
import { readFileSync } from 'node:fs' import { readFileSync } from 'node:fs'
import { parseShp } from 'shpjs' import { parseShp } from 'shpjs'
import { isNotNullNorUndefined, isNullOrUndefined, memoize } from 'camino-common/src/typescript-tools' import { isNotNullNorUndefined, isNotNullNorUndefinedNorEmpty, isNullOrUndefined, memoize } from 'camino-common/src/typescript-tools'
import { SDOMZoneId } from 'camino-common/src/static/sdom' import { SDOMZoneId } from 'camino-common/src/static/sdom'
import { TitreSlug } from 'camino-common/src/validators/titres' import { TitreSlug } from 'camino-common/src/validators/titres'
import { canReadEtape } from './permissions/etapes' import { canReadEtape } from './permissions/etapes'
...@@ -157,7 +157,7 @@ const csvCommonValidator = z ...@@ -157,7 +157,7 @@ const csvCommonValidator = z
if ('Nom du point' in value) { if ('Nom du point' in value) {
value.nom = value['Nom du point'] value.nom = value['Nom du point']
} }
Object.keys(value).forEach(k => (value[k.toLowerCase()] = value[k])) Object.keys(value).forEach(k => (value[k.toLowerCase().trim()] = value[k]))
return value return value
}) })
...@@ -186,7 +186,6 @@ type GeojsonImportErrorMessages = ...@@ -186,7 +186,6 @@ type GeojsonImportErrorMessages =
| EffectDbQueryAndValidateErrors | EffectDbQueryAndValidateErrors
| typeof ouvertureGeoJSONError | typeof ouvertureGeoJSONError
| typeof ouvertureShapeError | typeof ouvertureShapeError
| typeof ouvertureCsvError
| typeof importCsvRestrictionError | typeof importCsvRestrictionError
| typeof recuperationInfoCsvError | typeof recuperationInfoCsvError
| typeof extractionGeoJSONError | typeof extractionGeoJSONError
...@@ -194,6 +193,8 @@ type GeojsonImportErrorMessages = ...@@ -194,6 +193,8 @@ type GeojsonImportErrorMessages =
| GetGeojsonByGeoSystemeIdErrorMessages | GetGeojsonByGeoSystemeIdErrorMessages
| GetGeojsonInformationErrorMessages | GetGeojsonInformationErrorMessages
| ConvertPointsErrors | ConvertPointsErrors
| FileNameToCsvErrors
export const geojsonImport: RestNewPostCall<'/rest/geojson/import/:geoSystemeId'> = (rootPipe): Effect.Effect<GeojsonInformations, CaminoApiError<GeojsonImportErrorMessages>> => { export const geojsonImport: RestNewPostCall<'/rest/geojson/import/:geoSystemeId'> = (rootPipe): Effect.Effect<GeojsonInformations, CaminoApiError<GeojsonImportErrorMessages>> => {
return rootPipe.pipe( return rootPipe.pipe(
Effect.let('pathFrom', ({ body }) => join(process.cwd(), `/files/tmp/${body.tempDocumentName}`)), Effect.let('pathFrom', ({ body }) => join(process.cwd(), `/files/tmp/${body.tempDocumentName}`)),
...@@ -373,6 +374,8 @@ export const geojsonImport: RestNewPostCall<'/rest/geojson/import/:geoSystemeId' ...@@ -373,6 +374,8 @@ export const geojsonImport: RestNewPostCall<'/rest/geojson/import/:geoSystemeId'
'La liste des points est vide', 'La liste des points est vide',
'Le nombre de points est invalide', 'Le nombre de points est invalide',
'Problème de Système géographique (SRID)', 'Problème de Système géographique (SRID)',
'Le CSV ne contient aucun élément',
'Le séparateur est probablement incorrect',
() => ({ ...caminoError, status: HTTP_STATUS.BAD_REQUEST }) () => ({ ...caminoError, status: HTTP_STATUS.BAD_REQUEST })
), ),
Match.exhaustive Match.exhaustive
...@@ -417,7 +420,10 @@ const readIsoOrUTF8FileSync = (path: string): string => { ...@@ -417,7 +420,10 @@ const readIsoOrUTF8FileSync = (path: string): string => {
} }
} }
const fileNameToCsv = (pathFrom: string): Effect.Effect<unknown[], CaminoError<typeof ouvertureCsvError>> => { const csvVideError = 'Le CSV ne contient aucun élément' as const
const mauvaisSeparateurCsvError = 'Le séparateur est probablement incorrect' as const
type FileNameToCsvErrors = typeof ouvertureCsvError | typeof mauvaisSeparateurCsvError | typeof csvVideError
const fileNameToCsv = (pathFrom: string): Effect.Effect<unknown[], CaminoError<FileNameToCsvErrors>> => {
return Effect.try({ return Effect.try({
try: () => { try: () => {
const fileContent = readIsoOrUTF8FileSync(pathFrom) const fileContent = readIsoOrUTF8FileSync(pathFrom)
...@@ -428,11 +434,22 @@ const fileNameToCsv = (pathFrom: string): Effect.Effect<unknown[], CaminoError<t ...@@ -428,11 +434,22 @@ const fileNameToCsv = (pathFrom: string): Effect.Effect<unknown[], CaminoError<t
} }
const sheet1 = result.Sheets[result.SheetNames[0]] const sheet1 = result.Sheets[result.SheetNames[0]]
return xlsx.utils.sheet_to_json(sheet1, { raw: true }) return xlsx.utils.sheet_to_json(sheet1, { raw: true })
}, },
catch: e => ({ message: ouvertureCsvError, extra: e }), catch: e => ({ message: ouvertureCsvError, extra: e }),
}) }).pipe(
Effect.filterOrFail(
result => isNotNullNorUndefinedNorEmpty(result),
() => ({ message: csvVideError })
),
Effect.filterOrFail(
result => {
const firstValue = result[0]
return typeof firstValue === 'object' && isNotNullNorUndefined(firstValue) && Object.keys(firstValue).length >= 2
},
() => ({ message: mauvaisSeparateurCsvError, detail: "Seuls les séparateurs ';' sont acceptés" })
)
)
} }
const accesInterditError = 'Accès interdit' as const const accesInterditError = 'Accès interdit' as const
...@@ -485,7 +502,7 @@ export const geojsonImportPoints: RestNewPostCall<'/rest/geojson_points/import/: ...@@ -485,7 +502,7 @@ export const geojsonImportPoints: RestNewPostCall<'/rest/geojson_points/import/:
) )
} }
type GeosjsonImportForagesErrorMessages = ZodUnparseable | EffectDbQueryAndValidateErrors | typeof ouvertureCsvError | typeof ouvertureShapeError | typeof ouvertureGeoJSONError | ConvertPointsErrors type GeosjsonImportForagesErrorMessages = ZodUnparseable | EffectDbQueryAndValidateErrors | typeof ouvertureShapeError | typeof ouvertureGeoJSONError | ConvertPointsErrors | FileNameToCsvErrors
export const geojsonImportForages: RestNewPostCall<'/rest/geojson_forages/import/:geoSystemeId'> = ( export const geojsonImportForages: RestNewPostCall<'/rest/geojson_forages/import/:geoSystemeId'> = (
rootPipe rootPipe
): Effect.Effect<GeojsonImportForagesResponse, CaminoApiError<GeosjsonImportForagesErrorMessages>> => { ): Effect.Effect<GeojsonImportForagesResponse, CaminoApiError<GeosjsonImportForagesErrorMessages>> => {
...@@ -560,6 +577,8 @@ export const geojsonImportForages: RestNewPostCall<'/rest/geojson_forages/import ...@@ -560,6 +577,8 @@ export const geojsonImportForages: RestNewPostCall<'/rest/geojson_forages/import
'La liste des points est vide', 'La liste des points est vide',
'Le nombre de points est invalide', 'Le nombre de points est invalide',
'Problème de Système géographique (SRID)', 'Problème de Système géographique (SRID)',
'Le CSV ne contient aucun élément',
'Le séparateur est probablement incorrect',
() => ({ ...caminoError, status: HTTP_STATUS.BAD_REQUEST }) () => ({ ...caminoError, status: HTTP_STATUS.BAD_REQUEST })
), ),
Match.exhaustive Match.exhaustive
......
...@@ -4,6 +4,7 @@ import { CanReadDemarche } from './demarches' ...@@ -4,6 +4,7 @@ import { CanReadDemarche } from './demarches'
import { testBlankUser } from 'camino-common/src/tests-utils' import { testBlankUser } from 'camino-common/src/tests-utils'
import { isAssociee, isGestionnaire } from 'camino-common/src/static/administrationsTitresTypes' import { isAssociee, isGestionnaire } from 'camino-common/src/static/administrationsTitresTypes'
import { entrepriseIdValidator } from 'camino-common/src/entreprise' import { entrepriseIdValidator } from 'camino-common/src/entreprise'
import { ETAPES_TYPES } from 'camino-common/src/static/etapesTypes'
const shouldNotBeCalled = () => Promise.reject(new Error('should not be called')) const shouldNotBeCalled = () => Promise.reject(new Error('should not be called'))
...@@ -29,7 +30,7 @@ describe('canReadEtape', () => { ...@@ -29,7 +30,7 @@ describe('canReadEtape', () => {
() => Promise.resolve(titreTypeId), () => Promise.resolve(titreTypeId),
() => Promise.resolve([]), () => Promise.resolve([]),
shouldNotBeCalled, shouldNotBeCalled,
'ede', ETAPES_TYPES.expertises,
demarche demarche
) )
).toBe(false) ).toBe(false)
...@@ -40,7 +41,7 @@ describe('canReadEtape', () => { ...@@ -40,7 +41,7 @@ describe('canReadEtape', () => {
() => Promise.resolve(titreTypeId), () => Promise.resolve(titreTypeId),
() => Promise.resolve([]), () => Promise.resolve([]),
shouldNotBeCalled, shouldNotBeCalled,
'ede', ETAPES_TYPES.expertises,
demarche demarche
) )
).toBe(true) ).toBe(true)
......
...@@ -66,8 +66,7 @@ type XStateEvent = ...@@ -66,8 +66,7 @@ type XStateEvent =
| { type: 'RECEVOIR_INFORMATION_MCR' } | { type: 'RECEVOIR_INFORMATION_MCR' }
| { type: 'DEMANDER_COMPLEMENTS_MCR' } | { type: 'DEMANDER_COMPLEMENTS_MCR' }
| { type: 'RECEVOIR_COMPLEMENTS_MCR' } | { type: 'RECEVOIR_COMPLEMENTS_MCR' }
| { type: 'RECEVOIR_EXPERTISE_SERVICE_EAU' } | { type: 'RECEVOIR_EXPERTISE' }
| { type: 'RECEVOIR_EXPERTISE_SERVICE_MINES' }
| { type: 'NOTIFIER_DEMANDEUR_SIGNATURE_ARM' } | { type: 'NOTIFIER_DEMANDEUR_SIGNATURE_ARM' }
| { type: 'FAIRE_AVENANT_ARM' } | { type: 'FAIRE_AVENANT_ARM' }
| { type: 'NOTIFIER_AVENANT_ARM' } | { type: 'NOTIFIER_AVENANT_ARM' }
...@@ -169,8 +168,7 @@ const trad: { [key in Event]: { db: DBEtat; mainStep: boolean } } = { ...@@ -169,8 +168,7 @@ const trad: { [key in Event]: { db: DBEtat; mainStep: boolean } } = {
RECEVOIR_INFORMATION_MCR: { db: EtapesTypesEtapesStatuts.receptionDinformation, mainStep: false }, RECEVOIR_INFORMATION_MCR: { db: EtapesTypesEtapesStatuts.receptionDinformation, mainStep: false },
DEMANDER_COMPLEMENTS_MCR: { db: EtapesTypesEtapesStatuts.demandeDeComplements_RecevabiliteDeLaDemande_, mainStep: false }, DEMANDER_COMPLEMENTS_MCR: { db: EtapesTypesEtapesStatuts.demandeDeComplements_RecevabiliteDeLaDemande_, mainStep: false },
RECEVOIR_COMPLEMENTS_MCR: { db: EtapesTypesEtapesStatuts.receptionDeComplements_RecevabiliteDeLaDemande_, mainStep: false }, RECEVOIR_COMPLEMENTS_MCR: { db: EtapesTypesEtapesStatuts.receptionDeComplements_RecevabiliteDeLaDemande_, mainStep: false },
RECEVOIR_EXPERTISE_SERVICE_EAU: { db: EtapesTypesEtapesStatuts.expertiseDREALOuDGTMServiceEau, mainStep: false }, RECEVOIR_EXPERTISE: { db: EtapesTypesEtapesStatuts.expertises, mainStep: false },
RECEVOIR_EXPERTISE_SERVICE_MINES: { db: EtapesTypesEtapesStatuts.expertiseDGTMServicePreventionDesRisquesEtIndustriesExtractives_DATE_, mainStep: false },
NOTIFIER_DEMANDEUR_SIGNATURE_ARM: { db: EtapesTypesEtapesStatuts.notificationAuDemandeur_SignatureDeLautorisationDeRechercheMiniere_, mainStep: true }, NOTIFIER_DEMANDEUR_SIGNATURE_ARM: { db: EtapesTypesEtapesStatuts.notificationAuDemandeur_SignatureDeLautorisationDeRechercheMiniere_, mainStep: true },
FAIRE_AVENANT_ARM: { db: EtapesTypesEtapesStatuts.avenantALautorisationDeRechercheMiniere, mainStep: false }, FAIRE_AVENANT_ARM: { db: EtapesTypesEtapesStatuts.avenantALautorisationDeRechercheMiniere, mainStep: false },
NOTIFIER_AVENANT_ARM: { db: EtapesTypesEtapesStatuts.notificationAuDemandeur_SignatureDeLavenantALautorisationDeRechercheMiniere_, mainStep: false }, NOTIFIER_AVENANT_ARM: { db: EtapesTypesEtapesStatuts.notificationAuDemandeur_SignatureDeLavenantALautorisationDeRechercheMiniere_, mainStep: false },
...@@ -609,30 +607,19 @@ const armOctMachine = createMachine({ ...@@ -609,30 +607,19 @@ const armOctMachine = createMachine({
expertisesMachine: { expertisesMachine: {
type: 'parallel', type: 'parallel',
states: { states: {
expertiseServiceEauMachine: { expertiseMachine: {
initial: 'expertiseServiceEauAfaire', initial: 'expertiseAFaire',
states: { states: {
expertiseServiceEauAfaire: { expertiseAFaire: {
on: { on: {
RECEVOIR_EXPERTISE_SERVICE_EAU: 'expertiseServiceEauFait', RECEVOIR_EXPERTISE: 'expertiseFaite',
}, },
}, },
expertiseServiceEauFait: { expertiseFaite: {
type: 'final', type: 'final',
}, },
}, },
}, },
expertiseServiceMinesMachine: {
initial: 'expertiseServiceMinesAFaire',
states: {
expertiseServiceMinesAFaire: {
on: {
RECEVOIR_EXPERTISE_SERVICE_MINES: 'expertiseServiceMinesFait',
},
},
expertiseServiceMinesFait: { type: 'final' },
},
},
avisDesServicesEtCommissionsConsultativesMachine: { avisDesServicesEtCommissionsConsultativesMachine: {
initial: 'avisDesServicesEtCommissionsConsultativesARendre', initial: 'avisDesServicesEtCommissionsConsultativesARendre',
states: { states: {
......
...@@ -459,30 +459,16 @@ describe('mainStep', () => { ...@@ -459,30 +459,16 @@ describe('mainStep', () => {
{ {
"contenu": undefined, "contenu": undefined,
"etapeStatutId": "fav", "etapeStatutId": "fav",
"etapeTypeId": "ede", "etapeTypeId": "exp",
"mainStep": false, "mainStep": false,
"type": "RECEVOIR_EXPERTISE_SERVICE_EAU", "type": "RECEVOIR_EXPERTISE",
}, },
{ {
"contenu": undefined, "contenu": undefined,
"etapeStatutId": "def", "etapeStatutId": "def",
"etapeTypeId": "ede", "etapeTypeId": "exp",
"mainStep": false, "mainStep": false,
"type": "RECEVOIR_EXPERTISE_SERVICE_EAU", "type": "RECEVOIR_EXPERTISE",
},
{
"contenu": undefined,
"etapeStatutId": "fav",
"etapeTypeId": "edm",
"mainStep": false,
"type": "RECEVOIR_EXPERTISE_SERVICE_MINES",
},
{
"contenu": undefined,
"etapeStatutId": "def",
"etapeTypeId": "edm",
"mainStep": false,
"type": "RECEVOIR_EXPERTISE_SERVICE_MINES",
}, },
{ {
"contenu": undefined, "contenu": undefined,
...@@ -527,30 +513,16 @@ describe('mainStep', () => { ...@@ -527,30 +513,16 @@ describe('mainStep', () => {
{ {
"contenu": undefined, "contenu": undefined,
"etapeStatutId": "fav", "etapeStatutId": "fav",
"etapeTypeId": "ede", "etapeTypeId": "exp",
"mainStep": false,
"type": "RECEVOIR_EXPERTISE_SERVICE_EAU",
},
{
"contenu": undefined,
"etapeStatutId": "def",
"etapeTypeId": "ede",
"mainStep": false,
"type": "RECEVOIR_EXPERTISE_SERVICE_EAU",
},
{
"contenu": undefined,
"etapeStatutId": "fav",
"etapeTypeId": "edm",
"mainStep": false, "mainStep": false,
"type": "RECEVOIR_EXPERTISE_SERVICE_MINES", "type": "RECEVOIR_EXPERTISE",
}, },
{ {
"contenu": undefined, "contenu": undefined,
"etapeStatutId": "def", "etapeStatutId": "def",
"etapeTypeId": "edm", "etapeTypeId": "exp",
"mainStep": false, "mainStep": false,
"type": "RECEVOIR_EXPERTISE_SERVICE_MINES", "type": "RECEVOIR_EXPERTISE",
}, },
{ {
"contenu": undefined, "contenu": undefined,
......
...@@ -52,7 +52,6 @@ type XStateEvent = ...@@ -52,7 +52,6 @@ type XStateEvent =
| { type: 'DEPOSER_DEMANDE_CONCURRENTE' } | { type: 'DEPOSER_DEMANDE_CONCURRENTE' }
| OuvrirParticipationDuPublic | OuvrirParticipationDuPublic
| RendreAvisServicesEtCommissionsConsultatives | RendreAvisServicesEtCommissionsConsultatives
| { type: 'RENDRE_AVIS_POLICE_EAU' }
| RendreAvisCDM | RendreAvisCDM
| RendreRapportDREAL | RendreRapportDREAL
| { type: 'RENDRE_AVIS_PREFET' } | { type: 'RENDRE_AVIS_PREFET' }
...@@ -101,8 +100,6 @@ const trad: { [key in Event]: { db: DBEtat; mainStep: boolean } } = { ...@@ -101,8 +100,6 @@ const trad: { [key in Event]: { db: DBEtat; mainStep: boolean } } = {
DEPOSER_DEMANDE_CONCURRENTE: { db: EtapesTypesEtapesStatuts.avisDeDemandeConcurrente, mainStep: false }, DEPOSER_DEMANDE_CONCURRENTE: { db: EtapesTypesEtapesStatuts.avisDeDemandeConcurrente, mainStep: false },
OUVRIR_PARTICIPATION_DU_PUBLIC: { db: EtapesTypesEtapesStatuts.participationDuPublic, mainStep: true }, OUVRIR_PARTICIPATION_DU_PUBLIC: { db: EtapesTypesEtapesStatuts.participationDuPublic, mainStep: true },
RENDRE_AVIS_SERVICES_ET_COMMISSIONS_CONSULTATIVES: { db: EtapesTypesEtapesStatuts.avisDesServicesEtCommissionsConsultatives, mainStep: true }, RENDRE_AVIS_SERVICES_ET_COMMISSIONS_CONSULTATIVES: { db: EtapesTypesEtapesStatuts.avisDesServicesEtCommissionsConsultatives, mainStep: true },
RENDRE_AVIS_POLICE_EAU: { db: EtapesTypesEtapesStatuts.expertiseDREALOuDGTMServiceEau, mainStep: false },
RENDRE_AVIS_CDM: { db: EtapesTypesEtapesStatuts.avisDeLaCommissionDepartementaleDesMines_CDM_, mainStep: true }, RENDRE_AVIS_CDM: { db: EtapesTypesEtapesStatuts.avisDeLaCommissionDepartementaleDesMines_CDM_, mainStep: true },
RENDRE_RAPPORT_DREAL: { db: EtapesTypesEtapesStatuts.rapportEtAvisDeLaDREAL, mainStep: true }, RENDRE_RAPPORT_DREAL: { db: EtapesTypesEtapesStatuts.rapportEtAvisDeLaDREAL, mainStep: true },
RENDRE_AVIS_PREFET: { db: EtapesTypesEtapesStatuts.avisDuPrefet, mainStep: true }, RENDRE_AVIS_PREFET: { db: EtapesTypesEtapesStatuts.avisDuPrefet, mainStep: true },
......
...@@ -950,7 +950,7 @@ describe('getPossiblesEtapesTypes', () => { ...@@ -950,7 +950,7 @@ describe('getPossiblesEtapesTypes', () => {
test('ajoute une nouvelle étape en plein milieu', () => { test('ajoute une nouvelle étape en plein milieu', () => {
const tested = getPossiblesEtapesTypes(machine, 'arm', 'oct', undefined, undefined, toCaminoDate('2019-12-04'), etapes) const tested = getPossiblesEtapesTypes(machine, 'arm', 'oct', undefined, undefined, toCaminoDate('2019-12-04'), etapes)
expect(Object.keys(tested).toSorted()).toStrictEqual(['ede', 'edm', 'mod']) expect(Object.keys(tested).toSorted()).toStrictEqual(['exp', 'mod'])
}) })
test('peut faire une dae, une rde et pfd AVANT la mfr', () => { test('peut faire une dae, une rde et pfd AVANT la mfr', () => {
...@@ -1139,9 +1139,9 @@ describe('getPossiblesEtapesTypes', () => { ...@@ -1139,9 +1139,9 @@ describe('getPossiblesEtapesTypes', () => {
demarcheIdsConsentement: [], demarcheIdsConsentement: [],
}, },
{ {
id: newEtapeId('idedm'), id: newEtapeId('idexp'),
date: toCaminoDate('2021-11-30'), date: toCaminoDate('2021-11-30'),
typeId: 'edm', typeId: 'exp',
statutId: 'fav', statutId: 'fav',
concurrence: 'non-applicable', concurrence: 'non-applicable',
hasTitreFrom: 'non-applicable', hasTitreFrom: 'non-applicable',
...@@ -1211,7 +1211,7 @@ describe('getPossiblesEtapesTypes', () => { ...@@ -1211,7 +1211,7 @@ describe('getPossiblesEtapesTypes', () => {
] ]
const tested = getPossiblesEtapesTypes(machine, 'arm', 'oct', undefined, undefined, toCaminoDate('2022-07-01'), etapes) const tested = getPossiblesEtapesTypes(machine, 'arm', 'oct', undefined, undefined, toCaminoDate('2022-07-01'), etapes)
expect(Object.keys(tested).toSorted()).toStrictEqual(['asc', 'css', 'des', 'ede', 'mcb', 'mod', 'rcb', 'rde']) expect(Object.keys(tested).toSorted()).toStrictEqual(['asc', 'css', 'des', 'mcb', 'mod', 'rcb', 'rde'])
vi.resetAllMocks() vi.resetAllMocks()
}) })
test('peut faire une completude (mcp) le même jour que le dépôt (men) de la demande', () => { test('peut faire une completude (mcp) le même jour que le dépôt (men) de la demande', () => {
......
import { Knex } from 'knex'
export const up = async (knex: Knex): Promise<void> => {
await knex.raw(`
UPDATE titres_etapes SET type_id = 'exp' WHERE type_id IN ('edm', 'ede', 'esb')
`)
await knex.raw(`
INSERT INTO etape_avis(id, avis_type_id, avis_statut_id, avis_visibility_id, etape_id, description, date, largeobject_id)
SELECT '2020-03-11-avi-124c9191', 'autreAvis', 'Favorable', 'Administrations', '47Q4HFk541pQ3aZ5mQPNqN1I', 'Avis de la DEAL sur la demande d’autorisation de recherches minières de la SAS COMPAGNIE MINIERE MAJOR', '2020-03-11', '133842' WHERE EXISTS (SELECT 1 from titres_etapes where id='47Q4HFk541pQ3aZ5mQPNqN1I')
`)
await knex.raw(`
INSERT INTO etape_avis(id, avis_type_id, avis_statut_id, avis_visibility_id, etape_id, description, date, largeobject_id)
SELECT '2020-03-11-avi-688466bc', 'autreAvis', 'Favorable avec réserves', 'Administrations', 'EUJCYmirGHUHZGkhHx0zNbM3', 'Avis DGTM - Industries Extractives', '2020-03-11', 133998 WHERE EXISTS (SELECT 1 from titres_etapes where id='EUJCYmirGHUHZGkhHx0zNbM3')
`)
await knex.raw(`
DELETE FROM etapes_documents WHERE id IN ('2020-03-11-avi-124c9191', '2020-03-11-avi-688466bc')
`)
await knex.raw(
"UPDATE etapes_documents SET etape_document_type_id = 'aut', description = 'Avis\n' || description WHERE etape_document_type_id = 'avi' AND etape_id IN (SELECT id FROM titres_etapes WHERE type_id = 'exp')"
)
}
export const down = (): void => {}
...@@ -242,7 +242,7 @@ export const getAvisTypes = ( ...@@ -242,7 +242,7 @@ export const getAvisTypes = (
if (TitresTypes[titreTypeId].typeId === TITRES_TYPES_TYPES_IDS.AUTORISATION_D_EXPLOITATION) { if (TitresTypes[titreTypeId].typeId === TITRES_TYPES_TYPES_IDS.AUTORISATION_D_EXPLOITATION) {
avis[AVIS_TYPES.confirmationAccordProprietaireDuSol] = { id: AVIS_TYPES.confirmationAccordProprietaireDuSol, optionnel: true } avis[AVIS_TYPES.confirmationAccordProprietaireDuSol] = { id: AVIS_TYPES.confirmationAccordProprietaireDuSol, optionnel: true }
} }
} else if (etapeTypeId === ETAPES_TYPES.consultationDesAdministrationsCentrales) { } else if ([ETAPES_TYPES.consultationDesAdministrationsCentrales, ETAPES_TYPES.expertises].includes(etapeTypeId)) {
avis[AVIS_TYPES.autreAvis] = { id: AVIS_TYPES.autreAvis, optionnel: true } avis[AVIS_TYPES.autreAvis] = { id: AVIS_TYPES.autreAvis, optionnel: true }
} }
......