@blazeo.com/calendar-client 1.0.56 → 1.0.57
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/index.d.ts +80 -0
- package/dist/index.js +179 -15
- package/dist/index.mjs +175 -14
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -335,6 +335,77 @@ export const FlowModel: {
|
|
|
335
335
|
create(snapshot?: FlowSnapshot, options?: { env?: object }): unknown;
|
|
336
336
|
};
|
|
337
337
|
|
|
338
|
+
export type ActivityLogSearchResult = {
|
|
339
|
+
activityLogs: unknown[];
|
|
340
|
+
totalCount: number;
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export type ActivityLogSnapshot = {
|
|
344
|
+
id?: number | null;
|
|
345
|
+
activityLogId?: string;
|
|
346
|
+
leadId?: string | null;
|
|
347
|
+
eventId?: string | null;
|
|
348
|
+
activityTypeId?: number;
|
|
349
|
+
activityTypeName?: string;
|
|
350
|
+
categoryId?: number;
|
|
351
|
+
categoryName?: string;
|
|
352
|
+
isPartialData?: boolean;
|
|
353
|
+
userEmail?: string;
|
|
354
|
+
createdOn?: string | null;
|
|
355
|
+
data?: Record<string, string>;
|
|
356
|
+
activityLogDetails?: Array<{ key?: string; value?: string }>;
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
export const ActivityLogModel: {
|
|
360
|
+
get(opts: {
|
|
361
|
+
companyKey: string;
|
|
362
|
+
company_key?: string;
|
|
363
|
+
leadId?: string;
|
|
364
|
+
lead_id?: string;
|
|
365
|
+
eventId?: string;
|
|
366
|
+
event_id?: string;
|
|
367
|
+
activityTypeId?: number | string | number[];
|
|
368
|
+
activity_type_id?: number | string | number[];
|
|
369
|
+
activityTypeIds?: number | string | number[];
|
|
370
|
+
userEmail?: string;
|
|
371
|
+
user_email?: string;
|
|
372
|
+
fromDate?: string;
|
|
373
|
+
from_date?: string;
|
|
374
|
+
toDate?: string;
|
|
375
|
+
to_date?: string;
|
|
376
|
+
sortBy?: string;
|
|
377
|
+
sort?: string;
|
|
378
|
+
sort_column?: string;
|
|
379
|
+
sortOrder?: 'ASC' | 'DESC' | 'asc' | 'desc' | string;
|
|
380
|
+
sort_dir?: 'asc' | 'desc' | string;
|
|
381
|
+
searchColumn?: string;
|
|
382
|
+
search_column?: string;
|
|
383
|
+
column?: string;
|
|
384
|
+
searchText?: string;
|
|
385
|
+
search_text?: string;
|
|
386
|
+
search?: string;
|
|
387
|
+
filters?: Array<{
|
|
388
|
+
column?: string;
|
|
389
|
+
searchColumn?: string;
|
|
390
|
+
search_column?: string;
|
|
391
|
+
text?: string;
|
|
392
|
+
searchText?: string;
|
|
393
|
+
search_text?: string;
|
|
394
|
+
search?: string;
|
|
395
|
+
}>;
|
|
396
|
+
page?: number;
|
|
397
|
+
pageSize?: number;
|
|
398
|
+
page_size?: number;
|
|
399
|
+
skip?: number;
|
|
400
|
+
take?: number;
|
|
401
|
+
}): Promise<ActivityLogSearchResult | { status: 'failure'; message: string } | null>;
|
|
402
|
+
getByCompany(
|
|
403
|
+
companyKey: string,
|
|
404
|
+
opts?: Omit<Parameters<typeof ActivityLogModel.get>[0], 'companyKey'>
|
|
405
|
+
): Promise<ActivityLogSearchResult | { status: 'failure'; message: string } | null>;
|
|
406
|
+
create(snapshot?: ActivityLogSnapshot, options?: { env?: object }): unknown;
|
|
407
|
+
};
|
|
408
|
+
|
|
338
409
|
export const LeadModel: {
|
|
339
410
|
getRaw(leadId: string): Promise<{ status: string; data?: unknown; message?: string }>;
|
|
340
411
|
get(leadId: string): Promise<unknown>;
|
|
@@ -567,3 +638,12 @@ export const RecurringFrequency: Record<string, number>;
|
|
|
567
638
|
export const DayOfWeek: Record<string, number>;
|
|
568
639
|
export const LocationType: Record<string, number>;
|
|
569
640
|
export const EmailProvider: Record<string, number>;
|
|
641
|
+
export const CalendarVisibility: Record<string, number>;
|
|
642
|
+
export const ActivityLogType: {
|
|
643
|
+
AppointmentScheduled: 9;
|
|
644
|
+
AppointmentRescheduled: 10;
|
|
645
|
+
AppointmentCanceled: 11;
|
|
646
|
+
};
|
|
647
|
+
export const ActivityLogCategory: {
|
|
648
|
+
Appointments: 3;
|
|
649
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
// src/models/appointment/index.js
|
|
20
20
|
var index_exports = {};
|
|
21
21
|
__export(index_exports, {
|
|
22
|
+
ActivityLogCategory: () => ActivityLogCategory,
|
|
23
|
+
ActivityLogModel: () => ActivityLog_default,
|
|
24
|
+
ActivityLogType: () => ActivityLogType,
|
|
22
25
|
AssetModel: () => Asset_default,
|
|
23
26
|
AssignmentMethod: () => AssignmentMethod,
|
|
24
27
|
AttendeeStatus: () => AttendeeStatus,
|
|
@@ -383,6 +386,14 @@ var CalendarVisibility = {
|
|
|
383
386
|
Public: 0,
|
|
384
387
|
Private: 1
|
|
385
388
|
};
|
|
389
|
+
var ActivityLogType = {
|
|
390
|
+
AppointmentScheduled: 9,
|
|
391
|
+
AppointmentRescheduled: 10,
|
|
392
|
+
AppointmentCanceled: 11
|
|
393
|
+
};
|
|
394
|
+
var ActivityLogCategory = {
|
|
395
|
+
Appointments: 3
|
|
396
|
+
};
|
|
386
397
|
|
|
387
398
|
// src/models/appointment/Event.js
|
|
388
399
|
var import_mobx_state_tree4 = require("mobx-state-tree");
|
|
@@ -2978,20 +2989,170 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2978
2989
|
};
|
|
2979
2990
|
var Lead_default = LeadModel;
|
|
2980
2991
|
|
|
2981
|
-
// src/models/appointment/
|
|
2992
|
+
// src/models/appointment/ActivityLog.js
|
|
2982
2993
|
var import_mobx_state_tree21 = require("mobx-state-tree");
|
|
2983
|
-
var
|
|
2994
|
+
var ActivityLogDetailModel = import_mobx_state_tree21.types.model("ActivityLogDetail", {
|
|
2995
|
+
key: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, ""),
|
|
2996
|
+
value: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, "")
|
|
2997
|
+
});
|
|
2998
|
+
function mapActivityLogFromApi(d) {
|
|
2999
|
+
if (!d) return d;
|
|
3000
|
+
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
3001
|
+
const detailsRaw = pick2("activityLogDetails", "ActivityLogDetails");
|
|
3002
|
+
const details = Array.isArray(detailsRaw) ? detailsRaw.map((row) => ({
|
|
3003
|
+
key: pickDetail(row, "key", "Key") ?? "",
|
|
3004
|
+
value: pickDetail(row, "value", "Value") ?? ""
|
|
3005
|
+
})) : [];
|
|
3006
|
+
const dataRaw = pick2("data", "Data");
|
|
3007
|
+
const data = dataRaw && typeof dataRaw === "object" && !Array.isArray(dataRaw) ? { ...dataRaw } : details.reduce((acc, row) => {
|
|
3008
|
+
if (row.key) acc[row.key] = row.value ?? "";
|
|
3009
|
+
return acc;
|
|
3010
|
+
}, {});
|
|
3011
|
+
return {
|
|
3012
|
+
id: pick2("id", "Id") ?? null,
|
|
3013
|
+
activityLogId: pick2("activityLogId", "ActivityLogId", "activity_log_id") ?? "new",
|
|
3014
|
+
leadId: pick2("leadId", "LeadId", "lead_id") ?? null,
|
|
3015
|
+
eventId: pick2("eventId", "EventId", "event_id") ?? null,
|
|
3016
|
+
activityTypeId: pick2("activityTypeId", "ActivityTypeId", "activity_type_id") ?? 0,
|
|
3017
|
+
activityTypeName: pick2("activityTypeName", "ActivityTypeName", "activity_type_name") ?? "",
|
|
3018
|
+
categoryId: pick2("categoryId", "CategoryId", "category_id") ?? 3,
|
|
3019
|
+
categoryName: pick2("categoryName", "CategoryName", "category_name") ?? "Appointments",
|
|
3020
|
+
isPartialData: pick2("isPartialData", "IsPartialData", "is_partial_data") ?? false,
|
|
3021
|
+
userEmail: pick2("userEmail", "UserEmail", "user_email") ?? "",
|
|
3022
|
+
createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
|
|
3023
|
+
data,
|
|
3024
|
+
activityLogDetails: details
|
|
3025
|
+
};
|
|
3026
|
+
}
|
|
3027
|
+
function pickDetail(row, ...keys) {
|
|
3028
|
+
if (!row) return void 0;
|
|
3029
|
+
return keys.reduce((v, k) => v ?? row[k], void 0);
|
|
3030
|
+
}
|
|
3031
|
+
function normalizeActivityTypeIds(raw) {
|
|
3032
|
+
if (raw == null) return null;
|
|
3033
|
+
const values = Array.isArray(raw) ? raw : [raw];
|
|
3034
|
+
const ids = [];
|
|
3035
|
+
for (const value of values) {
|
|
3036
|
+
if (value == null || value === "") continue;
|
|
3037
|
+
const parts = String(value).split(",");
|
|
3038
|
+
for (const part of parts) {
|
|
3039
|
+
const trimmed = part.trim();
|
|
3040
|
+
if (!trimmed) continue;
|
|
3041
|
+
const n = Number(trimmed);
|
|
3042
|
+
if (Number.isFinite(n)) ids.push(n);
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
return ids.length ? ids : null;
|
|
3046
|
+
}
|
|
3047
|
+
function buildActivityLogQuery(opts = {}) {
|
|
3048
|
+
const companyKey = String(opts.companyKey ?? opts.company_key ?? opts.CompanyKey ?? "").trim();
|
|
3049
|
+
const query = { company_key: companyKey };
|
|
3050
|
+
const leadId = opts.leadId ?? opts.lead_id ?? opts.LeadId;
|
|
3051
|
+
if (leadId != null && String(leadId).trim() !== "") query.lead_id = String(leadId).trim();
|
|
3052
|
+
const eventId = opts.eventId ?? opts.event_id ?? opts.EventId;
|
|
3053
|
+
if (eventId != null && String(eventId).trim() !== "") query.event_id = String(eventId).trim();
|
|
3054
|
+
const userEmail = opts.userEmail ?? opts.user_email ?? opts.UserEmail;
|
|
3055
|
+
if (userEmail != null && String(userEmail).trim() !== "") query.user_email = String(userEmail).trim();
|
|
3056
|
+
const fromDate = opts.fromDate ?? opts.from_date ?? opts.FromDate;
|
|
3057
|
+
if (fromDate != null && String(fromDate).trim() !== "") query.from_date = String(fromDate).trim();
|
|
3058
|
+
const toDate = opts.toDate ?? opts.to_date ?? opts.ToDate;
|
|
3059
|
+
if (toDate != null && String(toDate).trim() !== "") query.to_date = String(toDate).trim();
|
|
3060
|
+
const activityTypeIds = normalizeActivityTypeIds(
|
|
3061
|
+
opts.activityTypeId ?? opts.activity_type_id ?? opts.activityTypeIds ?? opts.activity_type_ids
|
|
3062
|
+
);
|
|
3063
|
+
if (activityTypeIds == null ? void 0 : activityTypeIds.length) {
|
|
3064
|
+
query.activity_type_id = activityTypeIds.length === 1 ? activityTypeIds[0] : activityTypeIds.join(",");
|
|
3065
|
+
}
|
|
3066
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
3067
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
3068
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
3069
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
3070
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
3071
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
3072
|
+
}
|
|
3073
|
+
const filterPairs = [];
|
|
3074
|
+
const searchColumn = opts.searchColumn ?? opts.search_column ?? opts.column;
|
|
3075
|
+
const searchText = opts.searchText ?? opts.search_text ?? opts.search;
|
|
3076
|
+
const singleColumn = searchColumn != null ? String(searchColumn).trim() : "";
|
|
3077
|
+
const singleText = searchText != null ? String(searchText).trim() : "";
|
|
3078
|
+
if (singleColumn && singleText) filterPairs.push({ column: singleColumn, text: singleText });
|
|
3079
|
+
if (Array.isArray(opts.filters)) {
|
|
3080
|
+
for (const f of opts.filters) {
|
|
3081
|
+
const column = String((f == null ? void 0 : f.column) ?? (f == null ? void 0 : f.searchColumn) ?? (f == null ? void 0 : f.search_column) ?? "").trim();
|
|
3082
|
+
const text = String((f == null ? void 0 : f.text) ?? (f == null ? void 0 : f.searchText) ?? (f == null ? void 0 : f.search_text) ?? (f == null ? void 0 : f.search) ?? "").trim();
|
|
3083
|
+
if (column && text) filterPairs.push({ column, text });
|
|
3084
|
+
}
|
|
3085
|
+
}
|
|
3086
|
+
if (filterPairs.length) {
|
|
3087
|
+
query.search_column = filterPairs.map((f) => f.column);
|
|
3088
|
+
query.search_text = filterPairs.map((f) => f.text);
|
|
3089
|
+
}
|
|
3090
|
+
if (opts.page != null) {
|
|
3091
|
+
query.page = opts.page;
|
|
3092
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
3093
|
+
else if (opts.pageSize != null) query.page_size = opts.pageSize;
|
|
3094
|
+
} else {
|
|
3095
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
3096
|
+
if (opts.take != null) query.take = opts.take;
|
|
3097
|
+
}
|
|
3098
|
+
return { companyKey, query };
|
|
3099
|
+
}
|
|
3100
|
+
var ActivityLogModel = import_mobx_state_tree21.types.model("ActivityLog", {
|
|
2984
3101
|
id: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.number), null),
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
3102
|
+
activityLogId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.identifier, "new"),
|
|
3103
|
+
leadId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
|
|
3104
|
+
eventId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
|
|
3105
|
+
activityTypeId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.number, 0),
|
|
3106
|
+
activityTypeName: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, ""),
|
|
3107
|
+
categoryId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.number, 3),
|
|
3108
|
+
categoryName: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, "Appointments"),
|
|
3109
|
+
isPartialData: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.boolean, false),
|
|
3110
|
+
userEmail: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, ""),
|
|
2990
3111
|
createdOn: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
|
|
2991
|
-
|
|
2992
|
-
|
|
3112
|
+
data: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.frozen(), {}),
|
|
3113
|
+
activityLogDetails: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.array(ActivityLogDetailModel), [])
|
|
3114
|
+
}).actions((self) => ({
|
|
3115
|
+
/** GET /activitylog/get – pass companyKey in opts (required). */
|
|
3116
|
+
async get(opts = {}) {
|
|
3117
|
+
return ActivityLogModel.get(opts);
|
|
3118
|
+
}
|
|
3119
|
+
}));
|
|
3120
|
+
ActivityLogModel.get = async (opts = {}) => {
|
|
3121
|
+
const { companyKey, query } = buildActivityLogQuery(opts);
|
|
3122
|
+
if (!companyKey) return { status: "failure", message: "companyKey is required" };
|
|
3123
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
3124
|
+
const res = await reqGet("/activitylog/get", query);
|
|
3125
|
+
if (res.status === "success") {
|
|
3126
|
+
const payload = res.data ?? {};
|
|
3127
|
+
const logsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.ActivityLogs) ? payload.ActivityLogs : Array.isArray(payload.activityLogs) ? payload.activityLogs : null;
|
|
3128
|
+
if (logsRaw) {
|
|
3129
|
+
const activityLogs = logsRaw.map(
|
|
3130
|
+
(row) => ActivityLogModel.create(mapActivityLogFromApi(row), { env: getConfig() })
|
|
3131
|
+
);
|
|
3132
|
+
const totalCountRaw = payload.TotalCount ?? payload.totalCount;
|
|
3133
|
+
const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : activityLogs.length;
|
|
3134
|
+
return { activityLogs, totalCount };
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
return null;
|
|
3138
|
+
};
|
|
3139
|
+
ActivityLogModel.getByCompany = async (companyKey, opts = {}) => ActivityLogModel.get({ ...opts, companyKey });
|
|
3140
|
+
var ActivityLog_default = ActivityLogModel;
|
|
3141
|
+
|
|
3142
|
+
// src/models/appointment/CustomField.js
|
|
3143
|
+
var import_mobx_state_tree22 = require("mobx-state-tree");
|
|
3144
|
+
var CustomFieldModel = import_mobx_state_tree22.types.model("CustomField", {
|
|
3145
|
+
id: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.number), null),
|
|
3146
|
+
customFieldId: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.string), null),
|
|
3147
|
+
calendarId: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.string), null),
|
|
3148
|
+
label: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.string), null),
|
|
3149
|
+
type: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.string, ""),
|
|
3150
|
+
isRequired: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.boolean, false),
|
|
3151
|
+
createdOn: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.string), null),
|
|
3152
|
+
modifiedOn: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.string), null),
|
|
3153
|
+
isDeleted: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.boolean, false)
|
|
2993
3154
|
}).actions((self) => {
|
|
2994
|
-
const { reqGet, reqPost } = createRequestHelpers(self,
|
|
3155
|
+
const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree22.getEnv);
|
|
2995
3156
|
return {
|
|
2996
3157
|
/** GET /CustomField/GetAll?calendar_id= */
|
|
2997
3158
|
async getAll(calendarId) {
|
|
@@ -3012,7 +3173,7 @@ var CustomFieldModel = import_mobx_state_tree21.types.model("CustomField", {
|
|
|
3012
3173
|
const body = payload ?? toPayload5(self);
|
|
3013
3174
|
const res = await reqPost("/CustomField/Add", body);
|
|
3014
3175
|
if (res.status === "success" && res.data) {
|
|
3015
|
-
(0,
|
|
3176
|
+
(0, import_mobx_state_tree22.applySnapshot)(self, mapCustomFieldFromApi(res.data));
|
|
3016
3177
|
}
|
|
3017
3178
|
return res;
|
|
3018
3179
|
},
|
|
@@ -3319,10 +3480,10 @@ var AuthModel = {
|
|
|
3319
3480
|
var Auth_default = AuthModel;
|
|
3320
3481
|
|
|
3321
3482
|
// src/models/appointment/index.js
|
|
3322
|
-
var
|
|
3323
|
-
var RootStore =
|
|
3324
|
-
calendars:
|
|
3325
|
-
events:
|
|
3483
|
+
var import_mobx_state_tree23 = require("mobx-state-tree");
|
|
3484
|
+
var RootStore = import_mobx_state_tree23.types.model("RootStore", {
|
|
3485
|
+
calendars: import_mobx_state_tree23.types.optional(import_mobx_state_tree23.types.map(Calendar_default), {}),
|
|
3486
|
+
events: import_mobx_state_tree23.types.optional(import_mobx_state_tree23.types.map(Event_default), {})
|
|
3326
3487
|
}).actions((self) => ({
|
|
3327
3488
|
addCalendar(snapshot) {
|
|
3328
3489
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -3342,6 +3503,9 @@ function createRootStore(initialState = {}) {
|
|
|
3342
3503
|
}
|
|
3343
3504
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3344
3505
|
0 && (module.exports = {
|
|
3506
|
+
ActivityLogCategory,
|
|
3507
|
+
ActivityLogModel,
|
|
3508
|
+
ActivityLogType,
|
|
3345
3509
|
AssetModel,
|
|
3346
3510
|
AssignmentMethod,
|
|
3347
3511
|
AttendeeStatus,
|
package/dist/index.mjs
CHANGED
|
@@ -308,6 +308,14 @@ var CalendarVisibility = {
|
|
|
308
308
|
Public: 0,
|
|
309
309
|
Private: 1
|
|
310
310
|
};
|
|
311
|
+
var ActivityLogType = {
|
|
312
|
+
AppointmentScheduled: 9,
|
|
313
|
+
AppointmentRescheduled: 10,
|
|
314
|
+
AppointmentCanceled: 11
|
|
315
|
+
};
|
|
316
|
+
var ActivityLogCategory = {
|
|
317
|
+
Appointments: 3
|
|
318
|
+
};
|
|
311
319
|
|
|
312
320
|
// src/models/appointment/Event.js
|
|
313
321
|
import { types as types4, getEnv, applySnapshot } from "mobx-state-tree";
|
|
@@ -2903,18 +2911,168 @@ LeadModel.getSources = async (companyKey) => {
|
|
|
2903
2911
|
};
|
|
2904
2912
|
var Lead_default = LeadModel;
|
|
2905
2913
|
|
|
2906
|
-
// src/models/appointment/
|
|
2907
|
-
import { types as types21
|
|
2908
|
-
var
|
|
2914
|
+
// src/models/appointment/ActivityLog.js
|
|
2915
|
+
import { types as types21 } from "mobx-state-tree";
|
|
2916
|
+
var ActivityLogDetailModel = types21.model("ActivityLogDetail", {
|
|
2917
|
+
key: types21.optional(types21.string, ""),
|
|
2918
|
+
value: types21.optional(types21.string, "")
|
|
2919
|
+
});
|
|
2920
|
+
function mapActivityLogFromApi(d) {
|
|
2921
|
+
if (!d) return d;
|
|
2922
|
+
const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
|
|
2923
|
+
const detailsRaw = pick2("activityLogDetails", "ActivityLogDetails");
|
|
2924
|
+
const details = Array.isArray(detailsRaw) ? detailsRaw.map((row) => ({
|
|
2925
|
+
key: pickDetail(row, "key", "Key") ?? "",
|
|
2926
|
+
value: pickDetail(row, "value", "Value") ?? ""
|
|
2927
|
+
})) : [];
|
|
2928
|
+
const dataRaw = pick2("data", "Data");
|
|
2929
|
+
const data = dataRaw && typeof dataRaw === "object" && !Array.isArray(dataRaw) ? { ...dataRaw } : details.reduce((acc, row) => {
|
|
2930
|
+
if (row.key) acc[row.key] = row.value ?? "";
|
|
2931
|
+
return acc;
|
|
2932
|
+
}, {});
|
|
2933
|
+
return {
|
|
2934
|
+
id: pick2("id", "Id") ?? null,
|
|
2935
|
+
activityLogId: pick2("activityLogId", "ActivityLogId", "activity_log_id") ?? "new",
|
|
2936
|
+
leadId: pick2("leadId", "LeadId", "lead_id") ?? null,
|
|
2937
|
+
eventId: pick2("eventId", "EventId", "event_id") ?? null,
|
|
2938
|
+
activityTypeId: pick2("activityTypeId", "ActivityTypeId", "activity_type_id") ?? 0,
|
|
2939
|
+
activityTypeName: pick2("activityTypeName", "ActivityTypeName", "activity_type_name") ?? "",
|
|
2940
|
+
categoryId: pick2("categoryId", "CategoryId", "category_id") ?? 3,
|
|
2941
|
+
categoryName: pick2("categoryName", "CategoryName", "category_name") ?? "Appointments",
|
|
2942
|
+
isPartialData: pick2("isPartialData", "IsPartialData", "is_partial_data") ?? false,
|
|
2943
|
+
userEmail: pick2("userEmail", "UserEmail", "user_email") ?? "",
|
|
2944
|
+
createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
|
|
2945
|
+
data,
|
|
2946
|
+
activityLogDetails: details
|
|
2947
|
+
};
|
|
2948
|
+
}
|
|
2949
|
+
function pickDetail(row, ...keys) {
|
|
2950
|
+
if (!row) return void 0;
|
|
2951
|
+
return keys.reduce((v, k) => v ?? row[k], void 0);
|
|
2952
|
+
}
|
|
2953
|
+
function normalizeActivityTypeIds(raw) {
|
|
2954
|
+
if (raw == null) return null;
|
|
2955
|
+
const values = Array.isArray(raw) ? raw : [raw];
|
|
2956
|
+
const ids = [];
|
|
2957
|
+
for (const value of values) {
|
|
2958
|
+
if (value == null || value === "") continue;
|
|
2959
|
+
const parts = String(value).split(",");
|
|
2960
|
+
for (const part of parts) {
|
|
2961
|
+
const trimmed = part.trim();
|
|
2962
|
+
if (!trimmed) continue;
|
|
2963
|
+
const n = Number(trimmed);
|
|
2964
|
+
if (Number.isFinite(n)) ids.push(n);
|
|
2965
|
+
}
|
|
2966
|
+
}
|
|
2967
|
+
return ids.length ? ids : null;
|
|
2968
|
+
}
|
|
2969
|
+
function buildActivityLogQuery(opts = {}) {
|
|
2970
|
+
const companyKey = String(opts.companyKey ?? opts.company_key ?? opts.CompanyKey ?? "").trim();
|
|
2971
|
+
const query = { company_key: companyKey };
|
|
2972
|
+
const leadId = opts.leadId ?? opts.lead_id ?? opts.LeadId;
|
|
2973
|
+
if (leadId != null && String(leadId).trim() !== "") query.lead_id = String(leadId).trim();
|
|
2974
|
+
const eventId = opts.eventId ?? opts.event_id ?? opts.EventId;
|
|
2975
|
+
if (eventId != null && String(eventId).trim() !== "") query.event_id = String(eventId).trim();
|
|
2976
|
+
const userEmail = opts.userEmail ?? opts.user_email ?? opts.UserEmail;
|
|
2977
|
+
if (userEmail != null && String(userEmail).trim() !== "") query.user_email = String(userEmail).trim();
|
|
2978
|
+
const fromDate = opts.fromDate ?? opts.from_date ?? opts.FromDate;
|
|
2979
|
+
if (fromDate != null && String(fromDate).trim() !== "") query.from_date = String(fromDate).trim();
|
|
2980
|
+
const toDate = opts.toDate ?? opts.to_date ?? opts.ToDate;
|
|
2981
|
+
if (toDate != null && String(toDate).trim() !== "") query.to_date = String(toDate).trim();
|
|
2982
|
+
const activityTypeIds = normalizeActivityTypeIds(
|
|
2983
|
+
opts.activityTypeId ?? opts.activity_type_id ?? opts.activityTypeIds ?? opts.activity_type_ids
|
|
2984
|
+
);
|
|
2985
|
+
if (activityTypeIds == null ? void 0 : activityTypeIds.length) {
|
|
2986
|
+
query.activity_type_id = activityTypeIds.length === 1 ? activityTypeIds[0] : activityTypeIds.join(",");
|
|
2987
|
+
}
|
|
2988
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
2989
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
2990
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
2991
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
2992
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
2993
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
2994
|
+
}
|
|
2995
|
+
const filterPairs = [];
|
|
2996
|
+
const searchColumn = opts.searchColumn ?? opts.search_column ?? opts.column;
|
|
2997
|
+
const searchText = opts.searchText ?? opts.search_text ?? opts.search;
|
|
2998
|
+
const singleColumn = searchColumn != null ? String(searchColumn).trim() : "";
|
|
2999
|
+
const singleText = searchText != null ? String(searchText).trim() : "";
|
|
3000
|
+
if (singleColumn && singleText) filterPairs.push({ column: singleColumn, text: singleText });
|
|
3001
|
+
if (Array.isArray(opts.filters)) {
|
|
3002
|
+
for (const f of opts.filters) {
|
|
3003
|
+
const column = String((f == null ? void 0 : f.column) ?? (f == null ? void 0 : f.searchColumn) ?? (f == null ? void 0 : f.search_column) ?? "").trim();
|
|
3004
|
+
const text = String((f == null ? void 0 : f.text) ?? (f == null ? void 0 : f.searchText) ?? (f == null ? void 0 : f.search_text) ?? (f == null ? void 0 : f.search) ?? "").trim();
|
|
3005
|
+
if (column && text) filterPairs.push({ column, text });
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
if (filterPairs.length) {
|
|
3009
|
+
query.search_column = filterPairs.map((f) => f.column);
|
|
3010
|
+
query.search_text = filterPairs.map((f) => f.text);
|
|
3011
|
+
}
|
|
3012
|
+
if (opts.page != null) {
|
|
3013
|
+
query.page = opts.page;
|
|
3014
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
3015
|
+
else if (opts.pageSize != null) query.page_size = opts.pageSize;
|
|
3016
|
+
} else {
|
|
3017
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
3018
|
+
if (opts.take != null) query.take = opts.take;
|
|
3019
|
+
}
|
|
3020
|
+
return { companyKey, query };
|
|
3021
|
+
}
|
|
3022
|
+
var ActivityLogModel = types21.model("ActivityLog", {
|
|
2909
3023
|
id: types21.optional(types21.maybeNull(types21.number), null),
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
3024
|
+
activityLogId: types21.optional(types21.identifier, "new"),
|
|
3025
|
+
leadId: types21.optional(types21.maybeNull(types21.string), null),
|
|
3026
|
+
eventId: types21.optional(types21.maybeNull(types21.string), null),
|
|
3027
|
+
activityTypeId: types21.optional(types21.number, 0),
|
|
3028
|
+
activityTypeName: types21.optional(types21.string, ""),
|
|
3029
|
+
categoryId: types21.optional(types21.number, 3),
|
|
3030
|
+
categoryName: types21.optional(types21.string, "Appointments"),
|
|
3031
|
+
isPartialData: types21.optional(types21.boolean, false),
|
|
3032
|
+
userEmail: types21.optional(types21.string, ""),
|
|
2915
3033
|
createdOn: types21.optional(types21.maybeNull(types21.string), null),
|
|
2916
|
-
|
|
2917
|
-
|
|
3034
|
+
data: types21.optional(types21.frozen(), {}),
|
|
3035
|
+
activityLogDetails: types21.optional(types21.array(ActivityLogDetailModel), [])
|
|
3036
|
+
}).actions((self) => ({
|
|
3037
|
+
/** GET /activitylog/get – pass companyKey in opts (required). */
|
|
3038
|
+
async get(opts = {}) {
|
|
3039
|
+
return ActivityLogModel.get(opts);
|
|
3040
|
+
}
|
|
3041
|
+
}));
|
|
3042
|
+
ActivityLogModel.get = async (opts = {}) => {
|
|
3043
|
+
const { companyKey, query } = buildActivityLogQuery(opts);
|
|
3044
|
+
if (!companyKey) return { status: "failure", message: "companyKey is required" };
|
|
3045
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
3046
|
+
const res = await reqGet("/activitylog/get", query);
|
|
3047
|
+
if (res.status === "success") {
|
|
3048
|
+
const payload = res.data ?? {};
|
|
3049
|
+
const logsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.ActivityLogs) ? payload.ActivityLogs : Array.isArray(payload.activityLogs) ? payload.activityLogs : null;
|
|
3050
|
+
if (logsRaw) {
|
|
3051
|
+
const activityLogs = logsRaw.map(
|
|
3052
|
+
(row) => ActivityLogModel.create(mapActivityLogFromApi(row), { env: getConfig() })
|
|
3053
|
+
);
|
|
3054
|
+
const totalCountRaw = payload.TotalCount ?? payload.totalCount;
|
|
3055
|
+
const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : activityLogs.length;
|
|
3056
|
+
return { activityLogs, totalCount };
|
|
3057
|
+
}
|
|
3058
|
+
}
|
|
3059
|
+
return null;
|
|
3060
|
+
};
|
|
3061
|
+
ActivityLogModel.getByCompany = async (companyKey, opts = {}) => ActivityLogModel.get({ ...opts, companyKey });
|
|
3062
|
+
var ActivityLog_default = ActivityLogModel;
|
|
3063
|
+
|
|
3064
|
+
// src/models/appointment/CustomField.js
|
|
3065
|
+
import { types as types22, getEnv as getEnv10, applySnapshot as applySnapshot9 } from "mobx-state-tree";
|
|
3066
|
+
var CustomFieldModel = types22.model("CustomField", {
|
|
3067
|
+
id: types22.optional(types22.maybeNull(types22.number), null),
|
|
3068
|
+
customFieldId: types22.optional(types22.maybeNull(types22.string), null),
|
|
3069
|
+
calendarId: types22.optional(types22.maybeNull(types22.string), null),
|
|
3070
|
+
label: types22.optional(types22.maybeNull(types22.string), null),
|
|
3071
|
+
type: types22.optional(types22.string, ""),
|
|
3072
|
+
isRequired: types22.optional(types22.boolean, false),
|
|
3073
|
+
createdOn: types22.optional(types22.maybeNull(types22.string), null),
|
|
3074
|
+
modifiedOn: types22.optional(types22.maybeNull(types22.string), null),
|
|
3075
|
+
isDeleted: types22.optional(types22.boolean, false)
|
|
2918
3076
|
}).actions((self) => {
|
|
2919
3077
|
const { reqGet, reqPost } = createRequestHelpers(self, getEnv10);
|
|
2920
3078
|
return {
|
|
@@ -3244,10 +3402,10 @@ var AuthModel = {
|
|
|
3244
3402
|
var Auth_default = AuthModel;
|
|
3245
3403
|
|
|
3246
3404
|
// src/models/appointment/index.js
|
|
3247
|
-
import { types as
|
|
3248
|
-
var RootStore =
|
|
3249
|
-
calendars:
|
|
3250
|
-
events:
|
|
3405
|
+
import { types as types23, getEnv as getEnv11 } from "mobx-state-tree";
|
|
3406
|
+
var RootStore = types23.model("RootStore", {
|
|
3407
|
+
calendars: types23.optional(types23.map(Calendar_default), {}),
|
|
3408
|
+
events: types23.optional(types23.map(Event_default), {})
|
|
3251
3409
|
}).actions((self) => ({
|
|
3252
3410
|
addCalendar(snapshot) {
|
|
3253
3411
|
const cal = Calendar_default.create(snapshot);
|
|
@@ -3266,6 +3424,9 @@ function createRootStore(initialState = {}) {
|
|
|
3266
3424
|
return RootStore.create(initialState, { env });
|
|
3267
3425
|
}
|
|
3268
3426
|
export {
|
|
3427
|
+
ActivityLogCategory,
|
|
3428
|
+
ActivityLog_default as ActivityLogModel,
|
|
3429
|
+
ActivityLogType,
|
|
3269
3430
|
Asset_default as AssetModel,
|
|
3270
3431
|
AssignmentMethod,
|
|
3271
3432
|
AttendeeStatus,
|