implementado drive pilão de dados
This commit is contained in:
parent
a1e543cfb8
commit
daae40f4b2
54 changed files with 1476 additions and 19 deletions
|
|
@ -1,9 +1,11 @@
|
||||||
import { type tipoResposta } from "p-respostas";
|
import { type tipoResposta } from "p-respostas";
|
||||||
|
import type { z } from "zod";
|
||||||
|
import type { zAmbiente } from "../ts/ambiente";
|
||||||
type tipoPostCodigoContaSite = {
|
type tipoPostCodigoContaSite = {
|
||||||
site: string;
|
site: string;
|
||||||
};
|
};
|
||||||
export declare const codigoContaSite: ({ ambiente, post, buscar, }: {
|
export declare const codigoContaSite: ({ ambiente, post, buscar, }: {
|
||||||
ambiente: "desenvolvimento" | "producao";
|
ambiente: z.infer<typeof zAmbiente>;
|
||||||
post: tipoPostCodigoContaSite;
|
post: tipoPostCodigoContaSite;
|
||||||
/** função que conecta com a API */
|
/** função que conecta com a API */
|
||||||
buscar: (url: string, post: tipoPostCodigoContaSite) => Promise<tipoResposta<string>>;
|
buscar: (url: string, post: tipoPostCodigoContaSite) => Promise<tipoResposta<string>>;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
export declare const urlAutenticacao: (ambiente: "desenvolvimento" | "producao") => string;
|
import type { z } from "zod";
|
||||||
|
import type { zAmbiente } from "../ts/ambiente";
|
||||||
|
export declare const urlAutenticacao: (ambiente: z.infer<typeof zAmbiente>) => string;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import { type tipoResposta } from "p-respostas";
|
import { type tipoResposta } from "p-respostas";
|
||||||
|
import type { z } from "zod";
|
||||||
|
import type { zAmbiente } from "../ts/ambiente";
|
||||||
export type tipoUsuarioExterno = {
|
export type tipoUsuarioExterno = {
|
||||||
nome: string;
|
nome: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
|
@ -8,7 +10,7 @@ export type tipoUsuarioExterno = {
|
||||||
chave_produto: string;
|
chave_produto: string;
|
||||||
};
|
};
|
||||||
export declare const usuarios_quipo_governo: ({ token_produto, ambiente, buscar, }: {
|
export declare const usuarios_quipo_governo: ({ token_produto, ambiente, buscar, }: {
|
||||||
ambiente: "desenvolvimento" | "producao";
|
ambiente: z.infer<typeof zAmbiente>;
|
||||||
token_produto: string;
|
token_produto: string;
|
||||||
buscar: (url: string, headers: {
|
buscar: (url: string, headers: {
|
||||||
[k: string]: string;
|
[k: string]: string;
|
||||||
|
|
|
||||||
4
dist-import/autenticacao/_validarToken.d.ts
vendored
4
dist-import/autenticacao/_validarToken.d.ts
vendored
|
|
@ -2,9 +2,11 @@ import type { tipoResposta } from "p-respostas";
|
||||||
type tipoPostValidarTokem = {
|
type tipoPostValidarTokem = {
|
||||||
token: string;
|
token: string;
|
||||||
};
|
};
|
||||||
|
import type { z } from "zod";
|
||||||
|
import type { zAmbiente } from "../ts/ambiente";
|
||||||
/** faz a validação do token */
|
/** faz a validação do token */
|
||||||
export declare const validarToken: ({ ambiente, post, buscar, }: {
|
export declare const validarToken: ({ ambiente, post, buscar, }: {
|
||||||
ambiente: "desenvolvimento" | "producao";
|
ambiente: z.infer<typeof zAmbiente>;
|
||||||
post: tipoPostValidarTokem;
|
post: tipoPostValidarTokem;
|
||||||
/** função que conecta com a API */
|
/** função que conecta com a API */
|
||||||
buscar: (url: string, post: tipoPostValidarTokem) => Promise<tipoResposta<any>>;
|
buscar: (url: string, post: tipoPostValidarTokem) => Promise<tipoResposta<any>>;
|
||||||
|
|
|
||||||
1
dist-import/index.d.ts
vendored
1
dist-import/index.d.ts
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
export * from "./tokenQuipo";
|
export * from "./tokenQuipo";
|
||||||
export * from "./autenticacao";
|
export * from "./autenticacao";
|
||||||
export * from "./produtos";
|
export * from "./produtos";
|
||||||
|
export * from "./pilao-de-dados";
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
export * from "./tokenQuipo";
|
export * from "./tokenQuipo";
|
||||||
export * from "./autenticacao";
|
export * from "./autenticacao";
|
||||||
export * from "./produtos";
|
export * from "./produtos";
|
||||||
|
export * from "./pilao-de-dados";
|
||||||
|
|
|
||||||
22
dist-import/pilao-de-dados/_variaveis.d.ts
vendored
Normal file
22
dist-import/pilao-de-dados/_variaveis.d.ts
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { z } from "zod";
|
||||||
|
export declare const zAmbiente: z.ZodEnum<["desenvolvimento", "producao"]>;
|
||||||
|
export declare const PREFIXO = "/pilao-de-dados";
|
||||||
|
export declare const validarZ: <T>(zodType: z.ZodType<T, any, T>, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso<T>;
|
||||||
|
export declare const zp_produto_conta: z.ZodObject<{
|
||||||
|
produto: z.ZodString;
|
||||||
|
conta: z.ZodString;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
}, {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
}>;
|
||||||
|
export declare const tiposColunas: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
|
||||||
|
export declare const validarColuna: {
|
||||||
|
texto: z.ZodNullable<z.ZodString>;
|
||||||
|
numero: z.ZodNullable<z.ZodNumber>;
|
||||||
|
confirmacao: z.ZodNullable<z.ZodBoolean>;
|
||||||
|
lista_texto: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
||||||
|
lista_numero: z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>;
|
||||||
|
};
|
||||||
30
dist-import/pilao-de-dados/_variaveis.js
Normal file
30
dist-import/pilao-de-dados/_variaveis.js
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { respostaComuns } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
export const zAmbiente = z.enum(["desenvolvimento", "producao"]);
|
||||||
|
export const PREFIXO = "/pilao-de-dados";
|
||||||
|
export const validarZ = (zodType, objeto, mensagem) => {
|
||||||
|
const validar = zodType.safeParse(objeto);
|
||||||
|
if (!validar.success) {
|
||||||
|
debugger;
|
||||||
|
return respostaComuns.erro(mensagem, validar.error.errors.map((e) => `${e.path} ${e.message}`));
|
||||||
|
}
|
||||||
|
return respostaComuns.valor(validar.data);
|
||||||
|
};
|
||||||
|
export const zp_produto_conta = z.object({
|
||||||
|
produto: z.string(),
|
||||||
|
conta: z.string(),
|
||||||
|
});
|
||||||
|
export const tiposColunas = z.enum([
|
||||||
|
"texto",
|
||||||
|
"numero",
|
||||||
|
"confirmacao",
|
||||||
|
"lista_texto",
|
||||||
|
"lista_numero",
|
||||||
|
]);
|
||||||
|
export const validarColuna = {
|
||||||
|
texto: z.string().nullable(),
|
||||||
|
numero: z.number().nullable(),
|
||||||
|
confirmacao: z.boolean().nullable(),
|
||||||
|
lista_texto: z.array(z.string()).nullable(),
|
||||||
|
lista_numero: z.array(z.number()).nullable(),
|
||||||
|
};
|
||||||
24
dist-import/pilao-de-dados/consultar_serie.d.ts
vendored
Normal file
24
dist-import/pilao-de-dados/consultar_serie.d.ts
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import type { tipoResposta } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { type zp_produto_conta } from "./_variaveis";
|
||||||
|
import type { zp_registrar_serie } from "./registrar_serie";
|
||||||
|
export declare const zp_consultar_serie: z.ZodObject<{
|
||||||
|
identificador: z.ZodString;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
identificador: string;
|
||||||
|
}, {
|
||||||
|
identificador: string;
|
||||||
|
}>;
|
||||||
|
export declare const consultar_serie: ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null;
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>;
|
||||||
|
parametros: z.infer<typeof zp_consultar_serie>;
|
||||||
|
}) => {
|
||||||
|
dados: () => Promise<tipoResposta<{
|
||||||
|
registros: any[];
|
||||||
|
legenda: string;
|
||||||
|
serie: z.infer<typeof zp_registrar_serie>;
|
||||||
|
}>>;
|
||||||
|
url: () => string;
|
||||||
|
};
|
||||||
47
dist-import/pilao-de-dados/consultar_serie.js
Normal file
47
dist-import/pilao-de-dados/consultar_serie.js
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
import { respostaComuns } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { PREFIXO } from "./_variaveis";
|
||||||
|
//consultar compilação
|
||||||
|
export const zp_consultar_serie = z.object({
|
||||||
|
identificador: z.string(),
|
||||||
|
});
|
||||||
|
export const consultar_serie = ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }) => {
|
||||||
|
const dados = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const url = new URL(`${emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one"}${`${PREFIXO}/consultar-serie/${produto}/${conta}`}`);
|
||||||
|
const resp = yield fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
|
identificador,
|
||||||
|
}),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
||||||
|
.then((r) => r);
|
||||||
|
return resp;
|
||||||
|
});
|
||||||
|
const url = () => {
|
||||||
|
const vUrl = new URL(`${emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5081"
|
||||||
|
: "https://carro-de-boi.idz.one"}${PREFIXO}/grafico`);
|
||||||
|
vUrl.searchParams.append("produto", produto);
|
||||||
|
vUrl.searchParams.append("conta", conta);
|
||||||
|
vUrl.searchParams.append("identificador", identificador);
|
||||||
|
return vUrl.href;
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
dados,
|
||||||
|
url,
|
||||||
|
};
|
||||||
|
};
|
||||||
20
dist-import/pilao-de-dados/enviar_registros.d.ts
vendored
Normal file
20
dist-import/pilao-de-dados/enviar_registros.d.ts
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
import type { tipoResposta } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { type zp_produto_conta } from "./_variaveis";
|
||||||
|
export declare const zp_enviar_registros: z.ZodObject<{
|
||||||
|
tabela: z.ZodString;
|
||||||
|
registros: z.ZodArray<z.ZodAny, "many">;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
registros: any[];
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
registros: any[];
|
||||||
|
}>;
|
||||||
|
export declare const enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null;
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>;
|
||||||
|
/** Parametros da função */
|
||||||
|
parametros: z.infer<typeof zp_enviar_registros>;
|
||||||
|
}) => Promise<tipoResposta<true>>;
|
||||||
31
dist-import/pilao-de-dados/enviar_registros.js
Normal file
31
dist-import/pilao-de-dados/enviar_registros.js
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
import { respostaComuns } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { PREFIXO } from "./_variaveis";
|
||||||
|
//enviar registros para base de dados
|
||||||
|
export const zp_enviar_registros = z.object({
|
||||||
|
tabela: z.string(),
|
||||||
|
registros: z.array(z.any()),
|
||||||
|
});
|
||||||
|
export const enviar_registros = ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const url = new URL(`${emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one"}${PREFIXO}/enviar-registro/${produto}/${conta}`);
|
||||||
|
const resp = yield fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ tabela, registros }),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
||||||
|
.then((r) => r);
|
||||||
|
return resp;
|
||||||
|
});
|
||||||
138
dist-import/pilao-de-dados/index.d.ts
vendored
Normal file
138
dist-import/pilao-de-dados/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,138 @@
|
||||||
|
import { tiposColunas } from "./_variaveis";
|
||||||
|
export { tiposColunas };
|
||||||
|
export declare const pPilao: {
|
||||||
|
registrar_base_dados: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { colunas, tabela }, }: {
|
||||||
|
emDesenvolvimento?: boolean | null | undefined;
|
||||||
|
cliente: {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
};
|
||||||
|
parametros: {
|
||||||
|
tabela: string;
|
||||||
|
colunas: {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
}) => Promise<import("p-respostas").tipoResposta<true>>;
|
||||||
|
zp_registrar_base_dados: import("zod").ZodObject<{
|
||||||
|
tabela: import("zod").ZodString;
|
||||||
|
colunas: import("zod").ZodArray<import("zod").ZodObject<{
|
||||||
|
coluna: import("zod").ZodString;
|
||||||
|
tipo: import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}, {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}>, "many">;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
colunas: {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}[];
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
colunas: {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}[];
|
||||||
|
}>;
|
||||||
|
enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {
|
||||||
|
emDesenvolvimento?: boolean | null | undefined;
|
||||||
|
cliente: {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
};
|
||||||
|
parametros: {
|
||||||
|
tabela: string;
|
||||||
|
registros: any[];
|
||||||
|
};
|
||||||
|
}) => Promise<import("p-respostas").tipoResposta<true>>;
|
||||||
|
zp_enviar_registros: import("zod").ZodObject<{
|
||||||
|
tabela: import("zod").ZodString;
|
||||||
|
registros: import("zod").ZodArray<import("zod").ZodAny, "many">;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
registros: any[];
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
registros: any[];
|
||||||
|
}>;
|
||||||
|
registrar_serie: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }: {
|
||||||
|
emDesenvolvimento?: boolean | null | undefined;
|
||||||
|
cliente: {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
};
|
||||||
|
parametros: {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
};
|
||||||
|
}) => Promise<import("p-respostas").tipoResposta<true>>;
|
||||||
|
zp_registrar_serie: import("zod").ZodObject<{
|
||||||
|
tabela: import("zod").ZodString;
|
||||||
|
identificador: import("zod").ZodString;
|
||||||
|
colanuEixoX: import("zod").ZodString;
|
||||||
|
colunaAgrupamento: import("zod").ZodString;
|
||||||
|
agregacao: import("zod").ZodEnum<["contagem"]>;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
}>;
|
||||||
|
consultar_serie: ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }: {
|
||||||
|
emDesenvolvimento?: boolean | null | undefined;
|
||||||
|
cliente: {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
};
|
||||||
|
parametros: {
|
||||||
|
identificador: string;
|
||||||
|
};
|
||||||
|
}) => {
|
||||||
|
dados: () => Promise<import("p-respostas").tipoResposta<{
|
||||||
|
registros: any[];
|
||||||
|
legenda: string;
|
||||||
|
serie: {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
};
|
||||||
|
}>>;
|
||||||
|
url: () => string;
|
||||||
|
};
|
||||||
|
zp_consultar_serie: import("zod").ZodObject<{
|
||||||
|
identificador: import("zod").ZodString;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
identificador: string;
|
||||||
|
}, {
|
||||||
|
identificador: string;
|
||||||
|
}>;
|
||||||
|
zp_produto_conta: import("zod").ZodObject<{
|
||||||
|
produto: import("zod").ZodString;
|
||||||
|
conta: import("zod").ZodString;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
}, {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
}>;
|
||||||
|
validarZ: <T>(zodType: import("zod").ZodType<T, any, T>, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso<T>;
|
||||||
|
};
|
||||||
18
dist-import/pilao-de-dados/index.js
Normal file
18
dist-import/pilao-de-dados/index.js
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { tiposColunas, validarZ, zp_produto_conta } from "./_variaveis";
|
||||||
|
import { consultar_serie, zp_consultar_serie } from "./consultar_serie";
|
||||||
|
import { enviar_registros, zp_enviar_registros } from "./enviar_registros";
|
||||||
|
import { registrar_base_dados, zp_registrar_base_dados, } from "./registrar_base_dados";
|
||||||
|
import { registrar_serie, zp_registrar_serie } from "./registrar_serie";
|
||||||
|
export { tiposColunas };
|
||||||
|
export const pPilao = {
|
||||||
|
registrar_base_dados,
|
||||||
|
zp_registrar_base_dados,
|
||||||
|
enviar_registros,
|
||||||
|
zp_enviar_registros,
|
||||||
|
registrar_serie,
|
||||||
|
zp_registrar_serie,
|
||||||
|
consultar_serie,
|
||||||
|
zp_consultar_serie,
|
||||||
|
zp_produto_conta,
|
||||||
|
validarZ,
|
||||||
|
};
|
||||||
36
dist-import/pilao-de-dados/registrar_base_dados.d.ts
vendored
Normal file
36
dist-import/pilao-de-dados/registrar_base_dados.d.ts
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
import type { tipoResposta } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { type zp_produto_conta } from "./_variaveis";
|
||||||
|
/** Faz o registro de uma nova base de dados configurado a estrutura de colunas */
|
||||||
|
export declare const zp_registrar_base_dados: z.ZodObject<{
|
||||||
|
tabela: z.ZodString;
|
||||||
|
colunas: z.ZodArray<z.ZodObject<{
|
||||||
|
coluna: z.ZodString;
|
||||||
|
tipo: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}, {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}>, "many">;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
colunas: {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}[];
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
colunas: {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}[];
|
||||||
|
}>;
|
||||||
|
export declare const registrar_base_dados: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { colunas, tabela }, }: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null;
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>;
|
||||||
|
/** parametros da função */
|
||||||
|
parametros: z.infer<typeof zp_registrar_base_dados>;
|
||||||
|
}) => Promise<tipoResposta<true>>;
|
||||||
34
dist-import/pilao-de-dados/registrar_base_dados.js
Normal file
34
dist-import/pilao-de-dados/registrar_base_dados.js
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
import { respostaComuns } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { PREFIXO, tiposColunas } from "./_variaveis";
|
||||||
|
/** Faz o registro de uma nova base de dados configurado a estrutura de colunas */
|
||||||
|
export const zp_registrar_base_dados = z.object({
|
||||||
|
tabela: z.string(),
|
||||||
|
colunas: z.array(z.object({
|
||||||
|
coluna: z.string(),
|
||||||
|
tipo: tiposColunas,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
export const registrar_base_dados = ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { colunas, tabela }, }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const url = new URL(`${emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one"}${`${PREFIXO}/registar-base-dados/${produto}/${conta}`}`);
|
||||||
|
const resp = yield fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ tabela, colunas }),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
||||||
|
.then((r) => r);
|
||||||
|
return resp;
|
||||||
|
});
|
||||||
29
dist-import/pilao-de-dados/registrar_serie.d.ts
vendored
Normal file
29
dist-import/pilao-de-dados/registrar_serie.d.ts
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
import { type tipoResposta } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { type zp_produto_conta } from "./_variaveis";
|
||||||
|
export declare const zp_registrar_serie: z.ZodObject<{
|
||||||
|
tabela: z.ZodString;
|
||||||
|
identificador: z.ZodString;
|
||||||
|
colanuEixoX: z.ZodString;
|
||||||
|
colunaAgrupamento: z.ZodString;
|
||||||
|
agregacao: z.ZodEnum<["contagem"]>;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
}>;
|
||||||
|
export declare const registrar_serie: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null;
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>;
|
||||||
|
/** Parametros da função */
|
||||||
|
parametros: z.infer<typeof zp_registrar_serie>;
|
||||||
|
}) => Promise<tipoResposta<true>>;
|
||||||
41
dist-import/pilao-de-dados/registrar_serie.js
Normal file
41
dist-import/pilao-de-dados/registrar_serie.js
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
import { respostaComuns } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { PREFIXO } from "./_variaveis";
|
||||||
|
//registrar serie
|
||||||
|
export const zp_registrar_serie = z.object({
|
||||||
|
tabela: z.string(),
|
||||||
|
identificador: z.string(),
|
||||||
|
colanuEixoX: z.string(),
|
||||||
|
colunaAgrupamento: z.string(),
|
||||||
|
agregacao: z.enum(["contagem"]),
|
||||||
|
});
|
||||||
|
export const registrar_serie = ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
|
const url = new URL(`${emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one"}${`${PREFIXO}/registar-serie/${produto}/${conta}`}`);
|
||||||
|
const resp = yield fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
|
tabela,
|
||||||
|
agregacao,
|
||||||
|
emDesenvolvimento,
|
||||||
|
colanuEixoX,
|
||||||
|
colunaAgrupamento,
|
||||||
|
identificador,
|
||||||
|
}),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
||||||
|
.then((r) => r);
|
||||||
|
return resp;
|
||||||
|
});
|
||||||
2
dist-import/ts/ambiente.d.ts
vendored
Normal file
2
dist-import/ts/ambiente.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
import { z } from "zod";
|
||||||
|
export declare const zAmbiente: z.ZodEnum<["desenvolvimento", "producao"]>;
|
||||||
2
dist-import/ts/ambiente.js
Normal file
2
dist-import/ts/ambiente.js
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
import { z } from "zod";
|
||||||
|
export const zAmbiente = z.enum(["desenvolvimento", "producao"]);
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
import { type tipoResposta } from "p-respostas";
|
import { type tipoResposta } from "p-respostas";
|
||||||
|
import type { z } from "zod";
|
||||||
|
import type { zAmbiente } from "../ts/ambiente";
|
||||||
type tipoPostCodigoContaSite = {
|
type tipoPostCodigoContaSite = {
|
||||||
site: string;
|
site: string;
|
||||||
};
|
};
|
||||||
export declare const codigoContaSite: ({ ambiente, post, buscar, }: {
|
export declare const codigoContaSite: ({ ambiente, post, buscar, }: {
|
||||||
ambiente: "desenvolvimento" | "producao";
|
ambiente: z.infer<typeof zAmbiente>;
|
||||||
post: tipoPostCodigoContaSite;
|
post: tipoPostCodigoContaSite;
|
||||||
/** função que conecta com a API */
|
/** função que conecta com a API */
|
||||||
buscar: (url: string, post: tipoPostCodigoContaSite) => Promise<tipoResposta<string>>;
|
buscar: (url: string, post: tipoPostCodigoContaSite) => Promise<tipoResposta<string>>;
|
||||||
|
|
|
||||||
|
|
@ -1 +1,3 @@
|
||||||
export declare const urlAutenticacao: (ambiente: "desenvolvimento" | "producao") => string;
|
import type { z } from "zod";
|
||||||
|
import type { zAmbiente } from "../ts/ambiente";
|
||||||
|
export declare const urlAutenticacao: (ambiente: z.infer<typeof zAmbiente>) => string;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import { type tipoResposta } from "p-respostas";
|
import { type tipoResposta } from "p-respostas";
|
||||||
|
import type { z } from "zod";
|
||||||
|
import type { zAmbiente } from "../ts/ambiente";
|
||||||
export type tipoUsuarioExterno = {
|
export type tipoUsuarioExterno = {
|
||||||
nome: string;
|
nome: string;
|
||||||
email: string;
|
email: string;
|
||||||
|
|
@ -8,7 +10,7 @@ export type tipoUsuarioExterno = {
|
||||||
chave_produto: string;
|
chave_produto: string;
|
||||||
};
|
};
|
||||||
export declare const usuarios_quipo_governo: ({ token_produto, ambiente, buscar, }: {
|
export declare const usuarios_quipo_governo: ({ token_produto, ambiente, buscar, }: {
|
||||||
ambiente: "desenvolvimento" | "producao";
|
ambiente: z.infer<typeof zAmbiente>;
|
||||||
token_produto: string;
|
token_produto: string;
|
||||||
buscar: (url: string, headers: {
|
buscar: (url: string, headers: {
|
||||||
[k: string]: string;
|
[k: string]: string;
|
||||||
|
|
|
||||||
4
dist-require/autenticacao/_validarToken.d.ts
vendored
4
dist-require/autenticacao/_validarToken.d.ts
vendored
|
|
@ -2,9 +2,11 @@ import type { tipoResposta } from "p-respostas";
|
||||||
type tipoPostValidarTokem = {
|
type tipoPostValidarTokem = {
|
||||||
token: string;
|
token: string;
|
||||||
};
|
};
|
||||||
|
import type { z } from "zod";
|
||||||
|
import type { zAmbiente } from "../ts/ambiente";
|
||||||
/** faz a validação do token */
|
/** faz a validação do token */
|
||||||
export declare const validarToken: ({ ambiente, post, buscar, }: {
|
export declare const validarToken: ({ ambiente, post, buscar, }: {
|
||||||
ambiente: "desenvolvimento" | "producao";
|
ambiente: z.infer<typeof zAmbiente>;
|
||||||
post: tipoPostValidarTokem;
|
post: tipoPostValidarTokem;
|
||||||
/** função que conecta com a API */
|
/** função que conecta com a API */
|
||||||
buscar: (url: string, post: tipoPostValidarTokem) => Promise<tipoResposta<any>>;
|
buscar: (url: string, post: tipoPostValidarTokem) => Promise<tipoResposta<any>>;
|
||||||
|
|
|
||||||
1
dist-require/index.d.ts
vendored
1
dist-require/index.d.ts
vendored
|
|
@ -1,3 +1,4 @@
|
||||||
export * from "./tokenQuipo";
|
export * from "./tokenQuipo";
|
||||||
export * from "./autenticacao";
|
export * from "./autenticacao";
|
||||||
export * from "./produtos";
|
export * from "./produtos";
|
||||||
|
export * from "./pilao-de-dados";
|
||||||
|
|
|
||||||
|
|
@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
__exportStar(require("./tokenQuipo"), exports);
|
__exportStar(require("./tokenQuipo"), exports);
|
||||||
__exportStar(require("./autenticacao"), exports);
|
__exportStar(require("./autenticacao"), exports);
|
||||||
__exportStar(require("./produtos"), exports);
|
__exportStar(require("./produtos"), exports);
|
||||||
|
__exportStar(require("./pilao-de-dados"), exports);
|
||||||
|
|
|
||||||
22
dist-require/pilao-de-dados/_variaveis.d.ts
vendored
Normal file
22
dist-require/pilao-de-dados/_variaveis.d.ts
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { z } from "zod";
|
||||||
|
export declare const zAmbiente: z.ZodEnum<["desenvolvimento", "producao"]>;
|
||||||
|
export declare const PREFIXO = "/pilao-de-dados";
|
||||||
|
export declare const validarZ: <T>(zodType: z.ZodType<T, any, T>, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso<T>;
|
||||||
|
export declare const zp_produto_conta: z.ZodObject<{
|
||||||
|
produto: z.ZodString;
|
||||||
|
conta: z.ZodString;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
}, {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
}>;
|
||||||
|
export declare const tiposColunas: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
|
||||||
|
export declare const validarColuna: {
|
||||||
|
texto: z.ZodNullable<z.ZodString>;
|
||||||
|
numero: z.ZodNullable<z.ZodNumber>;
|
||||||
|
confirmacao: z.ZodNullable<z.ZodBoolean>;
|
||||||
|
lista_texto: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
|
||||||
|
lista_numero: z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>;
|
||||||
|
};
|
||||||
34
dist-require/pilao-de-dados/_variaveis.js
Normal file
34
dist-require/pilao-de-dados/_variaveis.js
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.validarColuna = exports.tiposColunas = exports.zp_produto_conta = exports.validarZ = exports.PREFIXO = exports.zAmbiente = void 0;
|
||||||
|
var p_respostas_1 = require("p-respostas");
|
||||||
|
var zod_1 = require("zod");
|
||||||
|
exports.zAmbiente = zod_1.z.enum(["desenvolvimento", "producao"]);
|
||||||
|
exports.PREFIXO = "/pilao-de-dados";
|
||||||
|
var validarZ = function (zodType, objeto, mensagem) {
|
||||||
|
var validar = zodType.safeParse(objeto);
|
||||||
|
if (!validar.success) {
|
||||||
|
debugger;
|
||||||
|
return p_respostas_1.respostaComuns.erro(mensagem, validar.error.errors.map(function (e) { return "".concat(e.path, " ").concat(e.message); }));
|
||||||
|
}
|
||||||
|
return p_respostas_1.respostaComuns.valor(validar.data);
|
||||||
|
};
|
||||||
|
exports.validarZ = validarZ;
|
||||||
|
exports.zp_produto_conta = zod_1.z.object({
|
||||||
|
produto: zod_1.z.string(),
|
||||||
|
conta: zod_1.z.string(),
|
||||||
|
});
|
||||||
|
exports.tiposColunas = zod_1.z.enum([
|
||||||
|
"texto",
|
||||||
|
"numero",
|
||||||
|
"confirmacao",
|
||||||
|
"lista_texto",
|
||||||
|
"lista_numero",
|
||||||
|
]);
|
||||||
|
exports.validarColuna = {
|
||||||
|
texto: zod_1.z.string().nullable(),
|
||||||
|
numero: zod_1.z.number().nullable(),
|
||||||
|
confirmacao: zod_1.z.boolean().nullable(),
|
||||||
|
lista_texto: zod_1.z.array(zod_1.z.string()).nullable(),
|
||||||
|
lista_numero: zod_1.z.array(zod_1.z.number()).nullable(),
|
||||||
|
};
|
||||||
24
dist-require/pilao-de-dados/consultar_serie.d.ts
vendored
Normal file
24
dist-require/pilao-de-dados/consultar_serie.d.ts
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
import type { tipoResposta } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { type zp_produto_conta } from "./_variaveis";
|
||||||
|
import type { zp_registrar_serie } from "./registrar_serie";
|
||||||
|
export declare const zp_consultar_serie: z.ZodObject<{
|
||||||
|
identificador: z.ZodString;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
identificador: string;
|
||||||
|
}, {
|
||||||
|
identificador: string;
|
||||||
|
}>;
|
||||||
|
export declare const consultar_serie: ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null;
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>;
|
||||||
|
parametros: z.infer<typeof zp_consultar_serie>;
|
||||||
|
}) => {
|
||||||
|
dados: () => Promise<tipoResposta<{
|
||||||
|
registros: any[];
|
||||||
|
legenda: string;
|
||||||
|
serie: z.infer<typeof zp_registrar_serie>;
|
||||||
|
}>>;
|
||||||
|
url: () => string;
|
||||||
|
};
|
||||||
89
dist-require/pilao-de-dados/consultar_serie.js
Normal file
89
dist-require/pilao-de-dados/consultar_serie.js
Normal file
|
|
@ -0,0 +1,89 @@
|
||||||
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||||
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||||
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||||
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||||
|
function step(op) {
|
||||||
|
if (f) throw new TypeError("Generator is already executing.");
|
||||||
|
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||||
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||||
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||||
|
switch (op[0]) {
|
||||||
|
case 0: case 1: t = op; break;
|
||||||
|
case 4: _.label++; return { value: op[1], done: false };
|
||||||
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||||
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||||
|
default:
|
||||||
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||||
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||||
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||||
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||||
|
if (t[2]) _.ops.pop();
|
||||||
|
_.trys.pop(); continue;
|
||||||
|
}
|
||||||
|
op = body.call(thisArg, _);
|
||||||
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||||
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.consultar_serie = exports.zp_consultar_serie = void 0;
|
||||||
|
var p_respostas_1 = require("p-respostas");
|
||||||
|
var zod_1 = require("zod");
|
||||||
|
var _variaveis_1 = require("./_variaveis");
|
||||||
|
//consultar compilação
|
||||||
|
exports.zp_consultar_serie = zod_1.z.object({
|
||||||
|
identificador: zod_1.z.string(),
|
||||||
|
});
|
||||||
|
var consultar_serie = function (_a) {
|
||||||
|
var emDesenvolvimento = _a.emDesenvolvimento, identificador = _a.parametros.identificador, _b = _a.cliente, conta = _b.conta, produto = _b.produto;
|
||||||
|
var dados = function () { return __awaiter(void 0, void 0, void 0, function () {
|
||||||
|
var url, resp;
|
||||||
|
return __generator(this, function (_a) {
|
||||||
|
switch (_a.label) {
|
||||||
|
case 0:
|
||||||
|
url = new URL("".concat(emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one").concat("".concat(_variaveis_1.PREFIXO, "/consultar-serie/").concat(produto, "/").concat(conta)));
|
||||||
|
return [4 /*yield*/, fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
|
identificador: identificador,
|
||||||
|
}),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then(function (r) { return r.json(); })
|
||||||
|
.catch(function (e) {
|
||||||
|
return p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message]);
|
||||||
|
})
|
||||||
|
.then(function (r) { return r; })];
|
||||||
|
case 1:
|
||||||
|
resp = _a.sent();
|
||||||
|
return [2 /*return*/, resp];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}); };
|
||||||
|
var url = function () {
|
||||||
|
var vUrl = new URL("".concat(emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5081"
|
||||||
|
: "https://carro-de-boi.idz.one").concat(_variaveis_1.PREFIXO, "/grafico"));
|
||||||
|
vUrl.searchParams.append("produto", produto);
|
||||||
|
vUrl.searchParams.append("conta", conta);
|
||||||
|
vUrl.searchParams.append("identificador", identificador);
|
||||||
|
return vUrl.href;
|
||||||
|
};
|
||||||
|
return {
|
||||||
|
dados: dados,
|
||||||
|
url: url,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
exports.consultar_serie = consultar_serie;
|
||||||
20
dist-require/pilao-de-dados/enviar_registros.d.ts
vendored
Normal file
20
dist-require/pilao-de-dados/enviar_registros.d.ts
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
import type { tipoResposta } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { type zp_produto_conta } from "./_variaveis";
|
||||||
|
export declare const zp_enviar_registros: z.ZodObject<{
|
||||||
|
tabela: z.ZodString;
|
||||||
|
registros: z.ZodArray<z.ZodAny, "many">;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
registros: any[];
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
registros: any[];
|
||||||
|
}>;
|
||||||
|
export declare const enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null;
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>;
|
||||||
|
/** Parametros da função */
|
||||||
|
parametros: z.infer<typeof zp_enviar_registros>;
|
||||||
|
}) => Promise<tipoResposta<true>>;
|
||||||
73
dist-require/pilao-de-dados/enviar_registros.js
Normal file
73
dist-require/pilao-de-dados/enviar_registros.js
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||||
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||||
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||||
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||||
|
function step(op) {
|
||||||
|
if (f) throw new TypeError("Generator is already executing.");
|
||||||
|
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||||
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||||
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||||
|
switch (op[0]) {
|
||||||
|
case 0: case 1: t = op; break;
|
||||||
|
case 4: _.label++; return { value: op[1], done: false };
|
||||||
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||||
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||||
|
default:
|
||||||
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||||
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||||
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||||
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||||
|
if (t[2]) _.ops.pop();
|
||||||
|
_.trys.pop(); continue;
|
||||||
|
}
|
||||||
|
op = body.call(thisArg, _);
|
||||||
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||||
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.enviar_registros = exports.zp_enviar_registros = void 0;
|
||||||
|
var p_respostas_1 = require("p-respostas");
|
||||||
|
var zod_1 = require("zod");
|
||||||
|
var _variaveis_1 = require("./_variaveis");
|
||||||
|
//enviar registros para base de dados
|
||||||
|
exports.zp_enviar_registros = zod_1.z.object({
|
||||||
|
tabela: zod_1.z.string(),
|
||||||
|
registros: zod_1.z.array(zod_1.z.any()),
|
||||||
|
});
|
||||||
|
var enviar_registros = function (_a) {
|
||||||
|
var emDesenvolvimento = _a.emDesenvolvimento, _b = _a.cliente, conta = _b.conta, produto = _b.produto, _c = _a.parametros, registros = _c.registros, tabela = _c.tabela;
|
||||||
|
return __awaiter(void 0, void 0, void 0, function () {
|
||||||
|
var url, resp;
|
||||||
|
return __generator(this, function (_d) {
|
||||||
|
switch (_d.label) {
|
||||||
|
case 0:
|
||||||
|
url = new URL("".concat(emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one").concat(_variaveis_1.PREFIXO, "/enviar-registro/").concat(produto, "/").concat(conta));
|
||||||
|
return [4 /*yield*/, fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ tabela: tabela, registros: registros }),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then(function (r) { return r.json(); })
|
||||||
|
.catch(function (e) { return p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message]); })
|
||||||
|
.then(function (r) { return r; })];
|
||||||
|
case 1:
|
||||||
|
resp = _d.sent();
|
||||||
|
return [2 /*return*/, resp];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
exports.enviar_registros = enviar_registros;
|
||||||
138
dist-require/pilao-de-dados/index.d.ts
vendored
Normal file
138
dist-require/pilao-de-dados/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,138 @@
|
||||||
|
import { tiposColunas } from "./_variaveis";
|
||||||
|
export { tiposColunas };
|
||||||
|
export declare const pPilao: {
|
||||||
|
registrar_base_dados: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { colunas, tabela }, }: {
|
||||||
|
emDesenvolvimento?: boolean | null | undefined;
|
||||||
|
cliente: {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
};
|
||||||
|
parametros: {
|
||||||
|
tabela: string;
|
||||||
|
colunas: {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
}) => Promise<import("p-respostas").tipoResposta<true>>;
|
||||||
|
zp_registrar_base_dados: import("zod").ZodObject<{
|
||||||
|
tabela: import("zod").ZodString;
|
||||||
|
colunas: import("zod").ZodArray<import("zod").ZodObject<{
|
||||||
|
coluna: import("zod").ZodString;
|
||||||
|
tipo: import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}, {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}>, "many">;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
colunas: {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}[];
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
colunas: {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}[];
|
||||||
|
}>;
|
||||||
|
enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {
|
||||||
|
emDesenvolvimento?: boolean | null | undefined;
|
||||||
|
cliente: {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
};
|
||||||
|
parametros: {
|
||||||
|
tabela: string;
|
||||||
|
registros: any[];
|
||||||
|
};
|
||||||
|
}) => Promise<import("p-respostas").tipoResposta<true>>;
|
||||||
|
zp_enviar_registros: import("zod").ZodObject<{
|
||||||
|
tabela: import("zod").ZodString;
|
||||||
|
registros: import("zod").ZodArray<import("zod").ZodAny, "many">;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
registros: any[];
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
registros: any[];
|
||||||
|
}>;
|
||||||
|
registrar_serie: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }: {
|
||||||
|
emDesenvolvimento?: boolean | null | undefined;
|
||||||
|
cliente: {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
};
|
||||||
|
parametros: {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
};
|
||||||
|
}) => Promise<import("p-respostas").tipoResposta<true>>;
|
||||||
|
zp_registrar_serie: import("zod").ZodObject<{
|
||||||
|
tabela: import("zod").ZodString;
|
||||||
|
identificador: import("zod").ZodString;
|
||||||
|
colanuEixoX: import("zod").ZodString;
|
||||||
|
colunaAgrupamento: import("zod").ZodString;
|
||||||
|
agregacao: import("zod").ZodEnum<["contagem"]>;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
}>;
|
||||||
|
consultar_serie: ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }: {
|
||||||
|
emDesenvolvimento?: boolean | null | undefined;
|
||||||
|
cliente: {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
};
|
||||||
|
parametros: {
|
||||||
|
identificador: string;
|
||||||
|
};
|
||||||
|
}) => {
|
||||||
|
dados: () => Promise<import("p-respostas").tipoResposta<{
|
||||||
|
registros: any[];
|
||||||
|
legenda: string;
|
||||||
|
serie: {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
};
|
||||||
|
}>>;
|
||||||
|
url: () => string;
|
||||||
|
};
|
||||||
|
zp_consultar_serie: import("zod").ZodObject<{
|
||||||
|
identificador: import("zod").ZodString;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
identificador: string;
|
||||||
|
}, {
|
||||||
|
identificador: string;
|
||||||
|
}>;
|
||||||
|
zp_produto_conta: import("zod").ZodObject<{
|
||||||
|
produto: import("zod").ZodString;
|
||||||
|
conta: import("zod").ZodString;
|
||||||
|
}, "strip", import("zod").ZodTypeAny, {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
}, {
|
||||||
|
produto: string;
|
||||||
|
conta: string;
|
||||||
|
}>;
|
||||||
|
validarZ: <T>(zodType: import("zod").ZodType<T, any, T>, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso<T>;
|
||||||
|
};
|
||||||
21
dist-require/pilao-de-dados/index.js
Normal file
21
dist-require/pilao-de-dados/index.js
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.pPilao = exports.tiposColunas = void 0;
|
||||||
|
var _variaveis_1 = require("./_variaveis");
|
||||||
|
Object.defineProperty(exports, "tiposColunas", { enumerable: true, get: function () { return _variaveis_1.tiposColunas; } });
|
||||||
|
var consultar_serie_1 = require("./consultar_serie");
|
||||||
|
var enviar_registros_1 = require("./enviar_registros");
|
||||||
|
var registrar_base_dados_1 = require("./registrar_base_dados");
|
||||||
|
var registrar_serie_1 = require("./registrar_serie");
|
||||||
|
exports.pPilao = {
|
||||||
|
registrar_base_dados: registrar_base_dados_1.registrar_base_dados,
|
||||||
|
zp_registrar_base_dados: registrar_base_dados_1.zp_registrar_base_dados,
|
||||||
|
enviar_registros: enviar_registros_1.enviar_registros,
|
||||||
|
zp_enviar_registros: enviar_registros_1.zp_enviar_registros,
|
||||||
|
registrar_serie: registrar_serie_1.registrar_serie,
|
||||||
|
zp_registrar_serie: registrar_serie_1.zp_registrar_serie,
|
||||||
|
consultar_serie: consultar_serie_1.consultar_serie,
|
||||||
|
zp_consultar_serie: consultar_serie_1.zp_consultar_serie,
|
||||||
|
zp_produto_conta: _variaveis_1.zp_produto_conta,
|
||||||
|
validarZ: _variaveis_1.validarZ,
|
||||||
|
};
|
||||||
36
dist-require/pilao-de-dados/registrar_base_dados.d.ts
vendored
Normal file
36
dist-require/pilao-de-dados/registrar_base_dados.d.ts
vendored
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
import type { tipoResposta } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { type zp_produto_conta } from "./_variaveis";
|
||||||
|
/** Faz o registro de uma nova base de dados configurado a estrutura de colunas */
|
||||||
|
export declare const zp_registrar_base_dados: z.ZodObject<{
|
||||||
|
tabela: z.ZodString;
|
||||||
|
colunas: z.ZodArray<z.ZodObject<{
|
||||||
|
coluna: z.ZodString;
|
||||||
|
tipo: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}, {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}>, "many">;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
colunas: {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}[];
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
colunas: {
|
||||||
|
coluna: string;
|
||||||
|
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
|
||||||
|
}[];
|
||||||
|
}>;
|
||||||
|
export declare const registrar_base_dados: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { colunas, tabela }, }: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null;
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>;
|
||||||
|
/** parametros da função */
|
||||||
|
parametros: z.infer<typeof zp_registrar_base_dados>;
|
||||||
|
}) => Promise<tipoResposta<true>>;
|
||||||
76
dist-require/pilao-de-dados/registrar_base_dados.js
Normal file
76
dist-require/pilao-de-dados/registrar_base_dados.js
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||||
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||||
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||||
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||||
|
function step(op) {
|
||||||
|
if (f) throw new TypeError("Generator is already executing.");
|
||||||
|
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||||
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||||
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||||
|
switch (op[0]) {
|
||||||
|
case 0: case 1: t = op; break;
|
||||||
|
case 4: _.label++; return { value: op[1], done: false };
|
||||||
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||||
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||||
|
default:
|
||||||
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||||
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||||
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||||
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||||
|
if (t[2]) _.ops.pop();
|
||||||
|
_.trys.pop(); continue;
|
||||||
|
}
|
||||||
|
op = body.call(thisArg, _);
|
||||||
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||||
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.registrar_base_dados = exports.zp_registrar_base_dados = void 0;
|
||||||
|
var p_respostas_1 = require("p-respostas");
|
||||||
|
var zod_1 = require("zod");
|
||||||
|
var _variaveis_1 = require("./_variaveis");
|
||||||
|
/** Faz o registro de uma nova base de dados configurado a estrutura de colunas */
|
||||||
|
exports.zp_registrar_base_dados = zod_1.z.object({
|
||||||
|
tabela: zod_1.z.string(),
|
||||||
|
colunas: zod_1.z.array(zod_1.z.object({
|
||||||
|
coluna: zod_1.z.string(),
|
||||||
|
tipo: _variaveis_1.tiposColunas,
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
var registrar_base_dados = function (_a) {
|
||||||
|
var emDesenvolvimento = _a.emDesenvolvimento, _b = _a.cliente, conta = _b.conta, produto = _b.produto, _c = _a.parametros, colunas = _c.colunas, tabela = _c.tabela;
|
||||||
|
return __awaiter(void 0, void 0, void 0, function () {
|
||||||
|
var url, resp;
|
||||||
|
return __generator(this, function (_d) {
|
||||||
|
switch (_d.label) {
|
||||||
|
case 0:
|
||||||
|
url = new URL("".concat(emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one").concat("".concat(_variaveis_1.PREFIXO, "/registar-base-dados/").concat(produto, "/").concat(conta)));
|
||||||
|
return [4 /*yield*/, fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ tabela: tabela, colunas: colunas }),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then(function (r) { return r.json(); })
|
||||||
|
.catch(function (e) { return p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message]); })
|
||||||
|
.then(function (r) { return r; })];
|
||||||
|
case 1:
|
||||||
|
resp = _d.sent();
|
||||||
|
return [2 /*return*/, resp];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
exports.registrar_base_dados = registrar_base_dados;
|
||||||
29
dist-require/pilao-de-dados/registrar_serie.d.ts
vendored
Normal file
29
dist-require/pilao-de-dados/registrar_serie.d.ts
vendored
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
import { type tipoResposta } from "p-respostas";
|
||||||
|
import { z } from "zod";
|
||||||
|
import { type zp_produto_conta } from "./_variaveis";
|
||||||
|
export declare const zp_registrar_serie: z.ZodObject<{
|
||||||
|
tabela: z.ZodString;
|
||||||
|
identificador: z.ZodString;
|
||||||
|
colanuEixoX: z.ZodString;
|
||||||
|
colunaAgrupamento: z.ZodString;
|
||||||
|
agregacao: z.ZodEnum<["contagem"]>;
|
||||||
|
}, "strip", z.ZodTypeAny, {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
}, {
|
||||||
|
tabela: string;
|
||||||
|
identificador: string;
|
||||||
|
colanuEixoX: string;
|
||||||
|
colunaAgrupamento: string;
|
||||||
|
agregacao: "contagem";
|
||||||
|
}>;
|
||||||
|
export declare const registrar_serie: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null;
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>;
|
||||||
|
/** Parametros da função */
|
||||||
|
parametros: z.infer<typeof zp_registrar_serie>;
|
||||||
|
}) => Promise<tipoResposta<true>>;
|
||||||
83
dist-require/pilao-de-dados/registrar_serie.js
Normal file
83
dist-require/pilao-de-dados/registrar_serie.js
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
"use strict";
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
var __generator = (this && this.__generator) || function (thisArg, body) {
|
||||||
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
||||||
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
||||||
|
function verb(n) { return function (v) { return step([n, v]); }; }
|
||||||
|
function step(op) {
|
||||||
|
if (f) throw new TypeError("Generator is already executing.");
|
||||||
|
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
||||||
|
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
||||||
|
if (y = 0, t) op = [op[0] & 2, t.value];
|
||||||
|
switch (op[0]) {
|
||||||
|
case 0: case 1: t = op; break;
|
||||||
|
case 4: _.label++; return { value: op[1], done: false };
|
||||||
|
case 5: _.label++; y = op[1]; op = [0]; continue;
|
||||||
|
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
||||||
|
default:
|
||||||
|
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
||||||
|
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
||||||
|
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
||||||
|
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
||||||
|
if (t[2]) _.ops.pop();
|
||||||
|
_.trys.pop(); continue;
|
||||||
|
}
|
||||||
|
op = body.call(thisArg, _);
|
||||||
|
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
||||||
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.registrar_serie = exports.zp_registrar_serie = void 0;
|
||||||
|
var p_respostas_1 = require("p-respostas");
|
||||||
|
var zod_1 = require("zod");
|
||||||
|
var _variaveis_1 = require("./_variaveis");
|
||||||
|
//registrar serie
|
||||||
|
exports.zp_registrar_serie = zod_1.z.object({
|
||||||
|
tabela: zod_1.z.string(),
|
||||||
|
identificador: zod_1.z.string(),
|
||||||
|
colanuEixoX: zod_1.z.string(),
|
||||||
|
colunaAgrupamento: zod_1.z.string(),
|
||||||
|
agregacao: zod_1.z.enum(["contagem"]),
|
||||||
|
});
|
||||||
|
var registrar_serie = function (_a) {
|
||||||
|
var emDesenvolvimento = _a.emDesenvolvimento, _b = _a.cliente, conta = _b.conta, produto = _b.produto, _c = _a.parametros, agregacao = _c.agregacao, colanuEixoX = _c.colanuEixoX, colunaAgrupamento = _c.colunaAgrupamento, identificador = _c.identificador, tabela = _c.tabela;
|
||||||
|
return __awaiter(void 0, void 0, void 0, function () {
|
||||||
|
var url, resp;
|
||||||
|
return __generator(this, function (_d) {
|
||||||
|
switch (_d.label) {
|
||||||
|
case 0:
|
||||||
|
url = new URL("".concat(emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one").concat("".concat(_variaveis_1.PREFIXO, "/registar-serie/").concat(produto, "/").concat(conta)));
|
||||||
|
return [4 /*yield*/, fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
|
tabela: tabela,
|
||||||
|
agregacao: agregacao,
|
||||||
|
emDesenvolvimento: emDesenvolvimento,
|
||||||
|
colanuEixoX: colanuEixoX,
|
||||||
|
colunaAgrupamento: colunaAgrupamento,
|
||||||
|
identificador: identificador,
|
||||||
|
}),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then(function (r) { return r.json(); })
|
||||||
|
.catch(function (e) { return p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message]); })
|
||||||
|
.then(function (r) { return r; })];
|
||||||
|
case 1:
|
||||||
|
resp = _d.sent();
|
||||||
|
return [2 /*return*/, resp];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
exports.registrar_serie = registrar_serie;
|
||||||
2
dist-require/ts/ambiente.d.ts
vendored
Normal file
2
dist-require/ts/ambiente.d.ts
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
import { z } from "zod";
|
||||||
|
export declare const zAmbiente: z.ZodEnum<["desenvolvimento", "producao"]>;
|
||||||
5
dist-require/ts/ambiente.js
Normal file
5
dist-require/ts/ambiente.js
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.zAmbiente = void 0;
|
||||||
|
var zod_1 = require("zod");
|
||||||
|
exports.zAmbiente = zod_1.z.enum(["desenvolvimento", "producao"]);
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "p-drives",
|
"name": "p-drives",
|
||||||
"version": "0.51.0",
|
"version": "0.55.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|
@ -27,7 +27,11 @@
|
||||||
"typescript": "^4.9.5"
|
"typescript": "^4.9.5"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": {
|
||||||
|
"name": "AZTECA SOFTWARE LTDA",
|
||||||
|
"email": "ti@e-licencie.com.br",
|
||||||
|
"url": "https://e-licencie.com.br"
|
||||||
|
},
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"zod": "3.23.8"
|
"zod": "3.23.8"
|
||||||
|
|
|
||||||
10
pnpm-lock.yaml
generated
10
pnpm-lock.yaml
generated
|
|
@ -26,7 +26,7 @@ importers:
|
||||||
version: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#ac72e915630a0f7750630a24389367141b0e8ae0(typescript@4.9.5)
|
version: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#ac72e915630a0f7750630a24389367141b0e8ae0(typescript@4.9.5)
|
||||||
p-respostas:
|
p-respostas:
|
||||||
specifier: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#producao
|
specifier: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#producao
|
||||||
version: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#7d895ac6d96b0f52f61668c9017249f36ab01c7d
|
version: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#d13e633204f5485d3af48c46f37317561250808a
|
||||||
typescript:
|
typescript:
|
||||||
specifier: ^4.9.5
|
specifier: ^4.9.5
|
||||||
version: 4.9.5
|
version: 4.9.5
|
||||||
|
|
@ -128,9 +128,9 @@ packages:
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: ^5.0.0
|
typescript: ^5.0.0
|
||||||
|
|
||||||
p-respostas@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#7d895ac6d96b0f52f61668c9017249f36ab01c7d:
|
p-respostas@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#d13e633204f5485d3af48c46f37317561250808a:
|
||||||
resolution: {commit: 7d895ac6d96b0f52f61668c9017249f36ab01c7d, repo: http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git, type: git}
|
resolution: {commit: d13e633204f5485d3af48c46f37317561250808a, repo: http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git, type: git}
|
||||||
version: 0.5.0
|
version: 0.9.0
|
||||||
|
|
||||||
queue-microtask@1.2.3:
|
queue-microtask@1.2.3:
|
||||||
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
|
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
|
||||||
|
|
@ -235,7 +235,7 @@ snapshots:
|
||||||
typescript: 4.9.5
|
typescript: 4.9.5
|
||||||
zod: 3.23.8
|
zod: 3.23.8
|
||||||
|
|
||||||
p-respostas@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#7d895ac6d96b0f52f61668c9017249f36ab01c7d:
|
p-respostas@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#d13e633204f5485d3af48c46f37317561250808a:
|
||||||
dependencies:
|
dependencies:
|
||||||
zod: 3.23.8
|
zod: 3.23.8
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import { respostaComuns, type tipoResposta } from "p-respostas"
|
import { respostaComuns, type tipoResposta } from "p-respostas"
|
||||||
|
import type { z } from "zod"
|
||||||
|
import type { zAmbiente } from "../ts/ambiente"
|
||||||
import { urlAutenticacao } from "./_urlAutenticacao"
|
import { urlAutenticacao } from "./_urlAutenticacao"
|
||||||
type tipoPostCodigoContaSite = { site: string }
|
type tipoPostCodigoContaSite = { site: string }
|
||||||
|
|
||||||
|
|
@ -7,7 +9,7 @@ export const codigoContaSite = async ({
|
||||||
post,
|
post,
|
||||||
buscar,
|
buscar,
|
||||||
}: {
|
}: {
|
||||||
ambiente: "desenvolvimento" | "producao"
|
ambiente: z.infer<typeof zAmbiente>
|
||||||
post: tipoPostCodigoContaSite
|
post: tipoPostCodigoContaSite
|
||||||
/** função que conecta com a API */
|
/** função que conecta com a API */
|
||||||
buscar: (
|
buscar: (
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
export const urlAutenticacao = (ambiente: "desenvolvimento" | "producao") =>
|
import type { z } from "zod"
|
||||||
|
import type { zAmbiente } from "../ts/ambiente"
|
||||||
|
|
||||||
|
export const urlAutenticacao = (ambiente: z.infer<typeof zAmbiente>) =>
|
||||||
`${
|
`${
|
||||||
ambiente == "producao"
|
ambiente == "producao"
|
||||||
? "https://carro-de-boi.idz.one"
|
? "https://carro-de-boi.idz.one"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import { respostaComuns, type tipoResposta } from "p-respostas"
|
import { respostaComuns, type tipoResposta } from "p-respostas"
|
||||||
|
import type { z } from "zod"
|
||||||
|
import type { zAmbiente } from "../ts/ambiente"
|
||||||
import { urlAutenticacao } from "./_urlAutenticacao"
|
import { urlAutenticacao } from "./_urlAutenticacao"
|
||||||
|
|
||||||
export type tipoUsuarioExterno = {
|
export type tipoUsuarioExterno = {
|
||||||
|
|
@ -15,7 +17,7 @@ export const usuarios_quipo_governo = async ({
|
||||||
ambiente,
|
ambiente,
|
||||||
buscar,
|
buscar,
|
||||||
}: {
|
}: {
|
||||||
ambiente: "desenvolvimento" | "producao"
|
ambiente: z.infer<typeof zAmbiente>
|
||||||
token_produto: string
|
token_produto: string
|
||||||
buscar: (
|
buscar: (
|
||||||
url: string,
|
url: string,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import type { tipoResposta } from "p-respostas"
|
import type { tipoResposta } from "p-respostas"
|
||||||
import { urlAutenticacao } from "./_urlAutenticacao"
|
import { urlAutenticacao } from "./_urlAutenticacao"
|
||||||
type tipoPostValidarTokem = { token: string }
|
type tipoPostValidarTokem = { token: string }
|
||||||
|
import type { z } from "zod"
|
||||||
|
import type { zAmbiente } from "../ts/ambiente"
|
||||||
|
|
||||||
/** faz a validação do token */
|
/** faz a validação do token */
|
||||||
export const validarToken = async ({
|
export const validarToken = async ({
|
||||||
|
|
@ -8,7 +10,7 @@ export const validarToken = async ({
|
||||||
post,
|
post,
|
||||||
buscar,
|
buscar,
|
||||||
}: {
|
}: {
|
||||||
ambiente: "desenvolvimento" | "producao"
|
ambiente: z.infer<typeof zAmbiente>
|
||||||
post: tipoPostValidarTokem
|
post: tipoPostValidarTokem
|
||||||
/** função que conecta com a API */
|
/** função que conecta com a API */
|
||||||
buscar: (
|
buscar: (
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
export * from "./tokenQuipo"
|
export * from "./tokenQuipo"
|
||||||
export * from "./autenticacao"
|
export * from "./autenticacao"
|
||||||
export * from "./produtos"
|
export * from "./produtos"
|
||||||
|
export * from "./pilao-de-dados"
|
||||||
|
|
|
||||||
43
src/pilao-de-dados/_variaveis.ts
Normal file
43
src/pilao-de-dados/_variaveis.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
import { respostaComuns } from "p-respostas"
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
export const zAmbiente = z.enum(["desenvolvimento", "producao"])
|
||||||
|
|
||||||
|
export const PREFIXO = "/pilao-de-dados"
|
||||||
|
|
||||||
|
export const validarZ = <T>(
|
||||||
|
zodType: z.ZodType<T, any>,
|
||||||
|
objeto: any,
|
||||||
|
mensagem: string,
|
||||||
|
) => {
|
||||||
|
const validar = zodType.safeParse(objeto)
|
||||||
|
if (!validar.success) {
|
||||||
|
debugger
|
||||||
|
return respostaComuns.erro(
|
||||||
|
mensagem,
|
||||||
|
validar.error.errors.map((e) => `${e.path} ${e.message}`),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return respostaComuns.valor(validar.data)
|
||||||
|
}
|
||||||
|
|
||||||
|
export const zp_produto_conta = z.object({
|
||||||
|
produto: z.string(),
|
||||||
|
conta: z.string(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const tiposColunas = z.enum([
|
||||||
|
"texto",
|
||||||
|
"numero",
|
||||||
|
"confirmacao",
|
||||||
|
"lista_texto",
|
||||||
|
"lista_numero",
|
||||||
|
])
|
||||||
|
|
||||||
|
export const validarColuna = {
|
||||||
|
texto: z.string().nullable(),
|
||||||
|
numero: z.number().nullable(),
|
||||||
|
confirmacao: z.boolean().nullable(),
|
||||||
|
lista_texto: z.array(z.string()).nullable(),
|
||||||
|
lista_numero: z.array(z.number()).nullable(),
|
||||||
|
}
|
||||||
75
src/pilao-de-dados/consultar_serie.ts
Normal file
75
src/pilao-de-dados/consultar_serie.ts
Normal file
|
|
@ -0,0 +1,75 @@
|
||||||
|
import type { tipoResposta } from "p-respostas"
|
||||||
|
import { respostaComuns } from "p-respostas"
|
||||||
|
import { z } from "zod"
|
||||||
|
import { PREFIXO, type zp_produto_conta } from "./_variaveis"
|
||||||
|
import type { zp_registrar_serie } from "./registrar_serie"
|
||||||
|
|
||||||
|
//consultar compilação
|
||||||
|
|
||||||
|
export const zp_consultar_serie = z.object({
|
||||||
|
identificador: z.string(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const consultar_serie = ({
|
||||||
|
emDesenvolvimento,
|
||||||
|
parametros: { identificador },
|
||||||
|
cliente: { conta, produto },
|
||||||
|
}: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null
|
||||||
|
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>
|
||||||
|
parametros: z.infer<typeof zp_consultar_serie>
|
||||||
|
}) => {
|
||||||
|
const dados = async (): Promise<
|
||||||
|
tipoResposta<{
|
||||||
|
registros: any[]
|
||||||
|
legenda: string
|
||||||
|
serie: z.infer<typeof zp_registrar_serie>
|
||||||
|
}>
|
||||||
|
> => {
|
||||||
|
const url = new URL(
|
||||||
|
`${
|
||||||
|
emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one"
|
||||||
|
}${`${PREFIXO}/consultar-serie/${produto}/${conta}`}`,
|
||||||
|
)
|
||||||
|
|
||||||
|
const resp = await fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
|
identificador,
|
||||||
|
}),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch((e) =>
|
||||||
|
respostaComuns.erro("Erro ao enviar registros", [e.message]),
|
||||||
|
)
|
||||||
|
.then((r) => r as tipoResposta<any>)
|
||||||
|
|
||||||
|
return resp
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = (): string => {
|
||||||
|
const vUrl = new URL(
|
||||||
|
`${
|
||||||
|
emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5081"
|
||||||
|
: "https://carro-de-boi.idz.one"
|
||||||
|
}${PREFIXO}/grafico`,
|
||||||
|
)
|
||||||
|
|
||||||
|
vUrl.searchParams.append("produto", produto)
|
||||||
|
vUrl.searchParams.append("conta", conta)
|
||||||
|
vUrl.searchParams.append("identificador", identificador)
|
||||||
|
|
||||||
|
return vUrl.href
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
dados,
|
||||||
|
url,
|
||||||
|
}
|
||||||
|
}
|
||||||
43
src/pilao-de-dados/enviar_registros.ts
Normal file
43
src/pilao-de-dados/enviar_registros.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
import type { tipoResposta } from "p-respostas"
|
||||||
|
import { respostaComuns } from "p-respostas"
|
||||||
|
import { z } from "zod"
|
||||||
|
import { PREFIXO, type zp_produto_conta } from "./_variaveis"
|
||||||
|
|
||||||
|
//enviar registros para base de dados
|
||||||
|
export const zp_enviar_registros = z.object({
|
||||||
|
tabela: z.string(),
|
||||||
|
registros: z.array(z.any()),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const enviar_registros = async ({
|
||||||
|
emDesenvolvimento,
|
||||||
|
cliente: { conta, produto },
|
||||||
|
parametros: { registros, tabela },
|
||||||
|
}: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null
|
||||||
|
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>
|
||||||
|
/** Parametros da função */
|
||||||
|
|
||||||
|
parametros: z.infer<typeof zp_enviar_registros>
|
||||||
|
}): Promise<tipoResposta<true>> => {
|
||||||
|
const url = new URL(
|
||||||
|
`${
|
||||||
|
emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one"
|
||||||
|
}${PREFIXO}/enviar-registro/${produto}/${conta}`,
|
||||||
|
)
|
||||||
|
|
||||||
|
const resp = await fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ tabela, registros }),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
||||||
|
.then((r) => r as tipoResposta<true>)
|
||||||
|
|
||||||
|
return resp
|
||||||
|
}
|
||||||
27
src/pilao-de-dados/index.ts
Normal file
27
src/pilao-de-dados/index.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
import { tiposColunas, validarZ, zp_produto_conta } from "./_variaveis"
|
||||||
|
import { consultar_serie, zp_consultar_serie } from "./consultar_serie"
|
||||||
|
import { enviar_registros, zp_enviar_registros } from "./enviar_registros"
|
||||||
|
import {
|
||||||
|
registrar_base_dados,
|
||||||
|
zp_registrar_base_dados,
|
||||||
|
} from "./registrar_base_dados"
|
||||||
|
import { registrar_serie, zp_registrar_serie } from "./registrar_serie"
|
||||||
|
|
||||||
|
export { tiposColunas }
|
||||||
|
|
||||||
|
export const pPilao = {
|
||||||
|
registrar_base_dados,
|
||||||
|
zp_registrar_base_dados,
|
||||||
|
|
||||||
|
enviar_registros,
|
||||||
|
zp_enviar_registros,
|
||||||
|
|
||||||
|
registrar_serie,
|
||||||
|
zp_registrar_serie,
|
||||||
|
|
||||||
|
consultar_serie,
|
||||||
|
zp_consultar_serie,
|
||||||
|
|
||||||
|
zp_produto_conta,
|
||||||
|
validarZ,
|
||||||
|
}
|
||||||
47
src/pilao-de-dados/registrar_base_dados.ts
Normal file
47
src/pilao-de-dados/registrar_base_dados.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
import type { tipoResposta } from "p-respostas"
|
||||||
|
import { respostaComuns } from "p-respostas"
|
||||||
|
import { z } from "zod"
|
||||||
|
import { PREFIXO, tiposColunas, type zp_produto_conta } from "./_variaveis"
|
||||||
|
|
||||||
|
/** Faz o registro de uma nova base de dados configurado a estrutura de colunas */
|
||||||
|
|
||||||
|
export const zp_registrar_base_dados = z.object({
|
||||||
|
tabela: z.string(),
|
||||||
|
colunas: z.array(
|
||||||
|
z.object({
|
||||||
|
coluna: z.string(),
|
||||||
|
tipo: tiposColunas,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const registrar_base_dados = async ({
|
||||||
|
emDesenvolvimento,
|
||||||
|
cliente: { conta, produto },
|
||||||
|
parametros: { colunas, tabela },
|
||||||
|
}: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>
|
||||||
|
/** parametros da função */
|
||||||
|
parametros: z.infer<typeof zp_registrar_base_dados>
|
||||||
|
}): Promise<tipoResposta<true>> => {
|
||||||
|
const url = new URL(
|
||||||
|
`${
|
||||||
|
emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one"
|
||||||
|
}${`${PREFIXO}/registar-base-dados/${produto}/${conta}`}`,
|
||||||
|
)
|
||||||
|
|
||||||
|
const resp = await fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({ tabela, colunas }),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
||||||
|
.then((r) => r as tipoResposta<true>)
|
||||||
|
|
||||||
|
return resp
|
||||||
|
}
|
||||||
59
src/pilao-de-dados/registrar_serie.ts
Normal file
59
src/pilao-de-dados/registrar_serie.ts
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
import { respostaComuns, type tipoResposta } from "p-respostas"
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
import { PREFIXO, type zp_produto_conta } from "./_variaveis"
|
||||||
|
|
||||||
|
//registrar serie
|
||||||
|
|
||||||
|
export const zp_registrar_serie = z.object({
|
||||||
|
tabela: z.string(),
|
||||||
|
identificador: z.string(),
|
||||||
|
colanuEixoX: z.string(),
|
||||||
|
colunaAgrupamento: z.string(),
|
||||||
|
agregacao: z.enum(["contagem"]),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const registrar_serie = async ({
|
||||||
|
emDesenvolvimento,
|
||||||
|
cliente: { conta, produto },
|
||||||
|
parametros: {
|
||||||
|
agregacao,
|
||||||
|
colanuEixoX,
|
||||||
|
colunaAgrupamento,
|
||||||
|
identificador,
|
||||||
|
tabela,
|
||||||
|
},
|
||||||
|
}: {
|
||||||
|
emDesenvolvimento?: boolean | undefined | null
|
||||||
|
|
||||||
|
/** Identificação do cliente */
|
||||||
|
cliente: z.infer<typeof zp_produto_conta>
|
||||||
|
/** Parametros da função */
|
||||||
|
parametros: z.infer<typeof zp_registrar_serie>
|
||||||
|
}): Promise<tipoResposta<true>> => {
|
||||||
|
const url = new URL(
|
||||||
|
`${
|
||||||
|
emDesenvolvimento
|
||||||
|
? "http://127.0.0.1:5080"
|
||||||
|
: "https://carro-de-boi.idz.one"
|
||||||
|
}${`${PREFIXO}/registar-serie/${produto}/${conta}`}`,
|
||||||
|
)
|
||||||
|
|
||||||
|
const resp = await fetch(url.toString(), {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
|
tabela,
|
||||||
|
agregacao,
|
||||||
|
emDesenvolvimento,
|
||||||
|
colanuEixoX,
|
||||||
|
colunaAgrupamento,
|
||||||
|
identificador,
|
||||||
|
}),
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
})
|
||||||
|
.then((r) => r.json())
|
||||||
|
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
||||||
|
.then((r) => r as tipoResposta<true>)
|
||||||
|
|
||||||
|
return resp
|
||||||
|
}
|
||||||
3
src/ts/ambiente.ts
Normal file
3
src/ts/ambiente.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
import { z } from "zod"
|
||||||
|
|
||||||
|
export const zAmbiente = z.enum(["desenvolvimento", "producao"])
|
||||||
Loading…
Add table
Add a link
Reference in a new issue