evo360-types 1.3.782 → 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-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/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/package.json +1 -1
|
@@ -92,14 +92,23 @@ export declare const zMessageCreatedBySchema: z.ZodObject<{
|
|
|
92
92
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
93
93
|
user_id: z.ZodOptional<z.ZodString>;
|
|
94
94
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
95
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
96
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
97
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
95
98
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
96
99
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
97
100
|
user_id: z.ZodOptional<z.ZodString>;
|
|
98
101
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
102
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
103
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
104
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
99
105
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
100
106
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
101
107
|
user_id: z.ZodOptional<z.ZodString>;
|
|
102
108
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
109
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
110
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
111
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
103
112
|
}, z.ZodTypeAny, "passthrough">>;
|
|
104
113
|
export declare const zMessagePricingSchema: z.ZodObject<{
|
|
105
114
|
category: z.ZodOptional<z.ZodEnum<["service", "utility", "authentication", "marketing"]>>;
|
|
@@ -494,14 +503,23 @@ export declare const zThreadMessageSchema: z.ZodObject<{
|
|
|
494
503
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
495
504
|
user_id: z.ZodOptional<z.ZodString>;
|
|
496
505
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
506
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
507
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
508
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
497
509
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
498
510
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
499
511
|
user_id: z.ZodOptional<z.ZodString>;
|
|
500
512
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
513
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
514
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
515
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
501
516
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
502
517
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
503
518
|
user_id: z.ZodOptional<z.ZodString>;
|
|
504
519
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
520
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
521
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
522
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
505
523
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
506
524
|
pricing: z.ZodOptional<z.ZodObject<{
|
|
507
525
|
category: z.ZodOptional<z.ZodEnum<["service", "utility", "authentication", "marketing"]>>;
|
|
@@ -827,14 +845,23 @@ export declare const zThreadMessageSchema: z.ZodObject<{
|
|
|
827
845
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
828
846
|
user_id: z.ZodOptional<z.ZodString>;
|
|
829
847
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
848
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
849
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
850
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
830
851
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
831
852
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
832
853
|
user_id: z.ZodOptional<z.ZodString>;
|
|
833
854
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
855
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
856
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
857
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
834
858
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
835
859
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
836
860
|
user_id: z.ZodOptional<z.ZodString>;
|
|
837
861
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
862
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
863
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
864
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
838
865
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
839
866
|
pricing: z.ZodOptional<z.ZodObject<{
|
|
840
867
|
category: z.ZodOptional<z.ZodEnum<["service", "utility", "authentication", "marketing"]>>;
|
|
@@ -1160,14 +1187,23 @@ export declare const zThreadMessageSchema: z.ZodObject<{
|
|
|
1160
1187
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
1161
1188
|
user_id: z.ZodOptional<z.ZodString>;
|
|
1162
1189
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
1190
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
1191
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
1192
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
1163
1193
|
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
1164
1194
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
1165
1195
|
user_id: z.ZodOptional<z.ZodString>;
|
|
1166
1196
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
1197
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
1198
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
1199
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
1167
1200
|
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
1168
1201
|
type: z.ZodEnum<["human", "automation", "system"]>;
|
|
1169
1202
|
user_id: z.ZodOptional<z.ZodString>;
|
|
1170
1203
|
workflow_id: z.ZodOptional<z.ZodString>;
|
|
1204
|
+
display_name: z.ZodOptional<z.ZodString>;
|
|
1205
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
1206
|
+
source: z.ZodOptional<z.ZodEnum<["coexistence_app"]>>;
|
|
1171
1207
|
}, z.ZodTypeAny, "passthrough">>>;
|
|
1172
1208
|
pricing: z.ZodOptional<z.ZodObject<{
|
|
1173
1209
|
category: z.ZodOptional<z.ZodEnum<["service", "utility", "authentication", "marketing"]>>;
|
|
@@ -30,6 +30,9 @@ exports.zMessageCreatedBySchema = zod_1.z.object({
|
|
|
30
30
|
type: zod_1.z.enum(['human', 'automation', 'system']),
|
|
31
31
|
user_id: zod_1.z.string().optional(),
|
|
32
32
|
workflow_id: zod_1.z.string().optional(),
|
|
33
|
+
display_name: zod_1.z.string().optional(),
|
|
34
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
35
|
+
source: zod_1.z.enum(['coexistence_app']).optional(),
|
|
33
36
|
}).passthrough();
|
|
34
37
|
exports.zMessagePricingSchema = zod_1.z.object({
|
|
35
38
|
category: zod_1.z.enum(['service', 'utility', 'authentication', 'marketing']).optional(),
|
|
@@ -30,6 +30,9 @@ export const zMessageCreatedBySchema = z.object({
|
|
|
30
30
|
type: z.enum(['human', 'automation', 'system']),
|
|
31
31
|
user_id: z.string().optional(),
|
|
32
32
|
workflow_id: z.string().optional(),
|
|
33
|
+
display_name: z.string().optional(),
|
|
34
|
+
/** feat-328 — eco do WhatsApp Business App na coexistência. */
|
|
35
|
+
source: z.enum(['coexistence_app']).optional(),
|
|
33
36
|
}).passthrough();
|
|
34
37
|
|
|
35
38
|
export const zMessagePricingSchema = z.object({
|
|
@@ -16015,9 +16015,9 @@ export declare const zNexFinopsContractAsaasInfoSchema: z.ZodObject<{
|
|
|
16015
16015
|
}, "strip", z.ZodTypeAny, {
|
|
16016
16016
|
value?: number | null | undefined;
|
|
16017
16017
|
customer_id?: string | null | undefined;
|
|
16018
|
+
cycle?: string | null | undefined;
|
|
16018
16019
|
subscription_id?: string | null | undefined;
|
|
16019
16020
|
subscription_status?: "ACTIVE" | "EXPIRED" | "INACTIVE" | null | undefined;
|
|
16020
|
-
cycle?: string | null | undefined;
|
|
16021
16021
|
next_due_date?: string | null | undefined;
|
|
16022
16022
|
card_last4?: string | null | undefined;
|
|
16023
16023
|
card_brand?: string | null | undefined;
|
|
@@ -16026,9 +16026,9 @@ export declare const zNexFinopsContractAsaasInfoSchema: z.ZodObject<{
|
|
|
16026
16026
|
}, {
|
|
16027
16027
|
value?: number | null | undefined;
|
|
16028
16028
|
customer_id?: string | null | undefined;
|
|
16029
|
+
cycle?: string | null | undefined;
|
|
16029
16030
|
subscription_id?: string | null | undefined;
|
|
16030
16031
|
subscription_status?: "ACTIVE" | "EXPIRED" | "INACTIVE" | null | undefined;
|
|
16031
|
-
cycle?: string | null | undefined;
|
|
16032
16032
|
next_due_date?: string | null | undefined;
|
|
16033
16033
|
card_last4?: string | null | undefined;
|
|
16034
16034
|
card_brand?: string | null | undefined;
|
|
@@ -16349,6 +16349,8 @@ export declare const zNexFinopsContractAllowancesWriteSchema: z.ZodObject<{
|
|
|
16349
16349
|
alert_thresholds: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodNumber, "many">>>;
|
|
16350
16350
|
/** feat-264 D4 — ausente/null = TRUE (reembolsa). */
|
|
16351
16351
|
nfse_fee_reimbursement: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
|
|
16352
|
+
/** feat-328 — tabela de preço do contrato. Ausente/null = tabela padrão. */
|
|
16353
|
+
price_table_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
16352
16354
|
}, "strip", z.ZodTypeAny, {
|
|
16353
16355
|
allowances?: Record<string, {
|
|
16354
16356
|
included: number;
|
|
@@ -16357,6 +16359,7 @@ export declare const zNexFinopsContractAllowancesWriteSchema: z.ZodObject<{
|
|
|
16357
16359
|
alerts_enabled?: boolean | null | undefined;
|
|
16358
16360
|
alert_thresholds?: number[] | null | undefined;
|
|
16359
16361
|
nfse_fee_reimbursement?: boolean | null | undefined;
|
|
16362
|
+
price_table_id?: string | null | undefined;
|
|
16360
16363
|
}, {
|
|
16361
16364
|
allowances?: Record<string, {
|
|
16362
16365
|
included: number;
|
|
@@ -16365,6 +16368,330 @@ export declare const zNexFinopsContractAllowancesWriteSchema: z.ZodObject<{
|
|
|
16365
16368
|
alerts_enabled?: boolean | null | undefined;
|
|
16366
16369
|
alert_thresholds?: number[] | null | undefined;
|
|
16367
16370
|
nfse_fee_reimbursement?: boolean | null | undefined;
|
|
16371
|
+
price_table_id?: string | null | undefined;
|
|
16372
|
+
}>;
|
|
16373
|
+
export declare const zNexFinopsPriceCapTierSchema: z.ZodObject<{
|
|
16374
|
+
up_to: z.ZodNumber;
|
|
16375
|
+
total: z.ZodNumber;
|
|
16376
|
+
}, "strip", z.ZodTypeAny, {
|
|
16377
|
+
total: number;
|
|
16378
|
+
up_to: number;
|
|
16379
|
+
}, {
|
|
16380
|
+
total: number;
|
|
16381
|
+
up_to: number;
|
|
16382
|
+
}>;
|
|
16383
|
+
export declare const zNexFinopsPriceCapSchema: z.ZodObject<{
|
|
16384
|
+
mode: z.ZodLiteral<"tiered_total">;
|
|
16385
|
+
tiers: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
16386
|
+
up_to: z.ZodNumber;
|
|
16387
|
+
total: z.ZodNumber;
|
|
16388
|
+
}, "strip", z.ZodTypeAny, {
|
|
16389
|
+
total: number;
|
|
16390
|
+
up_to: number;
|
|
16391
|
+
}, {
|
|
16392
|
+
total: number;
|
|
16393
|
+
up_to: number;
|
|
16394
|
+
}>, "many">, {
|
|
16395
|
+
total: number;
|
|
16396
|
+
up_to: number;
|
|
16397
|
+
}[], {
|
|
16398
|
+
total: number;
|
|
16399
|
+
up_to: number;
|
|
16400
|
+
}[]>;
|
|
16401
|
+
}, "strip", z.ZodTypeAny, {
|
|
16402
|
+
mode: "tiered_total";
|
|
16403
|
+
tiers: {
|
|
16404
|
+
total: number;
|
|
16405
|
+
up_to: number;
|
|
16406
|
+
}[];
|
|
16407
|
+
}, {
|
|
16408
|
+
mode: "tiered_total";
|
|
16409
|
+
tiers: {
|
|
16410
|
+
total: number;
|
|
16411
|
+
up_to: number;
|
|
16412
|
+
}[];
|
|
16413
|
+
}>;
|
|
16414
|
+
export declare const zNexFinopsPriceLineSchema: z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
16415
|
+
kind: z.ZodLiteral<"usage">;
|
|
16416
|
+
unit_price: z.ZodNumber;
|
|
16417
|
+
service_category: z.ZodString;
|
|
16418
|
+
cap: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
16419
|
+
mode: z.ZodLiteral<"tiered_total">;
|
|
16420
|
+
tiers: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
16421
|
+
up_to: z.ZodNumber;
|
|
16422
|
+
total: z.ZodNumber;
|
|
16423
|
+
}, "strip", z.ZodTypeAny, {
|
|
16424
|
+
total: number;
|
|
16425
|
+
up_to: number;
|
|
16426
|
+
}, {
|
|
16427
|
+
total: number;
|
|
16428
|
+
up_to: number;
|
|
16429
|
+
}>, "many">, {
|
|
16430
|
+
total: number;
|
|
16431
|
+
up_to: number;
|
|
16432
|
+
}[], {
|
|
16433
|
+
total: number;
|
|
16434
|
+
up_to: number;
|
|
16435
|
+
}[]>;
|
|
16436
|
+
}, "strip", z.ZodTypeAny, {
|
|
16437
|
+
mode: "tiered_total";
|
|
16438
|
+
tiers: {
|
|
16439
|
+
total: number;
|
|
16440
|
+
up_to: number;
|
|
16441
|
+
}[];
|
|
16442
|
+
}, {
|
|
16443
|
+
mode: "tiered_total";
|
|
16444
|
+
tiers: {
|
|
16445
|
+
total: number;
|
|
16446
|
+
up_to: number;
|
|
16447
|
+
}[];
|
|
16448
|
+
}>>>;
|
|
16449
|
+
}, "strip", z.ZodTypeAny, {
|
|
16450
|
+
kind: "usage";
|
|
16451
|
+
unit_price: number;
|
|
16452
|
+
service_category: string;
|
|
16453
|
+
cap?: {
|
|
16454
|
+
mode: "tiered_total";
|
|
16455
|
+
tiers: {
|
|
16456
|
+
total: number;
|
|
16457
|
+
up_to: number;
|
|
16458
|
+
}[];
|
|
16459
|
+
} | null | undefined;
|
|
16460
|
+
}, {
|
|
16461
|
+
kind: "usage";
|
|
16462
|
+
unit_price: number;
|
|
16463
|
+
service_category: string;
|
|
16464
|
+
cap?: {
|
|
16465
|
+
mode: "tiered_total";
|
|
16466
|
+
tiers: {
|
|
16467
|
+
total: number;
|
|
16468
|
+
up_to: number;
|
|
16469
|
+
}[];
|
|
16470
|
+
} | null | undefined;
|
|
16471
|
+
}>, z.ZodObject<{
|
|
16472
|
+
kind: z.ZodLiteral<"recurring">;
|
|
16473
|
+
amount: z.ZodNumber;
|
|
16474
|
+
service_category: z.ZodString;
|
|
16475
|
+
}, "strip", z.ZodTypeAny, {
|
|
16476
|
+
kind: "recurring";
|
|
16477
|
+
amount: number;
|
|
16478
|
+
service_category: string;
|
|
16479
|
+
}, {
|
|
16480
|
+
kind: "recurring";
|
|
16481
|
+
amount: number;
|
|
16482
|
+
service_category: string;
|
|
16483
|
+
}>, z.ZodObject<{
|
|
16484
|
+
kind: z.ZodLiteral<"disabled">;
|
|
16485
|
+
}, "strip", z.ZodTypeAny, {
|
|
16486
|
+
kind: "disabled";
|
|
16487
|
+
}, {
|
|
16488
|
+
kind: "disabled";
|
|
16489
|
+
}>]>;
|
|
16490
|
+
/** Chave = métrica (usage) ou módulo (recurring); mesmo limite das chaves de `allowances`. */
|
|
16491
|
+
export declare const zNexFinopsPriceLinesSchema: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
16492
|
+
kind: z.ZodLiteral<"usage">;
|
|
16493
|
+
unit_price: z.ZodNumber;
|
|
16494
|
+
service_category: z.ZodString;
|
|
16495
|
+
cap: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
16496
|
+
mode: z.ZodLiteral<"tiered_total">;
|
|
16497
|
+
tiers: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
16498
|
+
up_to: z.ZodNumber;
|
|
16499
|
+
total: z.ZodNumber;
|
|
16500
|
+
}, "strip", z.ZodTypeAny, {
|
|
16501
|
+
total: number;
|
|
16502
|
+
up_to: number;
|
|
16503
|
+
}, {
|
|
16504
|
+
total: number;
|
|
16505
|
+
up_to: number;
|
|
16506
|
+
}>, "many">, {
|
|
16507
|
+
total: number;
|
|
16508
|
+
up_to: number;
|
|
16509
|
+
}[], {
|
|
16510
|
+
total: number;
|
|
16511
|
+
up_to: number;
|
|
16512
|
+
}[]>;
|
|
16513
|
+
}, "strip", z.ZodTypeAny, {
|
|
16514
|
+
mode: "tiered_total";
|
|
16515
|
+
tiers: {
|
|
16516
|
+
total: number;
|
|
16517
|
+
up_to: number;
|
|
16518
|
+
}[];
|
|
16519
|
+
}, {
|
|
16520
|
+
mode: "tiered_total";
|
|
16521
|
+
tiers: {
|
|
16522
|
+
total: number;
|
|
16523
|
+
up_to: number;
|
|
16524
|
+
}[];
|
|
16525
|
+
}>>>;
|
|
16526
|
+
}, "strip", z.ZodTypeAny, {
|
|
16527
|
+
kind: "usage";
|
|
16528
|
+
unit_price: number;
|
|
16529
|
+
service_category: string;
|
|
16530
|
+
cap?: {
|
|
16531
|
+
mode: "tiered_total";
|
|
16532
|
+
tiers: {
|
|
16533
|
+
total: number;
|
|
16534
|
+
up_to: number;
|
|
16535
|
+
}[];
|
|
16536
|
+
} | null | undefined;
|
|
16537
|
+
}, {
|
|
16538
|
+
kind: "usage";
|
|
16539
|
+
unit_price: number;
|
|
16540
|
+
service_category: string;
|
|
16541
|
+
cap?: {
|
|
16542
|
+
mode: "tiered_total";
|
|
16543
|
+
tiers: {
|
|
16544
|
+
total: number;
|
|
16545
|
+
up_to: number;
|
|
16546
|
+
}[];
|
|
16547
|
+
} | null | undefined;
|
|
16548
|
+
}>, z.ZodObject<{
|
|
16549
|
+
kind: z.ZodLiteral<"recurring">;
|
|
16550
|
+
amount: z.ZodNumber;
|
|
16551
|
+
service_category: z.ZodString;
|
|
16552
|
+
}, "strip", z.ZodTypeAny, {
|
|
16553
|
+
kind: "recurring";
|
|
16554
|
+
amount: number;
|
|
16555
|
+
service_category: string;
|
|
16556
|
+
}, {
|
|
16557
|
+
kind: "recurring";
|
|
16558
|
+
amount: number;
|
|
16559
|
+
service_category: string;
|
|
16560
|
+
}>, z.ZodObject<{
|
|
16561
|
+
kind: z.ZodLiteral<"disabled">;
|
|
16562
|
+
}, "strip", z.ZodTypeAny, {
|
|
16563
|
+
kind: "disabled";
|
|
16564
|
+
}, {
|
|
16565
|
+
kind: "disabled";
|
|
16566
|
+
}>]>>;
|
|
16567
|
+
/** Create/update de tabela de preço. `lines` substitui o mapa inteiro (como `allowances`). */
|
|
16568
|
+
export declare const zNexFinopsPriceTableWriteSchema: z.ZodObject<{
|
|
16569
|
+
name: z.ZodString;
|
|
16570
|
+
is_default: z.ZodBoolean;
|
|
16571
|
+
inherits_from: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
16572
|
+
lines: z.ZodRecord<z.ZodString, z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
|
|
16573
|
+
kind: z.ZodLiteral<"usage">;
|
|
16574
|
+
unit_price: z.ZodNumber;
|
|
16575
|
+
service_category: z.ZodString;
|
|
16576
|
+
cap: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
16577
|
+
mode: z.ZodLiteral<"tiered_total">;
|
|
16578
|
+
tiers: z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
16579
|
+
up_to: z.ZodNumber;
|
|
16580
|
+
total: z.ZodNumber;
|
|
16581
|
+
}, "strip", z.ZodTypeAny, {
|
|
16582
|
+
total: number;
|
|
16583
|
+
up_to: number;
|
|
16584
|
+
}, {
|
|
16585
|
+
total: number;
|
|
16586
|
+
up_to: number;
|
|
16587
|
+
}>, "many">, {
|
|
16588
|
+
total: number;
|
|
16589
|
+
up_to: number;
|
|
16590
|
+
}[], {
|
|
16591
|
+
total: number;
|
|
16592
|
+
up_to: number;
|
|
16593
|
+
}[]>;
|
|
16594
|
+
}, "strip", z.ZodTypeAny, {
|
|
16595
|
+
mode: "tiered_total";
|
|
16596
|
+
tiers: {
|
|
16597
|
+
total: number;
|
|
16598
|
+
up_to: number;
|
|
16599
|
+
}[];
|
|
16600
|
+
}, {
|
|
16601
|
+
mode: "tiered_total";
|
|
16602
|
+
tiers: {
|
|
16603
|
+
total: number;
|
|
16604
|
+
up_to: number;
|
|
16605
|
+
}[];
|
|
16606
|
+
}>>>;
|
|
16607
|
+
}, "strip", z.ZodTypeAny, {
|
|
16608
|
+
kind: "usage";
|
|
16609
|
+
unit_price: number;
|
|
16610
|
+
service_category: string;
|
|
16611
|
+
cap?: {
|
|
16612
|
+
mode: "tiered_total";
|
|
16613
|
+
tiers: {
|
|
16614
|
+
total: number;
|
|
16615
|
+
up_to: number;
|
|
16616
|
+
}[];
|
|
16617
|
+
} | null | undefined;
|
|
16618
|
+
}, {
|
|
16619
|
+
kind: "usage";
|
|
16620
|
+
unit_price: number;
|
|
16621
|
+
service_category: string;
|
|
16622
|
+
cap?: {
|
|
16623
|
+
mode: "tiered_total";
|
|
16624
|
+
tiers: {
|
|
16625
|
+
total: number;
|
|
16626
|
+
up_to: number;
|
|
16627
|
+
}[];
|
|
16628
|
+
} | null | undefined;
|
|
16629
|
+
}>, z.ZodObject<{
|
|
16630
|
+
kind: z.ZodLiteral<"recurring">;
|
|
16631
|
+
amount: z.ZodNumber;
|
|
16632
|
+
service_category: z.ZodString;
|
|
16633
|
+
}, "strip", z.ZodTypeAny, {
|
|
16634
|
+
kind: "recurring";
|
|
16635
|
+
amount: number;
|
|
16636
|
+
service_category: string;
|
|
16637
|
+
}, {
|
|
16638
|
+
kind: "recurring";
|
|
16639
|
+
amount: number;
|
|
16640
|
+
service_category: string;
|
|
16641
|
+
}>, z.ZodObject<{
|
|
16642
|
+
kind: z.ZodLiteral<"disabled">;
|
|
16643
|
+
}, "strip", z.ZodTypeAny, {
|
|
16644
|
+
kind: "disabled";
|
|
16645
|
+
}, {
|
|
16646
|
+
kind: "disabled";
|
|
16647
|
+
}>]>>;
|
|
16648
|
+
notes: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
16649
|
+
}, "strip", z.ZodTypeAny, {
|
|
16650
|
+
name: string;
|
|
16651
|
+
is_default: boolean;
|
|
16652
|
+
lines: Record<string, {
|
|
16653
|
+
kind: "usage";
|
|
16654
|
+
unit_price: number;
|
|
16655
|
+
service_category: string;
|
|
16656
|
+
cap?: {
|
|
16657
|
+
mode: "tiered_total";
|
|
16658
|
+
tiers: {
|
|
16659
|
+
total: number;
|
|
16660
|
+
up_to: number;
|
|
16661
|
+
}[];
|
|
16662
|
+
} | null | undefined;
|
|
16663
|
+
} | {
|
|
16664
|
+
kind: "recurring";
|
|
16665
|
+
amount: number;
|
|
16666
|
+
service_category: string;
|
|
16667
|
+
} | {
|
|
16668
|
+
kind: "disabled";
|
|
16669
|
+
}>;
|
|
16670
|
+
notes?: string | null | undefined;
|
|
16671
|
+
inherits_from?: string | null | undefined;
|
|
16672
|
+
}, {
|
|
16673
|
+
name: string;
|
|
16674
|
+
is_default: boolean;
|
|
16675
|
+
lines: Record<string, {
|
|
16676
|
+
kind: "usage";
|
|
16677
|
+
unit_price: number;
|
|
16678
|
+
service_category: string;
|
|
16679
|
+
cap?: {
|
|
16680
|
+
mode: "tiered_total";
|
|
16681
|
+
tiers: {
|
|
16682
|
+
total: number;
|
|
16683
|
+
up_to: number;
|
|
16684
|
+
}[];
|
|
16685
|
+
} | null | undefined;
|
|
16686
|
+
} | {
|
|
16687
|
+
kind: "recurring";
|
|
16688
|
+
amount: number;
|
|
16689
|
+
service_category: string;
|
|
16690
|
+
} | {
|
|
16691
|
+
kind: "disabled";
|
|
16692
|
+
}>;
|
|
16693
|
+
notes?: string | null | undefined;
|
|
16694
|
+
inherits_from?: string | null | undefined;
|
|
16368
16695
|
}>;
|
|
16369
16696
|
export declare const zNexFinopsPaymentMethodKindSchema: z.ZodEnum<["asaas_subscription", "asaas_card_token"]>;
|
|
16370
16697
|
export declare const zNexFinopsPaymentMethodStatusSchema: z.ZodEnum<["active", "failing", "inactive", "revoked"]>;
|
|
@@ -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
|
|
|
@@ -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
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -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
|
/**
|