From d25080c09ff29f83056cb94e5b3fec66a1f5d3f4 Mon Sep 17 00:00:00 2001 From: Emmanuel Raviart Date: Sun, 22 Dec 2024 23:38:12 +0100 Subject: [PATCH] Mutualize META_TEXTE_CHRONICLE, etc betwenn textelr & texte_version --- src/lib/auditors/jorf/texte.ts | 95 +++++++++++++++ src/lib/auditors/jorf/texte_version.ts | 94 +-------------- src/lib/auditors/jorf/textelr.ts | 93 +-------------- src/lib/auditors/legi/texte.ts | 136 ++++++++++++++++++++++ src/lib/auditors/legi/texte_version.ts | 137 ++-------------------- src/lib/auditors/legi/textelr.ts | 137 ++-------------------- src/lib/index.ts | 32 ++---- src/lib/legal/index.ts | 32 ++---- src/lib/legal/jorf.ts | 153 ++++--------------------- src/lib/legal/legi.ts | 114 ++++++------------ 10 files changed, 337 insertions(+), 686 deletions(-) create mode 100644 src/lib/auditors/jorf/texte.ts create mode 100644 src/lib/auditors/legi/texte.ts diff --git a/src/lib/auditors/jorf/texte.ts b/src/lib/auditors/jorf/texte.ts new file mode 100644 index 0000000..253f4e1 --- /dev/null +++ b/src/lib/auditors/jorf/texte.ts @@ -0,0 +1,95 @@ +import { + auditDateIso8601String, + auditEmptyToNull, + auditFunction, + auditInteger, + auditNullish, + auditNumber, + auditRequire, + auditSwitch, + auditTrimString, + type Audit, +} from "@auditors/core" + +export function auditMetaTexteChronicle( + audit: Audit, + dataUnknown: unknown, +): [unknown, unknown] { + if (dataUnknown == null) { + return [dataUnknown, null] + } + if (typeof dataUnknown !== "object") { + return audit.unexpectedType(dataUnknown, "object") + } + + const data = { ...dataUnknown } + const errors: { [key: string]: unknown } = {} + const remainingKeys = new Set(Object.keys(data)) + + for (const key of ["CID"]) { + audit.attribute( + data, + key, + true, + errors, + remainingKeys, + auditTrimString, + auditEmptyToNull, + auditRequire, + ) + } + for (const key of ["DATE_PUBLI", "DATE_TEXTE"]) { + audit.attribute( + data, + key, + true, + errors, + remainingKeys, + auditFunction((date) => date.replace(/^11992-12-27$/, "1992-12-27")), + auditDateIso8601String, + auditRequire, + ) + } + for (const key of ["NOR", "NUM"]) { + audit.attribute( + data, + key, + true, + errors, + remainingKeys, + auditSwitch( + [auditNumber, auditFunction((num) => num.toString())], + [auditTrimString, auditEmptyToNull], + ), + ) + } + for (const key of [ + "NUM_PARUTION", + "NUM_SEQUENCE", + "PAGE_DEB_PUBLI", + "PAGE_FIN_PUBLI", + ]) { + audit.attribute( + data, + key, + true, + errors, + remainingKeys, + auditSwitch( + [auditNumber, auditInteger], + [auditTrimString, auditEmptyToNull, auditNullish], + ), + ) + } + audit.attribute( + data, + "ORIGINE_PUBLI", + true, + errors, + remainingKeys, + auditTrimString, + auditEmptyToNull, + ) + + return audit.reduceRemaining(data, errors, remainingKeys) +} diff --git a/src/lib/auditors/jorf/texte_version.ts b/src/lib/auditors/jorf/texte_version.ts index 30d299a..de54ccc 100644 --- a/src/lib/auditors/jorf/texte_version.ts +++ b/src/lib/auditors/jorf/texte_version.ts @@ -4,7 +4,6 @@ import { auditEmptyToNull, auditFunction, auditHttpUrl, - auditInteger, auditNullish, auditNumber, auditOptions, @@ -17,11 +16,13 @@ import { import { allJorfTexteVersionLienNatures, allJorfTexteVersionLienTypes, - allJorfTexteVersionNatures, - allJorfTexteVersionOrigines, + allJorfTexteNatures, + allJorfTexteOrigines, allSens, } from "$lib/legal" +import { auditMetaTexteChronicle } from "./texte" + export const jorfTexteVersionStats: { countByLienNature: { [nature: string]: number } countByLienType: { [type: string]: number } @@ -548,7 +549,7 @@ function auditMetaCommun( // (jorfTexteVersionStats.countByNature[nature] ?? 0) + 1 // return nature // }), - auditOptions(allJorfTexteVersionNatures), + auditOptions(allJorfTexteNatures), ) audit.attribute( data, @@ -563,7 +564,7 @@ function auditMetaCommun( // (jorfTexteVersionStats.countByOrigine[origine] ?? 0) + 1 // return origine // }), - auditOptions(allJorfTexteVersionOrigines), + auditOptions(allJorfTexteOrigines), auditRequire, ) @@ -604,89 +605,6 @@ function auditMetaSpec(audit: Audit, dataUnknown: unknown): [unknown, unknown] { return audit.reduceRemaining(data, errors, remainingKeys) } -function auditMetaTexteChronicle( - audit: Audit, - dataUnknown: unknown, -): [unknown, unknown] { - if (dataUnknown == null) { - return [dataUnknown, null] - } - if (typeof dataUnknown !== "object") { - return audit.unexpectedType(dataUnknown, "object") - } - - const data = { ...dataUnknown } - const errors: { [key: string]: unknown } = {} - const remainingKeys = new Set(Object.keys(data)) - - for (const key of ["CID"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditTrimString, - auditEmptyToNull, - auditRequire, - ) - } - for (const key of ["DATE_PUBLI", "DATE_TEXTE"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditFunction((date) => date.replace(/^11992-12-27$/, "1992-12-27")), - auditDateIso8601String, - auditRequire, - ) - } - for (const key of ["NOR", "NUM"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditSwitch( - [auditNumber, auditFunction((num) => num.toString())], - [auditTrimString, auditEmptyToNull], - ), - ) - } - for (const key of [ - "NUM_PARUTION", - "NUM_SEQUENCE", - "PAGE_DEB_PUBLI", - "PAGE_FIN_PUBLI", - ]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditSwitch( - [auditNumber, auditInteger], - [auditTrimString, auditEmptyToNull, auditNullish], - ), - ) - } - audit.attribute( - data, - "ORIGINE_PUBLI", - true, - errors, - remainingKeys, - auditTrimString, - auditEmptyToNull, - ) - - return audit.reduceRemaining(data, errors, remainingKeys) -} - function auditMetaTexteVersion( audit: Audit, dataUnknown: unknown, diff --git a/src/lib/auditors/jorf/textelr.ts b/src/lib/auditors/jorf/textelr.ts index 775390e..0c4ca11 100644 --- a/src/lib/auditors/jorf/textelr.ts +++ b/src/lib/auditors/jorf/textelr.ts @@ -20,10 +20,12 @@ import { allJorfTextelrLienArtEtats, // allJorfTextelrLienArtNatures, allJorfTextelrLienArtOrigines, - allJorfTextelrNatures, - allJorfTextelrOrigines, + allJorfTexteNatures, + allJorfTexteOrigines, } from "$lib/legal" +import { auditMetaTexteChronicle } from "./texte" + export const jorfTextelrStats: { countByEtat: { [etat: string]: number } countByLienArtEtat: { [etat: string]: number } @@ -427,7 +429,7 @@ function auditMetaCommun( // (jorfTextelrStats.countByNature[nature] ?? 0) + 1 // return nature // }), - auditOptions(allJorfTextelrNatures), + auditOptions(allJorfTexteNatures), ) audit.attribute( data, @@ -442,7 +444,7 @@ function auditMetaCommun( // (jorfTextelrStats.countByOrigine[origine] ?? 0) + 1 // return origine // }), - auditOptions(allJorfTextelrOrigines), + auditOptions(allJorfTexteOrigines), auditRequire, ) @@ -474,89 +476,6 @@ function auditMetaSpec(audit: Audit, dataUnknown: unknown): [unknown, unknown] { return audit.reduceRemaining(data, errors, remainingKeys) } -function auditMetaTexteChronicle( - audit: Audit, - dataUnknown: unknown, -): [unknown, unknown] { - if (dataUnknown == null) { - return [dataUnknown, null] - } - if (typeof dataUnknown !== "object") { - return audit.unexpectedType(dataUnknown, "object") - } - - const data = { ...dataUnknown } - const errors: { [key: string]: unknown } = {} - const remainingKeys = new Set(Object.keys(data)) - - for (const key of ["CID"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditTrimString, - auditEmptyToNull, - auditRequire, - ) - } - for (const key of ["DATE_PUBLI", "DATE_TEXTE"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditFunction((date) => date.replace(/^11992-12-27$/, "1992-12-27")), - auditDateIso8601String, - auditRequire, - ) - } - for (const key of ["NOR", "NUM"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditSwitch( - [auditNumber, auditFunction((num) => num.toString())], - [auditTrimString, auditEmptyToNull], - ), - ) - } - for (const key of [ - "NUM_PARUTION", - "NUM_SEQUENCE", - "PAGE_DEB_PUBLI", - "PAGE_FIN_PUBLI", - ]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditSwitch( - [auditNumber, auditInteger], - [auditTrimString, auditEmptyToNull, auditNullish], - ), - ) - } - audit.attribute( - data, - "ORIGINE_PUBLI", - true, - errors, - remainingKeys, - auditTrimString, - auditEmptyToNull, - ) - - return audit.reduceRemaining(data, errors, remainingKeys) -} - function auditStruct(audit: Audit, dataUnknown: unknown): [unknown, unknown] { if (dataUnknown == null) { return [dataUnknown, null] diff --git a/src/lib/auditors/legi/texte.ts b/src/lib/auditors/legi/texte.ts new file mode 100644 index 0000000..e71a0b0 --- /dev/null +++ b/src/lib/auditors/legi/texte.ts @@ -0,0 +1,136 @@ +import { + auditCleanArray, + auditDateIso8601String, + auditEmptyToNull, + auditFunction, + auditInteger, + auditNullish, + auditNumber, + auditRequire, + auditSwitch, + auditTrimString, + type Audit, +} from "@auditors/core" + +export function auditMetaTexteChronicle( + audit: Audit, + dataUnknown: unknown, +): [unknown, unknown] { + if (dataUnknown == null) { + return [dataUnknown, null] + } + if (typeof dataUnknown !== "object") { + return audit.unexpectedType(dataUnknown, "object") + } + + const data = { ...dataUnknown } + const errors: { [key: string]: unknown } = {} + const remainingKeys = new Set(Object.keys(data)) + + for (const key of ["CID"]) { + audit.attribute( + data, + key, + true, + errors, + remainingKeys, + auditTrimString, + auditEmptyToNull, + auditRequire, + ) + } + for (const key of ["DATE_PUBLI", "DATE_TEXTE", "DERNIERE_MODIFICATION"]) { + audit.attribute( + data, + key, + true, + errors, + remainingKeys, + auditFunction((date) => date.replace(/^11992-12-27$/, "1992-12-27")), + auditDateIso8601String, + auditRequire, + ) + } + for (const key of ["NOR", "NUM"]) { + audit.attribute( + data, + key, + true, + errors, + remainingKeys, + auditSwitch( + [auditNumber, auditFunction((num) => num.toString())], + [auditTrimString, auditEmptyToNull], + ), + ) + } + for (const key of [ + "NUM_PARUTION", + "NUM_SEQUENCE", + "PAGE_DEB_PUBLI", + "PAGE_FIN_PUBLI", + ]) { + audit.attribute( + data, + key, + true, + errors, + remainingKeys, + auditSwitch( + [auditNumber, auditInteger], + [auditTrimString, auditEmptyToNull, auditNullish], + ), + ) + } + audit.attribute( + data, + "ORIGINE_PUBLI", + true, + errors, + remainingKeys, + auditTrimString, + auditEmptyToNull, + ) + audit.attribute( + data, + "VERSIONS_A_VENIR", + true, + errors, + remainingKeys, + auditSwitch( + [auditTrimString, auditEmptyToNull, auditNullish], + auditVersionsAVenir, + ), + ) + + return audit.reduceRemaining(data, errors, remainingKeys) +} + +function auditVersionsAVenir( + audit: Audit, + dataUnknown: unknown, +): [unknown, unknown] { + if (dataUnknown == null) { + return [dataUnknown, null] + } + if (typeof dataUnknown !== "object") { + return audit.unexpectedType(dataUnknown, "object") + } + + const data = { ...dataUnknown } + const errors: { [key: string]: unknown } = {} + const remainingKeys = new Set(Object.keys(data)) + + audit.attribute( + data, + "VERSION_A_VENIR", + true, + errors, + remainingKeys, + auditFunction((date) => (Array.isArray(date) ? date : [date])), + auditCleanArray(auditDateIso8601String, auditRequire), + auditRequire, + ) + + return audit.reduceRemaining(data, errors, remainingKeys) +} diff --git a/src/lib/auditors/legi/texte_version.ts b/src/lib/auditors/legi/texte_version.ts index 0499d94..fba2744 100644 --- a/src/lib/auditors/legi/texte_version.ts +++ b/src/lib/auditors/legi/texte_version.ts @@ -4,7 +4,6 @@ import { auditEmptyToNull, auditFunction, auditHttpUrl, - auditInteger, auditNullish, auditNumber, auditOptions, @@ -15,13 +14,14 @@ import { } from "@auditors/core" import { - allLegiTexteVersionEtats, + allLegiTexteEtats, allLegiTexteVersionLienNatures, allLegiTexteVersionLienTypes, - allLegiTexteVersionNatures, - allLegiTexteVersionOrigines, + allLegiTexteNatures, + allLegiTexteOrigines, allSens, } from "$lib/legal" +import { auditMetaTexteChronicle } from "./texte" export const legiTexteVersionStats: { countByEtat: { [etat: string]: number } @@ -415,7 +415,7 @@ function auditMetaCommun( // (legiTexteVersionStats.countByNature[nature] ?? 0) + 1 // return nature // }), - auditOptions(allLegiTexteVersionNatures), + auditOptions(allLegiTexteNatures), ) audit.attribute( data, @@ -430,7 +430,7 @@ function auditMetaCommun( // (legiTexteVersionStats.countByOrigine[origine] ?? 0) + 1 // return origine // }), - auditOptions(allLegiTexteVersionOrigines), + auditOptions(allLegiTexteOrigines), auditRequire, ) @@ -471,100 +471,6 @@ function auditMetaSpec(audit: Audit, dataUnknown: unknown): [unknown, unknown] { return audit.reduceRemaining(data, errors, remainingKeys) } -function auditMetaTexteChronicle( - audit: Audit, - dataUnknown: unknown, -): [unknown, unknown] { - if (dataUnknown == null) { - return [dataUnknown, null] - } - if (typeof dataUnknown !== "object") { - return audit.unexpectedType(dataUnknown, "object") - } - - const data = { ...dataUnknown } - const errors: { [key: string]: unknown } = {} - const remainingKeys = new Set(Object.keys(data)) - - for (const key of ["CID"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditTrimString, - auditEmptyToNull, - auditRequire, - ) - } - for (const key of ["DATE_PUBLI", "DATE_TEXTE", "DERNIERE_MODIFICATION"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditFunction((date) => date.replace(/^11992-12-27$/, "1992-12-27")), - auditDateIso8601String, - auditRequire, - ) - } - for (const key of ["NOR", "NUM"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditSwitch( - [auditNumber, auditFunction((num) => num.toString())], - [auditTrimString, auditEmptyToNull], - ), - ) - } - for (const key of [ - "NUM_PARUTION", - "NUM_SEQUENCE", - "PAGE_DEB_PUBLI", - "PAGE_FIN_PUBLI", - ]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditSwitch( - [auditNumber, auditInteger], - [auditTrimString, auditEmptyToNull, auditNullish], - ), - ) - } - audit.attribute( - data, - "ORIGINE_PUBLI", - true, - errors, - remainingKeys, - auditTrimString, - auditEmptyToNull, - ) - audit.attribute( - data, - "VERSIONS_A_VENIR", - true, - errors, - remainingKeys, - auditSwitch( - [auditTrimString, auditEmptyToNull, auditNullish], - auditVersionsAVenir, - ), - ) - - return audit.reduceRemaining(data, errors, remainingKeys) -} - function auditMetaTexteVersion( audit: Audit, dataUnknown: unknown, @@ -616,7 +522,7 @@ function auditMetaTexteVersion( // (legiTexteVersionStats.countByEtat[etat] ?? 0) + 1 // return etat // }), - auditOptions(allLegiTexteVersionEtats), + auditOptions(allLegiTexteEtats), ) audit.attribute( data, @@ -766,32 +672,3 @@ function auditVisas(audit: Audit, dataUnknown: unknown): [unknown, unknown] { return audit.reduceRemaining(data, errors, remainingKeys) } - -function auditVersionsAVenir( - audit: Audit, - dataUnknown: unknown, -): [unknown, unknown] { - if (dataUnknown == null) { - return [dataUnknown, null] - } - if (typeof dataUnknown !== "object") { - return audit.unexpectedType(dataUnknown, "object") - } - - const data = { ...dataUnknown } - const errors: { [key: string]: unknown } = {} - const remainingKeys = new Set(Object.keys(data)) - - audit.attribute( - data, - "VERSION_A_VENIR", - true, - errors, - remainingKeys, - auditFunction((date) => (Array.isArray(date) ? date : [date])), - auditCleanArray(auditDateIso8601String, auditRequire), - auditRequire, - ) - - return audit.reduceRemaining(data, errors, remainingKeys) -} diff --git a/src/lib/auditors/legi/textelr.ts b/src/lib/auditors/legi/textelr.ts index a9de7d2..163c09c 100644 --- a/src/lib/auditors/legi/textelr.ts +++ b/src/lib/auditors/legi/textelr.ts @@ -15,14 +15,16 @@ import { } from "@auditors/core" import { - allLegiTextelrEtats, + allLegiTexteEtats, allLegiTextelrLienArtEtats, allLegiTextelrLienArtOrigines, allLegiTextelrLienSectionTaEtats, - allLegiTextelrNatures, - allLegiTextelrOrigines, + allLegiTexteNatures, + allLegiTexteOrigines, } from "$lib/legal" +import { auditMetaTexteChronicle } from "./texte" + export const legiTextelrStats: { countByEtat: { [etat: string]: number } countByLienArtEtat: { [etat: string]: number } @@ -390,7 +392,7 @@ function auditMetaCommun( // (legiTextelrStats.countByNature[nature] ?? 0) + 1 // return nature // }), - auditOptions(allLegiTextelrNatures), + auditOptions(allLegiTexteNatures), ) audit.attribute( data, @@ -405,7 +407,7 @@ function auditMetaCommun( // (legiTextelrStats.countByOrigine[origine] ?? 0) + 1 // return origine // }), - auditOptions(allLegiTextelrOrigines), + auditOptions(allLegiTexteOrigines), auditRequire, ) @@ -437,100 +439,6 @@ function auditMetaSpec(audit: Audit, dataUnknown: unknown): [unknown, unknown] { return audit.reduceRemaining(data, errors, remainingKeys) } -function auditMetaTexteChronicle( - audit: Audit, - dataUnknown: unknown, -): [unknown, unknown] { - if (dataUnknown == null) { - return [dataUnknown, null] - } - if (typeof dataUnknown !== "object") { - return audit.unexpectedType(dataUnknown, "object") - } - - const data = { ...dataUnknown } - const errors: { [key: string]: unknown } = {} - const remainingKeys = new Set(Object.keys(data)) - - for (const key of ["CID"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditTrimString, - auditEmptyToNull, - auditRequire, - ) - } - for (const key of ["DATE_PUBLI", "DATE_TEXTE", "DERNIERE_MODIFICATION"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditFunction((date) => date.replace(/^11992-12-27$/, "1992-12-27")), - auditDateIso8601String, - auditRequire, - ) - } - for (const key of ["NOR", "NUM"]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditSwitch( - [auditNumber, auditFunction((num) => num.toString())], - [auditTrimString, auditEmptyToNull], - ), - ) - } - for (const key of [ - "NUM_PARUTION", - "NUM_SEQUENCE", - "PAGE_DEB_PUBLI", - "PAGE_FIN_PUBLI", - ]) { - audit.attribute( - data, - key, - true, - errors, - remainingKeys, - auditSwitch( - [auditNumber, auditInteger], - [auditTrimString, auditEmptyToNull, auditNullish], - ), - ) - } - audit.attribute( - data, - "ORIGINE_PUBLI", - true, - errors, - remainingKeys, - auditTrimString, - auditEmptyToNull, - ) - audit.attribute( - data, - "VERSIONS_A_VENIR", - true, - errors, - remainingKeys, - auditSwitch( - [auditTrimString, auditEmptyToNull, auditNullish], - auditVersionsAVenir, - ), - ) - - return audit.reduceRemaining(data, errors, remainingKeys) -} - function auditStruct(audit: Audit, dataUnknown: unknown): [unknown, unknown] { if (dataUnknown == null) { return [dataUnknown, null] @@ -590,7 +498,7 @@ function auditVersion(audit: Audit, dataUnknown: unknown): [unknown, unknown] { // (legiTextelrStats.countByEtat[etat] ?? 0) + 1 // return etat // }), - auditOptions(allLegiTextelrEtats), + auditOptions(allLegiTexteEtats), ) audit.attribute( data, @@ -630,32 +538,3 @@ function auditVersions(audit: Audit, dataUnknown: unknown): [unknown, unknown] { return audit.reduceRemaining(data, errors, remainingKeys) } - -function auditVersionsAVenir( - audit: Audit, - dataUnknown: unknown, -): [unknown, unknown] { - if (dataUnknown == null) { - return [dataUnknown, null] - } - if (typeof dataUnknown !== "object") { - return audit.unexpectedType(dataUnknown, "object") - } - - const data = { ...dataUnknown } - const errors: { [key: string]: unknown } = {} - const remainingKeys = new Set(Object.keys(data)) - - audit.attribute( - data, - "VERSION_A_VENIR", - true, - errors, - remainingKeys, - auditFunction((date) => (Array.isArray(date) ? date : [date])), - auditCleanArray(auditDateIso8601String, auditRequire), - auditRequire, - ) - - return audit.reduceRemaining(data, errors, remainingKeys) -} diff --git a/src/lib/index.ts b/src/lib/index.ts index 8be1297..7c8d2cd 100644 --- a/src/lib/index.ts +++ b/src/lib/index.ts @@ -26,12 +26,10 @@ export { allJorfTextelrLienArtEtats, allJorfTextelrLienArtNatures, allJorfTextelrLienArtOrigines, - allJorfTextelrNatures, - allJorfTextelrOrigines, + allJorfTexteNatures, + allJorfTexteOrigines, allJorfTexteVersionLienNatures, allJorfTexteVersionLienTypes, - allJorfTexteVersionNatures, - allJorfTexteVersionOrigines, allLegiArticleEtats, allLegiArticleLienArticleOrigines, allLegiArticleLienNatures, @@ -43,17 +41,14 @@ export { allLegiSectionTaLienArtOrigines, allLegiSectionTaLienSectionTaEtats, allLegiSectionTaTexteNatures, - allLegiTextelrEtats, + allLegiTexteEtats, allLegiTextelrLienArtEtats, allLegiTextelrLienArtOrigines, allLegiTextelrLienSectionTaEtats, - allLegiTextelrNatures, - allLegiTextelrOrigines, - allLegiTexteVersionEtats, + allLegiTexteNatures, + allLegiTexteOrigines, allLegiTexteVersionLienNatures, allLegiTexteVersionLienTypes, - allLegiTexteVersionNatures, - allLegiTexteVersionOrigines, allSens, type DossierLegislatif, type DossierLegislatifType, @@ -69,6 +64,7 @@ export { type JorfArticleOrigine, type JorfArticleTexteNature, type JorfArticleType, + type JorfMetaTexteChronicle, type JorfSectionTa, type JorfSectionTaLienArtEtat, type JorfSectionTaTexteNature, @@ -77,14 +73,12 @@ export { type JorfTextelrLienArtEtat, type JorfTextelrLienArtNature, type JorfTextelrLienArtOrigine, - type JorfTextelrNature, - type JorfTextelrOrigine, + type JorfTexteNature, + type JorfTexteOrigine, type JorfTexteVersion, type JorfTexteVersionLien, type JorfTexteVersionLienNature, type JorfTexteVersionLienType, - type JorfTexteVersionNature, - type JorfTexteVersionOrigine, type LegiArticle, type LegiArticleEtat, type LegiArticleLien, @@ -94,23 +88,21 @@ export { type LegiArticleOrigine, type LegiArticleTexteNature, type LegiArticleType, + type LegiMetaTexteChronicle, type LegiSectionTa, type LegiSectionTaLienArtEtat, type LegiSectionTaTexteNature, type LegiTextelr, - type LegiTextelrEtat, + type LegiTexteEtat, type LegiTextelrLienArtEtat, type LegiTextelrLienArtOrigine, type LegiTextelrLienSectionTaEtat, - type LegiTextelrNature, - type LegiTextelrOrigine, + type LegiTexteNature, + type LegiTexteOrigine, type LegiTexteVersion, - type LegiTexteVersionEtat, type LegiTexteVersionLien, type LegiTexteVersionLienNature, type LegiTexteVersionLienType, - type LegiTexteVersionNature, - type LegiTexteVersionOrigine, type Sens, } from "./legal" diff --git a/src/lib/legal/index.ts b/src/lib/legal/index.ts index ca82315..f983e29 100644 --- a/src/lib/legal/index.ts +++ b/src/lib/legal/index.ts @@ -27,12 +27,10 @@ export { allJorfTextelrLienArtEtats, allJorfTextelrLienArtNatures, allJorfTextelrLienArtOrigines, - allJorfTextelrNatures, - allJorfTextelrOrigines, + allJorfTexteNatures, + allJorfTexteOrigines, allJorfTexteVersionLienNatures, allJorfTexteVersionLienTypes, - allJorfTexteVersionNatures, - allJorfTexteVersionOrigines, type Jo, type JoNature, type JoOrigine, @@ -45,6 +43,7 @@ export { type JorfArticleTexteNature, type JorfArticleType, type JorfSectionTa, + type JorfMetaTexteChronicle, type JorfSectionTaLienArt, type JorfSectionTaLienArtEtat, type JorfSectionTaLienSectionTa, @@ -58,15 +57,13 @@ export { type JorfTextelrLienArtNature, type JorfTextelrLienArtOrigine, type JorfTextelrLienSectionTa, - type JorfTextelrNature, - type JorfTextelrOrigine, + type JorfTexteNature, + type JorfTexteOrigine, type JorfTextelrStructure, type JorfTexteVersion, type JorfTexteVersionLien, type JorfTexteVersionLienNature, type JorfTexteVersionLienType, - type JorfTexteVersionNature, - type JorfTexteVersionOrigine, } from "./jorf" export { allLegiArticleEtats, @@ -81,17 +78,14 @@ export { allLegiSectionTaLienArtOrigines, allLegiSectionTaLienSectionTaEtats, allLegiSectionTaTexteNatures, - allLegiTextelrEtats, + allLegiTexteEtats, allLegiTextelrLienArtEtats, allLegiTextelrLienArtOrigines, allLegiTextelrLienSectionTaEtats, - allLegiTextelrNatures, - allLegiTextelrOrigines, - allLegiTexteVersionEtats, + allLegiTexteNatures, + allLegiTexteOrigines, allLegiTexteVersionLienNatures, allLegiTexteVersionLienTypes, - allLegiTexteVersionNatures, - allLegiTexteVersionOrigines, type LegiArticle, type LegiArticleEtat, type LegiArticleLien, @@ -103,6 +97,7 @@ export { type LegiArticleOrigine, type LegiArticleTexteNature, type LegiArticleType, + type LegiMetaTexteChronicle, type LegiSectionTa, type LegiSectionTaLienArt, type LegiSectionTaLienArtEtat, @@ -111,22 +106,19 @@ export { type LegiSectionTaStructure, type LegiSectionTaTexteNature, type LegiTextelr, - type LegiTextelrEtat, + type LegiTexteEtat, type LegiTextelrLienArt, type LegiTextelrLienArtEtat, type LegiTextelrLienArtOrigine, type LegiTextelrLienSectionTa, type LegiTextelrLienSectionTaEtat, - type LegiTextelrNature, - type LegiTextelrOrigine, + type LegiTexteNature, + type LegiTexteOrigine, type LegiTextelrStructure, type LegiTexteVersion, - type LegiTexteVersionEtat, type LegiTexteVersionLien, type LegiTexteVersionLienNature, type LegiTexteVersionLienType, - type LegiTexteVersionNature, - type LegiTexteVersionOrigine, } from "./legi" export { allSens, type Sens } from "./shared" diff --git a/src/lib/legal/jorf.ts b/src/lib/legal/jorf.ts index 13877cb..425c097 100644 --- a/src/lib/legal/jorf.ts +++ b/src/lib/legal/jorf.ts @@ -119,6 +119,19 @@ export interface JorfArticleTm { export type JorfArticleType = (typeof allJorfArticleTypes)[number] +export interface JorfMetaTexteChronicle { + CID: string + DATE_PUBLI: string + DATE_TEXTE: string + NOR?: string + NUM?: string + NUM_PARUTION?: number + NUM_SEQUENCE?: number + ORIGINE_PUBLI?: string + PAGE_DEB_PUBLI?: number + PAGE_FIN_PUBLI?: number +} + // Section Texte Article // Correspond à un niveau d'une table des matières export interface JorfSectionTa { @@ -207,23 +220,12 @@ export interface JorfTextelr { } ID: string ID_ELI?: string - NATURE?: JorfTextelrNature - ORIGINE: JorfTextelrOrigine + NATURE?: JorfTexteNature + ORIGINE: JorfTexteOrigine URL: string } META_SPEC: { - META_TEXTE_CHRONICLE: { - CID: string - DATE_PUBLI: string - DATE_TEXTE: string - NOR?: string - NUM?: string - NUM_PARUTION?: number - NUM_SEQUENCE?: number - ORIGINE_PUBLI?: string - PAGE_DEB_PUBLI?: number - PAGE_FIN_PUBLI?: number - } + META_TEXTE_CHRONICLE: JorfMetaTexteChronicle } } STRUCT?: JorfTextelrStructure @@ -260,9 +262,9 @@ export type JorfTextelrLienArtNature = export type JorfTextelrLienArtOrigine = (typeof allJorfTextelrLienArtOrigines)[number] -export type JorfTextelrNature = (typeof allJorfTextelrNatures)[number] +export type JorfTexteNature = (typeof allJorfTexteNatures)[number] -export type JorfTextelrOrigine = (typeof allJorfTextelrOrigines)[number] +export type JorfTexteOrigine = (typeof allJorfTexteOrigines)[number] export interface JorfTextelrLienSectionTa { "#text"?: string @@ -302,23 +304,12 @@ export interface JorfTexteVersion { } ID: string ID_ELI?: string - NATURE?: JorfTexteVersionNature - ORIGINE: JorfTexteVersionOrigine + NATURE?: JorfTexteNature + ORIGINE: JorfTexteOrigine URL: string } META_SPEC: { - META_TEXTE_CHRONICLE: { - CID: string - DATE_PUBLI: string - DATE_TEXTE: string - NOR?: string - NUM?: string - NUM_PARUTION?: number - NUM_SEQUENCE?: number - ORIGINE_PUBLI?: string - PAGE_DEB_PUBLI?: number - PAGE_FIN_PUBLI?: number - } + META_TEXTE_CHRONICLE: JorfMetaTexteChronicle META_TEXTE_VERSION: { AUTORITE?: string DATE_DEBUT: string @@ -376,11 +367,6 @@ export type JorfTexteVersionLienNature = export type JorfTexteVersionLienType = (typeof allJorfTexteVersionLienTypes)[number] -export type JorfTexteVersionNature = (typeof allJorfTexteVersionNatures)[number] - -export type JorfTexteVersionOrigine = - (typeof allJorfTexteVersionOrigines)[number] - /// Table des matières (TM) d'un Journal officiel export interface JoTm { "@niv": number @@ -546,7 +532,7 @@ export const allJorfTextelrLienArtNatures = [] as const export const allJorfTextelrLienArtOrigines = ["JORF"] as const -export const allJorfTextelrNatures = [ +export const allJorfTexteNatures = [ "ABROGATION", // 8 "Accord multilatéral", // 1 "ACCORD_FONCTION_PUBLIQUE", // 4 @@ -637,7 +623,7 @@ export const allJorfTextelrNatures = [ "VOCABULAIRE", // 169 ] as const -export const allJorfTextelrOrigines = ["JORF"] as const +export const allJorfTexteOrigines = ["JORF"] as const export const allJorfTexteVersionLienNatures = [ "ABROGATION", // 5 @@ -824,96 +810,3 @@ export const allJorfTexteVersionLienTypes = [ "TXT_ASSOCIE", // 11821 "TXT_SOURCE", // 81350 ] as const - -export const allJorfTexteVersionNatures = [ - "ABROGATION", // 8 - "Accord multilatéral", // 1 - "ACCORD_FONCTION_PUBLIQUE", // 4 - "ACCORD", // 46 - "ACTE", // 3 - "ADDITIF", // 131 - "ANNEXE", // 1 - "ANNONCES", // 756 - "ARRANGEMENT", // 1 - "ARRET", // 65 - "ARRETE", // 615239 - "ARRETEAVIS", // 1 - "ARRETEEURO", // 14 - "ARRETEURO", // 556 - "ATTESTATION", // 1 - "AVENANT", // 186 - "AVIS", // 97999 - "AVISEURO", // 4618 - "CANDIDAT", // 2 - "CHARTE", // 1 - "CIRCULAIRE", // 3532 - "CITATION", // 494 - "CODE", // 58 - "COMMUNIQUE", // 17 - "COMPLEMENT", // 2 - "COMPOSITION", // 9 - "CONSTITUTION", // 4 - "CONTRAT", // 2 - "CONVENTION", // 151 - "DATE", // 1 - "DECISION_CC", // 96 - "DECISION_EURO", // 550 - "DECISION", // 67164 - "DECLARATION", // 20 - "DECLARATIONEURO", // 18 - "DECRET_LOI", // 660 - "DECRET", // 209363 - "DELEGATION", // 1 - "DELIBERATION", // 3993 - "DELIBERATIONEURO", // 36 - "DEUXIEME", // 5 - "DIRECTIVE_EURO", // 4249 - "DIRECTIVE", // 13 - "DISPOSITIONS", // 1 - "ELECTION", // 1 - "ELECTIONDUPRESIDENTDELAREPUBLIQU", // 2 - "EXEQUATUR", // 174 - "INFORMATION", // 106 - "INFORMATIONEURO", // 1 - "INFORMATIONS_CESE", // 285 - "INFORMATIONS_DIVERSES", // 524 - "INFORMATIONS_PARLEMENTAIRES", // 6042 - "INSTRUCTION", // 158 - "INSTRUCTIONEURO", // 524 - "LETTRE", // 13 - "LETTREEURO", // 15 - "LISTE", // 5552 - "LOI_CONSTIT", // 12 - "LOI_ORGANIQUE", // 105 - "LOI_PROGRAMME", // 2 - "LOI", // 12859 - "MEMOIRE", // 63 - "MESSAGE", // 2 - "MODIFICATION", // 497 - "NOTE", // 3 - "OBSERVATION", // 288 - "ORDONNANCE", // 3282 - "PREMIER", // 1 - "PROCLAMATION", // 3 - "PROJET", // 3 - "PROPOSITION", // 6 - "PROTOCOLE", // 16 - "PUBLICATION", // 2 - "RAPPORT", // 1968 - "RECOMMANDATION", // 126 - "RECTIFICATIF", // 3 - "REGLEMENT", // 902 - "REGLEMENTEUROPEEN", // 571 - "RELEVE", // 3 - "REMISE", // 121 - "RESULTATS", // 14479 - "SAISINE", // 392 - "SENATUS", // 2 - "SUSPENSION", // 1 - "TABLEAU", // 1092 - "TRAITE", // 5 - "TROISIEME", // 2 - "VOCABULAIRE", // 169 -] as const - -export const allJorfTexteVersionOrigines = ["JORF"] as const diff --git a/src/lib/legal/legi.ts b/src/lib/legal/legi.ts index 840e3b3..392d8ae 100644 --- a/src/lib/legal/legi.ts +++ b/src/lib/legal/legi.ts @@ -136,6 +136,23 @@ export interface LegiSectionTa { TITRE_TA?: string // Titre de la section (peut contenir des sauts de lignes à remplacer par des espaces) } +export interface LegiMetaTexteChronicle { + CID: string + DATE_PUBLI: string + DATE_TEXTE: string + DERNIERE_MODIFICATION: string + NOR?: string + NUM?: string + NUM_PARUTION?: number + NUM_SEQUENCE?: number + ORIGINE_PUBLI?: string + PAGE_DEB_PUBLI?: number + PAGE_FIN_PUBLI?: number + VERSIONS_A_VENIR?: { + VERSION_A_VENIR: string[] + } +} + export interface LegiSectionTaLienArt { "@debut": string "@etat"?: LegiSectionTaLienArtEtat @@ -190,33 +207,18 @@ export interface LegiTextelr { META_COMMUN: { ANCIEN_ID?: string ID: string - NATURE?: LegiTextelrNature - ORIGINE: LegiTextelrOrigine + NATURE?: LegiTexteNature + ORIGINE: LegiTexteOrigine URL: string } META_SPEC: { - META_TEXTE_CHRONICLE: { - CID: string - DATE_PUBLI: string - DATE_TEXTE: string - DERNIERE_MODIFICATION: string - NOR?: string - NUM?: string - NUM_PARUTION?: number - NUM_SEQUENCE?: number - ORIGINE_PUBLI?: string - PAGE_DEB_PUBLI?: number - PAGE_FIN_PUBLI?: number - VERSIONS_A_VENIR?: { - VERSION_A_VENIR: string[] - } - } + META_TEXTE_CHRONICLE: LegiMetaTexteChronicle } } STRUCT?: LegiTextelrStructure VERSIONS: { VERSION: Array<{ - "@etat"?: LegiTextelrEtat + "@etat"?: LegiTexteEtat LIEN_TXT: { "@debut": string "@fin": string @@ -227,7 +229,7 @@ export interface LegiTextelr { } } -export type LegiTextelrEtat = (typeof allLegiTextelrEtats)[number] +export type LegiTexteEtat = (typeof allLegiTexteEtats)[number] export interface LegiTextelrLienArt { "@debut": string @@ -258,9 +260,9 @@ export interface LegiTextelrLienSectionTa { export type LegiTextelrLienSectionTaEtat = (typeof allLegiTextelrLienSectionTaEtats)[number] -export type LegiTextelrNature = (typeof allLegiTextelrNatures)[number] +export type LegiTexteNature = (typeof allLegiTexteNatures)[number] -export type LegiTextelrOrigine = (typeof allLegiTextelrOrigines)[number] +export type LegiTexteOrigine = (typeof allLegiTexteOrigines)[number] // Structure du LegiTextelr // Premier niveau de table des matières @@ -281,32 +283,17 @@ export interface LegiTexteVersion { } ID: string ID_ELI?: string - NATURE?: LegiTexteVersionNature - ORIGINE: LegiTexteVersionOrigine + NATURE?: LegiTexteNature + ORIGINE: LegiTexteOrigine URL: string } META_SPEC: { - META_TEXTE_CHRONICLE: { - CID: string - DATE_PUBLI: string - DATE_TEXTE: string - DERNIERE_MODIFICATION: string - NOR?: string - NUM?: string - NUM_PARUTION?: number - NUM_SEQUENCE?: number - ORIGINE_PUBLI?: string - PAGE_DEB_PUBLI?: number - PAGE_FIN_PUBLI?: number - VERSIONS_A_VENIR?: { - VERSION_A_VENIR: string[] - } - } + META_TEXTE_CHRONICLE: LegiMetaTexteChronicle META_TEXTE_VERSION: { AUTORITE?: string DATE_DEBUT?: string DATE_FIN?: string - ETAT?: LegiTexteVersionEtat + ETAT?: LegiTexteEtat LIENS?: { LIEN: Array } @@ -337,8 +324,6 @@ export interface LegiTexteVersion { } } -export type LegiTexteVersionEtat = (typeof allLegiTexteVersionEtats)[number] - export interface LegiTexteVersionLien { "#text"?: string "@cidtexte"?: string // Present if and only if @id is present @@ -358,11 +343,6 @@ export type LegiTexteVersionLienNature = export type LegiTexteVersionLienType = (typeof allLegiTexteVersionLienTypes)[number] -export type LegiTexteVersionNature = (typeof allLegiTexteVersionNatures)[number] - -export type LegiTexteVersionOrigine = - (typeof allLegiTexteVersionOrigines)[number] - export const allLegiArticleEtats = [ "ABROGE_DIFF", // 16233 "ABROGE", // 341353 @@ -521,7 +501,7 @@ export const allLegiSectionTaTexteNatures = [ "ORDONNANCE", // 4639 ] as const -export const allLegiTextelrEtats = [ +export const allLegiTexteEtats = [ "ABROGE_DIFF", // 1897 "ABROGE", // 24375 "ANNULE", // 210 @@ -558,11 +538,12 @@ export const allLegiTextelrLienSectionTaEtats = [ "VIGUEUR", // 48481 ] as const -export const allLegiTextelrNatures = [ +export const allLegiTexteNatures = [ "ACCORD_FONCTION_PUBLIQUE", // 4 "ARRETE", // 77686 "AVIS", // 12 "CODE", // 114 + "CIRCULAIRE", "CONSTITUTION", // 3 "CONVENTION", // 1 "DECISION", // 12 @@ -576,18 +557,7 @@ export const allLegiTextelrNatures = [ "ORDONNANCE", // 1520 ] as const -export const allLegiTextelrOrigines = ["LEGI"] as const - -export const allLegiTexteVersionEtats = [ - "ABROGE_DIFF", // 1712 - "ABROGE", // 23360 - "ANNULE", // 205 - "MODIFIE_MORT_NE", // 36 - "MODIFIE", // 3833 - "PERIME", // 3601 - "VIGUEUR_DIFF", // 2073 - "VIGUEUR", // 101189 -] as const +export const allLegiTexteOrigines = ["LEGI"] as const export const allLegiTexteVersionLienNatures = [ "ACCORD_FONCTION_PUBLIQUE", @@ -643,23 +613,3 @@ export const allLegiTexteVersionLienTypes = [ "TXT_ASSOCIE", // 4469 "TXT_SOURCE", // 19858 ] as const - -export const allLegiTexteVersionNatures = [ - "ACCORD_FONCTION_PUBLIQUE", // 4 - "ARRETE", // 77680 - "AVIS", // 12 - "CODE", // 114 - "CONSTITUTION", // 3 - "CONVENTION", // 1 - "DECISION", // 12 - "DECLARATION", // 1 - "DECRET_LOI", // 35 - "DECRET", // 53030 - "DELIBERATION", // 11 - "LOI_CONSTIT", // 19 - "LOI_ORGANIQUE", // 111 - "LOI", // 3457 - "ORDONNANCE", // 1520 -] as const - -export const allLegiTexteVersionOrigines = ["LEGI"] as const