rapida-partner 5.0.0 → 6.1.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapida-partner",
3
- "version": "5.0.0",
3
+ "version": "6.1.1",
4
4
  "main": "dist/index.js",
5
5
  "module": "index.ts",
6
6
  "files": [
@@ -45,10 +45,10 @@ export interface IAiAgentConfig {
45
45
  };
46
46
 
47
47
  infrastructure: {
48
- // "instagram" is a stub today: the generated webhook accepts the
49
- // request but does not process incoming messages yet. Prefer
50
- // "whatsapp"/"telegram" until it is implemented.
51
- messengers: ("whatsapp" | "instagram" | "telegram")[];
48
+ // At least one. "whatsapp" uses backend[].whatsapp (Meta Cloud API);
49
+ // "telegram" uses backend[].telegram.telegramBotToken and is not yet
50
+ // validated in a real conversation.
51
+ messengers: ("whatsapp" | "telegram")[];
52
52
  // The provider key comes from the project integrations, always with
53
53
  // service "chat": deepseekIntegration, geminiIntegration or
54
54
  // openaiIntegration. The code generator warns when it is missing (the
@@ -43,7 +43,8 @@ export interface IPublicContract {
43
43
 
44
44
  /**
45
45
  * Agregação de um contrato público. A resposta é uma lista de
46
- * `{ _id: <valor de groupBy>, <campo de sum>: <total> }`.
46
+ * `{ _id: <valor de groupBy>, <campo de sum>: <total> }`, mais `count` com
47
+ * o número de registros quando `count` é true.
47
48
  */
48
49
  export interface IContractAggregation {
49
50
  // Último segmento da rota: GET <endpoint>/aggregations/<id>.
@@ -52,6 +53,9 @@ export interface IContractAggregation {
52
53
  groupBy: string;
53
54
  // Campos numéricos somados em cada grupo (ex.: ["inputQuantity"]).
54
55
  sum: string[];
56
+ // Inclui em cada grupo o número de registros, em "count" (ex.: média de
57
+ // notas = soma de rating / count).
58
+ count?: boolean;
55
59
  }
56
60
 
57
61
  export interface IContractRequest {
@@ -46,6 +46,11 @@ interface IWhatsapp {
46
46
  whatsappAppSecret?: string;
47
47
  }
48
48
 
49
+ interface ITelegram {
50
+ // Token do bot criado no BotFather. Importe de constants/secrets.
51
+ telegramBotToken: string;
52
+ }
53
+
49
54
  interface IEmail {
50
55
  smtpUser?: string;
51
56
  smtpPass?: string;
@@ -91,6 +96,18 @@ interface IMarketplace {
91
96
  // Em que campo do produto do vendedor está cada informação usada pela
92
97
  // vitrine. O gerador tem um padrão para cada campo omitido.
93
98
  productFieldMap?: IMarketplaceProductFieldMap;
99
+ // Cupons do vendedor (módulo pronto getStoreCouponsModule, funcionalidade
100
+ // "coupons"). A loja valida o código e desconta no servidor.
101
+ couponsEndpoint?: string;
102
+ // Avaliações (módulo pronto getStoreReviewsModule, funcionalidade
103
+ // "reviews"). A loja cria a avaliação de quem recebeu o pedido e lê as
104
+ // aprovadas; a nota média vem da agregação "<endpoint>/aggregations/rating".
105
+ reviewsEndpoint?: string;
106
+ // Pedidos de devolução e troca (módulo pronto getStoreReturnsModule,
107
+ // funcionalidade "returns").
108
+ returnsEndpoint?: string;
109
+ // Artigos do blog (módulo pronto getStoreBlogModule, funcionalidade "blog").
110
+ blogPostsEndpoint?: string;
94
111
  }
95
112
 
96
113
  export interface IMarketplaceProductFieldMap {
@@ -144,6 +161,10 @@ export interface IBackend {
144
161
  storage?: IStorage;
145
162
  logging?: ILogging;
146
163
  whatsapp?: IWhatsapp;
164
+ // Só para o agente de IA com o mensageiro "telegram"
165
+ // (aiAgentConfig.infrastructure.messengers). Vai para TELEGRAM_BOT_TOKEN do
166
+ // .env do agente; o backend Nest não usa.
167
+ telegram?: ITelegram;
147
168
  email?: IEmail;
148
169
  marketplace?: IMarketplace;
149
170
  service?: IService;
@@ -31,6 +31,8 @@ export interface IProject {
31
31
  // "referralCommerce": vitrine sem venda própria; cada produto leva por link de
32
32
  // afiliado para o anúncio na fonte de origem (IBackend.referralSources), com
33
33
  // a curadoria de IProject.referralCuration. Requer suporte no gerador.
34
+ // "aiAgent": sinônimo de "backoffice" (mesmo painel). O agente de IA não
35
+ // depende do skeleton: é gerado sempre que aiAgentConfig existe.
34
36
  skeleton:
35
37
  | "backoffice"
36
38
  | "ecommerce"
@@ -96,6 +98,9 @@ export interface IProject {
96
98
  styles?: IStyle[];
97
99
  flowChart?: IFlowChart;
98
100
  dashboard?: IComponent[];
101
+ // Agente de IA (Kunlatalk) do projeto. Com ele, o gerador cria o agente em
102
+ // qualquer skeleton (ex.: um backoffice ou uma loja com atendente), além do
103
+ // frontend e do backend.
99
104
  aiAgentConfig?: IAiAgentConfig;
100
105
  notifications?: INotification[];
101
106
  repositories?: IProjectRepositories;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Artigo do blog da loja (funcionalidade "blog"), escrito no Backoffice do
3
+ * vendedor pelo módulo pronto getStoreBlogModule e lido pela loja por
4
+ * IMarketplace.blogPostsEndpoint. Os campos são os nomes do form.
5
+ */
6
+ export interface IStoreBlogPost {
7
+ title: string;
8
+ // Nome amigável na URL; um por workspace.
9
+ slug: string;
10
+ excerpt?: string;
11
+ // Conteúdo em HTML (editor de texto rico).
12
+ content: string;
13
+ // URL da imagem de capa (upload no form).
14
+ coverImage?: string;
15
+ // Data de publicação (ISO 8601); a loja só lista os publicados até agora.
16
+ publishedAt?: string;
17
+ isPublished: boolean;
18
+ }
@@ -0,0 +1,26 @@
1
+ /** Como o cupom desconta: percentual do subtotal ou valor fixo. */
2
+ export type TStoreCouponDiscountType = "percentage" | "value";
3
+
4
+ /**
5
+ * Cupom de desconto cadastrado no Backoffice do vendedor pelo módulo pronto
6
+ * getStoreCouponsModule e lido pela loja por IMarketplace.couponsEndpoint. A
7
+ * loja valida e desconta no servidor; o uso é contado pelos pedidos da loja.
8
+ * Os campos são os nomes do form do módulo pronto.
9
+ */
10
+ export interface IStoreCoupon {
11
+ // Código digitado pelo cliente; um por workspace, sem diferenciar maiúsculas.
12
+ code: string;
13
+ description?: string;
14
+ discountType: TStoreCouponDiscountType;
15
+ // Percentual (0 a 100) ou valor, conforme discountType.
16
+ discountValue: number;
17
+ // Subtotal mínimo do carrinho para o cupom valer.
18
+ minimumSubtotal?: number;
19
+ // Período de validade (ISO 8601). Sem datas, vale sempre.
20
+ startDate?: string;
21
+ endDate?: string;
22
+ // Usos no total e por cliente, contados nos pedidos aprovados da loja.
23
+ usageLimit?: number;
24
+ usageLimitPerCustomer?: number;
25
+ isActive: boolean;
26
+ }
@@ -0,0 +1,35 @@
1
+ /** O que o cliente pede: devolver (reembolso) ou trocar. */
2
+ export type TStoreReturnType = "return" | "exchange";
3
+
4
+ export type TStoreReturnReason = "defect" | "wrongItem" | "notAsDescribed" | "regret" | "other";
5
+
6
+ /** Andamento do pedido de devolução ou troca no vendedor. */
7
+ export type TStoreReturnStatus = "requested" | "approved" | "rejected" | "received" | "completed";
8
+
9
+ export interface IStoreReturnItem {
10
+ productId: string;
11
+ name: string;
12
+ quantity: number;
13
+ }
14
+
15
+ /**
16
+ * Pedido de devolução ou troca aberto pelo cliente em Minha conta e enviado
17
+ * pela loja ao vendedor (IMarketplace.returnsEndpoint, módulo pronto
18
+ * getStoreReturnsModule). O vendedor aprova ou recusa e acompanha o retorno;
19
+ * o reembolso continua sendo da loja (estorno no gateway). Os campos são os
20
+ * nomes do form.
21
+ */
22
+ export interface IStoreReturnRequest {
23
+ storeOrderId: string;
24
+ customerName?: string;
25
+ customerEmail?: string;
26
+ type: TStoreReturnType;
27
+ reason: TStoreReturnReason;
28
+ items: IStoreReturnItem[];
29
+ comment?: string;
30
+ status: TStoreReturnStatus;
31
+ // Resposta do vendedor ao cliente (instruções de envio, motivo da recusa).
32
+ resolutionNotes?: string;
33
+ // Código de postagem do produto devolvido.
34
+ returnTrackingCode?: string;
35
+ }
@@ -0,0 +1,21 @@
1
+ /** Moderação da avaliação no vendedor: só as aprovadas aparecem na vitrine. */
2
+ export type TStoreReviewStatus = "pending" | "approved" | "rejected";
3
+
4
+ /**
5
+ * Avaliação de produto enviada pela loja ao vendedor (IMarketplace.reviewsEndpoint,
6
+ * módulo pronto getStoreReviewsModule). Só cliente com pedido entregue avalia;
7
+ * o vendedor modera e pode responder. Os campos são os nomes do form.
8
+ */
9
+ export interface IStoreReview {
10
+ productId: string;
11
+ // Pedido da loja que comprova a compra; uma avaliação por produto e pedido.
12
+ storeOrderId: string;
13
+ customerName: string;
14
+ // Nota de 1 a 5.
15
+ rating: number;
16
+ title?: string;
17
+ comment?: string;
18
+ status: TStoreReviewStatus;
19
+ // Resposta pública do vendedor.
20
+ reply?: string;
21
+ }
@@ -11,7 +11,10 @@ export type TStoreFeature =
11
11
  | "installments"
12
12
  | "favorites"
13
13
  | "blog"
14
- | "shipping";
14
+ | "shipping"
15
+ | "coupons"
16
+ | "reviews"
17
+ | "returns";
15
18
 
16
19
  export type TStoreFeatureToggle = `${TStoreFeature}Enabled`;
17
20
 
@@ -73,6 +76,47 @@ export interface IStoreSettings extends Partial<Record<TStoreFeatureToggle, bool
73
76
  originZipCode?: string;
74
77
  freeShippingAbove?: number;
75
78
  shippingRanges?: IStoreShippingRange[];
79
+
80
+ // Só tem efeito com a funcionalidade "returns": dias, a partir da entrega,
81
+ // em que o cliente pode pedir devolução ou troca (o CDC exige ao menos 7
82
+ // para compra fora da loja física).
83
+ returnWindowDays?: number;
84
+
85
+ // Páginas institucionais e legais, em HTML (editor de texto rico). Cada
86
+ // página só é publicada, com link no rodapé, quando tem texto. O contato usa
87
+ // os campos de contato acima.
88
+ aboutText?: string;
89
+ privacyPolicyText?: string;
90
+ termsText?: string;
91
+ returnsPolicyText?: string;
92
+ // Texto do aviso de cookies; sem ele, o aviso não aparece.
93
+ cookieNoticeText?: string;
94
+
95
+ // Home: banners do carrossel (na ordem), benefícios e produtos em destaque
96
+ // (ids dos produtos do vendedor). Sem banners nem benefícios, a vitrine usa
97
+ // os textos padrão.
98
+ banners?: IStoreBanner[];
99
+ benefits?: IStoreBenefit[];
100
+ featuredProductIds?: string[];
101
+ }
102
+
103
+ /** Banner do carrossel da home. */
104
+ export interface IStoreBanner {
105
+ // URL da imagem (upload no Backoffice).
106
+ image?: string;
107
+ title: string;
108
+ subtitle?: string;
109
+ // Destino do botão: caminho da loja (ex.: "/busca?categoria=blu-ray") ou URL.
110
+ linkUrl?: string;
111
+ linkLabel?: string;
112
+ }
113
+
114
+ /** Benefício mostrado na home (ex.: "Frete grátis acima de R$ 300"). */
115
+ export interface IStoreBenefit {
116
+ // Nome de um ícone Lucide (ex.: "truck", "shield-check").
117
+ icon?: string;
118
+ title: string;
119
+ text?: string;
76
120
  }
77
121
 
78
122
  /** Faixa de CEP (inclusiva, somente dígitos) com valor e prazo do frete. */
@@ -0,0 +1,108 @@
1
+ import { EDataType } from "../../enums/form.enum";
2
+ import type { IPublicContract } from "../../interfaces/form-contract.interface";
3
+ import type { IForm, IFormElement } from "../../interfaces/form.interface";
4
+ import type { IList } from "../../interfaces/list.interface";
5
+ import type { IModule } from "../../interfaces/project.interface";
6
+ import { tr } from "../store-settings/translations";
7
+
8
+ export const STORE_BLOG_POSTS_ENDPOINT = "/store-blog-posts";
9
+
10
+ export interface IStoreBlogModuleOptions {
11
+ publicAccess?: IPublicContract["access"];
12
+ allowedOrigins?: string[];
13
+ }
14
+
15
+ const ENTITY = "storeBlogPosts";
16
+
17
+ const postElements: IFormElement[] = [
18
+ { type: "input", name: "title", dataType: EDataType.TEXT, label: tr("Título", "Title", "Título"), isRequired: true, space: 2 },
19
+ {
20
+ type: "input",
21
+ name: "slug",
22
+ dataType: EDataType.TEXT,
23
+ label: tr("Nome na URL", "URL name", "Nombre en la URL"),
24
+ tooltip: tr("Letras minúsculas, números e hífen (ex.: como-guardar-blu-ray)", "Lowercase letters, numbers and hyphens (e.g. how-to-store-blu-ray)", "Letras minúsculas, números y guion (ej.: como-guardar-blu-ray)"),
25
+ isRequired: true,
26
+ isUnique: true,
27
+ space: 2,
28
+ },
29
+ { type: "input", name: "excerpt", dataType: EDataType.TEXT, label: tr("Resumo", "Excerpt", "Resumen") },
30
+ {
31
+ type: "file",
32
+ name: "coverImage",
33
+ dataType: EDataType.TEXT,
34
+ label: tr("Imagem de capa", "Cover image", "Imagen de portada"),
35
+ validators: ["onlyImages"],
36
+ storageConfig: { path: "store-blog-posts", fileNameStrategy: "uuid", visibility: "public" },
37
+ },
38
+ {
39
+ type: "input",
40
+ name: "content",
41
+ dataType: EDataType.WYSIWYG,
42
+ label: tr("Conteúdo", "Content", "Contenido"),
43
+ isRequired: true,
44
+ storageConfig: { path: "store-blog-posts", fileNameStrategy: "uuid", visibility: "public" },
45
+ },
46
+ { type: "datepicker", name: "publishedAt", label: tr("Publicar em", "Publish on", "Publicar el") },
47
+ { type: "switch", name: "isPublished", label: tr("Publicado", "Published", "Publicado") },
48
+ ];
49
+
50
+ export const getStoreBlogPostForm = (options: IStoreBlogModuleOptions = {}): IForm => ({
51
+ componentType: "form",
52
+ id: "storeBlogPostForm",
53
+ title: tr("Artigo do blog", "Blog post", "Artículo del blog"),
54
+ icon: "newspaper",
55
+ guards: "isAuthorized",
56
+ elements: postElements,
57
+ contracts: [
58
+ {
59
+ id: ENTITY,
60
+ endpoint: STORE_BLOG_POSTS_ENDPOINT,
61
+ actions: ["create", "get", "getById", "update", "softDelete"],
62
+ request: { entity: ENTITY, fields: [] },
63
+ },
64
+ ],
65
+ publicContracts: [
66
+ {
67
+ id: "storeBlogPostsFromStore",
68
+ endpoint: STORE_BLOG_POSTS_ENDPOINT,
69
+ actions: ["get", "getById"],
70
+ access: options.publicAccess ?? "trustedCallers",
71
+ ...(options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {}),
72
+ request: { entity: ENTITY, fields: [] },
73
+ },
74
+ ],
75
+ });
76
+
77
+ export const getStoreBlogPostList = (): IList => ({
78
+ componentType: "list",
79
+ id: "storeBlogPostList",
80
+ title: tr("Blog", "Blog", "Blog"),
81
+ guards: ["isAuthorized"],
82
+ dataSource: { endpoint: STORE_BLOG_POSTS_ENDPOINT, paramType: "query", hasAuthentication: true },
83
+ listItems: [
84
+ { property: "title", type: "title", label: tr("Título", "Title", "Título"), dataType: EDataType.TEXT },
85
+ { property: "excerpt", type: "subtitle", label: tr("Resumo", "Excerpt", "Resumen"), dataType: EDataType.TEXT },
86
+ { property: "publishedAt", label: tr("Publicar em", "Publish on", "Publicar el"), dataType: EDataType.DATE },
87
+ ],
88
+ contracts: [
89
+ {
90
+ id: ENTITY,
91
+ endpoint: STORE_BLOG_POSTS_ENDPOINT,
92
+ actions: ["get", "getById", "update", "softDelete"],
93
+ request: { entity: ENTITY, fields: [] },
94
+ },
95
+ ],
96
+ });
97
+
98
+ /**
99
+ * Módulo pronto "Blog", para o Backoffice do vendedor (funcionalidade
100
+ * "blog"). A loja lista os artigos publicados por IMarketplace.blogPostsEndpoint
101
+ * (STORE_BLOG_POSTS_ENDPOINT).
102
+ */
103
+ export const getStoreBlogModule = (options: IStoreBlogModuleOptions = {}): IModule => ({
104
+ id: "storeBlogModule",
105
+ title: tr("Blog", "Blog", "Blog"),
106
+ icon: "newspaper",
107
+ components: [getStoreBlogPostList(), getStoreBlogPostForm(options)],
108
+ });
@@ -0,0 +1,127 @@
1
+ import { EDataType } from "../../enums/form.enum";
2
+ import type { IPublicContract } from "../../interfaces/form-contract.interface";
3
+ import type { IForm, IFormElement } from "../../interfaces/form.interface";
4
+ import type { IList } from "../../interfaces/list.interface";
5
+ import type { IModule } from "../../interfaces/project.interface";
6
+ import type { TStoreCouponDiscountType } from "../../interfaces/store-coupon.interface";
7
+ import { tr } from "../store-settings/translations";
8
+
9
+ export const STORE_COUPONS_ENDPOINT = "/store-coupons";
10
+
11
+ export interface IStoreCouponsModuleOptions {
12
+ // Quem lê os cupons sem login. "trustedCallers" (padrão): só o backend da
13
+ // loja, com o token de serviço de IMarketplace.sellerServiceAuth.
14
+ publicAccess?: IPublicContract["access"];
15
+ allowedOrigins?: string[];
16
+ }
17
+
18
+ const ENTITY = "storeCoupons";
19
+
20
+ const DISCOUNT_TYPE_LABELS: Record<TStoreCouponDiscountType, ReturnType<typeof tr>> = {
21
+ percentage: tr("Percentual (%)", "Percentage (%)", "Porcentaje (%)"),
22
+ value: tr("Valor fixo", "Fixed amount", "Monto fijo"),
23
+ };
24
+
25
+ const couponElements: IFormElement[] = [
26
+ {
27
+ type: "input",
28
+ name: "code",
29
+ dataType: EDataType.TEXT,
30
+ label: tr("Código", "Code", "Código"),
31
+ tooltip: tr("O que o cliente digita no carrinho (ex.: BEMVINDO10)", "What the customer types in the cart (e.g. WELCOME10)", "Lo que el cliente escribe en el carrito (ej.: BIENVENIDO10)"),
32
+ isRequired: true,
33
+ isUnique: true,
34
+ space: 2,
35
+ },
36
+ { type: "input", name: "description", dataType: EDataType.TEXT, label: tr("Descrição", "Description", "Descripción"), space: 2 },
37
+ {
38
+ type: "select",
39
+ name: "discountType",
40
+ dataType: EDataType.TEXT,
41
+ label: tr("Tipo de desconto", "Discount type", "Tipo de descuento"),
42
+ isRequired: true,
43
+ options: (Object.keys(DISCOUNT_TYPE_LABELS) as TStoreCouponDiscountType[]).map((value) => ({
44
+ label: DISCOUNT_TYPE_LABELS[value],
45
+ value,
46
+ isSelected: value === "percentage",
47
+ })),
48
+ space: 2,
49
+ },
50
+ { type: "input", name: "discountValue", dataType: EDataType.NUMBER, label: tr("Desconto", "Discount", "Descuento"), isRequired: true, space: 2 },
51
+ { type: "input", name: "minimumSubtotal", dataType: EDataType.CURRENCY, label: tr("Pedido mínimo", "Minimum order", "Pedido mínimo"), space: 2 },
52
+ { type: "datepicker", name: "startDate", label: tr("Válido a partir de", "Valid from", "Válido desde") },
53
+ { type: "datepicker", name: "endDate", label: tr("Válido até", "Valid until", "Válido hasta") },
54
+ { type: "input", name: "usageLimit", dataType: EDataType.INTEGER, label: tr("Limite de usos", "Usage limit", "Límite de usos"), space: 2 },
55
+ {
56
+ type: "input",
57
+ name: "usageLimitPerCustomer",
58
+ dataType: EDataType.INTEGER,
59
+ label: tr("Limite por cliente", "Limit per customer", "Límite por cliente"),
60
+ space: 2,
61
+ },
62
+ { type: "switch", name: "isActive", label: tr("Ativo", "Active", "Activo") },
63
+ ];
64
+
65
+ // Um código por workspace; fica no contrato interno, de onde o gerador cria o índice único.
66
+ const UNIQUE_CODE = [{ identificator: "storeCouponCodePerWorkspace", fields: ["code"] }];
67
+
68
+ export const getStoreCouponForm = (options: IStoreCouponsModuleOptions = {}): IForm => ({
69
+ componentType: "form",
70
+ id: "storeCouponForm",
71
+ title: tr("Cupom", "Coupon", "Cupón"),
72
+ icon: "ticket-percent",
73
+ guards: "isAuthorized",
74
+ elements: couponElements,
75
+ contracts: [
76
+ {
77
+ id: ENTITY,
78
+ endpoint: STORE_COUPONS_ENDPOINT,
79
+ actions: ["create", "get", "getById", "update", "softDelete"],
80
+ request: { entity: ENTITY, fields: [], uniqueConstraints: UNIQUE_CODE },
81
+ },
82
+ ],
83
+ publicContracts: [
84
+ {
85
+ id: "storeCouponsFromStore",
86
+ endpoint: STORE_COUPONS_ENDPOINT,
87
+ actions: ["get"],
88
+ access: options.publicAccess ?? "trustedCallers",
89
+ ...(options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {}),
90
+ request: { entity: ENTITY, fields: [] },
91
+ },
92
+ ],
93
+ });
94
+
95
+ export const getStoreCouponList = (): IList => ({
96
+ componentType: "list",
97
+ id: "storeCouponList",
98
+ title: tr("Cupons", "Coupons", "Cupones"),
99
+ guards: ["isAuthorized"],
100
+ dataSource: { endpoint: STORE_COUPONS_ENDPOINT, paramType: "query", hasAuthentication: true },
101
+ listItems: [
102
+ { property: "code", type: "title", label: tr("Código", "Code", "Código"), dataType: EDataType.TEXT },
103
+ { property: "description", type: "subtitle", label: tr("Descrição", "Description", "Descripción"), dataType: EDataType.TEXT },
104
+ { property: "discountValue", type: "description", label: tr("Desconto", "Discount", "Descuento"), dataType: EDataType.NUMBER },
105
+ { property: "endDate", label: tr("Válido até", "Valid until", "Válido hasta"), dataType: EDataType.DATE },
106
+ ],
107
+ contracts: [
108
+ {
109
+ id: ENTITY,
110
+ endpoint: STORE_COUPONS_ENDPOINT,
111
+ actions: ["get", "getById", "update", "softDelete"],
112
+ request: { entity: ENTITY, fields: [] },
113
+ },
114
+ ],
115
+ });
116
+
117
+ /**
118
+ * Módulo pronto "Cupons", para o Backoffice do vendedor (funcionalidade
119
+ * "coupons"). A loja lê os cupons por IMarketplace.couponsEndpoint
120
+ * (STORE_COUPONS_ENDPOINT), valida o código e desconta no servidor.
121
+ */
122
+ export const getStoreCouponsModule = (options: IStoreCouponsModuleOptions = {}): IModule => ({
123
+ id: "storeCouponsModule",
124
+ title: tr("Cupons", "Coupons", "Cupones"),
125
+ icon: "ticket-percent",
126
+ components: [getStoreCouponList(), getStoreCouponForm(options)],
127
+ });
@@ -0,0 +1,70 @@
1
+ import { EDataType } from "../../enums/form.enum";
2
+ import type { IFormElement } from "../../interfaces/form.interface";
3
+ import type { TStoreReturnReason, TStoreReturnStatus, TStoreReturnType } from "../../interfaces/store-return.interface";
4
+ import { tr } from "../store-settings/translations";
5
+
6
+ type TLabel = ReturnType<typeof tr>;
7
+
8
+ const readOnly = (name: string, label: TLabel, dataType: EDataType.TEXT | EDataType.INTEGER = EDataType.TEXT): IFormElement => ({
9
+ type: "input",
10
+ name,
11
+ dataType,
12
+ label,
13
+ isDisabled: true,
14
+ });
15
+
16
+ const options = <T extends string>(labels: Record<T, TLabel>, selected?: T) =>
17
+ (Object.keys(labels) as T[]).map((value: T) => ({ label: labels[value], value, ...(value === selected ? { isSelected: true } : {}) }));
18
+
19
+ export const STORE_RETURN_STATUS_LABELS: Record<TStoreReturnStatus, TLabel> = {
20
+ requested: tr("Solicitado", "Requested", "Solicitado"),
21
+ approved: tr("Aprovado", "Approved", "Aprobado"),
22
+ rejected: tr("Recusado", "Rejected", "Rechazado"),
23
+ received: tr("Produto recebido", "Item received", "Producto recibido"),
24
+ completed: tr("Concluído", "Completed", "Concluido"),
25
+ };
26
+
27
+ export const STORE_RETURN_TYPE_LABELS: Record<TStoreReturnType, TLabel> = {
28
+ return: tr("Devolução", "Return", "Devolución"),
29
+ exchange: tr("Troca", "Exchange", "Cambio"),
30
+ };
31
+
32
+ export const STORE_RETURN_REASON_LABELS: Record<TStoreReturnReason, TLabel> = {
33
+ defect: tr("Produto com defeito", "Defective item", "Producto defectuoso"),
34
+ wrongItem: tr("Produto errado", "Wrong item", "Producto equivocado"),
35
+ notAsDescribed: tr("Diferente do anunciado", "Not as described", "Distinto de lo anunciado"),
36
+ regret: tr("Desistência", "Changed my mind", "Desistimiento"),
37
+ other: tr("Outro", "Other", "Otro"),
38
+ };
39
+
40
+ export const resolutionElements: IFormElement[] = [
41
+ {
42
+ type: "select",
43
+ name: "status",
44
+ dataType: EDataType.TEXT,
45
+ label: tr("Andamento", "Status", "Estado"),
46
+ isRequired: true,
47
+ options: options(STORE_RETURN_STATUS_LABELS, "requested"),
48
+ },
49
+ { type: "input", name: "resolutionNotes", dataType: EDataType.TEXT, label: tr("Resposta ao cliente", "Reply to the customer", "Respuesta al cliente") },
50
+ { type: "input", name: "returnTrackingCode", dataType: EDataType.TEXT, label: tr("Código de postagem", "Return tracking code", "Código de envío") },
51
+ ];
52
+
53
+ export const requestElements: IFormElement[] = [
54
+ readOnly("storeOrderId", tr("Pedido na loja", "Store order", "Pedido en la tienda")),
55
+ { type: "select", name: "type", dataType: EDataType.TEXT, label: tr("Tipo", "Type", "Tipo"), isRequired: true, isDisabled: true, options: options(STORE_RETURN_TYPE_LABELS) },
56
+ { type: "select", name: "reason", dataType: EDataType.TEXT, label: tr("Motivo", "Reason", "Motivo"), isRequired: true, isDisabled: true, options: options(STORE_RETURN_REASON_LABELS) },
57
+ readOnly("comment", tr("Comentário do cliente", "Customer comment", "Comentario del cliente")),
58
+ readOnly("customerName", tr("Cliente", "Customer", "Cliente")),
59
+ readOnly("customerEmail", tr("E-mail do cliente", "Customer e-mail", "Correo del cliente")),
60
+ {
61
+ type: "array",
62
+ name: "items",
63
+ label: tr("Itens", "Items", "Artículos"),
64
+ elements: [
65
+ readOnly("productId", tr("Produto (id)", "Product (id)", "Producto (id)")),
66
+ readOnly("name", tr("Produto", "Product", "Producto")),
67
+ readOnly("quantity", tr("Quantidade", "Quantity", "Cantidad"), EDataType.INTEGER),
68
+ ],
69
+ },
70
+ ];
@@ -0,0 +1,101 @@
1
+ import { EDataType } from "../../enums/form.enum";
2
+ import type { IPublicContract } from "../../interfaces/form-contract.interface";
3
+ import type { IForm } from "../../interfaces/form.interface";
4
+ import type { IList } from "../../interfaces/list.interface";
5
+ import type { IModule } from "../../interfaces/project.interface";
6
+ import type { TStoreReturnStatus } from "../../interfaces/store-return.interface";
7
+ import { tr } from "../store-settings/translations";
8
+ import { STORE_RETURN_STATUS_LABELS, requestElements, resolutionElements } from "./store-return.elements";
9
+
10
+ export const STORE_RETURNS_ENDPOINT = "/store-returns";
11
+
12
+ export interface IStoreReturnsModuleOptions {
13
+ publicAccess?: IPublicContract["access"];
14
+ allowedOrigins?: string[];
15
+ }
16
+
17
+ const ENTITY = "storeReturns";
18
+
19
+ export const getStoreReturnForm = (options: IStoreReturnsModuleOptions = {}): IForm => ({
20
+ componentType: "form",
21
+ id: "storeReturnForm",
22
+ title: tr("Devolução ou troca", "Return or exchange", "Devolución o cambio"),
23
+ icon: "undo-2",
24
+ guards: "isAuthorized",
25
+ elements: [
26
+ {
27
+ type: "tab",
28
+ id: "storeReturnTabs",
29
+ tabs: [
30
+ { id: "resolution", title: tr("Resposta", "Resolution", "Respuesta"), elements: resolutionElements },
31
+ { id: "request", title: tr("Pedido do cliente", "Customer request", "Solicitud del cliente"), elements: requestElements },
32
+ ],
33
+ },
34
+ ],
35
+ contracts: [
36
+ {
37
+ id: ENTITY,
38
+ endpoint: STORE_RETURNS_ENDPOINT,
39
+ actions: ["get", "getById", "update"],
40
+ request: { entity: ENTITY, fields: [] },
41
+ },
42
+ ],
43
+ publicContracts: [
44
+ {
45
+ id: "storeReturnsFromStore",
46
+ endpoint: STORE_RETURNS_ENDPOINT,
47
+ actions: ["create", "get"],
48
+ access: options.publicAccess ?? "trustedCallers",
49
+ ...(options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {}),
50
+ request: { entity: ENTITY, fields: [] },
51
+ },
52
+ ],
53
+ });
54
+
55
+ export const getStoreReturnList = (): IList => ({
56
+ componentType: "list",
57
+ id: "storeReturnList",
58
+ title: tr("Devoluções e trocas", "Returns and exchanges", "Devoluciones y cambios"),
59
+ guards: ["isAuthorized"],
60
+ dataSource: { endpoint: STORE_RETURNS_ENDPOINT, paramType: "query", hasAuthentication: true },
61
+ listItems: [
62
+ { property: "storeOrderId", type: "title", label: tr("Pedido", "Order", "Pedido"), dataType: EDataType.TEXT },
63
+ { property: "customerName", type: "subtitle", label: tr("Cliente", "Customer", "Cliente"), dataType: EDataType.TEXT },
64
+ { property: "type", type: "description", label: tr("Tipo", "Type", "Tipo"), dataType: EDataType.TEXT },
65
+ { property: "status", type: "badge", label: tr("Andamento", "Status", "Estado"), dataType: EDataType.TEXT },
66
+ { property: "createdAt", label: tr("Pedido em", "Requested at", "Solicitado el"), dataType: EDataType.DATE, isTimestamp: true },
67
+ ],
68
+ listFilters: [
69
+ {
70
+ type: "select",
71
+ name: "status",
72
+ dataType: EDataType.TEXT,
73
+ label: tr("Andamento", "Status", "Estado"),
74
+ options: (Object.keys(STORE_RETURN_STATUS_LABELS) as TStoreReturnStatus[]).map((status) => ({
75
+ label: STORE_RETURN_STATUS_LABELS[status],
76
+ value: status,
77
+ })),
78
+ },
79
+ ],
80
+ contracts: [
81
+ {
82
+ id: ENTITY,
83
+ endpoint: STORE_RETURNS_ENDPOINT,
84
+ actions: ["get", "getById", "update"],
85
+ request: { entity: ENTITY, fields: [] },
86
+ },
87
+ ],
88
+ });
89
+
90
+ /**
91
+ * Módulo pronto "Devoluções e trocas", para o Backoffice do vendedor
92
+ * (funcionalidade "returns"). A loja abre aqui o pedido do cliente
93
+ * (IMarketplace.returnsEndpoint) e lê dali o andamento; o vendedor aprova,
94
+ * recusa e acompanha o retorno do produto. O reembolso continua na loja.
95
+ */
96
+ export const getStoreReturnsModule = (options: IStoreReturnsModuleOptions = {}): IModule => ({
97
+ id: "storeReturnsModule",
98
+ title: tr("Devoluções e trocas", "Returns and exchanges", "Devoluciones y cambios"),
99
+ icon: "undo-2",
100
+ components: [getStoreReturnList(), getStoreReturnForm(options)],
101
+ });
@@ -0,0 +1,132 @@
1
+ import { EDataType } from "../../enums/form.enum";
2
+ import type { IPublicContract } from "../../interfaces/form-contract.interface";
3
+ import type { IForm, IFormElement } from "../../interfaces/form.interface";
4
+ import type { IList } from "../../interfaces/list.interface";
5
+ import type { IModule } from "../../interfaces/project.interface";
6
+ import type { TStoreReviewStatus } from "../../interfaces/store-review.interface";
7
+ import { tr } from "../store-settings/translations";
8
+
9
+ export const STORE_REVIEWS_ENDPOINT = "/store-reviews";
10
+ // Nota média por produto: GET <endpoint>/aggregations/rating (soma de rating e count).
11
+ export const STORE_REVIEWS_RATING_AGGREGATION = "rating";
12
+
13
+ export interface IStoreReviewsModuleOptions {
14
+ publicAccess?: IPublicContract["access"];
15
+ allowedOrigins?: string[];
16
+ }
17
+
18
+ const ENTITY = "storeReviews";
19
+
20
+ export const STORE_REVIEW_STATUS_LABELS: Record<TStoreReviewStatus, ReturnType<typeof tr>> = {
21
+ pending: tr("Aguardando moderação", "Awaiting moderation", "Esperando moderación"),
22
+ approved: tr("Aprovada", "Approved", "Aprobada"),
23
+ rejected: tr("Recusada", "Rejected", "Rechazada"),
24
+ };
25
+
26
+ const readOnly = (name: string, label: ReturnType<typeof tr>, dataType: EDataType.TEXT | EDataType.INTEGER = EDataType.TEXT): IFormElement => ({
27
+ type: "input",
28
+ name,
29
+ dataType,
30
+ label,
31
+ isDisabled: true,
32
+ });
33
+
34
+ const reviewElements: IFormElement[] = [
35
+ {
36
+ type: "select",
37
+ name: "status",
38
+ dataType: EDataType.TEXT,
39
+ label: tr("Moderação", "Moderation", "Moderación"),
40
+ isRequired: true,
41
+ options: (Object.keys(STORE_REVIEW_STATUS_LABELS) as TStoreReviewStatus[]).map((status) => ({
42
+ label: STORE_REVIEW_STATUS_LABELS[status],
43
+ value: status,
44
+ isSelected: status === "pending",
45
+ })),
46
+ },
47
+ { type: "input", name: "reply", dataType: EDataType.TEXT, label: tr("Resposta do vendedor", "Seller reply", "Respuesta del vendedor") },
48
+ readOnly("rating", tr("Nota (1 a 5)", "Rating (1 to 5)", "Nota (1 a 5)"), EDataType.INTEGER),
49
+ readOnly("title", tr("Título", "Title", "Título")),
50
+ readOnly("comment", tr("Comentário", "Comment", "Comentario")),
51
+ readOnly("customerName", tr("Cliente", "Customer", "Cliente")),
52
+ readOnly("productId", tr("Produto (id)", "Product (id)", "Producto (id)")),
53
+ readOnly("storeOrderId", tr("Pedido na loja", "Store order", "Pedido en la tienda")),
54
+ ];
55
+
56
+ // Uma avaliação por produto em cada pedido da loja.
57
+ const UNIQUE_REVIEW = [{ identificator: "storeReviewPerOrderProduct", fields: ["storeOrderId", "productId"] }];
58
+
59
+ export const getStoreReviewForm = (options: IStoreReviewsModuleOptions = {}): IForm => ({
60
+ componentType: "form",
61
+ id: "storeReviewForm",
62
+ title: tr("Avaliação", "Review", "Reseña"),
63
+ icon: "star",
64
+ guards: "isAuthorized",
65
+ elements: reviewElements,
66
+ contracts: [
67
+ {
68
+ id: ENTITY,
69
+ endpoint: STORE_REVIEWS_ENDPOINT,
70
+ actions: ["get", "getById", "update", "softDelete"],
71
+ request: { entity: ENTITY, fields: [], uniqueConstraints: UNIQUE_REVIEW },
72
+ },
73
+ ],
74
+ publicContracts: [
75
+ {
76
+ id: "storeReviewsFromStore",
77
+ endpoint: STORE_REVIEWS_ENDPOINT,
78
+ actions: ["create", "get"],
79
+ access: options.publicAccess ?? "trustedCallers",
80
+ ...(options.allowedOrigins ? { allowedOrigins: options.allowedOrigins } : {}),
81
+ aggregations: [{ id: STORE_REVIEWS_RATING_AGGREGATION, groupBy: "productId", sum: ["rating"], count: true }],
82
+ request: { entity: ENTITY, fields: [] },
83
+ },
84
+ ],
85
+ });
86
+
87
+ export const getStoreReviewList = (): IList => ({
88
+ componentType: "list",
89
+ id: "storeReviewList",
90
+ title: tr("Avaliações", "Reviews", "Reseñas"),
91
+ guards: ["isAuthorized"],
92
+ dataSource: { endpoint: STORE_REVIEWS_ENDPOINT, paramType: "query", hasAuthentication: true },
93
+ listItems: [
94
+ { property: "title", type: "title", label: tr("Título", "Title", "Título"), dataType: EDataType.TEXT },
95
+ { property: "customerName", type: "subtitle", label: tr("Cliente", "Customer", "Cliente"), dataType: EDataType.TEXT },
96
+ { property: "rating", type: "description", label: tr("Nota", "Rating", "Nota"), dataType: EDataType.INTEGER },
97
+ { property: "status", type: "badge", label: tr("Moderação", "Moderation", "Moderación"), dataType: EDataType.TEXT },
98
+ { property: "createdAt", label: tr("Recebida em", "Received at", "Recibida el"), dataType: EDataType.DATE, isTimestamp: true },
99
+ ],
100
+ listFilters: [
101
+ {
102
+ type: "select",
103
+ name: "status",
104
+ dataType: EDataType.TEXT,
105
+ label: tr("Moderação", "Moderation", "Moderación"),
106
+ options: (Object.keys(STORE_REVIEW_STATUS_LABELS) as TStoreReviewStatus[]).map((status) => ({
107
+ label: STORE_REVIEW_STATUS_LABELS[status],
108
+ value: status,
109
+ })),
110
+ },
111
+ ],
112
+ contracts: [
113
+ {
114
+ id: ENTITY,
115
+ endpoint: STORE_REVIEWS_ENDPOINT,
116
+ actions: ["get", "getById", "update", "softDelete"],
117
+ request: { entity: ENTITY, fields: [] },
118
+ },
119
+ ],
120
+ });
121
+
122
+ /**
123
+ * Módulo pronto "Avaliações", para o Backoffice do vendedor (funcionalidade
124
+ * "reviews"). A loja cria aqui a avaliação de quem recebeu o pedido
125
+ * (IMarketplace.reviewsEndpoint) e lê as aprovadas e a nota média.
126
+ */
127
+ export const getStoreReviewsModule = (options: IStoreReviewsModuleOptions = {}): IModule => ({
128
+ id: "storeReviewsModule",
129
+ title: tr("Avaliações", "Reviews", "Reseñas"),
130
+ icon: "star",
131
+ components: [getStoreReviewList(), getStoreReviewForm(options)],
132
+ });
@@ -11,6 +11,9 @@ const FEATURE_LABELS: Record<TStoreFeature, ReturnType<typeof tr>> = {
11
11
  favorites: tr("Favoritos", "Favorites", "Favoritos"),
12
12
  blog: tr("Blog", "Blog", "Blog"),
13
13
  shipping: tr("Cobrar frete por faixa de CEP", "Charge shipping by ZIP code range", "Cobrar envío por rango de código postal"),
14
+ coupons: tr("Aceitar cupons de desconto", "Accept discount coupons", "Aceptar cupones de descuento"),
15
+ reviews: tr("Avaliações de produtos", "Product reviews", "Reseñas de productos"),
16
+ returns: tr("Pedidos de devolução e troca", "Return and exchange requests", "Solicitudes de devolución y cambio"),
14
17
  };
15
18
 
16
19
  const shippingElements: IFormElement[] = [
@@ -65,6 +68,16 @@ const featureDetails = (feature: TStoreFeature): IFormElement[] => {
65
68
  ];
66
69
  }
67
70
  if (feature === "shipping") return shippingElements;
71
+ if (feature === "returns") {
72
+ return [
73
+ {
74
+ type: "input",
75
+ name: "returnWindowDays",
76
+ dataType: EDataType.INTEGER,
77
+ label: tr("Prazo para pedir (dias após a entrega)", "Request window (days after delivery)", "Plazo para solicitar (días tras la entrega)"),
78
+ },
79
+ ];
80
+ }
68
81
  return [];
69
82
  };
70
83
 
@@ -0,0 +1,100 @@
1
+ import { EDataType } from "../../enums/form.enum";
2
+ import type { IFormElement } from "../../interfaces/form.interface";
3
+ import type { IStorageConfig } from "../../interfaces/form-file.interface";
4
+ import { tr } from "./translations";
5
+
6
+ const storageConfig: IStorageConfig = {
7
+ path: "store-settings",
8
+ fileNameStrategy: "uuid",
9
+ visibility: "public",
10
+ };
11
+
12
+ const richText = (name: string, label: ReturnType<typeof tr>): IFormElement => ({
13
+ type: "input",
14
+ name,
15
+ dataType: EDataType.WYSIWYG,
16
+ label,
17
+ storageConfig,
18
+ });
19
+
20
+ /** Páginas institucionais e legais (L20): cada uma só é publicada quando tem texto. */
21
+ export const pagesElements: IFormElement[] = [
22
+ richText("aboutText", tr("Sobre a loja", "About the store", "Sobre la tienda")),
23
+ richText("privacyPolicyText", tr("Política de privacidade", "Privacy policy", "Política de privacidad")),
24
+ richText("termsText", tr("Termos de uso", "Terms of use", "Términos de uso")),
25
+ richText("returnsPolicyText", tr("Trocas e devoluções", "Returns and exchanges", "Cambios y devoluciones")),
26
+ {
27
+ type: "input",
28
+ name: "cookieNoticeText",
29
+ dataType: EDataType.TEXT,
30
+ label: tr("Aviso de cookies", "Cookie notice", "Aviso de cookies"),
31
+ tooltip: tr("Sem texto, o aviso não aparece.", "Without text, the notice is not shown.", "Sin texto, el aviso no aparece."),
32
+ },
33
+ ];
34
+
35
+ export interface IFeaturedProductsApi {
36
+ // Endpoint dos produtos do vendedor (padrão "/products").
37
+ endpoint?: string;
38
+ // Campos mostrados na escolha (padrão ["name"]).
39
+ labelField?: string[];
40
+ }
41
+
42
+ /** Home da vitrine (L25): banners, benefícios e produtos em destaque. */
43
+ export const getShowcaseElements = (productsApi: IFeaturedProductsApi = {}): IFormElement[] => [
44
+ {
45
+ type: "array",
46
+ name: "banners",
47
+ label: tr("Banners", "Banners", "Banners"),
48
+ elements: [
49
+ {
50
+ type: "file",
51
+ name: "image",
52
+ dataType: EDataType.TEXT,
53
+ label: tr("Imagem", "Image", "Imagen"),
54
+ validators: ["onlyImages"],
55
+ storageConfig,
56
+ },
57
+ { type: "input", name: "title", dataType: EDataType.TEXT, label: tr("Título", "Title", "Título"), isRequired: true },
58
+ { type: "input", name: "subtitle", dataType: EDataType.TEXT, label: tr("Subtítulo", "Subtitle", "Subtítulo") },
59
+ {
60
+ type: "input",
61
+ name: "linkUrl",
62
+ dataType: EDataType.TEXT,
63
+ label: tr("Link do botão", "Button link", "Enlace del botón"),
64
+ tooltip: tr("Caminho da loja (ex.: /busca?categoria=blu-ray) ou URL", "Store path (e.g. /busca?categoria=blu-ray) or URL", "Ruta de la tienda (ej.: /busca?categoria=blu-ray) o URL"),
65
+ },
66
+ { type: "input", name: "linkLabel", dataType: EDataType.TEXT, label: tr("Texto do botão", "Button text", "Texto del botón") },
67
+ ],
68
+ },
69
+ {
70
+ type: "array",
71
+ name: "benefits",
72
+ label: tr("Benefícios", "Benefits", "Beneficios"),
73
+ elements: [
74
+ {
75
+ type: "input",
76
+ name: "icon",
77
+ dataType: EDataType.TEXT,
78
+ label: tr("Ícone", "Icon", "Ícono"),
79
+ tooltip: tr("Nome de um ícone Lucide (ex.: truck, shield-check)", "Lucide icon name (e.g. truck, shield-check)", "Nombre de un ícono Lucide (ej.: truck, shield-check)"),
80
+ },
81
+ { type: "input", name: "title", dataType: EDataType.TEXT, label: tr("Título", "Title", "Título"), isRequired: true },
82
+ { type: "input", name: "text", dataType: EDataType.TEXT, label: tr("Texto", "Text", "Texto") },
83
+ ],
84
+ },
85
+ {
86
+ type: "autocomplete",
87
+ name: "featuredProductIds",
88
+ dataType: EDataType.UNIQUEIDENTIFIER,
89
+ label: tr("Produtos em destaque", "Featured products", "Productos destacados"),
90
+ isMultiple: true,
91
+ optionsApi: {
92
+ endpoint: productsApi.endpoint ?? "/products",
93
+ relatedEntity: "products",
94
+ labelField: productsApi.labelField ?? ["name"],
95
+ valueField: "_id",
96
+ paramsToFilter: productsApi.labelField ?? ["name"],
97
+ paramType: "query",
98
+ },
99
+ },
100
+ ];
@@ -6,6 +6,7 @@ import type { TStoreFeature } from "../../interfaces/store-settings.interface";
6
6
  import { contactElements, legalElements, socialElements } from "./contact-legal.elements";
7
7
  import { getFeatureElements } from "./features.elements";
8
8
  import { identityElements, visualElements } from "./identity-visual.elements";
9
+ import { getShowcaseElements, pagesElements, type IFeaturedProductsApi } from "./pages-showcase.elements";
9
10
  import { tr } from "./translations";
10
11
 
11
12
  export const STORE_SETTINGS_ENDPOINT = "/store-settings";
@@ -17,9 +18,11 @@ export interface IStoreSettingsModuleOptions {
17
18
  // da loja, com o token de serviço de IMarketplace.sellerServiceAuth.
18
19
  publicAccess?: IPublicContract["access"];
19
20
  allowedOrigins?: string[];
21
+ // Produtos do vendedor oferecidos em "Produtos em destaque" (aba Vitrine).
22
+ featuredProductsApi?: IFeaturedProductsApi;
20
23
  }
21
24
 
22
- const buildTabs = (features: TStoreFeature[]): IFormTab => ({
25
+ const buildTabs = (features: TStoreFeature[], productsApi?: IFeaturedProductsApi): IFormTab => ({
23
26
  type: "tab",
24
27
  id: "storeSettingsTabs",
25
28
  tabs: [
@@ -28,6 +31,8 @@ const buildTabs = (features: TStoreFeature[]): IFormTab => ({
28
31
  { id: "contact", title: tr("Contato", "Contact", "Contacto"), elements: contactElements },
29
32
  { id: "legal", title: tr("Dados legais", "Legal data", "Datos legales"), elements: legalElements },
30
33
  { id: "social", title: tr("Redes sociais", "Social media", "Redes sociales"), elements: socialElements },
34
+ { id: "showcase", title: tr("Vitrine", "Storefront", "Escaparate"), elements: getShowcaseElements(productsApi) },
35
+ { id: "pages", title: tr("Páginas", "Pages", "Páginas"), elements: pagesElements },
31
36
  ...(features.length
32
37
  ? [{ id: "features", title: tr("Funcionalidades", "Features", "Funcionalidades"), elements: getFeatureElements(features) }]
33
38
  : []),
@@ -41,7 +46,7 @@ export const getStoreSettingsForm = (options: IStoreSettingsModuleOptions = {}):
41
46
  icon: "palette",
42
47
  guards: "isAuthorized",
43
48
  isSingleRecord: true,
44
- elements: [buildTabs(options.features ?? [])],
49
+ elements: [buildTabs(options.features ?? [], options.featuredProductsApi)],
45
50
  contracts: [
46
51
  {
47
52
  id: "storeSettings",
@@ -34,10 +34,11 @@
34
34
  "properties": {
35
35
  "messengers": {
36
36
  "type": "array",
37
- "description": "\"instagram\" is a stub today (webhook does not process incoming messages yet).",
37
+ "minItems": 1,
38
+ "uniqueItems": true,
38
39
  "items": {
39
40
  "type": "string",
40
- "enum": ["whatsapp", "instagram", "telegram"]
41
+ "enum": ["whatsapp", "telegram"]
41
42
  }
42
43
  },
43
44
  "aiProvider": {
@@ -89,6 +89,14 @@
89
89
  "whatsappVerifyToken": { "type": "string" }
90
90
  }
91
91
  },
92
+ "telegram": {
93
+ "type": "object",
94
+ "properties": {
95
+ "telegramBotToken": { "type": "string", "minLength": 1 }
96
+ },
97
+ "required": ["telegramBotToken"],
98
+ "additionalProperties": false
99
+ },
92
100
  "email": {
93
101
  "type": "object",
94
102
  "properties": {
@@ -135,6 +143,10 @@
135
143
  "storeOrdersEndpoint": { "type": "string" },
136
144
  "categoriesEndpoint": { "type": "string" },
137
145
  "brandsEndpoint": { "type": "string" },
146
+ "couponsEndpoint": { "type": "string" },
147
+ "reviewsEndpoint": { "type": "string" },
148
+ "returnsEndpoint": { "type": "string" },
149
+ "blogPostsEndpoint": { "type": "string" },
138
150
  "productFieldMap": {
139
151
  "type": "object",
140
152
  "properties": {
@@ -61,6 +61,9 @@
61
61
  "type": "string",
62
62
  "minLength": 1
63
63
  }
64
+ },
65
+ "count": {
66
+ "type": "boolean"
64
67
  }
65
68
  },
66
69
  "required": [
@@ -7,7 +7,7 @@
7
7
  "type": "array",
8
8
  "items": {
9
9
  "type": "string",
10
- "enum": ["whatsappButton", "stockAvailability", "cashDiscount", "installments", "favorites", "blog", "shipping"]
10
+ "enum": ["whatsappButton", "stockAvailability", "cashDiscount", "installments", "favorites", "blog", "shipping", "coupons", "reviews", "returns"]
11
11
  },
12
12
  "uniqueItems": true
13
13
  },
@@ -45,13 +45,51 @@
45
45
  "additionalProperties": false
46
46
  }
47
47
  },
48
+ "returnWindowDays": { "type": "integer", "minimum": 0 },
49
+ "aboutText": { "type": "string" },
50
+ "privacyPolicyText": { "type": "string" },
51
+ "termsText": { "type": "string" },
52
+ "returnsPolicyText": { "type": "string" },
53
+ "cookieNoticeText": { "type": "string" },
54
+ "banners": {
55
+ "type": "array",
56
+ "items": {
57
+ "type": "object",
58
+ "properties": {
59
+ "image": { "type": "string" },
60
+ "title": { "type": "string", "minLength": 1 },
61
+ "subtitle": { "type": "string" },
62
+ "linkUrl": { "type": "string" },
63
+ "linkLabel": { "type": "string" }
64
+ },
65
+ "required": ["title"],
66
+ "additionalProperties": false
67
+ }
68
+ },
69
+ "benefits": {
70
+ "type": "array",
71
+ "items": {
72
+ "type": "object",
73
+ "properties": {
74
+ "icon": { "type": "string" },
75
+ "title": { "type": "string", "minLength": 1 },
76
+ "text": { "type": "string" }
77
+ },
78
+ "required": ["title"],
79
+ "additionalProperties": false
80
+ }
81
+ },
82
+ "featuredProductIds": { "type": "array", "items": { "type": "string", "minLength": 1 }, "uniqueItems": true },
48
83
  "whatsappButtonEnabled": { "type": "boolean" },
49
84
  "stockAvailabilityEnabled": { "type": "boolean" },
50
85
  "cashDiscountEnabled": { "type": "boolean" },
51
86
  "installmentsEnabled": { "type": "boolean" },
52
87
  "favoritesEnabled": { "type": "boolean" },
53
88
  "blogEnabled": { "type": "boolean" },
54
- "shippingEnabled": { "type": "boolean" }
89
+ "shippingEnabled": { "type": "boolean" },
90
+ "couponsEnabled": { "type": "boolean" },
91
+ "reviewsEnabled": { "type": "boolean" },
92
+ "returnsEnabled": { "type": "boolean" }
55
93
  },
56
94
  "additionalProperties": false
57
95
  }