@blazeo.com/calendar-client 1.0.12 → 1.0.14

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.js CHANGED
@@ -551,16 +551,21 @@ EventModel.getByVisitorPhone = async (phone, opts = {}) => {
551
551
  }
552
552
  return null;
553
553
  };
554
- EventModel.getByDateRangeWithFilters = async (companyKey, startDateFrom, startDateTo, opts = {}) => {
554
+ async function getByFiltersInternal(path, companyKey, opts = {}, dateRange = null) {
555
555
  if (companyKey == null || String(companyKey).trim() === "") {
556
556
  throw new Error("companyKey required");
557
557
  }
558
558
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
559
559
  const query = {
560
- company_key: String(companyKey).trim(),
561
- start_date_from: startDateFrom,
562
- start_date_to: startDateTo
560
+ company_key: String(companyKey).trim()
563
561
  };
562
+ if (dateRange) {
563
+ if (dateRange.startDateFrom == null || dateRange.startDateTo == null) {
564
+ throw new Error("startDateFrom and startDateTo required");
565
+ }
566
+ query.start_date_from = dateRange.startDateFrom;
567
+ query.start_date_to = dateRange.startDateTo;
568
+ }
564
569
  const offset = opts.offset ?? getDefaultOffset();
565
570
  if (opts.calendarId != null && opts.calendarId !== "") query.calendar_id = opts.calendarId;
566
571
  if (opts.participantId != null && opts.participantId !== "") query.participant_id = opts.participantId;
@@ -586,7 +591,7 @@ EventModel.getByDateRangeWithFilters = async (companyKey, startDateFrom, startDa
586
591
  if (opts.skip != null) query.skip = opts.skip;
587
592
  if (opts.take != null) query.take = opts.take;
588
593
  }
589
- const res = await reqGet("/event/search/daterange/get", query, { headers: { offset: String(offset) } });
594
+ const res = await reqGet(path, query, { headers: { offset: String(offset) } });
590
595
  if (res.status !== "success") {
591
596
  return { events: [], totalCount: 0 };
592
597
  }
@@ -596,7 +601,9 @@ EventModel.getByDateRangeWithFilters = async (companyKey, startDateFrom, startDa
596
601
  const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : eventsRaw.length;
597
602
  const events = eventsRaw.map((e) => EventModel.create(mapEventFromApi(e), { env: getConfig() }));
598
603
  return { events, totalCount };
599
- };
604
+ }
605
+ EventModel.getByDateRangeWithFilters = async (companyKey, startDateFrom, startDateTo, opts = {}) => getByFiltersInternal("/event/search/daterange/get", companyKey, opts, { startDateFrom, startDateTo });
606
+ EventModel.getByFilters = async (companyKey, opts = {}) => getByFiltersInternal("/event/search/get", companyKey, opts);
600
607
  EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) => {
601
608
  const { req } = createRequestHelpersFromEnv(getConfig());
602
609
  const query = { calendar_id: calendarId, year, month, day };
@@ -2039,6 +2046,10 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
2039
2046
  const u = String(sortOrderRaw).trim().toUpperCase();
2040
2047
  query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
2041
2048
  }
2049
+ const searchColumn = opts.searchColumn ?? opts.search_column ?? opts.column;
2050
+ if (searchColumn != null && String(searchColumn).trim() !== "") query.search_column = String(searchColumn).trim();
2051
+ const searchText = opts.searchText ?? opts.search_text ?? opts.search;
2052
+ if (searchText != null && String(searchText).trim() !== "") query.search_text = String(searchText).trim();
2042
2053
  if (opts.page != null) {
2043
2054
  query.page = opts.page;
2044
2055
  if (opts.page_size != null) query.page_size = opts.page_size;
@@ -2055,6 +2066,18 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
2055
2066
  }
2056
2067
  return null;
2057
2068
  };
2069
+ LeadModel.getSources = async () => {
2070
+ var _a;
2071
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
2072
+ const res = await reqGet("/lead/sources/get");
2073
+ if (res.status === "success") {
2074
+ const sources = Array.isArray(res.data) ? res.data : Array.isArray((_a = res.data) == null ? void 0 : _a.sources) ? res.data.sources : null;
2075
+ if (sources) {
2076
+ return [...new Set(sources.map((s) => String(s ?? "").trim()).filter(Boolean))];
2077
+ }
2078
+ }
2079
+ return [];
2080
+ };
2058
2081
  var Lead_default = LeadModel;
2059
2082
 
2060
2083
  // src/models/appointment/index.js
package/dist/index.mjs CHANGED
@@ -498,16 +498,21 @@ EventModel.getByVisitorPhone = async (phone, opts = {}) => {
498
498
  }
499
499
  return null;
500
500
  };
501
- EventModel.getByDateRangeWithFilters = async (companyKey, startDateFrom, startDateTo, opts = {}) => {
501
+ async function getByFiltersInternal(path, companyKey, opts = {}, dateRange = null) {
502
502
  if (companyKey == null || String(companyKey).trim() === "") {
503
503
  throw new Error("companyKey required");
504
504
  }
505
505
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
506
506
  const query = {
507
- company_key: String(companyKey).trim(),
508
- start_date_from: startDateFrom,
509
- start_date_to: startDateTo
507
+ company_key: String(companyKey).trim()
510
508
  };
509
+ if (dateRange) {
510
+ if (dateRange.startDateFrom == null || dateRange.startDateTo == null) {
511
+ throw new Error("startDateFrom and startDateTo required");
512
+ }
513
+ query.start_date_from = dateRange.startDateFrom;
514
+ query.start_date_to = dateRange.startDateTo;
515
+ }
511
516
  const offset = opts.offset ?? getDefaultOffset();
512
517
  if (opts.calendarId != null && opts.calendarId !== "") query.calendar_id = opts.calendarId;
513
518
  if (opts.participantId != null && opts.participantId !== "") query.participant_id = opts.participantId;
@@ -533,7 +538,7 @@ EventModel.getByDateRangeWithFilters = async (companyKey, startDateFrom, startDa
533
538
  if (opts.skip != null) query.skip = opts.skip;
534
539
  if (opts.take != null) query.take = opts.take;
535
540
  }
536
- const res = await reqGet("/event/search/daterange/get", query, { headers: { offset: String(offset) } });
541
+ const res = await reqGet(path, query, { headers: { offset: String(offset) } });
537
542
  if (res.status !== "success") {
538
543
  return { events: [], totalCount: 0 };
539
544
  }
@@ -543,7 +548,9 @@ EventModel.getByDateRangeWithFilters = async (companyKey, startDateFrom, startDa
543
548
  const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : eventsRaw.length;
544
549
  const events = eventsRaw.map((e) => EventModel.create(mapEventFromApi(e), { env: getConfig() }));
545
550
  return { events, totalCount };
546
- };
551
+ }
552
+ EventModel.getByDateRangeWithFilters = async (companyKey, startDateFrom, startDateTo, opts = {}) => getByFiltersInternal("/event/search/daterange/get", companyKey, opts, { startDateFrom, startDateTo });
553
+ EventModel.getByFilters = async (companyKey, opts = {}) => getByFiltersInternal("/event/search/get", companyKey, opts);
547
554
  EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) => {
548
555
  const { req } = createRequestHelpersFromEnv(getConfig());
549
556
  const query = { calendar_id: calendarId, year, month, day };
@@ -1986,6 +1993,10 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
1986
1993
  const u = String(sortOrderRaw).trim().toUpperCase();
1987
1994
  query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
1988
1995
  }
1996
+ const searchColumn = opts.searchColumn ?? opts.search_column ?? opts.column;
1997
+ if (searchColumn != null && String(searchColumn).trim() !== "") query.search_column = String(searchColumn).trim();
1998
+ const searchText = opts.searchText ?? opts.search_text ?? opts.search;
1999
+ if (searchText != null && String(searchText).trim() !== "") query.search_text = String(searchText).trim();
1989
2000
  if (opts.page != null) {
1990
2001
  query.page = opts.page;
1991
2002
  if (opts.page_size != null) query.page_size = opts.page_size;
@@ -2002,6 +2013,18 @@ LeadModel.getByCompany = async (companyKey, opts = {}) => {
2002
2013
  }
2003
2014
  return null;
2004
2015
  };
2016
+ LeadModel.getSources = async () => {
2017
+ var _a;
2018
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
2019
+ const res = await reqGet("/lead/sources/get");
2020
+ if (res.status === "success") {
2021
+ const sources = Array.isArray(res.data) ? res.data : Array.isArray((_a = res.data) == null ? void 0 : _a.sources) ? res.data.sources : null;
2022
+ if (sources) {
2023
+ return [...new Set(sources.map((s) => String(s ?? "").trim()).filter(Boolean))];
2024
+ }
2025
+ }
2026
+ return [];
2027
+ };
2005
2028
  var Lead_default = LeadModel;
2006
2029
 
2007
2030
  // src/models/appointment/index.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazeo.com/calendar-client",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
5
5
  "exports": {
6
6
  ".": {