orbitx-core-models 11.173.0 → 11.175.0

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.
@@ -0,0 +1,20 @@
1
+ export declare const normalizeAddonSlug: (s: unknown) => string;
2
+ /**
3
+ * Which add-ons a company owns and which of those Ops has paused. Paused add-ons stay visible in every dashboard
4
+ * but their runtime behaviour must stop. Returns { owned, paused } as sets of normalised slugs/names.
5
+ */
6
+ export declare function getAddonState(companyId: unknown): Promise<{
7
+ owned: Set<string>;
8
+ paused: Set<string>;
9
+ }>;
10
+ /**
11
+ * True when the company owns at least one of `slugs` and every owned one is paused. Fails open (false) on any
12
+ * error so a lookup problem can never break live chats.
13
+ */
14
+ export declare function isAddonPaused(companyId: unknown, slugs: string[]): Promise<boolean>;
15
+ /**
16
+ * True when the company has NOT bought any of `slugs`, or every one it bought is paused, i.e. the feature must not
17
+ * run. Fails open (false) on error so a lookup problem never silently stops leads reaching a client's CRM.
18
+ */
19
+ export declare function isAddonUnavailable(companyId: unknown, slugs: string[]): Promise<boolean>;
20
+ //# sourceMappingURL=addonState.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addonState.d.ts","sourceRoot":"","sources":["../../src/helpers/addonState.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,kBAAkB,GAAI,GAAG,OAAO,KAAG,MAKtB,CAAC;AAI3B;;;GAGG;AACH,wBAAsB,aAAa,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,CAAC,CAuB5G;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAUzF;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAS9F"}
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeAddonSlug = void 0;
4
+ exports.getAddonState = getAddonState;
5
+ exports.isAddonPaused = isAddonPaused;
6
+ exports.isAddonUnavailable = isAddonUnavailable;
7
+ const subscription_model_1 = require("../models/subscription.model");
8
+ // Slugs are typed by hand in Ops (some use hyphens, some underscores), so compare a normalised form of both the
9
+ // slug and the name.
10
+ const normalizeAddonSlug = (s) => String(s || "")
11
+ .trim()
12
+ .toLowerCase()
13
+ .replace(/[^a-z0-9]+/g, "-")
14
+ .replace(/^-|-$/g, "");
15
+ exports.normalizeAddonSlug = normalizeAddonSlug;
16
+ const norm = exports.normalizeAddonSlug;
17
+ /**
18
+ * Which add-ons a company owns and which of those Ops has paused. Paused add-ons stay visible in every dashboard
19
+ * but their runtime behaviour must stop. Returns { owned, paused } as sets of normalised slugs/names.
20
+ */
21
+ async function getAddonState(companyId) {
22
+ const owned = new Set();
23
+ const paused = new Set();
24
+ if (!companyId)
25
+ return { owned, paused };
26
+ const sub = await subscription_model_1.Subscription.findOne({ company: companyId })
27
+ .select("addons disabledAddons")
28
+ .populate("addons.addon", "slug name")
29
+ .lean();
30
+ if (!sub)
31
+ return { owned, paused };
32
+ const disabled = new Set((sub.disabledAddons || []).map(String));
33
+ for (const row of sub.addons || []) {
34
+ const addon = row.addon;
35
+ if (!addon)
36
+ continue;
37
+ const keys = [norm(addon.slug), norm(addon.name)].filter(Boolean);
38
+ const isPaused = disabled.has(String(addon._id));
39
+ for (const k of keys) {
40
+ owned.add(k);
41
+ if (isPaused)
42
+ paused.add(k);
43
+ }
44
+ }
45
+ return { owned, paused };
46
+ }
47
+ /**
48
+ * True when the company owns at least one of `slugs` and every owned one is paused. Fails open (false) on any
49
+ * error so a lookup problem can never break live chats.
50
+ */
51
+ async function isAddonPaused(companyId, slugs) {
52
+ try {
53
+ const { owned, paused } = await getAddonState(companyId);
54
+ const wanted = slugs.map(norm);
55
+ const ownedWanted = wanted.filter((s) => owned.has(s));
56
+ return ownedWanted.length > 0 && ownedWanted.every((s) => paused.has(s));
57
+ }
58
+ catch (err) {
59
+ console.error("[addonState] lookup failed, treating add-on as active:", err === null || err === void 0 ? void 0 : err.message);
60
+ return false;
61
+ }
62
+ }
63
+ /**
64
+ * True when the company has NOT bought any of `slugs`, or every one it bought is paused, i.e. the feature must not
65
+ * run. Fails open (false) on error so a lookup problem never silently stops leads reaching a client's CRM.
66
+ */
67
+ async function isAddonUnavailable(companyId, slugs) {
68
+ try {
69
+ const { owned, paused } = await getAddonState(companyId);
70
+ const active = slugs.map(norm).filter((s) => owned.has(s) && !paused.has(s));
71
+ return active.length === 0;
72
+ }
73
+ catch (err) {
74
+ console.error("[addonState] lookup failed, treating add-on as available:", err === null || err === void 0 ? void 0 : err.message);
75
+ return false;
76
+ }
77
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Time buckets for the analytics charts (Ops and Client). The bucket size follows the selected date range (hourly
3
+ * for a day, daily for a week or month, weekly for a few months, monthly for a year) unless the caller asks for a
4
+ * specific one. Every bucket in the range is returned, so quiet periods show as zero instead of disappearing, and
5
+ * the keys built here match the keys MongoDB builds in groupKeyExpr.
6
+ */
7
+ export declare const UNITS: readonly ["hour", "day", "week", "month"];
8
+ export type BucketUnit = (typeof UNITS)[number];
9
+ type Range = {
10
+ $gte?: unknown;
11
+ $lte?: unknown;
12
+ } | null | undefined;
13
+ export declare const safeTimezone: (tz: unknown) => string;
14
+ /** The bucket size to use: the requested one when it fits the range, otherwise one that does. */
15
+ export declare const pickUnit: (range: Range, requested?: unknown, now?: Date) => BucketUnit;
16
+ /** The bucket a moment falls in, as a string key. */
17
+ export declare const keyOf: (date: Date, unit: BucketUnit, tz: string) => string;
18
+ /** Every bucket key between the range's start and end, in order. */
19
+ export declare const bucketKeys: (range: Range, unit: BucketUnit, tz: string, now?: Date) => string[];
20
+ /** A short axis label for a bucket key. */
21
+ export declare const labelOf: (key: string, unit: BucketUnit, multiYear?: boolean) => string;
22
+ /** A MongoDB expression that yields the same bucket key keyOf produces, for a date field. */
23
+ export declare const groupKeyExpr: (unit: BucketUnit, tz: string, field?: string) => Record<string, unknown>;
24
+ /** Bucket keys, labels and the unit used, for a range. */
25
+ export declare const buildAxis: (range: Range, requested?: unknown, tzInput?: unknown, now?: Date) => {
26
+ tz: string;
27
+ unit: "day" | "month" | "hour" | "week";
28
+ keys: string[];
29
+ labels: string[];
30
+ };
31
+ export {};
32
+ //# sourceMappingURL=analyticsBuckets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyticsBuckets.d.ts","sourceRoot":"","sources":["../../src/helpers/analyticsBuckets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,KAAK,2CAA4C,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC;AAChD,KAAK,KAAK,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,CAAC;AAOnE,eAAO,MAAM,YAAY,GAAI,IAAI,OAAO,KAAG,MAQ1C,CAAC;AAQF,iGAAiG;AACjG,eAAO,MAAM,QAAQ,GAAI,OAAO,KAAK,EAAE,YAAY,OAAO,EAAE,UAAgB,KAAG,UAgB9E,CAAC;AAiBF,qDAAqD;AACrD,eAAO,MAAM,KAAK,GAAI,MAAM,IAAI,EAAE,MAAM,UAAU,EAAE,IAAI,MAAM,KAAG,MAUhE,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,UAAU,GAAI,OAAO,KAAK,EAAE,MAAM,UAAU,EAAE,IAAI,MAAM,EAAE,UAAgB,KAAG,MAAM,EAgB/F,CAAC;AAIF,2CAA2C;AAC3C,eAAO,MAAM,OAAO,GAAI,KAAK,MAAM,EAAE,MAAM,UAAU,EAAE,mBAAiB,KAAG,MAK1E,CAAC;AAEF,6FAA6F;AAC7F,eAAO,MAAM,YAAY,GAAI,MAAM,UAAU,EAAE,IAAI,MAAM,EAAE,cAAoB,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAavG,CAAC;AAEF,0DAA0D;AAC1D,eAAO,MAAM,SAAS,GAAI,OAAO,KAAK,EAAE,YAAY,OAAO,EAAE,UAAU,OAAO,EAAE,UAAgB;;;;;CAM/F,CAAC"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ /**
3
+ * Time buckets for the analytics charts (Ops and Client). The bucket size follows the selected date range (hourly
4
+ * for a day, daily for a week or month, weekly for a few months, monthly for a year) unless the caller asks for a
5
+ * specific one. Every bucket in the range is returned, so quiet periods show as zero instead of disappearing, and
6
+ * the keys built here match the keys MongoDB builds in groupKeyExpr.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.buildAxis = exports.groupKeyExpr = exports.labelOf = exports.bucketKeys = exports.keyOf = exports.pickUnit = exports.safeTimezone = exports.UNITS = void 0;
10
+ exports.UNITS = ["hour", "day", "week", "month"];
11
+ const MONTH_NAMES = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
12
+ const HOUR_MS = 3600 * 1000;
13
+ const DAY_MS = 24 * HOUR_MS;
14
+ const MAX_BUCKETS = 400;
15
+ const safeTimezone = (tz) => {
16
+ if (!tz || typeof tz !== "string")
17
+ return "UTC";
18
+ try {
19
+ new Intl.DateTimeFormat("en-US", { timeZone: tz });
20
+ return tz;
21
+ }
22
+ catch {
23
+ return "UTC";
24
+ }
25
+ };
26
+ exports.safeTimezone = safeTimezone;
27
+ const rangeBounds = (range, now = new Date()) => {
28
+ const end = range && range.$lte ? new Date(range.$lte) : now;
29
+ const start = range && range.$gte ? new Date(range.$gte) : new Date(end.getTime() - 30 * DAY_MS);
30
+ return { start, end };
31
+ };
32
+ /** The bucket size to use: the requested one when it fits the range, otherwise one that does. */
33
+ const pickUnit = (range, requested, now = new Date()) => {
34
+ const { start, end } = rangeBounds(range, now);
35
+ const spanDays = Math.max(0, (end.getTime() - start.getTime()) / DAY_MS);
36
+ let unit = exports.UNITS.includes(requested) ? requested : null;
37
+ if (!unit) {
38
+ if (spanDays <= 1.5)
39
+ unit = "hour";
40
+ else if (spanDays <= 62)
41
+ unit = "day";
42
+ else if (spanDays <= 190)
43
+ unit = "week";
44
+ else
45
+ unit = "month";
46
+ }
47
+ // Never return so many buckets that the chart becomes unreadable.
48
+ if (unit === "hour" && spanDays > 4)
49
+ unit = "day";
50
+ if (unit === "day" && spanDays > 200)
51
+ unit = "week";
52
+ if (unit === "week" && spanDays > 1100)
53
+ unit = "month";
54
+ return unit;
55
+ };
56
+ exports.pickUnit = pickUnit;
57
+ const pad = (n) => String(n).padStart(2, "0");
58
+ const localParts = (date, tz) => {
59
+ const parts = new Intl.DateTimeFormat("en-CA", {
60
+ timeZone: tz,
61
+ hourCycle: "h23",
62
+ year: "numeric",
63
+ month: "2-digit",
64
+ day: "2-digit",
65
+ hour: "2-digit",
66
+ }).formatToParts(date);
67
+ const get = (type) => Number(parts.find((p) => p.type === type).value);
68
+ return { y: get("year"), m: get("month"), d: get("day"), h: get("hour") % 24 };
69
+ };
70
+ /** The bucket a moment falls in, as a string key. */
71
+ const keyOf = (date, unit, tz) => {
72
+ const { y, m, d, h } = localParts(date, tz);
73
+ if (unit === "hour")
74
+ return `${y}-${pad(m)}-${pad(d)} ${pad(h)}`;
75
+ if (unit === "month")
76
+ return `${y}-${pad(m)}`;
77
+ if (unit === "week") {
78
+ const weekday = new Date(Date.UTC(y, m - 1, d)).getUTCDay(); // 0 = Sunday
79
+ const monday = new Date(Date.UTC(y, m - 1, d - ((weekday + 6) % 7)));
80
+ return `${monday.getUTCFullYear()}-${pad(monday.getUTCMonth() + 1)}-${pad(monday.getUTCDate())}`;
81
+ }
82
+ return `${y}-${pad(m)}-${pad(d)}`;
83
+ };
84
+ exports.keyOf = keyOf;
85
+ /** Every bucket key between the range's start and end, in order. */
86
+ const bucketKeys = (range, unit, tz, now = new Date()) => {
87
+ const { start, end } = rangeBounds(range, now);
88
+ const step = unit === "hour" ? HOUR_MS : unit === "month" ? DAY_MS : 12 * HOUR_MS;
89
+ const keys = [];
90
+ const seen = new Set();
91
+ for (let t = start.getTime(); t <= end.getTime() + step; t += step) {
92
+ const at = new Date(Math.min(t, end.getTime()));
93
+ const key = (0, exports.keyOf)(at, unit, tz);
94
+ if (!seen.has(key)) {
95
+ seen.add(key);
96
+ keys.push(key);
97
+ if (keys.length >= MAX_BUCKETS)
98
+ break;
99
+ }
100
+ if (t >= end.getTime())
101
+ break;
102
+ }
103
+ return keys;
104
+ };
105
+ exports.bucketKeys = bucketKeys;
106
+ const hourLabel = (h) => `${h % 12 === 0 ? 12 : h % 12} ${h < 12 ? "AM" : "PM"}`;
107
+ /** A short axis label for a bucket key. */
108
+ const labelOf = (key, unit, multiYear = false) => {
109
+ if (unit === "hour")
110
+ return hourLabel(Number(key.slice(11, 13)));
111
+ const [y, m, d] = key.split("-");
112
+ if (unit === "month")
113
+ return multiYear ? `${MONTH_NAMES[Number(m) - 1]} '${y.slice(2)}` : MONTH_NAMES[Number(m) - 1];
114
+ return `${MONTH_NAMES[Number(m) - 1]} ${Number(d)}`;
115
+ };
116
+ exports.labelOf = labelOf;
117
+ /** A MongoDB expression that yields the same bucket key keyOf produces, for a date field. */
118
+ const groupKeyExpr = (unit, tz, field = "$createdAt") => {
119
+ if (unit === "hour")
120
+ return { $dateToString: { format: "%Y-%m-%d %H", date: field, timezone: tz } };
121
+ if (unit === "month")
122
+ return { $dateToString: { format: "%Y-%m", date: field, timezone: tz } };
123
+ if (unit === "week") {
124
+ return {
125
+ $dateToString: {
126
+ format: "%Y-%m-%d",
127
+ date: { $dateTrunc: { date: field, unit: "week", startOfWeek: "monday", timezone: tz } },
128
+ timezone: tz,
129
+ },
130
+ };
131
+ }
132
+ return { $dateToString: { format: "%Y-%m-%d", date: field, timezone: tz } };
133
+ };
134
+ exports.groupKeyExpr = groupKeyExpr;
135
+ /** Bucket keys, labels and the unit used, for a range. */
136
+ const buildAxis = (range, requested, tzInput, now = new Date()) => {
137
+ const tz = (0, exports.safeTimezone)(tzInput);
138
+ const unit = (0, exports.pickUnit)(range, requested, now);
139
+ const keys = (0, exports.bucketKeys)(range, unit, tz, now);
140
+ const multiYear = keys.length > 1 && keys[0].slice(0, 4) !== keys[keys.length - 1].slice(0, 4);
141
+ return { tz, unit, keys, labels: keys.map((k) => (0, exports.labelOf)(k, unit, multiYear)) };
142
+ };
143
+ exports.buildAxis = buildAxis;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * What a chat carries besides text: the files the visitor shared, and the delivery status of every SMS an agent
3
+ * sent. Used by the Employee, Ops and Client backends, so all three dashboards show the same thing.
4
+ */
5
+ export declare const fileNameFromUrl: (url: string) => string;
6
+ export interface VisitorDocument {
7
+ id: string;
8
+ url: string;
9
+ name: string;
10
+ kind: string;
11
+ sharedAt: Date;
12
+ }
13
+ export interface SmsStatusRow {
14
+ id: number;
15
+ sid: string | null;
16
+ status: string;
17
+ from: string | null;
18
+ to: string | null;
19
+ sentAt: Date;
20
+ statusUpdatedAt: Date;
21
+ errorCode: string | number | null;
22
+ errorMessage: string | null;
23
+ preview: string;
24
+ }
25
+ /** Files the visitor shared in the chat, oldest first. */
26
+ export declare function getVisitorDocuments(chatId: unknown): Promise<VisitorDocument[]>;
27
+ /** Every SMS an agent sent in the chat, oldest first, each with its own running number. */
28
+ export declare function getSmsStatus(chatId: unknown): Promise<SmsStatusRow[]>;
29
+ export declare function getChatAttachments(chatId: unknown): Promise<{
30
+ documents: VisitorDocument[];
31
+ sms: SmsStatusRow[];
32
+ }>;
33
+ //# sourceMappingURL=chatAttachments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatAttachments.d.ts","sourceRoot":"","sources":["../../src/helpers/chatAttachments.ts"],"names":[],"mappings":"AAGA;;;GAGG;AAGH,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,KAAG,MAQ7C,CAAC;AAWF,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,MAAM,EAAE,IAAI,CAAC;IACb,eAAe,EAAE,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAClC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,0DAA0D;AAC1D,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAkBrF;AAED,2FAA2F;AAC3F,wBAAsB,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAoB3E;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,eAAe,EAAE,CAAC;IAAC,GAAG,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC,CAGxH"}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fileNameFromUrl = void 0;
4
+ exports.getVisitorDocuments = getVisitorDocuments;
5
+ exports.getSmsStatus = getSmsStatus;
6
+ exports.getChatAttachments = getChatAttachments;
7
+ const mongoose_1 = require("mongoose");
8
+ const message_model_1 = require("../models/message.model");
9
+ /**
10
+ * What a chat carries besides text: the files the visitor shared, and the delivery status of every SMS an agent
11
+ * sent. Used by the Employee, Ops and Client backends, so all three dashboards show the same thing.
12
+ */
13
+ // Files are stored as <folder>/<uuid>-<original name>; the uuid has five dash-separated parts.
14
+ const fileNameFromUrl = (url) => {
15
+ try {
16
+ const last = decodeURIComponent(new URL(url).pathname.split("/").pop() || "");
17
+ const parts = last.split("-");
18
+ return (parts.length > 5 ? parts.slice(5).join("-") : last) || "File";
19
+ }
20
+ catch {
21
+ return "File";
22
+ }
23
+ };
24
+ exports.fileNameFromUrl = fileNameFromUrl;
25
+ const kindOf = (mediaType, url) => {
26
+ if (mediaType)
27
+ return mediaType;
28
+ if (/\.(png|jpe?g|gif|webp|svg)(\?|$)/i.test(url))
29
+ return "image";
30
+ if (/\.pdf(\?|$)/i.test(url))
31
+ return "pdf";
32
+ if (/\.(mp4|webm|mov)(\?|$)/i.test(url))
33
+ return "video";
34
+ if (/\.(mp3|wav|ogg)(\?|$)/i.test(url))
35
+ return "audio";
36
+ return "file";
37
+ };
38
+ /** Files the visitor shared in the chat, oldest first. */
39
+ async function getVisitorDocuments(chatId) {
40
+ const rows = await message_model_1.Message.find({
41
+ chatId,
42
+ isDeleted: { $ne: true },
43
+ senderType: "VISITOR",
44
+ mediaUrl: { $exists: true, $nin: [null, ""] },
45
+ })
46
+ .sort({ createdAt: 1 })
47
+ .select("mediaUrl mediaType createdAt")
48
+ .lean();
49
+ return rows.map((m) => ({
50
+ id: String(m._id),
51
+ url: m.mediaUrl,
52
+ name: (0, exports.fileNameFromUrl)(m.mediaUrl),
53
+ kind: kindOf(m.mediaType, m.mediaUrl),
54
+ sharedAt: m.createdAt,
55
+ }));
56
+ }
57
+ /** Every SMS an agent sent in the chat, oldest first, each with its own running number. */
58
+ async function getSmsStatus(chatId) {
59
+ // `sms` is written by chat-service with the native driver, so it is read the same way.
60
+ const rows = await message_model_1.Message.collection
61
+ .find({ chatId: new mongoose_1.Types.ObjectId(String(chatId)), isDeleted: { $ne: true }, "sms.seq": { $exists: true } })
62
+ .sort({ createdAt: 1 })
63
+ .project({ sms: 1, content: 1, createdAt: 1 })
64
+ .toArray();
65
+ return rows.map((m) => ({
66
+ id: m.sms.seq,
67
+ sid: m.sms.sid || null,
68
+ status: m.sms.status || "queued",
69
+ from: m.sms.from || null,
70
+ to: m.sms.to || null,
71
+ sentAt: m.createdAt,
72
+ statusUpdatedAt: m.sms.statusUpdatedAt || m.createdAt,
73
+ errorCode: m.sms.errorCode || null,
74
+ errorMessage: m.sms.errorMessage || null,
75
+ preview: String(m.content || "").replace(/<[^>]*>/g, " ").replace(/\s+/g, " ").trim().slice(0, 120),
76
+ }));
77
+ }
78
+ async function getChatAttachments(chatId) {
79
+ const [documents, sms] = await Promise.all([getVisitorDocuments(chatId), getSmsStatus(chatId)]);
80
+ return { documents, sms };
81
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * One error type and one Express error handler for every backend (Employee, Ops, Client, Partner). A backend's
3
+ * utils/app-error.js re-exports AppError, and its controllers/error.controller.js is
4
+ * module.exports = createErrorHandler({ development: <this backend's env says development> });
5
+ */
6
+ /** An expected error the caller should see: its message goes back as-is with its HTTP status. */
7
+ export declare class AppError extends Error {
8
+ statusCode: number;
9
+ success: boolean;
10
+ isOperational: boolean;
11
+ /** Optional machine-readable code and details, sent to the client when set. */
12
+ code?: string;
13
+ details?: unknown;
14
+ constructor(message: string, statusCode: number, extra?: {
15
+ code?: string;
16
+ details?: unknown;
17
+ });
18
+ }
19
+ /**
20
+ * The global error handler. In development the full error goes back; anywhere else (production, staging, or an
21
+ * environment name the backend doesn't set) known errors get a clean message and anything unexpected a generic 500.
22
+ * Before this was shared, a backend whose environment was neither "development" nor "production" never answered.
23
+ */
24
+ export declare function createErrorHandler({ development }: {
25
+ development: boolean | (() => boolean);
26
+ }): (err: any, _req: any, res: any, _next: any) => void;
27
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/helpers/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,iGAAiG;AACjG,qBAAa,QAAS,SAAQ,KAAK;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,UAAS;IAChB,aAAa,UAAQ;IACrB,+EAA+E;IAC/E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;gBAEN,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;CAO9F;AAyDD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,WAAW,EAAE,EAAE;IAAE,WAAW,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,CAAA;CAAE,IAIpF,KAAK,GAAG,EAAE,MAAM,GAAG,EAAE,KAAK,GAAG,EAAE,OAAO,GAAG,UAelD"}
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ /**
3
+ * One error type and one Express error handler for every backend (Employee, Ops, Client, Partner). A backend's
4
+ * utils/app-error.js re-exports AppError, and its controllers/error.controller.js is
5
+ * module.exports = createErrorHandler({ development: <this backend's env says development> });
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.AppError = void 0;
9
+ exports.createErrorHandler = createErrorHandler;
10
+ /** An expected error the caller should see: its message goes back as-is with its HTTP status. */
11
+ class AppError extends Error {
12
+ constructor(message, statusCode, extra) {
13
+ super(message);
14
+ this.success = false;
15
+ this.isOperational = true;
16
+ this.statusCode = statusCode;
17
+ if (extra === null || extra === void 0 ? void 0 : extra.code)
18
+ this.code = extra.code;
19
+ if ((extra === null || extra === void 0 ? void 0 : extra.details) !== undefined)
20
+ this.details = extra.details;
21
+ Error.captureStackTrace(this, this.constructor);
22
+ }
23
+ }
24
+ exports.AppError = AppError;
25
+ const BAD_REQUEST = 400;
26
+ const UNAUTHORIZED = 401;
27
+ const CONFLICT = 409;
28
+ const INTERNAL = 500;
29
+ // Invalid field value (e.g. a malformed id)
30
+ const handleCastErrorDB = (err) => new AppError(`Invalid ${err.path} : ${err.value}`, BAD_REQUEST);
31
+ // Duplicate key
32
+ const handleDuplicateFieldsDB = (err) => {
33
+ const key = Object.keys(err.keyValue || {})[0];
34
+ return new AppError(`${key} already exists, try another value.`, CONFLICT);
35
+ };
36
+ // Schema validation
37
+ const handleValidationErrorDB = (err) => {
38
+ const errors = Object.values(err.errors || {}).map((el) => el.message);
39
+ return new AppError(`Invalid input data. ${errors.join(". ")}`, BAD_REQUEST);
40
+ };
41
+ const handleJWTError = () => new AppError("Invalid token. Login again", UNAUTHORIZED);
42
+ const handleJWTExpireError = () => new AppError("Your token has been expired! please log in again", UNAUTHORIZED);
43
+ // File uploads (multer)
44
+ const handleMulterError = (err) => {
45
+ if (err.code === "LIMIT_UNEXPECTED_FILE")
46
+ return new AppError("Upload limit reached or invalid field name.", BAD_REQUEST);
47
+ if (err.code === "LIMIT_FILE_SIZE") {
48
+ return new AppError("File size limit exceeded. Maximum allowed size is 10 MB per file.", BAD_REQUEST);
49
+ }
50
+ return err;
51
+ };
52
+ const devError = (err, res) => {
53
+ res.status(err.statusCode).json({
54
+ success: err.success,
55
+ error: err,
56
+ message: err.message,
57
+ stack: err.stack,
58
+ });
59
+ };
60
+ const prodError = (err, res) => {
61
+ if (err.isOperational) {
62
+ res.status(err.statusCode).json({
63
+ success: err.success,
64
+ message: err.message,
65
+ ...(err.code && { error: { code: err.code, ...(err.details && { details: err.details }) } }),
66
+ });
67
+ }
68
+ else {
69
+ console.error("ERROR", err);
70
+ res.status(INTERNAL).json({ success: false, message: "Something went wrong!" });
71
+ }
72
+ };
73
+ /**
74
+ * The global error handler. In development the full error goes back; anywhere else (production, staging, or an
75
+ * environment name the backend doesn't set) known errors get a clean message and anything unexpected a generic 500.
76
+ * Before this was shared, a backend whose environment was neither "development" nor "production" never answered.
77
+ */
78
+ function createErrorHandler({ development }) {
79
+ const isDev = () => (typeof development === "function" ? development() : development);
80
+ // Express recognises an error handler by its four arguments.
81
+ return (err, _req, res, _next) => {
82
+ err.statusCode = err.statusCode || INTERNAL;
83
+ err.success = err.success || false;
84
+ if (isDev())
85
+ return devError(err, res);
86
+ let error = { ...err, message: err.message };
87
+ if (err.name === "CastError")
88
+ error = handleCastErrorDB(error);
89
+ if (err.code === 11000)
90
+ error = handleDuplicateFieldsDB(error);
91
+ if (err.name === "ValidationError")
92
+ error = handleValidationErrorDB(error);
93
+ if (err.name === "JsonWebTokenError")
94
+ error = handleJWTError();
95
+ if (err.name === "TokenExpiredError")
96
+ error = handleJWTExpireError();
97
+ if (err.name === "MulterError")
98
+ error = handleMulterError(error);
99
+ prodError(error, res);
100
+ };
101
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * List endpoints' ?filter / ?sort / ?fields / ?page&limit handling, for every backend. Two styles, because the
3
+ * dashboards send different kinds of filters:
4
+ * - "search" (Ops, Employee): text fields match case-insensitively ("a,b" = either), numbers take "gte:5",
5
+ * id fields must be valid ids, and it also works on aggregation pipelines.
6
+ * - "exact" (Client, Partner): exact matches, "field[gte]=..." ranges and createdAt dates.
7
+ * A backend's utils/api-features.js is `module.exports = createListQuery({ style, ... })`, so its routes keep
8
+ * calling `new APIFeatures(query, req.query).filter().sort().limitFields().paginate(total)`.
9
+ */
10
+ export type ListQueryStyle = "search" | "exact";
11
+ export interface ListQueryOptions {
12
+ style: ListQueryStyle;
13
+ /** A filter from the query string may narrow a list but never replace a condition the route already set
14
+ * (Mongoose's find() overwrites same-named keys, so ?companyId=<another id> would swap in someone else's). Top-level
15
+ * $ operators are never taken from the URL either. Only applies to find() queries. */
16
+ lockBaseFilter: boolean;
17
+ /** Page size when ?limit isn't given. */
18
+ defaultLimit: number;
19
+ }
20
+ export declare function createListQuery(options: ListQueryOptions): {
21
+ new (query: any, queryString: any): {
22
+ query: any;
23
+ queryString: any;
24
+ paginationResult?: {
25
+ total: number;
26
+ currentPage: number;
27
+ totalPages: number;
28
+ };
29
+ filter(): /*elided*/ any;
30
+ sort(): /*elided*/ any;
31
+ limitFields(): /*elided*/ any;
32
+ paginate(totalDocuments: number): /*elided*/ any;
33
+ };
34
+ };
35
+ //# sourceMappingURL=listQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listQuery.d.ts","sourceRoot":"","sources":["../../src/helpers/listQuery.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEhD,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,cAAc,CAAC;IACtB;;2FAEuF;IACvF,cAAc,EAAE,OAAO,CAAC;IACxB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;CACtB;AAsGD,wBAAgB,eAAe,CAAC,OAAO,EAAE,gBAAgB;gBAQlC,GAAG,eAAe,GAAG;eAJjC,GAAG;qBACG,GAAG;2BACG;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,WAAW,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE;;;;iCAqDpD,MAAM;;EAmBlC"}
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createListQuery = createListQuery;
4
+ const mongoose_1 = require("mongoose");
5
+ const PAGING_KEYS = ["page", "sort", "limit", "fields"];
6
+ // "a,b" -> any of them, case-insensitive; one value -> contains, case-insensitive. Empty -> drop the filter.
7
+ const textMatch = (value) => {
8
+ if (!value.includes(","))
9
+ return new RegExp(value, "i");
10
+ const values = value.split(",").map((v) => v.trim()).filter(Boolean);
11
+ return values.length ? { $in: values.map((v) => new RegExp(v, "i")) } : undefined;
12
+ };
13
+ function searchFilter(query, queryObj) {
14
+ var _a, _b;
15
+ for (const key in queryObj) {
16
+ const fieldType = (_b = (_a = query === null || query === void 0 ? void 0 : query.schema) === null || _a === void 0 ? void 0 : _a.paths[key]) === null || _b === void 0 ? void 0 : _b.instance;
17
+ let value = queryObj[key];
18
+ if (typeof value !== "string") {
19
+ delete queryObj[key];
20
+ continue;
21
+ }
22
+ if (value === "true")
23
+ value = true;
24
+ else if (value === "false")
25
+ value = false;
26
+ if (fieldType === "Boolean") {
27
+ queryObj[key] = value;
28
+ }
29
+ else if (fieldType === "ObjectId") {
30
+ if (mongoose_1.Types.ObjectId.isValid(value))
31
+ queryObj[key] = new mongoose_1.Types.ObjectId(value);
32
+ else
33
+ delete queryObj[key];
34
+ }
35
+ else if (fieldType === "Number") {
36
+ if (typeof value !== "string") {
37
+ delete queryObj[key]; // "true"/"false" on a number field (it used to crash the request)
38
+ }
39
+ else if (value.includes(":")) {
40
+ const [operator, val] = value.split(":");
41
+ if (["gte", "gt", "lte", "lt"].includes(operator) && !isNaN(val)) {
42
+ queryObj[key] = { [`$${operator}`]: parseFloat(val) };
43
+ }
44
+ else {
45
+ delete queryObj[key];
46
+ }
47
+ }
48
+ else if (!isNaN(value)) {
49
+ queryObj[key] = parseFloat(value);
50
+ }
51
+ else {
52
+ delete queryObj[key];
53
+ }
54
+ }
55
+ else {
56
+ // String fields and anything the schema doesn't describe (e.g. aggregation pipelines).
57
+ if (typeof value !== "string") {
58
+ queryObj[key] = value; // "true"/"false" on a non-Boolean field
59
+ continue;
60
+ }
61
+ const m = textMatch(value);
62
+ if (m)
63
+ queryObj[key] = m;
64
+ else
65
+ delete queryObj[key];
66
+ }
67
+ }
68
+ }
69
+ function exactFilter(query, queryObj) {
70
+ const schema = query.model.schema;
71
+ Object.keys(queryObj).forEach((key) => {
72
+ var _a;
73
+ const value = queryObj[key];
74
+ if (value === "true") {
75
+ queryObj[key] = true;
76
+ return;
77
+ }
78
+ if (value === "false") {
79
+ queryObj[key] = false;
80
+ return;
81
+ }
82
+ const match = key.match(/^(.+)\[(gte|gt|lte|lt)\]$/);
83
+ if (match) {
84
+ const field = match[1];
85
+ const operator = match[2];
86
+ let val = queryObj[key];
87
+ if (field === "createdAt" && typeof val === "string") {
88
+ if (val.match(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\s00:00$/)) {
89
+ val = val.replace(/\s00:00$/, "Z");
90
+ }
91
+ val = new Date(val);
92
+ }
93
+ if (!queryObj[field])
94
+ queryObj[field] = {};
95
+ queryObj[field][`$${operator}`] = val;
96
+ delete queryObj[key];
97
+ return;
98
+ }
99
+ const fieldType = (_a = schema.paths[key]) === null || _a === void 0 ? void 0 : _a.instance;
100
+ if (typeof value !== "string" || key.startsWith("$"))
101
+ return;
102
+ if (fieldType === "Number") {
103
+ if (!/^(gte|gt|lte|lt):/.test(value) && isNaN(value))
104
+ delete queryObj[key];
105
+ }
106
+ });
107
+ }
108
+ function createListQuery(options) {
109
+ const { style, lockBaseFilter, defaultLimit } = options;
110
+ return class APIFeatures {
111
+ constructor(query, queryString) {
112
+ this.query = query;
113
+ this.queryString = queryString;
114
+ }
115
+ filter() {
116
+ const queryObj = { ...this.queryString };
117
+ PAGING_KEYS.forEach((el) => delete queryObj[el]);
118
+ if (style === "search")
119
+ searchFilter(this.query, queryObj);
120
+ else
121
+ exactFilter(this.query, queryObj);
122
+ if (lockBaseFilter && typeof this.query.getFilter === "function") {
123
+ const fixed = this.query.getFilter();
124
+ Object.keys(queryObj).forEach((key) => {
125
+ if (key.startsWith("$") || Object.prototype.hasOwnProperty.call(fixed, key))
126
+ delete queryObj[key];
127
+ });
128
+ }
129
+ if (typeof this.query.find === "function") {
130
+ this.query = this.query.find(queryObj);
131
+ }
132
+ else if (typeof this.query.match === "function") {
133
+ this.query.match(queryObj);
134
+ }
135
+ return this;
136
+ }
137
+ sort() {
138
+ const sortBy = this.queryString.sort ? String(this.queryString.sort).split(",").join(" ") : "-createdAt";
139
+ this.query = this.query.sort(sortBy);
140
+ return this;
141
+ }
142
+ limitFields() {
143
+ if (this.queryString.fields) {
144
+ const fields = String(this.queryString.fields).split(",").join(" ");
145
+ if (typeof this.query.select === "function") {
146
+ this.query = this.query.select(fields);
147
+ }
148
+ else if (typeof this.query.project === "function") {
149
+ const projection = {};
150
+ fields.split(" ").forEach((f) => (projection[f] = 1));
151
+ this.query.project(projection);
152
+ }
153
+ }
154
+ else if (typeof this.query.select === "function") {
155
+ this.query = this.query.select("-__v");
156
+ }
157
+ else if (typeof this.query.project === "function") {
158
+ this.query.project({ __v: 0 });
159
+ }
160
+ return this;
161
+ }
162
+ paginate(totalDocuments) {
163
+ const page = this.queryString.page * 1 || 1;
164
+ const limit = this.queryString.limit * 1 || defaultLimit;
165
+ const skip = (page - 1) * limit;
166
+ if (typeof this.query.skip === "function") {
167
+ this.query = this.query.skip(skip).limit(limit);
168
+ }
169
+ else if (typeof this.query.append === "function") {
170
+ this.query.append([{ $skip: skip }, { $limit: limit }]);
171
+ }
172
+ this.paginationResult = {
173
+ total: totalDocuments,
174
+ currentPage: page,
175
+ totalPages: Math.ceil(totalDocuments / limit),
176
+ };
177
+ return this;
178
+ }
179
+ };
180
+ }
package/dist/index.d.ts CHANGED
@@ -105,4 +105,9 @@ import { resolveEffectivePermissions, hasPermission, validateGrantedKeys, valida
105
105
  import { roleSeeds, RoleSeed } from "./permissions/seeds/roles.seed";
106
106
  export { Chat, Message, User, Vertical, Macro, Partner, Company, CompanySettings, Review, Wallet, StripeLog, Transaction, Lead, TierConfig, TierProgress, MonthlyTierSnapshot, Product, Plan, PlanOption, Addon, Subscription, Coupon, Visitor, Group, Agent, LeadLedger, Invoice, LeadDispute, Session, LoginOtp, Counter, Employee, CallSession, Request, REQUEST_CATEGORIES, REQUEST_SUBCATEGORIES_BY_CATEGORY, Ticket, EmailSenderMap, CLIENT_TICKET_CATEGORIES, CLIENT_TICKET_CATEGORIES_LEGACY, PARTNER_TICKET_CATEGORIES, PARTNER_TICKET_CATEGORIES_LEGACY, CLIENT_TICKET_CATEGORY_OPTIONS, PARTNER_TICKET_CATEGORY_OPTIONS, CLIENT_TICKET_CATEGORY_OPTIONS_LEGACY, PARTNER_TICKET_CATEGORY_OPTIONS_LEGACY, ALL_TICKET_CATEGORY_OPTIONS, findTicketCategoryOption, EDITABLE_SUBCATEGORY_KEYS, applySubCategoryOverrides, TicketSubCategoryOverride, TICKET_STATUS_CLIENT_VIEW, sanitizeTicketForRequester, Role, AiSummarySettings, AiSummaryUsage, RetainerContract, Retainer, AppointmentCalendar, Appointment, ActivityLog, recordActivity, activityRecorder, clientIp, AuditTask, Update, updateEvents, resolveTicketRouting, pickFromGroup, OPEN_TICKET_STATUSES, SCRIPT_ANSWER_FIELDS, opsTree, employeeTree, partnerTree, clientTree, DASHBOARDS, getTree, getAllKeys, getParentKey, getAncestorKeys, resolveEffectivePermissions, hasPermission, validateGrantedKeys, validateExtraKeys, getFullAccessKeys, roleSeeds, };
107
107
  export type { IChat, ScriptAnswerField, IMessage, IUser, IVertical, IMacro, IPartner, ICompany, IOnboardingStep, ITwilioConfig, ICompanySettings, ICallConnectSettings, ILeadConfig, ILeadFields, IRetainerConfig, IReview, IReviewStatusHistoryEntry, IWallet, IStripeLog, ITransaction, ILead, ITierConfig, ITierProgress, IMonthlyTierSnapshot, IProduct, IPlan, IPlanOption, IAddon, ISubscription, ICoupon, CouponDiscountType, IVisitor, IGroup, IAgent, ILeadLedger, IInvoice, ILeadDispute, ISession, ILoginOtp, IEmployee, ICallSession, CallSessionStatus, CallSessionDirection, IRequest, IRequestAttachment, IRequestMessage, IRequestActivityEntry, IRequestField, RequestCategory, RequestStatus, ITicket, ITicketAttachment, ITicketActivityEntry, ITicketMessage, IEmailSenderMap, TicketCategory, ClientTicketCategory, ClientTicketCategoryLegacy, PartnerTicketCategory, PartnerTicketCategoryLegacy, TicketCategoryOption, TicketSubCategoryOption, TicketOwnerType, TicketSource, TicketStatus, TicketPriority, ITicketSubCategoryOverride, IRole, IAiSummarySettings, IAiSummaryExample, IAiSummaryUsage, IRetainerContract, IRetainerContractField, IRetainer, IRetainerFieldValue, RetainerProvider, RetainerContractStatus, RetainerStatus, RetainerDeliveryMode, IAppointmentCalendar, IAppointment, AppointmentCalendarStatus, AppointmentStatus, IActivityLog, IActivityChange, ActivityActorKind, ActivityDashboard, ActivityOutcome, ActivityEntry, ActivityRule, ActivityActor, ActivityContext, ActivityRecorderOptions, AiSummaryLength, IAuditTask, AuditTaskType, AuditTaskStatus, ILeadAudit, LeadAuditDecision, LeadAuditReviewStatus, IUpdate, UpdateDashboard, UpdateAudience, UpdateType, TicketRoutingInput, TicketRoutingResult, Dashboard, PermissionNode, PermissionSource, ValidationResult, RoleSeed, };
108
+ export * from "./helpers/errors";
109
+ export * from "./helpers/listQuery";
110
+ export * from "./helpers/chatAttachments";
111
+ export * from "./helpers/addonState";
112
+ export * from "./helpers/analyticsBuckets";
108
113
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OA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,KAAK,EACL,WAAW,EACX,aAAa,EACb,oBAAoB,EACpB,QAAQ,EACR,KAAK,EACL,WAAW,EACX,MAAM,EACN,aAAa,EACb,OAAO,EACP,kBAAkB,EAClB,QAAQ,EACR,MAAM,EACN,MAAM,EACN,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,SAAS,EACT,YAAY,EACZ,iBAAiB,EACjB,oBAAoB,EACpB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,qBAAqB,EACrB,aAAa,EACb,eAAe,EACf,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,0BAA0B,EAC1B,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,uBAAuB,EACvB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,0BAA0B,EAC1B,KAAK,EACL,kBAAkB,EAClB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,SAAS,EACT,mBAAmB,EACnB,gBAAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,yBAAyB,EACzB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,eAAe,EACf,UAAU,EACV,aAAa,EACb,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,OAAO,EACP,eAAe,EACf,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,GACT,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EA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AAgB,EAChB,sBAAsB,EACtB,cAAc,EACd,oBAAoB,EACpB,oBAAoB,EACpB,YAAY,EACZ,yBAAyB,EACzB,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,YAAY,EACZ,aAAa,EACb,eAAe,EACf,uBAAuB,EACvB,eAAe,EACf,UAAU,EACV,aAAa,EACb,eAAe,EACf,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,OAAO,EACP,eAAe,EACf,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,GACT,CAAC;AAIF,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,18 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.applySubCategoryOverrides = exports.EDITABLE_SUBCATEGORY_KEYS = exports.findTicketCategoryOption = exports.ALL_TICKET_CATEGORY_OPTIONS = exports.PARTNER_TICKET_CATEGORY_OPTIONS_LEGACY = exports.CLIENT_TICKET_CATEGORY_OPTIONS_LEGACY = exports.PARTNER_TICKET_CATEGORY_OPTIONS = exports.CLIENT_TICKET_CATEGORY_OPTIONS = exports.PARTNER_TICKET_CATEGORIES_LEGACY = exports.PARTNER_TICKET_CATEGORIES = exports.CLIENT_TICKET_CATEGORIES_LEGACY = exports.CLIENT_TICKET_CATEGORIES = exports.EmailSenderMap = exports.Ticket = exports.REQUEST_SUBCATEGORIES_BY_CATEGORY = exports.REQUEST_CATEGORIES = exports.Request = exports.CallSession = exports.Employee = exports.Counter = exports.LoginOtp = exports.Session = exports.LeadDispute = exports.Invoice = exports.LeadLedger = exports.Agent = exports.Group = exports.Visitor = exports.Coupon = exports.Subscription = exports.Addon = exports.PlanOption = exports.Plan = exports.Product = exports.MonthlyTierSnapshot = exports.TierProgress = exports.TierConfig = exports.Lead = exports.Transaction = exports.StripeLog = exports.Wallet = exports.Review = exports.CompanySettings = exports.Company = exports.Partner = exports.Macro = exports.Vertical = exports.User = exports.Message = exports.Chat = void 0;
4
18
  exports.roleSeeds = exports.getFullAccessKeys = exports.validateExtraKeys = exports.validateGrantedKeys = exports.hasPermission = exports.resolveEffectivePermissions = exports.getAncestorKeys = exports.getParentKey = exports.getAllKeys = exports.getTree = exports.DASHBOARDS = exports.clientTree = exports.partnerTree = exports.employeeTree = exports.opsTree = exports.SCRIPT_ANSWER_FIELDS = exports.OPEN_TICKET_STATUSES = exports.pickFromGroup = exports.resolveTicketRouting = exports.updateEvents = exports.Update = exports.AuditTask = exports.clientIp = exports.activityRecorder = exports.recordActivity = exports.ActivityLog = exports.Appointment = exports.AppointmentCalendar = exports.Retainer = exports.RetainerContract = exports.AiSummaryUsage = exports.AiSummarySettings = exports.Role = exports.sanitizeTicketForRequester = exports.TICKET_STATUS_CLIENT_VIEW = exports.TicketSubCategoryOverride = void 0;
@@ -153,3 +167,9 @@ Object.defineProperty(exports, "validateExtraKeys", { enumerable: true, get: fun
153
167
  Object.defineProperty(exports, "getFullAccessKeys", { enumerable: true, get: function () { return resolve_1.getFullAccessKeys; } });
154
168
  const roles_seed_1 = require("./permissions/seeds/roles.seed");
155
169
  Object.defineProperty(exports, "roleSeeds", { enumerable: true, get: function () { return roles_seed_1.roleSeeds; } });
170
+ // Helpers shared by the backends (each used to keep its own copy).
171
+ __exportStar(require("./helpers/errors"), exports);
172
+ __exportStar(require("./helpers/listQuery"), exports);
173
+ __exportStar(require("./helpers/chatAttachments"), exports);
174
+ __exportStar(require("./helpers/addonState"), exports);
175
+ __exportStar(require("./helpers/analyticsBuckets"), exports);
@@ -7,6 +7,8 @@ export interface IAgent extends Document {
7
7
  email: string;
8
8
  username: string;
9
9
  password: string;
10
+ /** Public URL of the agent's own profile photo (S3). Internal only -- never shown to chat visitors. */
11
+ profilePicture?: string | null;
10
12
  role: AgentRole;
11
13
  groupId?: Schema.Types.ObjectId | null;
12
14
  groupIds?: Schema.Types.ObjectId[];
@@ -1 +1 @@
1
- {"version":3,"file":"agent.interface.d.ts","sourceRoot":"","sources":["../../src/interfaces/agent.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAE5C,KAAK,SAAS,GAAG,YAAY,GAAG,iBAAiB,GAAG,OAAO,CAAC;AAC5D,KAAK,aAAa,GAAG,MAAM,CAAC;AAC5B,KAAK,cAAc,GAAG,WAAW,GAAG,MAAM,CAAC;AAE3C,MAAM,WAAW,MAAO,SAAQ,QAAQ;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;IACnC,aAAa,E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,CAAC;IACjD,UAAU,EAAE,OAAO,CAAC;CACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"agent.model.d.ts","sourceRoot":"","sources":["../../src/models/agent.model.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAU,KAAK,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAC,MAAM,EAAC,MAAM,+BAA+B,CAAC;AAsKrD,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,MAAM,CAAgD,CAAC;AACjF,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"agent.model.d.ts","sourceRoot":"","sources":["../../src/models/agent.model.ts"],"names":[],"mappings":"AAEA,OAAiB,EAAU,KAAK,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAC,MAAM,EAAC,MAAM,+BAA+B,CAAC;AA4KrD,eAAO,MAAM,KAAK,EAAE,KAAK,CAAC,MAAM,CAAgD,CAAC;AACjF,eAAe,KAAK,CAAC"}
@@ -60,6 +60,12 @@ const agentSchema = new mongoose_1.Schema({
60
60
  trim: true,
61
61
  index: true,
62
62
  },
63
+ // The agent's own profile photo (public S3 URL). Internal only -- the
64
+ // chat widget shows the alias, never this.
65
+ profilePicture: {
66
+ type: String,
67
+ default: null,
68
+ },
63
69
  password: {
64
70
  type: String,
65
71
  required: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orbitx-core-models",
3
- "version": "11.173.0",
3
+ "version": "11.175.0",
4
4
  "description": "Shared Mongoose models and interfaces for OrbitX services",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",