flit-modulo-exportacoes 2.0.28 → 2.0.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/lib/dao/contas-elastic.js +110 -0
  2. package/lib/dao/elastic-base.js +110 -0
  3. package/lib/dao/empresas-elastic.js +116 -0
  4. package/lib/dao/empresas-feriado-elastic.js +119 -0
  5. package/lib/dao/eventos-exportacoes-elastic.js +122 -0
  6. package/lib/dao/feriados-elastic.js +132 -0
  7. package/lib/dao/jornadas-elastic.js +163 -0
  8. package/lib/dao/usuarios-elastic.js +109 -0
  9. package/{dist → lib}/index.d.ts +2 -1
  10. package/lib/index.js +523 -0
  11. package/{dist → lib}/models.d.ts +49 -0
  12. package/{dist → lib}/models.js +17 -1
  13. package/{dist → lib}/unificacao-eventos-repetidos.js +94 -63
  14. package/lib/utils.js +301 -0
  15. package/package.json +12 -15
  16. package/dist/dao/contas-elastic.js +0 -36
  17. package/dist/dao/elastic-base.js +0 -37
  18. package/dist/dao/empresas-elastic.js +0 -42
  19. package/dist/dao/empresas-feriado-elastic.js +0 -43
  20. package/dist/dao/eventos-exportacoes-elastic.js +0 -45
  21. package/dist/dao/feriados-elastic.js +0 -56
  22. package/dist/dao/jornadas-elastic.js +0 -85
  23. package/dist/dao/usuarios-elastic.js +0 -35
  24. package/dist/eventos-exportacoes-model.d.ts +0 -49
  25. package/dist/eventos-exportacoes-model.js +0 -19
  26. package/dist/index.js +0 -458
  27. package/dist/utils.js +0 -244
  28. package/tslint.json +0 -118
  29. /package/{dist → lib}/dao/contas-elastic.d.ts +0 -0
  30. /package/{dist → lib}/dao/elastic-base.d.ts +0 -0
  31. /package/{dist → lib}/dao/empresas-elastic.d.ts +0 -0
  32. /package/{dist → lib}/dao/empresas-feriado-elastic.d.ts +0 -0
  33. /package/{dist → lib}/dao/eventos-exportacoes-elastic.d.ts +0 -0
  34. /package/{dist → lib}/dao/feriados-elastic.d.ts +0 -0
  35. /package/{dist → lib}/dao/jornadas-elastic.d.ts +0 -0
  36. /package/{dist → lib}/dao/usuarios-elastic.d.ts +0 -0
  37. /package/{dist → lib}/unificacao-eventos-repetidos.d.ts +0 -0
  38. /package/{dist → lib}/utils.d.ts +0 -0
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "flit-modulo-exportacoes",
3
- "version": "2.0.28",
3
+ "version": "2.0.30",
4
4
  "description": "",
5
- "main": "dist/lib/index.js",
5
+ "main": "lib/index.js",
6
6
  "directories": {
7
- "lib": "lib"
7
+ "lib": "src"
8
8
  },
9
9
  "keywords": [],
10
10
  "author": "DirectOn Tecnologia",
@@ -12,23 +12,20 @@
12
12
  "types": "dist/lib/index.d.ts",
13
13
  "prepublish": "npm run build",
14
14
  "dependencies": {
15
- "moment": "^2.29.4",
16
- "flit-calcular-jornada": "latest"
17
- },
18
- "peerDependencies": {
19
- "@elastic/elasticsearch": "^8"
15
+ "flit-calcular-jornada": "latest",
16
+ "moment": "^2.29.4"
20
17
  },
21
18
  "devDependencies": {
22
- "@types/luxon": "^3.3.1",
23
- "prettier": "^3.0.1",
24
- "tsc-alias": "^1.8.7",
25
- "typescript": "^5.1.6"
19
+ "@elastic/elasticsearch": "^8",
20
+ "@types/luxon": "^3.3.2",
21
+ "prettier": "^3.0.3",
22
+ "typescript": "^5.2.2"
26
23
  },
27
24
  "scripts": {
28
- "build": "tsc --project tsconfig.json && tsc-alias -p tsconfig.json",
29
- "format": "prettier --write \"lib/**/*.ts\"",
25
+ "build": "tsc --project tsconfig.json",
26
+ "format": "prettier --write \"src/**/*.ts\"",
30
27
  "prepare": "npm run build",
31
- "version": "npm run format && git add -A lib",
28
+ "version": "npm run format && git add -A src",
32
29
  "postversion": "git push && git push --tags"
33
30
  }
34
31
  }
@@ -1,36 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ContasElastic = void 0;
4
- const elastic_base_1 = require("./elastic-base");
5
- class ContasElastic extends elastic_base_1.ElasticBase {
6
- async internalGetContasElastic(contaId) {
7
- return await this.elasticClient.search({
8
- scroll: '1m',
9
- index: 'contas',
10
- size: this.totalRegistrosFiltradosElastic,
11
- _source: [
12
- 'parametros.horario_noturno'
13
- ],
14
- query: {
15
- bool: {
16
- must: [{
17
- match: {
18
- i_id: contaId
19
- }
20
- }, {
21
- match: {
22
- excluido: false
23
- }
24
- }]
25
- }
26
- },
27
- sort: [{
28
- i_id: 'asc'
29
- }]
30
- });
31
- }
32
- async getContaElastic(contaId) {
33
- return (await this.retornaTodosDadosPaginacaoElastic(await this.internalGetContasElastic(contaId)))[0];
34
- }
35
- }
36
- exports.ContasElastic = ContasElastic;
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ElasticBase = void 0;
4
- class ElasticBase {
5
- constructor(elasticClient) {
6
- this.totalRegistrosFiltradosElastic = 500;
7
- this.elasticClient = elasticClient;
8
- }
9
- async searchScrollObjectElastic(scrollId) {
10
- return await this.elasticClient.scroll({
11
- scroll: '1m',
12
- scroll_id: scrollId
13
- });
14
- }
15
- async adicionarRegistrosPaginacaoElastic({ scrollId, retorno }) {
16
- let objetosPaginacao = await this.searchScrollObjectElastic(scrollId);
17
- while ((objetosPaginacao?.hits?.hits ?? []).length > 0) {
18
- (objetosPaginacao?.hits?.hits ?? []).forEach(objeto => retorno.push(objeto));
19
- objetosPaginacao = await this.searchScrollObjectElastic(scrollId);
20
- }
21
- }
22
- async retornaTodosDadosPaginacaoElastic(filtroInicial) {
23
- const retorno = new Array();
24
- (filtroInicial?.hits?.hits ?? []).forEach(objeto => retorno.push(objeto));
25
- if (filtroInicial?._scroll_id) {
26
- if ((filtroInicial?.hits?.total ?? 0) > this.totalRegistrosFiltradosElastic) {
27
- await this.adicionarRegistrosPaginacaoElastic({
28
- retorno: retorno,
29
- scrollId: filtroInicial?._scroll_id
30
- });
31
- }
32
- await this.elasticClient.clearScroll({ scroll_id: filtroInicial?._scroll_id });
33
- }
34
- return retorno;
35
- }
36
- }
37
- exports.ElasticBase = ElasticBase;
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmpresasElastic = void 0;
4
- const elastic_base_1 = require("./elastic-base");
5
- class EmpresasElastic extends elastic_base_1.ElasticBase {
6
- async internalGetEmpresasElastic(contaId) {
7
- return await this.elasticClient.search({
8
- scroll: '1m',
9
- index: 'contas_empresas',
10
- size: this.totalRegistrosFiltradosElastic,
11
- _source: [
12
- 'i_id',
13
- 'cnpj',
14
- 'razao',
15
- 'fantasia',
16
- 'endereco.uf',
17
- 'endereco.cidade',
18
- 'parametros.codigo_externo'
19
- ],
20
- query: {
21
- bool: {
22
- must: [{
23
- match: {
24
- i_parent_id: contaId
25
- }
26
- }, {
27
- match: {
28
- excluido: false
29
- }
30
- }]
31
- }
32
- },
33
- sort: [{
34
- i_id: 'asc'
35
- }]
36
- });
37
- }
38
- async getEmpresasElastic(contaId) {
39
- return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetEmpresasElastic(contaId));
40
- }
41
- }
42
- exports.EmpresasElastic = EmpresasElastic;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EmpresasFeriadoElastic = void 0;
4
- const elastic_base_1 = require("./elastic-base");
5
- class EmpresasFeriadoElastic extends elastic_base_1.ElasticBase {
6
- async internalGeEmpresasFeriadoElastic({ empresaId, feriadoId }) {
7
- return await this.elasticClient.search({
8
- scroll: '1m',
9
- index: 'contas_feriados_empresasferiado',
10
- size: this.totalRegistrosFiltradosElastic,
11
- _source: [
12
- 'i_id'
13
- ],
14
- query: {
15
- bool: {
16
- must: [{
17
- match: {
18
- i_parent_id: feriadoId
19
- }
20
- }, {
21
- match: {
22
- 'ref.i_id': empresaId
23
- }
24
- }, {
25
- match: {
26
- excluido: false
27
- }
28
- }]
29
- }
30
- },
31
- sort: [{
32
- i_id: 'asc'
33
- }]
34
- });
35
- }
36
- async getEmpresasFeriadoElastic({ empresaId, feriadoId }) {
37
- return await this.retornaTodosDadosPaginacaoElastic(await this.internalGeEmpresasFeriadoElastic({
38
- empresaId: empresaId,
39
- feriadoId: feriadoId
40
- }));
41
- }
42
- }
43
- exports.EmpresasFeriadoElastic = EmpresasFeriadoElastic;
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EventosExportacoesElastic = void 0;
4
- const elastic_base_1 = require("./elastic-base");
5
- class EventosExportacoesElastic extends elastic_base_1.ElasticBase {
6
- async internalGetEventosExportacoesElastic({ contaId, tabelaEventosId }) {
7
- return await this.elasticClient.search({
8
- scroll: '1m',
9
- index: 'contas_eventosexportacoes',
10
- size: this.totalRegistrosFiltradosElastic,
11
- _source: [
12
- 'eventos',
13
- 'forma_envio_faltas'
14
- ],
15
- query: {
16
- bool: {
17
- must: [{
18
- match: {
19
- i_parent_id: contaId
20
- }
21
- }, {
22
- match: {
23
- i_id: tabelaEventosId
24
- }
25
- }, {
26
- match: {
27
- excluido: false
28
- }
29
- }]
30
- }
31
- },
32
- sort: [{
33
- i_id: 'asc'
34
- }]
35
- });
36
- }
37
- async getEventosExportacoesElastic({ contaId, tabelaEventosId }) {
38
- const retorno = await this.retornaTodosDadosPaginacaoElastic(await this.internalGetEventosExportacoesElastic({
39
- contaId: contaId,
40
- tabelaEventosId: tabelaEventosId
41
- }));
42
- return retorno[0];
43
- }
44
- }
45
- exports.EventosExportacoesElastic = EventosExportacoesElastic;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.FeriadosElastic = void 0;
7
- const moment_1 = __importDefault(require("moment"));
8
- const elastic_base_1 = require("./elastic-base");
9
- class FeriadosElastic extends elastic_base_1.ElasticBase {
10
- async internalGetFeriadosElastic({ contaId, dataFinal, dataInicial }) {
11
- return await this.elasticClient.search({
12
- scroll: '1m',
13
- index: 'contas_feriados',
14
- size: this.totalRegistrosFiltradosElastic,
15
- _source: [
16
- 'uf',
17
- 'i_id',
18
- 'tipo',
19
- 'data',
20
- 'municipio',
21
- 'todas_empresas'
22
- ],
23
- query: {
24
- bool: {
25
- must: [{
26
- match: {
27
- i_parent_id: contaId
28
- }
29
- }, {
30
- match: {
31
- excluido: false
32
- }
33
- }, {
34
- range: {
35
- data: {
36
- gte: (0, moment_1.default)(dataInicial).format('YYYY-MM-DDTHH:mm:ss.SSS'),
37
- lte: (0, moment_1.default)(dataFinal).format('YYYY-MM-DDTHH:mm:ss.SSS')
38
- }
39
- }
40
- }]
41
- }
42
- },
43
- sort: [{
44
- data: 'asc'
45
- }]
46
- });
47
- }
48
- async getFeriadosElastic({ contaId, dataFinal, dataInicial }) {
49
- return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetFeriadosElastic({
50
- contaId: contaId,
51
- dataFinal: dataFinal,
52
- dataInicial: dataInicial
53
- }));
54
- }
55
- }
56
- exports.FeriadosElastic = FeriadosElastic;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.JornadasElastic = void 0;
7
- const moment_1 = __importDefault(require("moment"));
8
- const elastic_base_1 = require("./elastic-base");
9
- class JornadasElastic extends elastic_base_1.ElasticBase {
10
- async internalGetJornadasElastic({ fim, inicio, contaId, empresaId, usuarioId }) {
11
- const queryMust = new Array();
12
- queryMust.push({
13
- match: {
14
- i_parent_id: contaId
15
- }
16
- });
17
- queryMust.push({
18
- match: {
19
- 'usuario.empresa.uid': empresaId
20
- }
21
- });
22
- if (usuarioId) {
23
- queryMust.push({
24
- match: {
25
- 'usuario.uid': usuarioId
26
- }
27
- });
28
- }
29
- queryMust.push({
30
- range: {
31
- data_hora: {
32
- gte: (0, moment_1.default)(inicio).format('YYYY-MM-DDTHH:mm:ss.SSS'),
33
- lte: (0, moment_1.default)(fim).format('YYYY-MM-DDTHH:mm:ss.SSS')
34
- }
35
- }
36
- });
37
- return await this.elasticClient.search({
38
- scroll: '1m',
39
- index: 'contas_jornadas',
40
- size: this.totalRegistrosFiltradosElastic,
41
- _source: [
42
- 'data_hora',
43
- 'usuario.uid',
44
- 'usuario.cpf',
45
- 'usuario.pis',
46
- 'horas_extras',
47
- 'horas_normais',
48
- 'horas_noturnas',
49
- 'horas_negativas',
50
- 'jornada_prevista',
51
- 'jornada_realizada',
52
- 'regime_compensacao',
53
- 'usuario.cargo.nome',
54
- 'usuario.empresa.uf',
55
- 'faixas_horas_extras',
56
- 'usuario.empresa.uid',
57
- 'marcacoes_ignoradas',
58
- 'usuario.empresa.cnpj',
59
- 'horas_noturnas_extras',
60
- 'usuario.empresa.cidade',
61
- 'horas_extras_intrajornada',
62
- 'usuario.parametros.codigo_externo',
63
- 'usuario.empresa.parametros.codigo_externo'
64
- ],
65
- query: {
66
- bool: {
67
- must: queryMust
68
- }
69
- },
70
- sort: [{
71
- data_hora: 'asc'
72
- }]
73
- });
74
- }
75
- async getJornadasElastic({ contaId, dataFinal, usuarioId, empresaId, dataInicial }) {
76
- return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetJornadasElastic({
77
- fim: dataFinal,
78
- contaId: contaId,
79
- inicio: dataInicial,
80
- empresaId: empresaId,
81
- usuarioId: usuarioId
82
- }));
83
- }
84
- }
85
- exports.JornadasElastic = JornadasElastic;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UsuariosElastic = void 0;
4
- const elastic_base_1 = require("./elastic-base");
5
- class UsuariosElastic extends elastic_base_1.ElasticBase {
6
- async internalGetUsuariosElastic(idsUsuarios) {
7
- return await this.elasticClient.search({
8
- scroll: '1m',
9
- index: 'usuarios',
10
- size: this.totalRegistrosFiltradosElastic,
11
- _source: [
12
- 'pis',
13
- 'cpf',
14
- 'i_id',
15
- 'parametros.codigo_externo'
16
- ],
17
- query: {
18
- bool: {
19
- filter: {
20
- terms: {
21
- i_id: idsUsuarios
22
- }
23
- }
24
- }
25
- },
26
- sort: [{
27
- i_id: 'asc'
28
- }]
29
- });
30
- }
31
- async getUsuariosElastic(idsUsuarios) {
32
- return await this.retornaTodosDadosPaginacaoElastic(await this.internalGetUsuariosElastic(idsUsuarios));
33
- }
34
- }
35
- exports.UsuariosElastic = UsuariosElastic;
@@ -1,49 +0,0 @@
1
- export declare enum EnumTipoEventosExportacoes {
2
- Dexion = "DEXION",
3
- Dominio = "DOMINIO",
4
- Najason = "NAJASON",
5
- Prosoft = "PROSOFT",
6
- Questor = "QUESTOR",
7
- NetSpeed = "NETSPEED",
8
- Alterdata = "ALTERDATA"
9
- }
10
- export declare enum EnumFormaEnvioFaltasEventosExportacoes {
11
- Dias = "DIAS",
12
- Horas = "HORAS",
13
- Minutos = "MINUTOS"
14
- }
15
- export type PropsCodigosEventosExportacoes<T = any> = {
16
- [Property in keyof CodigosEventosExportacoes]: T;
17
- };
18
- export interface EventosExportacoes {
19
- excluido: boolean;
20
- descricao: string;
21
- tipo: EnumTipoEventosExportacoes;
22
- eventos: CodigosEventosExportacoes;
23
- forma_envio_faltas: EnumFormaEnvioFaltasEventosExportacoes;
24
- }
25
- interface CodigosEventosExportacoes {
26
- falta: string;
27
- atraso: string;
28
- hora_normal?: string;
29
- horas_trabalhadas?: string;
30
- hora_extra: string;
31
- hora_extra_sabado?: string;
32
- hora_extra_feriado: string;
33
- hora_extra_domingo?: string;
34
- hora_extra_noturna: string;
35
- hora_extra_noturna_sabado?: string;
36
- hora_extra_noturna_feriado: string;
37
- hora_extra_noturna_domingo?: string;
38
- hora_extra_intrajornada?: string;
39
- hora_extra_intrajornada_com_reducao?: string;
40
- hora_noturna: string;
41
- horas_noturnas_totais?: string;
42
- faixa_hora_extra_semanal_1?: string;
43
- faixa_hora_extra_semanal_2?: string;
44
- faixa_hora_extra_semanal_3?: string;
45
- faixa_hora_extra_diferenciada_1?: string;
46
- faixa_hora_extra_diferenciada_2?: string;
47
- faixa_hora_extra_diferenciada_3?: string;
48
- }
49
- export {};
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EnumFormaEnvioFaltasEventosExportacoes = exports.EnumTipoEventosExportacoes = void 0;
4
- var EnumTipoEventosExportacoes;
5
- (function (EnumTipoEventosExportacoes) {
6
- EnumTipoEventosExportacoes["Dexion"] = "DEXION";
7
- EnumTipoEventosExportacoes["Dominio"] = "DOMINIO";
8
- EnumTipoEventosExportacoes["Najason"] = "NAJASON";
9
- EnumTipoEventosExportacoes["Prosoft"] = "PROSOFT";
10
- EnumTipoEventosExportacoes["Questor"] = "QUESTOR";
11
- EnumTipoEventosExportacoes["NetSpeed"] = "NETSPEED";
12
- EnumTipoEventosExportacoes["Alterdata"] = "ALTERDATA";
13
- })(EnumTipoEventosExportacoes || (exports.EnumTipoEventosExportacoes = EnumTipoEventosExportacoes = {}));
14
- var EnumFormaEnvioFaltasEventosExportacoes;
15
- (function (EnumFormaEnvioFaltasEventosExportacoes) {
16
- EnumFormaEnvioFaltasEventosExportacoes["Dias"] = "DIAS";
17
- EnumFormaEnvioFaltasEventosExportacoes["Horas"] = "HORAS";
18
- EnumFormaEnvioFaltasEventosExportacoes["Minutos"] = "MINUTOS";
19
- })(EnumFormaEnvioFaltasEventosExportacoes || (exports.EnumFormaEnvioFaltasEventosExportacoes = EnumFormaEnvioFaltasEventosExportacoes = {}));