@blazeo.com/calendar-client 1.0.3 → 1.0.4

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
@@ -41,10 +41,13 @@ await cal.create(); // POST to backend
41
41
 
42
42
  - **CalendarModel (static):** `get`, `getByCompany`, `getTimeZones`, `getTimeZone`, `getParticipants`, `getMonth`, `getEvents`, etc.
43
43
  - **EventModel (instance):** `get`, `create`, `cancel`, `getCancellable`, `getAvailability`, `setReminder`
44
+ - **FlowModel (static):** `list`, `get`, `createFlow`, `updateFlow`, `delete`, `duplicate`, `getAppearance`, `saveAppearance`, `getEmbed`, `saveEmbed`, `getPublic`, `getPreview`
45
+ - **LeadModel (static):** `get`, `getByEmail`, `getByCompany`
44
46
  - **RootStore:** `addCalendar`, `addEvent`
45
47
 
46
48
  All methods return `Promise<{ status, data?, message? }>`. Check `response.status === 'success'` and use `response.data`.
47
49
 
48
- ## Sample
50
+ ## Samples
49
51
 
50
- See the `sample` folder for a minimal React app that uses this package.
52
+ - **`sample/`** – Uses the package via `file:..` for local development (run `npm run build` in parent first).
53
+ - **`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,101 +1,124 @@
1
- /** @blazeo.com/calendar-client - type declarations */
2
-
3
- export function configure(env: { baseUrl?: string; fetch?: typeof fetch; getDefaultOffset?: () => number }): void;
4
- export function getConfig(): { baseUrl?: string; fetch?: typeof fetch; getDefaultOffset?: () => number } | null;
5
- export function setBaseUrl(baseUrl: string): void;
6
- export function getConfigStore(): unknown;
7
-
8
- export const ConfigModel: unknown;
9
-
10
- export const CalendarModel: {
11
- get(calendarId: string): Promise<unknown>;
12
- getRaw(calendarId: string): Promise<{ status: string; data?: unknown; message?: string }>;
13
- getByCompany(companyKey: string): Promise<unknown[]>;
14
- getTimeZones(): Promise<unknown>;
15
- getTimeZone(timezoneId: string): Promise<unknown>;
16
- getParticipants(calendarId: string): Promise<unknown>;
17
- getCalendarParticipant(calendarId: string): Promise<unknown>;
18
- getParticipantsInfo(calendarId: string): Promise<unknown>;
19
- getMonth(calendarId: string, year: number, month: number): Promise<unknown>;
20
- getEvents(calendarId: string): Promise<unknown>;
21
- createWithParticipants(name: string, companyKey: string, participantIds: string[], description: string, calendarId?: string): Promise<unknown>;
22
- editWithParticipants(calendarId: string, name: string, participantIds: string[], description: string): Promise<unknown>;
23
- create(snapshot: object, options?: { env?: object }): unknown;
24
- };
25
-
26
- export const EventModel: {
27
- get(eventId: string): Promise<unknown>;
28
- getByExternalId(externalEventId: string): Promise<unknown>;
29
- getRoundRobinParticipant(calendarId: string): Promise<unknown>;
30
- getEarliestAvailableDays(calendarId: string, count: number, opts?: { year?: number; month?: number; day?: number; offset?: number }): Promise<string[] | null>;
31
- getDaySelectable(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<boolean>;
32
- getByVisitorEmail(email: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
33
- getByVisitorPhone(phone: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
34
- getAvailability(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<unknown[]>;
35
- cancel(eventId: string): Promise<unknown>;
36
- getCancellable(eventId: string): Promise<boolean>;
37
- createEvent(payload: object, offsetMinutes?: number): Promise<unknown>;
38
- reschedule(payload: object, offsetMinutes?: number): Promise<unknown>;
39
- updateEvent(payload: object): Promise<unknown>;
40
- createTest(payload: object, offsetMinutes?: number): Promise<unknown>;
41
- getCustomData(calendarId: string, eventId?: string): Promise<unknown>;
42
- setReminder(eventId: string): Promise<unknown>;
43
- setAttendeeStatus(eventId: string, attendeeStatus: number | string): Promise<unknown>;
44
- create(snapshot: object, options?: { env?: object }): unknown;
45
- };
46
-
47
- export const AvailabilityModel: { create(snapshot: object, options?: { env?: object }): unknown };
48
- export const AvailabilityDetailModel: { create(snapshot: object, options?: { env?: object }): unknown };
49
- export const CalendarParticipantModel: {
50
- getByCalendar(calendarId: string): Promise<unknown[] | null>;
51
- getInfoByCalendar(calendarId: string): Promise<unknown[] | null>;
52
- getByParticipant(participantId: string): Promise<unknown[] | null>;
53
- create(snapshot: object, options?: { env?: object }): unknown;
54
- };
55
- export const ParticipantModel: {
56
- get(participantId: string): Promise<unknown>;
57
- getByIds(participantIds: string[] | string): Promise<unknown[] | null>;
58
- getAll(companyKey: string): Promise<unknown[] | null>;
59
- add(payload: object, calendarId?: string): Promise<unknown>;
60
- remove(participantId: string): Promise<unknown>;
61
- update(payload: object): Promise<unknown>;
62
- save(payload: object): Promise<unknown>;
63
- sendEmail(participantId: string): Promise<unknown>;
64
- create(snapshot: object, options?: { env?: object }): unknown;
65
- };
66
- export const OpeningHourModel: { create(snapshot: object, options?: { env?: object }): unknown };
67
- export const TimeSlotModel: { create(snapshot: object, options?: { env?: object }): unknown };
68
- export const TimeFrameModel: { create(snapshot: object, options?: { env?: object }): unknown };
69
- export const SettingModel: {
70
- get(calendarId: string): Promise<unknown>;
71
- save(payload: object): Promise<unknown>;
72
- uploadLogo(calendarId: string, file: File | Blob): Promise<unknown>;
73
- create(snapshot: object, options?: { env?: object }): unknown;
74
- };
75
- export const CompanyModel: {
76
- get(companyKey: string): Promise<unknown>;
77
- getAll(): Promise<unknown[] | null>;
78
- save(payload: object): Promise<unknown>;
79
- create(snapshot: object, options?: { env?: object }): unknown;
80
- };
81
- export const CalendarDayModel: { create(snapshot: object, options?: { env?: object }): unknown };
82
- export const ParticipantInfoModel: { create(snapshot: object, options?: { env?: object }): unknown };
83
- export const PreferenceModel: {
84
- getScopes(): Promise<string[] | null>;
85
- getOptions(): Promise<string[] | null>;
86
- getOptionTemplate(option: string): Promise<unknown>;
87
- get(option: string, keys: string | string[]): Promise<unknown>;
88
- set(scope: string, key: string, option: string, body: string | object): Promise<unknown>;
89
- delete(preferenceId: string): Promise<unknown>;
90
- create(snapshot: object, options?: { env?: object }): unknown;
91
- };
92
- export const PreferenceScope: Record<string, number>;
93
-
94
- export const RootStore: unknown;
95
- export function createRootStore(initialState?: object): unknown;
96
-
97
- export const Unit: Record<string, number>;
98
- export const AssignmentMethod: Record<string, number>;
99
- export const AttendeeStatus: Record<string, number>;
100
- export const RecurringFrequency: Record<string, number>;
101
- export const DayOfWeek: Record<string, number>;
1
+ /** @blazeo.com/calendar-client - type declarations */
2
+
3
+ export function configure(env: { baseUrl?: string; fetch?: typeof fetch; getDefaultOffset?: () => number }): void;
4
+ export function getConfig(): { baseUrl?: string; fetch?: typeof fetch; getDefaultOffset?: () => number } | null;
5
+ export function setBaseUrl(baseUrl: string): void;
6
+ export function getConfigStore(): unknown;
7
+
8
+ export const ConfigModel: unknown;
9
+
10
+ export const CalendarModel: {
11
+ get(calendarId: string): Promise<unknown>;
12
+ getRaw(calendarId: string): Promise<{ status: string; data?: unknown; message?: string }>;
13
+ getByCompany(companyKey: string): Promise<unknown[]>;
14
+ getTimeZones(): Promise<unknown>;
15
+ getTimeZone(timezoneId: string): Promise<unknown>;
16
+ getParticipants(calendarId: string): Promise<unknown>;
17
+ getCalendarParticipant(calendarId: string): Promise<unknown>;
18
+ getParticipantsInfo(calendarId: string): Promise<unknown>;
19
+ getMonth(calendarId: string, year: number, month: number): Promise<unknown>;
20
+ getEvents(calendarId: string): Promise<unknown>;
21
+ createWithParticipants(name: string, companyKey: string, participantIds: string[], description: string, calendarId?: string): Promise<unknown>;
22
+ editWithParticipants(calendarId: string, name: string, participantIds: string[], description: string): Promise<unknown>;
23
+ create(snapshot: object, options?: { env?: object }): unknown;
24
+ };
25
+
26
+ export const EventModel: {
27
+ get(eventId: string): Promise<unknown>;
28
+ getByExternalId(externalEventId: string): Promise<unknown>;
29
+ getRoundRobinParticipant(calendarId: string): Promise<unknown>;
30
+ getEarliestAvailableDays(calendarId: string, count: number, opts?: { year?: number; month?: number; day?: number; offset?: number }): Promise<string[] | null>;
31
+ getDaySelectable(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<boolean>;
32
+ getByVisitorEmail(email: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
33
+ getByVisitorPhone(phone: string, opts: { companyKey?: string; calendarId?: string; offset?: number }): Promise<unknown[] | null>;
34
+ getAvailability(calendarId: string, year: number, month: number, day: number, opts?: { participantId?: string; offset?: number }): Promise<unknown[]>;
35
+ cancel(eventId: string): Promise<unknown>;
36
+ getCancellable(eventId: string): Promise<boolean>;
37
+ createEvent(payload: object, offsetMinutes?: number): Promise<unknown>;
38
+ reschedule(payload: object, offsetMinutes?: number): Promise<unknown>;
39
+ updateEvent(payload: object): Promise<unknown>;
40
+ createTest(payload: object, offsetMinutes?: number): Promise<unknown>;
41
+ getCustomData(calendarId: string, eventId?: string): Promise<unknown>;
42
+ setReminder(eventId: string): Promise<unknown>;
43
+ setAttendeeStatus(eventId: string, attendeeStatus: number | string): Promise<unknown>;
44
+ create(snapshot: object, options?: { env?: object }): unknown;
45
+ };
46
+
47
+ export const AvailabilityModel: { create(snapshot: object, options?: { env?: object }): unknown };
48
+ export const AvailabilityDetailModel: { create(snapshot: object, options?: { env?: object }): unknown };
49
+ export const CalendarParticipantModel: {
50
+ getByCalendar(calendarId: string): Promise<unknown[] | null>;
51
+ getInfoByCalendar(calendarId: string): Promise<unknown[] | null>;
52
+ getByParticipant(participantId: string): Promise<unknown[] | null>;
53
+ create(snapshot: object, options?: { env?: object }): unknown;
54
+ };
55
+ export const ParticipantModel: {
56
+ get(participantId: string): Promise<unknown>;
57
+ getByIds(participantIds: string[] | string): Promise<unknown[] | null>;
58
+ getAll(companyKey: string): Promise<unknown[] | null>;
59
+ add(payload: object, calendarId?: string): Promise<unknown>;
60
+ remove(participantId: string): Promise<unknown>;
61
+ update(payload: object): Promise<unknown>;
62
+ save(payload: object): Promise<unknown>;
63
+ sendEmail(participantId: string): Promise<unknown>;
64
+ create(snapshot: object, options?: { env?: object }): unknown;
65
+ };
66
+ export const OpeningHourModel: { create(snapshot: object, options?: { env?: object }): unknown };
67
+ export const TimeSlotModel: { create(snapshot: object, options?: { env?: object }): unknown };
68
+ export const TimeFrameModel: { create(snapshot: object, options?: { env?: object }): unknown };
69
+ export const SettingModel: {
70
+ get(calendarId: string): Promise<unknown>;
71
+ save(payload: object): Promise<unknown>;
72
+ uploadLogo(calendarId: string, file: File | Blob): Promise<unknown>;
73
+ create(snapshot: object, options?: { env?: object }): unknown;
74
+ };
75
+ export const CompanyModel: {
76
+ get(companyKey: string): Promise<unknown>;
77
+ getAll(): Promise<unknown[] | null>;
78
+ save(payload: object): Promise<unknown>;
79
+ create(snapshot: object, options?: { env?: object }): unknown;
80
+ };
81
+ export const CalendarDayModel: { create(snapshot: object, options?: { env?: object }): unknown };
82
+ export const ParticipantInfoModel: { create(snapshot: object, options?: { env?: object }): unknown };
83
+ export const PreferenceModel: {
84
+ getScopes(): Promise<string[] | null>;
85
+ getOptions(): Promise<string[] | null>;
86
+ getOptionTemplate(option: string): Promise<unknown>;
87
+ get(option: string, keys: string | string[]): Promise<unknown>;
88
+ set(scope: string, key: string, option: string, body: string | object): Promise<unknown>;
89
+ delete(preferenceId: string): Promise<unknown>;
90
+ create(snapshot: object, options?: { env?: object }): unknown;
91
+ };
92
+ export const PreferenceScope: Record<string, number>;
93
+
94
+ export const FlowModel: {
95
+ list(companyKey: string, includeDeleted?: boolean): Promise<unknown[] | null>;
96
+ get(flowId: string): Promise<unknown>;
97
+ createFlow(payload: object): Promise<unknown>;
98
+ updateFlow(payload: object): Promise<unknown>;
99
+ delete(flowId: string): Promise<unknown>;
100
+ duplicate(flowId: string, newName?: string): Promise<unknown>;
101
+ getAppearance(flowId: string): Promise<unknown>;
102
+ saveAppearance(payload: object): Promise<unknown>;
103
+ getEmbed(flowId: string): Promise<unknown>;
104
+ saveEmbed(payload: object): Promise<unknown>;
105
+ getPublic(flowId: string): Promise<{ flow: unknown; appearance: unknown; embed: unknown } | null>;
106
+ getPreview(flowId: string): Promise<{ flow: unknown; appearance: unknown; embed: unknown } | null>;
107
+ create(snapshot: object, options?: { env?: object }): unknown;
108
+ };
109
+
110
+ export const LeadModel: {
111
+ get(leadId: string): Promise<unknown>;
112
+ getByEmail(email: string, companyKey: string): Promise<unknown>;
113
+ getByCompany(companyKey: string, opts?: { skip?: number; take?: number }): Promise<unknown[] | null>;
114
+ create(snapshot: object, options?: { env?: object }): unknown;
115
+ };
116
+
117
+ export const RootStore: unknown;
118
+ export function createRootStore(initialState?: object): unknown;
119
+
120
+ export const Unit: Record<string, number>;
121
+ export const AssignmentMethod: Record<string, number>;
122
+ export const AttendeeStatus: Record<string, number>;
123
+ export const RecurringFrequency: Record<string, number>;
124
+ export const DayOfWeek: Record<string, number>;
package/dist/index.js CHANGED
@@ -30,6 +30,8 @@ __export(index_exports, {
30
30
  ConfigModel: () => ConfigModel_default,
31
31
  DayOfWeek: () => DayOfWeek,
32
32
  EventModel: () => Event_default,
33
+ FlowModel: () => Flow_default,
34
+ LeadModel: () => Lead_default,
33
35
  OpeningHourModel: () => OpeningHour_default,
34
36
  ParticipantInfoModel: () => ParticipantInfo_default,
35
37
  ParticipantModel: () => Participant_default,
@@ -137,8 +139,8 @@ async function request(baseUrl, fetchFn, path, options = {}) {
137
139
  }
138
140
  return data;
139
141
  }
140
- function createRequestHelpers(self, getEnv7) {
141
- const env = () => getEnv7(self);
142
+ function createRequestHelpers(self, getEnv9) {
143
+ const env = () => getEnv9(self);
142
144
  const baseUrl = () => env().baseUrl;
143
145
  const fetchFn = () => env().fetch ?? (typeof fetch !== "undefined" ? fetch : () => {
144
146
  throw new Error("fetch not available");
@@ -1472,11 +1474,290 @@ PreferenceModel.delete = async (preferenceId) => {
1472
1474
  };
1473
1475
  var Preference_default = PreferenceModel;
1474
1476
 
1475
- // src/models/appointment/index.js
1477
+ // src/models/appointment/Flow.js
1476
1478
  var import_mobx_state_tree16 = require("mobx-state-tree");
1477
- var RootStore = import_mobx_state_tree16.types.model("RootStore", {
1478
- calendars: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.map(Calendar_default), {}),
1479
- events: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.map(Event_default), {})
1479
+ function mapFlowFromApi(d) {
1480
+ if (!d) return d;
1481
+ const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
1482
+ const b = (v) => v === true || v === "true" || v === 1;
1483
+ return {
1484
+ id: pick("id", "Id") ?? null,
1485
+ flowId: pick("flowId", "FlowId", "flow_id") ?? "",
1486
+ companyKey: pick("companyKey", "CompanyKey", "company_key") ?? "",
1487
+ name: pick("name", "Name") ?? "",
1488
+ description: pick("description", "Description") ?? null,
1489
+ flowJson: pick("flowJson", "FlowJson", "flow_json") ?? "",
1490
+ isActive: b(pick("isActive", "IsActive", "is_active")) ?? true,
1491
+ isDeleted: b(pick("isDeleted", "IsDeleted", "is_deleted")) ?? false,
1492
+ createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
1493
+ modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
1494
+ };
1495
+ }
1496
+ var FlowModel = import_mobx_state_tree16.types.model("Flow", {
1497
+ id: import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.number),
1498
+ flowId: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.identifier, "new"),
1499
+ companyKey: import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string),
1500
+ name: import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string),
1501
+ description: import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string),
1502
+ flowJson: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.string, ""),
1503
+ isActive: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.boolean, true),
1504
+ isDeleted: import_mobx_state_tree16.types.optional(import_mobx_state_tree16.types.boolean, false),
1505
+ createdOn: import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string),
1506
+ modifiedOn: import_mobx_state_tree16.types.maybeNull(import_mobx_state_tree16.types.string)
1507
+ }).actions((self) => {
1508
+ const { reqGet, reqPost } = createRequestHelpers(self, import_mobx_state_tree16.getEnv);
1509
+ return {
1510
+ /** GET flow/get – fetch this flow by flowId */
1511
+ async get() {
1512
+ if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
1513
+ const res = await reqGet("/flow/get", { flow_id: self.flowId });
1514
+ if (res.status === "success" && res.data) {
1515
+ (0, import_mobx_state_tree16.applySnapshot)(self, mapFlowFromApi(res.data));
1516
+ }
1517
+ return res;
1518
+ },
1519
+ /** POST flow/create – create flow */
1520
+ async create() {
1521
+ const payload = {
1522
+ companyKey: self.companyKey ?? void 0,
1523
+ name: self.name ?? void 0,
1524
+ description: self.description ?? void 0,
1525
+ flowJson: self.flowJson || void 0,
1526
+ isActive: self.isActive
1527
+ };
1528
+ const res = await reqPost("/flow/create", payload);
1529
+ if (res.status === "success" && res.data) {
1530
+ (0, import_mobx_state_tree16.applySnapshot)(self, mapFlowFromApi(res.data));
1531
+ }
1532
+ return res;
1533
+ },
1534
+ /** POST flow/update – update flow */
1535
+ async update() {
1536
+ const payload = {
1537
+ flowId: self.flowId,
1538
+ name: self.name ?? void 0,
1539
+ description: self.description ?? void 0,
1540
+ flowJson: self.flowJson || void 0,
1541
+ isActive: self.isActive
1542
+ };
1543
+ const res = await reqPost("/flow/update", payload);
1544
+ if (res.status === "success" && res.data) {
1545
+ (0, import_mobx_state_tree16.applySnapshot)(self, mapFlowFromApi(res.data));
1546
+ }
1547
+ return res;
1548
+ },
1549
+ /** POST flow/delete – soft delete flow */
1550
+ async delete() {
1551
+ if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
1552
+ return reqPost("/flow/delete", { flow_id: self.flowId });
1553
+ },
1554
+ /** POST flow/duplicate – duplicate flow */
1555
+ async duplicate(newName) {
1556
+ if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
1557
+ const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
1558
+ return res;
1559
+ }
1560
+ };
1561
+ });
1562
+ FlowModel.list = async (companyKey, includeDeleted = false) => {
1563
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1564
+ const query = { company_key: companyKey };
1565
+ if (includeDeleted) query.include_deleted = "true";
1566
+ const res = await reqGet("/flow/list", query);
1567
+ if (res.status === "success" && Array.isArray(res.data)) {
1568
+ return res.data.map((f) => FlowModel.create(mapFlowFromApi(f), { env: getConfig() }));
1569
+ }
1570
+ return null;
1571
+ };
1572
+ FlowModel.get = async (flowId) => {
1573
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1574
+ const res = await reqGet("/flow/get", { flow_id: flowId });
1575
+ if (res.status === "success" && res.data) {
1576
+ return FlowModel.create(mapFlowFromApi(res.data), { env: getConfig() });
1577
+ }
1578
+ return null;
1579
+ };
1580
+ FlowModel.createFlow = async (payload) => {
1581
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1582
+ const res = await reqPost("/flow/create", payload);
1583
+ if (res.status === "success" && res.data) {
1584
+ return FlowModel.create(mapFlowFromApi(res.data), { env: getConfig() });
1585
+ }
1586
+ return null;
1587
+ };
1588
+ FlowModel.updateFlow = async (payload) => {
1589
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1590
+ const res = await reqPost("/flow/update", payload);
1591
+ if (res.status === "success" && res.data) {
1592
+ return FlowModel.create(mapFlowFromApi(res.data), { env: getConfig() });
1593
+ }
1594
+ return null;
1595
+ };
1596
+ FlowModel.delete = async (flowId) => {
1597
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1598
+ return reqPost("/flow/delete", { flow_id: flowId });
1599
+ };
1600
+ FlowModel.duplicate = async (flowId, newName) => {
1601
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1602
+ const res = await reqPost("/flow/duplicate", { flow_id: flowId, new_name: newName ?? void 0 });
1603
+ if (res.status === "success" && res.data) {
1604
+ return FlowModel.create(mapFlowFromApi(res.data), { env: getConfig() });
1605
+ }
1606
+ return null;
1607
+ };
1608
+ FlowModel.getAppearance = async (flowId) => {
1609
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1610
+ const res = await reqGet("/flow/appearance/get", { flow_id: flowId });
1611
+ if (res.status === "success" && res.data != null) {
1612
+ const d = res.data;
1613
+ return {
1614
+ id: d.id ?? d.Id ?? null,
1615
+ flowId: d.flowId ?? d.FlowId ?? d.flow_id ?? flowId,
1616
+ appearanceJson: d.appearanceJson ?? d.AppearanceJson ?? d.appearance_json ?? "",
1617
+ createdOn: d.createdOn ?? d.CreatedOn ?? d.created_on ?? null,
1618
+ modifiedOn: d.modifiedOn ?? d.ModifiedOn ?? d.modified_on ?? null
1619
+ };
1620
+ }
1621
+ return null;
1622
+ };
1623
+ FlowModel.saveAppearance = async (payload) => {
1624
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1625
+ const res = await reqPost("/flow/appearance/save", payload);
1626
+ if (res.status === "success" && res.data) {
1627
+ const d = res.data;
1628
+ return {
1629
+ id: d.id ?? d.Id ?? null,
1630
+ flowId: d.flowId ?? d.FlowId ?? d.flow_id ?? payload.flowId ?? payload.flow_id,
1631
+ appearanceJson: d.appearanceJson ?? d.AppearanceJson ?? d.appearance_json ?? "",
1632
+ createdOn: d.createdOn ?? d.CreatedOn ?? d.created_on ?? null,
1633
+ modifiedOn: d.modifiedOn ?? d.ModifiedOn ?? d.modified_on ?? null
1634
+ };
1635
+ }
1636
+ return null;
1637
+ };
1638
+ FlowModel.getEmbed = async (flowId) => {
1639
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1640
+ const res = await reqGet("/flow/embed/get", { flow_id: flowId });
1641
+ if (res.status === "success" && res.data != null) {
1642
+ const d = res.data;
1643
+ return {
1644
+ id: d.id ?? d.Id ?? null,
1645
+ flowId: d.flowId ?? d.FlowId ?? d.flow_id ?? flowId,
1646
+ embedJson: d.embedJson ?? d.EmbedJson ?? d.embed_json ?? "",
1647
+ createdOn: d.createdOn ?? d.CreatedOn ?? d.created_on ?? null,
1648
+ modifiedOn: d.modifiedOn ?? d.ModifiedOn ?? d.modified_on ?? null
1649
+ };
1650
+ }
1651
+ return null;
1652
+ };
1653
+ FlowModel.saveEmbed = async (payload) => {
1654
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1655
+ const res = await reqPost("/flow/embed/save", payload);
1656
+ if (res.status === "success" && res.data) {
1657
+ const d = res.data;
1658
+ return {
1659
+ id: d.id ?? d.Id ?? null,
1660
+ flowId: d.flowId ?? d.FlowId ?? d.flow_id ?? payload.flowId ?? payload.flow_id,
1661
+ embedJson: d.embedJson ?? d.EmbedJson ?? d.embed_json ?? "",
1662
+ createdOn: d.createdOn ?? d.CreatedOn ?? d.created_on ?? null,
1663
+ modifiedOn: d.modifiedOn ?? d.ModifiedOn ?? d.modified_on ?? null
1664
+ };
1665
+ }
1666
+ return null;
1667
+ };
1668
+ FlowModel.getPublic = async (flowId) => {
1669
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1670
+ const res = await reqGet("/flow/public/get", { flow_id: flowId });
1671
+ if (res.status === "success" && res.data) {
1672
+ const d = res.data;
1673
+ return {
1674
+ flow: d.flow ? mapFlowFromApi(d.flow) : null,
1675
+ appearance: d.appearance ?? null,
1676
+ embed: d.embed ?? null
1677
+ };
1678
+ }
1679
+ return null;
1680
+ };
1681
+ FlowModel.getPreview = async (flowId) => {
1682
+ return FlowModel.getPublic(flowId);
1683
+ };
1684
+ var Flow_default = FlowModel;
1685
+
1686
+ // src/models/appointment/Lead.js
1687
+ var import_mobx_state_tree17 = require("mobx-state-tree");
1688
+ function mapLeadFromApi(d) {
1689
+ if (!d) return d;
1690
+ const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
1691
+ return {
1692
+ id: pick("id", "Id") ?? null,
1693
+ leadId: pick("leadId", "LeadId", "lead_id") ?? "",
1694
+ email: pick("email", "Email") ?? "",
1695
+ name: pick("name", "Name") ?? "",
1696
+ phone: pick("phone", "Phone") ?? "",
1697
+ companyKey: pick("companyKey", "CompanyKey", "company_key") ?? "",
1698
+ source: pick("source", "Source") ?? "",
1699
+ createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
1700
+ modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
1701
+ };
1702
+ }
1703
+ var LeadModel = import_mobx_state_tree17.types.model("Lead", {
1704
+ id: import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.number),
1705
+ leadId: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.identifier, "new"),
1706
+ email: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
1707
+ name: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
1708
+ phone: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
1709
+ companyKey: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
1710
+ source: import_mobx_state_tree17.types.optional(import_mobx_state_tree17.types.string, ""),
1711
+ createdOn: import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string),
1712
+ modifiedOn: import_mobx_state_tree17.types.maybeNull(import_mobx_state_tree17.types.string)
1713
+ }).actions((self) => {
1714
+ const { reqGet } = createRequestHelpers(self, import_mobx_state_tree17.getEnv);
1715
+ return {
1716
+ /** GET /lead/get – fetch this lead by leadId */
1717
+ async get() {
1718
+ if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
1719
+ const res = await reqGet("/lead/get", { lead_id: self.leadId });
1720
+ if (res.status === "success" && res.data) {
1721
+ (0, import_mobx_state_tree17.applySnapshot)(self, mapLeadFromApi(res.data));
1722
+ }
1723
+ return res;
1724
+ }
1725
+ };
1726
+ });
1727
+ LeadModel.get = async (leadId) => {
1728
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1729
+ const res = await reqGet("/lead/get", { lead_id: leadId });
1730
+ if (res.status === "success" && res.data) {
1731
+ return LeadModel.create(mapLeadFromApi(res.data), { env: getConfig() });
1732
+ }
1733
+ return null;
1734
+ };
1735
+ LeadModel.getByEmail = async (email, companyKey) => {
1736
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1737
+ const res = await reqGet("/lead/getbyemail", { email, company_key: companyKey });
1738
+ if (res.status === "success" && res.data) {
1739
+ return LeadModel.create(mapLeadFromApi(res.data), { env: getConfig() });
1740
+ }
1741
+ return null;
1742
+ };
1743
+ LeadModel.getByCompany = async (companyKey, opts = {}) => {
1744
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1745
+ const query = { company_key: companyKey };
1746
+ if (opts.skip != null) query.skip = opts.skip;
1747
+ if (opts.take != null) query.take = opts.take;
1748
+ const res = await reqGet("/lead/company/get", query);
1749
+ if (res.status === "success" && Array.isArray(res.data)) {
1750
+ return res.data.map((l) => LeadModel.create(mapLeadFromApi(l), { env: getConfig() }));
1751
+ }
1752
+ return null;
1753
+ };
1754
+ var Lead_default = LeadModel;
1755
+
1756
+ // src/models/appointment/index.js
1757
+ var import_mobx_state_tree18 = require("mobx-state-tree");
1758
+ var RootStore = import_mobx_state_tree18.types.model("RootStore", {
1759
+ calendars: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.map(Calendar_default), {}),
1760
+ events: import_mobx_state_tree18.types.optional(import_mobx_state_tree18.types.map(Event_default), {})
1480
1761
  }).actions((self) => ({
1481
1762
  addCalendar(snapshot) {
1482
1763
  const cal = Calendar_default.create(snapshot);
@@ -1507,6 +1788,8 @@ function createRootStore(initialState = {}) {
1507
1788
  ConfigModel,
1508
1789
  DayOfWeek,
1509
1790
  EventModel,
1791
+ FlowModel,
1792
+ LeadModel,
1510
1793
  OpeningHourModel,
1511
1794
  ParticipantInfoModel,
1512
1795
  ParticipantModel,
package/dist/index.mjs CHANGED
@@ -86,8 +86,8 @@ async function request(baseUrl, fetchFn, path, options = {}) {
86
86
  }
87
87
  return data;
88
88
  }
89
- function createRequestHelpers(self, getEnv7) {
90
- const env = () => getEnv7(self);
89
+ function createRequestHelpers(self, getEnv9) {
90
+ const env = () => getEnv9(self);
91
91
  const baseUrl = () => env().baseUrl;
92
92
  const fetchFn = () => env().fetch ?? (typeof fetch !== "undefined" ? fetch : () => {
93
93
  throw new Error("fetch not available");
@@ -1421,11 +1421,290 @@ PreferenceModel.delete = async (preferenceId) => {
1421
1421
  };
1422
1422
  var Preference_default = PreferenceModel;
1423
1423
 
1424
+ // src/models/appointment/Flow.js
1425
+ import { types as types16, getEnv as getEnv6, applySnapshot as applySnapshot6 } from "mobx-state-tree";
1426
+ function mapFlowFromApi(d) {
1427
+ if (!d) return d;
1428
+ const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
1429
+ const b = (v) => v === true || v === "true" || v === 1;
1430
+ return {
1431
+ id: pick("id", "Id") ?? null,
1432
+ flowId: pick("flowId", "FlowId", "flow_id") ?? "",
1433
+ companyKey: pick("companyKey", "CompanyKey", "company_key") ?? "",
1434
+ name: pick("name", "Name") ?? "",
1435
+ description: pick("description", "Description") ?? null,
1436
+ flowJson: pick("flowJson", "FlowJson", "flow_json") ?? "",
1437
+ isActive: b(pick("isActive", "IsActive", "is_active")) ?? true,
1438
+ isDeleted: b(pick("isDeleted", "IsDeleted", "is_deleted")) ?? false,
1439
+ createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
1440
+ modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
1441
+ };
1442
+ }
1443
+ var FlowModel = types16.model("Flow", {
1444
+ id: types16.maybeNull(types16.number),
1445
+ flowId: types16.optional(types16.identifier, "new"),
1446
+ companyKey: types16.maybeNull(types16.string),
1447
+ name: types16.maybeNull(types16.string),
1448
+ description: types16.maybeNull(types16.string),
1449
+ flowJson: types16.optional(types16.string, ""),
1450
+ isActive: types16.optional(types16.boolean, true),
1451
+ isDeleted: types16.optional(types16.boolean, false),
1452
+ createdOn: types16.maybeNull(types16.string),
1453
+ modifiedOn: types16.maybeNull(types16.string)
1454
+ }).actions((self) => {
1455
+ const { reqGet, reqPost } = createRequestHelpers(self, getEnv6);
1456
+ return {
1457
+ /** GET flow/get – fetch this flow by flowId */
1458
+ async get() {
1459
+ if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
1460
+ const res = await reqGet("/flow/get", { flow_id: self.flowId });
1461
+ if (res.status === "success" && res.data) {
1462
+ applySnapshot6(self, mapFlowFromApi(res.data));
1463
+ }
1464
+ return res;
1465
+ },
1466
+ /** POST flow/create – create flow */
1467
+ async create() {
1468
+ const payload = {
1469
+ companyKey: self.companyKey ?? void 0,
1470
+ name: self.name ?? void 0,
1471
+ description: self.description ?? void 0,
1472
+ flowJson: self.flowJson || void 0,
1473
+ isActive: self.isActive
1474
+ };
1475
+ const res = await reqPost("/flow/create", payload);
1476
+ if (res.status === "success" && res.data) {
1477
+ applySnapshot6(self, mapFlowFromApi(res.data));
1478
+ }
1479
+ return res;
1480
+ },
1481
+ /** POST flow/update – update flow */
1482
+ async update() {
1483
+ const payload = {
1484
+ flowId: self.flowId,
1485
+ name: self.name ?? void 0,
1486
+ description: self.description ?? void 0,
1487
+ flowJson: self.flowJson || void 0,
1488
+ isActive: self.isActive
1489
+ };
1490
+ const res = await reqPost("/flow/update", payload);
1491
+ if (res.status === "success" && res.data) {
1492
+ applySnapshot6(self, mapFlowFromApi(res.data));
1493
+ }
1494
+ return res;
1495
+ },
1496
+ /** POST flow/delete – soft delete flow */
1497
+ async delete() {
1498
+ if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
1499
+ return reqPost("/flow/delete", { flow_id: self.flowId });
1500
+ },
1501
+ /** POST flow/duplicate – duplicate flow */
1502
+ async duplicate(newName) {
1503
+ if (!self.flowId || self.flowId === "new") return { status: "failure", message: "flowId required" };
1504
+ const res = await reqPost("/flow/duplicate", { flow_id: self.flowId, new_name: newName ?? void 0 });
1505
+ return res;
1506
+ }
1507
+ };
1508
+ });
1509
+ FlowModel.list = async (companyKey, includeDeleted = false) => {
1510
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1511
+ const query = { company_key: companyKey };
1512
+ if (includeDeleted) query.include_deleted = "true";
1513
+ const res = await reqGet("/flow/list", query);
1514
+ if (res.status === "success" && Array.isArray(res.data)) {
1515
+ return res.data.map((f) => FlowModel.create(mapFlowFromApi(f), { env: getConfig() }));
1516
+ }
1517
+ return null;
1518
+ };
1519
+ FlowModel.get = async (flowId) => {
1520
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1521
+ const res = await reqGet("/flow/get", { flow_id: flowId });
1522
+ if (res.status === "success" && res.data) {
1523
+ return FlowModel.create(mapFlowFromApi(res.data), { env: getConfig() });
1524
+ }
1525
+ return null;
1526
+ };
1527
+ FlowModel.createFlow = async (payload) => {
1528
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1529
+ const res = await reqPost("/flow/create", payload);
1530
+ if (res.status === "success" && res.data) {
1531
+ return FlowModel.create(mapFlowFromApi(res.data), { env: getConfig() });
1532
+ }
1533
+ return null;
1534
+ };
1535
+ FlowModel.updateFlow = async (payload) => {
1536
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1537
+ const res = await reqPost("/flow/update", payload);
1538
+ if (res.status === "success" && res.data) {
1539
+ return FlowModel.create(mapFlowFromApi(res.data), { env: getConfig() });
1540
+ }
1541
+ return null;
1542
+ };
1543
+ FlowModel.delete = async (flowId) => {
1544
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1545
+ return reqPost("/flow/delete", { flow_id: flowId });
1546
+ };
1547
+ FlowModel.duplicate = async (flowId, newName) => {
1548
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1549
+ const res = await reqPost("/flow/duplicate", { flow_id: flowId, new_name: newName ?? void 0 });
1550
+ if (res.status === "success" && res.data) {
1551
+ return FlowModel.create(mapFlowFromApi(res.data), { env: getConfig() });
1552
+ }
1553
+ return null;
1554
+ };
1555
+ FlowModel.getAppearance = async (flowId) => {
1556
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1557
+ const res = await reqGet("/flow/appearance/get", { flow_id: flowId });
1558
+ if (res.status === "success" && res.data != null) {
1559
+ const d = res.data;
1560
+ return {
1561
+ id: d.id ?? d.Id ?? null,
1562
+ flowId: d.flowId ?? d.FlowId ?? d.flow_id ?? flowId,
1563
+ appearanceJson: d.appearanceJson ?? d.AppearanceJson ?? d.appearance_json ?? "",
1564
+ createdOn: d.createdOn ?? d.CreatedOn ?? d.created_on ?? null,
1565
+ modifiedOn: d.modifiedOn ?? d.ModifiedOn ?? d.modified_on ?? null
1566
+ };
1567
+ }
1568
+ return null;
1569
+ };
1570
+ FlowModel.saveAppearance = async (payload) => {
1571
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1572
+ const res = await reqPost("/flow/appearance/save", payload);
1573
+ if (res.status === "success" && res.data) {
1574
+ const d = res.data;
1575
+ return {
1576
+ id: d.id ?? d.Id ?? null,
1577
+ flowId: d.flowId ?? d.FlowId ?? d.flow_id ?? payload.flowId ?? payload.flow_id,
1578
+ appearanceJson: d.appearanceJson ?? d.AppearanceJson ?? d.appearance_json ?? "",
1579
+ createdOn: d.createdOn ?? d.CreatedOn ?? d.created_on ?? null,
1580
+ modifiedOn: d.modifiedOn ?? d.ModifiedOn ?? d.modified_on ?? null
1581
+ };
1582
+ }
1583
+ return null;
1584
+ };
1585
+ FlowModel.getEmbed = async (flowId) => {
1586
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1587
+ const res = await reqGet("/flow/embed/get", { flow_id: flowId });
1588
+ if (res.status === "success" && res.data != null) {
1589
+ const d = res.data;
1590
+ return {
1591
+ id: d.id ?? d.Id ?? null,
1592
+ flowId: d.flowId ?? d.FlowId ?? d.flow_id ?? flowId,
1593
+ embedJson: d.embedJson ?? d.EmbedJson ?? d.embed_json ?? "",
1594
+ createdOn: d.createdOn ?? d.CreatedOn ?? d.created_on ?? null,
1595
+ modifiedOn: d.modifiedOn ?? d.ModifiedOn ?? d.modified_on ?? null
1596
+ };
1597
+ }
1598
+ return null;
1599
+ };
1600
+ FlowModel.saveEmbed = async (payload) => {
1601
+ const { reqPost } = createRequestHelpersFromEnv(getConfig());
1602
+ const res = await reqPost("/flow/embed/save", payload);
1603
+ if (res.status === "success" && res.data) {
1604
+ const d = res.data;
1605
+ return {
1606
+ id: d.id ?? d.Id ?? null,
1607
+ flowId: d.flowId ?? d.FlowId ?? d.flow_id ?? payload.flowId ?? payload.flow_id,
1608
+ embedJson: d.embedJson ?? d.EmbedJson ?? d.embed_json ?? "",
1609
+ createdOn: d.createdOn ?? d.CreatedOn ?? d.created_on ?? null,
1610
+ modifiedOn: d.modifiedOn ?? d.ModifiedOn ?? d.modified_on ?? null
1611
+ };
1612
+ }
1613
+ return null;
1614
+ };
1615
+ FlowModel.getPublic = async (flowId) => {
1616
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1617
+ const res = await reqGet("/flow/public/get", { flow_id: flowId });
1618
+ if (res.status === "success" && res.data) {
1619
+ const d = res.data;
1620
+ return {
1621
+ flow: d.flow ? mapFlowFromApi(d.flow) : null,
1622
+ appearance: d.appearance ?? null,
1623
+ embed: d.embed ?? null
1624
+ };
1625
+ }
1626
+ return null;
1627
+ };
1628
+ FlowModel.getPreview = async (flowId) => {
1629
+ return FlowModel.getPublic(flowId);
1630
+ };
1631
+ var Flow_default = FlowModel;
1632
+
1633
+ // src/models/appointment/Lead.js
1634
+ import { types as types17, getEnv as getEnv7, applySnapshot as applySnapshot7 } from "mobx-state-tree";
1635
+ function mapLeadFromApi(d) {
1636
+ if (!d) return d;
1637
+ const pick = (...keys) => keys.reduce((v, k) => v ?? d[k], void 0);
1638
+ return {
1639
+ id: pick("id", "Id") ?? null,
1640
+ leadId: pick("leadId", "LeadId", "lead_id") ?? "",
1641
+ email: pick("email", "Email") ?? "",
1642
+ name: pick("name", "Name") ?? "",
1643
+ phone: pick("phone", "Phone") ?? "",
1644
+ companyKey: pick("companyKey", "CompanyKey", "company_key") ?? "",
1645
+ source: pick("source", "Source") ?? "",
1646
+ createdOn: pick("createdOn", "CreatedOn", "created_on") ?? null,
1647
+ modifiedOn: pick("modifiedOn", "ModifiedOn", "modified_on") ?? null
1648
+ };
1649
+ }
1650
+ var LeadModel = types17.model("Lead", {
1651
+ id: types17.maybeNull(types17.number),
1652
+ leadId: types17.optional(types17.identifier, "new"),
1653
+ email: types17.optional(types17.string, ""),
1654
+ name: types17.optional(types17.string, ""),
1655
+ phone: types17.optional(types17.string, ""),
1656
+ companyKey: types17.optional(types17.string, ""),
1657
+ source: types17.optional(types17.string, ""),
1658
+ createdOn: types17.maybeNull(types17.string),
1659
+ modifiedOn: types17.maybeNull(types17.string)
1660
+ }).actions((self) => {
1661
+ const { reqGet } = createRequestHelpers(self, getEnv7);
1662
+ return {
1663
+ /** GET /lead/get – fetch this lead by leadId */
1664
+ async get() {
1665
+ if (!self.leadId || self.leadId === "new") return { status: "failure", message: "leadId required" };
1666
+ const res = await reqGet("/lead/get", { lead_id: self.leadId });
1667
+ if (res.status === "success" && res.data) {
1668
+ applySnapshot7(self, mapLeadFromApi(res.data));
1669
+ }
1670
+ return res;
1671
+ }
1672
+ };
1673
+ });
1674
+ LeadModel.get = async (leadId) => {
1675
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1676
+ const res = await reqGet("/lead/get", { lead_id: leadId });
1677
+ if (res.status === "success" && res.data) {
1678
+ return LeadModel.create(mapLeadFromApi(res.data), { env: getConfig() });
1679
+ }
1680
+ return null;
1681
+ };
1682
+ LeadModel.getByEmail = async (email, companyKey) => {
1683
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1684
+ const res = await reqGet("/lead/getbyemail", { email, company_key: companyKey });
1685
+ if (res.status === "success" && res.data) {
1686
+ return LeadModel.create(mapLeadFromApi(res.data), { env: getConfig() });
1687
+ }
1688
+ return null;
1689
+ };
1690
+ LeadModel.getByCompany = async (companyKey, opts = {}) => {
1691
+ const { reqGet } = createRequestHelpersFromEnv(getConfig());
1692
+ const query = { company_key: companyKey };
1693
+ if (opts.skip != null) query.skip = opts.skip;
1694
+ if (opts.take != null) query.take = opts.take;
1695
+ const res = await reqGet("/lead/company/get", query);
1696
+ if (res.status === "success" && Array.isArray(res.data)) {
1697
+ return res.data.map((l) => LeadModel.create(mapLeadFromApi(l), { env: getConfig() }));
1698
+ }
1699
+ return null;
1700
+ };
1701
+ var Lead_default = LeadModel;
1702
+
1424
1703
  // src/models/appointment/index.js
1425
- import { types as types16, getEnv as getEnv6 } from "mobx-state-tree";
1426
- var RootStore = types16.model("RootStore", {
1427
- calendars: types16.optional(types16.map(Calendar_default), {}),
1428
- events: types16.optional(types16.map(Event_default), {})
1704
+ import { types as types18, getEnv as getEnv8 } from "mobx-state-tree";
1705
+ var RootStore = types18.model("RootStore", {
1706
+ calendars: types18.optional(types18.map(Calendar_default), {}),
1707
+ events: types18.optional(types18.map(Event_default), {})
1429
1708
  }).actions((self) => ({
1430
1709
  addCalendar(snapshot) {
1431
1710
  const cal = Calendar_default.create(snapshot);
@@ -1455,6 +1734,8 @@ export {
1455
1734
  ConfigModel_default as ConfigModel,
1456
1735
  DayOfWeek,
1457
1736
  Event_default as EventModel,
1737
+ Flow_default as FlowModel,
1738
+ Lead_default as LeadModel,
1458
1739
  OpeningHour_default as OpeningHourModel,
1459
1740
  ParticipantInfo_default as ParticipantInfoModel,
1460
1741
  Participant_default as ParticipantModel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blazeo.com/calendar-client",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
5
5
  "exports": {
6
6
  ".": {