@anpdgovbr/shared-types
Version:
Biblioteca central de tipos TypeScript compartilhados para os projetos da ANPD (BETA)
186 lines (185 loc) • 5.27 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AD_FIELD_MAPPING = exports.FIELD_CONFIGS = void 0;
/**
* Mapa contendo a configuração de todos os campos permitidos.
*
* A chave é um valor de AllowedField e o valor é a configuração completa (FieldConfig).
* Usado para centralizar regras de validação e mapeamentos entre API e AD.
*
* @public
*/
exports.FIELD_CONFIGS = {
title: {
apiName: "title",
adAttribute: "Title",
type: "string",
allowEmpty: true,
description: "Cargo/função do usuário",
maxLength: 128,
},
department: {
apiName: "department",
adAttribute: "Department",
type: "string",
allowEmpty: true,
description: "Departamento/setor do usuário",
maxLength: 64,
},
telephoneNumber: {
apiName: "telephoneNumber",
adAttribute: "OfficePhone",
type: "string",
allowEmpty: true,
description: "Telefone fixo do trabalho",
validation: {
pattern: /^[\d\s\-+()]*$/,
message: "Apenas números, espaços, hífens, parênteses e sinal de mais são permitidos",
},
},
mobile: {
apiName: "mobile",
adAttribute: "Mobile",
type: "string",
allowEmpty: true,
description: "Telefone celular",
validation: {
pattern: /^[\d\s\-+()]*$/,
message: "Apenas números, espaços, hífens, parênteses e sinal de mais são permitidos",
},
},
physicalDeliveryOfficeName: {
apiName: "physicalDeliveryOfficeName",
adAttribute: "Office",
type: "string",
allowEmpty: true,
description: "Localização física do escritório",
maxLength: 128,
},
mail: {
apiName: "mail",
adAttribute: "Mail",
type: "string",
allowEmpty: false,
description: "Email principal",
maxLength: 254,
validation: {
pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
message: "Formato de email inválido",
},
},
employeeID: {
apiName: "employeeID",
adAttribute: "EmployeeID",
type: "string",
allowEmpty: false,
description: "Identificador único de RH (ex.: CPF)",
maxLength: 64,
},
employeeNumber: {
apiName: "employeeNumber",
adAttribute: "EmployeeNumber",
type: "string",
allowEmpty: true,
description: "Número de matrícula interna (ex.: SIAPE)",
maxLength: 64,
},
manager: {
apiName: "manager",
adAttribute: "Manager",
type: "string",
allowEmpty: true,
description: "DN do gestor imediato",
maxLength: 256,
},
l: {
apiName: "l",
adAttribute: "L",
type: "string",
allowEmpty: true,
description: "Localidade (city)",
maxLength: 128,
},
st: {
apiName: "st",
adAttribute: "ST",
type: "string",
allowEmpty: true,
description: "Estado (state)",
maxLength: 128,
},
c: {
apiName: "c",
adAttribute: "C",
type: "string",
allowEmpty: true,
description: "País (ISO 3166-1 alpha-2)",
maxLength: 2,
},
postalCode: {
apiName: "postalCode",
adAttribute: "PostalCode",
type: "string",
allowEmpty: true,
description: "CEP (postal code)",
maxLength: 20,
},
company: {
apiName: "company",
adAttribute: "Company",
type: "string",
allowEmpty: true,
description: "Organização/órgão principal",
maxLength: 128,
},
division: {
apiName: "division",
adAttribute: "Division",
type: "string",
allowEmpty: true,
description: "Macro-área ou coordenação",
maxLength: 128,
},
employeeType: {
apiName: "employeeType",
adAttribute: "EmployeeType",
type: "string",
allowEmpty: true,
description: "Tipo de vínculo",
maxLength: 64,
},
thumbnailPhoto: {
apiName: "thumbnailPhoto",
adAttribute: "ThumbnailPhoto",
type: "string",
allowEmpty: true,
description: "Foto do usuário (base64/URL)",
maxLength: 4000000,
},
info: {
apiName: "info",
adAttribute: "Info",
type: "string",
allowEmpty: true,
description: "Campo livre (anotações internas)",
maxLength: 1024,
},
};
/**
* Mapeamento derivado que associa o nome do campo da API ao atributo do Active Directory.
*
* Construído automaticamente a partir de FIELD_CONFIGS e tipado como Record<AllowedField, string>.
* Útil para conversões rápidas entre representação da API e atributos do AD.
*
* @public
*/
exports.AD_FIELD_MAPPING = Object.fromEntries(Object.values(exports.FIELD_CONFIGS).map((c) => [c.apiName, c.adAttribute]));
/**
* Export default contendo o conjunto padrão de configurações de campo.
*
* @example
* import FIELD_CONFIGS from './vocab.config'
*
* @public
*/
exports.default = exports.FIELD_CONFIGS;