evo360-types 1.3.390 → 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/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
|
@@ -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
|
+
}
|