Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| documentation_technique_scripts [2025/05/19 16:59] – ctisserand | documentation_technique_scripts [2025/05/20 16:38] (Version actuelle) – ctisserand | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| - | # Demonstration | + | ====== Documentation pour écrire un script custom (LUA) ====== |
| + | |||
| + | < | ||
| + | # Squelette du script | ||
| ``` | ``` | ||
| -- script title | -- script title | ||
| Ligne 19: | Ligne 22: | ||
| return true or false | return true or false | ||
| ``` | ``` | ||
| - | # Titre | + | # Titre du script |
| ``` | ``` | ||
| --- country_alpha2 = title | --- country_alpha2 = title | ||
| Ligne 35: | Ligne 38: | ||
| Si la langue cible n'est pas disponible, EN est utilisé, sinon le premier disponible est utilisé | Si la langue cible n'est pas disponible, EN est utilisé, sinon le premier disponible est utilisé | ||
| - | # Paramètre | + | # Paramètres |
| ``` | ``` | ||
| --% module | country_alpha2 = name | country_alpha2 = name | --% module | country_alpha2 = name | country_alpha2 = name | ||
| Ligne 48: | Ligne 51: | ||
| Il ne sert pas a définir les tests (cf. Module), ils servent a définir le comportement du code | Il ne sert pas a définir les tests (cf. Module), ils servent a définir le comportement du code | ||
| - | # Module | + | # Modules (référence pour les script) |
| ``` | ``` | ||
| Ligne 59: | Ligne 62: | ||
| Il définissent les tests qui seront enregistrés dans le rapport archivé | Il définissent les tests qui seront enregistrés dans le rapport archivé | ||
| - | Une référence peut être utilisé plusieur | + | Une référence peut être utilisée plusieurs |
| - | Le nom final d'une référence est consitué de tous ces composant nécéssaire | + | Le nom final d'une référence est consitué de tous ces composants nécéssaires |
| exemple | exemple | ||
| Ligne 70: | Ligne 73: | ||
| # Services | # Services | ||
| - | Un service | + | Un service |
| + | |||
| + | Ci-dessous la liste des services disponibles ainsi que leur documentation extraite automatiquement | ||
| Exemple: | Exemple: | ||
| Ligne 77: | Ligne 82: | ||
| services.email.verify(input.data.email[0], | services.email.verify(input.data.email[0], | ||
| ``` | ``` | ||
| - | ## country | + | |
| ``` | ``` | ||
| - | country_exists(country: Any) | + | services.email.verify(email: Any, check_mx: Any = True, check_server_respond: |
| ``` | ``` | ||
| - | From the name of a country, find all the real country that match the name | + | Verify |
| - | - country: Name of the country to search | + | - email: the email address |
| + | - check_mx: Check if an MX entry exist for this domain. True by default | ||
| + | - check_server_respond: | ||
| ## inpi | ## inpi | ||
| ``` | ``` | ||
| - | by_siret(siret: | + | services.inpi.by_siret(siret: |
| ``` | ``` | ||
| Get the information on a company from INPI | Get the information on a company from INPI | ||
| Ligne 94: | Ligne 101: | ||
| ``` | ``` | ||
| - | by_siren(siren: | + | services.inpi.by_siren(siren: |
| ``` | ``` | ||
| Get the information on a company from INPI | Get the information on a company from INPI | ||
| Ligne 100: | Ligne 107: | ||
| - siren: the SIREN number of the company | - siren: the SIREN number of the company | ||
| - | + | ## country | |
| ``` | ``` | ||
| - | verify(email: Any, check_mx: Any = True, check_server_respond: | + | services.country.country_exists(country: Any) |
| ``` | ``` | ||
| - | Verify | + | From the name of a country, find all the real country that match the name |
| - | - email: the email address | + | - country: Name of the country to search |
| - | - check_mx: Check if an MX entry exist for this domain. True by default | + | |
| - | - check_server_respond: | + | |
| - | # Données | + | # Données |
| - | Les données | + | Les données |
| - data: dict[field_name, | - data: dict[field_name, | ||
| Ligne 120: | Ligne 125: | ||
| local name = input.data.name | local name = input.data.name | ||
| ``` | ``` | ||
| - | # Données pouvant | + | # Données pouvant |
| - | Les données | + | Les données |
| - identity: PersonalDetails | - identity: PersonalDetails | ||
| Ligne 132: | Ligne 137: | ||
| output.valid[doc.name] = true | output.valid[doc.name] = true | ||
| ``` | ``` | ||
| - | # Functions | + | # Functions |
| + | ## check | ||
| + | ``` | ||
| + | check( | ||
| + | doc: PersonalDetails | MRZDocument | DocumentWrapper | ||
| + | field: str | list[str] | ||
| + | fn: bool (list[str] | Any) | ||
| + | ref: str | ||
| + | parse: bool = False | ||
| + | hide: bool = False | ||
| + | all_values: | ||
| + | ) | ||
| + | ``` | ||
| + | Verify the validity of a field with the function given | ||
| + | - doc: a DocumentWrapper, | ||
| + | - field: standardize field name or a list of standardize field name to get from the document | ||
| + | - fn: the function to verify the validity of the data | ||
| + | - ref: a description to indicate the verification done for the report | ||
| + | - parse: True to try to parse the data before giving it to the function, False to have a string. If a PersonalDetails is or MRZDocument is given the value is already parsed | ||
| + | - hide: True to hide this verification from the report | ||
| + | - all_values: If False, the first value to return true is used, else every value must return true | ||
| + | |||
| + | ## check_concat | ||
| + | ``` | ||
| + | check_concat( | ||
| + | doc: DocumentWrapper | ||
| + | field: str | list[str] | ||
| + | fn: bool (list[str] | Any) | ||
| + | ref: str | ||
| + | hide: bool = False | ||
| + | parse: bool = False | ||
| + | allow_missing_field: | ||
| + | ) | ||
| + | ``` | ||
| + | Verify the validity of the concatenation of multiple field with the function given | ||
| + | - doc: a DocumentWrapper to get the value from | ||
| + | - field: standardize field name or a list of standardize field name to get from the document | ||
| + | - fn: the function to verify the validity of the data | ||
| + | - ref: a description to indicate the verification done for the report | ||
| + | - hide: True to hide this verification from the report | ||
| + | - parse: True to try to parse the data before giving it to the function, False to have a string | ||
| + | - allow_missing_field: | ||
| ## compare | ## compare | ||
| ``` | ``` | ||
| Ligne 158: | Ligne 205: | ||
| - hide: True if the verification is valid | - hide: True if the verification is valid | ||
| - | ## save_error | + | ## contains |
| ``` | ``` | ||
| - | save_error( | + | contains( |
| - | codes: list[tuple[EnrollmentStatusCodeEnum | str] | ErrorCodeException | EnrollmentStatusCode] | + | _list: list[Any] |
| + | item: Any | ||
| ) | ) | ||
| ``` | ``` | ||
| - | + | Test if y is contains in x | |
| - | - codes: save an instance of EnrollmentStatusCode or ErrorCodeException or (EnrollmentStatusCodeEnum, | + | - _list: Any list |
| - | + | - item: the item to find | |
| - | ## create_date_mask | + | |
| - | ``` | + | |
| - | create_date_mask( | + | |
| - | d: str | + | |
| - | date_format: | + | |
| - | ) | + | |
| - | ``` | + | |
| - | Create a valid mask for the date given (ex: 1990 -> YYYY, 901212 -> YYMMDD) | + | |
| - | - d: the date as a string | + | |
| - | - date_format: | + | |
| - | + | ||
| - | ## error_type | + | |
| - | ``` | + | |
| - | error_type( | + | |
| - | error: Exception | + | |
| - | ) | + | |
| - | ``` | + | |
| - | Get the name of a python exception | + | |
| - | - error: The exception to have the name from | + | |
| - | + | ||
| - | ## to_lua | + | |
| - | ``` | + | |
| - | to_lua( | + | |
| - | x: Any | + | |
| - | ) | + | |
| - | ``` | + | |
| - | convert an object from python to LUA | + | |
| - | - x: a python compatible object | + | |
| - | + | ||
| - | ## check | + | |
| - | ``` | + | |
| - | check( | + | |
| - | doc: PersonalDetails | MRZDocument | DocumentWrapper | + | |
| - | field: str | list[str] | + | |
| - | fn: bool (list[str] | Any) | + | |
| - | ref: str | + | |
| - | parse: bool = False | + | |
| - | hide: bool = False | + | |
| - | all_values: | + | |
| - | ) | + | |
| - | ``` | + | |
| - | Verify the validity of a field with the function given | + | |
| - | - doc: a DocumentWrapper, | + | |
| - | - field: standardize field name or a list of standardize field name to get from the document | + | |
| - | - fn: the function | + | |
| - | - ref: a description to indicate the verification done for the report | + | |
| - | - parse: True to try to parse the data before giving it to the function, False to have a string. If a PersonalDetails is or MRZDocument is given the value is already parsed | + | |
| - | - hide: True to hide this verification from the report | + | |
| - | - all_values: If False, the first value to return true is used, else every value must return true | + | |
| - | + | ||
| - | ## is_available | + | |
| - | ``` | + | |
| - | is_available( | + | |
| - | doc: DocumentWrapper | + | |
| - | field: str | + | |
| - | ) | + | |
| - | ``` | + | |
| - | Determine if the field is available in a document | + | |
| - | - doc: a DocumentWrapper to get the value from | + | |
| - | - field: standardize field name to get from the document | + | |
| ## correct | ## correct | ||
| Ligne 247: | Ligne 235: | ||
| - hide: True to hide this correction from the report | - hide: True to hide this correction from the report | ||
| - | ## contains | + | ## create_date_mask |
| ``` | ``` | ||
| - | contains( | + | create_date_mask( |
| - | _list: list[Any] | + | d: str |
| - | item: Any | + | date_format: Any = " |
| ) | ) | ||
| ``` | ``` | ||
| - | Test if y is contains in x | + | Create a valid mask for the date given (ex: 1990 -> YYYY, 901212 -> YYMMDD) |
| - | - _list: Any list | + | - d: the date as a string |
| - | - item: the item to find | + | - date_format: the format of the date to parse |
| ## custom_info | ## custom_info | ||
| Ligne 275: | Ligne 263: | ||
| - score: if used, indicate the score obtain with this verification | - score: if used, indicate the score obtain with this verification | ||
| - | ## check_concat | + | ## error_type |
| ``` | ``` | ||
| - | check_concat( | + | error_type( |
| - | doc: DocumentWrapper | + | error: Exception |
| - | field: str | list[str] | + | |
| - | fn: bool (list[str] | Any) | + | |
| - | ref: str | + | |
| - | hide: bool = False | + | |
| - | parse: bool = False | + | |
| - | allow_missing_field: | + | |
| ) | ) | ||
| ``` | ``` | ||
| - | Verify | + | Get the name of a python exception |
| - | - doc: a DocumentWrapper to get the value from | + | - error: The exception |
| - | - field: standardize field name or a list of standardize field name to get from the document | + | |
| - | - fn: the function to verify the validity of the data | + | |
| - | - ref: a description to indicate the verification done for the report | + | |
| - | - hide: True to hide this verification from the report | + | |
| - | - parse: True to try to parse the data before giving it to the function, False to have a string | + | |
| - | - allow_missing_field: | + | |
| - | + | ||
| - | ## get_value | + | |
| - | ``` | + | |
| - | get_value( | + | |
| - | doc: DocumentWrapper | + | |
| - | field: str | list[str] | + | |
| - | parse: bool = False | + | |
| - | ) | + | |
| - | ``` | + | |
| - | Get the value of a field in a document | + | |
| - | - doc: a DocumentWrapper to get the value from | + | |
| - | - field: standardize field name or a list of standardize field name to get from the document | + | |
| - | - parse: True to try to parse the result, False to have a string | + | |
| - | + | ||
| - | ## parse_date | + | |
| - | ``` | + | |
| - | parse_date( | + | |
| - | + | ||
| - | ) | + | |
| - | ``` | + | |
| ## fuzzy | ## fuzzy | ||
| Ligne 338: | Ligne 293: | ||
| Make a python coroutine usable. Available: #(...), .first(), .all() | Make a python coroutine usable. Available: #(...), .first(), .all() | ||
| - co: Python coroutine to use | - co: Python coroutine to use | ||
| + | |||
| + | ## get_value | ||
| + | ``` | ||
| + | get_value( | ||
| + | doc: DocumentWrapper | ||
| + | field: str | list[str] | ||
| + | parse: bool = False | ||
| + | ) | ||
| + | ``` | ||
| + | Get the value of a field in a document | ||
| + | - doc: a DocumentWrapper to get the value from | ||
| + | - field: standardize field name or a list of standardize field name to get from the document | ||
| + | - parse: True to try to parse the result, False to have a string | ||
| + | |||
| + | ## is_available | ||
| + | ``` | ||
| + | is_available( | ||
| + | doc: DocumentWrapper | ||
| + | field: str | ||
| + | ) | ||
| + | ``` | ||
| + | Determine if the field is available in a document | ||
| + | - doc: a DocumentWrapper to get the value from | ||
| + | - field: standardize field name to get from the document | ||
| ## list | ## list | ||
| Ligne 347: | Ligne 326: | ||
| convert a list from lua to python | convert a list from lua to python | ||
| - x: a LUA compatible list | - x: a LUA compatible list | ||
| + | |||
| + | ## parse_date | ||
| + | ``` | ||
| + | parse_date( | ||
| + | |||
| + | ) | ||
| + | ``` | ||
| + | |||
| + | |||
| + | ## save_error | ||
| + | ``` | ||
| + | save_error( | ||
| + | codes: list[tuple[EnrollmentStatusCodeEnum | str] | ErrorCodeException | EnrollmentStatusCode] | ||
| + | ) | ||
| + | ``` | ||
| + | |||
| + | - codes: save an instance of EnrollmentStatusCode or ErrorCodeException or (EnrollmentStatusCodeEnum, | ||
| ## throw | ## throw | ||
| Ligne 358: | Ligne 354: | ||
| - code: One of EnrollmentStatusCodeEnum possibility | - code: One of EnrollmentStatusCodeEnum possibility | ||
| - msg: A text to join with the code | - msg: A text to join with the code | ||
| + | |||
| + | ## to_lua | ||
| + | ``` | ||
| + | to_lua( | ||
| + | x: Any | ||
| + | ) | ||
| + | ``` | ||
| + | convert an object from python to LUA | ||
| + | - x: a python compatible object | ||
| # Enums | # Enums | ||
| Ligne 405: | Ligne 410: | ||
| - CG_FR_V1 | - CG_FR_V1 | ||
| - | # Other | ||
| - | ``` | ||
| - | services: object | ||
| - | ``` | ||
| - | ``` | ||
| - | output: object | ||
| - | ``` | ||
| - | ``` | ||
| - | MRZ_TYPES: dict[MRZDocumentType | IdentityDocument] | ||
| - | ``` | ||
| # Lua modules allowed | # Lua modules allowed | ||
| - | - pcall | + | - _G |
| + | - _VERSION | ||
| + | - assert | ||
| + | - bit | ||
| + | - collectgarbage | ||
| - coroutine | - coroutine | ||
| - | - assert | + | - debug |
| - | - tostring | + | - error |
| - | - tonumber | + | - math |
| - | + | ||
| - module | - module | ||
| - | - bit | + | - next |
| + | - os | ||
| + | - date | ||
| + | - difftime | ||
| + | - time | ||
| - package | - package | ||
| - | - error | + | - pairs |
| - | - debug | + | - pcall |
| + | |||
| - rawequal | - rawequal | ||
| - | - unpack | + | - string |
| - | - pairs | + | |
| - table | - table | ||
| - | - next | + | - tonumber |
| - | - math | + | - tostring |
| - | - _G | + | |
| - | - _VERSION | + | |
| - | - string | + | |
| - type | - type | ||
| + | - unpack | ||
| - utf8 | - utf8 | ||
| - | - collectgarbage | ||
| - | - os | ||
| - | - date | ||
| - | - time | ||
| - | - difftime | ||
| - | # Extracted Data Classes | + | # Définition des classes utilisés pour les données pivots |
| - | ## PROOF_OF_AGE | + | |
| - | ``` | + | |
| - | PROOF_OF_AGE( | + | |
| - | services: dict[str | dict] | null, | + | |
| - | is_of_age: bool | null, | + | |
| - | minimum_age: | + | |
| - | ) | + | |
| - | ``` | + | |
| ## BANK_DETAILS | ## BANK_DETAILS | ||
| ``` | ``` | ||
| Ligne 531: | Ligne 518: | ||
| ) | ) | ||
| ``` | ``` | ||
| - | ## HEALTH_INSURANCE_CARD | + | ## DIGITAL_IDENTITY |
| ``` | ``` | ||
| - | HEALTH_INSURANCE_CARD( | + | DIGITAL_IDENTITY( |
| - | services: dict[str | dict] | null, | + | |
| - | full_name: str | null, | + | |
| - | amc: str | null, | + | |
| - | csr: str | null, | + | |
| - | adherent_number: | + | |
| - | convention: | + | |
| - | starting_date: | + | |
| - | ending_date: | + | |
| - | ) | + | |
| - | ``` | + | |
| - | ## IDENTITY_DOCUMENT | + | |
| - | ``` | + | |
| - | IDENTITY_DOCUMENT( | + | |
| services: dict[str | dict] | null, | services: dict[str | dict] | null, | ||
| type: str | null, | type: str | null, | ||
| Ligne 575: | Ligne 549: | ||
| ) | ) | ||
| ``` | ``` | ||
| - | ### IDENTITY_DOCUMENT_EXTRA | + | ### DIGITAL_IDENTITY_EXTRA |
| ``` | ``` | ||
| - | IDENTITY_DOCUMENT_EXTRA( | + | DIGITAL_IDENTITY_EXTRA( |
| id_number: str | null, | id_number: str | null, | ||
| issuing_date: | issuing_date: | ||
| Ligne 592: | Ligne 566: | ||
| ) | ) | ||
| ``` | ``` | ||
| - | ## DIGITAL_IDENTITY | + | ## HEALTH_INSURANCE_CARD |
| ``` | ``` | ||
| - | DIGITAL_IDENTITY( | + | HEALTH_INSURANCE_CARD( |
| + | services: dict[str | dict] | null, | ||
| + | full_name: str | null, | ||
| + | amc: str | null, | ||
| + | csr: str | null, | ||
| + | adherent_number: | ||
| + | convention: | ||
| + | starting_date: | ||
| + | ending_date: | ||
| + | ) | ||
| + | ``` | ||
| + | ## IDENTITY | ||
| + | ``` | ||
| + | IDENTITY( | ||
| services: dict[str | dict] | null, | services: dict[str | dict] | null, | ||
| type: str | null, | type: str | null, | ||
| Ligne 623: | Ligne 610: | ||
| ) | ) | ||
| ``` | ``` | ||
| - | ### DIGITAL_IDENTITY_EXTRA | + | ### IDENTITY_EXTRA |
| ``` | ``` | ||
| - | DIGITAL_IDENTITY_EXTRA( | + | IDENTITY_EXTRA( |
| id_number: str | null, | id_number: str | null, | ||
| issuing_date: | issuing_date: | ||
| Ligne 640: | Ligne 627: | ||
| ) | ) | ||
| ``` | ``` | ||
| - | ## IDENTITY | + | ## IDENTITY_DOCUMENT |
| ``` | ``` | ||
| - | IDENTITY( | + | IDENTITY_DOCUMENT( |
| services: dict[str | dict] | null, | services: dict[str | dict] | null, | ||
| type: str | null, | type: str | null, | ||
| Ligne 671: | Ligne 658: | ||
| ) | ) | ||
| ``` | ``` | ||
| - | ### IDENTITY_EXTRA | + | ### IDENTITY_DOCUMENT_EXTRA |
| ``` | ``` | ||
| - | IDENTITY_EXTRA( | + | IDENTITY_DOCUMENT_EXTRA( |
| id_number: str | null, | id_number: str | null, | ||
| issuing_date: | issuing_date: | ||
| Ligne 755: | Ligne 742: | ||
| dmx_city: str | null, | dmx_city: str | null, | ||
| dmx_date: null | dmx_date: null | ||
| + | ) | ||
| + | ``` | ||
| + | ## PROOF_OF_AGE | ||
| + | ``` | ||
| + | PROOF_OF_AGE( | ||
| + | services: dict[str | dict] | null, | ||
| + | is_of_age: bool | null, | ||
| + | minimum_age: | ||
| ) | ) | ||
| ``` | ``` | ||
| Ligne 788: | Ligne 783: | ||
| ) | ) | ||
| ``` | ``` | ||
| - | # Classes | + | # Définition des objets utilisés dans les scripts |
| ## DocumentWrapper | ## DocumentWrapper | ||
| - | - document: Document | + | - document |
| - | - name: str | + | - name |
| - | - iteration: int | None | + | - iteration |
| - | - mode: DocumentWrapperModeEnum | + | - mode |
| - | - engine: EngineTypes | + | - engine |
| - | - type: list[DocumentTypeEnum] | + | - type |
| - | - content: dict | null | + | - content |
| - | - input_documents: list[Document] | + | - input_documents |
| - | - is_internal: bool | + | - is_internal |
| - | - step_step_documents: list[StepStepDocument] | + | - step_step_documents |
| - | - ignore_validation: bool | + | - ignore_validation |
| - | - tags: list[object] | + | - tags |
| - | - is_valid: bool | null | + | - is_valid |
| - | - document_provider: str | null | + | - document_provider |
| - | - enrollment_steps: list[EnrollmentStep] | + | - enrollment_steps |
| ## EnrollmentStatusCode | ## EnrollmentStatusCode | ||
| - | ## IdentityExtractedDataExtra | + | - id |
| - | - id_number: str | null | + | - code |
| - | - issuing_date: | + | - message |
| - | - expiration_date: | + | - step |
| - | - issuing_country: | + | - external_method_step |
| - | - issuer: str | null | + | - enrollment |
| - | - address: str | null | + | - validation |
| - | - dmx_id_number: | + | - document |
| - | - dmx_signature_status: | + | |
| - | - mrz_line_1: str | null | + | |
| - | - mrz_line_2: str | null | + | |
| - | - mrz_line_3: str | null | + | |
| - | - nfc_compatible: | + | |
| + | - pk: _empty | ||
| + | |||
| + | ## ErrorCodeException | ||
| + | |||
| + | - status_code: | ||
| - | ## PersonalDetails | ||
| ## IdentityDocument | ## IdentityDocument | ||
| - | - definition: list[dict[str | IdentityDocumentPart]] | + | - definition |
| - | - type: MRZDocumentType | + | - type |
| - | - name: str | + | - name |
| - | - line_size: int | + | - line_size |
| - | - nb_line: int | + | - nb_line |
| - | ## ErrorCodeException | + | ## IdentityExtractedDataExtra |
| + | - id_number | ||
| + | - issuing_date | ||
| + | - expiration_date | ||
| + | - issuing_country | ||
| + | - issuer | ||
| + | - address | ||
| + | - dmx_id_number | ||
| + | - dmx_signature_status | ||
| + | - mrz_line_1 | ||
| + | - mrz_line_2 | ||
| + | - mrz_line_3 | ||
| + | - nfc_compatible | ||
| - | - status_code: EnrollmentStatusCode | + | |
| + | ## PersonalDetails | ||
| + | - id | ||
| + | - name | ||
| + | - birth_name | ||
| + | - first_name | ||
| + | - first_names | ||
| + | |||
| + | - address | ||
| + | - zip_code | ||
| + | - city | ||
| + | - country | ||
| + | - phone_number | ||
| + | - birth_date | ||
| + | - gender | ||
| + | - birth_place | ||
| + | - birth_country | ||
| + | - nationality | ||
| + | - identity_valid | ||
| + | - enrollment | ||
| + | |||
| + | - pk: _empty | ||
| # Exemple | # Exemple | ||
| Ligne 927: | Ligne 954: | ||
| ``` | ``` | ||
| + | </ | ||