@blazeo.com/calendar-client 1.0.5 → 1.0.7

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/README.md CHANGED
@@ -1,54 +1,54 @@
1
- # @blazeo.com/calendar-client
2
-
3
- **Private package** – for Blazeo internal teams only. JavaScript client for the Blazeo Calendar / Appointment API. Use it in React (or any JS app) to call calendar and event endpoints via MobX State Tree models.
4
-
5
- ## Install
6
-
7
- From your npm registry (internal teams; ensure you're logged in to the scope):
8
-
9
- ```bash
10
- npm install @blazeo.com/calendar-client
11
- ```
12
-
13
- Or link locally:
14
-
15
- ```bash
16
- cd calendar-client && npm run build && npm link
17
- cd your-app && npm link @blazeo.com/calendar-client
18
- ```
19
-
20
- ## Usage
21
-
22
- Configure once at app startup, then use models and their methods:
23
-
24
- ```js
25
- import { configure, setBaseUrl, setConsumer, CalendarModel, createRootStore } from '@blazeo.com/calendar-client';
26
-
27
- configure({ baseUrl: 'https://your-appointment-api.example.com' });
28
- // or: setBaseUrl('https://localhost:7051');
29
- setConsumer('my-app'); // optional: sent as Consumer header (e.g. for lead source)
30
-
31
- // Calendar static methods (no store needed)
32
- const timezones = await CalendarModel.getTimeZones();
33
- const calendar = await CalendarModel.get('calendar-guid');
34
-
35
- // Or use RootStore with models
36
- const store = createRootStore();
37
- const cal = store.addCalendar({ calendarId: 'my-cal', name: 'My Calendar' });
38
- await cal.create(); // POST to backend
39
- ```
40
-
41
- ## API overview
42
-
43
- - **CalendarModel (static):** `get`, `getByCompany`, `getTimeZones`, `getTimeZone`, `getParticipants`, `getMonth`, `getEvents`, etc.
44
- - **EventModel (instance):** `get`, `create`, `cancel`, `getCancellable`, `getAvailability`, `setReminder`
45
- - **FlowModel:** Same pattern as Calendar — `FlowModel.create({}, { env })` with no fields; static `get`, `getRaw`, `list`, `createFlow`, `updateFlow`, `delete`, `duplicate`, appearance/embed/public/preview helpers; instance methods mirror those using `flowId` on the snapshot
46
- - **LeadModel:** `LeadModel.create({}, { env })`; static `get`, `getRaw`, `getByEmail`, `getByCompany`; instance `get`, `getByEmail`, `getByCompany` (uses `leadId` / `email` / `companyKey` on the snapshot)
47
- - **RootStore:** `addCalendar`, `addEvent`
48
-
49
- All methods return `Promise<{ status, data?, message? }>`. Check `response.status === 'success'` and use `response.data`.
50
-
51
- ## Samples
52
-
53
- - **`sample/`** – Uses the package via `file:..` for local development (run `npm run build` in parent first).
54
- - **`sample-npm/`** – Uses the package from npm: `npm i @blazeo.com/calendar-client`. For testing the published package.
1
+ # @blazeo.com/calendar-client
2
+
3
+ **Private package** – for Blazeo internal teams only. JavaScript client for the Blazeo Calendar / Appointment API. Use it in React (or any JS app) to call calendar and event endpoints via MobX State Tree models.
4
+
5
+ ## Install
6
+
7
+ From your npm registry (internal teams; ensure you're logged in to the scope):
8
+
9
+ ```bash
10
+ npm install @blazeo.com/calendar-client
11
+ ```
12
+
13
+ Or link locally:
14
+
15
+ ```bash
16
+ cd calendar-client && npm run build && npm link
17
+ cd your-app && npm link @blazeo.com/calendar-client
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ Configure once at app startup, then use models and their methods:
23
+
24
+ ```js
25
+ import { configure, setBaseUrl, setConsumer, CalendarModel, createRootStore } from '@blazeo.com/calendar-client';
26
+
27
+ configure({ baseUrl: 'https://your-appointment-api.example.com' });
28
+ // or: setBaseUrl('https://localhost:7051');
29
+ setConsumer('my-app'); // optional: sent as Consumer header (e.g. for lead source)
30
+
31
+ // Calendar static methods (no store needed)
32
+ const timezones = await CalendarModel.getTimeZones();
33
+ const calendar = await CalendarModel.get('calendar-guid');
34
+
35
+ // Or use RootStore with models
36
+ const store = createRootStore();
37
+ const cal = store.addCalendar({ calendarId: 'my-cal', name: 'My Calendar' });
38
+ await cal.create(); // POST to backend
39
+ ```
40
+
41
+ ## API overview
42
+
43
+ - **CalendarModel (static):** `get`, `getByCompany`, `getTimeZones`, `getTimeZone`, `getParticipants`, `getMonth`, `getEvents`, etc.
44
+ - **EventModel (instance):** `get`, `create`, `cancel`, `getCancellable`, `getAvailability`, `setReminder`
45
+ - **FlowModel:** Same pattern as Calendar — `FlowModel.create({}, { env })` with no fields; static `get`, `getRaw`, `list`, `createFlow`, `updateFlow`, `delete`, `duplicate`, appearance/embed/public/preview helpers; instance methods mirror those using `flowId` on the snapshot
46
+ - **LeadModel:** `LeadModel.create({}, { env })`; static `get`, `getRaw`, `getByEmail`, `getByCompany`; instance `get`, `getByEmail`, `getByCompany` (uses `leadId` / `email` / `companyKey` on the snapshot)
47
+ - **RootStore:** `addCalendar`, `addEvent`
48
+
49
+ All methods return `Promise<{ status, data?, message? }>`. Check `response.status === 'success'` and use `response.data`.
50
+
51
+ ## Samples
52
+
53
+ - **`sample/`** – Uses the package via `file:..` for local development (run `npm run build` in parent first).
54
+ - **`sample-npm/`** – Uses the package from npm: `npm i @blazeo.com/calendar-client`. For testing the published package.
package/dist/index.d.ts CHANGED
@@ -1,129 +1,146 @@
1
- /** @blazeo.com/calendar-client - type declarations */
2
-
3
- export function configure(env: { baseUrl?: string; consumer?: string; fetch?: typeof fetch; getDefaultOffset?: () => number }): void;
4
- export function getConfig(): { baseUrl?: string; consumer?: string; fetch?: typeof fetch; getDefaultOffset?: () => number } | null;
5
- export function setBaseUrl(baseUrl: string): void;
6
- export function setConsumer(consumer: string): void;
7
- export function getConfigStore(): unknown;
8
-
9
- export const ConfigModel: unknown;
10
-
11
- export const CalendarModel: {
12
- get(calendarId: string): Promise<unknown>;
13
- getRaw(calendarId: string): Promise<{ status: string; data?: unknown; message?: string }>;
14
- getByCompany(companyKey: string): Promise<unknown[]>;
15
- getTimeZones(): Promise<unknown>;
16
- getTimeZone(timezoneId: string): Promise<unknown>;
17
- getParticipants(calendarId: string): Promise<unknown>;
18
- getCalendarParticipant(calendarId: string): Promise<unknown>;
19
- getParticipantsInfo(calendarId: string): Promise<unknown>;
20
- getMonth(calendarId: string, year: number, month: number): Promise<unknown>;
21
- getEvents(calendarId: string): Promise<unknown>;
22
- createWithParticipants(name: string, companyKey: string, participantIds: string[], description: string, calendarId?: string): Promise<unknown>;
23
- editWithParticipants(calendarId: string, name: string, participantIds: string[], description: string): Promise<unknown>;
24
- create(snapshot: object, options?: { env?: object }): unknown;
25
- };
26
-
27
- export const EventModel: {
28
- get(eventId: string): Promise<unknown>;
29
- getByExternalId(externalEventId: string): Promise<unknown>;
30
- getRoundRobinParticipant(calendarId: string): Promise<unknown>;
31
- getEarliestAvailableDays(calendarId: string, count: number, opts?: { year?: number; month?: number; day?: number; offset?: number }): Promise<string[] | null>;
32
- getDaySelectable(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<boolean>;
33
- getByVisitorEmail(email: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
34
- getByVisitorPhone(phone: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
35
- getAvailability(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<unknown[]>;
36
- cancel(eventId: string): Promise<unknown>;
37
- getCancellable(eventId: string): Promise<boolean>;
38
- createEvent(payload: object, offsetMinutes?: number): Promise<unknown>;
39
- reschedule(payload: object, offsetMinutes?: number): Promise<unknown>;
40
- updateEvent(payload: object): Promise<unknown>;
41
- createTest(payload: object, offsetMinutes?: number): Promise<unknown>;
42
- getCustomData(calendarId: string, eventId?: string): Promise<unknown>;
43
- setReminder(eventId: string): Promise<unknown>;
44
- setAttendeeStatus(eventId: string, attendeeStatus: number | string): Promise<unknown>;
45
- create(snapshot: object, options?: { env?: object }): unknown;
46
- };
47
-
48
- export const AvailabilityModel: { create(snapshot: object, options?: { env?: object }): unknown };
49
- export const AvailabilityDetailModel: { create(snapshot: object, options?: { env?: object }): unknown };
50
- export const CalendarParticipantModel: {
51
- getByCalendar(calendarId: string): Promise<unknown[] | null>;
52
- getInfoByCalendar(calendarId: string): Promise<unknown[] | null>;
53
- getByParticipant(participantId: string): Promise<unknown[] | null>;
54
- create(snapshot: object, options?: { env?: object }): unknown;
55
- };
56
- export const ParticipantModel: {
57
- get(participantId: string): Promise<unknown>;
58
- getByIds(participantIds: string[] | string): Promise<unknown[] | null>;
59
- getAll(companyKey: string): Promise<unknown[] | null>;
60
- add(payload: object, calendarId?: string): Promise<unknown>;
61
- remove(participantId: string): Promise<unknown>;
62
- update(payload: object): Promise<unknown>;
63
- save(payload: object): Promise<unknown>;
64
- sendEmail(participantId: string): Promise<unknown>;
65
- create(snapshot: object, options?: { env?: object }): unknown;
66
- };
67
- export const OpeningHourModel: { create(snapshot: object, options?: { env?: object }): unknown };
68
- export const TimeSlotModel: { create(snapshot: object, options?: { env?: object }): unknown };
69
- export const TimeFrameModel: { create(snapshot: object, options?: { env?: object }): unknown };
70
- export const SettingModel: {
71
- get(calendarId: string): Promise<unknown>;
72
- save(payload: object): Promise<unknown>;
73
- uploadLogo(calendarId: string, file: File | Blob): Promise<unknown>;
74
- create(snapshot: object, options?: { env?: object }): unknown;
75
- };
76
- export const CompanyModel: {
77
- get(companyKey: string): Promise<unknown>;
78
- getAll(): Promise<unknown[] | null>;
79
- save(payload: object): Promise<unknown>;
80
- create(snapshot: object, options?: { env?: object }): unknown;
81
- };
82
- export const CalendarDayModel: { create(snapshot: object, options?: { env?: object }): unknown };
83
- export const ParticipantInfoModel: { create(snapshot: object, options?: { env?: object }): unknown };
84
- export const PreferenceModel: {
85
- getScopes(): Promise<string[] | null>;
86
- getOptions(): Promise<string[] | null>;
87
- getOptionTemplate(option: string): Promise<unknown>;
88
- get(option: string, keys: string | string[]): Promise<unknown>;
89
- set(scope: string, key: string, option: string, body: string | object): Promise<unknown>;
90
- delete(preferenceId: string): Promise<unknown>;
91
- create(snapshot: object, options?: { env?: object }): unknown;
92
- };
93
- export const PreferenceScope: Record<string, number>;
94
-
95
- export const FlowModel: {
96
- getRaw(flowId: string): Promise<{ status: string; data?: unknown; message?: string }>;
97
- list(companyKey: string, includeDeleted?: boolean): Promise<unknown[] | null>;
98
- get(flowId: string): Promise<unknown>;
99
- createFlow(payload: object): Promise<unknown>;
100
- updateFlow(payload: object): Promise<unknown>;
101
- delete(flowId: string): Promise<unknown>;
102
- duplicate(flowId: string, newName?: string): Promise<unknown>;
103
- getAppearance(flowId: string): Promise<unknown>;
104
- saveAppearance(payload: object): Promise<unknown>;
105
- getEmbed(flowId: string): Promise<unknown>;
106
- saveEmbed(payload: object): Promise<unknown>;
107
- getPublic(flowId: string): Promise<{ flow: unknown; appearance: unknown; embed: unknown } | null>;
108
- getPreview(flowId: string): Promise<{ flow: unknown; appearance: unknown; embed: unknown } | null>;
109
- /** Empty snapshot is valid: `FlowModel.create({}, { env })` after configure() */
110
- create(snapshot?: object, options?: { env?: object }): unknown;
111
- };
112
-
113
- export const LeadModel: {
114
- getRaw(leadId: string): Promise<{ status: string; data?: unknown; message?: string }>;
115
- get(leadId: string): Promise<unknown>;
116
- getByEmail(email: string, companyKey: string): Promise<unknown>;
117
- getByCompany(companyKey: string, opts?: { skip?: number; take?: number }): Promise<unknown[] | null>;
118
- /** Empty snapshot is valid: `LeadModel.create({}, { env })` after configure() */
119
- create(snapshot?: object, options?: { env?: object }): unknown;
120
- };
121
-
122
- export const RootStore: unknown;
123
- export function createRootStore(initialState?: object): unknown;
124
-
125
- export const Unit: Record<string, number>;
126
- export const AssignmentMethod: Record<string, number>;
127
- export const AttendeeStatus: Record<string, number>;
128
- export const RecurringFrequency: Record<string, number>;
129
- export const DayOfWeek: Record<string, number>;
1
+ /** @blazeo.com/calendar-client - type declarations */
2
+
3
+ export function configure(env: { baseUrl?: string; consumer?: string; fetch?: typeof fetch; getDefaultOffset?: () => number }): void;
4
+ export function getConfig(): { baseUrl?: string; consumer?: string; fetch?: typeof fetch; getDefaultOffset?: () => number } | null;
5
+ export function setBaseUrl(baseUrl: string): void;
6
+ export function setConsumer(consumer: string): void;
7
+ export function getConfigStore(): unknown;
8
+
9
+ export const ConfigModel: unknown;
10
+
11
+ export const CalendarModel: {
12
+ get(calendarId: string): Promise<unknown>;
13
+ getRaw(calendarId: string): Promise<{ status: string; data?: unknown; message?: string }>;
14
+ getByCompany(companyKey: string): Promise<unknown[]>;
15
+ getTimeZones(): Promise<unknown>;
16
+ getTimeZone(timezoneId: string): Promise<unknown>;
17
+ getParticipants(calendarId: string): Promise<unknown>;
18
+ getCalendarParticipant(calendarId: string): Promise<unknown>;
19
+ getParticipantsInfo(calendarId: string): Promise<unknown>;
20
+ getMonth(calendarId: string, year: number, month: number): Promise<unknown>;
21
+ getEvents(calendarId: string): Promise<unknown>;
22
+ createWithParticipants(name: string, companyKey: string, participantIds: string[], description: string, calendarId?: string): Promise<unknown>;
23
+ editWithParticipants(calendarId: string, name: string, participantIds: string[], description: string): Promise<unknown>;
24
+ create(snapshot: object, options?: { env?: object }): unknown;
25
+ };
26
+
27
+ export const EventModel: {
28
+ get(eventId: string): Promise<unknown>;
29
+ getByExternalId(externalEventId: string): Promise<unknown>;
30
+ getRoundRobinParticipant(calendarId: string): Promise<unknown>;
31
+ getEarliestAvailableDays(calendarId: string, count: number, opts?: { year?: number; month?: number; day?: number; offset?: number }): Promise<string[] | null>;
32
+ getDaySelectable(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<boolean>;
33
+ getByVisitorEmail(email: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
34
+ getByVisitorPhone(phone: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
35
+ getAvailability(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<unknown[]>;
36
+ cancel(eventId: string): Promise<unknown>;
37
+ getCancellable(eventId: string): Promise<boolean>;
38
+ createEvent(payload: object, offsetMinutes?: number): Promise<unknown>;
39
+ reschedule(payload: object, offsetMinutes?: number): Promise<unknown>;
40
+ updateEvent(payload: object): Promise<unknown>;
41
+ createTest(payload: object, offsetMinutes?: number): Promise<unknown>;
42
+ getCustomData(calendarId: string, eventId?: string): Promise<unknown>;
43
+ setReminder(eventId: string): Promise<unknown>;
44
+ setAttendeeStatus(eventId: string, attendeeStatus: number | string): Promise<unknown>;
45
+ create(snapshot: object, options?: { env?: object }): unknown;
46
+ };
47
+
48
+ export const AvailabilityModel: { create(snapshot: object, options?: { env?: object }): unknown };
49
+ export const AvailabilityDetailModel: { create(snapshot: object, options?: { env?: object }): unknown };
50
+ export const CalendarParticipantModel: {
51
+ getByCalendar(calendarId: string): Promise<unknown[] | null>;
52
+ getInfoByCalendar(calendarId: string): Promise<unknown[] | null>;
53
+ getByParticipant(participantId: string): Promise<unknown[] | null>;
54
+ create(snapshot: object, options?: { env?: object }): unknown;
55
+ };
56
+ export const ParticipantModel: {
57
+ get(participantId: string): Promise<unknown>;
58
+ getByIds(participantIds: string[] | string): Promise<unknown[] | null>;
59
+ getAll(companyKey: string): Promise<unknown[] | null>;
60
+ add(payload: object, calendarId?: string): Promise<unknown>;
61
+ remove(participantId: string): Promise<unknown>;
62
+ update(payload: object): Promise<unknown>;
63
+ save(payload: object): Promise<unknown>;
64
+ sendEmail(participantId: string): Promise<unknown>;
65
+ create(snapshot: object, options?: { env?: object }): unknown;
66
+ };
67
+ export const OpeningHourModel: { create(snapshot: object, options?: { env?: object }): unknown };
68
+ export const TimeSlotModel: { create(snapshot: object, options?: { env?: object }): unknown };
69
+ export const TimeFrameModel: { create(snapshot: object, options?: { env?: object }): unknown };
70
+ export const SettingModel: {
71
+ get(calendarId: string): Promise<unknown>;
72
+ save(payload: object): Promise<unknown>;
73
+ uploadLogo(calendarId: string, file: File | Blob): Promise<unknown>;
74
+ create(snapshot: object, options?: { env?: object }): unknown;
75
+ };
76
+ export const CompanyModel: {
77
+ get(companyKey: string): Promise<unknown>;
78
+ getAll(): Promise<unknown[] | null>;
79
+ save(payload: object): Promise<unknown>;
80
+ create(snapshot: object, options?: { env?: object }): unknown;
81
+ };
82
+ export const CalendarDayModel: { create(snapshot: object, options?: { env?: object }): unknown };
83
+ export const ParticipantInfoModel: { create(snapshot: object, options?: { env?: object }): unknown };
84
+ export const PreferenceModel: {
85
+ getScopes(): Promise<string[] | null>;
86
+ getOptions(): Promise<string[] | null>;
87
+ getOptionTemplate(option: string): Promise<unknown>;
88
+ get(option: string, keys: string | string[]): Promise<unknown>;
89
+ set(scope: string, key: string, option: string, body: string | object): Promise<unknown>;
90
+ delete(preferenceId: string): Promise<unknown>;
91
+ create(snapshot: object, options?: { env?: object }): unknown;
92
+ };
93
+ export const PreferenceScope: Record<string, number>;
94
+
95
+ export const FlowModel: {
96
+ getRaw(flowId: string): Promise<{ status: string; data?: unknown; message?: string }>;
97
+ list(companyKey: string, includeDeleted?: boolean): Promise<unknown[] | null>;
98
+ get(flowId: string): Promise<unknown>;
99
+ createFlow(payload: object): Promise<unknown>;
100
+ updateFlow(payload: object): Promise<unknown>;
101
+ delete(flowId: string): Promise<unknown>;
102
+ duplicate(flowId: string, newName?: string): Promise<unknown>;
103
+ getAppearance(flowId: string): Promise<unknown>;
104
+ saveAppearance(payload: object): Promise<unknown>;
105
+ getEmbed(flowId: string): Promise<unknown>;
106
+ saveEmbed(payload: object): Promise<unknown>;
107
+ getPublic(flowId: string): Promise<{ flow: unknown; appearance: unknown; embed: unknown } | null>;
108
+ getPreview(flowId: string): Promise<{ flow: unknown; appearance: unknown; embed: unknown } | null>;
109
+ /** Empty snapshot is valid: `FlowModel.create({}, { env })` after configure() */
110
+ create(snapshot?: object, options?: { env?: object }): unknown;
111
+ };
112
+
113
+ export const LeadModel: {
114
+ getRaw(leadId: string): Promise<{ status: string; data?: unknown; message?: string }>;
115
+ get(leadId: string): Promise<unknown>;
116
+ getByEmail(email: string, companyKey: string): Promise<unknown>;
117
+ getByCompany(
118
+ companyKey: string,
119
+ opts?: {
120
+ skip?: number;
121
+ take?: number;
122
+ /** Maps to API query `sort`. */
123
+ sortBy?: string;
124
+ /** Maps to API query `sort_dir` (`asc` / `desc`). */
125
+ sortOrder?: 'ASC' | 'DESC' | 'asc' | 'desc' | string;
126
+ /** Same as `sortBy` (sent as `sort` on the wire). */
127
+ sort?: string;
128
+ sort_column?: string;
129
+ /** Same as `sortOrder` (sent as `sort_dir` on the wire). */
130
+ sort_dir?: 'asc' | 'desc' | string;
131
+ page?: number;
132
+ page_size?: number;
133
+ }
134
+ ): Promise<unknown[] | null>;
135
+ /** Empty snapshot is valid: `LeadModel.create({}, { env })` after configure() */
136
+ create(snapshot?: object, options?: { env?: object }): unknown;
137
+ };
138
+
139
+ export const RootStore: unknown;
140
+ export function createRootStore(initialState?: object): unknown;
141
+
142
+ export const Unit: Record<string, number>;
143
+ export const AssignmentMethod: Record<string, number>;
144
+ export const AttendeeStatus: Record<string, number>;
145
+ export const RecurringFrequency: Record<string, number>;
146
+ export const DayOfWeek: Record<string, number>;
package/dist/index.js CHANGED
@@ -719,7 +719,7 @@ var CalendarModel = import_mobx_state_tree7.types.model("Calendar", {
719
719
  };
720
720
  const res = await reqPost("/Calendar/Create", payload);
721
721
  if (res.status === "success" && res.data) {
722
- (0, import_mobx_state_tree7.applySnapshot)(self, { ...res.data, calendarId: res.data.calendarId || self.calendarId });
722
+ self, { ...res.data, calendarId: res.data.calendarId || self.calendarId };
723
723
  }
724
724
  return res;
725
725
  },
@@ -1824,8 +1824,20 @@ LeadModel.getByEmail = async (email, companyKey) => {
1824
1824
  LeadModel.getByCompany = async (companyKey, opts = {}) => {
1825
1825
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
1826
1826
  const query = { company_key: companyKey };
1827
- if (opts.skip != null) query.skip = opts.skip;
1828
- if (opts.take != null) query.take = opts.take;
1827
+ const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
1828
+ if (sortBy != null && sortBy !== "") query.sort = sortBy;
1829
+ const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
1830
+ if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
1831
+ const u = String(sortOrderRaw).trim().toUpperCase();
1832
+ query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
1833
+ }
1834
+ if (opts.page != null) {
1835
+ query.page = opts.page;
1836
+ if (opts.page_size != null) query.page_size = opts.page_size;
1837
+ } else {
1838
+ if (opts.skip != null) query.skip = opts.skip;
1839
+ if (opts.take != null) query.take = opts.take;
1840
+ }
1829
1841
  const res = await reqGet("/lead/company/get", query);
1830
1842
  if (res.status === "success" && Array.isArray(res.data)) {
1831
1843
  return res.data.map((l) => LeadModel.create(mapLeadFromApi(l), { env: getConfig() }));
package/dist/index.mjs CHANGED
@@ -666,7 +666,7 @@ var CalendarModel = types7.model("Calendar", {
666
666
  };
667
667
  const res = await reqPost("/Calendar/Create", payload);
668
668
  if (res.status === "success" && res.data) {
669
- applySnapshot2(self, { ...res.data, calendarId: res.data.calendarId || self.calendarId });
669
+ self, { ...res.data, calendarId: res.data.calendarId || self.calendarId };
670
670
  }
671
671
  return res;
672
672
  },
@@ -1771,8 +1771,20 @@ LeadModel.getByEmail = async (email, companyKey) => {
1771
1771
  LeadModel.getByCompany = async (companyKey, opts = {}) => {
1772
1772
  const { reqGet } = createRequestHelpersFromEnv(getConfig());
1773
1773
  const query = { company_key: companyKey };
1774
- if (opts.skip != null) query.skip = opts.skip;
1775
- if (opts.take != null) query.take = opts.take;
1774
+ const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
1775
+ if (sortBy != null && sortBy !== "") query.sort = sortBy;
1776
+ const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
1777
+ if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
1778
+ const u = String(sortOrderRaw).trim().toUpperCase();
1779
+ query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
1780
+ }
1781
+ if (opts.page != null) {
1782
+ query.page = opts.page;
1783
+ if (opts.page_size != null) query.page_size = opts.page_size;
1784
+ } else {
1785
+ if (opts.skip != null) query.skip = opts.skip;
1786
+ if (opts.take != null) query.take = opts.take;
1787
+ }
1776
1788
  const res = await reqGet("/lead/company/get", query);
1777
1789
  if (res.status === "success" && Array.isArray(res.data)) {
1778
1790
  return res.data.map((l) => LeadModel.create(mapLeadFromApi(l), { env: getConfig() }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazeo.com/calendar-client",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
5
5
  "exports": {
6
6
  ".": {