@blazeo.com/calendar-client 1.0.56 → 1.0.58

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 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>;
@@ -438,6 +509,21 @@ export const LeadModel: {
438
509
  create(snapshot?: object, options?: { env?: object }): unknown;
439
510
  };
440
511
 
512
+ export const AuthorizationSource: {
513
+ None: 0;
514
+ Direct: 1;
515
+ Email: 2;
516
+ };
517
+
518
+ export type ParticipantCredentialsData = {
519
+ participantCredentialId?: string;
520
+ participantId: string;
521
+ email?: string;
522
+ authorizedByParticipantId?: string | null;
523
+ authorizationSource?: number | null;
524
+ authorizedOn?: string | null;
525
+ };
526
+
441
527
  export type CalendarProviderOption = {
442
528
  emailProvider: number;
443
529
  key: string;
@@ -487,8 +573,14 @@ export type ParticipantData = {
487
573
  createdOn?: string | null;
488
574
  modifiedOn?: string | null;
489
575
  isDeleted?: boolean;
490
- /** Last stored authorization error; populated by Auth/IsAuthorized when not authorized. */
576
+ /** Last stored authorization error from ParticipantCredentials. */
491
577
  authorizationError?: string;
578
+ /** Participant who initiated calendar authorization (in-app flow). */
579
+ authorizedByParticipantId?: string | null;
580
+ /** 1 = Direct, 2 = Email — from ParticipantCredentials. */
581
+ authorizationSource?: number | null;
582
+ /** When calendar OAuth last completed successfully. */
583
+ authorizedOn?: string | null;
492
584
  };
493
585
 
494
586
  export const CALENDAR_AUTH_MESSAGE_TYPE: 'calendar-authorization';
@@ -510,7 +602,7 @@ export const AuthModel: {
510
602
  getAuthorizationUrl(
511
603
  participantId: string,
512
604
  emailProvider: string | number,
513
- opts?: { host?: string }
605
+ opts?: { host?: string; authorizedByParticipantId?: string }
514
606
  ): Promise<{
515
607
  status: string;
516
608
  data?: ParticipantAuthorizationUrl;
@@ -567,3 +659,12 @@ export const RecurringFrequency: Record<string, number>;
567
659
  export const DayOfWeek: Record<string, number>;
568
660
  export const LocationType: Record<string, number>;
569
661
  export const EmailProvider: Record<string, number>;
662
+ export const CalendarVisibility: Record<string, number>;
663
+ export const ActivityLogType: {
664
+ AppointmentScheduled: 9;
665
+ AppointmentRescheduled: 10;
666
+ AppointmentCanceled: 11;
667
+ };
668
+ export const ActivityLogCategory: {
669
+ Appointments: 3;
670
+ };
package/dist/index.js CHANGED
@@ -19,10 +19,14 @@ 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,
25
28
  AuthModel: () => Auth_default,
29
+ AuthorizationSource: () => AuthorizationSource,
26
30
  AvailabilityDetailModel: () => AvailabilityDetail_default,
27
31
  AvailabilityModel: () => Availability_default,
28
32
  CALENDAR_AUTH_MESSAGE_TYPE: () => CALENDAR_AUTH_MESSAGE_TYPE,
@@ -373,6 +377,11 @@ var EmailProvider = {
373
377
  Microsoft: 2,
374
378
  Default: 3
375
379
  };
380
+ var AuthorizationSource = {
381
+ None: 0,
382
+ Direct: 1,
383
+ Email: 2
384
+ };
376
385
  var LocationType = {
377
386
  Physical: 0,
378
387
  Video: 1,
@@ -383,6 +392,14 @@ var CalendarVisibility = {
383
392
  Public: 0,
384
393
  Private: 1
385
394
  };
395
+ var ActivityLogType = {
396
+ AppointmentScheduled: 9,
397
+ AppointmentRescheduled: 10,
398
+ AppointmentCanceled: 11
399
+ };
400
+ var ActivityLogCategory = {
401
+ Appointments: 3
402
+ };
386
403
 
387
404
  // src/models/appointment/Event.js
388
405
  var import_mobx_state_tree4 = require("mobx-state-tree");
@@ -1555,7 +1572,11 @@ var ParticipantModel = import_mobx_state_tree11.types.model("Participant", {
1555
1572
  provider: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.number, 0),
1556
1573
  createdOn: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.string), null),
1557
1574
  modifiedOn: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.string), null),
1558
- isDeleted: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.boolean, false)
1575
+ isDeleted: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.boolean, false),
1576
+ authorizationError: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.string, ""),
1577
+ authorizedByParticipantId: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.string), null),
1578
+ authorizationSource: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.number), null),
1579
+ authorizedOn: import_mobx_state_tree11.types.optional(import_mobx_state_tree11.types.maybeNull(import_mobx_state_tree11.types.string), null)
1559
1580
  }).actions((self) => {
1560
1581
  const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree11.getEnv);
1561
1582
  return {
@@ -1649,7 +1670,20 @@ function mapParticipantFromApi(d) {
1649
1670
  createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
1650
1671
  modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null,
1651
1672
  isDeleted: Boolean(pick2("isDeleted", "IsDeleted", "is_deleted")),
1652
- authorizationError: pick2("authorizationError", "AuthorizationError", "authorization_error") ?? ""
1673
+ authorizationError: pick2("authorizationError", "AuthorizationError", "authorization_error") ?? "",
1674
+ authorizedByParticipantId: (() => {
1675
+ const v = pick2(
1676
+ "authorizedByParticipantId",
1677
+ "AuthorizedByParticipantId",
1678
+ "authorized_by_participant_id"
1679
+ );
1680
+ return v != null && v !== "" ? String(v) : null;
1681
+ })(),
1682
+ authorizationSource: (() => {
1683
+ const v = pick2("authorizationSource", "AuthorizationSource", "authorization_source");
1684
+ return v != null && v !== "" ? Number(v) : null;
1685
+ })(),
1686
+ authorizedOn: pick2("authorizedOn", "AuthorizedOn", "authorized_on") ?? null
1653
1687
  };
1654
1688
  }
1655
1689
  function mapFromApi2(d) {
@@ -2978,20 +3012,170 @@ LeadModel.getSources = async (companyKey) => {
2978
3012
  };
2979
3013
  var Lead_default = LeadModel;
2980
3014
 
2981
- // src/models/appointment/CustomField.js
3015
+ // src/models/appointment/ActivityLog.js
2982
3016
  var import_mobx_state_tree21 = require("mobx-state-tree");
2983
- var CustomFieldModel = import_mobx_state_tree21.types.model("CustomField", {
3017
+ var ActivityLogDetailModel = import_mobx_state_tree21.types.model("ActivityLogDetail", {
3018
+ key: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, ""),
3019
+ value: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, "")
3020
+ });
3021
+ function mapActivityLogFromApi(d) {
3022
+ if (!d) return d;
3023
+ const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
3024
+ const detailsRaw = pick2("activityLogDetails", "ActivityLogDetails");
3025
+ const details = Array.isArray(detailsRaw) ? detailsRaw.map((row) => ({
3026
+ key: pickDetail(row, "key", "Key") ?? "",
3027
+ value: pickDetail(row, "value", "Value") ?? ""
3028
+ })) : [];
3029
+ const dataRaw = pick2("data", "Data");
3030
+ const data = dataRaw && typeof dataRaw === "object" && !Array.isArray(dataRaw) ? { ...dataRaw } : details.reduce((acc, row) => {
3031
+ if (row.key) acc[row.key] = row.value ?? "";
3032
+ return acc;
3033
+ }, {});
3034
+ return {
3035
+ id: pick2("id", "Id") ?? null,
3036
+ activityLogId: pick2("activityLogId", "ActivityLogId", "activity_log_id") ?? "new",
3037
+ leadId: pick2("leadId", "LeadId", "lead_id") ?? null,
3038
+ eventId: pick2("eventId", "EventId", "event_id") ?? null,
3039
+ activityTypeId: pick2("activityTypeId", "ActivityTypeId", "activity_type_id") ?? 0,
3040
+ activityTypeName: pick2("activityTypeName", "ActivityTypeName", "activity_type_name") ?? "",
3041
+ categoryId: pick2("categoryId", "CategoryId", "category_id") ?? 3,
3042
+ categoryName: pick2("categoryName", "CategoryName", "category_name") ?? "Appointments",
3043
+ isPartialData: pick2("isPartialData", "IsPartialData", "is_partial_data") ?? false,
3044
+ userEmail: pick2("userEmail", "UserEmail", "user_email") ?? "",
3045
+ createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
3046
+ data,
3047
+ activityLogDetails: details
3048
+ };
3049
+ }
3050
+ function pickDetail(row, ...keys) {
3051
+ if (!row) return void 0;
3052
+ return keys.reduce((v, k) => v ?? row[k], void 0);
3053
+ }
3054
+ function normalizeActivityTypeIds(raw) {
3055
+ if (raw == null) return null;
3056
+ const values = Array.isArray(raw) ? raw : [raw];
3057
+ const ids = [];
3058
+ for (const value of values) {
3059
+ if (value == null || value === "") continue;
3060
+ const parts = String(value).split(",");
3061
+ for (const part of parts) {
3062
+ const trimmed = part.trim();
3063
+ if (!trimmed) continue;
3064
+ const n = Number(trimmed);
3065
+ if (Number.isFinite(n)) ids.push(n);
3066
+ }
3067
+ }
3068
+ return ids.length ? ids : null;
3069
+ }
3070
+ function buildActivityLogQuery(opts = {}) {
3071
+ const companyKey = String(opts.companyKey ?? opts.company_key ?? opts.CompanyKey ?? "").trim();
3072
+ const query = { company_key: companyKey };
3073
+ const leadId = opts.leadId ?? opts.lead_id ?? opts.LeadId;
3074
+ if (leadId != null && String(leadId).trim() !== "") query.lead_id = String(leadId).trim();
3075
+ const eventId = opts.eventId ?? opts.event_id ?? opts.EventId;
3076
+ if (eventId != null && String(eventId).trim() !== "") query.event_id = String(eventId).trim();
3077
+ const userEmail = opts.userEmail ?? opts.user_email ?? opts.UserEmail;
3078
+ if (userEmail != null && String(userEmail).trim() !== "") query.user_email = String(userEmail).trim();
3079
+ const fromDate = opts.fromDate ?? opts.from_date ?? opts.FromDate;
3080
+ if (fromDate != null && String(fromDate).trim() !== "") query.from_date = String(fromDate).trim();
3081
+ const toDate = opts.toDate ?? opts.to_date ?? opts.ToDate;
3082
+ if (toDate != null && String(toDate).trim() !== "") query.to_date = String(toDate).trim();
3083
+ const activityTypeIds = normalizeActivityTypeIds(
3084
+ opts.activityTypeId ?? opts.activity_type_id ?? opts.activityTypeIds ?? opts.activity_type_ids
3085
+ );
3086
+ if (activityTypeIds == null ? void 0 : activityTypeIds.length) {
3087
+ query.activity_type_id = activityTypeIds.length === 1 ? activityTypeIds[0] : activityTypeIds.join(",");
3088
+ }
3089
+ const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
3090
+ if (sortBy != null && sortBy !== "") query.sort = sortBy;
3091
+ const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
3092
+ if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
3093
+ const u = String(sortOrderRaw).trim().toUpperCase();
3094
+ query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
3095
+ }
3096
+ const filterPairs = [];
3097
+ const searchColumn = opts.searchColumn ?? opts.search_column ?? opts.column;
3098
+ const searchText = opts.searchText ?? opts.search_text ?? opts.search;
3099
+ const singleColumn = searchColumn != null ? String(searchColumn).trim() : "";
3100
+ const singleText = searchText != null ? String(searchText).trim() : "";
3101
+ if (singleColumn && singleText) filterPairs.push({ column: singleColumn, text: singleText });
3102
+ if (Array.isArray(opts.filters)) {
3103
+ for (const f of opts.filters) {
3104
+ const column = String((f == null ? void 0 : f.column) ?? (f == null ? void 0 : f.searchColumn) ?? (f == null ? void 0 : f.search_column) ?? "").trim();
3105
+ 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();
3106
+ if (column && text) filterPairs.push({ column, text });
3107
+ }
3108
+ }
3109
+ if (filterPairs.length) {
3110
+ query.search_column = filterPairs.map((f) => f.column);
3111
+ query.search_text = filterPairs.map((f) => f.text);
3112
+ }
3113
+ if (opts.page != null) {
3114
+ query.page = opts.page;
3115
+ if (opts.page_size != null) query.page_size = opts.page_size;
3116
+ else if (opts.pageSize != null) query.page_size = opts.pageSize;
3117
+ } else {
3118
+ if (opts.skip != null) query.skip = opts.skip;
3119
+ if (opts.take != null) query.take = opts.take;
3120
+ }
3121
+ return { companyKey, query };
3122
+ }
3123
+ var ActivityLogModel = import_mobx_state_tree21.types.model("ActivityLog", {
2984
3124
  id: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.number), null),
2985
- customFieldId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
2986
- calendarId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
2987
- label: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
2988
- type: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, ""),
2989
- isRequired: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.boolean, false),
3125
+ activityLogId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.identifier, "new"),
3126
+ leadId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
3127
+ eventId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
3128
+ activityTypeId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.number, 0),
3129
+ activityTypeName: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, ""),
3130
+ categoryId: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.number, 3),
3131
+ categoryName: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, "Appointments"),
3132
+ isPartialData: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.boolean, false),
3133
+ userEmail: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.string, ""),
2990
3134
  createdOn: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
2991
- modifiedOn: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.maybeNull(import_mobx_state_tree21.types.string), null),
2992
- isDeleted: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.boolean, false)
3135
+ data: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.frozen(), {}),
3136
+ activityLogDetails: import_mobx_state_tree21.types.optional(import_mobx_state_tree21.types.array(ActivityLogDetailModel), [])
3137
+ }).actions((self) => ({
3138
+ /** GET /activitylog/get – pass companyKey in opts (required). */
3139
+ async get(opts = {}) {
3140
+ return ActivityLogModel.get(opts);
3141
+ }
3142
+ }));
3143
+ ActivityLogModel.get = async (opts = {}) => {
3144
+ const { companyKey, query } = buildActivityLogQuery(opts);
3145
+ if (!companyKey) return { status: "failure", message: "companyKey is required" };
3146
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
3147
+ const res = await reqGet("/activitylog/get", query);
3148
+ if (res.status === "success") {
3149
+ const payload = res.data ?? {};
3150
+ const logsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.ActivityLogs) ? payload.ActivityLogs : Array.isArray(payload.activityLogs) ? payload.activityLogs : null;
3151
+ if (logsRaw) {
3152
+ const activityLogs = logsRaw.map(
3153
+ (row) => ActivityLogModel.create(mapActivityLogFromApi(row), { env: getConfig() })
3154
+ );
3155
+ const totalCountRaw = payload.TotalCount ?? payload.totalCount;
3156
+ const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : activityLogs.length;
3157
+ return { activityLogs, totalCount };
3158
+ }
3159
+ }
3160
+ return null;
3161
+ };
3162
+ ActivityLogModel.getByCompany = async (companyKey, opts = {}) => ActivityLogModel.get({ ...opts, companyKey });
3163
+ var ActivityLog_default = ActivityLogModel;
3164
+
3165
+ // src/models/appointment/CustomField.js
3166
+ var import_mobx_state_tree22 = require("mobx-state-tree");
3167
+ var CustomFieldModel = import_mobx_state_tree22.types.model("CustomField", {
3168
+ id: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.number), null),
3169
+ customFieldId: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.string), null),
3170
+ calendarId: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.string), null),
3171
+ label: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.string), null),
3172
+ type: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.string, ""),
3173
+ isRequired: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.boolean, false),
3174
+ createdOn: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.string), null),
3175
+ modifiedOn: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.maybeNull(import_mobx_state_tree22.types.string), null),
3176
+ isDeleted: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.boolean, false)
2993
3177
  }).actions((self) => {
2994
- const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree21.getEnv);
3178
+ const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree22.getEnv);
2995
3179
  return {
2996
3180
  /** GET /CustomField/GetAll?calendar_id= */
2997
3181
  async getAll(calendarId) {
@@ -3012,7 +3196,7 @@ var CustomFieldModel = import_mobx_state_tree21.types.model("CustomField", {
3012
3196
  const body = payload ?? toPayload5(self);
3013
3197
  const res = await reqPost("/CustomField/Add", body);
3014
3198
  if (res.status === "success" && res.data) {
3015
- (0, import_mobx_state_tree21.applySnapshot)(self, mapCustomFieldFromApi(res.data));
3199
+ (0, import_mobx_state_tree22.applySnapshot)(self, mapCustomFieldFromApi(res.data));
3016
3200
  }
3017
3201
  return res;
3018
3202
  },
@@ -3225,7 +3409,7 @@ var AuthModel = {
3225
3409
  * GET Auth/AuthorizationUrl — OAuth URL to open in a popup when user picks a provider.
3226
3410
  * @param {string} participantId
3227
3411
  * @param {string|number} emailProvider — google, gmail, 1, outlook, microsoft, 2
3228
- * @param {{ host?: string }} [opts]
3412
+ * @param {{ host?: string, authorizedByParticipantId?: string }} [opts]
3229
3413
  * @returns {Promise<{ status: string, data?: object, message?: string }>}
3230
3414
  */
3231
3415
  async getAuthorizationUrl(participantId, emailProvider, opts = {}) {
@@ -3235,6 +3419,9 @@ var AuthModel = {
3235
3419
  email_provider: String(emailProvider)
3236
3420
  };
3237
3421
  if (opts.host) q.host = opts.host;
3422
+ if (opts.authorizedByParticipantId) {
3423
+ q.authorized_by_participant_id = String(opts.authorizedByParticipantId);
3424
+ }
3238
3425
  const res = await reqGet("/Auth/AuthorizationUrl", q);
3239
3426
  if (res.status === "success" && res.data) {
3240
3427
  res.data = mapAuthorizationUrlFromApi(res.data);
@@ -3319,10 +3506,10 @@ var AuthModel = {
3319
3506
  var Auth_default = AuthModel;
3320
3507
 
3321
3508
  // src/models/appointment/index.js
3322
- var import_mobx_state_tree22 = require("mobx-state-tree");
3323
- var RootStore = import_mobx_state_tree22.types.model("RootStore", {
3324
- calendars: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.map(Calendar_default), {}),
3325
- events: import_mobx_state_tree22.types.optional(import_mobx_state_tree22.types.map(Event_default), {})
3509
+ var import_mobx_state_tree23 = require("mobx-state-tree");
3510
+ var RootStore = import_mobx_state_tree23.types.model("RootStore", {
3511
+ calendars: import_mobx_state_tree23.types.optional(import_mobx_state_tree23.types.map(Calendar_default), {}),
3512
+ events: import_mobx_state_tree23.types.optional(import_mobx_state_tree23.types.map(Event_default), {})
3326
3513
  }).actions((self) => ({
3327
3514
  addCalendar(snapshot) {
3328
3515
  const cal = Calendar_default.create(snapshot);
@@ -3342,10 +3529,14 @@ function createRootStore(initialState = {}) {
3342
3529
  }
3343
3530
  // Annotate the CommonJS export names for ESM import in node:
3344
3531
  0 && (module.exports = {
3532
+ ActivityLogCategory,
3533
+ ActivityLogModel,
3534
+ ActivityLogType,
3345
3535
  AssetModel,
3346
3536
  AssignmentMethod,
3347
3537
  AttendeeStatus,
3348
3538
  AuthModel,
3539
+ AuthorizationSource,
3349
3540
  AvailabilityDetailModel,
3350
3541
  AvailabilityModel,
3351
3542
  CALENDAR_AUTH_MESSAGE_TYPE,
package/dist/index.mjs CHANGED
@@ -298,6 +298,11 @@ var EmailProvider = {
298
298
  Microsoft: 2,
299
299
  Default: 3
300
300
  };
301
+ var AuthorizationSource = {
302
+ None: 0,
303
+ Direct: 1,
304
+ Email: 2
305
+ };
301
306
  var LocationType = {
302
307
  Physical: 0,
303
308
  Video: 1,
@@ -308,6 +313,14 @@ var CalendarVisibility = {
308
313
  Public: 0,
309
314
  Private: 1
310
315
  };
316
+ var ActivityLogType = {
317
+ AppointmentScheduled: 9,
318
+ AppointmentRescheduled: 10,
319
+ AppointmentCanceled: 11
320
+ };
321
+ var ActivityLogCategory = {
322
+ Appointments: 3
323
+ };
311
324
 
312
325
  // src/models/appointment/Event.js
313
326
  import { types as types4, getEnv, applySnapshot } from "mobx-state-tree";
@@ -1480,7 +1493,11 @@ var ParticipantModel = types11.model("Participant", {
1480
1493
  provider: types11.optional(types11.number, 0),
1481
1494
  createdOn: types11.optional(types11.maybeNull(types11.string), null),
1482
1495
  modifiedOn: types11.optional(types11.maybeNull(types11.string), null),
1483
- isDeleted: types11.optional(types11.boolean, false)
1496
+ isDeleted: types11.optional(types11.boolean, false),
1497
+ authorizationError: types11.optional(types11.string, ""),
1498
+ authorizedByParticipantId: types11.optional(types11.maybeNull(types11.string), null),
1499
+ authorizationSource: types11.optional(types11.maybeNull(types11.number), null),
1500
+ authorizedOn: types11.optional(types11.maybeNull(types11.string), null)
1484
1501
  }).actions((self) => {
1485
1502
  const { reqGet, reqPost } = createRequestHelpers(self, getEnv3);
1486
1503
  return {
@@ -1574,7 +1591,20 @@ function mapParticipantFromApi(d) {
1574
1591
  createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
1575
1592
  modifiedOn: pick2("modifiedOn", "ModifiedOn", "modified_on") ?? null,
1576
1593
  isDeleted: Boolean(pick2("isDeleted", "IsDeleted", "is_deleted")),
1577
- authorizationError: pick2("authorizationError", "AuthorizationError", "authorization_error") ?? ""
1594
+ authorizationError: pick2("authorizationError", "AuthorizationError", "authorization_error") ?? "",
1595
+ authorizedByParticipantId: (() => {
1596
+ const v = pick2(
1597
+ "authorizedByParticipantId",
1598
+ "AuthorizedByParticipantId",
1599
+ "authorized_by_participant_id"
1600
+ );
1601
+ return v != null && v !== "" ? String(v) : null;
1602
+ })(),
1603
+ authorizationSource: (() => {
1604
+ const v = pick2("authorizationSource", "AuthorizationSource", "authorization_source");
1605
+ return v != null && v !== "" ? Number(v) : null;
1606
+ })(),
1607
+ authorizedOn: pick2("authorizedOn", "AuthorizedOn", "authorized_on") ?? null
1578
1608
  };
1579
1609
  }
1580
1610
  function mapFromApi2(d) {
@@ -2903,18 +2933,168 @@ LeadModel.getSources = async (companyKey) => {
2903
2933
  };
2904
2934
  var Lead_default = LeadModel;
2905
2935
 
2906
- // src/models/appointment/CustomField.js
2907
- import { types as types21, getEnv as getEnv10, applySnapshot as applySnapshot9 } from "mobx-state-tree";
2908
- var CustomFieldModel = types21.model("CustomField", {
2936
+ // src/models/appointment/ActivityLog.js
2937
+ import { types as types21 } from "mobx-state-tree";
2938
+ var ActivityLogDetailModel = types21.model("ActivityLogDetail", {
2939
+ key: types21.optional(types21.string, ""),
2940
+ value: types21.optional(types21.string, "")
2941
+ });
2942
+ function mapActivityLogFromApi(d) {
2943
+ if (!d) return d;
2944
+ const pick2 = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
2945
+ const detailsRaw = pick2("activityLogDetails", "ActivityLogDetails");
2946
+ const details = Array.isArray(detailsRaw) ? detailsRaw.map((row) => ({
2947
+ key: pickDetail(row, "key", "Key") ?? "",
2948
+ value: pickDetail(row, "value", "Value") ?? ""
2949
+ })) : [];
2950
+ const dataRaw = pick2("data", "Data");
2951
+ const data = dataRaw && typeof dataRaw === "object" && !Array.isArray(dataRaw) ? { ...dataRaw } : details.reduce((acc, row) => {
2952
+ if (row.key) acc[row.key] = row.value ?? "";
2953
+ return acc;
2954
+ }, {});
2955
+ return {
2956
+ id: pick2("id", "Id") ?? null,
2957
+ activityLogId: pick2("activityLogId", "ActivityLogId", "activity_log_id") ?? "new",
2958
+ leadId: pick2("leadId", "LeadId", "lead_id") ?? null,
2959
+ eventId: pick2("eventId", "EventId", "event_id") ?? null,
2960
+ activityTypeId: pick2("activityTypeId", "ActivityTypeId", "activity_type_id") ?? 0,
2961
+ activityTypeName: pick2("activityTypeName", "ActivityTypeName", "activity_type_name") ?? "",
2962
+ categoryId: pick2("categoryId", "CategoryId", "category_id") ?? 3,
2963
+ categoryName: pick2("categoryName", "CategoryName", "category_name") ?? "Appointments",
2964
+ isPartialData: pick2("isPartialData", "IsPartialData", "is_partial_data") ?? false,
2965
+ userEmail: pick2("userEmail", "UserEmail", "user_email") ?? "",
2966
+ createdOn: pick2("createdOn", "CreatedOn", "created_on") ?? null,
2967
+ data,
2968
+ activityLogDetails: details
2969
+ };
2970
+ }
2971
+ function pickDetail(row, ...keys) {
2972
+ if (!row) return void 0;
2973
+ return keys.reduce((v, k) => v ?? row[k], void 0);
2974
+ }
2975
+ function normalizeActivityTypeIds(raw) {
2976
+ if (raw == null) return null;
2977
+ const values = Array.isArray(raw) ? raw : [raw];
2978
+ const ids = [];
2979
+ for (const value of values) {
2980
+ if (value == null || value === "") continue;
2981
+ const parts = String(value).split(",");
2982
+ for (const part of parts) {
2983
+ const trimmed = part.trim();
2984
+ if (!trimmed) continue;
2985
+ const n = Number(trimmed);
2986
+ if (Number.isFinite(n)) ids.push(n);
2987
+ }
2988
+ }
2989
+ return ids.length ? ids : null;
2990
+ }
2991
+ function buildActivityLogQuery(opts = {}) {
2992
+ const companyKey = String(opts.companyKey ?? opts.company_key ?? opts.CompanyKey ?? "").trim();
2993
+ const query = { company_key: companyKey };
2994
+ const leadId = opts.leadId ?? opts.lead_id ?? opts.LeadId;
2995
+ if (leadId != null && String(leadId).trim() !== "") query.lead_id = String(leadId).trim();
2996
+ const eventId = opts.eventId ?? opts.event_id ?? opts.EventId;
2997
+ if (eventId != null && String(eventId).trim() !== "") query.event_id = String(eventId).trim();
2998
+ const userEmail = opts.userEmail ?? opts.user_email ?? opts.UserEmail;
2999
+ if (userEmail != null && String(userEmail).trim() !== "") query.user_email = String(userEmail).trim();
3000
+ const fromDate = opts.fromDate ?? opts.from_date ?? opts.FromDate;
3001
+ if (fromDate != null && String(fromDate).trim() !== "") query.from_date = String(fromDate).trim();
3002
+ const toDate = opts.toDate ?? opts.to_date ?? opts.ToDate;
3003
+ if (toDate != null && String(toDate).trim() !== "") query.to_date = String(toDate).trim();
3004
+ const activityTypeIds = normalizeActivityTypeIds(
3005
+ opts.activityTypeId ?? opts.activity_type_id ?? opts.activityTypeIds ?? opts.activity_type_ids
3006
+ );
3007
+ if (activityTypeIds == null ? void 0 : activityTypeIds.length) {
3008
+ query.activity_type_id = activityTypeIds.length === 1 ? activityTypeIds[0] : activityTypeIds.join(",");
3009
+ }
3010
+ const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
3011
+ if (sortBy != null && sortBy !== "") query.sort = sortBy;
3012
+ const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
3013
+ if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
3014
+ const u = String(sortOrderRaw).trim().toUpperCase();
3015
+ query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
3016
+ }
3017
+ const filterPairs = [];
3018
+ const searchColumn = opts.searchColumn ?? opts.search_column ?? opts.column;
3019
+ const searchText = opts.searchText ?? opts.search_text ?? opts.search;
3020
+ const singleColumn = searchColumn != null ? String(searchColumn).trim() : "";
3021
+ const singleText = searchText != null ? String(searchText).trim() : "";
3022
+ if (singleColumn && singleText) filterPairs.push({ column: singleColumn, text: singleText });
3023
+ if (Array.isArray(opts.filters)) {
3024
+ for (const f of opts.filters) {
3025
+ const column = String((f == null ? void 0 : f.column) ?? (f == null ? void 0 : f.searchColumn) ?? (f == null ? void 0 : f.search_column) ?? "").trim();
3026
+ 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();
3027
+ if (column && text) filterPairs.push({ column, text });
3028
+ }
3029
+ }
3030
+ if (filterPairs.length) {
3031
+ query.search_column = filterPairs.map((f) => f.column);
3032
+ query.search_text = filterPairs.map((f) => f.text);
3033
+ }
3034
+ if (opts.page != null) {
3035
+ query.page = opts.page;
3036
+ if (opts.page_size != null) query.page_size = opts.page_size;
3037
+ else if (opts.pageSize != null) query.page_size = opts.pageSize;
3038
+ } else {
3039
+ if (opts.skip != null) query.skip = opts.skip;
3040
+ if (opts.take != null) query.take = opts.take;
3041
+ }
3042
+ return { companyKey, query };
3043
+ }
3044
+ var ActivityLogModel = types21.model("ActivityLog", {
2909
3045
  id: types21.optional(types21.maybeNull(types21.number), null),
2910
- customFieldId: types21.optional(types21.maybeNull(types21.string), null),
2911
- calendarId: types21.optional(types21.maybeNull(types21.string), null),
2912
- label: types21.optional(types21.maybeNull(types21.string), null),
2913
- type: types21.optional(types21.string, ""),
2914
- isRequired: types21.optional(types21.boolean, false),
3046
+ activityLogId: types21.optional(types21.identifier, "new"),
3047
+ leadId: types21.optional(types21.maybeNull(types21.string), null),
3048
+ eventId: types21.optional(types21.maybeNull(types21.string), null),
3049
+ activityTypeId: types21.optional(types21.number, 0),
3050
+ activityTypeName: types21.optional(types21.string, ""),
3051
+ categoryId: types21.optional(types21.number, 3),
3052
+ categoryName: types21.optional(types21.string, "Appointments"),
3053
+ isPartialData: types21.optional(types21.boolean, false),
3054
+ userEmail: types21.optional(types21.string, ""),
2915
3055
  createdOn: types21.optional(types21.maybeNull(types21.string), null),
2916
- modifiedOn: types21.optional(types21.maybeNull(types21.string), null),
2917
- isDeleted: types21.optional(types21.boolean, false)
3056
+ data: types21.optional(types21.frozen(), {}),
3057
+ activityLogDetails: types21.optional(types21.array(ActivityLogDetailModel), [])
3058
+ }).actions((self) => ({
3059
+ /** GET /activitylog/get – pass companyKey in opts (required). */
3060
+ async get(opts = {}) {
3061
+ return ActivityLogModel.get(opts);
3062
+ }
3063
+ }));
3064
+ ActivityLogModel.get = async (opts = {}) => {
3065
+ const { companyKey, query } = buildActivityLogQuery(opts);
3066
+ if (!companyKey) return { status: "failure", message: "companyKey is required" };
3067
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
3068
+ const res = await reqGet("/activitylog/get", query);
3069
+ if (res.status === "success") {
3070
+ const payload = res.data ?? {};
3071
+ const logsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.ActivityLogs) ? payload.ActivityLogs : Array.isArray(payload.activityLogs) ? payload.activityLogs : null;
3072
+ if (logsRaw) {
3073
+ const activityLogs = logsRaw.map(
3074
+ (row) => ActivityLogModel.create(mapActivityLogFromApi(row), { env: getConfig() })
3075
+ );
3076
+ const totalCountRaw = payload.TotalCount ?? payload.totalCount;
3077
+ const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : activityLogs.length;
3078
+ return { activityLogs, totalCount };
3079
+ }
3080
+ }
3081
+ return null;
3082
+ };
3083
+ ActivityLogModel.getByCompany = async (companyKey, opts = {}) => ActivityLogModel.get({ ...opts, companyKey });
3084
+ var ActivityLog_default = ActivityLogModel;
3085
+
3086
+ // src/models/appointment/CustomField.js
3087
+ import { types as types22, getEnv as getEnv10, applySnapshot as applySnapshot9 } from "mobx-state-tree";
3088
+ var CustomFieldModel = types22.model("CustomField", {
3089
+ id: types22.optional(types22.maybeNull(types22.number), null),
3090
+ customFieldId: types22.optional(types22.maybeNull(types22.string), null),
3091
+ calendarId: types22.optional(types22.maybeNull(types22.string), null),
3092
+ label: types22.optional(types22.maybeNull(types22.string), null),
3093
+ type: types22.optional(types22.string, ""),
3094
+ isRequired: types22.optional(types22.boolean, false),
3095
+ createdOn: types22.optional(types22.maybeNull(types22.string), null),
3096
+ modifiedOn: types22.optional(types22.maybeNull(types22.string), null),
3097
+ isDeleted: types22.optional(types22.boolean, false)
2918
3098
  }).actions((self) => {
2919
3099
  const { reqGet, reqPost } = createRequestHelpers(self, getEnv10);
2920
3100
  return {
@@ -3150,7 +3330,7 @@ var AuthModel = {
3150
3330
  * GET Auth/AuthorizationUrl — OAuth URL to open in a popup when user picks a provider.
3151
3331
  * @param {string} participantId
3152
3332
  * @param {string|number} emailProvider — google, gmail, 1, outlook, microsoft, 2
3153
- * @param {{ host?: string }} [opts]
3333
+ * @param {{ host?: string, authorizedByParticipantId?: string }} [opts]
3154
3334
  * @returns {Promise<{ status: string, data?: object, message?: string }>}
3155
3335
  */
3156
3336
  async getAuthorizationUrl(participantId, emailProvider, opts = {}) {
@@ -3160,6 +3340,9 @@ var AuthModel = {
3160
3340
  email_provider: String(emailProvider)
3161
3341
  };
3162
3342
  if (opts.host) q.host = opts.host;
3343
+ if (opts.authorizedByParticipantId) {
3344
+ q.authorized_by_participant_id = String(opts.authorizedByParticipantId);
3345
+ }
3163
3346
  const res = await reqGet("/Auth/AuthorizationUrl", q);
3164
3347
  if (res.status === "success" && res.data) {
3165
3348
  res.data = mapAuthorizationUrlFromApi(res.data);
@@ -3244,10 +3427,10 @@ var AuthModel = {
3244
3427
  var Auth_default = AuthModel;
3245
3428
 
3246
3429
  // src/models/appointment/index.js
3247
- import { types as types22, getEnv as getEnv11 } from "mobx-state-tree";
3248
- var RootStore = types22.model("RootStore", {
3249
- calendars: types22.optional(types22.map(Calendar_default), {}),
3250
- events: types22.optional(types22.map(Event_default), {})
3430
+ import { types as types23, getEnv as getEnv11 } from "mobx-state-tree";
3431
+ var RootStore = types23.model("RootStore", {
3432
+ calendars: types23.optional(types23.map(Calendar_default), {}),
3433
+ events: types23.optional(types23.map(Event_default), {})
3251
3434
  }).actions((self) => ({
3252
3435
  addCalendar(snapshot) {
3253
3436
  const cal = Calendar_default.create(snapshot);
@@ -3266,10 +3449,14 @@ function createRootStore(initialState = {}) {
3266
3449
  return RootStore.create(initialState, { env });
3267
3450
  }
3268
3451
  export {
3452
+ ActivityLogCategory,
3453
+ ActivityLog_default as ActivityLogModel,
3454
+ ActivityLogType,
3269
3455
  Asset_default as AssetModel,
3270
3456
  AssignmentMethod,
3271
3457
  AttendeeStatus,
3272
3458
  Auth_default as AuthModel,
3459
+ AuthorizationSource,
3273
3460
  AvailabilityDetail_default as AvailabilityDetailModel,
3274
3461
  Availability_default as AvailabilityModel,
3275
3462
  CALENDAR_AUTH_MESSAGE_TYPE,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazeo.com/calendar-client",
3
- "version": "1.0.56",
3
+ "version": "1.0.58",
4
4
  "description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
5
5
  "exports": {
6
6
  ".": {