Validate JORF TEXTE_VERSION & TEXTELR

This commit is contained in:
Emmanuel 2023-02-14 18:20:40 +01:00
parent 920d52bcc0
commit 98f7fd4e83
11 changed files with 2244 additions and 42 deletions

View file

@ -1,3 +1,5 @@
export { auditJo, joStats } from "./jo" export { auditJo, joStats } from "./jo"
export { auditJorfArticle, jorfArticleStats } from "./articles" export { auditJorfArticle, jorfArticleStats } from "./articles"
export { auditJorfSectionTa, jorfSectionTaStats } from "./section_ta" export { auditJorfSectionTa, jorfSectionTaStats } from "./section_ta"
export { auditJorfTextelr, jorfTextelrStats } from "./textelr"
export { auditJorfTexteVersion, jorfTexteVersionStats } from "./texte_version"

View file

@ -39,6 +39,7 @@ export function auditJo(
const data = { ...dataUnknown } const data = { ...dataUnknown }
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
audit.attribute( audit.attribute(
data, data,
"META", "META",

View file

@ -0,0 +1,916 @@
import {
auditCleanArray,
auditDateIso8601String,
auditEmptyToNull,
auditFunction,
auditHttpUrl,
auditInteger,
auditNullish,
auditNumber,
auditOptions,
auditRequire,
auditSwitch,
auditTrimString,
type Audit,
} from "@auditors/core"
import {
allJorfTexteVersionLienNaturesMutable,
allJorfTexteVersionLienTypesMutable,
allJorfTexteVersionNaturesMutable,
allJorfTexteVersionOriginesMutable,
allSensMutable,
} from "$lib/legal"
export const jorfTexteVersionStats: {
countByLienNature: { [nature: string]: number }
countByLienType: { [type: string]: number }
countByNature: { [nature: string]: number }
countByOrigine: { [origine: string]: number }
} = {
countByLienNature: {},
countByLienType: {},
countByNature: {},
countByOrigine: {},
}
function auditAbro(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,
"CONTENU",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditDatesEffet(
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,
"DATE_EFFET",
true,
errors,
remainingKeys,
auditFunction((date) => (Array.isArray(date) ? date : [date])),
auditCleanArray(auditDateIso8601String, auditRequire),
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditDomaines(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,
"DOMAINE",
true,
errors,
remainingKeys,
auditFunction((domaine) => (Array.isArray(domaine) ? domaine : [domaine])),
auditCleanArray(auditTrimString, auditEmptyToNull, auditRequire),
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditEliAlias(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,
"ID_ELI_ALIAS",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditHttpUrl,
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditEntreprise(
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,
"@texte_entreprise",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditOptions(["non", "oui"]),
auditRequire,
)
audit.attribute(
data,
"DATES_EFFET",
true,
errors,
remainingKeys,
auditSwitch(
[auditTrimString, auditEmptyToNull, auditNullish],
auditDatesEffet,
),
)
audit.attribute(
data,
"DOMAINES",
true,
errors,
remainingKeys,
auditSwitch(
[auditTrimString, auditEmptyToNull, auditNullish],
auditDomaines,
),
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
export function auditJorfTexteVersion(
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,
"ABRO",
true,
errors,
remainingKeys,
auditAbro,
auditEmptyToNull,
)
audit.attribute(
data,
"ENTREPRISE",
true,
errors,
remainingKeys,
auditEntreprise,
auditEmptyToNull,
)
audit.attribute(
data,
"META",
true,
errors,
remainingKeys,
auditMeta,
auditRequire,
)
audit.attribute(
data,
"NOTICE",
true,
errors,
remainingKeys,
auditNotice,
auditEmptyToNull,
)
audit.attribute(
data,
"RECT",
true,
errors,
remainingKeys,
auditRect,
auditEmptyToNull,
)
audit.attribute(
data,
"SIGNATAIRES",
true,
errors,
remainingKeys,
auditSignataires,
auditEmptyToNull,
)
audit.attribute(
data,
"SM",
true,
errors,
remainingKeys,
auditSm,
auditEmptyToNull,
)
audit.attribute(
data,
"TP",
true,
errors,
remainingKeys,
auditTp,
auditEmptyToNull,
)
audit.attribute(
data,
"VISAS",
true,
errors,
remainingKeys,
auditVisas,
auditEmptyToNull,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditLien(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,
"#text",
true,
errors,
remainingKeys,
auditSwitch(
[auditNumber, auditFunction((num) => num.toString())],
[auditTrimString, auditEmptyToNull],
),
)
for (const key of ["@cidtexte", "@id"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
}
audit.attribute(
data,
"@datesignatexte",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditDateIso8601String,
)
audit.attribute(
data,
"@naturetexte",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
// auditFunction((nature) => {
// jorfTexteVersionStats.countByLienNature[nature] =
// (jorfTexteVersionStats.countByLienNature[nature] ?? 0) + 1
// return nature
// }),
auditOptions(allJorfTexteVersionLienNaturesMutable),
)
for (const key of ["@num", "@nortexte", "@numtexte"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
}
audit.attribute(
data,
"@sens",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditOptions(allSensMutable),
auditRequire,
)
audit.attribute(
data,
"@typelien",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
// auditFunction((type) => {
// jorfTexteVersionStats.countByLienType[type] =
// (jorfTexteVersionStats.countByLienType[type] ?? 0) + 1
// return type
// }),
auditOptions(allJorfTexteVersionLienTypesMutable),
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditLiens(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,
"LIEN",
true,
errors,
remainingKeys,
auditFunction((lien) => (Array.isArray(lien) ? lien : [lien])),
auditCleanArray(auditLien, auditRequire),
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
/// Mots-clés du texte
function auditMcsTxt(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,
"MC",
true,
errors,
remainingKeys,
auditFunction((lien) => (Array.isArray(lien) ? lien : [lien])),
auditCleanArray(
auditSwitch(
[auditNumber, auditFunction((num) => num.toString())],
[auditTrimString, auditEmptyToNull],
),
),
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditMeta(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,
"META_COMMUN",
true,
errors,
remainingKeys,
auditMetaCommun,
auditRequire,
)
audit.attribute(
data,
"META_SPEC",
true,
errors,
remainingKeys,
auditMetaSpec,
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditMetaCommun(
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,
"ANCIEN_ID",
true,
errors,
remainingKeys,
auditSwitch(
[auditNumber, auditFunction((id) => id.toString())],
[auditTrimString, auditEmptyToNull],
),
)
audit.attribute(data, "ELI_ALIAS", true, errors, remainingKeys, auditEliAlias)
for (const key of ["ID", "URL"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditRequire,
)
}
audit.attribute(
data,
"ID_ELI",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditHttpUrl,
)
audit.attribute(
data,
"NATURE",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
// auditFunction((nature) => {
// jorfTexteVersionStats.countByNature[nature] =
// (jorfTexteVersionStats.countByNature[nature] ?? 0) + 1
// return nature
// }),
auditOptions(allJorfTexteVersionNaturesMutable),
)
audit.attribute(
data,
"ORIGINE",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
// auditFunction((origine) => {
// jorfTexteVersionStats.countByOrigine[origine] =
// (jorfTexteVersionStats.countByOrigine[origine] ?? 0) + 1
// return origine
// }),
auditOptions(allJorfTexteVersionOriginesMutable),
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditMetaSpec(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,
"META_TEXTE_CHRONICLE",
true,
errors,
remainingKeys,
auditMetaTexteChronicle,
auditRequire,
)
audit.attribute(
data,
"META_TEXTE_VERSION",
true,
errors,
remainingKeys,
auditMetaTexteVersion,
auditRequire,
)
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],
),
)
}
for (const key of ["ORIGINE_PUBLI"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
}
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditMetaTexteVersion(
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 ["AUTORITE", "MINISTERE", "TITRE"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
}
for (const key of ["DATE_DEBUT", "DATE_FIN"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditDateIso8601String,
)
}
audit.attribute(
data,
"LIENS",
true,
errors,
remainingKeys,
auditSwitch(auditTrimString, auditLiens),
auditEmptyToNull,
)
audit.attribute(
data,
"MCS_TXT",
true,
errors,
remainingKeys,
auditSwitch([auditTrimString, auditEmptyToNull, auditNullish], auditMcsTxt),
)
for (const key of ["TITREFULL"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditRequire,
)
}
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditNotice(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,
"CONTENU",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditRect(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,
"CONTENU",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditSignataires(
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,
"CONTENU",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditSm(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,
"CONTENU",
true,
errors,
remainingKeys,
auditSwitch(
[auditNumber, auditFunction((num) => num.toString())],
[auditTrimString, auditEmptyToNull],
),
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditTp(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,
"CONTENU",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditVisas(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,
"CONTENU",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}

View file

@ -0,0 +1,666 @@
import {
auditCleanArray,
auditDateIso8601String,
auditEmptyToNull,
auditFunction,
auditHttpUrl,
auditInteger,
auditNullish,
auditNumber,
auditOptions,
auditRequire,
auditStringToNumber,
auditSwitch,
auditTrimString,
type Audit,
} from "@auditors/core"
import {
allJorfTextelrEtatsMutable,
allJorfTextelrLienArtEtatsMutable,
// allJorfTextelrLienArtNaturesMutable,
allJorfTextelrLienArtOriginesMutable,
allJorfTextelrNaturesMutable,
allJorfTextelrOriginesMutable,
} from "$lib/legal"
export const jorfTextelrStats: {
countByEtat: { [etat: string]: number }
countByLienArtEtat: { [etat: string]: number }
countByLienArtNature: { [nature: string]: number }
countByLienArtOrigine: { [origine: string]: number }
countByNature: { [nature: string]: number }
countByOrigine: { [origine: string]: number }
} = {
countByEtat: {},
countByLienArtEtat: {},
countByLienArtNature: {},
countByLienArtOrigine: {},
countByNature: {},
countByOrigine: {},
}
function auditEliAlias(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,
"ID_ELI_ALIAS",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditHttpUrl,
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
export function auditJorfTextelr(
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,
"META",
true,
errors,
remainingKeys,
auditMeta,
auditRequire,
)
audit.attribute(
data,
"STRUCT",
true,
errors,
remainingKeys,
auditSwitch([auditTrimString, auditEmptyToNull, auditNullish], auditStruct),
)
audit.attribute(
data,
"VERSIONS",
true,
errors,
remainingKeys,
auditVersions,
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditLienArt(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 ["@debut", "@fin"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditDateIso8601String,
auditRequire,
)
}
audit.attribute(
data,
"@etat",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
// auditFunction((etat) => {
// jorfTextelrStats.countByLienArtEtat[etat] =
// (jorfTextelrStats.countByLienArtEtat[etat] ?? 0) + 1
// return etat
// }),
auditOptions(allJorfTextelrLienArtEtatsMutable),
)
for (const key of ["@id"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditRequire,
)
}
audit.attribute(
data,
"@nature",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
// auditFunction((nature) => {
// jorfTextelrStats.countByLienArtNature[nature] =
// (jorfTextelrStats.countByLienArtNature[nature] ?? 0) + 1
// return nature
// }),
// auditOptions(allJorfTextelrLienArtNaturesMutable),
auditNullish,
)
for (const key of ["@num"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
}
audit.attribute(
data,
"@origine",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
// auditFunction((origine) => {
// jorfTextelrStats.countByLienArtOrigine[origine] =
// (jorfTextelrStats.countByLienArtOrigine[origine] ?? 0) + 1
// return origine
// }),
auditOptions(allJorfTextelrLienArtOriginesMutable),
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditLienSectionTa(
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 ["#text"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
}
for (const key of ["@cid", "@id", "@url"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditRequire,
)
}
for (const key of ["@debut", "@fin"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditDateIso8601String,
auditRequire,
)
}
audit.attribute(
data,
"@etat",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditNullish,
// auditFunction((etat) => {
// jorfSectionTaStats.countByLienSectionTaEtat[etat] =
// (jorfSectionTaStats.countByLienSectionTaEtat[etat] ?? 0) + 1
// return etat
// }),
// auditOptions(allJorfSectionTaLienSectionTaEtatsMutable),
)
audit.attribute(
data,
"@niv",
true,
errors,
remainingKeys,
auditStringToNumber,
auditInteger,
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditLienTxt(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 ["@debut", "@fin"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditDateIso8601String,
auditRequire,
)
}
for (const key of ["@id"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditRequire,
)
}
for (const key of ["@num"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
}
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditMeta(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,
"META_COMMUN",
true,
errors,
remainingKeys,
auditMetaCommun,
auditRequire,
)
audit.attribute(
data,
"META_SPEC",
true,
errors,
remainingKeys,
auditMetaSpec,
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditMetaCommun(
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,
"ANCIEN_ID",
true,
errors,
remainingKeys,
auditSwitch(
[auditNumber, auditFunction((id) => id.toString())],
[auditTrimString, auditEmptyToNull],
),
)
audit.attribute(data, "ELI_ALIAS", true, errors, remainingKeys, auditEliAlias)
for (const key of ["ID", "URL"]) {
audit.attribute(
data,
key,
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditRequire,
)
}
audit.attribute(
data,
"ID_ELI",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
auditHttpUrl,
)
audit.attribute(
data,
"NATURE",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
// auditFunction((nature) => {
// jorfTextelrStats.countByNature[nature] =
// (jorfTextelrStats.countByNature[nature] ?? 0) + 1
// return nature
// }),
auditOptions(allJorfTextelrNaturesMutable),
)
audit.attribute(
data,
"ORIGINE",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
// auditFunction((origine) => {
// jorfTextelrStats.countByOrigine[origine] =
// (jorfTextelrStats.countByOrigine[origine] ?? 0) + 1
// return origine
// }),
auditOptions(allJorfTextelrOriginesMutable),
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditMetaSpec(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,
"META_TEXTE_CHRONICLE",
true,
errors,
remainingKeys,
auditMetaTexteChronicle,
auditRequire,
)
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],
),
)
}
for (const key of ["ORIGINE_PUBLI"]) {
audit.attribute(
data,
key,
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]
}
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,
"LIEN_ART",
true,
errors,
remainingKeys,
auditFunction((lien) => (Array.isArray(lien) ? lien : [lien])),
auditCleanArray(auditLienArt, auditRequire),
)
audit.attribute(
data,
"LIEN_SECTION_TA",
true,
errors,
remainingKeys,
auditFunction((lien) => (Array.isArray(lien) ? lien : [lien])),
auditCleanArray(auditLienSectionTa, auditRequire),
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditVersion(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,
"@etat",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
// auditFunction((etat) => {
// jorfTextelrStats.countByEtat[etat] =
// (jorfTextelrStats.countByEtat[etat] ?? 0) + 1
// return etat
// }),
auditOptions(allJorfTextelrEtatsMutable),
)
audit.attribute(
data,
"LIEN_TXT",
true,
errors,
remainingKeys,
auditLienTxt,
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}
function auditVersions(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",
true,
errors,
remainingKeys,
auditFunction((version) => (Array.isArray(version) ? version : [version])),
auditCleanArray(auditVersion, auditRequire),
auditRequire,
)
return audit.reduceRemaining(data, errors, remainingKeys)
}

View file

@ -16,12 +16,12 @@ import {
import { import {
allLegiArticleEtatsMutable, allLegiArticleEtatsMutable,
allLegiArticleLienNaturesMutable, allLegiArticleLienNaturesMutable,
allLegiArticleLienSensMutable,
allLegiArticleLienTypesMutable, allLegiArticleLienTypesMutable,
allLegiArticleNaturesMutable, allLegiArticleNaturesMutable,
allLegiArticleOriginesMutable, allLegiArticleOriginesMutable,
allLegiArticleTexteNaturesMutable, allLegiArticleTexteNaturesMutable,
allLegiArticleTypesMutable, allLegiArticleTypesMutable,
allSensMutable,
} from "$lib/legal" } from "$lib/legal"
export const legiArticleStats: { export const legiArticleStats: {
@ -189,7 +189,7 @@ function auditLien(audit: Audit, dataUnknown: unknown): [unknown, unknown] {
[auditTrimString, auditEmptyToNull], [auditTrimString, auditEmptyToNull],
), ),
) )
for (const key of ["@cidtexte", "@id", "@nortexte", "@num"]) { for (const key of ["@cidtexte", "@id", "@nortexte", "@num", "@numtexte"]) {
audit.attribute( audit.attribute(
data, data,
key, key,
@ -225,15 +225,6 @@ function auditLien(audit: Audit, dataUnknown: unknown): [unknown, unknown] {
// }), // }),
auditOptions(allLegiArticleLienNaturesMutable), auditOptions(allLegiArticleLienNaturesMutable),
) )
audit.attribute(
data,
"@numtexte",
true,
errors,
remainingKeys,
auditTrimString,
auditEmptyToNull,
)
audit.attribute( audit.attribute(
data, data,
"@sens", "@sens",
@ -242,7 +233,7 @@ function auditLien(audit: Audit, dataUnknown: unknown): [unknown, unknown] {
remainingKeys, remainingKeys,
auditTrimString, auditTrimString,
auditEmptyToNull, auditEmptyToNull,
auditOptions(allLegiArticleLienSensMutable), auditOptions(allSensMutable),
auditRequire, auditRequire,
) )
audit.attribute( audit.attribute(

View file

@ -36,14 +36,40 @@ export {
allJorfArticleTexteNaturesMutable, allJorfArticleTexteNaturesMutable,
allJorfArticleTypes, allJorfArticleTypes,
allJorfArticleTypesMutable, allJorfArticleTypesMutable,
allJorfSectionTaLienArtEtats,
allJorfSectionTaLienArtEtatsMutable,
allJorfSectionTaLienArtOrigines,
allJorfSectionTaLienArtOriginesMutable,
allJorfSectionTaLienSectionTaEtats,
allJorfSectionTaLienSectionTaEtatsMutable,
allJorfSectionTaTexteNatures,
allJorfSectionTaTexteNaturesMutable,
allJorfTextelrEtats,
allJorfTextelrEtatsMutable,
allJorfTextelrLienArtEtats,
allJorfTextelrLienArtEtatsMutable,
allJorfTextelrLienArtNatures,
allJorfTextelrLienArtNaturesMutable,
allJorfTextelrLienArtOrigines,
allJorfTextelrLienArtOriginesMutable,
allJorfTextelrNatures,
allJorfTextelrNaturesMutable,
allJorfTextelrOrigines,
allJorfTextelrOriginesMutable,
allJorfTexteVersionLienNatures,
allJorfTexteVersionLienNaturesMutable,
allJorfTexteVersionLienTypes,
allJorfTexteVersionLienTypesMutable,
allJorfTexteVersionNatures,
allJorfTexteVersionNaturesMutable,
allJorfTexteVersionOrigines,
allJorfTexteVersionOriginesMutable,
allLegiArticleEtats, allLegiArticleEtats,
allLegiArticleEtatsMutable, allLegiArticleEtatsMutable,
allLegiArticleLienArticleOrigines, allLegiArticleLienArticleOrigines,
allLegiArticleLienArticleOriginesMutable, allLegiArticleLienArticleOriginesMutable,
allLegiArticleLienNatures, allLegiArticleLienNatures,
allLegiArticleLienNaturesMutable, allLegiArticleLienNaturesMutable,
allLegiArticleLienSens,
allLegiArticleLienSensMutable,
allLegiArticleNatures, allLegiArticleNatures,
allLegiArticleNaturesMutable, allLegiArticleNaturesMutable,
allLegiArticleOrigines, allLegiArticleOrigines,
@ -52,7 +78,10 @@ export {
allLegiArticleTexteNaturesMutable, allLegiArticleTexteNaturesMutable,
allLegiArticleTypes, allLegiArticleTypes,
allLegiArticleTypesMutable, allLegiArticleTypesMutable,
allSens,
allSensMutable,
type DossierLegislatif, type DossierLegislatif,
type Jo,
type JoNature, type JoNature,
type JoOrigine, type JoOrigine,
type JorfArticle, type JorfArticle,
@ -62,15 +91,30 @@ export {
type JorfArticleOrigine, type JorfArticleOrigine,
type JorfArticleTexteNature, type JorfArticleTexteNature,
type JorfArticleType, type JorfArticleType,
type JorfSectionTa,
type JorfSectionTaLienArtEtat,
type JorfSectionTaTexteNature,
type JorfTextelr,
type JorfTextelrEtat,
type JorfTextelrLienArtEtat,
type JorfTextelrLienArtNature,
type JorfTextelrLienArtOrigine,
type JorfTextelrNature,
type JorfTextelrOrigine,
type JorfTexteVersion,
type JorfTexteVersionLienNature,
type JorfTexteVersionLienType,
type JorfTexteVersionNature,
type JorfTexteVersionOrigine,
type LegiArticle, type LegiArticle,
type LegiArticleEtat, type LegiArticleEtat,
type LegiArticleLienArticleOrigine, type LegiArticleLienArticleOrigine,
type LegiArticleLienNature, type LegiArticleLienNature,
type LegiArticleLienSens,
type LegiArticleNature, type LegiArticleNature,
type LegiArticleOrigine, type LegiArticleOrigine,
type LegiArticleTexteNature, type LegiArticleTexteNature,
type LegiArticleType, type LegiArticleType,
type Sens,
} from "./legal" } from "./legal"
export { export {
@ -80,7 +124,6 @@ export {
type Contexte, type Contexte,
type Etat, type Etat,
type Idcc, type Idcc,
type Jo,
type LegalObject, type LegalObject,
type LegalObjectType, type LegalObjectType,
type Lien, type Lien,

View file

@ -30,6 +30,26 @@ export {
allJorfSectionTaLienSectionTaEtatsMutable, allJorfSectionTaLienSectionTaEtatsMutable,
allJorfSectionTaTexteNatures, allJorfSectionTaTexteNatures,
allJorfSectionTaTexteNaturesMutable, allJorfSectionTaTexteNaturesMutable,
allJorfTextelrEtats,
allJorfTextelrEtatsMutable,
allJorfTextelrLienArtEtats,
allJorfTextelrLienArtEtatsMutable,
allJorfTextelrLienArtNatures,
allJorfTextelrLienArtNaturesMutable,
allJorfTextelrLienArtOrigines,
allJorfTextelrLienArtOriginesMutable,
allJorfTextelrNatures,
allJorfTextelrNaturesMutable,
allJorfTextelrOrigines,
allJorfTextelrOriginesMutable,
allJorfTexteVersionLienNatures,
allJorfTexteVersionLienNaturesMutable,
allJorfTexteVersionLienTypes,
allJorfTexteVersionLienTypesMutable,
allJorfTexteVersionNatures,
allJorfTexteVersionNaturesMutable,
allJorfTexteVersionOrigines,
allJorfTexteVersionOriginesMutable,
type Jo, type Jo,
type JoNature, type JoNature,
type JoOrigine, type JoOrigine,
@ -43,6 +63,18 @@ export {
type JorfSectionTa, type JorfSectionTa,
type JorfSectionTaLienArtEtat, type JorfSectionTaLienArtEtat,
type JorfSectionTaTexteNature, type JorfSectionTaTexteNature,
type JorfTextelr,
type JorfTextelrEtat,
type JorfTextelrLienArtEtat,
type JorfTextelrLienArtNature,
type JorfTextelrLienArtOrigine,
type JorfTextelrNature,
type JorfTextelrOrigine,
type JorfTexteVersion,
type JorfTexteVersionLienNature,
type JorfTexteVersionLienType,
type JorfTexteVersionNature,
type JorfTexteVersionOrigine,
} from "./jorf" } from "./jorf"
export { export {
allLegiArticleEtats, allLegiArticleEtats,
@ -51,8 +83,6 @@ export {
allLegiArticleLienArticleOriginesMutable, allLegiArticleLienArticleOriginesMutable,
allLegiArticleLienNatures, allLegiArticleLienNatures,
allLegiArticleLienNaturesMutable, allLegiArticleLienNaturesMutable,
allLegiArticleLienSens,
allLegiArticleLienSensMutable,
allLegiArticleLienTypes, allLegiArticleLienTypes,
allLegiArticleLienTypesMutable, allLegiArticleLienTypesMutable,
allLegiArticleNatures, allLegiArticleNatures,
@ -67,13 +97,13 @@ export {
type LegiArticleEtat, type LegiArticleEtat,
type LegiArticleLienArticleOrigine, type LegiArticleLienArticleOrigine,
type LegiArticleLienNature, type LegiArticleLienNature,
type LegiArticleLienSens,
type LegiArticleLienType, type LegiArticleLienType,
type LegiArticleNature, type LegiArticleNature,
type LegiArticleOrigine, type LegiArticleOrigine,
type LegiArticleTexteNature, type LegiArticleTexteNature,
type LegiArticleType, type LegiArticleType,
} from "./legi" } from "./legi"
export { allSens, allSensMutable, type Sens } from "./shared"
export interface Article { export interface Article {
META: { META: {

View file

@ -1,3 +1,5 @@
import type { Sens } from "./shared"
export interface Jo { export interface Jo {
META: { META: {
META_COMMUN: { META_COMMUN: {
@ -116,9 +118,9 @@ export interface JorfArticleTm {
export type JorfArticleType = (typeof allJorfArticleTypes)[number] export type JorfArticleType = (typeof allJorfArticleTypes)[number]
export interface JorfSectionTa { export interface JorfSectionTa {
ID: string
COMMENTAIRE?: string COMMENTAIRE?: string
CONTEXTE: { CONTEXTE: {
ID: string
TEXTE: { TEXTE: {
"@autorite"?: string "@autorite"?: string
"@cid": string "@cid": string
@ -184,6 +186,120 @@ interface JorfSectionTaTm {
TM?: JorfSectionTaTm TM?: JorfSectionTaTm
} }
export interface JorfTextelr {
// TODO
}
export type JorfTextelrEtat = (typeof allJorfTextelrEtats)[number]
export type JorfTextelrLienArtEtat = (typeof allJorfTextelrLienArtEtats)[number]
export type JorfTextelrLienArtNature =
(typeof allJorfTextelrLienArtNatures)[number]
export type JorfTextelrLienArtOrigine =
(typeof allJorfTextelrLienArtOrigines)[number]
export type JorfTextelrNature = (typeof allJorfTextelrNatures)[number]
export type JorfTextelrOrigine = (typeof allJorfTextelrOrigines)[number]
export interface JorfTexteVersion {
ABRO?: {
CONTENU: string // HTML
}
ENTREPRISE?: {
"@texte_entreprise": "non" | "oui"
DATES_EFFET?: {
DATE_EFFET: string[]
}
DOMAINES?: {
DOMAINE: string[]
}
}
META: {
META_COMMUN: {
ANCIEN_ID?: string
ELI_ALIAS?: {
ID_ELI_ALIAS: string
}
ID: string
ID_ELI?: string
NATURE?: JorfTexteVersionNature
ORIGINE: JorfTexteVersionOrigine
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_VERSION: {
AUTORITE?: string
DATE_DEBUT: string
DATE_FIN: string
LIENS?: {
LIEN: {
"#text"?: string
"@cidtexte"?: string
"@datesignatexte"?: string
"@id"?: string
"@naturetexte"?: JorfTexteVersionLienNature
"@num"?: string
"@nortexte"?: string
"@numtexte"?: string
"@sens": Sens
"@typelien": JorfTexteVersionLienType
}
}
MCS_TXT?: {
MC: string[]
}
MINISTERE?: string
TITRE: string
TITREFULL: string
}
}
}
NOTICE?: {
CONTENU: string // HTML
}
RECT?: {
CONTENU: string // HTML
}
SIGNATAIRES?: {
CONTENU: string // HTML
}
SM?: {
CONTENU: string // HTML
}
TP?: {
CONTENU: string // HTML
}
VISAS?: {
CONTENU: string // HTML
}
}
export type JorfTexteVersionLienNature =
(typeof allJorfTexteVersionLienNatures)[number]
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 /// Table des matières (TM) d'un Journal officiel
export interface JoTm { export interface JoTm {
"@niv": number "@niv": number
@ -199,15 +315,15 @@ export const allJoOrigines = ["JORF"] as const
export const allJoOriginesMutable = [...allJoOrigines] export const allJoOriginesMutable = [...allJoOrigines]
export const allJorfArticleEtats = [ export const allJorfArticleEtats = [
"ABROGE",
"ABROGE_DIFF", "ABROGE_DIFF",
"ABROGE",
"ANNULE", "ANNULE",
"MODIFIE",
"MODIFIE_MORT_NE", "MODIFIE_MORT_NE",
"MODIFIE",
"PERIME", "PERIME",
"TRANSFERE", "TRANSFERE",
"VIGUEUR",
"VIGUEUR_DIFF", "VIGUEUR_DIFF",
"VIGUEUR",
] as const ] as const
export const allJorfArticleEtatsMutable = [...allJorfArticleEtats] export const allJorfArticleEtatsMutable = [...allJorfArticleEtats]
@ -353,3 +469,406 @@ export const allJorfSectionTaTexteNatures = [
export const allJorfSectionTaTexteNaturesMutable = [ export const allJorfSectionTaTexteNaturesMutable = [
...allJorfSectionTaTexteNatures, ...allJorfSectionTaTexteNatures,
] ]
export const allJorfTextelrEtats = [
"ABROGE_DIFF", // 129
"ABROGE", // 21890
"ANNULE", // 199
"MODIFIE_MORT_NE", // 24
"MODIFIE", // 3008
"PERIME", // 3127
"VIGUEUR_DIFF", // 103
"VIGUEUR", // 98711
] as const
export const allJorfTextelrEtatsMutable = [...allJorfTextelrEtats]
export const allJorfTextelrLienArtEtats = ["VIGUEUR"] as const
export const allJorfTextelrLienArtEtatsMutable = [...allJorfTextelrLienArtEtats]
export const allJorfTextelrLienArtNatures = [] as const
export const allJorfTextelrLienArtNaturesMutable = [
...allJorfTextelrLienArtNatures,
]
export const allJorfTextelrLienArtOrigines = ["JORF"] as const
export const allJorfTextelrLienArtOriginesMutable = [
...allJorfTextelrLienArtOrigines,
]
export const allJorfTextelrNatures = [
"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 allJorfTextelrNaturesMutable = [...allJorfTextelrNatures]
export const allJorfTextelrOrigines = ["JORF"] as const
export const allJorfTextelrOriginesMutable = [...allJorfTextelrOrigines]
export const allJorfTexteVersionLienNatures = [
"ABROGATION", // 5
"Accord autonome", // 3
"ACCORD CADRE", // 1
"Accord collectif national sectoriel", // 7
"Accord collectif national", // 50
"ACCORD COLLECTIF NATIONAL", // 57
"Accord collectif", // 6
"ACCORD DE BRANCHE", // 1
"Accord de branche", // 24
"Accord de champ", // 1
"Accord de convergence", // 3
"Accord de méthode", // 23
"Accord de rattachement", // 1
"Accord de substitution", // 12
"Accord du", // 1
"Accord interbranches", // 5
"Accord interprétatif", // 3
"Accord interprofessionnel départemental", // 1
"Accord interprofessionnel", // 8
"Accord national de branche", // 45
"Accord national interprofessionnel", // 6
"ACCORD NATIONAL PARITAIRE", // 16
"Accord national professionnel", // 1
"ACCORD NATIONAL PROFESSIONNEL", // 11
"ACCORD NATIONAL", // 101
"Accord national", // 20
"Accord paritaire national", // 4
"ACCORD PARITAIRE", // 5
"Accord paritaire", // 8
"ACCORD PROFESSIONNEL", // 4
"Accord professionnel", // 56
"Accord régional", // 2
"ACCORD_FONCTION_PUBLIQUE", // 12
"Accord-cadre interbranches", // 2
"ACCORD-CADRE", // 20
"Accord-cadre", // 7
"Accord-type", // 1
"ACCORD", // 1048
"accord", // 130
"Accord", // 22442
"ACTE", // 5
"Additif", // 24
"ADDITIF", // 39
"Adhésion par lettre", // 8
"Adhésion", // 1
"Annexe spécifique", // 2
"ANNEXE", // 149
"Annexe", // 367
"ANNEXES", // 3
"ANNONCES", // 4
"ARRET", // 48
"ARRETE", // 547820
"ARRETEEURO", // 15
"ARRETEURO", // 599
"ATTESTATION", // 2
"Avenant de révision", // 36
"Avenant rectificatif", // 1
"Avenant", // 18057
"avenant", // 185
"AVENANT", // 858
"AVIS D'INTERPRETATION", // 2
"Avis d'interprétation", // 8
"Avis interprétatif", // 4
"AVIS", // 30500
"AVISEURO", // 3645
"CIRCULAIRE", // 4362
"CODE", // 535600
"COMMUNIQUE", // 4
"COMPOSITION", // 7
"CONSTITUTION", // 13896
"Convention collective de travail", // 4
"Convention collective départementale", // 36
"CONVENTION COLLECTIVE INTERREGIONALE", // 217
"Convention collective interrégionale", // 7
"Convention collective nationale de travail", // 1
"CONVENTION COLLECTIVE NATIONALE", // 6
"Convention collective nationale", // 6077
"Convention collective régionale", // 148
"convention collective", // 106
"CONVENTION COLLECTIVE", // 148
"Convention collective", // 666
"Convention de référencement", // 1
"Convention", // 1
"CONVENTION", // 329
"DECISION_CC", // 116
"DECISION_EURO", // 243
"Décision", // 1
"DECISION", // 109937
"DECLARATION", // 8
"DECRET_LOI", // 2061
"DECRET", // 747993
"Délibération", // 1
"DELIBERATION", // 10824
"DELIBERATIONEURO", // 26
"Dénonciation par lettre", // 3
"Dénonciation", // 2
"DIRECTIVE_EURO", // 22593
"DIRECTIVE", // 43
"ELECTIONDUPRESIDENTDELAREPUBLIQU", // 6
"INFORMATION", // 26
"INFORMATIONS_DIVERSES", // 16
"INFORMATIONS_PARLEMENTAIRES", // 2576
"INSTRUCTION", // 218
"INSTRUCTIONEURO", // 700
"Lettre de dénonciation", // 1
"LETTREEURO", // 5
"LISTE", // 262
"LOI_CONSTIT", // 30
"LOI_ORGANIQUE", // 2899
"LOI_PROGRAMME", // 55
"LOI", // 216342
"MEMOIRE", // 21
"MODIFICATION", // 125
"NOTE", // 3
"OBSERVATION", // 256
"ORDONNANCE", // 35340
"Procès-verbal de désaccord", // 4
"PROJET", // 93
"PROTOCOLE D'ACCORD COLLECTIF", // 7
"Protocole d'accord de méthode", // 1
"PROTOCOLE D'ACCORD INTERBRANCHE", // 3
"Protocole D'accord", // 1
"PROTOCOLE D'ACCORD", // 33
"Protocole d'accord", // 62
"Protocole", // 55
"PROTOCOLE", // 7
"PUBLICATION", // 1
"RAPPORT", // 1756
"Recommandation patronale", // 2
"RECOMMANDATION_EURO", // 1
"RECOMMANDATION", // 243
"Rectificatif au Bulletin officiel n°", // 4
"REGLEMENT", // 800
"REGLEMENTEUROPEEN", // 1897
"RESULTATS", // 3901
"SAISINE", // 352
"SALAIRES", // 4
"SENATUS", // 4
"SUSPENSION", // 1
"TABLEAU", // 12
] as const
export const allJorfTexteVersionLienNaturesMutable = [
...allJorfTexteVersionLienNatures,
]
export const allJorfTexteVersionLienTypes = [
"ABROGATION", // 34942
"ABROGE", // 72512
"ANNULATION", // 381
"ANNULE", // 32
"APPLICATION", // 294702
"CITATION", // 1220159
"CODIFICATION", // 249655
"CONCORDANCE", // 27893
"CONCORDE", // 328
"CREATION", // 44426
"CREE", // 1
"DENONCE", // 1
"DISJOINT", // 2
"DISJONCTION", // 1
"ELARGISSEMENT", // 10
"ETEND", // 40707
"EXTENSION", // 1002
"HISTO", // 2
"MODIFICATION", // 39581
"MODIFIE", // 277772
"PEREMPTION", // 1559
"PERIME", // 2
"RATIFICATION", // 3
"RATIFIE", // 342
"RATTACHEMENT", // 1
"RECTIFICATION", // 762
"RENVOI", // 1
"RENVOIT", // 811
"SPEC_APPLI", // 29805
"TEXTE_SUITE", // 74
"TRANSFERT", // 981
"TRANSPOSITION", // 6513
"TXT_ASSOCIE", // 11821
"TXT_SOURCE", // 81350
] as const
export const allJorfTexteVersionLienTypesMutable = [
...allJorfTexteVersionLienTypes,
]
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 allJorfTexteVersionNaturesMutable = [...allJorfTexteVersionNatures]
export const allJorfTexteVersionOrigines = ["JORF"] as const
export const allJorfTexteVersionOriginesMutable = [
...allJorfTexteVersionOrigines,
]

View file

@ -1,3 +1,5 @@
import type { Sens } from "./shared"
export interface LegiArticle { export interface LegiArticle {
BLOC_TEXTUEL?: { BLOC_TEXTUEL?: {
CONTENU: string // HTML CONTENU: string // HTML
@ -32,7 +34,7 @@ export interface LegiArticle {
"@naturetexte"?: LegiArticleLienNature "@naturetexte"?: LegiArticleLienNature
"@nortexte"?: string "@nortexte"?: string
"@num"?: string "@num"?: string
"@sens": LegiArticleLienSens "@sens": Sens
"@typelien": LegiArticleLienType "@typelien": LegiArticleLienType
}> }>
} }
@ -79,8 +81,6 @@ export type LegiArticleLienArticleOrigine =
export type LegiArticleLienNature = (typeof allLegiArticleLienNatures)[number] export type LegiArticleLienNature = (typeof allLegiArticleLienNatures)[number]
export type LegiArticleLienSens = (typeof allLegiArticleLienSens)[number]
export type LegiArticleLienType = (typeof allLegiArticleLienTypes)[number] export type LegiArticleLienType = (typeof allLegiArticleLienTypes)[number]
export type LegiArticleNature = (typeof allLegiArticleNatures)[number] export type LegiArticleNature = (typeof allLegiArticleNatures)[number]
@ -154,9 +154,6 @@ export const allLegiArticleLienNatures = [
] as const ] as const
export const allLegiArticleLienNaturesMutable = [...allLegiArticleLienNatures] export const allLegiArticleLienNaturesMutable = [...allLegiArticleLienNatures]
export const allLegiArticleLienSens = ["cible", "source"] as const
export const allLegiArticleLienSensMutable = [...allLegiArticleLienSens]
export const allLegiArticleLienTypes = [ export const allLegiArticleLienTypes = [
"ABROGATION", // 237556 "ABROGATION", // 237556
"ABROGE", // 480524 "ABROGE", // 480524

4
src/lib/legal/shared.ts Normal file
View file

@ -0,0 +1,4 @@
export type Sens = (typeof allSens)[number]
export const allSens = ["cible", "source"] as const
export const allSensMutable = [...allSens]

View file

@ -17,16 +17,20 @@ import {
auditJo, auditJo,
auditJorfArticle, auditJorfArticle,
auditJorfSectionTa, auditJorfSectionTa,
auditJorfTextelr,
auditJorfTexteVersion,
// jorfArticleStats, // jorfArticleStats,
jorfSectionTaStats, // jorfSectionTaStats,
// joStats, // joStats,
jorfTextelrStats,
// jorfTexteVersionStats,
} from "$lib/auditors/jorf" } from "$lib/auditors/jorf"
import type { import type {
Jo, Jo,
JorfArticle, JorfArticle,
JorfSectionTa, JorfSectionTa,
Textelr, JorfTextelr,
TexteVersion, JorfTexteVersion,
Versions, Versions,
XmlHeader, XmlHeader,
} from "$lib/legal" } from "$lib/legal"
@ -196,8 +200,8 @@ async function importJorf(
| Jo | Jo
| JorfArticle | JorfArticle
| JorfSectionTa | JorfSectionTa
| Textelr | JorfTextelr
| TexteVersion | JorfTexteVersion
| Versions | Versions
| XmlHeader | XmlHeader
), ),
@ -334,7 +338,19 @@ async function importJorf(
break break
case "TEXTE_VERSION": case "TEXTE_VERSION":
if (categoryTag === undefined || categoryTag === tag) { if (categoryTag === undefined || categoryTag === tag) {
const texteVersion = element as TexteVersion const [texteVersion, error] = auditChain(
auditJorfTexteVersion,
auditRequire,
)(strictAudit, element) as [JorfTexteVersion, unknown]
assert.strictEqual(
error,
null,
`Unexpected format for TEXTE_VERSION:\n${JSON.stringify(
texteVersion,
null,
2,
)}\nError:\n${JSON.stringify(error, null, 2)}`,
)
const textAFragments = [ const textAFragments = [
texteVersion.META.META_SPEC.META_TEXTE_VERSION.TITRE, texteVersion.META.META_SPEC.META_TEXTE_VERSION.TITRE,
texteVersion.META.META_SPEC.META_TEXTE_VERSION.TITREFULL, texteVersion.META.META_SPEC.META_TEXTE_VERSION.TITREFULL,
@ -348,7 +364,7 @@ async function importJorf(
) VALUES ( ) VALUES (
${texteVersion.META.META_COMMUN.ID}, ${texteVersion.META.META_COMMUN.ID},
${db.json(texteVersion as unknown as JSONValue)}, ${db.json(texteVersion as unknown as JSONValue)},
${texteVersion.META.META_COMMUN.NATURE}, ${texteVersion.META.META_COMMUN.NATURE ?? null},
setweight(to_tsvector('french', ${textAFragments.join( setweight(to_tsvector('french', ${textAFragments.join(
" ", " ",
)}), 'A') )}), 'A')
@ -356,7 +372,7 @@ async function importJorf(
ON CONFLICT (id) ON CONFLICT (id)
DO UPDATE SET DO UPDATE SET
data = ${db.json(texteVersion as unknown as JSONValue)}, data = ${db.json(texteVersion as unknown as JSONValue)},
nature = ${texteVersion.META.META_COMMUN.NATURE}, nature = ${texteVersion.META.META_COMMUN.NATURE ?? null},
text_search = setweight(to_tsvector('french', ${textAFragments.join( text_search = setweight(to_tsvector('french', ${textAFragments.join(
" ", " ",
)}), 'A') )}), 'A')
@ -366,7 +382,19 @@ async function importJorf(
break break
case "TEXTELR": case "TEXTELR":
if (categoryTag === undefined || categoryTag === tag) { if (categoryTag === undefined || categoryTag === tag) {
const textelr = element as Textelr const [textelr, error] = auditChain(
auditJorfTextelr,
auditRequire,
)(strictAudit, element) as [JorfTextelr, unknown]
assert.strictEqual(
error,
null,
`Unexpected format for TEXTELR:\n${JSON.stringify(
textelr,
null,
2,
)}\nError:\n${JSON.stringify(error, null, 2)}`,
)
await db` await db`
INSERT INTO textelr ( INSERT INTO textelr (
id, id,
@ -490,10 +518,15 @@ async function importJorf(
// JSON.stringify(jorfArticleStats, null, 2), // JSON.stringify(jorfArticleStats, null, 2),
// ) // )
// console.log("JO stats =", JSON.stringify(joStats, null, 2)) // console.log("JO stats =", JSON.stringify(joStats, null, 2))
console.log( // console.log(
"JORF SECTION_TA stats =", // "JORF SECTION_TA stats =",
JSON.stringify(jorfSectionTaStats, null, 2), // JSON.stringify(jorfSectionTaStats, null, 2),
) // )
console.log("JORF TEXTELR stats =", JSON.stringify(jorfTextelrStats, null, 2))
// console.log(
// "JORF TEXTE_VERSION stats =",
// JSON.stringify(jorfTexteVersionStats, null, 2),
// )
} }
sade("import_jorf <dilaDir>", true) sade("import_jorf <dilaDir>", true)