evo360-types 1.3.780 → 1.3.784
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/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-chat/waba-template/zod-schemas.d.ts +70 -0
- package/dist/apps/evo-chat/waba-template/zod-schemas.js +6 -2
- package/dist/apps/evo-chat/waba-template/zod-schemas.ts +6 -1
- package/dist/apps/evo-finops/zod-schemas.d.ts +329 -2
- package/dist/apps/evo-finops/zod-schemas.js +66 -2
- package/dist/apps/evo-finops/zod-schemas.ts +74 -0
- package/dist/apps/evo-hub-ia/v1/zod-schemas.d.ts +4 -4
- 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 +21 -1
- package/dist/types/evo-finops/common/contract.js +7 -0
- package/dist/types/evo-finops/common/contract.ts +23 -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/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/shared/template-profile.d.ts +23 -1
- package/dist/types/shared/template-profile.js +11 -0
- package/dist/types/shared/template-profile.ts +26 -1
- package/package.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.zServiceTaxInfoSchema = exports.zServiceLineItemSchema = exports.zServiceInvoiceStateSchema = exports.zProviderServiceInvoiceStatusSchema = exports.zExternalLinkSchema = exports.zExternalObjectTypeSchema = exports.zInvoiceSourceRefSchema = exports.zInvoiceSourceTypeSchema = exports.zInvoiceTakerRefSchema = exports.zInvoiceTakerSnapshotSchema = exports.zInvoiceTakerSnapshotAddressSchema = exports.zTakerDocumentSchema = exports.zTakerTaxProfileSchema = exports.zTakerProviderRefsSchema = exports.zTakerAddressSchema = exports.zInvoiceTakerTypeSchema = exports.zServiceSchema = exports.zCustomerServiceTaxInfoSchema = exports.zIssuerTaxProfileSchema = exports.zIssuerNfseConfigSchema = exports.zIssuerMunicipalCredentialsRefSchema = exports.zIssuerTaxRegimeSchema = exports.zIssuerCompanyIdentitySchema = exports.zIssuerCompanyAddressSchema = exports.zTaxProfileSyncStateSchema = exports.zAsaasProviderSchema = exports.zAsaasProviderAsaasBlockSchema = exports.zAsaasProviderCapabilitiesSchema = exports.zAsaasPaymentsCapabilitiesSchema = exports.zAsaasEnvFlagSchema = exports.zAsaasNfseCapabilitiesSchema = exports.zAsaasEnvAuthConfigSchema = exports.zAsaasSubaccountInputSchema = exports.zAsaasAccountScopeSchema = exports.zAsaasWebhookConfigSchema = exports.zRetryPolicySchema = exports.zAsaasWebhookEventSchema = exports.zAsaasAccountScopeModeSchema = exports.zProviderRemoteRefsSchema = exports.zProviderFiscalInfoPayloadSchema = exports.zProviderCredentialsInputSchema = exports.zProviderCredentialsSecretRefsSchema = exports.zProviderMunicipalOptionsSnapshotSchema = exports.zProviderOptionItemSchema = exports.zProviderMunicipalAuthTypeSchema = exports.zFinopsProviderBaseSchema = exports.zProviderStatusSchema = exports.zFinopsActionSchema = exports.zFinopsProviderTypeSchema = exports.zProviderEnvSchema = void 0;
|
|
4
|
-
exports.
|
|
5
|
-
exports.zNfseFeeReimbursementExecuteSchema = void 0;
|
|
4
|
+
exports.zNexFinopsContractPaymentMethodsWriteSchema = exports.zNexFinopsPaymentMethodPatchSchema = exports.zNexFinopsPaymentMethodStatusSchema = exports.zNexFinopsPaymentMethodKindSchema = exports.zNexFinopsPriceTableWriteSchema = exports.zNexFinopsPriceLinesSchema = exports.zNexFinopsPriceLineSchema = exports.zNexFinopsPriceCapSchema = exports.zNexFinopsPriceCapTierSchema = exports.zNexFinopsContractAllowancesWriteSchema = exports.zNexFinopsUsageAlertDefaultsSchema = exports.zNexFinopsAlertThresholdSchema = exports.zNexFinopsContractAllowancesSchema = exports.zNexFinopsContractAllowanceSchema = exports.zNexVendasJourneyPaymentSchema = exports.zNexVendasJourneyPaymentSupersededSchema = exports.zNexVendasJourneyPaymentWebhookEventSchema = exports.zNexVendasJourneyBoletoSchema = exports.zNexVendasJourneyPaymentChooseSchema = exports.zNexVendasJourneyPaymentStateSchema = exports.zNexVendasJourneyPaymentKindSchema = exports.zNexVendasJourneyPaymentMethodSchema = exports.zNexFinopsContractAsaasInfoSchema = exports.zNexFinopsAsaasSubscriptionStatusSchema = exports.zNexFinopsPaymentMethodSchema = exports.zNexFinopsProposalSchema = exports.zNexFinopsProposalWriteSchema = exports.zNexFinopsProposalPrefillSchema = exports.zNexFinopsProposalLoyaltyPeriodSchema = exports.zNexFinopsProposalPaymentMethodSchema = exports.zNexFinopsProposalStatusSchema = exports.zServiceInvoiceSchema = exports.zServiceInvoiceReplacedBySchema = exports.zServiceInvoiceReissuedFromSchema = exports.zServiceInvoiceReissueSchema = exports.zNfseReissueStageSchema = exports.zNfseReissueFieldSchema = exports.zNfseReissueStatusSchema = exports.zServiceInvoiceCancellationSchema = exports.zNfseCancellationStatusSchema = exports.zPaymentLinkSchema = exports.zPaymentLinkDocumentStateSchema = exports.zAsaasPaymentLinkSubscriptionCycleSchema = exports.zAsaasPaymentLinkChargeTypeSchema = exports.zAsaasPaymentLinkBillingTypeSchema = exports.zProviderPayloadSnapshotSchema = exports.zProviderTraceSchema = exports.zProviderInvoiceErrorSchema = exports.zProviderInvoiceIdentifiersSchema = exports.zProviderInvoiceLinksSchema = void 0;
|
|
5
|
+
exports.zNfseFeeReimbursementExecuteSchema = exports.zNfseFeeReimbursementCompetenciaSchema = exports.zNexFinopsPaymentMethodsDiscoverSchema = exports.zNexFinopsBillingCardChargeSweepSchema = exports.zEvoBillingPortalCardCaptureSchema = exports.zNexFinopsBillingCardChargeSchema = void 0;
|
|
6
6
|
const zod_1 = require("zod");
|
|
7
7
|
const zod_schemas_1 = require("../shared/zod-schemas");
|
|
8
8
|
// ---- Provider enums and base ----
|
|
@@ -1047,6 +1047,70 @@ exports.zNexFinopsContractAllowancesWriteSchema = zod_1.z
|
|
|
1047
1047
|
alert_thresholds: zod_1.z.array(exports.zNexFinopsAlertThresholdSchema).optional().nullable(),
|
|
1048
1048
|
/** feat-264 D4 — ausente/null = TRUE (reembolsa). */
|
|
1049
1049
|
nfse_fee_reimbursement: zod_1.z.boolean().optional().nullable(),
|
|
1050
|
+
/** feat-328 — tabela de preço do contrato. Ausente/null = tabela padrão. */
|
|
1051
|
+
price_table_id: zod_1.z.string().min(1).nullable().optional(),
|
|
1052
|
+
})
|
|
1053
|
+
.strip();
|
|
1054
|
+
// ---- Nexus FinOps — tabelas de preço (feat-328) ----
|
|
1055
|
+
//
|
|
1056
|
+
// A tabela só tem preço (Q1). Herança por linha: chave ausente = herda;
|
|
1057
|
+
// `kind: 'disabled'` anula a herdada. Regras que dependem das OUTRAS tabelas
|
|
1058
|
+
// (exatamente uma padrão, mãe viva, sem ciclo, padrão sem `disabled`) ficam no
|
|
1059
|
+
// use case do backend — aqui só a forma do documento.
|
|
1060
|
+
const zNexFinopsPriceAmountSchema = zod_1.z.number().finite().gte(0);
|
|
1061
|
+
exports.zNexFinopsPriceCapTierSchema = zod_1.z
|
|
1062
|
+
.object({
|
|
1063
|
+
up_to: zod_1.z.number().int().gt(0),
|
|
1064
|
+
total: zNexFinopsPriceAmountSchema,
|
|
1065
|
+
})
|
|
1066
|
+
.strip();
|
|
1067
|
+
exports.zNexFinopsPriceCapSchema = zod_1.z
|
|
1068
|
+
.object({
|
|
1069
|
+
mode: zod_1.z.literal("tiered_total"),
|
|
1070
|
+
tiers: zod_1.z
|
|
1071
|
+
.array(exports.zNexFinopsPriceCapTierSchema)
|
|
1072
|
+
.min(1)
|
|
1073
|
+
.superRefine((tiers, ctx) => {
|
|
1074
|
+
for (let i = 1; i < tiers.length; i++) {
|
|
1075
|
+
if (tiers[i].up_to <= tiers[i - 1].up_to) {
|
|
1076
|
+
ctx.addIssue({
|
|
1077
|
+
code: zod_1.z.ZodIssueCode.custom,
|
|
1078
|
+
path: [i, "up_to"],
|
|
1079
|
+
message: "tiers.up_to must be strictly increasing",
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
}),
|
|
1084
|
+
})
|
|
1085
|
+
.strip();
|
|
1086
|
+
exports.zNexFinopsPriceLineSchema = zod_1.z.discriminatedUnion("kind", [
|
|
1087
|
+
zod_1.z
|
|
1088
|
+
.object({
|
|
1089
|
+
kind: zod_1.z.literal("usage"),
|
|
1090
|
+
unit_price: zNexFinopsPriceAmountSchema,
|
|
1091
|
+
service_category: zod_1.z.string().min(1),
|
|
1092
|
+
cap: exports.zNexFinopsPriceCapSchema.nullable().optional(),
|
|
1093
|
+
})
|
|
1094
|
+
.strip(),
|
|
1095
|
+
zod_1.z
|
|
1096
|
+
.object({
|
|
1097
|
+
kind: zod_1.z.literal("recurring"),
|
|
1098
|
+
amount: zNexFinopsPriceAmountSchema,
|
|
1099
|
+
service_category: zod_1.z.string().min(1),
|
|
1100
|
+
})
|
|
1101
|
+
.strip(),
|
|
1102
|
+
zod_1.z.object({ kind: zod_1.z.literal("disabled") }).strip(),
|
|
1103
|
+
]);
|
|
1104
|
+
/** Chave = métrica (usage) ou módulo (recurring); mesmo limite das chaves de `allowances`. */
|
|
1105
|
+
exports.zNexFinopsPriceLinesSchema = zod_1.z.record(zod_1.z.string().min(1).max(64), exports.zNexFinopsPriceLineSchema);
|
|
1106
|
+
/** Create/update de tabela de preço. `lines` substitui o mapa inteiro (como `allowances`). */
|
|
1107
|
+
exports.zNexFinopsPriceTableWriteSchema = zod_1.z
|
|
1108
|
+
.object({
|
|
1109
|
+
name: zod_1.z.string().trim().min(1).max(120),
|
|
1110
|
+
is_default: zod_1.z.boolean(),
|
|
1111
|
+
inherits_from: zod_1.z.string().min(1).nullable().optional(),
|
|
1112
|
+
lines: exports.zNexFinopsPriceLinesSchema,
|
|
1113
|
+
notes: zod_1.z.string().nullable().optional(),
|
|
1050
1114
|
})
|
|
1051
1115
|
.strip();
|
|
1052
1116
|
// ---- Nexus FinOps — métodos de pagamento do cliente (feat-253) ----
|
|
@@ -1148,6 +1148,80 @@ export const zNexFinopsContractAllowancesWriteSchema = z
|
|
|
1148
1148
|
alert_thresholds: z.array(zNexFinopsAlertThresholdSchema).optional().nullable(),
|
|
1149
1149
|
/** feat-264 D4 — ausente/null = TRUE (reembolsa). */
|
|
1150
1150
|
nfse_fee_reimbursement: z.boolean().optional().nullable(),
|
|
1151
|
+
/** feat-328 — tabela de preço do contrato. Ausente/null = tabela padrão. */
|
|
1152
|
+
price_table_id: z.string().min(1).nullable().optional(),
|
|
1153
|
+
})
|
|
1154
|
+
.strip();
|
|
1155
|
+
|
|
1156
|
+
// ---- Nexus FinOps — tabelas de preço (feat-328) ----
|
|
1157
|
+
//
|
|
1158
|
+
// A tabela só tem preço (Q1). Herança por linha: chave ausente = herda;
|
|
1159
|
+
// `kind: 'disabled'` anula a herdada. Regras que dependem das OUTRAS tabelas
|
|
1160
|
+
// (exatamente uma padrão, mãe viva, sem ciclo, padrão sem `disabled`) ficam no
|
|
1161
|
+
// use case do backend — aqui só a forma do documento.
|
|
1162
|
+
|
|
1163
|
+
const zNexFinopsPriceAmountSchema = z.number().finite().gte(0);
|
|
1164
|
+
|
|
1165
|
+
export const zNexFinopsPriceCapTierSchema = z
|
|
1166
|
+
.object({
|
|
1167
|
+
up_to: z.number().int().gt(0),
|
|
1168
|
+
total: zNexFinopsPriceAmountSchema,
|
|
1169
|
+
})
|
|
1170
|
+
.strip();
|
|
1171
|
+
|
|
1172
|
+
export const zNexFinopsPriceCapSchema = z
|
|
1173
|
+
.object({
|
|
1174
|
+
mode: z.literal("tiered_total"),
|
|
1175
|
+
tiers: z
|
|
1176
|
+
.array(zNexFinopsPriceCapTierSchema)
|
|
1177
|
+
.min(1)
|
|
1178
|
+
.superRefine((tiers, ctx) => {
|
|
1179
|
+
for (let i = 1; i < tiers.length; i++) {
|
|
1180
|
+
if (tiers[i].up_to <= tiers[i - 1].up_to) {
|
|
1181
|
+
ctx.addIssue({
|
|
1182
|
+
code: z.ZodIssueCode.custom,
|
|
1183
|
+
path: [i, "up_to"],
|
|
1184
|
+
message: "tiers.up_to must be strictly increasing",
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
}),
|
|
1189
|
+
})
|
|
1190
|
+
.strip();
|
|
1191
|
+
|
|
1192
|
+
export const zNexFinopsPriceLineSchema = z.discriminatedUnion("kind", [
|
|
1193
|
+
z
|
|
1194
|
+
.object({
|
|
1195
|
+
kind: z.literal("usage"),
|
|
1196
|
+
unit_price: zNexFinopsPriceAmountSchema,
|
|
1197
|
+
service_category: z.string().min(1),
|
|
1198
|
+
cap: zNexFinopsPriceCapSchema.nullable().optional(),
|
|
1199
|
+
})
|
|
1200
|
+
.strip(),
|
|
1201
|
+
z
|
|
1202
|
+
.object({
|
|
1203
|
+
kind: z.literal("recurring"),
|
|
1204
|
+
amount: zNexFinopsPriceAmountSchema,
|
|
1205
|
+
service_category: z.string().min(1),
|
|
1206
|
+
})
|
|
1207
|
+
.strip(),
|
|
1208
|
+
z.object({ kind: z.literal("disabled") }).strip(),
|
|
1209
|
+
]);
|
|
1210
|
+
|
|
1211
|
+
/** Chave = métrica (usage) ou módulo (recurring); mesmo limite das chaves de `allowances`. */
|
|
1212
|
+
export const zNexFinopsPriceLinesSchema = z.record(
|
|
1213
|
+
z.string().min(1).max(64),
|
|
1214
|
+
zNexFinopsPriceLineSchema,
|
|
1215
|
+
);
|
|
1216
|
+
|
|
1217
|
+
/** Create/update de tabela de preço. `lines` substitui o mapa inteiro (como `allowances`). */
|
|
1218
|
+
export const zNexFinopsPriceTableWriteSchema = z
|
|
1219
|
+
.object({
|
|
1220
|
+
name: z.string().trim().min(1).max(120),
|
|
1221
|
+
is_default: z.boolean(),
|
|
1222
|
+
inherits_from: z.string().min(1).nullable().optional(),
|
|
1223
|
+
lines: zNexFinopsPriceLinesSchema,
|
|
1224
|
+
notes: z.string().nullable().optional(),
|
|
1151
1225
|
})
|
|
1152
1226
|
.strip();
|
|
1153
1227
|
|
|
@@ -1756,6 +1756,7 @@ export declare const zHubiaVoiceReplySchema: z.ZodObject<{
|
|
|
1756
1756
|
instructions?: string | undefined;
|
|
1757
1757
|
speed?: number | undefined;
|
|
1758
1758
|
}, {
|
|
1759
|
+
enabled?: boolean | undefined;
|
|
1759
1760
|
provider?: "openai" | "elevenlabs" | undefined;
|
|
1760
1761
|
elevenlabs?: {
|
|
1761
1762
|
stability?: number | undefined;
|
|
@@ -1766,7 +1767,6 @@ export declare const zHubiaVoiceReplySchema: z.ZodObject<{
|
|
|
1766
1767
|
voice?: string | undefined;
|
|
1767
1768
|
instructions?: string | undefined;
|
|
1768
1769
|
speed?: number | undefined;
|
|
1769
|
-
enabled?: boolean | undefined;
|
|
1770
1770
|
}>;
|
|
1771
1771
|
export type IHubiaVoiceReply = z.infer<typeof zHubiaVoiceReplySchema>;
|
|
1772
1772
|
export declare const zHubiaResponseModeSchema: z.ZodEnum<["text", "audio"]>;
|
|
@@ -2680,6 +2680,7 @@ export declare const zAiBindingSchema: z.ZodObject<{
|
|
|
2680
2680
|
instructions?: string | undefined;
|
|
2681
2681
|
speed?: number | undefined;
|
|
2682
2682
|
}, {
|
|
2683
|
+
enabled?: boolean | undefined;
|
|
2683
2684
|
provider?: "openai" | "elevenlabs" | undefined;
|
|
2684
2685
|
elevenlabs?: {
|
|
2685
2686
|
stability?: number | undefined;
|
|
@@ -2690,7 +2691,6 @@ export declare const zAiBindingSchema: z.ZodObject<{
|
|
|
2690
2691
|
voice?: string | undefined;
|
|
2691
2692
|
instructions?: string | undefined;
|
|
2692
2693
|
speed?: number | undefined;
|
|
2693
|
-
enabled?: boolean | undefined;
|
|
2694
2694
|
}>>;
|
|
2695
2695
|
/** feat-309: análise de fotos e PDFs recebidos neste departamento. Ausente = ligado.
|
|
2696
2696
|
* Só roda com `default_mode` `ai_only` ou `hybrid_assist` (em `human_only`/`blocked`
|
|
@@ -3503,6 +3503,7 @@ export declare const zAiBindingSchema: z.ZodObject<{
|
|
|
3503
3503
|
instructions?: string | undefined;
|
|
3504
3504
|
speed?: number | undefined;
|
|
3505
3505
|
}, {
|
|
3506
|
+
enabled?: boolean | undefined;
|
|
3506
3507
|
provider?: "openai" | "elevenlabs" | undefined;
|
|
3507
3508
|
elevenlabs?: {
|
|
3508
3509
|
stability?: number | undefined;
|
|
@@ -3513,7 +3514,6 @@ export declare const zAiBindingSchema: z.ZodObject<{
|
|
|
3513
3514
|
voice?: string | undefined;
|
|
3514
3515
|
instructions?: string | undefined;
|
|
3515
3516
|
speed?: number | undefined;
|
|
3516
|
-
enabled?: boolean | undefined;
|
|
3517
3517
|
}>>;
|
|
3518
3518
|
/** feat-309: análise de fotos e PDFs recebidos neste departamento. Ausente = ligado.
|
|
3519
3519
|
* Só roda com `default_mode` `ai_only` ou `hybrid_assist` (em `human_only`/`blocked`
|
|
@@ -4326,6 +4326,7 @@ export declare const zAiBindingSchema: z.ZodObject<{
|
|
|
4326
4326
|
instructions?: string | undefined;
|
|
4327
4327
|
speed?: number | undefined;
|
|
4328
4328
|
}, {
|
|
4329
|
+
enabled?: boolean | undefined;
|
|
4329
4330
|
provider?: "openai" | "elevenlabs" | undefined;
|
|
4330
4331
|
elevenlabs?: {
|
|
4331
4332
|
stability?: number | undefined;
|
|
@@ -4336,7 +4337,6 @@ export declare const zAiBindingSchema: z.ZodObject<{
|
|
|
4336
4337
|
voice?: string | undefined;
|
|
4337
4338
|
instructions?: string | undefined;
|
|
4338
4339
|
speed?: number | undefined;
|
|
4339
|
-
enabled?: boolean | undefined;
|
|
4340
4340
|
}>>;
|
|
4341
4341
|
/** feat-309: análise de fotos e PDFs recebidos neste departamento. Ausente = ligado.
|
|
4342
4342
|
* Só roda com `default_mode` `ai_only` ou `hybrid_assist` (em `human_only`/`blocked`
|
|
@@ -67,6 +67,14 @@ export interface IMessageCreatedBy {
|
|
|
67
67
|
type: 'human' | 'automation' | 'system';
|
|
68
68
|
user_id?: string;
|
|
69
69
|
workflow_id?: string;
|
|
70
|
+
/** Nome exibido do autor. Hoje o hub-waba grava `'WhatsApp Business App'` no eco da coexistência. */
|
|
71
|
+
display_name?: string;
|
|
72
|
+
/**
|
|
73
|
+
* feat-328 — origem especial da mensagem. `'coexistence_app'` marca o eco do
|
|
74
|
+
* WhatsApp Business App na coexistência (resposta humana dada pelo aparelho);
|
|
75
|
+
* conta como saída humana na métrica `attendances_human`.
|
|
76
|
+
*/
|
|
77
|
+
source?: 'coexistence_app';
|
|
70
78
|
}
|
|
71
79
|
export interface IMessagePricing {
|
|
72
80
|
category?: 'service' | 'utility' | 'authentication' | 'marketing';
|
|
@@ -93,6 +93,14 @@ export interface IMessageCreatedBy {
|
|
|
93
93
|
type: 'human' | 'automation' | 'system';
|
|
94
94
|
user_id?: string;
|
|
95
95
|
workflow_id?: string;
|
|
96
|
+
/** Nome exibido do autor. Hoje o hub-waba grava `'WhatsApp Business App'` no eco da coexistência. */
|
|
97
|
+
display_name?: string;
|
|
98
|
+
/**
|
|
99
|
+
* feat-328 — origem especial da mensagem. `'coexistence_app'` marca o eco do
|
|
100
|
+
* WhatsApp Business App na coexistência (resposta humana dada pelo aparelho);
|
|
101
|
+
* conta como saída humana na métrica `attendances_human`.
|
|
102
|
+
*/
|
|
103
|
+
source?: 'coexistence_app';
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
// ── Message pricing ──
|
|
@@ -54,7 +54,11 @@ export interface INexFinopsContractServiceItem {
|
|
|
54
54
|
export interface INexFinopsContractAllowance {
|
|
55
55
|
/** Quantidade incluída no ciclo. 0 = nada incluso; ausente = não contratado. */
|
|
56
56
|
included: number;
|
|
57
|
-
/**
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated feat-328 (Q4): nunca foi lido por ninguém. O preço do excedente
|
|
59
|
+
* vem da tabela de preço do contrato (`price_table_id` → `INexFinopsPriceTable`).
|
|
60
|
+
* Mantido só para não quebrar docs antigos; não escrever.
|
|
61
|
+
*/
|
|
58
62
|
unit_price_excess?: number | null;
|
|
59
63
|
}
|
|
60
64
|
/**
|
|
@@ -84,6 +88,14 @@ export declare const NexFinopsMetricCatalog: {
|
|
|
84
88
|
readonly label: "Teleconsultas com gravação";
|
|
85
89
|
readonly unit: "consultas";
|
|
86
90
|
};
|
|
91
|
+
readonly attendances_human: {
|
|
92
|
+
readonly label: "Atendimentos humanos";
|
|
93
|
+
readonly unit: "contatos";
|
|
94
|
+
};
|
|
95
|
+
readonly attendances_ai: {
|
|
96
|
+
readonly label: "Atendimentos por IA";
|
|
97
|
+
readonly unit: "contatos";
|
|
98
|
+
};
|
|
87
99
|
};
|
|
88
100
|
/**
|
|
89
101
|
* Chaves conhecidas do catálogo — para iterar e para tipar escolha de métrica
|
|
@@ -181,6 +193,14 @@ export interface INexFinopsContract extends IFireGlobalDoc {
|
|
|
181
193
|
alert_thresholds?: number[] | null;
|
|
182
194
|
/** feat-264 D4 — reembolsar a taxa de NFS-e ao cliente. ⚠️ Ausente/null = TRUE (reembolsa). */
|
|
183
195
|
nfse_fee_reimbursement?: boolean | null;
|
|
196
|
+
/**
|
|
197
|
+
* Id da `INexFinopsPriceTable` que precifica este contrato.
|
|
198
|
+
* ⚠️ Ausente/null = tabela **padrão** (`is_default`).
|
|
199
|
+
*
|
|
200
|
+
* Q8: todos os contratos vigentes do mesmo cliente devem apontar para a mesma
|
|
201
|
+
* tabela (efetiva) — validado pelo backend ao ativar o contrato.
|
|
202
|
+
*/
|
|
203
|
+
price_table_id?: string | null;
|
|
184
204
|
}
|
|
185
205
|
export declare const NEX_FINOPS_CONTRACT_STATUS_TRANSITIONS: Record<NexFinopsContractStatus, NexFinopsContractStatus[]>;
|
|
186
206
|
/**
|
|
@@ -18,6 +18,13 @@ exports.NexFinopsMetricCatalog = {
|
|
|
18
18
|
// duas vezes.
|
|
19
19
|
teleconsultations_unrecorded: { label: 'Teleconsultas sem gravação', unit: 'consultas' },
|
|
20
20
|
teleconsultations_recorded: { label: 'Teleconsultas com gravação', unit: 'consultas' },
|
|
21
|
+
// feat-328 — DISJUNTAS por pessoa-mês: humano = pessoa com >=1 mensagem de
|
|
22
|
+
// saida humana no mes; IA = o complemento (`attendances = human + ai`). Um
|
|
23
|
+
// contrato usa OU `attendances` (pool unico, legado) OU o par
|
|
24
|
+
// `attendances_human`/`attendances_ai`, NUNCA os tres — cobraria a mesma
|
|
25
|
+
// pessoa duas vezes. Validacao na escrita do contrato (backend, F3).
|
|
26
|
+
attendances_human: { label: 'Atendimentos humanos', unit: 'contatos' },
|
|
27
|
+
attendances_ai: { label: 'Atendimentos por IA', unit: 'contatos' },
|
|
21
28
|
};
|
|
22
29
|
/** Doc de config global dos alertas de consumo (convenção `/platform/<app>`). */
|
|
23
30
|
exports.EVO_BILLING_USAGE_ALERTS_CONFIG_PATH = 'platform/evo-billing/usage-alerts/config';
|
|
@@ -66,7 +66,11 @@ export interface INexFinopsContractServiceItem {
|
|
|
66
66
|
export interface INexFinopsContractAllowance {
|
|
67
67
|
/** Quantidade incluída no ciclo. 0 = nada incluso; ausente = não contratado. */
|
|
68
68
|
included: number;
|
|
69
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated feat-328 (Q4): nunca foi lido por ninguém. O preço do excedente
|
|
71
|
+
* vem da tabela de preço do contrato (`price_table_id` → `INexFinopsPriceTable`).
|
|
72
|
+
* Mantido só para não quebrar docs antigos; não escrever.
|
|
73
|
+
*/
|
|
70
74
|
unit_price_excess?: number | null;
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -87,6 +91,13 @@ export const NexFinopsMetricCatalog = {
|
|
|
87
91
|
// duas vezes.
|
|
88
92
|
teleconsultations_unrecorded: { label: 'Teleconsultas sem gravação', unit: 'consultas' },
|
|
89
93
|
teleconsultations_recorded: { label: 'Teleconsultas com gravação', unit: 'consultas' },
|
|
94
|
+
// feat-328 — DISJUNTAS por pessoa-mês: humano = pessoa com >=1 mensagem de
|
|
95
|
+
// saida humana no mes; IA = o complemento (`attendances = human + ai`). Um
|
|
96
|
+
// contrato usa OU `attendances` (pool unico, legado) OU o par
|
|
97
|
+
// `attendances_human`/`attendances_ai`, NUNCA os tres — cobraria a mesma
|
|
98
|
+
// pessoa duas vezes. Validacao na escrita do contrato (backend, F3).
|
|
99
|
+
attendances_human: { label: 'Atendimentos humanos', unit: 'contatos' },
|
|
100
|
+
attendances_ai: { label: 'Atendimentos por IA', unit: 'contatos' },
|
|
90
101
|
} as const;
|
|
91
102
|
|
|
92
103
|
/**
|
|
@@ -222,6 +233,17 @@ export interface INexFinopsContract extends IFireGlobalDoc {
|
|
|
222
233
|
|
|
223
234
|
/** feat-264 D4 — reembolsar a taxa de NFS-e ao cliente. ⚠️ Ausente/null = TRUE (reembolsa). */
|
|
224
235
|
nfse_fee_reimbursement?: boolean | null;
|
|
236
|
+
|
|
237
|
+
// ── Tabela de preço (feat-328) ──
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Id da `INexFinopsPriceTable` que precifica este contrato.
|
|
241
|
+
* ⚠️ Ausente/null = tabela **padrão** (`is_default`).
|
|
242
|
+
*
|
|
243
|
+
* Q8: todos os contratos vigentes do mesmo cliente devem apontar para a mesma
|
|
244
|
+
* tabela (efetiva) — validado pelo backend ao ativar o contrato.
|
|
245
|
+
*/
|
|
246
|
+
price_table_id?: string | null;
|
|
225
247
|
}
|
|
226
248
|
|
|
227
249
|
// ── Status transitions ──
|
|
@@ -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
|
+
}
|