-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: mise en place DECA Raw de BAL (#3817)
Co-authored-by: Paul G. <[email protected]> Co-authored-by: Paul Gaucher <[email protected]>
- Loading branch information
1 parent
a5e79a0
commit 296b1cc
Showing
4 changed files
with
159 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import type { CreateIndexesOptions, IndexSpecification } from "mongodb"; | ||
import { z } from "zod"; | ||
import { zObjectId } from "zod-mongodb-schema"; | ||
|
||
// Collection name | ||
const collectionName = "airbyte_raw_bal_deca"; | ||
|
||
// Indexes | ||
const indexes: [IndexSpecification, CreateIndexesOptions][] = [ | ||
[{ statut: 1 }, {}], | ||
[{ "employeur.siret": 1 }, { unique: false }], | ||
[{ "formation.code_diplome": 1 }, { unique: false }], | ||
[{ created_at: 1 }, { unique: false }], | ||
]; | ||
|
||
// Address schema | ||
const zAdresse = z.object({ | ||
voie: z.string().optional(), | ||
code_postal: z.string(), | ||
numero: z.string().optional(), | ||
}); | ||
|
||
// Alternant schema | ||
const zAlternant = z.object({ | ||
nom: z.string(), | ||
prenom: z.string(), | ||
sexe: z.string(), | ||
date_naissance: z.string().describe("Date de naissance de l'alternant").nullish(), | ||
departement_naissance: z.string(), | ||
nationalite: z.number(), | ||
handicap: z.boolean(), | ||
courriel: z.string(), | ||
telephone: z.string(), | ||
adresse: zAdresse, | ||
derniere_classe: z.number(), | ||
}); | ||
|
||
// Employeur schema | ||
const zEmployeur = z.object({ | ||
siret: z.string(), | ||
denomination: z.string(), | ||
adresse: zAdresse.pick({ code_postal: true }), | ||
naf: z.string(), | ||
code_idcc: z.string(), | ||
nombre_de_salaries: z.number(), | ||
courriel: z.string().optional(), | ||
telephone: z.string().optional(), | ||
}); | ||
|
||
// Formation schema | ||
const zFormation = z.object({ | ||
code_diplome: z.string(), | ||
rncp: z.string(), | ||
intitule_ou_qualification: z.string(), | ||
type_diplome: z.string(), | ||
date_debut_formation: z.string().describe("Date de début de la formation").nullish(), | ||
date_fin_formation: z.string().describe("Date de fin de la formation").nullish(), | ||
}); | ||
|
||
// Organisme formation schema | ||
const zOrganismeFormation = z.object({ | ||
siret: z.string(), | ||
uai_cfa: z.string(), | ||
}); | ||
|
||
// Main schema for the airbyte data | ||
const zAirbyteData = z.object({ | ||
_id: z.string(), | ||
no_contrat: z.string(), | ||
type_contrat: z.string(), | ||
alternant: zAlternant, | ||
date_debut_contrat: z.string().describe("Date de début du contrat").nullish(), | ||
date_fin_contrat: z.string().describe("Date de fin du contrat").nullish(), | ||
date_effet_rupture: z.string().describe("Date d'effet de la rupture du contrat").nullish(), | ||
dispositif: z.string(), | ||
employeur: zEmployeur, | ||
organisme_formation: zOrganismeFormation, | ||
formation: zFormation, | ||
created_at: z.string().describe("Date de création de l'enregistrement dans la base de données").nullish(), | ||
updated_at: z.string().describe("Date de dernière mise à jour de l'enregistrement dans la base de données").nullish(), | ||
_ab_cdc_updated_at: z.string().optional(), | ||
_ab_cdc_cursor: z | ||
.object({ | ||
$numberLong: z.string(), | ||
}) | ||
.optional(), | ||
_ab_cdc_deleted_at: z.null().optional(), | ||
}); | ||
|
||
const zAirbyteRawBalDeca = z.object({ | ||
_id: zObjectId.describe("Identifiant MongoDB de l'enregistrement"), | ||
_airbyte_data: zAirbyteData, | ||
_airbyte_data_hash: z.string(), | ||
_airbyte_emitted_at: z.string().describe("Date à laquelle les données ont été émises").optional(), | ||
}); | ||
|
||
// Define the type | ||
export type IAirbyteRawBalDeca = z.infer<typeof zAirbyteRawBalDeca>; | ||
|
||
export default { zod: zAirbyteRawBalDeca, indexes, collectionName }; |