@blazeo.com/calendar-client 1.0.8 → 1.0.9
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 +42 -0
- package/dist/index.mjs +42 -0
- package/package.json +42 -42
package/dist/index.js
CHANGED
|
@@ -497,6 +497,48 @@ EventModel.getByVisitorPhone = async (phone, opts = {}) => {
|
|
|
497
497
|
}
|
|
498
498
|
return null;
|
|
499
499
|
};
|
|
500
|
+
EventModel.getByDateRangeWithFilters = async (startDateFrom, startDateTo, opts = {}) => {
|
|
501
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
502
|
+
const query = {
|
|
503
|
+
start_date_from: startDateFrom,
|
|
504
|
+
start_date_to: startDateTo
|
|
505
|
+
};
|
|
506
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
507
|
+
if (opts.companyKey != null && opts.companyKey !== "") query.company_key = opts.companyKey;
|
|
508
|
+
if (opts.calendarId != null && opts.calendarId !== "") query.calendar_id = opts.calendarId;
|
|
509
|
+
if (opts.participantId != null && opts.participantId !== "") query.participant_id = opts.participantId;
|
|
510
|
+
if (opts.visitorName != null && opts.visitorName !== "") query.visitor_name = opts.visitorName;
|
|
511
|
+
if (opts.visitorEmail != null && opts.visitorEmail !== "") query.visitor_email = opts.visitorEmail;
|
|
512
|
+
if (opts.visitorPhone != null && opts.visitorPhone !== "") query.visitor_phone = opts.visitorPhone;
|
|
513
|
+
if (opts.title != null && opts.title !== "") query.title = opts.title;
|
|
514
|
+
if (opts.search != null && opts.search !== "") query.search = opts.search;
|
|
515
|
+
if (opts.attendeeStatus != null && opts.attendeeStatus !== "") query.attendee_status = opts.attendeeStatus;
|
|
516
|
+
if (opts.eventSource != null && opts.eventSource !== "") query.event_source = opts.eventSource;
|
|
517
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
518
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
519
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
520
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
521
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
522
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
523
|
+
}
|
|
524
|
+
if (opts.page != null) {
|
|
525
|
+
query.page = opts.page;
|
|
526
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
527
|
+
} else {
|
|
528
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
529
|
+
if (opts.take != null) query.take = opts.take;
|
|
530
|
+
}
|
|
531
|
+
const res = await reqGet("/event/search/daterange/get", query, { headers: { offset: String(offset) } });
|
|
532
|
+
if (res.status !== "success") {
|
|
533
|
+
return { events: [], totalCount: 0 };
|
|
534
|
+
}
|
|
535
|
+
const payload = res.data ?? {};
|
|
536
|
+
const eventsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.Events) ? payload.Events : Array.isArray(payload.events) ? payload.events : [];
|
|
537
|
+
const totalCountRaw = payload.TotalCount ?? payload.totalCount;
|
|
538
|
+
const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : eventsRaw.length;
|
|
539
|
+
const events = eventsRaw.map((e) => EventModel.create(mapEventFromApi(e), { env: getConfig() }));
|
|
540
|
+
return { events, totalCount };
|
|
541
|
+
};
|
|
500
542
|
EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) => {
|
|
501
543
|
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
502
544
|
const query = { calendar_id: calendarId, year, month, day };
|
package/dist/index.mjs
CHANGED
|
@@ -444,6 +444,48 @@ EventModel.getByVisitorPhone = async (phone, opts = {}) => {
|
|
|
444
444
|
}
|
|
445
445
|
return null;
|
|
446
446
|
};
|
|
447
|
+
EventModel.getByDateRangeWithFilters = async (startDateFrom, startDateTo, opts = {}) => {
|
|
448
|
+
const { reqGet } = createRequestHelpersFromEnv(getConfig());
|
|
449
|
+
const query = {
|
|
450
|
+
start_date_from: startDateFrom,
|
|
451
|
+
start_date_to: startDateTo
|
|
452
|
+
};
|
|
453
|
+
const offset = opts.offset ?? getDefaultOffset();
|
|
454
|
+
if (opts.companyKey != null && opts.companyKey !== "") query.company_key = opts.companyKey;
|
|
455
|
+
if (opts.calendarId != null && opts.calendarId !== "") query.calendar_id = opts.calendarId;
|
|
456
|
+
if (opts.participantId != null && opts.participantId !== "") query.participant_id = opts.participantId;
|
|
457
|
+
if (opts.visitorName != null && opts.visitorName !== "") query.visitor_name = opts.visitorName;
|
|
458
|
+
if (opts.visitorEmail != null && opts.visitorEmail !== "") query.visitor_email = opts.visitorEmail;
|
|
459
|
+
if (opts.visitorPhone != null && opts.visitorPhone !== "") query.visitor_phone = opts.visitorPhone;
|
|
460
|
+
if (opts.title != null && opts.title !== "") query.title = opts.title;
|
|
461
|
+
if (opts.search != null && opts.search !== "") query.search = opts.search;
|
|
462
|
+
if (opts.attendeeStatus != null && opts.attendeeStatus !== "") query.attendee_status = opts.attendeeStatus;
|
|
463
|
+
if (opts.eventSource != null && opts.eventSource !== "") query.event_source = opts.eventSource;
|
|
464
|
+
const sortBy = opts.sortBy ?? opts.sort ?? opts.sort_column;
|
|
465
|
+
if (sortBy != null && sortBy !== "") query.sort = sortBy;
|
|
466
|
+
const sortOrderRaw = opts.sortOrder ?? opts.sort_dir;
|
|
467
|
+
if (sortOrderRaw != null && String(sortOrderRaw).trim() !== "") {
|
|
468
|
+
const u = String(sortOrderRaw).trim().toUpperCase();
|
|
469
|
+
query.sort_dir = u.startsWith("DESC") ? "desc" : "asc";
|
|
470
|
+
}
|
|
471
|
+
if (opts.page != null) {
|
|
472
|
+
query.page = opts.page;
|
|
473
|
+
if (opts.page_size != null) query.page_size = opts.page_size;
|
|
474
|
+
} else {
|
|
475
|
+
if (opts.skip != null) query.skip = opts.skip;
|
|
476
|
+
if (opts.take != null) query.take = opts.take;
|
|
477
|
+
}
|
|
478
|
+
const res = await reqGet("/event/search/daterange/get", query, { headers: { offset: String(offset) } });
|
|
479
|
+
if (res.status !== "success") {
|
|
480
|
+
return { events: [], totalCount: 0 };
|
|
481
|
+
}
|
|
482
|
+
const payload = res.data ?? {};
|
|
483
|
+
const eventsRaw = Array.isArray(payload) ? payload : Array.isArray(payload.Events) ? payload.Events : Array.isArray(payload.events) ? payload.events : [];
|
|
484
|
+
const totalCountRaw = payload.TotalCount ?? payload.totalCount;
|
|
485
|
+
const totalCount = Number.isFinite(Number(totalCountRaw)) ? Number(totalCountRaw) : eventsRaw.length;
|
|
486
|
+
const events = eventsRaw.map((e) => EventModel.create(mapEventFromApi(e), { env: getConfig() }));
|
|
487
|
+
return { events, totalCount };
|
|
488
|
+
};
|
|
447
489
|
EventModel.getAvailability = async (calendarId, year, month, day, opts = {}) => {
|
|
448
490
|
const { req } = createRequestHelpersFromEnv(getConfig());
|
|
449
491
|
const query = { calendar_id: calendarId, year, month, day };
|
package/package.json
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@blazeo.com/calendar-client",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
|
|
5
|
-
"exports": {
|
|
6
|
-
".": {
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
8
|
-
"import": "./dist/index.mjs",
|
|
9
|
-
"require": "./dist/index.js"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"files": ["dist", "README.md"],
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "tsup src/models/appointment/index.js --format cjs,esm --clean && node -e \"require('fs').copyFileSync('src/index.d.ts','dist/index.d.ts')\"",
|
|
15
|
-
"prepublishOnly": "npm run build"
|
|
16
|
-
},
|
|
17
|
-
"keywords": ["blazeo", "calendar", "appointment", "booking", "mobx", "mobx-state-tree"],
|
|
18
|
-
"author": "Blazeo",
|
|
19
|
-
"license": "UNLICENSED",
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "https://github.com/blazeo-com/calendar-client.git"
|
|
23
|
-
},
|
|
24
|
-
"bugs": {
|
|
25
|
-
"url": "https://github.com/blazeo-com/calendar-client/issues"
|
|
26
|
-
},
|
|
27
|
-
"homepage": "https://github.com/blazeo-com/calendar-client#readme",
|
|
28
|
-
"publishConfig": {
|
|
29
|
-
"access": "restricted"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"mobx": "^6.10.0",
|
|
33
|
-
"mobx-state-tree": "^5.4.0"
|
|
34
|
-
},
|
|
35
|
-
"devDependencies": {
|
|
36
|
-
"tsup": "^8.0.1"
|
|
37
|
-
},
|
|
38
|
-
"peerDependencies": {},
|
|
39
|
-
"engines": {
|
|
40
|
-
"node": ">=18"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@blazeo.com/calendar-client",
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"description": "Blazeo Calendar / Appointment API client with MobX State Tree models",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"import": "./dist/index.mjs",
|
|
9
|
+
"require": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": ["dist", "README.md"],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsup src/models/appointment/index.js --format cjs,esm --clean && node -e \"require('fs').copyFileSync('src/index.d.ts','dist/index.d.ts')\"",
|
|
15
|
+
"prepublishOnly": "npm run build"
|
|
16
|
+
},
|
|
17
|
+
"keywords": ["blazeo", "calendar", "appointment", "booking", "mobx", "mobx-state-tree"],
|
|
18
|
+
"author": "Blazeo",
|
|
19
|
+
"license": "UNLICENSED",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/blazeo-com/calendar-client.git"
|
|
23
|
+
},
|
|
24
|
+
"bugs": {
|
|
25
|
+
"url": "https://github.com/blazeo-com/calendar-client/issues"
|
|
26
|
+
},
|
|
27
|
+
"homepage": "https://github.com/blazeo-com/calendar-client#readme",
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "restricted"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"mobx": "^6.10.0",
|
|
33
|
+
"mobx-state-tree": "^5.4.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"tsup": "^8.0.1"
|
|
37
|
+
},
|
|
38
|
+
"peerDependencies": {},
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=18"
|
|
41
|
+
}
|
|
42
|
+
}
|