evo360-types 1.3.637 → 1.3.644

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/dist/apps/evo-csq/zod-schemas.d.ts +237 -4
  2. package/dist/apps/evo-csq/zod-schemas.js +18 -2
  3. package/dist/apps/evo-csq/zod-schemas.ts +18 -0
  4. package/dist/apps/evo-finops/zod-schemas.d.ts +444 -0
  5. package/dist/apps/evo-finops/zod-schemas.js +61 -2
  6. package/dist/apps/evo-finops/zod-schemas.ts +67 -0
  7. package/dist/apps/evo-hub-ia/v1/zod-schemas.d.ts +48 -0
  8. package/dist/apps/evo-hub-ia/v1/zod-schemas.js +12 -0
  9. package/dist/apps/evo-hub-ia/v1/zod-schemas.ts +12 -0
  10. package/dist/types/evo-csq/index.d.ts +36 -6
  11. package/dist/types/evo-csq/index.js +8 -1
  12. package/dist/types/evo-csq/index.ts +39 -5
  13. package/dist/types/evo-finops/common/billing.d.ts +58 -2
  14. package/dist/types/evo-finops/common/billing.ts +72 -2
  15. package/dist/types/evo-finops/common/contract.d.ts +8 -0
  16. package/dist/types/evo-finops/common/contract.ts +11 -0
  17. package/dist/types/evo-finops/common/payment-method.d.ts +77 -0
  18. package/dist/types/evo-finops/common/payment-method.js +10 -0
  19. package/dist/types/evo-finops/common/payment-method.ts +106 -0
  20. package/dist/types/evo-finops/fb_collections.d.ts +2 -0
  21. package/dist/types/evo-finops/fb_collections.js +3 -1
  22. package/dist/types/evo-finops/fb_collections.ts +2 -0
  23. package/dist/types/evo-finops/index.d.ts +1 -0
  24. package/dist/types/evo-finops/index.js +1 -0
  25. package/dist/types/evo-finops/index.ts +1 -0
  26. package/dist/types/evo-finops/providers/asaas/asaas_provider.d.ts +9 -0
  27. package/dist/types/evo-finops/providers/asaas/asaas_provider.ts +10 -0
  28. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zProviderInvoiceLinksSchema = 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.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.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.zPaymentLinkSchema = exports.zPaymentLinkDocumentStateSchema = exports.zAsaasPaymentLinkSubscriptionCycleSchema = exports.zAsaasPaymentLinkChargeTypeSchema = exports.zAsaasPaymentLinkBillingTypeSchema = exports.zProviderPayloadSnapshotSchema = exports.zProviderTraceSchema = exports.zProviderInvoiceErrorSchema = exports.zProviderInvoiceIdentifiersSchema = void 0;
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.zNexFinopsPaymentMethodsDiscoverSchema = exports.zNexFinopsBillingCardChargeSchema = exports.zNexFinopsContractPaymentMethodsWriteSchema = exports.zNexFinopsPaymentMethodPatchSchema = exports.zNexFinopsPaymentMethodStatusSchema = exports.zNexFinopsPaymentMethodKindSchema = 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.zPaymentLinkSchema = exports.zPaymentLinkDocumentStateSchema = exports.zAsaasPaymentLinkSubscriptionCycleSchema = exports.zAsaasPaymentLinkChargeTypeSchema = exports.zAsaasPaymentLinkBillingTypeSchema = exports.zProviderPayloadSnapshotSchema = exports.zProviderTraceSchema = exports.zProviderInvoiceErrorSchema = exports.zProviderInvoiceIdentifiersSchema = exports.zProviderInvoiceLinksSchema = void 0;
5
5
  const zod_1 = require("zod");
6
6
  const zod_schemas_1 = require("../shared/zod-schemas");
7
7
  // ---- Provider enums and base ----
@@ -233,8 +233,18 @@ exports.zAsaasNfseCapabilitiesSchema = zod_1.z.object({
233
233
  allow_avulsa: zod_1.z.boolean(),
234
234
  allow_linked_to_payment: zod_1.z.boolean(),
235
235
  });
236
+ exports.zAsaasEnvFlagSchema = zod_1.z
237
+ .object({
238
+ sandbox: zod_1.z.boolean().optional(),
239
+ production: zod_1.z.boolean().optional(),
240
+ })
241
+ .strip();
236
242
  exports.zAsaasPaymentsCapabilitiesSchema = zod_1.z.object({
237
243
  enabled: zod_1.z.boolean(),
244
+ /** feat-253 — kill-switch do caminho A. */
245
+ card_subscription_adjust: exports.zAsaasEnvFlagSchema.optional(),
246
+ /** feat-253 — flag do caminho B (token). */
247
+ card_token: exports.zAsaasEnvFlagSchema.optional(),
238
248
  });
239
249
  exports.zAsaasProviderCapabilitiesSchema = zod_1.z.object({
240
250
  nfse: exports.zAsaasNfseCapabilitiesSchema,
@@ -913,3 +923,52 @@ exports.zNexFinopsContractAllowancesWriteSchema = zod_1.z
913
923
  alert_thresholds: zod_1.z.array(exports.zNexFinopsAlertThresholdSchema).optional().nullable(),
914
924
  })
915
925
  .strip();
926
+ // ---- Nexus FinOps — métodos de pagamento do cliente (feat-253) ----
927
+ //
928
+ // PCI: todos `.strip()`. Nenhum schema aceita número de cartão, CCV, dados do
929
+ // portador ou token — chave desconhecida é descartada antes de chegar ao use case.
930
+ exports.zNexFinopsPaymentMethodKindSchema = zod_1.z.enum([
931
+ "asaas_subscription",
932
+ "asaas_card_token",
933
+ ]);
934
+ exports.zNexFinopsPaymentMethodStatusSchema = zod_1.z.enum([
935
+ "active",
936
+ "failing",
937
+ "inactive",
938
+ "revoked",
939
+ ]);
940
+ /** `PATCH /payment-methods/:id` — o operador só renomeia ou liga/desliga. */
941
+ exports.zNexFinopsPaymentMethodPatchSchema = zod_1.z
942
+ .object({
943
+ label: zod_1.z.string().max(120).optional().nullable(),
944
+ status: zod_1.z.enum(["active", "inactive"]).optional(),
945
+ })
946
+ .strip();
947
+ /** `PUT /contracts/:id/payment-methods` — rota dedicada (o PUT genérico ignora estes campos). */
948
+ exports.zNexFinopsContractPaymentMethodsWriteSchema = zod_1.z
949
+ .object({
950
+ payment_method_ids: zod_1.z.array(zod_1.z.string().min(1).max(128)).max(10),
951
+ default_payment_method_id: zod_1.z.string().min(1).max(128).optional().nullable(),
952
+ })
953
+ .strip();
954
+ /** `POST /billings/:id/card-charge` (F2/F3). */
955
+ exports.zNexFinopsBillingCardChargeSchema = zod_1.z
956
+ .object({
957
+ action: zod_1.z.enum(["preview", "adjust", "revert", "charge_now"]),
958
+ expected_value: zod_1.z.number(),
959
+ asaas_payment_id: zod_1.z.string().min(1).max(128).optional(),
960
+ confirm: zod_1.z.boolean().optional(),
961
+ })
962
+ .strip();
963
+ /** `POST /payment-methods/discover` — sem `confirm` é dry-run. */
964
+ exports.zNexFinopsPaymentMethodsDiscoverSchema = zod_1.z
965
+ .object({
966
+ customer_id: zod_1.z.string().min(1).max(128).optional(),
967
+ confirm: zod_1.z
968
+ .object({
969
+ payment_method_ids: zod_1.z.array(zod_1.z.string().min(1).max(128)).max(500),
970
+ })
971
+ .strip()
972
+ .optional(),
973
+ })
974
+ .strip();
@@ -247,8 +247,19 @@ export const zAsaasNfseCapabilitiesSchema = z.object({
247
247
  allow_linked_to_payment: z.boolean(),
248
248
  });
249
249
 
250
+ export const zAsaasEnvFlagSchema = z
251
+ .object({
252
+ sandbox: z.boolean().optional(),
253
+ production: z.boolean().optional(),
254
+ })
255
+ .strip();
256
+
250
257
  export const zAsaasPaymentsCapabilitiesSchema = z.object({
251
258
  enabled: z.boolean(),
259
+ /** feat-253 — kill-switch do caminho A. */
260
+ card_subscription_adjust: zAsaasEnvFlagSchema.optional(),
261
+ /** feat-253 — flag do caminho B (token). */
262
+ card_token: zAsaasEnvFlagSchema.optional(),
252
263
  });
253
264
 
254
265
  export const zAsaasProviderCapabilitiesSchema = z.object({
@@ -1001,3 +1012,59 @@ export const zNexFinopsContractAllowancesWriteSchema = z
1001
1012
  alert_thresholds: z.array(zNexFinopsAlertThresholdSchema).optional().nullable(),
1002
1013
  })
1003
1014
  .strip();
1015
+
1016
+ // ---- Nexus FinOps — métodos de pagamento do cliente (feat-253) ----
1017
+ //
1018
+ // PCI: todos `.strip()`. Nenhum schema aceita número de cartão, CCV, dados do
1019
+ // portador ou token — chave desconhecida é descartada antes de chegar ao use case.
1020
+
1021
+ export const zNexFinopsPaymentMethodKindSchema = z.enum([
1022
+ "asaas_subscription",
1023
+ "asaas_card_token",
1024
+ ]);
1025
+
1026
+ export const zNexFinopsPaymentMethodStatusSchema = z.enum([
1027
+ "active",
1028
+ "failing",
1029
+ "inactive",
1030
+ "revoked",
1031
+ ]);
1032
+
1033
+ /** `PATCH /payment-methods/:id` — o operador só renomeia ou liga/desliga. */
1034
+ export const zNexFinopsPaymentMethodPatchSchema = z
1035
+ .object({
1036
+ label: z.string().max(120).optional().nullable(),
1037
+ status: z.enum(["active", "inactive"]).optional(),
1038
+ })
1039
+ .strip();
1040
+
1041
+ /** `PUT /contracts/:id/payment-methods` — rota dedicada (o PUT genérico ignora estes campos). */
1042
+ export const zNexFinopsContractPaymentMethodsWriteSchema = z
1043
+ .object({
1044
+ payment_method_ids: z.array(z.string().min(1).max(128)).max(10),
1045
+ default_payment_method_id: z.string().min(1).max(128).optional().nullable(),
1046
+ })
1047
+ .strip();
1048
+
1049
+ /** `POST /billings/:id/card-charge` (F2/F3). */
1050
+ export const zNexFinopsBillingCardChargeSchema = z
1051
+ .object({
1052
+ action: z.enum(["preview", "adjust", "revert", "charge_now"]),
1053
+ expected_value: z.number(),
1054
+ asaas_payment_id: z.string().min(1).max(128).optional(),
1055
+ confirm: z.boolean().optional(),
1056
+ })
1057
+ .strip();
1058
+
1059
+ /** `POST /payment-methods/discover` — sem `confirm` é dry-run. */
1060
+ export const zNexFinopsPaymentMethodsDiscoverSchema = z
1061
+ .object({
1062
+ customer_id: z.string().min(1).max(128).optional(),
1063
+ confirm: z
1064
+ .object({
1065
+ payment_method_ids: z.array(z.string().min(1).max(128)).max(500),
1066
+ })
1067
+ .strip()
1068
+ .optional(),
1069
+ })
1070
+ .strip();
@@ -2341,6 +2341,22 @@ export declare const zAiBindingSchema: z.ZodObject<{
2341
2341
  /** CSQ 2.0 — off (default) | shadow (avalia, não notifica) | active.
2342
2342
  * Ausente equivale a `off`: o gate do pipeline só segue com `shadow`/`active`. */
2343
2343
  csq_mode: z.ZodOptional<z.ZodEnum<["off", "shadow", "active"]>>;
2344
+ /** feat-226: conexão do juiz do CSQ (`/platform/evo-csq/llm-connections/{id}`).
2345
+ * `null`/ausente = default da plataforma. Independente do `llm_connection_id`
2346
+ * da HubIA: o juiz e o atendimento escolhem modelo por motivos diferentes. */
2347
+ csq_judge_connection_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
2348
+ /** feat-226: tokens do juiz contam no consumo do tenant. Só vale com
2349
+ * `csq_mode: 'active'`; em `shadow` nunca cobra. Ausente = `false`. */
2350
+ csq_billable: z.ZodOptional<z.ZodBoolean>;
2351
+ /** feat-226: texto só do juiz, fora de `prompt_overrides` para a HubIA nunca
2352
+ * o ler. Entra no prompt do juiz depois do roteiro, com a mesma precedência. */
2353
+ csq_prompts: z.ZodOptional<z.ZodObject<{
2354
+ policy_addendum: z.ZodOptional<z.ZodString>;
2355
+ }, "strip", z.ZodTypeAny, {
2356
+ policy_addendum?: string | undefined;
2357
+ }, {
2358
+ policy_addendum?: string | undefined;
2359
+ }>>;
2344
2360
  /** Conexão do catálogo da plataforma (`/platform/evo-ai/llm-connections/{id}`,
2345
2361
  * com `hubia` em `usable_for`) usada neste departamento. Vence o
2346
2362
  * `llm_connection_id` do canal. `null`/ausente = herda do canal. */
@@ -3091,6 +3107,22 @@ export declare const zAiBindingSchema: z.ZodObject<{
3091
3107
  /** CSQ 2.0 — off (default) | shadow (avalia, não notifica) | active.
3092
3108
  * Ausente equivale a `off`: o gate do pipeline só segue com `shadow`/`active`. */
3093
3109
  csq_mode: z.ZodOptional<z.ZodEnum<["off", "shadow", "active"]>>;
3110
+ /** feat-226: conexão do juiz do CSQ (`/platform/evo-csq/llm-connections/{id}`).
3111
+ * `null`/ausente = default da plataforma. Independente do `llm_connection_id`
3112
+ * da HubIA: o juiz e o atendimento escolhem modelo por motivos diferentes. */
3113
+ csq_judge_connection_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3114
+ /** feat-226: tokens do juiz contam no consumo do tenant. Só vale com
3115
+ * `csq_mode: 'active'`; em `shadow` nunca cobra. Ausente = `false`. */
3116
+ csq_billable: z.ZodOptional<z.ZodBoolean>;
3117
+ /** feat-226: texto só do juiz, fora de `prompt_overrides` para a HubIA nunca
3118
+ * o ler. Entra no prompt do juiz depois do roteiro, com a mesma precedência. */
3119
+ csq_prompts: z.ZodOptional<z.ZodObject<{
3120
+ policy_addendum: z.ZodOptional<z.ZodString>;
3121
+ }, "strip", z.ZodTypeAny, {
3122
+ policy_addendum?: string | undefined;
3123
+ }, {
3124
+ policy_addendum?: string | undefined;
3125
+ }>>;
3094
3126
  /** Conexão do catálogo da plataforma (`/platform/evo-ai/llm-connections/{id}`,
3095
3127
  * com `hubia` em `usable_for`) usada neste departamento. Vence o
3096
3128
  * `llm_connection_id` do canal. `null`/ausente = herda do canal. */
@@ -3841,6 +3873,22 @@ export declare const zAiBindingSchema: z.ZodObject<{
3841
3873
  /** CSQ 2.0 — off (default) | shadow (avalia, não notifica) | active.
3842
3874
  * Ausente equivale a `off`: o gate do pipeline só segue com `shadow`/`active`. */
3843
3875
  csq_mode: z.ZodOptional<z.ZodEnum<["off", "shadow", "active"]>>;
3876
+ /** feat-226: conexão do juiz do CSQ (`/platform/evo-csq/llm-connections/{id}`).
3877
+ * `null`/ausente = default da plataforma. Independente do `llm_connection_id`
3878
+ * da HubIA: o juiz e o atendimento escolhem modelo por motivos diferentes. */
3879
+ csq_judge_connection_id: z.ZodOptional<z.ZodNullable<z.ZodString>>;
3880
+ /** feat-226: tokens do juiz contam no consumo do tenant. Só vale com
3881
+ * `csq_mode: 'active'`; em `shadow` nunca cobra. Ausente = `false`. */
3882
+ csq_billable: z.ZodOptional<z.ZodBoolean>;
3883
+ /** feat-226: texto só do juiz, fora de `prompt_overrides` para a HubIA nunca
3884
+ * o ler. Entra no prompt do juiz depois do roteiro, com a mesma precedência. */
3885
+ csq_prompts: z.ZodOptional<z.ZodObject<{
3886
+ policy_addendum: z.ZodOptional<z.ZodString>;
3887
+ }, "strip", z.ZodTypeAny, {
3888
+ policy_addendum?: string | undefined;
3889
+ }, {
3890
+ policy_addendum?: string | undefined;
3891
+ }>>;
3844
3892
  /** Conexão do catálogo da plataforma (`/platform/evo-ai/llm-connections/{id}`,
3845
3893
  * com `hubia` em `usable_for`) usada neste departamento. Vence o
3846
3894
  * `llm_connection_id` do canal. `null`/ausente = herda do canal. */
@@ -371,6 +371,18 @@ exports.zAiBindingSchema = zod_schemas_1.zFireDocSchema.extend({
371
371
  /** CSQ 2.0 — off (default) | shadow (avalia, não notifica) | active.
372
372
  * Ausente equivale a `off`: o gate do pipeline só segue com `shadow`/`active`. */
373
373
  csq_mode: zod_schemas_2.zCsqModeSchema.optional(),
374
+ /** feat-226: conexão do juiz do CSQ (`/platform/evo-csq/llm-connections/{id}`).
375
+ * `null`/ausente = default da plataforma. Independente do `llm_connection_id`
376
+ * da HubIA: o juiz e o atendimento escolhem modelo por motivos diferentes. */
377
+ csq_judge_connection_id: zod_1.z.string().nullable().optional(),
378
+ /** feat-226: tokens do juiz contam no consumo do tenant. Só vale com
379
+ * `csq_mode: 'active'`; em `shadow` nunca cobra. Ausente = `false`. */
380
+ csq_billable: zod_1.z.boolean().optional(),
381
+ /** feat-226: texto só do juiz, fora de `prompt_overrides` para a HubIA nunca
382
+ * o ler. Entra no prompt do juiz depois do roteiro, com a mesma precedência. */
383
+ csq_prompts: zod_1.z.object({
384
+ policy_addendum: zod_1.z.string().max(4000).optional(),
385
+ }).optional(),
374
386
  // ───── LLM (feat-210) ─────
375
387
  /** Conexão do catálogo da plataforma (`/platform/evo-ai/llm-connections/{id}`,
376
388
  * com `hubia` em `usable_for`) usada neste departamento. Vence o
@@ -417,6 +417,18 @@ export const zAiBindingSchema = zFireDocSchema.extend({
417
417
  /** CSQ 2.0 — off (default) | shadow (avalia, não notifica) | active.
418
418
  * Ausente equivale a `off`: o gate do pipeline só segue com `shadow`/`active`. */
419
419
  csq_mode: zCsqModeSchema.optional(),
420
+ /** feat-226: conexão do juiz do CSQ (`/platform/evo-csq/llm-connections/{id}`).
421
+ * `null`/ausente = default da plataforma. Independente do `llm_connection_id`
422
+ * da HubIA: o juiz e o atendimento escolhem modelo por motivos diferentes. */
423
+ csq_judge_connection_id: z.string().nullable().optional(),
424
+ /** feat-226: tokens do juiz contam no consumo do tenant. Só vale com
425
+ * `csq_mode: 'active'`; em `shadow` nunca cobra. Ausente = `false`. */
426
+ csq_billable: z.boolean().optional(),
427
+ /** feat-226: texto só do juiz, fora de `prompt_overrides` para a HubIA nunca
428
+ * o ler. Entra no prompt do juiz depois do roteiro, com a mesma precedência. */
429
+ csq_prompts: z.object({
430
+ policy_addendum: z.string().max(4000).optional(),
431
+ }).optional(),
420
432
 
421
433
  // ───── LLM (feat-210) ─────
422
434
  /** Conexão do catálogo da plataforma (`/platform/evo-ai/llm-connections/{id}`,
@@ -58,12 +58,12 @@ export type CsqReviewVerdict = "agree" | "disagree";
58
58
  /** Fase do pipeline: `f0` = so indicadores + alertas deterministicos;
59
59
  * `f1` = com o juiz LLM. */
60
60
  export type CsqPhase = "f0" | "f1";
61
- /** De onde veio a conexao de LLM do juiz (feat-191 §2.3), na ordem de
62
- * resolucao: `tenant` (`judge_connection_id`), `legacy_channel`
63
- * (`channel_config.csq_judge_model`), `platform_default`, `constant`; e
64
- * `kill_switch` quando `/platform/evo-csq.llm.transport_kill_switch` forca a
65
- * Anthropic direta. */
66
- export type CsqLlmConnectionSource = "tenant" | "legacy_channel" | "platform_default" | "constant" | "kill_switch";
61
+ /** De onde veio a conexao de LLM do juiz. Desde a feat-226 a ordem e
62
+ * `binding` (`csq_judge_connection_id` do binding da HubIA),
63
+ * `platform_default`, `constant`; e `kill_switch` quando
64
+ * `/platform/evo-csq.llm.transport_kill_switch` forca a Anthropic direta.
65
+ * `tenant` e `legacy_channel` so aparecem em laudos anteriores a feat-226. */
66
+ export type CsqLlmConnectionSource = "binding" | "tenant" | "legacy_channel" | "platform_default" | "constant" | "kill_switch";
67
67
  /** Autor de uma mensagem da transcricao entregue ao juiz. */
68
68
  export type CsqAuthorKind = "lead" | "human" | "automation" | "hubia" | "event" | "note";
69
69
  /** Codigos de alerta v1. Os subtipos de `POLITICA_VIOLADA` e
@@ -414,9 +414,39 @@ export interface ICsqReview {
414
414
  /** Fingerprints dos alertas marcados como falso positivo. */
415
415
  false_alert_fingerprints: string[];
416
416
  note?: string;
417
+ /** feat-206 F5: alertas que o juiz deixou de dar (falso negativo). Dado de
418
+ * calibracao: nao vira alerta nem altera o laudo. */
419
+ missed_alerts?: ICsqReviewMissedAlert[];
420
+ /** feat-206 F5: criterios em que o supervisor discorda da nota do juiz. */
421
+ criteria_disagreements?: ICsqReviewCriterionDisagreement[];
417
422
  reviewer_login_id: string;
418
423
  reviewed_at: Date;
419
424
  }
425
+ /** Alerta que faltou no laudo, segundo o supervisor (feat-206 F5). */
426
+ export interface ICsqReviewMissedAlert {
427
+ code: CsqAlertCode;
428
+ /** Severidade que o supervisor acha que deveria ter. */
429
+ severity?: CsqSeverity;
430
+ /** Onde aconteceu; ausente = o ticket avaliado. */
431
+ ticket_id?: string;
432
+ /** Obrigatoria e curta (ate `CSQ_REVIEW_LIMITS.note_max_chars`). */
433
+ note: string;
434
+ }
435
+ /** Discordancia de nota de um criterio da rubrica (feat-206 F5). */
436
+ export interface ICsqReviewCriterionDisagreement {
437
+ /** `code` do criterio na rubrica (mesmo de `ICsqCriterionScore.criterion`). */
438
+ criterion: string;
439
+ /** Nota que o supervisor esperava. */
440
+ expected: CsqCriterionScore;
441
+ note?: string;
442
+ }
443
+ /** Tetos da revisao validados pelo backend (feat-206 F5). */
444
+ export declare const CSQ_REVIEW_LIMITS: {
445
+ /** Maximo de itens em `missed_alerts` e em `criteria_disagreements`. */
446
+ readonly max_items: 10;
447
+ /** Maximo de caracteres de cada nota de item. */
448
+ readonly note_max_chars: 300;
449
+ };
420
450
  /** Modo decidido pela triagem deterministica antes do prompt. Os modos
421
451
  * intermediarios ficam para a F3/F4. */
422
452
  export type CsqTriageMode = "skip_llm" | "full_review";
@@ -22,7 +22,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
22
22
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.CSQ_DEFAULTS = exports.CSQ_RUBRIC_V1 = exports.CSQ_AUTO_FAIL_POLICY_SUBTYPES = exports.CSQ_AUTO_FAIL_ALERT_CODES = exports.CSQ_SALES_FLOW_SUBTYPES = exports.CSQ_POLICY_VIOLATION_SUBTYPES = exports.CSQ_ALERT_CODES = exports.CSQ_RUBRIC_VERSION = void 0;
25
+ exports.CSQ_REVIEW_LIMITS = exports.CSQ_DEFAULTS = exports.CSQ_RUBRIC_V1 = exports.CSQ_AUTO_FAIL_POLICY_SUBTYPES = exports.CSQ_AUTO_FAIL_ALERT_CODES = exports.CSQ_SALES_FLOW_SUBTYPES = exports.CSQ_POLICY_VIOLATION_SUBTYPES = exports.CSQ_ALERT_CODES = exports.CSQ_RUBRIC_VERSION = void 0;
26
26
  __exportStar(require("./fb_collections"), exports);
27
27
  // ───────── Versao da rubrica ─────────
28
28
  /** Versao da rubrica da plataforma gravada em cada avaliacao. Pesos e criterios
@@ -193,3 +193,10 @@ exports.CSQ_DEFAULTS = {
193
193
  /** Atraso da rechecagem agendada da agenda (minutos apos closed_at). */
194
194
  recheck_delay_min: 30,
195
195
  };
196
+ /** Tetos da revisao validados pelo backend (feat-206 F5). */
197
+ exports.CSQ_REVIEW_LIMITS = {
198
+ /** Maximo de itens em `missed_alerts` e em `criteria_disagreements`. */
199
+ max_items: 10,
200
+ /** Maximo de caracteres de cada nota de item. */
201
+ note_max_chars: 300,
202
+ };
@@ -102,12 +102,13 @@ export type CsqReviewVerdict = "agree" | "disagree";
102
102
  * `f1` = com o juiz LLM. */
103
103
  export type CsqPhase = "f0" | "f1";
104
104
 
105
- /** De onde veio a conexao de LLM do juiz (feat-191 §2.3), na ordem de
106
- * resolucao: `tenant` (`judge_connection_id`), `legacy_channel`
107
- * (`channel_config.csq_judge_model`), `platform_default`, `constant`; e
108
- * `kill_switch` quando `/platform/evo-csq.llm.transport_kill_switch` forca a
109
- * Anthropic direta. */
105
+ /** De onde veio a conexao de LLM do juiz. Desde a feat-226 a ordem e
106
+ * `binding` (`csq_judge_connection_id` do binding da HubIA),
107
+ * `platform_default`, `constant`; e `kill_switch` quando
108
+ * `/platform/evo-csq.llm.transport_kill_switch` forca a Anthropic direta.
109
+ * `tenant` e `legacy_channel` so aparecem em laudos anteriores a feat-226. */
110
110
  export type CsqLlmConnectionSource =
111
+ | "binding"
111
112
  | "tenant"
112
113
  | "legacy_channel"
113
114
  | "platform_default"
@@ -659,10 +660,43 @@ export interface ICsqReview {
659
660
  /** Fingerprints dos alertas marcados como falso positivo. */
660
661
  false_alert_fingerprints: string[];
661
662
  note?: string;
663
+ /** feat-206 F5: alertas que o juiz deixou de dar (falso negativo). Dado de
664
+ * calibracao: nao vira alerta nem altera o laudo. */
665
+ missed_alerts?: ICsqReviewMissedAlert[];
666
+ /** feat-206 F5: criterios em que o supervisor discorda da nota do juiz. */
667
+ criteria_disagreements?: ICsqReviewCriterionDisagreement[];
662
668
  reviewer_login_id: string;
663
669
  reviewed_at: Date;
664
670
  }
665
671
 
672
+ /** Alerta que faltou no laudo, segundo o supervisor (feat-206 F5). */
673
+ export interface ICsqReviewMissedAlert {
674
+ code: CsqAlertCode;
675
+ /** Severidade que o supervisor acha que deveria ter. */
676
+ severity?: CsqSeverity;
677
+ /** Onde aconteceu; ausente = o ticket avaliado. */
678
+ ticket_id?: string;
679
+ /** Obrigatoria e curta (ate `CSQ_REVIEW_LIMITS.note_max_chars`). */
680
+ note: string;
681
+ }
682
+
683
+ /** Discordancia de nota de um criterio da rubrica (feat-206 F5). */
684
+ export interface ICsqReviewCriterionDisagreement {
685
+ /** `code` do criterio na rubrica (mesmo de `ICsqCriterionScore.criterion`). */
686
+ criterion: string;
687
+ /** Nota que o supervisor esperava. */
688
+ expected: CsqCriterionScore;
689
+ note?: string;
690
+ }
691
+
692
+ /** Tetos da revisao validados pelo backend (feat-206 F5). */
693
+ export const CSQ_REVIEW_LIMITS = {
694
+ /** Maximo de itens em `missed_alerts` e em `criteria_disagreements`. */
695
+ max_items: 10,
696
+ /** Maximo de caracteres de cada nota de item. */
697
+ note_max_chars: 300,
698
+ } as const;
699
+
666
700
  // ───────── Trilha e denormalizacao ─────────
667
701
 
668
702
  // ───────── Triagem sem LLM (feat-206 F1) ─────────
@@ -1,4 +1,5 @@
1
1
  import type { IFireGlobalDoc } from '../../shared';
2
+ import type { NexFinopsPaymentMethodKind } from './payment-method';
2
3
  export type NexFinopsBillingStatus = 'draft' | 'issued' | 'paid' | 'overdue' | 'canceled';
3
4
  export type NexFinopsBillingAttachmentCategory = 'boleto' | 'invoice' | 'other';
4
5
  export interface INexFinopsBillingServiceItem {
@@ -28,7 +29,7 @@ export interface INexFinopsBillingBoletoTerms {
28
29
  mora_taxa: number;
29
30
  }
30
31
  export interface INexFinopsBillingPaymentOption {
31
- type: 'pix' | 'boleto' | 'payment_link';
32
+ type: 'pix' | 'boleto' | 'payment_link' | 'credit_card';
32
33
  provider_id?: string | null;
33
34
  external_id?: string | null;
34
35
  url?: string | null;
@@ -63,12 +64,61 @@ export interface INexFinopsBillingAttachment {
63
64
  category?: NexFinopsBillingAttachmentCategory;
64
65
  }
65
66
  export interface INexFinopsBillingPaidVia {
66
- kind: 'payment_link' | 'manual' | 'pix' | 'boleto';
67
+ kind: 'payment_link' | 'manual' | 'pix' | 'boleto' | 'credit_card';
67
68
  payment_link_id?: string | null;
68
69
  asaas_payment_id?: string | null;
69
70
  event?: string | null;
70
71
  received_at?: string | null;
71
72
  raw_status?: string | null;
73
+ /** feat-253: método de pagamento (cartão) que liquidou a cobrança. */
74
+ payment_method_id?: string | null;
75
+ /** feat-253: degrau do roteamento do webhook de cartão que casou o pagamento. Interno (não vai ao portal). */
76
+ matched_by?: 'card_payment_id' | 'external_reference' | 'subscription_competency' | null;
77
+ }
78
+ /** Resumo do método herdado — só bandeira e últimos 4 (PCI). */
79
+ export interface INexFinopsBillingPaymentMethodSnapshot {
80
+ kind: NexFinopsPaymentMethodKind;
81
+ brand: string | null;
82
+ last4: string | null;
83
+ subscription_id?: string | null;
84
+ }
85
+ export type NexFinopsBillingCardChargeMode = 'subscription_adjust'
86
+ /** Contingência A′. */
87
+ | 'subscription_value_update' | 'token_charge';
88
+ export type NexFinopsBillingCardChargeStatus = 'scheduled' | 'stale' | 'confirmed' | 'refused' | 'refunded' | 'chargeback' | 'canceled' | 'reverted';
89
+ export interface INexFinopsBillingCardChargeHistoryEntry {
90
+ at: string;
91
+ by: string | null;
92
+ action: 'adjust' | 'readjust' | 'revert' | 'charge' | 'event';
93
+ value?: number | null;
94
+ event?: string | null;
95
+ }
96
+ export interface INexFinopsBillingCardCharge {
97
+ mode: NexFinopsBillingCardChargeMode;
98
+ payment_method_id: string;
99
+ asaas_payment_id: string;
100
+ subscription_id?: string | null;
101
+ /** `dueDate` do `pay_` no Asaas (YYYY-MM-DD). */
102
+ due_date: string;
103
+ /** Caminho A: valor antes do ajuste. */
104
+ value_before?: number | null;
105
+ /** = `billing.total` no momento do ajuste. */
106
+ value_after: number;
107
+ status: NexFinopsBillingCardChargeStatus;
108
+ raw_status?: string | null;
109
+ adjusted_at: string;
110
+ adjusted_by: {
111
+ kind: 'user' | 'system';
112
+ id: string | null;
113
+ };
114
+ last_event?: string | null;
115
+ last_event_at?: string | null;
116
+ failure?: {
117
+ event: string;
118
+ description?: string | null;
119
+ } | null;
120
+ /** Capado em 30 entradas. */
121
+ history: INexFinopsBillingCardChargeHistoryEntry[];
72
122
  }
73
123
  export interface INexFinopsBilling extends IFireGlobalDoc {
74
124
  customer_id: string;
@@ -95,6 +145,12 @@ export interface INexFinopsBilling extends IFireGlobalDoc {
95
145
  contract_snapshot?: Record<string, unknown> | null;
96
146
  customer_snapshot?: Record<string, unknown> | null;
97
147
  notes?: string | null;
148
+ /** Método herdado do `default_payment_method_id` do contrato na geração (ou escolhido depois). */
149
+ payment_method_id?: string | null;
150
+ payment_method_snapshot?: INexFinopsBillingPaymentMethodSnapshot | null;
151
+ /** Todos os `pay_` do Asaas já associados (A e B) — chave do roteamento do webhook. Interno. */
152
+ card_payment_ids?: string[];
153
+ card_charge?: INexFinopsBillingCardCharge | null;
98
154
  }
99
155
  /**
100
156
  * Transições permitidas de status de cobrança.
@@ -1,4 +1,5 @@
1
1
  import type { IFireGlobalDoc } from '../../shared';
2
+ import type { NexFinopsPaymentMethodKind } from './payment-method';
2
3
 
3
4
  // ── Status ──
4
5
 
@@ -42,7 +43,7 @@ export interface INexFinopsBillingBoletoTerms {
42
43
  }
43
44
 
44
45
  export interface INexFinopsBillingPaymentOption {
45
- type: 'pix' | 'boleto' | 'payment_link';
46
+ type: 'pix' | 'boleto' | 'payment_link' | 'credit_card';
46
47
  provider_id?: string | null;
47
48
  external_id?: string | null;
48
49
  url?: string | null;
@@ -80,12 +81,72 @@ export interface INexFinopsBillingAttachment {
80
81
  }
81
82
 
82
83
  export interface INexFinopsBillingPaidVia {
83
- kind: 'payment_link' | 'manual' | 'pix' | 'boleto';
84
+ kind: 'payment_link' | 'manual' | 'pix' | 'boleto' | 'credit_card';
84
85
  payment_link_id?: string | null;
85
86
  asaas_payment_id?: string | null;
86
87
  event?: string | null;
87
88
  received_at?: string | null;
88
89
  raw_status?: string | null;
90
+ /** feat-253: método de pagamento (cartão) que liquidou a cobrança. */
91
+ payment_method_id?: string | null;
92
+ /** feat-253: degrau do roteamento do webhook de cartão que casou o pagamento. Interno (não vai ao portal). */
93
+ matched_by?: 'card_payment_id' | 'external_reference' | 'subscription_competency' | null;
94
+ }
95
+
96
+ // ── Cobrança no cartão (feat-253) ──
97
+
98
+ /** Resumo do método herdado — só bandeira e últimos 4 (PCI). */
99
+ export interface INexFinopsBillingPaymentMethodSnapshot {
100
+ kind: NexFinopsPaymentMethodKind;
101
+ brand: string | null;
102
+ last4: string | null;
103
+ subscription_id?: string | null;
104
+ }
105
+
106
+ export type NexFinopsBillingCardChargeMode =
107
+ | 'subscription_adjust'
108
+ /** Contingência A′. */
109
+ | 'subscription_value_update'
110
+ | 'token_charge';
111
+
112
+ export type NexFinopsBillingCardChargeStatus =
113
+ | 'scheduled'
114
+ | 'stale'
115
+ | 'confirmed'
116
+ | 'refused'
117
+ | 'refunded'
118
+ | 'chargeback'
119
+ | 'canceled'
120
+ | 'reverted';
121
+
122
+ export interface INexFinopsBillingCardChargeHistoryEntry {
123
+ at: string;
124
+ by: string | null;
125
+ action: 'adjust' | 'readjust' | 'revert' | 'charge' | 'event';
126
+ value?: number | null;
127
+ event?: string | null;
128
+ }
129
+
130
+ export interface INexFinopsBillingCardCharge {
131
+ mode: NexFinopsBillingCardChargeMode;
132
+ payment_method_id: string;
133
+ asaas_payment_id: string;
134
+ subscription_id?: string | null;
135
+ /** `dueDate` do `pay_` no Asaas (YYYY-MM-DD). */
136
+ due_date: string;
137
+ /** Caminho A: valor antes do ajuste. */
138
+ value_before?: number | null;
139
+ /** = `billing.total` no momento do ajuste. */
140
+ value_after: number;
141
+ status: NexFinopsBillingCardChargeStatus;
142
+ raw_status?: string | null;
143
+ adjusted_at: string;
144
+ adjusted_by: { kind: 'user' | 'system'; id: string | null };
145
+ last_event?: string | null;
146
+ last_event_at?: string | null;
147
+ failure?: { event: string; description?: string | null } | null;
148
+ /** Capado em 30 entradas. */
149
+ history: INexFinopsBillingCardChargeHistoryEntry[];
89
150
  }
90
151
 
91
152
  // ── Main Document ──
@@ -144,6 +205,15 @@ export interface INexFinopsBilling extends IFireGlobalDoc {
144
205
 
145
206
  // Observações
146
207
  notes?: string | null;
208
+
209
+ // ── Cartão (feat-253) ──
210
+
211
+ /** Método herdado do `default_payment_method_id` do contrato na geração (ou escolhido depois). */
212
+ payment_method_id?: string | null;
213
+ payment_method_snapshot?: INexFinopsBillingPaymentMethodSnapshot | null;
214
+ /** Todos os `pay_` do Asaas já associados (A e B) — chave do roteamento do webhook. Interno. */
215
+ card_payment_ids?: string[];
216
+ card_charge?: INexFinopsBillingCardCharge | null;
147
217
  }
148
218
 
149
219
  // ── Status transitions ──
@@ -139,6 +139,14 @@ export interface INexFinopsContract extends IFireGlobalDoc {
139
139
  /** Método com que o primeiro pagamento foi feito. `accepted_payment_methods` é a oferta; este é o fato. */
140
140
  payment_method?: NexFinopsPaymentMethod | null;
141
141
  asaas?: INexFinopsContractAsaasInfo | null;
142
+ /**
143
+ * Ids de `payment_methods` do MESMO customer habilitados neste contrato.
144
+ * Escrito só pela rota dedicada `PUT /contracts/:id/payment-methods`; o
145
+ * `PUT /contracts/:id` genérico ignora este campo.
146
+ */
147
+ payment_method_ids?: string[] | null;
148
+ /** Precisa estar em `payment_method_ids`. É o que a cobrança herda no `billingGenerate`. */
149
+ default_payment_method_id?: string | null;
142
150
  /**
143
151
  * Franquia incluída no ciclo, por métrica. A CHAVE é o id da métrica (ver
144
152
  * `NexFinopsMetricCatalog`) e é deliberadamente `string`: métrica nova é um
@@ -172,6 +172,17 @@ export interface INexFinopsContract extends IFireGlobalDoc {
172
172
  payment_method?: NexFinopsPaymentMethod | null;
173
173
  asaas?: INexFinopsContractAsaasInfo | null;
174
174
 
175
+ // ── Métodos de pagamento habilitados (feat-253) ──
176
+
177
+ /**
178
+ * Ids de `payment_methods` do MESMO customer habilitados neste contrato.
179
+ * Escrito só pela rota dedicada `PUT /contracts/:id/payment-methods`; o
180
+ * `PUT /contracts/:id` genérico ignora este campo.
181
+ */
182
+ payment_method_ids?: string[] | null;
183
+ /** Precisa estar em `payment_method_ids`. É o que a cobrança herda no `billingGenerate`. */
184
+ default_payment_method_id?: string | null;
185
+
175
186
  // ── Franquias e alertas de consumo (feat-150 F0) ──
176
187
 
177
188
  /**