evo360-types 1.3.782 → 1.3.787
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/dist/apps/evo-chat/forward/zod-schemas.d.ts +4 -4
- package/dist/apps/evo-chat/thread-message/zod-schemas.d.ts +36 -0
- package/dist/apps/evo-chat/thread-message/zod-schemas.js +3 -0
- package/dist/apps/evo-chat/thread-message/zod-schemas.ts +3 -0
- package/dist/apps/evo-finops/zod-schemas.d.ts +794 -32
- package/dist/apps/evo-finops/zod-schemas.js +187 -2
- package/dist/apps/evo-finops/zod-schemas.ts +205 -0
- package/dist/types/evo-chat/thread-message/index.d.ts +8 -0
- package/dist/types/evo-chat/thread-message/index.ts +8 -0
- package/dist/types/evo-finops/common/contract.d.ts +29 -1
- package/dist/types/evo-finops/common/contract.js +7 -0
- package/dist/types/evo-finops/common/contract.ts +31 -1
- package/dist/types/evo-finops/common/price-table.d.ts +89 -0
- package/dist/types/evo-finops/common/price-table.js +88 -0
- package/dist/types/evo-finops/common/price-table.ts +183 -0
- package/dist/types/evo-finops/common/proposal.d.ts +25 -0
- package/dist/types/evo-finops/common/proposal.ts +28 -0
- package/dist/types/evo-finops/index.d.ts +1 -0
- package/dist/types/evo-finops/index.js +1 -0
- package/dist/types/evo-finops/index.ts +1 -0
- package/dist/types/evo-reports/index.d.ts +9 -0
- package/dist/types/evo-reports/index.ts +9 -0
- package/dist/types/nex-vendas/adhesion.d.ts +253 -0
- package/dist/types/nex-vendas/adhesion.js +15 -0
- package/dist/types/nex-vendas/adhesion.ts +280 -0
- package/dist/types/nex-vendas/index.d.ts +3 -0
- package/dist/types/nex-vendas/index.js +3 -0
- package/dist/types/nex-vendas/index.ts +3 -0
- package/dist/types/nex-vendas/journey.d.ts +82 -4
- package/dist/types/nex-vendas/journey.ts +86 -3
- package/dist/types/nex-vendas/notifications.d.ts +14 -0
- package/dist/types/nex-vendas/notifications.js +21 -0
- package/dist/types/nex-vendas/notifications.ts +21 -0
- package/dist/types/nex-vendas/offer.d.ts +129 -0
- package/dist/types/nex-vendas/offer.js +10 -0
- package/dist/types/nex-vendas/offer.ts +154 -0
- package/package.json +1 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { IFireGlobalDoc } from '../../shared';
|
|
2
|
+
/** Coleção das tabelas: `core/nexus/apps/nex-finops/price_tables/{id}`. */
|
|
3
|
+
export declare const NEX_FINOPS_PRICE_TABLES_COLLECTION = "price_tables";
|
|
4
|
+
/** Teto por faixas sobre o total da métrica (Q2): até `up_to` unidades, o total é `total`. */
|
|
5
|
+
export interface INexFinopsPriceCapTier {
|
|
6
|
+
/** Limite superior (inclusivo) de unidades da faixa. Inteiro > 0, estritamente crescente entre faixas. */
|
|
7
|
+
up_to: number;
|
|
8
|
+
/** Valor total (BRL) cobrado quando o consumo cai nesta faixa. */
|
|
9
|
+
total: number;
|
|
10
|
+
}
|
|
11
|
+
export interface INexFinopsPriceCap {
|
|
12
|
+
mode: 'tiered_total';
|
|
13
|
+
tiers: INexFinopsPriceCapTier[];
|
|
14
|
+
}
|
|
15
|
+
/** Linha de uso: cobra `unit_price` por unidade consumida (opcionalmente com teto por faixas). */
|
|
16
|
+
export interface INexFinopsPriceLineUsage {
|
|
17
|
+
kind: 'usage';
|
|
18
|
+
/** Preço unitário (BRL). */
|
|
19
|
+
unit_price: number;
|
|
20
|
+
/** Categoria de `billing_services` (SSR, SMS, TELE, TELEGRV, …): vira item de cobrança e código de serviço da NFS-e. */
|
|
21
|
+
service_category: string;
|
|
22
|
+
cap?: INexFinopsPriceCap | null;
|
|
23
|
+
}
|
|
24
|
+
/** Linha recorrente: valor fixo por ciclo (ex.: módulo ativo no fechamento). */
|
|
25
|
+
export interface INexFinopsPriceLineRecurring {
|
|
26
|
+
kind: 'recurring';
|
|
27
|
+
/** Valor por ciclo (BRL). */
|
|
28
|
+
amount: number;
|
|
29
|
+
/** Categoria de `billing_services`. */
|
|
30
|
+
service_category: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Anula a linha herdada: a chave passa a não ser cobrada nesta tabela (e nas
|
|
34
|
+
* filhas dela, salvo se alguma filha redeclarar). Conta como "declarada" na
|
|
35
|
+
* resolução — interrompe a busca na cadeia.
|
|
36
|
+
*/
|
|
37
|
+
export interface INexFinopsPriceLineDisabled {
|
|
38
|
+
kind: 'disabled';
|
|
39
|
+
}
|
|
40
|
+
/** Linha de preço, discriminada por `kind`. Chave do mapa = métrica (usage) ou módulo (recurring). */
|
|
41
|
+
export type INexFinopsPriceLine = INexFinopsPriceLineUsage | INexFinopsPriceLineRecurring | INexFinopsPriceLineDisabled;
|
|
42
|
+
export type NexFinopsPriceLineKind = INexFinopsPriceLine['kind'];
|
|
43
|
+
/**
|
|
44
|
+
* Tabela de preço. Exatamente uma tem `is_default: true` — e é a única sem mãe.
|
|
45
|
+
* Toda outra tem `inherits_from` apontando para uma tabela viva, sem ciclo
|
|
46
|
+
* (validação na escrita, backend).
|
|
47
|
+
*/
|
|
48
|
+
export interface INexFinopsPriceTable extends IFireGlobalDoc {
|
|
49
|
+
name: string;
|
|
50
|
+
is_default: boolean;
|
|
51
|
+
/** Id da tabela mãe. Obrigatório quando `!is_default`; ausente/null na padrão. */
|
|
52
|
+
inherits_from?: string | null;
|
|
53
|
+
/** Linhas PRÓPRIAS desta tabela (não as herdadas). Chave ausente = herda. */
|
|
54
|
+
lines: Record<string, INexFinopsPriceLine>;
|
|
55
|
+
notes?: string | null;
|
|
56
|
+
}
|
|
57
|
+
/** Linha efetiva após a resolução, com a tabela que a declarou (origem exibida no Nexus). */
|
|
58
|
+
export interface ResolvedPriceLine {
|
|
59
|
+
line: INexFinopsPriceLine;
|
|
60
|
+
/** Id da tabela da cadeia que declarou a chave. */
|
|
61
|
+
from_table: string;
|
|
62
|
+
}
|
|
63
|
+
export interface ResolvedPriceTable {
|
|
64
|
+
/** Ids percorridos, da tabela pedida até a padrão (inclusive). */
|
|
65
|
+
chain: string[];
|
|
66
|
+
/** Linhas efetivas por chave. Inclui `disabled` (o consumidor decide como exibir/ignorar). */
|
|
67
|
+
lines: Record<string, ResolvedPriceLine>;
|
|
68
|
+
}
|
|
69
|
+
export type PriceTableResolveErrorCode = 'no_default' | 'missing_table' | 'missing_parent' | 'cycle';
|
|
70
|
+
/** Erro tipado do resolvedor. `table_id` = tabela onde o problema foi detectado (quando houver). */
|
|
71
|
+
export declare class PriceTableResolveError extends Error {
|
|
72
|
+
readonly code: PriceTableResolveErrorCode;
|
|
73
|
+
readonly table_id: string | null;
|
|
74
|
+
constructor(code: PriceTableResolveErrorCode, message: string, tableId?: string | null);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Resolvedor PURO da cadeia de herança — o mesmo no backend e no Nexus (front),
|
|
78
|
+
* para a origem por linha mostrada na tela bater com o que o motor cobra.
|
|
79
|
+
*
|
|
80
|
+
* - `tableId` ausente/null ⇒ parte da tabela com `is_default` (erro `no_default` se não houver).
|
|
81
|
+
* - Caminha filha → `inherits_from` → … até a tabela sem mãe; a PRIMEIRA tabela da
|
|
82
|
+
* cadeia que DECLARA a chave vence (`disabled` também declara).
|
|
83
|
+
* - Erros: `missing_table` (o `tableId` pedido não existe), `missing_parent`
|
|
84
|
+
* (`inherits_from` aponta para id inexistente), `cycle` (a cadeia revisita uma tabela).
|
|
85
|
+
*
|
|
86
|
+
* Exemplo: padrão `{a: usage 1, b: usage 2}` ← filha `{b: disabled, c: usage 3}`
|
|
87
|
+
* resolve a filha em `{a ← padrão, b: disabled ← filha, c ← filha}`, chain `[filha, padrão]`.
|
|
88
|
+
*/
|
|
89
|
+
export declare function resolvePriceTableLines(tables: Record<string, INexFinopsPriceTable>, tableId: string | null | undefined): ResolvedPriceTable;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PriceTableResolveError = exports.NEX_FINOPS_PRICE_TABLES_COLLECTION = void 0;
|
|
4
|
+
exports.resolvePriceTableLines = resolvePriceTableLines;
|
|
5
|
+
// ── Tabelas de preço (feat-328) ──
|
|
6
|
+
//
|
|
7
|
+
// A tabela de preço diz QUANTO custa cada métrica/módulo. Ela **só tem preço**:
|
|
8
|
+
// o que foi vendido (franquias, pacote comercial) vive na Oferta/contrato
|
|
9
|
+
// (decisão Q1). Contrato aponta para uma tabela via `price_table_id`
|
|
10
|
+
// (ausente = tabela padrão).
|
|
11
|
+
//
|
|
12
|
+
// Herança é **por linha**: uma tabela filha declara só as chaves que muda.
|
|
13
|
+
// - chave ausente na filha ⇒ herda da mãe (e assim por diante até a padrão);
|
|
14
|
+
// - chave com linha própria ⇒ sobrescreve a herdada;
|
|
15
|
+
// - chave com `kind: 'disabled'` ⇒ ANULA a herdada (a métrica deixa de ser cobrada).
|
|
16
|
+
//
|
|
17
|
+
// Para "voltar a herdar", remove-se a linha própria — nunca se grava `null`.
|
|
18
|
+
/** Coleção das tabelas: `core/nexus/apps/nex-finops/price_tables/{id}`. */
|
|
19
|
+
exports.NEX_FINOPS_PRICE_TABLES_COLLECTION = 'price_tables';
|
|
20
|
+
/** Erro tipado do resolvedor. `table_id` = tabela onde o problema foi detectado (quando houver). */
|
|
21
|
+
class PriceTableResolveError extends Error {
|
|
22
|
+
code;
|
|
23
|
+
table_id;
|
|
24
|
+
constructor(code, message, tableId = null) {
|
|
25
|
+
super(message);
|
|
26
|
+
this.name = 'PriceTableResolveError';
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.table_id = tableId;
|
|
29
|
+
Object.setPrototypeOf(this, PriceTableResolveError.prototype);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.PriceTableResolveError = PriceTableResolveError;
|
|
33
|
+
/**
|
|
34
|
+
* Resolvedor PURO da cadeia de herança — o mesmo no backend e no Nexus (front),
|
|
35
|
+
* para a origem por linha mostrada na tela bater com o que o motor cobra.
|
|
36
|
+
*
|
|
37
|
+
* - `tableId` ausente/null ⇒ parte da tabela com `is_default` (erro `no_default` se não houver).
|
|
38
|
+
* - Caminha filha → `inherits_from` → … até a tabela sem mãe; a PRIMEIRA tabela da
|
|
39
|
+
* cadeia que DECLARA a chave vence (`disabled` também declara).
|
|
40
|
+
* - Erros: `missing_table` (o `tableId` pedido não existe), `missing_parent`
|
|
41
|
+
* (`inherits_from` aponta para id inexistente), `cycle` (a cadeia revisita uma tabela).
|
|
42
|
+
*
|
|
43
|
+
* Exemplo: padrão `{a: usage 1, b: usage 2}` ← filha `{b: disabled, c: usage 3}`
|
|
44
|
+
* resolve a filha em `{a ← padrão, b: disabled ← filha, c ← filha}`, chain `[filha, padrão]`.
|
|
45
|
+
*/
|
|
46
|
+
function resolvePriceTableLines(tables, tableId) {
|
|
47
|
+
let startId;
|
|
48
|
+
if (tableId) {
|
|
49
|
+
if (!Object.prototype.hasOwnProperty.call(tables, tableId)) {
|
|
50
|
+
throw new PriceTableResolveError('missing_table', `price table "${tableId}" not found`, tableId);
|
|
51
|
+
}
|
|
52
|
+
startId = tableId;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
const defaultId = Object.keys(tables).find((id) => tables[id]?.is_default === true);
|
|
56
|
+
if (!defaultId) {
|
|
57
|
+
throw new PriceTableResolveError('no_default', 'no default price table');
|
|
58
|
+
}
|
|
59
|
+
startId = defaultId;
|
|
60
|
+
}
|
|
61
|
+
const chain = [];
|
|
62
|
+
const lines = {};
|
|
63
|
+
const seen = new Set();
|
|
64
|
+
let currentId = startId;
|
|
65
|
+
while (currentId) {
|
|
66
|
+
if (seen.has(currentId)) {
|
|
67
|
+
throw new PriceTableResolveError('cycle', `price table inheritance cycle: ${[...chain, currentId].join(' -> ')}`, currentId);
|
|
68
|
+
}
|
|
69
|
+
seen.add(currentId);
|
|
70
|
+
chain.push(currentId);
|
|
71
|
+
const table = tables[currentId];
|
|
72
|
+
const ownLines = table.lines ?? {};
|
|
73
|
+
for (const key of Object.keys(ownLines)) {
|
|
74
|
+
const line = ownLines[key];
|
|
75
|
+
if (!line)
|
|
76
|
+
continue;
|
|
77
|
+
if (!Object.prototype.hasOwnProperty.call(lines, key)) {
|
|
78
|
+
lines[key] = { line, from_table: currentId };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const parentId = table.inherits_from ?? null;
|
|
82
|
+
if (parentId && !Object.prototype.hasOwnProperty.call(tables, parentId)) {
|
|
83
|
+
throw new PriceTableResolveError('missing_parent', `price table "${currentId}" inherits from missing table "${parentId}"`, currentId);
|
|
84
|
+
}
|
|
85
|
+
currentId = parentId;
|
|
86
|
+
}
|
|
87
|
+
return { chain, lines };
|
|
88
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import type { IFireGlobalDoc } from '../../shared';
|
|
2
|
+
|
|
3
|
+
// ── Tabelas de preço (feat-328) ──
|
|
4
|
+
//
|
|
5
|
+
// A tabela de preço diz QUANTO custa cada métrica/módulo. Ela **só tem preço**:
|
|
6
|
+
// o que foi vendido (franquias, pacote comercial) vive na Oferta/contrato
|
|
7
|
+
// (decisão Q1). Contrato aponta para uma tabela via `price_table_id`
|
|
8
|
+
// (ausente = tabela padrão).
|
|
9
|
+
//
|
|
10
|
+
// Herança é **por linha**: uma tabela filha declara só as chaves que muda.
|
|
11
|
+
// - chave ausente na filha ⇒ herda da mãe (e assim por diante até a padrão);
|
|
12
|
+
// - chave com linha própria ⇒ sobrescreve a herdada;
|
|
13
|
+
// - chave com `kind: 'disabled'` ⇒ ANULA a herdada (a métrica deixa de ser cobrada).
|
|
14
|
+
//
|
|
15
|
+
// Para "voltar a herdar", remove-se a linha própria — nunca se grava `null`.
|
|
16
|
+
|
|
17
|
+
/** Coleção das tabelas: `core/nexus/apps/nex-finops/price_tables/{id}`. */
|
|
18
|
+
export const NEX_FINOPS_PRICE_TABLES_COLLECTION = 'price_tables';
|
|
19
|
+
|
|
20
|
+
/** Teto por faixas sobre o total da métrica (Q2): até `up_to` unidades, o total é `total`. */
|
|
21
|
+
export interface INexFinopsPriceCapTier {
|
|
22
|
+
/** Limite superior (inclusivo) de unidades da faixa. Inteiro > 0, estritamente crescente entre faixas. */
|
|
23
|
+
up_to: number;
|
|
24
|
+
/** Valor total (BRL) cobrado quando o consumo cai nesta faixa. */
|
|
25
|
+
total: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface INexFinopsPriceCap {
|
|
29
|
+
mode: 'tiered_total';
|
|
30
|
+
tiers: INexFinopsPriceCapTier[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Linha de uso: cobra `unit_price` por unidade consumida (opcionalmente com teto por faixas). */
|
|
34
|
+
export interface INexFinopsPriceLineUsage {
|
|
35
|
+
kind: 'usage';
|
|
36
|
+
/** Preço unitário (BRL). */
|
|
37
|
+
unit_price: number;
|
|
38
|
+
/** Categoria de `billing_services` (SSR, SMS, TELE, TELEGRV, …): vira item de cobrança e código de serviço da NFS-e. */
|
|
39
|
+
service_category: string;
|
|
40
|
+
cap?: INexFinopsPriceCap | null;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Linha recorrente: valor fixo por ciclo (ex.: módulo ativo no fechamento). */
|
|
44
|
+
export interface INexFinopsPriceLineRecurring {
|
|
45
|
+
kind: 'recurring';
|
|
46
|
+
/** Valor por ciclo (BRL). */
|
|
47
|
+
amount: number;
|
|
48
|
+
/** Categoria de `billing_services`. */
|
|
49
|
+
service_category: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Anula a linha herdada: a chave passa a não ser cobrada nesta tabela (e nas
|
|
54
|
+
* filhas dela, salvo se alguma filha redeclarar). Conta como "declarada" na
|
|
55
|
+
* resolução — interrompe a busca na cadeia.
|
|
56
|
+
*/
|
|
57
|
+
export interface INexFinopsPriceLineDisabled {
|
|
58
|
+
kind: 'disabled';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Linha de preço, discriminada por `kind`. Chave do mapa = métrica (usage) ou módulo (recurring). */
|
|
62
|
+
export type INexFinopsPriceLine =
|
|
63
|
+
| INexFinopsPriceLineUsage
|
|
64
|
+
| INexFinopsPriceLineRecurring
|
|
65
|
+
| INexFinopsPriceLineDisabled;
|
|
66
|
+
|
|
67
|
+
export type NexFinopsPriceLineKind = INexFinopsPriceLine['kind'];
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Tabela de preço. Exatamente uma tem `is_default: true` — e é a única sem mãe.
|
|
71
|
+
* Toda outra tem `inherits_from` apontando para uma tabela viva, sem ciclo
|
|
72
|
+
* (validação na escrita, backend).
|
|
73
|
+
*/
|
|
74
|
+
export interface INexFinopsPriceTable extends IFireGlobalDoc {
|
|
75
|
+
name: string;
|
|
76
|
+
is_default: boolean;
|
|
77
|
+
/** Id da tabela mãe. Obrigatório quando `!is_default`; ausente/null na padrão. */
|
|
78
|
+
inherits_from?: string | null;
|
|
79
|
+
/** Linhas PRÓPRIAS desta tabela (não as herdadas). Chave ausente = herda. */
|
|
80
|
+
lines: Record<string, INexFinopsPriceLine>;
|
|
81
|
+
notes?: string | null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Linha efetiva após a resolução, com a tabela que a declarou (origem exibida no Nexus). */
|
|
85
|
+
export interface ResolvedPriceLine {
|
|
86
|
+
line: INexFinopsPriceLine;
|
|
87
|
+
/** Id da tabela da cadeia que declarou a chave. */
|
|
88
|
+
from_table: string;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export interface ResolvedPriceTable {
|
|
92
|
+
/** Ids percorridos, da tabela pedida até a padrão (inclusive). */
|
|
93
|
+
chain: string[];
|
|
94
|
+
/** Linhas efetivas por chave. Inclui `disabled` (o consumidor decide como exibir/ignorar). */
|
|
95
|
+
lines: Record<string, ResolvedPriceLine>;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type PriceTableResolveErrorCode = 'no_default' | 'missing_table' | 'missing_parent' | 'cycle';
|
|
99
|
+
|
|
100
|
+
/** Erro tipado do resolvedor. `table_id` = tabela onde o problema foi detectado (quando houver). */
|
|
101
|
+
export class PriceTableResolveError extends Error {
|
|
102
|
+
readonly code: PriceTableResolveErrorCode;
|
|
103
|
+
readonly table_id: string | null;
|
|
104
|
+
|
|
105
|
+
constructor(code: PriceTableResolveErrorCode, message: string, tableId: string | null = null) {
|
|
106
|
+
super(message);
|
|
107
|
+
this.name = 'PriceTableResolveError';
|
|
108
|
+
this.code = code;
|
|
109
|
+
this.table_id = tableId;
|
|
110
|
+
Object.setPrototypeOf(this, PriceTableResolveError.prototype);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Resolvedor PURO da cadeia de herança — o mesmo no backend e no Nexus (front),
|
|
116
|
+
* para a origem por linha mostrada na tela bater com o que o motor cobra.
|
|
117
|
+
*
|
|
118
|
+
* - `tableId` ausente/null ⇒ parte da tabela com `is_default` (erro `no_default` se não houver).
|
|
119
|
+
* - Caminha filha → `inherits_from` → … até a tabela sem mãe; a PRIMEIRA tabela da
|
|
120
|
+
* cadeia que DECLARA a chave vence (`disabled` também declara).
|
|
121
|
+
* - Erros: `missing_table` (o `tableId` pedido não existe), `missing_parent`
|
|
122
|
+
* (`inherits_from` aponta para id inexistente), `cycle` (a cadeia revisita uma tabela).
|
|
123
|
+
*
|
|
124
|
+
* Exemplo: padrão `{a: usage 1, b: usage 2}` ← filha `{b: disabled, c: usage 3}`
|
|
125
|
+
* resolve a filha em `{a ← padrão, b: disabled ← filha, c ← filha}`, chain `[filha, padrão]`.
|
|
126
|
+
*/
|
|
127
|
+
export function resolvePriceTableLines(
|
|
128
|
+
tables: Record<string, INexFinopsPriceTable>,
|
|
129
|
+
tableId: string | null | undefined,
|
|
130
|
+
): ResolvedPriceTable {
|
|
131
|
+
let startId: string;
|
|
132
|
+
if (tableId) {
|
|
133
|
+
if (!Object.prototype.hasOwnProperty.call(tables, tableId)) {
|
|
134
|
+
throw new PriceTableResolveError('missing_table', `price table "${tableId}" not found`, tableId);
|
|
135
|
+
}
|
|
136
|
+
startId = tableId;
|
|
137
|
+
} else {
|
|
138
|
+
const defaultId = Object.keys(tables).find((id) => tables[id]?.is_default === true);
|
|
139
|
+
if (!defaultId) {
|
|
140
|
+
throw new PriceTableResolveError('no_default', 'no default price table');
|
|
141
|
+
}
|
|
142
|
+
startId = defaultId;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const chain: string[] = [];
|
|
146
|
+
const lines: Record<string, ResolvedPriceLine> = {};
|
|
147
|
+
const seen = new Set<string>();
|
|
148
|
+
let currentId: string | null = startId;
|
|
149
|
+
|
|
150
|
+
while (currentId) {
|
|
151
|
+
if (seen.has(currentId)) {
|
|
152
|
+
throw new PriceTableResolveError(
|
|
153
|
+
'cycle',
|
|
154
|
+
`price table inheritance cycle: ${[...chain, currentId].join(' -> ')}`,
|
|
155
|
+
currentId,
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
seen.add(currentId);
|
|
159
|
+
chain.push(currentId);
|
|
160
|
+
|
|
161
|
+
const table: INexFinopsPriceTable = tables[currentId];
|
|
162
|
+
const ownLines: Record<string, INexFinopsPriceLine> = table.lines ?? {};
|
|
163
|
+
for (const key of Object.keys(ownLines)) {
|
|
164
|
+
const line = ownLines[key];
|
|
165
|
+
if (!line) continue;
|
|
166
|
+
if (!Object.prototype.hasOwnProperty.call(lines, key)) {
|
|
167
|
+
lines[key] = { line, from_table: currentId };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
const parentId: string | null = table.inherits_from ?? null;
|
|
172
|
+
if (parentId && !Object.prototype.hasOwnProperty.call(tables, parentId)) {
|
|
173
|
+
throw new PriceTableResolveError(
|
|
174
|
+
'missing_parent',
|
|
175
|
+
`price table "${currentId}" inherits from missing table "${parentId}"`,
|
|
176
|
+
currentId,
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
currentId = parentId;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return { chain, lines };
|
|
183
|
+
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { IFireGlobalDoc } from '../../shared';
|
|
2
|
+
import type { NexVendasContractType } from '../../nex-vendas/adhesion';
|
|
3
|
+
import type { INexVendasAttribution } from '../../nex-vendas/offer';
|
|
2
4
|
/**
|
|
3
5
|
* `viewed` é carimbado pelo endpoint público no primeiro acesso ao `short_code`.
|
|
4
6
|
* `expired` é **derivado** de `valid_until` na leitura (não há cron): o documento
|
|
@@ -87,11 +89,28 @@ export interface INexFinopsProposal extends IFireGlobalDoc {
|
|
|
87
89
|
* existe. Ausente é o legado anterior à feat-140 — envelope no modelo único.
|
|
88
90
|
*/
|
|
89
91
|
contract_template_key?: string | null;
|
|
92
|
+
/**
|
|
93
|
+
* feat-325 D2 — cópia congelada do `contract_type` do modelo escolhido.
|
|
94
|
+
* DERIVADO no backend a cada create/update a partir de `contract_template_key`;
|
|
95
|
+
* o valor enviado pelo cliente HTTP é sobrescrito. Ausente = `assinatura_eletronica`.
|
|
96
|
+
*/
|
|
97
|
+
contract_type?: NexVendasContractType | null;
|
|
90
98
|
valid_until: string;
|
|
91
99
|
sent_at?: Date | null;
|
|
92
100
|
viewed_at?: Date | null;
|
|
93
101
|
accepted_at?: Date | null;
|
|
94
102
|
notes?: string | null;
|
|
103
|
+
/** Slug da oferta que gerou esta proposta pelo `start`. Ausente = proposta do vendedor. */
|
|
104
|
+
offer_slug?: string | null;
|
|
105
|
+
/** Atribuição de marketing do `start` (utm, gclid, referrer, site, landing). */
|
|
106
|
+
attribution?: INexVendasAttribution | null;
|
|
107
|
+
/** UUID do navegador no `start`: repetição em 24 h devolve o mesmo `short_code`. */
|
|
108
|
+
client_request_id?: string | null;
|
|
109
|
+
/**
|
|
110
|
+
* Autor: uid do usuário Nexus, ou `system:offer` (`NEX_VENDAS_OFFER_PROPOSAL_CREATED_BY`)
|
|
111
|
+
* para a proposta gerada por oferta. Ausente em propostas anteriores à feat-326.
|
|
112
|
+
*/
|
|
113
|
+
created_by?: string | null;
|
|
95
114
|
}
|
|
96
115
|
/** O que o endpoint sem auth expõe. Sem ids internos, sem dado sensível. */
|
|
97
116
|
export interface INexFinopsProposalPublic {
|
|
@@ -112,6 +131,12 @@ export interface INexFinopsProposalPublic {
|
|
|
112
131
|
* envelope usa é decisão interna.
|
|
113
132
|
*/
|
|
114
133
|
loyalty_period_label?: string | null;
|
|
134
|
+
/**
|
|
135
|
+
* feat-325 — tipo de formalização, para o shop ajustar os passos ANTES do aceite
|
|
136
|
+
* da proposta ("Assinatura" × "Aceite"). Ausente em backend anterior à feat-325
|
|
137
|
+
* (= `assinatura_eletronica`).
|
|
138
|
+
*/
|
|
139
|
+
contract_type?: NexVendasContractType | null;
|
|
115
140
|
/**
|
|
116
141
|
* Dados que o vendedor cadastrou, por inteiro, para a página pública
|
|
117
142
|
* pré-preencher o formulário. `null` quando a proposta não tem prefill; cada
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { IFireGlobalDoc } from '../../shared';
|
|
2
|
+
import type { NexVendasContractType } from '../../nex-vendas/adhesion';
|
|
3
|
+
import type { INexVendasAttribution } from '../../nex-vendas/offer';
|
|
2
4
|
|
|
3
5
|
// ── Status, origem e formas de pagamento ──
|
|
4
6
|
|
|
@@ -115,6 +117,12 @@ export interface INexFinopsProposal extends IFireGlobalDoc {
|
|
|
115
117
|
* existe. Ausente é o legado anterior à feat-140 — envelope no modelo único.
|
|
116
118
|
*/
|
|
117
119
|
contract_template_key?: string | null;
|
|
120
|
+
/**
|
|
121
|
+
* feat-325 D2 — cópia congelada do `contract_type` do modelo escolhido.
|
|
122
|
+
* DERIVADO no backend a cada create/update a partir de `contract_template_key`;
|
|
123
|
+
* o valor enviado pelo cliente HTTP é sobrescrito. Ausente = `assinatura_eletronica`.
|
|
124
|
+
*/
|
|
125
|
+
contract_type?: NexVendasContractType | null;
|
|
118
126
|
|
|
119
127
|
// Validade — data ISO `YYYY-MM-DD`, igual a `starts_at`/`ends_at` do contrato
|
|
120
128
|
valid_until: string;
|
|
@@ -125,6 +133,20 @@ export interface INexFinopsProposal extends IFireGlobalDoc {
|
|
|
125
133
|
accepted_at?: Date | null;
|
|
126
134
|
|
|
127
135
|
notes?: string | null;
|
|
136
|
+
|
|
137
|
+
// ── Self-service (feat-326) ──
|
|
138
|
+
|
|
139
|
+
/** Slug da oferta que gerou esta proposta pelo `start`. Ausente = proposta do vendedor. */
|
|
140
|
+
offer_slug?: string | null;
|
|
141
|
+
/** Atribuição de marketing do `start` (utm, gclid, referrer, site, landing). */
|
|
142
|
+
attribution?: INexVendasAttribution | null;
|
|
143
|
+
/** UUID do navegador no `start`: repetição em 24 h devolve o mesmo `short_code`. */
|
|
144
|
+
client_request_id?: string | null;
|
|
145
|
+
/**
|
|
146
|
+
* Autor: uid do usuário Nexus, ou `system:offer` (`NEX_VENDAS_OFFER_PROPOSAL_CREATED_BY`)
|
|
147
|
+
* para a proposta gerada por oferta. Ausente em propostas anteriores à feat-326.
|
|
148
|
+
*/
|
|
149
|
+
created_by?: string | null;
|
|
128
150
|
}
|
|
129
151
|
|
|
130
152
|
// ── Projeção pública ──
|
|
@@ -148,6 +170,12 @@ export interface INexFinopsProposalPublic {
|
|
|
148
170
|
* envelope usa é decisão interna.
|
|
149
171
|
*/
|
|
150
172
|
loyalty_period_label?: string | null;
|
|
173
|
+
/**
|
|
174
|
+
* feat-325 — tipo de formalização, para o shop ajustar os passos ANTES do aceite
|
|
175
|
+
* da proposta ("Assinatura" × "Aceite"). Ausente em backend anterior à feat-325
|
|
176
|
+
* (= `assinatura_eletronica`).
|
|
177
|
+
*/
|
|
178
|
+
contract_type?: NexVendasContractType | null;
|
|
151
179
|
/**
|
|
152
180
|
* Dados que o vendedor cadastrou, por inteiro, para a página pública
|
|
153
181
|
* pré-preencher o formulário. `null` quando a proposta não tem prefill; cada
|
|
@@ -2,6 +2,7 @@ export * from "./fb_collections";
|
|
|
2
2
|
export * from "./common";
|
|
3
3
|
export * from "./common/taker";
|
|
4
4
|
export * from "./common/contract";
|
|
5
|
+
export * from "./common/price-table";
|
|
5
6
|
export * from "./common/proposal";
|
|
6
7
|
export * from "./common/billing";
|
|
7
8
|
export * from "./common/payment-method";
|
|
@@ -19,6 +19,7 @@ __exportStar(require("./fb_collections"), exports);
|
|
|
19
19
|
__exportStar(require("./common"), exports);
|
|
20
20
|
__exportStar(require("./common/taker"), exports);
|
|
21
21
|
__exportStar(require("./common/contract"), exports);
|
|
22
|
+
__exportStar(require("./common/price-table"), exports);
|
|
22
23
|
__exportStar(require("./common/proposal"), exports);
|
|
23
24
|
__exportStar(require("./common/billing"), exports);
|
|
24
25
|
__exportStar(require("./common/payment-method"), exports);
|
|
@@ -4,6 +4,7 @@ export * from "./fb_collections";
|
|
|
4
4
|
export * from "./common";
|
|
5
5
|
export * from "./common/taker";
|
|
6
6
|
export * from "./common/contract";
|
|
7
|
+
export * from "./common/price-table";
|
|
7
8
|
export * from "./common/proposal";
|
|
8
9
|
export * from "./common/billing";
|
|
9
10
|
export * from "./common/payment-method";
|
|
@@ -61,6 +61,15 @@ export interface IUsageDepartmentRow {
|
|
|
61
61
|
export interface IUsageContacts {
|
|
62
62
|
/** Contatos únicos no tenant no mês (dedup por pessoa, tenant-wide). */
|
|
63
63
|
atendidos: number;
|
|
64
|
+
/**
|
|
65
|
+
* feat-328 — dos `atendidos`, os que tiveram >=1 mensagem de SAÍDA humana no
|
|
66
|
+
* mês (inclui resposta pelo aparelho na coexistência — eco do WhatsApp
|
|
67
|
+
* Business App). Invariante: `atendidos = atendidos_humano + atendidos_ia`.
|
|
68
|
+
*/
|
|
69
|
+
atendidos_humano?: number;
|
|
70
|
+
/** feat-328 — complemento de `atendidos_humano`: atendidos só pela IA/automação no mês.
|
|
71
|
+
* Opcionais até a F3 preencher (a versão publicada não pode quebrar o build do `main`). */
|
|
72
|
+
atendidos_ia?: number;
|
|
64
73
|
/** Contatos únicos ativados no tenant no mês. */
|
|
65
74
|
ativados: number;
|
|
66
75
|
/**
|
|
@@ -79,6 +79,15 @@ export interface IUsageDepartmentRow {
|
|
|
79
79
|
export interface IUsageContacts {
|
|
80
80
|
/** Contatos únicos no tenant no mês (dedup por pessoa, tenant-wide). */
|
|
81
81
|
atendidos: number;
|
|
82
|
+
/**
|
|
83
|
+
* feat-328 — dos `atendidos`, os que tiveram >=1 mensagem de SAÍDA humana no
|
|
84
|
+
* mês (inclui resposta pelo aparelho na coexistência — eco do WhatsApp
|
|
85
|
+
* Business App). Invariante: `atendidos = atendidos_humano + atendidos_ia`.
|
|
86
|
+
*/
|
|
87
|
+
atendidos_humano?: number;
|
|
88
|
+
/** feat-328 — complemento de `atendidos_humano`: atendidos só pela IA/automação no mês.
|
|
89
|
+
* Opcionais até a F3 preencher (a versão publicada não pode quebrar o build do `main`). */
|
|
90
|
+
atendidos_ia?: number;
|
|
82
91
|
/** Contatos únicos ativados no tenant no mês. */
|
|
83
92
|
ativados: number;
|
|
84
93
|
/**
|