evo360-types 1.3.389 → 1.3.391
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/types/evo-crm/lead/index.d.ts +26 -0
- package/dist/types/evo-crm/lead/index.ts +38 -0
- package/dist/types/nex-tenants/chatbee-import.d.ts +92 -0
- package/dist/types/nex-tenants/chatbee-import.js +14 -0
- package/dist/types/nex-tenants/chatbee-import.ts +122 -0
- package/dist/types/nex-tenants/index.d.ts +1 -0
- package/dist/types/nex-tenants/index.js +1 -0
- package/dist/types/nex-tenants/index.ts +1 -0
- package/package.json +1 -1
|
@@ -29,6 +29,27 @@ export interface ILeadDistChannel {
|
|
|
29
29
|
ref?: FirestoreDocumentReference;
|
|
30
30
|
updated_at?: Date | null;
|
|
31
31
|
}
|
|
32
|
+
/** Origem de aquisição do lead (feat-038) — base expansível p/ múltiplas
|
|
33
|
+
* plataformas. v1 implementa só `type:'ctwa'` (Click-to-WhatsApp da Meta);
|
|
34
|
+
* Google Ads / Instagram Direct / TikTok / site ficam para fast-follow. */
|
|
35
|
+
export type LeadReferralType = "ctwa" | "instagram_direct" | "google_ads" | "tiktok" | "site" | "other";
|
|
36
|
+
export interface ILeadReferralBase {
|
|
37
|
+
type: LeadReferralType;
|
|
38
|
+
captured_at?: Date | string | null;
|
|
39
|
+
source_url?: string | null;
|
|
40
|
+
label?: string | null;
|
|
41
|
+
raw?: Record<string, unknown> | null;
|
|
42
|
+
}
|
|
43
|
+
export interface ILeadReferralCTWA extends ILeadReferralBase {
|
|
44
|
+
type: "ctwa";
|
|
45
|
+
ad_id?: string | null;
|
|
46
|
+
source_type?: string | null;
|
|
47
|
+
headline?: string | null;
|
|
48
|
+
body?: string | null;
|
|
49
|
+
media_type?: string | null;
|
|
50
|
+
ctwa_clid?: string | null;
|
|
51
|
+
}
|
|
52
|
+
export type ILeadReferral = ILeadReferralCTWA;
|
|
32
53
|
/** Estado da régua de reativação de lead (feat-037).
|
|
33
54
|
* Mantido pelo subscriber `ticket_closed` (streak) e pela task
|
|
34
55
|
* `lead_reactivation` (último disparo). Semântica do streak alinhada ao
|
|
@@ -57,6 +78,10 @@ export interface ILead extends IProfile {
|
|
|
57
78
|
tags?: ITag[] | null;
|
|
58
79
|
userRef?: FirestoreDocumentReference;
|
|
59
80
|
ctwa_clid?: string | null;
|
|
81
|
+
/**
|
|
82
|
+
* @deprecated A ESCRITA foi substituída por `acquisition_sources[]` (feat-038).
|
|
83
|
+
* Tipo mantido para leitura de leads antigos; sem backfill.
|
|
84
|
+
*/
|
|
60
85
|
ctwa_referral?: {
|
|
61
86
|
source_type?: string;
|
|
62
87
|
source_id?: string;
|
|
@@ -66,6 +91,7 @@ export interface ILead extends IProfile {
|
|
|
66
91
|
media_type?: string;
|
|
67
92
|
captured_at?: Date | string | null;
|
|
68
93
|
} | null;
|
|
94
|
+
acquisition_sources?: ILeadReferral[] | null;
|
|
69
95
|
reactivation?: ILeadReactivation | null;
|
|
70
96
|
[key: string]: unknown;
|
|
71
97
|
}
|
|
@@ -44,6 +44,37 @@ export interface ILeadDistChannel {
|
|
|
44
44
|
updated_at?: Date | null;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/** Origem de aquisição do lead (feat-038) — base expansível p/ múltiplas
|
|
48
|
+
* plataformas. v1 implementa só `type:'ctwa'` (Click-to-WhatsApp da Meta);
|
|
49
|
+
* Google Ads / Instagram Direct / TikTok / site ficam para fast-follow. */
|
|
50
|
+
export type LeadReferralType =
|
|
51
|
+
| "ctwa" // Click-to-WhatsApp (Meta FB/IG → WhatsApp) ← v1
|
|
52
|
+
| "instagram_direct" // ig.me ?ref= ← futuro
|
|
53
|
+
| "google_ads" // gclid / token em ?text= ← futuro
|
|
54
|
+
| "tiktok"
|
|
55
|
+
| "site"
|
|
56
|
+
| "other"; // ← futuro
|
|
57
|
+
|
|
58
|
+
export interface ILeadReferralBase {
|
|
59
|
+
type: LeadReferralType; // discriminador p/ o parser
|
|
60
|
+
captured_at?: Date | string | null; // 1º toque desta origem (idioma do repo)
|
|
61
|
+
source_url?: string | null; // link clicável
|
|
62
|
+
label?: string | null; // rótulo de exibição (headline || ad_id || domínio)
|
|
63
|
+
raw?: Record<string, unknown> | null; // payload original lossless → re-parse futuro sem backfill
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ILeadReferralCTWA extends ILeadReferralBase {
|
|
67
|
+
type: "ctwa";
|
|
68
|
+
ad_id?: string | null; // referral.source_id
|
|
69
|
+
source_type?: string | null; // 'ad' | 'post'
|
|
70
|
+
headline?: string | null;
|
|
71
|
+
body?: string | null;
|
|
72
|
+
media_type?: string | null;
|
|
73
|
+
ctwa_clid?: string | null; // espelho; o de topo (CAPI/feat-034) permanece na raiz
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type ILeadReferral = ILeadReferralCTWA; // | ILeadReferralGoogleAds | ...
|
|
77
|
+
|
|
47
78
|
/** Estado da régua de reativação de lead (feat-037).
|
|
48
79
|
* Mantido pelo subscriber `ticket_closed` (streak) e pela task
|
|
49
80
|
* `lead_reactivation` (último disparo). Semântica do streak alinhada ao
|
|
@@ -74,6 +105,10 @@ export interface ILead extends IProfile {
|
|
|
74
105
|
userRef?: FirestoreDocumentReference;
|
|
75
106
|
// CTWA attribution (feat-034) — capturado do referral do 1º inbound vindo de anúncio Click-to-WhatsApp.
|
|
76
107
|
ctwa_clid?: string | null;
|
|
108
|
+
/**
|
|
109
|
+
* @deprecated A ESCRITA foi substituída por `acquisition_sources[]` (feat-038).
|
|
110
|
+
* Tipo mantido para leitura de leads antigos; sem backfill.
|
|
111
|
+
*/
|
|
77
112
|
ctwa_referral?: {
|
|
78
113
|
source_type?: string;
|
|
79
114
|
source_id?: string;
|
|
@@ -83,6 +118,9 @@ export interface ILead extends IProfile {
|
|
|
83
118
|
media_type?: string;
|
|
84
119
|
captured_at?: Date | string | null;
|
|
85
120
|
} | null;
|
|
121
|
+
// Origens de aquisição multi-touch (feat-038) — união discriminada por `type`.
|
|
122
|
+
// Substitui a escrita de `ctwa_referral`; `ctwa_clid` de topo permanece (CAPI).
|
|
123
|
+
acquisition_sources?: ILeadReferral[] | null;
|
|
86
124
|
// Régua de reativação (feat-037) — mantida pelo subscriber ticket_closed + task lead_reactivation.
|
|
87
125
|
reactivation?: ILeadReactivation | null;
|
|
88
126
|
[key: string]: unknown; // index signature
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { IFireGlobalDoc } from "../shared";
|
|
3
|
+
export declare const CHATBEE_IMPORT_SCHEMA_VERSION: 1;
|
|
4
|
+
export declare const CHATBEE_IMPORT_FIRESTORE_PATH: "core/nexus/apps/nex-tenants/chatbee_imports";
|
|
5
|
+
export declare const CHATBEE_IMPORT_PUBSUB_TOPIC: "app_nexus_chatbee-import_request";
|
|
6
|
+
export type ChatbeeImportStatus = "pending" | "running" | "done" | "failed";
|
|
7
|
+
export type ChatbeeImportAuditAction = "import_requested" | "import_started" | "import_page" | "import_completed" | "import_failed";
|
|
8
|
+
/**
|
|
9
|
+
* Keyset cursor over `chatbee.msgs_raw` ordered by
|
|
10
|
+
* (contact.id, history.id, timestamp, message.id). A page resumes strictly
|
|
11
|
+
* AFTER this tuple. `null` (no cursor) means the run starts from the beginning.
|
|
12
|
+
*/
|
|
13
|
+
export interface IChatbeeImportCursor {
|
|
14
|
+
contact_id: string;
|
|
15
|
+
history_id: string;
|
|
16
|
+
/** Message event time as epoch microseconds (BQ TIMESTAMP precision). */
|
|
17
|
+
timestamp_us: string;
|
|
18
|
+
message_id: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Running totals committed per page so the UI can render live progress and a
|
|
22
|
+
* re-publish (self-continuation) resumes from a consistent count. Idempotent
|
|
23
|
+
* re-imports inflate `messages_skipped_dup`, not `messages_imported`.
|
|
24
|
+
*/
|
|
25
|
+
export interface IChatbeeImportCounters {
|
|
26
|
+
messages_imported: number;
|
|
27
|
+
messages_skipped_dup: number;
|
|
28
|
+
messages_skipped_unsupported: number;
|
|
29
|
+
threads_touched: number;
|
|
30
|
+
tickets_open: number;
|
|
31
|
+
tickets_closed: number;
|
|
32
|
+
contacts_reconciled: number;
|
|
33
|
+
reconcile_conflicts: number;
|
|
34
|
+
pages_processed: number;
|
|
35
|
+
}
|
|
36
|
+
export interface IChatbeeImportError {
|
|
37
|
+
code: string;
|
|
38
|
+
message: string;
|
|
39
|
+
}
|
|
40
|
+
export interface IChatbeeImportRequestedBy {
|
|
41
|
+
uid: string;
|
|
42
|
+
email: string;
|
|
43
|
+
loginId: string;
|
|
44
|
+
}
|
|
45
|
+
export interface IChatbeeImportDoc extends IFireGlobalDoc {
|
|
46
|
+
tenant: string;
|
|
47
|
+
/** Destination hub-waba channel id — threads/tickets/messages carry this channel_id. */
|
|
48
|
+
destination_channel_id: string;
|
|
49
|
+
/** Count-only preview: zero Firestore/PubSub/BQ writes, projects counters + totals. */
|
|
50
|
+
dry_run: boolean;
|
|
51
|
+
requested_by: IChatbeeImportRequestedBy;
|
|
52
|
+
requested_at: Date | null;
|
|
53
|
+
started_at?: Date | null;
|
|
54
|
+
finished_at?: Date | null;
|
|
55
|
+
status: ChatbeeImportStatus;
|
|
56
|
+
/** Keyset cursor of the last fully-committed page; null before the first page. */
|
|
57
|
+
cursor?: IChatbeeImportCursor | null;
|
|
58
|
+
counters?: IChatbeeImportCounters | null;
|
|
59
|
+
/** Total rows matched for this tenant (filled on dry-run / first page for the UI). */
|
|
60
|
+
total_messages?: number | null;
|
|
61
|
+
error?: IChatbeeImportError | null;
|
|
62
|
+
/** Non-fatal warnings (reconcile conflicts, stale-open demotions). Capped at 50. */
|
|
63
|
+
warnings?: string[] | null;
|
|
64
|
+
import_schema_version: typeof CHATBEE_IMPORT_SCHEMA_VERSION;
|
|
65
|
+
}
|
|
66
|
+
export declare const ChatbeeImportRequestSchema: z.ZodObject<{
|
|
67
|
+
tenant: z.ZodString;
|
|
68
|
+
destination_channel_id: z.ZodString;
|
|
69
|
+
dry_run: z.ZodOptional<z.ZodBoolean>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
tenant: string;
|
|
72
|
+
destination_channel_id: string;
|
|
73
|
+
dry_run?: boolean | undefined;
|
|
74
|
+
}, {
|
|
75
|
+
tenant: string;
|
|
76
|
+
destination_channel_id: string;
|
|
77
|
+
dry_run?: boolean | undefined;
|
|
78
|
+
}>;
|
|
79
|
+
export type IChatbeeImportRequestPayload = z.infer<typeof ChatbeeImportRequestSchema>;
|
|
80
|
+
export interface IChatbeeImportPubSubEvent {
|
|
81
|
+
importId: string;
|
|
82
|
+
tenant: string;
|
|
83
|
+
destination_channel_id: string;
|
|
84
|
+
dry_run: boolean;
|
|
85
|
+
/** Cursor to resume from on a self-continuation; null/absent for the first run. */
|
|
86
|
+
cursor?: IChatbeeImportCursor | null;
|
|
87
|
+
requested_by: {
|
|
88
|
+
uid: string;
|
|
89
|
+
loginId: string;
|
|
90
|
+
};
|
|
91
|
+
trace_id: string;
|
|
92
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChatbeeImportRequestSchema = exports.CHATBEE_IMPORT_PUBSUB_TOPIC = exports.CHATBEE_IMPORT_FIRESTORE_PATH = exports.CHATBEE_IMPORT_SCHEMA_VERSION = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
// ── Constants ──
|
|
6
|
+
exports.CHATBEE_IMPORT_SCHEMA_VERSION = 1;
|
|
7
|
+
exports.CHATBEE_IMPORT_FIRESTORE_PATH = "core/nexus/apps/nex-tenants/chatbee_imports";
|
|
8
|
+
exports.CHATBEE_IMPORT_PUBSUB_TOPIC = "app_nexus_chatbee-import_request";
|
|
9
|
+
// ── Zod Schemas (callable payloads) ──
|
|
10
|
+
exports.ChatbeeImportRequestSchema = zod_1.z.object({
|
|
11
|
+
tenant: zod_1.z.string().min(1),
|
|
12
|
+
destination_channel_id: zod_1.z.string().min(1),
|
|
13
|
+
dry_run: zod_1.z.boolean().optional(),
|
|
14
|
+
});
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { IFireGlobalDoc } from "../shared";
|
|
3
|
+
|
|
4
|
+
// ── Constants ──
|
|
5
|
+
|
|
6
|
+
export const CHATBEE_IMPORT_SCHEMA_VERSION = 1 as const;
|
|
7
|
+
|
|
8
|
+
export const CHATBEE_IMPORT_FIRESTORE_PATH =
|
|
9
|
+
"core/nexus/apps/nex-tenants/chatbee_imports" as const;
|
|
10
|
+
|
|
11
|
+
export const CHATBEE_IMPORT_PUBSUB_TOPIC =
|
|
12
|
+
"app_nexus_chatbee-import_request" as const;
|
|
13
|
+
|
|
14
|
+
// ── Enums / Literals ──
|
|
15
|
+
|
|
16
|
+
export type ChatbeeImportStatus =
|
|
17
|
+
| "pending"
|
|
18
|
+
| "running"
|
|
19
|
+
| "done"
|
|
20
|
+
| "failed";
|
|
21
|
+
|
|
22
|
+
export type ChatbeeImportAuditAction =
|
|
23
|
+
| "import_requested"
|
|
24
|
+
| "import_started"
|
|
25
|
+
| "import_page"
|
|
26
|
+
| "import_completed"
|
|
27
|
+
| "import_failed";
|
|
28
|
+
|
|
29
|
+
// ── Sub-interfaces ──
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Keyset cursor over `chatbee.msgs_raw` ordered by
|
|
33
|
+
* (contact.id, history.id, timestamp, message.id). A page resumes strictly
|
|
34
|
+
* AFTER this tuple. `null` (no cursor) means the run starts from the beginning.
|
|
35
|
+
*/
|
|
36
|
+
export interface IChatbeeImportCursor {
|
|
37
|
+
contact_id: string;
|
|
38
|
+
history_id: string;
|
|
39
|
+
/** Message event time as epoch microseconds (BQ TIMESTAMP precision). */
|
|
40
|
+
timestamp_us: string;
|
|
41
|
+
message_id: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Running totals committed per page so the UI can render live progress and a
|
|
46
|
+
* re-publish (self-continuation) resumes from a consistent count. Idempotent
|
|
47
|
+
* re-imports inflate `messages_skipped_dup`, not `messages_imported`.
|
|
48
|
+
*/
|
|
49
|
+
export interface IChatbeeImportCounters {
|
|
50
|
+
messages_imported: number;
|
|
51
|
+
messages_skipped_dup: number;
|
|
52
|
+
messages_skipped_unsupported: number;
|
|
53
|
+
threads_touched: number;
|
|
54
|
+
tickets_open: number;
|
|
55
|
+
tickets_closed: number;
|
|
56
|
+
contacts_reconciled: number;
|
|
57
|
+
reconcile_conflicts: number;
|
|
58
|
+
pages_processed: number;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface IChatbeeImportError {
|
|
62
|
+
code: string;
|
|
63
|
+
message: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface IChatbeeImportRequestedBy {
|
|
67
|
+
uid: string;
|
|
68
|
+
email: string;
|
|
69
|
+
loginId: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// ── Main Document ──
|
|
73
|
+
|
|
74
|
+
export interface IChatbeeImportDoc extends IFireGlobalDoc {
|
|
75
|
+
tenant: string;
|
|
76
|
+
/** Destination hub-waba channel id — threads/tickets/messages carry this channel_id. */
|
|
77
|
+
destination_channel_id: string;
|
|
78
|
+
/** Count-only preview: zero Firestore/PubSub/BQ writes, projects counters + totals. */
|
|
79
|
+
dry_run: boolean;
|
|
80
|
+
requested_by: IChatbeeImportRequestedBy;
|
|
81
|
+
requested_at: Date | null;
|
|
82
|
+
started_at?: Date | null;
|
|
83
|
+
finished_at?: Date | null;
|
|
84
|
+
status: ChatbeeImportStatus;
|
|
85
|
+
/** Keyset cursor of the last fully-committed page; null before the first page. */
|
|
86
|
+
cursor?: IChatbeeImportCursor | null;
|
|
87
|
+
counters?: IChatbeeImportCounters | null;
|
|
88
|
+
/** Total rows matched for this tenant (filled on dry-run / first page for the UI). */
|
|
89
|
+
total_messages?: number | null;
|
|
90
|
+
error?: IChatbeeImportError | null;
|
|
91
|
+
/** Non-fatal warnings (reconcile conflicts, stale-open demotions). Capped at 50. */
|
|
92
|
+
warnings?: string[] | null;
|
|
93
|
+
import_schema_version: typeof CHATBEE_IMPORT_SCHEMA_VERSION;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ── Zod Schemas (callable payloads) ──
|
|
97
|
+
|
|
98
|
+
export const ChatbeeImportRequestSchema = z.object({
|
|
99
|
+
tenant: z.string().min(1),
|
|
100
|
+
destination_channel_id: z.string().min(1),
|
|
101
|
+
dry_run: z.boolean().optional(),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export type IChatbeeImportRequestPayload = z.infer<
|
|
105
|
+
typeof ChatbeeImportRequestSchema
|
|
106
|
+
>;
|
|
107
|
+
|
|
108
|
+
// ── PubSub Event ──
|
|
109
|
+
|
|
110
|
+
export interface IChatbeeImportPubSubEvent {
|
|
111
|
+
importId: string;
|
|
112
|
+
tenant: string;
|
|
113
|
+
destination_channel_id: string;
|
|
114
|
+
dry_run: boolean;
|
|
115
|
+
/** Cursor to resume from on a self-continuation; null/absent for the first run. */
|
|
116
|
+
cursor?: IChatbeeImportCursor | null;
|
|
117
|
+
requested_by: {
|
|
118
|
+
uid: string;
|
|
119
|
+
loginId: string;
|
|
120
|
+
};
|
|
121
|
+
trace_id: string;
|
|
122
|
+
}
|