godeep-types 1.0.0

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 (74) hide show
  1. package/README.md +84 -0
  2. package/dist/module.d.mts +8 -0
  3. package/dist/module.json +9 -0
  4. package/dist/module.mjs +16 -0
  5. package/dist/runtime/plugin.d.ts +2 -0
  6. package/dist/runtime/plugin.js +4 -0
  7. package/dist/runtime/server/tsconfig.json +3 -0
  8. package/dist/runtime/translate/avaliacoes.d.ts +4 -0
  9. package/dist/runtime/translate/avaliacoes.js +26 -0
  10. package/dist/runtime/translate/banner.d.ts +6 -0
  11. package/dist/runtime/translate/banner.js +69 -0
  12. package/dist/runtime/translate/basket.d.ts +5 -0
  13. package/dist/runtime/translate/basket.js +40 -0
  14. package/dist/runtime/translate/busca.d.ts +8 -0
  15. package/dist/runtime/translate/busca.js +18 -0
  16. package/dist/runtime/translate/campos-cadastro.d.ts +4 -0
  17. package/dist/runtime/translate/campos-cadastro.js +95 -0
  18. package/dist/runtime/translate/carrinho.d.ts +6 -0
  19. package/dist/runtime/translate/carrinho.js +141 -0
  20. package/dist/runtime/translate/categoria.d.ts +4 -0
  21. package/dist/runtime/translate/categoria.js +75 -0
  22. package/dist/runtime/translate/cliente.d.ts +4 -0
  23. package/dist/runtime/translate/cliente.js +82 -0
  24. package/dist/runtime/translate/configuracoes.d.ts +3 -0
  25. package/dist/runtime/translate/configuracoes.js +46 -0
  26. package/dist/runtime/translate/esqueceu-senha.d.ts +4 -0
  27. package/dist/runtime/translate/esqueceu-senha.js +14 -0
  28. package/dist/runtime/translate/favoritos.d.ts +4 -0
  29. package/dist/runtime/translate/favoritos.js +13 -0
  30. package/dist/runtime/translate/frete.d.ts +3 -0
  31. package/dist/runtime/translate/frete.js +31 -0
  32. package/dist/runtime/translate/home.d.ts +4 -0
  33. package/dist/runtime/translate/home.js +26 -0
  34. package/dist/runtime/translate/index.d.ts +24 -0
  35. package/dist/runtime/translate/index.js +24 -0
  36. package/dist/runtime/translate/menu.d.ts +4 -0
  37. package/dist/runtime/translate/menu.js +124 -0
  38. package/dist/runtime/translate/newsletter.d.ts +3 -0
  39. package/dist/runtime/translate/newsletter.js +5 -0
  40. package/dist/runtime/translate/pagamento.d.ts +4 -0
  41. package/dist/runtime/translate/pagamento.js +66 -0
  42. package/dist/runtime/translate/pagina.d.ts +4 -0
  43. package/dist/runtime/translate/pagina.js +12 -0
  44. package/dist/runtime/translate/parametros.d.ts +7 -0
  45. package/dist/runtime/translate/parametros.js +115 -0
  46. package/dist/runtime/translate/pedidos.d.ts +3 -0
  47. package/dist/runtime/translate/pedidos.js +82 -0
  48. package/dist/runtime/translate/produto.d.ts +12 -0
  49. package/dist/runtime/translate/produto.js +510 -0
  50. package/dist/runtime/translate/redefinir-senha.d.ts +4 -0
  51. package/dist/runtime/translate/redefinir-senha.js +10 -0
  52. package/dist/runtime/translate/redes-sociais.d.ts +3 -0
  53. package/dist/runtime/translate/redes-sociais.js +40 -0
  54. package/dist/runtime/translate/usuario.d.ts +10 -0
  55. package/dist/runtime/translate/usuario.js +102 -0
  56. package/dist/runtime/translate/vitrine-listagem.d.ts +4 -0
  57. package/dist/runtime/translate/vitrine-listagem.js +81 -0
  58. package/dist/runtime/translate/vitrine.d.ts +6 -0
  59. package/dist/runtime/translate/vitrine.js +37 -0
  60. package/dist/runtime/types/godeep.d.ts +1449 -0
  61. package/dist/runtime/types/godeep.js +0 -0
  62. package/dist/runtime/types/index.d.ts +3 -0
  63. package/dist/runtime/types/index.js +3 -0
  64. package/dist/runtime/types/shims-vue.d.ts +10 -0
  65. package/dist/runtime/types/storefront.d.ts +1005 -0
  66. package/dist/runtime/types/storefront.js +0 -0
  67. package/dist/runtime/types/utils.d.ts +67 -0
  68. package/dist/runtime/types/utils.js +20 -0
  69. package/dist/runtime/utils/gerais.d.ts +2 -0
  70. package/dist/runtime/utils/gerais.js +13 -0
  71. package/dist/runtime/utils/index.d.ts +1 -0
  72. package/dist/runtime/utils/index.js +1 -0
  73. package/dist/types.d.mts +3 -0
  74. package/package.json +75 -0
@@ -0,0 +1,82 @@
1
+ const converterNewsletter = (valor) => {
2
+ if (typeof valor === "boolean") return valor;
3
+ if (typeof valor === "string")
4
+ return valor === "S" || valor === "Y" || valor === "true";
5
+ return false;
6
+ };
7
+ export function traduzirClienteResponse(dado, tipoPessoa) {
8
+ const telefone = dado.telefone ? {
9
+ residencial: dado.telefone.residencial || "",
10
+ whatsapp: dado.telefone.whatsapp || "",
11
+ comercial: dado.telefone.comercial1 || dado.telefone.comercial2 || "",
12
+ celular: dado.telefone.celular || ""
13
+ } : {
14
+ residencial: "",
15
+ whatsapp: "",
16
+ comercial: "",
17
+ celular: ""
18
+ };
19
+ if (tipoPessoa === "PF") {
20
+ return {
21
+ email: dado.email || "",
22
+ nome: dado.nome || "",
23
+ cpf: dado.cpf || "",
24
+ rg: dado.rg || "",
25
+ tipoPessoa: "PF",
26
+ dataNascimento: dado.dataNascimento || "",
27
+ sexo: dado.sexo || "",
28
+ newsletters: converterNewsletter(dado.newsletters),
29
+ telefone
30
+ };
31
+ }
32
+ return {
33
+ email: dado.email || "",
34
+ nomeFantasia: dado.nomeFantasia || "",
35
+ razaoSocial: dado.razaoSocial || "",
36
+ cnpj: dado.cnpj || "",
37
+ responsavel: dado.responsavel ?? "",
38
+ inscricaoEstadual: dado.inscricaoEstadual ?? "",
39
+ tipoPessoa: "PJ",
40
+ newsletters: converterNewsletter(dado.newsletters),
41
+ telefone
42
+ };
43
+ }
44
+ export function reverterCliente(dado) {
45
+ const newsletters = dado.newsletters ? "S" : "N";
46
+ const telefoneObj = "telefone" in dado ? dado.telefone : dado.telefone;
47
+ if ("cpf" in dado) {
48
+ return {
49
+ email: dado.email,
50
+ nome: dado.nome,
51
+ cpf: dado.cpf,
52
+ rg: dado.rg,
53
+ dataNascimento: dado.dataNascimento,
54
+ sexo: dado.sexo,
55
+ newsletters,
56
+ telefone: telefoneObj ? {
57
+ residencial: telefoneObj.residencial,
58
+ whatsapp: telefoneObj.whatsapp,
59
+ celular: telefoneObj.celular,
60
+ comercial1: telefoneObj.comercial,
61
+ comercial2: telefoneObj.comercial
62
+ } : void 0
63
+ };
64
+ }
65
+ return {
66
+ email: dado.email,
67
+ nomeFantasia: dado.nomeFantasia,
68
+ razaoSocial: dado.razaoSocial,
69
+ cnpj: dado.cnpj,
70
+ responsavel: dado.responsavel,
71
+ inscricaoEstadual: dado.inscricaoEstadual,
72
+ tipoPessoa: "PJ",
73
+ newsletters,
74
+ telefone: telefoneObj ? {
75
+ residencial: telefoneObj.residencial,
76
+ whatsapp: telefoneObj.whatsapp,
77
+ celular: telefoneObj.celular,
78
+ comercial1: telefoneObj.comercial,
79
+ comercial2: telefoneObj.comercial
80
+ } : void 0
81
+ };
82
+ }
@@ -0,0 +1,3 @@
1
+ import type { GodeepConfiguracoes } from '../types/godeep.js';
2
+ import type { StorefrontConfiguracoes } from '../types/storefront.js';
3
+ export declare function traduzirConfiguracoes(dado: GodeepConfiguracoes): StorefrontConfiguracoes;
@@ -0,0 +1,46 @@
1
+ function montarLogotipo(arquivo, real, urlResizer, urlParametro) {
2
+ if (!arquivo && !real && !urlResizer && !urlParametro) return void 0;
3
+ return {
4
+ real: real ?? arquivo,
5
+ urlResizer: urlResizer ?? void 0,
6
+ urlParametro: urlParametro ?? void 0
7
+ };
8
+ }
9
+ export function traduzirConfiguracoes(dado) {
10
+ const dadosLojaOrigem = dado?.dadosLoja;
11
+ const logotipo = montarLogotipo(
12
+ dadosLojaOrigem?.logotipo?.id,
13
+ dadosLojaOrigem?.logotipo?.real,
14
+ dadosLojaOrigem?.logotipo?.urlResizer,
15
+ dadosLojaOrigem?.logotipo?.urlParametro
16
+ );
17
+ const logotipoRodape = montarLogotipo(
18
+ dadosLojaOrigem?.logotipoRodape?.id,
19
+ dadosLojaOrigem?.logotipoRodape?.real,
20
+ dadosLojaOrigem?.logotipoRodape?.urlResizer,
21
+ dadosLojaOrigem?.logotipoRodape?.urlParametro
22
+ );
23
+ const dadosLoja = dadosLojaOrigem ? {
24
+ logotipo,
25
+ logotipoRodape,
26
+ favicon: dadosLojaOrigem.favicon,
27
+ razaoSocial: dadosLojaOrigem.razaoSocial,
28
+ nomeFantasia: dadosLojaOrigem.nomeFantasia,
29
+ nomeLoja: dadosLojaOrigem.nomeLoja,
30
+ fraseRodape: dadosLojaOrigem.fraseRodape,
31
+ emailSAC: dadosLojaOrigem.emailSAC,
32
+ telefoneSAC: dadosLojaOrigem.telefoneSAC,
33
+ horarioAtendimento: dadosLojaOrigem.horarioAtendimento,
34
+ enderecoLoja: dadosLojaOrigem.enderecoLoja,
35
+ enderecoGoogleMaps: dadosLojaOrigem.enderecoGoogleMaps,
36
+ numeroWhatsapp: dadosLojaOrigem.numeroWhatsapp,
37
+ exibirWhatsapp: dadosLojaOrigem.exibirWhatsapp === "1"
38
+ } : void 0;
39
+ return {
40
+ parametrosGerais: dado.dados?.parametros_gerais,
41
+ dadosLoja,
42
+ layout: dado.dados?.layout,
43
+ modulos: dado.dados?.modulos,
44
+ parametros: dado.dados?.parametros
45
+ };
46
+ }
@@ -0,0 +1,4 @@
1
+ import type { GodeepEsqueceuSenhaTokenResponse } from '../types/godeep.js';
2
+ import type { StorefrontEsqueceuSenhaTokenResponse } from '../types/storefront.js';
3
+ export declare function traduzirEsqueceuSenhaToken(dado: GodeepEsqueceuSenhaTokenResponse): StorefrontEsqueceuSenhaTokenResponse;
4
+ export declare function reverterEsqueceuSenhaToken(dado: StorefrontEsqueceuSenhaTokenResponse): GodeepEsqueceuSenhaTokenResponse;
@@ -0,0 +1,14 @@
1
+ export function traduzirEsqueceuSenhaToken(dado) {
2
+ return {
3
+ token: dado.dados?.token,
4
+ emailHash: dado.dados?.emailCifrado
5
+ };
6
+ }
7
+ export function reverterEsqueceuSenhaToken(dado) {
8
+ return {
9
+ dados: {
10
+ token: dado.token,
11
+ emailCifrado: dado.emailHash
12
+ }
13
+ };
14
+ }
@@ -0,0 +1,4 @@
1
+ import type { GodeepFavoritosResponse } from '../types/godeep.js';
2
+ import type { StorefrontFavoritoResponse } from '../types/storefront.js';
3
+ export declare function traduzirFavoritos(response: GodeepFavoritosResponse): StorefrontFavoritoResponse;
4
+ export declare function reverterFavoritos(response: StorefrontFavoritoResponse): GodeepFavoritosResponse;
@@ -0,0 +1,13 @@
1
+ import { traduzirProdutoParaCard, reverterProdutoCard } from "./produto.js";
2
+ export function traduzirFavoritos(response) {
3
+ return {
4
+ produtos: response.dados?.produtos?.map((produto) => traduzirProdutoParaCard(produto))
5
+ };
6
+ }
7
+ export function reverterFavoritos(response) {
8
+ return {
9
+ dados: {
10
+ produtos: response.produtos?.map((produto) => reverterProdutoCard(produto))
11
+ }
12
+ };
13
+ }
@@ -0,0 +1,3 @@
1
+ import type { GodeepFreteResponse } from '../types/godeep.js';
2
+ import type { StorefrontResultadoFrete } from '../types/storefront.js';
3
+ export declare function traduzirFreteResposta(resposta: GodeepFreteResponse): StorefrontResultadoFrete;
@@ -0,0 +1,31 @@
1
+ function mapearPrazo(opcao) {
2
+ if (typeof opcao.prazo_entrega === "number") return opcao.prazo_entrega;
3
+ if (typeof opcao.prazo_crossdocking === "number") {
4
+ return (opcao.prazo_crossdocking ?? 0) + (opcao.dias_processamento ?? 0);
5
+ }
6
+ return void 0;
7
+ }
8
+ function mapearPrazoTexto(opcao) {
9
+ if (typeof opcao.prazo_entrega === "number") {
10
+ const sufixo = typeof opcao.tipo_prazo === "string" ? opcao.tipo_prazo : " dias \xFAteis";
11
+ return `${opcao.prazo_entrega}${sufixo}`;
12
+ }
13
+ return opcao.tipo_prazo;
14
+ }
15
+ function traduzirOpcaoFrete(opcao) {
16
+ return {
17
+ nome: opcao.nome ?? opcao.transportadora ?? opcao.nome_admin ?? "",
18
+ valor: opcao.valor ?? opcao.valor_original ?? 0,
19
+ prazo: mapearPrazo(opcao),
20
+ prazoTexto: mapearPrazoTexto(opcao),
21
+ codigo: opcao.codigo ?? opcao.cotacao_id
22
+ };
23
+ }
24
+ export function traduzirFreteResposta(resposta) {
25
+ if (!Array.isArray(resposta)) {
26
+ return { opcoes: [], erro: "Resposta de frete inv\xE1lida" };
27
+ }
28
+ const opcoes = resposta.filter((opcao) => opcao && typeof opcao === "object").map((opcao) => traduzirOpcaoFrete(opcao)).filter((opcao) => opcao.nome || opcao.valor !== void 0);
29
+ const erro = resposta.find((opcao) => opcao.erro && opcao.erro !== "0")?.erro;
30
+ return { opcoes, erro };
31
+ }
@@ -0,0 +1,4 @@
1
+ import type { GodeepCmsHome } from '../types/godeep.js';
2
+ import type { StorefrontCmsHome } from '../types/storefront.js';
3
+ export declare function traduzirCmsHome(dado: GodeepCmsHome[]): StorefrontCmsHome[];
4
+ export declare function reverterCmsHome(dado: StorefrontCmsHome): GodeepCmsHome;
@@ -0,0 +1,26 @@
1
+ export function traduzirCmsHome(dado) {
2
+ const dados = [];
3
+ dado.map((item) => {
4
+ dados.push({
5
+ tipo: item.type,
6
+ tipoComponente: item.type_component,
7
+ idComponente: item.component_id,
8
+ posicaoComponente: item.component_position,
9
+ ordem: item.order,
10
+ slug: item.slug,
11
+ localizacao: item.localization
12
+ });
13
+ });
14
+ return dados;
15
+ }
16
+ export function reverterCmsHome(dado) {
17
+ return {
18
+ type: dado.tipo,
19
+ type_component: dado.tipoComponente,
20
+ component_id: dado.idComponente,
21
+ component_position: dado.posicaoComponente,
22
+ order: dado.ordem,
23
+ slug: dado.slug,
24
+ localization: dado.localizacao
25
+ };
26
+ }
@@ -0,0 +1,24 @@
1
+ export * from './produto.js';
2
+ export * from './categoria.js';
3
+ export * from './vitrine-listagem.js';
4
+ export * from './basket.js';
5
+ export * from './carrinho.js';
6
+ export * from './usuario.js';
7
+ export * from './busca.js';
8
+ export * from './banner.js';
9
+ export * from './menu.js';
10
+ export * from './cliente.js';
11
+ export * from './pagamento.js';
12
+ export * from './home.js';
13
+ export * from './pagina.js';
14
+ export * from './esqueceu-senha.js';
15
+ export * from './redefinir-senha.js';
16
+ export * from './favoritos.js';
17
+ export * from './avaliacoes.js';
18
+ export * from './configuracoes.js';
19
+ export * from './redes-sociais.js';
20
+ export * from './frete.js';
21
+ export * from './newsletter.js';
22
+ export * from './parametros.js';
23
+ export * from './pedidos.js';
24
+ export * from './campos-cadastro.js';
@@ -0,0 +1,24 @@
1
+ export * from "./produto.js";
2
+ export * from "./categoria.js";
3
+ export * from "./vitrine-listagem.js";
4
+ export * from "./basket.js";
5
+ export * from "./carrinho.js";
6
+ export * from "./usuario.js";
7
+ export * from "./busca.js";
8
+ export * from "./banner.js";
9
+ export * from "./menu.js";
10
+ export * from "./cliente.js";
11
+ export * from "./pagamento.js";
12
+ export * from "./home.js";
13
+ export * from "./pagina.js";
14
+ export * from "./esqueceu-senha.js";
15
+ export * from "./redefinir-senha.js";
16
+ export * from "./favoritos.js";
17
+ export * from "./avaliacoes.js";
18
+ export * from "./configuracoes.js";
19
+ export * from "./redes-sociais.js";
20
+ export * from "./frete.js";
21
+ export * from "./newsletter.js";
22
+ export * from "./parametros.js";
23
+ export * from "./pedidos.js";
24
+ export * from "./campos-cadastro.js";
@@ -0,0 +1,4 @@
1
+ import type { GodeepMenu } from '../types/godeep.js';
2
+ import type { StorefrontMenu } from '../types/storefront.js';
3
+ export declare function traduzirMenu(dado: GodeepMenu): StorefrontMenu;
4
+ export declare function reverterMenu(dado: StorefrontMenu): GodeepMenu;
@@ -0,0 +1,124 @@
1
+ const normalizarLink = (link) => {
2
+ if (!link) return "";
3
+ if (link.startsWith("/")) return link;
4
+ if (link.startsWith("http://") || link.startsWith("https://")) return link;
5
+ return `/${link}`;
6
+ };
7
+ const traduzirSubmenu = (submenu) => {
8
+ return submenu?.map((subItem) => ({
9
+ identificador: subItem.identificador,
10
+ classIcone: subItem.class_icone,
11
+ titulo: subItem.titulo ?? subItem.nome,
12
+ exibirMenuTodasCategorias: subItem.exibir_menu_todas_categorias,
13
+ link: normalizarLink(subItem.link),
14
+ slug: subItem.slug,
15
+ imagem: subItem.imagem,
16
+ imagem2: subItem.imagem2,
17
+ imageWidth: subItem.imageWidth,
18
+ imageHeight: subItem.imageHeight,
19
+ submenu: traduzirSubmenu(subItem.submenu)
20
+ }));
21
+ };
22
+ export function traduzirMenu(dado) {
23
+ return {
24
+ menu: {
25
+ principal: dado.menu?.principal?.map((item) => ({
26
+ id: item.id,
27
+ nome: item.nome,
28
+ link: normalizarLink(item.link),
29
+ exibirCategorias: item.exibir_categorias,
30
+ produto: item.produto,
31
+ target: item.target,
32
+ image: item.image,
33
+ imageWidth: item.imageWidth,
34
+ imageHeight: item.imageHeight,
35
+ icones: item.icones,
36
+ iconePrincipal: item.icone_principal,
37
+ iconeSecundario: item.icone_secundario,
38
+ submenu: traduzirSubmenu(item.submenu)
39
+ })),
40
+ categorias: {
41
+ selecionadas: dado.menu?.categorias?.selecionadas,
42
+ padrao: dado.menu?.categorias?.padrao?.map((item) => ({
43
+ id: item.id,
44
+ nome: item.nome,
45
+ link: normalizarLink(item.link),
46
+ slug: item.slug,
47
+ exibirMenuTodasCategorias: item.exibir_menu_todas_categorias,
48
+ imagem: item.imagem,
49
+ imagem2: item.imagem2,
50
+ submenu: traduzirSubmenu(item.submenu)
51
+ }))
52
+ },
53
+ links: dado.menu?.links,
54
+ rodape: dado.menu?.rodape?.map((item) => ({
55
+ titulo: item.titulo,
56
+ identificador: item.identificador,
57
+ link: normalizarLink(item.link),
58
+ tipo: item.tipo,
59
+ classIcone: item.class_icone,
60
+ urlImagem: item.url_imagem,
61
+ submenu: traduzirSubmenu(item.submenu)
62
+ }))
63
+ }
64
+ };
65
+ }
66
+ export function reverterMenu(dado) {
67
+ const revertSubmenu = (submenu) => submenu?.map((item) => ({
68
+ identificador: item.identificador,
69
+ class_icone: item.classIcone,
70
+ titulo: item.titulo,
71
+ exibir_menu_todas_categorias: item.exibirMenuTodasCategorias,
72
+ link: item.link,
73
+ slug: item.slug,
74
+ imagem: item.imagem,
75
+ imagem2: item.imagem2,
76
+ imageWidth: item.imageWidth,
77
+ imageHeight: item.imageHeight,
78
+ submenu: revertSubmenu(item.submenu),
79
+ nome: item.titulo
80
+ // fallback
81
+ }));
82
+ return {
83
+ menu: {
84
+ principal: dado.menu?.principal?.map((item) => ({
85
+ id: item.id,
86
+ nome: item.nome,
87
+ link: item.link,
88
+ exibir_categorias: item.exibirCategorias,
89
+ produto: item.produto,
90
+ target: item.target,
91
+ image: item.image,
92
+ imageWidth: item.imageWidth,
93
+ imageHeight: item.imageHeight,
94
+ icones: item.icones,
95
+ icone_principal: item.iconePrincipal,
96
+ icone_secundario: item.iconeSecundario,
97
+ submenu: revertSubmenu(item.submenu)
98
+ })),
99
+ categorias: {
100
+ selecionadas: dado.menu?.categorias?.selecionadas,
101
+ padrao: dado.menu?.categorias?.padrao?.map((item) => ({
102
+ id: item.id,
103
+ nome: item.nome,
104
+ link: item.link,
105
+ slug: item.slug,
106
+ exibir_menu_todas_categorias: item.exibirMenuTodasCategorias,
107
+ imagem: item.imagem,
108
+ imagem2: item.imagem2,
109
+ submenu: revertSubmenu(item.submenu)
110
+ }))
111
+ },
112
+ links: dado.menu?.links,
113
+ rodape: dado.menu?.rodape?.map((item) => ({
114
+ titulo: item.titulo,
115
+ identificador: item.identificador,
116
+ link: item.link,
117
+ tipo: item.tipo,
118
+ class_icone: item.classIcone,
119
+ url_imagem: item.urlImagem,
120
+ submenu: revertSubmenu(item.submenu)
121
+ }))
122
+ }
123
+ };
124
+ }
@@ -0,0 +1,3 @@
1
+ import type { GodeepNewsletterResponse } from '../types/godeep.js';
2
+ import type { StorefrontNewsletterResposta } from '../types/storefront.js';
3
+ export declare function traduzirNewsletterResposta(resposta: GodeepNewsletterResponse | null): StorefrontNewsletterResposta;
@@ -0,0 +1,5 @@
1
+ export function traduzirNewsletterResposta(resposta) {
2
+ return {
3
+ mensagens: resposta?.mensagens ?? []
4
+ };
5
+ }
@@ -0,0 +1,4 @@
1
+ import type { GodeepPagamentos } from '../types/godeep.js';
2
+ import type { StorefrontPagamentos } from '../types/storefront.js';
3
+ export declare function traduzirPagamentos(pagamento: GodeepPagamentos): StorefrontPagamentos;
4
+ export declare function reverterPagamentos(pagamento: StorefrontPagamentos): GodeepPagamentos;
@@ -0,0 +1,66 @@
1
+ export function traduzirPagamentos(pagamento) {
2
+ return {
3
+ dados: pagamento?.dados?.map((dado) => ({
4
+ id: dado?.id,
5
+ nome: dado?.nome,
6
+ imagem: dado?.imagem,
7
+ imagemCustomizada: dado?.imagemCustomizada,
8
+ imagemCompleta: dado?.imagemCompleta,
9
+ condicoes: dado?.condicoes?.map((condicao) => ({
10
+ idCondicaoPagamento: condicao?.id_condpagto,
11
+ idMeioPagamento: condicao?.id_meiopagto,
12
+ parcelasCondicaoPagamento: condicao?.parcelas_condpagto,
13
+ porcentagem: condicao?.porcentagem,
14
+ parcelaMinima: condicao?.parcela_minima,
15
+ bcashJuros: condicao?.bcash_juros,
16
+ ativo: condicao?.ativo,
17
+ tipoVariacao: condicao?.tipo_variacao,
18
+ habilita2Cartoes: condicao?.habilita_2cartoes,
19
+ enviarTotalComJuros: condicao?.enviar_total_com_juros,
20
+ nomeParcela: condicao?.nome_parcela,
21
+ codigoExportacao: condicao?.codigo_exportacao,
22
+ somenteTelevendes: condicao?.somente_televendas,
23
+ visivelCliente: condicao?.visivel_cliente,
24
+ excluido: condicao?.excluido
25
+ }))
26
+ })),
27
+ links: pagamento?.links && Object.keys(pagamento?.links ?? {}).length > 0 ? {
28
+ autorizacao: pagamento?.links?.href,
29
+ link: pagamento?.links?.href,
30
+ metodo: pagamento?.links?.method
31
+ } : void 0
32
+ };
33
+ }
34
+ export function reverterPagamentos(pagamento) {
35
+ return {
36
+ dados: pagamento?.dados?.map((dado) => ({
37
+ id: dado?.id,
38
+ nome: dado?.nome,
39
+ imagem: dado?.imagem,
40
+ imagemCustomizada: dado?.imagemCustomizada,
41
+ imagemCompleta: dado?.imagemCompleta,
42
+ condicoes: dado?.condicoes?.map((condicao) => ({
43
+ idCondicaoPagamento: condicao?.idCondicaoPagamento,
44
+ idMeioPagamento: condicao?.idMeioPagamento,
45
+ parcelasCondicaoPagamento: condicao?.parcelasCondicaoPagamento,
46
+ porcentagem: condicao?.porcentagem,
47
+ parcelaMinima: condicao?.parcelaMinima,
48
+ bcashJuros: condicao?.bcashJuros,
49
+ ativo: condicao?.ativo,
50
+ tipoVariacao: condicao?.tipoVariacao,
51
+ habilita2Cartoes: condicao?.habilita2Cartoes,
52
+ enviarTotalComJuros: condicao?.enviarTotalComJuros,
53
+ nomeParcela: condicao?.nomeParcela,
54
+ codigoExportacao: condicao?.codigoExportacao,
55
+ somenteTelevendes: condicao?.somenteTelevendes,
56
+ visivelCliente: condicao?.visivelCliente,
57
+ excluido: condicao?.excluido
58
+ }))
59
+ })),
60
+ links: pagamento?.links ? {
61
+ self: pagamento?.links?.autorizacao,
62
+ href: pagamento?.links?.link,
63
+ method: pagamento?.links?.metodo
64
+ } : void 0
65
+ };
66
+ }
@@ -0,0 +1,4 @@
1
+ import type { GodeepPaginaResponse } from '../types/godeep.js';
2
+ import type { StorefrontPaginaResponse } from '../types/storefront.js';
3
+ export declare function traduzirPagina(dado: GodeepPaginaResponse): StorefrontPaginaResponse;
4
+ export declare function reverterPagina(dado: StorefrontPaginaResponse): GodeepPaginaResponse;
@@ -0,0 +1,12 @@
1
+ export function traduzirPagina(dado) {
2
+ return {
3
+ conteudo: dado.dados?.conteudo
4
+ };
5
+ }
6
+ export function reverterPagina(dado) {
7
+ return {
8
+ dados: {
9
+ conteudo: dado.conteudo
10
+ }
11
+ };
12
+ }
@@ -0,0 +1,7 @@
1
+ import type { GodeepparametrosResponse } from '../types/godeep.js';
2
+ import type { StorefrontFiltroSecao, StorefrontFiltroPreco, StorefrontSubcategoriaItem } from '../types/storefront.js';
3
+ export declare function traduzirParametros(resposta: GodeepparametrosResponse | null): {
4
+ filtros: StorefrontFiltroSecao[];
5
+ subcategorias: StorefrontSubcategoriaItem[];
6
+ faixasPreco: StorefrontFiltroPreco[];
7
+ };
@@ -0,0 +1,115 @@
1
+ function mapearSubcategorias(subcategorias) {
2
+ if (!subcategorias?.subcategorias || !Array.isArray(subcategorias.subcategorias)) return [];
3
+ if (subcategorias.subcategorias.length === 0) return [];
4
+ return [
5
+ {
6
+ id: "subcategoria",
7
+ name: "Categorias",
8
+ options: subcategorias.subcategorias.map((sub) => ({
9
+ value: sub.path || sub.slug || "",
10
+ label: sub.nome || "",
11
+ checked: false
12
+ }))
13
+ }
14
+ ];
15
+ }
16
+ function mapearFiltros(filtros) {
17
+ if (!filtros || !Array.isArray(filtros) || filtros.length === 0) return [];
18
+ return [
19
+ {
20
+ id: "filtro",
21
+ name: "Filtros",
22
+ options: filtros.map((filtro) => ({
23
+ value: filtro.slug || "",
24
+ label: filtro.nome || "",
25
+ checked: false
26
+ }))
27
+ }
28
+ ];
29
+ }
30
+ function mapearFiltrosExtras(filtrosExtras) {
31
+ if (!filtrosExtras || !Array.isArray(filtrosExtras) || filtrosExtras.length === 0) return [];
32
+ const secoes = [];
33
+ filtrosExtras.forEach((extra) => {
34
+ if (!extra) return;
35
+ const filhos = extra.filhos?.filter(Boolean) ?? [];
36
+ if (filhos.length === 0) return;
37
+ secoes.push({
38
+ id: `filtro-extra-${extra.slug || extra.nome || "extra"}`,
39
+ name: extra.nome || extra.slug || "Filtros extras",
40
+ options: filhos.map((filho) => ({
41
+ value: filho.slug || String(filho.id ?? ""),
42
+ label: filho.nome || "",
43
+ checked: false
44
+ }))
45
+ });
46
+ });
47
+ return secoes;
48
+ }
49
+ function mapearMarcas(marcas) {
50
+ if (!marcas || !Array.isArray(marcas) || marcas.length === 0) return [];
51
+ return [
52
+ {
53
+ id: "marca",
54
+ name: "Marcas",
55
+ options: marcas.map((marca) => ({
56
+ value: String(marca.id ?? ""),
57
+ label: marca.nome || "",
58
+ checked: false,
59
+ id: marca.id
60
+ }))
61
+ }
62
+ ];
63
+ }
64
+ function mapearGrades(grades) {
65
+ if (!grades || !Array.isArray(grades) || grades.length === 0) return [];
66
+ const secoes = [];
67
+ grades.forEach((grade) => {
68
+ if (grade.filhos && Array.isArray(grade.filhos) && grade.filhos.length > 0) {
69
+ secoes.push({
70
+ id: "grade",
71
+ name: `Tamanho ${grade.nome || ""}`,
72
+ options: grade.filhos.map((filho) => ({
73
+ value: String(filho.opcao || ""),
74
+ label: String(filho.opcao || ""),
75
+ checked: false
76
+ }))
77
+ });
78
+ }
79
+ });
80
+ return secoes;
81
+ }
82
+ export function traduzirParametros(resposta) {
83
+ if (!resposta) {
84
+ return { filtros: [], subcategorias: [], faixasPreco: [] };
85
+ }
86
+ const secoes = [];
87
+ if (resposta.precos) {
88
+ secoes.push({
89
+ id: "preco",
90
+ name: "Faixa de Pre\xE7o",
91
+ options: [],
92
+ min: resposta.precos.min,
93
+ max: resposta.precos.max,
94
+ avg: resposta.precos.avg
95
+ });
96
+ }
97
+ secoes.push(...mapearSubcategorias(resposta.subcategorias));
98
+ secoes.push(...mapearFiltros(resposta.filtros));
99
+ secoes.push(...mapearFiltrosExtras(resposta.filtrosExtras));
100
+ secoes.push(...mapearMarcas(resposta.marcas));
101
+ secoes.push(...mapearGrades(resposta.grades));
102
+ const subcategorias = resposta.subcategorias?.subcategorias?.map((sub) => ({
103
+ id: sub.id,
104
+ nome: sub.nome,
105
+ slug: sub.slug,
106
+ path: sub.path,
107
+ imagem: sub.imagem
108
+ })) ?? [];
109
+ const faixasPreco = resposta.precos?.filtros ?? [];
110
+ return {
111
+ filtros: secoes,
112
+ subcategorias,
113
+ faixasPreco
114
+ };
115
+ }
@@ -0,0 +1,3 @@
1
+ import type { GodeepPedidosResponse } from '../types/godeep.js';
2
+ import type { StorefrontPedidosResponse } from '../types/storefront.js';
3
+ export declare function traduzirPedidos(resposta: GodeepPedidosResponse | null): StorefrontPedidosResponse;